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

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

  List<IdNameEntity>? estateList;  //第一步的下拉选房产数据源

  IdNameEntity? selectedEstate; //第一步数据：已经选中的房产

  String? address; //第二步选择的数据
  String? unitId; //第二步选择的数据

  String? type; //第三步数据：已经选中的类型

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

  SelectEstateState({
    this.estateList,
    this.selectedEstate,
    this.address,
    this.unitId,
    this.type,
    Map<String, Map<String, dynamic>>? formData,
  }) : formData = formData ??
            {
              'estate': {
                'value': '',
                'controller': TextEditingController(),
                'hintText': S.current.type_here,
                'focusNode': FocusNode(),
                'obsecure': false,
              },
            };

  SelectEstateState copyWith({
    double? remainingSpace,
    List<IdNameEntity>? estateList,
    IdNameEntity? selectedEstate,
    String? address,
    String? unitId,
    String? type,
  }) {
    return SelectEstateState(
      estateList: estateList ?? this.estateList,
      selectedEstate: selectedEstate ?? this.selectedEstate,
      address: address ?? this.address,
      unitId: unitId ?? this.unitId,
      type: type ?? this.type,
      formData: this.formData,
    );
  }
}
