feat: complete centralized error handling system with documentation

This commit is contained in:
2026-02-11 10:36:08 +05:30
parent 7570ffa3b9
commit 3e212220c7
43 changed files with 1144 additions and 2858 deletions

View File

@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_modular/flutter_modular.dart';
import 'package:design_system/design_system.dart';
import 'package:core_localization/core_localization.dart';
import 'package:krow_domain/krow_domain.dart';
import '../blocs/shifts/shifts_bloc.dart';
import '../widgets/tabs/my_shifts_tab.dart';
@@ -66,9 +67,20 @@ class _ShiftsPageState extends State<ShiftsPage> {
@override
Widget build(BuildContext context) {
final t = Translations.of(context);
return BlocProvider.value(
value: _bloc,
child: BlocBuilder<ShiftsBloc, ShiftsState>(
child: BlocConsumer<ShiftsBloc, ShiftsState>(
listener: (context, state) {
if (state is ShiftsError) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(translateErrorKey(state.message)),
behavior: SnackBarBehavior.floating,
),
);
}
},
builder: (context, state) {
final bool baseLoaded = state is ShiftsLoaded;
final List<Shift> myShifts = (state is ShiftsLoaded)
@@ -123,9 +135,9 @@ class _ShiftsPageState extends State<ShiftsPage> {
crossAxisAlignment: CrossAxisAlignment.start,
spacing: 16,
children: [
const Text(
"Shifts",
style: TextStyle(
Text(
t.staff_shifts.title,
style: const TextStyle(
fontSize: 24,
fontWeight: FontWeight.bold,
color: Colors.white,
@@ -137,7 +149,7 @@ class _ShiftsPageState extends State<ShiftsPage> {
children: [
_buildTab(
"myshifts",
"My Shifts",
t.staff_shifts.tabs.my_shifts,
UiIcons.calendar,
myShifts.length,
showCount: myShiftsLoaded,
@@ -146,7 +158,7 @@ class _ShiftsPageState extends State<ShiftsPage> {
const SizedBox(width: 8),
_buildTab(
"find",
"Find Shifts",
t.staff_shifts.tabs.find_work,
UiIcons.search,
availableJobs
.length, // Passed unfiltered count as badge? Or logic inside? Pass availableJobs.
@@ -156,7 +168,7 @@ class _ShiftsPageState extends State<ShiftsPage> {
const SizedBox(width: 8),
_buildTab(
"history",
"History",
t.staff_shifts.tabs.history,
UiIcons.clock,
historyShifts.length,
showCount: historyLoaded,
@@ -172,7 +184,26 @@ class _ShiftsPageState extends State<ShiftsPage> {
Expanded(
child: state is ShiftsLoading
? const Center(child: CircularProgressIndicator())
: _buildTabContent(
: state is ShiftsError
? Center(
child: Padding(
padding: const EdgeInsets.all(24.0),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Text(
translateErrorKey(state.message),
style: const TextStyle(
fontSize: 16,
color: Color(0xFF64748B),
),
textAlign: TextAlign.center,
),
],
),
),
)
: _buildTabContent(
myShifts,
pendingAssignments,
cancelledShifts,