import 'package:cs_resources/generated/l10n.dart';
import 'package:flutter/material.dart';

class ChangeMobileState {
  //表单的校验与数据
  final Map<String, Map<String, dynamic>> formData;

  //获取验证码的倒计时
  bool isOldCounting;
  int oldCountdownTime;

  bool isNewCounting;
  int newCountdownTime;

  //表单的错误信息展示
  String? oldCodeErrorText;
  String? newCodeErrorText;

  String? newCountryCode;

  // ===================================  Begin  ↓  ===================================

  ChangeMobileState({
    Map<String, Map<String, dynamic>>? formData,
    this.isOldCounting = false,
    this.oldCountdownTime = 0,
    this.isNewCounting = false,
    this.newCountdownTime = 0,
    this.oldCodeErrorText,
    this.newCodeErrorText,
    this.newCountryCode,
  }) : formData = formData ??
            {
              'old': {
                'value': '',
                'controller': TextEditingController(),
                'hintText': S.current.mobile_phone,
                'focusNode': FocusNode(),
                'obsecure': false,
              },
              'new': {
                'value': '',
                'controller': TextEditingController(),
                'hintText': S.current.mobile_phone,
                'focusNode': FocusNode(),
                'obsecure': false,
              },
              'new_code': {
                'value': '',
                'controller': TextEditingController(),
                'hintText': S.current.verification_code,
                'focusNode': FocusNode(),
                'obsecure': false,
              },
            };

  ChangeMobileState copyWith({
    bool? isOldCounting,
    int? oldCountdownTime,
    bool? isNewCounting,
    int? newCountdownTime,
    String? oldCodeErrorText,
    String? newCodeErrorText,

    String? newCountryCode,
  }) {
    return ChangeMobileState(
      formData: this.formData,
      isOldCounting: isOldCounting ?? this.isOldCounting,
      oldCountdownTime: oldCountdownTime ?? this.oldCountdownTime,
      isNewCounting: isNewCounting ?? this.isNewCounting,
      newCountdownTime: newCountdownTime ?? this.newCountdownTime,
      oldCodeErrorText: oldCodeErrorText,
      newCodeErrorText: newCodeErrorText,
      newCountryCode: newCountryCode ?? this.newCountryCode,
    );
  }
}
