This commit is contained in:
Patrick Alvin Alcala 2025-01-31 11:21:11 +08:00
parent 97e2291159
commit 57b8bdc067
17 changed files with 245 additions and 114 deletions

View file

@ -77,7 +77,7 @@ class AddGenericsPageState extends State<AddGenericsPage> {
child: Center(
child: Column(
children: [
const Gap(120),
const Gap(104),
const TitleWidget(firstTextSize: 16, secondTextSize: 32),
const Gap(32),
const TextWidget(text: 'Add Generics'),

View file

@ -111,7 +111,7 @@ class AddMedicinePageState extends State<AddMedicinePage> {
child: Center(
child: Column(
children: [
const Gap(120),
const Gap(104),
const TitleWidget(firstTextSize: 16, secondTextSize: 32),
const Gap(32),
const TextWidget(text: 'Add Medicine'),

View file

@ -83,7 +83,7 @@ class _AddStockPageState extends State<AddStockPage> {
child: Center(
child: Column(
children: [
const Gap(120),
const Gap(104),
const TitleWidget(firstTextSize: 16, secondTextSize: 32),
const Gap(32),
const TextWidget(text: 'Add Stock'),

View file

@ -42,7 +42,7 @@ class _AddTypePageState extends State<AddTypePage> {
child: Center(
child: Column(
children: [
const Gap(120),
const Gap(104),
const TitleWidget(firstTextSize: 16, secondTextSize: 32),
const Gap(32),
const TextWidget(text: 'Add Medicine Type'),

View file

@ -23,7 +23,7 @@ class IndexPage extends StatelessWidget {
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: [
const Gap(120),
const Gap(104),
const TitleWidget(firstTextSize: 32, secondTextSize: 40),
const Gap(32),
Padding(
@ -34,8 +34,13 @@ class IndexPage extends StatelessWidget {
const Gap(32),
ButtonWidget(text: 'Login', onPressed: gotoLogin),
const MaxGap(500),
const TextWidget(text: 'Copyright © 2025 - Ofelia Franco-Alcala Pharmacy', size: 14),
const TextWidget(text: 'Developed By: Pat Alcala', size: 12)
const TextWidget(
text: 'Copyright © 2025 - Ofelia Franco-Alcala Pharmacy',
size: 12,
bold: true,
),
const TextWidget(text: 'Developed By: Pat Alcala', size: 10, opacity: 0.8),
const Gap(8),
],
),
),

View file

@ -28,7 +28,7 @@ class _ListStocksPageState extends State<ListStocksPage> {
return Scaffold(
body: PageBackgroundWidget(
child: Column(children: [
const Gap(120),
const Gap(104),
const TitleWidget(firstTextSize: 16, secondTextSize: 32),
const Gap(32),
const TextWidget(text: 'List of Stocks'),

View file

@ -9,6 +9,7 @@ import 'package:pharmacy_mobile/widgets/page_background_widget.dart';
import 'package:pharmacy_mobile/widgets/text_widget.dart';
import 'package:pharmacy_mobile/widgets/title_widget.dart';
import 'package:quickalert/quickalert.dart';
import 'package:internet_connection_checker/internet_connection_checker.dart';
class LoginPage extends StatefulWidget {
const LoginPage({super.key});
@ -23,31 +24,55 @@ class _LoginPageState extends State<LoginPage> {
final _passwordController = TextEditingController();
final FocusNode _focusNode = FocusNode();
bool _isLoading = false;
void _signIn() async {
if (_isLoading) return;
final email = _emailController.text;
final password = _passwordController.text;
setState(() => _isLoading = true);
try {
await _authService.signIn(email, password);
// QuickAlert.show(
// context: context,
// type: QuickAlertType.success,
// text: 'Login Successful',
// autoCloseDuration: const Duration(seconds: 1),
// showConfirmBtn: false,
// );
context.push('/main');
if (await InternetConnectionChecker.instance.hasConnection) {
await _authService.signIn(email, password);
if (mounted) {
QuickAlert.show(
context: context,
type: QuickAlertType.success,
text: 'Login Successful',
autoCloseDuration: const Duration(seconds: 2),
showConfirmBtn: false,
).then((value) => {
if (mounted && context.mounted) {context.push('/main')}
});
}
} else {
if (mounted) {
QuickAlert.show(
context: context,
type: QuickAlertType.error,
text: 'No Internet Connection',
autoCloseDuration: const Duration(seconds: 2),
showConfirmBtn: false,
);
// ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text('Error: $e')));
}
}
} catch (e) {
if (mounted) {
QuickAlert.show(
context: context,
type: QuickAlertType.error,
text: 'Error: $e',
autoCloseDuration: const Duration(seconds: 2),
autoCloseDuration: const Duration(seconds: 5),
showConfirmBtn: false,
);
// ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text('Error: $e')));
}
} finally {
setState(() => _isLoading = false);
}
// if (mounted) {
@ -68,50 +93,61 @@ class _LoginPageState extends State<LoginPage> {
@override
Widget build(BuildContext context) {
return Scaffold(
resizeToAvoidBottomInset: false,
body: PageBackgroundWidget(
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: [
const Gap(120),
const TitleWidget(firstTextSize: 16, secondTextSize: 32),
const Gap(32),
const TextWidget(text: 'Login'),
const Gap(16),
Padding(
padding: const EdgeInsets.only(left: 16, right: 16),
child: Container(
padding: EdgeInsets.all(16),
decoration: BoxDecoration(
border: Border.all(color: Colors.white), borderRadius: BorderRadius.all(Radius.circular(16))),
child: Form(
child: Column(
children: [
InputWidget(label: 'Email', controller: _emailController),
const Gap(16),
KeyboardListener(
focusNode: _focusNode,
onKeyEvent: (event) {
if (event is KeyDownEvent && event.logicalKey == LogicalKeyboardKey.enter) {
_signIn();
}
},
child: InputWidget(
label: 'Password',
controller: _passwordController,
password: true,
),
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: [
const Gap(104),
const TitleWidget(firstTextSize: 16, secondTextSize: 32),
const Gap(32),
const TextWidget(text: 'Login'),
const Gap(16),
Padding(
padding: const EdgeInsets.only(left: 16, right: 16),
child: Container(
padding: EdgeInsets.all(32),
decoration: BoxDecoration(
color: const Color.fromARGB(219, 38, 17, 46),
borderRadius: BorderRadius.all(Radius.circular(16)),
// boxShadow: [
// BoxShadow(
// color: const Color.fromRGBO(0, 0, 0, 1).withOpacity(0.4), // Subtle shadow to give depth
// spreadRadius: 0,
// blurRadius: 4,
// offset: Offset(0, 2),
// )
// ]
),
const Gap(24),
// TextButton(onPressed: () => {_signIn()}, child: const Text('Login'))
ButtonWidget(text: 'Login', onPressed: _signIn)
],
)),
),
child: Form(
child: Column(
children: [
InputWidget(label: 'Email', controller: _emailController),
const Gap(16),
KeyboardListener(
focusNode: _focusNode,
onKeyEvent: (event) {
if (event is KeyDownEvent && event.logicalKey == LogicalKeyboardKey.enter) {
_signIn();
}
},
child: InputWidget(
label: 'Password',
controller: _passwordController,
password: true,
),
),
const Gap(24),
// TextButton(onPressed: () => {_signIn()}, child: const Text('Login'))
ButtonWidget(text: 'Login', onPressed: _signIn)
],
)),
),
),
],
),
],
),
),
));
),
));
}
}

View file

@ -17,8 +17,7 @@ class MainPage extends StatelessWidget {
final authService = AuthService();
void signOut() async {
await authService.signOut();
context.push('/');
await authService.signOut().then((_) => {context.push('/')});
}
void gotoAddMedicine() {
@ -30,46 +29,49 @@ class MainPage extends StatelessWidget {
}
return Scaffold(
body: PageBackgroundWidget(
child: Center(
child: Column(
children: [
const Gap(120),
const TitleWidget(firstTextSize: 16, secondTextSize: 32),
const Gap(32),
const TextWidget(text: 'Menu'),
const Gap(16),
MenuWidget(
icon: FontAwesomeIcons.squarePlus,
text: 'Add Medicine',
onPressed: gotoAddMedicine,
),
const Gap(16),
MenuWidget(
icon: FontAwesomeIcons.squarePlus,
text: 'Add Generics',
onPressed: gotoAddGenerics,
),
const Gap(16),
MenuWidget(
icon: FontAwesomeIcons.squarePlus, text: 'Add Stock', onPressed: () => {context.push('/addstock')}),
const Gap(16),
MenuWidget(
resizeToAvoidBottomInset: false,
body: SingleChildScrollView(
child: PageBackgroundWidget(
child: Center(
child: Column(
children: [
const Gap(104),
const TitleWidget(firstTextSize: 16, secondTextSize: 32),
const Gap(32),
const TextWidget(text: 'Menu'),
const Gap(16),
MenuWidget(
icon: FontAwesomeIcons.squarePlus,
text: 'Add Medicine Type',
onPressed: () => {context.push('/addtype')}),
const Gap(32),
MenuWidget(
icon: FontAwesomeIcons.listCheck,
text: 'List of Stocks',
onPressed: () => {context.push('/liststocks')}),
const Gap(32),
// TextButton(onPressed: () => {_signOut()}, child: const Text('Logout')),
ButtonWidget(
text: 'Logout',
onPressed: signOut,
)
],
text: 'Add Medicine',
onPressed: gotoAddMedicine,
),
const Gap(16),
MenuWidget(
icon: FontAwesomeIcons.squarePlus,
text: 'Add Generics',
onPressed: gotoAddGenerics,
),
const Gap(16),
MenuWidget(
icon: FontAwesomeIcons.squarePlus, text: 'Add Stock', onPressed: () => {context.push('/addstock')}),
const Gap(16),
MenuWidget(
icon: FontAwesomeIcons.squarePlus,
text: 'Add Medicine Type',
onPressed: () => {context.push('/addtype')}),
const Gap(32),
MenuWidget(
icon: FontAwesomeIcons.listCheck,
text: 'List of Stocks',
onPressed: () => {context.push('/liststocks')}),
const Gap(32),
// TextButton(onPressed: () => {_signOut()}, child: const Text('Logout')),
ButtonWidget(
text: 'Logout',
onPressed: signOut,
)
],
),
),
),
),