This commit is contained in:
Patrick Alvin Alcala 2025-01-27 13:18:18 +08:00
parent 3e6781a0bd
commit 5469c484e1
10 changed files with 204 additions and 48 deletions

View file

@ -1,4 +1,5 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:pharmacy_mobile/pages/add_medicine.dart';
// import 'package:pharmacy_mobile/auth/auth_gate.dart'; // import 'package:pharmacy_mobile/auth/auth_gate.dart';
import 'package:pharmacy_mobile/pages/index_page.dart'; import 'package:pharmacy_mobile/pages/index_page.dart';
import 'package:pharmacy_mobile/pages/login_page.dart'; import 'package:pharmacy_mobile/pages/login_page.dart';
@ -49,6 +50,11 @@ final _router = GoRouter(
path: '/main', path: '/main',
builder: (context, state) => MainPage(), builder: (context, state) => MainPage(),
), ),
GoRoute(
name: 'addmedicines',
path: '/addmedicines',
builder: (context, state) => AddMedicinePage(),
),
], ],
); );

View file

@ -0,0 +1,45 @@
import 'package:flutter/material.dart';
import 'package:gap/gap.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:pharmacy_mobile/widgets/text_widget.dart';
import 'package:pharmacy_mobile/widgets/title_widget.dart';
class AddMedicinePage extends StatefulWidget {
const AddMedicinePage({super.key});
@override
AddMedicinePageState createState() => AddMedicinePageState();
}
class AddMedicinePageState extends State<AddMedicinePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Container(
alignment: Alignment.center,
height: MediaQuery.of(context).size.height,
decoration: const BoxDecoration(
gradient: LinearGradient(
colors: [
Color.fromRGBO(34, 51, 69, 1),
Color.fromRGBO(22, 32, 44, 1),
],
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
),
),
child: Center(
child: Column(
children: [
const Gap(120),
const TitleWidget(firstTextSize: 16, secondTextSize: 32),
const Gap(32),
const TextWidget(text: 'Add Medicine'),
const Gap(16),
],
),
),
),
);
}
}

View file

@ -2,12 +2,17 @@ import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart'; import 'package:go_router/go_router.dart';
import 'package:google_fonts/google_fonts.dart'; import 'package:google_fonts/google_fonts.dart';
import 'package:gap/gap.dart'; import 'package:gap/gap.dart';
import 'package:pharmacy_mobile/widgets/button_widget.dart';
class IndexPage extends StatelessWidget { class IndexPage extends StatelessWidget {
const IndexPage({super.key}); const IndexPage({super.key});
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
void gotoLogin() {
context.push('/login');
}
return Scaffold( return Scaffold(
resizeToAvoidBottomInset: false, resizeToAvoidBottomInset: false,
body: Container( body: Container(
@ -40,8 +45,8 @@ class IndexPage extends StatelessWidget {
child: Image.asset('assets/ph_logo.webp', child: Image.asset('assets/ph_logo.webp',
width: 256, cacheWidth: (256 * MediaQuery.of(context).devicePixelRatio).round()), width: 256, cacheWidth: (256 * MediaQuery.of(context).devicePixelRatio).round()),
), ),
const Gap(16), const Gap(32),
TextButton(onPressed: () => {context.push('/login')}, child: const Text('Login')) ButtonWidget(text: 'Login', onPressed: gotoLogin)
], ],
), ),
), ),

View file

