Skip to content
This repository was archived by the owner on Jan 5, 2021. It is now read-only.

Commit 3e534e9

Browse files
author
Luis Correa
committed
Merge branch 'master' into clean_design
2 parents 8499a28 + 2be4e49 commit 3e534e9

File tree

3 files changed

+25
-24
lines changed

3 files changed

+25
-24
lines changed

lib/pages/login_page.dart

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import 'package:nauta_api/nauta_api.dart';
88

99
import 'package:todo/pages/connected_page.dart';
1010

11+
import 'package:get_ip/get_ip.dart';
12+
1113
class LoginPage extends StatefulWidget {
1214
LoginPage({Key key, this.title = 'NAUTA'}) : super(key: key);
1315

@@ -19,6 +21,7 @@ class LoginPage extends StatefulWidget {
1921

2022
class _LoginPageState extends State<LoginPage> {
2123
ProgressDialog pr;
24+
String wlanIp;
2225
String ip;
2326

2427
final _scaffoldKey = GlobalKey<ScaffoldState>();
@@ -27,14 +30,14 @@ class _LoginPageState extends State<LoginPage> {
2730
void initState() {
2831
super.initState();
2932

30-
NautaClient().getWlanUserIP().then(
31-
(value) => setState(
32-
() {
33-
ip = value;
34-
print(ip);
35-
},
36-
),
37-
);
33+
NautaClient().getWlanUserIP().then((value) {
34+
GetIp.ipAddress.then((value2) {
35+
setState(() {
36+
wlanIp = value;
37+
ip = value2;
38+
});
39+
});
40+
});
3841
}
3942

4043
@override
@@ -85,13 +88,8 @@ class _LoginPageState extends State<LoginPage> {
8588
),
8689
Padding(
8790
padding: EdgeInsets.only(top: 10),
88-
// Comprobar si ya obtuvo la ip de WLAN
89-
child: ip != null
90-
// Si obtuvo la ip aquí se debe comprobar si ip WLAN es igual
91-
// a ip del movil y mostrar un mensaje apropiado
92-
// (en este caso solo se muestra la ip)
91+
child: wlanIp != null && ip != null
9392
? Center(child: checkIp())
94-
// Si todavía no se ha obtenido la ip no muestra nada
9593
: null,
9694
),
9795
Container(
@@ -119,19 +117,14 @@ class _LoginPageState extends State<LoginPage> {
119117
}
120118

121119
Widget checkIp() {
122-
// TODO: implementar a lógica para comprobar si la ip de WLAN es igual a la ip del movil
123-
124-
// Aqui debe ir la lógica para comprobar si
125-
// la ip de WLAN es igual a la ip del movil
126-
// en ambos casos enviar un Text
127-
// para el caso de ip == ipMovil enviar Text de color
128-
// verde como se muestra en el ejemplo
129-
// para el caso contrario enviar Text de color rojo
120+
String ok = "Usted se encuentra conectado directamente a ETECSA.";
121+
String bad = "No se encuentra conectado directamente a ETECSA.";
122+
bool cmp = ip == wlanIp;
130123

131124
return Text(
132-
ip,
125+
cmp ? ok : bad,
133126
style: TextStyle(
134-
color: Colors.green,
127+
color: cmp ? Colors.green : Colors.red,
135128
),
136129
);
137130
}

pubspec.lock

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,13 @@ packages:
100100
description: flutter
101101
source: sdk
102102
version: "0.0.0"
103+
get_ip:
104+
dependency: "direct main"
105+
description:
106+
name: get_ip
107+
url: "https://pub.dartlang.org"
108+
source: hosted
109+
version: "0.4.0"
103110
hex:
104111
dependency: transitive
105112
description:

pubspec.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ dependencies:
3636
shared_preferences: ^0.5.7
3737
progress_dialog: ^1.2.4
3838
webview_flutter: ^0.3.22+1
39+
get_ip: ^0.4.0
3940

4041

4142
# The following adds the Cupertino Icons font to your application.

0 commit comments

Comments
 (0)