1
1
import 'package:flutter/material.dart' ;
2
+ import 'package:hawalnir1/src/pages/listView.dart' ;
3
+ import 'package:hawalnir1/src/widgets/animated_fab.dart' ;
2
4
import 'package:hawalnir1/src/widgets/eachPost.dart' ;
3
5
import 'package:http/http.dart' as http;
4
6
import 'widgets/drawerMain.dart' ;
@@ -14,17 +16,90 @@ WordpressClient client = new WordpressClient(_baseUrl, http.Client());
14
16
final String _baseUrl = 'http://ehawal.com/index.php/wp-json' ;
15
17
16
18
var dbHelper = DatabaseHelper ();
17
- int perPageInt = int .parse (perPage);
18
19
19
20
class HawalnirHome2 extends StatefulWidget {
20
21
@override
21
22
State <StatefulWidget > createState () => HawalnirHome2State ();
22
23
}
23
24
24
- class HawalnirHome2State extends State {
25
+ class HawalnirHome2State extends State <HawalnirHome2 >
26
+ with TickerProviderStateMixin {
27
+ var scrollCont =
28
+ ScrollController (initialScrollOffset: 0.0 , keepScrollOffset: true );
29
+ final GlobalKey <ScaffoldState > _scaffoldKey = GlobalKey <ScaffoldState >();
30
+
25
31
@override
26
32
Widget build (BuildContext context) {
27
33
return Scaffold (
34
+ key: _scaffoldKey,
35
+ // drawer: drawerMain(context),
36
+ endDrawer: drawerMain (context),
37
+ bottomNavigationBar: SizedBox (
38
+ height: 60 ,
39
+ child: BottomAppBar (
40
+
41
+ color: Colors .deepPurple,
42
+ notchMargin: 3.0 ,
43
+ shape: CircularNotchedRectangle (),
44
+ child: ButtonBar (
45
+ mainAxisSize: MainAxisSize .max,
46
+ alignment: MainAxisAlignment .spaceEvenly,
47
+ children: < Widget > [
48
+ IconButton (
49
+ padding: EdgeInsets .only (bottom: 10.0 ),
50
+ icon: Icon (Icons .save),
51
+ splashColor: Colors .blueAccent[200 ],
52
+ color: Colors .blueGrey,
53
+ tooltip: 'پاشكهوت كردنی بابهت' ,
54
+ onPressed: () {
55
+ Navigator .pushNamed (context, '/InstaPage' );
56
+ },
57
+ ),
58
+ IconButton (
59
+ padding: EdgeInsets .only (bottom: 10.0 ),
60
+ icon: Icon (Icons .favorite),
61
+ splashColor: Colors .redAccent,
62
+ color: Colors .blueGrey,
63
+ tooltip: 'پهسهند كردن' ,
64
+ onPressed: () {}, // add +1 to the database
65
+ ),
66
+ Divider (),
67
+ Divider (),
68
+ IconButton (
69
+ padding: EdgeInsets .only (bottom: 10.0 ),
70
+
71
+ icon: Icon (Icons .share),
72
+ color: Colors .blueGrey,
73
+ tooltip: 'بو هاورێكانت بنێره' ,
74
+ onPressed:
75
+ () {}, // Standard share for whatsapp + google + faccebook + twitter
76
+ ),
77
+ IconButton (
78
+ padding: EdgeInsets .only (bottom: 10.0 ),
79
+
80
+ icon: Icon (Icons .share),
81
+ color: Colors .blueGrey,
82
+ tooltip: 'بو هاورێكانت بنێره' ,
83
+ onPressed:
84
+ () {}, // Standard share for whatsapp + google + faccebook + twitter
85
+ ),
86
+ ],
87
+ ),
88
+ ),
89
+ ),
90
+ floatingActionButton: FloatingActionButton (
91
+ isExtended: false ,
92
+ elevation: 10.0 ,
93
+ shape: CircleBorder (),
94
+ child: Icon (Icons .menu),
95
+ backgroundColor: Colors .deepPurple,
96
+ onPressed: () {
97
+ debugPrint ("Drawer opened" );
98
+
99
+ _scaffoldKey.currentState.openEndDrawer ();
100
+ }),
101
+ floatingActionButtonLocation: FloatingActionButtonLocation .centerDocked,
102
+ resizeToAvoidBottomPadding: true ,
28
103
body: OfflineBuilder (
29
104
debounceDuration: Duration (seconds: 3 ),
30
105
connectivityBuilder: (
@@ -36,31 +111,28 @@ class HawalnirHome2State extends State {
36
111
return new Stack (
37
112
fit: StackFit .expand,
38
113
children: [
114
+ FutureBuilder <List <Post >>(
115
+ future: isExitst (),
116
+ builder: (context, snapshot) {
117
+ if (snapshot.hasError) print (snapshot.error);
39
118
40
- RefreshIndicator (
41
- onRefresh: isExitst,
42
- child: FutureBuilder <List <Post >>(
43
- future: isExitst (),
44
- builder: (context, snapshot) {
45
- if (snapshot.hasError) print (snapshot.error);
46
-
47
- return snapshot.hasData
48
- ? ListViewPosts2 (posts: snapshot.data)
49
- : Center (child: CircularProgressIndicator ());
50
- },
51
- ),
119
+ return snapshot.hasData
120
+ ? ListViewPosts (posts: snapshot.data)
121
+ : Center (child: CircularProgressIndicator ());
122
+ },
52
123
),
53
124
Positioned (
54
125
height: 24.0 ,
55
126
left: 0.0 ,
56
127
right: 0.0 ,
57
128
bottom: 0.0 ,
58
-
59
129
child: Container (
60
- color: connected ? Color (0xFF00EE44 ) : Color (0xFFEE4400 ),
61
- child: Center (
62
- child: Text ("${connected ? 'ONLINE' : 'OFFLINE' }" ),
63
- ),
130
+ color:
131
+ connected ? null : Color (0xFFEE4400 ),
132
+ child: Padding (
133
+ padding: EdgeInsets .all (5.0 ),
134
+ child: Text ("${connected ? '' : 'OFFLINE' }" ,
135
+ textDirection: TextDirection .rtl)),
64
136
),
65
137
),
66
138
],
@@ -80,47 +152,6 @@ class HawalnirHome2State extends State {
80
152
}
81
153
}
82
154
83
- class ListViewPosts2 extends StatefulWidget {
84
- final List <Post > posts;
85
-
86
- ListViewPosts2 ({Key key, this .posts}) : super (key: key);
87
-
88
- @override
89
- ListViewPosts2State createState () {
90
- return new ListViewPosts2State ();
91
- }
92
- }
93
-
94
- var scrollCont =
95
- ScrollController (initialScrollOffset: 0.0 , keepScrollOffset: true );
96
-
97
- class ListViewPosts2State extends State <ListViewPosts2 > {
98
- var dbHelper = DatabaseHelper ();
99
- List <Post > postList;
100
- int count = 0 ;
101
-
102
- @override
103
- Widget build (BuildContext context) {
104
- getPostsIDs ();
105
- return Directionality (
106
- textDirection: TextDirection .rtl, // RTL
107
-
108
- child: Scaffold (
109
- body: Stack (
110
- children: < Widget > [
111
- CustomScrollView (
112
- slivers: < Widget > [
113
- sliverAppBarGlobal (),
114
- sliverListGlobal (),
115
- ],
116
- ),
117
- ],
118
- ),
119
- ),
120
- );
121
- }
122
- }
123
-
124
155
// return OfflineBuilder(
125
156
// debounceDuration: Duration(seconds: 3),
126
157
// connectivityBuilder: (
@@ -217,11 +248,6 @@ class ListViewPosts2State extends State<ListViewPosts2> {
217
248
// ),
218
249
// );
219
250
220
- void _scrollToTop () {
221
- scrollCont.animateTo (0.0 ,
222
- duration: Duration (seconds: 1 ), curve: Curves .elasticInOut);
223
- }
224
-
225
251
// child: CustomScrollView(
226
252
// slivers: <Widget>[
227
253
// SliverAppBar(
0 commit comments