This commit is contained in:
Patrick Alvin Alcala 2025-02-26 12:52:08 +08:00
parent cbf2ff062f
commit 7886eeb6c2
26 changed files with 210 additions and 228 deletions

View file

@ -1,10 +1,14 @@
import 'dart:convert';
import 'dart:developer';
import 'dart:io';
import 'dart:typed_data';
import 'package:flutter/material.dart';
import 'package:gap/gap.dart';
import 'package:image_picker/image_picker.dart';
import 'package:internet_connection_checker/internet_connection_checker.dart';
import 'package:pharmacy_mobile/functions/barcode_scan_function.dart';
import 'package:pharmacy_mobile/functions/checkresult_function.dart';
import 'package:pharmacy_mobile/security/encryption.dart';
import 'package:pharmacy_mobile/tables/ref_categories.dart';
import 'package:pharmacy_mobile/tables/ref_generic_names.dart';
import 'package:pharmacy_mobile/tables/ref_manufactorers.dart';
@ -22,7 +26,6 @@ import 'package:pharmacy_mobile/widgets/snackbar_widget.dart';
import 'package:pharmacy_mobile/widgets/text_widget.dart';
import 'package:pharmacy_mobile/widgets/title_widget.dart';
import 'package:go_router/go_router.dart';
import 'package:simple_barcode_scanner/simple_barcode_scanner.dart';
import 'package:uuid/uuid.dart';
import 'package:flutter_image_compress/flutter_image_compress.dart';
@ -161,7 +164,8 @@ class _AddMedicinePageState extends State<AddMedicinePage> {
setState(() => _isLoading = true);
try {
final String encrpytedBarcode = await encrypt(_barcodeController.text);
// final String encrpytedBarcode = await encrypt(_barcodeController.text);
final String encrpytedBarcode = _barcodeController.text;
if (await InternetConnectionChecker.instance.hasConnection) {
final medName = _nameController.text;
@ -187,16 +191,19 @@ class _AddMedicinePageState extends State<AddMedicinePage> {
void _addImage() async {
final imageName = Uuid().v4();
uuid = imageName;
final ImagePicker picker = ImagePicker();
final XFile? image = await picker.pickImage(source: ImageSource.gallery);
final XFile? image = await picker.pickImage(source: ImageSource.gallery, imageQuality: 100);
const storageName = 'ref_medicines_images';
if (image == null) {
return;
}
final imageBytes = await image!.readAsBytes();
final webpImage = await _webpConvert(imageBytes);
imageUrl = await _storage.uploadImage(context, storageName, image, '$imageName.webp');
uuid = imageName;
if (mounted) {
imageUrl = await _storage.uploadImage(context, storageName, webpImage, '$imageName.webp');
}
setState(() {
if (imageUrl.isEmpty) {
@ -207,6 +214,19 @@ class _AddMedicinePageState extends State<AddMedicinePage> {
});
}
Future<Uint8List> _webpConvert(Uint8List file) async {
final result = await FlutterImageCompress.compressWithList(
file,
// minHeight: 1080,
// minWidth: 1080,
quality: 75,
rotate: 0,
keepExif: false,
format: CompressFormat.webp,
);
return result;
}
@override
void initState() {
autoRun();
@ -261,7 +281,10 @@ class _AddMedicinePageState extends State<AddMedicinePage> {
listTitle: 'generic_name',
onChanged: _updateGeneric),
const Gap(8),
TextWidget(text: _selectedCategory, size: 18),
Padding(
padding: const EdgeInsets.only(left: 12),
child: TextWidget(text: _selectedCategory, size: 18),
),
const Gap(16),
DropDownWidget(
label: 'Type', list: _typeList, listTitle: 'type_name', onChanged: _updateType),
@ -282,7 +305,11 @@ class _AddMedicinePageState extends State<AddMedicinePage> {
child: Image.network(imageUrl, fit: BoxFit.cover, width: 250, height: 250)),
)
else
ButtonWidget(text: 'Add Image', onPressed: _addImage),
ButtonWidget(
text: 'Add Image',
onPressed: _addImage,
outline: true,
),
const Gap(32),
if (_isLoading)
const Center(child: CircularProgressIndicator(color: Colors.white))

View file

@ -85,11 +85,16 @@ class _AddStockPageState extends State<AddStockPage> with WidgetsBindingObserver
}
void _saveStock() async {
final stockNameUUID = await _refMedicines.getUUID(_selectedMedicine);
final stockQuantity = _quantityController.text;
final stockExpiration = _dateController.text;
// final stockNameUUID = await _refMedicines.getUUID(_selectedMedicine);
// final stockQuantity = _quantityController.text;
// final stockExpiration = _dateController.text;
await _stocks.postStock(stockNameUUID, stockExpiration, stockQuantity);
// await _stocks.postStock(stockNameUUID, stockExpiration, stockQuantity);
final aa = await encrypt('text');
final bb =
await decrypt('4cee2f33af6ebac8dcfdeeccdd6c73c4698ce25b0cb26249c571fafc8483b5a047baefc4d626fa56e027343d');
log('encrypt: $aa');
log('plain: $bb');
}
Future<void> _scanBarcode() async {

View file

@ -70,7 +70,6 @@ class _CustomerPageState extends State<CustomerPage> {
size: barFontSize,
bold: true,
color: unselectedBarColor,
footer: true,
)),
BottomBarItem(
inActiveItem:
@ -81,7 +80,6 @@ class _CustomerPageState extends State<CustomerPage> {
size: barFontSize,
bold: true,
color: unselectedBarColor,
footer: true,
),
),
BottomBarItem(
@ -93,7 +91,6 @@ class _CustomerPageState extends State<CustomerPage> {
size: barFontSize,
bold: true,
color: unselectedBarColor,
footer: true,
),
),
BottomBarItem(
@ -104,7 +101,6 @@ class _CustomerPageState extends State<CustomerPage> {
size: barFontSize,
bold: true,
color: unselectedBarColor,
footer: true,
),
),
],

View file

@ -42,7 +42,7 @@ class _CustomerMainPageState extends State<CustomerMainPage> {
const Gap(32),
const TextWidget(text: 'Menu'),
const Gap(16),
MenuWidget2(
MenuWidget(
// icon: FontAwesomeIcons.diagramNext,
text: 'Diagnose by ',
description: 'aaa',

View file

@ -49,9 +49,12 @@ class IndexPage extends StatelessWidget {
text: 'Copyright © 2025 - Ofelia Franco-Alcala Pharmacy',
size: 10,
bold: true,
footer: true,
),
const TextWidget(text: 'Developed By: Pat Alcala', size: 8, opacity: 0.8, footer: true),
const TextWidget(
text: 'Developed By: Pat Alcala',
size: 8,
opacity: 0.8,
),
const Gap(16),
],
),

View file

@ -123,7 +123,10 @@ class _LoginPageState extends State<LoginPage> {
logoSize: 90,
),
const Gap(32),
const TextWidget(text: 'Login'),
const TextWidget(
text: 'Login',
title: true,
),
const Gap(16),
Padding(
padding: const EdgeInsets.only(left: 32, right: 32),

View file

@ -4,7 +4,6 @@ import 'package:gap/gap.dart';
import 'package:go_router/go_router.dart';
import 'package:pharmacy_mobile/auth/auth_service.dart';
import 'package:pharmacy_mobile/widgets/button_widget.dart';
import 'package:pharmacy_mobile/widgets/logo_widget.dart';
import 'package:pharmacy_mobile/widgets/menu_widget2.dart';
import 'package:pharmacy_mobile/widgets/page_background_widget.dart';
import 'package:pharmacy_mobile/widgets/snackbar_widget.dart';
@ -46,9 +45,12 @@ class _MainPageState extends State<MainPage> {
logoSize: 90,
),
const Gap(32),
const TextWidget(text: 'Menu'),
const TextWidget(
text: 'Menu',
title: true,
),
const Gap(16),
MenuWidget2(
MenuWidget(
icon: FontAwesomeIcons.circlePlus,
text: 'Add Type',
description: 'Create a new medical type',
@ -56,7 +58,7 @@ class _MainPageState extends State<MainPage> {
color: 'blue',
),
const Gap(16),
MenuWidget2(
MenuWidget(
icon: FontAwesomeIcons.circlePlus,
text: 'Add Category',
description: 'Create a new medicine category',
@ -64,35 +66,35 @@ class _MainPageState extends State<MainPage> {
color: 'blue',
),
const Gap(16),
MenuWidget2(
MenuWidget(
icon: FontAwesomeIcons.circlePlus,
text: 'Add Generics',
description: 'Add generic name on the list',
onPressed: () => {context.push('/addgenerics')},
color: 'blue'),
const Gap(32),
MenuWidget2(
MenuWidget(
icon: FontAwesomeIcons.circlePlus,
text: 'Add Medicine',
description: 'Add generic name on the list',
onPressed: () => {context.push('/addmedicines')},
color: 'green'),
const Gap(16),
MenuWidget2(
MenuWidget(
icon: FontAwesomeIcons.circlePlus,
text: 'Add Stock',
description: 'Add generic name on the list',
onPressed: () => {context.push('/addstock')},
color: 'green'),
const Gap(32),
MenuWidget2(
MenuWidget(
icon: Icons.delete,
text: 'Remove Stock',
description: 'Add generic name on the list',
onPressed: () => {context.push('/deletestock')},
color: 'red'),
const Gap(32),
MenuWidget2(
MenuWidget(
icon: FontAwesomeIcons.listCheck,
text: 'List of Stocks',
description: 'Add generic name on the list',

View file

@ -116,7 +116,10 @@ class _RegisterPageState extends State<RegisterPage> {
logoSize: 90,
),
const Gap(32),
const TextWidget(text: 'Register'),
const TextWidget(
text: 'Register',
title: true,
),
const Gap(16),
Padding(
padding: const EdgeInsets.only(left: 32, right: 32),

View file

@ -42,9 +42,9 @@ class Storage {
}
}
Future<String> uploadImage(BuildContext context, String storage, XFile image, String name) async {
Future<String> uploadImage(BuildContext context, String storage, Uint8List image, String name) async {
try {
final imageBytes = await image.readAsBytes();
final imageBytes = image;
final imagePath = name;
await _supabase.storage.from(storage).uploadBinary(imagePath, imageBytes);

View file

@ -47,9 +47,9 @@ class ButtonWidget extends StatelessWidget {
TextStyle _textStyle(bool? outline) {
if (outline == true) {
return GoogleFonts.outfit(textStyle: const TextStyle(fontSize: 14, color: Color.fromRGBO(198, 133, 232, 1)));
return GoogleFonts.inter(textStyle: const TextStyle(fontSize: 14, color: Color.fromRGBO(198, 133, 232, 1)));
} else {
return GoogleFonts.outfit(textStyle: const TextStyle(fontSize: 14, color: Color.fromRGBO(0, 0, 0, 1)));
return GoogleFonts.inter(textStyle: const TextStyle(fontSize: 14, color: Color.fromRGBO(0, 0, 0, 1)));
}
}
}

View file

@ -33,23 +33,24 @@ class _DatePickerWidgetState extends State<DatePickerWidget> {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('${widget.label}:',
style: GoogleFonts.outfit(
textStyle: const TextStyle(color: Colors.white, fontSize: 12),
style: GoogleFonts.inter(
textStyle: const TextStyle(color: Colors.white, fontSize: 12, fontWeight: FontWeight.w500),
)),
const Gap(8),
GestureDetector(
onTap: () => {_selectDate(context)},
child: Container(
padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 16),
padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 14),
decoration: BoxDecoration(
border: Border.all(color: Colors.white),
borderRadius: BorderRadius.circular(8),
borderRadius: BorderRadius.circular(4),
color: Colors.transparent,
),
alignment: Alignment.centerLeft,
child: Text(widget.controller.text.isNotEmpty ? widget.controller.text : 'Select Date',
style: GoogleFonts.outfit(
textStyle: const TextStyle(color: Color.fromRGBO(255, 255, 255, 1), fontSize: 16))),
style: GoogleFonts.inter(
textStyle: const TextStyle(color: Color.fromRGBO(255, 255, 255, 1), fontSize: 16),
fontWeight: FontWeight.w500)),
),
),
],

View file

@ -24,15 +24,15 @@ class DropDownWidget extends StatelessWidget {
children: [
Text(
'$label:',
style: GoogleFonts.outfit(
textStyle: const TextStyle(color: Colors.white, fontSize: 12),
style: GoogleFonts.inter(
textStyle: const TextStyle(color: Colors.white, fontSize: 12, fontWeight: FontWeight.w500),
),
),
const Gap(8),
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8), // Set the desired border radius
border: Border.all(color: const Color.fromRGBO(255, 255, 255, 1)), // Set the border color
borderRadius: BorderRadius.circular(4), // Set the desired border radius
border: Border.all(color: const Color.fromRGBO(255, 255, 255, 1)),
),
child: DropdownMenu(
initialSelection: '',
@ -42,20 +42,22 @@ class DropDownWidget extends StatelessWidget {
label: item[listTitle].toString(),
value: item[listTitle],
style: ButtonStyle(
foregroundColor: WidgetStateProperty.all<Color>(const Color.fromRGBO(230, 230, 230, 1)),
foregroundColor: WidgetStateProperty.all<Color>(const Color.fromRGBO(10, 10, 10, 1)),
textStyle: WidgetStateProperty.all<TextStyle>(
GoogleFonts.inter(fontSize: 16, fontWeight: FontWeight.w500)))),
],
onSelected: onChanged,
width: MediaQuery.of(context).size.width * 0.9,
menuHeight: MediaQuery.of(context).size.height * 0.8,
textStyle:
GoogleFonts.outfit(textStyle: const TextStyle(color: Color.fromRGBO(255, 255, 255, 1), fontSize: 16)),
textStyle: GoogleFonts.inter(
textStyle: const TextStyle(color: Color.fromRGBO(255, 255, 255, 1), fontSize: 16),
fontWeight: FontWeight.w500),
menuStyle: MenuStyle(
backgroundColor: WidgetStateProperty.all<Color>(const Color.fromRGBO(21, 13, 35, 0.902)),
// backgroundColor: WidgetStateProperty.all<Color>(const Color.fromRGBO(21, 13, 35, 0.902)),
backgroundColor: WidgetStateProperty.all<Color>(const Color.fromRGBO(255, 255, 255, 1)),
padding: WidgetStateProperty.all(const EdgeInsets.symmetric(vertical: 16, horizontal: 8)),
shape: WidgetStateProperty.all(RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8), // Set the border radius for the dropdown menu
borderRadius: BorderRadius.circular(4), // Set the border radius for the dropdown menu
)),
),
),

View file

@ -26,7 +26,7 @@ class DropdownWrapperWidget extends StatelessWidget {
spacing: 16,
children: [
const CircularProgressIndicator(color: Color.fromRGBO(255, 255, 255, 1)),
TextWidget(text: 'Fetching $text', size: 16, footer: true)
TextWidget(text: 'Fetching $text', size: 16)
],
),
],

View file

@ -26,7 +26,10 @@ class DropdownWrapperMultiWidget extends StatelessWidget {
spacing: 16,
children: [
const CircularProgressIndicator(color: Color.fromRGBO(255, 255, 255, 1)),
TextWidget(text: 'Fetching $text', size: 16, footer: true)
TextWidget(
text: 'Fetching $text',
size: 16,
)
],
),
],

View file

@ -20,7 +20,7 @@ class InputWidget extends StatelessWidget {
children: [
if (label.isNotEmpty)
Text('$label:',
style: GoogleFonts.outfit(
style: GoogleFonts.inter(
textStyle:
const TextStyle(color: Color.fromRGBO(255, 255, 255, 1), fontSize: 12, fontWeight: FontWeight.w500),
)),
@ -31,11 +31,15 @@ class InputWidget extends StatelessWidget {
decoration: InputDecoration(
filled: true,
fillColor: const Color.fromRGBO(255, 255, 255, 1),
border: OutlineInputBorder(borderRadius: BorderRadius.circular(8)),
contentPadding: const EdgeInsets.symmetric(vertical: 2, horizontal: 24),
border: OutlineInputBorder(borderRadius: BorderRadius.circular(4)),
contentPadding: const EdgeInsets.symmetric(vertical: 0, horizontal: 14),
prefixIcon: placeholder != null ? Icon(Icons.search, color: Colors.grey) : null,
hintText: placeholder),
style: GoogleFonts.outfit(textStyle: const TextStyle(color: Color.fromRGBO(0, 0, 0, 1), fontSize: 16)),
style: GoogleFonts.inter(
textStyle: const TextStyle(
color: Color.fromRGBO(0, 0, 0, 1),
fontSize: 16,
)),
obscureText: password ?? false,
onChanged: onChanged,
),

View file

@ -1,67 +0,0 @@
import 'package:flutter/material.dart';
import 'package:gap/gap.dart';
import 'package:google_fonts/google_fonts.dart';
class MenuWidget extends StatelessWidget {
final String text;
final IconData? icon;
final VoidCallback? onPressed;
final String? color;
final Color green = const Color.fromRGBO(58, 236, 27, 0.2);
final Color blue = const Color.fromRGBO(27, 90, 236, 0.2);
final Color red = const Color.fromRGBO(236, 27, 27, 0.2);
final Color yellow = const Color.fromRGBO(236, 232, 27, 0.2);
final Color teal = const Color.fromRGBO(27, 236, 229, 0.2);
const MenuWidget({super.key, required this.text, this.icon, this.onPressed, this.color});
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: onPressed,
child: Container(
width: MediaQuery.of(context).size.width - 96,
padding: const EdgeInsets.only(top: 16, bottom: 16),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8),
border: Border.all(
color: color != null ? _getColorBasedOnString(color ?? '') : const Color.fromRGBO(255, 255, 255, 0.6),
width: 2),
color: color != null ? _getColorBasedOnString(color ?? '') : const Color.fromRGBO(0, 0, 0, 0),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
const Gap(32),
Icon(icon, size: 24, color: const Color.fromRGBO(255, 255, 255, 1)),
const Gap(64),
Text(
text,
style: GoogleFonts.outfit(
color: const Color.fromRGBO(255, 255, 255, 1),
textStyle: const TextStyle(fontSize: 16, fontWeight: FontWeight.w500)),
),
],
),
),
);
}
Color _getColorBasedOnString(String color) {
switch (color.toLowerCase()) {
case 'green':
return green;
case 'blue':
return blue;
case 'red':
return red;
case 'yellow':
return yellow;
case 'teal':
return teal;
default:
return const Color.fromRGBO(0, 0, 0, 0); // Default to transparent if color is not recognized
}
}
}

View file

@ -3,7 +3,7 @@ import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:gap/gap.dart';
import 'package:pharmacy_mobile/widgets/text_widget.dart';
class MenuWidget2 extends StatelessWidget {
class MenuWidget extends StatelessWidget {
final String text;
final IconData? icon;
final VoidCallback? onPressed;
@ -34,7 +34,7 @@ class MenuWidget2 extends StatelessWidget {
const Color.fromRGBO(104, 156, 59, 0.8),
];
MenuWidget2({super.key, required this.text, required this.description, this.icon, this.onPressed, this.color});
MenuWidget({super.key, required this.text, required this.description, this.icon, this.onPressed, this.color});
@override
Widget build(BuildContext context) {

View file

@ -6,12 +6,12 @@ class TextWidget extends StatelessWidget {
final double? size;
final double? opacity;
final bool? bold;
final bool? footer;
final bool? title;
final bool? underlined;
final Color? color;
const TextWidget(
{super.key, required this.text, this.size, this.opacity, this.bold, this.footer, this.underlined, this.color});
{super.key, required this.text, this.size, this.opacity, this.bold, this.title, this.underlined, this.color});
@override
Widget build(BuildContext context) {
@ -23,8 +23,8 @@ class TextWidget extends StatelessWidget {
decorationColor: const Color.fromRGBO(255, 255, 255, 1),
decorationThickness: 2);
return footer == true
? Text(text, style: GoogleFonts.inter(textStyle: textStyle))
: Text(text, style: GoogleFonts.outfit(textStyle: textStyle));
return title == true
? Text(text, style: GoogleFonts.outfit(textStyle: textStyle))
: Text(text, style: GoogleFonts.inter(textStyle: textStyle));
}
}