update
This commit is contained in:
parent
f0d6bca4f3
commit
3aa12bfcad
135 changed files with 19410 additions and 112 deletions
|
|
@ -27,15 +27,6 @@ class _LoginPageState extends State<LoginPage> {
|
|||
|
||||
bool _isLoading = false;
|
||||
|
||||
void checkLoggedIn() async {
|
||||
final user = _authService.getCurrentUser();
|
||||
if (user == null) {
|
||||
context.push('/');
|
||||
} else {
|
||||
context.push('/main');
|
||||
}
|
||||
}
|
||||
|
||||
void _signIn() async {
|
||||
// if (_isLoading) return;
|
||||
|
||||
|
|
@ -102,12 +93,6 @@ class _LoginPageState extends State<LoginPage> {
|
|||
// }
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
checkLoggedIn();
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_emailController.dispose();
|
||||
|
|
@ -174,6 +159,25 @@ class _LoginPageState extends State<LoginPage> {
|
|||
)),
|
||||
),
|
||||
),
|
||||
const Gap(16),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
const TextWidget(
|
||||
text: "Don't have an account?",
|
||||
size: 14,
|
||||
),
|
||||
const Gap(8),
|
||||
GestureDetector(
|
||||
onTap: () => {context.push('/register')},
|
||||
child: const TextWidget(
|
||||
text: 'Register here',
|
||||
size: 14,
|
||||
underlined: true,
|
||||
),
|
||||
)
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
|
|
|
|||
|
|
@ -25,21 +25,6 @@ class _MainPageState extends State<MainPage> {
|
|||
await _authService.signOut().then((_) => {context.go('/'), showNotification(context, 'Logged Out', true)});
|
||||
}
|
||||
|
||||
void checkLoggedIn() async {
|
||||
final user = _authService.getCurrentUser();
|
||||
if (user == null) {
|
||||
if (mounted) {
|
||||
context.push('/');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
checkLoggedIn();
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return PopScope(
|
||||
|
|
|
|||
|
|
@ -1,11 +1,14 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:gap/gap.dart';
|
||||
import 'package:internet_connection_checker/internet_connection_checker.dart';
|
||||
import 'package:pharmacy_mobile/auth/auth_service.dart';
|
||||
import 'package:pharmacy_mobile/widgets/button_widget.dart';
|
||||
import 'package:pharmacy_mobile/widgets/input_widget.dart';
|
||||
import 'package:pharmacy_mobile/widgets/page_background_widget.dart';
|
||||
import 'package:pharmacy_mobile/widgets/snackbar_widget.dart';
|
||||
import 'package:pharmacy_mobile/widgets/text_widget.dart';
|
||||
import 'package:pharmacy_mobile/widgets/title_widget.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
class RegisterPage extends StatefulWidget {
|
||||
const RegisterPage({super.key});
|
||||
|
|
@ -28,23 +31,49 @@ class _RegisterPageState extends State<RegisterPage> {
|
|||
final password = _passwordController.text;
|
||||
final confirmPassword = _confirmPasswordController.text;
|
||||
|
||||
try {
|
||||
await _authService.signUp(email, password);
|
||||
} catch (e) {
|
||||
setState(() => _isLoading = true);
|
||||
|
||||
if (email.isEmpty) {
|
||||
if (mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text('Error: $e')));
|
||||
showNotification(context, 'Error: Please enter a valid email', false);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (password.isEmpty) {
|
||||
if (mounted) {
|
||||
showNotification(context, 'Error: Please enter a password', false);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (confirmPassword.isEmpty) {
|
||||
if (mounted) {
|
||||
showNotification(context, 'Error: Please confirm password', false);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (password != confirmPassword) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text('Password does not match!')));
|
||||
showNotification(context, 'Password does not match!', false);
|
||||
return;
|
||||
}
|
||||
|
||||
// if (mounted) {
|
||||
// context.showSnackBar('Check your email for a login link!');
|
||||
|
||||
// _emailController.clear();
|
||||
// }
|
||||
try {
|
||||
if (await InternetConnectionChecker.instance.hasConnection) {
|
||||
await _authService.signUp(email, password);
|
||||
} else {
|
||||
if (mounted) {
|
||||
showNotification(context, 'Error: No Internet Connection', false);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
if (mounted) {
|
||||
showNotification(context, 'Error: $e', false);
|
||||
}
|
||||
} finally {
|
||||
setState(() => _isLoading = false);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
@ -112,6 +141,25 @@ class _RegisterPageState extends State<RegisterPage> {
|
|||
)),
|
||||
),
|
||||
),
|
||||
const Gap(16),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
const TextWidget(
|
||||
text: "Already have an account?",
|
||||
size: 14,
|
||||
),
|
||||
const Gap(8),
|
||||
GestureDetector(
|
||||
onTap: () => {context.push('/login')},
|
||||
child: const TextWidget(
|
||||
text: 'Login here',
|
||||
size: 14,
|
||||
underlined: true,
|
||||
),
|
||||
)
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
)),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue