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,77 +49,76 @@ 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: SingleChildScrollView(
|
child: Center(
|
||||||
child: Column(
|
child: SingleChildScrollView(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
child: Column(
|
||||||
children: [
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
// logo
|
children: [
|
||||||
Icon(
|
// logo and welcome message
|
||||||
Icons.people_alt,
|
Icon(
|
||||||
size: 60,
|
Icons.people_alt,
|
||||||
color: Theme.of(context).colorScheme.primary,
|
size: 60,
|
||||||
),
|
|
||||||
|
|
||||||
const SizedBox(height: 50),
|
|
||||||
|
|
||||||
//welcome back message
|
|
||||||
Text(
|
|
||||||
"Welcome back, you've been missed",
|
|
||||||
style: TextStyle(
|
|
||||||
color: Theme.of(context).colorScheme.primary,
|
color: Theme.of(context).colorScheme.primary,
|
||||||
fontSize: 16,
|
|
||||||
),
|
),
|
||||||
),
|
const SizedBox(height: 16),
|
||||||
|
Text(
|
||||||
const SizedBox(height: 25),
|
'Welcome to ${Constants.appTitle}',
|
||||||
|
style: TextStyle(
|
||||||
// email textfield
|
color: Theme.of(context).colorScheme.primary,
|
||||||
MyTextField(
|
fontSize: 16,
|
||||||
hintText: "E-Mail",
|
|
||||||
obscureText: false,
|
|
||||||
controller: _emailController,
|
|
||||||
),
|
|
||||||
|
|
||||||
// password textfield
|
|
||||||
MyTextField(
|
|
||||||
hintText: "Password",
|
|
||||||
obscureText: true,
|
|
||||||
controller: _passwordController,
|
|
||||||
),
|
|
||||||
|
|
||||||
const SizedBox(height: 25),
|
|
||||||
|
|
||||||
// login button
|
|
||||||
MyButton(
|
|
||||||
text: "Login",
|
|
||||||
onTap: () => login(context),
|
|
||||||
),
|
|
||||||
|
|
||||||
const SizedBox(height: 25),
|
|
||||||
|
|
||||||
// register now
|
|
||||||
Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
"Not a member? ",
|
|
||||||
style: TextStyle(
|
|
||||||
color: Theme.of(context).colorScheme.primary,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
GestureDetector(
|
),
|
||||||
onTap: onTap,
|
|
||||||
child: const Text(
|
const SizedBox(height: 25),
|
||||||
"Register now",
|
|
||||||
|
// email textfield
|
||||||
|
MyTextField(
|
||||||
|
hintText: 'E-Mail',
|
||||||
|
obscureText: false,
|
||||||
|
controller: _emailController,
|
||||||
|
),
|
||||||
|
|
||||||
|
// password textfield
|
||||||
|
MyTextField(
|
||||||
|
hintText: 'Password',
|
||||||
|
obscureText: true,
|
||||||
|
controller: _passwordController,
|
||||||
|
),
|
||||||
|
|
||||||
|
const SizedBox(height: 25),
|
||||||
|
|
||||||
|
// login button
|
||||||
|
MyButton(
|
||||||
|
text: 'Login',
|
||||||
|
onTap: () => _login(context),
|
||||||
|
),
|
||||||
|
|
||||||
|
const SizedBox(height: 25),
|
||||||
|
|
||||||
|
// register now
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
'Don\'t have an account? ',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontWeight: FontWeight.bold,
|
color: Theme.of(context).colorScheme.primary,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
GestureDetector(
|
||||||
],
|
onTap: onTap,
|
||||||
)
|
child: const Text(
|
||||||
],
|
'Register now',
|
||||||
|
style: TextStyle(
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
@ -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 '
|
||||||
style: TextStyle(
|
'and start connecting with potential co-founders.',
|
||||||
color: Theme.of(context).colorScheme.primary,
|
style: TextStyle(
|
||||||
fontSize: 16,
|
color: Theme.of(context).colorScheme.primary,
|
||||||
|
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