import 'package:zhiying_base_widget/pages/goods_share_page/models/goods_share_style_model.dart';
import 'package:zhiying_base_widget/pages/goods_share_page/models/goods_share_temp_model.dart';

class GoodsShareImageModel {
  String content;
  String format;
  String templateId;
  List<GoodsShareTempModel> showFunList;
  String isEditTemplate;
  List<String> customContent;
  List<String> customImage;
  GoodsShareStyleModel cssList;

  GoodsShareImageModel(
      {this.content,
      this.format,
      this.templateId,
      this.showFunList,
      this.isEditTemplate,
      this.customContent,
      this.customImage,
      this.cssList});

  GoodsShareImageModel.fromJson(Map<String, dynamic> json) {
    content = json['content'];
    format = json['format'];
    templateId = json['template_id'];
    if (json['show_fun_list'] != null) {
      showFunList = new List<GoodsShareTempModel>();
      json['show_fun_list'].forEach((v) {
        showFunList.add(
            new GoodsShareTempModel.fromJson(Map<String, dynamic>.from(v)));
      });
    }
    isEditTemplate = json['is_edit_template'];
    customContent = json['custom_content'].cast<String>();
    customImage = json['custom_image'].cast<String>();
    cssList = json['css_list'] != null
        ? new GoodsShareStyleModel.fromJson(json['css_list'])
        : null;
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['content'] = this.content;
    data['format'] = this.format;
    data['template_id'] = this.templateId;
    if (this.showFunList != null) {
      data['show_fun_list'] = this.showFunList.map((v) => v.toJson()).toList();
    }
    data['is_edit_template'] = this.isEditTemplate;
    data['custom_content'] = this.customContent;
    data['custom_image'] = this.customImage;
    if (this.cssList != null) {
      data['css_list'] = this.cssList.toJson();
    }
    return data;
  }
}

class ShareImage {
  CopyBtn copyBtn;
  CopyBtn saveBtn;
  CopyBtn shareBtn;

  ShareImage({this.copyBtn, this.saveBtn, this.shareBtn});

  ShareImage.fromJson(Map<String, dynamic> json) {
    copyBtn = json['copy_btn'] != null
        ? new CopyBtn.fromJson(json['copy_btn'])
        : null;
    saveBtn = json['save_btn'] != null
        ? new CopyBtn.fromJson(json['save_btn'])
        : null;
    shareBtn = json['share_btn'] != null
        ? new CopyBtn.fromJson(json['share_btn'])
        : null;
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    if (this.copyBtn != null) {
      data['copy_btn'] = this.copyBtn.toJson();
    }
    if (this.saveBtn != null) {
      data['save_btn'] = this.saveBtn.toJson();
    }
    if (this.shareBtn != null) {
      data['share_btn'] = this.shareBtn.toJson();
    }
    return data;
  }
}

class CopyBtn {
  String name;
  String modName;
  String bgType;
  String bgColor;
  String bgImage;
  String textColor;
  String smallIcon;

  CopyBtn(
      {this.name,
      this.modName,
      this.bgType,
      this.bgColor,
      this.bgImage,
      this.textColor,
      this.smallIcon});

  CopyBtn.fromJson(Map<String, dynamic> json) {
    name = json['name'];
    modName = json['mod_name'];
    bgType = json['bg_type'];
    bgColor = json['bg_color'];
    bgImage = json['bg_image'];
    textColor = json['text_color'];
    smallIcon = json['small_icon'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['name'] = this.name;
    data['mod_name'] = this.modName;
    data['bg_type'] = this.bgType;
    data['bg_color'] = this.bgColor;
    data['bg_image'] = this.bgImage;
    data['text_color'] = this.textColor;
    data['small_icon'] = this.smallIcon;
    return data;
  }
}
