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: Center(
child: Column( child: Column(
children: [ children: [
const Gap(120), const Gap(104),
const TitleWidget(firstTextSize: 16, secondTextSize: 32), const TitleWidget(firstTextSize: 16, secondTextSize: 32),
const Gap(32), const Gap(32),
const TextWidget(text: 'Add Generics'), const TextWidget(text: 'Add Generics'),

View file

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

View file

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

View file

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

View file

@ -23,7 +23,7 @@ class IndexPage extends StatelessWidget {
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
children: [ children: [
const Gap(120), const Gap(104),
const TitleWidget(firstTextSize: 32, secondTextSize: 40), const TitleWidget(firstTextSize: 32, secondTextSize: 40),
const Gap(32), const Gap(32),
Padding( Padding(
@ -34,8 +34,13 @@ class IndexPage extends StatelessWidget {
const Gap(32), const Gap(32),
ButtonWidget(text: 'Login', onPressed: gotoLogin), ButtonWidget(text: 'Login', onPressed: gotoLogin),
const MaxGap(500), const MaxGap(500),
const TextWidget(text: 'Copyright © 2025 - Ofelia Franco-Alcala Pharmacy', size: 14), const TextWidget(
const TextWidget(text: 'Developed By: Pat Alcala', size: 12) 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( return Scaffold(
body: PageBackgroundWidget( body: PageBackgroundWidget(
child: Column(children: [ child: Column(children: [
const Gap(120), const Gap(104),
const TitleWidget(firstTextSize: 16, secondTextSize: 32), const TitleWidget(firstTextSize: 16, secondTextSize: 32),
const Gap(32), const Gap(32),
const TextWidget(text: 'List of Stocks'), 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/text_widget.dart';
import 'package:pharmacy_mobile/widgets/title_widget.dart'; import 'package:pharmacy_mobile/widgets/title_widget.dart';
import 'package:quickalert/quickalert.dart'; import 'package:quickalert/quickalert.dart';
import 'package:internet_connection_checker/internet_connection_checker.dart';
class LoginPage extends StatefulWidget { class LoginPage extends StatefulWidget {
const LoginPage({super.key}); const LoginPage({super.key});
@ -23,31 +24,55 @@ class _LoginPageState extends State<LoginPage> {
final _passwordController = TextEditingController(); final _passwordController = TextEditingController();
final FocusNode _focusNode = FocusNode(); final FocusNode _focusNode = FocusNode();
bool _isLoading = false;
void _signIn() async { void _signIn() async {
if (_isLoading) return;
final email = _emailController.text; final email = _emailController.text;
final password = _passwordController.text; final password = _passwordController.text;
setState(() => _isLoading = true);
try { try {
await _authService.signIn(email, password); if (await InternetConnectionChecker.instance.hasConnection) {
// QuickAlert.show( await _authService.signIn(email, password);
// context: context, if (mounted) {
// type: QuickAlertType.success, QuickAlert.show(
// text: 'Login Successful', context: context,
// autoCloseDuration: const Duration(seconds: 1), type: QuickAlertType.success,
// showConfirmBtn: false, text: 'Login Successful',
// ); autoCloseDuration: const Duration(seconds: 2),
context.push('/main'); 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) { } catch (e) {
if (mounted) { if (mounted) {
QuickAlert.show( QuickAlert.show(
context: context, context: context,
type: QuickAlertType.error, type: QuickAlertType.error,
text: 'Error: $e', text: 'Error: $e',
autoCloseDuration: const Duration(seconds: 2), autoCloseDuration: const Duration(seconds: 5),
showConfirmBtn: false, showConfirmBtn: false,
); );
// ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text('Error: $e'))); // ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text('Error: $e')));
} }
} finally {
setState(() => _isLoading = false);
} }
// if (mounted) { // if (mounted) {
@ -68,50 +93,61 @@ class _LoginPageState extends State<LoginPage> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
resizeToAvoidBottomInset: false,
body: PageBackgroundWidget( body: PageBackgroundWidget(
child: Center( child: Center(
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
children: [ children: [
const Gap(120), const Gap(104),
const TitleWidget(firstTextSize: 16, secondTextSize: 32), const TitleWidget(firstTextSize: 16, secondTextSize: 32),
const Gap(32), const Gap(32),
const TextWidget(text: 'Login'), const TextWidget(text: 'Login'),
const Gap(16), const Gap(16),
Padding( Padding(
padding: const EdgeInsets.only(left: 16, right: 16), padding: const EdgeInsets.only(left: 16, right: 16),
child: Container( child: Container(
padding: EdgeInsets.all(16), padding: EdgeInsets.all(32),
decoration: BoxDecoration( decoration: BoxDecoration(
border: Border.all(color: Colors.white), borderRadius: BorderRadius.all(Radius.circular(16))), color: const Color.fromARGB(219, 38, 17, 46),
child: Form( borderRadius: BorderRadius.all(Radius.circular(16)),
child: Column( // boxShadow: [
children: [ // BoxShadow(
InputWidget(label: 'Email', controller: _emailController), // color: const Color.fromRGBO(0, 0, 0, 1).withOpacity(0.4), // Subtle shadow to give depth
const Gap(16), // spreadRadius: 0,
KeyboardListener( // blurRadius: 4,
focusNode: _focusNode, // offset: Offset(0, 2),
onKeyEvent: (event) { // )
if (event is KeyDownEvent && event.logicalKey == LogicalKeyboardKey.enter) { // ]
_signIn();
}
},
child: InputWidget(
label: 'Password',
controller: _passwordController,
password: true,
),
), ),
const Gap(24), child: Form(
// TextButton(onPressed: () => {_signIn()}, child: const Text('Login')) child: Column(
ButtonWidget(text: 'Login', onPressed: _signIn) 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(); final authService = AuthService();
void signOut() async { void signOut() async {
await authService.signOut(); await authService.signOut().then((_) => {context.push('/')});
context.push('/');
} }
void gotoAddMedicine() { void gotoAddMedicine() {
@ -30,46 +29,49 @@ class MainPage extends StatelessWidget {
} }
return Scaffold( return Scaffold(
body: PageBackgroundWidget( resizeToAvoidBottomInset: false,
child: Center( body: SingleChildScrollView(
child: Column( child: PageBackgroundWidget(
children: [ child: Center(
const Gap(120), child: Column(
const TitleWidget(firstTextSize: 16, secondTextSize: 32), children: [
const Gap(32), const Gap(104),
const TextWidget(text: 'Menu'), const TitleWidget(firstTextSize: 16, secondTextSize: 32),
const Gap(16), const Gap(32),
MenuWidget( const TextWidget(text: 'Menu'),
icon: FontAwesomeIcons.squarePlus, const Gap(16),
text: 'Add Medicine', MenuWidget(
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, icon: FontAwesomeIcons.squarePlus,
text: 'Add Medicine Type', text: 'Add Medicine',
onPressed: () => {context.push('/addtype')}), onPressed: gotoAddMedicine,
const Gap(32), ),
MenuWidget( const Gap(16),
icon: FontAwesomeIcons.listCheck, MenuWidget(
text: 'List of Stocks', icon: FontAwesomeIcons.squarePlus,
onPressed: () => {context.push('/liststocks')}), text: 'Add Generics',
const Gap(32), onPressed: gotoAddGenerics,
// TextButton(onPressed: () => {_signOut()}, child: const Text('Logout')), ),
ButtonWidget( const Gap(16),
text: 'Logout', MenuWidget(
onPressed: signOut, 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) { Widget build(BuildContext context) {
return ElevatedButton( return ElevatedButton(
style: ElevatedButton.styleFrom( style: ElevatedButton.styleFrom(
foregroundColor: Color(0xFF8E44AD), // text color foregroundColor: Color.fromRGBO(0, 0, 0, 1), // text color
backgroundColor: const Color(0xFFE8DAEF), // background color backgroundColor: const Color.fromRGBO(198, 133, 232, 1), // background color
side: const BorderSide(color: Color.fromARGB(55, 255, 255, 255)), // border color side: const BorderSide(color: Color.fromRGBO(79, 51, 94, 1)), // border color
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(26), // rounded corners 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 padding: EdgeInsets.symmetric(vertical: 10, horizontal: 16), // padding
), ),
onPressed: onPressed, onPressed: onPressed,
child: Text( child: Text(
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: [ children: [
Text('$label:', Text('$label:',
style: GoogleFonts.outfit( 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), const Gap(8),
TextField( TextField(
controller: controller, controller: controller,
decoration: InputDecoration( decoration: InputDecoration(
border: OutlineInputBorder(borderRadius: BorderRadius.circular(10)), filled: true, // Enable filling the background
), fillColor: Colors.white,
style: GoogleFonts.outfit(textStyle: TextStyle(color: Colors.white, fontSize: 16)), 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, obscureText: password ?? false,
), ),
], ],

View file

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

View file

@ -4,12 +4,18 @@ import 'package:google_fonts/google_fonts.dart';
class TextWidget extends StatelessWidget { class TextWidget extends StatelessWidget {
final String text; final String text;
final double? size; 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 @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Text(text, 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)));
} }
} }

View file

@ -6,12 +6,14 @@ import FlutterMacOS
import Foundation import Foundation
import app_links import app_links
import connectivity_plus
import path_provider_foundation import path_provider_foundation
import shared_preferences_foundation import shared_preferences_foundation
import url_launcher_macos import url_launcher_macos
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
AppLinksMacosPlugin.register(with: registry.registrar(forPlugin: "AppLinksMacosPlugin")) AppLinksMacosPlugin.register(with: registry.registrar(forPlugin: "AppLinksMacosPlugin"))
ConnectivityPlusPlugin.register(with: registry.registrar(forPlugin: "ConnectivityPlusPlugin"))
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin")) PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin")) SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin"))
UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin")) UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin"))

View file

@ -33,6 +33,14 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.0.4" version: "1.0.4"
args:
dependency: transitive
description:
name: args
sha256: bf9f5caeea8d8fe6721a9c358dd8a5c1947b27f1cfaa18b39c301273594919e6
url: "https://pub.dev"
source: hosted
version: "2.6.0"
async: async:
dependency: transitive dependency: transitive
description: description:
@ -81,6 +89,22 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.19.0" version: "1.19.0"
connectivity_plus:
dependency: transitive
description:
name: connectivity_plus
sha256: "8a68739d3ee113e51ad35583fdf9ab82c55d09d693d3c39da1aebab87c938412"
url: "https://pub.dev"
source: hosted
version: "6.1.2"
connectivity_plus_platform_interface:
dependency: transitive
description:
name: connectivity_plus_platform_interface
sha256: "42657c1715d48b167930d5f34d00222ac100475f73d10162ddf43e714932f204"
url: "https://pub.dev"
source: hosted
version: "2.0.1"
crypto: crypto:
dependency: transitive dependency: transitive
description: description:
@ -97,6 +121,22 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.0.8" version: "1.0.8"
dbus:
dependency: transitive
description:
name: dbus
sha256: "79e0c23480ff85dc68de79e2cd6334add97e48f7f4865d17686dd6ea81a47e8c"
url: "https://pub.dev"
source: hosted
version: "0.7.11"
equatable:
dependency: transitive
description:
name: equatable
sha256: "567c64b3cb4cf82397aac55f4f0cbd3ca20d77c6c03bedbc4ceaddc08904aef7"
url: "https://pub.dev"
source: hosted
version: "2.0.7"
fake_async: fake_async:
dependency: transitive dependency: transitive
description: description:
@ -224,6 +264,14 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "4.1.2" version: "4.1.2"
internet_connection_checker:
dependency: "direct main"
description:
name: internet_connection_checker
sha256: ee08f13d8b13b978affe226e9274ca3ba7a9bed07c9479e8ae245f785b7a488a
url: "https://pub.dev"
source: hosted
version: "3.0.1"
intl: intl:
dependency: "direct main" dependency: "direct main"
description: description:
@ -312,6 +360,14 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "2.0.0" version: "2.0.0"
nm:
dependency: transitive
description:
name: nm
sha256: "2c9aae4127bdc8993206464fcc063611e0e36e72018696cd9631023a31b24254"
url: "https://pub.dev"
source: hosted
version: "0.5.0"
path: path:
dependency: transitive dependency: transitive
description: description:
@ -368,6 +424,14 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "2.3.0" version: "2.3.0"
petitparser:
dependency: transitive
description:
name: petitparser
sha256: c15605cd28af66339f8eb6fbe0e541bfe2d1b72d5825efc6598f3e0a31b9ad27
url: "https://pub.dev"
source: hosted
version: "6.0.2"
platform: platform:
dependency: transitive dependency: transitive
description: description:
@ -701,6 +765,14 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.1.0" version: "1.1.0"
xml:
dependency: transitive
description:
name: xml
sha256: b015a8ad1c488f66851d762d3090a21c600e479dc75e68328c52774040cf9226
url: "https://pub.dev"
source: hosted
version: "6.5.0"
yet_another_json_isolate: yet_another_json_isolate:
dependency: transitive dependency: transitive
description: description:

View file

@ -22,6 +22,7 @@ dependencies:
bottom_picker: ^2.10.1 bottom_picker: ^2.10.1
intl: ^0.20.2 intl: ^0.20.2
visibility_detector: ^0.4.0+2 visibility_detector: ^0.4.0+2
internet_connection_checker: ^3.0.1
dev_dependencies: dev_dependencies:
flutter_test: flutter_test:

View file

@ -7,11 +7,14 @@
#include "generated_plugin_registrant.h" #include "generated_plugin_registrant.h"
#include <app_links/app_links_plugin_c_api.h> #include <app_links/app_links_plugin_c_api.h>
#include <connectivity_plus/connectivity_plus_windows_plugin.h>
#include <url_launcher_windows/url_launcher_windows.h> #include <url_launcher_windows/url_launcher_windows.h>
void RegisterPlugins(flutter::PluginRegistry* registry) { void RegisterPlugins(flutter::PluginRegistry* registry) {
AppLinksPluginCApiRegisterWithRegistrar( AppLinksPluginCApiRegisterWithRegistrar(
registry->GetRegistrarForPlugin("AppLinksPluginCApi")); registry->GetRegistrarForPlugin("AppLinksPluginCApi"));
ConnectivityPlusWindowsPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("ConnectivityPlusWindowsPlugin"));
UrlLauncherWindowsRegisterWithRegistrar( UrlLauncherWindowsRegisterWithRegistrar(
registry->GetRegistrarForPlugin("UrlLauncherWindows")); registry->GetRegistrarForPlugin("UrlLauncherWindows"));
} }

View file

@ -4,6 +4,7 @@
list(APPEND FLUTTER_PLUGIN_LIST list(APPEND FLUTTER_PLUGIN_LIST
app_links app_links
connectivity_plus
url_launcher_windows url_launcher_windows
) )