new_user_page.dart 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  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 Stack(
  34. children: [
  35. IgnorePointer(child: Assets.images.bgMine.image(width: 360.w)),
  36. SafeArea(
  37. child: Stack(
  38. children: [
  39. Column(
  40. crossAxisAlignment: CrossAxisAlignment.start,
  41. children: [
  42. _buildTitle(),
  43. Container(
  44. margin: EdgeInsets.only(top: 22.w, left: 32.w, right: 32.w),
  45. child: Obx(() {
  46. return StepProgressBar(
  47. currentStep: controller.currentStep,
  48. totalSteps: controller.totalSteps,
  49. );
  50. }),
  51. ),
  52. SizedBox(height: 17.w),
  53. Expanded(
  54. child: PageView(
  55. controller: controller.pageController,
  56. physics: const NeverScrollableScrollPhysics(),
  57. children: const [
  58. StepGenderView(),
  59. StepBirthdayView(),
  60. StepNicknameView(),
  61. StepIntimacyStagesView(),
  62. StepPartnerView(),
  63. ],
  64. ),
  65. ),
  66. ],
  67. ),
  68. Align(
  69. alignment: Alignment.bottomCenter,
  70. child: Container(
  71. margin: EdgeInsets.only(
  72. bottom: 50.w,
  73. left: 50.w,
  74. right: 50.w,
  75. ),
  76. child: Obx(() {
  77. return _buildNextButton(
  78. onTap: () {
  79. controller.clickNextButton();
  80. },
  81. isEnable: controller.isCurrentStepValid,
  82. );
  83. }),
  84. ),
  85. ),
  86. ],
  87. ),
  88. ),
  89. ],
  90. );
  91. }
  92. _buildTitle() {
  93. return Container(
  94. alignment: Alignment.centerLeft,
  95. padding: EdgeInsets.only(top: 12.h, left: 16.w, right: 16.w),
  96. child: Row(
  97. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  98. children: [
  99. GestureDetector(
  100. onTap: () => controller.clickBack(),
  101. child: Assets.images.iconMineBackArrow.image(
  102. width: 24.w,
  103. height: 24.w,
  104. ),
  105. ),
  106. GestureDetector(
  107. onTap: () => controller.clickSkip(),
  108. child: Text(
  109. StringName.skip,
  110. style: Styles.getTextStyleBlack128W400(14.sp),
  111. ),
  112. ),
  113. ],
  114. ),
  115. );
  116. }
  117. Widget _buildNextButton({required VoidCallback onTap, required isEnable}) {
  118. return GestureDetector(
  119. onTap: () {
  120. onTap();
  121. },
  122. child: Row(
  123. children: [
  124. Column(
  125. mainAxisSize: MainAxisSize.min,
  126. children: [
  127. Container(
  128. width: 260.w,
  129. height: 48.h,
  130. decoration:
  131. isEnable
  132. ? Styles.getActivateButtonDecoration(50.r)
  133. : Styles.getInactiveButtonDecoration(50.r),
  134. child: Center(
  135. child: Text(
  136. controller.currentStep == controller.totalSteps
  137. ? StringName.newUserPartnerNowGenerate
  138. : StringName.nextStep,
  139. style: TextStyle(
  140. color: Colors.white,
  141. fontSize: 16.sp,
  142. fontWeight: FontWeight.w500,
  143. ),
  144. ),
  145. ),
  146. ),
  147. Visibility(
  148. visible: controller.currentStep == controller.totalSteps,
  149. child: SizedBox(height: 25.w),
  150. ),
  151. Visibility(
  152. visible: controller.currentStep == controller.totalSteps,
  153. child: GestureDetector(
  154. onTap: controller.clickUseGeneralMode,
  155. child: Text(
  156. StringName.newUserPartnerLater,
  157. style: TextStyle(
  158. color: Colors.black.withAlpha(87),
  159. fontSize: 14.sp,
  160. ),
  161. ),
  162. ),
  163. ),
  164. ],
  165. ),
  166. ],
  167. ),
  168. );
  169. }
  170. }