Added components to article

This commit is contained in:
Dennis Nemec
2026-05-11 17:12:05 +02:00
parent 2470299a10
commit ac6b03227d
37 changed files with 1189 additions and 513 deletions

View File

@ -4,8 +4,11 @@ import 'package:hl_lieferservice/widget/operations/bloc/operation_bloc.dart';
import '../bloc/operation_state.dart';
/// Listens to [OperationBloc] and shows SnackBars for success and error
/// messages. Loading indicators are handled locally by each feature.
/// Listens to [OperationBloc] and shows:
/// - SnackBars for success and error messages.
/// - A blocking modal barrier with a spinner while a mutation is in flight,
/// so the user gets unambiguous "wait" feedback and cannot double-tap or
/// navigate away mid-request.
class OperationViewEnforcer extends StatelessWidget {
final Widget child;
@ -13,7 +16,7 @@ class OperationViewEnforcer extends StatelessWidget {
@override
Widget build(BuildContext context) {
return BlocListener<OperationBloc, OperationState>(
return BlocConsumer<OperationBloc, OperationState>(
listener: (context, state) {
if (state is OperationFinished && state.message != null) {
ScaffoldMessenger.of(context).showSnackBar(
@ -27,7 +30,44 @@ class OperationViewEnforcer extends StatelessWidget {
);
}
},
child: child,
builder: (context, state) {
final isInProgress = state is OperationInProgress;
final progressMessage =
isInProgress ? state.message : null;
return Stack(
children: [
child,
if (isInProgress)
PopScope(
canPop: false,
child: Stack(
children: [
const ModalBarrier(
dismissible: false,
color: Colors.black54,
),
Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
const CircularProgressIndicator(),
if (progressMessage != null) ...[
const SizedBox(height: 16),
Text(
progressMessage,
style: const TextStyle(color: Colors.white),
),
],
],
),
),
],
),
),
],
);
},
);
}
}