app mobile allarmi prima
This commit is contained in:
176
lib/widgets/sito_card.dart
Normal file
176
lib/widgets/sito_card.dart
Normal file
@@ -0,0 +1,176 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import '../models/sito.dart';
|
||||
import '../utils/constants.dart';
|
||||
import '../screens/sito_detail_screen.dart';
|
||||
|
||||
class SitoCard extends StatelessWidget {
|
||||
final Sito sito;
|
||||
|
||||
const SitoCard({super.key, required this.sito});
|
||||
|
||||
IconData _getTipoIcon() {
|
||||
switch (sito.tipo) {
|
||||
case 'ponte':
|
||||
return Icons.architecture;
|
||||
case 'galleria':
|
||||
return Icons.south_west;
|
||||
case 'diga':
|
||||
return Icons.water_damage;
|
||||
case 'frana':
|
||||
return Icons.landscape;
|
||||
case 'versante':
|
||||
return Icons.terrain;
|
||||
case 'edificio':
|
||||
return Icons.business;
|
||||
default:
|
||||
return Icons.location_on;
|
||||
}
|
||||
}
|
||||
|
||||
Color _getTipoColor() {
|
||||
switch (sito.tipo) {
|
||||
case 'ponte':
|
||||
return Colors.blue;
|
||||
case 'galleria':
|
||||
return Colors.brown;
|
||||
case 'diga':
|
||||
return Colors.cyan;
|
||||
case 'frana':
|
||||
return Colors.orange;
|
||||
case 'versante':
|
||||
return Colors.green;
|
||||
case 'edificio':
|
||||
return Colors.purple;
|
||||
default:
|
||||
return AppColors.primary;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Card(
|
||||
margin: const EdgeInsets.only(bottom: AppSizes.paddingM),
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => SitoDetailScreen(sito: sito),
|
||||
),
|
||||
);
|
||||
},
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(AppSizes.paddingM),
|
||||
child: Row(
|
||||
children: [
|
||||
// Icona tipo sito
|
||||
Container(
|
||||
width: 60,
|
||||
height: 60,
|
||||
decoration: BoxDecoration(
|
||||
color: _getTipoColor().withOpacity(0.1),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: Icon(
|
||||
_getTipoIcon(),
|
||||
size: 32,
|
||||
color: _getTipoColor(),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: AppSizes.paddingM),
|
||||
|
||||
// Informazioni sito
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// Nome sito
|
||||
Text(
|
||||
sito.nome,
|
||||
style: AppTextStyles.h3,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
|
||||
// Tipo sito
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 8,
|
||||
vertical: 4,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: _getTipoColor().withOpacity(0.1),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Text(
|
||||
sito.tipoReadable,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: _getTipoColor(),
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
|
||||
// Località
|
||||
Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.place,
|
||||
size: 16,
|
||||
color: AppColors.textSecondary,
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
Expanded(
|
||||
child: Text(
|
||||
sito.localita,
|
||||
style: AppTextStyles.bodySmall.copyWith(
|
||||
color: AppColors.textSecondary,
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
// Codice identificativo
|
||||
if (sito.codiceIdentificativo != null) ...[
|
||||
const SizedBox(height: 4),
|
||||
Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.qr_code,
|
||||
size: 16,
|
||||
color: AppColors.textSecondary,
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
Text(
|
||||
sito.codiceIdentificativo!,
|
||||
style: AppTextStyles.bodySmall.copyWith(
|
||||
color: AppColors.textSecondary,
|
||||
fontFamily: 'monospace',
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
// Freccia
|
||||
Icon(
|
||||
Icons.chevron_right,
|
||||
color: AppColors.textSecondary,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user