change_mobile_state.dart 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. import 'package:cs_resources/generated/l10n.dart';
  2. import 'package:flutter/material.dart';
  3. class ChangeMobileState {
  4. //表单的校验与数据
  5. final Map<String, Map<String, dynamic>> formData;
  6. //获取验证码的倒计时
  7. bool isOldCounting;
  8. int oldCountdownTime;
  9. bool isNewCounting;
  10. int newCountdownTime;
  11. //表单的错误信息展示
  12. String? oldCodeErrorText;
  13. String? newCodeErrorText;
  14. // =================================== Begin ↓ ===================================
  15. ChangeMobileState({
  16. Map<String, Map<String, dynamic>>? formData,
  17. this.isOldCounting = false,
  18. this.oldCountdownTime = 0,
  19. this.isNewCounting = false,
  20. this.newCountdownTime = 0,
  21. this.oldCodeErrorText,
  22. this.newCodeErrorText,
  23. }) : formData = formData ??
  24. {
  25. 'old': {
  26. 'value': '',
  27. 'controller': TextEditingController(),
  28. 'hintText': S.current.mobile_phone,
  29. 'focusNode': FocusNode(),
  30. 'obsecure': false,
  31. },
  32. 'old_code': {
  33. 'value': '',
  34. 'controller': TextEditingController(),
  35. 'hintText': S.current.verification_code,
  36. 'focusNode': FocusNode(),
  37. 'obsecure': false,
  38. },
  39. 'new': {
  40. 'value': '',
  41. 'controller': TextEditingController(),
  42. 'hintText': S.current.mobile_phone,
  43. 'focusNode': FocusNode(),
  44. 'obsecure': false,
  45. },
  46. 'new_code': {
  47. 'value': '',
  48. 'controller': TextEditingController(),
  49. 'hintText': S.current.verification_code,
  50. 'focusNode': FocusNode(),
  51. 'obsecure': false,
  52. },
  53. };
  54. ChangeMobileState copyWith({
  55. bool? isOldCounting,
  56. int? oldCountdownTime,
  57. bool? isNewCounting,
  58. int? newCountdownTime,
  59. String? oldCodeErrorText,
  60. String? newCodeErrorText,
  61. }) {
  62. return ChangeMobileState(
  63. formData: this.formData,
  64. isOldCounting: isOldCounting ?? this.isOldCounting,
  65. oldCountdownTime: oldCountdownTime ?? this.oldCountdownTime,
  66. isNewCounting: isNewCounting ?? this.isNewCounting,
  67. newCountdownTime: newCountdownTime ?? this.newCountdownTime,
  68. oldCodeErrorText: oldCodeErrorText,
  69. newCodeErrorText: newCodeErrorText,
  70. );
  71. }
  72. }