From 7a657ccb127d893607b6bda590c65205e8165f46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cyanghuaxuan=E2=80=9D?= <“646903573@qq.com”> Date: Tue, 11 May 2021 17:29:24 +0800 Subject: [PATCH] =?UTF-8?q?1.=E6=9B=B4=E6=96=B0=E6=B3=A8=E5=86=8C=E5=90=8E?= =?UTF-8?q?=E6=94=BE=E5=9C=A8=E5=BA=95=E9=83=A8=E5=AF=BC=E8=88=AA=E6=A0=8F?= =?UTF-8?q?=E7=9A=84=E6=88=91=E7=9A=84=E5=9B=A2=E9=98=9F=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E4=B8=8D=E4=BC=9A=E5=88=B7=E6=96=B0=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/pages/team_page/team_page.dart | 35 ++++++++++++------- .../team/appbar/team_app_bar_widget.dart | 22 ++++++------ 2 files changed, 33 insertions(+), 24 deletions(-) diff --git a/lib/pages/team_page/team_page.dart b/lib/pages/team_page/team_page.dart index 7d707c3..c5dd1e7 100644 --- a/lib/pages/team_page/team_page.dart +++ b/lib/pages/team_page/team_page.dart @@ -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( create: (_) => TeamBloc(repository: TeamRepository())..add(TeamInitEvent(data)), - child: _TeamPageContainer(), + child: _TeamPageContainer( + data: data, + ), ), ); } } class _TeamPageContainer extends StatefulWidget { + final Map 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(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().listen((event) { + BlocProvider.of(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 _buildTabBarView(TeamStyleModel styleModel){ + List _buildTabBarView(TeamStyleModel styleModel) { List 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 { diff --git a/lib/widgets/team/appbar/team_app_bar_widget.dart b/lib/widgets/team/appbar/team_app_bar_widget.dart index e1e39c4..bb58675 100644 --- a/lib/widgets/team/appbar/team_app_bar_widget.dart +++ b/lib/widgets/team/appbar/team_app_bar_widget.dart @@ -1,27 +1,27 @@ - import 'package:flutter/material.dart'; import 'package:zhiying_base_widget/pages/team_page/model/team_style_model.dart'; import 'package:zhiying_comm/zhiying_comm.dart'; class TeamAppBarWidget extends StatelessWidget { - TeamStyleModel model; + TeamAppBarWidget(this.model); @override Widget build(BuildContext context) { - return SliverAppBar( // expandedHeight: 200.0, brightness: Brightness.light, - leading: IconButton( - icon: Icon( - Icons.arrow_back_ios, - size: 22, - color: HexColor.fromHex('#333333'), - ), - onPressed: () => Navigator.maybePop(context), - ), + leading: Navigator.canPop(context) + ? IconButton( + icon: Icon( + Icons.arrow_back_ios, + size: 22, + color: HexColor.fromHex('#333333'), + ), + onPressed: () => Navigator.maybePop(context), + ) + : Container(), backgroundColor: HexColor.fromHex(model?.appBarBgColor ?? '#FFFFFF'), floating: true, pinned: true,