feat(flutter): 接入分类记录收藏与下载授权
This commit is contained in:
1 parent
00280ca0da
commit
cc4d7c5a9d
52 files changed
+4440
-171
No files matched your search
+41
-6
@@ -9,10 +9,14 @@ import 'core/config/locale_controller.dart';
|
||||
import 'core/data/remote/api_client.dart';
|
||||
import 'core/data/remote/auth_api.dart';
|
||||
import 'core/data/remote/catalog_api.dart';
|
||||
import 'core/data/remote/category_api.dart';
|
||||
import 'core/data/remote/download_api.dart';
|
||||
import 'core/data/remote/library_api.dart';
|
||||
import 'core/data/remote/playback_api.dart';
|
||||
import 'core/data/remote/watch_api.dart';
|
||||
import 'core/data/repositories/catalog_repository.dart';
|
||||
import 'core/data/repositories/category_repository.dart';
|
||||
import 'core/data/repositories/download_repository.dart';
|
||||
import 'core/data/repositories/engagement_repository.dart';
|
||||
import 'core/data/repositories/favorite_repository.dart';
|
||||
import 'core/data/repositories/playback_repository.dart';
|
||||
@@ -20,6 +24,8 @@ import 'core/data/repositories/watch_history_repository.dart';
|
||||
import 'core/data/services/auth_controller.dart';
|
||||
import 'core/data/services/auth_session_store.dart';
|
||||
import 'core/data/services/catalog_controller.dart';
|
||||
import 'core/data/services/category_controller.dart';
|
||||
import 'core/data/services/download_controller.dart';
|
||||
import 'core/data/services/engagement_controller.dart';
|
||||
import 'core/data/services/favorite_controller.dart';
|
||||
import 'core/data/services/playback_session.dart';
|
||||
@@ -32,6 +38,8 @@ class LumaDramaApp extends StatefulWidget {
|
||||
super.key,
|
||||
this.playerFactory = VideoPlayerPort.new,
|
||||
this.catalogRepository,
|
||||
this.categoryRepository,
|
||||
this.downloadRepository,
|
||||
this.watchHistoryRepository,
|
||||
this.favoriteRepository,
|
||||
this.playbackRepository,
|
||||
@@ -41,6 +49,8 @@ class LumaDramaApp extends StatefulWidget {
|
||||
|
||||
/// 测试注入用;生产走 HTTP 仓库。
|
||||
final CatalogRepository? catalogRepository;
|
||||
final CategoryRepository? categoryRepository;
|
||||
final DownloadRepository? downloadRepository;
|
||||
final WatchHistoryRepository? watchHistoryRepository;
|
||||
final FavoriteRepository? favoriteRepository;
|
||||
final PlaybackRepository? playbackRepository;
|
||||
@@ -61,7 +71,17 @@ class _LumaDramaAppState extends State<LumaDramaApp> {
|
||||
deviceIdReader: _sessionStore.deviceId,
|
||||
);
|
||||
|
||||
late final AuthController _auth = AuthController(AuthApi(_apiClient), _sessionStore);
|
||||
late final AuthController _auth = AuthController(
|
||||
AuthApi(_apiClient),
|
||||
_sessionStore,
|
||||
);
|
||||
|
||||
late final CatalogRepository _catalogRepository =
|
||||
widget.catalogRepository ?? HttpCatalogRepository(CatalogApi(_apiClient));
|
||||
|
||||
late final CategoryRepository _categoryRepository =
|
||||
widget.categoryRepository ??
|
||||
HttpCategoryRepository(CategoryApi(_apiClient), _catalogRepository);
|
||||
|
||||
late final WatchHistoryRepository _watchHistory =
|
||||
widget.watchHistoryRepository ??
|
||||
@@ -78,9 +98,20 @@ class _LumaDramaAppState extends State<LumaDramaApp> {
|
||||
);
|
||||
|
||||
late final PlaybackRepository _playback =
|
||||
widget.playbackRepository ?? HttpPlaybackRepository(PlaybackApi(_apiClient));
|
||||
widget.playbackRepository ??
|
||||
HttpPlaybackRepository(PlaybackApi(_apiClient));
|
||||
|
||||
late final FavoriteController _favoriteController = FavoriteController(_favorites);
|
||||
late final FavoriteController _favoriteController = FavoriteController(
|
||||
_favorites,
|
||||
);
|
||||
|
||||
late final DownloadRepository _downloadRepository =
|
||||
widget.downloadRepository ??
|
||||
HttpDownloadRepository(DownloadApi(_apiClient));
|
||||
|
||||
late final DownloadController _downloadController = DownloadController(
|
||||
_downloadRepository,
|
||||
);
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -101,6 +132,7 @@ class _LumaDramaAppState extends State<LumaDramaApp> {
|
||||
unawaited(_favoriteController.load());
|
||||
} else {
|
||||
_favoriteController.clear();
|
||||
_downloadController.reset();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,6 +140,7 @@ class _LumaDramaAppState extends State<LumaDramaApp> {
|
||||
void dispose() {
|
||||
_auth.removeListener(_onAuthChanged);
|
||||
_favoriteController.dispose();
|
||||
_downloadController.dispose();
|
||||
_apiClient.close();
|
||||
super.dispose();
|
||||
}
|
||||
@@ -122,12 +155,14 @@ class _LumaDramaAppState extends State<LumaDramaApp> {
|
||||
Provider<WatchHistoryRepository>.value(value: _watchHistory),
|
||||
Provider<FavoriteRepository>.value(value: _favorites),
|
||||
ChangeNotifierProvider(
|
||||
create: (_) => CatalogController(
|
||||
widget.catalogRepository ?? HttpCatalogRepository(CatalogApi(_apiClient)),
|
||||
)..load(),
|
||||
create: (_) => CatalogController(_catalogRepository)..load(),
|
||||
),
|
||||
ChangeNotifierProvider(
|
||||
create: (_) => CategoryController(_categoryRepository)..load(),
|
||||
),
|
||||
ChangeNotifierProvider(create: (_) => LocaleController()..load()),
|
||||
ChangeNotifierProvider.value(value: _favoriteController),
|
||||
ChangeNotifierProvider.value(value: _downloadController),
|
||||
ChangeNotifierProvider(
|
||||
create: (_) =>
|
||||
EngagementController(SharedPreferencesEngagementRepository())
|
||||
|
||||
Reference in new issue
Block a user