123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- import 'package:cpt_community/modules/garage/garage_page.dart';
- import 'package:cpt_community/router/page/community_page_router.dart';
- import 'package:cs_resources/generated/assets.dart';
- import 'package:flutter/cupertino.dart';
- import 'package:plugin_platform/engine/toast/toast_engine.dart';
- import 'package:riverpod_annotation/riverpod_annotation.dart';
- import 'package:router/path/router_path.dart';
- import 'package:shared/utils/log_utils.dart';
- import 'package:auto_route/auto_route.dart';
- import 'community_state.dart';
- import 'newsfeed_post/newsfeed_post_page.dart';
- part 'community_vm.g.dart';
- @riverpod
- class CommunityVm extends _$CommunityVm {
- get topSectionsData => state.topSectionsData;
- CommunityVmState initState() {
- return CommunityVmState(
- currentTabIndex: 0,
- tabsList: ["News", "Following", "For You"],
- );
- }
- @override
- CommunityVmState build(){
- final state = initState();
- // 第一帧渲染完成
- WidgetsBinding.instance?.addPostFrameCallback((timeStamp) {
- });
- Log.d("--------------------------build---------------------");
- return state;
- }
- // 切换tab
- handlerChangeTab(int index, tabsRouter) {
- tabsRouter.setActiveIndex(index);
- // state = state.copyWith(tabsRouter: tabsRouter ,activeTabIdx: index);
- Log.d("community_vm handlerChangeTab--index: $index");
- }
- // 设置当前的 tabsRouter 和 pageController
- setTabsRouterAndPageController(dynamic tabsRouter, dynamic pageController) {
- Log.d("setTabsRouterAndPageController---:$tabsRouter");
- state = state.copyWith(tabsRouter: tabsRouter ,pageController: pageController, currentTabIndex: tabsRouter.activeIndex);
- }
- handlerChangeCommunityType(BuildContext context, int index){
- if(index == 1){
- Log.d("去往garage 页面");
- // 跳转到 garage sale 页面
- GaragePage.startInstance(context: context);
- // AutoRouter.of(context).push(const GaragePageRoute());
- }
- }
- // 点击发布的按钮 跳转到发布的页面
- void handlerGotoPost(context){
- // ComponentServiceManager().communityService.startCommunityPage();
- // AutoRouter.of(context).pushNamed(RouterPath.newsFeedPost);
- NewsfeedPostPage.startInstance();
- }
- }
|