Skip to content

Commit 7a5af95

Browse files
committed
Every thing works just fine.
1 parent 4a25cbb commit 7a5af95

File tree

8 files changed

+186
-147
lines changed

8 files changed

+186
-147
lines changed

lib/main.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ void main() {
4040
// '/GrngCat': (BuildContext context) => new GrngCat(),
4141
// '/KrdCat' : (BuildContext context) => new KrdCat(),
4242
'/InstaPage' : (BuildContext context) => new InstaPage(), //7
43-
// '/HawalnirHome2' : (BuildContext context) => new HawalnirHome2() ,
43+
'/MainPage' : (BuildContext context) => new MainPage() ,
4444
// '/AlertPage' : (BuildContext context) => new AlertPage(),
4545
},
4646

lib/src/app.dart

+56-48
Original file line numberDiff line numberDiff line change
@@ -10,56 +10,64 @@ var dbHelper = DatabaseHelper();
1010
class MainPage extends StatelessWidget {
1111
@override
1212
Widget build(BuildContext context) {
13-
//doWeHaveNet();
14-
if (doWeHaveNet() != true) {
15-
debugPrint(" FALSE ALL ");
16-
return Container(
17-
child: RaisedButton(
18-
onPressed: () {
19-
// doWeHaveNet();
20-
//debugPrint(" true one ");
13+
return Scaffold(
14+
appBar: AppBar(title: Icon(Icons.access_alarm),),
15+
// body: Container(child: offlineCheck()) ,
2116

22-
if (doWeHaveNet() == true) {
23-
debugPrint(" true ONE ");
24-
Navigator.of(context).pushNamed('/HawalnirHome2');
25-
}else {
17+
);
2618

27-
debugPrint("try again ");
28-
if(doWeHaveNet() != false){
29-
print(doWeHaveNet().toString());
30-
Navigator.of(context).pushNamed('/HawalnirHome2');
31-
}
3219

33-
}
34-
},
35-
child: Text("dsdsd"),
36-
));
37-
}else {
38-
debugPrint(" false 1");
39-
return HawalnirHome2();
40-
} }
41-
}
42-
43-
doWeHaveNet() async {
44-
//TODO POP something to know connection is lost
45-
int count = await dbHelper.getCount();
46-
try {
47-
final result = await InternetAddress.lookup('google.com');
48-
if (result.isNotEmpty && result[0].rawAddress.isNotEmpty) {
49-
print('connected');
50-
netConnection = true;
51-
// return weHaveNet(HawalnirHome2State().context);
52-
return true;
53-
}
54-
55-
} on SocketException catch (_) {
56-
print('not connected');
57-
if (count < 1) {
58-
debugPrint('we need intenet');
59-
// netConnection = false;
60-
// return false;
61-
}
6220
}
63-
64-
//TODO put a nice widget here for Connectivity problems
6521
}
22+
//doWeHaveNet();
23+
// if (doWeHaveNet() != true) {
24+
// debugPrint(" FALSE ALL ");
25+
// return Container(
26+
// child: RaisedButton(
27+
// onPressed: () {
28+
// // doWeHaveNet();
29+
// //debugPrint(" true one ");
30+
//
31+
// if (doWeHaveNet() == true) {
32+
// debugPrint(" true ONE ");
33+
// Navigator.of(context).pushNamed('/HawalnirHome2');
34+
// }else {
35+
//
36+
// debugPrint("try again ");
37+
// if(doWeHaveNet() != false){
38+
// print(doWeHaveNet().toString());
39+
// Navigator.of(context).pushNamed('/HawalnirHome2');
40+
// }
41+
//
42+
// }
43+
// },
44+
// child: Text("dsdsd"),
45+
// ));
46+
// }else {
47+
// debugPrint(" false 1");
48+
// return HawalnirHome2();
49+
// } }
50+
//}
51+
//
52+
//doWeHaveNet() async {
53+
// //TODO POP something to know connection is lost
54+
// int count = await dbHelper.getCount();
55+
// try {
56+
// final result = await InternetAddress.lookup('google.com');
57+
// if (result.isNotEmpty && result[0].rawAddress.isNotEmpty) {
58+
// print('connected');
59+
// netConnection = true;
60+
//// return weHaveNet(HawalnirHome2State().context);
61+
// return true;
62+
// }
63+
//
64+
// } on SocketException catch (_) {
65+
// print('not connected');
66+
// if (count < 1) {
67+
// debugPrint('we need intenet');
68+
//// netConnection = false;
69+
//// return false;
70+
// }
71+
// }
72+
//
73+
// //TODO put a nice widget here for Connectivity problems

