Browse Source

1.更新注册后放在底部导航栏的我的团队数据不会刷新的问题

tags/0.0.16+7
“yanghuaxuan” 3 years ago
parent
commit
7a657ccb12
2 changed files with 33 additions and 24 deletions
  1. +22
    -13
      lib/pages/team_page/team_page.dart
  2. +11
    -11
      lib/widgets/team/appbar/team_app_bar_widget.dart

+ 22
- 13
lib/pages/team_page/team_page.dart View File

@@ -1,3 +1,6 @@
import 'dart:async';

import 'package:event_bus/event_bus.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:tab_indicator_styler/tab_indicator_styler.dart'; import 'package:tab_indicator_styler/tab_indicator_styler.dart';
@@ -36,22 +39,28 @@ class TeamPage extends StatelessWidget {
], ],
child: BlocProvider<TeamBloc>( child: BlocProvider<TeamBloc>(
create: (_) => TeamBloc(repository: TeamRepository())..add(TeamInitEvent(data)), create: (_) => TeamBloc(repository: TeamRepository())..add(TeamInitEvent(data)),
child: _TeamPageContainer(),
child: _TeamPageContainer(
data: data,
),
), ),
); );
} }
} }


class _TeamPageContainer extends StatefulWidget { class _TeamPageContainer extends StatefulWidget {
final Map<String, dynamic> data;

const _TeamPageContainer({Key key, this.data}) : super(key: key);

@override @override
_TeamPageContainerState createState() => _TeamPageContainerState(); _TeamPageContainerState createState() => _TeamPageContainerState();
} }


class _TeamPageContainerState extends State<_TeamPageContainer> { class _TeamPageContainerState extends State<_TeamPageContainer> {

TabController _controller; TabController _controller;

// TabController 监听 // TabController 监听
void _tabChangeListener(){
void _tabChangeListener() {
if (!_controller.indexIsChanging) { if (!_controller.indexIsChanging) {
Provider.of<TeamPageNotifier>(context, listen: false).updateTabIndex(_controller?.index ?? 0); Provider.of<TeamPageNotifier>(context, listen: false).updateTabIndex(_controller?.index ?? 0);
} }
@@ -80,11 +89,15 @@ class _TeamPageContainerState extends State<_TeamPageContainer> {
); );
} }


StreamSubscription streamSubscription;


@override @override
void initState() { void initState() {
// _controller = TabController(length: tabTitle.length, vsync: ScrollableState()); // _controller = TabController(length: tabTitle.length, vsync: ScrollableState());
streamSubscription = EventUtil.instance.on<LoginSuccessEvent>().listen((event) {
BlocProvider.of<TeamBloc>(context).add(TeamInitEvent(widget?.data));
});

super.initState(); super.initState();
} }


@@ -97,6 +110,7 @@ class _TeamPageContainerState extends State<_TeamPageContainer> {


@override @override
void dispose() { void dispose() {
streamSubscription?.cancel();
_controller?.removeListener(_tabChangeListener); _controller?.removeListener(_tabChangeListener);
_controller?.dispose(); _controller?.dispose();
super.dispose(); super.dispose();
@@ -104,9 +118,6 @@ class _TeamPageContainerState extends State<_TeamPageContainer> {


/// 主体视图 /// 主体视图
Widget _getMainWidget(TeamStyleModel styleModel, TeamDataModel dataModel) { Widget _getMainWidget(TeamStyleModel styleModel, TeamDataModel dataModel) {



return Scaffold( return Scaffold(
resizeToAvoidBottomPadding: false, resizeToAvoidBottomPadding: false,
resizeToAvoidBottomInset: false, resizeToAvoidBottomInset: false,
@@ -178,22 +189,20 @@ class _TeamPageContainerState extends State<_TeamPageContainer> {
); );
} }



/// 创建TabBarView /// 创建TabBarView
List<Widget> _buildTabBarView(TeamStyleModel styleModel){
List<Widget> _buildTabBarView(TeamStyleModel styleModel) {
List<Widget> lists = []; List<Widget> lists = [];
int length = styleModel?.userLvTabs?.length ?? 0; 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]; UserLvTabs item = styleModel.userLvTabs[i];
lists.add(TeamFansWidget(styleModel, item.type, i)); lists.add(TeamFansWidget(styleModel, item.type, i));
} }
}else{
} else {
lists.add(Container()); lists.add(Container());
} }
return lists; return lists;
} }

} }


class _SliverTabBarDelegate extends SliverPersistentHeaderDelegate { class _SliverTabBarDelegate extends SliverPersistentHeaderDelegate {


+ 11
- 11
lib/widgets/team/appbar/team_app_bar_widget.dart View File

@@ -1,27 +1,27 @@

import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:zhiying_base_widget/pages/team_page/model/team_style_model.dart'; import 'package:zhiying_base_widget/pages/team_page/model/team_style_model.dart';
import 'package:zhiying_comm/zhiying_comm.dart'; import 'package:zhiying_comm/zhiying_comm.dart';


class TeamAppBarWidget extends StatelessWidget { class TeamAppBarWidget extends StatelessWidget {

TeamStyleModel model; TeamStyleModel model;

TeamAppBarWidget(this.model); TeamAppBarWidget(this.model);


@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {

return SliverAppBar( return SliverAppBar(
// expandedHeight: 200.0, // expandedHeight: 200.0,
brightness: Brightness.light, 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'), backgroundColor: HexColor.fromHex(model?.appBarBgColor ?? '#FFFFFF'),
floating: true, floating: true,
pinned: true, pinned: true,


Loading…
Cancel
Save