10 Commits

Author SHA1 Message Date
22bb86f052 Merge branch 'main' of ssh.catelli.it:brontomark/flux 2026-06-08 13:20:52 +02:00
fc850795c9 fix attachments with no parentId 2026-06-08 13:17:33 +02:00
b60ce96dd7 fix uploads
All checks were successful
Build and Release FLUX (Multi-Platform) / build-android (push) Successful in 2m14s
Build and Release FLUX (Multi-Platform) / build-web (push) Successful in 1m3s
Build and Release FLUX (Multi-Platform) / build-windows (push) Successful in 8m48s
2026-06-08 13:15:29 +02:00
6582da60d4 edge function per interrogare openai, capire quali immagini sono di documenti d'identità e assegnarli al cliente 2026-06-05 07:50:07 +02:00
d42cc5af1d v check fix
All checks were successful
Build and Release FLUX (Multi-Platform) / build-android (push) Successful in 1m30s
Build and Release FLUX (Multi-Platform) / build-web (push) Successful in 1m6s
Build and Release FLUX (Multi-Platform) / build-windows (push) Successful in 6m20s
2026-06-04 15:21:11 +02:00
7ea0e2ac10 changed version check
All checks were successful
Build and Release FLUX (Multi-Platform) / build-android (push) Successful in 1m33s
Build and Release FLUX (Multi-Platform) / build-web (push) Successful in 1m4s
Build and Release FLUX (Multi-Platform) / build-windows (push) Successful in 6m14s
2026-06-04 14:21:27 +02:00
5ce0110197 fix operations e tasks
Some checks failed
Build and Release FLUX (Multi-Platform) / build-windows (push) Successful in 6m20s
Build and Release FLUX (Multi-Platform) / build-android (push) Failing after 11m52s
Build and Release FLUX (Multi-Platform) / build-web (push) Successful in 1m0s
2026-06-04 13:42:29 +02:00
4efc3ce182 mmmh
All checks were successful
Build and Release FLUX (Multi-Platform) / build-android (push) Successful in 2m11s
Build and Release FLUX (Multi-Platform) / build-web (push) Successful in 1m1s
Build and Release FLUX (Multi-Platform) / build-windows (push) Successful in 8m5s
2026-06-04 12:34:38 +02:00
01515910b6 mah....volare 2026-06-03 19:16:15 +02:00
f27ede7625 v - changed operation list
All checks were successful
Build and Release FLUX (Multi-Platform) / build-android (push) Successful in 2m21s
Build and Release FLUX (Multi-Platform) / build-web (push) Successful in 1m9s
Build and Release FLUX (Multi-Platform) / build-windows (push) Successful in 8m4s
2026-06-03 13:22:47 +02:00
26 changed files with 1429 additions and 795 deletions

View File

