migrated the breaker system to MarianumConnect and refactored the API response to a rule-based model with support for version-specific blocks using maxBuild.
This commit is contained in:
@@ -1,9 +1,8 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
||||
import '../../api/mhsl/breaker/get_breakers/get_breakers_response.dart';
|
||||
import '../../api/marianumconnect/queries/get_breakers/get_breakers_response.dart';
|
||||
import '../../state/app/modules/breaker/bloc/breaker_bloc.dart';
|
||||
import '../../widget/placeholder_view.dart';
|
||||
|
||||
class Breaker extends StatelessWidget {
|
||||
final BreakerArea breaker;
|
||||
@@ -16,13 +15,71 @@ class Breaker extends StatelessWidget {
|
||||
final bloc = context.watch<BreakerBloc>();
|
||||
final blocked = bloc.isBlocked(breaker);
|
||||
if (blocked != null) {
|
||||
return PlaceholderView(
|
||||
icon: Icons.app_blocking_outlined,
|
||||
text:
|
||||
'Die App / Dieser Bereich ist zurzeit nicht verfügbar!\n\n'
|
||||
'${blocked.isEmpty ? "Es wurde vom Server kein Grund übermittelt.\nAktualisiere die App und versuche es später erneut" : blocked}',
|
||||
);
|
||||
return _BreakerBlockedView(message: blocked);
|
||||
}
|
||||
return child;
|
||||
}
|
||||
}
|
||||
|
||||
class _BreakerBlockedView extends StatelessWidget {
|
||||
final String message;
|
||||
|
||||
const _BreakerBlockedView({required this.message});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
final scheme = theme.colorScheme;
|
||||
final reason = message.trim();
|
||||
|
||||
return Material(
|
||||
color: scheme.surface,
|
||||
child: CustomScrollView(
|
||||
physics: const AlwaysScrollableScrollPhysics(),
|
||||
slivers: [
|
||||
SliverFillRemaining(
|
||||
hasScrollBody: false,
|
||||
child: Center(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 32,
|
||||
vertical: 24,
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(
|
||||
Icons.construction_outlined,
|
||||
size: 60,
|
||||
color: scheme.onSurfaceVariant,
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
Text(
|
||||
'Momentan nicht verfügbar',
|
||||
textAlign: TextAlign.center,
|
||||
style: theme.textTheme.titleLarge?.copyWith(
|
||||
fontWeight: FontWeight.w600,
|
||||
color: scheme.onSurface,
|
||||
),
|
||||
),
|
||||
if (reason.isNotEmpty) ...[
|
||||
const SizedBox(height: 10),
|
||||
Text(
|
||||
reason,
|
||||
textAlign: TextAlign.center,
|
||||
style: theme.textTheme.bodyMedium?.copyWith(
|
||||
color: scheme.onSurfaceVariant,
|
||||
height: 1.4,
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user