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

class GaragesalePostPageState {
  //title 字段的错误信息展示
  String? titleErrorText;

  //contactInfo 字段的错误信息展示
  String? contactInfoErrorText;

  //price 字段的错误信息展示
  String? priceErrorText;

  //description 字段的错误信息展示
  String? descriptionErrorText;

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

  // 标题
  final String? title;
  // 描述
  final String? description;

  // 价格
  final String? price;

  // contact type 类型选项
  final List<String> contactTypeOptionsList = ["Mobile Phone", "WhatsApp",];
  String? contactTypeSelectedOption;

  // contact information
  final String? contactInformation;

  //sale 类型选项
  final List<String> saleOptionsList = ["For Sale", "For Rent",];
  String? saleSelectedOption;

  //category 类型选项
  // final List<String> categoryOptionsList = ["Kids", "Homeware", "Fashion", "Electronics","Sports","Furniture","Others"];
  List<String> categoryOptionsList = [];
  String? categorySelectedOption;


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

  GaragesalePostPageState({
    formData,
    required this.categoryOptionsList,
    this.imgList = const [],
    this.titleErrorText,
    this.contactInfoErrorText,
    this.priceErrorText,
    this.descriptionErrorText,
    this.title,
    this.description,
    this.price,
    this.contactInformation,
    this.contactTypeSelectedOption,
    this.saleSelectedOption,
    this.categorySelectedOption,
  }): formData = formData ?? {
    'sale': {
      'value': saleSelectedOption ?? '',
      'controller': TextEditingController(text: saleSelectedOption ?? ''),
      'hintText': '',
      'focusNode': FocusNode(),
      'obsecure': false,
    },
    'category': {
      'value': categorySelectedOption??'',
      'controller': TextEditingController(text: categorySelectedOption??''),
      'hintText': '',
      'focusNode': FocusNode(),
      'obsecure': false,
    },
    'title': {
      'value': title ?? '',
      'controller': TextEditingController(text: title ?? ''),
      'hintText': '',
      'focusNode': FocusNode(),
      'obsecure': false,
    },
    'price': {
      'value': price ?? '',
      'controller': TextEditingController(text: price ??''),
      'hintText': '',
      'focusNode': FocusNode(),
      'obsecure': false,
    },
    'contactInfo': {
      'value': contactInformation ?? '',
      'controller': TextEditingController(text: contactInformation ?? ''),
      'hintText': '',
      'focusNode': FocusNode(),
      'obsecure': false,
    },
    'description': {
      'value': description??'',
      'controller': TextEditingController(text: description??''),
      'hintText': '',
      'focusNode': FocusNode(),
      'obsecure': false,
    },
  };

  GaragesalePostPageState copyWith({
    Map<String, Map<String, dynamic>>? formData,
    List<String>? imgList,
    List<String>? categoryOptionsList,
    String? titleErrorText,
    String? contactInfoErrorText,
    String? priceErrorText,
    String? descriptionErrorText,
    String? contactInformation,
    String? contactTypeSelectedOption,
    String? saleSelectedOption,
    String? categorySelectedOption,
    String? title,
    String? description,
    String? price,
  }) {
    return GaragesalePostPageState(
      formData: formData ?? this.formData,
      title: title ?? this.title,
      description: description ?? this.description,
      price: price ?? this.price,
      imgList: imgList ?? this.imgList,
      categoryOptionsList: categoryOptionsList ?? this.categoryOptionsList,
      contactInformation: contactInformation ?? this.contactInformation,
      contactTypeSelectedOption: contactTypeSelectedOption ?? this.contactTypeSelectedOption,
      saleSelectedOption: saleSelectedOption ?? this.saleSelectedOption,
      categorySelectedOption: categorySelectedOption ?? this.categorySelectedOption,
      titleErrorText: titleErrorText ,
      contactInfoErrorText: contactInfoErrorText,
      priceErrorText: priceErrorText ,
      descriptionErrorText: descriptionErrorText,
    );
  }

}