Skip to content

Commit bc31ded

Browse files
committed
feat(status): implement status page for app startup
- Add StatusPage widget to display status during critical startup sequence - Handle config fetching and error states - Implement retry functionality for failed config fetch - Update view exports to include new StatusPage
1 parent 0d90abd commit bc31ded

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed

lib/status/view/status_page.dart

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import 'package:core/core.dart' hide AppStatus;
2+
import 'package:flutter/material.dart';
3+
import 'package:flutter_bloc/flutter_bloc.dart';
4+
import 'package:flutter_news_app_mobile_client_full_source_code/app/bloc/app_bloc.dart';
5+
import 'package:flutter_news_app_mobile_client_full_source_code/l10n/l10n.dart';
6+
import 'package:ui_kit/ui_kit.dart';
7+
8+
/// A page that serves as the root UI during the critical startup sequence.
9+
///
10+
/// This widget is displayed *before* the main application's router and UI
11+
/// shell are built. It is responsible for showing the user a clear status
12+
/// while the remote configuration is being fetched, and it provides a way
13+
/// for the user to retry if the fetch operation fails.
14+
class StatusPage extends StatelessWidget {
15+
/// {@macro status_page}
16+
const StatusPage({super.key});
17+
18+
@override
19+
Widget build(BuildContext context) {
20+
// This page is a temporary root widget shown during the critical
21+
// startup phase before the main app UI (and GoRouter) is built.
22+
// It handles two key states: fetching the remote configuration and
23+
// recovering from a failed fetch.
24+
return Scaffold(
25+
body: BlocBuilder<AppBloc, AppState>(
26+
builder: (context, state) {
27+
final l10n = AppLocalizationsX(context).l10n;
28+
29+
if (state.status == AppStatus.configFetching) {
30+
// While fetching configuration, display a clear loading indicator.
31+
// This uses a shared widget from the UI kit for consistency.
32+
return LoadingStateWidget(
33+
icon: Icons.settings_applications_outlined,
34+
headline: l10n.headlinesFeedLoadingHeadline,
35+
subheadline: l10n.pleaseWait,
36+
);
37+
}
38+
39+
// If fetching fails, show an error message with a retry option.
40+
// This allows the user to recover from transient network issues.
41+
return FailureStateWidget(
42+
exception: const NetworkException(), // A generic network error
43+
retryButtonText: 'l10n.retryButtonText', //TODO(fulleni): localize me.
44+
onRetry: () {
45+
// Dispatch the event to AppBloc to re-trigger the fetch.
46+
context.read<AppBloc>().add(const AppConfigFetchRequested());
47+
},
48+
);
49+
},
50+
),
51+
);
52+
}
53+
}

lib/status/view/view.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
export 'maintenance_page.dart';
2+
export 'status_page.dart';
23
export 'update_required_page.dart';

0 commit comments

Comments
 (0)