@@ -680,7 +680,7 @@ | |||||
"languageVersion": "2.1" | "languageVersion": "2.1" | ||||
} | } | ||||
], | ], | ||||
"generated": "2020-09-08T07:00:40.458603Z", | |||||
"generated": "2020-09-10T07:09:00.863118Z", | |||||
"generator": "pub", | "generator": "pub", | ||||
"generatorVersion": "2.7.2" | "generatorVersion": "2.7.2" | ||||
} | } |
@@ -26,13 +26,6 @@ class _MainPageState extends State<MainPage> { | |||||
Widget build(BuildContext context) { | Widget build(BuildContext context) { | ||||
return Scaffold( | return Scaffold( | ||||
backgroundColor: Color(0xfff9f9f9), | backgroundColor: Color(0xfff9f9f9), | ||||
// body: ChangeNotifierProvider( | |||||
// create: (context) => MainPageNotifier(), | |||||
// child: BlocProvider<MainPageBloc>( | |||||
// bloc: MainPageBloc(), | |||||
// child: _MainPageContainer(widget.data), | |||||
// ), | |||||
// ), | |||||
body: MultiProvider( | body: MultiProvider( | ||||
providers: [ | providers: [ | ||||
ChangeNotifierProvider.value(value: MainPageNotifier()), | ChangeNotifierProvider.value(value: MainPageNotifier()), | ||||
@@ -141,7 +134,6 @@ class _MainPageContainerState extends State<_MainPageContainer> { | |||||
list.addAll(WidgetFactory.create( | list.addAll(WidgetFactory.create( | ||||
item.modName, | item.modName, | ||||
type: WidgetType.skeleton, | |||||
isSliver: true, | isSliver: true, | ||||
model: data, | model: data, | ||||
)); | )); | ||||
@@ -1,14 +1,120 @@ | |||||
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/pages/main_page/main_page.dart'; | |||||
class MinePage extends StatefulWidget { | class MinePage extends StatefulWidget { | ||||
@override | @override | ||||
_MinePageState createState() => _MinePageState(); | _MinePageState createState() => _MinePageState(); | ||||
} | } | ||||
class _MinePageState extends State<MinePage> { | |||||
class _MinePageState extends State<MinePage> with TickerProviderStateMixin { | |||||
TabController _tabController; | |||||
Map<String, dynamic> _datas = Map(); | |||||
@override | |||||
void initState() { | |||||
_tabController = TabController(length: 3, vsync: this); | |||||
// 模拟数据 | |||||
List<Map<String, dynamic>> list = List(); | |||||
list.add( | |||||
Map<String, dynamic>.from({'mod_name': 'index_search', 'mod_id': 5})); | |||||
list.add( | |||||
Map<String, dynamic>.from({'mod_name': 'index_carousel', 'mod_id': 6})); | |||||
list.add(Map<String, dynamic>.from({'mod_name': 'multi_nav', 'mod_id': 7})); | |||||
list.add(Map<String, dynamic>.from( | |||||
{'mod_name': 'index_banner_one', 'mod_id': 8})); | |||||
list.add(Map<String, dynamic>.from( | |||||
{'mod_name': 'index_banner_two', 'mod_id': 9})); | |||||
list.add(Map<String, dynamic>.from( | |||||
{'mod_name': 'index_recommend_list', 'mod_id': 10})); | |||||
_datas['components'] = list; | |||||
super.initState(); | |||||
} | |||||
@override | |||||
void dispose() { | |||||
_tabController.dispose(); | |||||
super.dispose(); | |||||
} | |||||
@override | @override | ||||
Widget build(BuildContext context) { | Widget build(BuildContext context) { | ||||
return Container(); | |||||
List<Widget> _silverBuilder(BuildContext context, bool innerBoxIsScrolled) { | |||||
return <Widget>[ | |||||
SliverAppBar(), | |||||
SliverPersistentHeader( | |||||
pinned: true, | |||||
delegate: _SilverAppBarDelegate( | |||||
Container( | |||||
color: Colors.amber, | |||||
child: TabBar( | |||||
labelColor: Colors.blue, | |||||
unselectedLabelColor: Colors.black, | |||||
controller: _tabController, | |||||
tabs: <Widget>[ | |||||
new Tab( | |||||
text: "tab10", | |||||
), | |||||
new Tab( | |||||
text: "tab2", | |||||
), | |||||
new Tab( | |||||
text: "tab3", | |||||
), | |||||
], | |||||
), | |||||
), | |||||
), | |||||
), | |||||
]; | |||||
} | |||||
return Scaffold( | |||||
body: SafeArea( | |||||
child: NestedScrollView( | |||||
headerSliverBuilder: _silverBuilder, | |||||
body: TabBarView( | |||||
controller: _tabController, | |||||
children: <Widget>[ | |||||
MainPage(_datas), | |||||
ListView.builder( | |||||
itemCount: 50, | |||||
itemBuilder: (context, count) { | |||||
return Container( | |||||
height: 50, | |||||
color: Colors.primaries[count % Colors.primaries.length], | |||||
child: Text('aaaaa ${count.toString()}'), | |||||
); | |||||
}), | |||||
MainPage(_datas), | |||||
], | |||||
), | |||||
)), | |||||
); | |||||
} | |||||
} | |||||
class _SilverAppBarDelegate extends SliverPersistentHeaderDelegate { | |||||
_SilverAppBarDelegate(this.child); | |||||
final Widget child; | |||||
@override | |||||
double get minExtent => 44; | |||||
@override | |||||
double get maxExtent => 44; | |||||
@override | |||||
Widget build( | |||||
BuildContext context, double shrinkOffset, bool overlapsContent) { | |||||
return new Container( | |||||
child: child, | |||||
); | |||||
} | |||||
@override | |||||
bool shouldRebuild(SliverPersistentHeaderDelegate oldDelegate) { | |||||
return false; | |||||
} | } | ||||
} | } |
@@ -0,0 +1,121 @@ | |||||
import 'package:flutter/cupertino.dart'; | |||||
import 'package:flutter/material.dart'; | |||||
import 'package:provider/provider.dart'; | |||||
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_notifier.dart'; | |||||
import 'package:zhiying_base_widget/widgets/others/mine_header_bg_widget.dart'; | |||||
import 'package:zhiying_comm/zhiying_comm.dart'; | |||||
class WalletPage extends StatefulWidget { | |||||
@override | |||||
_WalletPageState createState() => _WalletPageState(); | |||||
} | |||||
class _WalletPageState extends State<WalletPage> { | |||||
@override | |||||
Widget build(BuildContext context) { | |||||
return Scaffold( | |||||
backgroundColor: Color(0xfff9f9f9), | |||||
body: MultiProvider( | |||||
providers: [ | |||||
ChangeNotifierProvider.value(value: MainPageNotifier()), | |||||
ChangeNotifierProvider.value(value: MainPageBgNotifier()), | |||||
], | |||||
child: _WalletPageContainer(), | |||||
), | |||||
); | |||||
} | |||||
} | |||||
class _WalletPageContainer extends StatefulWidget { | |||||
_WalletPageContainer({Key key}) : super(key: key); | |||||
@override | |||||
_WalletPageContainerState createState() => _WalletPageContainerState(); | |||||
} | |||||
class _WalletPageContainerState extends State<_WalletPageContainer> { | |||||
final ScrollController _controller = ScrollController(); | |||||
final RefreshController _refreshController = | |||||
RefreshController(initialRefresh: false); | |||||
@override | |||||
void initState() { | |||||
super.initState(); | |||||
} | |||||
void _onLoading() async { | |||||
// await Future.delayed(Duration(milliseconds: 1000)); | |||||
// if (mounted) setState(() {}); | |||||
// _refreshController.loadComplete(); | |||||
} | |||||
@override | |||||
Widget build(BuildContext context) { | |||||
return SmartRefresher( | |||||
controller: _refreshController, | |||||
enablePullDown: false, | |||||
enablePullUp: false, | |||||
header: WaterDropHeader(), | |||||
onLoading: _onLoading, | |||||
child: Container( | |||||
width: double.infinity, | |||||
child: Stack( | |||||
fit: StackFit.passthrough, | |||||
children: <Widget>[ | |||||
MineHeaderBgWidget( | |||||
controller: _controller, | |||||
), | |||||
CustomScrollView( | |||||
slivers: _createContent(context), | |||||
), | |||||
Center( | |||||
child: FlatButton( | |||||
child: Text( | |||||
'aaaaaa', | |||||
style: TextStyle(color: Colors.black), | |||||
), | |||||
onPressed: () { | |||||
Provider.of<MainPageBgNotifier>(context, listen: false) | |||||
.switchBg(Container( | |||||
width: double.infinity, | |||||
height: 200, | |||||
color: Colors.purpleAccent, | |||||
)); | |||||
}, | |||||
), | |||||
) | |||||
], | |||||
), | |||||
), | |||||
); | |||||
} | |||||
List<Widget> _createContent(BuildContext context) { | |||||
List<Widget> list = List(); | |||||
list.addAll(WidgetFactory.create( | |||||
'normal_nav', | |||||
isSliver: true, | |||||
model: Map(), | |||||
)); | |||||
list.addAll(WidgetFactory.create( | |||||
'wallet_data', | |||||
isSliver: true, | |||||
model: Map(), | |||||
)); | |||||
list.addAll(WidgetFactory.create( | |||||
'wallet_detail', | |||||
isSliver: true, | |||||
model: Map(), | |||||
)); | |||||
list.addAll(WidgetFactory.create( | |||||
'wallet_income', | |||||
isSliver: true, | |||||
model: Map(), | |||||
)); | |||||
return list; | |||||
} | |||||
} |
@@ -0,0 +1,29 @@ | |||||
import 'dart:async'; | |||||
import 'package:zhiying_comm/util/base_bloc.dart'; | |||||
import 'package:zhiying_comm/zhiying_comm.dart'; | |||||
class WalletPageBloc extends BlocBase { | |||||
List<Map<String, dynamic>> _tabs = List(); | |||||
StreamController<List<Map<String, dynamic>>> _tabController = | |||||
StreamController<List<Map<String, dynamic>>>(); | |||||
Stream<List<Map<String, dynamic>>> get outData => _tabController.stream; | |||||
@override | |||||
void dispose() { | |||||
_tabController.close(); | |||||
_tabController = null; | |||||
} | |||||
void refresh() { | |||||
NetUtil.request('/api/v1/config.json', onSuccess: (data) { | |||||
List list = data; | |||||
_tabs = list.map((item) { | |||||
return Map<String, dynamic>.from(item); | |||||
}).toList(); | |||||
_tabController.add(_tabs); | |||||
}); | |||||
} | |||||
} |
@@ -0,0 +1,26 @@ | |||||
import 'dart:async'; | |||||
import 'package:zhiying_base_widget/pages/withdraw_page/withdraw_model.dart'; | |||||
import 'package:zhiying_comm/util/base_bloc.dart'; | |||||
import 'package:zhiying_comm/zhiying_comm.dart'; | |||||
class WithdrawBloc extends BlocBase { | |||||
WithdrawModel model; | |||||
StreamController<WithdrawModel> _dataController = | |||||
StreamController<WithdrawModel>(); | |||||
Stream<WithdrawModel> get outData => _dataController.stream; | |||||
@override | |||||
void dispose() { | |||||
_dataController.close(); | |||||
_dataController = null; | |||||
} | |||||
void refresh() { | |||||
NetUtil.request('/api/v1/config.json', onSuccess: (data) { | |||||
_dataController.add(model); | |||||
}); | |||||
} | |||||
} |
@@ -0,0 +1 @@ | |||||
class WithdrawModel {} |
@@ -0,0 +1,72 @@ | |||||
import 'package:flutter/cupertino.dart'; | |||||
import 'package:flutter/material.dart'; | |||||
/*提现页面*/ | |||||
class WithdrawPage extends StatefulWidget { | |||||
@override | |||||
_WithdrawPageState createState() => _WithdrawPageState(); | |||||
} | |||||
class _WithdrawPageState extends State<WithdrawPage> { | |||||
@override | |||||
Widget build(BuildContext context) { | |||||
return Scaffold( | |||||
appBar: _createNav(), | |||||
body: SafeArea( | |||||
child: _WithdrawContainer(), | |||||
), | |||||
); | |||||
} | |||||
// 导航栏 | |||||
Widget _createNav() { | |||||
return CupertinoNavigationBar( | |||||
leading: Navigator.canPop(context) | |||||
? GestureDetector( | |||||
child: Container( | |||||
padding: EdgeInsets.zero, | |||||
child: Icon( | |||||
Icons.arrow_back_ios, | |||||
size: 20, | |||||
), | |||||
), | |||||
onTap: () { | |||||
if (Navigator.canPop(context)) { | |||||
Navigator.pop(context); | |||||
} | |||||
}, | |||||
) | |||||
: Container(), | |||||
middle: Text( | |||||
'提现', | |||||
style: TextStyle( | |||||
fontSize: 15, | |||||
color: Color(0xff333333), | |||||
), | |||||
), | |||||
trailing: GestureDetector( | |||||
child: Text( | |||||
'明细', | |||||
style: TextStyle(fontSize: 13, color: Color(0xff333333)), | |||||
), | |||||
onTap: () {}, | |||||
), | |||||
); | |||||
} | |||||
} | |||||
class _WithdrawContainer extends StatefulWidget { | |||||
@override | |||||
_WithdrawContainerState createState() => _WithdrawContainerState(); | |||||
} | |||||
class _WithdrawContainerState extends State<_WithdrawContainer> { | |||||
@override | |||||
Widget build(BuildContext context) { | |||||
return SingleChildScrollView( | |||||
child: Column( | |||||
children: <Widget>[], | |||||
), | |||||
); | |||||
} | |||||
} |
@@ -1,11 +1,16 @@ | |||||
import 'package:zhiying_base_widget/pages/home_page/home_page.dart'; | import 'package:zhiying_base_widget/pages/home_page/home_page.dart'; | ||||
import 'package:zhiying_base_widget/pages/login_page/login_page.dart'; | import 'package:zhiying_base_widget/pages/login_page/login_page.dart'; | ||||
import 'package:zhiying_base_widget/pages/main_page/main_page.dart'; | import 'package:zhiying_base_widget/pages/main_page/main_page.dart'; | ||||
import 'package:zhiying_base_widget/widgets/home_banner/home_banner_creater.dart'; | |||||
import 'package:zhiying_base_widget/widgets/home_goods/home_goods_creater.dart'; | |||||
import 'package:zhiying_base_widget/widgets/home_quick_entry/home_quick_entry_creater.dart'; | |||||
import 'package:zhiying_base_widget/widgets/home_slide_banner/home_slide_banner_creater.dart'; | |||||
import 'package:zhiying_base_widget/widgets/mine_header/mine_header_creater.dart'; | |||||
import 'package:zhiying_base_widget/pages/wallet_page/wallet_page.dart'; | |||||
import 'package:zhiying_base_widget/widgets/home/home_banner/home_banner_creater.dart'; | |||||
import 'package:zhiying_base_widget/widgets/home/home_goods/home_goods_creater.dart'; | |||||
import 'package:zhiying_base_widget/widgets/home/home_quick_entry/home_quick_entry_creater.dart'; | |||||
import 'package:zhiying_base_widget/widgets/home/home_slide_banner/home_slide_banner_creater.dart'; | |||||
import 'package:zhiying_base_widget/widgets/mine/mine_header/mine_header.dart'; | |||||
import 'package:zhiying_base_widget/widgets/others/normal_nav/normal_nav_creater.dart'; | |||||
import 'package:zhiying_base_widget/widgets/wallet/wallet_data/wallet_data.dart'; | |||||
import 'package:zhiying_base_widget/widgets/wallet/wallet_detail/wallet_detail.dart'; | |||||
import 'package:zhiying_base_widget/widgets/wallet/wallet_income/wallet_income.dart'; | |||||
import 'package:zhiying_comm/zhiying_comm.dart'; | import 'package:zhiying_comm/zhiying_comm.dart'; | ||||
class BaseWidgetRegister { | class BaseWidgetRegister { | ||||
@@ -20,10 +25,15 @@ class BaseWidgetRegister { | |||||
PageFactory.regist('homePage', (model) => HomePage()); | PageFactory.regist('homePage', (model) => HomePage()); | ||||
PageFactory.regist('index', (model) => MainPage(model)); | PageFactory.regist('index', (model) => MainPage(model)); | ||||
PageFactory.regist('login', (model) => LoginPage(model)); | PageFactory.regist('login', (model) => LoginPage(model)); | ||||
PageFactory.regist('category', (model) => WalletPage()); | |||||
} | } | ||||
// 注册控件 | // 注册控件 | ||||
static void registWidgets() { | static void registWidgets() { | ||||
// ==================== 通用组件 | |||||
// 导航栏 | |||||
WidgetFactory.regist('normal_nav', NormalNavCreater()); | |||||
// ==================== 首页 | // ==================== 首页 | ||||
/// 可滚动banner | /// 可滚动banner | ||||
WidgetFactory.regist('index_carousel', HomeSlideBannerCreater()); | WidgetFactory.regist('index_carousel', HomeSlideBannerCreater()); | ||||
@@ -39,8 +49,16 @@ class BaseWidgetRegister { | |||||
WidgetFactory.regist('index_banner_two', HomeBannerCreater()); | WidgetFactory.regist('index_banner_two', HomeBannerCreater()); | ||||
// ==================== 个人中心 | // ==================== 个人中心 | ||||
WidgetFactory.regist('index_title', MineHeaderCreater()); | |||||
// WidgetFactory.regist('index_search', MineHeaderBgCreater()); | |||||
// WidgetFactory.regist('index_search', MineQuickEntryCreater()); | |||||
WidgetFactory.regist( | |||||
'index_title', DefaultWidgetCreater((model) => MineHeader())); | |||||
// ==================== 钱包 | |||||
WidgetFactory.regist( | |||||
'wallet_data', DefaultWidgetCreater((model) => WalletData())); | |||||
WidgetFactory.regist( | |||||
'wallet_detail', DefaultWidgetCreater((model) => WalletDetail())); | |||||
WidgetFactory.regist( | |||||
'wallet_income', DefaultWidgetCreater((model) => WalletIncome())); | |||||
} | } | ||||
} | } |
@@ -1,10 +1,12 @@ | |||||
import 'dart:async'; | import 'dart:async'; | ||||
import 'package:bloc/bloc.dart'; | import 'package:bloc/bloc.dart'; | ||||
import 'package:flutter/cupertino.dart'; | import 'package:flutter/cupertino.dart'; | ||||
import 'package:zhiying_base_widget/widgets/home_banner/bloc/home_banner_repository.dart'; | |||||
import './bloc.dart'; | |||||
import 'package:zhiying_base_widget/widgets/home/home_banner/bloc/home_banner_repository.dart'; | |||||
import 'package:zhiying_comm/util/empty_util.dart'; | import 'package:zhiying_comm/util/empty_util.dart'; | ||||
import './bloc.dart'; | |||||
class HomeBannerBloc extends Bloc<HomeBannerEvent, HomeBannerState> { | class HomeBannerBloc extends Bloc<HomeBannerEvent, HomeBannerState> { | ||||
HomeBannerRepository repository; | HomeBannerRepository repository; | ||||
@@ -24,7 +26,8 @@ class HomeBannerBloc extends Bloc<HomeBannerEvent, HomeBannerState> { | |||||
} | } | ||||
/// 初始化 | /// 初始化 | ||||
Stream<HomeBannerState> _mapHomeBannerInitEventToState(HomeBannerInitEvent event) async* { | |||||
Stream<HomeBannerState> _mapHomeBannerInitEventToState( | |||||
HomeBannerInitEvent event) async* { | |||||
var cache = await repository.fetchCacheData(modId: event.model['mod_id']); | var cache = await repository.fetchCacheData(modId: event.model['mod_id']); | ||||
if (!EmptyUtil.isEmpty(cache)) yield HomeBannerCacheState(); | if (!EmptyUtil.isEmpty(cache)) yield HomeBannerCacheState(); | ||||
var result = await repository.fetchNetData(modId: event.model['mod_id']); | var result = await repository.fetchNetData(modId: event.model['mod_id']); |
@@ -1,12 +1,14 @@ | |||||
import 'package:flutter/cupertino.dart'; | import 'package:flutter/cupertino.dart'; | ||||
import 'package:zhiying_base_widget/widgets/home_banner/model/HomeBannerModel.dart'; | |||||
import 'package:zhiying_comm/util/net_util.dart'; | |||||
import 'package:zhiying_base_widget/widgets/home/home_banner/model/HomeBannerModel.dart'; | |||||
import 'package:zhiying_comm/util/empty_util.dart'; | import 'package:zhiying_comm/util/empty_util.dart'; | ||||
import 'package:zhiying_comm/util/net_util.dart'; | |||||
class HomeBannerRepository { | class HomeBannerRepository { | ||||
/// 读取缓存数据 | /// 读取缓存数据 | ||||
Future<HomeBannerModel> fetchCacheData({@required int modId}) async { | Future<HomeBannerModel> fetchCacheData({@required int modId}) async { | ||||
var reult = await NetUtil.getRequestCachedData('/api/v1/mod', params: {'ids': [modId]}); | |||||
var reult = await NetUtil.getRequestCachedData('/api/v1/mod', params: { | |||||
'ids': [modId] | |||||
}); | |||||
if (!EmptyUtil.isEmpty(reult)) { | if (!EmptyUtil.isEmpty(reult)) { | ||||
return HomeBannerModel(); | return HomeBannerModel(); | ||||
} | } | ||||
@@ -15,7 +17,9 @@ class HomeBannerRepository { | |||||
/// 获取网路数据 | /// 获取网路数据 | ||||
Future<HomeBannerModel> fetchNetData({@required int modId}) async { | Future<HomeBannerModel> fetchNetData({@required int modId}) async { | ||||
var result = await NetUtil.post('/api/v1/mod', params: {'ids': [modId]}); | |||||
var result = await NetUtil.post('/api/v1/mod', params: { | |||||
'ids': [modId] | |||||
}); | |||||
if (NetUtil.isSuccess(result)) { | if (NetUtil.isSuccess(result)) { | ||||
return HomeBannerModel(); | return HomeBannerModel(); | ||||
} | } |
@@ -1,15 +1,13 @@ | |||||
import 'package:flutter/src/widgets/framework.dart'; | import 'package:flutter/src/widgets/framework.dart'; | ||||
import 'package:zhiying_base_widget/widgets/home_banner/home_banner_widget.dart'; | |||||
import 'package:zhiying_base_widget/widgets/home/home_banner/home_banner_widget.dart'; | |||||
import 'package:zhiying_comm/zhiying_comm.dart'; | import 'package:zhiying_comm/zhiying_comm.dart'; | ||||
/// | /// | ||||
/// 不可滚动Banner | /// 不可滚动Banner | ||||
/// | /// | ||||
class HomeBannerCreater extends WidgetCreater{ | |||||
class HomeBannerCreater extends WidgetCreater { | |||||
@override | @override | ||||
List<Widget> createWidgets(Map<String, dynamic> model) { | List<Widget> createWidgets(Map<String, dynamic> model) { | ||||
return [HomeBannerWidget(model)]; | return [HomeBannerWidget(model)]; | ||||
} | } | ||||
} | |||||
} |
@@ -1,8 +1,8 @@ | |||||
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:zhiying_base_widget/widgets/home_banner/bloc/bloc.dart'; | |||||
import 'package:zhiying_base_widget/widgets/home_banner/bloc/home_banner_repository.dart'; | |||||
import 'package:zhiying_base_widget/widgets/home_banner/home_banner_sk.dart'; | |||||
import 'package:zhiying_base_widget/widgets/home/home_banner/bloc/bloc.dart'; | |||||
import 'package:zhiying_base_widget/widgets/home/home_banner/bloc/home_banner_repository.dart'; | |||||
import 'package:zhiying_base_widget/widgets/home/home_banner/home_banner_sk.dart'; | |||||
import 'package:zhiying_comm/zhiying_comm.dart'; | import 'package:zhiying_comm/zhiying_comm.dart'; | ||||
/// | /// | ||||
@@ -21,7 +21,8 @@ class _HomeBannerWidgetState extends State<HomeBannerWidget> { | |||||
@override | @override | ||||
Widget build(BuildContext context) { | Widget build(BuildContext context) { | ||||
return BlocProvider<HomeBannerBloc>( | return BlocProvider<HomeBannerBloc>( | ||||
create: (_) => HomeBannerBloc(repository: HomeBannerRepository())..add(HomeBannerInitEvent(widget.model)), | |||||
create: (_) => HomeBannerBloc(repository: HomeBannerRepository()) | |||||
..add(HomeBannerInitEvent(widget.model)), | |||||
child: HomeBannerContainer( | child: HomeBannerContainer( | ||||
model: widget.model, | model: widget.model, | ||||
), | ), | ||||
@@ -50,13 +51,16 @@ class _HomeBannerContainerState extends State<HomeBannerContainer> { | |||||
return true; | return true; | ||||
}, | }, | ||||
builder: (context, state) { | builder: (context, state) { | ||||
print(state); | print(state); | ||||
if (state is HomeBannerLoadedState) { | if (state is HomeBannerLoadedState) { | ||||
return ItemWidget(data: [1,2,3],); | |||||
return ItemWidget( | |||||
data: [1, 2, 3], | |||||
); | |||||
} | } | ||||
if (state is HomeBannerCacheState) { | if (state is HomeBannerCacheState) { | ||||
return ItemWidget(data: [1,2],); | |||||
return ItemWidget( | |||||
data: [1, 2], | |||||
); | |||||
} | } | ||||
return HomeBannerSkeleton(widget.model); | return HomeBannerSkeleton(widget.model); | ||||
@@ -66,8 +70,8 @@ class _HomeBannerContainerState extends State<HomeBannerContainer> { | |||||
} | } | ||||
class ItemWidget extends StatelessWidget { | class ItemWidget extends StatelessWidget { | ||||
final List data; | final List data; | ||||
ItemWidget({this.data}); | ItemWidget({this.data}); | ||||
@override | @override | ||||
@@ -76,15 +80,14 @@ class ItemWidget extends StatelessWidget { | |||||
height: 180.h, | height: 180.h, | ||||
margin: EdgeInsets.only(top: 7.5, left: 2.5, right: 2.5), | margin: EdgeInsets.only(top: 7.5, left: 2.5, right: 2.5), | ||||
child: Row( | child: Row( | ||||
children:data.map((index){ | |||||
children: data.map((index) { | |||||
return Flexible( | return Flexible( | ||||
flex: 1, | flex: 1, | ||||
child: Container( | child: Container( | ||||
margin: EdgeInsets.only( left: 5, right: 5), | |||||
margin: EdgeInsets.only(left: 5, right: 5), | |||||
decoration: BoxDecoration( | decoration: BoxDecoration( | ||||
color: Colors.lightBlue, | color: Colors.lightBlue, | ||||
borderRadius: BorderRadius.circular(7.5) | |||||
), | |||||
borderRadius: BorderRadius.circular(7.5)), | |||||
), | ), | ||||
); | ); | ||||
}).toList(), | }).toList(), | ||||
@@ -92,4 +95,3 @@ class ItemWidget extends StatelessWidget { | |||||
); | ); | ||||
} | } | ||||
} | } | ||||
@@ -1,13 +1,12 @@ | |||||
import 'dart:async'; | import 'dart:async'; | ||||
import 'package:zhiying_base_widget/widgets/home_goods/models/home_goods_model.dart'; | |||||
import 'package:zhiying_base_widget/widgets/home_goods/models/home_goods_style_model.dart'; | |||||
import 'package:zhiying_base_widget/widgets/home/home_goods/models/home_goods_model.dart'; | |||||
import 'package:zhiying_base_widget/widgets/home/home_goods/models/home_goods_style_model.dart'; | |||||
import 'package:zhiying_comm/util/base_bloc.dart'; | import 'package:zhiying_comm/util/base_bloc.dart'; | ||||
import 'package:zhiying_comm/zhiying_comm.dart'; | import 'package:zhiying_comm/zhiying_comm.dart'; | ||||
class HomeGoodsBloc extends BlocBase { | class HomeGoodsBloc extends BlocBase { | ||||
List<HomeGoodsModel> _goods = List(); | List<HomeGoodsModel> _goods = List(); | ||||
String storeName = ''; | |||||
HomeGoodsStyleModel style; | HomeGoodsStyleModel style; | ||||
String _provider = ''; | String _provider = ''; | ||||
@@ -54,9 +53,6 @@ class HomeGoodsBloc extends BlocBase { | |||||
style = HomeGoodsStyleModel.fromJson( | style = HomeGoodsStyleModel.fromJson( | ||||
Map<String, dynamic>.from(json['style'])); | Map<String, dynamic>.from(json['style'])); | ||||
} | } | ||||
if (json.containsKey('provider_name')) { | |||||
storeName = json['provider_name'].toString(); | |||||
} | |||||
_goodsController.add(_goods); | _goodsController.add(_goods); | ||||
}); | }); |
@@ -1,14 +1,15 @@ | |||||
import 'dart:async'; | import 'dart:async'; | ||||
import 'package:zhiying_base_widget/widgets/home_goods/models/home_goods_header_model.dart'; | |||||
import 'package:zhiying_comm/zhiying_comm.dart'; | |||||
import 'package:zhiying_base_widget/widgets/home/home_goods/models/home_goods_header_model.dart'; | |||||
import 'package:zhiying_comm/util/base_bloc.dart'; | import 'package:zhiying_comm/util/base_bloc.dart'; | ||||
import 'package:zhiying_comm/zhiying_comm.dart'; | |||||
class HomeGoodsHeaderBloc extends BlocBase { | class HomeGoodsHeaderBloc extends BlocBase { | ||||
List<HomeGoodsHeaderModel> _tabs = List(); | List<HomeGoodsHeaderModel> _tabs = List(); | ||||
StreamController<List<HomeGoodsHeaderModel>> _tabController = | StreamController<List<HomeGoodsHeaderModel>> _tabController = | ||||
StreamController<List<HomeGoodsHeaderModel>>(); | StreamController<List<HomeGoodsHeaderModel>>(); | ||||
Stream<List<HomeGoodsHeaderModel>> get outData => _tabController.stream; | Stream<List<HomeGoodsHeaderModel>> get outData => _tabController.stream; | ||||
@override | @override | ||||
@@ -22,19 +23,25 @@ class HomeGoodsHeaderBloc extends BlocBase { | |||||
method: NetMethod.POST, | method: NetMethod.POST, | ||||
params: Map<String, dynamic>.from({ | params: Map<String, dynamic>.from({ | ||||
'ids': [id] | 'ids': [id] | ||||
}), | |||||
onCache: (data) {}, onSuccess: (data) { | |||||
String key = id.toString(); | |||||
Map<String, dynamic> json = Map<String, dynamic>.from(data); | |||||
if (json.containsKey(key)) { | |||||
List<dynamic> list = json[key]; | |||||
_tabs = list.map((item) { | |||||
return HomeGoodsHeaderModel.fromJson(Map<String, dynamic>.from(item)); | |||||
}).toList(); | |||||
}), onCache: (data) { | |||||
if (data != null) { | |||||
_loadData(id, data); | |||||
} | } | ||||
_tabController.add(_tabs); | |||||
}, onSuccess: (data) { | |||||
_loadData(id, data); | |||||
}); | }); | ||||
} | } | ||||
void _loadData(int id, dynamic data) { | |||||
String key = id.toString(); | |||||
Map<String, dynamic> json = Map<String, dynamic>.from(data); | |||||
if (json.containsKey(key)) { | |||||
List<dynamic> list = json[key]; | |||||
_tabs = list.map((item) { | |||||
return HomeGoodsHeaderModel.fromJson(Map<String, dynamic>.from(item)); | |||||
}).toList(); | |||||
} | |||||
_tabController.add(_tabs); | |||||
} | |||||
} | } |
@@ -3,11 +3,11 @@ import 'package:flutter/cupertino.dart'; | |||||
import 'package:flutter/material.dart'; | import 'package:flutter/material.dart'; | ||||
import 'package:provider/provider.dart'; | import 'package:provider/provider.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/home_goods/bloc/home_goods_bloc.dart'; | |||||
import 'package:zhiying_base_widget/widgets/home_goods/home_goods_creater.dart'; | |||||
import 'package:zhiying_base_widget/widgets/home_goods/home_goods_item.dart'; | |||||
import 'package:zhiying_base_widget/widgets/home_goods/models/home_goods_model.dart'; | |||||
import 'package:zhiying_base_widget/widgets/home_goods/skeleton/home_goods_sk.dart'; | |||||
import 'package:zhiying_base_widget/widgets/home/home_goods/bloc/home_goods_bloc.dart'; | |||||
import 'package:zhiying_base_widget/widgets/home/home_goods/home_goods_creater.dart'; | |||||
import 'package:zhiying_base_widget/widgets/home/home_goods/home_goods_item.dart'; | |||||
import 'package:zhiying_base_widget/widgets/home/home_goods/models/home_goods_model.dart'; | |||||
import 'package:zhiying_base_widget/widgets/home/home_goods/skeleton/home_goods_sk.dart'; | |||||
import 'package:zhiying_comm/util/base_bloc.dart'; | import 'package:zhiying_comm/util/base_bloc.dart'; | ||||
class HomeGoods extends StatefulWidget { | class HomeGoods extends StatefulWidget { | ||||
@@ -92,7 +92,6 @@ class _HomeGoodsContainerState extends State<_HomeGoodsContainer> { | |||||
goods[index], | goods[index], | ||||
_bloc.style, | _bloc.style, | ||||
data: widget.data, | data: widget.data, | ||||
shop: _bloc.storeName, | |||||
); | ); | ||||
}); | }); | ||||
}, | }, |
@@ -1,8 +1,8 @@ | |||||
import 'package:event_bus/event_bus.dart'; | import 'package:event_bus/event_bus.dart'; | ||||
import 'package:flutter/material.dart'; | import 'package:flutter/material.dart'; | ||||
import 'package:zhiying_base_widget/widgets/home_goods/bloc/home_goods_header_bloc.dart'; | |||||
import 'package:zhiying_base_widget/widgets/home_goods/home_goods.dart'; | |||||
import 'package:zhiying_base_widget/widgets/home_goods/home_goods_header.dart'; | |||||
import 'package:zhiying_base_widget/widgets/home/home_goods/bloc/home_goods_header_bloc.dart'; | |||||
import 'package:zhiying_base_widget/widgets/home/home_goods/home_goods.dart'; | |||||
import 'package:zhiying_base_widget/widgets/home/home_goods/home_goods_header.dart'; | |||||
import 'package:zhiying_comm/util/base_bloc.dart'; | import 'package:zhiying_comm/util/base_bloc.dart'; | ||||
import 'package:zhiying_comm/zhiying_comm.dart'; | import 'package:zhiying_comm/zhiying_comm.dart'; | ||||
@@ -1,10 +1,10 @@ | |||||
import 'package:event_bus/event_bus.dart'; | 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:zhiying_base_widget/widgets/home_goods/bloc/home_goods_header_bloc.dart'; | |||||
import 'package:zhiying_base_widget/widgets/home_goods/home_goods_creater.dart'; | |||||
import 'package:zhiying_base_widget/widgets/home_goods/models/home_goods_header_model.dart'; | |||||
import 'package:zhiying_base_widget/widgets/home_goods/skeleton/home_goods_header_sk.dart'; | |||||
import 'package:zhiying_base_widget/widgets/home/home_goods/bloc/home_goods_header_bloc.dart'; | |||||
import 'package:zhiying_base_widget/widgets/home/home_goods/home_goods_creater.dart'; | |||||
import 'package:zhiying_base_widget/widgets/home/home_goods/models/home_goods_header_model.dart'; | |||||
import 'package:zhiying_base_widget/widgets/home/home_goods/skeleton/home_goods_header_sk.dart'; | |||||
import 'package:zhiying_comm/util/base_bloc.dart'; | import 'package:zhiying_comm/util/base_bloc.dart'; | ||||
import 'package:zhiying_comm/zhiying_comm.dart'; | import 'package:zhiying_comm/zhiying_comm.dart'; | ||||
@@ -2,18 +2,17 @@ import 'dart: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/home_goods/models/home_goods_model.dart'; | |||||
import 'package:zhiying_base_widget/widgets/home_goods/models/home_goods_style_model.dart'; | |||||
import 'package:zhiying_base_widget/widgets/home/home_goods/models/home_goods_model.dart'; | |||||
import 'package:zhiying_base_widget/widgets/home/home_goods/models/home_goods_style_model.dart'; | |||||
import 'package:zhiying_comm/zhiying_comm.dart'; | import 'package:zhiying_comm/zhiying_comm.dart'; | ||||
// ignore: must_be_immutable | // ignore: must_be_immutable | ||||
class HomeGoodsItem extends StatelessWidget { | class HomeGoodsItem extends StatelessWidget { | ||||
final HomeGoodsModel goods; | final HomeGoodsModel goods; | ||||
final HomeGoodsStyleModel style; | final HomeGoodsStyleModel style; | ||||
final String shop; | |||||
Map<String, dynamic> data; | Map<String, dynamic> data; | ||||
HomeGoodsItem(this.goods, this.style, {Key key, this.data, this.shop}) | |||||
HomeGoodsItem(this.goods, this.style, {Key key, this.data}) | |||||
: super(key: key) { | : super(key: key) { | ||||
if (this.data != null && this.data.containsKey('data')) { | if (this.data != null && this.data.containsKey('data')) { | ||||
String data = this.data['data']; | String data = this.data['data']; | ||||
@@ -71,21 +70,22 @@ class HomeGoodsItem extends StatelessWidget { | |||||
Widget _createTitle() { | Widget _createTitle() { | ||||
List<InlineSpan> list = List(); | List<InlineSpan> list = List(); | ||||
if (shop != null && shop != '') { | |||||
if (goods.providerName != null && goods.providerName != '') { | |||||
list.add(WidgetSpan( | list.add(WidgetSpan( | ||||
child: Container( | child: Container( | ||||
padding: EdgeInsets.only(left: 2, right: 2, top: 3, bottom: 3), | padding: EdgeInsets.only(left: 2, right: 2, top: 3, bottom: 3), | ||||
margin: EdgeInsets.only(right: 4), | margin: EdgeInsets.only(right: 4), | ||||
child: Text( | child: Text( | ||||
shop, | |||||
goods.providerName, | |||||
style: TextStyle( | style: TextStyle( | ||||
fontSize: 9, | fontSize: 9, | ||||
height: 1, | height: 1, | ||||
color: HexColor.fromHex('#ffffff'), | |||||
color: HexColor.fromHex(style.providerNameColor), | |||||
), | ), | ||||
), | ), | ||||
decoration: BoxDecoration( | decoration: BoxDecoration( | ||||
color: Colors.red, borderRadius: BorderRadius.circular(2.5)), | |||||
color: HexColor.fromHex(style.providerNameBackgroundColor), | |||||
borderRadius: BorderRadius.circular(2.5)), | |||||
), | ), | ||||
)); | )); | ||||
} | } |
@@ -1,5 +1,5 @@ | |||||
import 'package:flutter/material.dart'; | import 'package:flutter/material.dart'; | ||||
import 'package:zhiying_base_widget/widgets/home_goods/skeleton/home_goods_item_sk.dart'; | |||||
import 'package:zhiying_base_widget/widgets/home/home_goods/skeleton/home_goods_item_sk.dart'; | |||||
class HomeGoodsSkeleton extends StatelessWidget { | class HomeGoodsSkeleton extends StatelessWidget { | ||||
const HomeGoodsSkeleton({Key key}) : super(key: key); | const HomeGoodsSkeleton({Key key}) : super(key: key); |
@@ -0,0 +1,100 @@ | |||||
import 'package:flutter/material.dart'; | |||||
class HomeGoodsTab extends StatefulWidget { | |||||
@override | |||||
_HomeGoodsTabState createState() => _HomeGoodsTabState(); | |||||
} | |||||
class _HomeGoodsTabState extends State<HomeGoodsTab> | |||||
with TickerProviderStateMixin { | |||||
TabController _tabController; | |||||
@override | |||||
void initState() { | |||||
_tabController = TabController(length: 3, vsync: this); | |||||
super.initState(); | |||||
} | |||||
@override | |||||
Widget build(BuildContext context) { | |||||
List<Widget> _silverBuilder(BuildContext context, bool innerBoxIsScrolled) { | |||||
return <Widget>[ | |||||
SliverAppBar(), | |||||
SliverPersistentHeader( | |||||
pinned: true, | |||||
delegate: _SilverAppBarDelegate( | |||||
Container( | |||||
color: Colors.amber, | |||||
child: TabBar( | |||||
labelColor: Colors.blue, | |||||
unselectedLabelColor: Colors.black, | |||||
controller: _tabController, | |||||
tabs: <Widget>[ | |||||
new Tab( | |||||
text: "tab1", | |||||
), | |||||
new Tab( | |||||
text: "tab2", | |||||
), | |||||
new Tab( | |||||
text: "tab3", | |||||
), | |||||
], | |||||
), | |||||
), | |||||
), | |||||
), | |||||
]; | |||||
} | |||||
return SliverPersistentHeader( | |||||
pinned: true, | |||||
delegate: _SilverAppBarDelegate( | |||||
Container( | |||||
color: Colors.amber, | |||||
child: TabBar( | |||||
labelColor: Colors.blue, | |||||
unselectedLabelColor: Colors.black, | |||||
controller: _tabController, | |||||
tabs: <Widget>[ | |||||
new Tab( | |||||
text: "tab1", | |||||
), | |||||
new Tab( | |||||
text: "tab2", | |||||
), | |||||
new Tab( | |||||
text: "tab3", | |||||
), | |||||
], | |||||
), | |||||
), | |||||
), | |||||
); | |||||
} | |||||
} | |||||
class _SilverAppBarDelegate extends SliverPersistentHeaderDelegate { | |||||
_SilverAppBarDelegate(this.child); | |||||
final Widget child; | |||||
@override | |||||
double get minExtent => 44; | |||||
@override | |||||
double get maxExtent => 44; | |||||
@override | |||||
Widget build( | |||||
BuildContext context, double shrinkOffset, bool overlapsContent) { | |||||
return new Container( | |||||
child: child, | |||||
); | |||||
} | |||||
@override | |||||
bool shouldRebuild(SliverPersistentHeaderDelegate oldDelegate) { | |||||
return false; | |||||
} | |||||
} |
@@ -0,0 +1,21 @@ | |||||
import 'package:event_bus/event_bus.dart'; | |||||
import 'package:flutter/material.dart'; | |||||
import 'package:zhiying_comm/zhiying_comm.dart'; | |||||
class HomeGoodsTabCreater extends WidgetCreater { | |||||
final EventBus _eventBus = EventBus(); | |||||
@override | |||||
List<Widget> createWidgets(Map<String, dynamic> model) { | |||||
print('创建商品列表'); | |||||
return [ | |||||
// TestPage(), | |||||
]; | |||||
} | |||||
@override | |||||
bool isSliverChild() { | |||||
return false; | |||||
} | |||||
} |
@@ -1,11 +1,14 @@ | |||||
import 'dart:async'; | import 'dart:async'; | ||||
import 'package:bloc/bloc.dart'; | import 'package:bloc/bloc.dart'; | ||||
import 'package:flutter/cupertino.dart'; | import 'package:flutter/cupertino.dart'; | ||||
import 'package:zhiying_base_widget/widgets/home_quick_entry/bloc/home_quick_entry_repository.dart'; | |||||
import './bloc.dart'; | |||||
import 'package:zhiying_base_widget/widgets/home/home_quick_entry/bloc/home_quick_entry_repository.dart'; | |||||
import 'package:zhiying_comm/util/empty_util.dart'; | import 'package:zhiying_comm/util/empty_util.dart'; | ||||
class HomeQuickEntryBloc extends Bloc<HomeQuickEntryEvent, HomeQuickEntryState> { | |||||
import './bloc.dart'; | |||||
class HomeQuickEntryBloc | |||||
extends Bloc<HomeQuickEntryEvent, HomeQuickEntryState> { | |||||
HomeQuickEntryRepository repository; | HomeQuickEntryRepository repository; | ||||
HomeQuickEntryBloc({@required this.repository}); | HomeQuickEntryBloc({@required this.repository}); | ||||
@@ -14,7 +17,8 @@ class HomeQuickEntryBloc extends Bloc<HomeQuickEntryEvent, HomeQuickEntryState> | |||||
HomeQuickEntryState get initialState => InitialHomeQuickEntryState(); | HomeQuickEntryState get initialState => InitialHomeQuickEntryState(); | ||||
@override | @override | ||||
Stream<HomeQuickEntryState> mapEventToState(HomeQuickEntryEvent event) async* { | |||||
Stream<HomeQuickEntryState> mapEventToState( | |||||
HomeQuickEntryEvent event) async* { | |||||
final currentState = state; | final currentState = state; | ||||
if (event is HomeQuickEntryInitEvent) { | if (event is HomeQuickEntryInitEvent) { | ||||
yield* _mapHomeQuickEntryInitToState(event); | yield* _mapHomeQuickEntryInitToState(event); | ||||
@@ -22,7 +26,8 @@ class HomeQuickEntryBloc extends Bloc<HomeQuickEntryEvent, HomeQuickEntryState> | |||||
} | } | ||||
/// 初始化 | /// 初始化 | ||||
Stream<HomeQuickEntryState> _mapHomeQuickEntryInitToState(HomeQuickEntryInitEvent event) async* { | |||||
Stream<HomeQuickEntryState> _mapHomeQuickEntryInitToState( | |||||
HomeQuickEntryInitEvent event) async* { | |||||
/// 获取缓存数据 | /// 获取缓存数据 | ||||
var cached = await repository.fetchCachedData(); | var cached = await repository.fetchCachedData(); | ||||
if (!EmptyUtil.isEmpty(cached)) { | if (!EmptyUtil.isEmpty(cached)) { |
@@ -1,13 +1,16 @@ | |||||
import 'dart:async'; | import 'dart:async'; | ||||
import 'package:bloc/bloc.dart'; | import 'package:bloc/bloc.dart'; | ||||
import 'package:flutter/cupertino.dart'; | import 'package:flutter/cupertino.dart'; | ||||
import 'package:zhiying_base_widget/widgets/home_slide_banner/bloc/home_slide_banner_event.dart'; | |||||
import 'package:zhiying_base_widget/widgets/home_slide_banner/bloc/home_slide_banner_repository.dart'; | |||||
import 'package:zhiying_base_widget/widgets/home_slide_banner/bloc/home_slide_banner_state.dart'; | |||||
import './bloc.dart'; | |||||
import 'package:zhiying_base_widget/widgets/home/home_slide_banner/bloc/home_slide_banner_event.dart'; | |||||
import 'package:zhiying_base_widget/widgets/home/home_slide_banner/bloc/home_slide_banner_repository.dart'; | |||||
import 'package:zhiying_base_widget/widgets/home/home_slide_banner/bloc/home_slide_banner_state.dart'; | |||||
import 'package:zhiying_comm/util/empty_util.dart'; | import 'package:zhiying_comm/util/empty_util.dart'; | ||||
class HomeSlideBannerBloc extends Bloc<HomeSlideBannerEvent, HomeSlideBannerState> { | |||||
import './bloc.dart'; | |||||
class HomeSlideBannerBloc | |||||
extends Bloc<HomeSlideBannerEvent, HomeSlideBannerState> { | |||||
HomeSlideBannerRepository repository; | HomeSlideBannerRepository repository; | ||||
HomeSlideBannerBloc({@required this.repository}); | HomeSlideBannerBloc({@required this.repository}); | ||||
@@ -16,7 +19,8 @@ class HomeSlideBannerBloc extends Bloc<HomeSlideBannerEvent, HomeSlideBannerStat | |||||
HomeSlideBannerState get initialState => InitialHomeSlideBannerState(); | HomeSlideBannerState get initialState => InitialHomeSlideBannerState(); | ||||
@override | @override | ||||
Stream<HomeSlideBannerState> mapEventToState(HomeSlideBannerEvent event) async* { | |||||
Stream<HomeSlideBannerState> mapEventToState( | |||||
HomeSlideBannerEvent event) async* { | |||||
final currentState = state; | final currentState = state; | ||||
/// 初始化 | /// 初始化 | ||||
@@ -27,10 +31,12 @@ class HomeSlideBannerBloc extends Bloc<HomeSlideBannerEvent, HomeSlideBannerStat | |||||
} | } | ||||
/// 初始化 | /// 初始化 | ||||
Stream<HomeSlideBannerState> _mapInitEventToState(HomeBannerInitEvent event) async* { | |||||
Stream<HomeSlideBannerState> _mapInitEventToState( | |||||
HomeBannerInitEvent event) async* { | |||||
var cached = await repository.fetchCachedDate(id: event.model['mod_id']); | var cached = await repository.fetchCachedDate(id: event.model['mod_id']); | ||||
if (!EmptyUtil.isEmpty(cached)) yield HomeSlideBannerCachedState(datas: cached); | |||||
var param = await repository.fetchData( id: event.model['mod_id']); | |||||
if (!EmptyUtil.isEmpty(cached)) | |||||
yield HomeSlideBannerCachedState(datas: cached); | |||||
var param = await repository.fetchData(id: event.model['mod_id']); | |||||
if (!EmptyUtil.isEmpty(param)) | if (!EmptyUtil.isEmpty(param)) | ||||
yield HomeSlideBannerLoadedState(datas: param); | yield HomeSlideBannerLoadedState(datas: param); | ||||
else | else |
@@ -0,0 +1,37 @@ | |||||
import 'package:flutter/cupertino.dart'; | |||||
import 'package:zhiying_base_widget/widgets/home/home_slide_banner/model/home_slide_banner_model.dart'; | |||||
import 'package:zhiying_comm/util/empty_util.dart'; | |||||
import 'package:zhiying_comm/util/global_config.dart'; | |||||
import 'package:zhiying_comm/util/net_util.dart'; | |||||
class HomeSlideBannerRepository { | |||||
/// 获取缓存数据 | |||||
Future<List<HomeSlideBannerModelItems>> fetchCachedDate( | |||||
{@required int id}) async { | |||||
var cached = await NetUtil.getRequestCachedData('/api/v1/mod', params: { | |||||
'ids': [id] | |||||
}); | |||||
if (!EmptyUtil.isEmpty(cached)) { | |||||
HomeSlideBannerModel model = HomeSlideBannerModel.fromJson(cached); | |||||
if (null != model && !EmptyUtil.isEmpty(model.items)) { | |||||
return model.items; | |||||
} | |||||
} | |||||
return null; | |||||
} | |||||
/// 获取数据 | |||||
Future<List<HomeSlideBannerModelItems>> fetchData({@required int id}) async { | |||||
var params = await NetUtil.post('/api/v1/mod', params: { | |||||
'ids': [id] | |||||
}); | |||||
if (!EmptyUtil.isEmpty(params) && NetUtil.isSuccess(params)) { | |||||
HomeSlideBannerModel model = HomeSlideBannerModel.fromJson( | |||||
params[GlobalConfig.HTTP_RESPONSE_KEY_DATA]); | |||||
if (null != model && !EmptyUtil.isEmpty(model.items)) { | |||||
return model.items; | |||||
} | |||||
} | |||||
return null; | |||||
} | |||||
} |
@@ -1,5 +1,5 @@ | |||||
import 'package:equatable/equatable.dart'; | import 'package:equatable/equatable.dart'; | ||||
import 'package:zhiying_base_widget/widgets/home_slide_banner/model/home_slide_banner_model.dart'; | |||||
import 'package:zhiying_base_widget/widgets/home/home_slide_banner/model/home_slide_banner_model.dart'; | |||||
abstract class HomeSlideBannerState extends Equatable { | abstract class HomeSlideBannerState extends Equatable { | ||||
const HomeSlideBannerState(); | const HomeSlideBannerState(); | ||||
@@ -30,7 +30,8 @@ class HomeSlideBannerLoadedState extends HomeSlideBannerState { | |||||
HomeSlideBannerLoadedState({this.datas}); | HomeSlideBannerLoadedState({this.datas}); | ||||
HomeSlideBannerLoadedState copyWith({List<HomeSlideBannerModelItems> newData}) { | |||||
HomeSlideBannerLoadedState copyWith( | |||||
{List<HomeSlideBannerModelItems> newData}) { | |||||
return HomeSlideBannerLoadedState( | return HomeSlideBannerLoadedState( | ||||
datas: newData ?? datas, | datas: newData ?? datas, | ||||
); | ); |
@@ -1,34 +0,0 @@ | |||||
import 'package:flutter/cupertino.dart'; | |||||
import 'package:zhiying_base_widget/widgets/home_slide_banner/model/home_slide_banner_model.dart'; | |||||
import 'package:zhiying_comm/util/net_util.dart'; | |||||
import 'package:zhiying_comm/util/empty_util.dart'; | |||||
import 'package:zhiying_comm/util/global_config.dart'; | |||||
class HomeSlideBannerRepository{ | |||||
/// 获取缓存数据 | |||||
Future<List<HomeSlideBannerModelItems>> fetchCachedDate({@required int id}) async{ | |||||
var cached = await NetUtil.getRequestCachedData('/api/v1/mod', params: {'ids': [id]}); | |||||
if(!EmptyUtil.isEmpty(cached)){ | |||||
HomeSlideBannerModel model = HomeSlideBannerModel.fromJson(cached); | |||||
if(null != model && !EmptyUtil.isEmpty(model.items)){ | |||||
return model.items; | |||||
} | |||||
} | |||||
return null; | |||||
} | |||||
/// 获取数据 | |||||
Future<List<HomeSlideBannerModelItems>> fetchData({@required int id}) async{ | |||||
var params = await NetUtil.post('/api/v1/mod', params: {'ids': [id]}); | |||||
if(!EmptyUtil.isEmpty(params) && NetUtil.isSuccess(params)){ | |||||
HomeSlideBannerModel model = HomeSlideBannerModel.fromJson(params[GlobalConfig.HTTP_RESPONSE_KEY_DATA]); | |||||
if(null != model && !EmptyUtil.isEmpty(model.items)){ | |||||
return model.items; | |||||
} | |||||
} | |||||
return null; | |||||
} | |||||
} |
@@ -0,0 +1,14 @@ | |||||
import 'package:flutter/material.dart'; | |||||
import 'package:zhiying_base_widget/widgets/mine/mine_data/mine_data_sk.dart'; | |||||
class MineData extends StatefulWidget { | |||||
@override | |||||
_MineDataState createState() => _MineDataState(); | |||||
} | |||||
class _MineDataState extends State<MineData> { | |||||
@override | |||||
Widget build(BuildContext context) { | |||||
return MineDataSkeleton(); | |||||
} | |||||
} |
@@ -0,0 +1,12 @@ | |||||
import 'package:flutter/material.dart'; | |||||
import 'package:zhiying_base_widget/widgets/mine/mine_data/mine_data.dart'; | |||||
import 'package:zhiying_comm/zhiying_comm.dart'; | |||||
class MineDataCreater extends WidgetCreater { | |||||
@override | |||||
List<Widget> createWidgets(Map<String, dynamic> model) { | |||||
return [ | |||||
MineData(), | |||||
]; | |||||
} | |||||
} |
@@ -0,0 +1,122 @@ | |||||
import 'package:flutter/material.dart'; | |||||
import 'package:shimmer/shimmer.dart'; | |||||
class MineDataSkeleton extends StatefulWidget { | |||||
@override | |||||
_MineDataSkeletonState createState() => _MineDataSkeletonState(); | |||||
} | |||||
class _MineDataSkeletonState extends State<MineDataSkeleton> { | |||||
@override | |||||
Widget build(BuildContext context) { | |||||
return Container( | |||||
margin: EdgeInsets.only(left: 12.5, right: 12.5), | |||||
decoration: BoxDecoration( | |||||
color: Colors.white, borderRadius: BorderRadius.circular(7.5)), | |||||
child: Shimmer.fromColors( | |||||
baseColor: Colors.grey[300], | |||||
highlightColor: Colors.grey[100], | |||||
child: Column( | |||||
children: <Widget>[ | |||||
Container( | |||||
width: double.infinity, | |||||
height: 62, | |||||
child: Column( | |||||
mainAxisAlignment: MainAxisAlignment.center, | |||||
children: <Widget>[ | |||||
Row( | |||||
crossAxisAlignment: CrossAxisAlignment.center, | |||||
children: <Widget>[ | |||||
Expanded( | |||||
child: _createText1(), | |||||
) | |||||
], | |||||
) | |||||
], | |||||
), | |||||
), | |||||
Container( | |||||
width: double.infinity, | |||||
height: 72, | |||||
child: Row( | |||||
crossAxisAlignment: CrossAxisAlignment.center, | |||||
mainAxisAlignment: MainAxisAlignment.center, | |||||
children: <Widget>[ | |||||
Expanded( | |||||
child: _createText2(), | |||||
), | |||||
Expanded( | |||||
child: _createText2(), | |||||
) | |||||
], | |||||
), | |||||
), | |||||
Container( | |||||
width: double.infinity, | |||||
height: 46, | |||||
child: Row( | |||||
crossAxisAlignment: CrossAxisAlignment.center, | |||||
children: <Widget>[ | |||||
Expanded( | |||||
child: Container( | |||||
margin: EdgeInsets.only(left: 15, right: 15), | |||||
height: 15, | |||||
color: Colors.white, | |||||
), | |||||
), | |||||
Expanded( | |||||
child: Container( | |||||
margin: EdgeInsets.only(left: 15, right: 15), | |||||
height: 15, | |||||
color: Colors.white, | |||||
), | |||||
) | |||||
], | |||||
), | |||||
) | |||||
], | |||||
), | |||||
), | |||||
); | |||||
} | |||||
Widget _createText1() { | |||||
return Column( | |||||
crossAxisAlignment: CrossAxisAlignment.start, | |||||
children: <Widget>[ | |||||
Container( | |||||
margin: EdgeInsets.only(left: 15, right: 15), | |||||
height: 15, | |||||
color: Colors.white, | |||||
), | |||||
Container( | |||||
margin: EdgeInsets.only(left: 15, top: 4), | |||||
height: 15, | |||||
width: 120, | |||||
color: Colors.white, | |||||
), | |||||
], | |||||
); | |||||
} | |||||
Widget _createText2() { | |||||
return Column( | |||||
crossAxisAlignment: CrossAxisAlignment.start, | |||||
mainAxisAlignment: MainAxisAlignment.center, | |||||
children: <Widget>[ | |||||
Container( | |||||
margin: EdgeInsets.only(left: 15), | |||||
height: 15, | |||||
width: 44, | |||||
color: Colors.white, | |||||
), | |||||
Container( | |||||
margin: EdgeInsets.only(left: 15, top: 6), | |||||
height: 15, | |||||
width: 64, | |||||
color: Colors.white, | |||||
), | |||||
], | |||||
); | |||||
} | |||||
} |
@@ -0,0 +1,14 @@ | |||||
import 'package:flutter/cupertino.dart'; | |||||
import 'package:flutter/material.dart'; | |||||
import 'mine_header_sk.dart'; | |||||
class MineHeader extends StatelessWidget { | |||||
@override | |||||
Widget build(BuildContext context) { | |||||
return Container( | |||||
width: double.infinity, | |||||
child: MineHeaderSkeleton(), | |||||
); | |||||
} | |||||
} |
@@ -0,0 +1,12 @@ | |||||
import 'package:flutter/material.dart'; | |||||
import 'package:zhiying_base_widget/widgets/mine/mine_header/mine_header.dart'; | |||||
import 'package:zhiying_comm/zhiying_comm.dart'; | |||||
class MineHeaderCreater extends WidgetCreater { | |||||
@override | |||||
List<Widget> createWidgets(Map<String, dynamic> model) { | |||||
return [ | |||||
MineHeader(), | |||||
]; | |||||
} | |||||
} |
@@ -0,0 +1,45 @@ | |||||
import 'package:flutter/material.dart'; | |||||
import 'package:shimmer/shimmer.dart'; | |||||
class MineHeaderSkeleton extends StatelessWidget { | |||||
@override | |||||
Widget build(BuildContext context) { | |||||
return Shimmer.fromColors( | |||||
baseColor: Colors.grey[300], | |||||
highlightColor: Colors.grey[100], | |||||
child: Container( | |||||
child: Row( | |||||
children: <Widget>[ | |||||
Container( | |||||
margin: EdgeInsets.only(left: 20, top: 20, bottom: 20, right: 12), | |||||
width: 56, | |||||
height: 56, | |||||
decoration: BoxDecoration( | |||||
color: Colors.white, | |||||
borderRadius: BorderRadius.circular(28), | |||||
), | |||||
), | |||||
Expanded( | |||||
child: Column( | |||||
mainAxisAlignment: MainAxisAlignment.start, | |||||
crossAxisAlignment: CrossAxisAlignment.start, | |||||
children: <Widget>[ | |||||
Container( | |||||
width: 120, | |||||
height: 20, | |||||
color: Colors.white, | |||||
), | |||||
Container( | |||||
margin: EdgeInsets.only(top: 8), | |||||
width: 80, | |||||
height: 12, | |||||
color: Colors.white, | |||||
), | |||||
], | |||||
)) | |||||
], | |||||
), | |||||
), | |||||
); | |||||
} | |||||
} |
@@ -3,10 +3,10 @@ import 'dart:ui'; | |||||
import 'package:flutter/cupertino.dart'; | import 'package:flutter/cupertino.dart'; | ||||
import 'package:flutter/material.dart'; | import 'package:flutter/material.dart'; | ||||
class MineHeaderDelegate extends SliverPersistentHeaderDelegate { | |||||
class MineNavDelegate extends SliverPersistentHeaderDelegate { | |||||
double _height; | double _height; | ||||
MineHeaderDelegate() : super() { | |||||
MineNavDelegate() : super() { | |||||
_height = MediaQueryData.fromWindow(window).padding.top + 44; | _height = MediaQueryData.fromWindow(window).padding.top + 44; | ||||
} | } | ||||
@@ -16,7 +16,7 @@ class MineHeaderDelegate extends SliverPersistentHeaderDelegate { | |||||
// print('${shrinkOffset.toString()}'); | // print('${shrinkOffset.toString()}'); | ||||
double percent = shrinkOffset / _height; | double percent = shrinkOffset / _height; | ||||
print('${percent.toString()}'); | print('${percent.toString()}'); | ||||
return MineHeader(Colors.red.withOpacity(percent)); | |||||
return MineNav(Colors.red.withOpacity(percent)); | |||||
} | } | ||||
@override | @override | ||||
@@ -30,10 +30,10 @@ class MineHeaderDelegate extends SliverPersistentHeaderDelegate { | |||||
false; // 如果内容需要更新,设置为true | false; // 如果内容需要更新,设置为true | ||||
} | } | ||||
class MineHeader extends StatelessWidget { | |||||
class MineNav extends StatelessWidget { | |||||
final Color color; | final Color color; | ||||
MineHeader(this.color); | |||||
MineNav(this.color); | |||||
@override | @override | ||||
Widget build(BuildContext context) { | Widget build(BuildContext context) { |
@@ -1,15 +1,15 @@ | |||||
import 'package:flutter/material.dart'; | import 'package:flutter/material.dart'; | ||||
import 'package:zhiying_base_widget/widgets/mine_header/mine_header.dart'; | |||||
import 'package:zhiying_base_widget/widgets/mine/mine_nav/mine_nav.dart'; | |||||
import 'package:zhiying_comm/zhiying_comm.dart'; | import 'package:zhiying_comm/zhiying_comm.dart'; | ||||
class MineHeaderCreater extends WidgetCreater { | |||||
class MineNavCreater extends WidgetCreater { | |||||
@override | @override | ||||
List<Widget> createWidgets(Map<String, dynamic> model) { | List<Widget> createWidgets(Map<String, dynamic> model) { | ||||
return [ | return [ | ||||
SliverPersistentHeader( | SliverPersistentHeader( | ||||
pinned: true, | pinned: true, | ||||
floating: false, | floating: false, | ||||
delegate: MineHeaderDelegate(), | |||||
delegate: MineNavDelegate(), | |||||
), | ), | ||||
]; | ]; | ||||
} | } |
@@ -1,6 +1,6 @@ | |||||
import 'dart:async'; | import 'dart:async'; | ||||
import 'package:zhiying_base_widget/widgets/mine_quick_entry/models/mine_quick_entry_model.dart'; | |||||
import 'package:zhiying_base_widget/widgets/mine/mine_quick_entry/models/mine_quick_entry_model.dart'; | |||||
import 'package:zhiying_comm/util/base_bloc.dart'; | import 'package:zhiying_comm/util/base_bloc.dart'; | ||||
import 'package:zhiying_comm/zhiying_comm.dart'; | import 'package:zhiying_comm/zhiying_comm.dart'; | ||||
@@ -1,7 +1,7 @@ | |||||
import 'package:flutter/material.dart'; | import 'package:flutter/material.dart'; | ||||
import 'package:zhiying_base_widget/widgets/mine_quick_entry/bloc/mine_quick_entry_bloc.dart'; | |||||
import 'package:zhiying_base_widget/widgets/mine_quick_entry/mine_quick_entry_sk.dart'; | |||||
import 'package:zhiying_base_widget/widgets/mine_quick_entry/models/mine_quick_entry_model.dart'; | |||||
import 'package:zhiying_base_widget/widgets/mine/mine_quick_entry/bloc/mine_quick_entry_bloc.dart'; | |||||
import 'package:zhiying_base_widget/widgets/mine/mine_quick_entry/mine_quick_entry_sk.dart'; | |||||
import 'package:zhiying_base_widget/widgets/mine/mine_quick_entry/models/mine_quick_entry_model.dart'; | |||||
import 'package:zhiying_comm/util/base_bloc.dart'; | import 'package:zhiying_comm/util/base_bloc.dart'; | ||||
class MineQuickEntry extends StatefulWidget { | class MineQuickEntry extends StatefulWidget { |
@@ -1,5 +1,5 @@ | |||||
import 'package:flutter/material.dart'; | import 'package:flutter/material.dart'; | ||||
import 'package:zhiying_base_widget/widgets/mine_quick_entry/mine_quick_entry.dart'; | |||||
import 'package:zhiying_base_widget/widgets/mine/mine_quick_entry/mine_quick_entry.dart'; | |||||
import 'package:zhiying_comm/zhiying_comm.dart'; | import 'package:zhiying_comm/zhiying_comm.dart'; | ||||
class MineQuickEntryCreater extends WidgetCreater { | class MineQuickEntryCreater extends WidgetCreater { |
@@ -5,6 +5,12 @@ class MineQuickEntrySkeleton extends StatelessWidget { | |||||
@override | @override | ||||
Widget build(BuildContext context) { | Widget build(BuildContext context) { | ||||
return Container( | return Container( | ||||
margin: EdgeInsets.only( | |||||
left: 12.5, | |||||
right: 12.5, | |||||
top: 6, | |||||
bottom: 6, | |||||
), | |||||
width: double.infinity, | width: double.infinity, | ||||
decoration: BoxDecoration( | decoration: BoxDecoration( | ||||
borderRadius: BorderRadius.circular(7.5), color: Colors.white), | borderRadius: BorderRadius.circular(7.5), color: Colors.white), |
@@ -54,7 +54,7 @@ class _MineHeaderBgWidgetState extends State<MineHeaderBgWidget> { | |||||
@override | @override | ||||
Widget build(BuildContext context) { | Widget build(BuildContext context) { | ||||
print('mmine_hider_bg_widget build'); | |||||
print('mine_header_bg_widget build ${_offsetY.toString()}'); | |||||
return Transform.translate( | return Transform.translate( | ||||
offset: Offset(0, _offsetY), | offset: Offset(0, _offsetY), | ||||
child: _content, | child: _content, | ||||
@@ -0,0 +1,104 @@ | |||||
import 'dart:ui'; | |||||
import 'package:flutter/cupertino.dart'; | |||||
import 'package:flutter/material.dart'; | |||||
import 'package:zhiying_base_widget/pages/mine_page/mine_page.dart'; | |||||
class NormalNavDelegate extends SliverPersistentHeaderDelegate { | |||||
double _height; | |||||
NormalNavDelegate() : super() { | |||||
_height = MediaQueryData.fromWindow(window).padding.top + 44; | |||||
} | |||||
@override | |||||
Widget build( | |||||
BuildContext context, double shrinkOffset, bool overlapsContent) { | |||||
print('${shrinkOffset.toString()}'); | |||||
double percent = shrinkOffset / _height; | |||||
print('${percent.toString()}'); | |||||
return NormalNav(Colors.red.withOpacity(percent)); | |||||
} | |||||
@override | |||||
double get maxExtent => _height; | |||||
@override | |||||
double get minExtent => _height; | |||||
@override | |||||
bool shouldRebuild(SliverPersistentHeaderDelegate oldDelegate) => | |||||
false; // 如果内容需要更新,设置为true | |||||
} | |||||
class NormalNav extends StatelessWidget { | |||||
final Color color; | |||||
NormalNav(this.color); | |||||
@override | |||||
Widget build(BuildContext context) { | |||||
return Container( | |||||
color: color, | |||||
child: Column( | |||||
children: <Widget>[ | |||||
Expanded(child: Container()), | |||||
Container( | |||||
width: double.infinity, | |||||
height: 44, | |||||
child: Row( | |||||
crossAxisAlignment: CrossAxisAlignment.center, | |||||
children: <Widget>[ | |||||
Navigator.of(context).canPop() | |||||
? GestureDetector( | |||||
child: Container( | |||||
width: 44, | |||||
height: 44, | |||||
child: Icon( | |||||
Icons.arrow_back_ios, | |||||
color: Colors.white, | |||||
), | |||||
), | |||||
onTap: () { | |||||
if (Navigator.canPop(context)) { | |||||
Navigator.pop(context); | |||||
} | |||||
}, | |||||
) | |||||
: Container( | |||||
width: 44, | |||||
height: 44, | |||||
), | |||||
Expanded( | |||||
child: Container( | |||||
child: Center( | |||||
child: Text( | |||||
'我的钱包', | |||||
style: TextStyle(fontSize: 18, color: Colors.white), | |||||
), | |||||
), | |||||
), | |||||
), | |||||
GestureDetector( | |||||
child: Container( | |||||
width: 44, | |||||
height: 44, | |||||
child: Icon( | |||||
Icons.settings, | |||||
color: Colors.white, | |||||
), | |||||
), | |||||
onTap: () { | |||||
Navigator.push(context, | |||||
MaterialPageRoute(builder: (context) { | |||||
return MinePage(); | |||||
})); | |||||
}, | |||||
), | |||||
], | |||||
), | |||||
) | |||||
], | |||||
)); | |||||
} | |||||
} |
@@ -0,0 +1,21 @@ | |||||
import 'package:flutter/material.dart'; | |||||
import 'package:zhiying_base_widget/widgets/others/normal_nav/normal_nav.dart'; | |||||
import 'package:zhiying_comm/zhiying_comm.dart'; | |||||
class NormalNavCreater extends WidgetCreater { | |||||
@override | |||||
List<Widget> createWidgets(Map<String, dynamic> model) { | |||||
return [ | |||||
SliverPersistentHeader( | |||||
pinned: true, | |||||
floating: true, | |||||
delegate: NormalNavDelegate(), | |||||
), | |||||
]; | |||||
} | |||||
@override | |||||
bool isSliverChild() { | |||||
return true; | |||||
} | |||||
} |
@@ -0,0 +1,13 @@ | |||||
import 'package:flutter/cupertino.dart'; | |||||
import 'package:flutter/material.dart'; | |||||
import 'package:zhiying_base_widget/widgets/wallet/wallet_data/wallet_data_sk.dart'; | |||||
class WalletData extends StatelessWidget { | |||||
@override | |||||
Widget build(BuildContext context) { | |||||
return Container( | |||||
width: double.infinity, | |||||
child: WalletDataSkeleton(), | |||||
); | |||||
} | |||||
} |
@@ -0,0 +1,12 @@ | |||||
import 'package:flutter/material.dart'; | |||||
import 'package:zhiying_base_widget/widgets/wallet/wallet_data/wallet_data.dart'; | |||||
import 'package:zhiying_comm/zhiying_comm.dart'; | |||||
class WalletDataCreater extends WidgetCreater { | |||||
@override | |||||
List<Widget> createWidgets(Map<String, dynamic> model) { | |||||
return [ | |||||
WalletData(), | |||||
]; | |||||
} | |||||
} |
@@ -0,0 +1,111 @@ | |||||
import 'package:flutter/material.dart'; | |||||
import 'package:shimmer/shimmer.dart'; | |||||
class WalletDataSkeleton extends StatelessWidget { | |||||
@override | |||||
Widget build(BuildContext context) { | |||||
return Container( | |||||
margin: EdgeInsets.only(left: 12.5, right: 12.5, top: 4, bottom: 4), | |||||
decoration: BoxDecoration( | |||||
color: Colors.white, borderRadius: BorderRadius.circular(7.5)), | |||||
child: Shimmer.fromColors( | |||||
baseColor: Colors.grey[300], | |||||
highlightColor: Colors.grey[100], | |||||
child: Column( | |||||
children: <Widget>[ | |||||
Container( | |||||
width: double.infinity, | |||||
height: 85, | |||||
child: Row( | |||||
children: <Widget>[ | |||||
Container( | |||||
margin: EdgeInsets.only(left: 15), | |||||
width: 26, | |||||
height: 34, | |||||
decoration: BoxDecoration( | |||||
color: Colors.white, | |||||
borderRadius: BorderRadius.circular(4)), | |||||
), | |||||
Expanded( | |||||
child: Column( | |||||
mainAxisAlignment: MainAxisAlignment.center, | |||||
children: <Widget>[ | |||||
Row( | |||||
crossAxisAlignment: CrossAxisAlignment.center, | |||||
children: <Widget>[ | |||||
Expanded( | |||||
child: _createText1(), | |||||
) | |||||
], | |||||
) | |||||
], | |||||
)) | |||||
], | |||||
), | |||||
), | |||||
Container( | |||||
width: double.infinity, | |||||
height: 60, | |||||
child: Row( | |||||
crossAxisAlignment: CrossAxisAlignment.center, | |||||
mainAxisAlignment: MainAxisAlignment.center, | |||||
children: <Widget>[ | |||||
Expanded( | |||||
child: _createText2(), | |||||
), | |||||
Expanded( | |||||
child: _createText2(), | |||||
), | |||||
Expanded( | |||||
child: _createText2(), | |||||
) | |||||
], | |||||
), | |||||
), | |||||
], | |||||
), | |||||
), | |||||
); | |||||
} | |||||
Widget _createText1() { | |||||
return Column( | |||||
crossAxisAlignment: CrossAxisAlignment.start, | |||||
mainAxisAlignment: MainAxisAlignment.center, | |||||
children: <Widget>[ | |||||
Container( | |||||
margin: EdgeInsets.only(left: 15), | |||||
height: 15, | |||||
width: 120, | |||||
color: Colors.white, | |||||
), | |||||
Container( | |||||
margin: EdgeInsets.only(left: 15, right: 15, top: 4), | |||||
height: 15, | |||||
color: Colors.white, | |||||
), | |||||
], | |||||
); | |||||
} | |||||
Widget _createText2() { | |||||
return Column( | |||||
crossAxisAlignment: CrossAxisAlignment.start, | |||||
mainAxisAlignment: MainAxisAlignment.center, | |||||
children: <Widget>[ | |||||
Container( | |||||
margin: EdgeInsets.only(left: 15), | |||||
height: 15, | |||||
width: 44, | |||||
color: Colors.white, | |||||
), | |||||
Container( | |||||
margin: EdgeInsets.only(left: 15, top: 6), | |||||
height: 15, | |||||
width: 64, | |||||
color: Colors.white, | |||||
), | |||||
], | |||||
); | |||||
} | |||||
} |
@@ -0,0 +1,18 @@ | |||||
import 'package:flutter/cupertino.dart'; | |||||
import 'package:flutter/material.dart'; | |||||
import 'package:zhiying_base_widget/pages/withdraw_page/withdraw_page.dart'; | |||||
import 'package:zhiying_base_widget/widgets/wallet/wallet_detail/wallet_detail_sk.dart'; | |||||
class WalletDetail extends StatelessWidget { | |||||
@override | |||||
Widget build(BuildContext context) { | |||||
return GestureDetector( | |||||
child: WalletDetailSkeleton(), | |||||
onTap: () { | |||||
Navigator.push(context, MaterialPageRoute(builder: (context) { | |||||
return WithdrawPage(); | |||||
})); | |||||
}, | |||||
); | |||||
} | |||||
} |
@@ -0,0 +1,34 @@ | |||||
import 'package:flutter/material.dart'; | |||||
import 'package:shimmer/shimmer.dart'; | |||||
class WalletDetailSkeleton extends StatelessWidget { | |||||
@override | |||||
Widget build(BuildContext context) { | |||||
return Container( | |||||
margin: EdgeInsets.only(left: 12.5, right: 12.5, top: 4, bottom: 4), | |||||
padding: EdgeInsets.only(left: 15, right: 15, top: 10, bottom: 10), | |||||
decoration: BoxDecoration( | |||||
color: Colors.white, borderRadius: BorderRadius.circular(7.5)), | |||||
child: Shimmer.fromColors( | |||||
baseColor: Colors.grey[300], | |||||
highlightColor: Colors.grey[100], | |||||
child: Row( | |||||
children: <Widget>[ | |||||
Container( | |||||
width: 18, | |||||
height: 18, | |||||
decoration: BoxDecoration( | |||||
borderRadius: BorderRadius.circular(9), | |||||
color: Colors.white), | |||||
), | |||||
Container( | |||||
margin: EdgeInsets.only(left: 8), | |||||
width: 120, | |||||
height: 14, | |||||
color: Colors.white, | |||||
), | |||||
], | |||||
)), | |||||
); | |||||
} | |||||
} |
@@ -0,0 +1,9 @@ | |||||
import 'package:flutter/material.dart'; | |||||
import 'package:zhiying_base_widget/widgets/wallet/wallet_income/wallet_income_sk.dart'; | |||||
class WalletIncome extends StatelessWidget { | |||||
@override | |||||
Widget build(BuildContext context) { | |||||
return WalletIncomeSkeleton(); | |||||
} | |||||
} |
@@ -0,0 +1,104 @@ | |||||
import 'package:flutter/material.dart'; | |||||
import 'package:shimmer/shimmer.dart'; | |||||
class WalletIncomeSkeleton extends StatelessWidget { | |||||
@override | |||||
Widget build(BuildContext context) { | |||||
return Container( | |||||
margin: EdgeInsets.only(left: 12.5, right: 12.5, top: 4, bottom: 4), | |||||
padding: EdgeInsets.only(left: 15, right: 15, top: 10, bottom: 10), | |||||
decoration: BoxDecoration( | |||||
color: Colors.white, borderRadius: BorderRadius.circular(7.5)), | |||||
child: Shimmer.fromColors( | |||||
baseColor: Colors.grey[300], | |||||
highlightColor: Colors.grey[100], | |||||
child: Column( | |||||
children: <Widget>[ | |||||
Container( | |||||
width: double.infinity, | |||||
child: _createTab(), | |||||
), | |||||
Container( | |||||
margin: EdgeInsets.only(top: 6), | |||||
width: double.infinity, | |||||
child: _createTags(), | |||||
), | |||||
Container( | |||||
margin: EdgeInsets.only(top: 6), | |||||
height: 64, | |||||
decoration: BoxDecoration( | |||||
borderRadius: BorderRadius.circular(7.5), | |||||
color: Colors.white), | |||||
), | |||||
_createDataRow(), | |||||
_createDataRow(), | |||||
_createDataRow(), | |||||
], | |||||
)), | |||||
); | |||||
} | |||||
Widget _createTab() { | |||||
return Row( | |||||
children: List.generate(5, (index) { | |||||
return Expanded( | |||||
child: Container( | |||||
height: 14, | |||||
margin: EdgeInsets.only(left: 10, right: 10, top: 4, bottom: 4), | |||||
color: Colors.white, | |||||
), | |||||
); | |||||
}), | |||||
); | |||||
} | |||||
Widget _createTags() { | |||||
return Row( | |||||
children: List.generate(5, (index) { | |||||
return Expanded( | |||||
child: Container( | |||||
height: 20, | |||||
margin: EdgeInsets.only(left: 10, right: 10, top: 4, bottom: 4), | |||||
decoration: BoxDecoration( | |||||
color: Colors.white, borderRadius: BorderRadius.circular(10)), | |||||
), | |||||
); | |||||
}), | |||||
); | |||||
} | |||||
Widget _createDataRow() { | |||||
return Column( | |||||
children: <Widget>[ | |||||
Container( | |||||
margin: EdgeInsets.only(top: 8, bottom: 2), | |||||
width: 64, | |||||
height: 18, | |||||
color: Colors.white, | |||||
), | |||||
Row( | |||||
children: <Widget>[ | |||||
Expanded( | |||||
child: Container( | |||||
margin: EdgeInsets.only(top: 6, right: 5), | |||||
height: 64, | |||||
decoration: BoxDecoration( | |||||
borderRadius: BorderRadius.circular(7.5), | |||||
color: Colors.white), | |||||
), | |||||
), | |||||
Expanded( | |||||
child: Container( | |||||
margin: EdgeInsets.only(top: 6, left: 5), | |||||
height: 64, | |||||
decoration: BoxDecoration( | |||||
borderRadius: BorderRadius.circular(7.5), | |||||
color: Colors.white), | |||||
), | |||||
) | |||||
], | |||||
) | |||||
], | |||||
); | |||||
} | |||||
} |