1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- import 'package:cpt_community/components/custom_tabs_state.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';
- part 'custom_tabs_vm.g.dart';
- @riverpod
- class CustomTabsVm extends _$CustomTabsVm {
- CustomTabsState initState(tabsList, activeIndex,tabItemBuilder, onClickAction) {
- CustomTabsState state = CustomTabsState(
- tabsList: tabsList,
- activeIndex:activeIndex,
- tabItemBuilder: tabItemBuilder,
- onClickAction: onClickAction
- );
- return state;
- }
- @override
- CustomTabsState build(){
- CustomTabsState state = initState([],0,null,null);
- return state;
- }
- Future<void> initPropData(tabsList, activeIndex,tabItemBuilder, onClickAction) async {
- CustomTabsState newState = state.copyWith(
- tabsList: tabsList,
- activeIndex: activeIndex,
- tabItemBuilder: tabItemBuilder,
- onClickAction: onClickAction
- );
- state = newState;
- }
- // 点击tab
- void handlerClickTab(int index, item){
- CustomTabsState newState = state.copyWith(
- activeIndex: index
- );
- state = newState;
-
- print("切换后新的 sate, ${state.activeIndex}");
- }
- }
|