lib/src/app2.dart

+4-11
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class HawalnirHome2 extends StatefulWidget {
3030
List<Post> cachedPosts;
3131
List<Post> posts;
3232
int dbCount;
33-
bool netConnection = true ;
33+
bool netConnection = false ;
3434

3535

3636
//Future<List<Post>> whichPosts() async {
@@ -104,30 +104,23 @@ doWeHaveNet() async {
104104
if (result.isNotEmpty && result[0].rawAddress.isNotEmpty) {
105105
print('connected');
106106
netConnection = true ;
107-
// return weHaveNet(HawalnirHome2State().context);
108-
return true ;
109-
110-
111107

112108
}
113109
} on SocketException catch (_) {
114110
print('not connected');
115111
if (count < 1) {
116112
debugPrint('we need intenet');
117113
netConnection = false ;
118-
return false ;
114+
119115
}
120116
}
121117
//TODO put a nice widget here for Connectivity problems
122118
}
123-
124-
125-
126-
127119
Future<List<Post>> isExitst() async {
120+
doWeHaveNet();
128121
cachedPosts = await dbHelper.getPostList();
129122

130-
if(doWeHaveNet() != true){
123+
if(netConnection != true){
131124
debugPrint("doWeHaveNet() is != true ");
132125
posts = cachedPosts ;
133126
posts.sort((a, b) => b.id.compareTo(a.id));

lib/src/pages/no-net.dart

+23-23
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
import '../app2.dart';
22
import 'package:flutter/material.dart';
33

4-
class NoInternet extends StatelessWidget {
5-
@override
6-
Widget build(BuildContext context) {
7-
return Container(
8-
child: Center(
9-
child: Column(
10-
children: <Widget>[
11-
12-
Text('Not Internet connection please try again') ,
13-
RaisedButton(onPressed: (){
14-
doWeHaveNet() ;
15-
})
16-
17-
18-
],
19-
)
20-
21-
22-
),
23-
24-
);
25-
}
26-
}
4+
//class NoInternet extends StatelessWidget {
5+
// @override
6+
// Widget build(BuildContext context) {
7+
// return Container(
8+
// child: Center(
9+
// child: Column(
10+
// children: <Widget>[
11+
//
12+
// Text('Not Internet connection please try again') ,
13+
// RaisedButton(onPressed: (){
14+
// doWeHaveNet() ;
15+
// })
16+
//
17+
//
18+
// ],
19+
// )
20+
//
21+
//
22+
// ),
23+
//
24+
// );
25+
// }
26+
//}

lib/src/widgets/catWidgets.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Widget hawalImage(Post post) {
2222
BoxShadow(
2323
spreadRadius: 10,
2424
blurRadius: 20,
25-
color: Colors.blue,
25+
color: Colors.black,
2626
offset: new Offset(1.0, 1.0),
2727
) ,
2828
] ,

lib/src/widgets/drawerMain.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ Widget drawerMain(context) {
2121
initiallyExpanded: true,
2222
title: Text("بابه‌ته‌كانی هه‌واڵ"),
2323
children: <Widget>[
24-
drawerBtn(" كوردستان", () {
24+
drawerBtn(" CheckOFFLINE", () {
2525
// we want to close the drawer
2626
Navigator.of(context).pop(); //TODO Find a better way
2727
Navigator.pushNamed(
28-
context, '/KrdCat'); // => KurdistanCat.dart
28+
context, '/MainPage'); // => KurdistanCat.dart
2929
}),
3030
drawerBtn(" insta", () {
3131
// we want to close the drawer

0 commit comments

Comments
 (0)