info_tab.dart 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter/widgets.dart';
  3. import 'package:ristoris/database/database.dart';
  4. class InfoTab extends StatelessWidget {
  5. final Cliente cliente;
  6. final ThemeData theme;
  7. const InfoTab({required this.cliente, required this.theme});
  8. @override
  9. Widget build(BuildContext context) {
  10. return SingleChildScrollView(
  11. padding: const EdgeInsets.all(16),
  12. child: Column(
  13. crossAxisAlignment: CrossAxisAlignment.start,
  14. children: [
  15. _infoRow('Codice', cliente.codCliente ?? '-'),
  16. _infoRow('Ragione Sociale', cliente.ragioneSociale ?? '-'),
  17. _infoRow('Indirizzo', cliente.indirizzo ?? '-'),
  18. _infoRow(
  19. 'Città',
  20. '${cliente.citta ?? ""} ${cliente.provincia ?? ""} ${cliente.cap ?? ""}',
  21. ),
  22. _infoRow('Telefono', cliente.telefono ?? '-'),
  23. _infoRow('Cellulare', cliente.cellulare ?? '-'),
  24. _infoRow('Email', cliente.email ?? '-'),
  25. _infoRow('Partita IVA', cliente.partitaIva ?? '-'),
  26. _infoRow('Codice Fiscale', cliente.codiceFiscale ?? '-'),
  27. if (cliente.sdi != null && cliente.sdi!.isNotEmpty) _infoRow('SDI', cliente.sdi!),
  28. if (cliente.pec != null && cliente.pec!.isNotEmpty) _infoRow('PEC', cliente.pec!),
  29. if (cliente.note != null && cliente.note!.isNotEmpty) _infoRow('Note', cliente.note!),
  30. if (cliente.codBlocco != null && cliente.codBlocco!.isNotEmpty)
  31. Card(
  32. color: Colors.red.shade50,
  33. child: Padding(
  34. padding: const EdgeInsets.all(12),
  35. child: Row(
  36. children: [
  37. Icon(Icons.block, color: Colors.red),
  38. const SizedBox(width: 8),
  39. Text('Blocco: ${cliente.codBlocco}'),
  40. ],
  41. ),
  42. ),
  43. ),
  44. ],
  45. ),
  46. );
  47. }
  48. Widget _infoRow(String label, String value) {
  49. return Padding(
  50. padding: const EdgeInsets.symmetric(vertical: 4),
  51. child: Row(
  52. crossAxisAlignment: CrossAxisAlignment.start,
  53. children: [
  54. SizedBox(
  55. width: 120,
  56. child: Text(
  57. label,
  58. style: theme.textTheme.bodySmall?.copyWith(
  59. color: theme.colorScheme.outline,
  60. ),
  61. ),
  62. ),
  63. Expanded(child: Text(value)),
  64. ],
  65. ),
  66. );
  67. }
  68. }