Refactor QrUploadDialog to integrate BlocListener for attachment state management
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flux/core/utils/extensions.dart';
|
import 'package:flux/core/utils/extensions.dart';
|
||||||
|
import 'package:flux/features/attachments/blocs/attachments_bloc.dart';
|
||||||
import 'package:qr_flutter/qr_flutter.dart';
|
import 'package:qr_flutter/qr_flutter.dart';
|
||||||
|
|
||||||
class QrUploadDialog extends StatelessWidget {
|
class QrUploadDialog extends StatelessWidget {
|
||||||
@@ -17,7 +19,14 @@ class QrUploadDialog extends StatelessWidget {
|
|||||||
// Usiamo i colori del tema per renderlo coerente col tuo design
|
// Usiamo i colori del tema per renderlo coerente col tuo design
|
||||||
final theme = Theme.of(context);
|
final theme = Theme.of(context);
|
||||||
|
|
||||||
return AlertDialog(
|
return BlocListener<AttachmentsBloc, AttachmentsState>(
|
||||||
|
listener: (context, state) {
|
||||||
|
if (state.status == AttachmentsStatus.success) {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
listenWhen: (previous, current) => previous.status != current.status,
|
||||||
|
child: AlertDialog(
|
||||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)),
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)),
|
||||||
backgroundColor: theme.colorScheme.surface,
|
backgroundColor: theme.colorScheme.surface,
|
||||||
title: Column(
|
title: Column(
|
||||||
@@ -88,6 +97,7 @@ class QrUploadDialog extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
actionsAlignment: MainAxisAlignment.center,
|
actionsAlignment: MainAxisAlignment.center,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user