pharmacy_mobile/lib/widgets/menu_widget.dart
2025-02-28 14:08:05 +08:00

101 lines
2.8 KiB
Dart

import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:gap/gap.dart';
import 'package:pharmacy_mobile/widgets/text_widget.dart';
class MenuWidget extends StatelessWidget {
final String text;
final IconData? icon;
final VoidCallback? onPressed;
final String? color;
final String description;
final double? width;
final List<Color> blue = [
const Color.fromRGBO(59, 101, 156, 0.8),
const Color.fromRGBO(59, 101, 156, 0.8),
const Color.fromRGBO(59, 156, 156, 0.8),
];
final List<Color> green = [
const Color.fromRGBO(59, 156, 103, 0.8),
const Color.fromRGBO(59, 156, 103, 0.8),
const Color.fromRGBO(122, 182, 70, 0.8),
];
final List<Color> red = [
const Color.fromRGBO(156, 59, 59, 0.8),
const Color.fromRGBO(164, 62, 62, 0.8),
const Color.fromRGBO(186, 120, 70, 0.8),
];
final List<Color> yellow = [
const Color.fromRGBO(156, 156, 59, 0.8),
const Color.fromRGBO(156, 156, 59, 0.8),
const Color.fromRGBO(104, 156, 59, 0.8),
];
MenuWidget(
{super.key, required this.text, required this.description, this.icon, this.onPressed, this.color, this.width});
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: onPressed,
child: Container(
width: width ?? MediaQuery.of(context).size.width - 96,
padding: const EdgeInsets.symmetric(vertical: 16),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12),
gradient: LinearGradient(
colors: _getColorList(color ?? ''),
begin: Alignment.centerLeft,
end: Alignment.centerRight,
),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
const Gap(24),
// Icon(icon, size: 28, color: Colors.white),
FaIcon(icon, size: 28, color: Colors.white),
const Gap(32),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
TextWidget(
text: text,
size: 20,
),
const Gap(4),
TextWidget(
text: description,
size: 12,
),
],
),
],
),
),
);
}
List<Color> _getColorList(String color) {
switch (color.toLowerCase()) {
case 'green':
return green;
case 'blue':
return blue;
case 'red':
return red;
case 'yellow':
return yellow;
default:
return [
const Color.fromRGBO(0, 0, 0, 1),
const Color.fromRGBO(68, 68, 68, 1),
const Color.fromRGBO(158, 158, 158, 1),
];
}
}
}