import 'package:zhiying_comm/zhiying_comm.dart';

class CustomNoticeModel {
  String name;
  String desc;
  String moduleType;
  String moduleKey;
  String isTopMargin;
  String isLeftRightMargin;
  String isShow;
  String topMargin;
  String leftRightMargin;
  String bgColor;
  String topLeftRadius;
  String topRightRadius;
  String bottomLeftRadius;
  String bottomRightRadius;
  String textColor;
  String appNameImg;
  String jumpImg;
  String bg_color;
  String outsideBgColor;
  List<NoticeListStyle> listStyle;

  CustomNoticeModel(
      {this.name,
        this.desc,
        this.moduleType,
        this.moduleKey,
        this.isTopMargin,
        this.isLeftRightMargin,
        this.isShow,
        this.topMargin,
        this.leftRightMargin,
        this.bgColor,
        this.topLeftRadius,
        this.topRightRadius,
        this.bottomLeftRadius,
        this.bottomRightRadius,
        this.textColor,
        this.appNameImg,
        this.jumpImg,
        this.listStyle,
        this.bg_color,
      });

  CustomNoticeModel.fromJson(Map<String, dynamic> json) {
    name = json['name'];
    desc = json['desc'];
    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'];
    bgColor = json['bg_color'];
    topLeftRadius = json['top_left_radius']?.toString();
    topRightRadius = json['top_right_radius']?.toString();
    bottomLeftRadius = json['bottom_left_radius']?.toString();
    bottomRightRadius = json['bottom_right_radius']?.toString();
    textColor = json['text_color'];
    appNameImg = json['app_name_img'];
    jumpImg = json['jump_img'];
    bg_color = json['bg_color'];
    if (json['list_style'] != null) {
      listStyle = new List<NoticeListStyle>();
      json['list_style'].forEach((v) {
        listStyle.add(new NoticeListStyle.fromJson(v));
      });
    }
    outsideBgColor=json['outside_bg_color']!=null?json['outside_bg_color']:null;
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['name'] = this.name;
    data['desc'] = this.desc;
    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['bg_color'] = this.bgColor;
    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['text_color'] = this.textColor;
    data['app_name_img'] = this.appNameImg;
    data['jump_img'] = this.jumpImg;
    data['bg_color']= this.bg_color;
    if (this.listStyle != null) {
      data['list_style'] = this.listStyle.map((v) => v.toJson()).toList();
    }
    return data;
  }
}

class NoticeListStyle extends SkipModel{
  String contentText;
  String requiredLogin;
  String requiredTaobaoAuth;
  String skipIdentifier;

  NoticeListStyle(
      {this.contentText,
        this.requiredLogin,
        this.requiredTaobaoAuth,
        this.skipIdentifier});

  NoticeListStyle.fromJson(Map<String, dynamic> json) {
    super.fromJson(json);
    contentText = json['content_text'];
    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['content_text'] = this.contentText;
    data['required_login'] = this.requiredLogin;
    data['required_taobao_auth'] = this.requiredTaobaoAuth;
    data['skip_identifier'] = this.skipIdentifier;
    return data;
  }
}
