|
|
@@ -1,3 +1,6 @@ |
|
|
|
import 'dart:async'; |
|
|
|
|
|
|
|
import 'package:event_bus/event_bus.dart'; |
|
|
|
import 'package:flutter/cupertino.dart'; |
|
|
|
import 'package:flutter/material.dart'; |
|
|
|
import 'package:tab_indicator_styler/tab_indicator_styler.dart'; |
|
|
@@ -36,22 +39,28 @@ class TeamPage extends StatelessWidget { |
|
|
|
], |
|
|
|
child: BlocProvider<TeamBloc>( |
|
|
|
create: (_) => TeamBloc(repository: TeamRepository())..add(TeamInitEvent(data)), |
|
|
|
child: _TeamPageContainer(), |
|
|
|
child: _TeamPageContainer( |
|
|
|
data: data, |
|
|
|
), |
|
|
|
), |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
class _TeamPageContainer extends StatefulWidget { |
|
|
|
final Map<String, dynamic> data; |
|
|
|
|
|
|
|
const _TeamPageContainer({Key key, this.data}) : super(key: key); |
|
|
|
|
|
|
|
@override |
|
|
|
_TeamPageContainerState createState() => _TeamPageContainerState(); |
|
|
|
} |
|
|
|
|
|
|
|
class _TeamPageContainerState extends State<_TeamPageContainer> { |
|
|
|
|
|
|
|
TabController _controller; |
|
|
|
|
|
|
|
// TabController 监听 |
|
|
|
void _tabChangeListener(){ |
|
|
|
void _tabChangeListener() { |
|
|
|
if (!_controller.indexIsChanging) { |
|
|
|
Provider.of<TeamPageNotifier>(context, listen: false).updateTabIndex(_controller?.index ?? 0); |
|
|
|
} |
|
|
@@ -80,11 +89,15 @@ class _TeamPageContainerState extends State<_TeamPageContainer> { |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
StreamSubscription streamSubscription; |
|
|
|
|
|
|
|
@override |
|
|
|
void initState() { |
|
|
|
// _controller = TabController(length: tabTitle.length, vsync: ScrollableState()); |
|
|
|
streamSubscription = EventUtil.instance.on<LoginSuccessEvent>().listen((event) { |
|
|
|
BlocProvider.of<TeamBloc>(context).add(TeamInitEvent(widget?.data)); |
|
|
|
}); |
|
|
|
|
|
|
|
super.initState(); |
|
|
|
} |
|
|
|
|
|
|
@@ -97,6 +110,7 @@ class _TeamPageContainerState extends State<_TeamPageContainer> { |
|
|
|
|
|
|
|
@override |
|
|
|
void dispose() { |
|
|
|
streamSubscription?.cancel(); |
|
|
|
_controller?.removeListener(_tabChangeListener); |
|
|
|
_controller?.dispose(); |
|
|
|
super.dispose(); |
|
|
@@ -104,9 +118,6 @@ class _TeamPageContainerState extends State<_TeamPageContainer> { |
|
|
|
|
|
|
|
/// 主体视图 |
|
|
|
Widget _getMainWidget(TeamStyleModel styleModel, TeamDataModel dataModel) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return Scaffold( |
|
|
|
resizeToAvoidBottomPadding: false, |
|
|
|
resizeToAvoidBottomInset: false, |
|
|
@@ -178,22 +189,20 @@ class _TeamPageContainerState extends State<_TeamPageContainer> { |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// 创建TabBarView |
|
|
|
List<Widget> _buildTabBarView(TeamStyleModel styleModel){ |
|
|
|
List<Widget> _buildTabBarView(TeamStyleModel styleModel) { |
|
|
|
List<Widget> lists = []; |
|
|
|
int length = styleModel?.userLvTabs?.length ?? 0; |
|
|
|
if(length > 0) { |
|
|
|
for (int i = 0; i < styleModel.userLvTabs.length; i ++) { |
|
|
|
if (length > 0) { |
|
|
|
for (int i = 0; i < styleModel.userLvTabs.length; i++) { |
|
|
|
UserLvTabs item = styleModel.userLvTabs[i]; |
|
|
|
lists.add(TeamFansWidget(styleModel, item.type, i)); |
|
|
|
} |
|
|
|
}else{ |
|
|
|
} else { |
|
|
|
lists.add(Container()); |
|
|
|
} |
|
|
|
return lists; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
class _SliverTabBarDelegate extends SliverPersistentHeaderDelegate { |
|
|
|