123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- import 'package:cpt_community/modules/my_following/tabs_data.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:shared/utils/log_utils.dart';
- import 'package:auto_route/auto_route.dart';
- import 'my_following_page.dart';
- import 'my_following_state.dart';
- part 'my_following_vm.g.dart';
- @riverpod
- class MyFollowingVm extends _$MyFollowingVm {
- MyFollowingState initState() {
- return MyFollowingState(
- currentPageViewIdx: 0,
- );
- }
- @override
- MyFollowingState build(){
- final state = initState();
- Log.d("--------------------------build---------------------");
- return state;
- }
- tabsRouterChange(){
- Log.d("----tabsRouterChange---${myFollowingPageTabsRouterKey.currentState?.controller?.activeIndex}-");
- state = state.copyWith(
- currentPageViewIdx: myFollowingPageTabsRouterKey.currentState?.controller?.activeIndex ?? 0
- );
- }
- // 切换tab
- handlerChangeTab(int tabIndex, TabsRouter? tabsRouter,) {
- tabsRouter = (tabsRouter?? myFollowingPageTabsRouterKey.currentState?.controller)!;
- tabsRouter.setActiveIndex(tabIndex);
- }
- // 设置当前tab
- setCurrentTabIndex(int activeTabIdx){
- state = state.copyWith(
- activeTabIdx: activeTabIdx,
- );
- }
- // 改变 follow 页面navigatorbar
- handlerChangeFollowPageNavbar(bool showSearchBar){
- WidgetsBinding.instance?.addPostFrameCallback((timeStamp) {
- if(showSearchBar){
- state = state.copyWith(
- followPageIsSearchBarStatus: true,
- );
- } else {
- state = state.copyWith(
- followPageIsSearchBarStatus: false,
- );
- }
- });
- }
- // 改变 follower 页面navigatorbar
- handlerChangeFollowerPageNavbar(bool showSearchBar){
- WidgetsBinding.instance?.addPostFrameCallback((timeStamp) {
- if(showSearchBar){
- state = state.copyWith(
- followerPageIsSearchBarStatus: true,
- );
- } else {
- state = state.copyWith(
- followerPageIsSearchBarStatus: false,
- );
- }
- });
- }
- // 更新 tab 的数字
- updateMyFollowingTabsNum(String code, int num, int activeTabIdx){
- if(code == tabsNamesData['Follower']){
- state = state.copyWith(
- followerCount: num,
- activeTabIdx: activeTabIdx,
- );
- } else if(code == tabsNamesData['Follow']){
- state = state.copyWith(
- followCount: num,
- activeTabIdx: activeTabIdx,
- );
- }
- }
- }
|