import 'package:zhiying_base_widget/widgets/mine/mine_header/model/mine_profile_model.dart';
import 'package:zhiying_comm/models/base/skip_model.dart';

class MineDataModel extends SkipModel{
  String accumulatedEarningsBgImg;
  String bottomLeftRadius;
  String bottomRightRadius;
  CashBtn cashBtn;
  String desc;
  String isLeftRightMargin;
  String isNeedDownloadApp;
  String isShow;
  String isTopMargin;
  String leftRightMargin;
  List<ListStyle> listStyle;
  String moduleKey;
  String moduleType;
  String name;
  String topLeftRadius;
  String topMargin;
  String topRightRadius;
  String bg_color;

  MineDataModel(
      {this.accumulatedEarningsBgImg,
        this.bottomLeftRadius,
        this.bottomRightRadius,
        this.cashBtn,
        this.desc,
        this.isLeftRightMargin,
        this.isNeedDownloadApp,
        this.isShow,
        this.isTopMargin,
        this.leftRightMargin,
        this.listStyle,
        this.moduleKey,
        this.moduleType,
        this.name,
        this.topLeftRadius,
        this.topMargin,
        this.topRightRadius,
        this.bg_color,
      });

  MineDataModel.fromJson(Map<String, dynamic> json) {
    accumulatedEarningsBgImg = json['accumulated_earnings_bg_img'];
    bottomLeftRadius = json['bottom_left_radius'];
    bottomRightRadius = json['bottom_right_radius'];
    cashBtn = json['cash_btn'] != null
        ? new CashBtn.fromJson(json['cash_btn'])
        : null;
    desc = json['desc'];
    isLeftRightMargin = json['is_left_right_margin'];
    isNeedDownloadApp = json['is_need_download_app'];
    isShow = json['is_show'];
    isTopMargin = json['is_top_margin'];
    leftRightMargin = json['left_right_margin'];
    if (json['list_style'] != null) {
      listStyle = new List<ListStyle>();
      json['list_style'].forEach((v) {
        listStyle.add(new ListStyle.fromJson(v));
      });
    }
    moduleKey = json['module_key'];
    moduleType = json['module_type'];
    name = json['name'];
    topLeftRadius = json['top_left_radius'];
    topMargin = json['top_margin'];
    topRightRadius = json['top_right_radius'];
    bg_color = json['bg_color'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['accumulated_earnings_bg_img'] = this.accumulatedEarningsBgImg;
    data['bottom_left_radius'] = this.bottomLeftRadius;
    data['bottom_right_radius'] = this.bottomRightRadius;
    if (this.cashBtn != null) {
      data['cash_btn'] = this.cashBtn.toJson();
    }
    data['desc'] = this.desc;
    data['is_left_right_margin'] = this.isLeftRightMargin;
    data['is_need_download_app'] = this.isNeedDownloadApp;
    data['is_show'] = this.isShow;
    data['is_top_margin'] = this.isTopMargin;
    data['left_right_margin'] = this.leftRightMargin;
    if (this.listStyle != null) {
      data['list_style'] = this.listStyle.map((v) => v.toJson()).toList();
    }
    data['module_key'] = this.moduleKey;
    data['module_type'] = this.moduleType;
    data['name'] = this.name;
    data['top_left_radius'] = this.topLeftRadius;
    data['top_margin'] = this.topMargin;
    data['top_right_radius'] = this.topRightRadius;
    data['bg_color'] = this.bg_color;
    return data;
  }
}

class CashBtn extends SkipModel{
  String btnText;
  String btnTextColor;
  String image;
  String requiredLogin;
  String requiredTaobaoAuth;
  String skipIdentifier;

  CashBtn(
      {this.btnText,
        this.btnTextColor,
        this.image,
        this.requiredLogin,
        this.requiredTaobaoAuth,
        this.skipIdentifier});

  CashBtn.fromJson(Map<String, dynamic> json) {
    btnText = json['btn_text'];
    btnTextColor = json['btn_text_color'];
    image = json['image'];
    requiredLogin = json['required_login'];
    requiredTaobaoAuth = json['required_taobao_auth'];
    skipIdentifier = json['skip_identifier'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['btn_text'] = this.btnText;
    data['btn_text_color'] = this.btnTextColor;
    data['image'] = this.image;
    data['required_login'] = this.requiredLogin;
    data['required_taobao_auth'] = this.requiredTaobaoAuth;
    data['skip_identifier'] = this.skipIdentifier;
    return data;
  }
}

class ListStyle extends SkipModel{
  String isShow;
  String name;
  String numColor;
  String requiredLogin;
  String requiredTaobaoAuth;
  String skipIdentifier;
  String textColor;
  String type;

  ListStyle(
      {this.isShow,
        this.name,
        this.numColor,
        this.requiredLogin,
        this.requiredTaobaoAuth,
        this.skipIdentifier,
        this.textColor,
        this.type});

  ListStyle.fromJson(Map<String, dynamic> json) {
    isShow = json['is_show'];
    name = json['name'];
    numColor = json['num_color'];
    requiredLogin = json['required_login'];
    requiredTaobaoAuth = json['required_taobao_auth'];
    skipIdentifier = json['skip_identifier'];
    textColor = json['text_color'];
    type = json['type'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['is_show'] = this.isShow;
    data['name'] = this.name;
    data['num_color'] = this.numColor;
    data['required_login'] = this.requiredLogin;
    data['required_taobao_auth'] = this.requiredTaobaoAuth;
    data['skip_identifier'] = this.skipIdentifier;
    data['text_color'] = this.textColor;
    data['type'] = this.type;
    return data;
  }
}