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(12), 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 } } }