Revised Login and Register Pages

master
Rafael 2024-06-18 15:01:38 +02:00
parent f1c0542e49
commit 50aadf1b48
4 changed files with 113 additions and 115 deletions

View File

@ -17,7 +17,7 @@ class MyTextField extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 25.0, vertical: 15),
padding: const EdgeInsets.symmetric(horizontal: 25.0, vertical: 8),
child: TextField(
obscureText: obscureText,
controller: controller,

View File

@ -2,6 +2,7 @@ import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import '../components/my_button.dart';
import '../components/my_textfield.dart';
import '../constants.dart';
import '../utils/helper_dialogs.dart';
import '../services/auth/auth_service.dart';
@ -16,7 +17,7 @@ class LoginPage extends StatelessWidget {
LoginPage({super.key, required this.onTap});
// login method
void login(BuildContext context) async {
void _login(BuildContext context) async {
if (_emailController.text.trim().isEmpty ||
_passwordController.text.trim().isEmpty) {
showMsg(
@ -27,12 +28,9 @@ class LoginPage extends StatelessWidget {
return;
}
// auth service
final auth = AuthService();
// try login
try {
await auth.signInWithEmailPassword(
await AuthService().signInWithEmailPassword(
_emailController.text,
_passwordController.text,
);
@ -51,77 +49,76 @@ class LoginPage extends StatelessWidget {
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Theme.of(context).colorScheme.surface,
body: Center(
child: SingleChildScrollView(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
// logo
Icon(
Icons.people_alt,
size: 60,
color: Theme.of(context).colorScheme.primary,
),
const SizedBox(height: 50),
//welcome back message
Text(
"Welcome back, you've been missed",
style: TextStyle(
body: SafeArea(
child: Center(
child: SingleChildScrollView(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
// logo and welcome message
Icon(
Icons.people_alt,
size: 60,
color: Theme.of(context).colorScheme.primary,
fontSize: 16,
),
),
const SizedBox(height: 25),
// 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(
"Not a member? ",
style: TextStyle(
color: Theme.of(context).colorScheme.primary,
),
const SizedBox(height: 16),
Text(
'Welcome to ${Constants.appTitle}',
style: TextStyle(
color: Theme.of(context).colorScheme.primary,
fontSize: 16,
),
GestureDetector(
onTap: onTap,
child: const Text(
"Register now",
),
const SizedBox(height: 25),
// 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(
fontWeight: FontWeight.bold,
color: Theme.of(context).colorScheme.primary,
),
),
),
],
)
],
GestureDetector(
onTap: onTap,
child: const Text(
'Register now',
style: TextStyle(
fontWeight: FontWeight.bold,
),
),
),
],
)
],
),
),
),
),

View File

@ -7,7 +7,6 @@ import '../services/auth/auth_service.dart';
import '../services/user_service.dart';
class RegisterPage extends StatelessWidget {
//text controllers
final TextEditingController _nameController = TextEditingController();
final TextEditingController _lastnameController = 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
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Theme.of(context).colorScheme.surface,
body: Center(
child: ListView(
children: [
Column(
body: SafeArea(
child: Center(
child: SingleChildScrollView(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
// logo
const SizedBox(height: 25),
// logo and register message
Icon(
Icons.people_alt,
size: 60,
color: Theme.of(context).colorScheme.primary,
),
const SizedBox(height: 50),
// register message
Text(
"Let's create an account for you",
style: TextStyle(
color: Theme.of(context).colorScheme.primary,
fontSize: 16,
const SizedBox(height: 16),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 25.0),
child: Text(
textAlign: TextAlign.center,
'Create an account '
'and start connecting with potential co-founders.',
style: TextStyle(
color: Theme.of(context).colorScheme.primary,
fontSize: 16,
),
),
),
const SizedBox(height: 25),
// name text field
// text fields
MyTextField(
hintText: "First Name",
hintText: 'First Name',
obscureText: false,
controller: _nameController,
),
MyTextField(
hintText: "Last Name",
hintText: 'Last Name',
obscureText: false,
controller: _lastnameController,
),
// email text field
MyTextField(
hintText: "E-Mail",
hintText: 'E-Mail',
obscureText: false,
controller: _emailController,
),
const SizedBox(height: 10),
// password text field
MyTextField(
hintText: "Password",
hintText: 'Password',
obscureText: true,
controller: _passwordController,
),
MyTextField(
hintText: "Confirm Password",
hintText: 'Confirm Password',
obscureText: true,
controller: _confirmPassController,
),
const SizedBox(height: 25),
//login button
// register button
MyButton(
text: "Register",
text: 'Register',
onTap: () => {
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',
)
}
else
{register(context)}
if (_validateFields(context)) {register(context)}
},
),
@ -161,7 +161,7 @@ class RegisterPage extends StatelessWidget {
)
],
),
],
),
),
),
);

View File

@ -31,8 +31,9 @@ class RegistrationCompletePage extends StatelessWidget {
),
const SizedBox(height: 40),
const Text(
'Additional information such as a short biography or a '
'profile picture can be entered in the profile options.',
'Enhance your profile by adding additional information, '
'such as a short biography or a profile picture, '
'in the profile settings.',
textAlign: TextAlign.center,
style: TextStyle(fontSize: 18),
),