|
|
@@ -1,3 +1,5 @@ |
|
|
|
import 'dart:ui'; |
|
|
|
|
|
|
|
import 'package:flutter/cupertino.dart'; |
|
|
|
import 'package:flutter/material.dart'; |
|
|
|
import 'package:provider/provider.dart'; |
|
|
@@ -18,8 +20,7 @@ import 'package:zhiying_comm/zhiying_comm.dart'; |
|
|
|
class MainPage extends StatefulWidget { |
|
|
|
final Map<String, dynamic> data; |
|
|
|
|
|
|
|
MainPage( |
|
|
|
this.data, { |
|
|
|
MainPage(this.data, { |
|
|
|
Key key, |
|
|
|
}) : super(key: key); |
|
|
|
|
|
|
@@ -58,7 +59,7 @@ class _MainPageContainerState extends State<_MainPageContainer> |
|
|
|
ScrollController _controller = ScrollController(); |
|
|
|
MainPageBloc _bloc; |
|
|
|
RefreshController _refreshController = |
|
|
|
RefreshController(initialRefresh: false); |
|
|
|
RefreshController(initialRefresh: false); |
|
|
|
|
|
|
|
Widget _floatWidget; |
|
|
|
|
|
|
@@ -69,8 +70,12 @@ class _MainPageContainerState extends State<_MainPageContainer> |
|
|
|
} |
|
|
|
|
|
|
|
void _onRefresh() async { |
|
|
|
await Duration(microseconds: 3); |
|
|
|
_refreshController.refreshCompleted(); |
|
|
|
// await Future.delayed(Duration(milliseconds: 3000)); |
|
|
|
// _refreshController.refreshCompleted(); |
|
|
|
|
|
|
|
if (widget.data.containsKey('skip_identifier')) { |
|
|
|
_bloc.loadData(widget.data['skip_identifier']); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@override |
|
|
@@ -117,15 +122,20 @@ class _MainPageContainerState extends State<_MainPageContainer> |
|
|
|
|
|
|
|
@override |
|
|
|
Widget build(BuildContext context) { |
|
|
|
double top = MediaQueryData |
|
|
|
.fromWindow(window) |
|
|
|
.padding |
|
|
|
.top; |
|
|
|
return StreamBuilder<List<Map<String, dynamic>>>( |
|
|
|
stream: _bloc.outData, |
|
|
|
builder: (BuildContext context, AsyncSnapshot snapshot) { |
|
|
|
List widgets = _createContent(context, snapshot.data ?? []); |
|
|
|
_refreshController.refreshCompleted(); |
|
|
|
return Scaffold( |
|
|
|
backgroundColor: Color(0xfff9f9f9), |
|
|
|
floatingActionButton: _floatWidget, |
|
|
|
floatingActionButtonLocation: |
|
|
|
FloatingActionButtonLocation.centerDocked, |
|
|
|
FloatingActionButtonLocation.centerDocked, |
|
|
|
body: MediaQuery.removePadding( |
|
|
|
removeTop: true, |
|
|
|
context: context, |
|
|
@@ -140,7 +150,9 @@ class _MainPageContainerState extends State<_MainPageContainer> |
|
|
|
SmartRefresher( |
|
|
|
enablePullDown: true, |
|
|
|
enablePullUp: false, |
|
|
|
header: RefreshHeader(), |
|
|
|
header: RefreshHeader( |
|
|
|
offsetY: top, |
|
|
|
), |
|
|
|
controller: _refreshController, |
|
|
|
onLoading: _onLoading, |
|
|
|
onRefresh: _onRefresh, |
|
|
@@ -157,12 +169,12 @@ class _MainPageContainerState extends State<_MainPageContainer> |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
List<Widget> _createContent( |
|
|
|
BuildContext context, List<Map<String, dynamic>> datas) { |
|
|
|
List<Widget> _createContent(BuildContext context, |
|
|
|
List<Map<String, dynamic>> datas) { |
|
|
|
List<Widget> list = List(); |
|
|
|
for (int i = 0; i < datas.length; i++) { |
|
|
|
WidgetModel item = |
|
|
|
WidgetModel.fromJson(Map<String, dynamic>.from(datas[i])); |
|
|
|
WidgetModel.fromJson(Map<String, dynamic>.from(datas[i])); |
|
|
|
|
|
|
|
print('item.modName ${item.modName}'); |
|
|
|
if (item.modName == 'index_taobao_auth_tip') { |
|
|
|