sign_up_page.dart 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. import 'package:cpt_auth/modules/sign_up/sign_up_controller.dart';
  2. import 'package:cpt_auth/modules/sign_up/sign_up_state.dart';
  3. import 'package:cs_resources/constants/color_constants.dart';
  4. import 'package:flutter/material.dart';
  5. import 'package:get/get.dart';
  6. import 'package:plugin_basic/base/base_state.dart';
  7. import 'package:plugin_basic/base/base_stateful_page.dart';
  8. import 'package:plugin_basic/utils/ext_get_nav.dart';
  9. import 'package:router/path/router_path.dart';
  10. import 'package:shared/utils/screen_util.dart';
  11. import 'package:widgets/ext/ex_widget.dart';
  12. import 'package:widgets/my_appbar.dart';
  13. import 'package:widgets/my_button.dart';
  14. import 'package:widgets/shatter/form_require_text.dart';
  15. import 'package:widgets/shatter/round_my_text_field.dart';
  16. class SignUpPage extends BaseStatefulPage<SignUpController> {
  17. SignUpPage({Key? key}) : super(key: key);
  18. //启动当前页面
  19. static void startInstance() {
  20. return Get.start(RouterPath.AUTH_SIGNUP);
  21. }
  22. @override
  23. Widget build(BuildContext context) {
  24. return Container();
  25. }
  26. @override
  27. SignUpController createRawController() {
  28. return SignUpController();
  29. }
  30. @override
  31. State<SignUpPage> createState() => _SignUpState();
  32. }
  33. class _SignUpState extends BaseState<SignUpPage, SignUpController> {
  34. late SignUpState state;
  35. @override
  36. void initState() {
  37. super.initState();
  38. state = controller.state;
  39. }
  40. @override
  41. Widget build(BuildContext context) {
  42. return autoCtlGetBuilder(builder: (controller) {
  43. return Scaffold(
  44. extendBodyBehindAppBar: true,
  45. appBar: MyAppBar.appBar(context, "Sign up".tr),
  46. body: SafeArea(
  47. bottom: true,
  48. top: false,
  49. child: Container(
  50. width: double.infinity,
  51. height: double.infinity,
  52. padding: EdgeInsets.only(top: kToolbarHeight + ScreenUtil.getStatusBarH(context) + 1),
  53. decoration: const BoxDecoration(
  54. gradient: LinearGradient(
  55. colors: [
  56. Color(0xFF091D44),
  57. Color(0xFF245A8A),
  58. Color(0xFF7F7CEC),
  59. ],
  60. begin: Alignment.topCenter,
  61. end: Alignment.bottomCenter,
  62. ),
  63. ),
  64. child: SingleChildScrollView(
  65. scrollDirection: Axis.vertical,
  66. physics: const BouncingScrollPhysics(),
  67. child: Column(
  68. mainAxisSize: MainAxisSize.max,
  69. crossAxisAlignment: CrossAxisAlignment.start,
  70. children: [
  71. //邮箱的设置
  72. FormRequireText(text: "Email".tr).marginOnly(left: 15, top: 19),
  73. CustomTextField(
  74. formKey: "email",
  75. formData: state.formData,
  76. errorText: state.emailErrorText,
  77. onSubmit: (key, value) {
  78. state.formData[key]!['focusNode'].unfocus();
  79. FocusScope.of(context).requestFocus(state.formData['password']!['focusNode']);
  80. },
  81. marginTop: 10,
  82. ),
  83. //密码的设置
  84. FormRequireText(text: "Password".tr).marginOnly(left: 15, top: 19),
  85. CustomTextField(
  86. formKey: "password",
  87. formData: state.formData,
  88. errorText: state.passwordErrorText,
  89. onSubmit: (key, value) {
  90. state.formData[key]!['focusNode'].unfocus();
  91. FocusScope.of(context).requestFocus(state.formData['confirm_password']!['focusNode']);
  92. },
  93. marginTop: 10,
  94. ),
  95. //确认密码的设置
  96. FormRequireText(text: "Confirm Password".tr).marginOnly(left: 15, top: 19),
  97. CustomTextField(
  98. formKey: "confirm_password",
  99. formData: state.formData,
  100. errorText: state.confirmPasswordErrorText,
  101. textInputAction: TextInputAction.done,
  102. onSubmit: (key, value) {
  103. FocusScope.of(context).unfocus();
  104. controller.doSignUp();
  105. },
  106. marginTop: 10,
  107. ),
  108. //注册按钮
  109. MyButton(
  110. type: ClickType.throttle,
  111. milliseconds: 500,
  112. onPressed: () {
  113. FocusScope.of(context).unfocus();
  114. controller.doSignUp();
  115. },
  116. text: "Submit".tr,
  117. textColor: ColorConstants.white,
  118. fontSize: 16,
  119. radius: 22.5,
  120. backgroundColor: hexToColor("#FFBB1B"),
  121. fontWeight: FontWeight.w500,
  122. ).marginSymmetric(horizontal: 15, vertical: 25),
  123. ],
  124. ),
  125. ),
  126. ),
  127. ),
  128. );
  129. });
  130. }
  131. }