@@ -1,4 +1,5 @@
class Tables { class Tables {
static const String appConfig = 'app_config';
static const String attachments = 'attachments'; static const String attachments = 'attachments';
static const String brands = 'brands'; static const String brands = 'brands';
static const String campaigns = 'campaigns'; static const String campaigns = 'campaigns';
@@ -18,6 +19,7 @@ class Tables {
static const String stores = 'stores'; static const String stores = 'stores';
static const String tasks = 'tasks'; static const String tasks = 'tasks';
static const String taskAssignments = 'task_assignments'; static const String taskAssignments = 'task_assignments';
static const String taskReminders = 'task_reminders';
static const String tickets = 'tickets'; static const String tickets = 'tickets';
static const String trackings = 'trackings'; static const String trackings = 'trackings';
} }

View File

@@ -1,67 +1,94 @@
import 'dart:io';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'dart:io' show Platform;
import 'package:package_info_plus/package_info_plus.dart'; import 'package:package_info_plus/package_info_plus.dart';
import 'package:supabase_flutter/supabase_flutter.dart'; import 'package:supabase_flutter/supabase_flutter.dart';
class VersionCheckService { class VersionCheckService {
final _supabase = Supabase.instance.client;
/// Controlla se l'app corrente deve essere bloccata o aggiornata.
/// Ritorna il link di download se l'aggiornamento è obbligatorio, altrimenti null.
Future<String?> checkForceUpdate() async { Future<String?> checkForceUpdate() async {
try { try {
// 1. Determiniamo la piattaforma corrente // 1. Capiamo su che piattaforma sta girando l'app in questo istante
String platformKey = 'web'; String currentPlatform = _getCurrentPlatform();
if (!kIsWeb) {
if (Platform.isAndroid) platformKey = 'android'; // 2. Recuperiamo SOLO la riga corrispondente alla nostra piattaforma
if (Platform.isWindows) platformKey = 'windows'; final dbResponse = await Supabase.instance.client
.from('app_config')
.select('min_version, download_url')
.eq('platform', currentPlatform)
.maybeSingle(); // Usiamo maybeSingle così se non c'è la riga non crasha
if (dbResponse == null) {
return null; // Nessuna regola per questa piattaforma
} }
// 2. Recuperiamo la configurazione minima da Supabase String minVersionFromDb = dbResponse['min_version'] as String;
final data = await _supabase String downloadUrl = dbResponse['download_url'] as String;
.from('app_config')
.select()
.eq('platform', platformKey)
.maybeSingle();
if (data == null) return null; // 3. Recuperiamo la versione locale di Flutter
PackageInfo packageInfo = await PackageInfo.fromPlatform();
String localVersionRaw = packageInfo.version;
final String minVersion = data['min_version']; // 🥷 TRUCCO 1: Pulizia totale dai build number (+37) o tag "v"
final String downloadUrl = data['download_url']; String cleanLocal = localVersionRaw
.split('+')
.first
.replaceAll('v', '')
.trim();
String cleanDb = minVersionFromDb
.split('+')
.first
.replaceAll('v', '')
.trim();
// 3. Recuperiamo la versione attuale dell'app dal pubspec.yaml // 🥷 TRUCCO 2: Confronto Semantico Reale
final packageInfo = await PackageInfo.fromPlatform(); if (_isVersionLower(current: cleanLocal, minimum: cleanDb)) {
final String currentVersion = packageInfo.version; // Ritorna il link VERO per questa specifica piattaforma preso dal CSV!
return downloadUrl;
// 4. Confronto matematico semantico (es. 1.2.3 vs 1.1.9)
if (_isVersionLower(currentVersion, minVersion)) {
return downloadUrl; // Aggiornamento obbligatorio richiesto!
} }
return null; return null;
} catch (e) { } catch (e) {
debugPrint('Errore controllo versione: $e'); debugPrint("Errore durante il check versione: $e");
return null; // In caso di errore non blocchiamo l'utente return null;
} }
} }
bool _isVersionLower(String current, String min) { // Helper ninja per mappare le piattaforme in base alle stringhe del tuo DB
String _getCurrentPlatform() {
if (kIsWeb) return 'web';
if (Platform.isAndroid) return 'android';
if (Platform.isIOS) return 'ios';
if (Platform.isWindows) return 'windows';
if (Platform.isMacOS) return 'macos';
if (Platform.isLinux) return 'linux';
return 'unknown';
}
// Il motore matematico (resta invariato)
bool _isVersionLower({required String current, required String minimum}) {
if (current == minimum) return false;
List<int> currentParts = current List<int> currentParts = current
.split('.') .split('.')
.map((e) => int.tryParse(e) ?? 0) .map((e) => int.tryParse(e) ?? 0)
.toList(); .toList();
List<int> minParts = min List<int> minParts = minimum
.split('.') .split('.')
.map((e) => int.tryParse(e) ?? 0) .map((e) => int.tryParse(e) ?? 0)
.toList(); .toList();
for (int i = 0; i < 3; i++) { while (currentParts.length < 3) {
int currentPart = currentParts.length > i ? currentParts[i] : 0; currentParts.add(0);
int minPart = minParts.length > i ? minParts[i] : 0;
if (currentPart < minPart) return true;
if (currentPart > minPart) return false;
} }
return false; while (minParts.length < 3) {
minParts.add(0);
}
if (currentParts[0] != minParts[0]) {
return currentParts[0] < minParts[0];
}
if (currentParts[1] != minParts[1]) {
return currentParts[1] < minParts[1];
}
return currentParts[2] < minParts[2];
} }
} }

View File

@@ -90,6 +90,32 @@ class _SharedAttachmentsSectionState extends State<SharedAttachmentsSection> {
// --- SELEZIONE FILE DAL PC/TELEFONO --- // --- SELEZIONE FILE DAL PC/TELEFONO ---
Future<void> _pickFiles() async { Future<void> _pickFiles() async {
final attachmentsBloc = context.read<AttachmentsBloc>();
String? targetId = attachmentsBloc.state.parentId;
// 🥷 SE L'ID NON C'È (Nuova Operazione), FORZIAMO IL SALVATAGGIO PREVENTIVO!
if (targetId == null || targetId.isEmpty) {
if (widget.onGenerateIdForQr != null) {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text('Salvataggio rapido scheda per allegati... ⏳'),
duration: Duration(seconds: 1),
),
);
// Chiamiamo la funzione passata dal TicketForm/OperationForm
targetId = await widget.onGenerateIdForQr!();
}
// Se il salvataggio fallisce (es. form non valido), ci fermiamo per evitare file orfani
if (targetId == null || targetId.isEmpty) return;
// Comunichiamo immediatamente al BLoC che l'entità padre è stata salvata e ha un nuovo ID.
// Questo eviterà che i file finiscano nei `localFiles` temporanei.
attachmentsBloc.add(ParentEntitySavedEvent(targetId));
}
// Ora che abbiamo la certezza matematica di avere un targetId, apriamo il picker
final result = await FilePicker.pickFiles( final result = await FilePicker.pickFiles(
allowMultiple: true, allowMultiple: true,
type: FileType.custom, type: FileType.custom,
@@ -98,8 +124,8 @@ class _SharedAttachmentsSectionState extends State<SharedAttachmentsSection> {
); );
if (result != null && mounted) { if (result != null && mounted) {
// MAGIA: Passiamo direttamente la lista di PlatformFile al tuo BLoC! // Ora il BLoC eseguirà l'ambiente di "Upload immediato" (Bivio 2) perché ha l'ID aggiornato!
context.read<AttachmentsBloc>().add(AddAttachmentsEvent(result.files)); attachmentsBloc.add(AddAttachmentsEvent(result.files));
} }
} }

View File

@@ -51,17 +51,17 @@ class DashboardStoreOperationListCubit
void _loadOperationsSilently() async { void _loadOperationsSilently() async {
try { try {
final operations = await _repository.fetchOperations( final paginatedData = await _repository.fetchPaginatedOperations(
companyId: companyId!, companyId: companyId!,
storeId: storeId!, storeId: storeId!,
limit: 10, page: 1,
offset: 0, itemsPerPage: 20,
); );
if (isClosed) return; if (isClosed) return;
emit( emit(
state.copyWith( state.copyWith(
status: DashboardStoreOperationListStatus.success, status: DashboardStoreOperationListStatus.success,
operations: operations, operations: paginatedData.operations,
error: null, error: null,
), ),
); );

View File

@@ -217,8 +217,6 @@ class OperationFormCubit extends Cubit<OperationFormState> {
String? reference, String? reference,
String? note, String? note,
String? type, String? type,
String? providerId,
String? providerDisplayName,
String? subType, String? subType,
String? description, String? description,
DateTime? expirationDate, DateTime? expirationDate,
@@ -248,10 +246,6 @@ class OperationFormCubit extends Cubit<OperationFormState> {
final updated = current.copyWith( final updated = current.copyWith(
reference: reference ?? current.reference, reference: reference ?? current.reference,
note: note ?? current.note, note: note ?? current.note,
providerId: clearProvider ? null : (providerId ?? current.providerId),
providerDisplayName: clearProvider
? null
: (providerDisplayName ?? current.providerDisplayName),
quantity: newQuantity ?? current.quantity, quantity: newQuantity ?? current.quantity,
type: clearType ? null : (type ?? current.type), type: clearType ? null : (type ?? current.type),
description: clearDescription description: clearDescription
@@ -274,6 +268,17 @@ class OperationFormCubit extends Cubit<OperationFormState> {
emit(state.copyWith(operation: updated)); emit(state.copyWith(operation: updated));
} }
void updateProvider(ProviderModel? newProvider) {
final current = state.operation;
final updatedOperation = current.copyWith(
// Se newProvider è null, passiamo una funzione che ritorna null per sbiancare i campi!
provider: () => newProvider,
);
emit(state.copyWith(operation: updatedOperation));
}
void updateCustomer(CustomerModel customer) { void updateCustomer(CustomerModel customer) {
final bool isBusiness = customer.isBusiness; final bool isBusiness = customer.isBusiness;
final updatedOperation = state.operation.copyWith( final updatedOperation = state.operation.copyWith(
@@ -293,13 +298,8 @@ class OperationFormCubit extends Cubit<OperationFormState> {
}) { }) {
// 1. Aggiorniamo il tipo nel modello in canna // 1. Aggiorniamo il tipo nel modello in canna
// (Presumo tu abbia un metodo copyWith o simile) // (Presumo tu abbia un metodo copyWith o simile)
final updatedOp = state.operation.copyWith(type: newType, subType: '');
// 2. Prepariamoci ad auto-selezionare il provider // 2. LA LOGICA DI DEFAULT
String? newProviderId = updatedOp.providerId;
String? newProviderName = updatedOp.providerDisplayName;
// 3. LA LOGICA DI DEFAULT
if (defaultProviderId != null) { if (defaultProviderId != null) {
// Troviamo il provider di default nella lista // Troviamo il provider di default nella lista
final defaultProvider = allProviders final defaultProvider = allProviders
@@ -309,25 +309,13 @@ class OperationFormCubit extends Cubit<OperationFormState> {
if (defaultProvider != null) { if (defaultProvider != null) {
// Usiamo l'extension appena creata! // Usiamo l'extension appena creata!
if (defaultProvider.supportsOperation(newType)) { if (defaultProvider.supportsOperation(newType)) {
newProviderId = defaultProvider.id; updateProvider(defaultProvider);
newProviderName = defaultProvider.name;
} else { } else {
// Se cambi tipo (es. da Mobile a Luce) e il default non lo supporta, sbianchiamo // Se cambi tipo (es. da Mobile a Luce) e il default non lo supporta, sbianchiamo
newProviderId = null; updateProvider(null);
newProviderName = null;
} }
} }
} }
// Emettiamo il nuovo stato
emit(
state.copyWith(
operation: updatedOp.copyWith(
providerId: newProviderId,
providerDisplayName: newProviderName,
),
),
);
} }
void setTypeWithSmartDefaults({ void setTypeWithSmartDefaults({
@@ -338,7 +326,7 @@ class OperationFormCubit extends Cubit<OperationFormState> {
final currentOp = state.operation; final currentOp = state.operation;
// ----------------------------------------- // -----------------------------------------
// 1. SMART DATES: Calcolo Scadenze Default // 1. SMART DATES: Calcolo Scadenze Default (Invariato)
// ----------------------------------------- // -----------------------------------------
DateTime? defaultDate; DateTime? defaultDate;
final now = DateTime.now(); final now = DateTime.now();
@@ -354,28 +342,19 @@ class OperationFormCubit extends Cubit<OperationFormState> {
} }
// ----------------------------------------- // -----------------------------------------
// 2. SMART PROVIDER: Filtro e Auto-Selezione // 2. SMART PROVIDER: Filtro e Auto-Selezione ad Oggetti
// ----------------------------------------- // -----------------------------------------
String? newProviderId = currentOp.providerId; // Pescatore direttamente l'oggetto dal modello corrente
String? newProviderName = currentOp.providerDisplayName; ProviderModel? targetProvider = currentOp.provider;
// A) Il provider attuale è ancora compatibile col nuovo tipo scelto? // A) Il provider attuale è ancora compatibile col nuovo tipo scelto?
if (newProviderId != null && newProviderId.isNotEmpty) { if (targetProvider != null && !targetProvider.supportsOperation(newType)) {
final currentProvider = allProviders // Non è più compatibile (es. da TIM fisso passo a Energy). Lo sbianchiamo!
.where((p) => p.id == newProviderId) targetProvider = null;
.firstOrNull;
if (currentProvider == null ||
!currentProvider.supportsOperation(newType)) {
// Non è più compatibile (es. da TIM fisso passo a Energy). Lo sbianchiamo!
newProviderId = null;
newProviderName = null;
}
} }
// B) Se non c'è un provider selezionato, proviamo ad auto-inserire quello di default del negozio // B) Se non c'è un provider selezionato, proviamo ad auto-inserire quello di default del negozio
if ((newProviderId == null || newProviderId.isEmpty) && if (targetProvider == null && defaultProviderId != null) {
defaultProviderId != null) {
final defaultProvider = allProviders final defaultProvider = allProviders
.where((p) => p.id == defaultProviderId) .where((p) => p.id == defaultProviderId)
.firstOrNull; .firstOrNull;
@@ -383,8 +362,7 @@ class OperationFormCubit extends Cubit<OperationFormState> {
// Controlliamo che il default del negozio supporti questa specifica operazione // Controlliamo che il default del negozio supporti questa specifica operazione
if (defaultProvider != null && if (defaultProvider != null &&
defaultProvider.supportsOperation(newType)) { defaultProvider.supportsOperation(newType)) {
newProviderId = defaultProvider.id; targetProvider = defaultProvider;
newProviderName = defaultProvider.name;
} }
} }
@@ -395,13 +373,15 @@ class OperationFormCubit extends Cubit<OperationFormState> {
state.copyWith( state.copyWith(
operation: currentOp.copyWith( operation: currentOp.copyWith(
type: newType, type: newType,
subType: subType: '', // Resettiamo il sottotipo per evitare incongruenze
'', // Resettiamo il sottotipo per evitare incongruenze (es. passo da Luce a DAZN)
expirationDate: expirationDate:
defaultDate, // Impostiamo la scadenza di default se calcolata defaultDate, // Impostiamo la scadenza di default se calcolata
providerId: newProviderId, // 🥷 APPLICHIAMO IL TRUCCO NINJA DELLE FUNZIONI
providerDisplayName: newProviderName, // Se targetProvider è null, le funzioni ritorneranno null sbiancando il DB!
provider: () => targetProvider,
// Nota: Per azzerare davvero questi due, ricordati in futuro di applicare
// il trucco delle funzioni anche a modelId e modelDisplayName nel modello!
modelId: null, modelId: null,
modelDisplayName: null, modelDisplayName: null,
), ),

View File

@@ -12,72 +12,103 @@ class OperationListCubit extends Cubit<OperationListState> {
final OperationsRepository _repository = GetIt.I<OperationsRepository>(); final OperationsRepository _repository = GetIt.I<OperationsRepository>();
final SessionCubit _sessionCubit = GetIt.I<SessionCubit>(); final SessionCubit _sessionCubit = GetIt.I<SessionCubit>();
OperationListCubit() : super(const OperationListState()) { OperationListCubit() : super(const OperationListState());
loadOperations(refresh: true);
}
Future<void> loadOperations({bool refresh = false}) async { // 🥷 MOTORE 1: DESKTOP (Sostituisce la lista)
Future<void> loadSpecificPageDesktop(int page) async {
if (state.status == OperationListStatus.loading) return; if (state.status == OperationListStatus.loading) return;
if (!refresh && state.hasReachedMax) return; emit(state.copyWith(status: OperationListStatus.loading));
emit(
state.copyWith(
status: OperationListStatus.loading,
errorMessage: null,
operations: refresh ? [] : state.operations,
hasReachedMax: refresh ? false : state.hasReachedMax,
),
);
try { try {
final currentOffset = refresh ? 0 : state.operations.length;
final companyId = _sessionCubit.state.company?.id; final companyId = _sessionCubit.state.company?.id;
final paginatedData = await _repository.fetchPaginatedOperations(
if (companyId == null) { companyId: companyId!,
throw Exception("Company ID non trovato nella sessione"); page: page,
} itemsPerPage: state.itemsPerPage,
final newOperations = await _repository.fetchOperations(
companyId: companyId,
offset: currentOffset,
limit: 50,
searchTerm: state.query,
dateRange: state.dateRange,
); );
final bool reachedMax = newOperations.length < 50;
emit( emit(
state.copyWith( state.copyWith(
status: OperationListStatus.success, status: OperationListStatus.success,
operations: refresh operations: paginatedData.operations, // 🎯 SOSTITUISCE I DATI
? newOperations totalItems: paginatedData.totalCount,
: [...state.operations, ...newOperations], currentPage: page,
hasReachedMax: reachedMax, hasReachedMax: paginatedData.operations.length < state.itemsPerPage,
), ),
); );
} catch (e) { } catch (e) {
emit( emit(
state.copyWith( state.copyWith(
status: OperationListStatus.failure, status: OperationListStatus.failure,
errorMessage: "Errore nel caricamento operazioni: $e", errorMessage: e.toString(),
), ),
); );
} }
} }
void updateFilters({String? query, DateTimeRange? range}) { // 🥷 MOTORE 2: MOBILE (Accoda alla lista)
Future<void> loadNextPageMobile({bool refresh = false}) async {
if (state.status == OperationListStatus.loading) return;
if (state.hasReachedMax && !refresh) return;
// Se stiamo pullando verso il basso (refresh), ripartiamo da pagina 1
final targetPage = refresh ? 1 : state.currentPage + 1;
// Mostriamo il loading solo se è un refresh totale, altrimenti manteniamo lo stato success
// per non far sparire la UI mentre carica in fondo
if (refresh) emit(state.copyWith(status: OperationListStatus.loading));
try {
final companyId = _sessionCubit.state.company?.id;
final paginatedData = await _repository.fetchPaginatedOperations(
companyId: companyId!,
page: targetPage,
itemsPerPage: state.itemsPerPage,
);
emit(
state.copyWith(
status: OperationListStatus.success,
// 🎯 ACCODA I DATI SE NON È REFRESH, ALTRIMENTI SOSTITUISCE
operations:
refresh ? paginatedData.operations : List.of(state.operations)
..addAll(paginatedData.operations),
totalItems: paginatedData.totalCount,
currentPage: targetPage,
hasReachedMax: paginatedData.operations.length < state.itemsPerPage,
),
);
} catch (e) {
emit(
state.copyWith(
status: OperationListStatus.failure,
errorMessage: e.toString(),
),
);
}
}
void updateFilters({String? text, DateTimeRange? range}) {
emit( emit(
state.copyWith( state.copyWith(
query: query ?? state.query, // 🥷 FORZIAMO IL TIPO: Diciamo a Dart che il risultato del ternario è proprio una funzione
dateRange: range ?? state.dateRange, searchTerm: text != null ? () => text : null,
dateRange: range != null ? () => range : null,
currentPage: 1, // Reset obbligatorio alla prima pagina
hasReachedMax: false,
), ),
); );
loadOperations(refresh: true);
// Ricarichiamo la pagina 1 con i nuovi filtri applicati
loadSpecificPageDesktop(1);
} }
void clearFilters() { void clearFilters() {
emit(const OperationListState()); // Resetta tutto allo stato iniziale // Invece di un const vuoto che potrebbe bruciarti l'impostazione itemsPerPage,
loadOperations(refresh: true); // creiamo uno stato pulito ma manteniamo la preferenza di paginazione.
emit(OperationListState(itemsPerPage: state.itemsPerPage));
loadSpecificPageDesktop(1);
} }
} }

View File

@@ -5,35 +5,57 @@ enum OperationListStatus { initial, loading, success, failure }
class OperationListState extends Equatable { class OperationListState extends Equatable {
final OperationListStatus status; final OperationListStatus status;
final List<OperationModel> operations; final List<OperationModel> operations;
final bool hasReachedMax;
final String? errorMessage; final String? errorMessage;
final String query;
// Paginazione Ibrida
final int currentPage;
final int itemsPerPage;
final int totalItems;
final bool hasReachedMax;
// 🥷 I FILTRI MANCANTI (Riparati!)
final String? searchTerm;
final DateTimeRange? dateRange; final DateTimeRange? dateRange;
const OperationListState({ const OperationListState({
this.status = OperationListStatus.initial, this.status = OperationListStatus.initial,
this.operations = const [], this.operations = const [],
this.hasReachedMax = false,
this.errorMessage, this.errorMessage,
this.query = '', this.currentPage = 1,
this.itemsPerPage = 25,
this.totalItems = 0,
this.hasReachedMax = false,
this.searchTerm,
this.dateRange, this.dateRange,
}); });
int get totalPages => (totalItems / itemsPerPage).ceil();
// 🥷 COPYWITH AVANZATO: Gestisce lo sbiancamento dei filtri alla perfezione
OperationListState copyWith({ OperationListState copyWith({
OperationListStatus? status, OperationListStatus? status,
List<OperationModel>? operations, List<OperationModel>? operations,
bool? hasReachedMax,
String? errorMessage, String? errorMessage,
String? query, int? currentPage,
DateTimeRange? dateRange, int? itemsPerPage,
int? totalItems,
bool? hasReachedMax,
String? Function()? searchTerm, // Callback per gestire il null esplicito
DateTimeRange? Function()?
dateRange, // Callback per gestire il null esplicito
}) { }) {
return OperationListState( return OperationListState(
status: status ?? this.status, status: status ?? this.status,
operations: operations ?? this.operations, operations: operations ?? this.operations,
errorMessage: errorMessage ?? this.errorMessage,
currentPage: currentPage ?? this.currentPage,
itemsPerPage: itemsPerPage ?? this.itemsPerPage,
totalItems: totalItems ?? this.totalItems,
hasReachedMax: hasReachedMax ?? this.hasReachedMax, hasReachedMax: hasReachedMax ?? this.hasReachedMax,
errorMessage: errorMessage,
query: query ?? this.query, // Se passi la funzione la eseguiamo, altrimenti teniamo il valore corrente
dateRange: dateRange ?? this.dateRange, searchTerm: searchTerm != null ? searchTerm() : this.searchTerm,
dateRange: dateRange != null ? dateRange() : this.dateRange,
); );
} }
@@ -41,9 +63,12 @@ class OperationListState extends Equatable {
List<Object?> get props => [ List<Object?> get props => [
status, status,
operations, operations,
hasReachedMax,
errorMessage, errorMessage,
query, currentPage,
itemsPerPage,
totalItems,
hasReachedMax,
searchTerm,
dateRange, dateRange,
]; ];
} }

View File

@@ -35,25 +35,31 @@ class OperationsRepository {
} }
} }
// --- RECUPERO PAGINATO CON FILTRI E JOIN --- // 🥷 2. RECUPERO PAGINATO ASSOLUTO CON CONTEGGIO TOTALI
Future<List<OperationModel>> fetchOperations({ Future<PaginatedOperations> fetchPaginatedOperations({
required String companyId, required String companyId,
String? storeId, String? storeId,
String? staffId, String? staffId,
String? providerId, String? providerId,
required int offset, required int page, // Usiamo 'page' (1, 2, 3...) invece di 'offset'
int limit = 50, int itemsPerPage = 25, // Default a 25 elementi per pagina
String? searchTerm, String? searchTerm,
DateTimeRange? dateRange, DateTimeRange? dateRange,
}) async { }) async {
try { try {
// Calcoliamo il range di partenza e fine per Supabase
// Es. Pagina 1, 25 items -> range(0, 24)
// Es. Pagina 2, 25 items -> range(25, 49)
final from = (page - 1) * itemsPerPage;
final to = from + itemsPerPage - 1;
var query = _supabase var query = _supabase
.from(Tables.operations) .from(Tables.operations)
.select(''' .select('''
*, *,
${Tables.customers}(*), ${Tables.customers}(*),
${Tables.stores}(name), ${Tables.stores}(name),
${Tables.providers}(name), ${Tables.providers}(*),
${Tables.models}(name_with_brand), ${Tables.models}(name_with_brand),
${Tables.staffMembers}(name), ${Tables.staffMembers}(name),
${Tables.attachments}(*) ${Tables.attachments}(*)
@@ -80,7 +86,6 @@ class OperationsRepository {
} }
if (searchTerm != null && searchTerm.isNotEmpty) { if (searchTerm != null && searchTerm.isNotEmpty) {
// Filtra sui campi della tabella principale O su quelli della tabella joinata
query = query.or( query = query.or(
'reference.ilike.%$searchTerm%,note.ilike.%$searchTerm%,customer.name.ilike.%$searchTerm%', 'reference.ilike.%$searchTerm%,note.ilike.%$searchTerm%,customer.name.ilike.%$searchTerm%',
); );
@@ -88,17 +93,25 @@ class OperationsRepository {
final response = await query final response = await query
.order('created_at', ascending: false) .order('created_at', ascending: false)
.range(offset, offset + limit - 1); .range(from, to)
.count(CountOption.exact);
return (response as List) // 3. Estrazione dei dati
final List<OperationModel> operations = (response.data as List)
.map((map) => OperationModel.fromMap(map)) .map((map) => OperationModel.fromMap(map))
.toList(); .toList();
final int totalCount = response.count;
return PaginatedOperations(
operations: operations,
totalCount: totalCount,
);
} catch (e) { } catch (e) {
throw Exception('$e'); throw Exception('Errore nel recupero della pagina $page: $e');
} }
} }
Stream<List<OperationModel>> watchStoreOperations({ Stream<List<Map<String, dynamic>>> watchStoreOperations({
required String storeId, required String storeId,
required int limit, required int limit,
}) { }) {
@@ -107,11 +120,7 @@ class OperationsRepository {
.stream(primaryKey: ['id']) .stream(primaryKey: ['id'])
.eq('store_id', storeId) .eq('store_id', storeId)
.order('created_at', ascending: false) .order('created_at', ascending: false)
.limit(limit) .limit(limit);
.map(
(listOfMaps) =>
listOfMaps.map((map) => OperationModel.fromMap(map)).toList(),
);
} }
// --- SALVATAGGIO COMPLETO (PRIMA PADRE, POI FIGLI) --- // --- SALVATAGGIO COMPLETO (PRIMA PADRE, POI FIGLI) ---
@@ -325,3 +334,10 @@ class OperationsRepository {
} }
} }
} }
class PaginatedOperations {
final List<OperationModel> operations;
final int totalCount;
PaginatedOperations({required this.operations, required this.totalCount});
}

View File

@@ -3,6 +3,7 @@ import 'package:flux/core/enums_and_consts/consts.dart';
import 'package:flux/core/utils/extensions.dart'; import 'package:flux/core/utils/extensions.dart';
import 'package:flux/features/attachments/models/attachment_model.dart'; import 'package:flux/features/attachments/models/attachment_model.dart';
import 'package:flux/features/customers/models/customer_model.dart'; import 'package:flux/features/customers/models/customer_model.dart';
import 'package:flux/features/master_data/providers/models/provider_model.dart';
enum OperationStatus { enum OperationStatus {
success('success', 'OK'), success('success', 'OK'),
@@ -29,8 +30,6 @@ class OperationModel extends Equatable {
final DateTime? createdAt; final DateTime? createdAt;
final String type; final String type;
final String? subType; final String? subType;
final String? providerId;
final String? providerDisplayName;
final String? modelId; final String? modelId;
final String? modelDisplayName; final String? modelDisplayName;
final String? description; final String? description;
@@ -50,6 +49,7 @@ class OperationModel extends Equatable {
final CustomerModel? customer; final CustomerModel? customer;
final String reference; final String reference;
final bool isBusiness; final bool isBusiness;
final ProviderModel? provider;
// ALLEGATI (Aggiunto) // ALLEGATI (Aggiunto)
final List<AttachmentModel> attachments; final List<AttachmentModel> attachments;
@@ -59,8 +59,6 @@ class OperationModel extends Equatable {
this.createdAt, this.createdAt,
this.type = '', this.type = '',
this.subType, this.subType,
this.providerId,
this.providerDisplayName,
this.modelId, this.modelId,
this.modelDisplayName, this.modelDisplayName,
this.description, this.description,
@@ -81,6 +79,7 @@ class OperationModel extends Equatable {
this.reference = '', this.reference = '',
this.attachments = const [], this.attachments = const [],
this.isBusiness = false, this.isBusiness = false,
this.provider,
}); });
OperationModel copyWith({ OperationModel copyWith({
@@ -88,8 +87,8 @@ class OperationModel extends Equatable {
DateTime? createdAt, DateTime? createdAt,
String? type, String? type,
String? subType, String? subType,
String? providerId, // 🥷 TRUCCO APPLICATO ANCHE QUI:
String? providerDisplayName, ProviderModel? Function()? provider,
String? modelId, String? modelId,
String? modelDisplayName, String? modelDisplayName,
String? description, String? description,
@@ -115,8 +114,9 @@ class OperationModel extends Equatable {
createdAt: createdAt ?? this.createdAt, createdAt: createdAt ?? this.createdAt,
type: type ?? this.type, type: type ?? this.type,
subType: subType ?? this.subType, subType: subType ?? this.subType,
providerId: providerId ?? this.providerId, // Se la funzione è passata, la eseguiamo (anche se ritorna null), altrimenti teniamo il vecchio
providerDisplayName: providerDisplayName ?? this.providerDisplayName, provider: provider != null ? provider() : this.provider,
modelId: modelId ?? this.modelId, modelId: modelId ?? this.modelId,
modelDisplayName: modelDisplayName ?? this.modelDisplayName, modelDisplayName: modelDisplayName ?? this.modelDisplayName,
description: description ?? this.description, description: description ?? this.description,
@@ -145,8 +145,7 @@ class OperationModel extends Equatable {
createdAt, createdAt,
type, type,
subType, subType,
providerId, provider,
providerDisplayName,
modelId, modelId,
modelDisplayName, modelDisplayName,
description, description,
@@ -183,10 +182,9 @@ class OperationModel extends Equatable {
subType: map['sub_type'] as String?, subType: map['sub_type'] as String?,
// I campi relazionali nullabili restano rigorosamente null! // I campi relazionali nullabili restano rigorosamente null!
providerId: map['provider_id'] as String?, provider: (map[Tables.providers] != null)
// MAGIA ANTI-CRASH: Usiamo ?['chiave'] per non far esplodere i join vuoti ? ProviderModel.fromMap(map[Tables.providers] as Map<String, dynamic>)
providerDisplayName: (map[Tables.providers]?['name'] as String?) : null,
?.myFormat(),
modelId: map['model_id'] as String?, modelId: map['model_id'] as String?,
modelDisplayName: (map[Tables.models]?['name_with_brand'] as String?) modelDisplayName: (map[Tables.models]?['name_with_brand'] as String?)
@@ -238,7 +236,7 @@ class OperationModel extends Equatable {
if (id != null) 'id': id, if (id != null) 'id': id,
'type': type, 'type': type,
'sub_type': subType, 'sub_type': subType,
'provider_id': providerId, 'provider_id': provider?.id,
'model_id': modelId, 'model_id': modelId,
'description': description, 'description': description,
if (expirationDate != null) if (expirationDate != null)

View File

@@ -1,6 +1,8 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flux/core/routes/routes.dart'; import 'package:flux/core/routes/routes.dart';
import 'package:flux/core/widgets/staff_selector_modal.dart';
import 'package:flux/features/master_data/staff/models/staff_member_model.dart';
import 'package:flux/features/operations/blocs/operation_list_cubit.dart'; import 'package:flux/features/operations/blocs/operation_list_cubit.dart';
import 'package:flux/features/operations/models/operation_model.dart'; import 'package:flux/features/operations/models/operation_model.dart';
import 'package:go_router/go_router.dart'; import 'package:go_router/go_router.dart';
@@ -14,20 +16,39 @@ class OperationListScreen extends StatefulWidget {
class _OperationListScreenState extends State<OperationListScreen> { class _OperationListScreenState extends State<OperationListScreen> {
final ScrollController _scrollController = ScrollController(); final ScrollController _scrollController = ScrollController();
final TextEditingController _searchController = TextEditingController();
// 🥷 1. LO STATO PER LE BULK ACTIONS // Set per gestire le Bulk Actions (Selezione multipla)
final Set<String> _selectedOperationIds = {}; final Set<String> _selectedOperationIds = {};
bool get _isSelectionMode => _selectedOperationIds.isNotEmpty; bool get _isSelectionMode => _selectedOperationIds.isNotEmpty;
// Flag per mostrare/nascondere la barra di ricerca integrata nell'AppBar
bool _showSearchBar = false;
@override @override
void initState() { void initState() {
super.initState(); super.initState();
_scrollController.addListener(_onScroll); _scrollController.addListener(_onScroll);
// Primo caricamento: partiamo da pagina 1
// (Il Cubit deciderà se fare il boot iniziale o se c'era già roba in cache)
WidgetsBinding.instance.addPostFrameCallback((_) {
final isDesktop = MediaQuery.sizeOf(context).width >= 900;
if (isDesktop) {
context.read<OperationListCubit>().loadSpecificPageDesktop(1);
} else {
context.read<OperationListCubit>().loadNextPageMobile(refresh: true);
}
});
} }
void _onScroll() { void _onScroll() {
final isDesktop = MediaQuery.sizeOf(context).width >= 900;
// 🥷 COMPORTAMENTO IBRIDO: Lo scroll infinito si attiva SOLO su mobile
if (isDesktop) return;
if (_isBottom) { if (_isBottom) {
context.read<OperationListCubit>().loadOperations(); context.read<OperationListCubit>().loadNextPageMobile();
} }
} }
@@ -41,6 +62,7 @@ class _OperationListScreenState extends State<OperationListScreen> {
@override @override
void dispose() { void dispose() {
_scrollController.dispose(); _scrollController.dispose();
_searchController.dispose();
super.dispose(); super.dispose();
} }
@@ -62,8 +84,10 @@ class _OperationListScreenState extends State<OperationListScreen> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final isDesktop = MediaQuery.sizeOf(context).width >= 900;
return Scaffold( return Scaffold(
// 🥷 2. APPBAR DINAMICA (Standard o Modalità Selezione) // --- APP BAR DINAMICA E INTEGRATA ---
appBar: _isSelectionMode appBar: _isSelectionMode
? AppBar( ? AppBar(
backgroundColor: Theme.of(context).colorScheme.primaryContainer, backgroundColor: Theme.of(context).colorScheme.primaryContainer,
@@ -77,24 +101,53 @@ class _OperationListScreenState extends State<OperationListScreen> {
icon: const Icon(Icons.edit_note), icon: const Icon(Icons.edit_note),
tooltip: 'Cambia Stato Massivo', tooltip: 'Cambia Stato Massivo',
onPressed: () { onPressed: () {
// TODO: Apri BottomSheet per cambiare stato a tutte le selezionate // TODO: Integrare bottom sheet per azioni massive
}, },
), ),
], ],
) )
: AppBar( : AppBar(
title: const Text("Gestione Servizi"), title: _showSearchBar
? TextField(
controller: _searchController,
autofocus: true,
decoration: const InputDecoration(
hintText: 'Cerca per cliente, nota o riferimento...',
border: InputBorder.none,
),
style: const TextStyle(fontSize: 16),
onChanged: (text) {
context.read<OperationListCubit>().updateFilters(
text: text,
);
},
)
: const Text("Gestione Servizi"),
elevation: 0, elevation: 0,
actions: [ actions: [
IconButton( IconButton(
icon: const Icon(Icons.filter_list), icon: Icon(_showSearchBar ? Icons.close : Icons.search),
onPressed: () { onPressed: () {
// TODO: Apri drawer laterale o modal per i filtri avanzati setState(() {
_showSearchBar = !_showSearchBar;
if (!_showSearchBar) {
_searchController.clear();
context.read<OperationListCubit>().clearFilters();
}
});
}, },
), ),
IconButton(icon: const Icon(Icons.search), onPressed: () {}), if (!isDesktop) // Il pull-to-refresh c'è già su mobile, su desktop mettiamo un tasto manuale
IconButton(
icon: const Icon(Icons.filter_list),
onPressed: () {
// TODO: Bottone Filtri Avanzati (es. DateRange Picker)
},
),
], ],
), ),
// --- CORPO RESPONSIVO ---
body: BlocBuilder<OperationListCubit, OperationListState>( body: BlocBuilder<OperationListCubit, OperationListState>(
builder: (context, state) { builder: (context, state) {
if (state.status == OperationListStatus.loading && if (state.status == OperationListStatus.loading &&
@@ -103,83 +156,216 @@ class _OperationListScreenState extends State<OperationListScreen> {
} }
if (state.operations.isEmpty) { if (state.operations.isEmpty) {
return const Center(child: Text("Nessuna pratica trovata.")); return Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Text("Nessuna pratica trovata."),
const SizedBox(height: 12),
ElevatedButton(
onPressed: () => isDesktop
? context
.read<OperationListCubit>()
.loadSpecificPageDesktop(1)
: context.read<OperationListCubit>().loadNextPageMobile(
refresh: true,
),
child: const Text("Ricarica"),
),
],
),
);
} }
// 🥷 3. IL MOTORE RESPONSIVO // 🥷 SCENARIO DESKTOP: Griglia + Barra di Paginazione Gmail-Style
return RefreshIndicator( if (isDesktop) {
onRefresh: () => context.read<OperationListCubit>().loadOperations( return Column(
refresh: true, children: [
), Expanded(
child: LayoutBuilder( child: GridView.builder(
builder: (context, constraints) { controller: _scrollController,
// Se lo schermo è largo (Desktop/Tablet), usiamo la griglia padding: const EdgeInsets.all(16),
final isDesktop = constraints.maxWidth > 700; gridDelegate: const SliverGridDelegateWithMaxCrossAxisExtent(
maxCrossAxisExtent:
return GridView.builder( 420, // Larghezza bilanciata per le card su desktop
controller: _scrollController, mainAxisExtent:
padding: const EdgeInsets.all(12).copyWith(bottom: 80), 175, // Altezza controllata per evitare buchi bianchi
// Magia della griglia: si adatta! crossAxisSpacing: 16,
gridDelegate: SliverGridDelegateWithMaxCrossAxisExtent( mainAxisSpacing: 16,
maxCrossAxisExtent: ),
450, // Larghezza massima della singola card itemCount: state.operations.length,
mainAxisExtent: itemBuilder: (context, index) {
180, // Altezza fissa della card (da aggiustare in base ai tuoi font) final operation = state.operations[index];
crossAxisSpacing: 12, return _buildResponsiveCard(operation);
mainAxisSpacing: 12, },
), ),
itemCount: state.hasReachedMax ),
? state.operations.length _buildDesktopPaginationFooter(
: state.operations.length + 1, state,
itemBuilder: (context, index) { ), // La barra in fondo stile Gmail
if (index >= state.operations.length) { ],
return const Center( );
child: CircularProgressIndicator(strokeWidth: 2), }
);
}
final operation = state.operations[index]; // 🥷 SCENARIO MOBILE: ListView con Infinite Scroll e Pull-to-Refresh
final isSelected = _selectedOperationIds.contains( return RefreshIndicator(
operation.id, onRefresh: () => context
); .read<OperationListCubit>()
.loadNextPageMobile(refresh: true),
child: ListView.builder(
controller: _scrollController,
padding: const EdgeInsets.only(
bottom: 80,
left: 8,
right: 8,
top: 8,
),
itemCount: state.hasReachedMax
? state.operations.length
: state.operations.length + 1,
itemBuilder: (context, index) {
if (index >= state.operations.length) {
return const Center(
child: Padding(
padding: EdgeInsets.all(16.0),
child: CircularProgressIndicator(strokeWidth: 2),
),
);
}
return _RichOperationCard( final operation = state.operations[index];
operation: operation, return Padding(
isSelected: isSelected, padding: const EdgeInsets.symmetric(vertical: 4.0),
isSelectionMode: _isSelectionMode, child: _buildResponsiveCard(operation),
onTap: () {
if (_isSelectionMode) {
_toggleSelection(operation.id!);
} else {
context.pushNamed(
Routes.operationForm,
extra: (createdBy: null, operation: operation),
pathParameters: {'id': operation.id!},
);
}
},
onLongPress: () => _toggleSelection(operation.id!),
);
},
); );
}, },
), ),
); );
}, },
), ),
floatingActionButton: _isSelectionMode floatingActionButton: _isSelectionMode
? null // Nascondi il FAB se stai selezionando ? null
: FloatingActionButton( : FloatingActionButton(
onPressed: () { onPressed: () async {
/* Tuo codice per nuova operazione */ StaffMemberModel? createdBy = await getStaffMember(context);
if (createdBy == null || !context.mounted) return;
context.pushNamed(
Routes.operationForm,
pathParameters: {'id': 'new'},
extra: (createdBy: createdBy, operation: null),
);
}, },
child: const Icon(Icons.add), child: const Icon(Icons.add),
), ),
); );
} }
// --- COSTRUZIONE DELLA COMPONENTISTICA DETTAGLIATA ---
Widget _buildResponsiveCard(OperationModel operation) {
final isSelected = _selectedOperationIds.contains(operation.id);
return _RichOperationCard(
operation: operation,
isSelected: isSelected,
isSelectionMode: _isSelectionMode,
onTap: () {
if (_isSelectionMode) {
_toggleSelection(operation.id!);
} else {
context.pushNamed(
Routes.operationForm,
extra: (createdBy: null, operation: operation),
pathParameters: {'id': operation.id!},
);
}
},
onLongPress: () => _toggleSelection(operation.id!),
);
}
// 🥷 LA BARRA DI PAGINAZIONE DESKTOP (Stile Gmail / Typesense)
Widget _buildDesktopPaginationFooter(OperationListState state) {
final theme = Theme.of(context);
final cubit = context.read<OperationListCubit>();
// Calcolo intervallo visualizzato (es. 1-25 di 140)
final fromItem = ((state.currentPage - 1) * state.itemsPerPage) + 1;
final toItem =
DateUtils.isSameDay(DateTime.now(), DateTime.now()) // segnaposto logico
? (fromItem + state.operations.length - 1)
: fromItem;
return Container(
height: 56,
padding: const EdgeInsets.symmetric(horizontal: 24),
decoration: BoxDecoration(
color: theme.colorScheme.surface,
border: Border(top: BorderSide(color: theme.dividerColor, width: 0.5)),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
// Info totali a sinistra
Text(
"$fromItem-$toItem di ${state.totalItems} pratiche totali",
style: theme.textTheme.bodyMedium?.copyWith(
color: Colors.grey[700],
),
),
// Controlli di navigazione a destra
Row(
children: [
// Prima Pagina
IconButton(
icon: const Icon(Icons.first_page),
onPressed: state.currentPage > 1
? () => cubit.loadSpecificPageDesktop(1)
: null,
),
// Pagina Precedente
IconButton(
icon: const Icon(Icons.chevron_left),
onPressed: state.currentPage > 1
? () => cubit.loadSpecificPageDesktop(state.currentPage - 1)
: null,
),
// Indicatore numerico centrale impacchettato
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: Text(
"Pagina ${state.currentPage} di ${state.totalPages}",
style: const TextStyle(fontWeight: FontWeight.bold),
),
),
// Pagina Successiva
IconButton(
icon: const Icon(Icons.chevron_right),
onPressed: state.currentPage < state.totalPages
? () => cubit.loadSpecificPageDesktop(state.currentPage + 1)
: null,
),
// Ultima Pagina
IconButton(
icon: const Icon(Icons.last_page),
onPressed: state.currentPage < state.totalPages
? () => cubit.loadSpecificPageDesktop(state.totalPages)
: null,
),
],
),
],
),
);
}
} }
// 🥷 4. LA SUPER CARD ESTRATTA // =========================================================================
// 🥷 3. LA CARD RICCA, REATTIVA E DEFINITIVA (Quella revisionata insieme)
// =========================================================================
class _RichOperationCard extends StatelessWidget { class _RichOperationCard extends StatelessWidget {
final OperationModel operation; final OperationModel operation;
final bool isSelected; final bool isSelected;
@@ -195,7 +381,6 @@ class _RichOperationCard extends StatelessWidget {
required this.onLongPress, required this.onLongPress,
}); });
// 🥷 1. IL COLORE DELLO STATO: Centralizzato per usarlo ovunque
Color _getStatusColor(OperationStatus status) { Color _getStatusColor(OperationStatus status) {
switch (status) { switch (status) {
case OperationStatus.success: case OperationStatus.success:
@@ -206,11 +391,10 @@ class _RichOperationCard extends StatelessWidget {
case OperationStatus.waitingForSupport: case OperationStatus.waitingForSupport:
return Colors.blue; return Colors.blue;
case OperationStatus.failure: case OperationStatus.failure:
return Colors.grey.shade800; // O Colors.red se preferisci return Colors.grey.shade800;
} }
} }
// 🥷 2. IL COLORE DEL TIPO: Per farlo risaltare
Color _getTypeColor(String type) { Color _getTypeColor(String type) {
switch (type) { switch (type) {
case 'FIN': case 'FIN':
@@ -239,6 +423,7 @@ class _RichOperationCard extends StatelessWidget {
final typeColor = _getTypeColor(operation.type); final typeColor = _getTypeColor(operation.type);
return Card( return Card(
margin: EdgeInsets.zero, // Gestito dai margini dei padri (griglia/lista)
elevation: isSelected ? 4 : 1, elevation: isSelected ? 4 : 1,
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12), borderRadius: BorderRadius.circular(12),
@@ -256,32 +441,35 @@ class _RichOperationCard extends StatelessWidget {
child: Container( child: Container(
decoration: BoxDecoration( decoration: BoxDecoration(
color: isSelected color: isSelected
? theme.colorScheme.primaryContainer.withValues(alpha: 0.2) ? theme.colorScheme.primaryContainer.withValues(alpha: 0.15)
: null, : null,
// BANDA LATERALE LEGATA ALLO STATO (Stilosissima) // 🥷 COERENZA 100%: Banda laterale legata allo status per eliminare i malintesi cromatici
border: Border(left: BorderSide(color: statusColor, width: 6)), border: Border(left: BorderSide(color: statusColor, width: 6)),
), ),
padding: const EdgeInsets.all(12), padding: const EdgeInsets.all(12),
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
// --- HEADER --- // --- LINEA HEADER ---
Row( Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
if (isSelectionMode) if (isSelectionMode)
SizedBox( Padding(
height: 24, padding: const EdgeInsets.only(right: 8.0),
width: 24, child: SizedBox(
child: Checkbox( height: 18,
value: isSelected, width: 18,
onChanged: (_) => onTap(), child: Checkbox(
value: isSelected,
onChanged: (_) => onTap(),
),
), ),
), ),
Expanded( Expanded(
child: Text( child: Text(
operation.reference.isEmpty (operation.reference.isEmpty)
? 'Nessuna Riferimento' ? 'Senza Riferimento'
: operation.reference, : operation.reference,
style: theme.textTheme.labelSmall?.copyWith( style: theme.textTheme.labelSmall?.copyWith(
color: Colors.grey[600], color: Colors.grey[600],
@@ -291,7 +479,9 @@ class _RichOperationCard extends StatelessWidget {
), ),
), ),
Text( Text(
"${operation.createdAt?.day.toString().padLeft(2, '0')}/${operation.createdAt?.month.toString().padLeft(2, '0')}/${operation.createdAt?.year}", operation.createdAt != null
? "${operation.createdAt!.day.toString().padLeft(2, '0')}/${operation.createdAt!.month.toString().padLeft(2, '0')}/${operation.createdAt!.year}"
: '',
style: theme.textTheme.labelSmall?.copyWith( style: theme.textTheme.labelSmall?.copyWith(
color: Colors.grey[600], color: Colors.grey[600],
), ),
@@ -300,7 +490,7 @@ class _RichOperationCard extends StatelessWidget {
), ),
const SizedBox(height: 8), const SizedBox(height: 8),
// --- CLIENTE E TIPO OPERAZIONE --- // --- LINEA CENTRALE: CLIENTE + INSERTO OPERATIVO ---
Row( Row(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
@@ -309,24 +499,25 @@ class _RichOperationCard extends StatelessWidget {
operation.customer?.name ?? "Cliente sconosciuto", operation.customer?.name ?? "Cliente sconosciuto",
style: const TextStyle( style: const TextStyle(
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
fontSize: 16, fontSize: 15,
), ),
maxLines: 2, maxLines: 2,
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
), ),
), ),
const SizedBox(width: 8), const SizedBox(width: 8),
// IL TIPO DI OPERAZIONE CHE SPICCA
// 🥷 IL RE DEL SERVICE: Il tipo operazione svetta con box e contrasto ad hoc
Container( Container(
padding: const EdgeInsets.symmetric( padding: const EdgeInsets.symmetric(
horizontal: 10, horizontal: 8,
vertical: 6, vertical: 4,
), ),
decoration: BoxDecoration( decoration: BoxDecoration(
color: typeColor.withValues(alpha: 0.15), color: typeColor.withValues(alpha: 0.12),
borderRadius: BorderRadius.circular(8), borderRadius: BorderRadius.circular(6),
border: Border.all( border: Border.all(
color: typeColor.withValues(alpha: 0.3), color: typeColor.withValues(alpha: 0.25),
), ),
), ),
child: Row( child: Row(
@@ -342,19 +533,20 @@ class _RichOperationCard extends StatelessWidget {
operation.type, operation.type,
operation.subType, operation.subType,
), ),
size: 14, size: 13,
color: typeColor, color: typeColor,
), ),
const SizedBox(width: 4), const SizedBox(width: 4),
], ],
Text( Text(
operation.subType?.isNotEmpty == true (operation.subType != null &&
operation.subType!.isNotEmpty)
? operation.subType! ? operation.subType!
: operation.type, : operation.type,
style: TextStyle( style: TextStyle(
color: typeColor, color: typeColor,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
fontSize: 12, fontSize: 11,
), ),
), ),
], ],
@@ -362,14 +554,14 @@ class _RichOperationCard extends StatelessWidget {
), ),
], ],
), ),
const SizedBox(height: 12), const SizedBox(height: 10),
// --- I TAG COMPATTI (Business/Privato, Provider, Device) --- // --- LINEA DEI TAG TECNICI ---
Wrap( Wrap(
spacing: 6, spacing: 6,
runSpacing: 6, runSpacing: 4,
children: [ children: [
// Espanso in "Business" e "Privato" // Tag Target Espanso (Privato / Business)
_MiniChip( _MiniChip(
label: operation.isBusiness ? 'Business' : 'Privato', label: operation.isBusiness ? 'Business' : 'Privato',
icon: operation.isBusiness icon: operation.isBusiness
@@ -378,17 +570,18 @@ class _RichOperationCard extends StatelessWidget {
color: operation.isBusiness ? Colors.indigo : Colors.teal, color: operation.isBusiness ? Colors.indigo : Colors.teal,
), ),
// Tag Provider con il suo colore personalizzato dal DB // Tag Gestore (Agganciato dinamicamente al displayColor generato dall'esadecimale del DB!)
if (operation.providerId != null) if (operation.provider != null)
_MiniChip( _MiniChip(
label: operation.providerDisplayName ?? 'Gestore', label: operation.provider?.name ?? 'Gestore',
// Se hai popolato il campo colorHex, qui puoi usare: operation.provider?.displayColor ?? Colors.grey color:
color: Colors.redAccent, operation.provider?.displayColor ?? Colors.blueGrey,
), ),
// Specifiche addizionali del Finanziamento
if (operation.type == 'Fin' && operation.modelId != null) if (operation.type == 'Fin' && operation.modelId != null)
_MiniChip( _MiniChip(
label: operation.modelDisplayName ?? 'Modello', label: operation.modelDisplayName ?? 'Prodotto',
icon: Icons.devices, icon: Icons.devices,
color: Colors.deepPurple, color: Colors.deepPurple,
), ),
@@ -397,7 +590,7 @@ class _RichOperationCard extends StatelessWidget {
const Spacer(), const Spacer(),
// --- FOOTER: Staff e Stato --- // --- FOOTER CARD: AGENTE + CHIP STATO ---
Row( Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
@@ -410,14 +603,31 @@ class _RichOperationCard extends StatelessWidget {
), ),
const SizedBox(width: 4), const SizedBox(width: 4),
Text( Text(
operation.staffDisplayName ?? 'Staff', operation.staffDisplayName ?? 'Assegnato',
style: theme.textTheme.labelSmall?.copyWith( style: theme.textTheme.labelSmall?.copyWith(
color: Colors.grey[700], color: Colors.grey[700],
), ),
), ),
], ],
), ),
_buildOperationStatus(operation.status, statusColor), Container(
padding: const EdgeInsets.symmetric(
horizontal: 8,
vertical: 4,
),
decoration: BoxDecoration(
color: statusColor,
borderRadius: BorderRadius.circular(6),
),
child: Text(
operation.status.displayName,
style: const TextStyle(
fontSize: 10,
color: Colors.white,
fontWeight: FontWeight.bold,
),
),
),
], ],
), ),
], ],
@@ -435,26 +645,9 @@ class _RichOperationCard extends StatelessWidget {
} }
return null; return null;
} }
Widget _buildOperationStatus(OperationStatus status, Color statusColor) {
return Container(
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
decoration: BoxDecoration(
color: statusColor,
borderRadius: BorderRadius.circular(8),
),
child: Text(
status.displayName,
style: const TextStyle(
fontSize: 10,
color: Colors.white,
fontWeight: FontWeight.bold,
),
),
);
}
} }
// Micro Widget di supporto per i tag interni
class _MiniChip extends StatelessWidget { class _MiniChip extends StatelessWidget {
final String label; final String label;
final IconData? icon; final IconData? icon;
@@ -465,23 +658,23 @@ class _MiniChip extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Container( return Container(
padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 4), padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 3),
decoration: BoxDecoration( decoration: BoxDecoration(
color: color.withValues(alpha: 0.1), color: color.withValues(alpha: 0.08),
border: Border.all(color: color.withValues(alpha: 0.3)), border: Border.all(color: color.withValues(alpha: 0.25)),
borderRadius: BorderRadius.circular(6), borderRadius: BorderRadius.circular(4),
), ),
child: Row( child: Row(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [ children: [
if (icon != null) ...[ if (icon != null) ...[
Icon(icon, size: 12, color: color), Icon(icon, size: 11, color: color),
const SizedBox(width: 4), const SizedBox(width: 4),
], ],
Text( Text(
label, label,
style: TextStyle( style: TextStyle(
fontSize: 11, fontSize: 10,
color: color, color: color,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
), ),

View File

@@ -102,10 +102,9 @@ class OperationDetailsSection extends StatelessWidget {
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
), ),
onTap: () { onTap: () {
context.read<OperationFormCubit>().updateFields( context
providerId: provider.id, .read<OperationFormCubit>()
providerDisplayName: provider.name, .updateProvider(provider);
);
Navigator.pop(modalContext); Navigator.pop(modalContext);
}, },
); );
@@ -134,19 +133,18 @@ class OperationDetailsSection extends StatelessWidget {
ListTile( ListTile(
title: const Text('Seleziona Gestore'), title: const Text('Seleziona Gestore'),
subtitle: Text( subtitle: Text(
(currentOp?.providerDisplayName != null && (currentOp?.provider != null)
currentOp!.providerDisplayName!.isNotEmpty) ? currentOp!.provider!.name
? currentOp!.providerDisplayName!
: 'Nessun gestore selezionato', : 'Nessun gestore selezionato',
style: TextStyle( style: TextStyle(
color: color:
(currentOp?.providerId == null || (currentOp?.provider == null ||
currentOp!.providerId!.isEmpty) currentOp!.provider!.name.isEmpty)
? Colors.grey ? Colors.grey
: null, : null,
fontWeight: fontWeight:
(currentOp?.providerId == null || (currentOp?.provider == null ||
currentOp!.providerId!.isEmpty) currentOp!.provider!.name.isEmpty)
? FontWeight.normal ? FontWeight.normal
: FontWeight.bold, : FontWeight.bold,
), ),

View File

@@ -8,6 +8,7 @@ import 'package:flux/features/settings/data/settings_repository.dart';
import 'package:flux/features/tasks/data/task_repository.dart'; import 'package:flux/features/tasks/data/task_repository.dart';
import 'package:flux/features/tasks/models/task_model.dart'; import 'package:flux/features/tasks/models/task_model.dart';
import 'package:flux/features/tasks/models/task_reminder_config.dart'; import 'package:flux/features/tasks/models/task_reminder_config.dart';
import 'package:flux/features/tasks/models/task_status.dart';
import 'package:get_it/get_it.dart'; import 'package:get_it/get_it.dart';
part 'task_form_state.dart'; part 'task_form_state.dart';
@@ -30,7 +31,7 @@ class TaskFormCubit extends Cubit<TaskFormState> {
} }
String get _companyId => _sessionCubit.state.company!.id!; String get _companyId => _sessionCubit.state.company!.id!;
String get _currentUserId => _sessionCubit.state.currentStaffMember!.id!; StaffMemberModel get _currentUser => _sessionCubit.state.currentStaffMember!;
String? get _currentStoreId => _sessionCubit.state.currentStore?.id; String? get _currentStoreId => _sessionCubit.state.currentStore?.id;
// --- ARMED INITIALIZATION (Nuovo, Esistente o Deep Link) --- // --- ARMED INITIALIZATION (Nuovo, Esistente o Deep Link) ---
@@ -57,6 +58,7 @@ class TaskFormCubit extends Cubit<TaskFormState> {
dueDate: task.dueDate, dueDate: task.dueDate,
isGlobal: task.isGlobal, // Sfrutta il tuo getter storeId == null isGlobal: task.isGlobal, // Sfrutta il tuo getter storeId == null
selectedStaffIds: task.assignedToIds, selectedStaffIds: task.assignedToIds,
taskStatus: task.status,
), ),
); );
await _loadExistingTaskReminders(task.id!); await _loadExistingTaskReminders(task.id!);
@@ -129,7 +131,7 @@ class TaskFormCubit extends Cubit<TaskFormState> {
try { try {
final defaults = await _settingsRepository.getMyReminderDefaults( final defaults = await _settingsRepository.getMyReminderDefaults(
companyId: _companyId, companyId: _companyId,
staffId: _currentUserId, staffId: _currentUser.id!,
); );
final initialReminders = defaults final initialReminders = defaults
.map( .map(
@@ -155,7 +157,7 @@ class TaskFormCubit extends Cubit<TaskFormState> {
try { try {
final existingConfigs = await _repository.fetchPersonalReminders( final existingConfigs = await _repository.fetchPersonalReminders(
taskId: taskId, taskId: taskId,
staffId: _currentUserId, staffId: _currentUser.id!,
); );
emit(state.copyWith(reminders: existingConfigs)); emit(state.copyWith(reminders: existingConfigs));
} catch (e) { } catch (e) {
@@ -218,7 +220,7 @@ class TaskFormCubit extends Cubit<TaskFormState> {
final taskToSave = TaskModel( final taskToSave = TaskModel(
id: state.id, id: state.id,
companyId: _companyId, companyId: _companyId,
createdById: _currentUserId, createdBy: _currentUser,
title: state.title.trim(), title: state.title.trim(),
description: state.description.trim(), description: state.description.trim(),
dueDate: state.dueDate, dueDate: state.dueDate,
@@ -233,14 +235,14 @@ class TaskFormCubit extends Cubit<TaskFormState> {
await _repository.createTask( await _repository.createTask(
task: taskToSave, task: taskToSave,
assignedStaffIds: state.selectedStaffIds, assignedStaffIds: state.selectedStaffIds,
currentUserId: _currentUserId, currentUserId: _currentUser.id!,
currentUserCustomReminders: state.reminders, currentUserCustomReminders: state.reminders,
); );
} else { } else {
await _repository.updateTask( await _repository.updateTask(
task: taskToSave, task: taskToSave,
assignedStaffIds: state.selectedStaffIds, assignedStaffIds: state.selectedStaffIds,
currentUserId: _currentUserId, currentUserId: _currentUser.id!,
currentUserCustomReminders: state.reminders, currentUserCustomReminders: state.reminders,
); );
} }
@@ -254,4 +256,51 @@ class TaskFormCubit extends Cubit<TaskFormState> {
); );
} }
} }
Future<void> deleteTask() async {
if (state.id == null) return;
emit(state.copyWith(status: TaskFormStatus.submitting));
try {
await _repository.deleteTask(state.id!);
emit(state.copyWith(status: TaskFormStatus.success));
} catch (e) {
emit(
state.copyWith(
status: TaskFormStatus.failure,
errorMessage: e.toString(),
),
);
}
}
Future<void> updateTaskLocalStatus(TaskStatus newStatus) async {
emit(state.copyWith(taskStatus: newStatus));
}
Future<void> updateTaskStatus(TaskStatus newStatus) async {
try {
// Chiamiamo il repo passando il task aggiornato
await _repository.updateTaskStatus(
taskId: state.id!,
newStatus: newStatus,
updatedById: _currentUser.id!,
);
if (!isClosed) {
// Se l'update va a buon fine, aggiorniamo lo stato locale del cubit
emit(
state.copyWith(status: TaskFormStatus.success, taskStatus: newStatus),
);
}
} catch (e) {
if (!isClosed) {
emit(
state.copyWith(
status: TaskFormStatus.failure,
errorMessage: e.toString(),
),
);
}
}
}
} }

View File

@@ -11,9 +11,9 @@ class TaskFormState extends Equatable {
final bool isGlobal; final bool isGlobal;
final List<String> selectedStaffIds; final List<String> selectedStaffIds;
final List<TaskReminderConfig> reminders; final List<TaskReminderConfig> reminders;
final Map<String, List<StaffMemberModel>> final Map<String, List<StaffMemberModel>> groupedAvailableStaff;
groupedAvailableStaff; // <-- RIPRISTINATO
final String? errorMessage; final String? errorMessage;
final TaskStatus taskStatus;
const TaskFormState({ const TaskFormState({
this.id, this.id,
@@ -26,6 +26,7 @@ class TaskFormState extends Equatable {
this.reminders = const [], this.reminders = const [],
this.groupedAvailableStaff = const {}, this.groupedAvailableStaff = const {},
this.errorMessage, this.errorMessage,
this.taskStatus = TaskStatus.open,
}); });
bool get isFormValid => title.trim().isNotEmpty; bool get isFormValid => title.trim().isNotEmpty;
@@ -41,6 +42,7 @@ class TaskFormState extends Equatable {
List<TaskReminderConfig>? reminders, List<TaskReminderConfig>? reminders,
Map<String, List<StaffMemberModel>>? groupedAvailableStaff, Map<String, List<StaffMemberModel>>? groupedAvailableStaff,
String? errorMessage, String? errorMessage,
TaskStatus? taskStatus,
}) { }) {
return TaskFormState( return TaskFormState(
id: id ?? this.id, id: id ?? this.id,
@@ -54,6 +56,7 @@ class TaskFormState extends Equatable {
groupedAvailableStaff: groupedAvailableStaff:
groupedAvailableStaff ?? this.groupedAvailableStaff, groupedAvailableStaff ?? this.groupedAvailableStaff,
errorMessage: errorMessage, errorMessage: errorMessage,
taskStatus: taskStatus ?? this.taskStatus,
); );
} }
@@ -69,5 +72,6 @@ class TaskFormState extends Equatable {
reminders, reminders,
groupedAvailableStaff, groupedAvailableStaff,
errorMessage, errorMessage,
taskStatus,
]; ];
} }

View File

@@ -21,7 +21,7 @@ class TasksRepository {
}) async { }) async {
try { try {
final response = await _supabase final response = await _supabase
.from('task_reminders') .from(Tables.taskReminders)
.select() .select()
.eq('task_id', taskId) .eq('task_id', taskId)
.eq('staff_id', staffId) .eq('staff_id', staffId)
@@ -53,13 +53,17 @@ class TasksRepository {
int? limit, int? limit,
}) async { }) async {
try { try {
// 1. FASE FILTRI: Usa il join esplicito stile "Notes" // 1. FASE FILTRI: Disambiguazione completa su Tasks e Assignments
var filterBuilder = _supabase var filterBuilder = _supabase
.from(Tables.tasks) .from(Tables.tasks)
.select(''' .select('''
*, *,
creator:${Tables.staffMembers}!created_by_id(*),
updater:${Tables.staffMembers}!updated_by_id(*),
task_assignments:${Tables.taskAssignments} ( task_assignments:${Tables.taskAssignments} (
${Tables.staffMembers} (*) *,
assignee:${Tables.staffMembers}!staff_id(*),
assigner:${Tables.staffMembers}!assigned_by_id(*)
) )
''') ''')
.eq('company_id', companyId); .eq('company_id', companyId);
@@ -71,7 +75,6 @@ class TasksRepository {
} }
if (staffId != null) { if (staffId != null) {
// Grazie al trigger, hai l'array pronto per il filtro senza impazzire!
filterBuilder = filterBuilder.contains('assigned_to_ids', [staffId]); filterBuilder = filterBuilder.contains('assigned_to_ids', [staffId]);
} }
@@ -105,8 +108,12 @@ class TasksRepository {
.from(Tables.tasks) .from(Tables.tasks)
.select(''' .select('''
*, *,
creator:${Tables.staffMembers}!created_by_id(*),
updater:${Tables.staffMembers}!updated_by_id(*),
task_assignments:${Tables.taskAssignments} ( task_assignments:${Tables.taskAssignments} (
${Tables.staffMembers} (*) *,
assignee:${Tables.staffMembers}!staff_id(*),
assigner:${Tables.staffMembers}!assigned_by_id(*)
) )
''') ''')
.eq('id', taskId) .eq('id', taskId)
@@ -122,14 +129,11 @@ class TasksRepository {
// ========================================================================= // =========================================================================
// REALTIME STREAM (La sentinella per la bacheca) // REALTIME STREAM (La sentinella per la bacheca)
// ========================================================================= // =========================================================================
Stream<List<TaskModel>> watchCompanyTasks(String companyId) { Stream<List<Map<String, dynamic>>> watchCompanyTasks(String companyId) {
return _supabase return _supabase
.from('tasks') .from('tasks')
.stream(primaryKey: ['id']) .stream(primaryKey: ['id'])
.eq('company_id', companyId) .eq('company_id', companyId);
.map((listOfMaps) {
return listOfMaps.map((map) => TaskModel.fromMap(map)).toList();
});
} }
// ========================================================================= // =========================================================================
@@ -160,6 +164,7 @@ class TasksRepository {
'task_id': taskId, 'task_id': taskId,
'staff_id': staffId, 'staff_id': staffId,
'company_id': task.companyId, 'company_id': task.companyId,
'assigned_by_id': currentUserId,
}, },
) )
.toList(); .toList();
@@ -276,7 +281,7 @@ class TasksRepository {
// 1. Aggiornamento dati Task Base // 1. Aggiornamento dati Task Base
await _supabase await _supabase
.from('tasks') .from(Tables.tasks)
.update({ .update({
'title': task.title, 'title': task.title,
'description': task.description, 'description': task.description,
@@ -286,15 +291,51 @@ class TasksRepository {
}) })
.eq('id', taskId); .eq('id', taskId);
// 2. Aggiornamento Assegnazioni: eliminiamo le vecchie, inseriamo le nuove // 🥷 2. GESTIONE CHIRURGICA DELLE ASSEGNAZIONI (Addio spam!)
await _supabase.from('task_assignments').delete().eq('task_id', taskId);
if (assignedStaffIds.isNotEmpty) { // A) Recuperiamo chi è GIÀ assegnato a questo task
final assignmentsToInsert = assignedStaffIds final existingAssignmentsResponse = await _supabase
.from('task_assignments')
.select('staff_id')
.eq('task_id', taskId);
final List<String> existingStaffIds =
(existingAssignmentsResponse as List)
.map((row) => row['staff_id'] as String)
.toList();
// B) Calcoliamo i Delta con i Set di Dart (Pura magia matematica)
final newStaffIdsSet = assignedStaffIds.toSet();
final existingStaffIdsSet = existingStaffIds.toSet();
// Quelli da inserire (presenti nei nuovi, ma non nei vecchi)
final toInsertIds = newStaffIdsSet
.difference(existingStaffIdsSet)
.toList();
// Quelli da eliminare (presenti nei vecchi, ma non nei nuovi)
final toDeleteIds = existingStaffIdsSet
.difference(newStaffIdsSet)
.toList();
// C) Eseguiamo solo lo stretto necessario
if (toDeleteIds.isNotEmpty) {
await _supabase
.from('task_assignments')
.delete()
.eq('task_id', taskId)
.inFilter('staff_id', toDeleteIds);
}
if (toInsertIds.isNotEmpty) {
final assignmentsToInsert = toInsertIds
.map( .map(
(staffId) => { (staffId) => {
'task_id': taskId, 'task_id': taskId,
'staff_id': staffId, 'staff_id': staffId,
'company_id': task.companyId, 'company_id': task.companyId,
'assigned_by_id':
currentUserId, // Il nostro salvavita anti-fantasma
}, },
) )
.toList(); .toList();
@@ -352,6 +393,35 @@ class TasksRepository {
} }
} }
Future<void> updateTaskStatus({
required String taskId,
required TaskStatus newStatus,
required String? updatedById,
}) async {
try {
await _supabase
.from(Tables.tasks)
.update({
'status': newStatus.toValue,
'updated_by_id': updatedById,
'updated_at': DateTime.now().toIso8601String(),
})
.eq('id', taskId);
} catch (e) {
throw Exception(
'Errore durante l\'aggiornamento dello stato del task: $e',
);
}
}
Future<void> deleteTask(String taskId) async {
try {
await _supabase.from(Tables.tasks).delete().eq('id', taskId);
} catch (e) {
throw Exception('Errore durante la cancellazione del task: $e');
}
}
// --- HELPER PRIVATO PER LA MAPPA DEL REMINDER --- // --- HELPER PRIVATO PER LA MAPPA DEL REMINDER ---
Map<String, dynamic> _buildReminderRow( Map<String, dynamic> _buildReminderRow(
TaskModel task, TaskModel task,

View File

@@ -9,11 +9,12 @@ class TaskModel extends Equatable {
final String? description; final String? description;
final List<String> assignedToIds; final List<String> assignedToIds;
final List<StaffMemberModel> assignedToStaff; // I dati completi dal JOIN final List<StaffMemberModel> assignedToStaff; // I dati completi dal JOIN
final String? createdById; final StaffMemberModel? createdBy;
final DateTime? dueDate; final DateTime? dueDate;
final TaskStatus status; final TaskStatus status;
final DateTime? createdAt; final DateTime? createdAt;
final String? storeId; final String? storeId;
final StaffMemberModel? updatedBy;
const TaskModel({ const TaskModel({
this.id, this.id,
@@ -22,24 +23,25 @@ class TaskModel extends Equatable {
this.description, this.description,
this.assignedToIds = const [], this.assignedToIds = const [],
this.assignedToStaff = const [], this.assignedToStaff = const [],
this.createdById, this.createdBy,
this.dueDate, this.dueDate,
this.status = TaskStatus.open, this.status = TaskStatus.open,
this.createdAt, this.createdAt,
this.storeId, this.storeId,
this.updatedBy,
}); });
bool get isGlobal => storeId == null; bool get isGlobal => storeId == null;
// --- FACTORY: MODELLO VUOTO (Per le creazioni) --- // --- FACTORY: MODELLO VUOTO (Per le creazioni) ---
factory TaskModel.empty({String? companyId, String? createdById}) { factory TaskModel.empty({String? companyId, StaffMemberModel? createdBy}) {
return TaskModel( return TaskModel(
companyId: companyId, companyId: companyId,
title: '', title: '',
description: '', description: '',
assignedToIds: const [], assignedToIds: const [],
assignedToStaff: const [], assignedToStaff: const [],
createdById: createdById, createdBy: createdBy,
status: TaskStatus.open, status: TaskStatus.open,
createdAt: DateTime.now(), createdAt: DateTime.now(),
); );
@@ -54,11 +56,12 @@ class TaskModel extends Equatable {
description, description,
assignedToIds, assignedToIds,
assignedToStaff, assignedToStaff,
createdById, createdBy,
dueDate, dueDate,
status, status,
createdAt, createdAt,
storeId, storeId,
updatedBy,
]; ];
// --- COPY WITH --- // --- COPY WITH ---
@@ -69,13 +72,15 @@ class TaskModel extends Equatable {
String? description, String? description,
List<String>? assignedToIds, List<String>? assignedToIds,
List<StaffMemberModel>? assignedToStaff, List<StaffMemberModel>? assignedToStaff,
String? createdById, StaffMemberModel? createdBy,
DateTime? dueDate, DateTime? dueDate,
bool clearDueDate = false, // Flag ninja per resettare la scadenza bool clearDueDate = false, // Flag ninja per resettare la scadenza
TaskStatus? status, TaskStatus? status,
DateTime? createdAt, DateTime? createdAt,
String? storeId, String? storeId,
bool clearStoreId = false, bool clearStoreId = false,
StaffMemberModel? updatedBy,
String? updatedByDisplayName,
}) { }) {
return TaskModel( return TaskModel(
id: id ?? this.id, id: id ?? this.id,
@@ -84,11 +89,12 @@ class TaskModel extends Equatable {
description: description ?? this.description, description: description ?? this.description,
assignedToIds: assignedToIds ?? this.assignedToIds, assignedToIds: assignedToIds ?? this.assignedToIds,
assignedToStaff: assignedToStaff ?? this.assignedToStaff, assignedToStaff: assignedToStaff ?? this.assignedToStaff,
createdById: createdById ?? this.createdById, createdBy: createdBy ?? this.createdBy,
dueDate: clearDueDate ? null : (dueDate ?? this.dueDate), dueDate: clearDueDate ? null : (dueDate ?? this.dueDate),
status: status ?? this.status, status: status ?? this.status,
createdAt: createdAt ?? this.createdAt, createdAt: createdAt ?? this.createdAt,
storeId: clearStoreId ? null : (storeId ?? this.storeId), storeId: clearStoreId ? null : (storeId ?? this.storeId),
updatedBy: updatedBy ?? this.updatedBy,
); );
} }
@@ -124,7 +130,9 @@ class TaskModel extends Equatable {
description: map['description'] as String?, description: map['description'] as String?,
assignedToIds: parsedAssignedToIds, assignedToIds: parsedAssignedToIds,
assignedToStaff: staffList, assignedToStaff: staffList,
createdById: map['created_by_id'] as String?, createdBy: map['created_by_id'] != null
? StaffMemberModel.fromMap(map['creator'])
: null,
dueDate: map['due_date'] != null dueDate: map['due_date'] != null
? DateTime.parse(map['due_date'] as String).toLocal() ? DateTime.parse(map['due_date'] as String).toLocal()
: null, : null,
@@ -133,6 +141,9 @@ class TaskModel extends Equatable {
? DateTime.parse(map['created_at'] as String).toLocal() ? DateTime.parse(map['created_at'] as String).toLocal()
: null, : null,
storeId: map['store_id'] as String?, storeId: map['store_id'] as String?,
updatedBy: map['updated_by_id'] != null
? StaffMemberModel.fromMap(map['updater'])
: null,
); );
} }
@@ -145,10 +156,11 @@ class TaskModel extends Equatable {
if (description != null) 'description': description, if (description != null) 'description': description,
// Passiamo l'array vuoto se non ci sono assegnazioni // Passiamo l'array vuoto se non ci sono assegnazioni
'assigned_to_ids': assignedToIds.isEmpty ? null : assignedToIds, 'assigned_to_ids': assignedToIds.isEmpty ? null : assignedToIds,
if (createdById != null) 'created_by_id': createdById, if (createdBy != null) 'created_by_id': createdBy!.id,
'due_date': dueDate?.toUtc().toIso8601String(), 'due_date': dueDate?.toUtc().toIso8601String(),
'status': status.toValue, 'status': status.toValue,
'store_id': storeId, 'store_id': storeId,
if (updatedBy != null) 'updated_by_id': updatedBy!.id,
}; };
} }
} }

View File

@@ -2,7 +2,7 @@
enum TaskStatus { open, inProgress, completed } enum TaskStatus { open, inProgress, completed }
extension TaskStatusExtension on TaskStatus { extension TaskStatusExtension on TaskStatus {
String get name { String get displayName {
switch (this) { switch (this) {
case TaskStatus.open: case TaskStatus.open:
return 'Da Iniziare'; return 'Da Iniziare';

View File

@@ -1,6 +1,7 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flux/features/tasks/blocs/task_form_cubit.dart'; import 'package:flux/features/tasks/blocs/task_form_cubit.dart';
import 'package:flux/features/tasks/models/task_status.dart';
import 'package:go_router/go_router.dart'; import 'package:go_router/go_router.dart';
class TaskFormScreen extends StatefulWidget { class TaskFormScreen extends StatefulWidget {
@@ -123,6 +124,30 @@ class _TaskFormScreenState extends State<TaskFormScreen> {
appBar: AppBar( appBar: AppBar(
title: Text(isEditing ? 'Modifica Task' : 'Nuovo Task'), title: Text(isEditing ? 'Modifica Task' : 'Nuovo Task'),
actions: [ actions: [
// 🥷 1. BOTTONE COMPLETAMENTO RAPIDO (Solo se in edit e non già completato)
if (isEditing && state.taskStatus != TaskStatus.completed)
Padding(
padding: const EdgeInsets.symmetric(
horizontal: 8.0,
vertical: 8.0,
),
child: ElevatedButton.icon(
onPressed: () {
context.read<TaskFormCubit>().updateTaskStatus(
TaskStatus.completed,
);
},
icon: const Icon(Icons.check_circle_outline),
label: const Text('Completa'),
style: ElevatedButton.styleFrom(
backgroundColor: Colors.green.shade600,
foregroundColor: Colors.white,
elevation: 0,
),
),
),
// 🥷 2. LOADER O BOTTONE SALVA
if (state.status == TaskFormStatus.submitting) if (state.status == TaskFormStatus.submitting)
const Padding( const Padding(
padding: EdgeInsets.all(16.0), padding: EdgeInsets.all(16.0),
@@ -133,13 +158,18 @@ class _TaskFormScreenState extends State<TaskFormScreen> {
), ),
) )
else else
TextButton.icon( Padding(
onPressed: state.isFormValid ? () => cubit.saveTask() : null, padding: const EdgeInsets.only(right: 8.0),
icon: const Icon(Icons.save), child: TextButton.icon(
label: const Text('Salva'), onPressed: state.isFormValid
style: TextButton.styleFrom( ? () => cubit.saveTask()
foregroundColor: Colors.orange, : null,
disabledForegroundColor: Colors.grey, icon: const Icon(Icons.save),
label: const Text('Salva'),
style: TextButton.styleFrom(
foregroundColor: Colors.orange,
disabledForegroundColor: Colors.grey,
),
), ),
), ),
], ],
@@ -264,6 +294,45 @@ class _TaskFormScreenState extends State<TaskFormScreen> {
), ),
onChanged: cubit.updateDescription, onChanged: cubit.updateDescription,
), ),
if (state.id != null) ...[
const SizedBox(height: 16),
DropdownButtonFormField<TaskStatus>(
// Leggiamo lo stato attuale dal Cubit (o usiamo un default per i nuovi task)
initialValue: state.taskStatus,
decoration: InputDecoration(
labelText: 'Stato Attuale',
prefixIcon: const Icon(Icons.flag_outlined),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(12),
),
filled: true,
fillColor: Theme.of(context).colorScheme.surface,
),
// Mappiamo tutti i valori dell'enum in elementi della tendina
items: TaskStatus.values.map((TaskStatus status) {
return DropdownMenuItem<TaskStatus>(
value: status,
child: Text(
status
.displayName, // Usa la property displayName del tuo enum!
style: TextStyle(
fontWeight: status == state.taskStatus
? FontWeight.bold
: FontWeight.normal,
),
),
);
}).toList(),
onChanged: (TaskStatus? newStatus) {
if (newStatus != null && newStatus != state.taskStatus) {
context.read<TaskFormCubit>().updateTaskStatus(newStatus);
}
},
),
],
const SizedBox(height: 24), const SizedBox(height: 24),
// --- SCADENZA --- // --- SCADENZA ---

View File

@@ -1,3 +1,4 @@
import 'dart:async';
import 'dart:io'; import 'dart:io';
import 'package:firebase_core/firebase_core.dart'; import 'package:firebase_core/firebase_core.dart';
@@ -47,6 +48,7 @@ import 'package:flux/features/master_data/store/data/store_repository.dart';
import 'package:flux/features/settings/ui/settings.dart'; import 'package:flux/features/settings/ui/settings.dart';
import 'package:flutter_web_plugins/url_strategy.dart'; import 'package:flutter_web_plugins/url_strategy.dart';
import 'package:url_launcher/url_launcher.dart'; import 'package:url_launcher/url_launcher.dart';
import 'package:universal_html/html.dart' as html;
String? initialRecoveryFragment; String? initialRecoveryFragment;
void main() async { void main() async {
@@ -304,21 +306,69 @@ class GlobalUpdateChecker extends StatefulWidget {
State<GlobalUpdateChecker> createState() => _GlobalUpdateCheckerState(); State<GlobalUpdateChecker> createState() => _GlobalUpdateCheckerState();
} }
class _GlobalUpdateCheckerState extends State<GlobalUpdateChecker> { class _GlobalUpdateCheckerState extends State<GlobalUpdateChecker>
with WidgetsBindingObserver {
bool _mustUpdate = false; bool _mustUpdate = false;
String? _updateUrl; String? _updateUrl;
StreamSubscription? _versionSubscription;
@override @override
void initState() { void initState() {
super.initState(); super.initState();
_checkVersionAndBlock(); // 🥷 1. Registriamo questo widget per ascoltare i cicli vitali dell'app
WidgetsBinding.instance.addObserver(this);
_startRealtimeVersionCheck();
} }
Future<void> _checkVersionAndBlock() async { @override
void dispose() {
// 🥷 2. Rimuoviamo l'observer quando il widget muore (mai, in questo caso, ma è buona norma)
WidgetsBinding.instance.removeObserver(this);
_stopRealtimeVersionCheck();
super.dispose();
}
// 🥷 3. IL VERO GESTORE DEL CICLO VITALE
@override
void didChangeAppLifecycleState(AppLifecycleState state) {
super.didChangeAppLifecycleState(state);
if (state == AppLifecycleState.resumed) {
// L'app è tornata attiva: riaccendiamo il radar
_startRealtimeVersionCheck();
} else if (state == AppLifecycleState.paused ||
state == AppLifecycleState.hidden) {
// L'app è andata in background: spegniamo il socket per evitare crash
_stopRealtimeVersionCheck();
}
}
void _startRealtimeVersionCheck() {
// Sicurezza: cancelliamo eventuali vecchi abbonamenti rimasti appesi
_stopRealtimeVersionCheck();
// Facciamo un check immediato non appena rientriamo in app
_checkVersion();
// Riapriamo il rubinetto di Supabase
_versionSubscription = GetIt.I<SupabaseClient>()
.from('app_config') // <-- Sostituisci col nome reale della tua tabella
.stream(primaryKey: ['id'])
.listen((_) {
_checkVersion();
});
}
void _stopRealtimeVersionCheck() {
// Chiudiamo gentilmente il socket
_versionSubscription?.cancel();
_versionSubscription = null;
}
Future<void> _checkVersion() async {
final updateUrl = await VersionCheckService().checkForceUpdate(); final updateUrl = await VersionCheckService().checkForceUpdate();
if (updateUrl != null && mounted) { if (updateUrl != null && mounted) {
// Invece di aprire un dialog, cambiamo lo stato e attiviamo lo "Scudo"
setState(() { setState(() {
_mustUpdate = true; _mustUpdate = true;
_updateUrl = updateUrl; _updateUrl = updateUrl;
@@ -328,21 +378,15 @@ class _GlobalUpdateCheckerState extends State<GlobalUpdateChecker> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
// 1. Se l'app è aggiornata, mostriamo solo l'app normale
if (!_mustUpdate) return widget.child; if (!_mustUpdate) return widget.child;
// 2. Se l'app è vecchia, sovrapponiamo il blocco con uno Stack
return Stack( return Stack(
children: [ children: [
// L'app sotto continua ad esistere, ma è inaccessibile
widget.child, widget.child,
// IL BLOCCO INVALICABILE SOPRA A TUTTO
Positioned.fill( Positioned.fill(
child: Container( child: Container(
color: Colors.black.withValues(alpha: 0.85), // Sfondo oscurante color: Colors.black.withValues(alpha: 0.85),
child: Center( child: Center(
// Usiamo Material per ereditare correttamente temi, font e colori
child: Material( child: Material(
color: Colors.transparent, color: Colors.transparent,
child: Container( child: Container(
@@ -386,7 +430,7 @@ class _GlobalUpdateCheckerState extends State<GlobalUpdateChecker> {
const SizedBox(height: 16), const SizedBox(height: 16),
Text( Text(
kIsWeb kIsWeb
? "È stata rilasciata una nuova versione dell'applicazione. Ricarica la pagina per continuare." ? "È stata rilasciata una nuova versione dell'applicazione. Ricarica la pagina per scaricare il nuovo codice."
: "Per continuare ad utilizzare l'applicazione è necessario scaricare e installare l'ultimo aggiornamento.", : "Per continuare ad utilizzare l'applicazione è necessario scaricare e installare l'ultimo aggiornamento.",
textAlign: TextAlign.center, textAlign: TextAlign.center,
style: const TextStyle(fontSize: 16), style: const TextStyle(fontSize: 16),
@@ -399,18 +443,14 @@ class _GlobalUpdateCheckerState extends State<GlobalUpdateChecker> {
style: FilledButton.styleFrom( style: FilledButton.styleFrom(
minimumSize: const Size(double.infinity, 50), minimumSize: const Size(double.infinity, 50),
), ),
onPressed: () async { onPressed: () {
// Trick cross-platform per fare il reload // Hard reload aggirando la cache!
await launchUrl( html.window.location.reload();
Uri.parse(Uri.base.toString()),
webOnlyWindowName: '_self',
);
}, },
) )
else else
FilledButton.icon( FilledButton.icon(
icon: const Icon(Icons.download), icon: const Icon(Icons.download),
label: const Text("SCARICA AGGIORNAMENTO"), label: const Text("SCARICA AGGIORNAMENTO"),
style: FilledButton.styleFrom( style: FilledButton.styleFrom(
minimumSize: const Size(double.infinity, 50), minimumSize: const Size(double.infinity, 50),

View File

@@ -1,27 +1,159 @@
PODS: PODS:
- app_links (6.4.1):
- FlutterMacOS
- file_picker (0.0.1):
- FlutterMacOS
- file_selector_macos (0.0.1):
- FlutterMacOS
- Firebase/CoreOnly (12.13.0):
- FirebaseCore (~> 12.13.0)
- Firebase/Messaging (12.13.0):
- Firebase/CoreOnly
- FirebaseMessaging (~> 12.13.0)
- firebase_core (4.9.0):
- Firebase/CoreOnly (~> 12.13.0)
- FlutterMacOS
- firebase_messaging (16.2.2):
- Firebase/CoreOnly (~> 12.13.0)
- Firebase/Messaging (~> 12.13.0)
- firebase_core
- FlutterMacOS
- FirebaseCore (12.13.0):
- FirebaseCoreInternal (~> 12.13.0)
- GoogleUtilities/Environment (~> 8.1)
- GoogleUtilities/Logger (~> 8.1)
- FirebaseCoreInternal (12.13.0):
- "GoogleUtilities/NSData+zlib (~> 8.1)"
- FirebaseInstallations (12.13.0):
- FirebaseCore (~> 12.13.0)
- GoogleUtilities/Environment (~> 8.1)
- GoogleUtilities/UserDefaults (~> 8.1)
- PromisesObjC (~> 2.4)
- FirebaseMessaging (12.13.0):
- FirebaseCore (~> 12.13.0)
- FirebaseInstallations (~> 12.13.0)
- GoogleDataTransport (~> 10.1)
- GoogleUtilities/AppDelegateSwizzler (~> 8.1)
- GoogleUtilities/Environment (~> 8.1)
- GoogleUtilities/Reachability (~> 8.1)
- GoogleUtilities/UserDefaults (~> 8.1)
- nanopb (~> 3.30910.0)
- FlutterMacOS (1.0.0) - FlutterMacOS (1.0.0)
- GoogleDataTransport (10.1.0):
- nanopb (~> 3.30910.0)
- PromisesObjC (~> 2.4)
- GoogleUtilities/AppDelegateSwizzler (8.1.0):
- GoogleUtilities/Environment
- GoogleUtilities/Logger
- GoogleUtilities/Network
- GoogleUtilities/Privacy
- GoogleUtilities/Environment (8.1.0):
- GoogleUtilities/Privacy
- GoogleUtilities/Logger (8.1.0):
- GoogleUtilities/Environment
- GoogleUtilities/Privacy
- GoogleUtilities/Network (8.1.0):
- GoogleUtilities/Logger
- "GoogleUtilities/NSData+zlib"
- GoogleUtilities/Privacy
- GoogleUtilities/Reachability
- "GoogleUtilities/NSData+zlib (8.1.0)":
- GoogleUtilities/Privacy
- GoogleUtilities/Privacy (8.1.0)
- GoogleUtilities/Reachability (8.1.0):
- GoogleUtilities/Logger
- GoogleUtilities/Privacy
- GoogleUtilities/UserDefaults (8.1.0):
- GoogleUtilities/Logger
- GoogleUtilities/Privacy
- nanopb (3.30910.0):
- nanopb/decode (= 3.30910.0)
- nanopb/encode (= 3.30910.0)
- nanopb/decode (3.30910.0)
- nanopb/encode (3.30910.0)
- package_info_plus (0.0.1):
- FlutterMacOS
- pdfx (1.0.0): - pdfx (1.0.0):
- FlutterMacOS - FlutterMacOS
- printing (1.0.0): - printing (1.0.0):
- FlutterMacOS - FlutterMacOS
- PromisesObjC (2.4.0)
- shared_preferences_foundation (0.0.1):
- Flutter
- FlutterMacOS
- url_launcher_macos (0.0.1):
- FlutterMacOS
DEPENDENCIES: DEPENDENCIES:
- app_links (from `Flutter/ephemeral/.symlinks/plugins/app_links/macos`)
- file_picker (from `Flutter/ephemeral/.symlinks/plugins/file_picker/macos`)
- file_selector_macos (from `Flutter/ephemeral/.symlinks/plugins/file_selector_macos/macos`)
- firebase_core (from `Flutter/ephemeral/.symlinks/plugins/firebase_core/macos`)
- firebase_messaging (from `Flutter/ephemeral/.symlinks/plugins/firebase_messaging/macos`)
- FlutterMacOS (from `Flutter/ephemeral`) - FlutterMacOS (from `Flutter/ephemeral`)
- package_info_plus (from `Flutter/ephemeral/.symlinks/plugins/package_info_plus/macos`)
- pdfx (from `Flutter/ephemeral/.symlinks/plugins/pdfx/macos`) - pdfx (from `Flutter/ephemeral/.symlinks/plugins/pdfx/macos`)
- printing (from `Flutter/ephemeral/.symlinks/plugins/printing/macos`) - printing (from `Flutter/ephemeral/.symlinks/plugins/printing/macos`)
- shared_preferences_foundation (from `Flutter/ephemeral/.symlinks/plugins/shared_preferences_foundation/darwin`)
- url_launcher_macos (from `Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos`)
SPEC REPOS:
trunk:
- Firebase
- FirebaseCore
- FirebaseCoreInternal
- FirebaseInstallations
- FirebaseMessaging
- GoogleDataTransport
- GoogleUtilities
- nanopb
- PromisesObjC
EXTERNAL SOURCES: EXTERNAL SOURCES:
app_links:
:path: Flutter/ephemeral/.symlinks/plugins/app_links/macos
file_picker:
:path: Flutter/ephemeral/.symlinks/plugins/file_picker/macos
file_selector_macos:
:path: Flutter/ephemeral/.symlinks/plugins/file_selector_macos/macos
firebase_core:
:path: Flutter/ephemeral/.symlinks/plugins/firebase_core/macos
firebase_messaging:
:path: Flutter/ephemeral/.symlinks/plugins/firebase_messaging/macos
FlutterMacOS: FlutterMacOS:
:path: Flutter/ephemeral :path: Flutter/ephemeral
package_info_plus:
:path: Flutter/ephemeral/.symlinks/plugins/package_info_plus/macos
pdfx: pdfx:
:path: Flutter/ephemeral/.symlinks/plugins/pdfx/macos :path: Flutter/ephemeral/.symlinks/plugins/pdfx/macos
printing: printing:
:path: Flutter/ephemeral/.symlinks/plugins/printing/macos :path: Flutter/ephemeral/.symlinks/plugins/printing/macos
shared_preferences_foundation:
:path: Flutter/ephemeral/.symlinks/plugins/shared_preferences_foundation/darwin
url_launcher_macos:
:path: Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos
SPEC CHECKSUMS: SPEC CHECKSUMS:
app_links: 05a6ec2341985eb05e9f97dc63f5837c39895c3f
file_picker: 7584aae6fa07a041af2b36a2655122d42f578c1a
file_selector_macos: 9e9e068e90ebee155097d00e89ae91edb2374db7
Firebase: 7d62445aeabdaea36f7d372f33052fed9a72514f
firebase_core: 8a780c7f989df0ca42dcd55332fc1b203f11f848
firebase_messaging: 3cb926039fe036f6b92834334d6e23ab33007f1f
FirebaseCore: 58905958aa00a061397a0fd759ae4b55bddb3576
FirebaseCoreInternal: 37bee58388fc6d183f0ab1b32d69ae44f2cf8aad
FirebaseInstallations: 134bde50e477628ded76070efdb12d515d53f948
FirebaseMessaging: 30564b85d2f81a96f9d312bd23acf8186ff092ae
FlutterMacOS: d0db08ddef1a9af05a5ec4b724367152bb0500b1 FlutterMacOS: d0db08ddef1a9af05a5ec4b724367152bb0500b1
GoogleDataTransport: aae35b7ea0c09004c3797d53c8c41f66f219d6a7
GoogleUtilities: 00c88b9a86066ef77f0da2fab05f65d7768ed8e1
nanopb: fad817b59e0457d11a5dfbde799381cd727c1275
package_info_plus: f0052d280d17aa382b932f399edf32507174e870
pdfx: 1e79f57f7a6ce2f4a4c30f21fa54d3dc82441b51 pdfx: 1e79f57f7a6ce2f4a4c30f21fa54d3dc82441b51
printing: c4cf83c78fd684f9bc318e6aadc18972aa48f617 printing: c4cf83c78fd684f9bc318e6aadc18972aa48f617
PromisesObjC: f5707f49cb48b9636751c5b2e7d227e43fba9f47
shared_preferences_foundation: 7036424c3d8ec98dfe75ff1667cb0cd531ec82bb
url_launcher_macos: f87a979182d112f911de6820aefddaf56ee9fbfd
PODFILE CHECKSUM: 54d867c82ac51cbd61b565781b9fada492027009 PODFILE CHECKSUM: 54d867c82ac51cbd61b565781b9fada492027009

View File

@@ -248,6 +248,7 @@
33CC110E2044A8840003C045 /* Bundle Framework */, 33CC110E2044A8840003C045 /* Bundle Framework */,
3399D490228B24CF009A79C7 /* ShellScript */, 3399D490228B24CF009A79C7 /* ShellScript */,
E13C7961A1538309550A7824 /* [CP] Embed Pods Frameworks */, E13C7961A1538309550A7824 /* [CP] Embed Pods Frameworks */,
AC0584CA1EFD6A4D37AEE7BD /* [CP] Copy Pods Resources */,
); );
buildRules = ( buildRules = (
); );
@@ -397,6 +398,23 @@
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0; showEnvVarsInLog = 0;
}; };
AC0584CA1EFD6A4D37AEE7BD /* [CP] Copy Pods Resources */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-input-files.xcfilelist",
);
name = "[CP] Copy Pods Resources";
outputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-output-files.xcfilelist",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources.sh\"\n";
showEnvVarsInLog = 0;
};
E13C7961A1538309550A7824 /* [CP] Embed Pods Frameworks */ = { E13C7961A1538309550A7824 /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase; isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;

View File

@@ -1,122 +0,0 @@
{
"pins" : [
{
"identity" : "abseil-cpp-binary",
"kind" : "remoteSourceControl",
"location" : "https://github.com/google/abseil-cpp-binary.git",
"state" : {
"revision" : "bbe8b69694d7873315fd3a4ad41efe043e1c07c5",
"version" : "1.2024072200.0"
}
},
{
"identity" : "app-check",
"kind" : "remoteSourceControl",
"location" : "https://github.com/google/app-check.git",
"state" : {
"revision" : "61b85103a1aeed8218f17c794687781505fbbef5",
"version" : "11.2.0"
}
},
{
"identity" : "firebase-ios-sdk",
"kind" : "remoteSourceControl",
"location" : "https://github.com/firebase/firebase-ios-sdk",
"state" : {
"revision" : "8d5b4189f1f482df8d5c58c9985ea70491ef5382",
"version" : "12.14.0"
}
},
{
"identity" : "google-ads-on-device-conversion-ios-sdk",
"kind" : "remoteSourceControl",
"location" : "https://github.com/googleads/google-ads-on-device-conversion-ios-sdk",
"state" : {
"revision" : "9bfcc6cf435b2e7c5562c1900b8680c594fa9a64",
"version" : "3.6.0"
}
},
{
"identity" : "googleappmeasurement",
"kind" : "remoteSourceControl",
"location" : "https://github.com/google/GoogleAppMeasurement.git",
"state" : {
"revision" : "219e564a8510e983e675c94f77f7f7c50049f22d",
"version" : "12.14.0"
}
},
{
"identity" : "googledatatransport",
"kind" : "remoteSourceControl",
"location" : "https://github.com/google/GoogleDataTransport.git",
"state" : {
"revision" : "617af071af9aa1d6a091d59a202910ac482128f9",
"version" : "10.1.0"
}
},
{
"identity" : "googleutilities",
"kind" : "remoteSourceControl",
"location" : "https://github.com/google/GoogleUtilities.git",
"state" : {
"revision" : "60da361632d0de02786f709bdc0c4df340f7613e",
"version" : "8.1.0"
}
},
{
"identity" : "grpc-binary",
"kind" : "remoteSourceControl",
"location" : "https://github.com/google/grpc-binary.git",
"state" : {
"revision" : "75b31c842f664a0f46a2e590a570e370249fd8f6",
"version" : "1.69.1"
}
},
{
"identity" : "gtm-session-fetcher",
"kind" : "remoteSourceControl",
"location" : "https://github.com/google/gtm-session-fetcher.git",
"state" : {
"revision" : "c0ac7575d70050c2973ba2318bd5af47f8e8153a",
"version" : "5.3.0"
}
},
{
"identity" : "interop-ios-for-google-sdks",
"kind" : "remoteSourceControl",
"location" : "https://github.com/google/interop-ios-for-google-sdks.git",
"state" : {
"revision" : "040d087ac2267d2ddd4cca36c757d1c6a05fdbfe",
"version" : "101.0.0"
}
},
{
"identity" : "leveldb",
"kind" : "remoteSourceControl",
"location" : "https://github.com/firebase/leveldb.git",
"state" : {
"revision" : "a0bc79961d7be727d258d33d5a6b2f1023270ba1",
"version" : "1.22.5"
}
},
{
"identity" : "nanopb",
"kind" : "remoteSourceControl",
"location" : "https://github.com/firebase/nanopb.git",
"state" : {
"revision" : "b7e1104502eca3a213b46303391ca4d3bc8ddec1",
"version" : "2.30910.0"
}
},
{
"identity" : "promises",
"kind" : "remoteSourceControl",
"location" : "https://github.com/google/promises.git",
"state" : {
"revision" : "540318ecedd63d883069ae7f1ed811a2df00b6ac",
"version" : "2.4.0"
}
}
],
"version" : 2
}

View File

@@ -1,122 +0,0 @@
{
"pins" : [
{
"identity" : "abseil-cpp-binary",
"kind" : "remoteSourceControl",
"location" : "https://github.com/google/abseil-cpp-binary.git",
"state" : {
"revision" : "bbe8b69694d7873315fd3a4ad41efe043e1c07c5",
"version" : "1.2024072200.0"
}
},
{
"identity" : "app-check",
"kind" : "remoteSourceControl",
"location" : "https://github.com/google/app-check.git",
"state" : {
"revision" : "61b85103a1aeed8218f17c794687781505fbbef5",
"version" : "11.2.0"
}
},
{
"identity" : "firebase-ios-sdk",
"kind" : "remoteSourceControl",
"location" : "https://github.com/firebase/firebase-ios-sdk",
"state" : {
"revision" : "8d5b4189f1f482df8d5c58c9985ea70491ef5382",
"version" : "12.14.0"
}
},
{
"identity" : "google-ads-on-device-conversion-ios-sdk",
"kind" : "remoteSourceControl",
"location" : "https://github.com/googleads/google-ads-on-device-conversion-ios-sdk",
"state" : {
"revision" : "9bfcc6cf435b2e7c5562c1900b8680c594fa9a64",
"version" : "3.6.0"
}
},
{
"identity" : "googleappmeasurement",
"kind" : "remoteSourceControl",
"location" : "https://github.com/google/GoogleAppMeasurement.git",
"state" : {
"revision" : "219e564a8510e983e675c94f77f7f7c50049f22d",
"version" : "12.14.0"
}
},
{
"identity" : "googledatatransport",
"kind" : "remoteSourceControl",
"location" : "https://github.com/google/GoogleDataTransport.git",
"state" : {
"revision" : "617af071af9aa1d6a091d59a202910ac482128f9",
"version" : "10.1.0"
}
},
{
"identity" : "googleutilities",
"kind" : "remoteSourceControl",
"location" : "https://github.com/google/GoogleUtilities.git",
"state" : {
"revision" : "60da361632d0de02786f709bdc0c4df340f7613e",
"version" : "8.1.0"
}
},
{
"identity" : "grpc-binary",
"kind" : "remoteSourceControl",
"location" : "https://github.com/google/grpc-binary.git",
"state" : {
"revision" : "75b31c842f664a0f46a2e590a570e370249fd8f6",
"version" : "1.69.1"
}
},
{
"identity" : "gtm-session-fetcher",
"kind" : "remoteSourceControl",
"location" : "https://github.com/google/gtm-session-fetcher.git",
"state" : {
"revision" : "c0ac7575d70050c2973ba2318bd5af47f8e8153a",
"version" : "5.3.0"
}
},
{
"identity" : "interop-ios-for-google-sdks",
"kind" : "remoteSourceControl",
"location" : "https://github.com/google/interop-ios-for-google-sdks.git",
"state" : {
"revision" : "040d087ac2267d2ddd4cca36c757d1c6a05fdbfe",
"version" : "101.0.0"
}
},
{
"identity" : "leveldb",
"kind" : "remoteSourceControl",
"location" : "https://github.com/firebase/leveldb.git",
"state" : {
"revision" : "a0bc79961d7be727d258d33d5a6b2f1023270ba1",
"version" : "1.22.5"
}
},
{
"identity" : "nanopb",
"kind" : "remoteSourceControl",
"location" : "https://github.com/firebase/nanopb.git",
"state" : {
"revision" : "b7e1104502eca3a213b46303391ca4d3bc8ddec1",
"version" : "2.30910.0"
}
},
{
"identity" : "promises",
"kind" : "remoteSourceControl",
"location" : "https://github.com/google/promises.git",
"state" : {
"revision" : "540318ecedd63d883069ae7f1ed811a2df00b6ac",
"version" : "2.4.0"
}
}
],
"version" : 2
}

View File

@@ -5,18 +5,18 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: _flutterfire_internals name: _flutterfire_internals
sha256: "8f89e371e2883de35cdc78f648e725fa4da5f3b6c927269f00fa68f1ea92b598" sha256: "0d1f0adfabbab9f46a1a80ce84a4d8b852b6e4dbf53ce413b30e0cf7d3631b71"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.3.71" version: "1.3.72"
app_links: app_links:
dependency: transitive dependency: transitive
description: description:
name: app_links name: app_links
sha256: "3462d9defc61565fde4944858b59bec5be2b9d5b05f20aed190adb3ad08a7abc" sha256: a350a5b37579b7227aaf9a59c07114617cd4283852e193f743b2b3d2d7483c18
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "7.0.0" version: "7.1.1"
app_links_linux: app_links_linux:
dependency: transitive dependency: transitive
description: description:
@@ -105,6 +105,14 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.4.1" version: "1.4.1"
charcode:
dependency: transitive
description:
name: charcode
sha256: fb0f1107cac15a5ea6ef0a6ef71a807b9e4267c713bb93e00e92d737cc8dbd8a
url: "https://pub.dev"
source: hosted
version: "1.4.0"
checked_yaml: checked_yaml:
dependency: transitive dependency: transitive
description: description:
@@ -133,10 +141,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: code_assets name: code_assets
sha256: dad6bf6b9f4f378b0a69edbf42584d336efd1a9ce15deb1ba591cbb1b5ff440f sha256: bf394f466ba9205f1812a0433b392d6af280f155f56651eda7c18cc32ed493b8
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.1.0" version: "1.2.1"
collection: collection:
dependency: "direct main" dependency: "direct main"
description: description:
@@ -169,6 +177,14 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "3.0.7" version: "3.0.7"
csslib:
dependency: transitive
description:
name: csslib
sha256: "09bad715f418841f976c77db72d5398dc1253c21fb9c0c7f0b0b985860b2d58e"
url: "https://pub.dev"
source: hosted
version: "1.0.2"
dart_jsonwebtoken: dart_jsonwebtoken:
dependency: transitive dependency: transitive
description: description:
@@ -181,10 +197,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: dbus name: dbus
sha256: d0c98dcd4f5169878b6cf8f6e0a52403a9dff371a3e2f019697accbf6f44a270 sha256: "0ce9b0a839e6dee59a37a623d2fc26a35bbbe6404213e419b0d6411023d62645"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "0.7.12" version: "0.7.14"
equatable: equatable:
dependency: "direct main" dependency: "direct main"
description: description:
@@ -269,10 +285,10 @@ packages:
dependency: "direct main" dependency: "direct main"
description: description:
name: firebase_core name: firebase_core
sha256: "93a5bde9775fd5adcc937f39dfa04ae0bc89c4d79bea6abc49de3f7b049d9ff6" sha256: ec46a100a560d3bd5f97f2d89ba7492cb09b6dd0a4a28753d1258f360d6bd9f9
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "4.9.0" version: "4.10.0"
firebase_core_platform_interface: firebase_core_platform_interface:
dependency: transitive dependency: transitive
description: description:
@@ -285,34 +301,34 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: firebase_core_web name: firebase_core_web
sha256: "7c98f10b8c8e5adedc0b810b66a877120696675e2c22d9ca9caca092da0d9e57" sha256: "5ad1be848692ec148f2d6a8ad2a3838cb852ea5f3c9e6479a7afce479e1854f8"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "3.7.0" version: "3.8.0"
firebase_messaging: firebase_messaging:
dependency: "direct main" dependency: "direct main"
description: description:
name: firebase_messaging name: firebase_messaging
sha256: "8d0dc81a31cd030170508dc3e89bfd14355b20a1b991340af5f018e37daab5d7" sha256: "9651e833454156b9f0927eaedccffba0f7f6a6e20ceddef82517211e7017e9c4"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "16.2.2" version: "16.3.0"
firebase_messaging_platform_interface: firebase_messaging_platform_interface:
dependency: transitive dependency: transitive
description: description:
name: firebase_messaging_platform_interface name: firebase_messaging_platform_interface
sha256: "37abb0b0535c5497605ee94c12470e1ebbbe47e71a22d0c20bffcc912311f8cb" sha256: "292bb5dc9c4a429078895406c347d7c7690deb858c1adeed8f4b4346f769dfa3"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "4.7.11" version: "4.8.0"
firebase_messaging_web: firebase_messaging_web:
dependency: transitive dependency: transitive
description: description:
name: firebase_messaging_web name: firebase_messaging_web
sha256: "54e22b43e2c26a2728a3f68c188de0f9011993ae19ae959a06d476dad935c776" sha256: "08c565bc83729439f5de2dfea77b4832002b705eb2f840366cefa80e4e5c3c66"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "4.1.7" version: "4.2.0"
fixnum: fixnum:
dependency: transitive dependency: transitive
description: description:
@@ -367,10 +383,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: flutter_plugin_android_lifecycle name: flutter_plugin_android_lifecycle
sha256: "38d1c268de9097ff59cf0e844ac38759fc78f76836d37edad06fa21e182055a0" sha256: "3854fe5e3bff0b113c658f260b90c95dea17c92db0f2addeac2e343dd9969785"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "2.0.34" version: "2.0.35"
flutter_staggered_grid_view: flutter_staggered_grid_view:
dependency: "direct main" dependency: "direct main"
description: description:
@@ -425,10 +441,10 @@ packages:
dependency: "direct main" dependency: "direct main"
description: description:
name: go_router name: go_router
sha256: "92d8cee7c57dff0a6c409c05597b460002434eccf7424a712283225b3962d03f" sha256: "5922b2861e2235a3504896f0d6fa07d84141b480cf52eecd2f42cd25585a9e8a"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "17.2.3" version: "17.3.0"
google_fonts: google_fonts:
dependency: "direct main" dependency: "direct main"
description: description:
@@ -457,10 +473,18 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: hooks name: hooks
sha256: a41af4e8fc687cd6d33de9751eb936c8c0204ebe2bcb6c15ecf707504bf47f31 sha256: "9a62a50b50b769a737bc0a8ff381f333529df3ab746b2f6b02e83760231455ba"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "2.0.0" version: "2.0.2"
html:
dependency: transitive
description:
name: html
sha256: "6d1264f2dffa1b1101c25a91dff0dc2daee4c18e87cd8538729773c073dbf602"
url: "https://pub.dev"
source: hosted
version: "0.15.6"
http: http:
dependency: transitive dependency: transitive
description: description:
@@ -497,10 +521,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: image_picker_android name: image_picker_android
sha256: d5b3e1774af29c9ab00103afb0d4614070f924d2e0057ac867ec98800114793f sha256: "6f3a1995eafb000333174fae92202622033b0ee7fd917a6cd3730295264df84a"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "0.8.13+17" version: "0.8.13+19"
image_picker_for_web: image_picker_for_web:
dependency: transitive dependency: transitive
description: description:
@@ -802,10 +826,10 @@ packages:
dependency: "direct main" dependency: "direct main"
description: description:
name: permission_handler name: permission_handler
sha256: bc917da36261b00137bbc8896bf1482169cd76f866282368948f032c8c1caae1 sha256: fe54465bcc62a4564c6e4db337bbaded6c0c0fa6e10487414436d163114784f6
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "12.0.1" version: "12.0.3"
permission_handler_android: permission_handler_android:
dependency: transitive dependency: transitive
description: description:
@@ -818,10 +842,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: permission_handler_apple name: permission_handler_apple
sha256: f000131e755c54cf4d84a5d8bd6e4149e262cc31c5a8b1d698de1ac85fa41023 sha256: e20daf680eef1ca62ffe8c8c526b778cc386d50137c77ac71c8ec9c88c13fb9d
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "9.4.7" version: "9.4.9"
permission_handler_html: permission_handler_html:
dependency: transitive dependency: transitive
description: description:
@@ -986,10 +1010,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: shared_preferences_android name: shared_preferences_android
sha256: e8d4762b1e2e8578fc4d0fd548cebf24afd24f49719c08974df92834565e2c53 sha256: a2c49fc1fed7140cadd892d765bd47edbe4ac0b9c7e7e3c493dcb58126f99cf0
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "2.4.23" version: "2.4.25"
shared_preferences_foundation: shared_preferences_foundation:
dependency: transitive dependency: transitive
description: description:
@@ -1095,10 +1119,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: synchronized name: synchronized
sha256: "63896c27e81b28f8cb4e69ead0d3e8f03f1d1e5fc531a3e579cabed6a2c7c9e5" sha256: "93b153dcb6a26dcddee6ca087dd634b53e38c10b5aa163e8e49501a776456153"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "3.4.0+1" version: "3.4.1"
term_glyph: term_glyph:
dependency: transitive dependency: transitive
description: description:
@@ -1131,6 +1155,14 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.0.0" version: "1.0.0"
universal_html:
dependency: "direct main"
description:
name: universal_html
sha256: c0bcae5c733c60f26c7dfc88b10b0fd27cbcc45cb7492311cdaa6067e21c9cd4
url: "https://pub.dev"
source: hosted
version: "2.3.0"
universal_io: universal_io:
dependency: "direct main" dependency: "direct main"
description: description:
@@ -1159,10 +1191,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: url_launcher_android name: url_launcher_android
sha256: "17bc677f0b301615530dd1d67e0a9828cafa2d0b6b6eae4cd3679b7eac4a273c" sha256: b413d49b73867ac08dd2f9890efd3cc11f2a0e577618d50843440a1fb3776c32
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "6.3.30" version: "6.3.32"
url_launcher_ios: url_launcher_ios:
dependency: transitive dependency: transitive
description: description:
@@ -1239,10 +1271,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: vector_graphics_compiler name: vector_graphics_compiler
sha256: b9b3f391857781aa96acacef96066f2f49b4cd03cf9fce3ca4d8da2ef5ea129e sha256: "7ee12e6dffe0fc8e755179d6d91b3b34f5924223fc104d85572ef9180d73d172"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.2.3" version: "1.2.5"
vector_math: vector_math:
dependency: transitive dependency: transitive
description: description:
@@ -1324,5 +1356,5 @@ packages:
source: hosted source: hosted
version: "2.1.0" version: "2.1.0"
sdks: sdks:
dart: ">=3.11.3 <4.0.0" dart: ">=3.12.0 <4.0.0"
flutter: ">=3.38.4" flutter: ">=3.44.0"

View File

@@ -1,7 +1,7 @@
name: flux name: flux
description: "Gestione attività negozio di telefonia" description: "Gestione attività negozio di telefonia"
publish_to: 'none' publish_to: 'none'
version: 1.1.14+32 version: 1.1.21+39
environment: environment:
sdk: ^3.11.3 sdk: ^3.11.3
@@ -41,6 +41,7 @@ dependencies:
flutter_staggered_grid_view: ^0.7.0 flutter_staggered_grid_view: ^0.7.0
firebase_core: ^4.9.0 firebase_core: ^4.9.0
firebase_messaging: ^16.2.2 firebase_messaging: ^16.2.2
universal_html: ^2.3.0
dependency_overrides: dependency_overrides:
pdfx: pdfx:
@@ -55,6 +56,8 @@ dev_dependencies:
flutter_lints: ^6.0.0 flutter_lints: ^6.0.0
flutter: flutter:
config:
enable-swift-package-manager: false
uses-material-design: true uses-material-design: true
generate: true generate: true

View File

@@ -0,0 +1,136 @@
import { serve } from "https://deno.land/std@0.168.0/http/server.ts"
import { createClient } from "https://esm.sh/@supabase/supabase-js@2"
const corsHeaders = {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Headers': 'authorization, x-client-info, apiKey, content-type',
}
serve(async (req) => {
if (req.method === 'OPTIONS') return new Response('ok', { headers: corsHeaders })
try {
const payload = await req.json()
const { table, type, record } = payload
// 🥷 1. FILTRO EVENTI: Agiamo solo sui nuovi allegati
if (table !== 'attachments' || type !== 'INSERT') {
return new Response(JSON.stringify({ message: "Ignorato: non è un INSERT su attachments." }), { status: 200, headers: corsHeaders })
}
// Se l'allegato ha GIÀ un customer_id, l'operatore l'ha caricato direttamente
// dalla scheda cliente. Non serve sprecare soldi con l'AI.
if (record.customer_id) {
return new Response(JSON.stringify({ message: "Customer già presente, analisi saltata." }), { status: 200, headers: corsHeaders })
}
// Se non è collegato a un ticket, a un'operazione o a una nota, non abbiamo
// modo di risalire al proprietario, quindi fermiamo tutto.
if (!record.operation_id && !record.ticket_id && !record.note_id) {
return new Response(JSON.stringify({ message: "Nessuna entità collegata da cui estrarre il customer." }), { status: 200, headers: corsHeaders })
}
// 🥷 2. FILTRO FORMATI: Passiamo a OpenAI solo immagini vere (niente zip o pdf per ora)
// Nota: OpenAI supporta anche i PDF in vision, ma le immagini sono più sicure/economiche per i documenti.
const validExtensions = ['jpg', 'jpeg', 'png', 'webp']
const ext = record.extension?.replace('.', '').toLowerCase()
if (!validExtensions.includes(ext)) {
return new Response(JSON.stringify({ message: "Formato non supportato da Vision." }), { status: 200, headers: corsHeaders })
}
const supabase = createClient(
Deno.env.get('SUPABASE_URL') ?? '',
Deno.env.get('SUPABASE_SERVICE_ROLE_KEY') ?? ''
)
// 🥷 3. GENERAZIONE URL SICURO
// Dal momento che il tuo storage bucket è (spero) privato, dobbiamo creare un URL
// temporaneo firmato da passare a OpenAI, valido solo per i prossimi 60 secondi.
const { data: urlData, error: urlError } = await supabase.storage
.from('documents')
.createSignedUrl(record.storage_path, 60)
if (urlError || !urlData) throw new Error(`Errore generazione URL: ${urlError?.message}`)
const imageUrl = urlData.signedUrl
// 🥷 4. L'INTERROGAZIONE ALL'AI (Il cuore del sistema)
console.log(`Analizzo immagine ${record.id} con OpenAI...`)
const openAiResponse = await fetch('https://api.openai.com/v1/chat/completions', {
method: 'POST',
headers: {
'Authorization': `Bearer ${Deno.env.get('OPENAI_API_KEY')}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
model: "gpt-4o-mini", // Il modello super veloce ed economico
response_format: { type: "json_object" }, // Vogliamo solo codice, niente chiacchiere
messages: [
{
role: "user",
content: [
{
type: "text",
text: "Questa immagine è una foto o una scansione di un documento d'identità personale valido (es. carta d'identità, patente di guida, passaporto, tessera sanitaria, codice fiscale)? Rispondi ESCLUSIVAMENTE con un JSON in questo formato: { \"is_id\": true } oppure { \"is_id\": false }"
},
{
type: "image_url",
image_url: { "url": imageUrl }
}
]
}
]
})
})
const aiData = await openAiResponse.json()
const resultText = aiData.choices[0].message.content
const result = JSON.parse(resultText)
// 🥷 5. LA LOGICA DI SMISTAMENTO
if (result.is_id === true) {
console.log(`🎯 Documento rilevato! Cerco il padrone...`)
let targetCustomerId = null
// Andiamo a pescare il customer_id esplorando l'albero delle relazioni
if (record.operation_id) {
const { data } = await supabase.from('operations').select('customer_id').eq('id', record.operation_id).single()
targetCustomerId = data?.customer_id
} else if (record.ticket_id) {
const { data } = await supabase.from('tickets').select('customer_id').eq('id', record.ticket_id).single()
targetCustomerId = data?.customer_id
} else if (record.note_id) {
// Se le note hanno una FK verso i clienti:
const { data } = await supabase.from('notes').select('customer_id').eq('id', record.note_id).single()
targetCustomerId = data?.customer_id
}
// Se abbiamo trovato il proprietario, facciamo l'update dell'allegato!
if (targetCustomerId) {
await supabase
.from('attachments')
.update({ customer_id: targetCustomerId })
.eq('id', record.id)
console.log(`✅ Allegato aggiornato. Legato al cliente: ${targetCustomerId}`)
} else {
console.log(`⚠️ Documento rilevato, ma non c'è nessun cliente legato all'entità genitore.`)
}
} else {
console.log(`L'immagine non è un documento (è uno scontrino, una foto di un router, ecc.).`)
}
return new Response(JSON.stringify({ success: true, is_id: result.is_id }), {
headers: { ...corsHeaders, 'Content-Type': 'application/json' }, status: 200
})
} catch (error) {
console.error("ERRORE FATALE NELLA FUNZIONE:", error)
return new Response(JSON.stringify({ error: error.toString() }), {
headers: { ...corsHeaders, 'Content-Type': 'application/json' }, status: 500
})
}
})

View File

@@ -11,173 +11,186 @@ serve(async (req) => {
if (req.method === 'OPTIONS') return new Response('ok', { headers: corsHeaders }) if (req.method === 'OPTIONS') return new Response('ok', { headers: corsHeaders })
try { try {
const bodyText = await req.text(); const bodyText = await req.text()
const payload = JSON.parse(bodyText); const payload = JSON.parse(bodyText)
// Estraggo i dati dal payload standard di Supabase const tableName = payload.table
const tableName = payload.table; const eventType = payload.type
const record = payload.record; const record = payload.record
const old_record = payload.old_record
if (!tableName || !record) { if (!tableName || !record) {
throw new Error("Payload non valido, manca table o record."); throw new Error("Payload non valido, manca table o record.")
} }
let event_type = '';
let target_staff_id = '';
let title = '';
let description = '';
let reference_id = '';
// Inizializziamo il client Supabase subito, ci serve per le query
const supabaseClient = createClient( const supabaseClient = createClient(
Deno.env.get('SUPABASE_URL') ?? '', Deno.env.get('SUPABASE_URL') ?? '',
Deno.env.get('SUPABASE_SERVICE_ROLE_KEY') ?? '' Deno.env.get('SUPABASE_SERVICE_ROLE_KEY') ?? ''
) )
// SMISTAMENTO IN BASE ALLA TABELLA // =========================================================================
if (tableName === 'task_assignments') { // 🥷 1. IDENTIFICARE ESTRARRE I BERSAGLI (CHI DEVO NOTIFICARE?)
event_type = 'task_assigned'; // =========================================================================
target_staff_id = record.staff_id; let usersToNotify: string[] = []
reference_id = record.task_id; let notificationTitle = ''
title = 'Nuovo Task Assegnato'; let notificationBody = ''
let referenceId = ''
let fluxEventType = '' // 'task_assigned', 'task_completed', etc.
// 1. Peschiamo i dettagli completi del task // SCENARIO A: ASSEGNAZIONE TASK
const { data: taskData } = await supabaseClient if (tableName === 'task_assignments' && eventType === 'INSERT') {
.from('tasks') const assigneeId = record.staff_id
.select('*') const assignerId = record.assigned_by_id
.eq('id', reference_id) referenceId = record.task_id
.single(); fluxEventType = 'task_assigned'
// 2. Peschiamo il nome del creatore if (assigneeId === assignerId) {
let creatorName = "Admin"; return new Response(JSON.stringify({ message: "Auto-assegnazione ignorata." }), { status: 200, headers: corsHeaders })
if (taskData?.created_by_id) {
const { data: creatorData } = await supabaseClient
.from('staff_members')
.select('first_name, last_name')
.eq('id', taskData.created_by_id)
.single();
if (creatorData) {
creatorName = `${creatorData.first_name} ${creatorData.last_name}`.trim();
}
} }
// 3. Formattiamo la data (se esiste) usersToNotify.push(assigneeId)
let dueDateStr = 'Nessuna scadenza';
// Costruiamo i testi
const { data: taskData } = await supabaseClient.from('tasks').select('title, description, due_date').eq('id', referenceId).single()
const { data: assignerData } = await supabaseClient.from('staff_members').select('first_name, last_name').eq('id', assignerId).single()
const taskTitle = taskData?.title || 'Senza titolo'
const taskDesc = taskData?.description || 'Nessuna descrizione'
const assignerName = assignerData ? `${assignerData.first_name} ${assignerData.last_name}`.trim() : 'Un collega'
let dueDateStr = 'Nessuna scadenza'
if (taskData?.due_date) { if (taskData?.due_date) {
const d = new Date(taskData.due_date); dueDateStr = new Date(taskData.due_date).toLocaleDateString('it-IT')
dueDateStr = d.toLocaleDateString('it-IT');
} }
// 4. Costruiamo il Body multilinea per Android notificationTitle = 'Nuovo Task Assegnato'
const taskTitle = taskData?.title || 'Senza titolo'; notificationBody = `${taskTitle}\n\nCreato da: ${assignerName}\nScadenza: ${dueDateStr}\nDettagli: ${taskDesc}`
const taskDesc = taskData?.description || 'Nessuna descrizione fornita.';
description = `${taskTitle}\n\nCreato da: ${creatorName}\nScadenza: ${dueDateStr}\nDettagli: ${taskDesc}`;
} }
// 1. Leggiamo le preferenze specifiche di questo dipendente // SCENARIO B: COMPLETAMENTO TASK
const { data: settings, error: settingsError } = await supabaseClient else if (tableName === 'tasks' && eventType === 'UPDATE') {
.from('staff_notification_settings') const justCompleted = record.status === 'completed' && old_record.status !== 'completed';
.select('*')
.eq('staff_id', target_staff_id)
.single()
if (settingsError || !settings) throw new Error('Preferenze utente non trovate') if (!justCompleted) {
return new Response(JSON.stringify({ message: "Update ignorato (non è un completamento)." }), { status: 200, headers: corsHeaders })
}
// 2. Determiniamo QUALI canali usare in base all'evento e agli switch dell'utente const completerId = record.updated_by_id
let sendPush = false referenceId = record.id
let sendEmail = false fluxEventType = 'task_completed' // Nota: assicurati di avere questa colonna o un fallback nelle preferenze
switch (event_type) { const { data: assignments } = await supabaseClient.from('task_assignments').select('staff_id').eq('task_id', referenceId)
case 'task_assigned':
sendPush = settings.task_assigned_push if (assignments && assignments.length > 0) {
sendEmail = settings.task_assigned_email usersToNotify = assignments.map(a => a.staff_id).filter(id => id !== completerId)
break }
case 'note_invited':
sendPush = settings.note_invited_push if (usersToNotify.length === 0) {
sendEmail = settings.note_invited_email return new Response(JSON.stringify({ message: "Nessun altro assegnatario da notificare per la chiusura." }), { status: 200, headers: corsHeaders })
break }
case 'new_operation':
sendPush = settings.new_operation_push const { data: completerData } = await supabaseClient.from('staff_members').select('first_name, last_name').eq('id', completerId).single()
sendEmail = settings.new_operation_email const completerName = completerData ? `${completerData.first_name} ${completerData.last_name}`.trim() : 'Un collega'
break const taskTitle = record.title || 'Senza titolo'
case 'new_ticket':
sendPush = settings.new_ticket_push notificationTitle = 'Task Completato ✅'
sendEmail = settings.new_ticket_email notificationBody = `${completerName} ha appena chiuso il task: ${taskTitle}`
break
default:
throw new Error('Tipo evento non riconosciuto')
} }
// Se l'utente ha spento tutto, interrompiamo subito risparmiando risorse // SCENARIO C: ALTRI EVENTI (Es. note_invited, ecc. Mettili qui quando ti serviranno)
if (!sendPush && !sendEmail) { else {
return new Response(JSON.stringify({ message: 'L\'utente ha disattivato le notifiche per questo evento.' }), { return new Response(JSON.stringify({ message: "Tabella o evento non gestito." }), { status: 200, headers: corsHeaders })
headers: { ...corsHeaders, 'Content-Type': 'application/json' }, status: 200
})
} }
// Se arriviamo qui, dobbiamo inviare qualcosa. Prepariamo i dati dell'utente.
const { data: staffMember } = await supabaseClient
.from('staff_members')
.select('email, first_name')
.eq('id', target_staff_id)
.single()
// 3. LOGICA PUSH (FCM) // =========================================================================
if (sendPush) { // 🥷 2. MOTORE DI INVIO MASSIVO PER I BERSAGLI IDENTIFICATI
const firebaseSecret = Deno.env.get('FIREBASE_SERVICE_ACCOUNT'); // =========================================================================
if (!firebaseSecret) { // Inizializziamo FCM una volta sola per risparmiare tempo se ci sono push da mandare
console.error("ERRORE: Secret FIREBASE_SERVICE_ACCOUNT mancante nel progetto!"); const firebaseSecret = Deno.env.get('FIREBASE_SERVICE_ACCOUNT')
} else { let fcmAccessToken = ''
const credentials = JSON.parse(firebaseSecret); let fcmProjectId = ''
const jwtClient = new JWT({
email: credentials.client_email,
key: credentials.private_key,
scopes: ['https://www.googleapis.com/auth/firebase.messaging'],
});
const fcmAccessToken = (await jwtClient.getAccessToken()).token;
const { data: devices } = await supabaseClient if (firebaseSecret) {
.from('staff_devices') const credentials = JSON.parse(firebaseSecret)
.select('fcm_token') fcmProjectId = credentials.project_id
.eq('staff_id', target_staff_id); const jwtClient = new JWT({
email: credentials.client_email,
key: credentials.private_key,
scopes: ['https://www.googleapis.com/auth/firebase.messaging'],
})
fcmAccessToken = (await jwtClient.getAccessToken()).token ?? ''
}
if (devices && devices.length > 0) { const resendApiKey = Deno.env.get('RESEND_API_KEY')
let pushSentCount = 0;
let emailSentCount = 0;
// Cicliamo tutti gli utenti che meritano la notifica
for (const targetStaffId of usersToNotify) {
// A) Leggiamo le preferenze dello specifico utente
const { data: settings } = await supabaseClient
.from('staff_notification_settings')
.select('*')
.eq('staff_id', targetStaffId)
.single()
if (!settings) continue; // Salta se non ha le preferenze
let sendPush = false
let sendEmail = false
// B) Traduciamo l'evento nelle sue preferenze
// (Se aggiungi 'task_completed' al DB settings, mettilo qui. Per ora riuso le preesistenti se manca)
switch (fluxEventType) {
case 'task_assigned':
sendPush = settings.task_assigned_push
sendEmail = settings.task_assigned_email
break
case 'task_completed':
// Se nel DB hai aggiunto task_completed_push usa quello.
// Altrimenti puoi fare fallback su task_assigned_push per testare.
sendPush = settings.task_assigned_push
sendEmail = settings.task_assigned_email
break
// Aggiungi qui gli altri case (note_invited, new_operation)
}
if (!sendPush && !sendEmail) continue; // Questo utente non vuole essere disturbato
// Recuperiamo nome ed email per questo specifico utente
const { data: staffMember } = await supabaseClient.from('staff_members').select('email, first_name').eq('id', targetStaffId).single()
// C) INVIO PUSH (FCM)
if (sendPush && fcmAccessToken) {
const { data: devices } = await supabaseClient.from('staff_devices').select('fcm_token').eq('staff_id', targetStaffId)
if (devices) {
for (const device of devices) { for (const device of devices) {
try { try {
const res = await fetch(`https://fcm.googleapis.com/v1/projects/${credentials.project_id}/messages:send`, { const res = await fetch(`https://fcm.googleapis.com/v1/projects/${fcmProjectId}/messages:send`, {
method: 'POST', method: 'POST',
headers: { 'Authorization': `Bearer ${fcmAccessToken}`, 'Content-Type': 'application/json' }, headers: { 'Authorization': `Bearer ${fcmAccessToken}`, 'Content-Type': 'application/json' },
body: JSON.stringify({ body: JSON.stringify({
message: { message: {
token: device.fcm_token, token: device.fcm_token,
notification: { title, body: description }, notification: { title: notificationTitle, body: notificationBody },
data: { click_action: 'FLUTTER_NOTIFICATION_CLICK', eventType: event_type, referenceId: reference_id }, data: { click_action: 'FLUTTER_NOTIFICATION_CLICK', eventType: fluxEventType, referenceId: referenceId },
}, },
}), }),
}); });
if (res.ok) pushSentCount++;
// QUI È DOVE CATTURIAMO LA RISPOSTA DI GOOGLE else console.error("FCM HA RIFIUTATO LA NOTIFICA:", await res.json());
const fcmResponseData = await res.json(); } catch (err) { console.error('Errore rete FCM:', err) }
if (!res.ok) {
console.error("FCM HA RIFIUTATO LA NOTIFICA:", fcmResponseData);
}
} catch (err) {
console.error('Errore di rete durante invio Push:', err);
}
} }
} }
} }
}
// 4. LOGICA EMAIL (Resend) // D) INVIO EMAIL (Resend)
if (sendEmail && staffMember?.email) { if (sendEmail && resendApiKey && staffMember?.email) {
const resendApiKey = Deno.env.get('RESEND_API_KEY')
if (resendApiKey) {
try { try {
await fetch('https://api.resend.com/emails', { await fetch('https://api.resend.com/emails', {
method: 'POST', method: 'POST',
@@ -185,20 +198,24 @@ serve(async (req) => {
body: JSON.stringify({ body: JSON.stringify({
from: 'FLUX Notifiche <onboarding@resend.dev>', from: 'FLUX Notifiche <onboarding@resend.dev>',
to: staffMember.email, to: staffMember.email,
subject: title, subject: notificationTitle,
html: `<p>Ciao ${staffMember.first_name},</p><p>${description}</p><p><br>Il team FLUX</p>`, html: `<p>Ciao ${staffMember.first_name},</p><p>${notificationBody.replace(/\n/g, '<br>')}</p><p><br>Il team FLUX</p>`,
}), }),
}) })
emailSentCount++;
} catch (err) { console.error('Errore invio Email:', err) } } catch (err) { console.error('Errore invio Email:', err) }
} }
} }
return new Response(JSON.stringify({ success: true, push_sent: sendPush, email_sent: sendEmail }), { return new Response(JSON.stringify({
headers: { ...corsHeaders, 'Content-Type': 'application/json' }, status: 200 success: true,
}) targets_found: usersToNotify.length,
push_sent: pushSentCount,
email_sent: emailSentCount
}), { headers: { ...corsHeaders, 'Content-Type': 'application/json' }, status: 200 })
} catch (error) { } catch (error) {
console.error("ERRORE FATALE NELLA FUNZIONE:", error); console.error("ERRORE FATALE NELLA FUNZIONE:", error)
return new Response(JSON.stringify({ error: error.message }), { return new Response(JSON.stringify({ error: error.message }), {
headers: { ...corsHeaders, 'Content-Type': 'application/json' }, status: 500 headers: { ...corsHeaders, 'Content-Type': 'application/json' }, status: 500
}) })