@@ -680,7 +680,7 @@ | |||
"languageVersion": "2.1" | |||
} | |||
], | |||
"generated": "2020-09-10T07:09:00.863118Z", | |||
"generated": "2020-09-11T04:26:30.812379Z", | |||
"generator": "pub", | |||
"generatorVersion": "2.7.2" | |||
} |
@@ -1,13 +1,14 @@ | |||
import 'dart:async'; | |||
import 'package:zhiying_comm/zhiying_comm.dart'; | |||
import 'package:zhiying_comm/util/base_bloc.dart'; | |||
import 'package:zhiying_comm/zhiying_comm.dart'; | |||
class HomePageBloc 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 | |||
@@ -17,12 +18,18 @@ class HomePageBloc extends BlocBase { | |||
} | |||
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); | |||
NetUtil.request('/api/v1/config.json', onCache: (data) { | |||
_refresh(data); | |||
}, onSuccess: (data) { | |||
_refresh(data); | |||
}); | |||
} | |||
void _refresh(dynamic data) { | |||
List list = data; | |||
_tabs = list.map((item) { | |||
return Map<String, dynamic>.from(item); | |||
}).toList(); | |||
_tabController.add(_tabs); | |||
} | |||
} |
@@ -71,6 +71,10 @@ class _MainPageContainerState extends State<_MainPageContainer> { | |||
@override | |||
void initState() { | |||
_bloc = BlocProvider.of<MainPageBloc>(context); | |||
if (widget.data.containsKey('mod_id')) { | |||
_bloc.loadData(widget.data['mod_id']); | |||
} | |||
_controller.addListener(() { | |||
// print('${_controller.offset} ${_controller.position.maxScrollExtent}'); | |||
if (_controller.offset >= _controller.position.maxScrollExtent && | |||
@@ -89,21 +93,21 @@ class _MainPageContainerState extends State<_MainPageContainer> { | |||
@override | |||
Widget build(BuildContext context) { | |||
return StreamBuilder<Map<String, dynamic>>( | |||
stream: _bloc.outData, | |||
builder: (BuildContext context, AsyncSnapshot snapshot) { | |||
return MediaQuery.removePadding( | |||
removeTop: true, | |||
context: context, | |||
child: SmartRefresher( | |||
enablePullDown: false, | |||
enablePullUp: false, | |||
header: WaterDropHeader(), | |||
controller: _refreshController, | |||
onLoading: _onLoading, | |||
child: Container( | |||
width: double.infinity, | |||
child: Stack( | |||
return MediaQuery.removePadding( | |||
removeTop: true, | |||
context: context, | |||
child: SmartRefresher( | |||
enablePullDown: false, | |||
enablePullUp: false, | |||
header: WaterDropHeader(), | |||
controller: _refreshController, | |||
onLoading: _onLoading, | |||
child: Container( | |||
width: double.infinity, | |||
child: StreamBuilder<List<Map<String, dynamic>>>( | |||
stream: _bloc.outData, | |||
builder: (BuildContext context, AsyncSnapshot snapshot) { | |||
return Stack( | |||
fit: StackFit.passthrough, | |||
children: <Widget>[ | |||
MineHeaderBgWidget( | |||
@@ -111,34 +115,29 @@ class _MainPageContainerState extends State<_MainPageContainer> { | |||
), | |||
CustomScrollView( | |||
controller: _controller, | |||
slivers: _createContent(context), | |||
slivers: _createContent(context, snapshot.data ?? []), | |||
) | |||
], | |||
), | |||
), | |||
)); | |||
}, | |||
); | |||
}, | |||
), | |||
)), | |||
); | |||
} | |||
List<Widget> _createContent(BuildContext context) { | |||
WidgetModel model = WidgetModel.fromJson(widget.data); | |||
List<Widget> _createContent( | |||
BuildContext context, List<Map<String, dynamic>> datas) { | |||
List<Widget> list = List(); | |||
for (int i = 0; i < model.components.length; i++) { | |||
WidgetModel item = model.components[i]; | |||
Map<String, dynamic> data = Map(); | |||
if (widget.data.containsKey('components')) { | |||
data = widget.data['components'][i]; | |||
} | |||
for (int i = 0; i < datas.length; i++) { | |||
WidgetModel item = | |||
WidgetModel.fromJson(Map<String, dynamic>.from(datas[i])); | |||
list.addAll(WidgetFactory.create( | |||
item.modName, | |||
isSliver: true, | |||
model: data, | |||
model: datas[i], | |||
)); | |||
} | |||
model.components.forEach((item) {}); | |||
return list; | |||
} | |||
} |
@@ -1,14 +1,15 @@ | |||
import 'dart:async'; | |||
import 'package:zhiying_comm/zhiying_comm.dart'; | |||
import 'package:zhiying_comm/util/base_bloc.dart'; | |||
import 'package:zhiying_comm/zhiying_comm.dart'; | |||
class MainPageBloc extends BlocBase { | |||
Map<String, dynamic> _mains = Map(); | |||
List<Map<String, dynamic>> _pageData = List(); | |||
StreamController<Map<String, dynamic>> _mainController = | |||
StreamController<Map<String, dynamic>>(); | |||
Stream<Map<String, dynamic>> get outData => _mainController.stream; | |||
StreamController<List<Map<String, dynamic>>> _mainController = | |||
StreamController<List<Map<String, dynamic>>>(); | |||
Stream<List<Map<String, dynamic>>> get outData => _mainController.stream; | |||
@override | |||
void dispose() { | |||
@@ -16,13 +17,28 @@ class MainPageBloc extends BlocBase { | |||
_mainController = null; | |||
} | |||
void loadData(List<int> ids) { | |||
NetUtil.request('/api/v1/config.json', onSuccess: (data) { | |||
List list = data; | |||
List<Map<String, dynamic>> tabs = list.map((item) { | |||
void loadData(int id) { | |||
NetUtil.request('/api/v1/mod', | |||
method: NetMethod.POST, | |||
params: Map<String, dynamic>.from({ | |||
'ids': [id] | |||
}), onCache: (data) { | |||
_loadData(id, data); | |||
}, 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]; | |||
_pageData = list.map((item) { | |||
return Map<String, dynamic>.from(item); | |||
}).toList(); | |||
_mainController.add(tabs.first); | |||
}); | |||
} | |||
_mainController.add(_pageData); | |||
} | |||
} |
@@ -1,12 +1,16 @@ | |||
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/main_page/main_page.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_banner/home_banner_widget.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_data/mine_data.dart'; | |||
import 'package:zhiying_base_widget/widgets/mine/mine_header/mine_header.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_creater.dart'; | |||
import 'package:zhiying_base_widget/widgets/mine/mine_quick_entry/mine_quick_entry.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'; | |||
@@ -24,7 +28,7 @@ class BaseWidgetRegister { | |||
static void registPage() { | |||
PageFactory.regist('homePage', (model) => HomePage()); | |||
PageFactory.regist('index', (model) => MainPage(model)); | |||
PageFactory.regist('login', (model) => LoginPage(model)); | |||
PageFactory.regist('profile', (model) => MainPage(model)); | |||
PageFactory.regist('category', (model) => WalletPage()); | |||
} | |||
@@ -49,8 +53,19 @@ class BaseWidgetRegister { | |||
WidgetFactory.regist('index_banner_two', HomeBannerCreater()); | |||
// ==================== 个人中心 | |||
WidgetFactory.regist('profile_appbar', MineNavCreater()); | |||
WidgetFactory.regist('profile_background', | |||
DefaultWidgetCreater((model) => MineNavBg(model))); | |||
WidgetFactory.regist( | |||
'index_title', DefaultWidgetCreater((model) => MineHeader())); | |||
'profile_header', DefaultWidgetCreater((model) => MineHeader(model))); | |||
WidgetFactory.regist( | |||
'profile_earning', DefaultWidgetCreater((model) => MineData())); | |||
WidgetFactory.regist( | |||
'profile_functions', DefaultWidgetCreater((model) => MineQuickEntry())); | |||
WidgetFactory.regist('profile_my_functions', | |||
DefaultWidgetCreater((model) => MineQuickEntry())); | |||
WidgetFactory.regist('profile_carousel', | |||
DefaultWidgetCreater((model) => HomeBannerWidget(model))); | |||
// ==================== 钱包 | |||
WidgetFactory.regist( | |||
@@ -3,12 +3,30 @@ import 'package:flutter/material.dart'; | |||
import 'mine_header_sk.dart'; | |||
class MineHeader extends StatelessWidget { | |||
class MineHeader extends StatefulWidget { | |||
final Map<String, dynamic> data; | |||
const MineHeader(this.data, {Key key}) : super(key: key); | |||
@override | |||
_MineHeaderState createState() => _MineHeaderState(); | |||
} | |||
class _MineHeaderState extends State<MineHeader> { | |||
@override | |||
Widget build(BuildContext context) { | |||
return _MineContainer(); | |||
} | |||
} | |||
class _MineContainer extends StatefulWidget { | |||
@override | |||
_MineContainerState createState() => _MineContainerState(); | |||
} | |||
class _MineContainerState extends State<_MineContainer> { | |||
@override | |||
Widget build(BuildContext context) { | |||
return Container( | |||
width: double.infinity, | |||
child: MineHeaderSkeleton(), | |||
); | |||
return MineHeaderSkeleton(); | |||
} | |||
} |
@@ -0,0 +1,37 @@ | |||
import 'dart:async'; | |||
import 'package:zhiying_comm/util/base_bloc.dart'; | |||
import 'package:zhiying_comm/zhiying_comm.dart'; | |||
class MineHeaderBloc extends BlocBase { | |||
Map<String, dynamic> _mineData; | |||
StreamController<Map<String, dynamic>> _mineController = | |||
StreamController<Map<String, dynamic>>(); | |||
Stream<Map<String, dynamic>> get outData => _mineController.stream; | |||
@override | |||
void dispose() { | |||
_mineController.close(); | |||
_mineController = null; | |||
} | |||
void loadData(int id) { | |||
NetUtil.request('/api/v1/mod', | |||
method: NetMethod.POST, | |||
params: Map<String, dynamic>.from({ | |||
'ids': [id] | |||
}), | |||
onCache: (data) {}, onSuccess: (data) { | |||
_loadData(id, data); | |||
}); | |||
} | |||
void _loadData(int id, dynamic data) { | |||
String key = id.toString(); | |||
Map<String, dynamic> json = Map<String, dynamic>.from(data); | |||
_mineController.add(_mineData); | |||
} | |||
} |
@@ -1,12 +0,0 @@ | |||
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(), | |||
]; | |||
} | |||
} |
@@ -1,22 +1,53 @@ | |||
import 'dart:convert' as convert; | |||
import 'dart:ui'; | |||
import 'package:cached_network_image/cached_network_image.dart'; | |||
import 'package:flutter/cupertino.dart'; | |||
import 'package:flutter/material.dart'; | |||
import 'package:zhiying_comm/zhiying_comm.dart'; | |||
class MineNavDelegate extends SliverPersistentHeaderDelegate { | |||
final Map<String, dynamic> data; | |||
double _height; | |||
Color _color; | |||
MineNavDelegate() : super() { | |||
List<Widget> _icons = List(); | |||
MineNavDelegate(this.data) : super() { | |||
_height = MediaQueryData.fromWindow(window).padding.top + 44; | |||
String d = data['data']; | |||
Map<String, dynamic> json = convert.jsonDecode(d); | |||
if (json.containsKey('app_bar_bg_color')) { | |||
_color = HexColor.fromHex(json['app_bar_bg_color']); | |||
} else { | |||
_color = Colors.amber; | |||
} | |||
if (json.containsKey('app_bar_icons')) { | |||
List icons = json['app_bar_icons']; | |||
_icons = icons.map((icon) { | |||
SkipModel model = SkipModel.fromJson(Map<String, dynamic>.from(icon)); | |||
return GestureDetector( | |||
child: Container( | |||
width: 24, | |||
height: 24, | |||
margin: EdgeInsets.only(left: 6), | |||
child: CachedNetworkImage( | |||
imageUrl: model.icon, | |||
), | |||
), | |||
onTap: () { | |||
print('页面跳转 ${model.skipIdentifier}'); | |||
}, | |||
); | |||
}).toList(); | |||
} | |||
} | |||
@override | |||
Widget build( | |||
BuildContext context, double shrinkOffset, bool overlapsContent) { | |||
// print('${shrinkOffset.toString()}'); | |||
double percent = shrinkOffset / _height; | |||
print('${percent.toString()}'); | |||
return MineNav(Colors.red.withOpacity(percent)); | |||
return MineNav(_color.withOpacity(percent), _icons); | |||
} | |||
@override | |||
@@ -32,12 +63,14 @@ class MineNavDelegate extends SliverPersistentHeaderDelegate { | |||
class MineNav extends StatelessWidget { | |||
final Color color; | |||
final List<Widget> widgets; | |||
MineNav(this.color); | |||
MineNav(this.color, this.widgets); | |||
@override | |||
Widget build(BuildContext context) { | |||
return Container( | |||
padding: EdgeInsets.only(left: 12, right: 12), | |||
color: color, | |||
child: Column( | |||
children: <Widget>[ | |||
@@ -48,16 +81,7 @@ class MineNav extends StatelessWidget { | |||
child: Row( | |||
mainAxisAlignment: MainAxisAlignment.end, | |||
crossAxisAlignment: CrossAxisAlignment.center, | |||
children: <Widget>[ | |||
Icon( | |||
Icons.settings, | |||
color: Colors.white, | |||
), | |||
Icon( | |||
Icons.chat, | |||
color: Colors.white, | |||
) | |||
], | |||
children: this.widgets, | |||
), | |||
) | |||
], | |||
@@ -0,0 +1,44 @@ | |||
import 'package:cached_network_image/cached_network_image.dart'; | |||
import 'package:flutter/material.dart'; | |||
import 'package:provider/provider.dart'; | |||
import 'package:zhiying_base_widget/pages/main_page/notifier/main_page_bg_notifier.dart'; | |||
class MineNavBg extends StatefulWidget { | |||
final Map<String, dynamic> data; | |||
const MineNavBg(this.data, {Key key}) : super(key: key); | |||
@override | |||
_MineNavBgState createState() => _MineNavBgState(); | |||
} | |||
class _MineNavBgState extends State<MineNavBg> { | |||
@override | |||
void initState() { | |||
super.initState(); | |||
} | |||
void _updateBg() { | |||
final double statusBarHeight = MediaQuery.of(context).padding.top; | |||
if (widget.data.containsKey('img')) { | |||
Provider.of<MainPageBgNotifier>(context, listen: false).switchBg( | |||
Container( | |||
width: double.infinity, | |||
height: statusBarHeight + 250, | |||
child: CachedNetworkImage( | |||
imageUrl: widget.data['img'], | |||
fit: BoxFit.fitHeight, | |||
), | |||
), | |||
); | |||
} | |||
} | |||
@override | |||
Widget build(BuildContext context) { | |||
Future.delayed(Duration.zero, () { | |||
_updateBg(); | |||
}); | |||
return Container(); | |||
} | |||
} |
@@ -9,7 +9,7 @@ class MineNavCreater extends WidgetCreater { | |||
SliverPersistentHeader( | |||
pinned: true, | |||
floating: false, | |||
delegate: MineNavDelegate(), | |||
delegate: MineNavDelegate(model), | |||
), | |||
]; | |||
} | |||
@@ -1,12 +0,0 @@ | |||
import 'package:flutter/material.dart'; | |||
import 'package:zhiying_base_widget/widgets/mine/mine_quick_entry/mine_quick_entry.dart'; | |||
import 'package:zhiying_comm/zhiying_comm.dart'; | |||
class MineQuickEntryCreater extends WidgetCreater { | |||
@override | |||
List<Widget> createWidgets(Map<String, dynamic> model) { | |||
return [ | |||
MineQuickEntry(), | |||
]; | |||
} | |||
} |
@@ -37,56 +37,13 @@ class _MineHeaderBgWidgetState extends State<MineHeaderBgWidget> { | |||
} | |||
} | |||
@override | |||
void dispose() { | |||
super.dispose(); | |||
} | |||
@override | |||
void didChangeDependencies() { | |||
super.didChangeDependencies(); | |||
print('didChangeDependencies'); | |||
// if (isNeedLoadMore && _provider != '') { | |||
// print('HomeGoods loadmore...'); | |||
// _bloc.loadMore(_provider); | |||
} | |||
@override | |||
Widget build(BuildContext context) { | |||
print('mine_header_bg_widget build ${_offsetY.toString()}'); | |||
return Transform.translate( | |||
offset: Offset(0, _offsetY), | |||
child: _content, | |||
); | |||
} | |||
// @override | |||
// Widget build(BuildContext context) { | |||
// return Container( | |||
// height: 300, | |||
// width: double.infinity, | |||
// child: Stack( | |||
// children: imageUrls | |||
// .asMap() | |||
// .keys | |||
// .map<Widget>((i) => AnimatedOpacity( | |||
// curve: Curves.easeIn, | |||
// duration: Duration(milliseconds: 1600), | |||
// opacity: i == zIndex ? 1 : 0, | |||
// child: Container( | |||
//// color: Color(int.parse(list[i], radix: 16)) | |||
//// .withAlpha(255), | |||
// child: CachedNetworkImage( | |||
// imageUrl: imageUrls[i], | |||
// fit: BoxFit.fill, | |||
// ), | |||
// height: 300, //100% | |||
// ), | |||
// )) | |||
// .toList(), | |||
// )); | |||
// } | |||
} | |||
class _MineHeaderBgContainer extends StatefulWidget { | |||