community_state.dart 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. import 'package:cpt_community/modules/community/community_page.dart';
  2. import 'package:cs_resources/generated/assets.dart';
  3. class CommunityVmState {
  4. List<Map<String, dynamic>>? topSectionsData;
  5. List<String>? newsFeedTabsList;
  6. List<String>? garageSaleTabsList;
  7. List<Map<String, dynamic>>? garageCategoryList = []; // garageCategoryList
  8. int currentCategoryIdx = 0; // 0: news feed, 1: garage sale
  9. int currentPageViewIdx = 0;
  10. int lastNewsfeedTabIdx = 0; // 上一次newsfeed 的 tabIdx
  11. int lastGarageTabIdx = 0; // 上一次garagesale 的 tabIdx
  12. dynamic? tabsRouter;
  13. dynamic? pageController;
  14. CommunityVmState({
  15. List<Map<String, dynamic>>? topSectionsData,
  16. required this.currentPageViewIdx,
  17. currentCategoryIdx,
  18. lastNewsfeedTabIdx,
  19. lastGarageTabIdx,
  20. newsFeedTabsList,
  21. garageSaleTabsList,
  22. List<Map<String, dynamic>>? garageCategoryList,
  23. this.tabsRouter,
  24. this.pageController,
  25. }) : topSectionsData = topSectionsData?? [
  26. {
  27. "title": "News Feed",
  28. "icon": Assets.communityNews,
  29. },
  30. {
  31. "title": "Garage Sale",
  32. "icon": Assets.communityGarageSale,
  33. },
  34. ],
  35. currentCategoryIdx = currentCategoryIdx?? 0,
  36. lastGarageTabIdx = lastGarageTabIdx?? 0,
  37. lastNewsfeedTabIdx = lastNewsfeedTabIdx?? 0,
  38. newsFeedTabsList = newsFeedTabsList?? [
  39. "News",
  40. "Following",
  41. "For You",
  42. ],
  43. garageSaleTabsList = garageSaleTabsList?? [
  44. "For Sale",
  45. "For Rent",
  46. ], garageCategoryList = garageCategoryList?? [];
  47. CommunityVmState copyWith({
  48. List<Map<String, dynamic>>? topSectionsData,
  49. List<String>? newsFeedTabsList,
  50. List<String>? garageSaleTabsList,
  51. int? currentCategoryIdx,
  52. int? currentPageViewIdx,
  53. int? lastNewsfeedTabIdx,
  54. int? lastGarageTabIdx,
  55. List<Map<String, dynamic>>? garageCategoryList,
  56. dynamic? tabsRouter,
  57. dynamic? pageController,
  58. }) {
  59. return CommunityVmState(
  60. topSectionsData: topSectionsData ?? this.topSectionsData,
  61. newsFeedTabsList: newsFeedTabsList ?? this.newsFeedTabsList,
  62. garageSaleTabsList: garageSaleTabsList ?? this.garageSaleTabsList,
  63. currentCategoryIdx: currentCategoryIdx ?? this.currentCategoryIdx,
  64. currentPageViewIdx: currentPageViewIdx ?? this.currentPageViewIdx,
  65. lastNewsfeedTabIdx: lastNewsfeedTabIdx ?? this.lastNewsfeedTabIdx,
  66. lastGarageTabIdx: lastGarageTabIdx ?? this.lastGarageTabIdx,
  67. garageCategoryList: garageCategoryList ?? this.garageCategoryList,
  68. tabsRouter: tabsRouter ?? this.tabsRouter,
  69. pageController: pageController ?? this.pageController,
  70. );
  71. }
  72. }