pharmacy_mobile/lib/widgets/consultation_widget.dart
2025-02-27 11:32:15 +08:00

128 lines
3.4 KiB
Dart

import 'package:flutter/material.dart';
import 'package:gap/gap.dart';
import 'package:pharmacy_mobile/widgets/text_widget.dart';
class ConsultationWidget extends StatelessWidget {
final String name;
final String description;
final String contact;
final String imagePath;
final VoidCallback? onTap;
final String? color;
final double? margin;
// final String description;
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),
];
final List<Color> pink = [
const Color.fromRGBO(130, 59, 156, 0.8),
const Color.fromRGBO(130, 59, 156, 0.8),
const Color.fromARGB(204, 156, 59, 150),
];
ConsultationWidget({
super.key,
required this.name,
required this.description,
required this.contact,
required this.imagePath,
this.onTap,
this.color,
this.margin,
});
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: onTap,
child: Container(
width: MediaQuery.of(context).size.width - (margin ?? 0),
padding: const EdgeInsets.symmetric(vertical: 24),
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(32),
ClipRRect(
borderRadius: BorderRadius.circular(12), // Adjust the radius as needed
child:
Image.asset(imagePath, width: 80, cacheWidth: (80 * MediaQuery.of(context).devicePixelRatio).round()),
),
const Gap(24),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
TextWidget(
text: name,
size: 16,
bold: true,
),
const Gap(4),
TextWidget(
text: description,
size: 12,
),
const Gap(4),
TextWidget(
text: contact,
size: 12,
color: const Color.fromRGBO(188, 188, 188, 1),
),
],
),
],
),
),
);
}
List<Color> _getColorList(String color) {
switch (color.toLowerCase()) {
case 'green':
return green;
case 'blue':
return blue;
case 'red':
return red;
case 'yellow':
return yellow;
case 'pink':
return pink;
default:
return [
const Color.fromRGBO(0, 0, 0, 1),
const Color.fromRGBO(68, 68, 68, 1),
const Color.fromRGBO(158, 158, 158, 1),
];
}
}
}