app mobile allarmi prima
This commit is contained in:
102
lib/widgets/allarme_card.dart
Normal file
102
lib/widgets/allarme_card.dart
Normal file
@@ -0,0 +1,102 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import '../models/allarme.dart';
|
||||
import '../utils/constants.dart';
|
||||
import '../screens/allarme_detail_screen.dart';
|
||||
|
||||
class AllarmeCard extends StatelessWidget {
|
||||
final Allarme allarme;
|
||||
|
||||
const AllarmeCard({super.key, required this.allarme});
|
||||
|
||||
Color _getSeverityColor() {
|
||||
switch (allarme.severita) {
|
||||
case 'critical': return AppColors.critical;
|
||||
case 'warning': return AppColors.warning;
|
||||
case 'info': return AppColors.info;
|
||||
default: return AppColors.textSecondary;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Card(
|
||||
margin: const EdgeInsets.only(bottom: AppSizes.paddingM),
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => AllarmeDetailScreen(allarme: allarme),
|
||||
),
|
||||
);
|
||||
},
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(AppSizes.paddingM),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
||||
decoration: BoxDecoration(
|
||||
color: _getSeverityColor(),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Text(allarme.severitaReadable, style: const TextStyle(color: Colors.white, fontSize: 12, fontWeight: FontWeight.bold)),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.info.withOpacity(0.1),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Text(allarme.statoReadable, style: const TextStyle(fontSize: 12)),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
Text(allarme.titolo, style: AppTextStyles.h3, maxLines: 2),
|
||||
const SizedBox(height: 8),
|
||||
Row(
|
||||
children: [
|
||||
Icon(AlarmTypeIcons.getIcon(allarme.tipo), size: 16, color: AppColors.textSecondary),
|
||||
const SizedBox(width: 8),
|
||||
Text(allarme.tipoReadable, style: AppTextStyles.bodyMedium.copyWith(color: AppColors.textSecondary)),
|
||||
],
|
||||
),
|
||||
if (allarme.descrizione != null) ...[
|
||||
const SizedBox(height: 8),
|
||||
Text(allarme.descrizione!, style: AppTextStyles.bodyMedium, maxLines: 2, overflow: TextOverflow.ellipsis),
|
||||
],
|
||||
if (allarme.valoreRilevato != null && allarme.valoreSoglia != null) ...[
|
||||
const SizedBox(height: 12),
|
||||
Container(
|
||||
padding: const EdgeInsets.all(8),
|
||||
decoration: BoxDecoration(
|
||||
color: _getSeverityColor().withOpacity(0.1),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(Icons.show_chart, size: 16, color: _getSeverityColor()),
|
||||
const SizedBox(width: 8),
|
||||
Expanded(
|
||||
child: Text(
|
||||
'Valore: ${allarme.valoreRilevato!.toStringAsFixed(2)} ${allarme.unitaMisura ?? ''} (soglia: ${allarme.valoreSoglia!.toStringAsFixed(2)})',
|
||||
style: AppTextStyles.bodySmall,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
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