import 'package:widgets/load_state_layout.dart';

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

  List<Map<String, dynamic>> list;

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

  MyPostsForSaleState({
    this.activeTabIndex,
    this.loadingState = LoadState.State_Loading,
    String? errorMessage,
    required this.list,
    this.tabsList,
  });

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

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

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