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

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

  //类型选项
  List<IdNameEntity>? optionList;
  IdNameEntity? selectedOption;

  //选择的图片
  List<String> imgList;

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

  FeedbackCreateState({
    Map<String, Map<String, dynamic>>? formData,
    required this.imgList,
    this.optionList,
    this.selectedOption,
  }) : formData = formData ??
            {
              'title': {
                'value': '',
                'controller': TextEditingController(),
                'focusNode': FocusNode(),
                'obsecure': false,
              },
              'desc': {
                'value': '',
                'controller': TextEditingController(),
                'focusNode': FocusNode(),
                'hintText': S.current.type_here,
                'obsecure': false,
              },
            };

  FeedbackCreateState copyWith({
    List<IdNameEntity>? optionList,
    IdNameEntity? selectedOption,
    List<String>? imgList,
  }) {
    return FeedbackCreateState(
      formData: this.formData,
      imgList: imgList ?? this.imgList,
      optionList: optionList ?? this.optionList,
      selectedOption: selectedOption ?? this.selectedOption,
    );
  }
}
