buono
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'provider_location_model.dart';
|
||||
import 'provider_role.dart';
|
||||
@@ -8,6 +9,7 @@ class ProviderModel extends Equatable {
|
||||
final String companyId;
|
||||
final String name; // Nome "commerciale" per riconoscerlo velocemente
|
||||
final bool isActive;
|
||||
final String? colorHex;
|
||||
|
||||
// Dati fiscali e legali
|
||||
final String? businessName; // Ragione Sociale
|
||||
@@ -29,6 +31,7 @@ class ProviderModel extends Equatable {
|
||||
required this.companyId,
|
||||
required this.name,
|
||||
this.isActive = true,
|
||||
this.colorHex,
|
||||
this.businessName,
|
||||
this.vatNumber,
|
||||
this.fiscalCode,
|
||||
@@ -42,6 +45,17 @@ class ProviderModel extends Equatable {
|
||||
this.locations,
|
||||
});
|
||||
|
||||
// 🥷 IL GETTER MAGICO: Converte l'esadecimale in un Color di Flutter
|
||||
Color get displayColor {
|
||||
if (colorHex == null || colorHex!.isEmpty) {
|
||||
return Colors.blueGrey; // Colore di default
|
||||
}
|
||||
|
||||
// Rimuove l'eventuale '#' e aggiunge 'FF' per l'opacità (Alpha)
|
||||
final hex = colorHex!.replaceAll('#', '');
|
||||
return Color(int.parse('FF$hex', radix: 16));
|
||||
}
|
||||
|
||||
factory ProviderModel.empty({required String companyId}) {
|
||||
return ProviderModel(
|
||||
companyId: companyId,
|
||||
@@ -56,6 +70,7 @@ class ProviderModel extends Equatable {
|
||||
String? companyId,
|
||||
String? name,
|
||||
bool? isActive,
|
||||
String? Function()? colorHex,
|
||||
String? businessName,
|
||||
String? vatNumber,
|
||||
String? fiscalCode,
|
||||
@@ -73,6 +88,7 @@ class ProviderModel extends Equatable {
|
||||
companyId: companyId ?? this.companyId,
|
||||
name: name ?? this.name,
|
||||
isActive: isActive ?? this.isActive,
|
||||
colorHex: colorHex != null ? colorHex() : this.colorHex,
|
||||
businessName: businessName ?? this.businessName,
|
||||
vatNumber: vatNumber ?? this.vatNumber,
|
||||
fiscalCode: fiscalCode ?? this.fiscalCode,
|
||||
@@ -114,6 +130,7 @@ class ProviderModel extends Equatable {
|
||||
companyId: map['company_id'] as String,
|
||||
name: map['name'] as String,
|
||||
isActive: map['is_active'] as bool? ?? true,
|
||||
colorHex: map['color_hex'] as String?,
|
||||
businessName: map['business_name'] as String?,
|
||||
vatNumber: map['vat_number'] as String?,
|
||||
fiscalCode: map['fiscal_code'] as String?,
|
||||
@@ -134,6 +151,7 @@ class ProviderModel extends Equatable {
|
||||
'company_id': companyId,
|
||||
'name': name,
|
||||
'is_active': isActive,
|
||||
'color_hex': colorHex,
|
||||
'business_name': businessName,
|
||||
'vat_number': vatNumber,
|
||||
'fiscal_code': fiscalCode,
|
||||
@@ -155,6 +173,7 @@ class ProviderModel extends Equatable {
|
||||
companyId,
|
||||
name,
|
||||
isActive,
|
||||
colorHex,
|
||||
businessName,
|
||||
vatNumber,
|
||||
fiscalCode,
|
||||
|
||||
Reference in New Issue
Block a user