@ -1,9 +1,13 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:go_router/go_router.dart'; import 'package:go_router/go_router.dart';
import 'package:google_fonts/google_fonts.dart'; import 'package:google_fonts/google_fonts.dart';
import 'package:gap/gap.dart'; import 'package:gap/gap.dart';
import 'package:pharmacy_mobile/auth/auth_service.dart'; import 'package:pharmacy_mobile/auth/auth_service.dart';
import 'package:pharmacy_mobile/main.dart'; import 'package:pharmacy_mobile/main.dart';
import 'package:pharmacy_mobile/widgets/button_widget.dart';
import 'package:pharmacy_mobile/widgets/text_widget.dart';
import 'package:pharmacy_mobile/widgets/title_widget.dart';
import 'dart:developer'; import 'dart:developer';
import 'package:quickalert/quickalert.dart'; import 'package:quickalert/quickalert.dart';
@ -18,6 +22,7 @@ class _LoginPageState extends State<LoginPage> {
final _authService = AuthService(); final _authService = AuthService();
final _emailController = TextEditingController(); final _emailController = TextEditingController();
final _passwordController = TextEditingController(); final _passwordController = TextEditingController();
final FocusNode _focusNode = FocusNode();
void _signIn() async { void _signIn() async {
final email = _emailController.text; final email = _emailController.text;
@ -81,16 +86,9 @@ class _LoginPageState extends State<LoginPage> {
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
children: [ children: [
const Gap(120), const Gap(120),
Text('Ofelia Franco-Alcala', const TitleWidget(firstTextSize: 16, secondTextSize: 32),
style: GoogleFonts.outfit(
textStyle: const TextStyle(color: Color.fromRGBO(255, 255, 255, 1), fontSize: 16))),
Text('Pharmacy',
style: GoogleFonts.outfit(
textStyle: const TextStyle(color: Color.fromRGBO(255, 255, 255, 1), fontSize: 32))),
const Gap(32), const Gap(32),
Text('Login', const TextWidget(text: 'Login'),
style: GoogleFonts.outfit(
textStyle: const TextStyle(color: Color.fromRGBO(255, 255, 255, 1), fontSize: 32))),
const Gap(16), const Gap(16),
Padding( Padding(
padding: const EdgeInsets.only(left: 16, right: 16), padding: const EdgeInsets.only(left: 16, right: 16),
@ -110,17 +108,26 @@ class _LoginPageState extends State<LoginPage> {
style: const TextStyle(color: Colors.white), style: const TextStyle(color: Colors.white),
), ),
const Gap(8), const Gap(8),
TextFormField( KeyboardListener(
obscureText: true, focusNode: _focusNode,
controller: _passwordController, onKeyEvent: (event) {
decoration: const InputDecoration( if (event is KeyDownEvent && event.logicalKey == LogicalKeyboardKey.enter) {
labelText: 'Password', _signIn();
border: OutlineInputBorder(), }
},
child: TextFormField(
obscureText: true,
controller: _passwordController,
decoration: const InputDecoration(
labelText: 'Password',
border: OutlineInputBorder(),
),
style: const TextStyle(color: Colors.white),
), ),
style: const TextStyle(color: Colors.white),
), ),
const Gap(16), const Gap(16),
TextButton(onPressed: () => {_signIn()}, child: const Text('Login')) // TextButton(onPressed: () => {_signIn()}, child: const Text('Login'))
ButtonWidget(text: 'Login', onPressed: _signIn)
], ],
)), )),
), ),

View file

