import 'package:zhiying_base_widget/dialog/global_dialog/intellect_search_goods_dialog/model/no_goods_dialog_style_model.dart';
import 'package:zhiying_comm/zhiying_comm.dart';

class CustomQuickEntryModel {
  String name;
  String desc;
  String pagination;
  String moduleType;
  String moduleKey;
  String isTopMargin;
  String isLeftRightMargin;
  String isShow;
  String topMargin;
  String leftRightMargin;
  String topLeftRadius;
  String topRightRadius;
  String bottomLeftRadius;
  String bottomRightRadius;
  String rowSize;
  String bgColor;
  String paginationSelectColor;
  String paginationUnselectColor;
  String isShowTitle;
  String isShowSubTitle;
  String isShowCornerIcon;
  String isShowCategory;
  List<ListStyle> listStyle;
  List<TypeList> typeList;
  String titleColor;
  String subTitleColor;
  String columSize;

  CustomQuickEntryModel(
      {this.name,
        this.desc,
        this.pagination,
        this.moduleType,
        this.moduleKey,
        this.isTopMargin,
        this.isLeftRightMargin,
        this.isShow,
        this.topMargin,
        this.leftRightMargin,
        this.topLeftRadius,
        this.topRightRadius,
        this.bottomLeftRadius,
        this.bottomRightRadius,
        this.rowSize,
        this.bgColor,
        this.paginationSelectColor,
        this.paginationUnselectColor,
        this.isShowSubTitle,
        this.isShowCornerIcon,
        this.isShowCategory,
        this.listStyle,
        this.typeList,
        this.titleColor,
        this.subTitleColor,
        this.columSize,
        this.isShowTitle,
      });

  CustomQuickEntryModel.fromJson(Map<String, dynamic> json) {
    name = json['name'];
    desc = json['desc'];
    pagination = json['pagination'];
    moduleType = json['module_type'];
    moduleKey = json['module_key'];
    isTopMargin = json['is_top_margin'];
    isLeftRightMargin = json['is_left_right_margin'];
    isShow = json['is_show'];
    topMargin = json['top_margin'];
    leftRightMargin = json['left_right_margin'];
    topLeftRadius = json['top_left_radius'];
    topRightRadius = json['top_right_radius'];
    bottomLeftRadius = json['bottom_left_radius'];
    bottomRightRadius = json['bottom_right_radius'];
    rowSize = json['row_size']?.toString();
    bgColor = json['bg_color'];
    paginationSelectColor = json['pagination_select_color'];
    paginationUnselectColor = json['pagination_unselect_color'];
    isShowTitle = json['is_show_title'] ?? '1';
    isShowSubTitle = json['is_show_sub_title'];
    isShowCornerIcon = json['is_show_corner_icon'];
    isShowCategory = json['is_show_category'];
    if (json['list_style'] != null) {
      listStyle = new List<ListStyle>();
      json['list_style'].forEach((v) {
        listStyle.add(new ListStyle.fromJson(v));
      });
    }
    if (json['type_list'] != null) {
      typeList = new List<TypeList>();
      json['type_list'].forEach((v) {
        typeList.add(new TypeList.fromJson(v));
      });
    }
    titleColor = json['title_color'];
    subTitleColor = json['sub_title_color'];
    columSize = json['colum_size']?.toString();
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['name'] = this.name;
    data['desc'] = this.desc;
    data['pagination'] = this.pagination;
    data['module_type'] = this.moduleType;
    data['module_key'] = this.moduleKey;
    data['is_top_margin'] = this.isTopMargin;
    data['is_left_right_margin'] = this.isLeftRightMargin;
    data['is_show'] = this.isShow;
    data['top_margin'] = this.topMargin;
    data['left_right_margin'] = this.leftRightMargin;
    data['top_left_radius'] = this.topLeftRadius;
    data['top_right_radius'] = this.topRightRadius;
    data['bottom_left_radius'] = this.bottomLeftRadius;
    data['bottom_right_radius'] = this.bottomRightRadius;
    data['row_size'] = this.rowSize;
    data['bg_color'] = this.bgColor;
    data['pagination_select_color'] = this.paginationSelectColor;
    data['pagination_unselect_color'] = this.paginationUnselectColor;
    data['is_show_sub_title'] = this.isShowSubTitle;
    data['is_show_corner_icon'] = this.isShowCornerIcon;
    data['is_show_category'] = this.isShowCategory;
    if (this.listStyle != null) {
      data['list_style'] = this.listStyle.map((v) => v.toJson()).toList();
    }
    if (this.typeList != null) {
      data['type_list'] = this.typeList.map((v) => v.toJson()).toList();
    }
    data['title_color'] = this.titleColor;
    data['sub_title_color'] = this.subTitleColor;
    data['colum_size'] = this.columSize;
    return data;
  }
}

class ListStyle extends SkipModel{
  String img;
  String title;
  String subTitle;
  String rightIcon;
  String typeListKey;
  String requiredLogin;
  String requiredTaobaoAuth;
  String skipIdentifier;

  ListStyle(
      {this.img,
        this.title,
        this.subTitle,
        this.rightIcon,
        this.typeListKey,
        this.requiredLogin,
        this.requiredTaobaoAuth,
        this.skipIdentifier});

  ListStyle.fromJson(Map<String, dynamic> json) {
    super.fromJson(json);
    img = json['img'];
    title = json['title'];
    subTitle = json['sub_title'];
    rightIcon = json['right_icon'];
    typeListKey = json['type_list_key'];
    requiredLogin = json['required_login'];
    requiredTaobaoAuth = json['required_taobao_auth'];
    skipIdentifier = json['skip_identifier'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = super.toJson();
    data['img'] = this.img;
    data['title'] = this.title;
    data['sub_title'] = this.subTitle;
    data['right_icon'] = this.rightIcon;
    data['type_list_key'] = this.typeListKey;
    data['required_login'] = this.requiredLogin;
    data['required_taobao_auth'] = this.requiredTaobaoAuth;
    data['skip_identifier'] = this.skipIdentifier;
    return data;
  }
}

class TypeList {
  String name;
  String key;

  TypeList({this.name, this.key});

  TypeList.fromJson(Map<String, dynamic> json) {
    name = json['name'];
    key = json['key'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['name'] = this.name;
    data['key'] = this.key;
    return data;
  }
}
