change_birthday_page.dart 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  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/birthday/change_birthday_controller.dart';
  6. import 'package:keyboard/utils/styles.dart';
  7. import 'package:keyboard/widget/birthday_date_picker.dart';
  8. import '../../../resource/assets.gen.dart';
  9. import '../../../router/app_pages.dart';
  10. class ChangeBirthdayPage extends BasePage<ChangeBirthdayController> {
  11. const ChangeBirthdayPage({super.key});
  12. static Future start({String? birthday}) async {
  13. return Get.toNamed(
  14. RoutePath.changeBirthday,
  15. arguments: {"birthday": birthday},
  16. );
  17. }
  18. @override
  19. bool immersive() {
  20. return true;
  21. }
  22. @override
  23. Color backgroundColor() {
  24. return const Color(0xFFF6F5FA);
  25. }
  26. @override
  27. Widget buildBody(BuildContext context) {
  28. return Stack(
  29. children: [
  30. IgnorePointer(child: Assets.images.bgMine.image(width: 360.w)),
  31. SafeArea(
  32. child: Stack(
  33. children: [
  34. SingleChildScrollView(
  35. child: Column(
  36. children: [
  37. _buildTitle(),
  38. SizedBox(height: 40.h),
  39. _buildContent(context),
  40. ],
  41. ),
  42. ),
  43. Align(
  44. alignment: Alignment.bottomCenter,
  45. child: Container(
  46. margin: EdgeInsets.only(bottom: 32.h),
  47. child: Obx(() {
  48. return _buildSaveButton(
  49. onTap: () {
  50. controller.clickSave();
  51. },
  52. isEnable: controller.constellation.value.name.isNotEmpty,
  53. );
  54. }),
  55. ),
  56. ),
  57. ],
  58. ),
  59. ),
  60. ],
  61. );
  62. }
  63. _buildTitle() {
  64. return Container(
  65. alignment: Alignment.centerLeft,
  66. padding: EdgeInsets.only(top: 12.h, left: 16.w, right: 16.w),
  67. child: Row(
  68. mainAxisAlignment: MainAxisAlignment.start,
  69. children: [
  70. GestureDetector(
  71. onTap: controller.clickBack,
  72. child: Assets.images.iconMineBackArrow.image(
  73. width: 24.w,
  74. height: 24.w,
  75. ),
  76. ),
  77. ],
  78. ),
  79. );
  80. }
  81. _buildContent(BuildContext context) {
  82. return Column(
  83. children: [
  84. Text('选择生日', style: Styles.getTextStyleBlack204W500(22.sp)),
  85. Container(
  86. margin: EdgeInsets.only(top: 119.h),
  87. alignment: Alignment.center,
  88. child: Container(child: _datePicker(context)),
  89. ),
  90. SizedBox(height: 18.h),
  91. Obx(() {
  92. return Row(
  93. mainAxisAlignment: MainAxisAlignment.center,
  94. children: [
  95. // 星座
  96. Container(
  97. width: 26.r,
  98. height: 26.r,
  99. decoration: ShapeDecoration(
  100. color: Colors.white,
  101. shape: OvalBorder(
  102. side: BorderSide(width: 1.r, color: Colors.white),
  103. ),
  104. shadows: [
  105. BoxShadow(
  106. color: Color(0x30A46EFE),
  107. blurRadius: 2.r,
  108. offset: Offset(0, 2),
  109. spreadRadius: 0,
  110. ),
  111. ],
  112. ),
  113. child: Container(
  114. margin: EdgeInsets.all(2.r),
  115. width: 22.r,
  116. height: 22.r,
  117. decoration: ShapeDecoration(
  118. gradient: LinearGradient(
  119. begin: Alignment.centerLeft,
  120. end: Alignment.centerRight,
  121. colors: [
  122. const Color(0xFF7D46FC),
  123. const Color(0xFFBC87FF),
  124. ],
  125. ),
  126. shape: OvalBorder(),
  127. shadows: [
  128. BoxShadow(
  129. color: Color(0x30A46EFE),
  130. blurRadius: 2.r,
  131. offset: Offset(0, 2.08),
  132. spreadRadius: 0,
  133. ),
  134. ],
  135. ),
  136. child: Center(child: controller.constellation.value.image.image(width: 14.r,height: 14.r,fit: BoxFit.contain),)
  137. ),
  138. ),
  139. SizedBox(width: 7.w,),
  140. Text(
  141. controller.constellation.value.name,
  142. style: Styles.getTextStyleBlack204W500(14.sp),
  143. ),
  144. ],
  145. );
  146. }),
  147. ],
  148. );
  149. }
  150. SizedBox _datePicker(BuildContext context) {
  151. var widget = SizedBox(
  152. height: 150.h,
  153. width: 320.w,
  154. // child: DatePickerWidget(),
  155. child: BirthdayDatePicker(
  156. initialDate: controller.initialDate,
  157. minimumDate: controller.minimumDate,
  158. maximumDate: DateTime.now(),
  159. onDateChanged: (date) {
  160. controller.updateConstellation(date);
  161. },
  162. ),
  163. );
  164. return widget;
  165. }
  166. Widget _buildSaveButton({required VoidCallback onTap, required isEnable}) {
  167. return GestureDetector(
  168. onTap: () {
  169. onTap();
  170. },
  171. child: Container(
  172. width: 260.w,
  173. height: 48.h,
  174. decoration:
  175. isEnable
  176. ? Styles.getActivateButtonDecoration(31.r)
  177. : Styles.getInactiveButtonDecoration(31.r),
  178. child: Center(
  179. child: Text(
  180. '保存',
  181. style: TextStyle(
  182. color: Colors.white,
  183. fontSize: 16.sp,
  184. fontWeight: FontWeight.w500,
  185. ),
  186. ),
  187. ),
  188. ),
  189. );
  190. }
  191. }