sign_up_state.dart 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. import 'package:cs_resources/generated/l10n.dart';
  2. import 'package:flutter/material.dart';
  3. class SignUpState {
  4. //表单的校验与数据
  5. final Map<String, Map<String, dynamic>> formData;
  6. //表单的错误信息展示
  7. String? firstNameErrorText;
  8. String? lastNameErrorText;
  9. String? emailErrorText;
  10. String? phoneErrorText;
  11. String? passwordErrorText;
  12. String? confirmPasswordErrorText;
  13. //是否明文展示密码
  14. bool pwdVisibility;
  15. bool confirmPwdVisibility;
  16. bool isAgreeTerms;
  17. // =================================== Begin ↓ ===================================
  18. SignUpState({
  19. Map<String, Map<String, dynamic>>? formData,
  20. this.pwdVisibility = false,
  21. this.confirmPwdVisibility = false,
  22. this.isAgreeTerms = false,
  23. this.firstNameErrorText,
  24. this.lastNameErrorText,
  25. this.emailErrorText,
  26. this.phoneErrorText,
  27. this.passwordErrorText,
  28. this.confirmPasswordErrorText,
  29. }) : formData = formData ??
  30. {
  31. 'first_name': {
  32. 'value': '',
  33. 'controller': TextEditingController(),
  34. 'hintText': S.current.first_name,
  35. 'focusNode': FocusNode(),
  36. 'obsecure': false,
  37. },
  38. 'last_name': {
  39. 'value': '',
  40. 'controller': TextEditingController(),
  41. 'hintText': S.current.last_name,
  42. 'focusNode': FocusNode(),
  43. 'obsecure': false,
  44. },
  45. 'email': {
  46. 'value': '',
  47. 'controller': TextEditingController(),
  48. 'hintText': S.current.email,
  49. 'focusNode': FocusNode(),
  50. 'obsecure': false,
  51. },
  52. 'phone': {
  53. 'value': '',
  54. 'controller': TextEditingController(),
  55. 'hintText': S.current.mobile_phone,
  56. 'focusNode': FocusNode(),
  57. 'obsecure': false,
  58. },
  59. 'password': {
  60. 'value': '',
  61. 'controller': TextEditingController(),
  62. 'hintText': S.current.password,
  63. 'focusNode': FocusNode(),
  64. 'obsecure': true,
  65. },
  66. 'confirm_password': {
  67. 'value': '',
  68. 'controller': TextEditingController(),
  69. 'hintText': S.current.confirm_password,
  70. 'focusNode': FocusNode(),
  71. 'obsecure': true,
  72. },
  73. };
  74. SignUpState copyWith({
  75. String? firstNameErrorText,
  76. String? lastNameErrorText,
  77. String? emailErrorText,
  78. String? phoneErrorText,
  79. String? passwordErrorText,
  80. String? confirmPasswordErrorText,
  81. bool? pwdVisibility,
  82. bool? confirmPwdVisibility,
  83. bool? isAgreeTerms,
  84. }) {
  85. return SignUpState(
  86. formData: this.formData,
  87. isAgreeTerms: isAgreeTerms ?? this.isAgreeTerms,
  88. pwdVisibility: pwdVisibility ?? this.pwdVisibility,
  89. confirmPwdVisibility: confirmPwdVisibility ?? this.confirmPwdVisibility,
  90. firstNameErrorText: firstNameErrorText,
  91. lastNameErrorText: lastNameErrorText,
  92. emailErrorText: emailErrorText,
  93. phoneErrorText: phoneErrorText,
  94. passwordErrorText: passwordErrorText,
  95. confirmPasswordErrorText: confirmPasswordErrorText,
  96. );
  97. }
  98. }