new_user_page.dart 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. import 'package:flutter/src/widgets/framework.dart';
  2. import 'package:flutter_screenutil/flutter_screenutil.dart';
  3. import 'package:get/get.dart';
  4. import 'package:get/get_core/src/get_main.dart';
  5. import 'package:keyboard/base/base_page.dart';
  6. import 'package:keyboard/module/new_user/new_user_controller.dart';
  7. import 'package:flutter/material.dart';
  8. import 'package:keyboard/module/new_user/step/birthday/step_birthday_view.dart';
  9. import 'package:keyboard/module/new_user/step/gender/step_gender_view.dart';
  10. import 'package:keyboard/module/new_user/step/intimacy/step_intimacy_stages_view.dart';
  11. import 'package:keyboard/module/new_user/step/nickname/step_nickname_view.dart';
  12. import 'package:keyboard/module/new_user/step/partner/step_partner_view.dart';
  13. import 'package:keyboard/router/app_pages.dart';
  14. import '../../resource/assets.gen.dart';
  15. import '../../resource/string.gen.dart';
  16. import '../../utils/styles.dart';
  17. import '../../widget/step_progress_bar.dart';
  18. class NewUserPage extends BasePage<NewUserController> {
  19. const NewUserPage({super.key});
  20. static start() {
  21. Get.toNamed(RoutePath.newUser);
  22. }
  23. @override
  24. Color backgroundColor() {
  25. return const Color(0xFFF6F5FA);
  26. }
  27. @override
  28. bool immersive() {
  29. return true;
  30. }
  31. @override
  32. Widget buildBody(BuildContext context) {
  33. return PopScope(
  34. canPop: false,
  35. onPopInvokedWithResult: (didPop, result) {
  36. if (didPop) {
  37. return;
  38. }
  39. controller.clickBack();
  40. },
  41. child: Stack(
  42. children: [
  43. IgnorePointer(child: Assets.images.bgMine.image(width: 360.w)),
  44. SafeArea(
  45. child: Stack(
  46. children: [
  47. Column(
  48. crossAxisAlignment: CrossAxisAlignment.start,
  49. children: [
  50. _buildTitle(),
  51. Container(
  52. margin: EdgeInsets.only(
  53. top: 22.w,
  54. left: 32.w,
  55. right: 32.w,
  56. ),
  57. child: Obx(() {
  58. return StepProgressBar(
  59. currentStep: controller.currentStep,
  60. totalSteps: controller.totalSteps,
  61. );
  62. }),
  63. ),
  64. SizedBox(height: 17.w),
  65. Expanded(
  66. child: PageView(
  67. controller: controller.pageController,
  68. physics: const NeverScrollableScrollPhysics(),
  69. children: const [
  70. StepGenderView(),
  71. StepBirthdayView(),
  72. StepNicknameView(),
  73. StepIntimacyStagesView(),
  74. StepPartnerView(),
  75. ],
  76. ),
  77. ),
  78. ],
  79. ),
  80. Align(
  81. alignment: Alignment.bottomCenter,
  82. child: Container(
  83. margin: EdgeInsets.only(
  84. bottom: 50.w,
  85. left: 50.w,
  86. right: 50.w,
  87. ),
  88. child: Obx(() {
  89. return _buildNextButton(
  90. onTap: () {
  91. controller.clickNextButton();
  92. },
  93. isEnable: controller.isCurrentStepValid,
  94. );
  95. }),
  96. ),
  97. ),
  98. ],
  99. ),
  100. ),
  101. ],
  102. ),
  103. );
  104. }
  105. _buildTitle() {
  106. return Container(
  107. alignment: Alignment.centerLeft,
  108. padding: EdgeInsets.only(top: 12.h, left: 16.w, right: 16.w),
  109. child: Row(
  110. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  111. children: [
  112. GestureDetector(
  113. onTap: () => controller.clickBack(),
  114. child: Assets.images.iconMineBackArrow.image(
  115. width: 24.w,
  116. height: 24.w,
  117. ),
  118. ),
  119. GestureDetector(
  120. onTap: () => controller.clickSkip(),
  121. child: Text(
  122. StringName.skip,
  123. style: Styles.getTextStyleBlack128W400(14.sp),
  124. ),
  125. ),
  126. ],
  127. ),
  128. );
  129. }
  130. Widget _buildNextButton({required VoidCallback onTap, required isEnable}) {
  131. return GestureDetector(
  132. onTap: () {
  133. onTap();
  134. },
  135. child: Row(
  136. children: [
  137. Column(
  138. mainAxisSize: MainAxisSize.min,
  139. children: [
  140. Container(
  141. width: 260.w,
  142. height: 48.h,
  143. decoration:
  144. isEnable
  145. ? Styles.getActivateButtonDecoration(50.r)
  146. : Styles.getInactiveButtonDecoration(50.r),
  147. child: Center(
  148. child: Text(
  149. controller.currentStep == controller.totalSteps
  150. ? StringName.newUserPartnerNowGenerate
  151. : StringName.nextStep,
  152. style: TextStyle(
  153. color: Colors.white,
  154. fontSize: 16.sp,
  155. fontWeight: FontWeight.w500,
  156. ),
  157. ),
  158. ),
  159. ),
  160. Visibility(
  161. visible: controller.currentStep == controller.totalSteps,
  162. child: SizedBox(height: 25.w),
  163. ),
  164. Visibility(
  165. visible: controller.currentStep == controller.totalSteps,
  166. child: GestureDetector(
  167. onTap: controller.clickUseGeneralMode,
  168. child: Text(
  169. StringName.newUserPartnerLater,
  170. style: TextStyle(
  171. color: Colors.black.withAlpha(87),
  172. fontSize: 14.sp,
  173. ),
  174. ),
  175. ),
  176. ),
  177. ],
  178. ),
  179. ],
  180. ),
  181. );
  182. }
  183. }