Skip to content

Commit 59aca7a

Browse files
committed
feat(app): add package info service and update required page functionality
- Add PackageInfoService to the app dependencies - Inject PackageInfoService into App and _AppView widgets - Update UpdateRequiredPage to use app status from remote config - Enhance App widget to handle package info related features
1 parent 1fef224 commit 59aca7a

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

lib/app/view/app.dart

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import 'package:flutter_news_app_mobile_client_full_source_code/app/config/app_e
1111
import 'package:flutter_news_app_mobile_client_full_source_code/app/services/app_status_service.dart';
1212
import 'package:flutter_news_app_mobile_client_full_source_code/app/services/demo_data_initializer_service.dart';
1313
import 'package:flutter_news_app_mobile_client_full_source_code/app/services/demo_data_migration_service.dart';
14+
import 'package:flutter_news_app_mobile_client_full_source_code/app/services/package_info_service.dart';
1415
import 'package:flutter_news_app_mobile_client_full_source_code/authentication/bloc/authentication_bloc.dart';
1516
import 'package:flutter_news_app_mobile_client_full_source_code/l10n/app_localizations.dart';
1617
import 'package:flutter_news_app_mobile_client_full_source_code/router/router.dart';
@@ -48,6 +49,7 @@ class App extends StatelessWidget {
4849
required InlineAdCacheService inlineAdCacheService,
4950
required RemoteConfig? initialRemoteConfig,
5051
required HttpException? initialRemoteConfigError,
52+
required PackageInfoService packageInfoService,
5153
super.key,
5254
this.demoDataMigrationService,
5355
this.demoDataInitializerService,
@@ -68,7 +70,8 @@ class App extends StatelessWidget {
6870
_navigatorKey = navigatorKey,
6971
_inlineAdCacheService = inlineAdCacheService,
7072
_initialRemoteConfig = initialRemoteConfig,
71-
_initialRemoteConfigError = initialRemoteConfigError;
73+
_initialRemoteConfigError = initialRemoteConfigError,
74+
_packageInfoService = packageInfoService;
7275

7376
final AuthRepository _authenticationRepository;
7477
final DataRepository<Headline> _headlinesRepository;
@@ -86,6 +89,7 @@ class App extends StatelessWidget {
8689
final DataRepository<LocalAd> _localAdRepository;
8790
final GlobalKey<NavigatorState> _navigatorKey;
8891
final InlineAdCacheService _inlineAdCacheService;
92+
final PackageInfoService _packageInfoService;
8993
final DemoDataMigrationService? demoDataMigrationService;
9094
final DemoDataInitializerService? demoDataInitializerService;
9195
final User? initialUser;
@@ -114,6 +118,7 @@ class App extends StatelessWidget {
114118
RepositoryProvider.value(value: _adService),
115119
RepositoryProvider.value(value: _localAdRepository),
116120
RepositoryProvider.value(value: _inlineAdCacheService),
121+
RepositoryProvider.value(value: _packageInfoService),
117122
],
118123
child: MultiBlocProvider(
119124
providers: [
@@ -133,6 +138,7 @@ class App extends StatelessWidget {
133138
navigatorKey: _navigatorKey,
134139
initialRemoteConfig: _initialRemoteConfig,
135140
initialRemoteConfigError: _initialRemoteConfigError,
141+
packageInfoService: _packageInfoService,
136142
)..add(AppStarted(initialUser: initialUser)),
137143
),
138144
BlocProvider(
@@ -167,6 +173,7 @@ class App extends StatelessWidget {
167173
localAdRepository: _localAdRepository,
168174
navigatorKey: _navigatorKey,
169175
inlineAdCacheService: _inlineAdCacheService,
176+
packageInfoService: _packageInfoService,
170177
),
171178
),
172179
);
@@ -189,6 +196,7 @@ class _AppView extends StatefulWidget {
189196
required this.localAdRepository,
190197
required this.navigatorKey,
191198
required this.inlineAdCacheService,
199+
required this.packageInfoService,
192200
});
193201

194202
final AuthRepository authenticationRepository;
@@ -205,6 +213,7 @@ class _AppView extends StatefulWidget {
205213
final DataRepository<LocalAd> localAdRepository;
206214
final GlobalKey<NavigatorState> navigatorKey;
207215
final InlineAdCacheService inlineAdCacheService;
216+
final PackageInfoService packageInfoService;
208217

209218
@override
210219
State<_AppView> createState() => _AppViewState();
@@ -402,7 +411,11 @@ class _AppViewState extends State<_AppView> {
402411
],
403412
supportedLocales: AppLocalizations.supportedLocales,
404413
locale: state.locale,
405-
home: const UpdateRequiredPage(),
414+
home: UpdateRequiredPage(
415+
iosUpdateUrl: state.remoteConfig!.appStatus.iosUpdateUrl,
416+
androidUpdateUrl:
417+
state.remoteConfig!.appStatus.androidUpdateUrl,
418+
),
406419
);
407420
}
408421

0 commit comments

Comments
 (0)