fixed pages
This commit is contained in:
@@ -173,37 +173,10 @@ class _ReschedulePageState extends State<ReschedulePage> {
|
||||
itemCount: slots.length,
|
||||
itemBuilder: (_, i) {
|
||||
final s = slots[i];
|
||||
return Card(
|
||||
margin: const EdgeInsets.only(bottom: 10),
|
||||
child: ListTile(
|
||||
title: Text(
|
||||
s.className,
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.w800,
|
||||
),
|
||||
),
|
||||
subtitle: Text(
|
||||
'${_weekdayLabel(s.date)} ${s.date} • ${s.time}\n'
|
||||
'Posti liberi: ${s.freePlaces}/${s.maxCapacity}'
|
||||
'${s.alreadyBooked ? " • Sei già prenotato" : ""}',
|
||||
),
|
||||
isThreeLine: true,
|
||||
trailing: s.bookable
|
||||
? ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: green,
|
||||
),
|
||||
onPressed: () => _confirm(s),
|
||||
child: const Text('Scegli'),
|
||||
)
|
||||
: const Text(
|
||||
'Non disp.',
|
||||
style: TextStyle(
|
||||
color: Colors.black38,
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
),
|
||||
),
|
||||
return _SlotCard(
|
||||
slot: s,
|
||||
weekday: _weekdayLabel(s.date),
|
||||
onChoose: () => _confirm(s),
|
||||
);
|
||||
},
|
||||
),
|
||||
@@ -262,3 +235,137 @@ class _ReschedulePageState extends State<ReschedulePage> {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class _SlotCard extends StatelessWidget {
|
||||
final AvailableSlot slot;
|
||||
final String weekday;
|
||||
final VoidCallback onChoose;
|
||||
|
||||
const _SlotCard({
|
||||
required this.slot,
|
||||
required this.weekday,
|
||||
required this.onChoose,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
const green = Color(0xFF10B981);
|
||||
const orange = Color(0xFFF59E0B);
|
||||
|
||||
// Determina lo stato dello slot
|
||||
final bool isBooked = slot.alreadyBooked;
|
||||
final bool isFull = !slot.bookable && !isBooked;
|
||||
final bool isSelectable = slot.bookable && !isBooked;
|
||||
|
||||
// Colori in base allo stato
|
||||
Color bgColor;
|
||||
Color borderColor;
|
||||
if (isBooked) {
|
||||
bgColor = const Color(0xFFFFF4E5); // arancio chiaro
|
||||
borderColor = orange;
|
||||
} else if (isFull) {
|
||||
bgColor = const Color(0xFFF3F3F5); // grigio chiaro
|
||||
borderColor = const Color(0xFFD9D9E0);
|
||||
} else {
|
||||
bgColor = Colors.white;
|
||||
borderColor = const Color(0x14000000);
|
||||
}
|
||||
|
||||
// Etichetta / badge a destra
|
||||
Widget trailing;
|
||||
if (isSelectable) {
|
||||
trailing = ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: green,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
),
|
||||
onPressed: onChoose,
|
||||
child: const Text('Scegli'),
|
||||
);
|
||||
} else if (isBooked) {
|
||||
trailing = _StatusBadge(text: 'Già prenotato', color: orange);
|
||||
} else {
|
||||
trailing = _StatusBadge(
|
||||
text: 'Al completo',
|
||||
color: const Color(0xFF9AA0A6),
|
||||
);
|
||||
}
|
||||
|
||||
return Container(
|
||||
margin: const EdgeInsets.only(bottom: 10),
|
||||
padding: const EdgeInsets.fromLTRB(14, 12, 12, 12),
|
||||
decoration: BoxDecoration(
|
||||
color: bgColor,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
border: Border.all(color: borderColor, width: 1.5),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
slot.className,
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.w800,
|
||||
fontSize: 15,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
'$weekday ${slot.date} • ${slot.time}',
|
||||
style: const TextStyle(
|
||||
fontSize: 12,
|
||||
color: Colors.black54,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 2),
|
||||
Text(
|
||||
'Posti liberi: ${slot.freePlaces}/${slot.maxCapacity}',
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: isFull ? orange : Colors.black45,
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
trailing,
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _StatusBadge extends StatelessWidget {
|
||||
final String text;
|
||||
final Color color;
|
||||
|
||||
const _StatusBadge({required this.text, required this.color});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
|
||||
decoration: BoxDecoration(
|
||||
color: color.withValues(alpha: 0.15),
|
||||
borderRadius: BorderRadius.circular(999),
|
||||
border: Border.all(color: color, width: 1.5),
|
||||
),
|
||||
child: Text(
|
||||
text,
|
||||
style: TextStyle(
|
||||
color: color,
|
||||
fontWeight: FontWeight.w800,
|
||||
fontSize: 12,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user