Revised Login and Register Pages
parent
f1c0542e49
commit
50aadf1b48
|
@ -17,7 +17,7 @@ class MyTextField extends StatelessWidget {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 25.0, vertical: 15),
|
padding: const EdgeInsets.symmetric(horizontal: 25.0, vertical: 8),
|
||||||
child: TextField(
|
child: TextField(
|
||||||
obscureText: obscureText,
|
obscureText: obscureText,
|
||||||
controller: controller,
|
controller: controller,
|
||||||
|
|
|
@ -2,6 +2,7 @@ import 'package:firebase_auth/firebase_auth.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import '../components/my_button.dart';
|
import '../components/my_button.dart';
|
||||||
import '../components/my_textfield.dart';
|
import '../components/my_textfield.dart';
|
||||||
|
import '../constants.dart';
|
||||||
import '../utils/helper_dialogs.dart';
|
import '../utils/helper_dialogs.dart';
|
||||||
import '../services/auth/auth_service.dart';
|
import '../services/auth/auth_service.dart';
|
||||||
|
|
||||||
|
@ -16,7 +17,7 @@ class LoginPage extends StatelessWidget {
|
||||||
LoginPage({super.key, required this.onTap});
|
LoginPage({super.key, required this.onTap});
|
||||||
|
|
||||||
// login method
|
// login method
|
||||||
void login(BuildContext context) async {
|
void _login(BuildContext context) async {
|
||||||
if (_emailController.text.trim().isEmpty ||
|
if (_emailController.text.trim().isEmpty ||
|
||||||
_passwordController.text.trim().isEmpty) {
|
_passwordController.text.trim().isEmpty) {
|
||||||
showMsg(
|
showMsg(
|
||||||
|
@ -27,12 +28,9 @@ class LoginPage extends StatelessWidget {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// auth service
|
|
||||||
final auth = AuthService();
|
|
||||||
|
|
||||||
// try login
|
// try login
|
||||||
try {
|
try {
|
||||||
await auth.signInWithEmailPassword(
|
await AuthService().signInWithEmailPassword(
|
||||||
_emailController.text,
|
_emailController.text,
|
||||||
_passwordController.text,
|
_passwordController.text,
|
||||||
);
|
);
|
||||||
|
@ -51,23 +49,21 @@ class LoginPage extends StatelessWidget {
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
backgroundColor: Theme.of(context).colorScheme.surface,
|
backgroundColor: Theme.of(context).colorScheme.surface,
|
||||||
body: Center(
|
body: SafeArea(
|
||||||
|
child: Center(
|
||||||
child: SingleChildScrollView(
|
child: SingleChildScrollView(
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
// logo
|
// logo and welcome message
|
||||||
Icon(
|
Icon(
|
||||||
Icons.people_alt,
|
Icons.people_alt,
|
||||||
size: 60,
|
size: 60,
|
||||||
color: Theme.of(context).colorScheme.primary,
|
color: Theme.of(context).colorScheme.primary,
|
||||||
),
|
),
|
||||||
|
const SizedBox(height: 16),
|
||||||
const SizedBox(height: 50),
|
|
||||||
|
|
||||||
//welcome back message
|
|
||||||
Text(
|
Text(
|
||||||
"Welcome back, you've been missed",
|
'Welcome to ${Constants.appTitle}',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: Theme.of(context).colorScheme.primary,
|
color: Theme.of(context).colorScheme.primary,
|
||||||
fontSize: 16,
|
fontSize: 16,
|
||||||
|
@ -78,14 +74,14 @@ class LoginPage extends StatelessWidget {
|
||||||
|
|
||||||
// email textfield
|
// email textfield
|
||||||
MyTextField(
|
MyTextField(
|
||||||
hintText: "E-Mail",
|
hintText: 'E-Mail',
|
||||||
obscureText: false,
|
obscureText: false,
|
||||||
controller: _emailController,
|
controller: _emailController,
|
||||||
),
|
),
|
||||||
|
|
||||||
// password textfield
|
// password textfield
|
||||||
MyTextField(
|
MyTextField(
|
||||||
hintText: "Password",
|
hintText: 'Password',
|
||||||
obscureText: true,
|
obscureText: true,
|
||||||
controller: _passwordController,
|
controller: _passwordController,
|
||||||
),
|
),
|
||||||
|
@ -94,8 +90,8 @@ class LoginPage extends StatelessWidget {
|
||||||
|
|
||||||
// login button
|
// login button
|
||||||
MyButton(
|
MyButton(
|
||||||
text: "Login",
|
text: 'Login',
|
||||||
onTap: () => login(context),
|
onTap: () => _login(context),
|
||||||
),
|
),
|
||||||
|
|
||||||
const SizedBox(height: 25),
|
const SizedBox(height: 25),
|
||||||
|
@ -105,7 +101,7 @@ class LoginPage extends StatelessWidget {
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
"Not a member? ",
|
'Don\'t have an account? ',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: Theme.of(context).colorScheme.primary,
|
color: Theme.of(context).colorScheme.primary,
|
||||||
),
|
),
|
||||||
|
@ -113,7 +109,7 @@ class LoginPage extends StatelessWidget {
|
||||||
GestureDetector(
|
GestureDetector(
|
||||||
onTap: onTap,
|
onTap: onTap,
|
||||||
child: const Text(
|
child: const Text(
|
||||||
"Register now",
|
'Register now',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
),
|
),
|
||||||
|
@ -125,6 +121,7 @@ class LoginPage extends StatelessWidget {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,6 @@ import '../services/auth/auth_service.dart';
|
||||||
import '../services/user_service.dart';
|
import '../services/user_service.dart';
|
||||||
|
|
||||||
class RegisterPage extends StatelessWidget {
|
class RegisterPage extends StatelessWidget {
|
||||||
//text controllers
|
|
||||||
final TextEditingController _nameController = TextEditingController();
|
final TextEditingController _nameController = TextEditingController();
|
||||||
final TextEditingController _lastnameController = TextEditingController();
|
final TextEditingController _lastnameController = TextEditingController();
|
||||||
final TextEditingController _emailController = TextEditingController();
|
final TextEditingController _emailController = TextEditingController();
|
||||||
|
@ -50,89 +49,90 @@ class RegisterPage extends StatelessWidget {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool _validateFields(BuildContext context) {
|
||||||
|
if ((_nameController.text.trim().isEmpty &&
|
||||||
|
_lastnameController.text.trim().isEmpty) ||
|
||||||
|
_emailController.text.trim().isEmpty ||
|
||||||
|
_passwordController.text.trim().isEmpty) {
|
||||||
|
showMsg(
|
||||||
|
context,
|
||||||
|
'Missing information',
|
||||||
|
'Please enter your name, email and password',
|
||||||
|
);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
backgroundColor: Theme.of(context).colorScheme.surface,
|
backgroundColor: Theme.of(context).colorScheme.surface,
|
||||||
body: Center(
|
body: SafeArea(
|
||||||
child: ListView(
|
child: Center(
|
||||||
children: [
|
child: SingleChildScrollView(
|
||||||
Column(
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
// logo
|
const SizedBox(height: 25),
|
||||||
|
// logo and register message
|
||||||
Icon(
|
Icon(
|
||||||
Icons.people_alt,
|
Icons.people_alt,
|
||||||
size: 60,
|
size: 60,
|
||||||
color: Theme.of(context).colorScheme.primary,
|
color: Theme.of(context).colorScheme.primary,
|
||||||
),
|
),
|
||||||
|
const SizedBox(height: 16),
|
||||||
const SizedBox(height: 50),
|
Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 25.0),
|
||||||
// register message
|
child: Text(
|
||||||
Text(
|
textAlign: TextAlign.center,
|
||||||
"Let's create an account for you",
|
'Create an account '
|
||||||
|
'and start connecting with potential co-founders.',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: Theme.of(context).colorScheme.primary,
|
color: Theme.of(context).colorScheme.primary,
|
||||||
fontSize: 16,
|
fontSize: 16,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
|
|
||||||
const SizedBox(height: 25),
|
const SizedBox(height: 25),
|
||||||
|
|
||||||
// name text field
|
// text fields
|
||||||
MyTextField(
|
MyTextField(
|
||||||
hintText: "First Name",
|
hintText: 'First Name',
|
||||||
obscureText: false,
|
obscureText: false,
|
||||||
controller: _nameController,
|
controller: _nameController,
|
||||||
),
|
),
|
||||||
MyTextField(
|
MyTextField(
|
||||||
hintText: "Last Name",
|
hintText: 'Last Name',
|
||||||
obscureText: false,
|
obscureText: false,
|
||||||
controller: _lastnameController,
|
controller: _lastnameController,
|
||||||
),
|
),
|
||||||
|
|
||||||
// email text field
|
|
||||||
MyTextField(
|
MyTextField(
|
||||||
hintText: "E-Mail",
|
hintText: 'E-Mail',
|
||||||
obscureText: false,
|
obscureText: false,
|
||||||
controller: _emailController,
|
controller: _emailController,
|
||||||
),
|
),
|
||||||
|
|
||||||
const SizedBox(height: 10),
|
|
||||||
|
|
||||||
// password text field
|
|
||||||
MyTextField(
|
MyTextField(
|
||||||
hintText: "Password",
|
hintText: 'Password',
|
||||||
obscureText: true,
|
obscureText: true,
|
||||||
controller: _passwordController,
|
controller: _passwordController,
|
||||||
),
|
),
|
||||||
|
|
||||||
MyTextField(
|
MyTextField(
|
||||||
hintText: "Confirm Password",
|
hintText: 'Confirm Password',
|
||||||
obscureText: true,
|
obscureText: true,
|
||||||
controller: _confirmPassController,
|
controller: _confirmPassController,
|
||||||
),
|
),
|
||||||
|
|
||||||
const SizedBox(height: 25),
|
const SizedBox(height: 25),
|
||||||
|
|
||||||
//login button
|
// register button
|
||||||
MyButton(
|
MyButton(
|
||||||
text: "Register",
|
text: 'Register',
|
||||||
onTap: () => {
|
onTap: () => {
|
||||||
if ((_nameController.text.trim().isEmpty &&
|
if (_validateFields(context)) {register(context)}
|
||||||
_lastnameController.text.trim().isEmpty) ||
|
|
||||||
_emailController.text.trim().isEmpty ||
|
|
||||||
_passwordController.text.trim().isEmpty)
|
|
||||||
{
|
|
||||||
showMsg(
|
|
||||||
context,
|
|
||||||
'Missing information',
|
|
||||||
'Please enter your name, email and password',
|
|
||||||
)
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{register(context)}
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|
||||||
|
@ -161,7 +161,7 @@ class RegisterPage extends StatelessWidget {
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
],
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
|
@ -31,8 +31,9 @@ class RegistrationCompletePage extends StatelessWidget {
|
||||||
),
|
),
|
||||||
const SizedBox(height: 40),
|
const SizedBox(height: 40),
|
||||||
const Text(
|
const Text(
|
||||||
'Additional information such as a short biography or a '
|
'Enhance your profile by adding additional information, '
|
||||||
'profile picture can be entered in the profile options.',
|
'such as a short biography or a profile picture, '
|
||||||
|
'in the profile settings.',
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
style: TextStyle(fontSize: 18),
|
style: TextStyle(fontSize: 18),
|
||||||
),
|
),
|
||||||
|
|
Loading…
Reference in New Issue