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

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

  //表单的错误信息展示
  String? codeErrorText;
  String? passwordErrorText;
  String? confirmPasswordErrorText;

  //是否明文展示密码
  bool pwdVisibility;

  bool confirmPwdVisibility;

  //获取验证码的倒计时
  bool isCounting;
  int countdownTime;

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

  ForgotVerifyState({
    Map<String, Map<String, dynamic>>? formData,
    this.pwdVisibility = false,
    this.confirmPwdVisibility = false,
    this.isCounting = false,
    this.countdownTime = 0,
    this.codeErrorText,
    this.passwordErrorText,
    this.confirmPasswordErrorText,
  }) : formData = formData ??
            {
              'code': {
                'value': '',
                'controller': TextEditingController(),
                'hintText': S.current.verification_code,
                'focusNode': FocusNode(),
                'obsecure': false,
              },
              'password': {
                'value': '',
                'controller': TextEditingController(),
                'hintText': S.current.reset_password,
                'focusNode': FocusNode(),
                'obsecure': true,
              },
              'confirm_password': {
                'value': '',
                'controller': TextEditingController(),
                'hintText': S.current.confirm_password,
                'focusNode': FocusNode(),
                'obsecure': true,
              },
            };

  ForgotVerifyState copyWith({
    String? codeErrorText,
    String? passwordErrorText,
    String? confirmPasswordErrorText,
    bool? pwdVisibility,
    bool? confirmPwdVisibility,
    bool? isCounting,
    int? countdownTime,
  }) {
    return ForgotVerifyState(
      formData: this.formData,
      pwdVisibility: pwdVisibility ?? this.pwdVisibility,
      confirmPwdVisibility: confirmPwdVisibility ?? this.confirmPwdVisibility,
      isCounting: isCounting ?? this.isCounting,
      countdownTime: countdownTime ?? this.countdownTime,
      codeErrorText: codeErrorText,
      passwordErrorText: passwordErrorText,
      confirmPasswordErrorText: confirmPasswordErrorText,
    );
  }
}
