import 'package:flutter/cupertino.dart';
import 'package:widgets/load_state_layout.dart';

class ServiceEvaluateCreateState {
  //页面 LoadView 状态的展示
  LoadState loadingState;
  String? errorMessage;

  //notes 字段的错误信息展示
  String? notesErrorText;

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

  // score 评分
  final double? score;

  // 描述
  final String? notes;

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

  Map<String, dynamic>? datas;

  ServiceEvaluateCreateState({
    required this.loadingState,
    this.errorMessage,
    this.notesErrorText,
    formData,
    this.notes,
    this.score,
    required this.imgList,
    this.datas,
  }): formData = formData ?? {
    'notes': {
      'value': '',
      'controller': TextEditingController(),
      'hintText': '',
      'focusNode': FocusNode(),
      'obsecure': false,
    },
  };

  ServiceEvaluateCreateState copyWith({
    LoadState? loadingState,
    String? errorMessage,
    String? notesErrorText,
    Map<String, Map<String, dynamic>>? formData,
    String? notes,
    double? score,
    List<String>? imgList,
    Map<String, dynamic>? datas,
  }) {
    return ServiceEvaluateCreateState(
      loadingState: loadingState ?? this.loadingState,
      errorMessage: errorMessage ?? this.errorMessage,
      notesErrorText: notesErrorText ?? this.notesErrorText,
      formData: formData ?? this.formData,
      notes: notes ?? this.notes,
      score: score ?? this.score,
      imgList: imgList ?? this.imgList,
      datas: datas ?? this.datas,
    );
  }
}