@@ -6,6 +6,7 @@ import 'package:pull_to_refresh/pull_to_refresh.dart'; | |||||
import 'package:provider/provider.dart'; | import 'package:provider/provider.dart'; | ||||
import 'package:flutter_bloc/flutter_bloc.dart'; | import 'package:flutter_bloc/flutter_bloc.dart'; | ||||
import 'package:zhiying_base_widget/pages/main_page/notifier/main_page_notifier.dart'; | import 'package:zhiying_base_widget/pages/main_page/notifier/main_page_notifier.dart'; | ||||
import 'package:zhiying_base_widget/widgets/base_state/base_state.dart'; | |||||
import 'package:zhiying_base_widget/widgets/custom/bottom_pic/bottom_pic.dart'; | import 'package:zhiying_base_widget/widgets/custom/bottom_pic/bottom_pic.dart'; | ||||
import 'package:zhiying_base_widget/widgets/empty/empty_widget.dart'; | import 'package:zhiying_base_widget/widgets/empty/empty_widget.dart'; | ||||
import 'package:zhiying_base_widget/widgets/home/home_auth/home_auth.dart'; | import 'package:zhiying_base_widget/widgets/home/home_auth/home_auth.dart'; | ||||
@@ -66,7 +67,7 @@ class _CustomItemPageContainer extends StatefulWidget { | |||||
__CustomItemPageContainerState createState() => __CustomItemPageContainerState(); | __CustomItemPageContainerState createState() => __CustomItemPageContainerState(); | ||||
} | } | ||||
class __CustomItemPageContainerState extends State<_CustomItemPageContainer> with AutomaticKeepAliveClientMixin { | |||||
class __CustomItemPageContainerState extends BasePageState<_CustomItemPageContainer> { | |||||
@override | @override | ||||
bool get wantKeepAlive => true; | bool get wantKeepAlive => true; | ||||
@@ -88,6 +89,10 @@ class __CustomItemPageContainerState extends State<_CustomItemPageContainer> wit | |||||
/// 刷新 | /// 刷新 | ||||
void _refreshEvent() { | void _refreshEvent() { | ||||
BlocProvider.of<CustomItemPageBloc>(context).add(CustomItemPageRefreshEvent()); | BlocProvider.of<CustomItemPageBloc>(context).add(CustomItemPageRefreshEvent()); | ||||
///刷新页面 | |||||
refreshPage(); | |||||
} | } | ||||
/// 下拉更多 | /// 下拉更多 | ||||
@@ -120,7 +125,7 @@ class __CustomItemPageContainerState extends State<_CustomItemPageContainer> wit | |||||
} | } | ||||
@override | @override | ||||
Widget build(BuildContext context) { | |||||
Widget buildX(BuildContext context) { | |||||
return BlocConsumer<CustomItemPageBloc, CustomItemPageState>( | return BlocConsumer<CustomItemPageBloc, CustomItemPageState>( | ||||
listener: (context, state) {}, | listener: (context, state) {}, | ||||
buildWhen: (prev, current) { | buildWhen: (prev, current) { | ||||
@@ -8,6 +8,7 @@ import 'package:pull_to_refresh/pull_to_refresh.dart'; | |||||
import 'package:zhiying_base_widget/pages/main_page/main_page_bloc.dart'; | import 'package:zhiying_base_widget/pages/main_page/main_page_bloc.dart'; | ||||
import 'package:zhiying_base_widget/pages/main_page/notifier/main_page_bg_notifier.dart'; | import 'package:zhiying_base_widget/pages/main_page/notifier/main_page_bg_notifier.dart'; | ||||
import 'package:zhiying_base_widget/pages/main_page/notifier/main_page_notifier.dart'; | import 'package:zhiying_base_widget/pages/main_page/notifier/main_page_notifier.dart'; | ||||
import 'package:zhiying_base_widget/widgets/base_state/base_state.dart'; | |||||
import 'package:zhiying_base_widget/widgets/home/home_auth/home_auth.dart'; | import 'package:zhiying_base_widget/widgets/home/home_auth/home_auth.dart'; | ||||
import 'package:zhiying_base_widget/widgets/mine/mine_nav/mine_nav_bg.dart'; | import 'package:zhiying_base_widget/widgets/mine/mine_nav/mine_nav_bg.dart'; | ||||
import 'package:zhiying_base_widget/widgets/others/mine_header_bg_widget.dart'; | import 'package:zhiying_base_widget/widgets/others/mine_header_bg_widget.dart'; | ||||
@@ -53,7 +54,7 @@ class _MainPageContainer extends StatefulWidget { | |||||
_MainPageContainerState createState() => _MainPageContainerState(); | _MainPageContainerState createState() => _MainPageContainerState(); | ||||
} | } | ||||
class _MainPageContainerState extends State<_MainPageContainer> { | |||||
class _MainPageContainerState extends BasePageState<_MainPageContainer> { | |||||
bool _isEnded = false; | bool _isEnded = false; | ||||
ScrollController _controller = ScrollController(); | ScrollController _controller = ScrollController(); | ||||
MainPageBloc _bloc; | MainPageBloc _bloc; | ||||
@@ -73,6 +74,7 @@ class _MainPageContainerState extends State<_MainPageContainer> { | |||||
if (widget.data.containsKey('skip_identifier')) { | if (widget.data.containsKey('skip_identifier')) { | ||||
_bloc.loadData(widget.data['skip_identifier']); | _bloc.loadData(widget.data['skip_identifier']); | ||||
refreshPage(); | |||||
} | } | ||||
} | } | ||||
@@ -106,7 +108,7 @@ class _MainPageContainerState extends State<_MainPageContainer> { | |||||
} | } | ||||
@override | @override | ||||
Widget build(BuildContext context) { | |||||
Widget buildX(BuildContext context) { | |||||
double top = MediaQueryData.fromWindow(window).padding.top; | double top = MediaQueryData.fromWindow(window).padding.top; | ||||
return StreamBuilder<List<Map<String, dynamic>>>( | return StreamBuilder<List<Map<String, dynamic>>>( | ||||
stream: _bloc.outData, | stream: _bloc.outData, | ||||
@@ -185,9 +187,6 @@ class _MainPageContainerState extends State<_MainPageContainer> { | |||||
///处理特殊背景图 | ///处理特殊背景图 | ||||
Widget validateBgWidget(BuildContext context, List<Map<String, dynamic>> datas) { | Widget validateBgWidget(BuildContext context, List<Map<String, dynamic>> datas) { | ||||
for (int i = 0; i < datas.length; i++) { | for (int i = 0; i < datas.length; i++) { | ||||
WidgetModel item = WidgetModel.fromJson(Map<String, dynamic>.from(datas[i])); | WidgetModel item = WidgetModel.fromJson(Map<String, dynamic>.from(datas[i])); | ||||
if (item.modName == "profile_background") { | if (item.modName == "profile_background") { | ||||
@@ -221,7 +220,7 @@ class _MainPageContainerState extends State<_MainPageContainer> { | |||||
if (_bloc.backgroundModel != null) { | if (_bloc.backgroundModel != null) { | ||||
var headerBg = _bloc.backgroundModel.headerBg; | var headerBg = _bloc.backgroundModel.headerBg; | ||||
return Container( | return Container( | ||||
height: double.tryParse(_bloc?.backgroundModel?.headerBg?.height)?? 0, | |||||
height: double.tryParse(_bloc?.backgroundModel?.headerBg?.height) ?? 0, | |||||
decoration: BoxDecoration( | decoration: BoxDecoration( | ||||
gradient: LinearGradient( | gradient: LinearGradient( | ||||
begin: Alignment.topCenter, | begin: Alignment.topCenter, | ||||
@@ -5,6 +5,7 @@ import 'package:pull_to_refresh/pull_to_refresh.dart'; | |||||
import 'package:zhiying_base_widget/pages/main_page/notifier/main_page_bg_notifier.dart'; | import 'package:zhiying_base_widget/pages/main_page/notifier/main_page_bg_notifier.dart'; | ||||
import 'package:zhiying_base_widget/pages/main_page/notifier/main_page_notifier.dart'; | import 'package:zhiying_base_widget/pages/main_page/notifier/main_page_notifier.dart'; | ||||
import 'package:zhiying_base_widget/utils/contants.dart'; | import 'package:zhiying_base_widget/utils/contants.dart'; | ||||
import 'package:zhiying_base_widget/widgets/base_state/base_state.dart'; | |||||
import 'package:zhiying_base_widget/widgets/hot_ranking/hot_ranking_list/model/hot_ranking_list_model.dart'; | import 'package:zhiying_base_widget/widgets/hot_ranking/hot_ranking_list/model/hot_ranking_list_model.dart'; | ||||
import 'package:zhiying_base_widget/widgets/refresh/refresh_header/refresh_header.dart'; | import 'package:zhiying_base_widget/widgets/refresh/refresh_header/refresh_header.dart'; | ||||
import 'package:zhiying_base_widget/widgets/wallet/wallet_appbar/wallet_appbar_sk.dart'; | import 'package:zhiying_base_widget/widgets/wallet/wallet_appbar/wallet_appbar_sk.dart'; | ||||
@@ -28,22 +29,19 @@ class WalletPage extends StatefulWidget { | |||||
_WalletPageState createState() => _WalletPageState(); | _WalletPageState createState() => _WalletPageState(); | ||||
} | } | ||||
class _WalletPageState extends State<WalletPage> { | |||||
class _WalletPageState extends BasePageState<WalletPage> { | |||||
@override | @override | ||||
Widget build(BuildContext context) { | |||||
Widget buildX(BuildContext context) { | |||||
return Scaffold( | return Scaffold( | ||||
backgroundColor: Color(0xfff9f9f9), | backgroundColor: Color(0xfff9f9f9), | ||||
body: MultiProvider( | |||||
providers: [ | |||||
ChangeNotifierProvider.value(value: BaseChangeNotifier()), | |||||
], | |||||
child: BlocProvider<WalletPageBloc>( | |||||
body: BlocProvider<WalletPageBloc>( | |||||
bloc: WalletPageBloc(), | bloc: WalletPageBloc(), | ||||
child: _WalletPageContainer( | child: _WalletPageContainer( | ||||
data: widget.data, | data: widget.data, | ||||
), | ), | ||||
), | ), | ||||
), | |||||
); | ); | ||||
} | } | ||||
} | } | ||||
@@ -103,7 +101,6 @@ class _WalletPageContainerState extends State<_WalletPageContainer> | |||||
void _onRefresh() async { | void _onRefresh() async { | ||||
if (widget.data.containsKey(Constants.SkipIdentifierName)) { | if (widget.data.containsKey(Constants.SkipIdentifierName)) { | ||||
_pageBloc.loadData(widget.data[Constants.SkipIdentifierName]); | _pageBloc.loadData(widget.data[Constants.SkipIdentifierName]); | ||||
Provider.of<BaseChangeNotifier>(context,listen: false).refresh(); | |||||
} | } | ||||
} | } | ||||
@@ -0,0 +1,56 @@ | |||||
import 'package:flutter/material.dart'; | |||||
import 'package:provider/provider.dart'; | |||||
import 'package:zhiying_comm/zhiying_comm.dart'; | |||||
import 'package:zhiying_comm/util/base_bloc.dart'; | |||||
///每个页面顶层使用这个状态 | |||||
abstract class BasePageState<T extends StatefulWidget> extends State<T> { | |||||
// Widget build(BuildContext context) { | |||||
// return MultiProvider(providers: [ | |||||
// ChangeNotifierProvider.value(value: BaseChangeNotifier()), | |||||
// ], child: child); | |||||
// } | |||||
BaseChangeNotifier baseChangeNotifier; | |||||
@override | |||||
Widget build(BuildContext context) { | |||||
if(baseChangeNotifier==null){ | |||||
baseChangeNotifier = BaseChangeNotifier(); | |||||
} | |||||
return MultiProvider(providers: [ | |||||
ChangeNotifierProvider.value(value: baseChangeNotifier), | |||||
], child: buildX(context)); | |||||
} | |||||
Widget buildX(BuildContext context); | |||||
///刷新,所继承的子类调用此方法可刷新子组件 | |||||
void refreshPage() { | |||||
baseChangeNotifier.refresh(); | |||||
} | |||||
} | |||||
///每个需要刷新的小组件使用这个状态 | |||||
abstract class BaseWidgetState<T extends StatefulWidget> extends State<T> { | |||||
RefreshListener refreshListener = RefreshListener(); | |||||
@override | |||||
void didChangeDependencies() { | |||||
refreshListener.listen(context, (value) { | |||||
print("刷新子控件"); | |||||
refreshWidget(value); | |||||
}); | |||||
super.didChangeDependencies(); | |||||
} | |||||
@override | |||||
void dispose() { | |||||
//refreshListener?.close(); | |||||
super.dispose(); | |||||
} | |||||
void refreshWidget(String value); | |||||
} |
@@ -4,6 +4,7 @@ import 'package:flutter/cupertino.dart'; | |||||
import 'package:flutter/material.dart'; | import 'package:flutter/material.dart'; | ||||
import 'package:flutter_bloc/flutter_bloc.dart'; | import 'package:flutter_bloc/flutter_bloc.dart'; | ||||
import 'package:flutter_swiper/flutter_swiper.dart'; | import 'package:flutter_swiper/flutter_swiper.dart'; | ||||
import 'package:zhiying_base_widget/widgets/base_state/base_state.dart'; | |||||
import 'package:zhiying_comm/zhiying_comm.dart'; | import 'package:zhiying_comm/zhiying_comm.dart'; | ||||
import 'package:cached_network_image/cached_network_image.dart'; | import 'package:cached_network_image/cached_network_image.dart'; | ||||
import 'custom_quick_entry_sk.dart'; | import 'custom_quick_entry_sk.dart'; | ||||
@@ -35,7 +36,7 @@ class _CustomQuickEntryContainer extends StatefulWidget { | |||||
__CustomQuickEntryContainerState createState() => __CustomQuickEntryContainerState(); | __CustomQuickEntryContainerState createState() => __CustomQuickEntryContainerState(); | ||||
} | } | ||||
class __CustomQuickEntryContainerState extends State<_CustomQuickEntryContainer> with TickerProviderStateMixin, AutomaticKeepAliveClientMixin { | |||||
class __CustomQuickEntryContainerState extends BaseWidgetState<_CustomQuickEntryContainer> with TickerProviderStateMixin, AutomaticKeepAliveClientMixin { | |||||
/// Icon点击事件 | /// Icon点击事件 | ||||
void _itemIconClick(ListStyle model) { | void _itemIconClick(ListStyle model) { | ||||
print("item type = ${model.skipIdentifier}"); | print("item type = ${model.skipIdentifier}"); | ||||
@@ -48,7 +49,7 @@ class __CustomQuickEntryContainerState extends State<_CustomQuickEntryContainer> | |||||
@override | @override | ||||
void initState() { | void initState() { | ||||
_controller = SwiperController(); | _controller = SwiperController(); | ||||
print(widget?.model); | |||||
super.initState(); | super.initState(); | ||||
} | } | ||||
@@ -220,7 +221,6 @@ class __CustomQuickEntryContainerState extends State<_CustomQuickEntryContainer> | |||||
), | ), | ||||
), | ), | ||||
) | ) | ||||
], | ], | ||||
), | ), | ||||
), | ), | ||||
@@ -350,10 +350,11 @@ class __CustomQuickEntryContainerState extends State<_CustomQuickEntryContainer> | |||||
width: 40, | width: 40, | ||||
), | ), | ||||
), | ), | ||||
/// 小角标 | /// 小角标 | ||||
Visibility( | Visibility( | ||||
visible: model?.isShowCornerIcon == '1', | visible: model?.isShowCornerIcon == '1', | ||||
child: Align(alignment: Alignment.topRight, child: Transform.translate( offset: Offset(7, -3) ,child: MyNetWorkImage(item?.rightIcon, width: 34)))) | |||||
child: Align(alignment: Alignment.topRight, child: Transform.translate(offset: Offset(7, -3), child: MyNetWorkImage(item?.rightIcon, width: 34)))) | |||||
], | ], | ||||
), | ), | ||||
@@ -405,7 +406,8 @@ class __CustomQuickEntryContainerState extends State<_CustomQuickEntryContainer> | |||||
SwiperPagination _swiperPaginationDot(CustomQuickEntryModel model) { | SwiperPagination _swiperPaginationDot(CustomQuickEntryModel model) { | ||||
return SwiperPagination( | return SwiperPagination( | ||||
margin: const EdgeInsets.only(), | margin: const EdgeInsets.only(), | ||||
builder: DotSwiperPaginationBuilder(color: HexColor.fromHex(model?.paginationUnselectColor), activeColor: HexColor.fromHex(model?.paginationSelectColor), size: 8, activeSize: 8)); | |||||
builder: DotSwiperPaginationBuilder( | |||||
color: HexColor.fromHex(model?.paginationUnselectColor), activeColor: HexColor.fromHex(model?.paginationSelectColor), size: 8, activeSize: 8)); | |||||
} | } | ||||
// 自定义进度条 条形 | // 自定义进度条 条形 | ||||
@@ -448,6 +450,11 @@ class __CustomQuickEntryContainerState extends State<_CustomQuickEntryContainer> | |||||
@override | @override | ||||
// TODO: implement wantKeepAlive | // TODO: implement wantKeepAlive | ||||
bool get wantKeepAlive => true; | bool get wantKeepAlive => true; | ||||
@override | |||||
void refreshWidget(String value) { | |||||
setState(() {}); | |||||
} | |||||
} | } | ||||
/// | /// | ||||
@@ -476,7 +483,7 @@ class CustomQuickCateEntry extends StatefulWidget { | |||||
_CustomQuickCateEntryState createState() => _CustomQuickCateEntryState(); | _CustomQuickCateEntryState createState() => _CustomQuickCateEntryState(); | ||||
} | } | ||||
class _CustomQuickCateEntryState extends State<CustomQuickCateEntry> with TickerProviderStateMixin, AutomaticKeepAliveClientMixin { | |||||
class _CustomQuickCateEntryState extends BaseWidgetState<CustomQuickCateEntry> with TickerProviderStateMixin, AutomaticKeepAliveClientMixin { | |||||
TabController tabController; | TabController tabController; | ||||
bool isOnTap = false; | bool isOnTap = false; | ||||
@@ -858,7 +865,6 @@ class _CustomQuickCateEntryState extends State<CustomQuickCateEntry> with Ticker | |||||
child: Column( | child: Column( | ||||
crossAxisAlignment: CrossAxisAlignment.center, | crossAxisAlignment: CrossAxisAlignment.center, | ||||
children: <Widget>[ | children: <Widget>[ | ||||
Stack( | Stack( | ||||
children: [ | children: [ | ||||
/// 图标 | /// 图标 | ||||
@@ -868,10 +874,11 @@ class _CustomQuickCateEntryState extends State<CustomQuickCateEntry> with Ticker | |||||
width: 40, | width: 40, | ||||
), | ), | ||||
), | ), | ||||
/// 小角标 | /// 小角标 | ||||
Visibility( | Visibility( | ||||
visible: model?.isShowCornerIcon == '1', | |||||
child: Align(alignment: Alignment.topRight, child: Transform.translate( offset: Offset(7, -3) ,child: MyNetWorkImage(item?.rightIcon, width: 34)))) | |||||
visible: model?.isShowCornerIcon == '1', | |||||
child: Align(alignment: Alignment.topRight, child: Transform.translate(offset: Offset(7, -3), child: MyNetWorkImage(item?.rightIcon, width: 34)))) | |||||
], | ], | ||||
), | ), | ||||
@@ -973,6 +980,11 @@ class _CustomQuickCateEntryState extends State<CustomQuickCateEntry> with Ticker | |||||
@override | @override | ||||
bool get wantKeepAlive => true; | bool get wantKeepAlive => true; | ||||
@override | |||||
void refreshWidget(String value) { | |||||
BlocProvider.of<CustomQuickEntryBloc>(context).add(CustomQuickEntryInitEvent(model: widget?.model?.toJson())); | |||||
} | |||||
} | } | ||||
class PageItem { | class PageItem { | ||||
@@ -1,4 +1,5 @@ | |||||
import 'package:flutter/material.dart'; | import 'package:flutter/material.dart'; | ||||
import 'package:zhiying_base_widget/widgets/base_state/base_state.dart'; | |||||
import 'package:zhiying_base_widget/widgets/mine/mine_data/mine_data_sk.dart'; | import 'package:zhiying_base_widget/widgets/mine/mine_data/mine_data_sk.dart'; | ||||
import 'package:zhiying_base_widget/widgets/mine/mine_data/mine_data_widget.dart'; | import 'package:zhiying_base_widget/widgets/mine/mine_data/mine_data_widget.dart'; | ||||
import 'package:zhiying_base_widget/widgets/mine/mine_header/mine_header_bloc.dart'; | import 'package:zhiying_base_widget/widgets/mine/mine_header/mine_header_bloc.dart'; | ||||
@@ -14,7 +15,7 @@ class MineDataContainer extends StatefulWidget { | |||||
_MineDataContainerState createState() => _MineDataContainerState(); | _MineDataContainerState createState() => _MineDataContainerState(); | ||||
} | } | ||||
class _MineDataContainerState extends State<MineDataContainer> { | |||||
class _MineDataContainerState extends BaseWidgetState<MineDataContainer> { | |||||
MineHeaderBloc _bloc; | MineHeaderBloc _bloc; | ||||
@override | @override | ||||
@@ -35,4 +36,11 @@ class _MineDataContainerState extends State<MineDataContainer> { | |||||
: MineDataWidget(profile, widget?.data); | : MineDataWidget(profile, widget?.data); | ||||
}); | }); | ||||
} | } | ||||
@override | |||||
void refreshWidget(String value) { | |||||
_bloc.loadData(); | |||||
} | |||||
} | } |
@@ -4,6 +4,7 @@ import 'package:cached_network_image/cached_network_image.dart'; | |||||
import 'package:flutter/material.dart'; | import 'package:flutter/material.dart'; | ||||
import 'package:flutter/services.dart'; | import 'package:flutter/services.dart'; | ||||
import 'package:fluttertoast/fluttertoast.dart'; | import 'package:fluttertoast/fluttertoast.dart'; | ||||
import 'package:zhiying_base_widget/widgets/base_state/base_state.dart'; | |||||
import 'package:zhiying_base_widget/widgets/mine/mine_header/mine_header_bloc.dart'; | import 'package:zhiying_base_widget/widgets/mine/mine_header/mine_header_bloc.dart'; | ||||
import 'package:zhiying_base_widget/widgets/mine/mine_header/mine_header_sk.dart'; | import 'package:zhiying_base_widget/widgets/mine/mine_header/mine_header_sk.dart'; | ||||
import 'package:zhiying_base_widget/widgets/mine/mine_header/model/mine_header_model.dart'; | import 'package:zhiying_base_widget/widgets/mine/mine_header/model/mine_header_model.dart'; | ||||
@@ -29,7 +30,7 @@ class MineHeaderContainer extends StatefulWidget { | |||||
_MineHeaderContainerState createState() => _MineHeaderContainerState(); | _MineHeaderContainerState createState() => _MineHeaderContainerState(); | ||||
} | } | ||||
class _MineHeaderContainerState extends State<MineHeaderContainer> { | |||||
class _MineHeaderContainerState extends BaseWidgetState<MineHeaderContainer> { | |||||
MineHeaderBloc _bloc; | MineHeaderBloc _bloc; | ||||
@override | @override | ||||
@@ -182,4 +183,9 @@ class _MineHeaderContainerState extends State<MineHeaderContainer> { | |||||
); | ); | ||||
}); | }); | ||||
} | } | ||||
@override | |||||
void refreshWidget(String value) { | |||||
_bloc?.loadData(); | |||||
} | |||||
} | } |
@@ -2,6 +2,7 @@ import 'dart:convert' as convert; | |||||
import 'package:cached_network_image/cached_network_image.dart'; | import 'package:cached_network_image/cached_network_image.dart'; | ||||
import 'package:flutter/material.dart'; | import 'package:flutter/material.dart'; | ||||
import 'package:zhiying_base_widget/widgets/base_state/base_state.dart'; | |||||
import 'package:zhiying_base_widget/widgets/mine/mine_header/model/mine_header_model.dart'; | import 'package:zhiying_base_widget/widgets/mine/mine_header/model/mine_header_model.dart'; | ||||
import 'package:zhiying_comm/zhiying_comm.dart'; | import 'package:zhiying_comm/zhiying_comm.dart'; | ||||
@@ -21,7 +22,7 @@ class MineStaticContainer extends StatefulWidget { | |||||
_MineStaticContainerState createState() => _MineStaticContainerState(); | _MineStaticContainerState createState() => _MineStaticContainerState(); | ||||
} | } | ||||
class _MineStaticContainerState extends State<MineStaticContainer> { | |||||
class _MineStaticContainerState extends BaseWidgetState<MineStaticContainer> { | |||||
@override | @override | ||||
Widget build(BuildContext context) { | Widget build(BuildContext context) { | ||||
return Container( | return Container( | ||||
@@ -32,15 +33,10 @@ class _MineStaticContainerState extends State<MineStaticContainer> { | |||||
margin: EdgeInsets.only(left: 20, top: 20, bottom: 20, right: 12), | margin: EdgeInsets.only(left: 20, top: 20, bottom: 20, right: 12), | ||||
width: 56, | width: 56, | ||||
height: 56, | height: 56, | ||||
child: ClipRRect( | |||||
borderRadius: BorderRadius.circular(28), | |||||
child: CachedNetworkImage( | |||||
imageUrl: widget.staticModel.nonLginAvatar, | |||||
fit: BoxFit.cover)), | |||||
child: ClipRRect(borderRadius: BorderRadius.circular(28), child: CachedNetworkImage(imageUrl: widget.staticModel.nonLginAvatar, fit: BoxFit.cover)), | |||||
), | ), | ||||
onTap: () { | onTap: () { | ||||
RouterUtil.route( | |||||
SkipModel.fromJson(widget.json), widget.json, context); | |||||
RouterUtil.route(SkipModel.fromJson(widget.json), widget.json, context); | |||||
}, | }, | ||||
), | ), | ||||
Expanded( | Expanded( | ||||
@@ -52,10 +48,7 @@ class _MineStaticContainerState extends State<MineStaticContainer> { | |||||
width: 120, | width: 120, | ||||
child: Text( | child: Text( | ||||
widget.staticModel.loginName, | widget.staticModel.loginName, | ||||
style: TextStyle( | |||||
color: HexColor.fromHex( | |||||
widget.staticModel?.userNameColor ?? '#ffffff'), | |||||
fontSize: 17), | |||||
style: TextStyle(color: HexColor.fromHex(widget.staticModel?.userNameColor ?? '#ffffff'), fontSize: 17), | |||||
), | ), | ||||
), | ), | ||||
Container( | Container( | ||||
@@ -63,10 +56,7 @@ class _MineStaticContainerState extends State<MineStaticContainer> { | |||||
width: 80, | width: 80, | ||||
child: Text( | child: Text( | ||||
widget.staticModel.loginNameHelpText, | widget.staticModel.loginNameHelpText, | ||||
style: TextStyle( | |||||
color: HexColor.fromHex( | |||||
widget.staticModel?.userNameColor ?? '#ffffff'), | |||||
fontSize: 13), | |||||
style: TextStyle(color: HexColor.fromHex(widget.staticModel?.userNameColor ?? '#ffffff'), fontSize: 13), | |||||
)), | )), | ||||
], | ], | ||||
)) | )) | ||||
@@ -74,4 +64,9 @@ class _MineStaticContainerState extends State<MineStaticContainer> { | |||||
), | ), | ||||
); | ); | ||||
} | } | ||||
@override | |||||
void refreshWidget(String value) { | |||||
setState(() {}); | |||||
} | |||||
} | } |
@@ -3,6 +3,7 @@ import 'dart:convert'; | |||||
import 'package:cached_network_image/cached_network_image.dart'; | import 'package:cached_network_image/cached_network_image.dart'; | ||||
import 'package:flutter/cupertino.dart'; | import 'package:flutter/cupertino.dart'; | ||||
import 'package:flutter/material.dart'; | import 'package:flutter/material.dart'; | ||||
import 'package:zhiying_base_widget/widgets/base_state/base_state.dart'; | |||||
import 'package:zhiying_base_widget/widgets/wallet/wallet_data/model/wallet_header_model.dart'; | import 'package:zhiying_base_widget/widgets/wallet/wallet_data/model/wallet_header_model.dart'; | ||||
import 'package:zhiying_base_widget/widgets/wallet/wallet_data/wallet_data_bloc.dart'; | import 'package:zhiying_base_widget/widgets/wallet/wallet_data/wallet_data_bloc.dart'; | ||||
import 'package:zhiying_base_widget/widgets/wallet/wallet_data/wallet_data_sk.dart'; | import 'package:zhiying_base_widget/widgets/wallet/wallet_data/wallet_data_sk.dart'; | ||||
@@ -18,7 +19,7 @@ class WalletData extends StatefulWidget { | |||||
_WalletDataState createState() => _WalletDataState(); | _WalletDataState createState() => _WalletDataState(); | ||||
} | } | ||||
class _WalletDataState extends State<WalletData> { | |||||
class _WalletDataState extends BaseWidgetState<WalletData> { | |||||
Map<String, dynamic> data; | Map<String, dynamic> data; | ||||
WalletDataBloc _bloc; | WalletDataBloc _bloc; | ||||
@@ -32,16 +33,6 @@ class _WalletDataState extends State<WalletData> { | |||||
_bloc.loadHeaderData(); | _bloc.loadHeaderData(); | ||||
} | } | ||||
@override | |||||
void didChangeDependencies() { | |||||
RefreshListener.listen(context, (event) { | |||||
_bloc.loadHeaderData(); | |||||
}); | |||||
super.didChangeDependencies(); | |||||
} | |||||
@override | @override | ||||
void dispose() { | void dispose() { | ||||
super.dispose(); | super.dispose(); | ||||
@@ -68,11 +59,7 @@ class _WalletDataState extends State<WalletData> { | |||||
: Container( | : Container( | ||||
margin: EdgeInsets.only(left: 12.5, right: 12.5, top: 10), | margin: EdgeInsets.only(left: 12.5, right: 12.5, top: 10), | ||||
padding: EdgeInsets.only(left: 18, right: 13), | padding: EdgeInsets.only(left: 18, right: 13), | ||||
decoration: BoxDecoration( | |||||
image: DecorationImage( | |||||
image: CachedNetworkImageProvider( | |||||
model?.headerImg ?? ""), | |||||
fit: BoxFit.fill)), | |||||
decoration: BoxDecoration(image: DecorationImage(image: CachedNetworkImageProvider(model?.headerImg ?? ""), fit: BoxFit.fill)), | |||||
height: 145, | height: 145, | ||||
child: Column( | child: Column( | ||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly, | mainAxisAlignment: MainAxisAlignment.spaceEvenly, | ||||
@@ -91,26 +78,17 @@ class _WalletDataState extends State<WalletData> { | |||||
Padding( | Padding( | ||||
padding: const EdgeInsets.all(8.0), | padding: const EdgeInsets.all(8.0), | ||||
child: Column( | child: Column( | ||||
crossAxisAlignment: | |||||
CrossAxisAlignment.start, | |||||
crossAxisAlignment: CrossAxisAlignment.start, | |||||
children: <Widget>[ | children: <Widget>[ | ||||
Text( | Text( | ||||
model?.headerCashOutText ?? "", | model?.headerCashOutText ?? "", | ||||
style: TextStyle( | |||||
fontSize: 12.5, | |||||
color: HexColor.fromHex( | |||||
model?.headerCashOutTextColor ?? | |||||
"")), | |||||
style: TextStyle(fontSize: 12.5, color: HexColor.fromHex(model?.headerCashOutTextColor ?? "")), | |||||
), | ), | ||||
Text( | Text( | ||||
dataModel.containsKey( | |||||
model.headerCashOutKey) | |||||
? dataModel[model.headerCashOutKey] | |||||
: "", | |||||
dataModel.containsKey(model.headerCashOutKey) ? dataModel[model.headerCashOutKey] : "", | |||||
style: TextStyle( | style: TextStyle( | ||||
fontSize: 20, | fontSize: 20, | ||||
color: HexColor.fromHex( | |||||
model.headerCashOutTextColor), | |||||
color: HexColor.fromHex(model.headerCashOutTextColor), | |||||
fontFamily: 'Din-Bold', | fontFamily: 'Din-Bold', | ||||
package: 'zhiying_comm', | package: 'zhiying_comm', | ||||
), | ), | ||||
@@ -122,28 +100,18 @@ class _WalletDataState extends State<WalletData> { | |||||
), | ), | ||||
GestureDetector( | GestureDetector( | ||||
onTap: () { | onTap: () { | ||||
RouterUtil.route( | |||||
model, model.toJson(), context); | |||||
RouterUtil.route(model, model.toJson(), context); | |||||
}, | }, | ||||
child: Container( | child: Container( | ||||
decoration: BoxDecoration( | decoration: BoxDecoration( | ||||
borderRadius: BorderRadius.circular(10), | borderRadius: BorderRadius.circular(10), | ||||
image: DecorationImage( | |||||
image: CachedNetworkImageProvider( | |||||
model.headerCashOutBtnImg ?? ''), | |||||
fit: BoxFit.fill), | |||||
image: DecorationImage(image: CachedNetworkImageProvider(model.headerCashOutBtnImg ?? ''), fit: BoxFit.fill), | |||||
), | ), | ||||
child: Padding( | child: Padding( | ||||
padding: EdgeInsets.only( | |||||
left: 14.5, | |||||
right: 14.5, | |||||
top: 10, | |||||
bottom: 10), | |||||
padding: EdgeInsets.only(left: 14.5, right: 14.5, top: 10, bottom: 10), | |||||
child: Text( | child: Text( | ||||
model.headerCashOutBtnText, | model.headerCashOutBtnText, | ||||
style: TextStyle( | |||||
color: HexColor.fromHex( | |||||
model.headerCashOutBtnTextColor)), | |||||
style: TextStyle(color: HexColor.fromHex(model.headerCashOutBtnTextColor)), | |||||
), | ), | ||||
), | ), | ||||
), | ), | ||||
@@ -153,9 +121,7 @@ class _WalletDataState extends State<WalletData> { | |||||
Divider( | Divider( | ||||
height: 1, | height: 1, | ||||
), | ), | ||||
Row( | |||||
mainAxisAlignment: MainAxisAlignment.spaceAround, | |||||
children: _buildTopListItem(model)) | |||||
Row(mainAxisAlignment: MainAxisAlignment.spaceAround, children: _buildTopListItem(model)) | |||||
], | ], | ||||
), | ), | ||||
)); | )); | ||||
@@ -171,23 +137,22 @@ class _WalletDataState extends State<WalletData> { | |||||
mainAxisSize: MainAxisSize.min, | mainAxisSize: MainAxisSize.min, | ||||
children: <Widget>[ | children: <Widget>[ | ||||
Text( | Text( | ||||
dataModel.containsKey(item.valueKey) | |||||
? dataModel[item.valueKey] | |||||
: "", | |||||
style: TextStyle( | |||||
color: HexColor.fromHex(item.valueColor), | |||||
fontSize: 15, | |||||
fontFamily: 'Din-Bold', | |||||
package: 'zhiying_comm'), | |||||
dataModel.containsKey(item.valueKey) ? dataModel[item.valueKey] : "", | |||||
style: TextStyle(color: HexColor.fromHex(item.valueColor), fontSize: 15, fontFamily: 'Din-Bold', package: 'zhiying_comm'), | |||||
), | ), | ||||
Text( | Text( | ||||
item.text, | item.text, | ||||
style: TextStyle( | |||||
color: HexColor.fromHex(item.textColor), fontSize: 11), | |||||
style: TextStyle(color: HexColor.fromHex(item.textColor), fontSize: 11), | |||||
), | ), | ||||
], | ], | ||||
)); | )); | ||||
} | } | ||||
return listWidget; | return listWidget; | ||||
} | } | ||||
@override | |||||
void refreshWidget(String value) { | |||||
_bloc.loadHeaderData(); | |||||
} | |||||
} | } |
@@ -43,9 +43,11 @@ class _WalletDetailState extends State<WalletDetail> with TickerProviderStateMix | |||||
super.initState(); | super.initState(); | ||||
} | } | ||||
RefreshListener refreshListener = RefreshListener(); | |||||
@override | @override | ||||
void didChangeDependencies() { | void didChangeDependencies() { | ||||
RefreshListener.listen(context, (event) { | |||||
refreshListener.listen(context, (event) { | |||||
if (event == "refresh") { | if (event == "refresh") { | ||||
if (_bloc.currentType == null) { | if (_bloc.currentType == null) { | ||||
_bloc.loadData(_model.providers[0].type, _bloc.selectDay); | _bloc.loadData(_model.providers[0].type, _bloc.selectDay); | ||||