import 'package:widgets/load_state_layout.dart';

class MyPostsForRentState {
  int? activeTabIndex =0;
  //页面 LoadView 状态的展示
  LoadState loadingState;
  String? errorMessage;

  int? page;
  int? limit = 10;
  int? count = 0;
  List<Map<String, dynamic>> list;

  List<String>? tabsList = ['For Sale', 'For Rent'];

  MyPostsForRentState({
    this.activeTabIndex,
    this.loadingState = LoadState.State_Loading,
    String? errorMessage,
    this.page = 1,
    this.limit = 10,
    this.count = 0,
    required this.list,
    this.tabsList,
  });

  MyPostsForRentState copyWith({
    int? activeTabIndex,
    LoadState? loadingState,
    String? errorMessage,
    int? page,
    int? limit,
    int? count,
    List<Map<String, dynamic>>? list,
    List<String>? tabsList,
  }) {
    return MyPostsForRentState(
      activeTabIndex: activeTabIndex ?? this.activeTabIndex,
      loadingState: loadingState ?? this.loadingState,
      errorMessage: errorMessage ?? this.errorMessage,
      page: page ?? this.page,
      limit: limit ?? this.limit,
      count: count ?? this.count,
      tabsList: tabsList ?? this.tabsList,
      list: list ?? this.list,
    );
  }

  Map<String, dynamic> toMap() {
    return {
      'activeTabIndex': this.activeTabIndex,
      'loadingState': this.loadingState,
      'errorMessage': this.errorMessage,
      'page': this.page,
      'limit': this.limit,
      'count': this.count,
      'list': this.list,
      'tabsList': this.tabsList,
    };
  }

  factory MyPostsForRentState.fromMap(Map<String, dynamic> map) {
    return MyPostsForRentState(
      activeTabIndex: map['activeTabIndex'] as int,
      loadingState: map['loadingState'] as LoadState,
      errorMessage: map['errorMessage'] as String,
      page: map['page'] as int,
      limit: map['limit'] as int,
      count: map['count'] as int,
      list: map['list'] as List<Map<String, dynamic>>,
      tabsList: map['tabsList'] as List<String>,
    );
  }
}