Skip to content

Commit 52b0f46

Browse files
authored
Merge pull request #7 from ACTwoSeven/backend
Se crea la posibilidad de que vaya a login o register
2 parents 485f343 + 59f2959 commit 52b0f46

File tree

3 files changed

+163
-116
lines changed

3 files changed

+163
-116
lines changed

lib/Pages/LoginOrRegisterPage.dart

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import 'package:flutter/material.dart';
2+
import 'package:pathfinder/Pages/RegisterPage.dart';
3+
4+
import 'LoginPage.dart';
5+
6+
7+
class LoginOrRegisterPage extends StatefulWidget {
8+
const LoginOrRegisterPage({Key? key}) : super(key: key);
9+
10+
@override
11+
State<LoginOrRegisterPage> createState() => _LoginOrRegisterPageState();
12+
}
13+
14+
class _LoginOrRegisterPageState extends State<LoginOrRegisterPage> {
15+
//Inicializar mostrar la página login
16+
bool showloginPage = true;
17+
18+
// Cambiar entre página de login y registro
19+
void togglePages(){
20+
setState(() {
21+
showloginPage = !showloginPage;
22+
});
23+
}
24+
25+
@override
26+
Widget build(BuildContext context) {
27+
if (showloginPage){
28+
return LoginPage(
29+
onTap: togglePages,
30+
);
31+
}else {
32+
return RegisterPage();
33+
}
34+
}
35+
}
36+
37+

lib/Pages/LoginPage.dart

Lines changed: 124 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,14 @@ import 'package:firebase_auth/firebase_auth.dart';
33
import 'package:google_sign_in/google_sign_in.dart';
44

55
class LoginPage extends StatefulWidget {
6-
const LoginPage({super.key});
6+
final Function()? onTap;
7+
const LoginPage({super.key, required this.onTap});
8+
9+
710

811
@override
912
_LoginPageState createState() => _LoginPageState();
13+
1014
}
1115

1216

