This commit is contained in:
Patrick Alvin Alcala 2025-02-04 12:05:42 +08:00
parent 50d2cba7f2
commit 7fca1e79a8
9 changed files with 53 additions and 23 deletions

View file

@ -1,15 +1,20 @@
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';
class MenuWidget extends StatelessWidget {
final String text;
final IconData? icon;
final VoidCallback? onPressed;
final Color? borderColor;
final String? color;
const MenuWidget({super.key, required this.text, this.icon, this.onPressed, this.borderColor});
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) {
@ -20,7 +25,10 @@ class MenuWidget extends StatelessWidget {
padding: EdgeInsets.only(top: 16, bottom: 16),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12),
border: Border.all(color: borderColor ?? const Color.fromARGB(255, 255, 255, 255), width: 2),
border: Border.all(
color: color != null ? _getColorBasedOnString(color ?? '') : const Color.fromRGBO(255, 255, 255, 0.6),
width: 2),
color: color != null ? _getColorBasedOnString(color ?? '') : Colors.transparent,
),
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
@ -39,4 +47,21 @@ class MenuWidget extends StatelessWidget {
),
);
}
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 Colors.transparent; // Default to transparent if color is not recognized
}
}
}