77 lines
2.2 KiB
Dart
77 lines
2.2 KiB
Dart
|
|
import 'package:flutter/material.dart';
|
||
|
|
|
||
|
|
class ServiceActionCard extends StatelessWidget {
|
||
|
|
final String title;
|
||
|
|
final IconData icon;
|
||
|
|
final VoidCallback onTap;
|
||
|
|
final Color color;
|
||
|
|
final int count;
|
||
|
|
const ServiceActionCard({
|
||
|
|
super.key,
|
||
|
|
required this.title,
|
||
|
|
required this.icon,
|
||
|
|
required this.onTap,
|
||
|
|
required this.color,
|
||
|
|
this.count = 0,
|
||
|
|
});
|
||
|
|
|
||
|
|
@override
|
||
|
|
Widget build(BuildContext context) {
|
||
|
|
final bool isActive = count > 0;
|
||
|
|
|
||
|
|
return Card(
|
||
|
|
elevation: isActive ? 4 : 1,
|
||
|
|
shape: RoundedRectangleBorder(
|
||
|
|
borderRadius: BorderRadius.circular(16),
|
||
|
|
side: BorderSide(
|
||
|
|
color: isActive ? color : Colors.transparent,
|
||
|
|
width: 2,
|
||
|
|
),
|
||
|
|
),
|
||
|
|
child: InkWell(
|
||
|
|
onTap: onTap,
|
||
|
|
borderRadius: BorderRadius.circular(16),
|
||
|
|
child: Container(
|
||
|
|
width: 110, // Dimensione fissa per farle stare in una Row/Wrap
|
||
|
|
padding: const EdgeInsets.symmetric(vertical: 16, horizontal: 8),
|
||
|
|
decoration: BoxDecoration(
|
||
|
|
borderRadius: BorderRadius.circular(16),
|
||
|
|
color: isActive ? color.withValues(alpha: 0.1) : Colors.transparent,
|
||
|
|
),
|
||
|
|
child: Column(
|
||
|
|
mainAxisSize: MainAxisSize.min,
|
||
|
|
children: [
|
||
|
|
Icon(
|
||
|
|
icon,
|
||
|
|
color: isActive ? color : Colors.grey.shade400,
|
||
|
|
size: 32,
|
||
|
|
),
|
||
|
|
const SizedBox(height: 8),
|
||
|
|
Text(
|
||
|
|
title,
|
||
|
|
textAlign: TextAlign.center,
|
||
|
|
style: TextStyle(
|
||
|
|
fontWeight: isActive ? FontWeight.bold : FontWeight.normal,
|
||
|
|
color: isActive ? color : Colors.grey.shade600,
|
||
|
|
fontSize: 12,
|
||
|
|
),
|
||
|
|
),
|
||
|
|
if (isActive) ...[
|
||
|
|
const SizedBox(height: 4),
|
||
|
|
CircleAvatar(
|
||
|
|
radius: 10,
|
||
|
|
backgroundColor: color,
|
||
|
|
child: Text(
|
||
|
|
count.toString(),
|
||
|
|
style: const TextStyle(fontSize: 10, color: Colors.white),
|
||
|
|
),
|
||
|
|
),
|
||
|
|
],
|
||
|
|
],
|
||
|
|
),
|
||
|
|
),
|
||
|
|
),
|
||
|
|
);
|
||
|
|
}
|
||
|
|
}
|