change_mobile_state.dart 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. 'new': {
  33. 'value': '',
  34. 'controller': TextEditingController(),
  35. 'hintText': S.current.mobile_phone,
  36. 'focusNode': FocusNode(),
  37. 'obsecure': false,
  38. },
  39. 'new_code': {
  40. 'value': '',
  41. 'controller': TextEditingController(),
  42. 'hintText': S.current.verification_code,
  43. 'focusNode': FocusNode(),
  44. 'obsecure': false,
  45. },
  46. };
  47. ChangeMobileState copyWith({
  48. bool? isOldCounting,
  49. int? oldCountdownTime,
  50. bool? isNewCounting,
  51. int? newCountdownTime,
  52. String? oldCodeErrorText,
  53. String? newCodeErrorText,
  54. }) {
  55. return ChangeMobileState(
  56. formData: this.formData,
  57. isOldCounting: isOldCounting ?? this.isOldCounting,
  58. oldCountdownTime: oldCountdownTime ?? this.oldCountdownTime,
  59. isNewCounting: isNewCounting ?? this.isNewCounting,
  60. newCountdownTime: newCountdownTime ?? this.newCountdownTime,
  61. oldCodeErrorText: oldCodeErrorText,
  62. newCodeErrorText: newCodeErrorText,
  63. );
  64. }
  65. }