/// YApi QuickType插件生成，具体参考文档:https://plugins.jetbrains.com/plugin/18847-yapi-quicktype/documentation

import 'dart:convert';

import 'package:domain/entity/rewards_home_entity.dart';
import 'package:widgets/load_state_layout.dart';

// RewardsHomeState rewardsHomeStateFromJson(String str) =>
//     RewardsHomeState.fromJson(json.decode(str));

String rewardsHomeStateToJson(RewardsHomeState data) =>
    json.encode(data.toJson());

class RewardsHomeState {
  //页面 LoadView 状态的展示
  LoadState loadingState;
  String? errorMessage;
  List<Map<String, dynamic>> list;
  List<Map<String, dynamic>> lists;
  List<Map<String, dynamic>>? categoryList;
  RewardsHomeState({
    this.loadingState = LoadState.State_Loading,
    String? errorMessage,
    required this.list,
    required this.lists,
    required this.categoryList,
  });

  RewardsHomeState copyWith(
      {LoadState? loadingState,
      String? errorMessage,
      List<Map<String, dynamic>>? categoryList,
      List<Map<String, dynamic>>? list,
      List<Map<String, dynamic>>? lists}) {
    return RewardsHomeState(
      loadingState: loadingState ?? this.loadingState,
      errorMessage: errorMessage ?? this.errorMessage,
      list: list ?? this.list,
      lists: lists ?? this.lists,
      categoryList: list ?? this.categoryList,
    );
  }

  Map<String, dynamic> toMap() {
    return {
      'list': List<dynamic>.from(lists.map((x) => x)),
      "lists": List<dynamic>.from(lists.map((x) => x)),
      'categoryList': this.categoryList,
    };
  }

  Map<dynamic, dynamic> toJson() => {
        "lists": List<dynamic>.from(lists.map((x) => x)),
      };
  factory RewardsHomeState.fromJson(Map<dynamic, dynamic> json, dynamic map) =>
      RewardsHomeState(
        lists: List<Map<String, dynamic>>.from(json["lists"].map((x) => x)),
        list: List<Map<String, dynamic>>.from(json["lists"].map((x) => x)),
        categoryList: map['categoryList'] as List<Map<String, dynamic>>,
      );
  factory RewardsHomeState.fromMap(Map<String, dynamic> map, dynamic json) {
    return RewardsHomeState(
      list: List<Map<String, dynamic>>.from(json["lists"].map((x) => x)),
      lists: List<Map<String, dynamic>>.from(json["lists"].map((x) => x)),
      categoryList: map['categoryList'] as List<Map<String, dynamic>>,
    );
  }
}
