Compare commits
3 Commits
2aab70aec5
...
c610d68b9c
| Author | SHA1 | Date | |
|---|---|---|---|
| c610d68b9c | |||
| efb82b0d4a | |||
| 216fd85888 |
@@ -164,4 +164,8 @@ class SessionCubit extends Cubit<SessionState> {
|
|||||||
void setIsMobileDevice(bool isMobile) {
|
void setIsMobileDevice(bool isMobile) {
|
||||||
emit(state.copyWith(isMobileDevice: isMobile));
|
emit(state.copyWith(isMobileDevice: isMobile));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setIsSingleUserMode(bool isSingleUser) {
|
||||||
|
emit(state.copyWith(isSingleUserMode: isSingleUser));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ class SessionState extends Equatable {
|
|||||||
final StaffMemberModel? currentStaffMember;
|
final StaffMemberModel? currentStaffMember;
|
||||||
final OnboardingStep onboardingStep;
|
final OnboardingStep onboardingStep;
|
||||||
final bool isMobileDevice;
|
final bool isMobileDevice;
|
||||||
|
final bool isSingleUserMode;
|
||||||
|
|
||||||
const SessionState({
|
const SessionState({
|
||||||
this.status = SessionStatus.initial,
|
this.status = SessionStatus.initial,
|
||||||
@@ -34,6 +35,7 @@ class SessionState extends Equatable {
|
|||||||
this.currentStaffMember,
|
this.currentStaffMember,
|
||||||
this.onboardingStep = OnboardingStep.none,
|
this.onboardingStep = OnboardingStep.none,
|
||||||
this.isMobileDevice = false,
|
this.isMobileDevice = false,
|
||||||
|
this.isSingleUserMode = false,
|
||||||
});
|
});
|
||||||
|
|
||||||
/// Metodo per creare una copia dello stato modificando solo i campi necessari
|
/// Metodo per creare una copia dello stato modificando solo i campi necessari
|
||||||
@@ -45,6 +47,7 @@ class SessionState extends Equatable {
|
|||||||
StaffMemberModel? currentStaffMember,
|
StaffMemberModel? currentStaffMember,
|
||||||
OnboardingStep? onboardingStep,
|
OnboardingStep? onboardingStep,
|
||||||
bool? isMobileDevice,
|
bool? isMobileDevice,
|
||||||
|
bool? isSingleUserMode,
|
||||||
}) {
|
}) {
|
||||||
return SessionState(
|
return SessionState(
|
||||||
status: status ?? this.status,
|
status: status ?? this.status,
|
||||||
@@ -54,6 +57,7 @@ class SessionState extends Equatable {
|
|||||||
currentStaffMember: currentStaffMember ?? this.currentStaffMember,
|
currentStaffMember: currentStaffMember ?? this.currentStaffMember,
|
||||||
onboardingStep: onboardingStep ?? this.onboardingStep,
|
onboardingStep: onboardingStep ?? this.onboardingStep,
|
||||||
isMobileDevice: isMobileDevice ?? this.isMobileDevice,
|
isMobileDevice: isMobileDevice ?? this.isMobileDevice,
|
||||||
|
isSingleUserMode: isSingleUserMode ?? this.isSingleUserMode,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,6 +70,7 @@ class SessionState extends Equatable {
|
|||||||
currentStaffMember,
|
currentStaffMember,
|
||||||
onboardingStep,
|
onboardingStep,
|
||||||
isMobileDevice,
|
isMobileDevice,
|
||||||
|
isSingleUserMode,
|
||||||
];
|
];
|
||||||
|
|
||||||
// Helper rapidi per la UI
|
// Helper rapidi per la UI
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import 'package:flux/features/master_data/products/ui/products_screen.dart';
|
|||||||
import 'package:flux/features/master_data/providers/blocs/provider_cubit.dart';
|
import 'package:flux/features/master_data/providers/blocs/provider_cubit.dart';
|
||||||
import 'package:flux/features/master_data/providers/ui/providers_master_data_screen.dart';
|
import 'package:flux/features/master_data/providers/ui/providers_master_data_screen.dart';
|
||||||
import 'package:flux/features/master_data/staff/blocs/staff_cubit.dart';
|
import 'package:flux/features/master_data/staff/blocs/staff_cubit.dart';
|
||||||
|
import 'package:flux/features/master_data/staff/models/staff_member_model.dart';
|
||||||
import 'package:flux/features/master_data/staff/ui/staff_screen.dart';
|
import 'package:flux/features/master_data/staff/ui/staff_screen.dart';
|
||||||
import 'package:flux/features/master_data/store/ui/stores_screen.dart';
|
import 'package:flux/features/master_data/store/ui/stores_screen.dart';
|
||||||
import 'package:flux/features/onboarding/blocs/onboarding_cubit.dart';
|
import 'package:flux/features/onboarding/blocs/onboarding_cubit.dart';
|
||||||
@@ -33,7 +34,7 @@ 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:flux/features/operations/ui/operation_form_screen.dart';
|
import 'package:flux/features/operations/ui/operation_form_screen.dart';
|
||||||
import 'package:flux/features/operations/ui/operation_list_screen.dart';
|
import 'package:flux/features/operations/ui/operation_list_screen.dart';
|
||||||
import 'package:flux/features/settings/settings_view.dart';
|
import 'package:flux/features/settings/settings_screen.dart';
|
||||||
import 'package:flux/features/settings/theme_settings_view.dart';
|
import 'package:flux/features/settings/theme_settings_view.dart';
|
||||||
import 'package:flux/features/tickets/blocs/ticket_form_cubit.dart';
|
import 'package:flux/features/tickets/blocs/ticket_form_cubit.dart';
|
||||||
import 'package:flux/features/tickets/blocs/ticket_list_cubit.dart';
|
import 'package:flux/features/tickets/blocs/ticket_list_cubit.dart';
|
||||||
@@ -170,7 +171,7 @@ class AppRouter {
|
|||||||
GoRoute(
|
GoRoute(
|
||||||
path: '/settings',
|
path: '/settings',
|
||||||
name: Routes.settings,
|
name: Routes.settings,
|
||||||
builder: (context, state) => const SettingsView(),
|
builder: (context, state) => const SettingsScreen(),
|
||||||
routes: [
|
routes: [
|
||||||
GoRoute(
|
GoRoute(
|
||||||
path: 'themeSettings',
|
path: 'themeSettings',
|
||||||
@@ -213,14 +214,22 @@ class AppRouter {
|
|||||||
// 1. Leggiamo l'ID dall'URL
|
// 1. Leggiamo l'ID dall'URL
|
||||||
final String pathId = state.pathParameters['id'] ?? 'new';
|
final String pathId = state.pathParameters['id'] ?? 'new';
|
||||||
|
|
||||||
// 2. Leggiamo l'oggetto dalla RAM (se arriviamo da un tap interno all'app)
|
// 2. CAST DA NINJA (Aggiungi i punti interrogativi!)
|
||||||
final TicketModel? ticketFromExtra = state.extra as TicketModel?;
|
final record =
|
||||||
|
state.extra
|
||||||
|
as ({StaffMemberModel? createdBy, TicketModel? ticket})?;
|
||||||
|
|
||||||
// 3. Capiamo se è un nuovo ticket o una modifica
|
// 3. LOGICA SOBRIA
|
||||||
final String? realTicketId = pathId == 'new' ? null : pathId;
|
final String? realTicketId;
|
||||||
context.read<StaffCubit>().loadStaffForStore(
|
|
||||||
GetIt.I.get<SessionCubit>().state.currentStore!.id!,
|
if (pathId == 'new') {
|
||||||
);
|
realTicketId = null;
|
||||||
|
} else if (record?.ticket?.id != null) {
|
||||||
|
// <-- Parentesi TONDE per la condizione, GRAFFE per il blocco!
|
||||||
|
realTicketId = record!.ticket!.id;
|
||||||
|
} else {
|
||||||
|
realTicketId = pathId;
|
||||||
|
}
|
||||||
context.read<CustomersCubit>().loadCustomers();
|
context.read<CustomersCubit>().loadCustomers();
|
||||||
context.read<ProductsCubit>().loadModels();
|
context.read<ProductsCubit>().loadModels();
|
||||||
context.read<ProductsCubit>().loadBrands();
|
context.read<ProductsCubit>().loadBrands();
|
||||||
@@ -233,12 +242,18 @@ class AppRouter {
|
|||||||
parentId: realTicketId,
|
parentId: realTicketId,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
BlocProvider(create: (context) => TicketFormCubit()),
|
BlocProvider(
|
||||||
|
create: (context) => TicketFormCubit(
|
||||||
|
// Passiamo il creatore e l'eventuale ticket esistente presi dal Record!
|
||||||
|
createdBy: record?.createdBy,
|
||||||
|
existingTicket: record?.ticket,
|
||||||
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
|
|
||||||
child: TicketFormScreen(
|
child: TicketFormScreen(
|
||||||
ticketId: realTicketId,
|
ticketId: realTicketId,
|
||||||
existingTicket: ticketFromExtra,
|
existingTicket: record?.ticket,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
@@ -268,9 +283,22 @@ class AppRouter {
|
|||||||
name: Routes.operationForm,
|
name: Routes.operationForm,
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
final String pathId = state.pathParameters['id'] ?? 'new';
|
final String pathId = state.pathParameters['id'] ?? 'new';
|
||||||
final OperationModel? operationFromExtra =
|
|
||||||
state.extra as OperationModel?;
|
final record =
|
||||||
final String? realOperationId = pathId == 'new' ? null : pathId;
|
state.extra
|
||||||
|
as ({
|
||||||
|
StaffMemberModel? createdBy,
|
||||||
|
OperationModel? operation,
|
||||||
|
})?;
|
||||||
|
|
||||||
|
final String? realOperationId;
|
||||||
|
if (pathId == 'new') {
|
||||||
|
realOperationId = null;
|
||||||
|
} else if (record?.operation?.id != null) {
|
||||||
|
realOperationId = record!.operation!.id;
|
||||||
|
} else {
|
||||||
|
realOperationId = pathId;
|
||||||
|
}
|
||||||
final currentStoreId = GetIt.I
|
final currentStoreId = GetIt.I
|
||||||
.get<SessionCubit>()
|
.get<SessionCubit>()
|
||||||
.state
|
.state
|
||||||
@@ -282,8 +310,6 @@ class AppRouter {
|
|||||||
);
|
);
|
||||||
context.read<ProductsCubit>().loadModels();
|
context.read<ProductsCubit>().loadModels();
|
||||||
context.read<ProductsCubit>().loadBrands();
|
context.read<ProductsCubit>().loadBrands();
|
||||||
context.read<StaffCubit>().loadStaffForStore(currentStoreId);
|
|
||||||
|
|
||||||
return MultiBlocProvider(
|
return MultiBlocProvider(
|
||||||
providers: [
|
providers: [
|
||||||
BlocProvider(
|
BlocProvider(
|
||||||
@@ -292,11 +318,16 @@ class AppRouter {
|
|||||||
parentType: AttachmentParentType.operation,
|
parentType: AttachmentParentType.operation,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
BlocProvider(create: (context) => OperationFormCubit()),
|
BlocProvider(
|
||||||
|
create: (context) => OperationFormCubit(
|
||||||
|
createdBy: record?.createdBy,
|
||||||
|
existingOperation: record?.operation,
|
||||||
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
child: OperationFormScreen(
|
child: OperationFormScreen(
|
||||||
operationId: realOperationId,
|
operationId: realOperationId,
|
||||||
existingOperation: operationFromExtra,
|
existingOperation: record?.operation,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|||||||
147
lib/core/widgets/staff_selector_modal.dart
Normal file
147
lib/core/widgets/staff_selector_modal.dart
Normal file
@@ -0,0 +1,147 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
import 'package:flux/core/blocs/session/session_cubit.dart';
|
||||||
|
import 'package:flux/features/master_data/staff/blocs/staff_cubit.dart';
|
||||||
|
import 'package:flux/features/master_data/staff/models/staff_member_model.dart';
|
||||||
|
// import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
// Importa il tuo StaffModel
|
||||||
|
|
||||||
|
/// Funzione helper globale per lanciare la modale ovunque ti trovi con 1 riga di codice
|
||||||
|
Future<dynamic> showStaffSelectorModal(BuildContext context) async {
|
||||||
|
return showModalBottomSheet(
|
||||||
|
context: context,
|
||||||
|
isScrollControlled:
|
||||||
|
true, // Permette alla modale di essere più alta se serve
|
||||||
|
backgroundColor: Colors.transparent,
|
||||||
|
builder: (context) => const StaffSelectorModal(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
class StaffSelectorModal extends StatelessWidget {
|
||||||
|
const StaffSelectorModal({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final theme = Theme.of(context);
|
||||||
|
|
||||||
|
return Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: theme.colorScheme.surface,
|
||||||
|
borderRadius: const BorderRadius.vertical(top: Radius.circular(24)),
|
||||||
|
),
|
||||||
|
padding: const EdgeInsets.all(24),
|
||||||
|
child: SafeArea(
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min, // Occupa solo lo spazio necessario
|
||||||
|
children: [
|
||||||
|
// --- Maniglietta superiore (UX standard dei BottomSheet) ---
|
||||||
|
Container(
|
||||||
|
width: 40,
|
||||||
|
height: 4,
|
||||||
|
margin: const EdgeInsets.only(bottom: 24),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: theme.dividerColor,
|
||||||
|
borderRadius: BorderRadius.circular(2),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
|
||||||
|
// --- Titolo ---
|
||||||
|
const Text(
|
||||||
|
'Chi sei?',
|
||||||
|
style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 8),
|
||||||
|
Text(
|
||||||
|
'Seleziona il tuo profilo per continuare',
|
||||||
|
style: TextStyle(color: Colors.grey.shade600),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 32),
|
||||||
|
BlocBuilder<StaffCubit, StaffState>(
|
||||||
|
builder: (context, state) {
|
||||||
|
if (state.status == StaffStatus.loading) {
|
||||||
|
return const CircularProgressIndicator();
|
||||||
|
}
|
||||||
|
final staffList = state.storeStaff;
|
||||||
|
return _buildStaffGrid(context, staffList);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
|
||||||
|
// --- Tasto Annulla ---
|
||||||
|
TextButton(
|
||||||
|
onPressed: () => Navigator.of(context).pop(), // Restituisce null
|
||||||
|
child: const Text('Annulla'),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildStaffGrid(
|
||||||
|
BuildContext context,
|
||||||
|
List<StaffMemberModel> staffList,
|
||||||
|
) {
|
||||||
|
return Wrap(
|
||||||
|
spacing: 16,
|
||||||
|
runSpacing: 16,
|
||||||
|
alignment: WrapAlignment.center,
|
||||||
|
children: staffList.map((staff) {
|
||||||
|
return InkWell(
|
||||||
|
borderRadius: BorderRadius.circular(16),
|
||||||
|
onTap: () {
|
||||||
|
// Quando l'utente tappa il suo nome, la modale si chiude
|
||||||
|
// e restituisce il modello (o l'ID) alla schermata precedente!
|
||||||
|
Navigator.of(context).pop(staff);
|
||||||
|
},
|
||||||
|
child: Container(
|
||||||
|
width: 100, // Pulsanti larghi e comodi
|
||||||
|
padding: const EdgeInsets.all(16),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Theme.of(
|
||||||
|
context,
|
||||||
|
).colorScheme.surfaceContainerHighest.withValues(alpha: 0.3),
|
||||||
|
borderRadius: BorderRadius.circular(16),
|
||||||
|
border: Border.all(color: Theme.of(context).dividerColor),
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
CircleAvatar(
|
||||||
|
radius: 30,
|
||||||
|
backgroundColor: Theme.of(context).colorScheme.primary,
|
||||||
|
foregroundColor: Theme.of(context).colorScheme.onPrimary,
|
||||||
|
child: Text(
|
||||||
|
staff.name.substring(0, 1).toUpperCase(),
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 24,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 12),
|
||||||
|
Text(
|
||||||
|
staff.name,
|
||||||
|
style: const TextStyle(fontWeight: FontWeight.bold),
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}).toList(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<StaffMemberModel?> getStaffMember(BuildContext context) async {
|
||||||
|
final sessionState = context.read<SessionCubit>().state;
|
||||||
|
|
||||||
|
if (sessionState.isSingleUserMode) {
|
||||||
|
// Dispositivo personale: non rompiamo le palle. Usiamo l'utente loggato.
|
||||||
|
return sessionState.currentStaffMember;
|
||||||
|
} else {
|
||||||
|
// Dispositivo Condiviso (Kiosk Mode): Chiediamo chi è!
|
||||||
|
return await showStaffSelectorModal(context);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,9 +4,11 @@ import 'package:flux/core/blocs/session/session_cubit.dart';
|
|||||||
import 'package:flux/core/routes/routes.dart';
|
import 'package:flux/core/routes/routes.dart';
|
||||||
import 'package:flux/core/theme/theme.dart';
|
import 'package:flux/core/theme/theme.dart';
|
||||||
import 'package:flux/core/utils/extensions.dart';
|
import 'package:flux/core/utils/extensions.dart';
|
||||||
|
import 'package:flux/core/widgets/staff_selector_modal.dart';
|
||||||
import 'package:flux/features/home/latest_store_operations/ui/latest_store_operations_card.dart';
|
import 'package:flux/features/home/latest_store_operations/ui/latest_store_operations_card.dart';
|
||||||
import 'package:flux/features/home/ui/quick_actions_widget.dart';
|
import 'package:flux/features/home/ui/quick_actions_widget.dart';
|
||||||
import 'package:flux/features/master_data/staff/blocs/staff_cubit.dart';
|
import 'package:flux/features/master_data/staff/blocs/staff_cubit.dart';
|
||||||
|
import 'package:flux/features/master_data/staff/models/staff_member_model.dart';
|
||||||
import 'package:go_router/go_router.dart';
|
import 'package:go_router/go_router.dart';
|
||||||
|
|
||||||
class HomeScreen extends StatelessWidget {
|
class HomeScreen extends StatelessWidget {
|
||||||
@@ -186,11 +188,13 @@ class HomeScreen extends StatelessWidget {
|
|||||||
icon: Icons.add,
|
icon: Icons.add,
|
||||||
label: context.l10n.commonOperation,
|
label: context.l10n.commonOperation,
|
||||||
color: Colors.blue,
|
color: Colors.blue,
|
||||||
onTap: () {
|
onTap: () async {
|
||||||
// Entriamo nel form! Nessun parametro extra = Nuovo Servizio
|
StaffMemberModel? createdBy = await getStaffMember(context);
|
||||||
|
if (createdBy == null || !context.mounted) return;
|
||||||
context.pushNamed(
|
context.pushNamed(
|
||||||
Routes.operationForm,
|
Routes.operationForm,
|
||||||
pathParameters: {'id': 'new'},
|
pathParameters: {'id': 'new'},
|
||||||
|
extra: (createdBy: createdBy, operation: null),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
@@ -199,11 +203,13 @@ class HomeScreen extends StatelessWidget {
|
|||||||
icon: Icons.handyman,
|
icon: Icons.handyman,
|
||||||
label: context.l10n.homeNewOperationTicket,
|
label: context.l10n.homeNewOperationTicket,
|
||||||
color: Colors.redAccent,
|
color: Colors.redAccent,
|
||||||
onTap: () {
|
onTap: () async {
|
||||||
// Andiamo alla lista! (Da lì poi aggiungeremo il tasto "+" per il form)
|
StaffMemberModel? createdBy = await getStaffMember(context);
|
||||||
|
if (createdBy == null || !context.mounted) return;
|
||||||
context.pushNamed(
|
context.pushNamed(
|
||||||
Routes.ticketForm,
|
Routes.ticketForm,
|
||||||
pathParameters: {'id': 'new'},
|
pathParameters: {'id': 'new'},
|
||||||
|
extra: (createdBy: createdBy, ticket: null),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
@@ -383,6 +389,7 @@ class HomeScreen extends StatelessWidget {
|
|||||||
onTap: () {
|
onTap: () {
|
||||||
// Cambiamo il negozio nel SessionCubit!
|
// Cambiamo il negozio nel SessionCubit!
|
||||||
context.read<SessionCubit>().changeStore(store);
|
context.read<SessionCubit>().changeStore(store);
|
||||||
|
context.read<StaffCubit>().loadStaffForStore(store.id!);
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import 'package:equatable/equatable.dart';
|
|||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:flux/core/blocs/session/session_cubit.dart';
|
import 'package:flux/core/blocs/session/session_cubit.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/staff/models/staff_member_model.dart';
|
||||||
import 'package:flux/features/operations/data/operations_repository.dart';
|
import 'package:flux/features/operations/data/operations_repository.dart';
|
||||||
import 'package:flux/features/operations/models/operation_model.dart';
|
import 'package:flux/features/operations/models/operation_model.dart';
|
||||||
import 'package:get_it/get_it.dart';
|
import 'package:get_it/get_it.dart';
|
||||||
@@ -14,19 +15,19 @@ class OperationFormCubit extends Cubit<OperationFormState> {
|
|||||||
final SessionCubit _sessionCubit = GetIt.I<SessionCubit>();
|
final SessionCubit _sessionCubit = GetIt.I<SessionCubit>();
|
||||||
final Uuid _uuid = const Uuid();
|
final Uuid _uuid = const Uuid();
|
||||||
|
|
||||||
OperationFormCubit()
|
OperationFormCubit({
|
||||||
: super(
|
StaffMemberModel? createdBy,
|
||||||
OperationFormState(
|
OperationModel? existingOperation,
|
||||||
// Inizializziamo con un modello vuoto di sicurezza
|
}) : super(
|
||||||
operation: OperationModel(
|
OperationFormState(
|
||||||
storeId: '',
|
operation:
|
||||||
companyId: '',
|
existingOperation ??
|
||||||
reference: '',
|
OperationModel.empty().copyWith(
|
||||||
status: OperationStatus.draft,
|
staffId: createdBy?.id,
|
||||||
createdAt: DateTime.now(),
|
staffDisplayName: createdBy?.name,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
Future<void> initForm({
|
Future<void> initForm({
|
||||||
OperationModel? existingOperation,
|
OperationModel? existingOperation,
|
||||||
@@ -43,26 +44,37 @@ class OperationFormCubit extends Cubit<OperationFormState> {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
} else if (operationId != null) {
|
} else if (operationId != null) {
|
||||||
// Avendo separato i cubit, se ci passano solo l'ID lo scarichiamo dal DB
|
emit(state.copyWith(status: OperationFormStatus.loading));
|
||||||
final operation = await _repository.fetchOperationById(operationId);
|
try {
|
||||||
emit(
|
final operation = await _repository.fetchOperationById(operationId);
|
||||||
state.copyWith(
|
emit(
|
||||||
operation: operation,
|
state.copyWith(
|
||||||
status: OperationFormStatus.ready,
|
operation: operation,
|
||||||
),
|
status: OperationFormStatus.ready,
|
||||||
);
|
),
|
||||||
|
);
|
||||||
|
} on Exception catch (e) {
|
||||||
|
emit(
|
||||||
|
state.copyWith(
|
||||||
|
status: OperationFormStatus.failure,
|
||||||
|
errorMessage: e.toString(),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// NUOVA PRATICA: Creiamo un nuovo Batch UUID
|
// NUOVA PRATICA: Creiamo un nuovo Batch UUID
|
||||||
|
final currentStore = _sessionCubit.state.currentStore;
|
||||||
|
final companyId = _sessionCubit.state.company?.id ?? '';
|
||||||
|
final newOperation = state.operation.copyWith(
|
||||||
|
companyId: companyId,
|
||||||
|
storeId: currentStore?.id,
|
||||||
|
status: OperationStatus.success,
|
||||||
|
reference: '',
|
||||||
|
batchUuid: _uuid.v4(),
|
||||||
|
);
|
||||||
emit(
|
emit(
|
||||||
state.copyWith(
|
state.copyWith(
|
||||||
operation: OperationModel(
|
operation: newOperation,
|
||||||
storeId: _sessionCubit.state.currentStore?.id ?? '',
|
|
||||||
reference: '',
|
|
||||||
createdAt: DateTime.now(),
|
|
||||||
companyId: _sessionCubit.state.company!.id!,
|
|
||||||
status: OperationStatus.draft,
|
|
||||||
batchUuid: _uuid.v4(),
|
|
||||||
),
|
|
||||||
status: OperationFormStatus.ready,
|
status: OperationFormStatus.ready,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ class OperationsRepository {
|
|||||||
.from('operation')
|
.from('operation')
|
||||||
.select('''
|
.select('''
|
||||||
*,
|
*,
|
||||||
customer(name),
|
customer(*),
|
||||||
store(name),
|
store(name),
|
||||||
staff_member(name),
|
staff_member(name),
|
||||||
provider(name),
|
provider(name),
|
||||||
@@ -47,7 +47,7 @@ class OperationsRepository {
|
|||||||
.from('operation')
|
.from('operation')
|
||||||
.select('''
|
.select('''
|
||||||
*,
|
*,
|
||||||
customer(name),
|
customer(*),
|
||||||
store(name),
|
store(name),
|
||||||
provider(name),
|
provider(name),
|
||||||
model(name_with_brand),
|
model(name_with_brand),
|
||||||
|
|||||||
@@ -187,7 +187,9 @@ class _OperationFormScreenState extends State<OperationFormScreen> {
|
|||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: Text(
|
title: Text(
|
||||||
state.operation.id == null ? 'Nuova Pratica' : 'Modifica Pratica',
|
state.operation.id == null
|
||||||
|
? 'Nuova Pratica - Operatore: ${state.operation.staffDisplayName}'
|
||||||
|
: 'Modifica Pratica - Operatore: ${state.operation.staffDisplayName}',
|
||||||
),
|
),
|
||||||
// Mettiamo un piccolo indicatore visivo anche nella AppBar se non è OK
|
// Mettiamo un piccolo indicatore visivo anche nella AppBar se non è OK
|
||||||
actions:
|
actions:
|
||||||
@@ -570,8 +572,8 @@ class _OperationFormScreenState extends State<OperationFormScreen> {
|
|||||||
return Column(
|
return Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
_buildStaffSection(state),
|
/* _buildStaffSection(state),
|
||||||
const Divider(height: 50),
|
const Divider(height: 50), */
|
||||||
_buildOperationStatusSection(state),
|
_buildOperationStatusSection(state),
|
||||||
const Divider(height: 32),
|
const Divider(height: 32),
|
||||||
_buildCustomerSection(state),
|
_buildCustomerSection(state),
|
||||||
|
|||||||
@@ -1,5 +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/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';
|
||||||
@@ -113,7 +116,15 @@ class _OperationListScreenState extends State<OperationListScreen> {
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
floatingActionButton: FloatingActionButton(
|
floatingActionButton: FloatingActionButton(
|
||||||
onPressed: () => startNewOperation(context),
|
onPressed: () async {
|
||||||
|
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),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
42
lib/features/settings/blocs/settings_cubit.dart
Normal file
42
lib/features/settings/blocs/settings_cubit.dart
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
import 'package:equatable/equatable.dart';
|
||||||
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
import 'package:flux/core/blocs/session/session_cubit.dart';
|
||||||
|
import 'package:get_it/get_it.dart';
|
||||||
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
|
|
||||||
|
class SettingsState extends Equatable {
|
||||||
|
final bool isSingleUserMode;
|
||||||
|
|
||||||
|
const SettingsState({this.isSingleUserMode = false});
|
||||||
|
|
||||||
|
SettingsState copyWith({bool? isSingleUserMode}) {
|
||||||
|
return SettingsState(
|
||||||
|
isSingleUserMode: isSingleUserMode ?? this.isSingleUserMode,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Object?> get props => [isSingleUserMode];
|
||||||
|
}
|
||||||
|
|
||||||
|
class SettingsCubit extends Cubit<SettingsState> {
|
||||||
|
final SharedPreferences _prefs = GetIt.I.get<SharedPreferences>();
|
||||||
|
|
||||||
|
SettingsCubit() : super(const SettingsState()) {
|
||||||
|
final bool isSingleUserMode = _prefs.getBool('isSingleUserMode') ?? false;
|
||||||
|
final sessionCubit = GetIt.I.get<SessionCubit>();
|
||||||
|
sessionCubit.setIsSingleUserMode(isSingleUserMode);
|
||||||
|
emit(state.copyWith(isSingleUserMode: isSingleUserMode));
|
||||||
|
}
|
||||||
|
|
||||||
|
void toggleSingleUserMode() {
|
||||||
|
final bool isSingleUserMode = !state.isSingleUserMode;
|
||||||
|
GetIt.I.get<SharedPreferences>().setBool(
|
||||||
|
'isSingleUserMode',
|
||||||
|
isSingleUserMode,
|
||||||
|
);
|
||||||
|
final sessionCubit = GetIt.I.get<SessionCubit>();
|
||||||
|
sessionCubit.setIsSingleUserMode(isSingleUserMode);
|
||||||
|
emit(state.copyWith(isSingleUserMode: !state.isSingleUserMode));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,10 +4,11 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
|||||||
import 'package:flux/core/blocs/session/session_cubit.dart';
|
import 'package:flux/core/blocs/session/session_cubit.dart';
|
||||||
import 'package:flux/core/routes/routes.dart';
|
import 'package:flux/core/routes/routes.dart';
|
||||||
import 'package:flux/core/theme/theme.dart';
|
import 'package:flux/core/theme/theme.dart';
|
||||||
|
import 'package:flux/features/settings/blocs/settings_cubit.dart';
|
||||||
import 'package:go_router/go_router.dart';
|
import 'package:go_router/go_router.dart';
|
||||||
|
|
||||||
class SettingsView extends StatelessWidget {
|
class SettingsScreen extends StatelessWidget {
|
||||||
const SettingsView({super.key});
|
const SettingsScreen({super.key});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@@ -24,6 +25,14 @@ class SettingsView extends StatelessWidget {
|
|||||||
context: context,
|
context: context,
|
||||||
onTap: () {},
|
onTap: () {},
|
||||||
),
|
),
|
||||||
|
BlocBuilder<SettingsCubit, SettingsState>(
|
||||||
|
builder: (context, state) => CheckboxListTile(
|
||||||
|
value: state.isSingleUserMode,
|
||||||
|
title: const Text('Singolo Utente'),
|
||||||
|
onChanged: (_) =>
|
||||||
|
context.read<SettingsCubit>().toggleSingleUserMode(),
|
||||||
|
),
|
||||||
|
),
|
||||||
_settingsTile(
|
_settingsTile(
|
||||||
title: 'Impostazioni Azienda',
|
title: 'Impostazioni Azienda',
|
||||||
icon: Icons.business,
|
icon: Icons.business,
|
||||||
@@ -1,8 +1,11 @@
|
|||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:flux/core/blocs/session/session_cubit.dart';
|
import 'package:flux/core/blocs/session/session_cubit.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/staff/models/staff_member_model.dart';
|
||||||
import 'package:flux/features/tickets/models/ticket_model.dart';
|
import 'package:flux/features/tickets/models/ticket_model.dart';
|
||||||
import 'package:flux/features/tickets/data/ticket_repository.dart';
|
import 'package:flux/features/tickets/data/ticket_repository.dart';
|
||||||
|
import 'package:flux/features/tracking/data/tracking_repository.dart';
|
||||||
|
import 'package:flux/features/tracking/models/tracking_model.dart';
|
||||||
import 'package:get_it/get_it.dart';
|
import 'package:get_it/get_it.dart';
|
||||||
import 'ticket_form_state.dart';
|
import 'ticket_form_state.dart';
|
||||||
|
|
||||||
@@ -10,30 +13,35 @@ class TicketFormCubit extends Cubit<TicketFormState> {
|
|||||||
final TicketRepository _repository = GetIt.I.get<TicketRepository>();
|
final TicketRepository _repository = GetIt.I.get<TicketRepository>();
|
||||||
final SessionCubit _sessionCubit = GetIt.I.get<SessionCubit>();
|
final SessionCubit _sessionCubit = GetIt.I.get<SessionCubit>();
|
||||||
|
|
||||||
TicketFormCubit()
|
// Costruttore: prepariamo subito il ticket base con i dati di chi lo crea
|
||||||
|
TicketFormCubit({StaffMemberModel? createdBy, TicketModel? existingTicket})
|
||||||
: super(
|
: super(
|
||||||
// Inizializziamo con un ticket vuoto di default
|
TicketFormState(
|
||||||
TicketFormState(ticket: TicketModel.empty()),
|
// Se c'è un ticket esistente usa quello, ALTRIMENTI ne crea uno vuoto
|
||||||
|
// e ci stampa subito il nome del creatore!
|
||||||
|
ticket:
|
||||||
|
existingTicket ??
|
||||||
|
TicketModel.empty().copyWith(
|
||||||
|
createdById: createdBy?.id,
|
||||||
|
createdByName: createdBy?.name,
|
||||||
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
/// 1. INIZIALIZZAZIONE (Se stiamo modificando un ticket esistente)
|
/// 1. INIZIALIZZAZIONE
|
||||||
Future<void> initForm({String? id, TicketModel? existingTicket}) async {
|
Future<void> initForm({String? id, TicketModel? existingTicket}) async {
|
||||||
if (existingTicket != null) {
|
if (existingTicket != null) {
|
||||||
// SCENARIO 1 (App Native / Navigazione interna Web):
|
// SCENARIO 1: Abbiamo il ticket intero passato via record
|
||||||
// Abbiamo l'oggetto intero passato via 'extra'. Lo mostriamo all'istante!
|
|
||||||
emit(
|
emit(
|
||||||
state.copyWith(ticket: existingTicket, status: TicketFormStatus.ready),
|
state.copyWith(ticket: existingTicket, status: TicketFormStatus.ready),
|
||||||
);
|
);
|
||||||
} else if (id != null) {
|
} else if (id != null) {
|
||||||
// SCENARIO 2 (Web Refresh o Link condiviso):
|
// SCENARIO 2: QR CODE o Web Refresh! (Hai solo l'ID)
|
||||||
// L'utente ha premuto F5 su /tickets/form/123. L'extra è andato perso, ma abbiamo l'ID!
|
emit(state.copyWith(status: TicketFormStatus.loading));
|
||||||
emit(
|
|
||||||
state.copyWith(status: TicketFormStatus.loading),
|
|
||||||
); // Mostriamo uno spinner
|
|
||||||
try {
|
try {
|
||||||
final fetchedTicket = await _repository.getTicketById(
|
// Boom! Lo scarica dal database in tempo reale
|
||||||
id,
|
final fetchedTicket = await _repository.getTicketById(id);
|
||||||
); // Lo scarichiamo!
|
|
||||||
emit(
|
emit(
|
||||||
state.copyWith(ticket: fetchedTicket, status: TicketFormStatus.ready),
|
state.copyWith(ticket: fetchedTicket, status: TicketFormStatus.ready),
|
||||||
);
|
);
|
||||||
@@ -46,20 +54,17 @@ class TicketFormCubit extends Cubit<TicketFormState> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// SCENARIO 3 (Nuovo Ticket):
|
// SCENARIO 3: Nuovo Ticket
|
||||||
// È un nuovo ticket! Inseriamo i default base (Azienda, Negozio, Creatore)
|
|
||||||
final currentUser = _sessionCubit.state.currentStaffMember;
|
|
||||||
final currentStore = _sessionCubit.state.currentStore;
|
final currentStore = _sessionCubit.state.currentStore;
|
||||||
final companyId = _sessionCubit.state.company?.id ?? '';
|
final companyId = _sessionCubit.state.company?.id ?? '';
|
||||||
|
|
||||||
final newTicket = TicketModel.empty().copyWith(
|
// IL TRUCCO È QUI: Usiamo `state.ticket` invece di `TicketModel.empty()`.
|
||||||
|
// `state.ticket` HA GIÀ i dati di 'createdBy' settati nel costruttore!
|
||||||
|
final newTicket = state.ticket.copyWith(
|
||||||
companyId: companyId,
|
companyId: companyId,
|
||||||
storeId: currentStore?.id,
|
storeId: currentStore?.id,
|
||||||
createdById: currentUser?.id,
|
ticketStatus: TicketStatus.open, // <-- O il tuo status di default
|
||||||
createdByName: currentUser?.name,
|
ticketType: TicketType.repair,
|
||||||
// Impostiamo lo stato iniziale
|
|
||||||
ticketStatus: TicketStatus.open,
|
|
||||||
ticketType: TicketType.repair, // Default
|
|
||||||
);
|
);
|
||||||
|
|
||||||
emit(state.copyWith(ticket: newTicket, status: TicketFormStatus.ready));
|
emit(state.copyWith(ticket: newTicket, status: TicketFormStatus.ready));
|
||||||
@@ -219,4 +224,51 @@ class TicketFormCubit extends Cubit<TicketFormState> {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> takeInCharge({
|
||||||
|
required String staffId,
|
||||||
|
required String staffName,
|
||||||
|
}) async {
|
||||||
|
final currentTicket = state.ticket;
|
||||||
|
|
||||||
|
// Sicurezza: non possiamo prendere in carico un ticket fantasma
|
||||||
|
if (currentTicket.id == null || currentTicket.id!.isEmpty) return;
|
||||||
|
|
||||||
|
// 1. Prepariamo il ticket aggiornato
|
||||||
|
final updatedTicket = currentTicket.copyWith(
|
||||||
|
ticketStatus: TicketStatus
|
||||||
|
.inProgress, // Assumendo che tu abbia un enum per gli stati
|
||||||
|
assignedToId: staffId,
|
||||||
|
assignedToName: staffName,
|
||||||
|
);
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 2. Aggiorniamo il ticket sul Database (usa il tuo metodo esistente del repo)
|
||||||
|
await _repository.updateTicket(updatedTicket);
|
||||||
|
|
||||||
|
// 3. Spara il log automatico nella Timeline!
|
||||||
|
await GetIt.I.get<TrackingRepository>().logQuickEvent(
|
||||||
|
companyId: currentTicket.companyId,
|
||||||
|
message: "Ticket preso in carico. Inizio lavorazione.",
|
||||||
|
type: TrackingType.statusChange,
|
||||||
|
parentId: currentTicket.id!,
|
||||||
|
parentType: TrackingParentType.ticket,
|
||||||
|
staffId: staffId,
|
||||||
|
// Lo mettiamo pubblico (isInternal: false) così il cliente a casa vede che
|
||||||
|
// il suo dispositivo è ufficialmente sotto i ferri!
|
||||||
|
isInternal: false,
|
||||||
|
);
|
||||||
|
|
||||||
|
// 4. Aggiorniamo lo stato locale del Cubit per far scattare la UI
|
||||||
|
emit(state.copyWith(ticket: updatedTicket));
|
||||||
|
} catch (e) {
|
||||||
|
// Gestisci eventuali errori (es. mostrando una snackbar)
|
||||||
|
emit(
|
||||||
|
state.copyWith(
|
||||||
|
status: TicketFormStatus.failure,
|
||||||
|
errorMessage: 'Errore durante la presa in carico: $e',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,11 @@ import 'package:flux/features/tickets/blocs/ticket_form_state.dart';
|
|||||||
import 'package:flux/features/tickets/models/ticket_model.dart';
|
import 'package:flux/features/tickets/models/ticket_model.dart';
|
||||||
import 'package:flux/core/widgets/shared_forms/staff_section.dart';
|
import 'package:flux/core/widgets/shared_forms/staff_section.dart';
|
||||||
import 'package:flux/features/tickets/models/ticket_status_extension.dart';
|
import 'package:flux/features/tickets/models/ticket_status_extension.dart';
|
||||||
|
import 'package:flux/features/tickets/ui/ticket_timeline_section.dart';
|
||||||
|
import 'package:flux/features/tickets/ui/ticket_workspace_screen.dart';
|
||||||
import 'package:flux/features/tickets/utils/ticket_pdf_service.dart';
|
import 'package:flux/features/tickets/utils/ticket_pdf_service.dart';
|
||||||
|
import 'package:flux/features/tracking/blocs/tracking_cubit.dart';
|
||||||
|
import 'package:flux/features/tracking/models/tracking_model.dart';
|
||||||
import 'package:get_it/get_it.dart';
|
import 'package:get_it/get_it.dart';
|
||||||
import 'package:printing/printing.dart';
|
import 'package:printing/printing.dart';
|
||||||
|
|
||||||
@@ -293,9 +297,88 @@ class _TicketFormScreenState extends State<TicketFormScreen> {
|
|||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: Text(
|
title: Text(
|
||||||
ticket.id == null ? 'Nuova Scheda Assistenza' : 'Modifica Scheda',
|
ticket.id == null
|
||||||
|
? 'Nuovo Ticket - Operatore: ${state.ticket.createdByName}'
|
||||||
|
: 'Modifica Ticket - Operatore: ${state.ticket.createdByName}',
|
||||||
),
|
),
|
||||||
actions: [
|
actions: [
|
||||||
|
BlocBuilder<TicketFormCubit, TicketFormState>(
|
||||||
|
builder: (context, state) {
|
||||||
|
final ticket = state.ticket;
|
||||||
|
|
||||||
|
// Se il ticket non è ancora salvato, niente azioni rapide
|
||||||
|
if (ticket.id == null || ticket.id!.isEmpty) {
|
||||||
|
return const SizedBox.shrink();
|
||||||
|
}
|
||||||
|
|
||||||
|
// CONDIZIONE A: Da iniziare
|
||||||
|
if (ticket.ticketStatus == TicketStatus.open ||
|
||||||
|
ticket.ticketStatus == TicketStatus.inProgress) {
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(
|
||||||
|
horizontal: 16.0,
|
||||||
|
vertical: 8.0,
|
||||||
|
),
|
||||||
|
child: FilledButton.icon(
|
||||||
|
style: FilledButton.styleFrom(
|
||||||
|
backgroundColor:
|
||||||
|
Colors.amber.shade700, // Colore Action
|
||||||
|
),
|
||||||
|
onPressed: () {
|
||||||
|
final currentUserId = GetIt.I
|
||||||
|
.get<SessionCubit>()
|
||||||
|
.state
|
||||||
|
.currentStaffMember!
|
||||||
|
.id!;
|
||||||
|
final currentUserName = GetIt.I
|
||||||
|
.get<SessionCubit>()
|
||||||
|
.state
|
||||||
|
.currentStaffMember!
|
||||||
|
.name;
|
||||||
|
|
||||||
|
context.read<TicketFormCubit>().takeInCharge(
|
||||||
|
staffId: currentUserId,
|
||||||
|
staffName: currentUserName,
|
||||||
|
);
|
||||||
|
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (_) =>
|
||||||
|
TicketWorkspaceScreen(ticket: ticket),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
icon: const Icon(Icons.play_arrow, color: Colors.white),
|
||||||
|
label: const Text(
|
||||||
|
'Prendi in Carico',
|
||||||
|
style: TextStyle(color: Colors.white),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
// CONDIZIONE B: Già in lavorazione
|
||||||
|
else if (ticket.ticketStatus == TicketStatus.inProgress) {
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(
|
||||||
|
horizontal: 16.0,
|
||||||
|
vertical: 8.0,
|
||||||
|
),
|
||||||
|
child: FilledButton.icon(
|
||||||
|
onPressed: () {
|
||||||
|
// Naviga direttamente alla schermata di lavorazione
|
||||||
|
// Navigator.push(context, MaterialPageRoute(builder: (_) => TicketWorkspaceScreen(ticket: ticket)));
|
||||||
|
},
|
||||||
|
icon: const Icon(Icons.handyman),
|
||||||
|
label: const Text('Vai a Lavorazione'),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Se è chiuso o in altri stati strani, nascondiamo il bottone
|
||||||
|
return const SizedBox.shrink();
|
||||||
|
},
|
||||||
|
),
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(right: 16.0),
|
padding: const EdgeInsets.only(right: 16.0),
|
||||||
child: Chip(
|
child: Chip(
|
||||||
@@ -409,7 +492,11 @@ class _TicketFormScreenState extends State<TicketFormScreen> {
|
|||||||
return Row(
|
return Row(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Expanded(child: Column(children: [_cardAnagrafica(ticket)])),
|
Expanded(
|
||||||
|
child: Column(
|
||||||
|
children: [_cardTimeline(ticket), _cardAnagrafica(ticket)],
|
||||||
|
),
|
||||||
|
),
|
||||||
const SizedBox(width: 24),
|
const SizedBox(width: 24),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Column(
|
child: Column(
|
||||||
@@ -441,7 +528,11 @@ class _TicketFormScreenState extends State<TicketFormScreen> {
|
|||||||
const SizedBox(width: 24),
|
const SizedBox(width: 24),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [_cardDettagli(ticket), _cardCosti(ticket)],
|
children: [
|
||||||
|
_cardTimeline(ticket),
|
||||||
|
_cardDettagli(ticket),
|
||||||
|
_cardCosti(ticket),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@@ -451,6 +542,7 @@ class _TicketFormScreenState extends State<TicketFormScreen> {
|
|||||||
return Column(
|
return Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
children: [
|
children: [
|
||||||
|
_cardTimeline(ticket),
|
||||||
_cardAnagrafica(ticket),
|
_cardAnagrafica(ticket),
|
||||||
_cardDispositivi(ticket),
|
_cardDispositivi(ticket),
|
||||||
_cardDettagli(ticket),
|
_cardDettagli(ticket),
|
||||||
@@ -461,7 +553,7 @@ class _TicketFormScreenState extends State<TicketFormScreen> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- LE 5 CARD (MODULARIZZATE E COLORATE) ---
|
// --- LE 6 CARD (MODULARIZZATE E COLORATE) ---
|
||||||
|
|
||||||
Widget _cardAnagrafica(TicketModel ticket) {
|
Widget _cardAnagrafica(TicketModel ticket) {
|
||||||
return _buildCard(
|
return _buildCard(
|
||||||
@@ -469,7 +561,7 @@ class _TicketFormScreenState extends State<TicketFormScreen> {
|
|||||||
icon: Icons.person,
|
icon: Icons.person,
|
||||||
themeColor: Colors.indigo,
|
themeColor: Colors.indigo,
|
||||||
children: [
|
children: [
|
||||||
StaffSection(
|
/* StaffSection(
|
||||||
label: 'Creato Da',
|
label: 'Creato Da',
|
||||||
staffId: ticket.createdById,
|
staffId: ticket.createdById,
|
||||||
staffName: ticket.createdByName,
|
staffName: ticket.createdByName,
|
||||||
@@ -477,7 +569,7 @@ class _TicketFormScreenState extends State<TicketFormScreen> {
|
|||||||
.read<TicketFormCubit>()
|
.read<TicketFormCubit>()
|
||||||
.updateCreator(staffId: staff.id!, staffName: staff.name),
|
.updateCreator(staffId: staff.id!, staffName: staff.name),
|
||||||
),
|
),
|
||||||
const Divider(height: 32),
|
const Divider(height: 32), */
|
||||||
SharedCustomerSection(
|
SharedCustomerSection(
|
||||||
customer: ticket.customer,
|
customer: ticket.customer,
|
||||||
onCustomerSelected: (customer) =>
|
onCustomerSelected: (customer) =>
|
||||||
@@ -781,6 +873,51 @@ class _TicketFormScreenState extends State<TicketFormScreen> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Widget _cardTimeline(TicketModel ticket) {
|
||||||
|
// Se il ticket è nuovo (non ha ancora un ID salvato a DB), nascondiamo la timeline
|
||||||
|
if (ticket.id == null || ticket.id!.isEmpty) {
|
||||||
|
return const SizedBox.shrink();
|
||||||
|
}
|
||||||
|
|
||||||
|
return _buildCard(
|
||||||
|
title: 'Timeline & Note',
|
||||||
|
icon: Icons.history,
|
||||||
|
themeColor: Colors.blueGrey,
|
||||||
|
children: [
|
||||||
|
BlocProvider(
|
||||||
|
create: (context) => TrackingCubit(
|
||||||
|
parentId: ticket.id!,
|
||||||
|
parentType: TrackingParentType.ticket,
|
||||||
|
),
|
||||||
|
child: BlocBuilder<TrackingCubit, TrackingState>(
|
||||||
|
builder: (context, state) {
|
||||||
|
if (state.isLoading && state.logs.isEmpty) {
|
||||||
|
return const Center(child: CircularProgressIndicator());
|
||||||
|
}
|
||||||
|
|
||||||
|
return TicketTimelineSection(
|
||||||
|
logs: state.logs,
|
||||||
|
onAddNote: (message, isInternal) {
|
||||||
|
// Recupera l'ID dello staff loggato dal tuo auth state
|
||||||
|
// final currentStaffId = ...
|
||||||
|
context.read<TrackingCubit>().addManualNote(
|
||||||
|
message,
|
||||||
|
isInternal,
|
||||||
|
staffId: GetIt.I
|
||||||
|
.get<SessionCubit>()
|
||||||
|
.state
|
||||||
|
.currentStaffMember
|
||||||
|
?.id,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// --- WIDGET BASE PER LA CARD ---
|
// --- WIDGET BASE PER LA CARD ---
|
||||||
Widget _buildCard({
|
Widget _buildCard({
|
||||||
required String title,
|
required String title,
|
||||||
|
|||||||
@@ -1,10 +1,14 @@
|
|||||||
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/blocs/session/session_cubit.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/tickets/blocs/ticket_list_cubit.dart';
|
import 'package:flux/features/tickets/blocs/ticket_list_cubit.dart';
|
||||||
import 'package:flux/features/tickets/blocs/ticket_list_state.dart';
|
import 'package:flux/features/tickets/blocs/ticket_list_state.dart';
|
||||||
import 'package:flux/features/tickets/models/ticket_model.dart';
|
import 'package:flux/features/tickets/models/ticket_model.dart';
|
||||||
import 'package:flux/features/tickets/models/ticket_status_extension.dart';
|
import 'package:flux/features/tickets/models/ticket_status_extension.dart';
|
||||||
|
import 'package:flux/features/tickets/ui/ticket_form_screen.dart';
|
||||||
import 'package:go_router/go_router.dart';
|
import 'package:go_router/go_router.dart';
|
||||||
|
|
||||||
class TicketListScreen extends StatefulWidget {
|
class TicketListScreen extends StatefulWidget {
|
||||||
@@ -148,11 +152,17 @@ class _TicketListScreenState extends State<TicketListScreen> {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
floatingActionButton: FloatingActionButton.extended(
|
floatingActionButton: FloatingActionButton.extended(
|
||||||
onPressed: () {
|
|
||||||
context.pushNamed(Routes.ticketForm, pathParameters: {'id': 'new'});
|
|
||||||
},
|
|
||||||
icon: const Icon(Icons.add),
|
icon: const Icon(Icons.add),
|
||||||
label: const Text('Nuovo Ticket'),
|
label: const Text('Nuovo Ticket'),
|
||||||
|
onPressed: () async {
|
||||||
|
StaffMemberModel? createdBy = await getStaffMember(context);
|
||||||
|
if (createdBy == null || !context.mounted) return;
|
||||||
|
context.pushNamed(
|
||||||
|
Routes.ticketForm,
|
||||||
|
pathParameters: {'id': 'new'},
|
||||||
|
extra: (createdBy: createdBy, ticket: null),
|
||||||
|
);
|
||||||
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
278
lib/features/tickets/ui/ticket_timeline_section.dart
Normal file
278
lib/features/tickets/ui/ticket_timeline_section.dart
Normal file
@@ -0,0 +1,278 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flux/features/tracking/models/tracking_model.dart';
|
||||||
|
|
||||||
|
class TicketTimelineSection extends StatefulWidget {
|
||||||
|
final List<TrackingModel> logs;
|
||||||
|
final void Function(String message, bool isInternal) onAddNote;
|
||||||
|
|
||||||
|
const TicketTimelineSection({
|
||||||
|
super.key,
|
||||||
|
required this.logs,
|
||||||
|
required this.onAddNote,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<TicketTimelineSection> createState() => _TicketTimelineSectionState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _TicketTimelineSectionState extends State<TicketTimelineSection> {
|
||||||
|
final TextEditingController _textController = TextEditingController();
|
||||||
|
bool _isInternal = true; // Di default blindiamo tutto a uso interno!
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_textController.dispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
void _submitNote() {
|
||||||
|
final text = _textController.text.trim();
|
||||||
|
if (text.isNotEmpty) {
|
||||||
|
widget.onAddNote(text, _isInternal);
|
||||||
|
_textController.clear();
|
||||||
|
// Chiudiamo la tastiera se siamo su mobile
|
||||||
|
FocusScope.of(context).unfocus();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final theme = Theme.of(context);
|
||||||
|
|
||||||
|
return Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
|
children: [
|
||||||
|
// --- ZONA INPUT ---
|
||||||
|
Container(
|
||||||
|
padding: const EdgeInsets.all(12),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: theme.colorScheme.surfaceContainerHighest.withValues(
|
||||||
|
alpha: 0.3,
|
||||||
|
),
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
border: Border.all(color: theme.dividerColor),
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: TextField(
|
||||||
|
controller: _textController,
|
||||||
|
decoration: const InputDecoration(
|
||||||
|
hintText: 'Scrivi un aggiornamento...',
|
||||||
|
border: InputBorder.none,
|
||||||
|
isDense: true,
|
||||||
|
),
|
||||||
|
textInputAction: TextInputAction.send,
|
||||||
|
onSubmitted: (_) => _submitNote(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
IconButton.filled(
|
||||||
|
onPressed: _submitNote,
|
||||||
|
icon: const Icon(Icons.send, size: 20),
|
||||||
|
tooltip: 'Invia',
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const Divider(height: 16),
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Icon(
|
||||||
|
_isInternal ? Icons.lock : Icons.public,
|
||||||
|
size: 16,
|
||||||
|
color: _isInternal
|
||||||
|
? Colors.amber.shade700
|
||||||
|
: Colors.green,
|
||||||
|
),
|
||||||
|
const SizedBox(width: 8),
|
||||||
|
Text(
|
||||||
|
_isInternal
|
||||||
|
? 'Nota Interna (Privata)'
|
||||||
|
: 'Visibile al Cliente',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 12,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color: _isInternal
|
||||||
|
? Colors.amber.shade700
|
||||||
|
: Colors.green,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
Switch(
|
||||||
|
value: _isInternal,
|
||||||
|
activeThumbColor: Colors.amber.shade700,
|
||||||
|
activeTrackColor: Colors.amber,
|
||||||
|
inactiveThumbColor: Colors.green,
|
||||||
|
inactiveTrackColor: Colors.green.withValues(alpha: 0.2),
|
||||||
|
onChanged: (val) {
|
||||||
|
setState(() {
|
||||||
|
_isInternal = val;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
|
||||||
|
const SizedBox(height: 24),
|
||||||
|
|
||||||
|
// --- TIMELINE SCROLLABILE ---
|
||||||
|
if (widget.logs.isEmpty)
|
||||||
|
const Padding(
|
||||||
|
padding: EdgeInsets.all(32.0),
|
||||||
|
child: Center(
|
||||||
|
child: Text(
|
||||||
|
'Nessun evento registrato.',
|
||||||
|
style: TextStyle(color: Colors.grey),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
else
|
||||||
|
ConstrainedBox(
|
||||||
|
constraints: const BoxConstraints(
|
||||||
|
maxHeight: 400,
|
||||||
|
), // Limite di altezza
|
||||||
|
child: ListView.builder(
|
||||||
|
shrinkWrap: true,
|
||||||
|
itemCount: widget.logs.length,
|
||||||
|
itemBuilder: (context, index) {
|
||||||
|
final log = widget.logs[index];
|
||||||
|
final isLast = index == widget.logs.length - 1;
|
||||||
|
|
||||||
|
return IntrinsicHeight(
|
||||||
|
child: Row(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
// --- LINEA E PALLINO ---
|
||||||
|
SizedBox(
|
||||||
|
width: 30,
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
margin: const EdgeInsets.only(top: 4),
|
||||||
|
width: 14,
|
||||||
|
height: 14,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: _getEventColor(log.eventType),
|
||||||
|
shape: BoxShape.circle,
|
||||||
|
border: Border.all(
|
||||||
|
color: theme.scaffoldBackgroundColor,
|
||||||
|
width: 2,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (!isLast)
|
||||||
|
Expanded(
|
||||||
|
child: Container(
|
||||||
|
width: 2,
|
||||||
|
color: theme.dividerColor,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
|
||||||
|
// --- CONTENUTO EVENTO ---
|
||||||
|
Expanded(
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.only(bottom: 24.0),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
log.staffName ?? 'Sistema',
|
||||||
|
style: const TextStyle(
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
fontSize: 13,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 8),
|
||||||
|
Text(
|
||||||
|
_formatDate(log.createdAt),
|
||||||
|
style: theme.textTheme.bodySmall?.copyWith(
|
||||||
|
color: Colors.grey,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (!log.isInternal) ...[
|
||||||
|
const Spacer(),
|
||||||
|
Container(
|
||||||
|
padding: const EdgeInsets.symmetric(
|
||||||
|
horizontal: 6,
|
||||||
|
vertical: 2,
|
||||||
|
),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.green.withValues(
|
||||||
|
alpha: 0.1,
|
||||||
|
),
|
||||||
|
borderRadius: BorderRadius.circular(4),
|
||||||
|
border: Border.all(
|
||||||
|
color: Colors.green.withValues(
|
||||||
|
alpha: 0.3,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: const Text(
|
||||||
|
"PUBBLICO",
|
||||||
|
style: TextStyle(
|
||||||
|
color: Colors.green,
|
||||||
|
fontSize: 9,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 6),
|
||||||
|
Text(
|
||||||
|
log.message,
|
||||||
|
style: const TextStyle(fontSize: 14),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Color _getEventColor(TrackingType type) {
|
||||||
|
switch (type) {
|
||||||
|
case TrackingType.statusChange:
|
||||||
|
return Colors.blue;
|
||||||
|
case TrackingType.assignment:
|
||||||
|
return Colors.purple;
|
||||||
|
case TrackingType.systemAlert:
|
||||||
|
return Colors.redAccent;
|
||||||
|
case TrackingType.customerContact:
|
||||||
|
return Colors.teal;
|
||||||
|
case TrackingType.manualNote:
|
||||||
|
// ignore: unreachable_switch_default
|
||||||
|
default:
|
||||||
|
return Colors.amber.shade600;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String _formatDate(DateTime date) {
|
||||||
|
final day = date.day.toString().padLeft(2, '0');
|
||||||
|
final month = date.month.toString().padLeft(2, '0');
|
||||||
|
final hour = date.hour.toString().padLeft(2, '0');
|
||||||
|
final minute = date.minute.toString().padLeft(2, '0');
|
||||||
|
return "$day/$month - $hour:$minute";
|
||||||
|
}
|
||||||
|
}
|
||||||
251
lib/features/tickets/ui/ticket_workspace_screen.dart
Normal file
251
lib/features/tickets/ui/ticket_workspace_screen.dart
Normal file
@@ -0,0 +1,251 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
// Importa il tuo TicketModel, Cubit, ecc.
|
||||||
|
|
||||||
|
class TicketWorkspaceScreen extends StatelessWidget {
|
||||||
|
// Passiamo il ticket attuale per avere i dati (o il Cubit se preferisci)
|
||||||
|
final dynamic ticket; // Sostituisci con TicketModel
|
||||||
|
|
||||||
|
const TicketWorkspaceScreen({super.key, required this.ticket});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final theme = Theme.of(context);
|
||||||
|
|
||||||
|
return Scaffold(
|
||||||
|
appBar: AppBar(
|
||||||
|
title: const Text('Banco di Lavoro'),
|
||||||
|
backgroundColor: theme.colorScheme.inversePrimary,
|
||||||
|
centerTitle: true,
|
||||||
|
),
|
||||||
|
// SafeArea in basso per ospitare i bottoni fissi
|
||||||
|
bottomNavigationBar: SafeArea(child: _buildBottomActions(context)),
|
||||||
|
body: SingleChildScrollView(
|
||||||
|
padding: const EdgeInsets.all(24.0),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
|
children: [
|
||||||
|
_buildDeviceHeader(theme),
|
||||||
|
const SizedBox(height: 24),
|
||||||
|
_buildDefectRecap(theme),
|
||||||
|
const SizedBox(height: 32),
|
||||||
|
_buildOperationsSection(theme),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- 1. HEADER DISPOSITIVO E PASSWORD ---
|
||||||
|
Widget _buildDeviceHeader(ThemeData theme) {
|
||||||
|
return Card(
|
||||||
|
elevation: 0,
|
||||||
|
color: theme.colorScheme.primaryContainer.withValues(alpha: 0.4),
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(16),
|
||||||
|
side: BorderSide(
|
||||||
|
color: theme.colorScheme.primary.withValues(alpha: 0.2),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.all(20.0),
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
'DISPOSITIVO IN LAVORAZIONE',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 12,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color: theme.colorScheme.primary,
|
||||||
|
letterSpacing: 1.2,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 8),
|
||||||
|
Text(
|
||||||
|
ticket.deviceModel ??
|
||||||
|
'Modello Sconosciuto', // Es: "iPhone 13 Pro"
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 24,
|
||||||
|
fontWeight: FontWeight.w800,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
// IL DATO PIÙ CERCATO DAI TECNICI: LA PASSWORD
|
||||||
|
Container(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: theme.colorScheme.surface,
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
border: Border.all(color: theme.dividerColor),
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
const Text(
|
||||||
|
'PIN / SBLOCCO',
|
||||||
|
style: TextStyle(fontSize: 10, color: Colors.grey),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 4),
|
||||||
|
Text(
|
||||||
|
ticket.unlockPassword?.isNotEmpty == true
|
||||||
|
? ticket.unlockPassword!
|
||||||
|
: 'Nessuno',
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 20,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
letterSpacing: 2,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- 2. RECAP DIFETTO ---
|
||||||
|
Widget _buildDefectRecap(ThemeData theme) {
|
||||||
|
return Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
const Row(
|
||||||
|
children: [
|
||||||
|
Icon(Icons.warning_amber_rounded, color: Colors.orange),
|
||||||
|
SizedBox(width: 8),
|
||||||
|
Text(
|
||||||
|
'Difetto Segnalato',
|
||||||
|
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 12),
|
||||||
|
Container(
|
||||||
|
width: double.infinity,
|
||||||
|
padding: const EdgeInsets.all(16),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: theme.colorScheme.surfaceContainerHighest.withValues(
|
||||||
|
alpha: 0.3,
|
||||||
|
),
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
border: Border.all(color: theme.dividerColor),
|
||||||
|
),
|
||||||
|
child: Text(
|
||||||
|
ticket.defectDescription ?? 'Nessuna descrizione inserita.',
|
||||||
|
style: const TextStyle(fontSize: 16, height: 1.5),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- 3. SEZIONE COSTI E RICAMBI (Mockup) ---
|
||||||
|
Widget _buildOperationsSection(ThemeData theme) {
|
||||||
|
return Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
const Text(
|
||||||
|
'Ricambi e Manodopera',
|
||||||
|
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
|
||||||
|
),
|
||||||
|
TextButton.icon(
|
||||||
|
onPressed: () {
|
||||||
|
// TODO: Apri modal per aggiungere una riga di costo
|
||||||
|
},
|
||||||
|
icon: const Icon(Icons.add),
|
||||||
|
label: const Text('Aggiungi Voce'),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 12),
|
||||||
|
// Qui ci andrà un ListView.builder collegato alla tabella dei costi/operazioni
|
||||||
|
Container(
|
||||||
|
padding: const EdgeInsets.all(32),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
border: Border.all(
|
||||||
|
color: theme.dividerColor,
|
||||||
|
style: BorderStyle.solid,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: const Center(
|
||||||
|
child: Text(
|
||||||
|
'Nessun ricambio o costo inserito.\nClicca su "Aggiungi Voce" per iniziare.',
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: TextStyle(color: Colors.grey),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- 4. BOTTONI AZIONE FINALI (In basso) ---
|
||||||
|
Widget _buildBottomActions(BuildContext context) {
|
||||||
|
return Container(
|
||||||
|
padding: const EdgeInsets.all(16.0),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Theme.of(context).scaffoldBackgroundColor,
|
||||||
|
boxShadow: [
|
||||||
|
BoxShadow(
|
||||||
|
color: Colors.black.withValues(alpha: 0.05),
|
||||||
|
blurRadius: 10,
|
||||||
|
offset: const Offset(0, -5),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
// Bottone Pausa / Attesa Ricambi
|
||||||
|
Expanded(
|
||||||
|
flex: 1,
|
||||||
|
child: OutlinedButton.icon(
|
||||||
|
style: OutlinedButton.styleFrom(
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 16),
|
||||||
|
foregroundColor: Colors.orange.shade700,
|
||||||
|
side: BorderSide(color: Colors.orange.shade700),
|
||||||
|
),
|
||||||
|
onPressed: () {
|
||||||
|
// TODO: Logica Metti in Pausa
|
||||||
|
},
|
||||||
|
icon: const Icon(Icons.pause),
|
||||||
|
label: const Text(
|
||||||
|
'Metti in Pausa',
|
||||||
|
style: TextStyle(fontWeight: FontWeight.bold),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 12),
|
||||||
|
// Bottone Completa
|
||||||
|
Expanded(
|
||||||
|
flex: 2,
|
||||||
|
child: FilledButton.icon(
|
||||||
|
style: FilledButton.styleFrom(
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 16),
|
||||||
|
backgroundColor: Colors.green.shade600,
|
||||||
|
),
|
||||||
|
onPressed: () {
|
||||||
|
// TODO: Logica Completa Riparazione
|
||||||
|
},
|
||||||
|
icon: const Icon(Icons.check_circle_outline),
|
||||||
|
label: const Text(
|
||||||
|
'COMPLETA RIPARAZIONE',
|
||||||
|
style: TextStyle(fontWeight: FontWeight.bold, letterSpacing: 1),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
54
lib/features/tracking/blocs/tracking_cubit.dart
Normal file
54
lib/features/tracking/blocs/tracking_cubit.dart
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
import 'package:flux/core/blocs/session/session_cubit.dart';
|
||||||
|
import 'package:flux/features/tracking/data/tracking_repository.dart';
|
||||||
|
import 'package:flux/features/tracking/models/tracking_model.dart';
|
||||||
|
import 'package:get_it/get_it.dart';
|
||||||
|
|
||||||
|
// Stati base: initial, loading, loaded, error
|
||||||
|
class TrackingState {
|
||||||
|
final bool isLoading;
|
||||||
|
final List<TrackingModel> logs;
|
||||||
|
|
||||||
|
TrackingState({this.isLoading = false, this.logs = const []});
|
||||||
|
}
|
||||||
|
|
||||||
|
class TrackingCubit extends Cubit<TrackingState> {
|
||||||
|
final TrackingRepository _repo = GetIt.I.get<TrackingRepository>();
|
||||||
|
final String parentId;
|
||||||
|
final TrackingParentType parentType;
|
||||||
|
final String companyId = GetIt.I.get<SessionCubit>().state.company!.id!;
|
||||||
|
|
||||||
|
TrackingCubit({required this.parentId, required this.parentType})
|
||||||
|
: super(TrackingState()) {
|
||||||
|
loadTrackings();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> loadTrackings() async {
|
||||||
|
emit(TrackingState(isLoading: true, logs: state.logs));
|
||||||
|
final trackings = await _repo.getTrackingsByParent(
|
||||||
|
parentId: parentId,
|
||||||
|
parentType: parentType,
|
||||||
|
);
|
||||||
|
emit(TrackingState(isLoading: false, logs: trackings));
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> addManualNote(
|
||||||
|
String message,
|
||||||
|
bool isInternal, {
|
||||||
|
String? staffId,
|
||||||
|
}) async {
|
||||||
|
// Aggiungiamo un feedback visivo immediato (Optimistic UI) se vogliamo,
|
||||||
|
// oppure semplicemente mostriamo il loading
|
||||||
|
await _repo.logQuickEvent(
|
||||||
|
companyId: companyId,
|
||||||
|
message: message,
|
||||||
|
type: TrackingType.manualNote,
|
||||||
|
parentId: parentId!,
|
||||||
|
parentType: parentType,
|
||||||
|
staffId: staffId,
|
||||||
|
isInternal: isInternal,
|
||||||
|
);
|
||||||
|
// Ricarichiamo la lista fresca dal server
|
||||||
|
await loadTrackings();
|
||||||
|
}
|
||||||
|
}
|
||||||
57
lib/features/tracking/data/tracking_repository.dart
Normal file
57
lib/features/tracking/data/tracking_repository.dart
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
import 'package:flux/features/tracking/models/tracking_model.dart';
|
||||||
|
import 'package:get_it/get_it.dart';
|
||||||
|
import 'package:supabase_flutter/supabase_flutter.dart';
|
||||||
|
|
||||||
|
class TrackingRepository {
|
||||||
|
final SupabaseClient _supabase = GetIt.I.get<SupabaseClient>();
|
||||||
|
|
||||||
|
TrackingRepository();
|
||||||
|
|
||||||
|
/// Recupera la cronologia di un'entità (Ticket o Operazione)
|
||||||
|
Future<List<TrackingModel>> getTrackingsByParent({
|
||||||
|
required String parentId, // <-- Reso obbligatorio
|
||||||
|
required TrackingParentType parentType, // <-- Reso obbligatorio
|
||||||
|
}) async {
|
||||||
|
// Facciamo la query con la JOIN per recuperare il nome dello staff al volo
|
||||||
|
final response = await _supabase
|
||||||
|
.from('tracking')
|
||||||
|
.select('*, staff_member(name)')
|
||||||
|
.eq('parent_id', parentId)
|
||||||
|
.eq('parent_type', parentType.name)
|
||||||
|
.order(
|
||||||
|
'created_at',
|
||||||
|
ascending: true,
|
||||||
|
); // ascending: true per avere la timeline dall'alto (vecchi) al basso (nuovi)
|
||||||
|
|
||||||
|
return response.map((map) => TrackingModel.fromMap(map)).toList();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Inserisce un nuovo evento di tracking
|
||||||
|
Future<void> logEvent(TrackingModel tracking) async {
|
||||||
|
await _supabase.from('tracking').insert(tracking.toMap());
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Metodo helper rapido per loggare un cambio di stato o una nota
|
||||||
|
Future<void> logQuickEvent({
|
||||||
|
required String companyId,
|
||||||
|
required String message,
|
||||||
|
required TrackingType type,
|
||||||
|
required String parentId, // <-- Reso obbligatorio
|
||||||
|
required TrackingParentType parentType, // <-- Reso obbligatorio
|
||||||
|
String? staffId,
|
||||||
|
bool isInternal = true,
|
||||||
|
}) async {
|
||||||
|
final log = TrackingModel(
|
||||||
|
createdAt:
|
||||||
|
DateTime.now(), // Questo verrà ignorato dal toMap in fase di insert, ma serve al modello
|
||||||
|
companyId: companyId,
|
||||||
|
staffId: staffId,
|
||||||
|
parentId: parentId,
|
||||||
|
parentType: parentType,
|
||||||
|
eventType: type,
|
||||||
|
isInternal: isInternal,
|
||||||
|
message: message,
|
||||||
|
);
|
||||||
|
await logEvent(log);
|
||||||
|
}
|
||||||
|
}
|
||||||
132
lib/features/tracking/models/tracking_model.dart
Normal file
132
lib/features/tracking/models/tracking_model.dart
Normal file
@@ -0,0 +1,132 @@
|
|||||||
|
import 'package:equatable/equatable.dart';
|
||||||
|
|
||||||
|
enum TrackingType {
|
||||||
|
statusChange,
|
||||||
|
manualNote,
|
||||||
|
systemAlert,
|
||||||
|
customerContact,
|
||||||
|
assignment;
|
||||||
|
|
||||||
|
static TrackingType fromString(String value) {
|
||||||
|
return TrackingType.values.firstWhere(
|
||||||
|
(e) => e.name == value,
|
||||||
|
orElse: () => TrackingType.manualNote,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
enum TrackingParentType {
|
||||||
|
ticket,
|
||||||
|
operation;
|
||||||
|
|
||||||
|
String get value => name;
|
||||||
|
|
||||||
|
static TrackingParentType fromString(String val) {
|
||||||
|
return TrackingParentType.values.firstWhere(
|
||||||
|
(e) => e.name == val,
|
||||||
|
orElse: () => TrackingParentType.ticket, // Default di sicurezza
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class TrackingModel extends Equatable {
|
||||||
|
final String? id;
|
||||||
|
final DateTime createdAt;
|
||||||
|
final String companyId;
|
||||||
|
final String? staffId;
|
||||||
|
final String? staffName; // Per non fare mille join, lo prendiamo dal repo
|
||||||
|
final String parentId;
|
||||||
|
final TrackingParentType parentType;
|
||||||
|
final TrackingType eventType;
|
||||||
|
final bool isInternal;
|
||||||
|
final String message;
|
||||||
|
|
||||||
|
const TrackingModel({
|
||||||
|
this.id,
|
||||||
|
required this.createdAt,
|
||||||
|
required this.companyId,
|
||||||
|
this.staffId,
|
||||||
|
this.staffName,
|
||||||
|
required this.parentId,
|
||||||
|
required this.parentType,
|
||||||
|
required this.eventType,
|
||||||
|
required this.isInternal,
|
||||||
|
required this.message,
|
||||||
|
});
|
||||||
|
|
||||||
|
TrackingModel copyWith({
|
||||||
|
String? id,
|
||||||
|
DateTime? createdAt,
|
||||||
|
String? companyId,
|
||||||
|
String? staffId,
|
||||||
|
String? staffName,
|
||||||
|
TrackingParentType? parentType,
|
||||||
|
String? parentId,
|
||||||
|
TrackingType? eventType,
|
||||||
|
bool? isInternal,
|
||||||
|
String? message,
|
||||||
|
}) {
|
||||||
|
return TrackingModel(
|
||||||
|
id: id ?? this.id,
|
||||||
|
createdAt: createdAt ?? this.createdAt,
|
||||||
|
companyId: companyId ?? this.companyId,
|
||||||
|
staffId: staffId ?? this.staffId,
|
||||||
|
staffName: staffName ?? this.staffName,
|
||||||
|
parentId: parentId ?? this.parentId,
|
||||||
|
parentType: parentType ?? this.parentType,
|
||||||
|
eventType: eventType ?? this.eventType,
|
||||||
|
isInternal: isInternal ?? this.isInternal,
|
||||||
|
message: message ?? this.message,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
factory TrackingModel.fromMap(Map<String, dynamic> map) {
|
||||||
|
return TrackingModel(
|
||||||
|
id: map['id'],
|
||||||
|
createdAt: DateTime.parse(map['created_at']),
|
||||||
|
companyId: map['company_id'],
|
||||||
|
staffId: map['staff_id'],
|
||||||
|
staffName: map['staff_member']?['name'], // Se fai la join su staff_member
|
||||||
|
parentId: map['parent_id'] as String,
|
||||||
|
parentType: TrackingParentType.fromString(map['parent_type']),
|
||||||
|
eventType: TrackingType.fromString(map['event_type']),
|
||||||
|
isInternal: map['is_internal'] ?? true,
|
||||||
|
message: map['message'],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toMap() {
|
||||||
|
final map = <String, dynamic>{
|
||||||
|
'company_id': companyId,
|
||||||
|
'staff_id': staffId,
|
||||||
|
'parent_id': parentId,
|
||||||
|
'parent_type': parentType.name,
|
||||||
|
'event_type': eventType.name,
|
||||||
|
'is_internal': isInternal,
|
||||||
|
'message': message,
|
||||||
|
};
|
||||||
|
|
||||||
|
// Aggiungiamo id e data SOLO se stiamo aggiornando un record esistente.
|
||||||
|
// In fase di creazione (insert), li omettiamo così Supabase usa i valori di default (gen_random_uuid e now()).
|
||||||
|
if (id != null) {
|
||||||
|
map['id'] = id;
|
||||||
|
map['created_at'] = createdAt.toIso8601String();
|
||||||
|
}
|
||||||
|
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Object?> get props => [
|
||||||
|
id,
|
||||||
|
createdAt,
|
||||||
|
companyId,
|
||||||
|
staffId,
|
||||||
|
staffName,
|
||||||
|
parentId,
|
||||||
|
parentType,
|
||||||
|
eventType,
|
||||||
|
isInternal,
|
||||||
|
message,
|
||||||
|
];
|
||||||
|
}
|
||||||
@@ -9,8 +9,10 @@ import 'package:flux/features/auth/bloc/auth_cubit.dart';
|
|||||||
import 'package:flux/features/company/data/company_repository.dart';
|
import 'package:flux/features/company/data/company_repository.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/data/operations_repository.dart';
|
import 'package:flux/features/operations/data/operations_repository.dart';
|
||||||
|
import 'package:flux/features/settings/blocs/settings_cubit.dart';
|
||||||
import 'package:flux/features/settings/document_sequence/data/document_sequence_repository.dart';
|
import 'package:flux/features/settings/document_sequence/data/document_sequence_repository.dart';
|
||||||
import 'package:flux/features/tickets/data/ticket_repository.dart';
|
import 'package:flux/features/tickets/data/ticket_repository.dart';
|
||||||
|
import 'package:flux/features/tracking/data/tracking_repository.dart';
|
||||||
import 'package:flux/l10n/app_localizations.dart';
|
import 'package:flux/l10n/app_localizations.dart';
|
||||||
import 'package:get_it/get_it.dart';
|
import 'package:get_it/get_it.dart';
|
||||||
import 'package:go_router/go_router.dart';
|
import 'package:go_router/go_router.dart';
|
||||||
@@ -56,9 +58,15 @@ void main() async {
|
|||||||
BlocProvider<StoreCubit>(create: (_) => StoreCubit()),
|
BlocProvider<StoreCubit>(create: (_) => StoreCubit()),
|
||||||
BlocProvider<CustomersCubit>(create: (_) => CustomersCubit()),
|
BlocProvider<CustomersCubit>(create: (_) => CustomersCubit()),
|
||||||
BlocProvider<ProductsCubit>(create: (_) => ProductsCubit()),
|
BlocProvider<ProductsCubit>(create: (_) => ProductsCubit()),
|
||||||
BlocProvider<StaffCubit>(create: (_) => StaffCubit()),
|
BlocProvider<StaffCubit>(
|
||||||
|
create: (_) => StaffCubit()
|
||||||
|
..loadStaffForStore(
|
||||||
|
GetIt.I.get<SessionCubit>().state.currentStore!.id!,
|
||||||
|
),
|
||||||
|
),
|
||||||
BlocProvider<OperationListCubit>(create: (_) => OperationListCubit()),
|
BlocProvider<OperationListCubit>(create: (_) => OperationListCubit()),
|
||||||
BlocProvider<ProvidersCubit>(create: (_) => ProvidersCubit()),
|
BlocProvider<ProvidersCubit>(create: (_) => ProvidersCubit()),
|
||||||
|
BlocProvider<SettingsCubit>(create: (_) => SettingsCubit()),
|
||||||
],
|
],
|
||||||
child: const FluxApp(),
|
child: const FluxApp(),
|
||||||
),
|
),
|
||||||
@@ -112,6 +120,7 @@ Future<void> setupLocator() async {
|
|||||||
SessionCubit(getIt<CoreRepository>(), getIt<SharedPreferences>()),
|
SessionCubit(getIt<CoreRepository>(), getIt<SharedPreferences>()),
|
||||||
);
|
);
|
||||||
getIt.registerLazySingleton<CompanyRepository>(() => CompanyRepository());
|
getIt.registerLazySingleton<CompanyRepository>(() => CompanyRepository());
|
||||||
|
getIt.registerLazySingleton<TrackingRepository>(() => TrackingRepository());
|
||||||
}
|
}
|
||||||
|
|
||||||
class FluxApp extends StatefulWidget {
|
class FluxApp extends StatefulWidget {
|
||||||
|
|||||||
Reference in New Issue
Block a user