update
This commit is contained in:
parent
06531e3959
commit
f0d6bca4f3
135 changed files with 19329 additions and 22 deletions
|
|
@ -1,6 +1,5 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:pharmacy_mobile/pages/index_page.dart';
|
||||
import 'package:pharmacy_mobile/pages/login_page.dart';
|
||||
import 'package:pharmacy_mobile/pages/main_page.dart';
|
||||
import 'package:supabase_flutter/supabase_flutter.dart';
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
import 'dart:developer';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:gap/gap.dart';
|
||||
import 'package:pharmacy_mobile/functions/checkresult_function.dart';
|
||||
|
|
|
|||
|
|
@ -27,6 +27,15 @@ 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;
|
||||
|
||||
|
|
@ -55,13 +64,16 @@ class _LoginPageState extends State<LoginPage> {
|
|||
|
||||
if (mounted) {
|
||||
final user = _authService.getCurrentUser();
|
||||
showNotification(context, 'Login Successful', true);
|
||||
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (mounted) {
|
||||
context.push('/main');
|
||||
}
|
||||
});
|
||||
if (user != null) {
|
||||
showNotification(context, 'Login Successful', true);
|
||||
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (mounted) {
|
||||
context.push('/main');
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (mounted) {
|
||||
|
|
@ -90,6 +102,12 @@ class _LoginPageState extends State<LoginPage> {
|
|||
// }
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
checkLoggedIn();
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_emailController.dispose();
|
||||
|
|
|
|||
|
|
@ -10,18 +10,38 @@ import 'package:pharmacy_mobile/widgets/snackbar_widget.dart';
|
|||
import 'package:pharmacy_mobile/widgets/text_widget.dart';
|
||||
import 'package:pharmacy_mobile/widgets/title_widget.dart';
|
||||
|
||||
class MainPage extends StatelessWidget {
|
||||
class MainPage extends StatefulWidget {
|
||||
const MainPage({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final authService = AuthService();
|
||||
State<MainPage> createState() => _MainPageState();
|
||||
}
|
||||
|
||||
void signOut() async {
|
||||
// ignore: use_build_context_synchronously
|
||||
await authService.signOut().then((_) => {context.go('/'), showNotification(context, 'Logged Out', true)});
|
||||
class _MainPageState extends State<MainPage> {
|
||||
final _authService = AuthService();
|
||||
|
||||
void signOut() async {
|
||||
// ignore: use_build_context_synchronously
|
||||
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(
|
||||
canPop: false,
|
||||
child: Scaffold(
|
||||
|
|
|
|||
|
|
@ -17,10 +17,10 @@ class ButtonWidget extends StatelessWidget {
|
|||
backgroundColor: Colors.transparent,
|
||||
side: const BorderSide(color: Color.fromRGBO(198, 133, 232, 1)),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
),
|
||||
minimumSize: Size(MediaQuery.of(context).size.width <= 768 ? MediaQuery.of(context).size.width - 96 : 320,
|
||||
44), // minimum size
|
||||
minimumSize:
|
||||
Size(MediaQuery.of(context).size.width <= 768 ? MediaQuery.of(context).size.width - 96 : 320, 44),
|
||||
padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 16),
|
||||
)
|
||||
: ElevatedButton.styleFrom(
|
||||
|
|
@ -28,7 +28,7 @@ class ButtonWidget extends StatelessWidget {
|
|||
backgroundColor: const Color.fromRGBO(198, 133, 232, 1), // background color
|
||||
side: const BorderSide(color: Color.fromRGBO(79, 51, 94, 1)), // border color
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12), // rounded corners
|
||||
borderRadius: BorderRadius.circular(20), // rounded corners
|
||||
),
|
||||
minimumSize: Size(MediaQuery.of(context).size.width <= 768 ? MediaQuery.of(context).size.width - 96 : 320,
|
||||
44), // minimum size
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ class InputWidget extends StatelessWidget {
|
|||
decoration: InputDecoration(
|
||||
filled: true, // Enable filling the background
|
||||
fillColor: const Color.fromRGBO(255, 255, 255, 1),
|
||||
border: OutlineInputBorder(borderRadius: BorderRadius.circular(12)),
|
||||
border: OutlineInputBorder(borderRadius: BorderRadius.circular(8)),
|
||||
contentPadding: const EdgeInsets.symmetric(vertical: 10, horizontal: 24)),
|
||||
style: GoogleFonts.outfit(textStyle: const TextStyle(color: Color.fromRGBO(0, 0, 0, 1), fontSize: 16)),
|
||||
obscureText: password ?? false,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue