change_mobile_state.dart 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. String? newCountryCode;
  15. // =================================== Begin ↓ ===================================
  16. ChangeMobileState({
  17. Map<String, Map<String, dynamic>>? formData,
  18. this.isOldCounting = false,
  19. this.oldCountdownTime = 0,
  20. this.isNewCounting = false,
  21. this.newCountdownTime = 0,
  22. this.oldCodeErrorText,
  23. this.newCodeErrorText,
  24. this.newCountryCode,
  25. }) : formData = formData ??
  26. {
  27. 'old': {
  28. 'value': '',
  29. 'controller': TextEditingController(),
  30. 'hintText': S.current.mobile_phone,
  31. 'focusNode': FocusNode(),
  32. 'obsecure': false,
  33. },
  34. 'new': {
  35. 'value': '',
  36. 'controller': TextEditingController(),
  37. 'hintText': S.current.mobile_phone,
  38. 'focusNode': FocusNode(),
  39. 'obsecure': false,
  40. },
  41. 'new_code': {
  42. 'value': '',
  43. 'controller': TextEditingController(),
  44. 'hintText': S.current.verification_code,
  45. 'focusNode': FocusNode(),
  46. 'obsecure': false,
  47. },
  48. };
  49. ChangeMobileState copyWith({
  50. bool? isOldCounting,
  51. int? oldCountdownTime,
  52. bool? isNewCounting,
  53. int? newCountdownTime,
  54. String? oldCodeErrorText,
  55. String? newCodeErrorText,
  56. String? newCountryCode,
  57. }) {
  58. return ChangeMobileState(
  59. formData: this.formData,
  60. isOldCounting: isOldCounting ?? this.isOldCounting,
  61. oldCountdownTime: oldCountdownTime ?? this.oldCountdownTime,
  62. isNewCounting: isNewCounting ?? this.isNewCounting,
  63. newCountdownTime: newCountdownTime ?? this.newCountdownTime,
  64. oldCodeErrorText: oldCodeErrorText,
  65. newCodeErrorText: newCodeErrorText,
  66. newCountryCode: newCountryCode ?? this.newCountryCode,
  67. );
  68. }
  69. }