@@ -84,136 +88,141 @@ class _LoginPageState extends State<LoginPage> {
8488
return Scaffold(
8589
body: SafeArea(
8690
child: Center(
87-
child: Column(
88-
mainAxisAlignment: MainAxisAlignment.center,
89-
children: [
90-
const SizedBox(height: 50,),
91-
Padding(
92-
padding: EdgeInsets.all(30),
93-
child: Center(
94-
child: Container(
95-
width: 100,
96-
height: 100,
97-
child: Image.asset('image/user.png'),
91+
child: SingleChildScrollView(
92+
child: Column(
93+
mainAxisAlignment: MainAxisAlignment.center,
94+
children: [
95+
const SizedBox(height: 50,),
96+
Padding(
97+
padding: EdgeInsets.all(30),
98+
child: Center(
99+
child: Container(
100+
width: 100,
101+
height: 100,
102+
child: Image.asset('image/user.png'),
103+
),
98104
),
99105
),
100-
),
101-
Padding(
102-
padding: EdgeInsets.all(20),
103-
child: TextField(
104-
controller: correo,
105-
decoration: InputDecoration(
106-
border: OutlineInputBorder(
107-
borderRadius: BorderRadius.circular(10)),
108-
labelText: 'Correo',
109-
hintText: 'Digite su correo electronico',
110-
prefixIcon: Icon(Icons.email),
106+
Padding(
107+
padding: EdgeInsets.all(20),
108+
child: TextField(
109+
controller: correo,
110+
decoration: InputDecoration(
111+
border: OutlineInputBorder(
112+
borderRadius: BorderRadius.circular(10)),
113+
labelText: 'Correo',
114+
hintText: 'Digite su correo electronico',
115+
prefixIcon: Icon(Icons.email),
116+
),
111117
),
112118
),
113-
),
114-
Padding(
115-
padding: EdgeInsets.all(20),
116-
child: TextField(
117-
controller: pass,
118-
obscureText: !_mostrarContrasena,
119-
decoration: InputDecoration(
120-
border: OutlineInputBorder(
121-
borderRadius: BorderRadius.circular(10)),
122-
labelText: 'Contraseña',
123-
prefixIcon: Icon(Icons.password),
124-
suffixIcon: IconButton(
125-
icon: Icon(
126-
_mostrarContrasena
127-
? Icons.visibility
128-
: Icons.visibility_off,
119+
Padding(
120+
padding: EdgeInsets.all(20),
121+
child: TextField(
122+
controller: pass,
123+
obscureText: !_mostrarContrasena,
124+
decoration: InputDecoration(
125+
border: OutlineInputBorder(
126+
borderRadius: BorderRadius.circular(10)),
127+
labelText: 'Contraseña',
128+
prefixIcon: Icon(Icons.password),
129+
suffixIcon: IconButton(
130+
icon: Icon(
131+
_mostrarContrasena
132+
? Icons.visibility
133+
: Icons.visibility_off,
134+
),
135+
onPressed: () {
136+
_toggleMostrarContrasena(!_mostrarContrasena);
137+
},
129138
),
130-
onPressed: () {
131-
_toggleMostrarContrasena(!_mostrarContrasena);
132-
},
139+
hintText: 'Digite su contraseña',
133140
),
134-
hintText: 'Digite su contraseña',
135141
),
136142
),
137-
),
138-
Padding(
139-
padding: const EdgeInsets.symmetric(horizontal: 25.0),
140-
child: Row(
141-
mainAxisAlignment: MainAxisAlignment.end,
142-
children: [
143-
Text(
144-
'¿Olvidaste tu contraseña?',
145-
style: TextStyle(color: Colors.grey[600]),
146-
),
147-
],
148-
),
149-
),
150-
Padding(
151-
padding: const EdgeInsets.only(left: 20, top: 50, right: 10),
152-
child: Center(
153-
child: ElevatedButton(
154-
onPressed: () {
155-
print('Ingresando...');
156-
signUserIn();
157-
},
158-
child: Text('Ingresar'),
143+
Padding(
144+
padding: const EdgeInsets.symmetric(horizontal: 25.0),
145+
child: Row(
146+
mainAxisAlignment: MainAxisAlignment.end,
147+
children: [
148+
Text(
149+
'¿Olvidaste tu contraseña?',
150+
style: TextStyle(color: Colors.grey[600]),
151+
),
152+
],
159153
),
160154
),
161-
),
162-
const SizedBox(height: 50,),
163-
//Continua con
164-
Padding(
165-
padding: const EdgeInsets.symmetric(horizontal: 25.0),
166-
child: Row(children: [
167-
Expanded(child: Divider(
168-
thickness: 0.5,
169-
color: Colors.grey[400],
170-
),
171-
),
172-
Padding(
173-
padding: const EdgeInsets.symmetric(horizontal: 10.0),
174-
child: Text(
175-
'O inicia sesión con:',
176-
style: TextStyle(color: Colors.grey[700]),
155+
Padding(
156+
padding: const EdgeInsets.only(left: 20, top: 50, right: 10),
157+
child: Center(
158+
child: ElevatedButton(
159+
onPressed: () {
160+
print('Ingresando...');
161+
signUserIn();
162+
},
163+
child: Text('Ingresar'),
177164
),
178165
),
179-
Expanded(child: Divider(
180-
thickness: 0.5,
181-
color: Colors.grey[400],
182-
))
183-
],),
184-
),
166+
),
167+
const SizedBox(height: 50,),
168+
//Continua con
169+
Padding(
170+
padding: const EdgeInsets.symmetric(horizontal: 25.0),
171+
child: Row(children: [
172+
Expanded(child: Divider(
173+
thickness: 0.5,
174+
color: Colors.grey[400],
175+
),
176+
),
177+
Padding(
178+
padding: const EdgeInsets.symmetric(horizontal: 10.0),
179+
child: Text(
180+
'O inicia sesión con:',
181+
style: TextStyle(color: Colors.grey[700]),
182+
),
183+
),
184+
Expanded(child: Divider(
185+
thickness: 0.5,
186+
color: Colors.grey[400],
187+
))
188+
],),
189+
),
185190

186-
const SizedBox(height: 50,),
187-
//Google sign in button
188-
Row(
189-
mainAxisAlignment: MainAxisAlignment.center,
190-
children: [
191-
Image.asset(
192-
'lib/Images/google_logo.png',
193-
height: 40,),
194-
const SizedBox(),
195-
],),
191+
const SizedBox(height: 50,),
192+
//Google sign in button
193+
Row(
194+
mainAxisAlignment: MainAxisAlignment.center,
195+
children: [
196+
Image.asset(
197+
'lib/Images/google_logo.png',
198+
height: 40,),
199+
const SizedBox(),
200+
],),
196201

197-
const SizedBox(height: 50,),
202+
const SizedBox(height: 50,),
198203

199-
//Registrate
200-
Row(
201-
mainAxisAlignment: MainAxisAlignment.center,
202-
children: [
203-
Text(
204-
'No estás registrado?',
205-
style: TextStyle(color: Colors.grey[700]),
206-
),
207-
const SizedBox(width: 4,),
208-
Text(
209-
'Registrate!',
210-
style: TextStyle(
211-
color: Colors.blue, fontWeight: FontWeight.bold
204+
//Registrate
205+
Row(
206+
mainAxisAlignment: MainAxisAlignment.center,
207+
children: [
208+
Text(
209+
'No estás registrado?',
210+
style: TextStyle(color: Colors.grey[700]),
212211
),
213-
)
214-
],
215-
)
216-
]
212+
const SizedBox(width: 4,),
213+
GestureDetector(
214+
onTap: widget.onTap,
215+
child: const Text(
216+
'Registrate!',
217+
style: TextStyle(
218+
color: Colors.blue, fontWeight: FontWeight.bold
219+
),
220+
),
221+
)
222+
],
223+
)
224+
]
225+
),
217226
),
218227
),
219228
),

lib/Pages/auth_page.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import 'package:firebase_auth/firebase_auth.dart';
22
import 'package:flutter/material.dart';
33
import 'package:pathfinder/Pages/LoginPage.dart';
44
import 'HomePage.dart';
5+
import 'LoginOrRegisterPage.dart';
56

67
class AuthPage extends StatelessWidget{
78
const AuthPage({super.key});
@@ -17,7 +18,7 @@ class AuthPage extends StatelessWidget{
1718
return HomePage();
1819
}
1920
else{
20-
return LoginPage();
21+
return LoginOrRegisterPage();
2122
}
2223
},
2324
),

0 commit comments

Comments
 (0)