Skip to content

Commit 76095a7

Browse files
committed
refactor(dependencies): migrate to generic data and auth repositories
- Replace HtDataRepository with DataRepository - Replace HtAuthRepository with AuthRepository - Update import paths for core, data_repository, and auth_repository - Remove unused imports and update class references - Adjust exception handling from HtHttpException to HttpException - Update AppConfig to remove unused demo factory - Update App class constructors and method calls to use new repository names
1 parent abbc6b8 commit 76095a7

File tree

4 files changed

+92
-99
lines changed

4 files changed

+92
-99
lines changed

lib/app/bloc/app_bloc.dart

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,30 @@
22

33
import 'dart:async';
44

5+
import 'package:auth_repository/auth_repository.dart';
56
import 'package:bloc/bloc.dart';
7+
import 'package:core/core.dart';
8+
import 'package:data_repository/data_repository.dart';
69
import 'package:equatable/equatable.dart';
7-
import 'package:ht_auth_repository/ht_auth_repository.dart';
8-
import 'package:ht_dashboard/app/config/config.dart' as local_config;
9-
import 'package:ht_data_repository/ht_data_repository.dart';
10-
import 'package:ht_shared/ht_shared.dart';
10+
import 'package:flutter_news_app_web_dashboard_full_source_code/app/config/config.dart'
11+
as local_config;
1112
import 'package:logging/logging.dart';
1213

1314
part 'app_event.dart';
1415
part 'app_state.dart';
1516

