1
+ import 'package:auth_api/auth_api.dart' ;
2
+ import 'package:auth_client/auth_client.dart' ;
3
+ import 'package:auth_inmemory/auth_inmemory.dart' ;
4
+ import 'package:auth_repository/auth_repository.dart' ;
5
+ import 'package:core/core.dart' ;
6
+ import 'package:data_api/data_api.dart' ;
7
+ import 'package:data_client/data_client.dart' ;
8
+ import 'package:data_inmemory/data_inmemory.dart' ;
9
+ import 'package:data_repository/data_repository.dart' ;
1
10
import 'package:flutter/material.dart' ;
2
11
import 'package:flutter_bloc/flutter_bloc.dart' ;
3
- import 'package:ht_auth_api/ht_auth_api.dart' ;
4
- import 'package:ht_auth_client/ht_auth_client.dart' ;
5
- import 'package:ht_auth_inmemory/ht_auth_inmemory.dart' ;
6
- import 'package:ht_auth_repository/ht_auth_repository.dart' ;
7
- import 'package:ht_data_api/ht_data_api.dart' ;
8
- import 'package:ht_data_client/ht_data_client.dart' ;
9
- import 'package:ht_data_inmemory/ht_data_inmemory.dart' ;
10
- import 'package:ht_data_repository/ht_data_repository.dart' ;
11
- import 'package:ht_http_client/ht_http_client.dart' ;
12
- import 'package:ht_kv_storage_shared_preferences/ht_kv_storage_shared_preferences.dart' ;
13
- import 'package:ht_main/app/app.dart' ;
14
- import 'package:ht_main/app/config/config.dart' as app_config;
15
- import 'package:ht_main/app/services/demo_data_migration_service.dart' ;
16
- import 'package:ht_main/bloc_observer.dart' ;
17
- import 'package:ht_shared/ht_shared.dart' ;
18
- import 'package:ht_ui_kit/ht_ui_kit.dart' ;
12
+ import 'package:flutter_news_app_mobile_client_full_source_code/app/app.dart' ;
13
+ import 'package:flutter_news_app_mobile_client_full_source_code/app/config/config.dart'
14
+ as app_config;
15
+ import 'package:flutter_news_app_mobile_client_full_source_code/app/services/demo_data_migration_service.dart' ;
16
+ import 'package:flutter_news_app_mobile_client_full_source_code/bloc_observer.dart' ;
17
+ import 'package:http_client/http_client.dart' ;
18
+ import 'package:kv_storage_shared_preferences/kv_storage_shared_preferences.dart' ;
19
19
import 'package:logging/logging.dart' ;
20
20
import 'package:timeago/timeago.dart' as timeago;
21
+ import 'package:ui_kit/ui_kit.dart' ;
21
22
22
23
Future <Widget > bootstrap (
23
24
app_config.AppConfig appConfig,
@@ -31,126 +32,126 @@ Future<Widget> bootstrap(
31
32
32
33
final logger = Logger ('bootstrap' );
33
34
34
- final kvStorage = await HtKvStorageSharedPreferences .getInstance ();
35
+ final kvStorage = await KVStorageSharedPreferences .getInstance ();
35
36
36
- late final HtAuthClient authClient;
37
- late final HtAuthRepository authenticationRepository;
38
- HtHttpClient ? httpClient;
37
+ late final AuthClient authClient;
38
+ late final AuthRepository authenticationRepository;
39
+ HttpClient ? httpClient;
39
40
40
41
if (appConfig.environment == app_config.AppEnvironment .demo) {
41
- authClient = HtAuthInmemory ();
42
- authenticationRepository = HtAuthRepository (
42
+ authClient = AuthInmemory ();
43
+ authenticationRepository = AuthRepository (
43
44
authClient: authClient,
44
45
storageService: kvStorage,
45
46
);
46
47
} else {
47
48
// For production and development environments, an HTTP client is needed.
48
- httpClient = HtHttpClient (
49
+ httpClient = HttpClient (
49
50
baseUrl: appConfig.baseUrl,
50
51
tokenProvider: () => authenticationRepository.getAuthToken (),
51
52
logger: logger,
52
53
);
53
- authClient = HtAuthApi (httpClient: httpClient);
54
- authenticationRepository = HtAuthRepository (
54
+ authClient = AuthApi (httpClient: httpClient);
55
+ authenticationRepository = AuthRepository (
55
56
authClient: authClient,
56
57
storageService: kvStorage,
57
58
);
58
59
}
59
60
60
61
// Conditional data client instantiation based on environment
61
- HtDataClient <Headline > headlinesClient;
62
- HtDataClient <Topic > topicsClient;
63
- HtDataClient <Country > countriesClient;
64
- HtDataClient <Source > sourcesClient;
65
- HtDataClient <UserContentPreferences > userContentPreferencesClient;
66
- HtDataClient <UserAppSettings > userAppSettingsClient;
67
- HtDataClient <RemoteConfig > remoteConfigClient;
62
+ DataClient <Headline > headlinesClient;
63
+ DataClient <Topic > topicsClient;
64
+ DataClient <Country > countriesClient;
65
+ DataClient <Source > sourcesClient;
66
+ DataClient <UserContentPreferences > userContentPreferencesClient;
67
+ DataClient <UserAppSettings > userAppSettingsClient;
68
+ DataClient <RemoteConfig > remoteConfigClient;
68
69
69
70
if (appConfig.environment == app_config.AppEnvironment .demo) {
70
- headlinesClient = HtDataInMemory <Headline >(
71
+ headlinesClient = DataInMemory <Headline >(
71
72
toJson: (i) => i.toJson (),
72
73
getId: (i) => i.id,
73
74
initialData: headlinesFixturesData,
74
75
logger: logger,
75
76
);
76
- topicsClient = HtDataInMemory <Topic >(
77
+ topicsClient = DataInMemory <Topic >(
77
78
toJson: (i) => i.toJson (),
78
79
getId: (i) => i.id,
79
80
initialData: topicsFixturesData,
80
81
logger: logger,
81
82
);
82
- countriesClient = HtDataInMemory <Country >(
83
+ countriesClient = DataInMemory <Country >(
83
84
toJson: (i) => i.toJson (),
84
85
getId: (i) => i.id,
85
86
initialData: countriesFixturesData,
86
87
logger: logger,
87
88
);
88
- sourcesClient = HtDataInMemory <Source >(
89
+ sourcesClient = DataInMemory <Source >(
89
90
toJson: (i) => i.toJson (),
90
91
getId: (i) => i.id,
91
92
initialData: sourcesFixturesData,
92
93
logger: logger,
93
94
);
94
- userContentPreferencesClient = HtDataInMemory <UserContentPreferences >(
95
+ userContentPreferencesClient = DataInMemory <UserContentPreferences >(
95
96
toJson: (i) => i.toJson (),
96
97
getId: (i) => i.id,
97
98
logger: logger,
98
99
);
99
- userAppSettingsClient = HtDataInMemory <UserAppSettings >(
100
+ userAppSettingsClient = DataInMemory <UserAppSettings >(
100
101
toJson: (i) => i.toJson (),
101
102
getId: (i) => i.id,
102
103
logger: logger,
103
104
);
104
- remoteConfigClient = HtDataInMemory <RemoteConfig >(
105
+ remoteConfigClient = DataInMemory <RemoteConfig >(
105
106
toJson: (i) => i.toJson (),
106
107
getId: (i) => i.id,
107
108
initialData: remoteConfigsFixturesData,
108
109
logger: logger,
109
110
);
110
111
} else if (appConfig.environment == app_config.AppEnvironment .development) {
111
- headlinesClient = HtDataApi <Headline >(
112
+ headlinesClient = DataApi <Headline >(
112
113
httpClient: httpClient! ,
113
114
modelName: 'headline' ,
114
115
fromJson: Headline .fromJson,
115
116
toJson: (headline) => headline.toJson (),
116
117
logger: logger,
117
118
);
118
- topicsClient = HtDataApi <Topic >(
119
+ topicsClient = DataApi <Topic >(
119
120
httpClient: httpClient,
120
121
modelName: 'topic' ,
121
122
fromJson: Topic .fromJson,
122
123
toJson: (topic) => topic.toJson (),
123
124
logger: logger,
124
125
);
125
- countriesClient = HtDataApi <Country >(
126
+ countriesClient = DataApi <Country >(
126
127
httpClient: httpClient,
127
128
modelName: 'country' ,
128
129
fromJson: Country .fromJson,
129
130
toJson: (country) => country.toJson (),
130
131
logger: logger,
131
132
);
132
- sourcesClient = HtDataApi <Source >(
133
+ sourcesClient = DataApi <Source >(
133
134
httpClient: httpClient,
134
135
modelName: 'source' ,
135
136
fromJson: Source .fromJson,
136
137
toJson: (source) => source.toJson (),
137
138
logger: logger,
138
139
);
139
- userContentPreferencesClient = HtDataApi <UserContentPreferences >(
140
+ userContentPreferencesClient = DataApi <UserContentPreferences >(
140
141
httpClient: httpClient,
141
142
modelName: 'user_content_preferences' ,
142
143
fromJson: UserContentPreferences .fromJson,
143
144
toJson: (prefs) => prefs.toJson (),
144
145
logger: logger,
145
146
);
146
- userAppSettingsClient = HtDataApi <UserAppSettings >(
147
+ userAppSettingsClient = DataApi <UserAppSettings >(
147
148
httpClient: httpClient,
148
149
modelName: 'user_app_settings' ,
149
150
fromJson: UserAppSettings .fromJson,
150
151
toJson: (settings) => settings.toJson (),
151
152
logger: logger,
152
153
);
153
- remoteConfigClient = HtDataApi <RemoteConfig >(
154
+ remoteConfigClient = DataApi <RemoteConfig >(
154
155
httpClient: httpClient,
155
156
modelName: 'remote_config' ,
156
157
fromJson: RemoteConfig .fromJson,
@@ -159,49 +160,49 @@ Future<Widget> bootstrap(
159
160
);
160
161
} else {
161
162
// Default to API clients for production
162
- headlinesClient = HtDataApi <Headline >(
163
+ headlinesClient = DataApi <Headline >(
163
164
httpClient: httpClient! ,
164
165
modelName: 'headline' ,
165
166
fromJson: Headline .fromJson,
166
167
toJson: (headline) => headline.toJson (),
167
168
logger: logger,
168
169
);
169
- topicsClient = HtDataApi <Topic >(
170
+ topicsClient = DataApi <Topic >(
170
171
httpClient: httpClient,
171
172
modelName: 'topic' ,
172
173
fromJson: Topic .fromJson,
173
174
toJson: (topic) => topic.toJson (),
174
175
logger: logger,
175
176
);
176
- countriesClient = HtDataApi <Country >(
177
+ countriesClient = DataApi <Country >(
177
178
httpClient: httpClient,
178
179
modelName: 'country' ,
179
180
fromJson: Country .fromJson,
180
181
toJson: (country) => country.toJson (),
181
182
logger: logger,
182
183
);
183
- sourcesClient = HtDataApi <Source >(
184
+ sourcesClient = DataApi <Source >(
184
185
httpClient: httpClient,
185
186
modelName: 'source' ,
186
187
fromJson: Source .fromJson,
187
188
toJson: (source) => source.toJson (),
188
189
logger: logger,
189
190
);
190
- userContentPreferencesClient = HtDataApi <UserContentPreferences >(
191
+ userContentPreferencesClient = DataApi <UserContentPreferences >(
191
192
httpClient: httpClient,
192
193
modelName: 'user_content_preferences' ,
193
194
fromJson: UserContentPreferences .fromJson,
194
195
toJson: (prefs) => prefs.toJson (),
195
196
logger: logger,
196
197
);
197
- userAppSettingsClient = HtDataApi <UserAppSettings >(
198
+ userAppSettingsClient = DataApi <UserAppSettings >(
198
199
httpClient: httpClient,
199
200
modelName: 'user_app_settings' ,
200
201
fromJson: UserAppSettings .fromJson,
201
202
toJson: (settings) => settings.toJson (),
202
203
logger: logger,
203
204
);
204
- remoteConfigClient = HtDataApi <RemoteConfig >(
205
+ remoteConfigClient = DataApi <RemoteConfig >(
205
206
httpClient: httpClient,
206
207
modelName: 'remote_config' ,
207
208
fromJson: RemoteConfig .fromJson,
@@ -210,22 +211,22 @@ Future<Widget> bootstrap(
210
211
);
211
212
}
212
213
213
- final headlinesRepository = HtDataRepository <Headline >(
214
+ final headlinesRepository = DataRepository <Headline >(
214
215
dataClient: headlinesClient,
215
216
);
216
- final topicsRepository = HtDataRepository <Topic >(dataClient: topicsClient);
217
- final countriesRepository = HtDataRepository <Country >(
217
+ final topicsRepository = DataRepository <Topic >(dataClient: topicsClient);
218
+ final countriesRepository = DataRepository <Country >(
218
219
dataClient: countriesClient,
219
220
);
220
- final sourcesRepository = HtDataRepository <Source >(dataClient: sourcesClient);
221
+ final sourcesRepository = DataRepository <Source >(dataClient: sourcesClient);
221
222
final userContentPreferencesRepository =
222
- HtDataRepository <UserContentPreferences >(
223
+ DataRepository <UserContentPreferences >(
223
224
dataClient: userContentPreferencesClient,
224
225
);
225
- final userAppSettingsRepository = HtDataRepository <UserAppSettings >(
226
+ final userAppSettingsRepository = DataRepository <UserAppSettings >(
226
227
dataClient: userAppSettingsClient,
227
228
);
228
- final remoteConfigRepository = HtDataRepository <RemoteConfig >(
229
+ final remoteConfigRepository = DataRepository <RemoteConfig >(
229
230
dataClient: remoteConfigClient,
230
231
);
231
232
@@ -239,7 +240,7 @@ Future<Widget> bootstrap(
239
240
: null ;
240
241
241
242
return App (
242
- htAuthenticationRepository : authenticationRepository,
243
+ authenticationRepository : authenticationRepository,
243
244
htHeadlinesRepository: headlinesRepository,
244
245
htTopicsRepository: topicsRepository,
245
246
htCountriesRepository: countriesRepository,
0 commit comments