12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- 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 {
- late PageController _pageController;
- get topSectionsData => state.topSectionsData;
- CommunityVmState initState() {
- return CommunityVmState(
- 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");
- }
- 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();
- }
- }
|