fix router
This commit is contained in:
@@ -4,6 +4,7 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flux/core/blocs/session/session_cubit.dart';
|
||||
import 'package:flux/core/data/core_repository.dart';
|
||||
import 'package:flux/core/layout/app_shell.dart';
|
||||
import 'package:flux/core/widgets/image_upload/blocs/image_upload_cubit.dart';
|
||||
import 'package:flux/core/widgets/image_upload/ui/image_upload_screen.dart';
|
||||
import 'package:flux/core/widgets/set_password_screen.dart';
|
||||
import 'package:flux/core/widgets/image_upload/ui/upload_success_screen.dart';
|
||||
@@ -27,6 +28,7 @@ import 'package:flux/features/onboarding/blocs/onboarding_cubit.dart';
|
||||
import 'package:flux/features/onboarding/ui/onboarding_screen.dart';
|
||||
import 'package:flux/features/attachments/blocs/attachments_bloc.dart';
|
||||
import 'package:flux/features/operations/blocs/operation_form_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/ui/operation_form_screen.dart';
|
||||
import 'package:flux/features/operations/ui/operation_list_screen.dart';
|
||||
@@ -168,7 +170,10 @@ class AppRouter {
|
||||
),
|
||||
GoRoute(
|
||||
path: '/operations',
|
||||
builder: (context, state) => const OperationListScreen(),
|
||||
builder: (context, state) => BlocProvider(
|
||||
create: (context) => OperationListCubit(),
|
||||
child: const OperationListScreen(),
|
||||
),
|
||||
),
|
||||
GoRoute(
|
||||
path: '/customers',
|
||||
@@ -294,9 +299,15 @@ class AppRouter {
|
||||
);
|
||||
|
||||
// Creiamo il BLoC "al volo" solo per questa schermata
|
||||
return BlocProvider(
|
||||
create: (context) =>
|
||||
AttachmentsBloc(parentId: id, parentType: parentType),
|
||||
return MultiBlocProvider(
|
||||
providers: [
|
||||
BlocProvider<AttachmentsBloc>(
|
||||
create: (context) =>
|
||||
AttachmentsBloc(parentId: id, parentType: parentType),
|
||||
),
|
||||
BlocProvider(create: (context) => ImageUploadCubit()),
|
||||
],
|
||||
|
||||
child: ImageUploadScreen(
|
||||
title: 'Caricamento Rapido',
|
||||
companyId: companyId,
|
||||
|
||||
@@ -135,7 +135,7 @@ class _LatestOperationsCardContent extends StatelessWidget {
|
||||
final operation = state.operations[index];
|
||||
return InkWell(
|
||||
onTap: () => context.push(
|
||||
'/operation-form',
|
||||
'/operations/form/id=${operation.id}',
|
||||
extra: operation,
|
||||
),
|
||||
child: Padding(
|
||||
|
||||
@@ -12,7 +12,9 @@ class OperationListCubit extends Cubit<OperationListState> {
|
||||
final OperationsRepository _repository = GetIt.I<OperationsRepository>();
|
||||
final SessionCubit _sessionCubit = GetIt.I<SessionCubit>();
|
||||
|
||||
OperationListCubit() : super(const OperationListState());
|
||||
OperationListCubit() : super(const OperationListState()) {
|
||||
loadOperations(refresh: true);
|
||||
}
|
||||
|
||||
Future<void> loadOperations({bool refresh = false}) async {
|
||||
if (state.status == OperationListStatus.loading) return;
|
||||
|
||||
@@ -158,7 +158,7 @@ class _OperationListScreenState extends State<OperationListScreen> {
|
||||
),
|
||||
trailing: const Icon(Icons.chevron_right),
|
||||
onTap: () => context.pushNamed(
|
||||
'operation-form',
|
||||
'operations/form/id=${operation.id}',
|
||||
extra: operation, // <-- LA MAGIA È QUI: Passa l'oggetto intero!
|
||||
// Teniamo anche il parametro URL per coerenza di routing
|
||||
queryParameters: operation.id != null
|
||||
|
||||
Reference in New Issue
Block a user