@ -4,7 +4,10 @@ import 'package:gap/gap.dart';
import 'package:go_router/go_router.dart'; import 'package:go_router/go_router.dart';
import 'package:google_fonts/google_fonts.dart'; import 'package:google_fonts/google_fonts.dart';
import 'package:pharmacy_mobile/auth/auth_service.dart'; import 'package:pharmacy_mobile/auth/auth_service.dart';
import 'package:pharmacy_mobile/widgets/button_widget.dart';
import 'package:pharmacy_mobile/widgets/menu_widget.dart'; import 'package:pharmacy_mobile/widgets/menu_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 StatelessWidget {
const MainPage({super.key}); const MainPage({super.key});
@ -18,6 +21,10 @@ class MainPage extends StatelessWidget {
context.push('/'); context.push('/');
} }
void gotoAddMedicine() {
context.push('/addmedicines');
}
return Scaffold( return Scaffold(
body: Container( body: Container(
alignment: Alignment.center, alignment: Alignment.center,
@ -36,27 +43,41 @@ class MainPage extends StatelessWidget {
child: Column( child: Column(
children: [ children: [
const Gap(120), const Gap(120),
Text('Ofelia Franco-Alcala', const TitleWidget(firstTextSize: 16, secondTextSize: 32),
style: GoogleFonts.outfit(
textStyle: const TextStyle(color: Color.fromRGBO(255, 255, 255, 1), fontSize: 16))),
Text('Pharmacy',
style: GoogleFonts.outfit(
textStyle: const TextStyle(color: Color.fromRGBO(255, 255, 255, 1), fontSize: 32))),
const Gap(32), const Gap(32),
Text('Menu', const TextWidget(text: 'Menu'),
style: GoogleFonts.outfit(
textStyle: const TextStyle(color: Color.fromRGBO(255, 255, 255, 1), fontSize: 32))),
const Gap(16), const Gap(16),
MenuWidget( MenuWidget(
icon: FontAwesomeIcons.squarePlus, icon: FontAwesomeIcons.squarePlus,
text: 'Add Medicine', text: 'Add Medicine',
onPressed: gotoAddMedicine,
), ),
const Gap(16), const Gap(16),
MenuWidget( MenuWidget(
icon: FontAwesomeIcons.squarePlus, icon: FontAwesomeIcons.squarePlus,
text: 'Add Generics', text: 'Add Generics',
), ),
TextButton(onPressed: () => {signOut()}, child: const Text('Logout')) const Gap(16),
MenuWidget(
icon: FontAwesomeIcons.squarePlus,
text: 'Add Stock',
),
const Gap(16),
MenuWidget(
icon: FontAwesomeIcons.squarePlus,
text: 'Add Medicine Type',
),
const Gap(32),
MenuWidget(
icon: FontAwesomeIcons.listCheck,
text: 'List of Stocks',
),
const Gap(32),
// TextButton(onPressed: () => {_signOut()}, child: const Text('Logout')),
ButtonWidget(
text: 'Logout',
onPressed: signOut,
)
], ],
), ),
), ),

View file

@ -0,0 +1,30 @@
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
// import 'package:google_fonts/google_fonts.dart';
class ButtonWidget extends StatelessWidget {
final String text;
final VoidCallback onPressed;
const ButtonWidget({super.key, required this.text, required this.onPressed});
@override
Widget build(BuildContext context) {
return TextButton(
style: TextButton.styleFrom(
foregroundColor: Colors.white, // text color
backgroundColor: const Color.fromARGB(255, 54, 140, 136), // background color
side: const BorderSide(color: Color.fromARGB(55, 255, 255, 255)), // border color
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(26), // rounded corners
),
minimumSize: Size(MediaQuery.of(context).size.width - 64, 40), // minimum size
padding: EdgeInsets.symmetric(vertical: 10, horizontal: 16), // padding
),
onPressed: onPressed,
child: Text(
text,
style: GoogleFonts.outfit(textStyle: const TextStyle(fontSize: 18)),
));
}
}

View file

@ -1,33 +1,40 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:gap/gap.dart'; import 'package:gap/gap.dart';
import 'package:google_fonts/google_fonts.dart';
// import 'package:pharmacy_mobile/widgets/text_widget.dart';
class MenuWidget extends StatelessWidget { class MenuWidget extends StatelessWidget {
final String? text; final String text;
final IconData? icon; final IconData? icon;
final VoidCallback? onPressed;
const MenuWidget({ const MenuWidget({
super.key, super.key,
this.text, required this.text,
this.icon, this.icon,
this.onPressed,
}); });
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Container( return GestureDetector(
width: MediaQuery.of(context).size.width - 32, onTap: onPressed,
height: 100, child: Container(
decoration: BoxDecoration( width: MediaQuery.of(context).size.width - 64,
borderRadius: BorderRadius.circular(10), height: 80,
color: Colors.grey[200], decoration: BoxDecoration(
), borderRadius: BorderRadius.circular(10),
child: Row(mainAxisAlignment: MainAxisAlignment.start, children: [ color: Colors.grey[200],
const Gap(32), ),
Icon(icon, size: 32, color: const Color.fromRGBO(34, 51, 69, 1)), child: Row(mainAxisAlignment: MainAxisAlignment.start, children: [
const Gap(120), const Gap(32),
Text( Icon(icon, size: 32, color: const Color.fromRGBO(34, 51, 69, 1)),
text ?? 'Data', const Gap(64),
style: TextStyle(fontSize: 16), Text(
) text,
])); style: GoogleFonts.outfit(textStyle: const TextStyle(fontSize: 20)),
),
])),
);
} }
} }

View file

@ -0,0 +1,14 @@
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
class TextWidget extends StatelessWidget {
final String text;
const TextWidget({super.key, required this.text});
@override
Widget build(BuildContext context) {
return Text(text,
style: GoogleFonts.outfit(textStyle: const TextStyle(color: Color.fromRGBO(255, 255, 255, 1), fontSize: 32)));
}
}

View file

@ -0,0 +1,21 @@
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
class TitleWidget extends StatelessWidget {
final double firstTextSize;
final double secondTextSize;
const TitleWidget({super.key, required this.firstTextSize, required this.secondTextSize});
@override
Widget build(BuildContext context) {
return Column(children: [
Text('Ofelia Franco-Alcala',
style: GoogleFonts.outfit(
textStyle: TextStyle(color: Color.fromRGBO(255, 255, 255, 1), fontSize: firstTextSize))),
Text('Pharmacy',
style: GoogleFonts.outfit(
textStyle: TextStyle(color: Color.fromRGBO(255, 255, 255, 1), fontSize: secondTextSize))),
]);
}
}

View file

@ -1,5 +1,5 @@
name: pharmacy_mobile name: pharmacy_mobile
description: "A new Flutter project." description: "A Pharmacy Mobile Application."
publish_to: "none" publish_to: "none"
version: 1.0.0+1 version: 1.0.0+1