import 'package:cpt_community/modules/community/community_page.dart';
import 'package:cs_resources/generated/assets.dart';
import 'package:cs_resources/generated/l10n.dart';

class CommunityVmState {
  List<Map<String, dynamic>>? topSectionsData;
  List<String>? newsFeedTabsList;
  List<String>? garageSaleTabsList;
  List<Map<String, dynamic>>? garageCategoryList = []; // garageCategoryList
  int currentCategoryIdx = 0; // 0: news feed, 1: garage sale
  int currentPageViewIdx = 0;
  int lastNewsfeedTabIdx = 0; // 上一次newsfeed 的 tabIdx
  int lastGarageTabIdx = 0; // 上一次garagesale 的 tabIdx
  dynamic? tabsRouter;
  dynamic? pageController;

  CommunityVmState({
    List<Map<String, dynamic>>? topSectionsData,
    required this.currentPageViewIdx,
    currentCategoryIdx,
    lastNewsfeedTabIdx,
    lastGarageTabIdx,
    newsFeedTabsList,
    garageSaleTabsList,
    List<Map<String, dynamic>>? garageCategoryList,
    this.tabsRouter,
    this.pageController,
  })  : topSectionsData = topSectionsData ??
            [
              {
                "title": S.current.news_feed,
                "icon": Assets.communityNews,
              },
              {
                "title": S.current.garage_sale,
                "icon": Assets.communityGarageSale,
              },
            ],
        currentCategoryIdx = currentCategoryIdx ?? 0,
        lastGarageTabIdx = lastGarageTabIdx ?? 0,
        lastNewsfeedTabIdx = lastNewsfeedTabIdx ?? 0,
        newsFeedTabsList = newsFeedTabsList ??
            [
              S.current.newsfeed_news,
              S.current.newsfeed_following,
              S.current.for_you,
            ],
        garageSaleTabsList = garageSaleTabsList ??
            [
              S.current.for_sale,
              S.current.for_rent,
            ],
        garageCategoryList = garageCategoryList ?? [];

  CommunityVmState copyWith({
    List<Map<String, dynamic>>? topSectionsData,
    List<String>? newsFeedTabsList,
    List<String>? garageSaleTabsList,
    int? currentCategoryIdx,
    int? currentPageViewIdx,
    int? lastNewsfeedTabIdx,
    int? lastGarageTabIdx,
    List<Map<String, dynamic>>? garageCategoryList,
    dynamic? tabsRouter,
    dynamic? pageController,
  }) {
    return CommunityVmState(
      topSectionsData: topSectionsData ?? this.topSectionsData,
      newsFeedTabsList: newsFeedTabsList ?? this.newsFeedTabsList,
      garageSaleTabsList: garageSaleTabsList ?? this.garageSaleTabsList,
      currentCategoryIdx: currentCategoryIdx ?? this.currentCategoryIdx,
      currentPageViewIdx: currentPageViewIdx ?? this.currentPageViewIdx,
      lastNewsfeedTabIdx: lastNewsfeedTabIdx ?? this.lastNewsfeedTabIdx,
      lastGarageTabIdx: lastGarageTabIdx ?? this.lastGarageTabIdx,
      garageCategoryList: garageCategoryList ?? this.garageCategoryList,
      tabsRouter: tabsRouter ?? this.tabsRouter,
      pageController: pageController ?? this.pageController,
    );
  }
}
