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

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

  //表单的错误信息展示
  String? fullNameErrorText;
  String? phoneErrorText;
  String? nricErrorText;

  DateTime? accessDate; //通行时间

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

  VisitorRegisterState({
    Map<String, Map<String, dynamic>>? formData,
    this.fullNameErrorText,
    this.phoneErrorText,
    this.nricErrorText,
    this.accessDate,
  }) : formData = formData ??
            {
              'full_name': {
                'value': '',
                'controller': TextEditingController(),
                'focusNode': FocusNode(),
                'obsecure': false,
              },
              'phone': {
                'value': '',
                'controller': TextEditingController(),
                'focusNode': FocusNode(),
                'obsecure': false,
              },
              'nric': {
                'value': '',
                'controller': TextEditingController(),
                'focusNode': FocusNode(),
                'obsecure': false,
              },
              'plate_number': {
                'value': '',
                'controller': TextEditingController(),
                'focusNode': FocusNode(),
                'obsecure': false,
              },
              'note': {
                'value': '',
                'controller': TextEditingController(),
                'focusNode': FocusNode(),
                'hintText': S.current.type_here,
                'obsecure': false,
              },
            };

  VisitorRegisterState copyWith({
    String? fullNameErrorText,
    String? phoneErrorText,
    String? nricErrorText,
    DateTime? accessDate,
  }) {
    return VisitorRegisterState(
      formData: this.formData,
      fullNameErrorText: fullNameErrorText,
      phoneErrorText: phoneErrorText,
      nricErrorText: nricErrorText,
      accessDate: accessDate ?? this.accessDate,
    );
  }
}