1617
class AppBloc extends Bloc<AppEvent, AppState> {
1718
AppBloc({
18-
required HtAuthRepository authenticationRepository,
19-
required HtDataRepository<UserAppSettings> userAppSettingsRepository,
20-
required HtDataRepository<RemoteConfig> appConfigRepository,
19+
required AuthRepository authenticationRepository,
20+
required DataRepository<UserAppSettings> userAppSettingsRepository,
21+
required DataRepository<RemoteConfig> appConfigRepository,
2122
required local_config.AppEnvironment environment,
2223
Logger? logger,
2324
}) : _authenticationRepository = authenticationRepository,
2425
_userAppSettingsRepository = userAppSettingsRepository,
2526
_appConfigRepository = appConfigRepository,
2627
_logger = logger ?? Logger('AppBloc'),
27-
super(
28-
AppState(environment: environment),
29-
) {
28+
super(AppState(environment: environment)) {
3029
on<AppUserChanged>(_onAppUserChanged);
3130
on<AppLogoutRequested>(_onLogoutRequested);
3231
on<AppUserAppSettingsChanged>(_onAppUserAppSettingsChanged);
@@ -36,9 +35,9 @@ class AppBloc extends Bloc<AppEvent, AppState> {
3635
);
3736
}
3837

39-
final HtAuthRepository _authenticationRepository;
40-
final HtDataRepository<UserAppSettings> _userAppSettingsRepository;
41-
final HtDataRepository<RemoteConfig> _appConfigRepository;
38+
final AuthRepository _authenticationRepository;
39+
final DataRepository<UserAppSettings> _userAppSettingsRepository;
40+
final DataRepository<RemoteConfig> _appConfigRepository;
4241
final Logger _logger;
4342
late final StreamSubscription<User?> _userSubscription;
4443

@@ -97,7 +96,7 @@ class AppBloc extends Bloc<AppEvent, AppState> {
9796
);
9897
await _userAppSettingsRepository.create(item: defaultSettings);
9998
emit(state.copyWith(userAppSettings: defaultSettings));
100-
} on HtHttpException catch (e, s) {
99+
} on HttpException catch (e, s) {
101100
// Handle HTTP exceptions during settings load
102101
_logger.severe(
103102
'Error loading user app settings for user ${user.id}: ${e.message}',

lib/app/config/app_config.dart

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,15 @@
1-
import 'package:ht_dashboard/app/config/app_environment.dart';
1+
import 'package:flutter_news_app_web_dashboard_full_source_code/app/config/app_environment.dart';
22

33
class AppConfig {
4-
const AppConfig({
5-
required this.environment,
6-
required this.baseUrl,
7-
});
4+
const AppConfig({required this.environment, required this.baseUrl});
85

96
factory AppConfig.production() => const AppConfig(
107
environment: AppEnvironment.production,
118
baseUrl: 'http://api.yourproductiondomain.com',
129
);
1310

14-
factory AppConfig.demo() => const AppConfig(
15-
environment: AppEnvironment.demo,
16-
baseUrl: '',
17-
);
11+
factory AppConfig.demo() =>
12+
const AppConfig(environment: AppEnvironment.demo, baseUrl: '');
1813

1914
factory AppConfig.development() => const AppConfig(
2015
environment: AppEnvironment.development,

lib/app/view/app.dart

Lines changed: 71 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,122 +1,121 @@
11
//
22
// ignore_for_file: deprecated_member_use
33

4+
import 'package:auth_repository/auth_repository.dart';
5+
import 'package:core/core.dart' hide AppStatus;
6+
// Import for app_theme.dart
7+
import 'package:data_repository/data_repository.dart';
48
import 'package:flex_color_scheme/flex_color_scheme.dart';
59
import 'package:flutter/material.dart';
610
import 'package:flutter_bloc/flutter_bloc.dart';
11+
import 'package:flutter_news_app_web_dashboard_full_source_code/app/bloc/app_bloc.dart';
12+
import 'package:flutter_news_app_web_dashboard_full_source_code/app/config/app_environment.dart';
13+
import 'package:flutter_news_app_web_dashboard_full_source_code/app_configuration/bloc/app_configuration_bloc.dart';
14+
import 'package:flutter_news_app_web_dashboard_full_source_code/authentication/bloc/authentication_bloc.dart';
15+
import 'package:flutter_news_app_web_dashboard_full_source_code/content_management/bloc/content_management_bloc.dart';
16+
import 'package:flutter_news_app_web_dashboard_full_source_code/dashboard/bloc/dashboard_bloc.dart';
17+
import 'package:flutter_news_app_web_dashboard_full_source_code/l10n/app_localizations.dart';
18+
import 'package:flutter_news_app_web_dashboard_full_source_code/router/router.dart';
719
import 'package:go_router/go_router.dart';
8-
import 'package:ht_auth_repository/ht_auth_repository.dart';
9-
import 'package:ht_dashboard/app/bloc/app_bloc.dart';
10-
import 'package:ht_dashboard/app/config/app_environment.dart';
11-
import 'package:ht_dashboard/app_configuration/bloc/app_configuration_bloc.dart';
12-
import 'package:ht_dashboard/authentication/bloc/authentication_bloc.dart';
13-
import 'package:ht_dashboard/content_management/bloc/content_management_bloc.dart';
14-
import 'package:ht_dashboard/dashboard/bloc/dashboard_bloc.dart';
15-
import 'package:ht_dashboard/l10n/app_localizations.dart';
16-
import 'package:ht_dashboard/router/router.dart';
17-
// Import for app_theme.dart
18-
import 'package:ht_data_repository/ht_data_repository.dart';
19-
import 'package:ht_kv_storage_service/ht_kv_storage_service.dart';
20-
import 'package:ht_shared/ht_shared.dart' hide AppStatus;
21-
import 'package:ht_ui_kit/ht_ui_kit.dart';
20+
import 'package:kv_storage_service/kv_storage_service.dart';
2221
import 'package:logging/logging.dart';
22+
import 'package:ui_kit/ui_kit.dart';
2323

2424
class App extends StatelessWidget {
2525
const App({
26-
required HtAuthRepository htAuthenticationRepository,
27-
required HtDataRepository<Headline> htHeadlinesRepository,
28-
required HtDataRepository<Topic> htTopicsRepository,
29-
required HtDataRepository<Country> htCountriesRepository,
30-
required HtDataRepository<Source> htSourcesRepository,
31-
required HtDataRepository<UserAppSettings> htUserAppSettingsRepository,
32-
required HtDataRepository<UserContentPreferences>
33-
htUserContentPreferencesRepository,
34-
required HtDataRepository<RemoteConfig> htRemoteConfigRepository,
35-
required HtDataRepository<DashboardSummary> htDashboardSummaryRepository,
36-
required HtKVStorageService kvStorageService,
26+
required AuthRepository authenticationRepository,
27+
required DataRepository<Headline> headlinesRepository,
28+
required DataRepository<Topic> topicsRepository,
29+
required DataRepository<Country> countriesRepository,
30+
required DataRepository<Source> sourcesRepository,
31+
required DataRepository<UserAppSettings> userAppSettingsRepository,
32+
required DataRepository<UserContentPreferences>
33+
userContentPreferencesRepository,
34+
required DataRepository<RemoteConfig> remoteConfigRepository,
35+
required DataRepository<DashboardSummary> dashboardSummaryRepository,
36+
required KVStorageService storageService,
3737
required AppEnvironment environment,
3838
super.key,
39-
}) : _htAuthenticationRepository = htAuthenticationRepository,
40-
_htHeadlinesRepository = htHeadlinesRepository,
41-
_htTopicsRepository = htTopicsRepository,
42-
_htCountriesRepository = htCountriesRepository,
43-
_htSourcesRepository = htSourcesRepository,
44-
_htUserAppSettingsRepository = htUserAppSettingsRepository,
45-
_htUserContentPreferencesRepository = htUserContentPreferencesRepository,
46-
_htRemoteConfigRepository = htRemoteConfigRepository,
47-
_kvStorageService = kvStorageService,
48-
_htDashboardSummaryRepository = htDashboardSummaryRepository,
39+
}) : _authenticationRepository = authenticationRepository,
40+
_headlinesRepository = headlinesRepository,
41+
_topicsRepository = topicsRepository,
42+
_countriesRepository = countriesRepository,
43+
_sourcesRepository = sourcesRepository,
44+
_userAppSettingsRepository = userAppSettingsRepository,
45+
_userContentPreferencesRepository = userContentPreferencesRepository,
46+
_remoteConfigRepository = remoteConfigRepository,
47+
_kvStorageService = storageService,
48+
_dashboardSummaryRepository = dashboardSummaryRepository,
4949
_environment = environment;
5050

51-
final HtAuthRepository _htAuthenticationRepository;
52-
final HtDataRepository<Headline> _htHeadlinesRepository;
53-
final HtDataRepository<Topic> _htTopicsRepository;
54-
final HtDataRepository<Country> _htCountriesRepository;
55-
final HtDataRepository<Source> _htSourcesRepository;
56-
final HtDataRepository<UserAppSettings> _htUserAppSettingsRepository;
57-
final HtDataRepository<UserContentPreferences>
58-
_htUserContentPreferencesRepository;
59-
final HtDataRepository<RemoteConfig> _htRemoteConfigRepository;
60-
final HtDataRepository<DashboardSummary> _htDashboardSummaryRepository;
61-
final HtKVStorageService _kvStorageService;
51+
final AuthRepository _authenticationRepository;
52+
final DataRepository<Headline> _headlinesRepository;
53+
final DataRepository<Topic> _topicsRepository;
54+
final DataRepository<Country> _countriesRepository;
55+
final DataRepository<Source> _sourcesRepository;
56+
final DataRepository<UserAppSettings> _userAppSettingsRepository;
57+
final DataRepository<UserContentPreferences>
58+
_userContentPreferencesRepository;
59+
final DataRepository<RemoteConfig> _remoteConfigRepository;
60+
final DataRepository<DashboardSummary> _dashboardSummaryRepository;
61+
final KVStorageService _kvStorageService;
6262
final AppEnvironment _environment;
6363

6464
@override
6565
Widget build(BuildContext context) {
6666
return MultiRepositoryProvider(
6767
providers: [
68-
RepositoryProvider.value(value: _htAuthenticationRepository),
69-
RepositoryProvider.value(value: _htHeadlinesRepository),
70-
RepositoryProvider.value(value: _htTopicsRepository),
71-
RepositoryProvider.value(value: _htCountriesRepository),
72-
RepositoryProvider.value(value: _htSourcesRepository),
73-
RepositoryProvider.value(value: _htUserAppSettingsRepository),
74-
RepositoryProvider.value(value: _htUserContentPreferencesRepository),
75-
RepositoryProvider.value(value: _htRemoteConfigRepository),
76-
RepositoryProvider.value(value: _htDashboardSummaryRepository),
68+
RepositoryProvider.value(value: _authenticationRepository),
69+
RepositoryProvider.value(value: _headlinesRepository),
70+
RepositoryProvider.value(value: _topicsRepository),
71+
RepositoryProvider.value(value: _countriesRepository),
72+
RepositoryProvider.value(value: _sourcesRepository),
73+
RepositoryProvider.value(value: _userAppSettingsRepository),
74+
RepositoryProvider.value(value: _userContentPreferencesRepository),
75+
RepositoryProvider.value(value: _remoteConfigRepository),
76+
RepositoryProvider.value(value: _dashboardSummaryRepository),
7777
RepositoryProvider.value(value: _kvStorageService),
7878
],
7979
child: MultiBlocProvider(
8080
providers: [
8181
BlocProvider(
8282
create: (context) => AppBloc(
83-
authenticationRepository: context.read<HtAuthRepository>(),
83+
authenticationRepository: context.read<AuthRepository>(),
8484
userAppSettingsRepository: context
85-
.read<HtDataRepository<UserAppSettings>>(),
86-
appConfigRepository: context
87-
.read<HtDataRepository<RemoteConfig>>(),
85+
.read<DataRepository<UserAppSettings>>(),
86+
appConfigRepository: context.read<DataRepository<RemoteConfig>>(),
8887
environment: _environment,
8988
logger: Logger('AppBloc'),
9089
),
9190
),
9291
BlocProvider(
9392
create: (context) => AuthenticationBloc(
94-
authenticationRepository: context.read<HtAuthRepository>(),
93+
authenticationRepository: context.read<AuthRepository>(),
9594
),
9695
),
9796
BlocProvider(
9897
create: (context) => AppConfigurationBloc(
9998
remoteConfigRepository: context
100-
.read<HtDataRepository<RemoteConfig>>(),
99+
.read<DataRepository<RemoteConfig>>(),
101100
),
102101
),
103102
BlocProvider(
104103
create: (context) => ContentManagementBloc(
105-
headlinesRepository: context.read<HtDataRepository<Headline>>(),
106-
topicsRepository: context.read<HtDataRepository<Topic>>(),
107-
sourcesRepository: context.read<HtDataRepository<Source>>(),
104+
headlinesRepository: context.read<DataRepository<Headline>>(),
105+
topicsRepository: context.read<DataRepository<Topic>>(),
106+
sourcesRepository: context.read<DataRepository<Source>>(),
108107
),
109108
),
110109
BlocProvider(
111110
create: (context) => DashboardBloc(
112111
dashboardSummaryRepository: context
113-
.read<HtDataRepository<DashboardSummary>>(),
114-
headlinesRepository: context.read<HtDataRepository<Headline>>(),
112+
.read<DataRepository<DashboardSummary>>(),
113+
headlinesRepository: context.read<DataRepository<Headline>>(),
115114
),
116115
),
117116
],
118117
child: _AppView(
119-
htAuthenticationRepository: _htAuthenticationRepository,
118+
authenticationRepository: _authenticationRepository,
120119
environment: _environment,
121120
),
122121
),
@@ -127,11 +126,11 @@ class App extends StatelessWidget {
127126
class _AppView extends StatefulWidget {
128127
/// {@macro app_view}
129128
const _AppView({
130-
required this.htAuthenticationRepository,
129+
required this.authenticationRepository,
131130
required this.environment,
132131
});
133132

134-
final HtAuthRepository htAuthenticationRepository;
133+
final AuthRepository authenticationRepository;
135134
final AppEnvironment environment;
136135

137136
@override
@@ -149,7 +148,7 @@ class _AppViewState extends State<_AppView> {
149148
_statusNotifier = ValueNotifier<AppStatus>(appBloc.state.status);
150149
_router = createRouter(
151150
authStatusNotifier: _statusNotifier,
152-
htAuthenticationRepository: widget.htAuthenticationRepository,
151+
authenticationRepository: widget.authenticationRepository,
153152
environment: widget.environment,
154153
);
155154
}
@@ -210,10 +209,10 @@ class _AppViewState extends State<_AppView> {
210209
debugShowCheckedModeBanner: false,
211210
routerConfig: _router,
212211
localizationsDelegates: const [
213-
HtUiKitLocalizations.delegate,
212+
UiKitLocalizations.delegate,
214213
...AppLocalizations.localizationsDelegates,
215214
],
216-
supportedLocales: HtUiKitLocalizations.supportedLocales,
215+
supportedLocales: UiKitLocalizations.supportedLocales,
217216
theme: baseTheme == AppBaseTheme.dark
218217
? darkThemeData
219218
: lightThemeData,

lib/app/view/app_shell.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import 'package:flutter/material.dart';
22
import 'package:flutter_adaptive_scaffold/flutter_adaptive_scaffold.dart';
33
import 'package:flutter_bloc/flutter_bloc.dart';
4+
import 'package:flutter_news_app_web_dashboard_full_source_code/app/bloc/app_bloc.dart';
5+
import 'package:flutter_news_app_web_dashboard_full_source_code/l10n/l10n.dart';
6+
import 'package:flutter_news_app_web_dashboard_full_source_code/router/routes.dart';
47
import 'package:go_router/go_router.dart';
5-
import 'package:ht_dashboard/app/bloc/app_bloc.dart';
6-
import 'package:ht_dashboard/l10n/l10n.dart';
7-
import 'package:ht_dashboard/router/routes.dart';
8-
import 'package:ht_ui_kit/ht_ui_kit.dart';
8+
import 'package:ui_kit/ui_kit.dart';
99

1010
/// A responsive scaffold shell for the main application sections.
1111
///

0 commit comments

Comments
 (0)