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,
)
],
),
),
),
),

View file

@ -12,19 +12,19 @@ class ButtonWidget extends StatelessWidget {
Widget build(BuildContext context) {
return ElevatedButton(
style: ElevatedButton.styleFrom(
foregroundColor: Color(0xFF8E44AD), // text color
backgroundColor: const Color(0xFFE8DAEF), // background color
side: const BorderSide(color: Color.fromARGB(55, 255, 255, 255)), // border color
foregroundColor: Color.fromRGBO(0, 0, 0, 1), // text color
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(26), // rounded corners
),
minimumSize: Size(MediaQuery.of(context).size.width - 64, 40), // minimum size
minimumSize: Size(MediaQuery.of(context).size.width - 96, 40), // minimum size
padding: EdgeInsets.symmetric(vertical: 10, horizontal: 16), // padding
),
onPressed: onPressed,
child: Text(
text,
style: GoogleFonts.outfit(textStyle: const TextStyle(fontSize: 18)),
style: GoogleFonts.outfit(textStyle: const TextStyle(fontSize: 16)),
));
}
}

View file

@ -16,15 +16,17 @@ class InputWidget extends StatelessWidget {
children: [
Text('$label:',
style: GoogleFonts.outfit(
textStyle: const TextStyle(color: Colors.white, fontSize: 16),
textStyle: const TextStyle(color: Colors.white, fontSize: 12, fontWeight: FontWeight.w500),
)),
const Gap(8),
TextField(
controller: controller,
decoration: InputDecoration(
border: OutlineInputBorder(borderRadius: BorderRadius.circular(10)),
),
style: GoogleFonts.outfit(textStyle: TextStyle(color: Colors.white, fontSize: 16)),
filled: true, // Enable filling the background
fillColor: Colors.white,
border: OutlineInputBorder(borderRadius: BorderRadius.circular(12)),
contentPadding: EdgeInsets.symmetric(vertical: 10, horizontal: 24)),
style: GoogleFonts.outfit(textStyle: TextStyle(color: const Color.fromRGBO(0, 0, 0, 1), fontSize: 16)),
obscureText: password ?? false,
),
],

View file

@ -14,8 +14,9 @@ class PageBackgroundWidget extends StatelessWidget {
gradient: RadialGradient(
tileMode: TileMode.clamp,
colors: [
Color.fromRGBO(132, 84, 125, 1),
Color.fromRGBO(96, 48, 90, 1),
// Color.fromRGBO(132, 84, 125, 1),
// Color.fromRGBO(96, 48, 90, 1),
Color.fromRGBO(45, 15, 43, 1),
Color.fromRGBO(77, 29, 73, 1),
// Color.fromRGBO(241, 220, 223, 1),
],

View file

@ -4,12 +4,18 @@ import 'package:google_fonts/google_fonts.dart';
class TextWidget extends StatelessWidget {
final String text;
final double? size;
final double? opacity;
final bool? bold;
const TextWidget({super.key, required this.text, this.size});
const TextWidget({super.key, required this.text, this.size, this.opacity, this.bold});
@override
Widget build(BuildContext context) {
return Text(text,
style: GoogleFonts.outfit(textStyle: TextStyle(color: Color.fromRGBO(255, 255, 255, 1), fontSize: size ?? 32)));
style: GoogleFonts.outfit(
textStyle: TextStyle(
color: Color.fromRGBO(255, 255, 255, opacity ?? 1),
fontSize: size ?? 32,
fontWeight: bold == true ? FontWeight.bold : FontWeight.normal)));
}
}