change_gender_page.dart 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. import 'package:flutter_screenutil/flutter_screenutil.dart';
  2. import 'package:keyboard/base/base_page.dart';
  3. import 'package:get/get.dart';
  4. import 'package:keyboard/module/change/gender/change_gender_controller.dart';
  5. import 'package:flutter/material.dart';
  6. import '../../../resource/assets.gen.dart';
  7. import '../../../router/app_pages.dart';
  8. import '../../../utils/styles.dart';
  9. class ChangeGenderPage extends BasePage<ChangeGenderController> {
  10. const ChangeGenderPage({super.key});
  11. static Future start({int? gender}) async {
  12. return Get.toNamed(RoutePath.changeGender, arguments: {"gender": gender});
  13. }
  14. @override
  15. bool immersive() {
  16. return true;
  17. }
  18. @override
  19. Color backgroundColor() {
  20. return const Color(0xFFF6F5FA);
  21. }
  22. @override
  23. Widget buildBody(BuildContext context) {
  24. return Stack(
  25. children: [
  26. IgnorePointer(child: Assets.images.bgMine.image(width: 360.w)),
  27. SafeArea(
  28. child: Stack(
  29. children: [
  30. SingleChildScrollView(
  31. child: Column(
  32. children: [
  33. _buildTitle(),
  34. SizedBox(height: 40.h),
  35. _buildContent(),
  36. ],
  37. ),
  38. ),
  39. Align(
  40. alignment: Alignment.bottomCenter,
  41. child: Container(
  42. margin: EdgeInsets.only(bottom: 32.h),
  43. child: Obx(() {
  44. return _buildSaveButton(
  45. onTap: () {
  46. controller.clickSave();
  47. },
  48. isEnable: controller.currentGender.value != null,
  49. );
  50. }),
  51. ),
  52. ),
  53. ],
  54. ),
  55. ),
  56. ],
  57. );
  58. }
  59. _buildTitle() {
  60. return Container(
  61. alignment: Alignment.centerLeft,
  62. padding: EdgeInsets.only(top: 12.h, left: 16.w, right: 16.w),
  63. child: Row(
  64. mainAxisAlignment: MainAxisAlignment.start,
  65. children: [
  66. GestureDetector(
  67. onTap: controller.clickBack,
  68. child: Assets.images.iconMineBackArrow.image(
  69. width: 24.w,
  70. height: 24.w,
  71. ),
  72. ),
  73. ],
  74. ),
  75. );
  76. }
  77. Widget _buildSaveButton({required VoidCallback onTap, required isEnable}) {
  78. return GestureDetector(
  79. onTap: () {
  80. onTap();
  81. },
  82. child: Container(
  83. width: 260.w,
  84. height: 48.h,
  85. decoration:
  86. isEnable
  87. ? Styles.getActivateButtonDecoration(31.r)
  88. : Styles.getInactiveButtonDecoration(31.r),
  89. child: Center(
  90. child: Text(
  91. '保存',
  92. style: TextStyle(
  93. color: Colors.white,
  94. fontSize: 16.sp,
  95. fontWeight: FontWeight.w500,
  96. ),
  97. ),
  98. ),
  99. ),
  100. );
  101. }
  102. _buildContent() {
  103. return Column(
  104. children: [
  105. Text('选择性别', style: Styles.getTextStyleBlack204W500(22.sp)),
  106. SizedBox(height: 119.h),
  107. _buildFemale(),
  108. SizedBox(height: 25.h),
  109. _buildMale(),
  110. ],
  111. );
  112. }
  113. _buildFemale() {
  114. return GestureDetector(
  115. onTap: () {
  116. if (controller.currentGender.value == 2) {
  117. controller.currentGender.value = 1;
  118. } else {
  119. controller.currentGender.value = 2;
  120. }
  121. },
  122. child: Obx(() {
  123. return SizedBox(
  124. width: 320.w,
  125. height: 115.h,
  126. child: Stack(
  127. clipBehavior: Clip.none,
  128. children: [
  129. controller.currentGender.value == 2
  130. ? Assets.images.iconChangeGenderFemaleSelect.image(
  131. width: 320.w,
  132. fit: BoxFit.fill,
  133. )
  134. : Assets.images.iconChangeGenderFemaleUnselect.image(
  135. width: 320.w,
  136. fit: BoxFit.cover,
  137. ),
  138. Container(
  139. alignment: Alignment.centerRight,
  140. padding: EdgeInsets.only(right: 40.w),
  141. child: Column(
  142. mainAxisAlignment: MainAxisAlignment.center,
  143. children: [
  144. Row(
  145. mainAxisSize: MainAxisSize.min,
  146. children: [
  147. Assets.images.iconChangeGenderFemaleLogo.image(
  148. width: 20.w,
  149. height: 20.w,
  150. ),
  151. SizedBox(width: 4.w),
  152. Text(
  153. '女生',
  154. textAlign: TextAlign.center,
  155. style: TextStyle(
  156. color:
  157. controller.currentGender.value == 2
  158. ? Colors.black.withAlpha(204)
  159. : Colors.black
  160. .withAlpha(204)
  161. .withValues(alpha: 0.5),
  162. fontSize: 22.sp,
  163. fontWeight: FontWeight.w700,
  164. ),
  165. ),
  166. ],
  167. ),
  168. SizedBox(height: 4.w),
  169. Row(
  170. mainAxisSize: MainAxisSize.min,
  171. children: [
  172. SizedBox(width: 20.w, height: 20.w),
  173. SizedBox(width: 4.w),
  174. Text(
  175. 'Girl',
  176. textAlign: TextAlign.center,
  177. style: TextStyle(
  178. color: Colors.black.withAlpha(128),
  179. fontSize: 14.sp,
  180. fontWeight: FontWeight.w400,
  181. ),
  182. ),
  183. ],
  184. ),
  185. ],
  186. ),
  187. ),
  188. ],
  189. ),
  190. );
  191. }),
  192. );
  193. }
  194. _buildMale() {
  195. return GestureDetector(
  196. onTap: () {
  197. if (controller.currentGender.value == 1) {
  198. controller.currentGender.value = 2;
  199. } else {
  200. controller.currentGender.value = 1;
  201. }
  202. },
  203. child: Obx(() {
  204. return SizedBox(
  205. width: 320.w,
  206. height: 115.h,
  207. child: Stack(
  208. clipBehavior: Clip.none,
  209. children: [
  210. controller.currentGender.value == 1
  211. ? Assets.images.iconChangeGenderMaleSelect.image(
  212. width: 320.w,
  213. fit: BoxFit.fill,
  214. )
  215. : Assets.images.iconChangeGenderMaleUnselect.image(
  216. width: 320.w,
  217. fit: BoxFit.cover,
  218. ),
  219. Container(
  220. alignment: Alignment.centerLeft,
  221. padding: EdgeInsets.only(left: 40.w),
  222. child: Column(
  223. mainAxisAlignment: MainAxisAlignment.center,
  224. children: [
  225. Row(
  226. mainAxisSize: MainAxisSize.min,
  227. children: [
  228. Text(
  229. '男生',
  230. textAlign: TextAlign.center,
  231. style: TextStyle(
  232. color:
  233. controller.currentGender.value == 1
  234. ? Colors.black.withAlpha(204)
  235. : Colors.black
  236. .withAlpha(204)
  237. .withValues(alpha: 0.5),
  238. fontSize: 22.sp,
  239. fontWeight: FontWeight.w700,
  240. ),
  241. ),
  242. SizedBox(width: 4.w),
  243. Assets.images.iconChangeGenderMaleLogo.image(
  244. width: 20.w,
  245. height: 20.w,
  246. ),
  247. ],
  248. ),
  249. SizedBox(height: 4.w),
  250. Row(
  251. mainAxisSize: MainAxisSize.min,
  252. children: [
  253. Text(
  254. 'Boy',
  255. textAlign: TextAlign.center,
  256. style: TextStyle(
  257. color: Colors.black.withAlpha(128),
  258. fontSize: 14.sp,
  259. fontWeight: FontWeight.w400,
  260. ),
  261. ),
  262. SizedBox(width: 4.w),
  263. SizedBox(width: 20.w, height: 20.w),
  264. ],
  265. ),
  266. ],
  267. ),
  268. ),
  269. ],
  270. ),
  271. );
  272. }),
  273. );
  274. }
  275. }