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