change_nickname_page.dart 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter_screenutil/flutter_screenutil.dart';
  3. import 'package:get/get.dart';
  4. import 'package:keyboard/base/base_page.dart';
  5. import 'package:keyboard/module/change/nickname/change_nickname_controller.dart';
  6. import 'package:keyboard/utils/styles.dart';
  7. import '../../../resource/assets.gen.dart';
  8. import '../../../router/app_pages.dart';
  9. class ChangeNicknamePage extends BasePage<ChangeNicknameController> {
  10. const ChangeNicknamePage({super.key});
  11. static Future start({String? nickName}) async {
  12. return Get.toNamed(
  13. RoutePath.changeNickname,
  14. arguments: {"nickName": nickName},
  15. );
  16. }
  17. @override
  18. bool immersive() {
  19. return true;
  20. }
  21. @override
  22. Color backgroundColor() {
  23. return const Color(0xFFF6F5FA);
  24. }
  25. @override
  26. Widget buildBody(BuildContext context) {
  27. return Stack(
  28. children: [
  29. IgnorePointer(child: Assets.images.bgMine.image(width: 360.w)),
  30. SafeArea(
  31. child: Stack(
  32. children: [
  33. SingleChildScrollView(
  34. child: Column(
  35. children: [
  36. _buildTitle(),
  37. SizedBox(height: 40.h),
  38. _buildContent(),
  39. ],
  40. ),
  41. ),
  42. Align(
  43. alignment: Alignment.bottomCenter,
  44. child: Container(
  45. margin: EdgeInsets.only(bottom: 32.h),
  46. child: Obx(() {
  47. return _buildSaveButton(
  48. onTap: () {
  49. controller.clickSave();
  50. },
  51. isEnable: controller.nickname.value.isNotEmpty,
  52. );
  53. }),
  54. ),
  55. ),
  56. ],
  57. ),
  58. ),
  59. ],
  60. );
  61. }
  62. _buildTitle() {
  63. return Container(
  64. alignment: Alignment.centerLeft,
  65. padding: EdgeInsets.only(top: 12.h, left: 16.w, right: 16.w),
  66. child: Row(
  67. mainAxisAlignment: MainAxisAlignment.start,
  68. children: [
  69. GestureDetector(
  70. onTap: controller.clickBack,
  71. child: Assets.images.iconMineBackArrow.image(
  72. width: 24.w,
  73. height: 24.w,
  74. ),
  75. ),
  76. ],
  77. ),
  78. );
  79. }
  80. _buildContent() {
  81. return Column(
  82. children: [
  83. Text('修改昵称', style: Styles.getTextStyleBlack204W500(22.sp)),
  84. Container(
  85. margin: EdgeInsets.only(top: 119.h, left: 27.w, right: 27.w),
  86. alignment: Alignment.center,
  87. child: Container(
  88. height: 48.h,
  89. alignment: Alignment.center,
  90. child: TextField(
  91. controller: controller.textEditingController,
  92. // maxLength: maxLength,
  93. maxLines: 1,
  94. onChanged: (value) {
  95. controller.nickname.value = value;
  96. },
  97. cursorColor: Color(0xFF7B7DFF),
  98. textAlign: TextAlign.center,
  99. textAlignVertical: TextAlignVertical.center,
  100. decoration: InputDecoration(
  101. counterText: "",
  102. hintText: "请输入你的昵称",
  103. hintStyle: TextStyle(
  104. color: Colors.black.withAlpha(77),
  105. fontSize: 18.sp,
  106. fontWeight: FontWeight.w500,
  107. ),
  108. border: UnderlineInputBorder(
  109. borderSide: BorderSide(
  110. color: Colors.black.withAlpha(26),
  111. width: 1.w,
  112. ),
  113. ),
  114. focusedBorder: UnderlineInputBorder(
  115. borderSide: BorderSide(
  116. color: Colors.black.withAlpha(26),
  117. width: 1.w,
  118. ),
  119. ),
  120. filled: true,
  121. fillColor: Colors.transparent,
  122. ),
  123. ),
  124. ),
  125. ),
  126. ],
  127. );
  128. }
  129. Widget _buildSaveButton({required VoidCallback onTap, required isEnable}) {
  130. return GestureDetector(
  131. onTap: () {
  132. onTap();
  133. },
  134. child: Container(
  135. width: 260.w,
  136. height: 48.h,
  137. decoration:
  138. isEnable
  139. ? Styles.getActivateButtonDecoration(31.r)
  140. : Styles.getInactiveButtonDecoration(31.r),
  141. child: Center(
  142. child: Text(
  143. '保存',
  144. style: TextStyle(
  145. color: Colors.white,
  146. fontSize: 16.sp,
  147. fontWeight: FontWeight.w500,
  148. ),
  149. ),
  150. ),
  151. ),
  152. );
  153. }
  154. }