@@ -4,6 +4,7 @@ import 'dart:ffi';
44import 'package:flutter/material.dart' ;
55import 'package:flutter_demo/dao/home_dao.dart' ;
66import 'package:flutter_demo/model/home_model.dart' ;
7+ import 'package:flutter_demo/widget/local_nav.dart' ;
78import 'package:flutter_swiper/flutter_swiper.dart' ;
89
910class HomePage extends StatefulWidget {
@@ -25,6 +26,7 @@ class _HomePageState extends State {
2526 double _appbarOp = 0.0 ;
2627
2728 var _homejson = '' ;
29+ var _localNavList = null ;
2830
2931 _onScroll (offset) {
3032 double alpha = offset / APPBAR_SCROLL_OFFSET ;
@@ -42,7 +44,6 @@ class _HomePageState extends State {
4244 @override
4345 void initState () {
4446 super .initState ();
45-
4647 _loadHomeJson ();
4748 }
4849
@@ -51,6 +52,7 @@ class _HomePageState extends State {
5152 HomeModel model = await HomeDao .fetch ();
5253 setState (() {
5354 _homejson = json.encode (model);
55+ _localNavList = model.localNavList;
5456 });
5557 } catch (e) {
5658 setState (() {
@@ -62,51 +64,55 @@ class _HomePageState extends State {
6264 @override
6365 Widget build (BuildContext context) {
6466 return Scaffold (
67+ backgroundColor: const Color (0xfff2f2f2 ),
6568 body: Stack (
66- children: [
67- MediaQuery .removePadding (
68- removeTop: true ,
69- context: context,
70- child: NotificationListener (
71- onNotification: (noti) {
72- if (noti is ScrollUpdateNotification && noti.depth == 0 ) {
73- print (noti.metrics.pixels);
74- _onScroll (noti.metrics.pixels);
75- }
76- return true ;
77- },
78- child: ListView (
79- children: [
80- Container (
81- height: 160 ,
82- child: Swiper (
83- itemCount: _imageUrl.length,
84- autoplay: true ,
85- itemBuilder: (BuildContext ctx, int idx) {
86- return Image .network (_imageUrl[idx],
87- fit: BoxFit .fill);
88- },
89- pagination:
90- SwiperPagination (alignment: Alignment .bottomCenter),
91- ),
92- ),
93- Container (
94- child: Text (_homejson),
95- height: 1000 ,
96- )
97- ],
98- ))),
99- Opacity (
100- opacity: _appbarOp,
101- child: Container (
102- height: 80 ,
103- decoration: BoxDecoration (color: Colors .white),
104- child: Center (
105- child: Padding (
106- padding: EdgeInsets .only (top: 20 ), child: Text ('Home' )),
107- ),
108- )),
109- ],
110- ));
69+ children: [
70+ MediaQuery .removePadding (
71+ removeTop: true ,
72+ context: context,
73+ child: NotificationListener (
74+ onNotification: (noti) {
75+ if (noti is ScrollUpdateNotification && noti.depth == 0 ) {
76+ print (noti.metrics.pixels);
77+ _onScroll (noti.metrics.pixels);
78+ }
79+ return true ;
80+ },
81+ child: ListView (
82+ children: [
83+ Container (
84+ height: 160 ,
85+ child: Swiper (
86+ itemCount: _imageUrl.length,
87+ autoplay: true ,
88+ itemBuilder: (BuildContext ctx, int idx) {
89+ return Image .network (_imageUrl[idx],
90+ fit: BoxFit .fill);
91+ },
92+ pagination: SwiperPagination (
93+ alignment: Alignment .bottomCenter),
94+ ),
95+ ),
96+ Padding (
97+ child: LocalNav (localNavList: _localNavList),
98+ padding: const EdgeInsets .fromLTRB (7 , 4 , 7 , 4 )),
99+ Container (
100+ child: Text (_homejson),
101+ height: 1000 ,
102+ )
103+ ],
104+ ))),
105+ Opacity (
106+ opacity: _appbarOp,
107+ child: Container (
108+ height: 80 ,
109+ decoration: BoxDecoration (color: Colors .white),
110+ child: Center (
111+ child: Padding (
112+ padding: EdgeInsets .only (top: 20 ), child: Text ('Home' )),
113+ ),
114+ )),
115+ ],
116+ ));
111117 }
112118}
0 commit comments