From 77d5748dbb8a6137ac51d636e0a87c04107be294 Mon Sep 17 00:00:00 2001 From: Vicky <10212746+haifeng-jiang@user.noreply.gitee.com> Date: Thu, 15 Oct 2026 17:53:27 +0800 Subject: [PATCH 01/76] =?UTF-8?q?chore(client):=20=E5=BD=92=E6=A1=A3?= =?UTF-8?q?=E5=8E=9F=E5=9E=8B=E9=98=B6=E6=AE=B5=E6=9C=AA=E6=8F=90=E4=BA=A4?= =?UTF-8?q?=E6=94=B9=E5=8A=A8=EF=BC=88binding/logic/view=20=E5=88=86?= =?UTF-8?q?=E5=B1=82=E4=B8=8E=E5=90=84=E9=A1=B5=E8=BF=AD=E4=BB=A3=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 为什么:客户端原型在 14d7bd3 之后又做了一轮(页面分层、发现页、分类滑动、播放器控件等), 一直留在工作区没入库。下一批账号链路要改其中的 app.dart / home_view / player_view / mine_view, 先归档这批既存改动,本批的实际 diff 才说得清边界。 只归档,不改行为:当前工作区 flutter analyze 0 问题、flutter test 148 全过。 --- README.md | 35 +- android/app/src/debug/AndroidManifest.xml | 2 + android/app/src/main/AndroidManifest.xml | 1 + android/app/src/profile/AndroidManifest.xml | 2 + ios/Runner.xcodeproj/project.pbxproj | 6 +- ios/Runner/Info.plist | 7 + lib/core/data/models/drama.dart | 108 ++- .../data/repositories/catalog_repository.dart | 126 +-- .../watch_history_repository.dart | 13 + .../data/services/catalog_controller.dart | 56 +- lib/core/data/services/playback_session.dart | 14 +- lib/core/data/services/video_player_port.dart | 25 +- lib/pages/discover/discover_logic.dart | 24 +- lib/pages/discover/discover_view.dart | 826 ++++++++---------- .../drama_detail/drama_detail_logic.dart | 33 +- lib/pages/drama_detail/drama_detail_view.dart | 50 +- lib/pages/home/home_feed_sections.dart | 30 - .../home/widgets/category_swipe_region.dart | 35 - lib/pages/home/widgets/home_feed_header.dart | 170 ---- lib/pages/home/widgets/home_quick_drawer.dart | 19 +- lib/pages/mine/mine_logic.dart | 6 +- lib/pages/player/player_logic.dart | 259 ++++-- .../player/widgets/seek_progress_bar.dart | 42 +- pubspec.lock | 24 + pubspec.yaml | 11 +- test/catalog/catalog_controller_test.dart | 138 ++- test/catalog/demo_media_test.dart | 26 - test/catalog/home_feed_category_test.dart | 22 - test/playback/playback_preload_test.dart | 2 +- test/playback/playback_queue_test.dart | 90 +- test/playback/playback_session_test.dart | 43 +- test/playback/seek_progress_bar_test.dart | 7 +- test/playback/watch_history_test.dart | 76 ++ 33 files changed, 1264 insertions(+), 1064 deletions(-) delete mode 100644 lib/pages/home/home_feed_sections.dart delete mode 100644 lib/pages/home/widgets/category_swipe_region.dart delete mode 100644 lib/pages/home/widgets/home_feed_header.dart delete mode 100644 test/catalog/demo_media_test.dart delete mode 100644 test/catalog/home_feed_category_test.dart diff --git a/README.md b/README.md index c2bc86e..8ee766b 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,39 @@ 项目使用 Flutter、Provider 和 `video_player`。播放会话统一管理播放器生命周期;观看进度和演示互动数据保存在本机。首页、找剧、我的共用同一个根页面,切换时保留页面状态。 +## 对接后端 + +目录数据来自短剧服务的客户端接口(`FruitServer` 的 `reelshort-app-api`,默认 `http://127.0.0.1:8081`): + +- `GET /app/home/feed`、`GET /app/discover/feed`:轮播 + 分区,一次请求渲染整页。 + 每张卡片带 `preview`(首个可播免费集),首页竖屏播放可以直接起播; + 没有片源的剧不下发 `preview`,也不会出现在首页的滑动队列里 +- `GET /app/dramas/{id}`:详情(含剧集列表;可播放的剧集直接带播放地址) +- `GET /app/episodes/{id}/play`:播放票据,返回可访问性与地址 + +启动后端后直接 `flutter run` 或 Xcode 里 Run 即可,接口地址按运行环境自动选择 +(见 `lib/core/config/app_config.dart`): + +| 运行环境 | 默认地址 | +| --- | --- | +| iOS 模拟器 / 桌面端 | `http://127.0.0.1:8081` | +| iPhone 真机 | [`devHostBaseUrl`],即电脑当前的局域网地址(`ipconfig getifaddr en0`) | +| Android 模拟器 | 需手动指定 `--dart-define=API_BASE_URL=http://10.0.2.2:8081` | + +任何环境都可以用 `--dart-define=API_BASE_URL=http://x.x.x.x:8081` 覆盖默认值。 +电脑换网络后局域网地址会变,改 `devHostBaseUrl` 即可;也可以换成 Bonjour 名字 +(`http://$(scutil --get LocalHostName).local:8081`),换网络也不用改。 + +真机调试还需注意:手机和电脑在同一个 Wi-Fi;首次启动时 iPhone 会弹「本地网络」权限, +必须允许;iOS 的明文 HTTP 与局域网访问已在 `ios/Runner/Info.plist` 里放行 +(`NSAllowsLocalNetworking`、`NSLocalNetworkUsageDescription`),改动这些配置后 +要重新构建安装,热重载不生效;如果仍连不上,到「系统设置 → 网络 → 防火墙 → 选项」 +把 `java` 设为允许传入连接。 + +封面与视频都走 `http://:8081/files/**`,本地不再打包演示素材 +(原先 `assets/media` 里的演示视频有 316MB,已从打包清单移除)。 + ## 当前说明 -现阶段的剧目与剧集是演示数据,多部剧暂时复用同一段测试视频。 +收藏、点赞、评论与观看进度仍保存在本机(后端互动接口尚未开发); +金币与会员相关界面仍是占位数据。 diff --git a/android/app/src/debug/AndroidManifest.xml b/android/app/src/debug/AndroidManifest.xml index 399f698..cbb4f77 100644 --- a/android/app/src/debug/AndroidManifest.xml +++ b/android/app/src/debug/AndroidManifest.xml @@ -4,4 +4,6 @@ to allow setting breakpoints, to provide hot reload, etc. --> + + diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 674882b..6b90a62 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -1,4 +1,5 @@ + + + diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index 6833b0c..b8a8db0 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -360,7 +360,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 13.0; + IPHONEOS_DEPLOYMENT_TARGET = 15.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = iphoneos; @@ -487,7 +487,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 13.0; + IPHONEOS_DEPLOYMENT_TARGET = 15.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; @@ -538,7 +538,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 13.0; + IPHONEOS_DEPLOYMENT_TARGET = 15.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = iphoneos; diff --git a/ios/Runner/Info.plist b/ios/Runner/Info.plist index 724c986..d52254b 100644 --- a/ios/Runner/Info.plist +++ b/ios/Runner/Info.plist @@ -26,6 +26,13 @@ $(FLUTTER_BUILD_NUMBER) LSRequiresIPhoneOS + NSAppTransportSecurity + + NSAllowsLocalNetworking + + + NSLocalNetworkUsageDescription + 开发阶段需要访问同一局域网内的短剧内容服务。 UIApplicationSceneManifest UIApplicationSupportsMultipleScenes diff --git a/lib/core/data/models/drama.dart b/lib/core/data/models/drama.dart index 8a90835..a137f78 100644 --- a/lib/core/data/models/drama.dart +++ b/lib/core/data/models/drama.dart @@ -1,19 +1,51 @@ -enum DramaFormat { animated, liveAction } - +/// 短剧与剧集,字段与后端 `/app/**` 的下发结构对应。 +/// +/// 封面与播放地址都是后端返回的相对路径(`/files/...`), +/// 渲染前用 `AppConfig.mediaUrl` 补上服务地址。 class Episode { const Episode({ required this.id, required this.number, required this.title, - required this.assetPath, required this.isFree, + this.videoUrl = '', + this.durationSec = 0, + this.locked = false, }); final String id; final int number; final String title; - final String assetPath; final bool isFree; + + /// 播放地址:详情接口不下发,由 `/app/episodes/{id}/play` 返回后写入。 + final String videoUrl; + final int durationSec; + + /// 后端判定需要解锁;解锁能力(金币/VIP)在 M3 接入。 + final bool locked; + + Episode withVideoUrl(String url) => Episode( + id: id, + number: number, + title: title, + isFree: isFree, + videoUrl: url, + durationSec: durationSec, + locked: locked, + ); + + factory Episode.fromJson(Map json) { + return Episode( + id: (json['id'] ?? '').toString(), + number: (json['number'] as num?)?.toInt() ?? 0, + title: json['title'] as String? ?? '', + isFree: json['isFree'] == true, + durationSec: (json['durationSec'] as num?)?.toInt() ?? 0, + locked: json['locked'] == true, + videoUrl: json['playUrl'] as String? ?? '', + ); + } } class Drama { @@ -21,15 +53,73 @@ class Drama { required this.id, required this.title, required this.synopsis, - required this.posterAsset, - required this.episodes, - this.format = DramaFormat.liveAction, + required this.posterUrl, + this.episodes = const [], + this.category = '', + this.genre = '', + this.totalEpisodes = 0, + this.freeEpisodes = 0, + this.isHot = false, + this.viewCount = 0, + this.detailLoaded = false, }); final String id; final String title; final String synopsis; - final String posterAsset; + final String posterUrl; final List episodes; - final DramaFormat format; + final String category; + final String genre; + final int totalEpisodes; + final int freeEpisodes; + final bool isHot; + final int viewCount; + + /// 详情接口是否已经取过完整剧集列表。 + /// 列表卡片只带一集可播预览,需要完整剧集时再进详情。 + final bool detailLoaded; + + /// 卡片只带一集预览,集数以后端给的总集数为准。 + int get episodeCount => totalEpisodes > 0 ? totalEpisodes : episodes.length; + + /// 列表卡片:带一集可播预览(首页直接起播),完整剧集进详情再取。 + factory Drama.fromCardJson(Map json) { + final preview = json['preview']; + return Drama( + id: (json['id'] ?? '').toString(), + title: json['title'] as String? ?? '', + synopsis: json['synopsis'] as String? ?? '', + posterUrl: json['cover'] as String? ?? '', + episodes: preview is Map + ? [Episode.fromJson(preview)] + : const [], + category: json['category'] as String? ?? '', + genre: json['genre'] as String? ?? '', + totalEpisodes: (json['totalEpisodes'] as num?)?.toInt() ?? 0, + isHot: json['isHot'] == true, + viewCount: (json['viewCount'] as num?)?.toInt() ?? 0, + ); + } + + /// 详情:带剧集列表。 + factory Drama.fromDetailJson(Map json) { + return Drama( + id: (json['id'] ?? '').toString(), + title: json['title'] as String? ?? '', + synopsis: json['synopsis'] as String? ?? '', + posterUrl: json['cover'] as String? ?? '', + category: json['category'] as String? ?? '', + genre: json['genre'] as String? ?? '', + totalEpisodes: (json['totalEpisodes'] as num?)?.toInt() ?? 0, + freeEpisodes: (json['freeEpisodes'] as num?)?.toInt() ?? 0, + isHot: json['isHot'] == true, + viewCount: (json['viewCount'] as num?)?.toInt() ?? 0, + detailLoaded: true, + episodes: (json['episodes'] as List? ?? const []) + .whereType>() + .map(Episode.fromJson) + .toList(), + ); + } } diff --git a/lib/core/data/repositories/catalog_repository.dart b/lib/core/data/repositories/catalog_repository.dart index e5ee180..8762895 100644 --- a/lib/core/data/repositories/catalog_repository.dart +++ b/lib/core/data/repositories/catalog_repository.dart @@ -1,104 +1,36 @@ import '../models/drama.dart'; +import '../models/home_feed.dart'; +import '../models/play_ticket.dart'; +import '../remote/catalog_api.dart'; +/// 目录数据来源:首页/发现页聚合、详情、播放票据。 +/// +/// 首页卡片不带剧集,进详情或播放时才按需取,保证列表接口足够轻。 abstract interface class CatalogRepository { - Future> fetchDramas(); + Future fetchHomeFeed(); + + Future fetchDiscoverFeed(); + + Future fetchDrama(String dramaId); + + Future resolvePlay(String episodeId); } -class DemoCatalogRepository implements CatalogRepository { +class HttpCatalogRepository implements CatalogRepository { + HttpCatalogRepository(this._api); + + final CatalogApi _api; + @override - Future> fetchDramas() async => const [ - Drama( - id: 'the-signal-demo', - title: 'The Signal', - synopsis: - 'A mock series for testing vertical episode playback with one reused local clip.', - posterAsset: 'assets/images/stitch_signal_poster_clean.png', - format: DramaFormat.animated, - episodes: [ - Episode( - id: 'signal-01', - number: 1, - title: 'Episode 1', - assetPath: 'assets/media/demo_clip.mp4', - isFree: true, - ), - Episode( - id: 'signal-02', - number: 2, - title: 'Episode 2', - assetPath: 'assets/media/demo_clip.mp4', - isFree: true, - ), - Episode( - id: 'signal-03', - number: 3, - title: 'Episode 3', - assetPath: 'assets/media/demo_clip.mp4', - isFree: true, - ), - ], - ), - Drama( - id: 'city-lights-demo', - title: 'City Lights & Velvet Nights', - synopsis: - 'A mock romance series using the same local video for navigation testing.', - posterAsset: 'assets/images/stitch_city_poster_clean.png', - format: DramaFormat.liveAction, - episodes: [ - Episode( - id: 'city-01', - number: 1, - title: 'Episode 1', - assetPath: 'assets/media/demo_clip.mp4', - isFree: true, - ), - Episode( - id: 'city-02', - number: 2, - title: 'Episode 2', - assetPath: 'assets/media/demo_clip.mp4', - isFree: true, - ), - Episode( - id: 'city-03', - number: 3, - title: 'Episode 3', - assetPath: 'assets/media/demo_clip.mp4', - isFree: true, - ), - ], - ), - Drama( - id: 'vengeance-demo', - title: 'Vengeance Rising', - synopsis: - 'A mock action series using the same local video for navigation testing.', - posterAsset: 'assets/images/stitch_vengeance_poster_clean.png', - format: DramaFormat.liveAction, - episodes: [ - Episode( - id: 'vengeance-01', - number: 1, - title: 'Episode 1', - assetPath: 'assets/media/demo_clip.mp4', - isFree: true, - ), - Episode( - id: 'vengeance-02', - number: 2, - title: 'Episode 2', - assetPath: 'assets/media/demo_clip.mp4', - isFree: true, - ), - Episode( - id: 'vengeance-03', - number: 3, - title: 'Episode 3', - assetPath: 'assets/media/demo_clip.mp4', - isFree: true, - ), - ], - ), - ]; + Future fetchHomeFeed() => _api.homeFeed(); + + @override + Future fetchDiscoverFeed() => _api.discoverFeed(); + + @override + Future fetchDrama(String dramaId) => _api.dramaDetail(dramaId); + + @override + Future resolvePlay(String episodeId) => + _api.playTicket(episodeId); } diff --git a/lib/core/data/repositories/watch_history_repository.dart b/lib/core/data/repositories/watch_history_repository.dart index 746500c..da15c63 100644 --- a/lib/core/data/repositories/watch_history_repository.dart +++ b/lib/core/data/repositories/watch_history_repository.dart @@ -1,5 +1,7 @@ import 'package:shared_preferences/shared_preferences.dart'; +import '../models/drama.dart'; + const demoProfileId = 'demo-local-v1'; abstract interface class WatchHistoryRepository { @@ -60,6 +62,17 @@ class SharedPreferencesWatchHistoryRepository } } +/// 续看位置:列表卡片没有剧集列表,取不到首集时退回最近观看的那一集。 +extension WatchHistoryResume on WatchHistoryRepository { + Future resumePositionFor(String profileId, Drama drama) async { + final episodeId = drama.episodes.isNotEmpty + ? drama.episodes.first.id + : await lastEpisodeId(profileId, drama.id); + if (episodeId == null) return null; + return positionFor(profileId, drama.id, episodeId); + } +} + Duration clampResumePosition(Duration saved, Duration duration) { if (duration <= const Duration(milliseconds: 500)) return Duration.zero; if (saved <= Duration.zero) return Duration.zero; diff --git a/lib/core/data/services/catalog_controller.dart b/lib/core/data/services/catalog_controller.dart index c2e1b70..00e446c 100644 --- a/lib/core/data/services/catalog_controller.dart +++ b/lib/core/data/services/catalog_controller.dart @@ -1,26 +1,72 @@ import 'package:flutter/foundation.dart'; -import '../models/drama.dart'; -import '../repositories/catalog_repository.dart'; +import '../models/drama.dart'; +import '../models/home_feed.dart'; +import '../repositories/catalog_repository.dart'; +import '../remote/api_client.dart'; + +/// 目录状态:首页/发现页聚合数据 + 详情按需加载。 +/// +/// 列表卡片不含剧集,只有进详情或播放时才取一次详情, +/// 这样首页接口能保持很小的响应体。 class CatalogController extends ChangeNotifier { CatalogController(this.repository); + final CatalogRepository repository; - List dramas = const []; + HomeFeed feed = const HomeFeed(); bool loading = false; String? error; + List get dramas => feed.dramas; + List get banners => feed.banners; + List get sections => feed.sections; + Future load() async { loading = true; error = null; notifyListeners(); try { - dramas = await repository.fetchDramas(); + feed = await repository.fetchHomeFeed(); + } on ApiException catch (exception) { + error = exception.message; } catch (_) { - error = 'The catalog could not be loaded.'; + error = 'catalogError'; } finally { loading = false; notifyListeners(); } } + + /// 需要完整剧集时补一次详情;已加载过则直接返回,避免重复请求。 + Future requireDetail(Drama drama) async { + if (drama.detailLoaded) return drama; + final detail = await repository.fetchDrama(drama.id); + _replace(detail); + return detail; + } + + /// 播放前解析票据:返回带播放地址的剧集,锁定集保持无地址。 + Future resolvePlay(Episode episode) async { + if (episode.videoUrl.isNotEmpty) return episode; + final ticket = await repository.resolvePlay(episode.id); + return ticket.accessible ? episode.withVideoUrl(ticket.playUrl) : episode; + } + + void _replace(Drama detail) { + final sections = feed.sections + .map( + (section) => FeedSection( + code: section.code, + title: section.title, + dramas: [ + for (final drama in section.dramas) + if (drama.id == detail.id) detail else drama, + ], + ), + ) + .toList(); + feed = HomeFeed(banners: feed.banners, sections: sections); + notifyListeners(); + } } diff --git a/lib/core/data/services/playback_session.dart b/lib/core/data/services/playback_session.dart index bc2d864..b1f3210 100644 --- a/lib/core/data/services/playback_session.dart +++ b/lib/core/data/services/playback_session.dart @@ -128,6 +128,9 @@ class PlaybackSession extends ChangeNotifier { if (!slot.retiring && !_closed) slot.prepared = true; } catch (error) { slot.failure = error; + if (kDebugMode) { + debugPrint('片源准备失败 ${episodes[index].videoUrl}: $error'); + } } }(); return slot; @@ -149,14 +152,23 @@ class PlaybackSession extends ChangeNotifier { /// use exactly the same mechanism without warming an unrelated episode. Future select(int index, {int? preloadIndex}) async { if (_closed || index < 0 || index >= episodes.length) return; + // 切到另一集时,上一集按下的暂停不跟着走:滑过去就应该自动播放。 + // 重复选中同一集(例如页面重新可见)不在这里恢复,尊重用户按下的暂停。 + if (!_selected || index != _currentIndex) { + _userWantsPlay = true; + } final request = ++_generation; _selected = true; _currentIndex = index; _nextIndex = preloadIndex; _error = null; + if (!_visible) { + _loading = false; + _notify(); + return; + } _loading = preparedPlayerAt(index) == null && !isLocked; _notify(); - if (!_visible) return; final acquired = await _coordinator._acquire( this, () => _visible && request == _generation, diff --git a/lib/core/data/services/video_player_port.dart b/lib/core/data/services/video_player_port.dart index b334db5..4256398 100644 --- a/lib/core/data/services/video_player_port.dart +++ b/lib/core/data/services/video_player_port.dart @@ -1,5 +1,6 @@ import 'package:video_player/video_player.dart'; +import '../../config/app_config.dart'; import '../models/drama.dart'; import '../models/player_port.dart'; @@ -7,11 +8,25 @@ class VideoPlayerPort implements PlayerPort { VideoPlayerPort( Episode episode, { Future? closedCaptionFile, - }) : controller = VideoPlayerController.asset( - episode.assetPath, - closedCaptionFile: closedCaptionFile, - videoPlayerOptions: VideoPlayerOptions(mixWithOthers: false), - ); + }) : controller = _open(episode, closedCaptionFile); + + /// 后端下发的是相对路径(`/files/...`),交给播放器前补上服务地址。 + /// 否则 Uri 没有 scheme/host,AVPlayer 和 ExoPlayer 都加载不了。 + static Uri resolveUri(Episode episode) => + Uri.parse(AppConfig.mediaUrl(episode.videoUrl)); + + static VideoPlayerController _open( + Episode episode, + Future? closedCaptionFile, + ) { + final options = VideoPlayerOptions(mixWithOthers: false); + // 片源统一由后端下发(详情里的可播放地址 / 播放票据) + return VideoPlayerController.networkUrl( + resolveUri(episode), + closedCaptionFile: closedCaptionFile, + videoPlayerOptions: options, + ); + } final VideoPlayerController controller; Future? _initialization; diff --git a/lib/pages/discover/discover_logic.dart b/lib/pages/discover/discover_logic.dart index dce193f..0536385 100644 --- a/lib/pages/discover/discover_logic.dart +++ b/lib/pages/discover/discover_logic.dart @@ -18,6 +18,7 @@ class DiscoverLogic extends ChangeNotifier { final FocusNode searchFocus = FocusNode(); final ScrollController scroll = ScrollController(); int category = 0; + bool searchOpen = false; bool _disposed = false; void notify() { @@ -25,11 +26,7 @@ class DiscoverLogic extends ChangeNotifier { } void refreshPosition() { - position = history.positionFor( - demoProfileId, - drama.id, - drama.episodes.first.id, - ); + position = history.resumePositionFor(demoProfileId, drama); } void selectCategory(int index) { @@ -39,6 +36,14 @@ class DiscoverLogic extends ChangeNotifier { void onSearchChanged() => notify(); + bool get showSearch => searchOpen || search.text.isNotEmpty; + + void openSearch() { + searchOpen = true; + notify(); + searchFocus.requestFocus(); + } + void syncDrama({ required bool active, required bool wasActive, @@ -54,6 +59,8 @@ class DiscoverLogic extends ChangeNotifier { notify(); } if (active && searchRequest != previousSearchRequest) { + searchOpen = true; + notify(); WidgetsBinding.instance.addPostFrameCallback((_) { if (isActive()) searchFocus.requestFocus(); }); @@ -113,8 +120,9 @@ class DiscoverLogic extends ChangeNotifier { void showFilters(BuildContext context) { final l10n = AppLocalizations.of(context)!; final labels = [ - l10n.featured, - l10n.suspense, + l10n.forYou, + l10n.hot, + l10n.newest, l10n.romance, l10n.actionGenre, ]; @@ -131,7 +139,7 @@ class DiscoverLogic extends ChangeNotifier { ListTile( title: Text(labels[index]), trailing: index == category - ? const Icon(Icons.check_rounded, color: Color(0xFFFF5B3D)) + ? const Icon(Icons.check_rounded, color: Color(0xFF2F7BFF)) : null, onTap: () { selectCategory(index); diff --git a/lib/pages/discover/discover_view.dart b/lib/pages/discover/discover_view.dart index c60f3f6..9027291 100644 --- a/lib/pages/discover/discover_view.dart +++ b/lib/pages/discover/discover_view.dart @@ -1,12 +1,17 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; +import 'package:provider/provider.dart'; import '../../core/data/models/drama.dart'; -import '../../core/formatting/localized_content.dart'; +import '../../core/data/models/home_feed.dart'; import '../../core/data/repositories/watch_history_repository.dart'; +import '../../core/data/services/catalog_controller.dart'; +import '../../core/theme/app_colors.dart'; +import '../../core/widgets/remote_image.dart'; import '../../l10n/app_localizations.dart'; import 'discover_binding.dart'; import 'discover_logic.dart'; +import 'widgets/cover_carousel.dart'; class DiscoverPage extends StatefulWidget { const DiscoverPage({ @@ -18,6 +23,10 @@ class DiscoverPage extends StatefulWidget { this.embedded = false, this.active = true, this.searchRequest = 0, + this.signedIn = false, + this.onSignIn, + this.onCoins, + this.onRewards, this.onAction, this.dramas, this.onDramaSelected, @@ -30,6 +39,10 @@ class DiscoverPage extends StatefulWidget { final bool embedded; final bool active; final int searchRequest; + final bool signedIn; + final VoidCallback? onSignIn; + final VoidCallback? onCoins; + final VoidCallback? onRewards; final ValueChanged? onAction; final List? dramas; final ValueChanged? onDramaSelected; @@ -48,6 +61,7 @@ class _DiscoverPageState extends State { drama: widget.drama, history: widget.history, ); + if (widget.focusSearch) logic.searchOpen = true; } @override @@ -80,50 +94,64 @@ class _DiscoverPageState extends State { Widget _page(BuildContext context) { final l10n = AppLocalizations.of(context)!; - final cards = _cardsFor(l10n, logic.category, logic.search.text); + final catalog = context.watch(); + final allDramas = widget.dramas ?? [logic.drama]; + final cards = _cardsFor( + allDramas, + catalog.sections, + logic.category, + '', + ); final content = SafeArea( bottom: !widget.embedded, child: Column( children: [ - _topBar(l10n), + _header(l10n), Expanded( child: ListView( controller: logic.scroll, - padding: const EdgeInsets.fromLTRB(16, 4, 16, 24), + padding: const EdgeInsets.only(bottom: 24), children: [ - _searchBar(l10n), - const SizedBox(height: 12), - _categories(l10n), - const SizedBox(height: 15), - _continueCard(l10n), - const SizedBox(height: 15), - _quickActions(l10n), - const SizedBox(height: 20), - _sectionTitle(l10n), - const SizedBox(height: 13), - if (cards.isEmpty) - Padding( - padding: const EdgeInsets.symmetric(vertical: 24), - child: Text( - l10n.noSearchResults, - style: const TextStyle(color: Color(0xFFE6E1E3)), - ), - ) - else - GridView.builder( - shrinkWrap: true, - physics: const NeverScrollableScrollPhysics(), - itemCount: cards.length, - gridDelegate: - const SliverGridDelegateWithFixedCrossAxisCount( - crossAxisCount: 2, - crossAxisSpacing: 10, - mainAxisSpacing: 14, - childAspectRatio: 0.59, - ), - itemBuilder: (context, index) => - _posterCard(l10n, cards[index]), + Padding( + padding: const EdgeInsets.fromLTRB(16, 4, 16, 0), + child: ClipRRect( + borderRadius: BorderRadius.circular(18), + child: _carousel(l10n, catalog.banners, allDramas), ), + ), + Padding( + padding: const EdgeInsets.fromLTRB(16, 18, 16, 0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + _categories(l10n), + const SizedBox(height: 18), + _continueHeader(l10n), + const SizedBox(height: 12), + if (cards.isEmpty) + Padding( + padding: const EdgeInsets.symmetric(vertical: 24), + child: Text( + l10n.noSearchResults, + style: const TextStyle(color: Color(0xFFE6E1E3)), + ), + ) + else + SizedBox( + height: 196, + child: ListView( + scrollDirection: Axis.horizontal, + children: [ + for (final card in cards) ...[ + _continueTile(l10n, card), + const SizedBox(width: 12), + ], + ], + ), + ), + ], + ), + ), ], ), ), @@ -142,412 +170,233 @@ class _DiscoverPageState extends State { ); } - Widget _topBar(AppLocalizations l10n) => SizedBox( - height: 51, - child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 16), + Widget _header(AppLocalizations l10n) { + return Padding( + padding: const EdgeInsets.fromLTRB(16, 6, 12, 8), child: Row( children: [ - Container( - width: 29, - height: 29, - decoration: BoxDecoration( - color: _orange, - borderRadius: BorderRadius.circular(7), - ), - child: const Icon(Icons.play_arrow_rounded, color: Colors.white), - ), - const SizedBox(width: 7), - Text( - l10n.discoverTab, - style: const TextStyle(fontSize: 19, fontWeight: FontWeight.w800), - ), - const Spacer(), - IconButton( - tooltip: l10n.search, - onPressed: () => logic.searchFocus.requestFocus(), - icon: const Icon(Icons.search_rounded, size: 22), - ), - const SizedBox(width: 4), - InkWell( - onTap: () => logic.act( - context, - DiscoverPageAction.my, - embedded: widget.embedded, - onAction: widget.onAction, - ), - child: const CircleAvatar( - radius: 14, - backgroundColor: Color(0xFF34353B), - child: Icon(Icons.person_rounded, size: 19), - ), - ), - ], - ), - ), - ); - - Widget _searchBar(AppLocalizations l10n) => Container( - height: 43, - decoration: BoxDecoration( - color: const Color(0xFF25252A), - borderRadius: BorderRadius.circular(24), - ), - child: Row( - children: [ - const SizedBox(width: 11), - const Icon(Icons.search_rounded, color: Color(0xFFF2EEEF), size: 20), - const SizedBox(width: 7), - Expanded( - child: TextField( - controller: logic.search, - focusNode: logic.searchFocus, - autofocus: widget.focusSearch, - onChanged: (_) => logic.onSearchChanged(), - style: const TextStyle(fontSize: 12), - decoration: InputDecoration( - hintText: l10n.searchDiscover, - hintStyle: const TextStyle( - color: Color(0xFFE6E1E3), - fontSize: 12, - ), - border: InputBorder.none, - isDense: true, - ), - ), - ), - IconButton( - tooltip: l10n.filter, - onPressed: () => logic.showFilters(context), - icon: const Icon(Icons.tune_rounded, size: 20), - ), - ], - ), - ); - - Widget _categories(AppLocalizations l10n) { - final labels = [ - l10n.featured, - l10n.suspense, - l10n.romance, - l10n.actionGenre, - ]; - return SizedBox( - height: 30, - child: ListView.separated( - scrollDirection: Axis.horizontal, - itemCount: labels.length, - separatorBuilder: (_, _) => const SizedBox(width: 7), - itemBuilder: (context, index) => ChoiceChip( - label: Text(labels[index]), - selected: logic.category == index, - onSelected: (_) => logic.selectCategory(index), - showCheckmark: false, - visualDensity: VisualDensity.compact, - padding: const EdgeInsets.symmetric(horizontal: 7), - backgroundColor: const Color(0xFF29272B), - selectedColor: _orange, - side: BorderSide.none, - labelStyle: TextStyle( - color: logic.category == index ? Colors.white : const Color(0xFFDDD5D7), - fontSize: 10, - fontWeight: FontWeight.w700, - ), - ), - ), - ); - } - - Widget _continueCard(AppLocalizations l10n) => FutureBuilder( - future: logic.position, - builder: (context, snapshot) { - final position = snapshot.data ?? Duration.zero; - final total = widget.duration > Duration.zero - ? widget.duration - : const Duration(seconds: 12); - final progress = (position.inMilliseconds / total.inMilliseconds).clamp( - 0.0, - 1.0, - ); - return Container( - padding: const EdgeInsets.all(10), - decoration: BoxDecoration( - color: const Color(0xFF1C1D21), - borderRadius: BorderRadius.circular(12), - ), - child: Row( - children: [ - ClipRRect( - borderRadius: BorderRadius.circular(5), - child: SizedBox( - width: 55, - height: 69, - child: Stack( - fit: StackFit.expand, - children: [ - Image.asset(widget.drama.posterAsset, fit: BoxFit.cover), - const Positioned( - left: 0, - right: 0, - bottom: 0, - height: 12, - child: ColoredBox(color: Color(0xFF1C1D21)), - ), - ], - ), - ), - ), - const SizedBox(width: 9), - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - l10n.continueWatchingHeading, - maxLines: 1, - overflow: TextOverflow.ellipsis, - style: const TextStyle( - color: Color(0xFFFFA490), - fontSize: 9, - fontWeight: FontWeight.w800, - ), - ), - const SizedBox(height: 3), - Text( - localizedDramaTitle(l10n, widget.drama), - maxLines: 1, - overflow: TextOverflow.ellipsis, - style: const TextStyle( - fontSize: 14, - fontWeight: FontWeight.w800, - ), - ), - const SizedBox(height: 2), - Text( - l10n.episodeProgress(1, widget.drama.episodes.length), - maxLines: 1, - overflow: TextOverflow.ellipsis, - style: const TextStyle( - color: Color(0xFFE6E1E3), - fontSize: 11, - ), - ), - const SizedBox(height: 7), - ClipRRect( - borderRadius: BorderRadius.circular(3), - child: LinearProgressIndicator( - value: progress, - minHeight: 3, - backgroundColor: const Color(0xFF474248), - color: _orange, - ), - ), - ], - ), - ), - const SizedBox(width: 9), - FilledButton.icon( - onPressed: () => logic.act( - context, - DiscoverPageAction.resume, - embedded: widget.embedded, - onAction: widget.onAction, - ), - style: FilledButton.styleFrom( - backgroundColor: const Color(0xFFFFBD5C), - foregroundColor: const Color(0xFF2A160B), - padding: const EdgeInsets.symmetric(horizontal: 10), - minimumSize: const Size(0, 32), - textStyle: const TextStyle( - fontSize: 10, - fontWeight: FontWeight.bold, - ), - ), - icon: const Icon(Icons.play_arrow_rounded, size: 14), - label: Text(l10n.resume), - ), - ], - ), - ); - }, - ); - - Widget _quickActions(AppLocalizations l10n) { - final actions = [ - (Icons.tune_rounded, l10n.filter, () => logic.showFilters(context)), - (Icons.bar_chart_rounded, l10n.topCharts, () => logic.catalogInfo(context)), - ( - Icons.auto_awesome_rounded, - l10n.newReleases, - () => logic.catalogInfo(context), - ), - ( - Icons.bookmark_outline_rounded, - l10n.watchlist, - () { - logic.act( - context, - DiscoverPageAction.watchlist, - embedded: widget.embedded, - onAction: widget.onAction, - ); - }, - ), - ]; - return Row( - children: [ - for (var index = 0; index < actions.length; index++) ...[ + const _BrandMark(), + const SizedBox(width: 8), Expanded( - child: InkWell( - onTap: actions[index].$3, - borderRadius: BorderRadius.circular(12), - child: Container( - height: 77, - padding: const EdgeInsets.symmetric(horizontal: 3), - decoration: BoxDecoration( - color: const Color(0xFF202126), - borderRadius: BorderRadius.circular(12), - ), - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - CircleAvatar( - radius: 16, - backgroundColor: const Color(0xFF333036), - child: Icon( - actions[index].$1, - size: 19, - color: index == 1 - ? const Color(0xFFFFC15E) - : const Color(0xFFFFAB96), - ), - ), - const SizedBox(height: 7), - Text( - actions[index].$2, - maxLines: 1, - overflow: TextOverflow.ellipsis, - textAlign: TextAlign.center, - style: const TextStyle( - fontSize: 10, - fontWeight: FontWeight.w700, - ), - ), - ], - ), + child: Text( + l10n.appName, + maxLines: 1, + overflow: TextOverflow.ellipsis, + style: const TextStyle( + color: Colors.white, + fontSize: 20, + fontWeight: FontWeight.w700, + height: 1.1, ), ), ), - if (index < actions.length - 1) const SizedBox(width: 7), + const SizedBox(width: 8), + if (widget.signedIn) ...[ + _HeaderPill( + icon: Icons.monetization_on_rounded, + label: r'$ 0', + onTap: widget.onCoins, + ), + const SizedBox(width: 8), + _HeaderPill( + icon: Icons.card_giftcard_rounded, + label: l10n.rewards, + onTap: widget.onRewards, + ), + ] else + _LoginButton(label: l10n.logIn, onTap: widget.onSignIn), ], + ), + ); + } + + Widget _carousel( + AppLocalizations l10n, + List banners, + List allDramas, + ) { + final items = banners.where((banner) => banner.imageUrl.isNotEmpty).toList(); + if (items.isEmpty) return const SizedBox.shrink(); + return CoverCarousel( + items: [ + for (final banner in items) + CoverItem( + title: _bannerTitle(banner, allDramas), + subtitle: '', + image: banner.imageUrl, + onOpen: () => _openBanner(banner, allDramas), + ), ], ); } - Widget _sectionTitle(AppLocalizations l10n) => Row( + String _bannerTitle(FeedBanner banner, List allDramas) { + final dramaId = banner.dramaId; + if (dramaId == null) return ''; + for (final drama in allDramas) { + if (drama.id == dramaId) return drama.title; + } + return ''; + } + + void _openBanner(FeedBanner banner, List allDramas) { + final dramaId = banner.dramaId; + if (dramaId == null) return; + for (final drama in allDramas) { + if (drama.id == dramaId) { + logic.openCard( + context, + drama, + embedded: widget.embedded, + onDramaSelected: widget.onDramaSelected, + onAction: widget.onAction, + ); + return; + } + } + } + + Widget _continueHeader(AppLocalizations l10n) => Row( children: [ - Container(width: 3, height: 20, color: _orange), - const SizedBox(width: 7), Expanded( child: Text( - l10n.trendingMicroDramas, + l10n.continueWatching, maxLines: 1, overflow: TextOverflow.ellipsis, - style: const TextStyle(fontSize: 17, fontWeight: FontWeight.w800), + style: const TextStyle( + fontSize: 18, + fontWeight: FontWeight.w600, + letterSpacing: 0.2, + height: 1.2, + ), ), ), - TextButton( - onPressed: () => logic.selectCategory(0), - child: Text( - l10n.seeAll, - style: const TextStyle(color: Color(0xFFFFB3A1)), + const SizedBox(width: 8), + Text( + l10n.seeAll, + style: const TextStyle( + color: AppColors.blue, + fontSize: 13, + fontWeight: FontWeight.w500, ), ), ], ); - Widget _posterCard(AppLocalizations l10n, _ShowcaseCard card) { - final playable = - logic.dramaFor(card.dramaId, widget.dramas ?? [logic.drama]) != null; - return InkWell( - onTap: () => logic.openCard( - context, - logic.dramaFor(card.dramaId, widget.dramas ?? [logic.drama]), - embedded: widget.embedded, - onDramaSelected: widget.onDramaSelected, - onAction: widget.onAction, - ), - borderRadius: BorderRadius.circular(11), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Expanded( - child: ClipRRect( - borderRadius: BorderRadius.circular(10), - child: Stack( - fit: StackFit.expand, - children: [ - Image.asset(card.image, fit: BoxFit.cover), - const Positioned( - left: 0, - right: 0, - bottom: 0, - height: 37, - child: ColoredBox(color: Color(0xFF101116)), + Widget _continueTile(AppLocalizations l10n, _ShowcaseCard card) { + final drama = logic.dramaFor(card.dramaId, widget.dramas ?? [logic.drama]); + return SizedBox( + width: 132, + child: InkWell( + onTap: () => logic.openCard( + context, + drama, + embedded: widget.embedded, + onDramaSelected: widget.onDramaSelected, + onAction: widget.onAction, + ), + child: ClipRRect( + borderRadius: BorderRadius.circular(14), + child: Stack( + fit: StackFit.expand, + children: [ + RemoteImage(card.image), + const DecoratedBox( + decoration: BoxDecoration( + gradient: LinearGradient( + begin: Alignment.topCenter, + end: Alignment.bottomCenter, + colors: [Color(0x00000000), Color(0xE6000000)], + stops: [0.45, 1], ), - Positioned( - top: 6, - left: 6, - child: Container( - padding: const EdgeInsets.symmetric( - horizontal: 6, - vertical: 3, - ), - decoration: BoxDecoration( - color: playable ? _orange : const Color(0xDD37343B), - borderRadius: BorderRadius.circular(7), - ), - child: Text( - playable ? l10n.free : l10n.artworkOnly, - style: const TextStyle( - fontSize: 9, - fontWeight: FontWeight.w800, - ), - ), - ), + ), + ), + if (drama == null) + const ColoredBox( + color: Color(0x99000000), + child: Center( + child: Icon(Icons.image_outlined, color: Colors.white), ), - Positioned( - bottom: 10, - left: 8, - right: 8, - child: Text( - playable ? l10n.freeTestMedia : l10n.videoPending, + ), + Positioned( + left: 10, + right: 10, + bottom: 10, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + card.title, + maxLines: 2, + overflow: TextOverflow.ellipsis, style: const TextStyle( - color: Color(0xFFFFC789), - fontSize: 10, - fontWeight: FontWeight.bold, + color: Colors.white, + fontSize: 13, + fontWeight: FontWeight.w600, + height: 1.2, ), ), - ), - ], + const SizedBox(height: 3), + Text( + drama == null ? l10n.videoPending : card.genre, + maxLines: 1, + overflow: TextOverflow.ellipsis, + style: const TextStyle( + color: Color(0xE6FFFFFF), + fontSize: 11, + fontWeight: FontWeight.w400, + height: 1.2, + ), + ), + ], + ), + ), + ], + ), + ), + ), + ); + } + + Widget _categories(AppLocalizations l10n) { + final labels = [ + l10n.forYou, + l10n.hot, + l10n.newest, + l10n.romance, + l10n.actionGenre, + ]; + return SizedBox( + height: 32, + child: ListView.separated( + scrollDirection: Axis.horizontal, + itemCount: labels.length, + separatorBuilder: (_, _) => const SizedBox(width: 8), + itemBuilder: (context, index) { + final selected = logic.category == index; + return GestureDetector( + onTap: () => logic.selectCategory(index), + child: AnimatedContainer( + duration: const Duration(milliseconds: 180), + alignment: Alignment.center, + padding: const EdgeInsets.symmetric(horizontal: 12), + decoration: BoxDecoration( + color: selected ? AppColors.blue : const Color(0xFF1C1E24), + borderRadius: BorderRadius.circular(16), + ), + child: Text( + labels[index], + maxLines: 1, + style: TextStyle( + color: selected ? Colors.white : AppColors.muted, + fontSize: 13, + fontWeight: selected ? FontWeight.w600 : FontWeight.w500, + height: 1.1, + ), ), ), - ), - const SizedBox(height: 6), - Text( - card.title, - maxLines: 1, - overflow: TextOverflow.ellipsis, - style: const TextStyle(fontSize: 13, fontWeight: FontWeight.w800), - ), - const SizedBox(height: 3), - Text( - card.genre, - maxLines: 1, - overflow: TextOverflow.ellipsis, - style: const TextStyle(color: Color(0xFFE6E1E3), fontSize: 11), - ), - ], + ); + }, ), ); } @@ -637,60 +486,131 @@ class _ShowcaseCard { required this.title, required this.genre, required this.image, - required this.category, this.dramaId, }); final String title; final String genre; final String image; - final int category; final String? dramaId; } +/// 分区由服务端下发:0 为全部,其余按分区顺序对应筛选菜单(热门 / 最新 / 各分类)。 List<_ShowcaseCard> _cardsFor( - AppLocalizations l10n, + List dramas, + List sections, int category, String query, ) { - final cards = [ - _ShowcaseCard( - title: l10n.dramaSignalTitle, - genre: l10n.genreSuspenseMystery, - image: 'assets/images/stitch_signal_poster_clean.png', - category: 1, - dramaId: 'the-signal-demo', - ), - _ShowcaseCard( - title: l10n.dramaCityTitle, - genre: l10n.genreUrbanRomance, - image: 'assets/images/stitch_city_poster_clean.png', - category: 2, - dramaId: 'city-lights-demo', - ), - _ShowcaseCard( - title: l10n.dramaVengeanceTitle, - genre: l10n.genreActionThriller, - image: 'assets/images/stitch_vengeance_poster_clean.png', - category: 3, - dramaId: 'vengeance-demo', - ), - _ShowcaseCard( - title: l10n.dramaEchoesTitle, - genre: l10n.genreDramaMystery, - image: 'assets/images/stitch_rain_scene.jpg', - category: 1, - ), - ]; + final source = switch (category) { + 0 => dramas, + _ => category < sections.length ? sections[category].dramas : const [], + }; final normalized = query.trim().toLowerCase(); - return cards.where((card) { - final categoryMatches = category == 0 || card.category == category; - final queryMatches = - normalized.isEmpty || - card.title.toLowerCase().contains(normalized) || - card.genre.toLowerCase().contains(normalized); - return categoryMatches && queryMatches; - }).toList(); + return [ + for (final drama in source) + if (normalized.isEmpty || + drama.title.toLowerCase().contains(normalized) || + drama.genre.toLowerCase().contains(normalized) || + drama.category.toLowerCase().contains(normalized)) + _ShowcaseCard( + title: drama.title, + genre: drama.genre.isEmpty ? drama.category : drama.genre, + image: drama.posterUrl, + dramaId: drama.id, + ), + ]; } -const _orange = Color(0xFFFF5B3D); +const _orange = AppColors.blue; +const _coin = Color(0xFFF5C451); + +class _BrandMark extends StatelessWidget { + const _BrandMark(); + + @override + Widget build(BuildContext context) { + return Container( + width: 28, + height: 28, + alignment: Alignment.center, + decoration: BoxDecoration( + color: AppColors.blue, + borderRadius: BorderRadius.circular(8), + ), + child: const Icon( + Icons.play_arrow_rounded, + color: Colors.white, + size: 20, + ), + ); + } +} + +class _HeaderPill extends StatelessWidget { + const _HeaderPill({ + required this.icon, + required this.label, + required this.onTap, + }); + + final IconData icon; + final String label; + final VoidCallback? onTap; + + @override + Widget build(BuildContext context) { + return Material( + color: const Color(0xFF1C1E24), + shape: const StadiumBorder(side: BorderSide(color: Color(0x66F5C451))), + child: InkWell( + customBorder: const StadiumBorder(), + onTap: onTap, + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 5), + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + Icon(icon, size: 15, color: _coin), + const SizedBox(width: 4), + Text( + label, + maxLines: 1, + style: const TextStyle( + color: Colors.white, + fontSize: 12, + fontWeight: FontWeight.w600, + height: 1.1, + ), + ), + ], + ), + ), + ), + ); + } +} + +class _LoginButton extends StatelessWidget { + const _LoginButton({required this.label, required this.onTap}); + + final String label; + final VoidCallback? onTap; + + @override + Widget build(BuildContext context) { + return TextButton( + onPressed: onTap, + style: TextButton.styleFrom( + foregroundColor: Colors.white, + backgroundColor: AppColors.blue, + padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 6), + minimumSize: Size.zero, + tapTargetSize: MaterialTapTargetSize.shrinkWrap, + shape: const StadiumBorder(), + textStyle: const TextStyle(fontSize: 13, fontWeight: FontWeight.w600), + ), + child: Text(label, maxLines: 1), + ); + } +} diff --git a/lib/pages/drama_detail/drama_detail_logic.dart b/lib/pages/drama_detail/drama_detail_logic.dart index e6d8dfb..7f613d1 100644 --- a/lib/pages/drama_detail/drama_detail_logic.dart +++ b/lib/pages/drama_detail/drama_detail_logic.dart @@ -1,14 +1,21 @@ import 'package:flutter/material.dart'; import '../../core/data/models/drama.dart'; +import '../../core/data/remote/api_client.dart'; import '../../core/data/repositories/watch_history_repository.dart'; import '../player/player_view.dart'; class DramaDetailLogic extends ChangeNotifier { DramaDetailLogic({required this.drama, required this.history}); - final Drama drama; + /// 先用列表卡片渲染,取到详情后换成带完整剧集的版本。 + Drama drama; final WatchHistoryRepository history; + bool loading = false; + bool failed = false; + + /// 接口给出的失败原因;为空时界面回退到本地文案。 + String? failureMessage; int? continueIndex; bool _disposed = false; @@ -16,6 +23,30 @@ class DramaDetailLogic extends ChangeNotifier { if (!_disposed) notifyListeners(); } + /// 列表卡片只带一集可播预览,进详情时补一次完整剧集列表。 + Future load(Future Function() fetch) async { + if (drama.detailLoaded) { + await loadContinue(); + return; + } + loading = true; + failed = false; + failureMessage = null; + notify(); + try { + drama = await fetch(); + await loadContinue(); + } on ApiException catch (exception) { + failed = true; + failureMessage = exception.message; + } catch (_) { + failed = true; + } finally { + loading = false; + notify(); + } + } + Future loadContinue() async { try { final id = await history.lastEpisodeId(demoProfileId, drama.id); diff --git a/lib/pages/drama_detail/drama_detail_view.dart b/lib/pages/drama_detail/drama_detail_view.dart index 264febd..1dcc719 100644 --- a/lib/pages/drama_detail/drama_detail_view.dart +++ b/lib/pages/drama_detail/drama_detail_view.dart @@ -1,7 +1,12 @@ +import 'dart:async'; + import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; import '../../core/data/models/drama.dart'; +import '../../core/data/services/catalog_controller.dart'; import '../../core/formatting/localized_content.dart'; +import '../../core/widgets/remote_image.dart'; import '../../l10n/app_localizations.dart'; import 'drama_detail_binding.dart'; import 'drama_detail_logic.dart'; @@ -21,7 +26,15 @@ class _DramaDetailPageState extends State { void initState() { super.initState(); logic = DramaDetailBinding().create(drama: widget.drama); - logic.loadContinue(); + _load(); + } + + void _load() { + unawaited( + logic.load( + () => context.read().requireDetail(widget.drama), + ), + ); } @override @@ -40,6 +53,34 @@ class _DramaDetailPageState extends State { Widget _page(BuildContext context) { final l10n = AppLocalizations.of(context)!; + if (logic.loading) { + return const Scaffold( + backgroundColor: Color(0xFF111111), + body: Center(child: CircularProgressIndicator()), + ); + } + if (logic.failed) { + return Scaffold( + backgroundColor: const Color(0xFF111111), + body: Center( + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 32), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Text( + logic.failureMessage ?? l10n.detailError, + textAlign: TextAlign.center, + style: const TextStyle(color: Colors.white70), + ), + const SizedBox(height: 16), + FilledButton(onPressed: _load, child: Text(l10n.retry)), + ], + ), + ), + ), + ); + } final drama = logic.drama; return Scaffold( body: CustomScrollView( @@ -50,7 +91,7 @@ class _DramaDetailPageState extends State { backgroundColor: const Color(0xFF111111), foregroundColor: Colors.white, flexibleSpace: FlexibleSpaceBar( - background: Image.asset(drama.posterAsset, fit: BoxFit.cover), + background: RemoteImage(drama.posterUrl), ), ), SliverPadding( @@ -61,7 +102,7 @@ class _DramaDetailPageState extends State { l10n.technicalDemoCount(drama.episodes.length), style: Theme.of(context).textTheme.labelSmall?.copyWith( letterSpacing: 1.4, - color: const Color(0xFF9278EA), + color: const Color(0xFF2F7BFF), fontWeight: FontWeight.bold, ), ), @@ -112,12 +153,11 @@ class _DramaDetailPageState extends State { minTileHeight: 76, leading: CircleAvatar( backgroundColor: const Color( - 0xFFFF6B45, + 0xFF2F7BFF, ).withValues(alpha: 0.18), child: Text('${episode.number}'), ), title: Text(l10n.episodeLabel(episode.number)), - subtitle: Text(l10n.freeTestMedia), trailing: const Icon(Icons.play_circle_outline_rounded), onTap: () => logic.openPlayer(context, index), ), diff --git a/lib/pages/home/home_feed_sections.dart b/lib/pages/home/home_feed_sections.dart deleted file mode 100644 index 74559dc..0000000 --- a/lib/pages/home/home_feed_sections.dart +++ /dev/null @@ -1,30 +0,0 @@ -import '../../core/data/models/drama.dart'; - -enum HomeFeedCategory { following, animated, liveAction, recommended } - -/// Maps catalog entries into home feeds without owning playback or UI state. -class HomeFeedSections { - HomeFeedSections(this.dramas, {this.followedDramaIds = const {}}); - - final List dramas; - final Set followedDramaIds; - - List indicesFor(HomeFeedCategory category) => [ - for (var index = 0; index < dramas.length; index++) - if (dramas[index].episodes.isNotEmpty && - switch (category) { - HomeFeedCategory.following => followedDramaIds.contains( - dramas[index].id, - ), - HomeFeedCategory.animated => - dramas[index].format == DramaFormat.animated, - HomeFeedCategory.liveAction => - dramas[index].format == DramaFormat.liveAction, - HomeFeedCategory.recommended => true, - }) - index, - ]; - - Drama dramaAt(HomeFeedCategory category, int categoryIndex) => - dramas[indicesFor(category)[categoryIndex]]; -} diff --git a/lib/pages/home/widgets/category_swipe_region.dart b/lib/pages/home/widgets/category_swipe_region.dart deleted file mode 100644 index c641cc1..0000000 --- a/lib/pages/home/widgets/category_swipe_region.dart +++ /dev/null @@ -1,35 +0,0 @@ -import 'package:flutter/material.dart'; - -/// Converts horizontal drags into a previous/next category request. -/// Placement decides where the gesture is active; the seek bar sits outside it. -class CategorySwipeRegion extends StatefulWidget { - const CategorySwipeRegion({ - super.key, - required this.onShift, - required this.child, - }); - - final ValueChanged onShift; - final Widget child; - - @override - State createState() => _CategorySwipeRegionState(); -} - -class _CategorySwipeRegionState extends State { - double _distance = 0; - - @override - Widget build(BuildContext context) => GestureDetector( - behavior: HitTestBehavior.translucent, - onHorizontalDragStart: (_) => _distance = 0, - onHorizontalDragUpdate: (details) => _distance += details.delta.dx, - onHorizontalDragEnd: (details) { - final velocity = details.primaryVelocity ?? 0; - if (_distance.abs() < 44 && velocity.abs() < 300) return; - final direction = _distance.abs() >= 44 ? _distance : velocity; - widget.onShift(direction < 0 ? 1 : -1); - }, - child: widget.child, - ); -} diff --git a/lib/pages/home/widgets/home_feed_header.dart b/lib/pages/home/widgets/home_feed_header.dart deleted file mode 100644 index 2998d41..0000000 --- a/lib/pages/home/widgets/home_feed_header.dart +++ /dev/null @@ -1,170 +0,0 @@ -import 'package:flutter/material.dart'; - -import '../../../l10n/app_localizations.dart'; -import '../home_feed_sections.dart'; -import 'category_swipe_region.dart'; - -/// Reused by playable and empty home feeds. -class HomeFeedHeader extends StatelessWidget { - const HomeFeedHeader({ - super.key, - required this.l10n, - required this.category, - required this.onCategorySelected, - required this.onCategoryShift, - required this.onSearch, - required this.onMy, - this.onMenu, - this.onMute, - this.muted = false, - }); - - final AppLocalizations l10n; - final HomeFeedCategory category; - final ValueChanged onCategorySelected; - final ValueChanged onCategoryShift; - final VoidCallback onSearch; - final VoidCallback onMy; - final VoidCallback? onMenu; - final VoidCallback? onMute; - final bool muted; - - String _label(HomeFeedCategory category) => switch (category) { - HomeFeedCategory.following => l10n.followingTab, - HomeFeedCategory.animated => l10n.animatedTab, - HomeFeedCategory.liveAction => l10n.liveActionTab, - HomeFeedCategory.recommended => l10n.recommendedTab, - }; - - @override - Widget build(BuildContext context) => IconTheme( - data: const IconThemeData(color: Colors.white), - child: DefaultTextStyle.merge( - style: const TextStyle(color: Colors.white), - child: _header(context), - ), - ); - - Widget _header(BuildContext context) => Column( - mainAxisSize: MainAxisSize.min, - children: [ - Padding( - padding: const EdgeInsets.fromLTRB(16, 8, 16, 0), - child: Row( - children: [ - if (onMenu != null) - IconButton( - key: const Key('home-open-menu'), - tooltip: l10n.openQuickMenu, - onPressed: onMenu, - icon: const Icon(Icons.menu_rounded), - ), - Container( - width: 29, - height: 29, - decoration: BoxDecoration( - color: const Color(0xFFFF5C37), - borderRadius: BorderRadius.circular(8), - ), - child: const Icon(Icons.play_arrow_rounded, color: Colors.white), - ), - const SizedBox(width: 8), - Text( - l10n.homeTab, - style: const TextStyle(fontSize: 20, fontWeight: FontWeight.w700), - ), - const Spacer(), - IconButton( - tooltip: l10n.search, - onPressed: onSearch, - icon: const Icon(Icons.search_rounded), - ), - IconButton( - tooltip: l10n.myTab, - onPressed: onMy, - icon: const CircleAvatar( - radius: 15, - backgroundColor: Color(0xFF3C3A3A), - child: Icon( - Icons.person_rounded, - color: Colors.white, - size: 19, - ), - ), - ), - ], - ), - ), - Padding( - padding: const EdgeInsets.fromLTRB(12, 4, 12, 0), - child: Row( - children: [ - Expanded( - child: CategorySwipeRegion( - key: const Key('home-category-swipe'), - onShift: onCategoryShift, - child: Row( - children: [ - for (final item in HomeFeedCategory.values) - Expanded( - child: InkWell( - key: Key('home-category-${item.name}'), - onTap: () => onCategorySelected(item), - child: Padding( - padding: const EdgeInsets.symmetric(vertical: 9), - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - Text( - _label(item), - maxLines: 1, - overflow: TextOverflow.ellipsis, - style: TextStyle( - color: category == item - ? const Color(0xFFFFC2B0) - : const Color(0xFFF7F4F2), - shadows: const [ - Shadow(blurRadius: 8, color: Colors.black), - ], - fontSize: 12, - fontWeight: category == item - ? FontWeight.w700 - : FontWeight.w500, - ), - ), - const SizedBox(height: 4), - SizedBox( - width: 18, - height: 2, - child: DecoratedBox( - decoration: BoxDecoration( - color: category == item - ? const Color(0xFFFF5C37) - : Colors.transparent, - ), - ), - ), - ], - ), - ), - ), - ), - ], - ), - ), - ), - if (onMute != null) - IconButton( - tooltip: muted ? l10n.unmute : l10n.mute, - onPressed: onMute, - icon: Icon( - muted ? Icons.volume_off_rounded : Icons.volume_up_rounded, - size: 21, - ), - ), - ], - ), - ), - ], - ); -} diff --git a/lib/pages/home/widgets/home_quick_drawer.dart b/lib/pages/home/widgets/home_quick_drawer.dart index 2a60d68..1d12caf 100644 --- a/lib/pages/home/widgets/home_quick_drawer.dart +++ b/lib/pages/home/widgets/home_quick_drawer.dart @@ -4,6 +4,7 @@ import 'package:provider/provider.dart'; import '../../../core/config/locale_controller.dart'; import '../../../core/data/models/drama.dart'; import '../../../core/formatting/localized_content.dart'; +import '../../../core/widgets/remote_image.dart'; import '../../../l10n/app_localizations.dart'; /// Shortcuts for the existing root tabs; this widget owns no navigation state. @@ -27,7 +28,7 @@ class HomeQuickDrawer extends StatelessWidget { static const _panel = Color(0xFF222225); static const _card = Color(0xFF303033); - static const _orange = Color(0xFFFF5C37); + static const _orange = Color(0xFF2F7BFF); @override Widget build(BuildContext context) { @@ -88,11 +89,10 @@ class HomeQuickDrawer extends StatelessWidget { children: [ ClipRRect( borderRadius: BorderRadius.circular(10), - child: Image.asset( - drama.posterAsset, + child: RemoteImage( + drama.posterUrl, width: 74, height: 100, - fit: BoxFit.cover, ), ), const SizedBox(width: 12), @@ -111,18 +111,9 @@ class HomeQuickDrawer extends StatelessWidget { ), const SizedBox(height: 7), Text( - l10n.episodeCount(drama.episodes.length), + l10n.episodeCount(drama.episodeCount), style: const TextStyle(color: Color(0xFFE7E2E0)), ), - const SizedBox(height: 5), - Text( - l10n.freeTestMedia, - maxLines: 2, - style: const TextStyle( - color: Color(0xFFFFB99E), - fontSize: 11, - ), - ), ], ), ), diff --git a/lib/pages/mine/mine_logic.dart b/lib/pages/mine/mine_logic.dart index 749d1c3..bc699a3 100644 --- a/lib/pages/mine/mine_logic.dart +++ b/lib/pages/mine/mine_logic.dart @@ -29,11 +29,7 @@ class MineLogic extends ChangeNotifier { } void refreshPosition() { - position = history.positionFor( - demoProfileId, - drama.id, - drama.episodes.first.id, - ); + position = history.resumePositionFor(demoProfileId, drama); } void selectSection(int index) { diff --git a/lib/pages/player/player_logic.dart b/lib/pages/player/player_logic.dart index b5085e8..5fee99d 100644 --- a/lib/pages/player/player_logic.dart +++ b/lib/pages/player/player_logic.dart @@ -2,11 +2,13 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; +import 'package:provider/provider.dart'; import '../../core/data/models/drama.dart'; import '../../core/data/models/player_port.dart'; import '../../core/data/repositories/watch_history_repository.dart'; import '../../core/data/services/android_picture_in_picture.dart'; +import '../../core/data/services/catalog_controller.dart'; import '../../core/data/services/platform_share_service.dart'; import '../../core/data/services/playback_queue.dart'; import '../../core/data/services/playback_session.dart'; @@ -16,7 +18,6 @@ import '../../l10n/app_localizations.dart'; import '../discover/discover_logic.dart'; import '../discover/discover_view.dart'; import '../drama_detail/drama_detail_view.dart'; -import '../home/home_feed_sections.dart'; import '../mine/mine_logic.dart'; import '../mine/mine_view.dart'; import 'player_view.dart'; @@ -30,10 +31,7 @@ class PlayerLogic extends ChangeNotifier { late PageController pages; late PlaybackQueue queue; - late HomeFeedSections homeSections; late List visibleIndices; - HomeFeedCategory category = HomeFeedCategory.recommended; - int categoryRequest = 0; late PlaybackSession session; VideoPlayerPort? trackedPlayer; Episode? trackedEpisode; @@ -47,6 +45,8 @@ class PlayerLogic extends ChangeNotifier { bool fullscreen = false; bool pip = false; bool pipPreparing = false; + bool screenCleared = false; + final Map pickedEpisode = {}; bool Function() isMounted = () => false; bool homeMode = false; @@ -67,6 +67,24 @@ class PlayerLogic extends ChangeNotifier { bool get immersive => fullscreen || pip || pipPreparing; + bool get chromeHidden => immersive || screenCleared; + + Episode displayEpisode(Drama drama, Episode fallback) { + final number = pickedEpisode[drama.id]; + if (number == null) return fallback; + for (final episode in drama.episodes) { + if (episode.number == number) return episode; + } + return fallback; + } + + void setScreenCleared(bool value) { + if (screenCleared == value) return; + screenCleared = value; + notify(); + notifyImmersive(); + } + void notify() { if (!_disposed) notifyListeners(); } @@ -97,17 +115,13 @@ class PlayerLogic extends ChangeNotifier { queue = feedDramas == null ? PlaybackQueue.series(pageDrama) : PlaybackQueue.home(feedDramas!); - homeSections = HomeFeedSections([ - for (final entry in queue.entries) entry.drama, - ]); - visibleIndices = homeMode - ? homeSections.indicesFor(category) - : List.generate(queue.length, (index) => index); + visibleIndices = List.generate(queue.length, (index) => index); pages = PageController(initialPage: initialIndex); session = PlaybackSession( episodes: [for (final entry in queue.entries) entry.episode], factory: factory, - canPlay: (episode) => episode.isFree, + // 后端只在可播放时才下发地址(免费集或已解锁),拿不到地址即视为锁定 + canPlay: (episode) => episode.videoUrl.isNotEmpty, prepare: preparePlayer, activate: activatePlayer, coordinator: coordinator, @@ -135,8 +149,10 @@ class PlayerLogic extends ChangeNotifier { if (isMounted() && backRequest == request) { if (fullscreen) { unawaited(setFullscreen(false)); + } else if (screenCleared) { + setScreenCleared(false); } else { - shiftCategory(-1); + onMenu?.call(); } } }); @@ -170,7 +186,7 @@ class PlayerLogic extends ChangeNotifier { super.dispose(); } - void notifyImmersive() => onImmersiveChanged?.call(immersive); + void notifyImmersive() => onImmersiveChanged?.call(chromeHidden); Future setFullscreen(bool value) async { if (fullscreen == value || !isMounted()) return; @@ -192,7 +208,7 @@ class PlayerLogic extends ChangeNotifier { } catch (_) { if (value && isMounted()) { fullscreen = false; - notify(); + notify(); notifyImmersive(); } } @@ -226,7 +242,7 @@ class PlayerLogic extends ChangeNotifier { session.setAppResumed(true); } else { pipPreparing = false; - notify(); + notify(); notifyImmersive(); ScaffoldMessenger.of(context).showSnackBar( SnackBar(content: Text(AppLocalizations.of(context)!.pipUnavailable)), @@ -327,7 +343,7 @@ class PlayerLogic extends ChangeNotifier { curve: Curves.easeOutCubic, ); } catch (_) { - // A category change can detach the old page controller mid-animation. + // The page can leave the tree before the animation finishes. } } @@ -371,49 +387,6 @@ class PlayerLogic extends ChangeNotifier { : null; } - void shiftCategory(int offset) { - if (!homeMode) return; - final next = category.index + offset; - if (next < 0) { - onMenu?.call(); - return; - } - if (next >= HomeFeedCategory.values.length) return; - unawaited(selectCategory(HomeFeedCategory.values[next])); - } - - Future selectCategory(HomeFeedCategory next) async { - if (!homeMode || next == category) return; - final request = ++categoryRequest; - ++pageRequest; - session.setRouteVisible(false); - cancelScrub(); - await saveCurrentProgress(); - if (!isMounted() || request != categoryRequest) return; - - final oldPages = pages; - final indices = homeSections.indicesFor(next); - category = next; - visibleIndices = indices; - pages = PageController(); - notify(); - WidgetsBinding.instance.addPostFrameCallback((_) => oldPages.dispose()); - - if (indices.isEmpty) return; - onDramaChanged?.call(queue.entryAt(indices.first).drama); - await session.select( - indices.first, - preloadIndex: nextVisibleIndex(indices.first), - ); - if (isMounted() && request == categoryRequest) { - if (stoppedAtFeedEnd) { - stoppedAtFeedEnd = false; - session.setUserWantsPlay(true); - } - session.setRouteVisible(active); - } - } - void beginScrub(VideoPlayerPort player) { if (session.active != player) return; scrubbingPlayer = player; @@ -426,7 +399,11 @@ class PlayerLogic extends ChangeNotifier { session.setOverlayOpen(false); } - Future seekTo(BuildContext context, VideoPlayerPort player, Duration position) async { + Future seekTo( + BuildContext context, + VideoPlayerPort player, + Duration position, + ) async { if (scrubbingPlayer != player || session.active != player) return; try { await session.playbackSettled; @@ -464,12 +441,31 @@ class PlayerLogic extends ChangeNotifier { if (isMounted()) session.setRouteVisible(active); } + Future openSeriesAt( + BuildContext context, + Drama drama, + int index, + ) async { + session.setRouteVisible(false); + await session.playbackSettled; + await saveCurrentProgress(); + if (!context.mounted) return; + await Navigator.of(context).push( + MaterialPageRoute( + builder: (_) => PlayerPage(drama: drama, initialIndex: index), + ), + ); + if (isMounted()) session.setRouteVisible(active); + } + Future showEpisodes(BuildContext context) async { - if (feedDramas != null) { - await openDetail(context); - return; - } final l10n = AppLocalizations.of(context)!; + final entry = queue.entryAt(session.currentIndex); + final drama = await _withFullEpisodes(context, entry.drama); + if (!context.mounted) return; + final homeFeed = feedDramas != null; + final episodes = drama.episodes; + final currentNumber = entry.episode.number; session.setOverlayOpen(true); await session.playbackSettled; if (!context.mounted) { @@ -479,49 +475,57 @@ class PlayerLogic extends ChangeNotifier { try { await showModalBottomSheet( context: context, - backgroundColor: const Color(0xFF202024), + backgroundColor: const Color(0xFF16171C), showDragHandle: true, builder: (sheetContext) => SafeArea( child: SizedBox( - height: MediaQuery.sizeOf(context).height * 0.6, + height: MediaQuery.sizeOf(sheetContext).height * 0.46, child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Padding( - padding: const EdgeInsets.fromLTRB(20, 4, 20, 12), + padding: const EdgeInsets.fromLTRB(20, 0, 20, 4), child: Text( l10n.episodes, style: const TextStyle( - fontSize: 22, - fontWeight: FontWeight.bold, + fontSize: 18, + fontWeight: FontWeight.w600, + ), + ), + ), + Padding( + padding: const EdgeInsets.fromLTRB(20, 0, 20, 16), + child: Text( + localizedDramaTitle(l10n, drama), + maxLines: 1, + overflow: TextOverflow.ellipsis, + style: const TextStyle( + color: Color(0xFFB7B3B8), + fontSize: 14, + fontWeight: FontWeight.w400, ), ), ), Expanded( - child: ListView.builder( - itemCount: queue.length, - itemBuilder: (context, index) { - final episode = queue.entryAt(index).episode; - return ListTile( - leading: CircleAvatar( - backgroundColor: const Color(0xFF3A3030), - child: Text('${episode.number}'), + child: GridView.builder( + padding: const EdgeInsets.fromLTRB(16, 0, 16, 16), + gridDelegate: + const SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: 6, + mainAxisSpacing: 10, + crossAxisSpacing: 10, + childAspectRatio: 1.45, ), - title: Text(l10n.episodeLabel(episode.number)), - subtitle: Text(l10n.freeTestMedia), - trailing: const Icon(Icons.play_arrow_rounded), - onTap: () { - Navigator.of(sheetContext).pop(); - unawaited( - pages.animateToPage( - index, - duration: const Duration(milliseconds: 260), - curve: Curves.easeOutCubic, - ), - ); - }, - ); - }, + itemCount: episodes.length, + itemBuilder: (_, index) => _episodeCell( + context, + sheetContext, + drama, + episodes[index], + index, + homeFeed, + currentNumber, + ), ), ), ], @@ -534,6 +538,68 @@ class PlayerLogic extends ChangeNotifier { } } + /// 列表卡片只带一集可播预览,需要完整剧集时补一次详情; + /// 取不到(或页面外没有目录来源)就退回卡片本身。 + Future _withFullEpisodes(BuildContext context, Drama drama) async { + if (drama.detailLoaded) return drama; + final CatalogController catalog; + try { + catalog = context.read(); + } catch (_) { + return drama; + } + try { + return await catalog.requireDetail(drama); + } catch (_) { + return drama; + } + } + + Widget _episodeCell( + BuildContext pageContext, + BuildContext sheetContext, + Drama drama, + Episode episode, + int index, + bool homeFeed, + int currentNumber, + ) { + final selected = episode.number == currentNumber; + return Material( + color: selected ? const Color(0xFF2F7BFF) : const Color(0xFF2A2C33), + borderRadius: BorderRadius.circular(8), + child: InkWell( + borderRadius: BorderRadius.circular(8), + onTap: () { + Navigator.of(sheetContext).pop(); + if (homeFeed) { + if (episode.number == currentNumber) return; + unawaited(openSeriesAt(pageContext, drama, index)); + return; + } + if (index == session.currentIndex) return; + unawaited( + pages.animateToPage( + index, + duration: const Duration(milliseconds: 260), + curve: Curves.easeOutCubic, + ), + ); + }, + child: Center( + child: Text( + '${episode.number}', + style: const TextStyle( + color: Colors.white, + fontSize: 15, + fontWeight: FontWeight.w600, + ), + ), + ), + ), + ); + } + Future showMy(BuildContext context, {int initialSection = 0}) async { if (embedded) { onMy?.call(); @@ -574,7 +640,10 @@ class PlayerLogic extends ChangeNotifier { await showDiscover(context, focusSearch: true); } - Future showDiscover(BuildContext context, {bool focusSearch = false}) async { + Future showDiscover( + BuildContext context, { + bool focusSearch = false, + }) async { if (embedded) { onDiscover?.call(); return; @@ -601,7 +670,8 @@ class PlayerLogic extends ChangeNotifier { await openDetail(context); } else if (action == DiscoverPageAction.my || action == DiscoverPageAction.watchlist) { - await showMy(context, + await showMy( + context, initialSection: action == DiscoverPageAction.watchlist ? 1 : 0, ); } else { @@ -661,5 +731,4 @@ class PlayerLogic extends ChangeNotifier { session.setOverlayOpen(false); } } - } diff --git a/lib/pages/player/widgets/seek_progress_bar.dart b/lib/pages/player/widgets/seek_progress_bar.dart index d5080b6..f2b23b9 100644 --- a/lib/pages/player/widgets/seek_progress_bar.dart +++ b/lib/pages/player/widgets/seek_progress_bar.dart @@ -22,7 +22,6 @@ class SeekProgressBar extends StatefulWidget { this.onScrubStart, this.onSeek, this.showTimes = true, - this.compactIdle = false, }); final ValueListenable? valueListenable; @@ -30,7 +29,6 @@ class SeekProgressBar extends StatefulWidget { final VoidCallback? onScrubStart; final Future Function(Duration)? onSeek; final bool showTimes; - final bool compactIdle; @override State createState() => _SeekProgressBarState(); @@ -99,20 +97,32 @@ class _SeekProgressBarState extends State { return Column( mainAxisSize: MainAxisSize.min, children: [ + if (widget.showTimes && scrubbing) + Padding( + padding: const EdgeInsets.only(bottom: 2), + child: Text( + '${_format(previewPosition)} / ${_format(video.duration)}', + textAlign: TextAlign.center, + style: const TextStyle( + color: Colors.white, + fontSize: 14, + fontWeight: FontWeight.w600, + height: 1.2, + ), + ), + ), SizedBox( - height: widget.compactIdle && !scrubbing ? 20 : 36, + height: scrubbing ? 48 : 44, child: SliderTheme( data: SliderTheme.of(context).copyWith( - trackHeight: widget.compactIdle && !scrubbing ? 2 : 3, - activeTrackColor: const Color(0xFFFF5C37), + trackHeight: scrubbing ? 4 : 3, + activeTrackColor: const Color(0xFF2F7BFF), inactiveTrackColor: Colors.white30, thumbColor: Colors.white, thumbShape: RoundSliderThumbShape( - enabledThumbRadius: widget.compactIdle && !scrubbing ? 0 : 6, - ), - overlayShape: RoundSliderOverlayShape( - overlayRadius: widget.compactIdle && !scrubbing ? 0 : 11, + enabledThumbRadius: scrubbing ? 8 : 6, ), + overlayShape: const RoundSliderOverlayShape(overlayRadius: 18), ), child: Semantics( label: widget.semanticsLabel, @@ -134,20 +144,6 @@ class _SeekProgressBarState extends State { ), ), ), - if (widget.showTimes && (!widget.compactIdle || scrubbing)) - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text( - _format(previewPosition), - style: const TextStyle(fontSize: 12, color: Colors.white), - ), - Text( - _format(video.duration), - style: const TextStyle(fontSize: 12, color: Colors.white), - ), - ], - ), ], ); } diff --git a/pubspec.lock b/pubspec.lock index ee2e934..63efda0 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -157,6 +157,22 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "0.15.7" + http: + dependency: "direct main" + description: + name: http + sha256: "87721a4a50b19c7f1d49001e51409bddc46303966ce89a65af4f4e6004896412" + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.6.0" + http_parser: + dependency: transitive + description: + name: http_parser + sha256: "178d74305e7866013777bab2c3d8726205dc5a4dd935297175b19a23a2e66571" + url: "https://pub.flutter-io.cn" + source: hosted + version: "4.1.2" image: dependency: transitive description: @@ -418,6 +434,14 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "0.7.12" + typed_data: + dependency: transitive + description: + name: typed_data + sha256: f9049c039ebfeb4cf7a7104a675823cd72dba8297f264b6637062516699fa006 + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.4.0" vector_math: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 99de653..50740f4 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -34,6 +34,8 @@ dependencies: # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. cupertino_icons: ^1.0.8 + # 只用官方 http:纯 Dart、体积小;不引 dio/代码生成/图片缓存,控制包体积 + http: ^1.2.2 provider: ^6.1.5+1 video_player: ^2.14.0 shared_preferences: ^2.5.5 @@ -59,13 +61,8 @@ dev_dependencies: # The following section is specific to Flutter packages. flutter: generate: true - assets: - - assets/media/demo_clip.mp4 - - assets/images/demo_poster.jpg - - assets/images/stitch_signal_poster_clean.png - - assets/images/stitch_city_poster_clean.png - - assets/images/stitch_vengeance_poster_clean.png - - assets/images/stitch_rain_scene.jpg + # 封面与视频全部由后端下发(/files/**),本地不再打包演示素材: + # 原先 assets/media 下的演示视频有 316MB,会把安装包撑到无法接受的大小。 # The following line ensures that the Material Icons font is # included with your application, so that you can use the icons in diff --git a/test/catalog/catalog_controller_test.dart b/test/catalog/catalog_controller_test.dart index dc4ab8f..599e64e 100644 --- a/test/catalog/catalog_controller_test.dart +++ b/test/catalog/catalog_controller_test.dart @@ -1,39 +1,131 @@ import 'package:flutter_test/flutter_test.dart'; -import 'package:nontonki/core/data/repositories/catalog_repository.dart'; import 'package:nontonki/core/data/models/drama.dart'; +import 'package:nontonki/core/data/models/home_feed.dart'; +import 'package:nontonki/core/data/models/play_ticket.dart'; +import 'package:nontonki/core/data/repositories/catalog_repository.dart'; import 'package:nontonki/core/data/services/catalog_controller.dart'; void main() { - test( - 'empty catalog is distinct from a failed load, and retry recovers', - () async { - final repo = ScriptedCatalogRepository(); - final controller = CatalogController(repo); - await controller.load(); - expect(controller.dramas, isEmpty); - expect(controller.error, isNull); + test('空目录与加载失败可区分,重试后恢复', () async { + final repository = ScriptedCatalogRepository(); + final controller = CatalogController(repository); - repo.fail = true; - await controller.load(); - expect(controller.error, isNotNull); + await controller.load(); + expect(controller.dramas, isEmpty); + expect(controller.error, isNull); - repo.fail = false; - repo.items = await DemoCatalogRepository().fetchDramas(); - await controller.load(); - expect(controller.error, isNull); - expect(controller.dramas, hasLength(3)); - expect(controller.dramas.first.episodes.length, 3); - }, - ); + repository.fail = true; + await controller.load(); + expect(controller.error, isNotNull); + + repository.fail = false; + repository.feed = HomeFeed( + sections: [ + FeedSection(code: 'hot', title: '热门推荐', dramas: [_card('1')]), + ], + ); + await controller.load(); + expect(controller.error, isNull); + expect(controller.dramas, hasLength(1)); + expect(controller.sections.single.title, '热门推荐'); + }); + + test('详情按需加载:同一部短剧只请求一次', () async { + final repository = ScriptedCatalogRepository(); + final controller = CatalogController(repository); + repository.feed = HomeFeed( + sections: [ + FeedSection(code: 'hot', title: '热门推荐', dramas: [_card('1')]), + ], + ); + await controller.load(); + + final card = controller.dramas.single; + expect(card.episodes, isEmpty); + + final detail = await controller.requireDetail(card); + expect(detail.episodes, hasLength(2)); + expect(repository.detailCalls, 1); + + // 第二次已经是详情,直接复用,不再请求 + await controller.requireDetail(detail); + expect(repository.detailCalls, 1); + expect(controller.dramas.single.episodes, hasLength(2)); + }); + + test('播放票据:可播放写入地址,锁定集保持无地址', () async { + final repository = ScriptedCatalogRepository(); + final controller = CatalogController(repository); + repository.tickets['10'] = const PlayTicket( + episodeId: '10', + accessible: true, + accessType: PlayTicket.free, + playUrl: '/files/episode/10.mp4', + ); + + const free = Episode(id: '10', number: 1, title: '免费集', isFree: true); + final resolved = await controller.resolvePlay(free); + expect(resolved.videoUrl, '/files/episode/10.mp4'); + + const locked = Episode( + id: '11', + number: 2, + title: '锁定集', + isFree: false, + locked: true, + ); + final lockedResolved = await controller.resolvePlay(locked); + expect(lockedResolved.videoUrl, isEmpty); + }); } +Drama _card(String id) => Drama( + id: id, + title: 'Drama $id', + synopsis: '简介 $id', + posterUrl: '/files/$id.jpg', +); + +Drama _detail(String id) => Drama( + id: id, + title: 'Drama $id', + synopsis: '简介 $id', + posterUrl: '/files/$id.jpg', + detailLoaded: true, + episodes: const [ + Episode(id: '1', number: 1, title: '第一集', isFree: true), + Episode(id: '2', number: 2, title: '第二集', isFree: false), + ], +); + class ScriptedCatalogRepository implements CatalogRepository { bool fail = false; - List items = const []; + HomeFeed feed = const HomeFeed(); + int detailCalls = 0; + final Map tickets = {}; @override - Future> fetchDramas() async { + Future fetchHomeFeed() async { if (fail) throw StateError('offline'); - return items; + return feed; + } + + @override + Future fetchDiscoverFeed() async => feed; + + @override + Future fetchDrama(String dramaId) async { + detailCalls++; + return _detail(dramaId); + } + + @override + Future resolvePlay(String episodeId) async { + return tickets[episodeId] ?? + PlayTicket( + episodeId: episodeId, + accessible: false, + accessType: PlayTicket.noMedia, + ); } } diff --git a/test/catalog/demo_media_test.dart b/test/catalog/demo_media_test.dart deleted file mode 100644 index b823934..0000000 --- a/test/catalog/demo_media_test.dart +++ /dev/null @@ -1,26 +0,0 @@ -import 'package:flutter/services.dart'; -import 'package:flutter_test/flutter_test.dart'; -import 'package:nontonki/core/data/repositories/catalog_repository.dart'; - -void main() { - TestWidgetsFlutterBinding.ensureInitialized(); - - test('all mock entries reuse one bundled local demo video', () async { - final dramas = await DemoCatalogRepository().fetchDramas(); - expect(dramas, hasLength(3)); - expect(dramas.every((drama) => drama.episodes.length == 3), isTrue); - final paths = { - for (final drama in dramas) - for (final episode in drama.episodes) episode.assetPath, - }; - expect(paths, {'assets/media/demo_clip.mp4'}); - expect( - dramas.every( - (drama) => drama.episodes.every((episode) => episode.isFree), - ), - isTrue, - ); - final bytes = await rootBundle.load(paths.single); - expect(bytes.lengthInBytes, greaterThan(1000000)); - }); -} diff --git a/test/catalog/home_feed_category_test.dart b/test/catalog/home_feed_category_test.dart deleted file mode 100644 index f10457a..0000000 --- a/test/catalog/home_feed_category_test.dart +++ /dev/null @@ -1,22 +0,0 @@ -import 'package:flutter_test/flutter_test.dart'; -import 'package:nontonki/pages/home/home_feed_sections.dart'; -import 'package:nontonki/core/data/repositories/catalog_repository.dart'; - -void main() { - test( - 'home categories filter demo dramas without changing their media', - () async { - final dramas = await DemoCatalogRepository().fetchDramas(); - final sections = HomeFeedSections(dramas); - - expect(sections.indicesFor(HomeFeedCategory.recommended), [0, 1, 2]); - expect(sections.indicesFor(HomeFeedCategory.animated), [0]); - expect(sections.indicesFor(HomeFeedCategory.liveAction), [1, 2]); - expect(sections.indicesFor(HomeFeedCategory.following), isEmpty); - expect( - sections.dramaAt(HomeFeedCategory.liveAction, 0).title, - 'City Lights & Velvet Nights', - ); - }, - ); -} diff --git a/test/playback/playback_preload_test.dart b/test/playback/playback_preload_test.dart index 569f263..4dc671b 100644 --- a/test/playback/playback_preload_test.dart +++ b/test/playback/playback_preload_test.dart @@ -12,7 +12,7 @@ void main() { id: 'ep-$i', number: i + 1, title: 'Episode $i', - assetPath: 'test-$i.mp4', + videoUrl: 'https://example.test/$i.mp4', isFree: i < 4, ), ); diff --git a/test/playback/playback_queue_test.dart b/test/playback/playback_queue_test.dart index 461451d..179f4a2 100644 --- a/test/playback/playback_queue_test.dart +++ b/test/playback/playback_queue_test.dart @@ -1,26 +1,76 @@ import 'package:flutter_test/flutter_test.dart'; -import 'package:nontonki/core/data/repositories/catalog_repository.dart'; +import 'package:nontonki/core/data/models/drama.dart'; import 'package:nontonki/core/data/services/playback_queue.dart'; void main() { - test( - 'home feed advances between dramas, series player between episodes', - () async { - final dramas = await DemoCatalogRepository().fetchDramas(); - final home = PlaybackQueue.home(dramas); - expect(home.length, 3); - expect(home.entryAt(0).drama.id, dramas[0].id); - expect(home.entryAt(1).drama.id, dramas[1].id); - expect(home.entryAt(1).episode.number, 1); - expect(home.nextIndex(0), 1); - expect(home.nextIndex(2), isNull); + test('home feed advances between dramas, series player between episodes', () { + final dramas = [_drama('a', 3), _drama('b', 2), _drama('c', 4)]; - final series = PlaybackQueue.series(dramas[0]); - expect(series.length, 3); - expect(series.entryAt(0).drama.id, series.entryAt(1).drama.id); - expect(series.entryAt(1).episode.number, 2); - expect(series.nextIndex(0), 1); - expect(series.nextIndex(2), isNull); - }, - ); + final home = PlaybackQueue.home(dramas); + expect(home.length, 3); + expect(home.entryAt(0).drama.id, 'a'); + expect(home.entryAt(1).drama.id, 'b'); + expect(home.entryAt(1).episode.number, 1); + expect(home.nextIndex(0), 1); + expect(home.nextIndex(2), isNull); + + final series = PlaybackQueue.series(dramas[0]); + expect(series.length, 3); + expect(series.entryAt(0).drama.id, series.entryAt(1).drama.id); + expect(series.entryAt(1).episode.number, 2); + expect(series.nextIndex(0), 1); + expect(series.nextIndex(2), isNull); + }); + + test('dramas without episodes are left out of the home queue', () { + final home = PlaybackQueue.home([ + _drama('a', 2), + Drama( + id: 'empty', + title: '没有剧集', + synopsis: '', + posterUrl: '/files/empty.jpg', + ), + ]); + expect(home.length, 1); + expect(home.entryAt(0).drama.id, 'a'); + }); + + test('a list card with a preview episode plays on the home feed', () { + final home = PlaybackQueue.home([ + Drama.fromCardJson(const { + 'id': 5, + 'title': '闪婚后', + 'cover': '/files/cover.jpg', + 'totalEpisodes': 77, + 'preview': { + 'id': 9, + 'number': 1, + 'title': '第 1 集', + 'isFree': true, + 'playUrl': '/files/episode/9.mp4', + }, + }), + ]); + + expect(home.length, 1); + expect(home.entryAt(0).episode.videoUrl, '/files/episode/9.mp4'); + }); } + +Drama _drama(String id, int episodeCount) => Drama( + id: id, + title: 'Drama $id', + synopsis: '简介 $id', + posterUrl: '/files/$id.jpg', + episodes: [ + for (var index = 1; index <= episodeCount; index++) + Episode( + id: '$id-$index', + number: index, + title: '第 $index 集', + isFree: true, + videoUrl: 'https://example.test/$id-$index.mp4', + ), + ], +); diff --git a/test/playback/playback_session_test.dart b/test/playback/playback_session_test.dart index 4dcc547..99e17ab 100644 --- a/test/playback/playback_session_test.dart +++ b/test/playback/playback_session_test.dart @@ -12,7 +12,7 @@ void main() { id: 'ep-${i + 1}', number: i + 1, title: 'Episode ${i + 1}', - assetPath: 'assets/media/episode_0${i + 1}.mp4', + videoUrl: 'https://example.test/episode_0${i + 1}.mp4', isFree: i < 2, ), ); @@ -99,6 +99,47 @@ void main() { await session.close(); }); + test('pausing then swiping to the next episode resumes playback', () async { + final factory = FakeFactory(); + final session = PlaybackSession( + episodes: episodes, + factory: factory.create, + canPlay: (episode) => episode.isFree, + ); + await session.select(0); + session.setUserWantsPlay(false); + await Future.delayed(Duration.zero); + expect(session.userWantsPlay, isFalse); + + await session.select(1); + + expect(session.userWantsPlay, isTrue); + await Future.delayed(Duration.zero); + final playing = session.active; + expect(playing, isA()); + expect((playing! as FakePlayer).playCalls, greaterThan(0)); + await session.close(); + }); + + test('re-selecting the same episode keeps the user pause', () async { + final factory = FakeFactory(); + final session = PlaybackSession( + episodes: episodes, + factory: factory.create, + canPlay: (episode) => episode.isFree, + ); + await session.select(0); + session.setUserWantsPlay(false); + await Future.delayed(Duration.zero); + + // 页面重新可见等场景会重复选中同一集,这时不能把暂停改成播放。 + await session.select(0); + + expect(session.userWantsPlay, isFalse); + expect(session.canAutoAdvance, isFalse); + await session.close(); + }); + test('automatic advance respects visibility and playback intent', () async { final factory = FakeFactory(); final session = PlaybackSession( diff --git a/test/playback/seek_progress_bar_test.dart b/test/playback/seek_progress_bar_test.dart index f13a976..01f1114 100644 --- a/test/playback/seek_progress_bar_test.dart +++ b/test/playback/seek_progress_bar_test.dart @@ -78,21 +78,20 @@ void main() { body: SeekProgressBar( valueListenable: video, semanticsLabel: 'Seek video', - compactIdle: true, onSeek: (_) async {}, ), ), ), ); - expect(find.text('00:03'), findsNothing); + expect(find.textContaining('00:12'), findsNothing); final gesture = await tester.startGesture( tester.getCenter(find.byType(Slider)), ); await gesture.moveBy(const Offset(40, 0)); await tester.pump(); - expect(find.text('00:12'), findsOneWidget); + expect(find.textContaining('/ 00:12'), findsOneWidget); await gesture.up(); await tester.pumpAndSettle(); - expect(find.text('00:12'), findsNothing); + expect(find.textContaining('00:12'), findsNothing); }); } diff --git a/test/playback/watch_history_test.dart b/test/playback/watch_history_test.dart index fbd5ffa..8e3c081 100644 --- a/test/playback/watch_history_test.dart +++ b/test/playback/watch_history_test.dart @@ -1,4 +1,5 @@ import 'package:flutter_test/flutter_test.dart'; +import 'package:nontonki/core/data/models/drama.dart'; import 'package:nontonki/core/data/repositories/watch_history_repository.dart'; import 'package:shared_preferences_platform_interface/in_memory_shared_preferences_async.dart'; import 'package:shared_preferences_platform_interface/shared_preferences_async_platform_interface.dart'; @@ -51,4 +52,79 @@ void main() { expect(await history.lastEpisodeId('profile-a', 'drama-a'), 'episode-2'); expect(await history.lastEpisodeId('profile-a', 'drama-b'), isNull); }); + + test('resume prefers the first loaded episode', () async { + SharedPreferencesAsyncPlatform.instance = + InMemorySharedPreferencesAsync.empty(); + final history = SharedPreferencesWatchHistoryRepository(); + await history.save( + 'profile-a', + 'drama-a', + 'episode-1', + const Duration(seconds: 3), + ); + await history.save( + 'profile-a', + 'drama-a', + 'episode-2', + const Duration(seconds: 5), + ); + + final drama = Drama( + id: 'drama-a', + title: 'title', + synopsis: 'synopsis', + posterUrl: '', + episodes: const [ + Episode(id: 'episode-1', number: 1, title: 'E1', isFree: true), + Episode(id: 'episode-2', number: 2, title: 'E2', isFree: true), + ], + ); + + expect( + await history.resumePositionFor('profile-a', drama), + const Duration(seconds: 3), + ); + }); + + test('resume falls back to the last watched episode for a list card', () async { + SharedPreferencesAsyncPlatform.instance = + InMemorySharedPreferencesAsync.empty(); + final history = SharedPreferencesWatchHistoryRepository(); + await history.save( + 'profile-a', + 'drama-a', + 'episode-2', + const Duration(seconds: 5), + ); + + const card = Drama( + id: 'drama-a', + title: 'title', + synopsis: 'synopsis', + posterUrl: '', + totalEpisodes: 12, + ); + + expect( + await history.resumePositionFor('profile-a', card), + const Duration(seconds: 5), + ); + }); + + test('a list card with no history has no resume position', () async { + SharedPreferencesAsyncPlatform.instance = + InMemorySharedPreferencesAsync.empty(); + final history = SharedPreferencesWatchHistoryRepository(); + + const card = Drama( + id: 'drama-b', + title: 'title', + synopsis: 'synopsis', + posterUrl: '', + totalEpisodes: 12, + ); + + expect(await history.resumePositionFor('profile-a', card), isNull); + }); } -- 2.54.0 From e1b98df509490144a3781a2b7ac0cf72518addfb Mon Sep 17 00:00:00 2001 From: Vicky <10212746+haifeng-jiang@user.noreply.gitee.com> Date: Thu, 15 Oct 2026 17:53:35 +0800 Subject: [PATCH 02/76] =?UTF-8?q?feat(client):=20C=20=E7=AB=AF=201-2=20?= =?UTF-8?q?=E8=B4=A6=E5=8F=B7=E9=93=BE=E8=B7=AF=EF=BC=88=E9=82=AE=E7=AE=B1?= =?UTF-8?q?=E7=99=BB=E5=BD=95/=E6=B3=A8=E5=86=8C=20+=20=E4=BB=A4=E7=89=8C?= =?UTF-8?q?=E4=B8=8E=20401=20+=20=E5=8C=BF=E5=90=8D/=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E5=88=86=E5=8F=89=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 为什么:客户端此前完全没有账号概念(mine 页的"登录"只是本地 demo 开关), 而受限动作(收藏/评论)要对到具体账号。本批把账号链路接上,为后续互动、进度同步、下载打底。 - AuthApi + AuthController + AuthSessionStore:注册/登录/登出/刷新,令牌与设备号存 shared_preferences (用 SharedPreferencesAsync,与 engagement 仓库同一套 API) - ApiClient:统一带 Authorization 与 X-Device-Id;401 自动刷新一次并重试,刷新失败清登录态走 onUnauthorized - 登录/注册页(pages/auth,沿用 binding/logic/view 与现有视觉):邮箱格式、密码 8-64 位含字母数字本地先校验, 错误提示走 l10n;登录/注册一键切换 - 匿名/登录分叉:首页、发现、详情保持匿名可看;收藏/点赞等受限动作走 ensureSignedIn() 弹底部提示引导登录 - mine 页展示真实账号(昵称 + uid),拿不到才回落到演示文案 - 测试:新增 auth 控制器(注册落盘/401 刷新重试/刷新失败清会话/登出)与登录页(校验/切换)用例; widget_test 改为预置本地会话(账号不再是本地开关);修掉 playback 用例对 host 大小写的环境依赖断言 门禁:flutter analyze 0 问题;flutter test 148 全过。 --- lib/app.dart | 52 +- lib/core/data/models/auth_session.dart | 51 ++ lib/core/data/remote/api_client.dart | 130 +++ lib/core/data/remote/auth_api.dart | 73 ++ lib/core/data/services/auth_controller.dart | 103 +++ .../data/services/auth_session_store.dart | 74 ++ lib/core/widgets/auth_gate.dart | 83 ++ lib/l10n/app_en.arb | 52 +- lib/l10n/app_localizations.dart | 300 ++++++ lib/l10n/app_localizations_en.dart | 150 +++ lib/l10n/app_localizations_zh.dart | 150 +++ lib/l10n/app_zh.arb | 52 +- lib/pages/auth/auth_binding.dart | 6 + lib/pages/auth/auth_logic.dart | 50 + lib/pages/auth/auth_view.dart | 227 +++++ lib/pages/home/home_logic.dart | 47 +- lib/pages/home/home_view.dart | 103 ++- lib/pages/mine/mine_view.dart | 490 +++++----- lib/pages/player/player_view.dart | 866 ++++++------------ test/auth/auth_controller_test.dart | 156 ++++ test/auth/auth_page_test.dart | 81 ++ test/home/home_logic_test.dart | 227 +++++ test/playback/video_player_port_test.dart | 37 + test/widget_test.dart | 327 +++---- 24 files changed, 2871 insertions(+), 1016 deletions(-) create mode 100644 lib/core/data/models/auth_session.dart create mode 100644 lib/core/data/remote/api_client.dart create mode 100644 lib/core/data/remote/auth_api.dart create mode 100644 lib/core/data/services/auth_controller.dart create mode 100644 lib/core/data/services/auth_session_store.dart create mode 100644 lib/core/widgets/auth_gate.dart create mode 100644 lib/pages/auth/auth_binding.dart create mode 100644 lib/pages/auth/auth_logic.dart create mode 100644 lib/pages/auth/auth_view.dart create mode 100644 test/auth/auth_controller_test.dart create mode 100644 test/auth/auth_page_test.dart create mode 100644 test/home/home_logic_test.dart create mode 100644 test/playback/video_player_port_test.dart diff --git a/lib/app.dart b/lib/app.dart index ba4b636..ff4f0cc 100644 --- a/lib/app.dart +++ b/lib/app.dart @@ -2,8 +2,13 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; 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/repositories/catalog_repository.dart'; import 'core/data/repositories/engagement_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/engagement_controller.dart'; import 'core/data/services/playback_session.dart'; @@ -11,19 +16,53 @@ import 'core/data/services/video_player_port.dart'; import 'l10n/app_localizations.dart'; import 'pages/home/home_view.dart'; -class LumaDramaApp extends StatelessWidget { - const LumaDramaApp({super.key, this.playerFactory = VideoPlayerPort.new}); +class LumaDramaApp extends StatefulWidget { + const LumaDramaApp({ + super.key, + this.playerFactory = VideoPlayerPort.new, + this.catalogRepository, + }); final PlayerFactory playerFactory; + /// 测试注入用;生产走 HTTP 仓库。 + final CatalogRepository? catalogRepository; + + @override + State createState() => _LumaDramaAppState(); +} + +class _LumaDramaAppState extends State { + late final AuthSessionStore _sessionStore = AuthSessionStore(); + + /// 全 App 共用一个 ApiClient:这样目录、账号、后续的互动/进度请求 + /// 都自动带 `Authorization` 与 `X-Device-Id`,401 的刷新重试也只有一处实现。 + late final ApiClient _apiClient = ApiClient( + accessTokenReader: () => _auth.accessToken, + tokenRefresher: () => _auth.refresh(), + onUnauthorized: () => _auth.clear(), + deviceIdReader: _sessionStore.deviceId, + ); + + late final AuthController _auth = AuthController(AuthApi(_apiClient), _sessionStore); + + @override + void initState() { + super.initState(); + // 恢复本地令牌与设备号;未登录也能正常浏览,不阻塞首屏 + _auth.load(); + } + @override Widget build(BuildContext context) { return MultiProvider( providers: [ Provider(create: (_) => PlaybackCoordinator()), - Provider(create: (_) => playerFactory), + Provider(create: (_) => widget.playerFactory), ChangeNotifierProvider( - create: (_) => CatalogController(DemoCatalogRepository())..load(), + create: (_) => CatalogController( + widget.catalogRepository ?? HttpCatalogRepository(CatalogApi(_apiClient)), + )..load(), ), ChangeNotifierProvider(create: (_) => LocaleController()..load()), ChangeNotifierProvider( @@ -31,6 +70,7 @@ class LumaDramaApp extends StatelessWidget { EngagementController(SharedPreferencesEngagementRepository()) ..load(), ), + ChangeNotifierProvider.value(value: _auth), ], child: Consumer( builder: (context, locale, _) => MaterialApp( @@ -51,14 +91,14 @@ class LumaDramaApp extends StatelessWidget { theme: ThemeData( useMaterial3: true, colorScheme: ColorScheme.fromSeed( - seedColor: const Color(0xFF6D4AFF), + seedColor: const Color(0xFF2F7BFF), ), scaffoldBackgroundColor: const Color(0xFFF8F7FC), ), darkTheme: ThemeData( useMaterial3: true, colorScheme: ColorScheme.fromSeed( - seedColor: const Color(0xFF9B86FF), + seedColor: const Color(0xFF2F7BFF), brightness: Brightness.dark, ), scaffoldBackgroundColor: const Color(0xFF101019), diff --git a/lib/core/data/models/auth_session.dart b/lib/core/data/models/auth_session.dart new file mode 100644 index 0000000..d3efa84 --- /dev/null +++ b/lib/core/data/models/auth_session.dart @@ -0,0 +1,51 @@ +/// 登录态:服务端下发的令牌与用户摘要。 +/// +/// 只保留客户端真正要用的字段(uid / 昵称 / 头像),不做整份 AppUserRespVO 的映射 —— +/// 首页卡片、个人页需要的都在这里,避免为用不到的字段维护一份平行模型。 +class AuthUser { + const AuthUser({required this.uid, required this.nickname, this.avatarUrl = ''}); + + final String uid; + final String nickname; + final String avatarUrl; + + factory AuthUser.fromJson(Map json) => AuthUser( + uid: json['uid'] as String? ?? '', + nickname: json['nickname'] as String? ?? '', + avatarUrl: json['avatarUrl'] as String? ?? '', + ); + + Map toJson() => { + 'uid': uid, + 'nickname': nickname, + 'avatarUrl': avatarUrl, + }; +} + +class AuthSession { + const AuthSession({ + required this.accessToken, + required this.refreshToken, + this.expiresIn = 0, + required this.user, + }); + + final String accessToken; + final String refreshToken; + final int expiresIn; + final AuthUser user; + + factory AuthSession.fromJson(Map json) => AuthSession( + accessToken: json['accessToken'] as String? ?? '', + refreshToken: json['refreshToken'] as String? ?? '', + expiresIn: (json['expiresIn'] as num?)?.toInt() ?? 0, + user: AuthUser.fromJson((json['user'] as Map?)?.cast() ?? const {}), + ); + + Map toJson() => { + 'accessToken': accessToken, + 'refreshToken': refreshToken, + 'expiresIn': expiresIn, + 'user': user.toJson(), + }; +} diff --git a/lib/core/data/remote/api_client.dart b/lib/core/data/remote/api_client.dart new file mode 100644 index 0000000..ca1d5b2 --- /dev/null +++ b/lib/core/data/remote/api_client.dart @@ -0,0 +1,130 @@ +import 'dart:convert'; + +import 'package:http/http.dart' as http; + +import '../../config/app_config.dart'; + +/// 接口异常:code 为后端业务码,message 可直接展示。 +class ApiException implements Exception { + const ApiException(this.code, this.message); + + final int code; + final String message; + + @override + String toString() => 'ApiException($code, $message)'; +} + +/// 后端统一响应壳 `{code, message, data}` 的解析入口。 +class ApiClient { + ApiClient({ + String? baseUrl, + http.Client? client, + this.accessTokenReader, + this.tokenRefresher, + this.onUnauthorized, + this.deviceIdReader, + }) + : baseUrl = baseUrl ?? AppConfig.apiBaseUrl, + _client = client ?? http.Client(); + + final String baseUrl; + final http.Client _client; + + /// 取当前 access token(未登录返回 null) + final String? Function()? accessTokenReader; + + /// 刷新令牌:返回 true 表示刷新成功,可以重试原请求 + final Future Function()? tokenRefresher; + + /// 刷新也失败时回调(清本地登录态、回收 UI) + final void Function()? onUnauthorized; + + /// 设备号(`X-Device-Id`):注册风控、后续下载绑定都要用 + final Future Function()? deviceIdReader; + + Future get(String path, {Map? query}) { + return _send('GET', path, query: query); + } + + Future post( + String path, { + Object? body, + Map? query, + bool skipAuthRetry = false, + }) { + return _send('POST', path, body: body, query: query, skipAuthRetry: skipAuthRetry); + } + + Future _send( + String method, + String path, { + Object? body, + Map? query, + bool retried = false, + bool skipAuthRetry = false, + }) async { + final uri = Uri.parse( + '$baseUrl$path', + ).replace(queryParameters: query?.isEmpty ?? true ? null : query); + final headers = await _headers(withBody: body != null); + final response = await (method == 'GET' + ? _client.get(uri, headers: headers) + : _client.post( + uri, + headers: headers, + body: body == null ? null : jsonEncode(body), + )) + .timeout(AppConfig.requestTimeout); + + Map shell = const {}; + try { + shell = (jsonDecode(utf8.decode(response.bodyBytes)) as Map) + .cast(); + } catch (_) { + shell = const {}; + } + final code = shell['code'] as int? ?? -1; + + // 令牌过期:刷新一次再重试原请求;刷新失败就清登录态并抛给调用方 + if (code == 401 && !retried && !skipAuthRetry && tokenRefresher != null) { + final refreshed = await tokenRefresher!.call(); + if (refreshed) { + return _send( + method, + path, + body: body, + query: query, + retried: true, + skipAuthRetry: skipAuthRetry, + ); + } + onUnauthorized?.call(); + throw ApiException(401, shell['message'] as String? ?? '登录已过期'); + } + + if (code == -1) { + throw ApiException(response.statusCode, 'HTTP ${response.statusCode}'); + } + if (code != 0) { + throw ApiException(code, shell['message'] as String? ?? '请求失败'); + } + return shell['data']; + } + + Future> _headers({required bool withBody}) async { + final headers = {'Accept': 'application/json'}; + if (withBody) headers['Content-Type'] = 'application/json'; + final token = accessTokenReader?.call(); + if (token != null && token.isNotEmpty) { + headers['Authorization'] = 'Bearer $token'; + } + final deviceId = await deviceIdReader?.call(); + if (deviceId != null && deviceId.isNotEmpty) { + headers['X-Device-Id'] = deviceId; + } + return headers; + } + + void close() => _client.close(); +} diff --git a/lib/core/data/remote/auth_api.dart b/lib/core/data/remote/auth_api.dart new file mode 100644 index 0000000..175f753 --- /dev/null +++ b/lib/core/data/remote/auth_api.dart @@ -0,0 +1,73 @@ +import '../models/auth_session.dart'; +import 'api_client.dart'; + +/// 账号相关接口(/app/auth/**)。 +/// +/// 注册/登录都用「邮箱 + 密码」;邮箱注册不需要验证码(后端按 targetType 放开), +/// 手机号注册仍要验证码 —— 客户端这一批只开放邮箱入口。 +class AuthApi { + const AuthApi(this._client); + + final ApiClient _client; + + Future register({ + required String email, + required String password, + required String deviceId, + String platform = '', + String appVersion = '', + }) async { + final data = await _client.post( + '/app/auth/register', + body: { + 'targetType': 'EMAIL', + 'target': email, + 'password': password, + 'countryCode': 'ID', + 'deviceId': deviceId, + 'platform': platform, + 'appVersion': appVersion, + }, + ); + return AuthSession.fromJson((data as Map).cast()); + } + + Future login({ + required String email, + required String password, + required String deviceId, + String platform = '', + String appVersion = '', + }) async { + final data = await _client.post( + '/app/auth/login', + body: { + 'targetType': 'EMAIL', + 'target': email, + 'password': password, + 'deviceId': deviceId, + 'platform': platform, + 'appVersion': appVersion, + }, + ); + return AuthSession.fromJson((data as Map).cast()); + } + + Future refresh(String refreshToken) async { + final data = await _client.post( + '/app/auth/refresh', + body: {'refreshToken': refreshToken}, + // 刷新请求本身不带旧令牌重试,失败就是失败 + skipAuthRetry: true, + ); + return AuthSession.fromJson((data as Map).cast()); + } + + Future logout(String refreshToken) async { + await _client.post( + '/app/auth/logout', + body: {'refreshToken': refreshToken}, + skipAuthRetry: true, + ); + } +} diff --git a/lib/core/data/services/auth_controller.dart b/lib/core/data/services/auth_controller.dart new file mode 100644 index 0000000..7b51540 --- /dev/null +++ b/lib/core/data/services/auth_controller.dart @@ -0,0 +1,103 @@ +import 'package:flutter/foundation.dart'; + +import '../models/auth_session.dart'; +import '../remote/api_client.dart'; +import '../remote/auth_api.dart'; +import 'auth_session_store.dart'; + +/// 登录态的唯一来源。 +/// +/// 职责:本地会话的读写([AuthSessionStore])、注册/登录/登出、令牌刷新; +/// 也是 [ApiClient] 的 `accessTokenReader` / `tokenRefresher` / `onUnauthorized` 实现方 —— +/// 401 → 刷新 → 重试失败就清会话,UI 通过 [isSignedIn] 自动回到未登录态。 +class AuthController extends ChangeNotifier { + AuthController(this._api, this._store); + + final AuthApi _api; + final AuthSessionStore _store; + + AuthSession? _session; + String _deviceId = ''; + bool _loaded = false; + + bool get isLoaded => _loaded; + bool get isSignedIn => _session != null; + AuthUser? get user => _session?.user; + String? get accessToken => _session?.accessToken; + String get deviceId => _deviceId; + + /// App 启动时调用:恢复本地令牌与设备号。 + Future load() async { + _deviceId = await _store.deviceId(); + _session = await _store.read(); + _loaded = true; + notifyListeners(); + } + + Future register({required String email, required String password}) async { + final session = await _api.register( + email: email, + password: password, + deviceId: await _store.deviceId(), + platform: _platform, + ); + await _apply(session); + } + + Future signIn({required String email, required String password}) async { + final session = await _api.login( + email: email, + password: password, + deviceId: await _store.deviceId(), + platform: _platform, + ); + await _apply(session); + } + + Future signOut() async { + final refreshToken = _session?.refreshToken ?? ''; + _session = null; + await _store.clear(); + notifyListeners(); + if (refreshToken.isNotEmpty) { + // 服务端吊销失败不影响本地已登出,异常直接吞掉 + try { + await _api.logout(refreshToken); + } catch (_) {} + } + } + + /// 供 [ApiClient] 调用:刷新令牌并落盘。失败时清本地会话。 + Future refresh() async { + final refreshToken = _session?.refreshToken ?? ''; + if (refreshToken.isEmpty) { + await clear(); + return false; + } + try { + await _apply(await _api.refresh(refreshToken)); + return true; + } catch (_) { + await clear(); + return false; + } + } + + Future clear() async { + if (_session == null) return; + _session = null; + await _store.clear(); + notifyListeners(); + } + + Future _apply(AuthSession session) async { + _session = session; + await _store.save(session); + notifyListeners(); + } + + String get _platform { + if (kIsWeb) return 'WEB'; + return defaultTargetPlatform == TargetPlatform.iOS ? 'IOS' : 'ANDROID'; + } +} diff --git a/lib/core/data/services/auth_session_store.dart b/lib/core/data/services/auth_session_store.dart new file mode 100644 index 0000000..1586759 --- /dev/null +++ b/lib/core/data/services/auth_session_store.dart @@ -0,0 +1,74 @@ +import 'dart:convert'; +import 'dart:math'; + +import 'package:shared_preferences/shared_preferences.dart'; + +import '../models/auth_session.dart'; + +/// 令牌与设备号的本地持久化。 +/// +/// 用 `SharedPreferencesAsync`(与项目里 engagement 仓库一致):旧的 +/// `SharedPreferences.getInstance()` 在新版本里已标注弃用,两套混用还会让 +/// widget 测试只 mock 到其中一套。 +/// +/// 设备号是后端注册风控与后续"下载设备绑定"的依据,所以**首次生成后就固定下来**; +/// 不引 UUID 库(保持极简依赖),用「时间戳 + 随机数」拼一个够用的 id。 +class AuthSessionStore { + static const _kAccessToken = 'auth.accessToken'; + static const _kRefreshToken = 'auth.refreshToken'; + static const _kUser = 'auth.user'; + static const _kDeviceId = 'device.id'; + + String? _cachedDeviceId; + + Future deviceId() async { + if (_cachedDeviceId != null) return _cachedDeviceId!; + final prefs = SharedPreferencesAsync(); + var value = await prefs.getString(_kDeviceId) ?? ''; + if (value.isEmpty) { + final random = Random(); + value = + 'd-${DateTime.now().millisecondsSinceEpoch.toRadixString(36)}-' + '${random.nextInt(1 << 32).toRadixString(36)}'; + await prefs.setString(_kDeviceId, value); + } + _cachedDeviceId = value; + return value; + } + + Future read() async { + final prefs = SharedPreferencesAsync(); + final accessToken = await prefs.getString(_kAccessToken) ?? ''; + final refreshToken = await prefs.getString(_kRefreshToken) ?? ''; + if (accessToken.isEmpty || refreshToken.isEmpty) return null; + final rawUser = await prefs.getString(_kUser); + Map user = const {}; + if (rawUser != null && rawUser.isNotEmpty) { + try { + user = (jsonDecode(rawUser) as Map).cast(); + } catch (_) { + user = const {}; + } + } + return AuthSession( + accessToken: accessToken, + refreshToken: refreshToken, + user: AuthUser.fromJson(user), + ); + } + + Future save(AuthSession session) async { + final prefs = SharedPreferencesAsync(); + await prefs.setString(_kAccessToken, session.accessToken); + await prefs.setString(_kRefreshToken, session.refreshToken); + await prefs.setString(_kUser, jsonEncode(session.user.toJson())); + } + + Future clear() async { + final prefs = SharedPreferencesAsync(); + await prefs.remove(_kAccessToken); + await prefs.remove(_kRefreshToken); + await prefs.remove(_kUser); + // 设备号不清:它代表"这台设备",与登录态无关 + } +} diff --git a/lib/core/widgets/auth_gate.dart b/lib/core/widgets/auth_gate.dart new file mode 100644 index 0000000..2e07000 --- /dev/null +++ b/lib/core/widgets/auth_gate.dart @@ -0,0 +1,83 @@ +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; + +import '../../l10n/app_localizations.dart'; +import '../../pages/auth/auth_view.dart'; +import '../data/services/auth_controller.dart'; +import '../theme/app_colors.dart'; + +/// 打开登录 / 注册页(沿用现有 Navigator 风格,不引路由库) +Future openAuthPage(BuildContext context, {bool signUpMode = false}) { + return Navigator.of(context).push( + MaterialPageRoute( + builder: (_) => AuthPage(signUpMode: signUpMode), + ), + ); +} + +/// 受限动作的登录闸:已登录返回 true;未登录弹底部提示并引导登录,返回 false。 +/// +/// 首页/发现/详情保持匿名可看,只有收藏、点赞、评论这类"要对到具体账号"的动作才走这里。 +Future ensureSignedIn(BuildContext context) async { + final auth = context.read(); + if (auth.isSignedIn) return true; + + final l10n = AppLocalizations.of(context)!; + final go = await showModalBottomSheet( + context: context, + backgroundColor: AppColors.card, + shape: const RoundedRectangleBorder( + borderRadius: BorderRadius.vertical(top: Radius.circular(18)), + ), + builder: (sheetContext) => SafeArea( + child: Padding( + padding: const EdgeInsets.fromLTRB(20, 18, 20, 20), + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + l10n.authGateTitle, + style: const TextStyle( + color: Colors.white, + fontSize: 16, + fontWeight: FontWeight.w800, + ), + ), + const SizedBox(height: 6), + Text( + l10n.authGateMessage, + style: const TextStyle(color: AppColors.muted, fontSize: 13), + ), + const SizedBox(height: 16), + Row( + children: [ + Expanded( + child: OutlinedButton( + onPressed: () => Navigator.of(sheetContext).pop(false), + child: Text(l10n.cancel), + ), + ), + const SizedBox(width: 10), + Expanded( + child: FilledButton( + style: FilledButton.styleFrom( + backgroundColor: AppColors.blue, + ), + onPressed: () => Navigator.of(sheetContext).pop(true), + child: Text(l10n.authGateAction), + ), + ), + ], + ), + ], + ), + ), + ), + ); + + if (go == true && context.mounted) { + await openAuthPage(context); + } + return false; +} diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index 4559e95..e9b4cfe 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -96,6 +96,8 @@ "lockedBody": "Unlocking will be available after store and verification setup. This demo does not process payments.", "playbackError": "This clip could not be played.", "catalogError": "The catalog could not be loaded.", + "detailError": "The episode list could not be loaded.", + "noMediaNotice": "This episode has no playable media yet.", "noStories": "No stories available yet.", "retry": "Retry", "backToSeries": "Back to series", @@ -130,5 +132,53 @@ "continueWatchingHeading": "CONTINUE WATCHING", "preferencesHeading": "PREFERENCES", "brandMark": "NONTONKI · DEMO", - "shareFooter": "Nontonki demo" + "shareFooter": "Nontonki demo", + "shortsTab": "Shorts", + "myListTab": "My List", + "watchFull": "Watch Full", + "swipeForNext": "Swipe up for next", + "clearScreen": "Clear screen", + "exitClearScreen": "Exit clear screen", + "logIn": "Log in", + "logInHint": "Keep your coins and list", + "rewards": "Rewards", + "forYou": "For You", + "hot": "Hot", + "newest": "New", + "favorite": "Favorite", + "myAccount": "My account", + "coins": "Coins", + "topUpWallet": "Top Up Wallet", + "vipMembership": "VIP Membership", + "notActive": "Not Active", + "joinVip": "Join VIP", + "earnRewards": "Earn Rewards", + "freeBonus": "Get Free Bonus", + "watchHistory": "Watch History", + "settings": "Settings", + "signOut": "Sign Out", + "mockUserName": "Vicky sheng", + "mockUserId": "ID: M1CZWVYE", + "mockNotice": "Sample data only.", + "topBadge": "TOP 1", + "signIn": "Sign In", + "signUp": "Sign Up", + "authSignInTitle": "Welcome back", + "authSignUpTitle": "Create your account", + "authSubtitle": "Sign in with your email and password.", + "authEmailLabel": "Email", + "authPasswordLabel": "Password", + "authPasswordHint": "At least 8 characters, letters and numbers", + "authEmailRequired": "Enter your email", + "authEmailInvalid": "That email doesn't look right", + "authPasswordRequired": "Enter your password", + "authPasswordLength": "Password must be 8-64 characters", + "authPasswordWeak": "Password needs both letters and numbers", + "authNetworkError": "Network error, please try again", + "authSwitchToSignUp": "New here? Create an account", + "authSwitchToSignIn": "Already have an account? Sign in", + "authGateTitle": "Sign in to continue", + "authGateMessage": "Favorites and comments need an account.", + "authGateAction": "Sign In", + "cancel": "Not now" } diff --git a/lib/l10n/app_localizations.dart b/lib/l10n/app_localizations.dart index 3b7f19a..3b0ce7e 100644 --- a/lib/l10n/app_localizations.dart +++ b/lib/l10n/app_localizations.dart @@ -632,6 +632,18 @@ abstract class AppLocalizations { /// **'The catalog could not be loaded.'** String get catalogError; + /// No description provided for @detailError. + /// + /// In en, this message translates to: + /// **'The episode list could not be loaded.'** + String get detailError; + + /// No description provided for @noMediaNotice. + /// + /// In en, this message translates to: + /// **'This episode has no playable media yet.'** + String get noMediaNotice; + /// No description provided for @noStories. /// /// In en, this message translates to: @@ -841,6 +853,294 @@ abstract class AppLocalizations { /// In en, this message translates to: /// **'Nontonki demo'** String get shareFooter; + + /// No description provided for @shortsTab. + /// + /// In en, this message translates to: + /// **'Shorts'** + String get shortsTab; + + /// No description provided for @myListTab. + /// + /// In en, this message translates to: + /// **'My List'** + String get myListTab; + + /// No description provided for @watchFull. + /// + /// In en, this message translates to: + /// **'Watch Full'** + String get watchFull; + + /// No description provided for @swipeForNext. + /// + /// In en, this message translates to: + /// **'Swipe up for next'** + String get swipeForNext; + + /// No description provided for @clearScreen. + /// + /// In en, this message translates to: + /// **'Clear screen'** + String get clearScreen; + + /// No description provided for @exitClearScreen. + /// + /// In en, this message translates to: + /// **'Exit clear screen'** + String get exitClearScreen; + + /// No description provided for @logIn. + /// + /// In en, this message translates to: + /// **'Log in'** + String get logIn; + + /// No description provided for @logInHint. + /// + /// In en, this message translates to: + /// **'Keep your coins and list'** + String get logInHint; + + /// No description provided for @rewards. + /// + /// In en, this message translates to: + /// **'Rewards'** + String get rewards; + + /// No description provided for @forYou. + /// + /// In en, this message translates to: + /// **'For You'** + String get forYou; + + /// No description provided for @hot. + /// + /// In en, this message translates to: + /// **'Hot'** + String get hot; + + /// No description provided for @newest. + /// + /// In en, this message translates to: + /// **'New'** + String get newest; + + /// No description provided for @favorite. + /// + /// In en, this message translates to: + /// **'Favorite'** + String get favorite; + + /// No description provided for @myAccount. + /// + /// In en, this message translates to: + /// **'My account'** + String get myAccount; + + /// No description provided for @coins. + /// + /// In en, this message translates to: + /// **'Coins'** + String get coins; + + /// No description provided for @topUpWallet. + /// + /// In en, this message translates to: + /// **'Top Up Wallet'** + String get topUpWallet; + + /// No description provided for @vipMembership. + /// + /// In en, this message translates to: + /// **'VIP Membership'** + String get vipMembership; + + /// No description provided for @notActive. + /// + /// In en, this message translates to: + /// **'Not Active'** + String get notActive; + + /// No description provided for @joinVip. + /// + /// In en, this message translates to: + /// **'Join VIP'** + String get joinVip; + + /// No description provided for @earnRewards. + /// + /// In en, this message translates to: + /// **'Earn Rewards'** + String get earnRewards; + + /// No description provided for @freeBonus. + /// + /// In en, this message translates to: + /// **'Get Free Bonus'** + String get freeBonus; + + /// No description provided for @watchHistory. + /// + /// In en, this message translates to: + /// **'Watch History'** + String get watchHistory; + + /// No description provided for @settings. + /// + /// In en, this message translates to: + /// **'Settings'** + String get settings; + + /// No description provided for @signOut. + /// + /// In en, this message translates to: + /// **'Sign Out'** + String get signOut; + + /// No description provided for @mockUserName. + /// + /// In en, this message translates to: + /// **'Vicky sheng'** + String get mockUserName; + + /// No description provided for @mockUserId. + /// + /// In en, this message translates to: + /// **'ID: M1CZWVYE'** + String get mockUserId; + + /// No description provided for @mockNotice. + /// + /// In en, this message translates to: + /// **'Sample data only.'** + String get mockNotice; + + /// No description provided for @topBadge. + /// + /// In en, this message translates to: + /// **'TOP 1'** + String get topBadge; + + /// No description provided for @signIn. + /// + /// In en, this message translates to: + /// **'Sign In'** + String get signIn; + + /// No description provided for @signUp. + /// + /// In en, this message translates to: + /// **'Sign Up'** + String get signUp; + + /// No description provided for @authSignInTitle. + /// + /// In en, this message translates to: + /// **'Welcome back'** + String get authSignInTitle; + + /// No description provided for @authSignUpTitle. + /// + /// In en, this message translates to: + /// **'Create your account'** + String get authSignUpTitle; + + /// No description provided for @authSubtitle. + /// + /// In en, this message translates to: + /// **'Sign in with your email and password.'** + String get authSubtitle; + + /// No description provided for @authEmailLabel. + /// + /// In en, this message translates to: + /// **'Email'** + String get authEmailLabel; + + /// No description provided for @authPasswordLabel. + /// + /// In en, this message translates to: + /// **'Password'** + String get authPasswordLabel; + + /// No description provided for @authPasswordHint. + /// + /// In en, this message translates to: + /// **'At least 8 characters, letters and numbers'** + String get authPasswordHint; + + /// No description provided for @authEmailRequired. + /// + /// In en, this message translates to: + /// **'Enter your email'** + String get authEmailRequired; + + /// No description provided for @authEmailInvalid. + /// + /// In en, this message translates to: + /// **'That email doesn\'t look right'** + String get authEmailInvalid; + + /// No description provided for @authPasswordRequired. + /// + /// In en, this message translates to: + /// **'Enter your password'** + String get authPasswordRequired; + + /// No description provided for @authPasswordLength. + /// + /// In en, this message translates to: + /// **'Password must be 8-64 characters'** + String get authPasswordLength; + + /// No description provided for @authPasswordWeak. + /// + /// In en, this message translates to: + /// **'Password needs both letters and numbers'** + String get authPasswordWeak; + + /// No description provided for @authNetworkError. + /// + /// In en, this message translates to: + /// **'Network error, please try again'** + String get authNetworkError; + + /// No description provided for @authSwitchToSignUp. + /// + /// In en, this message translates to: + /// **'New here? Create an account'** + String get authSwitchToSignUp; + + /// No description provided for @authSwitchToSignIn. + /// + /// In en, this message translates to: + /// **'Already have an account? Sign in'** + String get authSwitchToSignIn; + + /// No description provided for @authGateTitle. + /// + /// In en, this message translates to: + /// **'Sign in to continue'** + String get authGateTitle; + + /// No description provided for @authGateMessage. + /// + /// In en, this message translates to: + /// **'Favorites and comments need an account.'** + String get authGateMessage; + + /// No description provided for @authGateAction. + /// + /// In en, this message translates to: + /// **'Sign In'** + String get authGateAction; + + /// No description provided for @cancel. + /// + /// In en, this message translates to: + /// **'Not now'** + String get cancel; } class _AppLocalizationsDelegate diff --git a/lib/l10n/app_localizations_en.dart b/lib/l10n/app_localizations_en.dart index ae2a353..8b0d272 100644 --- a/lib/l10n/app_localizations_en.dart +++ b/lib/l10n/app_localizations_en.dart @@ -294,6 +294,12 @@ class AppLocalizationsEn extends AppLocalizations { @override String get catalogError => 'The catalog could not be loaded.'; + @override + String get detailError => 'The episode list could not be loaded.'; + + @override + String get noMediaNotice => 'This episode has no playable media yet.'; + @override String get noStories => 'No stories available yet.'; @@ -401,4 +407,148 @@ class AppLocalizationsEn extends AppLocalizations { @override String get shareFooter => 'Nontonki demo'; + + @override + String get shortsTab => 'Shorts'; + + @override + String get myListTab => 'My List'; + + @override + String get watchFull => 'Watch Full'; + + @override + String get swipeForNext => 'Swipe up for next'; + + @override + String get clearScreen => 'Clear screen'; + + @override + String get exitClearScreen => 'Exit clear screen'; + + @override + String get logIn => 'Log in'; + + @override + String get logInHint => 'Keep your coins and list'; + + @override + String get rewards => 'Rewards'; + + @override + String get forYou => 'For You'; + + @override + String get hot => 'Hot'; + + @override + String get newest => 'New'; + + @override + String get favorite => 'Favorite'; + + @override + String get myAccount => 'My account'; + + @override + String get coins => 'Coins'; + + @override + String get topUpWallet => 'Top Up Wallet'; + + @override + String get vipMembership => 'VIP Membership'; + + @override + String get notActive => 'Not Active'; + + @override + String get joinVip => 'Join VIP'; + + @override + String get earnRewards => 'Earn Rewards'; + + @override + String get freeBonus => 'Get Free Bonus'; + + @override + String get watchHistory => 'Watch History'; + + @override + String get settings => 'Settings'; + + @override + String get signOut => 'Sign Out'; + + @override + String get mockUserName => 'Vicky sheng'; + + @override + String get mockUserId => 'ID: M1CZWVYE'; + + @override + String get mockNotice => 'Sample data only.'; + + @override + String get topBadge => 'TOP 1'; + + @override + String get signIn => 'Sign In'; + + @override + String get signUp => 'Sign Up'; + + @override + String get authSignInTitle => 'Welcome back'; + + @override + String get authSignUpTitle => 'Create your account'; + + @override + String get authSubtitle => 'Sign in with your email and password.'; + + @override + String get authEmailLabel => 'Email'; + + @override + String get authPasswordLabel => 'Password'; + + @override + String get authPasswordHint => 'At least 8 characters, letters and numbers'; + + @override + String get authEmailRequired => 'Enter your email'; + + @override + String get authEmailInvalid => 'That email doesn\'t look right'; + + @override + String get authPasswordRequired => 'Enter your password'; + + @override + String get authPasswordLength => 'Password must be 8-64 characters'; + + @override + String get authPasswordWeak => 'Password needs both letters and numbers'; + + @override + String get authNetworkError => 'Network error, please try again'; + + @override + String get authSwitchToSignUp => 'New here? Create an account'; + + @override + String get authSwitchToSignIn => 'Already have an account? Sign in'; + + @override + String get authGateTitle => 'Sign in to continue'; + + @override + String get authGateMessage => 'Favorites and comments need an account.'; + + @override + String get authGateAction => 'Sign In'; + + @override + String get cancel => 'Not now'; } diff --git a/lib/l10n/app_localizations_zh.dart b/lib/l10n/app_localizations_zh.dart index f61dc49..cc8b39c 100644 --- a/lib/l10n/app_localizations_zh.dart +++ b/lib/l10n/app_localizations_zh.dart @@ -289,6 +289,12 @@ class AppLocalizationsZh extends AppLocalizations { @override String get catalogError => '剧目列表加载失败。'; + @override + String get detailError => '剧集信息加载失败。'; + + @override + String get noMediaNotice => '该剧集还没有可播放的片源。'; + @override String get noStories => '暂无剧目。'; @@ -393,4 +399,148 @@ class AppLocalizationsZh extends AppLocalizations { @override String get shareFooter => 'Nontonki 演示'; + + @override + String get shortsTab => '短剧'; + + @override + String get myListTab => '片单'; + + @override + String get watchFull => '看全集'; + + @override + String get swipeForNext => '上滑看下一部'; + + @override + String get clearScreen => '清屏'; + + @override + String get exitClearScreen => '退出清屏'; + + @override + String get logIn => '登录'; + + @override + String get logInHint => '登录后保存金币和片单'; + + @override + String get rewards => '奖励'; + + @override + String get forYou => '为你推荐'; + + @override + String get hot => '热门'; + + @override + String get newest => '最新'; + + @override + String get favorite => '收藏'; + + @override + String get myAccount => '我的账户'; + + @override + String get coins => '金币'; + + @override + String get topUpWallet => '充值'; + + @override + String get vipMembership => '会员'; + + @override + String get notActive => '未开通'; + + @override + String get joinVip => '开通会员'; + + @override + String get earnRewards => '赚奖励'; + + @override + String get freeBonus => '领免费奖励'; + + @override + String get watchHistory => '观看历史'; + + @override + String get settings => '设置'; + + @override + String get signOut => '退出登录'; + + @override + String get mockUserName => 'Vicky sheng'; + + @override + String get mockUserId => 'ID: M1CZWVYE'; + + @override + String get mockNotice => '当前是示例数据。'; + + @override + String get topBadge => 'TOP 1'; + + @override + String get signIn => '登录'; + + @override + String get signUp => '注册'; + + @override + String get authSignInTitle => '欢迎回来'; + + @override + String get authSignUpTitle => '创建账号'; + + @override + String get authSubtitle => '用邮箱和密码登录。'; + + @override + String get authEmailLabel => '邮箱'; + + @override + String get authPasswordLabel => '密码'; + + @override + String get authPasswordHint => '至少 8 位,需包含字母和数字'; + + @override + String get authEmailRequired => '请输入邮箱'; + + @override + String get authEmailInvalid => '邮箱格式不正确'; + + @override + String get authPasswordRequired => '请输入密码'; + + @override + String get authPasswordLength => '密码长度需在 8-64 位之间'; + + @override + String get authPasswordWeak => '密码需同时包含字母和数字'; + + @override + String get authNetworkError => '网络异常,请稍后重试'; + + @override + String get authSwitchToSignUp => '还没有账号?去注册'; + + @override + String get authSwitchToSignIn => '已有账号?去登录'; + + @override + String get authGateTitle => '登录后可继续'; + + @override + String get authGateMessage => '收藏、评论等操作需要登录。'; + + @override + String get authGateAction => '去登录'; + + @override + String get cancel => '暂不'; } diff --git a/lib/l10n/app_zh.arb b/lib/l10n/app_zh.arb index 0f1d215..fc54650 100644 --- a/lib/l10n/app_zh.arb +++ b/lib/l10n/app_zh.arb @@ -91,6 +91,8 @@ "lockedBody": "完成商店与服务端验单配置后才能解锁。本演示目前不处理付款。", "playbackError": "此视频暂时无法播放。", "catalogError": "剧目列表加载失败。", + "detailError": "剧集信息加载失败。", + "noMediaNotice": "该剧集还没有可播放的片源。", "noStories": "暂无剧目。", "retry": "重试", "backToSeries": "返回剧集详情", @@ -125,5 +127,53 @@ "continueWatchingHeading": "继续观看", "preferencesHeading": "偏好设置", "brandMark": "NONTONKI · 演示", - "shareFooter": "Nontonki 演示" + "shareFooter": "Nontonki 演示", + "shortsTab": "短剧", + "myListTab": "片单", + "watchFull": "看全集", + "swipeForNext": "上滑看下一部", + "clearScreen": "清屏", + "exitClearScreen": "退出清屏", + "logIn": "登录", + "logInHint": "登录后保存金币和片单", + "rewards": "奖励", + "forYou": "为你推荐", + "hot": "热门", + "newest": "最新", + "favorite": "收藏", + "myAccount": "我的账户", + "coins": "金币", + "topUpWallet": "充值", + "vipMembership": "会员", + "notActive": "未开通", + "joinVip": "开通会员", + "earnRewards": "赚奖励", + "freeBonus": "领免费奖励", + "watchHistory": "观看历史", + "settings": "设置", + "signOut": "退出登录", + "mockUserName": "Vicky sheng", + "mockUserId": "ID: M1CZWVYE", + "mockNotice": "当前是示例数据。", + "topBadge": "TOP 1", + "signIn": "登录", + "signUp": "注册", + "authSignInTitle": "欢迎回来", + "authSignUpTitle": "创建账号", + "authSubtitle": "用邮箱和密码登录。", + "authEmailLabel": "邮箱", + "authPasswordLabel": "密码", + "authPasswordHint": "至少 8 位,需包含字母和数字", + "authEmailRequired": "请输入邮箱", + "authEmailInvalid": "邮箱格式不正确", + "authPasswordRequired": "请输入密码", + "authPasswordLength": "密码长度需在 8-64 位之间", + "authPasswordWeak": "密码需同时包含字母和数字", + "authNetworkError": "网络异常,请稍后重试", + "authSwitchToSignUp": "还没有账号?去注册", + "authSwitchToSignIn": "已有账号?去登录", + "authGateTitle": "登录后可继续", + "authGateMessage": "收藏、评论等操作需要登录。", + "authGateAction": "去登录", + "cancel": "暂不" } diff --git a/lib/pages/auth/auth_binding.dart b/lib/pages/auth/auth_binding.dart new file mode 100644 index 0000000..dbc17f7 --- /dev/null +++ b/lib/pages/auth/auth_binding.dart @@ -0,0 +1,6 @@ +import 'auth_logic.dart'; + +/// 与其它页保持一致的三层写法:binding 负责装配,logic 放状态与逻辑,view 只渲染。 +class AuthBinding { + AuthLogic create({bool signUpMode = false}) => AuthLogic(signUpMode: signUpMode); +} diff --git a/lib/pages/auth/auth_logic.dart b/lib/pages/auth/auth_logic.dart new file mode 100644 index 0000000..8b9eb0e --- /dev/null +++ b/lib/pages/auth/auth_logic.dart @@ -0,0 +1,50 @@ +/// 登录 / 注册页的表单状态与提交逻辑。 +/// +/// 校验规则与后端一致(邮箱格式、密码 8-64 位且含字母数字),本地先拦一次是为了少一次网络往返、 +/// 也让用户立刻看到哪个字段不合格;后端仍会再校验一遍(前端校验不作为安全边界)。 +class AuthLogic { + bool signUpMode; + String email = ''; + String password = ''; + bool busy = false; + String? errorMessage; + + AuthLogic({this.signUpMode = false, this.errorMessage}); + + void toggleMode() { + signUpMode = !signUpMode; + errorMessage = null; + } + + /// 返回 null 表示校验通过,否则返回错误文案(由视图用 l10n 映射) + AuthFieldError? validate() { + final mail = email.trim(); + if (mail.isEmpty) return AuthFieldError.emailRequired; + if (!_emailPattern.hasMatch(mail)) return AuthFieldError.emailInvalid; + if (password.isEmpty) return AuthFieldError.passwordRequired; + if (password.length < 8 || password.length > 64) { + return AuthFieldError.passwordLength; + } + if (!_hasLetter.hasMatch(password) || !_hasDigit.hasMatch(password)) { + return AuthFieldError.passwordWeak; + } + return null; + } + + String get normalizedEmail => email.trim().toLowerCase(); + + static final _emailPattern = RegExp( + r'^[A-Za-z0-9._%+\-]{1,64}@[A-Za-z0-9]([A-Za-z0-9\-]{0,61}[A-Za-z0-9])?' + r'(\.[A-Za-z0-9]([A-Za-z0-9\-]{0,61}[A-Za-z0-9])?)*\.[A-Za-z]{2,}$', + ); + static final _hasLetter = RegExp('[A-Za-z]'); + static final _hasDigit = RegExp('[0-9]'); +} + +enum AuthFieldError { + emailRequired, + emailInvalid, + passwordRequired, + passwordLength, + passwordWeak, +} diff --git a/lib/pages/auth/auth_view.dart b/lib/pages/auth/auth_view.dart new file mode 100644 index 0000000..7fc1bbf --- /dev/null +++ b/lib/pages/auth/auth_view.dart @@ -0,0 +1,227 @@ +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; + +import '../../core/data/remote/api_client.dart'; +import '../../core/data/services/auth_controller.dart'; +import '../../core/theme/app_colors.dart'; +import '../../l10n/app_localizations.dart'; +import 'auth_logic.dart'; + +/// 登录 / 注册页:邮箱 + 密码。 +/// +/// 风格沿用 `nontonki` 现有页面(深色卡片 + 圆角 + 主色蓝),不另起一套视觉。 +class AuthPage extends StatefulWidget { + const AuthPage({super.key, this.signUpMode = false}); + + final bool signUpMode; + + @override + State createState() => _AuthPageState(); +} + +class _AuthPageState extends State { + late AuthLogic _logic; + + @override + void initState() { + super.initState(); + _logic = AuthLogic(signUpMode: widget.signUpMode); + } + + String _errorText(AppLocalizations l10n, AuthFieldError error) { + switch (error) { + case AuthFieldError.emailRequired: + return l10n.authEmailRequired; + case AuthFieldError.emailInvalid: + return l10n.authEmailInvalid; + case AuthFieldError.passwordRequired: + return l10n.authPasswordRequired; + case AuthFieldError.passwordLength: + return l10n.authPasswordLength; + case AuthFieldError.passwordWeak: + return l10n.authPasswordWeak; + } + } + + Future _submit() async { + final l10n = AppLocalizations.of(context)!; + final invalid = _logic.validate(); + if (invalid != null) { + setState(() => _logic.errorMessage = _errorText(l10n, invalid)); + return; + } + setState(() { + _logic.busy = true; + _logic.errorMessage = null; + }); + final auth = context.read(); + try { + if (_logic.signUpMode) { + await auth.register( + email: _logic.normalizedEmail, + password: _logic.password, + ); + } else { + await auth.signIn( + email: _logic.normalizedEmail, + password: _logic.password, + ); + } + if (!mounted) return; + Navigator.of(context).maybePop(); + } on ApiException catch (error) { + // 后端文案已经是可直接展示的中文/印尼语提示,错误码不外露 + setState(() => _logic.errorMessage = error.message); + } catch (_) { + setState(() => _logic.errorMessage = l10n.authNetworkError); + } finally { + if (mounted) setState(() => _logic.busy = false); + } + } + + @override + Widget build(BuildContext context) { + final l10n = AppLocalizations.of(context)!; + return Scaffold( + backgroundColor: AppColors.ink, + appBar: AppBar( + backgroundColor: AppColors.ink, + elevation: 0, + foregroundColor: Colors.white, + title: Text(_logic.signUpMode ? l10n.signUp : l10n.signIn), + ), + body: SafeArea( + child: ListView( + padding: const EdgeInsets.fromLTRB(20, 12, 20, 28), + children: [ + Text( + _logic.signUpMode ? l10n.authSignUpTitle : l10n.authSignInTitle, + style: const TextStyle( + color: Colors.white, + fontSize: 22, + fontWeight: FontWeight.w800, + ), + ), + const SizedBox(height: 6), + Text( + l10n.authSubtitle, + style: const TextStyle(color: AppColors.muted, fontSize: 13), + ), + const SizedBox(height: 22), + _field( + label: l10n.authEmailLabel, + hint: 'name@example.com', + keyboardType: TextInputType.emailAddress, + onChanged: (value) => _logic.email = value, + autofocus: true, + ), + const SizedBox(height: 14), + _field( + label: l10n.authPasswordLabel, + hint: l10n.authPasswordHint, + obscure: true, + onChanged: (value) => _logic.password = value, + ), + if (_logic.errorMessage != null) ...[ + const SizedBox(height: 12), + Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const Icon(Icons.error_outline, color: Color(0xFFFF6B6B), size: 16), + const SizedBox(width: 6), + Expanded( + child: Text( + _logic.errorMessage!, + style: const TextStyle(color: Color(0xFFFF6B6B), fontSize: 13), + ), + ), + ], + ), + ], + const SizedBox(height: 22), + SizedBox( + height: 48, + child: FilledButton( + style: FilledButton.styleFrom( + backgroundColor: AppColors.blue, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(24), + ), + ), + onPressed: _logic.busy ? null : _submit, + child: _logic.busy + ? const SizedBox( + width: 18, + height: 18, + child: CircularProgressIndicator( + strokeWidth: 2, + color: Colors.white, + ), + ) + : Text( + _logic.signUpMode ? l10n.signUp : l10n.signIn, + style: const TextStyle( + fontSize: 15, + fontWeight: FontWeight.w700, + ), + ), + ), + ), + const SizedBox(height: 14), + TextButton( + onPressed: _logic.busy + ? null + : () => setState(() => _logic.toggleMode()), + child: Text( + _logic.signUpMode ? l10n.authSwitchToSignIn : l10n.authSwitchToSignUp, + style: const TextStyle(color: AppColors.blueSoft, fontSize: 13), + ), + ), + ], + ), + ), + ); + } + + Widget _field({ + required String label, + required String hint, + required ValueChanged onChanged, + bool obscure = false, + bool autofocus = false, + TextInputType? keyboardType, + }) { + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + label, + style: const TextStyle( + color: AppColors.muted, + fontSize: 12, + fontWeight: FontWeight.w700, + ), + ), + const SizedBox(height: 6), + TextField( + autofocus: autofocus, + obscureText: obscure, + keyboardType: keyboardType, + onChanged: onChanged, + style: const TextStyle(color: Colors.white, fontSize: 15), + decoration: InputDecoration( + hintText: hint, + hintStyle: const TextStyle(color: Color(0xFF6C7280), fontSize: 14), + filled: true, + fillColor: AppColors.card, + contentPadding: const EdgeInsets.symmetric(horizontal: 14, vertical: 14), + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(12), + borderSide: BorderSide.none, + ), + ), + ), + ], + ); + } +} diff --git a/lib/pages/home/home_logic.dart b/lib/pages/home/home_logic.dart index f31090f..66b235d 100644 --- a/lib/pages/home/home_logic.dart +++ b/lib/pages/home/home_logic.dart @@ -1,16 +1,19 @@ import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; import '../../core/data/models/drama.dart'; +import '../../core/data/services/catalog_controller.dart'; import '../discover/discover_logic.dart'; import '../drama_detail/drama_detail_view.dart'; import '../mine/mine_logic.dart'; +import '../player/player_view.dart'; class HomeLogic extends ChangeNotifier { HomeLogic(List dramas) : currentDrama = dramas.first; final scaffoldKey = GlobalKey(); Drama currentDrama; - int tab = 0; + int tab = 1; int searchRequest = 0; int sectionRequest = 0; int resumeRequest = 0; @@ -19,6 +22,7 @@ class HomeLogic extends ChangeNotifier { bool drawerOpen = false; bool detailOpen = false; bool videoImmersive = false; + bool profile = false; bool _disposed = false; void notify() { @@ -62,9 +66,7 @@ class HomeLogic extends ChangeNotifier { if (!context.mounted) return; try { await Navigator.of(context).push( - MaterialPageRoute( - builder: (_) => DramaDetailPage(drama: currentDrama), - ), + MaterialPageRoute(builder: (_) => DramaDetailPage(drama: currentDrama)), ); } finally { if (context.mounted) { @@ -80,6 +82,34 @@ class HomeLogic extends ChangeNotifier { ); } + Future playDrama(BuildContext context, Drama drama) async { + // 列表卡片只有一集预览,进入播放前补齐完整剧集,否则选集列表是空的。 + var playable = drama; + try { + playable = await context.read().requireDetail(drama); + } catch (_) { + // 取详情失败就用卡片自带的那一集起播。 + } + if (!context.mounted) return; + Navigator.of(context).push( + MaterialPageRoute( + builder: (_) => PlayerPage(drama: playable, initialIndex: 0), + ), + ); + } + + void openProfile() { + profile = true; + scaffoldKey.currentState?.closeDrawer(); + select(2, mySection: 0); + } + + void openLibrary({int section = 1}) { + profile = false; + scaffoldKey.currentState?.closeDrawer(); + select(2, mySection: section); + } + void discoverAction(BuildContext context, DiscoverPageAction action) { switch (action) { case DiscoverPageAction.home: @@ -87,7 +117,7 @@ class HomeLogic extends ChangeNotifier { case DiscoverPageAction.my: select(2); case DiscoverPageAction.watchlist: - select(2, watchlist: true); + openLibrary(); case DiscoverPageAction.resume: select(0, resume: true); case DiscoverPageAction.detail: @@ -112,11 +142,10 @@ class HomeLogic extends ChangeNotifier { } else if (videoImmersive) { backRequest++; notify(); - } else if (tab != 0) { - select(0); + } else if (tab != 1) { + select(1); } else { - backRequest++; - notify(); + openMenu(); } } diff --git a/lib/pages/home/home_view.dart b/lib/pages/home/home_view.dart index 32db9d5..591beaa 100644 --- a/lib/pages/home/home_view.dart +++ b/lib/pages/home/home_view.dart @@ -1,8 +1,13 @@ +import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; +import '../../core/config/app_config.dart'; import '../../core/data/models/drama.dart'; +import '../../core/data/services/auth_controller.dart'; import '../../core/data/services/catalog_controller.dart'; +import '../../core/widgets/auth_gate.dart'; +import '../../core/theme/app_colors.dart'; import '../../l10n/app_localizations.dart'; import '../discover/discover_view.dart'; import '../mine/mine_view.dart'; @@ -29,7 +34,6 @@ class HomePage extends StatelessWidget { CatalogController catalog, AppLocalizations l10n, ) { - if (catalog.loading) { return const Scaffold( backgroundColor: Colors.black, @@ -46,6 +50,13 @@ class HomePage extends StatelessWidget { Text(catalog.error == null ? l10n.noStories : l10n.catalogError), const SizedBox(height: 12), FilledButton(onPressed: catalog.load, child: Text(l10n.retry)), + if (kDebugMode) ...[ + const SizedBox(height: 16), + Text( + AppConfig.apiBaseUrl, + style: const TextStyle(fontSize: 12, color: Colors.white54), + ), + ], ], ), ), @@ -92,8 +103,11 @@ class _HomeTabsState extends State<_HomeTabs> { ); } + Widget _scaffold(BuildContext context) { final l10n = AppLocalizations.of(context)!; + // 登录态统一从 AuthController 取(原来是 home_logic 里的本地演示开关) + final signedIn = context.watch().isSignedIn; return PopScope( canPop: false, onPopInvokedWithResult: (didPop, _) { @@ -107,8 +121,8 @@ class _HomeTabsState extends State<_HomeTabs> { drama: logic.currentDrama, onOpenSeries: () => logic.openCurrentSeries(context), onDiscover: () => logic.selectFromMenu(1), - onHistory: () => logic.selectFromMenu(2, mySection: 0), - onWatchlist: () => logic.selectFromMenu(2, mySection: 1), + onHistory: () => logic.openLibrary(section: 0), + onWatchlist: logic.openLibrary, onLiked: () => logic.selectFromMenu(2, mySection: 2), ), drawerEnableOpenDragGesture: false, @@ -127,7 +141,7 @@ class _HomeTabsState extends State<_HomeTabs> { resumeRequest: logic.resumeRequest, backRequest: logic.backRequest, onDiscover: () => logic.select(1), - onMy: () => logic.select(2), + onMy: logic.openProfile, onSearch: () => logic.select(1, search: true), onMenu: logic.openMenu, onImmersiveChanged: logic.onImmersiveChanged, @@ -135,11 +149,15 @@ class _HomeTabsState extends State<_HomeTabs> { DiscoverPage( drama: logic.currentDrama, dramas: widget.dramas, - onDramaSelected: (drama) => logic.openDrama(context, drama), + onDramaSelected: (drama) => logic.playDrama(context, drama), duration: Duration.zero, embedded: true, active: logic.tab == 1, searchRequest: logic.searchRequest, + signedIn: signedIn, + onSignIn: () => openAuthPage(context), + onCoins: logic.openProfile, + onRewards: logic.openProfile, onAction: (action) => logic.discoverAction(context, action), ), MyPage( @@ -148,10 +166,15 @@ class _HomeTabsState extends State<_HomeTabs> { onDramaSelected: (drama) => logic.openDrama(context, drama), duration: Duration.zero, initialSection: logic.mySection, + profile: logic.profile, sectionRequest: logic.sectionRequest, embedded: true, active: logic.tab == 2, onAction: logic.myAction, + onOpenHistory: () => logic.openLibrary(section: 0), + signedIn: signedIn, + onSignIn: () => openAuthPage(context), + onSignOut: () => context.read().signOut(), ), ], ), @@ -167,28 +190,38 @@ class _HomeTabsState extends State<_HomeTabs> { border: Border(top: BorderSide(color: Color(0xFF242329))), ), child: Row( - mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ - _TabButton( - key: const Key('tab-home'), - icon: Icons.play_circle_outline_rounded, - label: l10n.homeTab, - selected: logic.tab == 0, - onTap: () => logic.select(0), - ), _TabButton( key: const Key('tab-discover'), - icon: Icons.explore_outlined, - label: l10n.discoverTab, + icon: Icons.home_outlined, + selectedIcon: Icons.home_rounded, + label: l10n.homeTab, selected: logic.tab == 1, onTap: () => logic.select(1), ), + _TabButton( + key: const Key('tab-home'), + icon: Icons.movie_outlined, + selectedIcon: Icons.movie_rounded, + label: l10n.shortsTab, + selected: logic.tab == 0, + onTap: () => logic.select(0), + ), + _TabButton( + key: const Key('tab-my-list'), + icon: Icons.bookmark_border_rounded, + selectedIcon: Icons.bookmark_rounded, + label: l10n.myListTab, + selected: logic.tab == 2 && !logic.profile, + onTap: logic.openLibrary, + ), _TabButton( key: const Key('tab-my'), - icon: Icons.video_library_outlined, + icon: Icons.person_outline_rounded, + selectedIcon: Icons.person_rounded, label: l10n.myTab, - selected: logic.tab == 2, - onTap: () => logic.select(2), + selected: logic.tab == 2 && logic.profile, + onTap: logic.openProfile, ), ], ), @@ -203,35 +236,47 @@ class _TabButton extends StatelessWidget { const _TabButton({ super.key, required this.icon, + required this.selectedIcon, required this.label, required this.selected, required this.onTap, }); final IconData icon; + final IconData selectedIcon; final String label; final bool selected; final VoidCallback onTap; @override - Widget build(BuildContext context) => InkWell( - onTap: onTap, - child: SizedBox( - width: 80, + Widget build(BuildContext context) => Expanded( + child: InkWell( + onTap: onTap, child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ - Icon( - icon, - size: 21, - color: selected ? const Color(0xFFFF5C37) : const Color(0xFFE6E1DE), + Container( + padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 3), + decoration: selected + ? BoxDecoration( + color: AppColors.blue, + borderRadius: BorderRadius.circular(14), + ) + : null, + child: Icon( + selected ? selectedIcon : icon, + size: 20, + color: selected ? Colors.white : AppColors.muted, + ), ), + const SizedBox(height: 2), Text( label, + maxLines: 1, + overflow: TextOverflow.ellipsis, style: TextStyle( fontSize: 10, - color: selected - ? const Color(0xFFFF5C37) - : const Color(0xFFE6E1DE), + fontWeight: selected ? FontWeight.w700 : FontWeight.w500, + color: selected ? AppColors.blue : AppColors.muted, ), ), ], diff --git a/lib/pages/mine/mine_view.dart b/lib/pages/mine/mine_view.dart index 4e0e738..141c7ed 100644 --- a/lib/pages/mine/mine_view.dart +++ b/lib/pages/mine/mine_view.dart @@ -4,7 +4,10 @@ import 'package:provider/provider.dart'; import '../../core/formatting/localized_content.dart'; import '../../core/data/models/drama.dart'; import '../../core/data/repositories/watch_history_repository.dart'; +import '../../core/data/services/auth_controller.dart'; import '../../core/data/services/engagement_controller.dart'; +import '../../core/widgets/remote_image.dart'; +import '../../core/theme/app_colors.dart'; import '../../l10n/app_localizations.dart'; import 'mine_binding.dart'; import 'mine_logic.dart'; @@ -15,11 +18,16 @@ class MyPage extends StatefulWidget { required this.drama, required this.duration, this.initialSection = 0, + this.profile = false, + this.onOpenHistory, this.history, this.embedded = false, this.active = true, this.sectionRequest = 0, this.onAction, + this.signedIn = false, + this.onSignIn, + this.onSignOut, this.dramas, this.onDramaSelected, }); @@ -27,11 +35,16 @@ class MyPage extends StatefulWidget { final Drama drama; final Duration duration; final int initialSection; + final bool profile; + final VoidCallback? onOpenHistory; final WatchHistoryRepository? history; final bool embedded; final bool active; final int sectionRequest; final ValueChanged? onAction; + final bool signedIn; + final VoidCallback? onSignIn; + final VoidCallback? onSignOut; final List? dramas; final ValueChanged? onDramaSelected; @@ -86,7 +99,7 @@ class _MyPageState extends State { bottom: !widget.embedded, child: Column( children: [ - _topBar(l10n), + if (!widget.profile) _topBar(l10n), Expanded( child: FutureBuilder( future: logic.position, @@ -101,15 +114,13 @@ class _MyPageState extends State { 1.0, ); return ListView( - padding: const EdgeInsets.fromLTRB(16, 12, 16, 20), + padding: const EdgeInsets.fromLTRB(16, 8, 16, 20), children: [ - _profile(l10n), - const SizedBox(height: 22), - _continueCard(l10n, fraction, position, total), - const SizedBox(height: 26), - _library(l10n, position, total, fraction), - const SizedBox(height: 26), - _preferences(l10n), + if (widget.profile) + ..._accountPage(l10n) + else ...[ + _library(l10n, position, total, fraction), + ], const SizedBox(height: 24), Center( child: Text( @@ -147,8 +158,8 @@ class _MyPageState extends State { const Icon(Icons.play_circle_fill_rounded, color: _orange, size: 27), const SizedBox(width: 7), Text( - l10n.myTab, - style: const TextStyle(fontSize: 18, fontWeight: FontWeight.w800), + l10n.myListTab, + style: const TextStyle(fontSize: 22, fontWeight: FontWeight.w800), ), const Spacer(), IconButton( @@ -172,158 +183,247 @@ class _MyPageState extends State { ), ); - Widget _profile(AppLocalizations l10n) => Row( - children: [ - const CircleAvatar( - radius: 30, - backgroundColor: Color(0xFF32343A), - child: Icon(Icons.person_rounded, color: Colors.white, size: 34), + List _accountPage(AppLocalizations l10n) => [ + if (widget.signedIn) _signedInRow(l10n) else _guestRow(l10n), + if (widget.signedIn) ...[const SizedBox(height: 18), _wallet(l10n)], + const SizedBox(height: 14), + _menuCard(l10n), + const SizedBox(height: 18), + Text( + l10n.preferencesHeading, + style: const TextStyle( + color: AppColors.muted, + fontSize: 12, + fontWeight: FontWeight.w800, + letterSpacing: 1.1, ), - const SizedBox(width: 12), - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - l10n.localViewer, - maxLines: 1, - overflow: TextOverflow.ellipsis, - style: const TextStyle(fontSize: 19, fontWeight: FontWeight.w800), - ), - const SizedBox(height: 4), - Text( - l10n.localDemoProfile, - style: const TextStyle(color: Color(0xFFE6E1E3), fontSize: 12), - ), - ], - ), - ), - Container( - padding: const EdgeInsets.symmetric(horizontal: 11, vertical: 6), - decoration: BoxDecoration( - color: const Color(0xFF24252A), - borderRadius: BorderRadius.circular(20), - ), - child: Text(l10n.demo, style: const TextStyle(fontSize: 11)), - ), - ], - ); - - Widget _continueCard( - AppLocalizations l10n, - double fraction, - Duration position, - Duration total, - ) => Container( - padding: const EdgeInsets.all(13), - decoration: BoxDecoration( - color: const Color(0xFF201B1E), - borderRadius: BorderRadius.circular(13), ), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + const SizedBox(height: 8), + ListTile( + contentPadding: EdgeInsets.zero, + leading: const Icon(Icons.language_rounded, color: AppColors.blueSoft), + title: Text(l10n.appLanguage), + trailing: const Icon(Icons.chevron_right_rounded), + onTap: () => logic.showLanguage(context), + ), + ]; + + Widget _guestRow(AppLocalizations l10n) { + return Row( children: [ - Row( - children: [ - const Icon(Icons.history_rounded, color: _orange, size: 17), - const SizedBox(width: 6), - Expanded( - child: Text( - l10n.continueWatching, + const CircleAvatar( + radius: 28, + backgroundColor: Color(0xFF32343A), + child: Icon(Icons.person_rounded, color: Colors.white, size: 30), + ), + const SizedBox(width: 12), + Expanded( + child: Text( + l10n.logInHint, + maxLines: 2, + overflow: TextOverflow.ellipsis, + style: const TextStyle(fontSize: 15, fontWeight: FontWeight.w600), + ), + ), + const SizedBox(width: 8), + TextButton( + onPressed: widget.onSignIn, + style: TextButton.styleFrom( + foregroundColor: Colors.white, + backgroundColor: AppColors.blue, + padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 8), + shape: const StadiumBorder(), + ), + child: Text(l10n.logIn), + ), + ], + ); + } + + Widget _signedInRow(AppLocalizations l10n) { + // 显示真实登录账号(昵称 + uid);拿不到才回落到演示文案 + final user = context.watch().user; + final name = (user?.nickname.isNotEmpty ?? false) ? user!.nickname : l10n.mockUserName; + final uidText = (user?.uid.isNotEmpty ?? false) ? 'ID: ${user!.uid}' : l10n.mockUserId; + return Row( + children: [ + const CircleAvatar( + radius: 28, + backgroundColor: Color(0xFF32343A), + child: Icon(Icons.person_rounded, color: Colors.white, size: 30), + ), + const SizedBox(width: 12), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + name, maxLines: 1, overflow: TextOverflow.ellipsis, style: const TextStyle( - fontSize: 14, - fontWeight: FontWeight.w800, + fontSize: 20, + fontWeight: FontWeight.w600, ), ), - ), - Text( - l10n.episodeProgress(1, widget.drama.episodes.length), - style: const TextStyle(color: Color(0xFFFFA38F), fontSize: 10), - ), - ], - ), - const SizedBox(height: 12), - Row( - children: [ - _poster(width: 75, height: 96), - const SizedBox(width: 11), - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - localizedDramaTitle(l10n, widget.drama), - style: const TextStyle( - fontSize: 17, - fontWeight: FontWeight.w800, - ), - ), - const SizedBox(height: 3), - Text( - l10n.dramaTag, - style: const TextStyle( - color: Color(0xFFE6E1E3), - fontSize: 12, - ), - ), - const SizedBox(height: 10), - Text( - l10n.watchedPercent((fraction * 100).round()), - style: const TextStyle( - color: Color(0xFFE7DEDD), - fontSize: 11, - ), - ), - const SizedBox(height: 5), - ClipRRect( - borderRadius: BorderRadius.circular(3), - child: LinearProgressIndicator( - value: fraction, - minHeight: 4, - backgroundColor: const Color(0xFF444046), - color: _orange, - ), - ), - const SizedBox(height: 6), - Text( - '${_clock(position)} / ${_clock(total)}', - style: const TextStyle( - color: Color(0xFFE6E1E3), - fontSize: 12, - ), - ), - ], + const SizedBox(height: 2), + Text( + uidText, + style: const TextStyle(color: AppColors.muted, fontSize: 12), ), - ), - ], - ), - const SizedBox(height: 12), - SizedBox( - width: double.infinity, - child: FilledButton.icon( - onPressed: () => logic.act( - context, - MyPageAction.resume, - embedded: widget.embedded, - onAction: widget.onAction, - ), - style: FilledButton.styleFrom( - backgroundColor: _orange, - foregroundColor: Colors.white, - minimumSize: const Size.fromHeight(37), - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(9), - ), - ), - icon: const Icon(Icons.play_arrow_rounded, size: 18), - label: Text(l10n.resume), + ], ), ), + TextButton( + onPressed: widget.onSignOut ?? () => _mockSnack(l10n), + style: TextButton.styleFrom( + backgroundColor: const Color(0xFF2A2C33), + foregroundColor: Colors.white, + padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 8), + shape: const StadiumBorder(), + ), + child: Text(l10n.signOut), + ), ], - ), - ); + ); + } + + Widget _wallet(AppLocalizations l10n) { + return Container( + padding: const EdgeInsets.all(14), + decoration: BoxDecoration( + color: const Color(0xFF17191F), + borderRadius: BorderRadius.circular(16), + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + l10n.myAccount, + style: const TextStyle(fontSize: 16, fontWeight: FontWeight.w800), + ), + const SizedBox(height: 12), + Row( + children: [ + Expanded( + child: _accountTile( + label: l10n.coins, + value: '\$ 0', + action: l10n.topUpWallet, + color: AppColors.blue, + onPressed: () => _mockSnack(l10n), + ), + ), + const SizedBox(width: 10), + Expanded( + child: _accountTile( + label: l10n.vipMembership, + value: l10n.notActive, + action: l10n.joinVip, + color: const Color(0xFFF5C451), + onPressed: () => _mockSnack(l10n), + ), + ), + ], + ), + ], + ), + ); + } + + void _mockSnack(AppLocalizations l10n) { + ScaffoldMessenger.of( + context, + ).showSnackBar(SnackBar(content: Text(l10n.mockNotice))); + } + + Widget _accountTile({ + required String label, + required String value, + required String action, + required Color color, + required VoidCallback onPressed, + }) { + return Container( + padding: const EdgeInsets.all(12), + decoration: BoxDecoration( + color: const Color(0xFF12141A), + borderRadius: BorderRadius.circular(14), + border: Border.all(color: color.withValues(alpha: 0.45)), + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text(label, style: TextStyle(color: color, fontSize: 12)), + const SizedBox(height: 6), + Text( + value, + style: const TextStyle(fontSize: 18, fontWeight: FontWeight.w800), + ), + const SizedBox(height: 10), + SizedBox( + width: double.infinity, + child: FilledButton( + onPressed: onPressed, + style: FilledButton.styleFrom( + backgroundColor: color, + foregroundColor: color == AppColors.blue + ? Colors.white + : const Color(0xFF2A2110), + visualDensity: VisualDensity.compact, + shape: const StadiumBorder(), + ), + child: Text(action, maxLines: 1, overflow: TextOverflow.ellipsis), + ), + ), + ], + ), + ); + } + + Widget _menuCard(AppLocalizations l10n) { + return Material( + color: const Color(0xFF17191F), + borderRadius: BorderRadius.circular(16), + clipBehavior: Clip.antiAlias, + child: Column( + children: [ + ListTile( + leading: const Icon( + Icons.card_giftcard_rounded, + color: AppColors.blueSoft, + ), + title: Text(l10n.earnRewards), + trailing: Text( + l10n.freeBonus, + style: const TextStyle(color: AppColors.blue, fontSize: 12), + ), + onTap: () => _mockSnack(l10n), + ), + const Divider(height: 1, color: Color(0xFF2A2C33)), + ListTile( + leading: const Icon( + Icons.history_rounded, + color: AppColors.blueSoft, + ), + title: Text(l10n.watchHistory), + trailing: const Icon(Icons.chevron_right_rounded), + onTap: widget.onOpenHistory, + ), + const Divider(height: 1, color: Color(0xFF2A2C33)), + ListTile( + leading: const Icon( + Icons.settings_rounded, + color: AppColors.blueSoft, + ), + title: Text(l10n.settings), + trailing: const Icon(Icons.chevron_right_rounded), + onTap: () => logic.showLanguage(context), + ), + ], + ), + ); + } Widget _library( AppLocalizations l10n, @@ -353,14 +453,25 @@ class _MyPageState extends State { for (var index = 0; index < tabs.length; index++) ...[ InkWell( onTap: () => logic.selectSection(index), - child: Text( - tabs[index], - style: TextStyle( + borderRadius: BorderRadius.circular(20), + child: Container( + padding: const EdgeInsets.symmetric( + horizontal: 14, + vertical: 8, + ), + decoration: BoxDecoration( color: logic.section == index - ? _orange - : const Color(0xFFE4DBDD), - fontSize: 16, - fontWeight: FontWeight.w800, + ? AppColors.blue + : const Color(0xFF24262E), + borderRadius: BorderRadius.circular(20), + ), + child: Text( + tabs[index], + style: const TextStyle( + color: Colors.white, + fontSize: 14, + fontWeight: FontWeight.w700, + ), ), ), ), @@ -446,7 +557,7 @@ class _MyPageState extends State { maxLines: 1, overflow: TextOverflow.ellipsis, style: const TextStyle( - color: Color(0xFFFFA18D), + color: AppColors.blueSoft, fontSize: 10, ), ), @@ -507,12 +618,7 @@ class _MyPageState extends State { children: [ ClipRRect( borderRadius: BorderRadius.circular(8), - child: Image.asset( - drama.posterAsset, - width: 74, - height: 103, - fit: BoxFit.cover, - ), + child: RemoteImage(drama.posterUrl, width: 74, height: 103), ), const SizedBox(width: 11), Expanded( @@ -530,7 +636,7 @@ class _MyPageState extends State { ), const SizedBox(height: 7), Text( - l10n.episodeCount(drama.episodes.length), + l10n.episodeCount(drama.episodeCount), style: const TextStyle( color: Color(0xFFE6E1E3), fontSize: 12, @@ -545,49 +651,6 @@ class _MyPageState extends State { ), ); - Widget _preferences(AppLocalizations l10n) => Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - l10n.preferencesHeading, - style: const TextStyle( - color: Color(0xFFCEBBB9), - fontSize: 11, - fontWeight: FontWeight.w800, - letterSpacing: 0.5, - ), - ), - const SizedBox(height: 12), - Material( - color: const Color(0xFF1B1C21), - borderRadius: BorderRadius.circular(12), - clipBehavior: Clip.antiAlias, - child: ListTile( - leading: const Icon( - Icons.translate_rounded, - color: Color(0xFFFFBC65), - ), - title: Text(l10n.appLanguage), - subtitle: Text(l10n.language), - trailing: Row( - mainAxisSize: MainAxisSize.min, - children: [ - Text( - Localizations.localeOf(context).languageCode == 'zh' - ? l10n.simplifiedChinese - : l10n.english, - style: const TextStyle(color: Color(0xFFFFB2A1), fontSize: 11), - ), - const SizedBox(width: 4), - const Icon(Icons.chevron_right_rounded, size: 18), - ], - ), - onTap: () => logic.showLanguage(context), - ), - ), - ], - ); - Widget _bottomNav(AppLocalizations l10n) => Container( height: 63, decoration: const BoxDecoration( @@ -629,12 +692,7 @@ class _MyPageState extends State { Widget _poster({required double width, required double height}) => ClipRRect( borderRadius: BorderRadius.circular(7), - child: Image.asset( - widget.drama.posterAsset, - width: width, - height: height, - fit: BoxFit.cover, - ), + child: RemoteImage(widget.drama.posterUrl, width: width, height: height), ); } @@ -683,4 +741,4 @@ String _clock(Duration duration) { return '${(seconds ~/ 60).toString().padLeft(2, '0')}:${(seconds % 60).toString().padLeft(2, '0')}'; } -const _orange = Color(0xFFFF5B3D); +const _orange = AppColors.blue; diff --git a/lib/pages/player/player_view.dart b/lib/pages/player/player_view.dart index 9b2a104..a9a1237 100644 --- a/lib/pages/player/player_view.dart +++ b/lib/pages/player/player_view.dart @@ -10,10 +10,8 @@ import '../../core/data/services/engagement_controller.dart'; import '../../core/data/services/playback_session.dart'; import '../../core/data/services/video_player_port.dart'; import '../../core/formatting/localized_content.dart'; +import '../../core/widgets/auth_gate.dart'; import '../../l10n/app_localizations.dart'; -import '../home/home_feed_sections.dart'; -import '../home/widgets/category_swipe_region.dart'; -import '../home/widgets/home_feed_header.dart'; import 'player_binding.dart'; import 'player_logic.dart'; import 'widgets/seek_progress_bar.dart'; @@ -100,28 +98,23 @@ class _PlayerPageState extends State with WidgetsBindingObserver { Widget _buildPlayer(BuildContext context) { final engagement = context.watch(); - final category = logic.category; final indices = logic.visibleIndices; final pages = logic.pages; final content = AnimatedBuilder( animation: logic.session, - builder: (context, _) => indices.isEmpty && widget.homeMode - ? _buildEmptyCategory(context) - : PageView.builder( - key: ValueKey(category), - controller: pages, - scrollDirection: Axis.vertical, - allowImplicitScrolling: true, - itemCount: indices.length, - onPageChanged: (position) { - if (category != logic.category) return; - final index = indices[position]; - widget.onDramaChanged?.call(logic.queue.entryAt(index).drama); - unawaited(logic.selectEpisode(index)); - }, - itemBuilder: (context, position) => - _buildEpisode(context, indices[position], engagement), - ), + builder: (context, _) => PageView.builder( + controller: pages, + scrollDirection: Axis.vertical, + allowImplicitScrolling: true, + itemCount: indices.length, + onPageChanged: (position) { + final index = indices[position]; + widget.onDramaChanged?.call(logic.queue.entryAt(index).drama); + unawaited(logic.selectEpisode(index)); + }, + itemBuilder: (context, position) => + _buildEpisode(context, indices[position], engagement), + ), ); return AnnotatedRegion( value: SystemUiOverlayStyle.light, @@ -132,54 +125,6 @@ class _PlayerPageState extends State with WidgetsBindingObserver { : Scaffold(backgroundColor: Colors.black, body: content), ), ); - } - - Widget _buildEmptyCategory(BuildContext context) { - final l10n = AppLocalizations.of(context)!; - return CategorySwipeRegion( - key: const Key('home-empty-swipe'), - onShift: logic.shiftCategory, - child: ColoredBox( - color: const Color(0xFF111214), - child: SafeArea( - child: Column( - children: [ - HomeFeedHeader( - l10n: l10n, - category: logic.category, - onCategorySelected: (value) => - unawaited(logic.selectCategory(value)), - onCategoryShift: logic.shiftCategory, - onSearch: () => logic.showSearch(context), - onMy: () => logic.showMy(context), - onMenu: widget.onMenu, - ), - const Spacer(), - const Icon( - Icons.video_library_outlined, - size: 48, - color: Color(0xFFE6E1E3), - ), - const SizedBox(height: 12), - Text( - l10n.noCategoryDramas, - style: const TextStyle(fontSize: 16, color: Colors.white), - ), - const SizedBox(height: 8), - Padding( - padding: const EdgeInsets.symmetric(horizontal: 24), - child: Text( - l10n.demoCatalogNotice, - textAlign: TextAlign.center, - style: const TextStyle(fontSize: 13, color: Color(0xFFF3EEEA)), - ), - ), - const Spacer(), - ], - ), - ), - ), - ); } Widget _buildEpisode( @@ -190,20 +135,25 @@ class _PlayerPageState extends State with WidgetsBindingObserver { final l10n = AppLocalizations.of(context)!; final entry = logic.queue.entryAt(index); final drama = entry.drama; - final episode = entry.episode; + final episode = widget.homeMode + ? logic.displayEpisode(drama, entry.episode) + : entry.episode; final selected = index == logic.session.currentIndex; // Selection changes before the prepared slot is promoted. Use its controller // throughout the handoff instead of briefly falling back to a placeholder. final port = - (selected ? logic.session.active : null) ?? logic.session.preparedPlayerAt(index); + (selected ? logic.session.active : null) ?? + logic.session.preparedPlayerAt(index); final videoPort = port is VideoPlayerPort ? port : null; final ready = videoPort?.controller.value.isInitialized ?? false; + final theater = logic.fullscreen || logic.pip || logic.pipPreparing; Widget? video; if (ready) { video = GestureDetector( - onTap: () => logic.session.setUserWantsPlay(!logic.session.userWantsPlay), + onTap: () => + logic.session.setUserWantsPlay(!logic.session.userWantsPlay), child: FittedBox( - fit: logic.immersive ? BoxFit.contain : BoxFit.cover, + fit: theater ? BoxFit.contain : BoxFit.cover, child: SizedBox( width: videoPort!.controller.value.size.width, height: videoPort.controller.value.size.height, @@ -214,28 +164,14 @@ class _PlayerPageState extends State with WidgetsBindingObserver { ), ), ); - if (widget.homeMode) { - video = CategorySwipeRegion( - key: selected ? const Key('home-video-swipe') : null, - onShift: logic.shiftCategory, - child: video, - ); - } } return Stack( fit: StackFit.expand, children: [ - if (widget.homeMode && !ready && !logic.immersive) - CategorySwipeRegion( - key: selected ? const Key('home-video-swipe') : null, - onShift: logic.shiftCategory, - child: const ColoredBox(color: Colors.black), - ) - else - const ColoredBox(color: Colors.black), + const ColoredBox(color: Colors.black), ?video, - if (!logic.immersive) + if (!logic.chromeHidden) const IgnorePointer( child: DecoratedBox( decoration: BoxDecoration( @@ -243,31 +179,92 @@ class _PlayerPageState extends State with WidgetsBindingObserver { begin: Alignment.topCenter, end: Alignment.bottomCenter, colors: [ - Color(0xD6000000), Color(0x66000000), + Color(0x00000000), Color(0x33000000), - Color(0xF0000000), + Color(0xE6000000), ], - stops: [0, 0.22, 0.5, 1], + stops: [0, 0.16, 0.55, 1], ), ), ), ), if (selected && logic.session.loading) const Center( - child: CircularProgressIndicator(color: Color(0xFFFF6B45)), + child: CircularProgressIndicator(color: Color(0xFF2F7BFF)), ), - if (selected && ready && !logic.session.userWantsPlay && !logic.pip) + if (selected && !ready && logic.session.error != null) Center( - child: IconButton.filled( - iconSize: 48, - onPressed: () => logic.session.setUserWantsPlay(true), - icon: const Icon(Icons.play_arrow_rounded), + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 36), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + const Icon( + Icons.error_outline_rounded, + color: Colors.white70, + size: 36, + ), + const SizedBox(height: 12), + Text( + l10n.playbackError, + textAlign: TextAlign.center, + style: const TextStyle(color: Colors.white70), + ), + ], + ), ), ), - if (widget.homeMode && (logic.pip || logic.pipPreparing)) + // 锁定集与还没上传片源的剧集都会走到这里,之前是一片纯黑,看不出原因。 + if (selected && + !ready && + logic.session.error == null && + logic.session.isLocked) + Center( + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 36), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + const Icon( + Icons.movie_filter_outlined, + color: Colors.white70, + size: 36, + ), + const SizedBox(height: 12), + Text( + episode.locked + ? l10n.lockedTitle(episode.number) + : l10n.noMediaNotice, + textAlign: TextAlign.center, + style: const TextStyle(color: Colors.white70), + ), + ], + ), + ), + ), + if (selected && ready && !logic.session.userWantsPlay && !logic.pip) + const Center( + child: IgnorePointer( + child: DecoratedBox( + decoration: BoxDecoration( + color: Color(0x73000000), + shape: BoxShape.circle, + ), + child: Padding( + padding: EdgeInsets.all(10), + child: Icon( + Icons.play_arrow_rounded, + size: 48, + color: Colors.white, + ), + ), + ), + ), + ), + if (logic.pip || logic.pipPreparing) const SizedBox.expand() - else if (widget.homeMode && logic.fullscreen) + else if (logic.fullscreen) _FullscreenControls( l10n: l10n, controller: ready ? videoPort!.controller : null, @@ -276,238 +273,62 @@ class _PlayerPageState extends State with WidgetsBindingObserver { ? () => unawaited(logic.enterPip(context)) : null, onScrubStart: ready ? () => logic.beginScrub(videoPort!) : null, - onSeek: ready ? (position) => logic.seekTo(context, videoPort!, position) : null, + onSeek: ready + ? (position) => logic.seekTo(context, videoPort!, position) + : null, ) - else if (widget.homeMode) - _StitchHomeOverlay( + else if (!logic.screenCleared) + _PlaybackOverlay( l10n: l10n, drama: drama, episode: episode, controller: ready ? videoPort!.controller : null, liked: engagement.isLiked(drama.id), saved: engagement.isSaved(drama.id), - muted: logic.muted, - category: logic.category, - onCategorySelected: (value) => unawaited(logic.selectCategory(value)), - onCategoryShift: logic.shiftCategory, - onDetail: () => logic.openDetail(context), + onBack: widget.embedded + ? null + : () => unawaited(logic.leave(context)), onDiscover: () => logic.showDiscover(context), onEpisodes: () => logic.showEpisodes(context), onMy: () => logic.showMy(context), - onSearch: () => logic.showSearch(context), - onMenu: widget.onMenu, - onMute: logic.toggleMute, - onLike: () => engagement.toggleLiked(drama.id), - onSave: () => engagement.toggleSaved(drama.id), + // 收藏/点赞要对到具体账号:未登录先引导登录(首页/详情仍可匿名浏览) + onLike: () async { + if (await ensureSignedIn(context)) { + unawaited(engagement.toggleLiked(drama.id)); + } + }, + onSave: () async { + if (await ensureSignedIn(context)) { + unawaited(engagement.toggleSaved(drama.id)); + } + }, onComments: () => logic.showComments(context, drama), onShare: () => logic.shareDrama(context, drama), - onFullscreen: () => unawaited(logic.setFullscreen(true)), + onClear: () => logic.setScreenCleared(true), onPip: logic.pictureInPicture.isPlatformSupported ? () => unawaited(logic.enterPip(context)) : null, onScrubStart: ready ? () => logic.beginScrub(videoPort!) : null, - onSeek: ready ? (position) => logic.seekTo(context, videoPort!, position) : null, - showBottomNav: !widget.embedded, - ) - else + onSeek: ready + ? (position) => logic.seekTo(context, videoPort!, position) + : null, + showBottomNav: false, + ), + if (logic.screenCleared) SafeArea( - child: Padding( - padding: const EdgeInsets.fromLTRB(16, 4, 16, 8), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - children: [ - if (!widget.homeMode) - IconButton( - onPressed: () => unawaited(logic.leave(context)), - tooltip: l10n.backToSeries, - icon: const Icon(Icons.arrow_back_rounded), - ) - else - const Icon( - Icons.play_circle_fill_rounded, - color: Color(0xFFFF6B45), - ), - const SizedBox(width: 6), - Expanded( - child: Text( - widget.homeMode - ? l10n.appName - : localizedDramaTitle(l10n, drama), - maxLines: 1, - overflow: TextOverflow.ellipsis, - style: const TextStyle(fontWeight: FontWeight.bold), - ), - ), - IconButton( - tooltip: l10n.language, - onPressed: () => logic.showMy(context), - icon: const Icon(Icons.language_rounded), - ), - ], + child: Align( + alignment: Alignment.topRight, + child: Padding( + padding: const EdgeInsets.only(top: 4, right: 8), + child: IconButton( + tooltip: l10n.exitClearScreen, + onPressed: () => logic.setScreenCleared(false), + style: IconButton.styleFrom( + foregroundColor: Colors.white, + backgroundColor: const Color(0x59000000), ), - if (widget.homeMode) - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Text( - l10n.homeTab, - style: const TextStyle( - color: Colors.white, - fontSize: 15, - fontWeight: FontWeight.w800, - decoration: TextDecoration.underline, - ), - ), - const SizedBox(width: 22), - TextButton( - onPressed: () => logic.openDetail(context), - child: Text( - l10n.discoverTab, - style: const TextStyle( - color: Color(0xFFF3EEEA), - fontSize: 15, - ), - ), - ), - ], - ), - const Spacer(), - if (selected && logic.session.error != null) - Padding( - padding: const EdgeInsets.only(bottom: 12), - child: FilledButton( - onPressed: () => unawaited(logic.selectEpisode(index)), - child: Text('${l10n.playbackError} ${l10n.retry}'), - ), - ), - Row( - crossAxisAlignment: CrossAxisAlignment.end, - children: [ - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - l10n.demoTestMedia, - style: const TextStyle( - color: Color(0xFFFFB199), - fontSize: 11, - fontWeight: FontWeight.w700, - ), - ), - const SizedBox(height: 8), - Text( - localizedDramaTitle(l10n, drama), - style: const TextStyle( - color: Colors.white, - fontSize: 26, - fontWeight: FontWeight.w800, - shadows: [ - Shadow(blurRadius: 12, color: Colors.black), - ], - ), - ), - const SizedBox(height: 6), - Text( - localizedDramaSynopsis(l10n, drama), - maxLines: 2, - overflow: TextOverflow.ellipsis, - style: const TextStyle(color: Color(0xFFF7F4F2)), - ), - ], - ), - ), - const SizedBox(width: 8), - Column( - children: [ - IconButton.filledTonal( - tooltip: l10n.exploreSeries, - onPressed: () => logic.openDetail(context), - style: IconButton.styleFrom( - backgroundColor: Colors.black45, - foregroundColor: Colors.white, - ), - icon: const Icon(Icons.info_outline_rounded), - ), - const SizedBox(height: 8), - IconButton.filledTonal( - tooltip: l10n.episodes, - onPressed: () => logic.showEpisodes(context), - style: IconButton.styleFrom( - backgroundColor: Colors.black45, - foregroundColor: Colors.white, - ), - icon: const Icon(Icons.grid_view_rounded), - ), - const SizedBox(height: 8), - IconButton.filledTonal( - tooltip: logic.session.userWantsPlay - ? l10n.pause - : l10n.play, - style: IconButton.styleFrom( - backgroundColor: Colors.black45, - foregroundColor: Colors.white, - ), - onPressed: ready - ? () => logic.session.setUserWantsPlay( - !logic.session.userWantsPlay, - ) - : null, - icon: Icon( - logic.session.userWantsPlay - ? Icons.pause_rounded - : Icons.play_arrow_rounded, - ), - ), - ], - ), - ], - ), - const SizedBox(height: 18), - TextButton.icon( - onPressed: () => logic.showEpisodes(context), - icon: const Icon(Icons.play_arrow_rounded), - label: Text( - '${l10n.episodeProgress(episode.number, drama.episodes.length)} · ${l10n.episodes}', - ), - style: TextButton.styleFrom(foregroundColor: Colors.white), - ), - SeekProgressBar( - valueListenable: ready ? videoPort!.controller : null, - semanticsLabel: l10n.seekVideo, - showTimes: false, - onScrubStart: ready ? () => logic.beginScrub(videoPort!) : null, - onSeek: ready - ? (position) => logic.seekTo(context, videoPort!, position) - : null, - ), - if (widget.homeMode) ...[ - const SizedBox(height: 16), - Row( - mainAxisAlignment: MainAxisAlignment.spaceAround, - children: [ - _BottomAction( - icon: Icons.home_rounded, - label: l10n.homeTab, - selected: true, - onTap: () {}, - ), - _BottomAction( - icon: Icons.explore_outlined, - label: l10n.discoverTab, - onTap: () => logic.showDiscover(context), - ), - _BottomAction( - icon: Icons.person_outline_rounded, - label: l10n.myTab, - onTap: () => logic.showMy(context), - ), - ], - ), - ], - ], + icon: const Icon(Icons.close_fullscreen_rounded), + ), ), ), ), @@ -555,11 +376,10 @@ class _FullscreenControls extends StatelessWidget { ), const Spacer(), Padding( - padding: const EdgeInsets.symmetric(horizontal: 20), + padding: const EdgeInsets.fromLTRB(20, 0, 20, 16), child: SeekProgressBar( valueListenable: controller, semanticsLabel: l10n.seekVideo, - compactIdle: true, onScrubStart: onScrubStart, onSeek: onSeek, ), @@ -569,30 +389,23 @@ class _FullscreenControls extends StatelessWidget { ); } -class _StitchHomeOverlay extends StatelessWidget { - const _StitchHomeOverlay({ +class _PlaybackOverlay extends StatelessWidget { + const _PlaybackOverlay({ required this.l10n, required this.drama, required this.episode, required this.controller, required this.liked, required this.saved, - required this.muted, - required this.category, - required this.onCategorySelected, - required this.onCategoryShift, - required this.onDetail, + required this.onBack, required this.onDiscover, required this.onEpisodes, required this.onMy, - required this.onSearch, - required this.onMenu, - required this.onMute, required this.onLike, required this.onSave, required this.onComments, required this.onShare, - required this.onFullscreen, + required this.onClear, required this.onPip, required this.onScrubStart, required this.onSeek, @@ -605,22 +418,15 @@ class _StitchHomeOverlay extends StatelessWidget { final VideoPlayerController? controller; final bool liked; final bool saved; - final bool muted; - final HomeFeedCategory category; - final ValueChanged onCategorySelected; - final ValueChanged onCategoryShift; - final VoidCallback onDetail; + final VoidCallback? onBack; final VoidCallback onDiscover; final VoidCallback onEpisodes; final VoidCallback onMy; - final VoidCallback onSearch; - final VoidCallback? onMenu; - final VoidCallback onMute; final VoidCallback onLike; final VoidCallback onSave; final VoidCallback onComments; final VoidCallback onShare; - final VoidCallback onFullscreen; + final VoidCallback onClear; final VoidCallback? onPip; final VoidCallback? onScrubStart; final Future Function(Duration)? onSeek; @@ -629,250 +435,168 @@ class _StitchHomeOverlay extends StatelessWidget { @override Widget build(BuildContext context) => SafeArea( bottom: showBottomNav, - child: Column( + child: Stack( children: [ - HomeFeedHeader( - l10n: l10n, - category: category, - onCategorySelected: onCategorySelected, - onCategoryShift: onCategoryShift, - onSearch: onSearch, - onMy: onMy, - onMenu: onMenu, - onMute: onMute, - muted: muted, - ), - const Spacer(), - Padding( - padding: const EdgeInsets.fromLTRB(16, 0, 12, 0), - child: Row( - crossAxisAlignment: CrossAxisAlignment.end, - children: [ - Expanded( - child: Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - _MetaChip(text: l10n.freeTestMedia, accent: true), - const SizedBox(height: 5), - Text( - localizedDramaTitle(l10n, drama), - style: const TextStyle( - color: Colors.white, - fontSize: 19, - fontWeight: FontWeight.w800, - shadows: [Shadow(blurRadius: 12, color: Colors.black)], - ), - ), - const SizedBox(height: 3), - Text( - localizedDramaSynopsis(l10n, drama), - maxLines: 1, - overflow: TextOverflow.ellipsis, - style: const TextStyle( - fontSize: 11, - height: 1.2, - color: Colors.white, - shadows: [Shadow(blurRadius: 8, color: Colors.black)], - ), - ), - Tooltip( - message: l10n.exploreSeries, - child: TextButton( - onPressed: onDetail, - style: TextButton.styleFrom( - padding: EdgeInsets.zero, - minimumSize: const Size(0, 28), - foregroundColor: const Color(0xFFFFA18B), - ), - child: Text( - l10n.exploreSeries, - style: const TextStyle(fontSize: 12), - ), - ), - ), - ], - ), - ), - const SizedBox(width: 8), - Column( - mainAxisSize: MainAxisSize.min, + Column( + children: [ + const Spacer(), + Padding( + padding: const EdgeInsets.fromLTRB(20, 0, 8, 0), + child: Row( + crossAxisAlignment: CrossAxisAlignment.end, children: [ - _RailAction( - key: const Key('rail-save'), - icon: saved - ? Icons.bookmark_rounded - : Icons.bookmark_border_rounded, - label: l10n.save, - selected: saved, - onTap: onSave, - ), - _RailAction( - key: const Key('rail-comments'), - icon: Icons.mode_comment_outlined, - label: l10n.comments, - onTap: onComments, - ), - _RailAction( - key: const Key('rail-like'), - icon: liked - ? Icons.favorite_rounded - : Icons.favorite_border_rounded, - label: l10n.like, - selected: liked, - onTap: onLike, - ), - _RailAction( - key: const Key('rail-share'), - icon: Icons.share_rounded, - label: l10n.share, - onTap: onShare, - ), + Expanded(child: _info()), + _rail(), ], ), - ], - ), - ), - const SizedBox(height: 2), - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Tooltip( - message: l10n.watchFullscreen, - child: TextButton.icon( - onPressed: onFullscreen, - icon: const Icon(Icons.screen_rotation_outlined, size: 15), - label: Text(l10n.watchFullscreen), - style: TextButton.styleFrom( - foregroundColor: Colors.white, - textStyle: const TextStyle(fontSize: 11), - visualDensity: VisualDensity.compact, - ), + ), + const SizedBox(height: 4), + Padding( + padding: EdgeInsets.fromLTRB( + 16, + 0, + 16, + 20 + MediaQuery.paddingOf(context).bottom, + ), + child: SeekProgressBar( + valueListenable: controller, + semanticsLabel: l10n.seekVideo, + onScrubStart: onScrubStart, + onSeek: onSeek, ), ), - if (onPip != null) - IconButton( - tooltip: l10n.pictureInPicture, - onPressed: onPip, - visualDensity: VisualDensity.compact, - iconSize: 17, - icon: const Icon(Icons.picture_in_picture_alt_outlined), - ), + if (showBottomNav) _fallbackNav(), ], ), - Padding( - padding: const EdgeInsets.symmetric(horizontal: 16), - child: Tooltip( - message: l10n.episodes, - child: InkWell( - onTap: onEpisodes, - borderRadius: BorderRadius.circular(8), - child: Container( - height: 42, - padding: const EdgeInsets.symmetric(horizontal: 10), - decoration: BoxDecoration( - color: const Color(0xE6212125), - borderRadius: BorderRadius.circular(8), - ), - child: IconTheme( - data: const IconThemeData(color: Colors.white), - child: DefaultTextStyle.merge( - style: const TextStyle(color: Colors.white), - child: Row( - children: [ - const Icon(Icons.play_circle_outline_rounded, size: 19), - const SizedBox(width: 7), - Expanded( - child: Text( - '${l10n.episodeLabel(episode.number)} · ${l10n.nowPlaying}', - maxLines: 1, - overflow: TextOverflow.ellipsis, - style: const TextStyle( - color: Colors.white, - fontSize: 13, - fontWeight: FontWeight.w600, - ), - ), - ), - Text( - '${l10n.episodes} (${drama.episodes.length})', - style: const TextStyle( - color: Colors.white, - fontSize: 12, - fontWeight: FontWeight.w600, - ), - ), - const Icon(Icons.keyboard_arrow_up_rounded, size: 18), - ], - ), - ), - ), + if (onBack != null) + Positioned( + top: 4, + left: 8, + child: IconButton( + tooltip: l10n.backToSeries, + onPressed: onBack, + style: IconButton.styleFrom( + foregroundColor: Colors.white, + backgroundColor: const Color(0x59000000), ), + icon: const Icon(Icons.arrow_back_rounded), ), ), - ), - const SizedBox(height: 2), - Padding( - padding: const EdgeInsets.symmetric(horizontal: 12), - child: SeekProgressBar( - valueListenable: controller, - semanticsLabel: l10n.seekVideo, - onScrubStart: onScrubStart, - onSeek: onSeek, - compactIdle: true, - ), - ), - const SizedBox(height: 2), - if (showBottomNav) - Container( - height: 62, - color: const Color(0xF20C0C0F), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceAround, - children: [ - _BottomAction( - icon: Icons.play_circle_outline_rounded, - label: l10n.homeTab, - selected: true, - onTap: () {}, - ), - _BottomAction( - icon: Icons.explore_outlined, - label: l10n.discoverTab, - onTap: onDiscover, - ), - _BottomAction( - icon: Icons.video_library_outlined, - label: l10n.myTab, - onTap: onMy, - ), - ], + Positioned( + top: 4, + right: 8, + child: IconButton( + tooltip: l10n.clearScreen, + onPressed: onClear, + style: IconButton.styleFrom( + foregroundColor: Colors.white, + backgroundColor: const Color(0x59000000), ), + icon: const Icon(Icons.fit_screen_outlined), ), + ), ], ), ); -} -class _MetaChip extends StatelessWidget { - const _MetaChip({required this.text, this.accent = false}); - final String text; - final bool accent; - - @override - Widget build(BuildContext context) => Container( - padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4), - decoration: BoxDecoration( - color: const Color(0xB51F1F22), - borderRadius: BorderRadius.circular(12), - ), - child: Text( - text, - style: TextStyle( - fontSize: 10, - fontWeight: FontWeight.w600, - color: accent ? const Color(0xFFFFC2B0) : const Color(0xFFF7F4F2), + Widget _info() => Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + localizedDramaTitle(l10n, drama), + maxLines: 2, + overflow: TextOverflow.ellipsis, + style: const TextStyle( + color: Colors.white, + fontSize: 22, + fontWeight: FontWeight.w800, + height: 1.15, + shadows: [Shadow(blurRadius: 12, color: Colors.black)], + ), ), + const SizedBox(height: 6), + Text( + '${l10n.episodeLabel(episode.number)} · ${l10n.nowPlaying}', + style: const TextStyle( + color: Colors.white, + fontSize: 13, + fontWeight: FontWeight.w600, + shadows: [Shadow(blurRadius: 8, color: Colors.black)], + ), + ), + ], + ); + + Widget _rail() => Column( + mainAxisSize: MainAxisSize.min, + children: [ + _RailAction( + key: const Key('rail-like'), + icon: liked ? Icons.favorite_rounded : Icons.favorite_border_rounded, + label: l10n.like, + selected: liked, + onTap: onLike, + ), + _RailAction( + key: const Key('rail-save'), + icon: saved ? Icons.bookmark_rounded : Icons.bookmark_border_rounded, + label: l10n.save, + selected: saved, + onTap: onSave, + ), + _RailAction( + icon: Icons.grid_view_rounded, + label: l10n.episodes, + onTap: onEpisodes, + ), + _RailAction( + key: const Key('rail-comments'), + icon: Icons.mode_comment_outlined, + label: l10n.comments, + onTap: onComments, + ), + _RailAction( + key: const Key('rail-share'), + icon: Icons.share_rounded, + label: l10n.share, + onTap: onShare, + ), + if (onPip != null) + IconButton( + tooltip: l10n.pictureInPicture, + onPressed: onPip, + visualDensity: VisualDensity.compact, + iconSize: 20, + color: Colors.white, + icon: const Icon(Icons.picture_in_picture_alt_outlined), + ), + ], + ); + + Widget _fallbackNav() => Container( + height: 62, + color: const Color(0xF20C0C0F), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + _BottomAction( + icon: Icons.play_circle_outline_rounded, + label: l10n.homeTab, + selected: true, + onTap: () {}, + ), + _BottomAction( + icon: Icons.explore_outlined, + label: l10n.discoverTab, + onTap: onDiscover, + ), + _BottomAction( + icon: Icons.video_library_outlined, + label: l10n.myTab, + onTap: onMy, + ), + ], ), ); } @@ -894,14 +618,14 @@ class _RailAction extends StatelessWidget { Widget build(BuildContext context) => Column( mainAxisSize: MainAxisSize.min, children: [ - IconButton.filledTonal( + IconButton( tooltip: label, onPressed: onTap, - style: IconButton.styleFrom( - backgroundColor: const Color(0xB719191B), - foregroundColor: selected ? const Color(0xFFFF6B45) : Colors.white, - ), - icon: Icon(icon, size: 22), + visualDensity: VisualDensity.compact, + padding: EdgeInsets.zero, + constraints: const BoxConstraints.tightFor(width: 42, height: 36), + color: selected ? const Color(0xFF8FB4FF) : Colors.white, + icon: Icon(icon, size: 24), ), Text( label, @@ -940,14 +664,16 @@ class _BottomAction extends StatelessWidget { children: [ Icon( icon, - color: selected ? const Color(0xFFFF6B45) : const Color(0xFFF3EEEA), + color: selected ? const Color(0xFF2F7BFF) : const Color(0xFFF3EEEA), ), const SizedBox(height: 2), Text( label, style: TextStyle( fontSize: 11, - color: selected ? const Color(0xFFFF6B45) : const Color(0xFFF3EEEA), + color: selected + ? const Color(0xFF2F7BFF) + : const Color(0xFFF3EEEA), ), ), ], diff --git a/test/auth/auth_controller_test.dart b/test/auth/auth_controller_test.dart new file mode 100644 index 0000000..1ca93aa --- /dev/null +++ b/test/auth/auth_controller_test.dart @@ -0,0 +1,156 @@ +import 'dart:convert'; + +import 'package:flutter_test/flutter_test.dart'; +import 'package:http/http.dart' as http; +import 'package:http/testing.dart'; +import 'package:shared_preferences_platform_interface/in_memory_shared_preferences_async.dart'; +import 'package:shared_preferences_platform_interface/shared_preferences_async_platform_interface.dart'; + +// 包名此刻仍是 nontonki,1-3 改名时会一并替换成 fruitshorts +import 'package:nontonki/core/data/remote/api_client.dart'; +import 'package:nontonki/core/data/remote/auth_api.dart'; +import 'package:nontonki/core/data/services/auth_controller.dart'; +import 'package:nontonki/core/data/services/auth_session_store.dart'; + +/// 用假的 http.Client 覆盖三条关键路径:注册成功、401 → 刷新 → 重试、刷新失败 → 清会话。 +void main() { + setUp(() { + SharedPreferencesAsyncPlatform.instance = + InMemorySharedPreferencesAsync.empty(); + }); + + /// http.Response(String) 默认按 Latin-1 编码,中文消息会直接抛 + /// "Contains invalid characters" —— 统一用 UTF-8 字节构造。 + http.Response jsonResponse(String body, [int statusCode = 200]) { + return http.Response.bytes( + utf8.encode(body), + statusCode, + headers: const {'content-type': 'application/json; charset=utf-8'}, + ); + } + + String tokenBody({ + required String accessToken, + required String refreshToken, + String uid = 'U1', + }) { + return jsonEncode({ + 'code': 0, + 'message': 'ok', + 'data': { + 'accessToken': accessToken, + 'refreshToken': refreshToken, + 'expiresIn': 7200, + 'user': {'uid': uid, 'nickname': 'Tester', 'avatarUrl': ''}, + }, + }); + } + + ApiClient clientWith( + AuthController Function() auth, { + required MockClient httpClient, + }) { + final store = AuthSessionStore(); + return ApiClient( + baseUrl: 'http://127.0.0.1:8081', + client: httpClient, + accessTokenReader: () => auth().accessToken, + tokenRefresher: () => auth().refresh(), + onUnauthorized: () => auth().clear(), + deviceIdReader: store.deviceId, + ); + } + + test('register stores session and exposes signed-in state', () async { + late AuthController auth; + final mock = MockClient((request) async { + expect(request.url.path, '/app/auth/register'); + expect(request.headers['X-Device-Id'], isNotEmpty); + expect(request.headers.containsKey('Authorization'), isFalse); + return jsonResponse(tokenBody(accessToken: 'a1', refreshToken: 'r1')); + }); + final store = AuthSessionStore(); + auth = AuthController(AuthApi(clientWith(() => auth, httpClient: mock)), store); + + expect(auth.isSignedIn, isFalse); + await auth.register(email: 'a@b.com', password: 'abcd1234'); + expect(auth.isSignedIn, isTrue); + expect(auth.accessToken, 'a1'); + expect(auth.user?.nickname, 'Tester'); + // 落盘:新建一个 store 也能读回来 + expect((await AuthSessionStore().read())?.refreshToken, 'r1'); + }); + + test('401 triggers refresh once and retries with the new token', () async { + var calls = 0; + late AuthController auth; + final mock = MockClient((request) async { + calls++; + if (request.url.path == '/app/auth/refresh') { + return jsonResponse(tokenBody(accessToken: 'a2', refreshToken: 'r2')); + } + if (request.url.path != '/app/me') { + // 注册等其它请求:直接发第一版令牌 + return jsonResponse(tokenBody(accessToken: 'a1', refreshToken: 'r1')); + } + final token = request.headers['Authorization']; + if (token == 'Bearer a1') { + return jsonResponse( + jsonEncode({'code': 401, 'message': '未登录或登录已过期', 'data': null}), + ); + } + expect(token, 'Bearer a2'); + return jsonResponse(jsonEncode({'code': 0, 'message': 'ok', 'data': {'hit': true}})); + }); + final store = AuthSessionStore(); + auth = AuthController(AuthApi(clientWith(() => auth, httpClient: mock)), store); + await auth.register(email: 'a@b.com', password: 'abcd1234'); + calls = 0; + + final api = clientWith(() => auth, httpClient: mock); + final data = await api.get('/app/me'); + expect((data as Map)['hit'], isTrue); + expect(calls, 3); // 原请求(401) + 刷新 + 重试 + expect(auth.accessToken, 'a2'); + }); + + test('refresh failure clears the session (401 handling)', () async { + late AuthController auth; + final mock = MockClient((request) async { + if (request.url.path == '/app/auth/refresh') { + return jsonResponse(jsonEncode({'code': 401, 'message': '登录已过期', 'data': null})); + } + if (request.url.path == '/app/auth/register') { + return jsonResponse(tokenBody(accessToken: 'a1', refreshToken: 'r1')); + } + return jsonResponse( + jsonEncode({'code': 401, 'message': '未登录或登录已过期', 'data': null}), + ); + }); + final store = AuthSessionStore(); + auth = AuthController(AuthApi(clientWith(() => auth, httpClient: mock)), store); + await auth.register(email: 'a@b.com', password: 'abcd1234'); + + final api = clientWith(() => auth, httpClient: mock); + await expectLater(api.get('/app/me'), throwsA(isA())); + expect(auth.isSignedIn, isFalse); + expect(await AuthSessionStore().read(), isNull); + }); + + test('signOut clears local session even if the server call fails', () async { + late AuthController auth; + final mock = MockClient((request) async { + if (request.url.path == '/app/auth/logout') { + return jsonResponse('{}', 500); + } + return jsonResponse(tokenBody(accessToken: 'a1', refreshToken: 'r1')); + }); + final store = AuthSessionStore(); + auth = AuthController(AuthApi(clientWith(() => auth, httpClient: mock)), store); + await auth.register(email: 'a@b.com', password: 'abcd1234'); + + await auth.signOut(); + expect(auth.isSignedIn, isFalse); + expect(await AuthSessionStore().read(), isNull); + }); +} diff --git a/test/auth/auth_page_test.dart b/test/auth/auth_page_test.dart new file mode 100644 index 0000000..0973f6d --- /dev/null +++ b/test/auth/auth_page_test.dart @@ -0,0 +1,81 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:http/http.dart' as http; +import 'package:http/testing.dart'; +import 'package:provider/provider.dart'; +import 'package:shared_preferences_platform_interface/in_memory_shared_preferences_async.dart'; +import 'package:shared_preferences_platform_interface/shared_preferences_async_platform_interface.dart'; + +import 'package:nontonki/core/data/remote/auth_api.dart'; +import 'package:nontonki/core/data/remote/api_client.dart'; +import 'package:nontonki/core/data/services/auth_controller.dart'; +import 'package:nontonki/core/data/services/auth_session_store.dart'; +import 'package:nontonki/l10n/app_localizations.dart'; +import 'package:nontonki/pages/auth/auth_view.dart'; + +/// 登录/注册页的可读证据:校验提示 + 登录/注册切换 + 未登录时不会去发请求。 +void main() { + setUp(() { + SharedPreferencesAsyncPlatform.instance = + InMemorySharedPreferencesAsync.empty(); + }); + + Future pumpAuthPage(WidgetTester tester, {bool signUp = false}) async { + final auth = AuthController( + AuthApi( + // 这个测试不联网:请求一律 500,正好用于验证"本地校验没过就不发请求" + ApiClient( + baseUrl: 'http://127.0.0.1:1', + client: MockClient((_) async => http.Response('{}', 500)), + ), + ), + AuthSessionStore(), + ); + await tester.pumpWidget( + ChangeNotifierProvider.value( + value: auth, + child: MaterialApp( + locale: const Locale('en'), + localizationsDelegates: AppLocalizations.localizationsDelegates, + supportedLocales: AppLocalizations.supportedLocales, + home: AuthPage(signUpMode: signUp), + ), + ), + ); + await tester.pumpAndSettle(); + } + + testWidgets('empty form shows the email error and stays on the page', (tester) async { + await pumpAuthPage(tester); + + expect(find.text('Welcome back'), findsOneWidget); + + await tester.tap(find.byType(FilledButton)); + await tester.pumpAndSettle(); + + expect(find.text('Enter your email'), findsOneWidget); + expect(find.text('Welcome back'), findsOneWidget); + }); + + testWidgets('weak password is rejected locally', (tester) async { + await pumpAuthPage(tester); + + await tester.enterText(find.byType(TextField).first, 'a@b.com'); + await tester.enterText(find.byType(TextField).last, 'abcdefgh'); + await tester.tap(find.byType(FilledButton)); + await tester.pumpAndSettle(); + + expect(find.text('Password needs both letters and numbers'), findsOneWidget); + }); + + testWidgets('switch link flips between sign in and sign up', (tester) async { + await pumpAuthPage(tester); + expect(find.text('Welcome back'), findsOneWidget); + + await tester.tap(find.text('New here? Create an account')); + await tester.pumpAndSettle(); + + expect(find.text('Create your account'), findsOneWidget); + expect(find.text('Already have an account? Sign in'), findsOneWidget); + }); +} diff --git a/test/home/home_logic_test.dart b/test/home/home_logic_test.dart new file mode 100644 index 0000000..c56b869 --- /dev/null +++ b/test/home/home_logic_test.dart @@ -0,0 +1,227 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:nontonki/core/data/models/drama.dart'; +import 'package:nontonki/pages/discover/discover_logic.dart'; +import 'package:nontonki/pages/home/home_logic.dart'; +import 'package:nontonki/pages/mine/mine_logic.dart'; + +Drama _drama(String id) => Drama( + id: id, + title: id, + synopsis: 'synopsis', + posterUrl: '/files/poster.png', + episodes: const [], +); + +void main() { + TestWidgetsFlutterBinding.ensureInitialized(); + + final dramas = [_drama('signal'), _drama('city')]; + + test('the first catalog entry becomes the current drama', () { + final logic = HomeLogic(dramas); + + expect(logic.currentDrama.id, 'signal'); + expect(logic.tab, 1); + expect(logic.mySection, 0); + expect(logic.drawerOpen, isFalse); + expect(logic.profile, isFalse); + expect(logic.videoImmersive, isFalse); + logic.dispose(); + }); + + test('an empty catalog cannot build the shell', () { + expect(() => HomeLogic(const []), throwsStateError); + }); + + test('a plain tab switch raises no request counter', () { + final logic = HomeLogic(dramas); + var notifications = 0; + logic.addListener(() => notifications++); + + logic.select(1); + + expect(logic.tab, 1); + expect(logic.searchRequest, 0); + expect(logic.sectionRequest, 0); + expect(logic.resumeRequest, 0); + expect(logic.backRequest, 0); + expect(notifications, 1); + logic.dispose(); + }); + + test('each select flag raises exactly its own counter', () { + final logic = HomeLogic(dramas); + + logic.select(1, search: true); + expect(logic.tab, 1); + expect(logic.searchRequest, 1); + expect(logic.sectionRequest, 0); + + logic.select(2, mySection: 0); + expect(logic.mySection, 0); + expect(logic.sectionRequest, 1); + expect(logic.searchRequest, 1); + + logic.select(0, resume: true); + expect(logic.resumeRequest, 1); + expect(logic.sectionRequest, 1); + + expect(logic.backRequest, 0); + logic.dispose(); + }); + + test('the watchlist shortcut defaults to the second section', () { + final logic = HomeLogic(dramas); + + logic.select(2, watchlist: true); + + expect(logic.tab, 2); + expect(logic.mySection, 1); + expect(logic.sectionRequest, 1); + logic.dispose(); + }); + + test('openProfile and openLibrary disagree about the profile flag', () { + final logic = HomeLogic(dramas); + + logic.openProfile(); + expect(logic.profile, isTrue); + expect(logic.tab, 2); + expect(logic.mySection, 0); + expect(logic.sectionRequest, 1); + + logic.openLibrary(section: 1); + expect(logic.profile, isFalse); + expect(logic.mySection, 1); + expect(logic.sectionRequest, 2); + + logic.openLibrary(); + expect(logic.profile, isFalse); + expect(logic.mySection, 1); + expect(logic.sectionRequest, 3); + logic.dispose(); + }); + + test('system back returns home, and home itself opens the drawer', () { + final logic = HomeLogic(dramas); + + logic.onSystemBack(); + expect(logic.drawerOpen, isTrue); + expect(logic.tab, 1); + expect(logic.backRequest, 0); + logic.onDrawerChanged(false); + + logic.select(0); + logic.onSystemBack(); + expect(logic.tab, 1); + expect(logic.backRequest, 0); + + logic.select(0); + logic.onImmersiveChanged(true); + logic.onSystemBack(); + expect(logic.backRequest, 1); + expect(logic.tab, 0); + + logic.onDrawerChanged(true); + logic.onSystemBack(); + expect(logic.backRequest, 1); + + logic.onDrawerChanged(false); + logic.onImmersiveChanged(false); + logic.onSystemBack(); + expect(logic.tab, 1); + logic.dispose(); + }); + + test('drawer state only notifies on an actual change', () { + final logic = HomeLogic(dramas); + var notifications = 0; + logic.addListener(() => notifications++); + + logic.onDrawerChanged(false); + expect(notifications, 0); + + logic.onDrawerChanged(true); + expect(logic.drawerOpen, isTrue); + expect(notifications, 1); + + logic.onDrawerChanged(true); + expect(notifications, 1); + logic.dispose(); + }); + + test('drama and immersive callbacks update state', () { + final logic = HomeLogic(dramas); + + logic.onDramaChanged(dramas[1]); + expect(logic.currentDrama.id, 'city'); + + logic.onImmersiveChanged(true); + expect(logic.videoImmersive, isTrue); + logic.dispose(); + }); + + test('my page actions map onto root tabs', () { + final logic = HomeLogic(dramas); + + logic.myAction(MyPageAction.discover); + expect(logic.tab, 1); + expect(logic.searchRequest, 1); + + logic.myAction(MyPageAction.resume); + expect(logic.tab, 0); + expect(logic.resumeRequest, 1); + + logic.myAction(MyPageAction.home); + expect(logic.tab, 0); + expect(logic.resumeRequest, 1); + logic.dispose(); + }); + + test('notifying after dispose is a no-op', () { + final logic = HomeLogic(dramas); + var notifications = 0; + logic.addListener(() => notifications++); + + logic.dispose(); + logic.notify(); + + expect(notifications, 0); + }); + + testWidgets('discover actions map onto root tabs', (tester) async { + final logic = HomeLogic(dramas); + late BuildContext context; + await tester.pumpWidget( + MaterialApp( + home: Builder( + builder: (inner) { + context = inner; + return const SizedBox.shrink(); + }, + ), + ), + ); + + logic.discoverAction(context, DiscoverPageAction.watchlist); + expect(logic.tab, 2); + expect(logic.profile, isFalse); + expect(logic.mySection, 1); + expect(logic.sectionRequest, 1); + + logic.discoverAction(context, DiscoverPageAction.my); + expect(logic.tab, 2); + expect(logic.profile, isFalse); + + logic.discoverAction(context, DiscoverPageAction.resume); + expect(logic.tab, 0); + expect(logic.resumeRequest, 1); + + logic.discoverAction(context, DiscoverPageAction.home); + expect(logic.tab, 0); + + expect(tester.takeException(), isNull); + logic.dispose(); + }); +} diff --git a/test/playback/video_player_port_test.dart b/test/playback/video_player_port_test.dart new file mode 100644 index 0000000..0c7553c --- /dev/null +++ b/test/playback/video_player_port_test.dart @@ -0,0 +1,37 @@ +import 'package:flutter_test/flutter_test.dart'; +import 'package:nontonki/core/config/app_config.dart'; +import 'package:nontonki/core/data/models/drama.dart'; +import 'package:nontonki/core/data/services/video_player_port.dart'; + +Episode _episode(String videoUrl) => Episode( + id: '1', + number: 1, + title: '第 1 集', + isFree: true, + videoUrl: videoUrl, +); + +void main() { + test('相对播放地址补上服务地址', () { + final uri = VideoPlayerPort.resolveUri( + _episode('/files/episode/202610/clip.mp4'), + ); + + expect(uri.isAbsolute, isTrue); + // Uri.parse().toString() 会把 host 规范成小写,而 devHostBaseUrl 里的 + // Bonjour 名字带大写(jiangdeMacBook-Air.local)—— 比较时统一小写, + // 否则会依赖运行平台(flutter test 里 defaultTargetPlatform 默认是 android) + expect( + uri.toString().toLowerCase(), + '${AppConfig.apiBaseUrl}/files/episode/202610/clip.mp4'.toLowerCase(), + ); + }); + + test('已经是绝对地址的不再拼接', () { + final uri = VideoPlayerPort.resolveUri( + _episode('https://cdn.example.test/clip.mp4'), + ); + + expect(uri.toString(), 'https://cdn.example.test/clip.mp4'); + }); +} diff --git a/test/widget_test.dart b/test/widget_test.dart index 94c734c..6a63e43 100644 --- a/test/widget_test.dart +++ b/test/widget_test.dart @@ -6,12 +6,25 @@ import 'package:nontonki/pages/player/player_view.dart'; import 'package:shared_preferences_platform_interface/in_memory_shared_preferences_async.dart'; import 'package:shared_preferences_platform_interface/shared_preferences_async_platform_interface.dart'; +import 'support/fake_catalog.dart'; import 'support/widget_player.dart'; void main() { - setUp(() { + /// 默认按「已登录」起测:账号体系接上后,"登录"不再是本地演示开关, + /// 而是本地会话(这里直接给 shared_preferences 的内存实现塞一份会话)。 + /// 昵称/uid 与演示文案保持一致,避免为显示细节改写既有断言。 + void seedSignedInSession() { SharedPreferencesAsyncPlatform.instance = - InMemorySharedPreferencesAsync.empty(); + InMemorySharedPreferencesAsync.withData({ + 'auth.accessToken': 'test-access', + 'auth.refreshToken': 'test-refresh', + 'auth.user': + '{"uid":"M1CZWVYE","nickname":"Vicky sheng","avatarUrl":""}', + }); + } + + setUp(() { + seedSignedInSession(); }); testWidgets( @@ -24,9 +37,12 @@ void main() { created.add(episode.id); return WidgetPlayer(); }, + catalogRepository: FakeCatalogRepository(), ), ); await tester.pumpAndSettle(); + await tester.tap(find.byKey(const Key('tab-home'))); + await tester.pumpAndSettle(); expect(created, hasLength(2)); expect(find.byType(CircularProgressIndicator), findsNothing); await tester.drag(find.byType(PageView), const Offset(0, -550)); @@ -48,25 +64,25 @@ void main() { addTearDown(tester.view.resetDevicePixelRatio); await tester.pumpWidget( - const LumaDramaApp(playerFactory: createWidgetPlayer), + LumaDramaApp(playerFactory: createWidgetPlayer, catalogRepository: FakeCatalogRepository()), ); await tester.pumpAndSettle(); + await tester.tap(find.byKey(const Key('tab-home'))); + await tester.pumpAndSettle(); expect(find.text('The Signal'), findsOneWidget); expect(find.byType(Slider), findsOneWidget); expect(find.text('Home'), findsWidgets); - expect(find.text('Recommended'), findsOneWidget); expect(find.textContaining('Playing now'), findsOneWidget); + expect(find.text('Recommended'), findsNothing); + expect(find.text('Following'), findsNothing); expect(find.byTooltip('Episodes'), findsWidgets); - expect(find.byTooltip('Watch in landscape'), findsOneWidget); + expect(find.byTooltip('Clear screen'), findsOneWidget); expect(find.byTooltip('Picture in picture'), findsOneWidget); - - await tester.tap(find.byTooltip('Explore series')); - await tester.pumpAndSettle(); - expect(find.text('Watch episode 1'), findsOneWidget); - expect(find.text('Episodes'), findsOneWidget); + expect(find.text('Watch Full'), findsNothing); + expect(find.byTooltip('Explore series'), findsNothing); }); - testWidgets('landscape control hides tabs and restores them on exit', ( + testWidgets('clear screen hides tabs and restores them on tap', ( tester, ) async { tester.view.physicalSize = const Size(390, 844); @@ -75,16 +91,19 @@ void main() { addTearDown(tester.view.resetDevicePixelRatio); await tester.pumpWidget( - const LumaDramaApp(playerFactory: createWidgetPlayer), + LumaDramaApp(playerFactory: createWidgetPlayer, catalogRepository: FakeCatalogRepository()), ); await tester.pumpAndSettle(); - await tester.tap(find.byTooltip('Watch in landscape')); + await tester.tap(find.byKey(const Key('tab-home'))); + await tester.pumpAndSettle(); + await tester.tap(find.byTooltip('Clear screen')); await tester.pumpAndSettle(); expect(find.byKey(const Key('home-tabs-bar')), findsNothing); - expect(find.byTooltip('Exit fullscreen'), findsOneWidget); - await tester.tap(find.byTooltip('Exit fullscreen')); + expect(find.byTooltip('Exit clear screen'), findsOneWidget); + await tester.tap(find.byTooltip('Exit clear screen')); await tester.pumpAndSettle(); expect(find.byKey(const Key('home-tabs-bar')), findsOneWidget); + expect(find.byTooltip('Clear screen'), findsOneWidget); expect(tester.takeException(), isNull); }); @@ -97,17 +116,23 @@ void main() { addTearDown(tester.view.resetDevicePixelRatio); await tester.pumpWidget( - const LumaDramaApp(playerFactory: createWidgetPlayer), + LumaDramaApp(playerFactory: createWidgetPlayer, catalogRepository: FakeCatalogRepository()), ); await tester.pumpAndSettle(); - await tester.tap(find.byTooltip('Open quick menu')); + expect(find.text('Continue Watching'), findsOneWidget); + await tester.binding.handlePopRoute(); await tester.pumpAndSettle(); - expect(tester.widget(find.byType(PlayerPage)).active, isFalse); + expect( + tester + .widget(find.byType(PlayerPage, skipOffstage: false)) + .active, + isFalse, + ); expect(find.text('Quick access'), findsOneWidget); expect( find.descendant( of: find.byType(Drawer), - matching: find.text('Same demo clip · free'), + matching: find.text('7 EPISODES'), ), findsOneWidget, ); @@ -118,15 +143,21 @@ void main() { expect(find.text('Watch episode 1'), findsOneWidget); await tester.binding.handlePopRoute(); await tester.pumpAndSettle(); - expect(tester.widget(find.byType(PlayerPage)).active, isTrue); + expect( + tester + .widget(find.byType(PlayerPage, skipOffstage: false)) + .active, + isFalse, + ); + expect(find.text('Continue Watching'), findsOneWidget); - await tester.tap(find.byTooltip('Open quick menu')); + await tester.binding.handlePopRoute(); await tester.pumpAndSettle(); await tester.tap(find.byKey(const Key('drawer-discover'))); await tester.pumpAndSettle(); - expect(find.text('Trending Micro-Dramas'), findsOneWidget); + expect(find.text('Continue Watching'), findsOneWidget); expect( - Navigator.of(tester.element(find.text('Trending Micro-Dramas'))).canPop(), + Navigator.of(tester.element(find.text('Continue Watching'))).canPop(), isFalse, ); }); @@ -140,37 +171,26 @@ void main() { addTearDown(tester.view.resetDevicePixelRatio); await tester.pumpWidget( - const LumaDramaApp(playerFactory: createWidgetPlayer), + LumaDramaApp(playerFactory: createWidgetPlayer, catalogRepository: FakeCatalogRepository()), ); await tester.pumpAndSettle(); expect(find.byTooltip('Captions'), findsNothing); - await tester.tap(find.byTooltip('My')); + await tester.tap(find.byKey(const Key('tab-my'))); await tester.pumpAndSettle(); - expect(find.text('Continue Watching'), findsOneWidget); - expect(find.text('History'), findsOneWidget); - expect(find.text('Watchlist'), findsOneWidget); - await tester.scrollUntilVisible( - find.text('App Language'), - 120, - scrollable: find - .descendant( - of: find.byType(ListView), - matching: find.byType(Scrollable), - ) - .first, - ); + expect(find.text('Vicky sheng'), findsOneWidget); + expect(find.text('Coins'), findsOneWidget); expect(find.text('PREFERENCES'), findsOneWidget); await tester.tap(find.text('App Language')); await tester.pumpAndSettle(); await tester.tap(find.text('简体中文').last); await tester.pumpAndSettle(); expect(find.text('我的'), findsWidgets); - expect(find.text('继续观看'), findsOneWidget); - expect(find.text('找剧'), findsOneWidget); - await tester.tap(find.text('找剧')); + expect(find.text('我的账户'), findsOneWidget); + expect(find.text('首页'), findsOneWidget); + await tester.tap(find.text('首页')); await tester.pumpAndSettle(); - expect(find.text('热门短剧'), findsOneWidget); - expect(find.text('排行榜'), findsOneWidget); + expect(find.text('为你推荐'), findsOneWidget); + expect(find.text('热门'), findsOneWidget); }); testWidgets('home controls fit a compact Android viewport', (tester) async { @@ -180,16 +200,18 @@ void main() { addTearDown(tester.view.resetDevicePixelRatio); await tester.pumpWidget( - const LumaDramaApp(playerFactory: createWidgetPlayer), + LumaDramaApp(playerFactory: createWidgetPlayer, catalogRepository: FakeCatalogRepository()), ); await tester.pumpAndSettle(); - expect(find.text('Recommended'), findsOneWidget); + await tester.tap(find.byKey(const Key('tab-home'))); + await tester.pumpAndSettle(); + expect(find.text('The Signal'), findsOneWidget); await tester.drag(find.byType(PageView), const Offset(0, -500)); await tester.pumpAndSettle(); expect(find.text('City Lights & Velvet Nights'), findsOneWidget); - await tester.tap(find.byTooltip('Explore series')); + await tester.tap(find.byKey(const Key('tab-discover'))); await tester.pumpAndSettle(); - await tester.tap(find.text('Watch episode 1')); + await tester.tap(find.text('City Lights & Velvet Nights')); await tester.pumpAndSettle(); expect(find.byType(Slider), findsOneWidget); expect(tester.takeException(), isNull); @@ -204,17 +226,18 @@ void main() { addTearDown(tester.view.resetDevicePixelRatio); await tester.pumpWidget( - const LumaDramaApp(playerFactory: createWidgetPlayer), + LumaDramaApp(playerFactory: createWidgetPlayer, catalogRepository: FakeCatalogRepository()), ); await tester.pumpAndSettle(); - await tester.tap(find.byTooltip('My')); + await tester.tap(find.byKey(const Key('tab-my'))); await tester.pumpAndSettle(); - expect(find.text('Continue Watching'), findsOneWidget); - expect(find.text('History'), findsOneWidget); expect(tester.takeException(), isNull); - await tester.tap(find.text('Home').last); + expect(find.text('Vicky sheng'), findsOneWidget); + expect(find.text('Coins'), findsOneWidget); + expect(tester.takeException(), isNull); + await tester.tap(find.text('Shorts')); await tester.pumpAndSettle(); - expect(find.text('Recommended'), findsOneWidget); + expect(find.text('The Signal'), findsOneWidget); }); testWidgets( @@ -226,58 +249,53 @@ void main() { addTearDown(tester.view.resetDevicePixelRatio); await tester.pumpWidget( - const LumaDramaApp(playerFactory: createWidgetPlayer), + LumaDramaApp(playerFactory: createWidgetPlayer, catalogRepository: FakeCatalogRepository()), ); await tester.pumpAndSettle(); - await tester.tap(find.text('Discover')); + await tester.tap(find.text('Home')); await tester.pumpAndSettle(); - expect(find.text('Trending Micro-Dramas'), findsOneWidget); - expect(find.text('Filter'), findsOneWidget); - expect(find.text('Top Charts'), findsOneWidget); - expect(find.text('New Releases'), findsOneWidget); - expect(find.text('Watchlist'), findsOneWidget); - expect(find.text('Same demo clip · free'), findsNWidgets(3)); - expect(find.text('Video pending'), findsOneWidget); + expect(find.text('For You'), findsOneWidget); + expect(find.text('Continue Watching'), findsOneWidget); + expect(find.text('Rewards'), findsOneWidget); + expect(find.text(r'$ 0'), findsOneWidget); + expect(find.text('Urban Romance', skipOffstage: false), findsOneWidget); + expect( + find.text('Action · Thriller', skipOffstage: false), + findsOneWidget, + ); + expect(find.byTooltip('Search'), findsNothing); expect(tester.takeException(), isNull); - await tester.enterText(find.byType(TextField), 'Vengeance'); - await tester.pumpAndSettle(); - expect(find.text('Vengeance Rising'), findsOneWidget); - expect(find.text('Same demo clip · free'), findsOneWidget); - - await tester.tap(find.text('Watchlist')); + await tester.tap(find.byKey(const Key('tab-my-list'))); await tester.pumpAndSettle(); expect(find.text('No shows here yet.'), findsOneWidget); - await tester.tap(find.text('Home').last); + await tester.tap(find.text('Shorts')); await tester.pumpAndSettle(); - expect(find.text('Recommended'), findsOneWidget); + expect(find.text('The Signal'), findsOneWidget); }, ); - testWidgets('bottom tabs stay on one route and preserve Discover search', ( - tester, - ) async { + testWidgets('bottom tabs stay on one route', (tester) async { tester.view.physicalSize = const Size(390, 844); tester.view.devicePixelRatio = 1; addTearDown(tester.view.resetPhysicalSize); addTearDown(tester.view.resetDevicePixelRatio); await tester.pumpWidget( - const LumaDramaApp(playerFactory: createWidgetPlayer), + LumaDramaApp(playerFactory: createWidgetPlayer, catalogRepository: FakeCatalogRepository()), ); await tester.pumpAndSettle(); - await tester.tap(find.text('Discover')); + await tester.tap(find.text('Home')); await tester.pumpAndSettle(); - await tester.enterText(find.byType(TextField), 'Vengeance'); - await tester.pumpAndSettle(); - expect(find.text('Vengeance Rising'), findsOneWidget); + expect(find.text('Continue Watching'), findsOneWidget); + expect(find.byTooltip('Search'), findsNothing); expect( - Navigator.of(tester.element(find.byType(TextField))).canPop(), + Navigator.of(tester.element(find.text('Continue Watching'))).canPop(), isFalse, ); - await tester.tap(find.byKey(const Key('tab-my'))); + await tester.tap(find.byKey(const Key('tab-my-list'))); await tester.pumpAndSettle(); expect(find.text('History'), findsOneWidget); expect( @@ -290,20 +308,20 @@ void main() { await tester.tap(find.byKey(const Key('tab-discover'))); await tester.pumpAndSettle(); - expect(find.widgetWithText(TextField, 'Vengeance'), findsOneWidget); - expect(find.text('Vengeance Rising'), findsOneWidget); + expect(find.text('Continue Watching'), findsOneWidget); + expect(find.byTooltip('Search'), findsNothing); expect( - Navigator.of(tester.element(find.byType(TextField))).canPop(), + Navigator.of(tester.element(find.text('Continue Watching'))).canPop(), isFalse, ); - await tester.tap(find.byKey(const Key('tab-my'))); + await tester.tap(find.byKey(const Key('tab-my-list'))); await tester.pumpAndSettle(); expect(find.text('No shows here yet.'), findsOneWidget); await tester.tap(find.byKey(const Key('tab-home'))); await tester.pumpAndSettle(); - expect(find.text('Recommended'), findsOneWidget); + expect(find.text('The Signal'), findsOneWidget); expect( - Navigator.of(tester.element(find.text('Recommended'))).canPop(), + Navigator.of(tester.element(find.text('The Signal'))).canPop(), isFalse, ); }); @@ -317,9 +335,11 @@ void main() { addTearDown(tester.view.resetDevicePixelRatio); await tester.pumpWidget( - const LumaDramaApp(playerFactory: createWidgetPlayer), + LumaDramaApp(playerFactory: createWidgetPlayer, catalogRepository: FakeCatalogRepository()), ); await tester.pumpAndSettle(); + await tester.tap(find.byKey(const Key('tab-home'))); + await tester.pumpAndSettle(); expect(find.text('The Signal'), findsOneWidget); await tester.drag(find.byType(PageView), const Offset(0, -550)); @@ -327,66 +347,38 @@ void main() { expect(find.text('City Lights & Velvet Nights'), findsOneWidget); expect(find.textContaining('Episode 1'), findsOneWidget); - await tester.tap(find.byTooltip('Explore series')); + await tester.tap(find.byKey(const Key('tab-discover'))); await tester.pumpAndSettle(); - expect(find.text('City Lights & Velvet Nights'), findsOneWidget); - await tester.tap(find.text('Watch episode 1')); + await tester.tap(find.text('City Lights & Velvet Nights')); await tester.pumpAndSettle(); expect(find.byType(Slider), findsOneWidget); await tester.drag(find.byType(PageView), const Offset(0, -550)); await tester.pumpAndSettle(); - expect(find.textContaining('EPISODE 2 / 3'), findsOneWidget); + expect(find.text('Episode 2 · Playing now'), findsOneWidget); expect(find.text('City Lights & Velvet Nights'), findsWidgets); }, ); - testWidgets('home categories switch by video, top row and tap', ( - tester, - ) async { + testWidgets('shorts page has no category navigation', (tester) async { tester.view.physicalSize = const Size(390, 844); tester.view.devicePixelRatio = 1; addTearDown(tester.view.resetPhysicalSize); addTearDown(tester.view.resetDevicePixelRatio); await tester.pumpWidget( - const LumaDramaApp(playerFactory: createWidgetPlayer), + LumaDramaApp(playerFactory: createWidgetPlayer, catalogRepository: FakeCatalogRepository()), ); await tester.pumpAndSettle(); - expect(find.byIcon(Icons.tune_rounded), findsNothing); + await tester.tap(find.byKey(const Key('tab-home'))); + await tester.pumpAndSettle(); + expect(find.text('Following'), findsNothing); + expect(find.text('Animated'), findsNothing); + expect(find.text('Live Action'), findsNothing); + expect(find.text('Recommended'), findsNothing); expect(find.text('The Signal'), findsOneWidget); - - await tester.drag( - find.byKey(const Key('home-video-swipe')), - const Offset(220, 0), - ); - await tester.pumpAndSettle(); - expect(find.text('City Lights & Velvet Nights'), findsOneWidget); - expect(find.byKey(const Key('home-category-liveAction')), findsOneWidget); - await tester.drag(find.byType(PageView), const Offset(0, -550)); await tester.pumpAndSettle(); - expect(find.text('Vengeance Rising'), findsOneWidget); - - await tester.drag( - find.byKey(const Key('home-category-swipe')), - const Offset(190, 0), - ); - await tester.pumpAndSettle(); - expect(find.text('The Signal'), findsOneWidget); - - await tester.drag( - find.byKey(const Key('home-category-swipe')), - const Offset(-190, 0), - ); - await tester.pumpAndSettle(); expect(find.text('City Lights & Velvet Nights'), findsOneWidget); - - await tester.tap(find.byKey(const Key('home-category-following'))); - await tester.pumpAndSettle(); - expect(find.text('No dramas in this category yet.'), findsOneWidget); - await tester.tap(find.byKey(const Key('home-category-recommended'))); - await tester.pumpAndSettle(); - expect(find.text('The Signal'), findsOneWidget); expect(tester.takeException(), isNull); }); testWidgets('right rail saves, comments, likes and invokes share in order', ( @@ -412,13 +404,15 @@ void main() { ); await tester.pumpWidget( - const LumaDramaApp(playerFactory: createWidgetPlayer), + LumaDramaApp(playerFactory: createWidgetPlayer, catalogRepository: FakeCatalogRepository()), ); await tester.pumpAndSettle(); + await tester.tap(find.byKey(const Key('tab-home'))); + await tester.pumpAndSettle(); final keys = [ + const Key('rail-like'), const Key('rail-save'), const Key('rail-comments'), - const Key('rail-like'), const Key('rail-share'), ]; final tops = keys @@ -426,9 +420,9 @@ void main() { .toList(); expect(tops, orderedEquals(tops.toList()..sort())); - await tester.tap(find.byKey(keys[0])); + await tester.tap(find.byKey(const Key('rail-save'))); await tester.pumpAndSettle(); - await tester.tap(find.byKey(keys[1])); + await tester.tap(find.byKey(const Key('rail-comments'))); await tester.pumpAndSettle(); expect(find.text('Only visible on this device'), findsOneWidget); await tester.enterText(find.byKey(const Key('comment-input')), 'Nice demo'); @@ -438,75 +432,38 @@ void main() { await tester.binding.handlePopRoute(); await tester.pumpAndSettle(); - await tester.tap(find.byKey(keys[2])); - await tester.tap(find.byKey(keys[3])); + await tester.tap(find.byKey(const Key('rail-like'))); + await tester.tap(find.byKey(const Key('rail-share'))); await tester.pumpAndSettle(); expect(sharedText, contains('The Signal')); expect(tester.takeException(), isNull); }); - testWidgets( - 'right swipe from leftmost category opens drawer and root stays', - (tester) async { - tester.view.physicalSize = const Size(390, 844); - tester.view.devicePixelRatio = 1; - addTearDown(tester.view.resetPhysicalSize); - addTearDown(tester.view.resetDevicePixelRatio); - await tester.pumpWidget( - const LumaDramaApp(playerFactory: createWidgetPlayer), - ); - await tester.pumpAndSettle(); - - for (var i = 0; i < 3; i++) { - await tester.drag( - find.byKey(const Key('home-category-swipe')), - const Offset(200, 0), - ); - await tester.pumpAndSettle(); - } - expect(find.text('No dramas in this category yet.'), findsOneWidget); - await tester.drag( - find.byKey(const Key('home-empty-swipe')), - const Offset(200, 0), - ); - await tester.pumpAndSettle(); - expect(find.text('Quick access'), findsOneWidget); - await tester.drag(find.byType(Drawer), const Offset(150, 0)); - await tester.pumpAndSettle(); - expect(find.text('Quick access'), findsOneWidget); - await tester.binding.handlePopRoute(); - await tester.pumpAndSettle(); - await tester.binding.handlePopRoute(); - await tester.pumpAndSettle(); - expect(find.byKey(const Key('home-tabs-bar')), findsOneWidget); - }, - ); - - testWidgets('system back steps categories then opens drawer without exit', ( - tester, - ) async { + testWidgets('system back opens the drawer and stays on home', (tester) async { tester.view.physicalSize = const Size(390, 844); tester.view.devicePixelRatio = 1; addTearDown(tester.view.resetPhysicalSize); addTearDown(tester.view.resetDevicePixelRatio); await tester.pumpWidget( - const LumaDramaApp(playerFactory: createWidgetPlayer), + LumaDramaApp(playerFactory: createWidgetPlayer, catalogRepository: FakeCatalogRepository()), ); await tester.pumpAndSettle(); - await tester.binding.handlePopRoute(); - await tester.pumpAndSettle(); - expect(find.text('City Lights & Velvet Nights'), findsOneWidget); - await tester.binding.handlePopRoute(); - await tester.pumpAndSettle(); - expect(find.text('The Signal'), findsOneWidget); - await tester.binding.handlePopRoute(); - await tester.pumpAndSettle(); - expect(find.text('No dramas in this category yet.'), findsOneWidget); + expect(find.text('Continue Watching'), findsOneWidget); await tester.binding.handlePopRoute(); await tester.pumpAndSettle(); expect(find.text('Quick access'), findsOneWidget); expect(find.byKey(const Key('home-tabs-bar')), findsOneWidget); + await tester.binding.handlePopRoute(); + await tester.pumpAndSettle(); + expect(find.text('Quick access'), findsNothing); + expect(find.text('Continue Watching'), findsOneWidget); + expect( + Navigator.of( + tester.element(find.byKey(const Key('home-tabs-bar'))), + ).canPop(), + isFalse, + ); }); testWidgets('My watchlist lists saved dramas across the home feed', ( @@ -517,9 +474,11 @@ void main() { addTearDown(tester.view.resetPhysicalSize); addTearDown(tester.view.resetDevicePixelRatio); await tester.pumpWidget( - const LumaDramaApp(playerFactory: createWidgetPlayer), + LumaDramaApp(playerFactory: createWidgetPlayer, catalogRepository: FakeCatalogRepository()), ); await tester.pumpAndSettle(); + await tester.tap(find.byKey(const Key('tab-home'))); + await tester.pumpAndSettle(); await tester.tap(find.byKey(const Key('rail-save'))); await tester.pumpAndSettle(); @@ -527,7 +486,7 @@ void main() { await tester.pumpAndSettle(); await tester.tap(find.byKey(const Key('rail-save'))); await tester.pumpAndSettle(); - await tester.tap(find.byKey(const Key('tab-my'))); + await tester.tap(find.byKey(const Key('tab-my-list'))); await tester.pumpAndSettle(); await tester.tap(find.text('Watchlist')); await tester.pumpAndSettle(); -- 2.54.0 From feecc349a09c11c5420c02e1462136e008fb6cb7 Mon Sep 17 00:00:00 2001 From: Vicky <10212746+haifeng-jiang@user.noreply.gitee.com> Date: Thu, 15 Oct 2026 17:53:45 +0800 Subject: [PATCH 03/76] =?UTF-8?q?chore(client):=20=E5=BD=92=E6=A1=A3?= =?UTF-8?q?=E5=8E=9F=E5=9E=8B=E9=98=B6=E6=AE=B5=E6=96=B0=E5=A2=9E=E6=96=87?= =?UTF-8?q?=E4=BB=B6=EF=BC=88=E9=85=8D=E7=BD=AE=E3=80=81=E4=B8=BB=E9=A2=98?= =?UTF-8?q?=E3=80=81=E6=A8=A1=E5=9E=8B=E4=B8=8E=E6=B5=8B=E8=AF=95=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 为什么:上一批归档只覆盖了「已跟踪文件的修改」,原型阶段新增的文件(app_config、theme、 home_feed/play_ticket 模型、catalog_api、测试目录等)还是未入库状态 —— 而已入库的代码会 import 它们, 留在工作区会导致 HEAD 处的代码编译不过。一并归档,让 HEAD 自洽。 纯归档,无行为改动。 --- lib/core/config/app_config.dart | 50 ++ lib/core/data/models/home_feed.dart | 86 ++++ lib/core/data/models/play_ticket.dart | 37 ++ lib/core/data/remote/catalog_api.dart | 36 ++ lib/core/theme/app_colors.dart | 11 + lib/core/widgets/remote_image.dart | 44 ++ test/catalog/drama_model_test.dart | 60 +++ test/config/locale_controller_test.dart | 92 ++++ .../core/android_picture_in_picture_test.dart | 132 +++++ test/discover/cover_carousel_test.dart | 51 ++ test/discover/discover_logic_test.dart | 346 +++++++++++++ .../drama_detail/drama_detail_logic_test.dart | 98 ++++ .../engagement_repository_test.dart | 135 +++++ test/formatting/localized_content_test.dart | 96 ++++ test/integration/live_catalog_test.dart | 76 +++ test/mine/mine_logic_test.dart | 256 ++++++++++ test/player/player_logic_test.dart | 479 ++++++++++++++++++ test/support/fake_catalog.dart | 81 +++ test/support/fake_watch_history.dart | 44 ++ 19 files changed, 2210 insertions(+) create mode 100644 lib/core/config/app_config.dart create mode 100644 lib/core/data/models/home_feed.dart create mode 100644 lib/core/data/models/play_ticket.dart create mode 100644 lib/core/data/remote/catalog_api.dart create mode 100644 lib/core/theme/app_colors.dart create mode 100644 lib/core/widgets/remote_image.dart create mode 100644 test/catalog/drama_model_test.dart create mode 100644 test/config/locale_controller_test.dart create mode 100644 test/core/android_picture_in_picture_test.dart create mode 100644 test/discover/cover_carousel_test.dart create mode 100644 test/discover/discover_logic_test.dart create mode 100644 test/drama_detail/drama_detail_logic_test.dart create mode 100644 test/engagement/engagement_repository_test.dart create mode 100644 test/formatting/localized_content_test.dart create mode 100644 test/integration/live_catalog_test.dart create mode 100644 test/mine/mine_logic_test.dart create mode 100644 test/player/player_logic_test.dart create mode 100644 test/support/fake_catalog.dart create mode 100644 test/support/fake_watch_history.dart diff --git a/lib/core/config/app_config.dart b/lib/core/config/app_config.dart new file mode 100644 index 0000000..a989a8b --- /dev/null +++ b/lib/core/config/app_config.dart @@ -0,0 +1,50 @@ +import 'dart:io'; + +import 'package:flutter/foundation.dart'; + +/// 客户端与后端约定的运行时配置。 +/// +/// 接口地址的优先级:`--dart-define=API_BASE_URL=...` > 按运行环境判断的默认值。 +/// 开发机的局域网地址会随网络变化,换网络后改 [devHostBaseUrl] 即可。 +class AppConfig { + const AppConfig._(); + + /// 开发机的局域网地址。真机上的 `127.0.0.1` 指向手机自己,只能走这个地址。 + /// + /// 这个地址跟着电脑所在的网络走,换网络后要用 + /// `ipconfig getifaddr en0` 重新确认并改这里; + /// 也可以换成 Bonjour 名字 `http://.local:8081`(本机是 + /// `jiangdeMacBook-Air.local`),换网络不用改,但部分办公网会拦组播解析。 + static const String devHostBaseUrl = + 'http://jiangdeMacBook-Air.local:8081'; + + static const String _loopbackBaseUrl = 'http://127.0.0.1:8081'; + + static const String _overrideBaseUrl = String.fromEnvironment('API_BASE_URL'); + + static String get apiBaseUrl => + _overrideBaseUrl.isNotEmpty ? _overrideBaseUrl : _defaultBaseUrl; + + static final String _defaultBaseUrl = + _runsOnDevMachine ? _loopbackBaseUrl : devHostBaseUrl; + + /// 模拟器、桌面端与开发机同机,环回地址可用;iOS 真机不满足。 + /// Android 没有等价的探测方式,统一按真机处理(模拟器用 + /// `--dart-define=API_BASE_URL=http://10.0.2.2:8081` 覆盖)。 + static final bool _runsOnDevMachine = + kIsWeb || + defaultTargetPlatform == TargetPlatform.macOS || + defaultTargetPlatform == TargetPlatform.windows || + defaultTargetPlatform == TargetPlatform.linux || + (defaultTargetPlatform == TargetPlatform.iOS && + Platform.environment.containsKey('SIMULATOR_DEVICE_NAME')); + + static const Duration requestTimeout = Duration(seconds: 8); + + /// 后端返回的是相对路径(/files/...),这里补上服务地址。 + static String mediaUrl(String path) { + if (path.isEmpty) return ''; + if (path.startsWith('http://') || path.startsWith('https://')) return path; + return '$apiBaseUrl$path'; + } +} diff --git a/lib/core/data/models/home_feed.dart b/lib/core/data/models/home_feed.dart new file mode 100644 index 0000000..f16f468 --- /dev/null +++ b/lib/core/data/models/home_feed.dart @@ -0,0 +1,86 @@ +import 'drama.dart'; + +/// 首页/发现页聚合数据,一次请求拿到轮播与分区。 +class HomeFeed { + const HomeFeed({this.banners = const [], this.sections = const []}); + + final List banners; + final List sections; + + bool get isEmpty => sections.every((section) => section.dramas.isEmpty); + + /// 分区打平后的短剧列表,供现有 UI 的横滑/竖滑复用;按 id 去重。 + List get dramas { + final seen = {}; + final result = []; + for (final section in sections) { + for (final drama in section.dramas) { + if (seen.add(drama.id)) result.add(drama); + } + } + return result; + } + + factory HomeFeed.fromJson(Map json) { + final banners = (json['banners'] as List? ?? const []) + .whereType>() + .map(FeedBanner.fromJson) + .toList(); + final sections = (json['sections'] as List? ?? const []) + .whereType>() + .map(FeedSection.fromJson) + .toList(); + return HomeFeed(banners: banners, sections: sections); + } +} + +class FeedSection { + const FeedSection({ + required this.code, + required this.title, + this.dramas = const [], + }); + + final String code; + final String title; + final List dramas; + + factory FeedSection.fromJson(Map json) { + return FeedSection( + code: json['code'] as String? ?? '', + title: json['title'] as String? ?? '', + dramas: (json['dramas'] as List? ?? const []) + .whereType>() + .map(Drama.fromCardJson) + .toList(), + ); + } +} + +class FeedBanner { + const FeedBanner({ + required this.id, + required this.imageUrl, + this.linkType = 'NONE', + this.linkValue = '', + }); + + final String id; + final String imageUrl; + final String linkType; + final String linkValue; + + /// 点击轮播要打开的短剧 id,非短剧跳转返回 null。 + String? get dramaId => linkType == 'DRAMA' && linkValue.isNotEmpty + ? linkValue + : null; + + factory FeedBanner.fromJson(Map json) { + return FeedBanner( + id: (json['id'] ?? '').toString(), + imageUrl: json['imageUrl'] as String? ?? '', + linkType: json['linkType'] as String? ?? 'NONE', + linkValue: json['linkValue'] as String? ?? '', + ); + } +} diff --git a/lib/core/data/models/play_ticket.dart b/lib/core/data/models/play_ticket.dart new file mode 100644 index 0000000..b09aab7 --- /dev/null +++ b/lib/core/data/models/play_ticket.dart @@ -0,0 +1,37 @@ +/// 播放票据:客户端据此决定直接播放、提示解锁还是提示暂无片源。 +class PlayTicket { + const PlayTicket({ + required this.episodeId, + required this.accessible, + required this.accessType, + this.playUrl = '', + this.durationSec = 0, + this.unlockCoin = 0, + }); + + static const String free = 'FREE'; + static const String coinRequired = 'COIN_REQUIRED'; + static const String vipRequired = 'VIP_REQUIRED'; + static const String noMedia = 'NO_MEDIA'; + + final String episodeId; + final bool accessible; + final String accessType; + final String playUrl; + final int durationSec; + final int unlockCoin; + + bool get needsUnlock => + accessType == coinRequired || accessType == vipRequired; + + factory PlayTicket.fromJson(Map json) { + return PlayTicket( + episodeId: (json['episodeId'] ?? '').toString(), + accessible: json['accessible'] == true, + accessType: json['accessType'] as String? ?? noMedia, + playUrl: json['playUrl'] as String? ?? '', + durationSec: (json['durationSec'] as num?)?.toInt() ?? 0, + unlockCoin: (json['unlockCoin'] as num?)?.toInt() ?? 0, + ); + } +} diff --git a/lib/core/data/remote/catalog_api.dart b/lib/core/data/remote/catalog_api.dart new file mode 100644 index 0000000..54352b4 --- /dev/null +++ b/lib/core/data/remote/catalog_api.dart @@ -0,0 +1,36 @@ +import '../models/drama.dart'; +import '../models/home_feed.dart'; +import '../models/play_ticket.dart'; +import 'api_client.dart'; + +/// 客户端目录接口,对应后端 `/app/**`。 +class CatalogApi { + const CatalogApi(this._client); + + final ApiClient _client; + + Future homeFeed() async { + return HomeFeed.fromJson(_asMap(await _client.get('/app/home/feed'))); + } + + Future discoverFeed() async { + return HomeFeed.fromJson(_asMap(await _client.get('/app/discover/feed'))); + } + + Future dramaDetail(String dramaId) async { + return Drama.fromDetailJson( + _asMap(await _client.get('/app/dramas/$dramaId')), + ); + } + + Future playTicket(String episodeId) async { + return PlayTicket.fromJson( + _asMap(await _client.get('/app/episodes/$episodeId/play')), + ); + } + + Map _asMap(Object? data) { + if (data is Map) return data; + throw const ApiException(-1, '返回数据格式异常'); + } +} diff --git a/lib/core/theme/app_colors.dart b/lib/core/theme/app_colors.dart new file mode 100644 index 0000000..56de8ad --- /dev/null +++ b/lib/core/theme/app_colors.dart @@ -0,0 +1,11 @@ +import 'package:flutter/material.dart'; + +/// Shared colors. Blue is the primary action color. +abstract final class AppColors { + static const blue = Color(0xFF2F7BFF); + static const blueSoft = Color(0xFF8FB4FF); + static const ink = Color(0xFF0B0C10); + static const bar = Color(0xFF101114); + static const card = Color(0xFF17191F); + static const muted = Color(0xFFB7BDC9); +} diff --git a/lib/core/widgets/remote_image.dart b/lib/core/widgets/remote_image.dart new file mode 100644 index 0000000..48e0117 --- /dev/null +++ b/lib/core/widgets/remote_image.dart @@ -0,0 +1,44 @@ +import 'package:flutter/material.dart'; + +import '../config/app_config.dart'; + +/// 封面图统一入口:后端给的是相对路径,这里补服务地址并处理加载失败。 +class RemoteImage extends StatelessWidget { + const RemoteImage( + this.path, { + super.key, + this.width, + this.height, + this.fit = BoxFit.cover, + }); + + final String path; + final double? width; + final double? height; + final BoxFit fit; + + @override + Widget build(BuildContext context) { + final url = AppConfig.mediaUrl(path); + if (url.isEmpty) return _fallback(); + return Image.network( + url, + width: width, + height: height, + fit: fit, + errorBuilder: (_, _, _) => _fallback(), + frameBuilder: (context, child, frame, wasSynchronouslyLoaded) { + if (wasSynchronouslyLoaded || frame != null) return child; + return _fallback(); + }, + ); + } + + Widget _fallback() { + return Container( + width: width, + height: height, + color: const Color(0xFF1C1F26), + ); + } +} diff --git a/test/catalog/drama_model_test.dart b/test/catalog/drama_model_test.dart new file mode 100644 index 0000000..6fb9778 --- /dev/null +++ b/test/catalog/drama_model_test.dart @@ -0,0 +1,60 @@ +import 'package:flutter_test/flutter_test.dart'; +import 'package:nontonki/core/data/models/drama.dart'; + +void main() { + test('a list card carries one playable preview and the total count', () { + final drama = Drama.fromCardJson(const { + 'id': 5, + 'title': '闪婚后', + 'synopsis': 'synopsis', + 'cover': '/files/cover.jpg', + 'category': '都市情感', + 'genre': '都市情感', + 'totalEpisodes': 77, + 'isHot': true, + 'viewCount': 3100000, + 'preview': { + 'id': 9, + 'number': 1, + 'title': '第 1 集', + 'isFree': true, + 'playUrl': '/files/episode/9.mp4', + }, + }); + + expect(drama.detailLoaded, isFalse); + expect(drama.episodes, hasLength(1)); + expect(drama.episodes.single.videoUrl, '/files/episode/9.mp4'); + expect(drama.episodeCount, 77); + expect(drama.isHot, isTrue); + }); + + test('a list card without a playable preview has no episodes', () { + final drama = Drama.fromCardJson(const { + 'id': 6, + 'title': '替嫁新娘', + 'totalEpisodes': 12, + }); + + expect(drama.episodes, isEmpty); + expect(drama.episodeCount, 12); + }); + + test('a detail response counts the episodes it ships', () { + final drama = Drama.fromDetailJson(const { + 'id': 5, + 'title': '闪婚后', + 'synopsis': 'synopsis', + 'cover': '/files/cover.jpg', + 'totalEpisodes': 77, + 'episodes': [ + {'id': 9, 'number': 1, 'title': '第 1 集', 'isFree': true}, + {'id': 10, 'number': 2, 'title': '第 2 集', 'isFree': false}, + ], + }); + + expect(drama.detailLoaded, isTrue); + expect(drama.episodeCount, 77); + expect(drama.episodes.first.id, '9'); + }); +} diff --git a/test/config/locale_controller_test.dart b/test/config/locale_controller_test.dart new file mode 100644 index 0000000..7ca480b --- /dev/null +++ b/test/config/locale_controller_test.dart @@ -0,0 +1,92 @@ +import 'package:flutter/widgets.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:nontonki/core/config/locale_controller.dart'; +import 'package:shared_preferences/shared_preferences.dart'; +import 'package:shared_preferences_platform_interface/in_memory_shared_preferences_async.dart'; +import 'package:shared_preferences_platform_interface/shared_preferences_async_platform_interface.dart'; + +void main() { + setUp(() { + SharedPreferencesAsyncPlatform.instance = + InMemorySharedPreferencesAsync.empty(); + }); + + test('no stored choice keeps the device locale', () async { + final controller = LocaleController(); + var notifications = 0; + controller.addListener(() => notifications++); + + await controller.load(); + + expect(controller.locale, isNull); + expect(notifications, 1); + }); + + test('a chosen language survives a restart', () async { + final first = LocaleController(); + await first.select('zh'); + expect(first.locale, const Locale('zh')); + + final reopened = LocaleController(); + await reopened.load(); + expect(reopened.locale, const Locale('zh')); + }); + + test('selecting english clears a stored chinese preference', () async { + await LocaleController().select('zh'); + + final reopened = LocaleController(); + await reopened.load(); + await reopened.select('en'); + + final third = LocaleController(); + await third.load(); + expect(third.locale, const Locale('en')); + }); + + test('an unsupported code clears the locale instead of throwing', () async { + final controller = LocaleController(); + await controller.select('zh'); + expect(controller.locale, const Locale('zh')); + + await controller.select('tlh'); + + expect(controller.locale, isNull); + }); + + test('an unsupported stored code resolves to the device locale', () async { + await SharedPreferencesAsync().setString('ui.locale', 'fr'); + + final controller = LocaleController(); + await controller.load(); + + expect(controller.locale, isNull); + }); + + test('a broken preference store never breaks load or select', () async { + SharedPreferencesAsyncPlatform.instance = _BrokenPreferences(); + final controller = LocaleController(); + + await controller.load(); + expect(controller.locale, isNull); + + await controller.select('zh'); + expect(controller.locale, const Locale('zh')); + }); +} + +/// Stands in for a platform whose preference store is unavailable. +base class _BrokenPreferences extends InMemorySharedPreferencesAsync { + _BrokenPreferences() : super.empty(); + + @override + Future getString(String key, SharedPreferencesOptions options) => + Future.error(StateError('preferences unavailable')); + + @override + Future setString( + String key, + String value, + SharedPreferencesOptions options, + ) => Future.error(StateError('preferences unavailable')); +} diff --git a/test/core/android_picture_in_picture_test.dart b/test/core/android_picture_in_picture_test.dart new file mode 100644 index 0000000..99d28cf --- /dev/null +++ b/test/core/android_picture_in_picture_test.dart @@ -0,0 +1,132 @@ +import 'package:flutter/foundation.dart'; +import 'package:flutter/services.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:nontonki/core/data/services/android_picture_in_picture.dart'; + +void main() { + TestWidgetsFlutterBinding.ensureInitialized(); + + const channel = MethodChannel('test/pip_channel'); + final messenger = + TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger; + + AndroidPictureInPicture pip() => AndroidPictureInPicture(channel: channel); + + /// Simulates a native call arriving on the channel. + Future sendToDart(String method, Object? arguments) => messenger + .handlePlatformMessage( + channel.name, + const StandardMethodCodec().encodeMethodCall( + MethodCall(method, arguments), + ), + (_) {}, + ); + + tearDown(() { + debugDefaultTargetPlatformOverride = null; + channel.setMethodCallHandler(null); + }); + + group('platform support', () { + test('android is the only supported target', () { + debugDefaultTargetPlatformOverride = TargetPlatform.android; + expect(pip().isPlatformSupported, isTrue); + + for (final platform in [ + TargetPlatform.iOS, + TargetPlatform.macOS, + TargetPlatform.linux, + TargetPlatform.windows, + TargetPlatform.fuchsia, + ]) { + debugDefaultTargetPlatformOverride = platform; + expect( + pip().isPlatformSupported, + isFalse, + reason: '$platform must not claim picture in picture support', + ); + } + }); + }); + + group('enter', () { + test('is refused without touching the channel off android', () async { + debugDefaultTargetPlatformOverride = TargetPlatform.iOS; + final calls = []; + messenger.setMockMethodCallHandler(channel, (call) async { + calls.add(call); + return true; + }); + addTearDown(() => messenger.setMockMethodCallHandler(channel, null)); + + expect(await pip().enter(), isFalse); + expect(calls, isEmpty); + }); + + test('a missing native answer counts as a refusal', () async { + debugDefaultTargetPlatformOverride = TargetPlatform.android; + messenger.setMockMethodCallHandler(channel, (call) async => null); + addTearDown(() => messenger.setMockMethodCallHandler(channel, null)); + + expect(await pip().enter(), isFalse); + }); + + test('a native success is reported as entered', () async { + debugDefaultTargetPlatformOverride = TargetPlatform.android; + final calls = []; + messenger.setMockMethodCallHandler(channel, (call) async { + calls.add(call); + return true; + }); + addTearDown(() => messenger.setMockMethodCallHandler(channel, null)); + + expect(await pip().enter(), isTrue); + expect(calls.single.method, 'enter'); + expect(calls.single.arguments, isNull); + }); + }); + + group('state listener', () { + test('pip state changes reach the listener in order', () async { + final received = []; + pip().setStateListener(received.add); + + await sendToDart('onPipChanged', true); + await sendToDart('onPipChanged', false); + + expect(received, [true, false]); + }); + + test('only a literal true is read as enabled', () async { + final received = []; + pip().setStateListener(received.add); + + await sendToDart('onPipChanged', null); + await sendToDart('onPipChanged', 'yes'); + await sendToDart('onPipChanged', 1); + + expect(received, [false, false, false]); + }); + + test('unrelated native methods are ignored', () async { + final received = []; + pip().setStateListener(received.add); + + await sendToDart('somethingElse', true); + await sendToDart('onPipChanged', true); + + expect(received, [true]); + }); + + test('clearing the listener silences later callbacks', () async { + final received = []; + final observer = pip()..setStateListener(received.add); + await sendToDart('onPipChanged', true); + + observer.setStateListener(null); + await sendToDart('onPipChanged', true); + + expect(received, [true]); + }); + }); +} diff --git a/test/discover/cover_carousel_test.dart b/test/discover/cover_carousel_test.dart new file mode 100644 index 0000000..28e60e8 --- /dev/null +++ b/test/discover/cover_carousel_test.dart @@ -0,0 +1,51 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:nontonki/pages/discover/widgets/cover_carousel.dart'; + +void main() { + TestWidgetsFlutterBinding.ensureInitialized(); + + testWidgets('the cube turns and keeps the title on the poster', (tester) async { + await tester.pumpWidget( + MaterialApp( + home: Scaffold( + body: CoverCarousel( + items: [ + for (final title in ['The Signal', 'City Lights', 'Vengeance']) + CoverItem( + title: title, + subtitle: 'Mock', + image: '/files/poster.png', + onOpen: _noop, + ), + ], + ), + ), + ), + ); + await tester.pump(); + + expect(find.text('The Signal'), findsOneWidget); + expect(find.text('Mock'), findsOneWidget); + + final box = tester.getRect(find.byType(CoverCarousel)); + final gesture = await tester.startGesture(Offset(box.right - 40, box.center.dy)); + await gesture.moveBy(const Offset(-500, 0)); + await tester.pump(); + + final turned = tester.widgetList(find.byType(Transform)).any( + (transform) => (transform.transform.entry(0, 0) - 1).abs() > 0.15, + ); + expect(turned, isTrue); + + await gesture.moveBy(const Offset(-200, 0)); + await gesture.up(); + await tester.pump(); + await tester.pump(const Duration(milliseconds: 450)); + + expect(find.text('City Lights'), findsOneWidget); + expect(tester.takeException(), isNull); + }); +} + +void _noop() {} diff --git a/test/discover/discover_logic_test.dart b/test/discover/discover_logic_test.dart new file mode 100644 index 0000000..671f76c --- /dev/null +++ b/test/discover/discover_logic_test.dart @@ -0,0 +1,346 @@ +import 'dart:async'; + +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:nontonki/core/data/models/drama.dart'; +import 'package:nontonki/l10n/app_localizations.dart'; +import 'package:nontonki/pages/discover/discover_logic.dart'; + +import '../support/fake_watch_history.dart'; + +Drama _drama(String id, {List numbers = const [1, 2, 3]}) => Drama( + id: id, + title: id, + synopsis: 'synopsis', + posterUrl: '/files/poster.png', + episodes: [ + for (final number in numbers) + Episode( + id: '$id-$number', + number: number, + title: 'Episode $number', + videoUrl: 'https://example.test/clip.mp4', + isFree: true, + ), + ], +); + +void main() { + TestWidgetsFlutterBinding.ensureInitialized(); + + test('the constructor resolves the resume position of episode one', () async { + final history = FakeWatchHistory()..saved = const Duration(seconds: 4); + final logic = DiscoverLogic(history: history, drama: _drama('signal')); + + expect(await logic.position, const Duration(seconds: 4)); + expect(history.reads, ['demo-local-v1|signal|signal-1']); + expect(logic.category, 0); + expect(logic.searchOpen, isFalse); + logic.dispose(); + }); + + test('refreshPosition re-reads after the drama is swapped', () async { + final history = FakeWatchHistory(); + final logic = DiscoverLogic(history: history, drama: _drama('signal')); + + logic.drama = _drama('city'); + logic.refreshPosition(); + await logic.position; + + expect(history.reads, [ + 'demo-local-v1|signal|signal-1', + 'demo-local-v1|city|city-1', + ]); + logic.dispose(); + }); + + test('a list card without episodes resumes from the last watch', () async { + final history = FakeWatchHistory() + ..saved = const Duration(seconds: 9) + ..lastEpisode = 'signal-2'; + final logic = DiscoverLogic( + history: history, + drama: _drama('signal', numbers: const []), + ); + + expect(await logic.position, const Duration(seconds: 9)); + expect(history.reads, ['demo-local-v1|signal|signal-2']); + logic.dispose(); + }); + + test('a list card without history has no resume position', () async { + final history = FakeWatchHistory(); + final logic = DiscoverLogic( + history: history, + drama: _drama('signal', numbers: const []), + ); + + expect(await logic.position, isNull); + expect(history.reads, isEmpty); + logic.dispose(); + }); + + test('selectCategory stores the index and notifies once', () { + final logic = DiscoverLogic(history: FakeWatchHistory(), drama: _drama('s')); + var notifications = 0; + logic.addListener(() => notifications++); + + logic.selectCategory(3); + + expect(logic.category, 3); + expect(notifications, 1); + logic.dispose(); + }); + + test('search visibility follows the flag or the typed text', () { + final logic = DiscoverLogic(history: FakeWatchHistory(), drama: _drama('s')); + + expect(logic.showSearch, isFalse); + + logic.search.text = 'vengeance'; + logic.onSearchChanged(); + expect(logic.showSearch, isTrue); + + logic.search.clear(); + expect(logic.showSearch, isFalse); + + logic.searchOpen = true; + expect(logic.showSearch, isTrue); + logic.dispose(); + }); + + test('dramaFor matches by id and tolerates a missing id', () { + final logic = DiscoverLogic(history: FakeWatchHistory(), drama: _drama('s')); + final catalog = [_drama('signal'), _drama('city')]; + + expect(logic.dramaFor('city', catalog)?.id, 'city'); + expect(logic.dramaFor('missing', catalog), isNull); + expect(logic.dramaFor(null, catalog), isNull); + expect(logic.dramaFor('city', const []), isNull); + logic.dispose(); + }); + + test('syncDrama only adopts a drama while the page is active', () { + final history = FakeWatchHistory(); + final logic = DiscoverLogic(history: history, drama: _drama('signal')); + + void sync( + Drama next, { + required bool active, + required bool wasActive, + required bool dramaChanged, + int searchRequest = 0, + int previousSearchRequest = 0, + }) => logic.syncDrama( + active: active, + wasActive: wasActive, + nextDrama: next, + dramaChanged: dramaChanged, + searchRequest: searchRequest, + previousSearchRequest: previousSearchRequest, + isActive: () => active, + ); + + // An inactive page keeps showing its own drama. + sync(_drama('city'), active: false, wasActive: true, dramaChanged: true); + expect(logic.drama.id, 'signal'); + + // Becoming active adopts the incoming drama. + sync(_drama('city'), active: true, wasActive: false, dramaChanged: false); + expect(logic.drama.id, 'city'); + + // Staying active with a changed drama re-reads history. + history.reads.clear(); + sync(_drama('vengeance'), active: true, wasActive: true, dramaChanged: true); + expect(logic.drama.id, 'vengeance'); + expect(history.reads, ['demo-local-v1|vengeance|vengeance-1']); + + // Staying active with no change leaves both drama and history alone. + history.reads.clear(); + sync(_drama('other'), active: true, wasActive: true, dramaChanged: false); + expect(logic.drama.id, 'vengeance'); + expect(history.reads, isEmpty); + logic.dispose(); + }); + + testWidgets('a search request opens and focuses the field when active', ( + tester, + ) async { + final logic = DiscoverLogic(history: FakeWatchHistory(), drama: _drama('s')); + await tester.pumpWidget( + MaterialApp( + home: Scaffold( + body: TextField( + controller: logic.search, + focusNode: logic.searchFocus, + ), + ), + ), + ); + + logic.syncDrama( + active: true, + wasActive: true, + nextDrama: logic.drama, + dramaChanged: false, + searchRequest: 1, + previousSearchRequest: 0, + isActive: () => true, + ); + + expect(logic.searchOpen, isTrue); + await tester.pumpAndSettle(); + expect(logic.searchFocus.hasFocus, isTrue); + + await tester.pumpWidget(const SizedBox.shrink()); + logic.dispose(); + }); + + testWidgets('a hidden page never opens or focuses the search field', ( + tester, + ) async { + final logic = DiscoverLogic(history: FakeWatchHistory(), drama: _drama('s')); + await tester.pumpWidget( + MaterialApp( + home: Scaffold( + body: TextField( + controller: logic.search, + focusNode: logic.searchFocus, + ), + ), + ), + ); + + // The search request branch is gated on `active`, so a page that is not on + // screen must neither reveal the field nor pull focus away from the visible tab. + logic.syncDrama( + active: false, + wasActive: false, + nextDrama: logic.drama, + dramaChanged: false, + searchRequest: 1, + previousSearchRequest: 0, + isActive: () => false, + ); + + expect(logic.searchOpen, isFalse); + await tester.pumpAndSettle(); + expect(logic.searchFocus.hasFocus, isFalse); + + await tester.pumpWidget(const SizedBox.shrink()); + logic.dispose(); + }); + + testWidgets('act returns the choice for a page and forwards it when embedded', ( + tester, + ) async { + final logic = DiscoverLogic(history: FakeWatchHistory(), drama: _drama('s')); + final forwarded = []; + final popped = Completer(); + late BuildContext pageContext; + + await tester.pumpWidget( + MaterialApp( + home: Builder( + builder: (context) => TextButton( + onPressed: () => Navigator.of(context) + .push( + MaterialPageRoute( + builder: (inner) { + pageContext = inner; + return const SizedBox.shrink(); + }, + ), + ) + .then(popped.complete), + child: const Text('open'), + ), + ), + ), + ); + + await tester.tap(find.text('open')); + await tester.pumpAndSettle(); + + logic.act( + pageContext, + DiscoverPageAction.home, + embedded: true, + onAction: forwarded.add, + ); + expect(forwarded, [DiscoverPageAction.home]); + expect(Navigator.of(pageContext).canPop(), isTrue); + + logic.act(pageContext, DiscoverPageAction.watchlist, embedded: false); + await tester.pumpAndSettle(); + + await expectLater(popped.future, completion(DiscoverPageAction.watchlist)); + logic.dispose(); + }); + + testWidgets('a card without playable media shows the artwork notice', ( + tester, + ) async { + final logic = DiscoverLogic(history: FakeWatchHistory(), drama: _drama('s')); + late BuildContext context; + + await tester.pumpWidget( + MaterialApp( + locale: const Locale('en'), + localizationsDelegates: AppLocalizations.localizationsDelegates, + supportedLocales: AppLocalizations.supportedLocales, + home: Builder( + builder: (inner) { + context = inner; + return const Scaffold(body: SizedBox.shrink()); + }, + ), + ), + ); + + logic.openCard(context, null, embedded: false); + await tester.pumpAndSettle(); + + final l10n = AppLocalizations.of(context)!; + expect(find.text(l10n.artworkOnlyNotice), findsOneWidget); + logic.dispose(); + }); + + testWidgets('an embedded card forwards the chosen drama', (tester) async { + final logic = DiscoverLogic(history: FakeWatchHistory(), drama: _drama('s')); + late BuildContext context; + Drama? selected; + + await tester.pumpWidget( + MaterialApp( + home: Builder( + builder: (inner) { + context = inner; + return const SizedBox.shrink(); + }, + ), + ), + ); + + logic.openCard( + context, + _drama('city'), + embedded: true, + onDramaSelected: (drama) => selected = drama, + ); + + expect(selected?.id, 'city'); + logic.dispose(); + }); + + test('notify after dispose is a no-op', () { + final logic = DiscoverLogic(history: FakeWatchHistory(), drama: _drama('s')); + var notifications = 0; + logic.addListener(() => notifications++); + + logic.dispose(); + logic.notify(); + + expect(notifications, 0); + }); +} diff --git a/test/drama_detail/drama_detail_logic_test.dart b/test/drama_detail/drama_detail_logic_test.dart new file mode 100644 index 0000000..e6e5b53 --- /dev/null +++ b/test/drama_detail/drama_detail_logic_test.dart @@ -0,0 +1,98 @@ +import 'package:flutter_test/flutter_test.dart'; +import 'package:nontonki/core/data/models/drama.dart'; +import 'package:nontonki/core/data/remote/api_client.dart'; +import 'package:nontonki/pages/drama_detail/drama_detail_logic.dart'; + +import '../support/fake_watch_history.dart'; + +Drama _card(String id) => Drama( + id: id, + title: id, + synopsis: 'synopsis', + posterUrl: '/files/$id.jpg', + totalEpisodes: 3, + episodes: [ + Episode( + id: '$id-1', + number: 1, + title: '第 1 集', + isFree: true, + videoUrl: '/files/$id-1.mp4', + ), + ], +); + +Drama _detail(String id) => Drama( + id: id, + title: id, + synopsis: 'synopsis', + posterUrl: '/files/$id.jpg', + totalEpisodes: 3, + detailLoaded: true, + episodes: [ + for (var number = 1; number <= 3; number++) + Episode( + id: '$id-$number', + number: number, + title: '第 $number 集', + isFree: true, + videoUrl: '/files/$id-$number.mp4', + ), + ], +); + +void main() { + test('a list card is upgraded to the full episode list', () async { + var calls = 0; + final logic = DramaDetailLogic( + drama: _card('signal'), + history: FakeWatchHistory(), + ); + + await logic.load(() async { + calls++; + return _detail('signal'); + }); + + expect(calls, 1); + expect(logic.loading, isFalse); + expect(logic.failed, isFalse); + expect(logic.drama.episodes, hasLength(3)); + logic.dispose(); + }); + + test('a failed load keeps the card and reports the reason', () async { + final logic = DramaDetailLogic( + drama: _card('signal'), + history: FakeWatchHistory(), + ); + + await logic.load(() async => throw const ApiException(500, '服务异常')); + + expect(logic.failed, isTrue); + expect(logic.failureMessage, '服务异常'); + expect(logic.drama.episodes, hasLength(1)); + + await logic.load(() async => throw StateError('offline')); + expect(logic.failed, isTrue); + expect(logic.failureMessage, isNull); + logic.dispose(); + }); + + test('an already loaded detail skips the request', () async { + var calls = 0; + final logic = DramaDetailLogic( + drama: _detail('signal'), + history: FakeWatchHistory(), + ); + + await logic.load(() async { + calls++; + return _detail('signal'); + }); + + expect(calls, 0); + expect(logic.drama.episodes, hasLength(3)); + logic.dispose(); + }); +} diff --git a/test/engagement/engagement_repository_test.dart b/test/engagement/engagement_repository_test.dart new file mode 100644 index 0000000..c2701be --- /dev/null +++ b/test/engagement/engagement_repository_test.dart @@ -0,0 +1,135 @@ +import 'dart:convert'; + +import 'package:flutter_test/flutter_test.dart'; +import 'package:nontonki/core/data/models/engagement_snapshot.dart'; +import 'package:nontonki/core/data/repositories/engagement_repository.dart'; +import 'package:shared_preferences/shared_preferences.dart'; +import 'package:shared_preferences_platform_interface/in_memory_shared_preferences_async.dart'; +import 'package:shared_preferences_platform_interface/shared_preferences_async_platform_interface.dart'; + +/// Mirrors the private key used by [SharedPreferencesEngagementRepository]. +const _key = 'engagement.v1.demo-local-v1'; + +void main() { + late SharedPreferencesAsync preferences; + + setUp(() { + SharedPreferencesAsyncPlatform.instance = + InMemorySharedPreferencesAsync.empty(); + preferences = SharedPreferencesAsync(); + }); + + SharedPreferencesEngagementRepository repository() => + SharedPreferencesEngagementRepository(preferences: preferences); + + Future loadRaw(String raw) async { + await preferences.setString(_key, raw); + return repository().load(); + } + + test('a first launch reads an empty snapshot', () async { + final snapshot = await repository().load(); + + expect(snapshot.savedDramaIds, isEmpty); + expect(snapshot.likedDramaIds, isEmpty); + expect(snapshot.commentsByDrama, isEmpty); + }); + + test('a snapshot survives a save and reload round trip', () async { + await repository().save( + const EngagementSnapshot( + savedDramaIds: {'signal', 'city'}, + likedDramaIds: {'city'}, + commentsByDrama: { + 'signal': ['first note', 'second note'], + }, + ), + ); + + final loaded = await repository().load(); + + expect(loaded.savedDramaIds, {'signal', 'city'}); + expect(loaded.likedDramaIds, {'city'}); + expect(loaded.commentsByDrama, { + 'signal': ['first note', 'second note'], + }); + }); + + test('an empty snapshot round trips as empty collections', () async { + await repository().save(const EngagementSnapshot()); + + final loaded = await repository().load(); + + expect(loaded.savedDramaIds, isEmpty); + expect(loaded.likedDramaIds, isEmpty); + expect(loaded.commentsByDrama, isEmpty); + }); + + test('corrupt or non-object payloads fall back to an empty snapshot', () async { + for (final raw in [ + '', + 'not json at all', + '[]', + '"a bare string"', + '42', + 'null', + ]) { + final snapshot = await loadRaw(raw); + + expect(snapshot.savedDramaIds, isEmpty, reason: raw); + expect(snapshot.likedDramaIds, isEmpty, reason: raw); + expect(snapshot.commentsByDrama, isEmpty, reason: raw); + } + }); + + test('wrongly typed fields are dropped instead of throwing', () async { + final snapshot = await loadRaw( + jsonEncode({ + 'saved': 'signal', + 'liked': {'city': true}, + 'comments': { + 'signal': 'a plain string', + 'city': ['kept', 7, null, true], + 'town': [], + }, + }), + ); + + expect(snapshot.savedDramaIds, isEmpty); + expect(snapshot.likedDramaIds, isEmpty); + expect(snapshot.commentsByDrama, { + 'city': ['kept'], + 'town': [], + }); + }); + + test('a payload missing keys falls back per field', () async { + final snapshot = await loadRaw(jsonEncode({'saved': ['signal']})); + + expect(snapshot.savedDramaIds, {'signal'}); + expect(snapshot.likedDramaIds, isEmpty); + expect(snapshot.commentsByDrama, isEmpty); + }); + + test('save writes only json primitives', () async { + await repository().save( + const EngagementSnapshot( + savedDramaIds: {'signal'}, + likedDramaIds: {'city'}, + commentsByDrama: { + 'signal': ['note'], + }, + ), + ); + + final raw = await preferences.getString(_key); + expect(raw, isNotNull); + + final decoded = jsonDecode(raw!) as Map; + expect(decoded['saved'], ['signal']); + expect(decoded['liked'], ['city']); + expect(decoded['comments'], { + 'signal': ['note'], + }); + }); +} diff --git a/test/formatting/localized_content_test.dart b/test/formatting/localized_content_test.dart new file mode 100644 index 0000000..6c79427 --- /dev/null +++ b/test/formatting/localized_content_test.dart @@ -0,0 +1,96 @@ +import 'package:flutter_test/flutter_test.dart'; +import 'package:nontonki/core/data/models/drama.dart'; +import 'package:nontonki/core/formatting/localized_content.dart'; +import 'package:nontonki/l10n/app_localizations_en.dart'; +import 'package:nontonki/l10n/app_localizations_zh.dart'; + +Drama _drama({required String id, String title = 'raw', String synopsis = 'raw'}) => + Drama( + id: id, + title: title, + synopsis: synopsis, + posterUrl: '/files/poster.png', + episodes: const [], + ); + +void main() { + final en = AppLocalizationsEn(); + final zh = AppLocalizationsZh(); + + test('each seeded drama maps onto its own localized copy', () { + final signal = _drama(id: 'the-signal-demo'); + final city = _drama(id: 'city-lights-demo'); + final vengeance = _drama(id: 'vengeance-demo'); + + expect(localizedDramaTitle(en, signal), en.dramaSignalTitle); + expect(localizedDramaTitle(en, city), en.dramaCityTitle); + expect(localizedDramaTitle(en, vengeance), en.dramaVengeanceTitle); + + expect(localizedDramaSynopsis(en, signal), en.dramaSignalSynopsis); + expect(localizedDramaSynopsis(en, city), en.dramaCitySynopsis); + expect(localizedDramaSynopsis(en, vengeance), en.dramaVengeanceSynopsis); + }); + + test('the mapping does not collapse two dramas onto one entry', () { + final titles = { + localizedDramaTitle(en, _drama(id: 'the-signal-demo')), + localizedDramaTitle(en, _drama(id: 'city-lights-demo')), + localizedDramaTitle(en, _drama(id: 'vengeance-demo')), + }; + final synopses = { + localizedDramaSynopsis(en, _drama(id: 'the-signal-demo')), + localizedDramaSynopsis(en, _drama(id: 'city-lights-demo')), + localizedDramaSynopsis(en, _drama(id: 'vengeance-demo')), + }; + + expect(titles, hasLength(3)); + expect(synopses, hasLength(3)); + }); + + test('localized copy is translated rather than reused verbatim', () { + final signal = _drama(id: 'the-signal-demo'); + + expect(localizedDramaTitle(zh, signal), zh.dramaSignalTitle); + expect(localizedDramaSynopsis(zh, signal), zh.dramaSignalSynopsis); + expect(localizedDramaTitle(zh, signal), isNot(en.dramaSignalTitle)); + }); + + test('an unknown drama keeps the catalog text in every locale', () { + final custom = _drama( + id: 'custom-demo', + title: 'Custom Title', + synopsis: 'Custom synopsis', + ); + + expect(localizedDramaTitle(en, custom), 'Custom Title'); + expect(localizedDramaTitle(zh, custom), 'Custom Title'); + expect(localizedDramaSynopsis(en, custom), 'Custom synopsis'); + expect(localizedDramaSynopsis(zh, custom), 'Custom synopsis'); + }); + + test('the raw catalog text is ignored for a seeded drama', () { + final signal = _drama( + id: 'the-signal-demo', + title: 'stale title', + synopsis: 'stale synopsis', + ); + + expect(localizedDramaTitle(en, signal), isNot('stale title')); + expect(localizedDramaSynopsis(en, signal), isNot('stale synopsis')); + }); + + test('episodes one to four use named titles', () { + expect(localizedEpisodeTitle(en, 1), en.episodeOneTitle); + expect(localizedEpisodeTitle(en, 2), en.episodeTwoTitle); + expect(localizedEpisodeTitle(en, 3), en.episodeThreeTitle); + expect(localizedEpisodeTitle(en, 4), en.episodeFourTitle); + }); + + test('later episodes fall back to a numbered label', () { + for (final number in [5, 12, 100]) { + expect(localizedEpisodeTitle(en, number), en.episodeLabel(number)); + expect(localizedEpisodeTitle(en, number), contains('$number')); + } + expect(localizedEpisodeTitle(zh, 12), zh.episodeLabel(12)); + }); +} diff --git a/test/integration/live_catalog_test.dart b/test/integration/live_catalog_test.dart new file mode 100644 index 0000000..a3698de --- /dev/null +++ b/test/integration/live_catalog_test.dart @@ -0,0 +1,76 @@ +import 'package:flutter_test/flutter_test.dart'; +import 'package:nontonki/core/data/remote/api_client.dart'; +import 'package:nontonki/core/data/remote/catalog_api.dart'; + +/// 联调测试:直连本机客户端接口服务(8081)。 +/// 服务没启动时自动跳过,不影响日常 `flutter test`。 +void main() { + final client = ApiClient(baseUrl: 'http://127.0.0.1:8081'); + final api = CatalogApi(client); + + tearDownAll(client.close); + + Future serverUp() async { + try { + await api.homeFeed(); + return true; + } catch (_) { + return false; + } + } + + test('首页聚合:能解析出轮播与分区', () async { + if (!await serverUp()) { + markTestSkipped('客户端接口服务未启动,已跳过联调测试'); + return; + } + final feed = await api.homeFeed(); + expect(feed.sections, isNotEmpty); + expect(feed.dramas, isNotEmpty); + final card = feed.dramas.first; + expect(card.id, isNotEmpty); + expect(card.title, isNotEmpty); + expect(card.posterUrl, startsWith('/files/')); + }); + + test('详情:剧集按下发顺序排列,可播放集带地址', () async { + if (!await serverUp()) { + markTestSkipped('客户端接口服务未启动,已跳过联调测试'); + return; + } + final feed = await api.homeFeed(); + final card = feed.dramas.first; + final detail = await api.dramaDetail(card.id); + + expect(detail.id, card.id); + expect(detail.episodes, isNotEmpty); + final numbers = detail.episodes.map((episode) => episode.number).toList(); + expect(numbers, orderedEquals([...numbers]..sort())); + for (final episode in detail.episodes) { + if (episode.locked) { + expect(episode.videoUrl, isEmpty); + } else { + expect(episode.videoUrl, startsWith('/files/')); + } + } + }); + + test('播放票据:可播放时返回地址', () async { + if (!await serverUp()) { + markTestSkipped('客户端接口服务未启动,已跳过联调测试'); + return; + } + final feed = await api.homeFeed(); + final detail = await api.dramaDetail(feed.dramas.first.id); + final playable = detail.episodes + .where((episode) => episode.videoUrl.isNotEmpty) + .toList(); + if (playable.isEmpty) { + return; + } + + final ticket = await api.playTicket(playable.first.id); + expect(ticket.accessible, isTrue); + expect(ticket.playUrl, startsWith('/files/')); + }); +} diff --git a/test/mine/mine_logic_test.dart b/test/mine/mine_logic_test.dart new file mode 100644 index 0000000..c94dba8 --- /dev/null +++ b/test/mine/mine_logic_test.dart @@ -0,0 +1,256 @@ +import 'dart:async'; + +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:nontonki/core/config/locale_controller.dart'; +import 'package:nontonki/core/data/models/drama.dart'; +import 'package:nontonki/l10n/app_localizations.dart'; +import 'package:nontonki/pages/mine/mine_logic.dart'; +import 'package:provider/provider.dart'; +import 'package:shared_preferences_platform_interface/in_memory_shared_preferences_async.dart'; +import 'package:shared_preferences_platform_interface/shared_preferences_async_platform_interface.dart'; + +import '../support/fake_watch_history.dart'; + +Drama _drama(String id, {List numbers = const [1, 2, 3]}) => Drama( + id: id, + title: id, + synopsis: 'synopsis', + posterUrl: '/files/poster.png', + episodes: [ + for (final number in numbers) + Episode( + id: '$id-$number', + number: number, + title: 'Episode $number', + videoUrl: 'https://example.test/clip.mp4', + isFree: true, + ), + ], +); + +void main() { + TestWidgetsFlutterBinding.ensureInitialized(); + + test('the constructor keeps the requested section and reads episode one', () async { + final history = FakeWatchHistory()..saved = const Duration(seconds: 7); + final logic = MineLogic( + history: history, + drama: _drama('signal'), + initialSection: 1, + ); + + expect(logic.section, 1); + expect(logic.filter, 0); + expect(await logic.position, const Duration(seconds: 7)); + expect(history.reads, ['demo-local-v1|signal|signal-1']); + logic.dispose(); + }); + + test('a list card without episodes resumes from the last watch', () async { + final history = FakeWatchHistory() + ..saved = const Duration(seconds: 7) + ..lastEpisode = 'signal-3'; + final logic = MineLogic( + history: history, + drama: _drama('signal', numbers: const []), + initialSection: 1, + ); + + expect(await logic.position, const Duration(seconds: 7)); + expect(history.reads, ['demo-local-v1|signal|signal-3']); + logic.dispose(); + }); + + test('section and filter selections notify', () { + final logic = MineLogic( + history: FakeWatchHistory(), + drama: _drama('s'), + initialSection: 0, + ); + var notifications = 0; + logic.addListener(() => notifications++); + + logic.selectSection(1); + expect(logic.section, 1); + expect(notifications, 1); + + logic.selectFilter(2); + expect(logic.filter, 2); + expect(notifications, 2); + logic.dispose(); + }); + + test('syncPage only adopts a drama while the page is active', () { + final history = FakeWatchHistory(); + final logic = MineLogic( + history: history, + drama: _drama('signal'), + initialSection: 0, + ); + + void sync( + Drama next, { + required bool active, + required bool wasActive, + required bool dramaChanged, + int sectionRequest = 0, + int previousSectionRequest = 0, + int initialSection = 0, + }) => logic.syncPage( + active: active, + wasActive: wasActive, + nextDrama: next, + dramaChanged: dramaChanged, + sectionRequest: sectionRequest, + previousSectionRequest: previousSectionRequest, + initialSection: initialSection, + ); + + sync(_drama('city'), active: false, wasActive: true, dramaChanged: true); + expect(logic.drama.id, 'signal'); + + sync(_drama('city'), active: true, wasActive: false, dramaChanged: false); + expect(logic.drama.id, 'city'); + + history.reads.clear(); + sync(_drama('vengeance'), active: true, wasActive: true, dramaChanged: true); + expect(logic.drama.id, 'vengeance'); + expect(history.reads, ['demo-local-v1|vengeance|vengeance-1']); + + history.reads.clear(); + sync(_drama('other'), active: true, wasActive: true, dramaChanged: false); + expect(logic.drama.id, 'vengeance'); + expect(history.reads, isEmpty); + logic.dispose(); + }); + + test('a section request resets the section even while the page is inactive', () { + final logic = MineLogic( + history: FakeWatchHistory(), + drama: _drama('s'), + initialSection: 0, + ); + + logic.syncPage( + active: false, + wasActive: false, + nextDrama: logic.drama, + dramaChanged: false, + sectionRequest: 1, + previousSectionRequest: 0, + initialSection: 1, + ); + + expect(logic.section, 1); + logic.dispose(); + }); + + testWidgets('act returns the choice for a page and forwards it when embedded', ( + tester, + ) async { + final logic = MineLogic( + history: FakeWatchHistory(), + drama: _drama('s'), + initialSection: 0, + ); + final forwarded = []; + final popped = Completer(); + late BuildContext pageContext; + + await tester.pumpWidget( + MaterialApp( + home: Builder( + builder: (context) => TextButton( + onPressed: () => Navigator.of(context) + .push( + MaterialPageRoute( + builder: (inner) { + pageContext = inner; + return const SizedBox.shrink(); + }, + ), + ) + .then(popped.complete), + child: const Text('open'), + ), + ), + ), + ); + + await tester.tap(find.text('open')); + await tester.pumpAndSettle(); + + logic.act( + pageContext, + MyPageAction.discover, + embedded: true, + onAction: forwarded.add, + ); + expect(forwarded, [MyPageAction.discover]); + expect(Navigator.of(pageContext).canPop(), isTrue); + + logic.act(pageContext, MyPageAction.resume, embedded: false); + await tester.pumpAndSettle(); + + await expectLater(popped.future, completion(MyPageAction.resume)); + logic.dispose(); + }); + + testWidgets('the language sheet switches the app locale', (tester) async { + SharedPreferencesAsyncPlatform.instance = + InMemorySharedPreferencesAsync.empty(); + final locale = LocaleController(); + final logic = MineLogic( + history: FakeWatchHistory(), + drama: _drama('s'), + initialSection: 0, + ); + late BuildContext context; + + await tester.pumpWidget( + ChangeNotifierProvider.value( + value: locale, + child: MaterialApp( + locale: const Locale('en'), + localizationsDelegates: AppLocalizations.localizationsDelegates, + supportedLocales: AppLocalizations.supportedLocales, + home: Builder( + builder: (inner) { + context = inner; + return const Scaffold(body: SizedBox.shrink()); + }, + ), + ), + ), + ); + + unawaited(logic.showLanguage(context)); + await tester.pumpAndSettle(); + + final l10n = AppLocalizations.of(context)!; + expect(find.text(l10n.english), findsOneWidget); + expect(find.text(l10n.simplifiedChinese), findsOneWidget); + + await tester.tap(find.text(l10n.simplifiedChinese)); + await tester.pumpAndSettle(); + + expect(locale.locale, const Locale('zh')); + logic.dispose(); + }); + + test('notify after dispose is a no-op', () { + final logic = MineLogic( + history: FakeWatchHistory(), + drama: _drama('s'), + initialSection: 0, + ); + var notifications = 0; + logic.addListener(() => notifications++); + + logic.dispose(); + logic.notify(); + + expect(notifications, 0); + }); +} diff --git a/test/player/player_logic_test.dart b/test/player/player_logic_test.dart new file mode 100644 index 0000000..1dedbf4 --- /dev/null +++ b/test/player/player_logic_test.dart @@ -0,0 +1,479 @@ +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:nontonki/core/data/models/drama.dart'; +import 'package:nontonki/core/data/models/player_port.dart'; +import 'package:nontonki/core/data/services/android_picture_in_picture.dart'; +import 'package:nontonki/core/data/services/playback_session.dart'; +import 'package:nontonki/pages/player/player_logic.dart'; +import 'package:nontonki/pages/player/player_view.dart'; + +import '../support/fake_watch_history.dart'; + +Drama _drama( + String id, { + List numbers = const [1, 2, 3], + bool isFree = true, +}) => Drama( + id: id, + title: id, + synopsis: 'synopsis', + posterUrl: '/files/poster.png', + episodes: [ + for (final number in numbers) + Episode( + id: '$id-$number', + number: number, + title: 'Episode $number', + // 与后端一致:只有可播放的剧集才带地址,锁定集为空 + videoUrl: isFree ? 'https://example.test/clip.mp4' : '', + isFree: isFree, + ), + ], +); + +AndroidPictureInPicture _pip() => + AndroidPictureInPicture(channel: const MethodChannel('test/player_logic/pip')); + +PlayerLogic _logic(FakeWatchHistory history) => + PlayerLogic(history: history, pictureInPicture: _pip()); + +/// Drains the session's serialized work so a test never ends mid-disposal. +/// +/// `start` kicks off selection without awaiting it, so the first read of +/// `playbackSettled` can still be the untouched initial future. Pumping the +/// event queue between reads closes that race. +Future _drain(PlayerLogic logic) async { + for (var attempt = 0; attempt < 4; attempt++) { + await pumpEventQueue(); + await logic.session.playbackSettled; + await logic.session.preloadSettled; + } +} + +void main() { + TestWidgetsFlutterBinding.ensureInitialized(); + + group('displayEpisode', () { + test('falls back until a number is picked for that drama', () { + final logic = _logic(FakeWatchHistory()); + final drama = _drama('signal'); + final fallback = drama.episodes.first; + + expect(logic.displayEpisode(drama, fallback).number, 1); + + logic.pickedEpisode['signal'] = 3; + expect(logic.displayEpisode(drama, fallback).number, 3); + + // Picks are scoped to their own drama. + final city = _drama('city'); + expect(logic.displayEpisode(city, city.episodes.first).number, 1); + }); + + test('an unknown picked number stops overriding the fallback', () { + final logic = _logic(FakeWatchHistory()); + final drama = _drama('signal'); + final fallback = drama.episodes.first; + + logic.pickedEpisode['signal'] = 99; + + expect(logic.displayEpisode(drama, fallback).number, 1); + }); + }); + + group('nextVisibleIndex', () { + test('walks the visible list and stops at the end', () { + final logic = _logic(FakeWatchHistory()); + logic.visibleIndices = [0, 2, 4]; + + expect(logic.nextVisibleIndex(0), 2); + expect(logic.nextVisibleIndex(2), 4); + expect(logic.nextVisibleIndex(4), isNull); + }); + + test('an index outside the visible list has no successor', () { + final logic = _logic(FakeWatchHistory()); + logic.visibleIndices = [0, 2, 4]; + + expect(logic.nextVisibleIndex(1), isNull); + expect(logic.nextVisibleIndex(9), isNull); + expect(logic.nextVisibleIndex(-1), isNull); + }); + + test('an empty visible list has no successor', () { + final logic = _logic(FakeWatchHistory()); + logic.visibleIndices = []; + + expect(logic.nextVisibleIndex(0), isNull); + }); + }); + + group('surface flags', () { + test('clearing the screen hides the chrome until it is restored', () { + final logic = _logic(FakeWatchHistory()); + final immersive = []; + logic.onImmersiveChanged = immersive.add; + var notifications = 0; + logic.addListener(() => notifications++); + + expect(logic.chromeHidden, isFalse); + expect(logic.immersive, isFalse); + + logic.setScreenCleared(true); + expect(logic.chromeHidden, isTrue); + expect(notifications, 1); + expect(immersive, [true]); + + // Repeating the same value is not a state change. + logic.setScreenCleared(true); + expect(notifications, 1); + expect(immersive, [true]); + + logic.setScreenCleared(false); + expect(logic.chromeHidden, isFalse); + expect(notifications, 2); + expect(immersive, [true, false]); + }); + + test('a picture in picture callback outranks the cleared screen flag', () async { + final factory = _RecordingFactory(); + final drama = _drama('signal'); + final logic = _logic(FakeWatchHistory()); + final immersive = []; + logic.attach( + PlayerPage(drama: drama, initialIndex: 0), + isMounted: () => true, + ); + logic.onImmersiveChanged = immersive.add; + logic.start(factory: factory.create, coordinator: PlaybackCoordinator()); + await _drain(logic); + + logic.onPipChanged(true); + + expect(logic.pip, isTrue); + expect(logic.pipPreparing, isFalse); + expect(logic.immersive, isTrue); + expect(logic.chromeHidden, isTrue); + expect(immersive.last, isTrue); + + logic.onPipChanged(false); + expect(logic.pip, isFalse); + expect(logic.immersive, isFalse); + + logic.dispose(); + await _drain(logic); + }); + + test('a picture in picture callback is ignored once unmounted', () { + final logic = _logic(FakeWatchHistory()); + logic.isMounted = () => false; + + logic.onPipChanged(true); + + expect(logic.pip, isFalse); + }); + }); + + group('history writes', () { + test('progress writes are serialized in call order', () async { + final history = FakeWatchHistory(); + final logic = _logic(history); + final drama = _drama('signal'); + + await logic.queueProgress( + drama, + drama.episodes[0], + const Duration(seconds: 1), + ); + await logic.queueProgress( + drama, + drama.episodes[1], + const Duration(seconds: 2), + ); + + expect(history.writes, [ + 'demo-local-v1|signal|signal-1|1000', + 'demo-local-v1|signal|signal-2|2000', + ]); + }); + + test('a failed write does not drop the writes after it', () async { + final history = FakeWatchHistory(); + final logic = _logic(history); + final drama = _drama('signal'); + + history.failWrites = true; + await logic.queueProgress( + drama, + drama.episodes[0], + const Duration(seconds: 1), + ); + + history.failWrites = false; + await logic.queueProgress( + drama, + drama.episodes[1], + const Duration(seconds: 2), + ); + + expect(history.writes, ['demo-local-v1|signal|signal-2|2000']); + }); + + test('saving with no tracked player writes nothing', () async { + final history = FakeWatchHistory(); + final logic = _logic(history); + + await logic.saveCurrentProgress(); + await logic.saveCurrentProgress(); + + expect(history.writes, isEmpty); + expect(history.reads, isEmpty); + }); + }); + + group('start', () { + test('a detail route plays a single series', () async { + final factory = _RecordingFactory(); + final drama = _drama('signal'); + final logic = _logic(FakeWatchHistory()); + logic.attach( + PlayerPage(drama: drama, initialIndex: 0), + isMounted: () => true, + ); + + logic.start(factory: factory.create, coordinator: PlaybackCoordinator()); + await _drain(logic); + + expect(logic.queue.length, 3); + expect(logic.visibleIndices, [0, 1, 2]); + expect(logic.session.currentIndex, 0); + expect(factory.created, hasLength(2)); + expect(factory.created.first.plays, 1); + + logic.dispose(); + await _drain(logic); + expect(factory.live, 0); + }); + + test('home mode plays one episode per feed drama', () async { + final factory = _RecordingFactory(); + final feed = [_drama('signal'), _drama('city'), _drama('vengeance')]; + final logic = _logic(FakeWatchHistory()); + logic.attach( + PlayerPage( + drama: feed.first, + initialIndex: 0, + homeMode: true, + feedDramas: feed, + ), + isMounted: () => true, + ); + + logic.start(factory: factory.create, coordinator: PlaybackCoordinator()); + await _drain(logic); + + expect(logic.queue.length, 3); + expect(logic.queue.entryAt(1).drama.id, 'city'); + expect(logic.queue.entryAt(1).episode.number, 1); + expect(logic.visibleIndices, [0, 1, 2]); + + logic.dispose(); + await _drain(logic); + }); + + test('a locked episode never reaches the player factory', () async { + final factory = _RecordingFactory(); + final drama = _drama('locked', isFree: false); + final logic = _logic(FakeWatchHistory()); + logic.attach( + PlayerPage(drama: drama, initialIndex: 0), + isMounted: () => true, + ); + + logic.start(factory: factory.create, coordinator: PlaybackCoordinator()); + await _drain(logic); + + expect(logic.session.isLocked, isTrue); + expect(factory.created, isEmpty); + + logic.dispose(); + await _drain(logic); + }); + + test('starting from a later index only preloads what follows it', () async { + final factory = _RecordingFactory(); + final drama = _drama('signal'); + final logic = _logic(FakeWatchHistory()); + logic.attach( + PlayerPage(drama: drama, initialIndex: 2), + isMounted: () => true, + ); + + logic.start(factory: factory.create, coordinator: PlaybackCoordinator()); + await _drain(logic); + + expect(logic.session.currentIndex, 2); + // The last episode has no successor to warm. + expect(factory.created, hasLength(1)); + + logic.dispose(); + await _drain(logic); + }); + + test('an inactive route holds no players until it becomes visible', () async { + final factory = _RecordingFactory(); + final drama = _drama('signal'); + final logic = _logic(FakeWatchHistory()); + logic.attach( + PlayerPage(drama: drama, initialIndex: 0, active: false), + isMounted: () => true, + ); + + logic.start(factory: factory.create, coordinator: PlaybackCoordinator()); + await _drain(logic); + + expect(factory.created, isEmpty); + expect(logic.session.loading, isFalse); + + logic.dispose(); + await _drain(logic); + }); + }); + + group('lifecycle', () { + test('backgrounding pauses the active player and resuming plays it', () async { + final factory = _RecordingFactory(); + final drama = _drama('signal'); + final logic = _logic(FakeWatchHistory()); + logic.attach( + PlayerPage(drama: drama, initialIndex: 0), + isMounted: () => true, + ); + logic.start(factory: factory.create, coordinator: PlaybackCoordinator()); + await _drain(logic); + + final player = factory.created.first; + expect(player.plays, 1); + expect(player.pauses, 0); + + logic.onLifecycle(AppLifecycleState.paused); + await _drain(logic); + expect(player.pauses, 1); + + logic.onLifecycle(AppLifecycleState.resumed); + await _drain(logic); + expect(player.plays, 2); + + logic.dispose(); + await _drain(logic); + }); + + test('an inactive route stops playing without losing the intent', () async { + final factory = _RecordingFactory(); + final drama = _drama('signal'); + final logic = _logic(FakeWatchHistory()); + final start = PlayerPage(drama: drama, initialIndex: 0); + logic.attach(start, isMounted: () => true); + logic.start(factory: factory.create, coordinator: PlaybackCoordinator()); + await _drain(logic); + final player = factory.created.first; + expect(player.plays, 1); + + logic.onPageUpdated(start); + await _drain(logic); + expect(player.plays, 1); + + logic.attach( + PlayerPage(drama: drama, initialIndex: 0, active: false), + isMounted: () => true, + ); + logic.onPageUpdated(start); + await _drain(logic); + expect(player.pauses, 1); + expect(logic.session.userWantsPlay, isTrue); + + logic.dispose(); + await _drain(logic); + }); + }); + + group('dispose', () { + test('is safe to repeat and releases every player', () async { + final factory = _RecordingFactory(); + final drama = _drama('signal'); + final logic = _logic(FakeWatchHistory()); + logic.attach( + PlayerPage(drama: drama, initialIndex: 0), + isMounted: () => true, + ); + logic.start(factory: factory.create, coordinator: PlaybackCoordinator()); + await _drain(logic); + expect(factory.live, greaterThan(0)); + + logic.dispose(); + await _drain(logic); + + expect(factory.live, 0); + expect(() => logic.dispose(), returnsNormally); + }); + + test('disables further notifications', () async { + final factory = _RecordingFactory(); + final drama = _drama('signal'); + final logic = _logic(FakeWatchHistory()); + logic.attach( + PlayerPage(drama: drama, initialIndex: 0), + isMounted: () => true, + ); + logic.start(factory: factory.create, coordinator: PlaybackCoordinator()); + await _drain(logic); + + var notifications = 0; + logic.addListener(() => notifications++); + + logic.dispose(); + await _drain(logic); + logic.notify(); + + expect(notifications, 0); + }); + }); +} + +/// Counts native-style allocations so leaks are visible to a test. +class _RecordingFactory { + final List<_RecordingPlayer> created = []; + int live = 0; + + PlayerPort create(Episode episode) { + live++; + final player = _RecordingPlayer(onDispose: () => live--); + created.add(player); + return player; + } +} + +class _RecordingPlayer implements PlayerPort { + _RecordingPlayer({required this.onDispose}); + + final void Function() onDispose; + int plays = 0; + int pauses = 0; + bool disposed = false; + + @override + Future initialize() async {} + + @override + Future play() async => plays++; + + @override + Future pause() async => pauses++; + + @override + Future dispose() async { + if (disposed) return; + disposed = true; + onDispose(); + } +} diff --git a/test/support/fake_catalog.dart b/test/support/fake_catalog.dart new file mode 100644 index 0000000..393315f --- /dev/null +++ b/test/support/fake_catalog.dart @@ -0,0 +1,81 @@ +import 'package:nontonki/core/data/models/drama.dart'; +import 'package:nontonki/core/data/models/home_feed.dart'; +import 'package:nontonki/core/data/models/play_ticket.dart'; +import 'package:nontonki/core/data/repositories/catalog_repository.dart'; + +/// 测试用目录数据:三部分区里的短剧,标题与后端演示数据保持一致。 +class FakeCatalogRepository implements CatalogRepository { + FakeCatalogRepository({List? dramas}) : dramas = dramas ?? demoDramas; + + final List dramas; + + @override + Future fetchHomeFeed() async => _feed(); + + @override + Future fetchDiscoverFeed() async => _feed(); + + @override + Future fetchDrama(String dramaId) async { + return dramas.firstWhere((drama) => drama.id == dramaId); + } + + @override + Future resolvePlay(String episodeId) async { + return PlayTicket( + episodeId: episodeId, + accessible: true, + accessType: PlayTicket.free, + playUrl: 'https://example.test/$episodeId.mp4', + ); + } + + HomeFeed _feed() => HomeFeed( + sections: [FeedSection(code: 'hot', title: '热门推荐', dramas: dramas)], + ); +} + +final List demoDramas = [ + _drama( + 'the-signal-demo', + 'The Signal', + 'Suspense · Mystery', + format: 1, + ), + _drama( + 'city-lights-demo', + 'City Lights & Velvet Nights', + 'Urban Romance', + format: 8, + ), + _drama( + 'vengeance-demo', + 'Vengeance Rising', + 'Action · Thriller', + format: 15, + ), +]; + +Drama _drama( + String id, + String title, + String genre, { + required int format, +}) => Drama( + id: id, + title: title, + synopsis: '$title synopsis', + posterUrl: '/files/$id.png', + genre: genre, + detailLoaded: true, + episodes: [ + for (var index = 0; index < 7; index++) + Episode( + id: '$id-${index + 1}', + number: index + 1, + title: 'Episode ${index + 1}', + isFree: true, + videoUrl: 'https://example.test/$format-$index.mp4', + ), + ], +); diff --git a/test/support/fake_watch_history.dart b/test/support/fake_watch_history.dart new file mode 100644 index 0000000..57f6ad4 --- /dev/null +++ b/test/support/fake_watch_history.dart @@ -0,0 +1,44 @@ +import 'package:nontonki/core/data/repositories/watch_history_repository.dart'; + +/// Records every history interaction so tests can assert on the key it used. +class FakeWatchHistory implements WatchHistoryRepository { + final List reads = []; + final List writes = []; + + /// Position returned by [positionFor] when [failReads] is false. + Duration? saved; + + /// Last episode returned by [lastEpisodeId]. + String? lastEpisode; + + bool failReads = false; + bool failWrites = false; + + @override + Future positionFor( + String profileId, + String dramaId, + String episodeId, + ) async { + reads.add('$profileId|$dramaId|$episodeId'); + if (failReads) throw StateError('history unavailable'); + return saved; + } + + @override + Future lastEpisodeId(String profileId, String dramaId) async { + if (failReads) throw StateError('history unavailable'); + return lastEpisode; + } + + @override + Future save( + String profileId, + String dramaId, + String episodeId, + Duration position, + ) async { + if (failWrites) throw StateError('history unavailable'); + writes.add('$profileId|$dramaId|$episodeId|${position.inMilliseconds}'); + } +} -- 2.54.0 From ae49b10407ed376eab112fbe4bddd4191f0e587f Mon Sep 17 00:00:00 2001 From: Vicky <10212746+haifeng-jiang@user.noreply.gitee.com> Date: Thu, 15 Oct 2026 17:53:54 +0800 Subject: [PATCH 04/76] =?UTF-8?q?chore(client):=20=E5=BD=92=E6=A1=A3?= =?UTF-8?q?=E5=8F=91=E7=8E=B0=E9=A1=B5=20widgets=EF=BC=88=E5=8E=9F?= =?UTF-8?q?=E5=9E=8B=E9=98=B6=E6=AE=B5=E6=96=B0=E5=A2=9E=E7=9B=AE=E5=BD=95?= =?UTF-8?q?=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../discover/widgets/cover_carousel.dart | 206 ++++++++++++++++++ 1 file changed, 206 insertions(+) create mode 100644 lib/pages/discover/widgets/cover_carousel.dart diff --git a/lib/pages/discover/widgets/cover_carousel.dart b/lib/pages/discover/widgets/cover_carousel.dart new file mode 100644 index 0000000..cd53152 --- /dev/null +++ b/lib/pages/discover/widgets/cover_carousel.dart @@ -0,0 +1,206 @@ +import 'dart:math' as math; + +import 'package:flutter/material.dart'; +import '../../../core/widgets/remote_image.dart'; + +class CoverItem { + const CoverItem({ + required this.title, + required this.subtitle, + required this.image, + required this.onOpen, + }); + + final String title; + final String subtitle; + final String image; + final VoidCallback onOpen; +} + +/// Full-bleed posters that turn as faces of a cube. Titles sit on the image. +class CoverCarousel extends StatefulWidget { + const CoverCarousel({super.key, required this.items}); + + final List items; + + @override + State createState() => _CoverCarouselState(); +} + +class _CoverCarouselState extends State + with SingleTickerProviderStateMixin { + late final AnimationController _snap; + double _page = 0; + double _from = 0; + double _to = 0; + int? _pointer; + double _drag = 0; + double _dragPage = 0; + + @override + void initState() { + super.initState(); + _snap = AnimationController(vsync: this)..addListener(_onSnap); + } + + @override + void dispose() { + _snap.dispose(); + super.dispose(); + } + + double get _last => math.max(0, widget.items.length - 1).toDouble(); + + void _onSnap() { + final t = Curves.easeOutCubic.transform(_snap.value); + setState(() => _page = _from + (_to - _from) * t); + } + + void _turnTo(double target) { + _from = _page; + _to = target.clamp(0, _last); + _snap.duration = const Duration(milliseconds: 420); + _snap.forward(from: 0); + } + + @override + Widget build(BuildContext context) { + return LayoutBuilder( + builder: (context, constraints) { + final width = constraints.maxWidth; + final height = math.min(width * 0.52, 210).toDouble(); + return SizedBox( + width: double.infinity, + height: height, + child: _stage(width), + ); + }, + ); + } + + Widget _stage(double width) { + return Listener( + behavior: HitTestBehavior.opaque, + onPointerDown: (event) { + _snap.stop(); + _pointer = event.pointer; + _drag = 0; + _dragPage = _page; + }, + onPointerMove: (event) { + if (event.pointer != _pointer) return; + _drag += event.delta.dx; + setState(() { + _page = (_dragPage - _drag / width).clamp(0.0, _last); + }); + }, + onPointerUp: (event) { + if (event.pointer != _pointer) return; + _pointer = null; + _turnTo(_page.roundToDouble()); + }, + onPointerCancel: (event) { + if (event.pointer != _pointer) return; + _pointer = null; + _turnTo(_page.roundToDouble()); + }, + child: ClipRect( + child: Stack( + fit: StackFit.expand, + children: [for (final index in _visible) _face(index, width)], + ), + ), + ); + } + + List get _visible { + final first = _page.floor(); + final indexes = [first, first + 1]; + indexes.retainWhere((index) => index >= 0 && index < widget.items.length); + indexes.sort((a, b) => (b - _page).abs().compareTo((a - _page).abs())); + return indexes; + } + + Widget _face(int index, double width) { + final delta = index - _page; + if (delta <= -1 || delta >= 1) return const SizedBox.shrink(); + final item = widget.items[index]; + final angle = delta * math.pi / 2; + // Push the face out to the cube surface, spin the whole cube on its + // vertical center, then bring that center back to the banner. + final face = Matrix4.identity() + ..translateByDouble(0, 0, -width / 2, 1) + ..rotateY(angle) + ..translateByDouble(0, 0, width / 2, 1); + final transform = Matrix4.identity() + ..setEntry(3, 2, 0.0018) + ..multiply(face); + return Positioned.fill( + child: Transform( + alignment: Alignment.center, + filterQuality: FilterQuality.medium, + transform: transform, + child: GestureDetector( + onTap: () { + if ((_page - index).abs() < 0.08) item.onOpen(); + }, + child: _poster(item), + ), + ), + ); + } + + Widget _poster(CoverItem item) { + return Stack( + fit: StackFit.expand, + children: [ + RemoteImage(item.image), + const DecoratedBox( + decoration: BoxDecoration( + gradient: LinearGradient( + begin: Alignment.topCenter, + end: Alignment.bottomCenter, + colors: [Color(0x00000000), Color(0x00000000), Color(0xE6000000)], + stops: [0, 0.5, 1], + ), + ), + ), + Positioned( + left: 20, + right: 20, + bottom: 22, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + item.title, + maxLines: 2, + overflow: TextOverflow.ellipsis, + style: const TextStyle( + color: Colors.white, + fontSize: 20, + fontWeight: FontWeight.w600, + height: 1.15, + shadows: [Shadow(blurRadius: 12, color: Colors.black)], + ), + ), + const SizedBox(height: 6), + Text( + item.subtitle, + maxLines: 1, + overflow: TextOverflow.ellipsis, + style: const TextStyle( + color: Color(0xF2FFFFFF), + fontSize: 14, + fontWeight: FontWeight.w400, + height: 1.2, + shadows: [Shadow(blurRadius: 8, color: Colors.black)], + ), + ), + ], + ), + ), + ], + ); + } +} -- 2.54.0 From 1853e1845cc78b38b86cf76e32317bfb65dc840e Mon Sep 17 00:00:00 2001 From: Vicky <10212746+haifeng-jiang@user.noreply.gitee.com> Date: Fri, 16 Oct 2026 09:30:46 +0800 Subject: [PATCH 05/76] =?UTF-8?q?refactor(client):=20=E7=BD=91=E7=BB=9C?= =?UTF-8?q?=E5=B1=82=E7=94=B1=E5=AE=98=E6=96=B9=20http=20=E6=8D=A2?= =?UTF-8?q?=E6=88=90=20dio=EF=BC=88=E5=AF=B9=E5=A4=96=E8=A1=8C=E4=B8=BA?= =?UTF-8?q?=E4=B8=8D=E5=8F=98=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 为什么:权威文档(AGENTS.md / CODING_STANDARDS.md)强制网络层用 dio,差异清单 A 组第 1 题 用户裁定选 A;原来用官方 http 是在无文档状态下按口头要求选的。 - ApiClient 改用 dio + BaseOptions(validateStatus 恒真、8s 超时、ResponseType.bytes 自行 UTF-8 解码) - 新增 AuthHeaderInterceptor(Authorization / X-Device-Id)与 EnvelopeInterceptor (解包 {code,message,data} + 错误码映射 + 401 判定) - 401 → 刷新 → 重发一次在 ApiClient 里编排,刻意不放在拦截器内重发:dio 的排队拦截器 在回调里再发请求会自锁 - 接口层(auth_api/catalog_api)签名、全部 controller/logic/page 未改动 - 测试:新增假 dio adapter 替代 MockClient,断言口径一条未改;用例名改为 should_<期望>_when_<条件>; 新增 api_client_test(解包/错误映射/请求头/查询参数/跳过重试)与 live_auth_test(真实后端 POST 链路) - pubspec:加 dio、移除已无引用的 http - 实测:dart analyze lib test 零告警;flutter test 155 全过;真实联调(8081)GET/POST 链路均通 --- lib/core/data/remote/api_client.dart | 159 +++++++++++---------- lib/core/data/remote/api_exception.dart | 15 ++ lib/core/data/remote/api_interceptors.dart | 133 +++++++++++++++++ pubspec.lock | 32 +++-- pubspec.yaml | 4 +- test/auth/auth_controller_test.dart | 109 +++++++------- test/auth/auth_page_test.dart | 12 +- test/core/api_client_test.dart | 107 ++++++++++++++ test/integration/live_auth_test.dart | 34 +++++ test/support/fake_http_adapter.dart | 46 ++++++ 10 files changed, 508 insertions(+), 143 deletions(-) create mode 100644 lib/core/data/remote/api_exception.dart create mode 100644 lib/core/data/remote/api_interceptors.dart create mode 100644 test/core/api_client_test.dart create mode 100644 test/integration/live_auth_test.dart create mode 100644 test/support/fake_http_adapter.dart diff --git a/lib/core/data/remote/api_client.dart b/lib/core/data/remote/api_client.dart index ca1d5b2..e9fb88b 100644 --- a/lib/core/data/remote/api_client.dart +++ b/lib/core/data/remote/api_client.dart @@ -1,35 +1,52 @@ -import 'dart:convert'; - -import 'package:http/http.dart' as http; +import 'package:dio/dio.dart'; import '../../config/app_config.dart'; +import 'api_exception.dart'; +import 'api_interceptors.dart'; -/// 接口异常:code 为后端业务码,message 可直接展示。 -class ApiException implements Exception { - const ApiException(this.code, this.message); - - final int code; - final String message; - - @override - String toString() => 'ApiException($code, $message)'; -} +/// `ApiException` 从这里也能拿到:历史调用方一律 `import 'api_client.dart'`,不必改 import。 +export 'api_exception.dart'; /// 后端统一响应壳 `{code, message, data}` 的解析入口。 +/// +/// 职责: +/// - 用 dio 发请求(`AuthHeaderInterceptor` 注入令牌与设备号,`EnvelopeInterceptor` 解包与映射错误码); +/// - 编排「401 → 刷新令牌 → 重发一次」——**刻意不放在拦截器里重发**,因为 dio 的排队拦截器 +/// 在回调里再发起请求会把自己排到队尾,造成自锁。 class ApiClient { ApiClient({ String? baseUrl, - http.Client? client, + HttpClientAdapter? adapter, this.accessTokenReader, this.tokenRefresher, this.onUnauthorized, this.deviceIdReader, - }) - : baseUrl = baseUrl ?? AppConfig.apiBaseUrl, - _client = client ?? http.Client(); + }) : baseUrl = baseUrl ?? AppConfig.apiBaseUrl { + _dio = Dio( + BaseOptions( + baseUrl: this.baseUrl, + connectTimeout: AppConfig.requestTimeout, + receiveTimeout: AppConfig.requestTimeout, + // 拿原始字节自己解码:后端消息是 UTF-8,且"不是 JSON 的响应体"要能被识别出来 + responseType: ResponseType.bytes, + // 非 2xx 不抛异常:业务结果由响应体里的 code 表达(与旧实现一致) + validateStatus: (_) => true, + ), + ); + _dio.interceptors.addAll([ + AuthHeaderInterceptor( + accessTokenReader: accessTokenReader, + deviceIdReader: deviceIdReader, + ), + const EnvelopeInterceptor(), + ]); + if (adapter != null) { + _dio.httpClientAdapter = adapter; + } + } final String baseUrl; - final http.Client _client; + late final Dio _dio; /// 取当前 access token(未登录返回 null) final String? Function()? accessTokenReader; @@ -44,7 +61,7 @@ class ApiClient { final Future Function()? deviceIdReader; Future get(String path, {Map? query}) { - return _send('GET', path, query: query); + return _request('GET', path, query: query); } Future post( @@ -53,10 +70,16 @@ class ApiClient { Map? query, bool skipAuthRetry = false, }) { - return _send('POST', path, body: body, query: query, skipAuthRetry: skipAuthRetry); + return _request( + 'POST', + path, + body: body, + query: query, + skipAuthRetry: skipAuthRetry, + ); } - Future _send( + Future _request( String method, String path, { Object? body, @@ -64,67 +87,45 @@ class ApiClient { bool retried = false, bool skipAuthRetry = false, }) async { - final uri = Uri.parse( - '$baseUrl$path', - ).replace(queryParameters: query?.isEmpty ?? true ? null : query); - final headers = await _headers(withBody: body != null); - final response = await (method == 'GET' - ? _client.get(uri, headers: headers) - : _client.post( - uri, - headers: headers, - body: body == null ? null : jsonEncode(body), - )) - .timeout(AppConfig.requestTimeout); - - Map shell = const {}; + final disableAuthRetry = skipAuthRetry || tokenRefresher == null; try { - shell = (jsonDecode(utf8.decode(response.bodyBytes)) as Map) - .cast(); - } catch (_) { - shell = const {}; - } - final code = shell['code'] as int? ?? -1; - - // 令牌过期:刷新一次再重试原请求;刷新失败就清登录态并抛给调用方 - if (code == 401 && !retried && !skipAuthRetry && tokenRefresher != null) { - final refreshed = await tokenRefresher!.call(); - if (refreshed) { - return _send( - method, - path, - body: body, - query: query, - retried: true, - skipAuthRetry: skipAuthRetry, - ); + final response = await _dio.request( + path, + data: body, + queryParameters: (query?.isEmpty ?? true) ? null : query, + options: Options( + method: method, + contentType: body == null ? null : Headers.jsonContentType, + extra: { + ApiRequestFlags.disableAuthRetry: disableAuthRetry, + ApiRequestFlags.retried: retried, + }, + ), + ); + return response.data; + } on DioException catch (error) { + final cause = error.error; + if (cause is TokenExpiredException) { + final refreshed = await tokenRefresher?.call() ?? false; + if (refreshed) { + return _request( + method, + path, + body: body, + query: query, + retried: true, + skipAuthRetry: skipAuthRetry, + ); + } + onUnauthorized?.call(); + throw ApiException(401, cause.message ?? '登录已过期'); } - onUnauthorized?.call(); - throw ApiException(401, shell['message'] as String? ?? '登录已过期'); + if (cause is ApiException) { + throw cause; + } + rethrow; } - - if (code == -1) { - throw ApiException(response.statusCode, 'HTTP ${response.statusCode}'); - } - if (code != 0) { - throw ApiException(code, shell['message'] as String? ?? '请求失败'); - } - return shell['data']; } - Future> _headers({required bool withBody}) async { - final headers = {'Accept': 'application/json'}; - if (withBody) headers['Content-Type'] = 'application/json'; - final token = accessTokenReader?.call(); - if (token != null && token.isNotEmpty) { - headers['Authorization'] = 'Bearer $token'; - } - final deviceId = await deviceIdReader?.call(); - if (deviceId != null && deviceId.isNotEmpty) { - headers['X-Device-Id'] = deviceId; - } - return headers; - } - - void close() => _client.close(); + void close() => _dio.close(force: true); } diff --git a/lib/core/data/remote/api_exception.dart b/lib/core/data/remote/api_exception.dart new file mode 100644 index 0000000..abd2226 --- /dev/null +++ b/lib/core/data/remote/api_exception.dart @@ -0,0 +1,15 @@ +// Author: fruit.com.cn + +/// 接口异常:code 为后端业务码,message 可直接展示。 +/// +/// 单独成文件是为了让 [ApiClient] 与拦截器都能引用它而不互相 import +/// (`api_client.dart` 会 `export` 本文件,历史调用方继续 `import 'api_client.dart'` 即可拿到它)。 +class ApiException implements Exception { + const ApiException(this.code, this.message); + + final int code; + final String message; + + @override + String toString() => 'ApiException($code, $message)'; +} diff --git a/lib/core/data/remote/api_interceptors.dart b/lib/core/data/remote/api_interceptors.dart new file mode 100644 index 0000000..a48087d --- /dev/null +++ b/lib/core/data/remote/api_interceptors.dart @@ -0,0 +1,133 @@ +// Author: fruit.com.cn + +import 'dart:convert'; + +import 'package:dio/dio.dart'; + +import 'api_exception.dart'; + +/// 请求级开关:放在 `RequestOptions.extra` 里,由 `ApiClient` 写入、拦截器读取。 +class ApiRequestFlags { + const ApiRequestFlags._(); + + /// 本次请求不参与「401 → 刷新 → 重试」:刷新令牌自身、登出,以及没有刷新回调时。 + static const String disableAuthRetry = 'app.auth.disableRetry'; + + /// 本次请求已经是刷新后的重试,见到它就不再刷新,避免无限循环。 + static const String retried = 'app.auth.retried'; +} + +/// 内部信号:响应体里 `code == 401`,应当由 `ApiClient` 刷新令牌后重发一次。 +/// +/// 只在本层流转,不会漏给调用方 —— 调用方拿到的始终是 `ApiException`。 +class TokenExpiredException implements Exception { + const TokenExpiredException(this.message); + + /// 后端返回的提示语(可能为空),用于刷新失败时拼 `ApiException` 的消息。 + final String? message; +} + +/// 注入鉴权与设备标识请求头。 +/// +/// 每个请求都重新取一次令牌,所以刷新成功后重发的那次会自动带上新令牌。 +class AuthHeaderInterceptor extends Interceptor { + AuthHeaderInterceptor({this.accessTokenReader, this.deviceIdReader}); + + /// 当前 access token;未登录返回 null 或空串。 + final String? Function()? accessTokenReader; + + /// 设备号(`X-Device-Id`):注册风控、下载绑定都用它。 + final Future Function()? deviceIdReader; + + @override + Future onRequest( + RequestOptions options, + RequestInterceptorHandler handler, + ) async { + options.headers['Accept'] = 'application/json'; + final token = accessTokenReader?.call(); + if (token != null && token.isNotEmpty) { + options.headers['Authorization'] = 'Bearer $token'; + } + final deviceId = await deviceIdReader?.call(); + if (deviceId != null && deviceId.isNotEmpty) { + options.headers['X-Device-Id'] = deviceId; + } + handler.next(options); + } +} + +/// 解包后端统一响应壳 `{code,message,data}`,并把业务码映射成异常。 +/// +/// 判定口径与旧的 `http` 实现逐条对齐: +/// - body 不是合法 JSON → 视为 `code = -1`,抛 `ApiException(状态码, 'HTTP <状态码>')` +/// - `code != 0` → 抛 `ApiException(code, message ?? '请求失败')` +/// - `code == 401` 且允许刷新 → 抛 [TokenExpiredException] 作为信号(由 `ApiClient` 刷新后重发) +class EnvelopeInterceptor extends Interceptor { + const EnvelopeInterceptor(); + + @override + void onResponse( + Response response, + ResponseInterceptorHandler handler, + ) { + final options = response.requestOptions; + final shell = _decodeShell(response.data); + final code = shell['code'] as int? ?? -1; + final message = shell['message'] as String?; + final retried = options.extra[ApiRequestFlags.retried] == true; + final disableRetry = + options.extra[ApiRequestFlags.disableAuthRetry] == true; + + if (code == 401 && !retried && !disableRetry) { + return handler.reject( + DioException( + requestOptions: options, + response: response, + type: DioExceptionType.badResponse, + error: TokenExpiredException(message), + ), + true, + ); + } + if (code == -1) { + final status = response.statusCode ?? -1; + return handler.reject( + DioException( + requestOptions: options, + response: response, + type: DioExceptionType.badResponse, + error: ApiException(status, 'HTTP $status'), + ), + true, + ); + } + if (code != 0) { + return handler.reject( + DioException( + requestOptions: options, + response: response, + type: DioExceptionType.badResponse, + error: ApiException(code, message ?? '请求失败'), + ), + true, + ); + } + response.data = shell['data']; + handler.next(response); + } + + /// 统一按 UTF-8 解码:后端的中文提示语不能因为缺 charset 而乱码。 + Map _decodeShell(Object? body) { + final text = switch (body) { + List bytes => utf8.decode(bytes, allowMalformed: true), + String text => text, + _ => '', + }; + try { + return (jsonDecode(text) as Map).cast(); + } catch (_) { + return const {}; + } + } +} diff --git a/pubspec.lock b/pubspec.lock index 63efda0..98d77df 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -89,6 +89,22 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "1.0.9" + dio: + dependency: "direct main" + description: + name: dio + sha256: "852ec3b48cc431ac04fff978413c541502b67ffc3e26921e74e3d994694192c1" + url: "https://pub.flutter-io.cn" + source: hosted + version: "5.11.1" + dio_web_adapter: + dependency: transitive + description: + name: dio_web_adapter + sha256: "3a1b2cd7be71086f38504956e3ebcd2837288d231ff454bafa78021244102bfc" + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.2.2" fake_async: dependency: transitive description: @@ -157,14 +173,6 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "0.15.7" - http: - dependency: "direct main" - description: - name: http - sha256: "87721a4a50b19c7f1d49001e51409bddc46303966ce89a65af4f4e6004896412" - url: "https://pub.flutter-io.cn" - source: hosted - version: "1.6.0" http_parser: dependency: transitive description: @@ -253,6 +261,14 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "1.19.0" + mime: + dependency: transitive + description: + name: mime + sha256: bd47de35f07e27267e69c8c8b22edf9473bfee170a60d60fcc93730c5144b7f6 + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.1.0" nested: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 50740f4..6fedbac 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -34,8 +34,8 @@ dependencies: # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. cupertino_icons: ^1.0.8 - # 只用官方 http:纯 Dart、体积小;不引 dio/代码生成/图片缓存,控制包体积 - http: ^1.2.2 + # 网络层用 dio(统一拦截器/超时/错误映射);纯 Dart 无原生插件,仍然不引代码生成与图片缓存库 + dio: ^5.7.0 provider: ^6.1.5+1 video_player: ^2.14.0 shared_preferences: ^2.5.5 diff --git a/test/auth/auth_controller_test.dart b/test/auth/auth_controller_test.dart index 1ca93aa..298c3fe 100644 --- a/test/auth/auth_controller_test.dart +++ b/test/auth/auth_controller_test.dart @@ -1,8 +1,6 @@ import 'dart:convert'; import 'package:flutter_test/flutter_test.dart'; -import 'package:http/http.dart' as http; -import 'package:http/testing.dart'; import 'package:shared_preferences_platform_interface/in_memory_shared_preferences_async.dart'; import 'package:shared_preferences_platform_interface/shared_preferences_async_platform_interface.dart'; @@ -12,23 +10,18 @@ import 'package:nontonki/core/data/remote/auth_api.dart'; import 'package:nontonki/core/data/services/auth_controller.dart'; import 'package:nontonki/core/data/services/auth_session_store.dart'; -/// 用假的 http.Client 覆盖三条关键路径:注册成功、401 → 刷新 → 重试、刷新失败 → 清会话。 +import '../support/fake_http_adapter.dart'; + +/// 用假的 dio adapter 覆盖四条关键路径:注册成功、401 → 刷新 → 重试、刷新失败 → 清会话、登出。 +/// +/// 网络层从 http 换成 dio 后,这里的**断言口径一条没变**,只是注入方式从 +/// `http.testing.MockClient` 换成 `FakeHttpAdapter`。 void main() { setUp(() { SharedPreferencesAsyncPlatform.instance = InMemorySharedPreferencesAsync.empty(); }); - /// http.Response(String) 默认按 Latin-1 编码,中文消息会直接抛 - /// "Contains invalid characters" —— 统一用 UTF-8 字节构造。 - http.Response jsonResponse(String body, [int statusCode = 200]) { - return http.Response.bytes( - utf8.encode(body), - statusCode, - headers: const {'content-type': 'application/json; charset=utf-8'}, - ); - } - String tokenBody({ required String accessToken, required String refreshToken, @@ -48,12 +41,12 @@ void main() { ApiClient clientWith( AuthController Function() auth, { - required MockClient httpClient, + required FakeHttpAdapter adapter, }) { final store = AuthSessionStore(); return ApiClient( baseUrl: 'http://127.0.0.1:8081', - client: httpClient, + adapter: adapter, accessTokenReader: () => auth().accessToken, tokenRefresher: () => auth().refresh(), onUnauthorized: () => auth().clear(), @@ -61,16 +54,19 @@ void main() { ); } - test('register stores session and exposes signed-in state', () async { + test('should store the session and expose a signed-in state when register succeeds', () async { late AuthController auth; - final mock = MockClient((request) async { - expect(request.url.path, '/app/auth/register'); - expect(request.headers['X-Device-Id'], isNotEmpty); - expect(request.headers.containsKey('Authorization'), isFalse); - return jsonResponse(tokenBody(accessToken: 'a1', refreshToken: 'r1')); + final adapter = FakeHttpAdapter((options) async { + expect(options.uri.path, '/app/auth/register'); + expect(options.headers['X-Device-Id'], isNotEmpty); + expect(options.headers.containsKey('Authorization'), isFalse); + return FakeHttpResponse(tokenBody(accessToken: 'a1', refreshToken: 'r1')); }); final store = AuthSessionStore(); - auth = AuthController(AuthApi(clientWith(() => auth, httpClient: mock)), store); + auth = AuthController( + AuthApi(clientWith(() => auth, adapter: adapter)), + store, + ); expect(auth.isSignedIn, isFalse); await auth.register(email: 'a@b.com', password: 'abcd1234'); @@ -81,72 +77,89 @@ void main() { expect((await AuthSessionStore().read())?.refreshToken, 'r1'); }); - test('401 triggers refresh once and retries with the new token', () async { + test('should refresh once and retry with the new token when a response carries code 401', () async { var calls = 0; late AuthController auth; - final mock = MockClient((request) async { + final adapter = FakeHttpAdapter((options) async { calls++; - if (request.url.path == '/app/auth/refresh') { - return jsonResponse(tokenBody(accessToken: 'a2', refreshToken: 'r2')); + if (options.uri.path == '/app/auth/refresh') { + return FakeHttpResponse(tokenBody(accessToken: 'a2', refreshToken: 'r2')); } - if (request.url.path != '/app/me') { + if (options.uri.path != '/app/me') { // 注册等其它请求:直接发第一版令牌 - return jsonResponse(tokenBody(accessToken: 'a1', refreshToken: 'r1')); + return FakeHttpResponse(tokenBody(accessToken: 'a1', refreshToken: 'r1')); } - final token = request.headers['Authorization']; + final token = options.headers['Authorization']; if (token == 'Bearer a1') { - return jsonResponse( + return FakeHttpResponse( jsonEncode({'code': 401, 'message': '未登录或登录已过期', 'data': null}), ); } expect(token, 'Bearer a2'); - return jsonResponse(jsonEncode({'code': 0, 'message': 'ok', 'data': {'hit': true}})); + return FakeHttpResponse( + jsonEncode({ + 'code': 0, + 'message': 'ok', + 'data': {'hit': true}, + }), + ); }); final store = AuthSessionStore(); - auth = AuthController(AuthApi(clientWith(() => auth, httpClient: mock)), store); + auth = AuthController( + AuthApi(clientWith(() => auth, adapter: adapter)), + store, + ); await auth.register(email: 'a@b.com', password: 'abcd1234'); calls = 0; - final api = clientWith(() => auth, httpClient: mock); + final api = clientWith(() => auth, adapter: adapter); final data = await api.get('/app/me'); expect((data as Map)['hit'], isTrue); expect(calls, 3); // 原请求(401) + 刷新 + 重试 expect(auth.accessToken, 'a2'); }); - test('refresh failure clears the session (401 handling)', () async { + test('should clear the session when the refresh itself fails', () async { late AuthController auth; - final mock = MockClient((request) async { - if (request.url.path == '/app/auth/refresh') { - return jsonResponse(jsonEncode({'code': 401, 'message': '登录已过期', 'data': null})); + final adapter = FakeHttpAdapter((options) async { + if (options.uri.path == '/app/auth/refresh') { + return FakeHttpResponse( + jsonEncode({'code': 401, 'message': '登录已过期', 'data': null}), + ); } - if (request.url.path == '/app/auth/register') { - return jsonResponse(tokenBody(accessToken: 'a1', refreshToken: 'r1')); + if (options.uri.path == '/app/auth/register') { + return FakeHttpResponse(tokenBody(accessToken: 'a1', refreshToken: 'r1')); } - return jsonResponse( + return FakeHttpResponse( jsonEncode({'code': 401, 'message': '未登录或登录已过期', 'data': null}), ); }); final store = AuthSessionStore(); - auth = AuthController(AuthApi(clientWith(() => auth, httpClient: mock)), store); + auth = AuthController( + AuthApi(clientWith(() => auth, adapter: adapter)), + store, + ); await auth.register(email: 'a@b.com', password: 'abcd1234'); - final api = clientWith(() => auth, httpClient: mock); + final api = clientWith(() => auth, adapter: adapter); await expectLater(api.get('/app/me'), throwsA(isA())); expect(auth.isSignedIn, isFalse); expect(await AuthSessionStore().read(), isNull); }); - test('signOut clears local session even if the server call fails', () async { + test('should clear the local session when sign out hits a server error', () async { late AuthController auth; - final mock = MockClient((request) async { - if (request.url.path == '/app/auth/logout') { - return jsonResponse('{}', 500); + final adapter = FakeHttpAdapter((options) async { + if (options.uri.path == '/app/auth/logout') { + return FakeHttpResponse('{}', 500); } - return jsonResponse(tokenBody(accessToken: 'a1', refreshToken: 'r1')); + return FakeHttpResponse(tokenBody(accessToken: 'a1', refreshToken: 'r1')); }); final store = AuthSessionStore(); - auth = AuthController(AuthApi(clientWith(() => auth, httpClient: mock)), store); + auth = AuthController( + AuthApi(clientWith(() => auth, adapter: adapter)), + store, + ); await auth.register(email: 'a@b.com', password: 'abcd1234'); await auth.signOut(); diff --git a/test/auth/auth_page_test.dart b/test/auth/auth_page_test.dart index 0973f6d..05077f5 100644 --- a/test/auth/auth_page_test.dart +++ b/test/auth/auth_page_test.dart @@ -1,7 +1,5 @@ import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:http/http.dart' as http; -import 'package:http/testing.dart'; import 'package:provider/provider.dart'; import 'package:shared_preferences_platform_interface/in_memory_shared_preferences_async.dart'; import 'package:shared_preferences_platform_interface/shared_preferences_async_platform_interface.dart'; @@ -13,6 +11,8 @@ import 'package:nontonki/core/data/services/auth_session_store.dart'; import 'package:nontonki/l10n/app_localizations.dart'; import 'package:nontonki/pages/auth/auth_view.dart'; +import '../support/fake_http_adapter.dart'; + /// 登录/注册页的可读证据:校验提示 + 登录/注册切换 + 未登录时不会去发请求。 void main() { setUp(() { @@ -26,7 +26,7 @@ void main() { // 这个测试不联网:请求一律 500,正好用于验证"本地校验没过就不发请求" ApiClient( baseUrl: 'http://127.0.0.1:1', - client: MockClient((_) async => http.Response('{}', 500)), + adapter: FakeHttpAdapter((_) async => FakeHttpResponse('{}', 500)), ), ), AuthSessionStore(), @@ -45,7 +45,7 @@ void main() { await tester.pumpAndSettle(); } - testWidgets('empty form shows the email error and stays on the page', (tester) async { + testWidgets('should show the email error and stay on the page when the form is empty', (tester) async { await pumpAuthPage(tester); expect(find.text('Welcome back'), findsOneWidget); @@ -57,7 +57,7 @@ void main() { expect(find.text('Welcome back'), findsOneWidget); }); - testWidgets('weak password is rejected locally', (tester) async { + testWidgets('should reject a weak password locally when only letters are typed', (tester) async { await pumpAuthPage(tester); await tester.enterText(find.byType(TextField).first, 'a@b.com'); @@ -68,7 +68,7 @@ void main() { expect(find.text('Password needs both letters and numbers'), findsOneWidget); }); - testWidgets('switch link flips between sign in and sign up', (tester) async { + testWidgets('should flip between sign in and sign up when the switch link is tapped', (tester) async { await pumpAuthPage(tester); expect(find.text('Welcome back'), findsOneWidget); diff --git a/test/core/api_client_test.dart b/test/core/api_client_test.dart new file mode 100644 index 0000000..7abf6ca --- /dev/null +++ b/test/core/api_client_test.dart @@ -0,0 +1,107 @@ +// Author: fruit.com.cn + +import 'dart:convert'; + +import 'package:flutter_test/flutter_test.dart'; + +import 'package:nontonki/core/data/remote/api_client.dart'; + +import '../support/fake_http_adapter.dart'; + +/// 网络层换 dio 之后,把「对外契约」逐条钉住:解包、错误码映射、请求头、查询参数、跳过重试。 +void main() { + String envelope(Object? data, {int code = 0, String message = 'ok'}) { + return jsonEncode({'code': code, 'message': message, 'data': data}); + } + + test('should return the data field when the envelope code is zero', () async { + final adapter = FakeHttpAdapter( + (_) async => FakeHttpResponse(envelope({'id': 7})), + ); + final client = ApiClient(baseUrl: 'http://127.0.0.1:8081', adapter: adapter); + + final data = await client.get('/app/dramas/7'); + expect((data as Map)['id'], 7); + }); + + test('should throw an ApiException carrying the server message when the envelope code is not zero', () async { + final adapter = FakeHttpAdapter( + (_) async => FakeHttpResponse( + envelope(null, code: 40001, message: '邮箱格式不正确'), + ), + ); + final client = ApiClient(baseUrl: 'http://127.0.0.1:8081', adapter: adapter); + + await expectLater( + client.post('/app/auth/register', body: {'target': 'bad'}), + throwsA( + isA() + .having((e) => e.code, 'code', 40001) + .having((e) => e.message, 'message', '邮箱格式不正确'), + ), + ); + }); + + test('should map a body without envelope to an ApiException carrying the http status', () async { + final adapter = FakeHttpAdapter((_) async => FakeHttpResponse('oops', 502)); + final client = ApiClient(baseUrl: 'http://127.0.0.1:8081', adapter: adapter); + + await expectLater( + client.get('/app/home/feed'), + throwsA( + isA().having((e) => e.code, 'code', 502), + ), + ); + }); + + test('should send the bearer token and the device header when both are available', () async { + final adapter = FakeHttpAdapter((_) async => FakeHttpResponse(envelope(null))); + final client = ApiClient( + baseUrl: 'http://127.0.0.1:8081', + adapter: adapter, + accessTokenReader: () => 'token-1', + deviceIdReader: () async => 'device-9', + ); + + await client.get('/app/me'); + + final request = adapter.requests.single; + expect(request.headers['Authorization'], 'Bearer token-1'); + expect(request.headers['X-Device-Id'], 'device-9'); + expect(request.headers['Accept'], 'application/json'); + }); + + test('should put the query map into the request uri', () async { + final adapter = FakeHttpAdapter((_) async => FakeHttpResponse(envelope(null))); + final client = ApiClient(baseUrl: 'http://127.0.0.1:8081', adapter: adapter); + + await client.get('/app/search', query: {'keyword': '短剧', 'page': '2'}); + + final uri = adapter.requests.single.uri; + expect(uri.path, '/app/search'); + expect(uri.queryParameters['keyword'], '短剧'); + expect(uri.queryParameters['page'], '2'); + }); + + test('should not refresh the token when the call opts out of auth retry', () async { + var refreshed = false; + final adapter = FakeHttpAdapter( + (_) async => FakeHttpResponse(envelope(null, code: 401, message: '登录已过期')), + ); + final client = ApiClient( + baseUrl: 'http://127.0.0.1:8081', + adapter: adapter, + tokenRefresher: () async { + refreshed = true; + return true; + }, + ); + + await expectLater( + client.post('/app/auth/refresh', body: {'refreshToken': 'r1'}, skipAuthRetry: true), + throwsA(isA().having((e) => e.code, 'code', 401)), + ); + expect(refreshed, isFalse); + expect(adapter.requests, hasLength(1)); + }); +} diff --git a/test/integration/live_auth_test.dart b/test/integration/live_auth_test.dart new file mode 100644 index 0000000..844b820 --- /dev/null +++ b/test/integration/live_auth_test.dart @@ -0,0 +1,34 @@ +// Author: fruit.com.cn + +import 'package:flutter_test/flutter_test.dart'; + +import 'package:nontonki/core/data/remote/api_client.dart'; +import 'package:nontonki/core/data/remote/auth_api.dart'; + +/// 联调测试:直连本机客户端接口服务(8081)验证 **POST + JSON body + 错误码映射**。 +/// +/// 特意用"不存在的邮箱"登录:既能走完整的 POST 链路,又不会在库里留下测试数据。 +/// 服务没启动时自动跳过,不影响日常 `flutter test`。 +void main() { + final client = ApiClient(baseUrl: 'http://127.0.0.1:8081'); + final api = AuthApi(client); + + tearDownAll(client.close); + + test('should surface a business error when signing in with an unknown email', () async { + try { + await api.login( + email: 'no-such-user-for-dio-check@example.com', + password: 'abcd1234', + deviceId: 'dio-check-device', + ); + fail('不存在的邮箱不应该登录成功'); + } on ApiException catch (error) { + // 关键点:错误码来自响应体(不是 HTTP 状态码),说明统一解包生效 + expect(error.code, isNot(0)); + expect(error.message, isNotEmpty); + } catch (_) { + markTestSkipped('客户端接口服务未启动,已跳过联调测试'); + } + }); +} diff --git a/test/support/fake_http_adapter.dart b/test/support/fake_http_adapter.dart new file mode 100644 index 0000000..900fbb0 --- /dev/null +++ b/test/support/fake_http_adapter.dart @@ -0,0 +1,46 @@ +// Author: fruit.com.cn + +import 'dart:convert'; +import 'dart:typed_data'; + +import 'package:dio/dio.dart'; + +/// 假响应:[body] 会按 UTF-8 编码成字节,[statusCode] 默认 200。 +class FakeHttpResponse { + FakeHttpResponse(this.body, [this.statusCode = 200]); + + final String body; + final int statusCode; +} + +/// dio 的测试替身:把请求交给回调处理,全程不联网。 +/// +/// 顺带记录每个收到的请求,测试可以直接断言"发了几次、带了什么头"。 +class FakeHttpAdapter implements HttpClientAdapter { + FakeHttpAdapter(this.handler); + + final Future Function(RequestOptions options) handler; + + /// 按顺序记录收到的请求,用于断言请求次数与请求头。 + final List requests = []; + + @override + Future fetch( + RequestOptions options, + Stream? requestStream, + Future? cancelFuture, + ) async { + requests.add(options); + final response = await handler(options); + return ResponseBody.fromBytes( + utf8.encode(response.body), + response.statusCode, + headers: const { + 'content-type': ['application/json; charset=utf-8'], + }, + ); + } + + @override + void close({bool force = false}) {} +} -- 2.54.0 From 0e5d550b501e93958f541e4ffc42984964ba938c Mon Sep 17 00:00:00 2001 From: Vicky <10212746+haifeng-jiang@user.noreply.gitee.com> Date: Fri, 16 Oct 2026 09:41:14 +0800 Subject: [PATCH 06/76] =?UTF-8?q?test(client):=20=E7=94=A8=E4=BE=8B?= =?UTF-8?q?=E5=90=8D=E7=BB=9F=E4=B8=80=E4=B8=BA=20should=5F<=E6=9C=9F?= =?UTF-8?q?=E6=9C=9B>=5Fwhen=5F<=E6=9D=A1=E4=BB=B6>=EF=BC=88155/155?= =?UTF-8?q?=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 为什么:红线第 8 条门禁立即生效,要求 Flutter 测试命名合规;此前 155 条用例名是英文自然语言 或中文描述,合规数 0/155,属存量欠账,按"先补齐再上新功能"在本批处理。 - 25 个测试文件、155 条用例改名,按「文件 + 旧名」精确定位,每条断言命中恰好 1 次才替换 - 只改名字字面量:改动行 155 删 + 155 增,无一行不含字符串字面量(断言与用例体零改动) - 门禁:dart analyze lib test = No issues found;flutter test = 155 全过 --- test/auth/auth_controller_test.dart | 8 ++-- test/auth/auth_page_test.dart | 6 +-- test/catalog/catalog_controller_test.dart | 6 +-- test/catalog/drama_model_test.dart | 6 +-- test/config/locale_controller_test.dart | 12 +++--- .../core/android_picture_in_picture_test.dart | 16 ++++---- test/core/api_client_test.dart | 12 +++--- test/discover/cover_carousel_test.dart | 2 +- test/discover/discover_logic_test.dart | 28 ++++++------- .../drama_detail/drama_detail_logic_test.dart | 6 +-- .../engagement_controller_test.dart | 4 +- .../engagement_repository_test.dart | 14 +++---- test/formatting/localized_content_test.dart | 14 +++---- test/home/home_logic_test.dart | 24 +++++------ test/integration/live_auth_test.dart | 2 +- test/integration/live_catalog_test.dart | 6 +-- test/mine/mine_logic_test.dart | 16 ++++---- test/playback/playback_preload_test.dart | 20 +++++----- test/playback/playback_queue_test.dart | 6 +-- test/playback/playback_session_test.dart | 14 +++---- test/playback/seek_progress_bar_test.dart | 6 +-- test/playback/video_player_port_test.dart | 4 +- test/playback/watch_history_test.dart | 10 ++--- test/player/player_logic_test.dart | 40 +++++++++---------- test/widget_test.dart | 28 ++++++------- 25 files changed, 155 insertions(+), 155 deletions(-) diff --git a/test/auth/auth_controller_test.dart b/test/auth/auth_controller_test.dart index 298c3fe..6ff0c25 100644 --- a/test/auth/auth_controller_test.dart +++ b/test/auth/auth_controller_test.dart @@ -54,7 +54,7 @@ void main() { ); } - test('should store the session and expose a signed-in state when register succeeds', () async { + test('should_store_session_and_expose_signed_in_state_when_register_succeeds', () async { late AuthController auth; final adapter = FakeHttpAdapter((options) async { expect(options.uri.path, '/app/auth/register'); @@ -77,7 +77,7 @@ void main() { expect((await AuthSessionStore().read())?.refreshToken, 'r1'); }); - test('should refresh once and retry with the new token when a response carries code 401', () async { + test('should_refresh_once_and_retry_with_new_token_when_response_code_is_401', () async { var calls = 0; late AuthController auth; final adapter = FakeHttpAdapter((options) async { @@ -119,7 +119,7 @@ void main() { expect(auth.accessToken, 'a2'); }); - test('should clear the session when the refresh itself fails', () async { + test('should_clear_session_when_refresh_itself_fails', () async { late AuthController auth; final adapter = FakeHttpAdapter((options) async { if (options.uri.path == '/app/auth/refresh') { @@ -147,7 +147,7 @@ void main() { expect(await AuthSessionStore().read(), isNull); }); - test('should clear the local session when sign out hits a server error', () async { + test('should_clear_local_session_when_sign_out_hits_server_error', () async { late AuthController auth; final adapter = FakeHttpAdapter((options) async { if (options.uri.path == '/app/auth/logout') { diff --git a/test/auth/auth_page_test.dart b/test/auth/auth_page_test.dart index 05077f5..1ea91c9 100644 --- a/test/auth/auth_page_test.dart +++ b/test/auth/auth_page_test.dart @@ -45,7 +45,7 @@ void main() { await tester.pumpAndSettle(); } - testWidgets('should show the email error and stay on the page when the form is empty', (tester) async { + testWidgets('should_show_email_error_and_stay_on_page_when_form_is_empty', (tester) async { await pumpAuthPage(tester); expect(find.text('Welcome back'), findsOneWidget); @@ -57,7 +57,7 @@ void main() { expect(find.text('Welcome back'), findsOneWidget); }); - testWidgets('should reject a weak password locally when only letters are typed', (tester) async { + testWidgets('should_reject_weak_password_locally_when_only_letters_are_typed', (tester) async { await pumpAuthPage(tester); await tester.enterText(find.byType(TextField).first, 'a@b.com'); @@ -68,7 +68,7 @@ void main() { expect(find.text('Password needs both letters and numbers'), findsOneWidget); }); - testWidgets('should flip between sign in and sign up when the switch link is tapped', (tester) async { + testWidgets('should_flip_between_sign_in_and_sign_up_when_switch_link_is_tapped', (tester) async { await pumpAuthPage(tester); expect(find.text('Welcome back'), findsOneWidget); diff --git a/test/catalog/catalog_controller_test.dart b/test/catalog/catalog_controller_test.dart index 599e64e..1b97d6d 100644 --- a/test/catalog/catalog_controller_test.dart +++ b/test/catalog/catalog_controller_test.dart @@ -6,7 +6,7 @@ import 'package:nontonki/core/data/repositories/catalog_repository.dart'; import 'package:nontonki/core/data/services/catalog_controller.dart'; void main() { - test('空目录与加载失败可区分,重试后恢复', () async { + test('should_distinguish_empty_catalog_from_load_failure_when_retry_succeeds', () async { final repository = ScriptedCatalogRepository(); final controller = CatalogController(repository); @@ -30,7 +30,7 @@ void main() { expect(controller.sections.single.title, '热门推荐'); }); - test('详情按需加载:同一部短剧只请求一次', () async { + test('should_request_drama_detail_once_when_it_is_loaded_on_demand', () async { final repository = ScriptedCatalogRepository(); final controller = CatalogController(repository); repository.feed = HomeFeed( @@ -53,7 +53,7 @@ void main() { expect(controller.dramas.single.episodes, hasLength(2)); }); - test('播放票据:可播放写入地址,锁定集保持无地址', () async { + test('should_write_play_url_for_free_episode_and_keep_locked_episode_empty_when_ticket_is_issued', () async { final repository = ScriptedCatalogRepository(); final controller = CatalogController(repository); repository.tickets['10'] = const PlayTicket( diff --git a/test/catalog/drama_model_test.dart b/test/catalog/drama_model_test.dart index 6fb9778..c3a3653 100644 --- a/test/catalog/drama_model_test.dart +++ b/test/catalog/drama_model_test.dart @@ -2,7 +2,7 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:nontonki/core/data/models/drama.dart'; void main() { - test('a list card carries one playable preview and the total count', () { + test('should_carry_one_preview_and_total_count_when_list_card_is_parsed', () { final drama = Drama.fromCardJson(const { 'id': 5, 'title': '闪婚后', @@ -29,7 +29,7 @@ void main() { expect(drama.isHot, isTrue); }); - test('a list card without a playable preview has no episodes', () { + test('should_have_no_episodes_when_list_card_has_no_playable_preview', () { final drama = Drama.fromCardJson(const { 'id': 6, 'title': '替嫁新娘', @@ -40,7 +40,7 @@ void main() { expect(drama.episodeCount, 12); }); - test('a detail response counts the episodes it ships', () { + test('should_count_shipped_episodes_when_detail_response_is_parsed', () { final drama = Drama.fromDetailJson(const { 'id': 5, 'title': '闪婚后', diff --git a/test/config/locale_controller_test.dart b/test/config/locale_controller_test.dart index 7ca480b..b43afaa 100644 --- a/test/config/locale_controller_test.dart +++ b/test/config/locale_controller_test.dart @@ -11,7 +11,7 @@ void main() { InMemorySharedPreferencesAsync.empty(); }); - test('no stored choice keeps the device locale', () async { + test('should_keep_device_locale_when_no_choice_is_stored', () async { final controller = LocaleController(); var notifications = 0; controller.addListener(() => notifications++); @@ -22,7 +22,7 @@ void main() { expect(notifications, 1); }); - test('a chosen language survives a restart', () async { + test('should_restore_chosen_language_when_app_restarts', () async { final first = LocaleController(); await first.select('zh'); expect(first.locale, const Locale('zh')); @@ -32,7 +32,7 @@ void main() { expect(reopened.locale, const Locale('zh')); }); - test('selecting english clears a stored chinese preference', () async { + test('should_clear_stored_chinese_preference_when_english_is_selected', () async { await LocaleController().select('zh'); final reopened = LocaleController(); @@ -44,7 +44,7 @@ void main() { expect(third.locale, const Locale('en')); }); - test('an unsupported code clears the locale instead of throwing', () async { + test('should_clear_locale_when_code_is_unsupported', () async { final controller = LocaleController(); await controller.select('zh'); expect(controller.locale, const Locale('zh')); @@ -54,7 +54,7 @@ void main() { expect(controller.locale, isNull); }); - test('an unsupported stored code resolves to the device locale', () async { + test('should_resolve_to_device_locale_when_stored_code_is_unsupported', () async { await SharedPreferencesAsync().setString('ui.locale', 'fr'); final controller = LocaleController(); @@ -63,7 +63,7 @@ void main() { expect(controller.locale, isNull); }); - test('a broken preference store never breaks load or select', () async { + test('should_survive_load_and_select_when_preference_store_is_broken', () async { SharedPreferencesAsyncPlatform.instance = _BrokenPreferences(); final controller = LocaleController(); diff --git a/test/core/android_picture_in_picture_test.dart b/test/core/android_picture_in_picture_test.dart index 99d28cf..a2520f3 100644 --- a/test/core/android_picture_in_picture_test.dart +++ b/test/core/android_picture_in_picture_test.dart @@ -28,7 +28,7 @@ void main() { }); group('platform support', () { - test('android is the only supported target', () { + test('should_support_only_android_when_target_is_checked', () { debugDefaultTargetPlatformOverride = TargetPlatform.android; expect(pip().isPlatformSupported, isTrue); @@ -50,7 +50,7 @@ void main() { }); group('enter', () { - test('is refused without touching the channel off android', () async { + test('should_refuse_without_touching_channel_when_target_is_not_android', () async { debugDefaultTargetPlatformOverride = TargetPlatform.iOS; final calls = []; messenger.setMockMethodCallHandler(channel, (call) async { @@ -63,7 +63,7 @@ void main() { expect(calls, isEmpty); }); - test('a missing native answer counts as a refusal', () async { + test('should_count_as_refused_when_native_answer_is_missing', () async { debugDefaultTargetPlatformOverride = TargetPlatform.android; messenger.setMockMethodCallHandler(channel, (call) async => null); addTearDown(() => messenger.setMockMethodCallHandler(channel, null)); @@ -71,7 +71,7 @@ void main() { expect(await pip().enter(), isFalse); }); - test('a native success is reported as entered', () async { + test('should_report_entered_when_native_call_succeeds', () async { debugDefaultTargetPlatformOverride = TargetPlatform.android; final calls = []; messenger.setMockMethodCallHandler(channel, (call) async { @@ -87,7 +87,7 @@ void main() { }); group('state listener', () { - test('pip state changes reach the listener in order', () async { + test('should_deliver_pip_state_changes_in_order_when_native_events_arrive', () async { final received = []; pip().setStateListener(received.add); @@ -97,7 +97,7 @@ void main() { expect(received, [true, false]); }); - test('only a literal true is read as enabled', () async { + test('should_treat_only_literal_true_as_enabled_when_native_value_arrives', () async { final received = []; pip().setStateListener(received.add); @@ -108,7 +108,7 @@ void main() { expect(received, [false, false, false]); }); - test('unrelated native methods are ignored', () async { + test('should_ignore_unrelated_native_methods_when_events_arrive', () async { final received = []; pip().setStateListener(received.add); @@ -118,7 +118,7 @@ void main() { expect(received, [true]); }); - test('clearing the listener silences later callbacks', () async { + test('should_silence_later_callbacks_when_listener_is_cleared', () async { final received = []; final observer = pip()..setStateListener(received.add); await sendToDart('onPipChanged', true); diff --git a/test/core/api_client_test.dart b/test/core/api_client_test.dart index 7abf6ca..903e231 100644 --- a/test/core/api_client_test.dart +++ b/test/core/api_client_test.dart @@ -14,7 +14,7 @@ void main() { return jsonEncode({'code': code, 'message': message, 'data': data}); } - test('should return the data field when the envelope code is zero', () async { + test('should_return_data_field_when_envelope_code_is_zero', () async { final adapter = FakeHttpAdapter( (_) async => FakeHttpResponse(envelope({'id': 7})), ); @@ -24,7 +24,7 @@ void main() { expect((data as Map)['id'], 7); }); - test('should throw an ApiException carrying the server message when the envelope code is not zero', () async { + test('should_throw_api_exception_with_server_message_when_envelope_code_is_not_zero', () async { final adapter = FakeHttpAdapter( (_) async => FakeHttpResponse( envelope(null, code: 40001, message: '邮箱格式不正确'), @@ -42,7 +42,7 @@ void main() { ); }); - test('should map a body without envelope to an ApiException carrying the http status', () async { + test('should_map_to_api_exception_with_http_status_when_body_has_no_envelope', () async { final adapter = FakeHttpAdapter((_) async => FakeHttpResponse('oops', 502)); final client = ApiClient(baseUrl: 'http://127.0.0.1:8081', adapter: adapter); @@ -54,7 +54,7 @@ void main() { ); }); - test('should send the bearer token and the device header when both are available', () async { + test('should_send_bearer_token_and_device_header_when_both_are_available', () async { final adapter = FakeHttpAdapter((_) async => FakeHttpResponse(envelope(null))); final client = ApiClient( baseUrl: 'http://127.0.0.1:8081', @@ -71,7 +71,7 @@ void main() { expect(request.headers['Accept'], 'application/json'); }); - test('should put the query map into the request uri', () async { + test('should_put_query_map_into_request_uri_when_query_is_given', () async { final adapter = FakeHttpAdapter((_) async => FakeHttpResponse(envelope(null))); final client = ApiClient(baseUrl: 'http://127.0.0.1:8081', adapter: adapter); @@ -83,7 +83,7 @@ void main() { expect(uri.queryParameters['page'], '2'); }); - test('should not refresh the token when the call opts out of auth retry', () async { + test('should_skip_refresh_when_call_opts_out_of_auth_retry', () async { var refreshed = false; final adapter = FakeHttpAdapter( (_) async => FakeHttpResponse(envelope(null, code: 401, message: '登录已过期')), diff --git a/test/discover/cover_carousel_test.dart b/test/discover/cover_carousel_test.dart index 28e60e8..2f52609 100644 --- a/test/discover/cover_carousel_test.dart +++ b/test/discover/cover_carousel_test.dart @@ -5,7 +5,7 @@ import 'package:nontonki/pages/discover/widgets/cover_carousel.dart'; void main() { TestWidgetsFlutterBinding.ensureInitialized(); - testWidgets('the cube turns and keeps the title on the poster', (tester) async { + testWidgets('should_turn_cube_and_keep_title_on_poster_when_carousel_pages', (tester) async { await tester.pumpWidget( MaterialApp( home: Scaffold( diff --git a/test/discover/discover_logic_test.dart b/test/discover/discover_logic_test.dart index 671f76c..cc89799 100644 --- a/test/discover/discover_logic_test.dart +++ b/test/discover/discover_logic_test.dart @@ -28,7 +28,7 @@ Drama _drama(String id, {List numbers = const [1, 2, 3]}) => Drama( void main() { TestWidgetsFlutterBinding.ensureInitialized(); - test('the constructor resolves the resume position of episode one', () async { + test('should_resolve_resume_position_of_episode_one_when_constructed', () async { final history = FakeWatchHistory()..saved = const Duration(seconds: 4); final logic = DiscoverLogic(history: history, drama: _drama('signal')); @@ -39,7 +39,7 @@ void main() { logic.dispose(); }); - test('refreshPosition re-reads after the drama is swapped', () async { + test('should_reread_resume_position_when_drama_is_swapped', () async { final history = FakeWatchHistory(); final logic = DiscoverLogic(history: history, drama: _drama('signal')); @@ -54,7 +54,7 @@ void main() { logic.dispose(); }); - test('a list card without episodes resumes from the last watch', () async { + test('should_resume_from_last_watch_when_list_card_has_no_episodes', () async { final history = FakeWatchHistory() ..saved = const Duration(seconds: 9) ..lastEpisode = 'signal-2'; @@ -68,7 +68,7 @@ void main() { logic.dispose(); }); - test('a list card without history has no resume position', () async { + test('should_have_no_resume_position_when_list_card_has_no_history', () async { final history = FakeWatchHistory(); final logic = DiscoverLogic( history: history, @@ -80,7 +80,7 @@ void main() { logic.dispose(); }); - test('selectCategory stores the index and notifies once', () { + test('should_store_index_and_notify_once_when_category_is_selected', () { final logic = DiscoverLogic(history: FakeWatchHistory(), drama: _drama('s')); var notifications = 0; logic.addListener(() => notifications++); @@ -92,7 +92,7 @@ void main() { logic.dispose(); }); - test('search visibility follows the flag or the typed text', () { + test('should_show_search_when_flag_is_on_or_text_is_typed', () { final logic = DiscoverLogic(history: FakeWatchHistory(), drama: _drama('s')); expect(logic.showSearch, isFalse); @@ -109,7 +109,7 @@ void main() { logic.dispose(); }); - test('dramaFor matches by id and tolerates a missing id', () { + test('should_match_by_id_and_tolerate_missing_id_when_looking_up_drama', () { final logic = DiscoverLogic(history: FakeWatchHistory(), drama: _drama('s')); final catalog = [_drama('signal'), _drama('city')]; @@ -120,7 +120,7 @@ void main() { logic.dispose(); }); - test('syncDrama only adopts a drama while the page is active', () { + test('should_adopt_drama_only_when_page_is_active', () { final history = FakeWatchHistory(); final logic = DiscoverLogic(history: history, drama: _drama('signal')); @@ -163,7 +163,7 @@ void main() { logic.dispose(); }); - testWidgets('a search request opens and focuses the field when active', ( + testWidgets('should_open_and_focus_field_when_search_is_requested_and_page_is_active', ( tester, ) async { final logic = DiscoverLogic(history: FakeWatchHistory(), drama: _drama('s')); @@ -196,7 +196,7 @@ void main() { logic.dispose(); }); - testWidgets('a hidden page never opens or focuses the search field', ( + testWidgets('should_keep_search_field_closed_when_page_is_hidden', ( tester, ) async { final logic = DiscoverLogic(history: FakeWatchHistory(), drama: _drama('s')); @@ -231,7 +231,7 @@ void main() { logic.dispose(); }); - testWidgets('act returns the choice for a page and forwards it when embedded', ( + testWidgets('should_return_choice_and_forward_it_when_act_runs_embedded', ( tester, ) async { final logic = DiscoverLogic(history: FakeWatchHistory(), drama: _drama('s')); @@ -278,7 +278,7 @@ void main() { logic.dispose(); }); - testWidgets('a card without playable media shows the artwork notice', ( + testWidgets('should_show_artwork_notice_when_card_has_no_playable_media', ( tester, ) async { final logic = DiscoverLogic(history: FakeWatchHistory(), drama: _drama('s')); @@ -306,7 +306,7 @@ void main() { logic.dispose(); }); - testWidgets('an embedded card forwards the chosen drama', (tester) async { + testWidgets('should_forward_chosen_drama_when_card_is_embedded', (tester) async { final logic = DiscoverLogic(history: FakeWatchHistory(), drama: _drama('s')); late BuildContext context; Drama? selected; @@ -333,7 +333,7 @@ void main() { logic.dispose(); }); - test('notify after dispose is a no-op', () { + test('should_do_nothing_when_notifying_after_dispose', () { final logic = DiscoverLogic(history: FakeWatchHistory(), drama: _drama('s')); var notifications = 0; logic.addListener(() => notifications++); diff --git a/test/drama_detail/drama_detail_logic_test.dart b/test/drama_detail/drama_detail_logic_test.dart index e6e5b53..a2a25c3 100644 --- a/test/drama_detail/drama_detail_logic_test.dart +++ b/test/drama_detail/drama_detail_logic_test.dart @@ -42,7 +42,7 @@ Drama _detail(String id) => Drama( ); void main() { - test('a list card is upgraded to the full episode list', () async { + test('should_upgrade_to_full_episode_list_when_detail_loads_for_list_card', () async { var calls = 0; final logic = DramaDetailLogic( drama: _card('signal'), @@ -61,7 +61,7 @@ void main() { logic.dispose(); }); - test('a failed load keeps the card and reports the reason', () async { + test('should_keep_card_and_report_reason_when_load_fails', () async { final logic = DramaDetailLogic( drama: _card('signal'), history: FakeWatchHistory(), @@ -79,7 +79,7 @@ void main() { logic.dispose(); }); - test('an already loaded detail skips the request', () async { + test('should_skip_request_when_detail_is_already_loaded', () async { var calls = 0; final logic = DramaDetailLogic( drama: _detail('signal'), diff --git a/test/engagement/engagement_controller_test.dart b/test/engagement/engagement_controller_test.dart index fddd9b2..1e6a9fe 100644 --- a/test/engagement/engagement_controller_test.dart +++ b/test/engagement/engagement_controller_test.dart @@ -5,7 +5,7 @@ import 'package:shared_preferences_platform_interface/in_memory_shared_preferenc import 'package:shared_preferences_platform_interface/shared_preferences_async_platform_interface.dart'; void main() { - test('saved, liked and comments are kept by drama id', () async { + test('should_keep_saved_liked_and_comments_by_drama_id_when_toggled', () async { final repository = InMemoryEngagementRepository(); final first = EngagementController(repository); await first.load(); @@ -28,7 +28,7 @@ void main() { expect(reopened.isSaved('signal'), isFalse); }); - test('local engagement survives a new repository instance', () async { + test('should_survive_new_repository_instance_when_engagement_is_local', () async { SharedPreferencesAsyncPlatform.instance = InMemorySharedPreferencesAsync.empty(); final first = EngagementController(SharedPreferencesEngagementRepository()); diff --git a/test/engagement/engagement_repository_test.dart b/test/engagement/engagement_repository_test.dart index c2701be..5f6f8c3 100644 --- a/test/engagement/engagement_repository_test.dart +++ b/test/engagement/engagement_repository_test.dart @@ -27,7 +27,7 @@ void main() { return repository().load(); } - test('a first launch reads an empty snapshot', () async { + test('should_read_empty_snapshot_when_first_launch', () async { final snapshot = await repository().load(); expect(snapshot.savedDramaIds, isEmpty); @@ -35,7 +35,7 @@ void main() { expect(snapshot.commentsByDrama, isEmpty); }); - test('a snapshot survives a save and reload round trip', () async { + test('should_survive_save_and_reload_round_trip_when_snapshot_is_stored', () async { await repository().save( const EngagementSnapshot( savedDramaIds: {'signal', 'city'}, @@ -55,7 +55,7 @@ void main() { }); }); - test('an empty snapshot round trips as empty collections', () async { + test('should_round_trip_as_empty_collections_when_snapshot_is_empty', () async { await repository().save(const EngagementSnapshot()); final loaded = await repository().load(); @@ -65,7 +65,7 @@ void main() { expect(loaded.commentsByDrama, isEmpty); }); - test('corrupt or non-object payloads fall back to an empty snapshot', () async { + test('should_fall_back_to_empty_snapshot_when_payload_is_corrupt_or_not_an_object', () async { for (final raw in [ '', 'not json at all', @@ -82,7 +82,7 @@ void main() { } }); - test('wrongly typed fields are dropped instead of throwing', () async { + test('should_drop_mistyped_fields_when_payload_has_wrong_types', () async { final snapshot = await loadRaw( jsonEncode({ 'saved': 'signal', @@ -103,7 +103,7 @@ void main() { }); }); - test('a payload missing keys falls back per field', () async { + test('should_fall_back_per_field_when_payload_keys_are_missing', () async { final snapshot = await loadRaw(jsonEncode({'saved': ['signal']})); expect(snapshot.savedDramaIds, {'signal'}); @@ -111,7 +111,7 @@ void main() { expect(snapshot.commentsByDrama, isEmpty); }); - test('save writes only json primitives', () async { + test('should_write_only_json_primitives_when_saving', () async { await repository().save( const EngagementSnapshot( savedDramaIds: {'signal'}, diff --git a/test/formatting/localized_content_test.dart b/test/formatting/localized_content_test.dart index 6c79427..e097924 100644 --- a/test/formatting/localized_content_test.dart +++ b/test/formatting/localized_content_test.dart @@ -17,7 +17,7 @@ void main() { final en = AppLocalizationsEn(); final zh = AppLocalizationsZh(); - test('each seeded drama maps onto its own localized copy', () { + test('should_map_each_seeded_drama_to_its_own_localized_copy_when_looked_up', () { final signal = _drama(id: 'the-signal-demo'); final city = _drama(id: 'city-lights-demo'); final vengeance = _drama(id: 'vengeance-demo'); @@ -31,7 +31,7 @@ void main() { expect(localizedDramaSynopsis(en, vengeance), en.dramaVengeanceSynopsis); }); - test('the mapping does not collapse two dramas onto one entry', () { + test('should_keep_two_dramas_apart_when_localized_copy_is_mapped', () { final titles = { localizedDramaTitle(en, _drama(id: 'the-signal-demo')), localizedDramaTitle(en, _drama(id: 'city-lights-demo')), @@ -47,7 +47,7 @@ void main() { expect(synopses, hasLength(3)); }); - test('localized copy is translated rather than reused verbatim', () { + test('should_translate_localized_copy_when_content_is_looked_up', () { final signal = _drama(id: 'the-signal-demo'); expect(localizedDramaTitle(zh, signal), zh.dramaSignalTitle); @@ -55,7 +55,7 @@ void main() { expect(localizedDramaTitle(zh, signal), isNot(en.dramaSignalTitle)); }); - test('an unknown drama keeps the catalog text in every locale', () { + test('should_keep_catalog_text_in_every_locale_when_drama_is_unknown', () { final custom = _drama( id: 'custom-demo', title: 'Custom Title', @@ -68,7 +68,7 @@ void main() { expect(localizedDramaSynopsis(zh, custom), 'Custom synopsis'); }); - test('the raw catalog text is ignored for a seeded drama', () { + test('should_ignore_raw_catalog_text_when_drama_is_seeded', () { final signal = _drama( id: 'the-signal-demo', title: 'stale title', @@ -79,14 +79,14 @@ void main() { expect(localizedDramaSynopsis(en, signal), isNot('stale synopsis')); }); - test('episodes one to four use named titles', () { + test('should_use_named_titles_when_episode_number_is_one_to_four', () { expect(localizedEpisodeTitle(en, 1), en.episodeOneTitle); expect(localizedEpisodeTitle(en, 2), en.episodeTwoTitle); expect(localizedEpisodeTitle(en, 3), en.episodeThreeTitle); expect(localizedEpisodeTitle(en, 4), en.episodeFourTitle); }); - test('later episodes fall back to a numbered label', () { + test('should_fall_back_to_numbered_label_when_episode_number_is_later', () { for (final number in [5, 12, 100]) { expect(localizedEpisodeTitle(en, number), en.episodeLabel(number)); expect(localizedEpisodeTitle(en, number), contains('$number')); diff --git a/test/home/home_logic_test.dart b/test/home/home_logic_test.dart index c56b869..4ac5323 100644 --- a/test/home/home_logic_test.dart +++ b/test/home/home_logic_test.dart @@ -18,7 +18,7 @@ void main() { final dramas = [_drama('signal'), _drama('city')]; - test('the first catalog entry becomes the current drama', () { + test('should_make_first_catalog_entry_the_current_drama_when_catalog_loads', () { final logic = HomeLogic(dramas); expect(logic.currentDrama.id, 'signal'); @@ -30,11 +30,11 @@ void main() { logic.dispose(); }); - test('an empty catalog cannot build the shell', () { + test('should_not_build_shell_when_catalog_is_empty', () { expect(() => HomeLogic(const []), throwsStateError); }); - test('a plain tab switch raises no request counter', () { + test('should_not_raise_request_counter_when_only_tab_switches', () { final logic = HomeLogic(dramas); var notifications = 0; logic.addListener(() => notifications++); @@ -50,7 +50,7 @@ void main() { logic.dispose(); }); - test('each select flag raises exactly its own counter', () { + test('should_raise_only_its_own_counter_when_each_select_flag_is_used', () { final logic = HomeLogic(dramas); logic.select(1, search: true); @@ -71,7 +71,7 @@ void main() { logic.dispose(); }); - test('the watchlist shortcut defaults to the second section', () { + test('should_default_to_second_section_when_watchlist_shortcut_is_used', () { final logic = HomeLogic(dramas); logic.select(2, watchlist: true); @@ -82,7 +82,7 @@ void main() { logic.dispose(); }); - test('openProfile and openLibrary disagree about the profile flag', () { + test('should_differ_on_profile_flag_when_open_profile_and_open_library_are_used', () { final logic = HomeLogic(dramas); logic.openProfile(); @@ -103,7 +103,7 @@ void main() { logic.dispose(); }); - test('system back returns home, and home itself opens the drawer', () { + test('should_return_home_and_open_drawer_when_system_back_is_pressed', () { final logic = HomeLogic(dramas); logic.onSystemBack(); @@ -134,7 +134,7 @@ void main() { logic.dispose(); }); - test('drawer state only notifies on an actual change', () { + test('should_notify_only_on_actual_change_when_drawer_state_is_set', () { final logic = HomeLogic(dramas); var notifications = 0; logic.addListener(() => notifications++); @@ -151,7 +151,7 @@ void main() { logic.dispose(); }); - test('drama and immersive callbacks update state', () { + test('should_update_state_when_drama_and_immersive_callbacks_fire', () { final logic = HomeLogic(dramas); logic.onDramaChanged(dramas[1]); @@ -162,7 +162,7 @@ void main() { logic.dispose(); }); - test('my page actions map onto root tabs', () { + test('should_map_onto_root_tabs_when_my_page_actions_fire', () { final logic = HomeLogic(dramas); logic.myAction(MyPageAction.discover); @@ -179,7 +179,7 @@ void main() { logic.dispose(); }); - test('notifying after dispose is a no-op', () { + test('should_do_nothing_when_notifying_after_dispose', () { final logic = HomeLogic(dramas); var notifications = 0; logic.addListener(() => notifications++); @@ -190,7 +190,7 @@ void main() { expect(notifications, 0); }); - testWidgets('discover actions map onto root tabs', (tester) async { + testWidgets('should_map_onto_root_tabs_when_discover_actions_fire', (tester) async { final logic = HomeLogic(dramas); late BuildContext context; await tester.pumpWidget( diff --git a/test/integration/live_auth_test.dart b/test/integration/live_auth_test.dart index 844b820..21e0ed7 100644 --- a/test/integration/live_auth_test.dart +++ b/test/integration/live_auth_test.dart @@ -15,7 +15,7 @@ void main() { tearDownAll(client.close); - test('should surface a business error when signing in with an unknown email', () async { + test('should_surface_business_error_when_sign_in_uses_unknown_email', () async { try { await api.login( email: 'no-such-user-for-dio-check@example.com', diff --git a/test/integration/live_catalog_test.dart b/test/integration/live_catalog_test.dart index a3698de..0b79238 100644 --- a/test/integration/live_catalog_test.dart +++ b/test/integration/live_catalog_test.dart @@ -19,7 +19,7 @@ void main() { } } - test('首页聚合:能解析出轮播与分区', () async { + test('should_parse_banner_and_sections_when_home_feed_is_fetched', () async { if (!await serverUp()) { markTestSkipped('客户端接口服务未启动,已跳过联调测试'); return; @@ -33,7 +33,7 @@ void main() { expect(card.posterUrl, startsWith('/files/')); }); - test('详情:剧集按下发顺序排列,可播放集带地址', () async { + test('should_order_episodes_by_number_and_attach_url_when_detail_is_fetched', () async { if (!await serverUp()) { markTestSkipped('客户端接口服务未启动,已跳过联调测试'); return; @@ -55,7 +55,7 @@ void main() { } }); - test('播放票据:可播放时返回地址', () async { + test('should_return_play_url_when_episode_is_playable', () async { if (!await serverUp()) { markTestSkipped('客户端接口服务未启动,已跳过联调测试'); return; diff --git a/test/mine/mine_logic_test.dart b/test/mine/mine_logic_test.dart index c94dba8..9fb07c8 100644 --- a/test/mine/mine_logic_test.dart +++ b/test/mine/mine_logic_test.dart @@ -32,7 +32,7 @@ Drama _drama(String id, {List numbers = const [1, 2, 3]}) => Drama( void main() { TestWidgetsFlutterBinding.ensureInitialized(); - test('the constructor keeps the requested section and reads episode one', () async { + test('should_keep_requested_section_and_read_episode_one_when_constructed', () async { final history = FakeWatchHistory()..saved = const Duration(seconds: 7); final logic = MineLogic( history: history, @@ -47,7 +47,7 @@ void main() { logic.dispose(); }); - test('a list card without episodes resumes from the last watch', () async { + test('should_resume_from_last_watch_when_list_card_has_no_episodes', () async { final history = FakeWatchHistory() ..saved = const Duration(seconds: 7) ..lastEpisode = 'signal-3'; @@ -62,7 +62,7 @@ void main() { logic.dispose(); }); - test('section and filter selections notify', () { + test('should_notify_when_section_and_filter_are_selected', () { final logic = MineLogic( history: FakeWatchHistory(), drama: _drama('s'), @@ -81,7 +81,7 @@ void main() { logic.dispose(); }); - test('syncPage only adopts a drama while the page is active', () { + test('should_adopt_drama_only_when_page_is_active', () { final history = FakeWatchHistory(); final logic = MineLogic( history: history, @@ -125,7 +125,7 @@ void main() { logic.dispose(); }); - test('a section request resets the section even while the page is inactive', () { + test('should_reset_section_when_section_request_arrives_while_page_is_inactive', () { final logic = MineLogic( history: FakeWatchHistory(), drama: _drama('s'), @@ -146,7 +146,7 @@ void main() { logic.dispose(); }); - testWidgets('act returns the choice for a page and forwards it when embedded', ( + testWidgets('should_return_choice_and_forward_it_when_act_runs_embedded', ( tester, ) async { final logic = MineLogic( @@ -197,7 +197,7 @@ void main() { logic.dispose(); }); - testWidgets('the language sheet switches the app locale', (tester) async { + testWidgets('should_switch_app_locale_when_language_sheet_is_used', (tester) async { SharedPreferencesAsyncPlatform.instance = InMemorySharedPreferencesAsync.empty(); final locale = LocaleController(); @@ -239,7 +239,7 @@ void main() { logic.dispose(); }); - test('notify after dispose is a no-op', () { + test('should_do_nothing_when_notifying_after_dispose', () { final logic = MineLogic( history: FakeWatchHistory(), drama: _drama('s'), diff --git a/test/playback/playback_preload_test.dart b/test/playback/playback_preload_test.dart index 4dc671b..a4f09a8 100644 --- a/test/playback/playback_preload_test.dart +++ b/test/playback/playback_preload_test.dart @@ -17,7 +17,7 @@ void main() { ), ); - test('warm playback starts before old native disposal finishes', () async { + test('should_start_warm_playback_when_old_native_disposal_is_still_running', () async { final release = Completer(); final factory = _Factory(disposeGates: {'ep-0': release}); final session = PlaybackSession( @@ -41,7 +41,7 @@ void main() { await session.close(); }); - test('failed native release blocks another route from allocating', () async { + test('should_block_another_route_from_allocating_when_native_release_fails', () async { final factory = _Factory(disposeFailures: {'ep-0'}); final coordinator = PlaybackCoordinator(); PlaybackSession createSession() => PlaybackSession( @@ -68,7 +68,7 @@ void main() { }); test( - 'next is prepared silently and promoted without another initialize', + 'should_prepare_next_silently_and_promote_it_when_swiped', () async { final factory = _Factory(); final prepared = []; @@ -103,7 +103,7 @@ void main() { }, ); - test('in-flight preload is reused when swiped before ready', () async { + test('should_reuse_in_flight_preload_when_swiped_before_ready', () async { final gate = Completer(); final factory = _Factory(gates: {'ep-1': gate}); final session = PlaybackSession( @@ -127,7 +127,7 @@ void main() { await session.close(); }); - test('rapid reverse and skipped selection discard stale warm work', () async { + test('should_discard_stale_warm_work_when_reversing_rapidly_or_skipping_selection', () async { final gate = Completer(); final factory = _Factory(gates: {'ep-1': gate}); final session = PlaybackSession( @@ -153,7 +153,7 @@ void main() { }); test( - 'category adjacency and locked next never preload the wrong episode', + 'should_never_preload_wrong_episode_when_next_is_locked_or_category_based', () async { final factory = _Factory(); final session = PlaybackSession( @@ -172,7 +172,7 @@ void main() { }, ); - test('preload failure is isolated and selecting it retries once', () async { + test('should_isolate_preload_failure_and_retry_once_when_selected', () async { final factory = _Factory(failOnce: {'ep-1'}); final session = PlaybackSession( episodes: episodes, @@ -190,7 +190,7 @@ void main() { await session.close(); }); - test('completion in background never starts either player', () async { + test('should_start_no_player_when_completion_happens_in_background', () async { final gate = Completer(); final factory = _Factory(gates: {'ep-1': gate}); final session = PlaybackSession( @@ -215,7 +215,7 @@ void main() { await session.close(); }); - test('closing during preloading disposes pending resources', () async { + test('should_dispose_pending_resources_when_closing_during_preload', () async { final gate = Completer(); final factory = _Factory(gates: {'ep-1': gate}); final session = PlaybackSession( @@ -233,7 +233,7 @@ void main() { }); test( - 'home and series share a two-player budget across route handoff', + 'should_share_two_player_budget_when_handing_off_between_home_and_series', () async { final factory = _Factory(); final coordinator = PlaybackCoordinator(); diff --git a/test/playback/playback_queue_test.dart b/test/playback/playback_queue_test.dart index 179f4a2..1117367 100644 --- a/test/playback/playback_queue_test.dart +++ b/test/playback/playback_queue_test.dart @@ -3,7 +3,7 @@ import 'package:nontonki/core/data/models/drama.dart'; import 'package:nontonki/core/data/services/playback_queue.dart'; void main() { - test('home feed advances between dramas, series player between episodes', () { + test('should_advance_between_dramas_on_home_and_between_episodes_in_series_when_queue_is_built', () { final dramas = [_drama('a', 3), _drama('b', 2), _drama('c', 4)]; final home = PlaybackQueue.home(dramas); @@ -22,7 +22,7 @@ void main() { expect(series.nextIndex(2), isNull); }); - test('dramas without episodes are left out of the home queue', () { + test('should_leave_dramas_out_when_they_have_no_episodes', () { final home = PlaybackQueue.home([ _drama('a', 2), Drama( @@ -36,7 +36,7 @@ void main() { expect(home.entryAt(0).drama.id, 'a'); }); - test('a list card with a preview episode plays on the home feed', () { + test('should_play_preview_episode_when_list_card_has_one', () { final home = PlaybackQueue.home([ Drama.fromCardJson(const { 'id': 5, diff --git a/test/playback/playback_session_test.dart b/test/playback/playback_session_test.dart index 99e17ab..de700d1 100644 --- a/test/playback/playback_session_test.dart +++ b/test/playback/playback_session_test.dart @@ -17,7 +17,7 @@ void main() { ), ); - test('locked episode never creates or initializes a player', () async { + test('should_create_no_player_when_episode_is_locked', () async { final factory = FakeFactory(); final session = PlaybackSession( episodes: episodes, @@ -30,7 +30,7 @@ void main() { await session.close(); }); - test('rapid selection drops stale initialize and keeps one player', () async { + test('should_drop_stale_initialize_and_keep_one_player_when_selection_is_rapid', () async { final factory = FakeFactory(holdFirstInitialize: true); final session = PlaybackSession( episodes: episodes, @@ -52,7 +52,7 @@ void main() { }); test( - 'background and overlay pause without forgetting playback intent', + 'should_pause_without_forgetting_intent_when_backgrounding_or_overlay_shows', () async { final factory = FakeFactory(); final session = PlaybackSession( @@ -80,7 +80,7 @@ void main() { }, ); - test('resume preparation finishes before video starts', () async { + test('should_finish_resume_preparation_before_video_starts_when_resuming', () async { final factory = FakeFactory(); final prepared = Completer(); final session = PlaybackSession( @@ -99,7 +99,7 @@ void main() { await session.close(); }); - test('pausing then swiping to the next episode resumes playback', () async { + test('should_resume_playback_when_swiping_after_pause', () async { final factory = FakeFactory(); final session = PlaybackSession( episodes: episodes, @@ -121,7 +121,7 @@ void main() { await session.close(); }); - test('re-selecting the same episode keeps the user pause', () async { + test('should_keep_user_pause_when_reselecting_the_same_episode', () async { final factory = FakeFactory(); final session = PlaybackSession( episodes: episodes, @@ -140,7 +140,7 @@ void main() { await session.close(); }); - test('automatic advance respects visibility and playback intent', () async { + test('should_respect_visibility_and_intent_when_advancing_automatically', () async { final factory = FakeFactory(); final session = PlaybackSession( episodes: episodes, diff --git a/test/playback/seek_progress_bar_test.dart b/test/playback/seek_progress_bar_test.dart index 01f1114..137e7db 100644 --- a/test/playback/seek_progress_bar_test.dart +++ b/test/playback/seek_progress_bar_test.dart @@ -4,7 +4,7 @@ import 'package:nontonki/pages/player/widgets/seek_progress_bar.dart'; import 'package:video_player/video_player.dart'; void main() { - test('seek target stays inside playable duration', () { + test('should_keep_seek_target_inside_playable_duration_when_dragging', () { const duration = Duration(seconds: 12); expect(seekPositionForFraction(0, duration), Duration.zero); expect( @@ -14,7 +14,7 @@ void main() { expect(seekPositionForFraction(1, duration), lessThan(duration)); }); - testWidgets('horizontal slider drag previews and seeks on release', ( + testWidgets('should_preview_while_dragging_and_seek_on_release_when_slider_is_horizontal', ( tester, ) async { final video = ValueNotifier( @@ -61,7 +61,7 @@ void main() { expect(target!, lessThan(const Duration(seconds: 12))); }); - testWidgets('compact seek bar shows time only while dragging', ( + testWidgets('should_show_time_only_while_dragging_when_seek_bar_is_compact', ( tester, ) async { final video = ValueNotifier( diff --git a/test/playback/video_player_port_test.dart b/test/playback/video_player_port_test.dart index 0c7553c..5a35138 100644 --- a/test/playback/video_player_port_test.dart +++ b/test/playback/video_player_port_test.dart @@ -12,7 +12,7 @@ Episode _episode(String videoUrl) => Episode( ); void main() { - test('相对播放地址补上服务地址', () { + test('should_prefix_service_base_when_play_url_is_relative', () { final uri = VideoPlayerPort.resolveUri( _episode('/files/episode/202610/clip.mp4'), ); @@ -27,7 +27,7 @@ void main() { ); }); - test('已经是绝对地址的不再拼接', () { + test('should_keep_url_untouched_when_play_url_is_absolute', () { final uri = VideoPlayerPort.resolveUri( _episode('https://cdn.example.test/clip.mp4'), ); diff --git a/test/playback/watch_history_test.dart b/test/playback/watch_history_test.dart index 8e3c081..d814deb 100644 --- a/test/playback/watch_history_test.dart +++ b/test/playback/watch_history_test.dart @@ -5,7 +5,7 @@ import 'package:shared_preferences_platform_interface/in_memory_shared_preferenc import 'package:shared_preferences_platform_interface/shared_preferences_async_platform_interface.dart'; void main() { - test('resume position clamps invalid and completed values', () { + test('should_clamp_invalid_and_completed_values_when_resolving_resume_position', () { const duration = Duration(seconds: 8); expect( clampResumePosition(const Duration(seconds: -1), duration), @@ -25,7 +25,7 @@ void main() { ); }); - test('watch history is scoped by profile, drama and episode', () async { + test('should_scope_history_by_profile_drama_and_episode_when_saving', () async { SharedPreferencesAsyncPlatform.instance = InMemorySharedPreferencesAsync.empty(); final history = SharedPreferencesWatchHistoryRepository(); @@ -53,7 +53,7 @@ void main() { expect(await history.lastEpisodeId('profile-a', 'drama-b'), isNull); }); - test('resume prefers the first loaded episode', () async { + test('should_prefer_first_loaded_episode_when_resuming', () async { SharedPreferencesAsyncPlatform.instance = InMemorySharedPreferencesAsync.empty(); final history = SharedPreferencesWatchHistoryRepository(); @@ -87,7 +87,7 @@ void main() { ); }); - test('resume falls back to the last watched episode for a list card', () async { + test('should_fall_back_to_last_watched_episode_when_resuming_a_list_card', () async { SharedPreferencesAsyncPlatform.instance = InMemorySharedPreferencesAsync.empty(); final history = SharedPreferencesWatchHistoryRepository(); @@ -112,7 +112,7 @@ void main() { ); }); - test('a list card with no history has no resume position', () async { + test('should_have_no_resume_position_when_list_card_has_no_history', () async { SharedPreferencesAsyncPlatform.instance = InMemorySharedPreferencesAsync.empty(); final history = SharedPreferencesWatchHistoryRepository(); diff --git a/test/player/player_logic_test.dart b/test/player/player_logic_test.dart index 1dedbf4..6a71cbe 100644 --- a/test/player/player_logic_test.dart +++ b/test/player/player_logic_test.dart @@ -55,7 +55,7 @@ void main() { TestWidgetsFlutterBinding.ensureInitialized(); group('displayEpisode', () { - test('falls back until a number is picked for that drama', () { + test('should_fall_back_until_episode_number_is_picked_for_that_drama_when_resolving', () { final logic = _logic(FakeWatchHistory()); final drama = _drama('signal'); final fallback = drama.episodes.first; @@ -70,7 +70,7 @@ void main() { expect(logic.displayEpisode(city, city.episodes.first).number, 1); }); - test('an unknown picked number stops overriding the fallback', () { + test('should_stop_overriding_fallback_when_picked_number_is_unknown', () { final logic = _logic(FakeWatchHistory()); final drama = _drama('signal'); final fallback = drama.episodes.first; @@ -82,7 +82,7 @@ void main() { }); group('nextVisibleIndex', () { - test('walks the visible list and stops at the end', () { + test('should_walk_visible_list_and_stop_at_the_end_when_advancing', () { final logic = _logic(FakeWatchHistory()); logic.visibleIndices = [0, 2, 4]; @@ -91,7 +91,7 @@ void main() { expect(logic.nextVisibleIndex(4), isNull); }); - test('an index outside the visible list has no successor', () { + test('should_have_no_successor_when_index_is_outside_visible_list', () { final logic = _logic(FakeWatchHistory()); logic.visibleIndices = [0, 2, 4]; @@ -100,7 +100,7 @@ void main() { expect(logic.nextVisibleIndex(-1), isNull); }); - test('an empty visible list has no successor', () { + test('should_have_no_successor_when_visible_list_is_empty', () { final logic = _logic(FakeWatchHistory()); logic.visibleIndices = []; @@ -109,7 +109,7 @@ void main() { }); group('surface flags', () { - test('clearing the screen hides the chrome until it is restored', () { + test('should_hide_chrome_until_restored_when_screen_is_cleared', () { final logic = _logic(FakeWatchHistory()); final immersive = []; logic.onImmersiveChanged = immersive.add; @@ -135,7 +135,7 @@ void main() { expect(immersive, [true, false]); }); - test('a picture in picture callback outranks the cleared screen flag', () async { + test('should_outrank_cleared_screen_flag_when_picture_in_picture_callback_fires', () async { final factory = _RecordingFactory(); final drama = _drama('signal'); final logic = _logic(FakeWatchHistory()); @@ -164,7 +164,7 @@ void main() { await _drain(logic); }); - test('a picture in picture callback is ignored once unmounted', () { + test('should_ignore_picture_in_picture_callback_when_unmounted', () { final logic = _logic(FakeWatchHistory()); logic.isMounted = () => false; @@ -175,7 +175,7 @@ void main() { }); group('history writes', () { - test('progress writes are serialized in call order', () async { + test('should_serialize_progress_writes_in_call_order_when_saving', () async { final history = FakeWatchHistory(); final logic = _logic(history); final drama = _drama('signal'); @@ -197,7 +197,7 @@ void main() { ]); }); - test('a failed write does not drop the writes after it', () async { + test('should_keep_later_writes_when_an_earlier_write_fails', () async { final history = FakeWatchHistory(); final logic = _logic(history); final drama = _drama('signal'); @@ -219,7 +219,7 @@ void main() { expect(history.writes, ['demo-local-v1|signal|signal-2|2000']); }); - test('saving with no tracked player writes nothing', () async { + test('should_write_nothing_when_no_player_is_tracked', () async { final history = FakeWatchHistory(); final logic = _logic(history); @@ -232,7 +232,7 @@ void main() { }); group('start', () { - test('a detail route plays a single series', () async { + test('should_play_single_series_when_route_is_detail', () async { final factory = _RecordingFactory(); final drama = _drama('signal'); final logic = _logic(FakeWatchHistory()); @@ -255,7 +255,7 @@ void main() { expect(factory.live, 0); }); - test('home mode plays one episode per feed drama', () async { + test('should_play_one_episode_per_feed_drama_when_in_home_mode', () async { final factory = _RecordingFactory(); final feed = [_drama('signal'), _drama('city'), _drama('vengeance')]; final logic = _logic(FakeWatchHistory()); @@ -281,7 +281,7 @@ void main() { await _drain(logic); }); - test('a locked episode never reaches the player factory', () async { + test('should_never_reach_player_factory_when_episode_is_locked', () async { final factory = _RecordingFactory(); final drama = _drama('locked', isFree: false); final logic = _logic(FakeWatchHistory()); @@ -300,7 +300,7 @@ void main() { await _drain(logic); }); - test('starting from a later index only preloads what follows it', () async { + test('should_preload_only_what_follows_when_starting_from_a_later_index', () async { final factory = _RecordingFactory(); final drama = _drama('signal'); final logic = _logic(FakeWatchHistory()); @@ -320,7 +320,7 @@ void main() { await _drain(logic); }); - test('an inactive route holds no players until it becomes visible', () async { + test('should_hold_no_players_when_route_is_inactive', () async { final factory = _RecordingFactory(); final drama = _drama('signal'); final logic = _logic(FakeWatchHistory()); @@ -341,7 +341,7 @@ void main() { }); group('lifecycle', () { - test('backgrounding pauses the active player and resuming plays it', () async { + test('should_pause_active_player_when_backgrounded_and_play_it_when_resumed', () async { final factory = _RecordingFactory(); final drama = _drama('signal'); final logic = _logic(FakeWatchHistory()); @@ -368,7 +368,7 @@ void main() { await _drain(logic); }); - test('an inactive route stops playing without losing the intent', () async { + test('should_stop_playing_without_losing_intent_when_route_becomes_inactive', () async { final factory = _RecordingFactory(); final drama = _drama('signal'); final logic = _logic(FakeWatchHistory()); @@ -398,7 +398,7 @@ void main() { }); group('dispose', () { - test('is safe to repeat and releases every player', () async { + test('should_release_every_player_when_dispose_runs_twice', () async { final factory = _RecordingFactory(); final drama = _drama('signal'); final logic = _logic(FakeWatchHistory()); @@ -417,7 +417,7 @@ void main() { expect(() => logic.dispose(), returnsNormally); }); - test('disables further notifications', () async { + test('should_disable_further_notifications_when_disposed', () async { final factory = _RecordingFactory(); final drama = _drama('signal'); final logic = _logic(FakeWatchHistory()); diff --git a/test/widget_test.dart b/test/widget_test.dart index 6a63e43..28f02e2 100644 --- a/test/widget_test.dart +++ b/test/widget_test.dart @@ -28,7 +28,7 @@ void main() { }); testWidgets( - 'home swipe promotes next without recreating it or showing loading', + 'should_promote_next_without_recreating_it_or_showing_loading_when_home_is_swiped', (tester) async { final created = []; await tester.pumpWidget( @@ -57,7 +57,7 @@ void main() { }, ); - testWidgets('immersive home opens the series detail', (tester) async { + testWidgets('should_open_series_detail_when_immersive_home_is_tapped', (tester) async { tester.view.physicalSize = const Size(390, 844); tester.view.devicePixelRatio = 1; addTearDown(tester.view.resetPhysicalSize); @@ -82,7 +82,7 @@ void main() { expect(find.byTooltip('Explore series'), findsNothing); }); - testWidgets('clear screen hides tabs and restores them on tap', ( + testWidgets('should_hide_tabs_and_restore_them_when_clear_screen_is_tapped', ( tester, ) async { tester.view.physicalSize = const Size(390, 844); @@ -107,7 +107,7 @@ void main() { expect(tester.takeException(), isNull); }); - testWidgets('home quick drawer opens current series and switches root tabs', ( + testWidgets('should_open_current_series_and_switch_root_tabs_when_quick_drawer_is_used', ( tester, ) async { tester.view.physicalSize = const Size(360, 720); @@ -162,7 +162,7 @@ void main() { ); }); - testWidgets('interface language changes without a caption control', ( + testWidgets('should_change_interface_language_when_locale_is_picked', ( tester, ) async { tester.view.physicalSize = const Size(390, 844); @@ -193,7 +193,7 @@ void main() { expect(find.text('热门'), findsOneWidget); }); - testWidgets('home controls fit a compact Android viewport', (tester) async { + testWidgets('should_fit_compact_android_viewport_when_home_controls_are_shown', (tester) async { tester.view.physicalSize = const Size(360, 720); tester.view.devicePixelRatio = 1; addTearDown(tester.view.resetPhysicalSize); @@ -217,7 +217,7 @@ void main() { expect(tester.takeException(), isNull); }); - testWidgets('My page fits a compact Android viewport and returns home', ( + testWidgets('should_fit_compact_android_viewport_and_return_home_when_my_page_is_shown', ( tester, ) async { tester.view.physicalSize = const Size(360, 720); @@ -241,7 +241,7 @@ void main() { }); testWidgets( - 'Discover shows three mock playable dramas and one pending poster', + 'should_show_three_playable_dramas_and_one_pending_poster_when_discover_is_opened', (tester) async { tester.view.physicalSize = const Size(360, 720); tester.view.devicePixelRatio = 1; @@ -276,7 +276,7 @@ void main() { }, ); - testWidgets('bottom tabs stay on one route', (tester) async { + testWidgets('should_stay_on_one_route_when_bottom_tabs_are_used', (tester) async { tester.view.physicalSize = const Size(390, 844); tester.view.devicePixelRatio = 1; addTearDown(tester.view.resetPhysicalSize); @@ -327,7 +327,7 @@ void main() { }); testWidgets( - 'home swipe changes drama, entered player swipe changes episode', + 'should_change_drama_on_home_swipe_and_episode_on_player_swipe_when_swiping', (tester) async { tester.view.physicalSize = const Size(390, 844); tester.view.devicePixelRatio = 1; @@ -359,7 +359,7 @@ void main() { }, ); - testWidgets('shorts page has no category navigation', (tester) async { + testWidgets('should_hide_category_navigation_when_shorts_page_is_shown', (tester) async { tester.view.physicalSize = const Size(390, 844); tester.view.devicePixelRatio = 1; addTearDown(tester.view.resetPhysicalSize); @@ -381,7 +381,7 @@ void main() { expect(find.text('City Lights & Velvet Nights'), findsOneWidget); expect(tester.takeException(), isNull); }); - testWidgets('right rail saves, comments, likes and invokes share in order', ( + testWidgets('should_save_comment_like_and_share_in_order_when_right_rail_is_used', ( tester, ) async { tester.view.physicalSize = const Size(390, 844); @@ -439,7 +439,7 @@ void main() { expect(tester.takeException(), isNull); }); - testWidgets('system back opens the drawer and stays on home', (tester) async { + testWidgets('should_open_drawer_and_stay_on_home_when_system_back_is_pressed', (tester) async { tester.view.physicalSize = const Size(390, 844); tester.view.devicePixelRatio = 1; addTearDown(tester.view.resetPhysicalSize); @@ -466,7 +466,7 @@ void main() { ); }); - testWidgets('My watchlist lists saved dramas across the home feed', ( + testWidgets('should_list_saved_dramas_across_home_feed_when_watchlist_is_opened', ( tester, ) async { tester.view.physicalSize = const Size(390, 844); -- 2.54.0 From 61454e36b1aa40a0266999ef0f9adcfd4e271823 Mon Sep 17 00:00:00 2001 From: Vicky <10212746+haifeng-jiang@user.noreply.gitee.com> Date: Fri, 16 Oct 2026 10:16:59 +0800 Subject: [PATCH 07/76] =?UTF-8?q?feat(client):=20=E6=94=B9=E5=90=8D?= =?UTF-8?q?=E4=B8=BA=20FruitShorts=20=E5=B9=B6=E6=96=B0=E5=A2=9E=20id-ID?= =?UTF-8?q?=20=E5=8D=B0=E5=B0=BC=E8=AF=AD=E6=96=87=E6=A1=88=EF=BC=881-3=20?= =?UTF-8?q?+=201-4=20=E5=90=88=E5=B9=B6=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 为什么:a) 应用对外名称要统一成 FruitShorts(产品名,nontonki 是原型代号); b) 首发市场是印尼,界面必须有印尼语;c) 归档要求"新增 id-ID 与改名合并生成一次 l10n,别分两次"。 改名: - pubspec name: nontonki → fruitshorts(Dart 包名),description 同步;28 个文件的 package: 导入前缀替换 - Android android:label、iOS CFBundleDisplayName/CFBundleName → FruitShorts - 图标资源 assets/icon/nontonki.png → fruitshorts.png(含 pubspec 两处引用) - README 同步(补印尼语说明,顺带修掉写错的模块名 reelshort-app-api → fruitshorts-app-api) 文案: - 三份 arb 的 appName → FruitShorts、brandMark → FRUITSHORTS、shareFooter → FruitShorts(不留 demo 标记) - 新增 lib/l10n/app_id.arb:174 个值键与 en/zh 完全一致,按印尼语习惯翻译(Coin→Koin、Episode→Episode) - 一次性 flutter gen-l10n 生成 app_localizations_id.dart;id 自动进入 supportedLocales,默认 locale 未改 - 新增 test/config/l10n_id_test.dart:钉住 id 文案、supportedLocales 含 id、品牌文案无 demo 标记、占位符渲染 不动:applicationId / bundle id(lumadrama 遗留,等裁定)、目录名、业务逻辑与页面结构、语言选择页(仍只有 en/zh) 门禁:dart analyze lib test 零告警;flutter test 159 全过(基线 155 + 新增 4);残留扫描 0 命中; 三份 arb 键集一致(174/174/174);真机(iPhone iOS 26.6.1)构建安装启动成功,devicectl 列出显示名 FruitShorts --- README.md | 4 +- android/app/src/main/AndroidManifest.xml | 2 +- ios/Runner/Info.plist | 4 +- lib/l10n/app_en.arb | 6 +- lib/l10n/app_id.arb | 184 ++++++ lib/l10n/app_localizations.dart | 12 +- lib/l10n/app_localizations_en.dart | 6 +- lib/l10n/app_localizations_id.dart | 556 ++++++++++++++++++ lib/l10n/app_localizations_zh.dart | 6 +- lib/l10n/app_zh.arb | 6 +- lib/pages/auth/auth_view.dart | 2 +- pubspec.yaml | 8 +- test/auth/auth_controller_test.dart | 9 +- test/auth/auth_page_test.dart | 12 +- test/catalog/catalog_controller_test.dart | 10 +- test/catalog/drama_model_test.dart | 2 +- test/config/l10n_id_test.dart | 48 ++ test/config/locale_controller_test.dart | 2 +- .../core/android_picture_in_picture_test.dart | 2 +- test/core/api_client_test.dart | 2 +- test/discover/cover_carousel_test.dart | 2 +- test/discover/discover_logic_test.dart | 6 +- .../drama_detail/drama_detail_logic_test.dart | 6 +- .../engagement_controller_test.dart | 4 +- .../engagement_repository_test.dart | 4 +- test/formatting/localized_content_test.dart | 8 +- test/home/home_logic_test.dart | 8 +- test/integration/live_auth_test.dart | 4 +- test/integration/live_catalog_test.dart | 4 +- test/mine/mine_logic_test.dart | 8 +- test/playback/playback_preload_test.dart | 6 +- test/playback/playback_queue_test.dart | 4 +- test/playback/playback_session_test.dart | 6 +- test/playback/seek_progress_bar_test.dart | 2 +- test/playback/video_player_port_test.dart | 6 +- test/playback/watch_history_test.dart | 4 +- test/player/player_logic_test.dart | 12 +- test/support/fake_catalog.dart | 8 +- test/support/fake_watch_history.dart | 2 +- test/support/widget_player.dart | 4 +- test/widget_test.dart | 4 +- 41 files changed, 893 insertions(+), 102 deletions(-) create mode 100644 lib/l10n/app_id.arb create mode 100644 lib/l10n/app_localizations_id.dart create mode 100644 test/config/l10n_id_test.dart diff --git a/README.md b/README.md index 8ee766b..004a776 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ - **沉浸式首页**:竖屏播放,上下滑切换短剧,左右滑切换内容类别;支持拖动进度、横屏全屏观看。 - **剧集播放**:从详情页进入后按集连续播放,支持选集和本地续看。 - **找剧与个人页**:浏览、搜索和查看剧集详情;在个人页查看观看记录、收藏与喜欢的内容。 -- **互动与多语言**:本地演示评论、系统分享,以及英文和简体中文界面。 +- **互动与多语言**:本地演示评论、系统分享,以及英文、简体中文和印尼语界面。 - **画中画**:Android 接入系统画中画;iOS 画中画尚未实现。 ## 技术实现 @@ -14,7 +14,7 @@ ## 对接后端 -目录数据来自短剧服务的客户端接口(`FruitServer` 的 `reelshort-app-api`,默认 `http://127.0.0.1:8081`): +目录数据来自短剧服务的客户端接口(`FruitServer` 的 `fruitshorts-app-api`,默认 `http://127.0.0.1:8081`): - `GET /app/home/feed`、`GET /app/discover/feed`:轮播 + 分区,一次请求渲染整页。 每张卡片带 `preview`(首个可播免费集),首页竖屏播放可以直接起播; diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 6b90a62..bd2525e 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -1,7 +1,7 @@ CFBundleDevelopmentRegion $(DEVELOPMENT_LANGUAGE) CFBundleDisplayName - Nontonki + FruitShorts CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIdentifier @@ -15,7 +15,7 @@ CFBundleInfoDictionaryVersion 6.0 CFBundleName - Nontonki + FruitShorts CFBundlePackageType APPL CFBundleShortVersionString diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index e9b4cfe..ef8e20c 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -1,6 +1,6 @@ { "@@locale": "en", - "appName": "Nontonki", + "appName": "FruitShorts", "demo": "DEMO", "homeHeadline": "Watch now", "homeSubtitle": "Free short drama preview.", @@ -131,8 +131,8 @@ "genreDramaMystery": "Drama · Mystery", "continueWatchingHeading": "CONTINUE WATCHING", "preferencesHeading": "PREFERENCES", - "brandMark": "NONTONKI · DEMO", - "shareFooter": "Nontonki demo", + "brandMark": "FRUITSHORTS", + "shareFooter": "FruitShorts", "shortsTab": "Shorts", "myListTab": "My List", "watchFull": "Watch Full", diff --git a/lib/l10n/app_id.arb b/lib/l10n/app_id.arb new file mode 100644 index 0000000..788b6e7 --- /dev/null +++ b/lib/l10n/app_id.arb @@ -0,0 +1,184 @@ +{ + "@@locale": "id", + "appName": "FruitShorts", + "demo": "Demo", + "homeHeadline": "Tonton sekarang", + "homeSubtitle": "Pratinjau drama pendek gratis.", + "mediaNotice": "Video demo lokal dari pengguna · Pratinjau gratis", + "featuredDemo": "UNGGULAN · DEMO TEKNIS", + "demoTitle": "Sinyal", + "demoSynopsis": "Pratinjau video lokal singkat. Episode lain bisa ditambahkan saat medianya tersedia.", + "homeTab": "Beranda", + "openQuickMenu": "Buka menu cepat", + "quickAccess": "Akses cepat", + "currentSeries": "Serial saat ini", + "discoverTab": "Jelajahi", + "searchDiscover": "Cari drama, aktor, genre...", + "featured": "Unggulan", + "suspense": "Thriller", + "romance": "Romantis", + "actionGenre": "Aksi", + "filter": "Filter", + "topCharts": "Peringkat Teratas", + "newReleases": "Rilisan Baru", + "trendingMicroDramas": "Drama Mini Populer", + "seeAll": "Lihat Semua", + "artworkOnly": "Gambar", + "artworkOnlyNotice": "Ini hanya gambar katalog. Videonya belum tersedia.", + "videoPending": "Video belum siap", + "watchNow": "Tonton gratis", + "noSearchResults": "Tidak ada drama yang cocok.", + "demoCatalogNotice": "Tiga drama demo memakai video lokal yang sama.", + "myTab": "Saya", + "localViewer": "Penonton Lokal", + "localDemoProfile": "Profil demo lokal", + "continueWatching": "Lanjut Tonton", + "watchedPercent": "Sudah ditonton {percent}%", + "@watchedPercent": {"placeholders": {"percent": {"type": "int"}}}, + "resume": "Lanjutkan", + "history": "Riwayat", + "watchlist": "Daftar Tonton", + "likedTab": "Disukai", + "all": "Semua", + "inProgress": "Sedang Berjalan", + "completed": "Selesai", + "noSavedShows": "Belum ada tontonan di sini.", + "preferences": "Preferensi", + "appLanguage": "Bahasa Aplikasi", + "followingTab": "Mengikuti", + "animatedTab": "Animasi", + "recommendedTab": "Rekomendasi", + "noCategoryDramas": "Belum ada drama di kategori ini.", + "trendingTab": "Sedang Tren", + "liveActionTab": "Live Action", + "search": "Cari", + "free": "Gratis", + "mute": "Bisukan", + "unmute": "Nyalakan suara", + "like": "Suka", + "save": "Simpan", + "comments": "Komentar", + "share": "Bagikan", + "localOnlyComments": "Hanya terlihat di perangkat ini", + "noComments": "Belum ada komentar.", + "writeComment": "Tulis komentar", + "postComment": "Kirim", + "shareFailed": "Tidak bisa membuka menu berbagi.", + "nowPlaying": "Sedang diputar", + "watchFullscreen": "Tonton mode lanskap", + "exitFullscreen": "Keluar dari layar penuh", + "pictureInPicture": "Gambar dalam gambar", + "pipUnavailable": "Gambar dalam gambar tidak tersedia di perangkat ini", + "originalTag": "Original", + "dramaTag": "Drama pendek", + "episodeLabel": "Episode {number}", + "@episodeLabel": {"placeholders": {"number": {"type": "int"}}}, + "exploreSeries": "Lihat serial", + "episodeCount": "{count} EPISODE", + "@episodeCount": {"placeholders": {"count": {"type": "int"}}}, + "technicalDemoCount": "PRATINJAU GRATIS · {count} EPISODE", + "@technicalDemoCount": {"placeholders": {"count": {"type": "int"}}}, + "episodes": "Episode", + "watchEpisodeOne": "Tonton episode 1", + "continueEpisode": "Lanjut episode {number}", + "@continueEpisode": {"placeholders": {"number": {"type": "int"}}}, + "freeTestMedia": "Klip demo sama · gratis", + "lockedStoreUnavailable": "Terkunci · toko belum tersedia", + "freeTestClip": "Klip uji gratis", + "locked": "Terkunci", + "freeSamplesNotice": "Dua sampel gratis · pengaturan toko belum selesai", + "demoTestMedia": "GRATIS · KLIP DEMO SAMA", + "episodeProgress": "EPISODE {number} / {total}", + "@episodeProgress": {"placeholders": {"number": {"type": "int"}, "total": {"type": "int"}}}, + "testVideoNotice": "Video uji teknis buatan sendiri", + "lockedTitle": "Episode {number} terkunci", + "@lockedTitle": {"placeholders": {"number": {"type": "int"}}}, + "lockedBody": "Pembukaan kunci tersedia setelah toko dan verifikasi disiapkan. Demo ini tidak memproses pembayaran.", + "playbackError": "Klip ini tidak bisa diputar.", + "catalogError": "Katalog gagal dimuat.", + "detailError": "Daftar episode gagal dimuat.", + "noMediaNotice": "Episode ini belum punya media yang bisa diputar.", + "noStories": "Belum ada cerita.", + "retry": "Coba lagi", + "backToSeries": "Kembali ke serial", + "nextEpisode": "Episode berikutnya", + "pause": "Jeda", + "play": "Putar", + "seekVideo": "Geser posisi video", + "seekFailed": "Gagal mengubah posisi putar.", + "captions": "Subtitle", + "captionsOff": "Subtitle nonaktif", + "englishCaptions": "Subtitle bahasa Inggris", + "chineseCaptions": "Subtitle bahasa Mandarin", + "language": "Bahasa", + "systemLanguage": "Sistem", + "english": "English", + "simplifiedChinese": "简体中文", + "episodeOneTitle": "Cahaya Pertama", + "episodeTwoTitle": "Frekuensi Baru", + "episodeThreeTitle": "Menyeberang", + "episodeFourTitle": "Setelah Gema", + "dramaSignalTitle": "Sinyal", + "dramaSignalSynopsis": "Serial demo untuk tontonan vertikal. Setiap episode memakai satu klip lokal yang sama.", + "dramaCityTitle": "Cahaya Kota & Malam Beludru", + "dramaCitySynopsis": "Serial romansa demo. Video lokal yang sama dipakai untuk mencoba pindah episode dan lanjut tonton.", + "dramaVengeanceTitle": "Badai Pembalasan", + "dramaVengeanceSynopsis": "Serial aksi demo. Video lokal yang sama dipakai untuk mencoba pindah episode dan lanjut tonton.", + "dramaEchoesTitle": "Gema Takdir", + "genreSuspenseMystery": "Thriller · Misteri", + "genreUrbanRomance": "Romansa Kota", + "genreActionThriller": "Aksi · Thriller", + "genreDramaMystery": "Drama · Misteri", + "continueWatchingHeading": "LANJUT TONTON", + "preferencesHeading": "PREFERENSI", + "brandMark": "FRUITSHORTS", + "shareFooter": "FruitShorts", + "shortsTab": "Drama Pendek", + "myListTab": "Daftar Saya", + "watchFull": "Tonton Penuh", + "swipeForNext": "Geser ke atas untuk lanjut", + "clearScreen": "Bersihkan layar", + "exitClearScreen": "Keluar dari mode bersih", + "logIn": "Masuk", + "logInHint": "Simpan koin dan daftar kamu", + "rewards": "Hadiah", + "forYou": "Untuk Kamu", + "hot": "Populer", + "newest": "Terbaru", + "favorite": "Favorit", + "myAccount": "Akun saya", + "coins": "Koin", + "topUpWallet": "Isi Ulang Dompet", + "vipMembership": "Keanggotaan VIP", + "notActive": "Tidak Aktif", + "joinVip": "Gabung VIP", + "earnRewards": "Dapatkan Hadiah", + "freeBonus": "Bonus Gratis", + "watchHistory": "Riwayat Tontonan", + "settings": "Pengaturan", + "signOut": "Keluar", + "mockUserName": "Vicky sheng", + "mockUserId": "ID: M1CZWVYE", + "mockNotice": "Hanya data contoh.", + "topBadge": "TOP 1", + "signIn": "Masuk", + "signUp": "Daftar", + "authSignInTitle": "Selamat datang kembali", + "authSignUpTitle": "Buat akun kamu", + "authSubtitle": "Masuk dengan email dan kata sandi.", + "authEmailLabel": "Email", + "authPasswordLabel": "Kata sandi", + "authPasswordHint": "Minimal 8 karakter, berisi huruf dan angka", + "authEmailRequired": "Masukkan email kamu", + "authEmailInvalid": "Email itu sepertinya tidak benar", + "authPasswordRequired": "Masukkan kata sandi kamu", + "authPasswordLength": "Kata sandi harus 8-64 karakter", + "authPasswordWeak": "Kata sandi perlu huruf dan angka", + "authNetworkError": "Jaringan bermasalah, coba lagi", + "authSwitchToSignUp": "Baru di sini? Buat akun", + "authSwitchToSignIn": "Sudah punya akun? Masuk", + "authGateTitle": "Masuk untuk melanjutkan", + "authGateMessage": "Favorit dan komentar perlu akun.", + "authGateAction": "Masuk", + "cancel": "Nanti saja" +} diff --git a/lib/l10n/app_localizations.dart b/lib/l10n/app_localizations.dart index 3b0ce7e..fcc3d0e 100644 --- a/lib/l10n/app_localizations.dart +++ b/lib/l10n/app_localizations.dart @@ -6,6 +6,7 @@ import 'package:flutter_localizations/flutter_localizations.dart'; import 'package:intl/intl.dart' as intl; import 'app_localizations_en.dart'; +import 'app_localizations_id.dart'; import 'app_localizations_zh.dart'; // ignore_for_file: type=lint @@ -95,13 +96,14 @@ abstract class AppLocalizations { /// A list of this localizations delegate's supported locales. static const List supportedLocales = [ Locale('en'), + Locale('id'), Locale('zh'), ]; /// No description provided for @appName. /// /// In en, this message translates to: - /// **'Nontonki'** + /// **'FruitShorts'** String get appName; /// No description provided for @demo. @@ -845,13 +847,13 @@ abstract class AppLocalizations { /// No description provided for @brandMark. /// /// In en, this message translates to: - /// **'NONTONKI · DEMO'** + /// **'FRUITSHORTS'** String get brandMark; /// No description provided for @shareFooter. /// /// In en, this message translates to: - /// **'Nontonki demo'** + /// **'FruitShorts'** String get shareFooter; /// No description provided for @shortsTab. @@ -1154,7 +1156,7 @@ class _AppLocalizationsDelegate @override bool isSupported(Locale locale) => - ['en', 'zh'].contains(locale.languageCode); + ['en', 'id', 'zh'].contains(locale.languageCode); @override bool shouldReload(_AppLocalizationsDelegate old) => false; @@ -1165,6 +1167,8 @@ AppLocalizations lookupAppLocalizations(Locale locale) { switch (locale.languageCode) { case 'en': return AppLocalizationsEn(); + case 'id': + return AppLocalizationsId(); case 'zh': return AppLocalizationsZh(); } diff --git a/lib/l10n/app_localizations_en.dart b/lib/l10n/app_localizations_en.dart index 8b0d272..dbc4e6a 100644 --- a/lib/l10n/app_localizations_en.dart +++ b/lib/l10n/app_localizations_en.dart @@ -9,7 +9,7 @@ class AppLocalizationsEn extends AppLocalizations { AppLocalizationsEn([String locale = 'en']) : super(locale); @override - String get appName => 'Nontonki'; + String get appName => 'FruitShorts'; @override String get demo => 'DEMO'; @@ -403,10 +403,10 @@ class AppLocalizationsEn extends AppLocalizations { String get preferencesHeading => 'PREFERENCES'; @override - String get brandMark => 'NONTONKI · DEMO'; + String get brandMark => 'FRUITSHORTS'; @override - String get shareFooter => 'Nontonki demo'; + String get shareFooter => 'FruitShorts'; @override String get shortsTab => 'Shorts'; diff --git a/lib/l10n/app_localizations_id.dart b/lib/l10n/app_localizations_id.dart new file mode 100644 index 0000000..ebcf54d --- /dev/null +++ b/lib/l10n/app_localizations_id.dart @@ -0,0 +1,556 @@ +// ignore: unused_import +import 'package:intl/intl.dart' as intl; +import 'app_localizations.dart'; + +// ignore_for_file: type=lint + +/// The translations for Indonesian (`id`). +class AppLocalizationsId extends AppLocalizations { + AppLocalizationsId([String locale = 'id']) : super(locale); + + @override + String get appName => 'FruitShorts'; + + @override + String get demo => 'Demo'; + + @override + String get homeHeadline => 'Tonton sekarang'; + + @override + String get homeSubtitle => 'Pratinjau drama pendek gratis.'; + + @override + String get mediaNotice => 'Video demo lokal dari pengguna · Pratinjau gratis'; + + @override + String get featuredDemo => 'UNGGULAN · DEMO TEKNIS'; + + @override + String get demoTitle => 'Sinyal'; + + @override + String get demoSynopsis => + 'Pratinjau video lokal singkat. Episode lain bisa ditambahkan saat medianya tersedia.'; + + @override + String get homeTab => 'Beranda'; + + @override + String get openQuickMenu => 'Buka menu cepat'; + + @override + String get quickAccess => 'Akses cepat'; + + @override + String get currentSeries => 'Serial saat ini'; + + @override + String get discoverTab => 'Jelajahi'; + + @override + String get searchDiscover => 'Cari drama, aktor, genre...'; + + @override + String get featured => 'Unggulan'; + + @override + String get suspense => 'Thriller'; + + @override + String get romance => 'Romantis'; + + @override + String get actionGenre => 'Aksi'; + + @override + String get filter => 'Filter'; + + @override + String get topCharts => 'Peringkat Teratas'; + + @override + String get newReleases => 'Rilisan Baru'; + + @override + String get trendingMicroDramas => 'Drama Mini Populer'; + + @override + String get seeAll => 'Lihat Semua'; + + @override + String get artworkOnly => 'Gambar'; + + @override + String get artworkOnlyNotice => + 'Ini hanya gambar katalog. Videonya belum tersedia.'; + + @override + String get videoPending => 'Video belum siap'; + + @override + String get watchNow => 'Tonton gratis'; + + @override + String get noSearchResults => 'Tidak ada drama yang cocok.'; + + @override + String get demoCatalogNotice => + 'Tiga drama demo memakai video lokal yang sama.'; + + @override + String get myTab => 'Saya'; + + @override + String get localViewer => 'Penonton Lokal'; + + @override + String get localDemoProfile => 'Profil demo lokal'; + + @override + String get continueWatching => 'Lanjut Tonton'; + + @override + String watchedPercent(int percent) { + return 'Sudah ditonton $percent%'; + } + + @override + String get resume => 'Lanjutkan'; + + @override + String get history => 'Riwayat'; + + @override + String get watchlist => 'Daftar Tonton'; + + @override + String get likedTab => 'Disukai'; + + @override + String get all => 'Semua'; + + @override + String get inProgress => 'Sedang Berjalan'; + + @override + String get completed => 'Selesai'; + + @override + String get noSavedShows => 'Belum ada tontonan di sini.'; + + @override + String get preferences => 'Preferensi'; + + @override + String get appLanguage => 'Bahasa Aplikasi'; + + @override + String get followingTab => 'Mengikuti'; + + @override + String get animatedTab => 'Animasi'; + + @override + String get recommendedTab => 'Rekomendasi'; + + @override + String get noCategoryDramas => 'Belum ada drama di kategori ini.'; + + @override + String get trendingTab => 'Sedang Tren'; + + @override + String get liveActionTab => 'Live Action'; + + @override + String get search => 'Cari'; + + @override + String get free => 'Gratis'; + + @override + String get mute => 'Bisukan'; + + @override + String get unmute => 'Nyalakan suara'; + + @override + String get like => 'Suka'; + + @override + String get save => 'Simpan'; + + @override + String get comments => 'Komentar'; + + @override + String get share => 'Bagikan'; + + @override + String get localOnlyComments => 'Hanya terlihat di perangkat ini'; + + @override + String get noComments => 'Belum ada komentar.'; + + @override + String get writeComment => 'Tulis komentar'; + + @override + String get postComment => 'Kirim'; + + @override + String get shareFailed => 'Tidak bisa membuka menu berbagi.'; + + @override + String get nowPlaying => 'Sedang diputar'; + + @override + String get watchFullscreen => 'Tonton mode lanskap'; + + @override + String get exitFullscreen => 'Keluar dari layar penuh'; + + @override + String get pictureInPicture => 'Gambar dalam gambar'; + + @override + String get pipUnavailable => + 'Gambar dalam gambar tidak tersedia di perangkat ini'; + + @override + String get originalTag => 'Original'; + + @override + String get dramaTag => 'Drama pendek'; + + @override + String episodeLabel(int number) { + return 'Episode $number'; + } + + @override + String get exploreSeries => 'Lihat serial'; + + @override + String episodeCount(int count) { + return '$count EPISODE'; + } + + @override + String technicalDemoCount(int count) { + return 'PRATINJAU GRATIS · $count EPISODE'; + } + + @override + String get episodes => 'Episode'; + + @override + String get watchEpisodeOne => 'Tonton episode 1'; + + @override + String continueEpisode(int number) { + return 'Lanjut episode $number'; + } + + @override + String get freeTestMedia => 'Klip demo sama · gratis'; + + @override + String get lockedStoreUnavailable => 'Terkunci · toko belum tersedia'; + + @override + String get freeTestClip => 'Klip uji gratis'; + + @override + String get locked => 'Terkunci'; + + @override + String get freeSamplesNotice => + 'Dua sampel gratis · pengaturan toko belum selesai'; + + @override + String get demoTestMedia => 'GRATIS · KLIP DEMO SAMA'; + + @override + String episodeProgress(int number, int total) { + return 'EPISODE $number / $total'; + } + + @override + String get testVideoNotice => 'Video uji teknis buatan sendiri'; + + @override + String lockedTitle(int number) { + return 'Episode $number terkunci'; + } + + @override + String get lockedBody => + 'Pembukaan kunci tersedia setelah toko dan verifikasi disiapkan. Demo ini tidak memproses pembayaran.'; + + @override + String get playbackError => 'Klip ini tidak bisa diputar.'; + + @override + String get catalogError => 'Katalog gagal dimuat.'; + + @override + String get detailError => 'Daftar episode gagal dimuat.'; + + @override + String get noMediaNotice => + 'Episode ini belum punya media yang bisa diputar.'; + + @override + String get noStories => 'Belum ada cerita.'; + + @override + String get retry => 'Coba lagi'; + + @override + String get backToSeries => 'Kembali ke serial'; + + @override + String get nextEpisode => 'Episode berikutnya'; + + @override + String get pause => 'Jeda'; + + @override + String get play => 'Putar'; + + @override + String get seekVideo => 'Geser posisi video'; + + @override + String get seekFailed => 'Gagal mengubah posisi putar.'; + + @override + String get captions => 'Subtitle'; + + @override + String get captionsOff => 'Subtitle nonaktif'; + + @override + String get englishCaptions => 'Subtitle bahasa Inggris'; + + @override + String get chineseCaptions => 'Subtitle bahasa Mandarin'; + + @override + String get language => 'Bahasa'; + + @override + String get systemLanguage => 'Sistem'; + + @override + String get english => 'English'; + + @override + String get simplifiedChinese => '简体中文'; + + @override + String get episodeOneTitle => 'Cahaya Pertama'; + + @override + String get episodeTwoTitle => 'Frekuensi Baru'; + + @override + String get episodeThreeTitle => 'Menyeberang'; + + @override + String get episodeFourTitle => 'Setelah Gema'; + + @override + String get dramaSignalTitle => 'Sinyal'; + + @override + String get dramaSignalSynopsis => + 'Serial demo untuk tontonan vertikal. Setiap episode memakai satu klip lokal yang sama.'; + + @override + String get dramaCityTitle => 'Cahaya Kota & Malam Beludru'; + + @override + String get dramaCitySynopsis => + 'Serial romansa demo. Video lokal yang sama dipakai untuk mencoba pindah episode dan lanjut tonton.'; + + @override + String get dramaVengeanceTitle => 'Badai Pembalasan'; + + @override + String get dramaVengeanceSynopsis => + 'Serial aksi demo. Video lokal yang sama dipakai untuk mencoba pindah episode dan lanjut tonton.'; + + @override + String get dramaEchoesTitle => 'Gema Takdir'; + + @override + String get genreSuspenseMystery => 'Thriller · Misteri'; + + @override + String get genreUrbanRomance => 'Romansa Kota'; + + @override + String get genreActionThriller => 'Aksi · Thriller'; + + @override + String get genreDramaMystery => 'Drama · Misteri'; + + @override + String get continueWatchingHeading => 'LANJUT TONTON'; + + @override + String get preferencesHeading => 'PREFERENSI'; + + @override + String get brandMark => 'FRUITSHORTS'; + + @override + String get shareFooter => 'FruitShorts'; + + @override + String get shortsTab => 'Drama Pendek'; + + @override + String get myListTab => 'Daftar Saya'; + + @override + String get watchFull => 'Tonton Penuh'; + + @override + String get swipeForNext => 'Geser ke atas untuk lanjut'; + + @override + String get clearScreen => 'Bersihkan layar'; + + @override + String get exitClearScreen => 'Keluar dari mode bersih'; + + @override + String get logIn => 'Masuk'; + + @override + String get logInHint => 'Simpan koin dan daftar kamu'; + + @override + String get rewards => 'Hadiah'; + + @override + String get forYou => 'Untuk Kamu'; + + @override + String get hot => 'Populer'; + + @override + String get newest => 'Terbaru'; + + @override + String get favorite => 'Favorit'; + + @override + String get myAccount => 'Akun saya'; + + @override + String get coins => 'Koin'; + + @override + String get topUpWallet => 'Isi Ulang Dompet'; + + @override + String get vipMembership => 'Keanggotaan VIP'; + + @override + String get notActive => 'Tidak Aktif'; + + @override + String get joinVip => 'Gabung VIP'; + + @override + String get earnRewards => 'Dapatkan Hadiah'; + + @override + String get freeBonus => 'Bonus Gratis'; + + @override + String get watchHistory => 'Riwayat Tontonan'; + + @override + String get settings => 'Pengaturan'; + + @override + String get signOut => 'Keluar'; + + @override + String get mockUserName => 'Vicky sheng'; + + @override + String get mockUserId => 'ID: M1CZWVYE'; + + @override + String get mockNotice => 'Hanya data contoh.'; + + @override + String get topBadge => 'TOP 1'; + + @override + String get signIn => 'Masuk'; + + @override + String get signUp => 'Daftar'; + + @override + String get authSignInTitle => 'Selamat datang kembali'; + + @override + String get authSignUpTitle => 'Buat akun kamu'; + + @override + String get authSubtitle => 'Masuk dengan email dan kata sandi.'; + + @override + String get authEmailLabel => 'Email'; + + @override + String get authPasswordLabel => 'Kata sandi'; + + @override + String get authPasswordHint => 'Minimal 8 karakter, berisi huruf dan angka'; + + @override + String get authEmailRequired => 'Masukkan email kamu'; + + @override + String get authEmailInvalid => 'Email itu sepertinya tidak benar'; + + @override + String get authPasswordRequired => 'Masukkan kata sandi kamu'; + + @override + String get authPasswordLength => 'Kata sandi harus 8-64 karakter'; + + @override + String get authPasswordWeak => 'Kata sandi perlu huruf dan angka'; + + @override + String get authNetworkError => 'Jaringan bermasalah, coba lagi'; + + @override + String get authSwitchToSignUp => 'Baru di sini? Buat akun'; + + @override + String get authSwitchToSignIn => 'Sudah punya akun? Masuk'; + + @override + String get authGateTitle => 'Masuk untuk melanjutkan'; + + @override + String get authGateMessage => 'Favorit dan komentar perlu akun.'; + + @override + String get authGateAction => 'Masuk'; + + @override + String get cancel => 'Nanti saja'; +} diff --git a/lib/l10n/app_localizations_zh.dart b/lib/l10n/app_localizations_zh.dart index cc8b39c..91dddb8 100644 --- a/lib/l10n/app_localizations_zh.dart +++ b/lib/l10n/app_localizations_zh.dart @@ -9,7 +9,7 @@ class AppLocalizationsZh extends AppLocalizations { AppLocalizationsZh([String locale = 'zh']) : super(locale); @override - String get appName => 'Nontonki'; + String get appName => 'FruitShorts'; @override String get demo => '演示'; @@ -395,10 +395,10 @@ class AppLocalizationsZh extends AppLocalizations { String get preferencesHeading => '偏好设置'; @override - String get brandMark => 'NONTONKI · 演示'; + String get brandMark => 'FRUITSHORTS'; @override - String get shareFooter => 'Nontonki 演示'; + String get shareFooter => 'FruitShorts'; @override String get shortsTab => '短剧'; diff --git a/lib/l10n/app_zh.arb b/lib/l10n/app_zh.arb index fc54650..6ab8562 100644 --- a/lib/l10n/app_zh.arb +++ b/lib/l10n/app_zh.arb @@ -1,6 +1,6 @@ { "@@locale": "zh", - "appName": "Nontonki", + "appName": "FruitShorts", "demo": "演示", "homeHeadline": "即刻观看", "homeSubtitle": "免费短剧预览。", @@ -126,8 +126,8 @@ "genreDramaMystery": "剧情 · 悬疑", "continueWatchingHeading": "继续观看", "preferencesHeading": "偏好设置", - "brandMark": "NONTONKI · 演示", - "shareFooter": "Nontonki 演示", + "brandMark": "FRUITSHORTS", + "shareFooter": "FruitShorts", "shortsTab": "短剧", "myListTab": "片单", "watchFull": "看全集", diff --git a/lib/pages/auth/auth_view.dart b/lib/pages/auth/auth_view.dart index 7fc1bbf..49dcc70 100644 --- a/lib/pages/auth/auth_view.dart +++ b/lib/pages/auth/auth_view.dart @@ -9,7 +9,7 @@ import 'auth_logic.dart'; /// 登录 / 注册页:邮箱 + 密码。 /// -/// 风格沿用 `nontonki` 现有页面(深色卡片 + 圆角 + 主色蓝),不另起一套视觉。 +/// 风格沿用 FruitShorts 现有页面(深色卡片 + 圆角 + 主色蓝),不另起一套视觉。 class AuthPage extends StatefulWidget { const AuthPage({super.key, this.signUpMode = false}); diff --git a/pubspec.yaml b/pubspec.yaml index 6fedbac..7f4fd45 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ -name: nontonki -description: "Nontonki short-drama playback prototype." +name: fruitshorts +description: "FruitShorts short-drama playback app (Indonesia first)." # The following line prevents the package from being accidentally published to # pub.dev using `flutter pub publish`. This is preferred for private packages. publish_to: 'none' # Remove this line if you wish to publish to pub.dev @@ -103,7 +103,7 @@ flutter: flutter_launcher_icons: android: true ios: true - image_path: assets/icon/nontonki.png + image_path: assets/icon/fruitshorts.png adaptive_icon_background: "#D74A7D" - adaptive_icon_foreground: assets/icon/nontonki.png + adaptive_icon_foreground: assets/icon/fruitshorts.png remove_alpha_ios: true diff --git a/test/auth/auth_controller_test.dart b/test/auth/auth_controller_test.dart index 6ff0c25..cbefd61 100644 --- a/test/auth/auth_controller_test.dart +++ b/test/auth/auth_controller_test.dart @@ -4,11 +4,10 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:shared_preferences_platform_interface/in_memory_shared_preferences_async.dart'; import 'package:shared_preferences_platform_interface/shared_preferences_async_platform_interface.dart'; -// 包名此刻仍是 nontonki,1-3 改名时会一并替换成 fruitshorts -import 'package:nontonki/core/data/remote/api_client.dart'; -import 'package:nontonki/core/data/remote/auth_api.dart'; -import 'package:nontonki/core/data/services/auth_controller.dart'; -import 'package:nontonki/core/data/services/auth_session_store.dart'; +import 'package:fruitshorts/core/data/remote/api_client.dart'; +import 'package:fruitshorts/core/data/remote/auth_api.dart'; +import 'package:fruitshorts/core/data/services/auth_controller.dart'; +import 'package:fruitshorts/core/data/services/auth_session_store.dart'; import '../support/fake_http_adapter.dart'; diff --git a/test/auth/auth_page_test.dart b/test/auth/auth_page_test.dart index 1ea91c9..61f3aa9 100644 --- a/test/auth/auth_page_test.dart +++ b/test/auth/auth_page_test.dart @@ -4,12 +4,12 @@ import 'package:provider/provider.dart'; import 'package:shared_preferences_platform_interface/in_memory_shared_preferences_async.dart'; import 'package:shared_preferences_platform_interface/shared_preferences_async_platform_interface.dart'; -import 'package:nontonki/core/data/remote/auth_api.dart'; -import 'package:nontonki/core/data/remote/api_client.dart'; -import 'package:nontonki/core/data/services/auth_controller.dart'; -import 'package:nontonki/core/data/services/auth_session_store.dart'; -import 'package:nontonki/l10n/app_localizations.dart'; -import 'package:nontonki/pages/auth/auth_view.dart'; +import 'package:fruitshorts/core/data/remote/auth_api.dart'; +import 'package:fruitshorts/core/data/remote/api_client.dart'; +import 'package:fruitshorts/core/data/services/auth_controller.dart'; +import 'package:fruitshorts/core/data/services/auth_session_store.dart'; +import 'package:fruitshorts/l10n/app_localizations.dart'; +import 'package:fruitshorts/pages/auth/auth_view.dart'; import '../support/fake_http_adapter.dart'; diff --git a/test/catalog/catalog_controller_test.dart b/test/catalog/catalog_controller_test.dart index 1b97d6d..471e64c 100644 --- a/test/catalog/catalog_controller_test.dart +++ b/test/catalog/catalog_controller_test.dart @@ -1,9 +1,9 @@ import 'package:flutter_test/flutter_test.dart'; -import 'package:nontonki/core/data/models/drama.dart'; -import 'package:nontonki/core/data/models/home_feed.dart'; -import 'package:nontonki/core/data/models/play_ticket.dart'; -import 'package:nontonki/core/data/repositories/catalog_repository.dart'; -import 'package:nontonki/core/data/services/catalog_controller.dart'; +import 'package:fruitshorts/core/data/models/drama.dart'; +import 'package:fruitshorts/core/data/models/home_feed.dart'; +import 'package:fruitshorts/core/data/models/play_ticket.dart'; +import 'package:fruitshorts/core/data/repositories/catalog_repository.dart'; +import 'package:fruitshorts/core/data/services/catalog_controller.dart'; void main() { test('should_distinguish_empty_catalog_from_load_failure_when_retry_succeeds', () async { diff --git a/test/catalog/drama_model_test.dart b/test/catalog/drama_model_test.dart index c3a3653..7b715cb 100644 --- a/test/catalog/drama_model_test.dart +++ b/test/catalog/drama_model_test.dart @@ -1,5 +1,5 @@ import 'package:flutter_test/flutter_test.dart'; -import 'package:nontonki/core/data/models/drama.dart'; +import 'package:fruitshorts/core/data/models/drama.dart'; void main() { test('should_carry_one_preview_and_total_count_when_list_card_is_parsed', () { diff --git a/test/config/l10n_id_test.dart b/test/config/l10n_id_test.dart new file mode 100644 index 0000000..c04c29c --- /dev/null +++ b/test/config/l10n_id_test.dart @@ -0,0 +1,48 @@ +// Author: fruit.com.cn + +import 'package:flutter/widgets.dart'; +import 'package:flutter_test/flutter_test.dart'; + +import 'package:fruitshorts/l10n/app_localizations.dart'; + +/// id-ID 文案接入的可读证据:设备语言是 `id` 时真的拿到印尼语、`id` 在支持列表里、 +/// 并且品牌文案里不再有 demo 标记。 +void main() { + test('should_return_indonesian_copy_when_locale_is_id', () async { + final l10n = await AppLocalizations.delegate.load(const Locale('id')); + + expect(l10n.homeTab, 'Beranda'); + expect(l10n.watchNow, 'Tonton gratis'); + expect(l10n.watchlist, 'Daftar Tonton'); + expect(l10n.coins, 'Koin'); + expect(l10n.signIn, 'Masuk'); + }); + + test('should_include_id_when_supported_locales_are_read', () { + final codes = AppLocalizations.supportedLocales + .map((locale) => locale.languageCode) + .toList(); + + expect(codes, containsAll(['en', 'zh', 'id'])); + }); + + test('should_drop_demo_marker_when_brand_copy_is_loaded', () async { + for (final locale in const [Locale('en'), Locale('zh'), Locale('id')]) { + final l10n = await AppLocalizations.delegate.load(locale); + + expect(l10n.appName, 'FruitShorts', reason: '$locale appName'); + expect(l10n.brandMark, 'FRUITSHORTS', reason: '$locale brandMark'); + expect(l10n.shareFooter, 'FruitShorts', reason: '$locale shareFooter'); + expect(l10n.brandMark.toLowerCase(), isNot(contains('demo'))); + expect(l10n.shareFooter.toLowerCase(), isNot(contains('demo'))); + } + }); + + test('should_keep_placeholders_when_indonesian_copy_renders', () async { + final l10n = await AppLocalizations.delegate.load(const Locale('id')); + + expect(l10n.episodeLabel(3), contains('3')); + expect(l10n.episodeProgress(2, 10), contains('2')); + expect(l10n.episodeProgress(2, 10), contains('10')); + }); +} diff --git a/test/config/locale_controller_test.dart b/test/config/locale_controller_test.dart index b43afaa..cd32c01 100644 --- a/test/config/locale_controller_test.dart +++ b/test/config/locale_controller_test.dart @@ -1,6 +1,6 @@ import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:nontonki/core/config/locale_controller.dart'; +import 'package:fruitshorts/core/config/locale_controller.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:shared_preferences_platform_interface/in_memory_shared_preferences_async.dart'; import 'package:shared_preferences_platform_interface/shared_preferences_async_platform_interface.dart'; diff --git a/test/core/android_picture_in_picture_test.dart b/test/core/android_picture_in_picture_test.dart index a2520f3..4dd72a0 100644 --- a/test/core/android_picture_in_picture_test.dart +++ b/test/core/android_picture_in_picture_test.dart @@ -1,7 +1,7 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/services.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:nontonki/core/data/services/android_picture_in_picture.dart'; +import 'package:fruitshorts/core/data/services/android_picture_in_picture.dart'; void main() { TestWidgetsFlutterBinding.ensureInitialized(); diff --git a/test/core/api_client_test.dart b/test/core/api_client_test.dart index 903e231..2b69055 100644 --- a/test/core/api_client_test.dart +++ b/test/core/api_client_test.dart @@ -4,7 +4,7 @@ import 'dart:convert'; import 'package:flutter_test/flutter_test.dart'; -import 'package:nontonki/core/data/remote/api_client.dart'; +import 'package:fruitshorts/core/data/remote/api_client.dart'; import '../support/fake_http_adapter.dart'; diff --git a/test/discover/cover_carousel_test.dart b/test/discover/cover_carousel_test.dart index 2f52609..7d298d2 100644 --- a/test/discover/cover_carousel_test.dart +++ b/test/discover/cover_carousel_test.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:nontonki/pages/discover/widgets/cover_carousel.dart'; +import 'package:fruitshorts/pages/discover/widgets/cover_carousel.dart'; void main() { TestWidgetsFlutterBinding.ensureInitialized(); diff --git a/test/discover/discover_logic_test.dart b/test/discover/discover_logic_test.dart index cc89799..30daae7 100644 --- a/test/discover/discover_logic_test.dart +++ b/test/discover/discover_logic_test.dart @@ -2,9 +2,9 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:nontonki/core/data/models/drama.dart'; -import 'package:nontonki/l10n/app_localizations.dart'; -import 'package:nontonki/pages/discover/discover_logic.dart'; +import 'package:fruitshorts/core/data/models/drama.dart'; +import 'package:fruitshorts/l10n/app_localizations.dart'; +import 'package:fruitshorts/pages/discover/discover_logic.dart'; import '../support/fake_watch_history.dart'; diff --git a/test/drama_detail/drama_detail_logic_test.dart b/test/drama_detail/drama_detail_logic_test.dart index a2a25c3..248fe9a 100644 --- a/test/drama_detail/drama_detail_logic_test.dart +++ b/test/drama_detail/drama_detail_logic_test.dart @@ -1,7 +1,7 @@ import 'package:flutter_test/flutter_test.dart'; -import 'package:nontonki/core/data/models/drama.dart'; -import 'package:nontonki/core/data/remote/api_client.dart'; -import 'package:nontonki/pages/drama_detail/drama_detail_logic.dart'; +import 'package:fruitshorts/core/data/models/drama.dart'; +import 'package:fruitshorts/core/data/remote/api_client.dart'; +import 'package:fruitshorts/pages/drama_detail/drama_detail_logic.dart'; import '../support/fake_watch_history.dart'; diff --git a/test/engagement/engagement_controller_test.dart b/test/engagement/engagement_controller_test.dart index 1e6a9fe..0bba97c 100644 --- a/test/engagement/engagement_controller_test.dart +++ b/test/engagement/engagement_controller_test.dart @@ -1,6 +1,6 @@ import 'package:flutter_test/flutter_test.dart'; -import 'package:nontonki/core/data/services/engagement_controller.dart'; -import 'package:nontonki/core/data/repositories/engagement_repository.dart'; +import 'package:fruitshorts/core/data/services/engagement_controller.dart'; +import 'package:fruitshorts/core/data/repositories/engagement_repository.dart'; import 'package:shared_preferences_platform_interface/in_memory_shared_preferences_async.dart'; import 'package:shared_preferences_platform_interface/shared_preferences_async_platform_interface.dart'; diff --git a/test/engagement/engagement_repository_test.dart b/test/engagement/engagement_repository_test.dart index 5f6f8c3..c877051 100644 --- a/test/engagement/engagement_repository_test.dart +++ b/test/engagement/engagement_repository_test.dart @@ -1,8 +1,8 @@ import 'dart:convert'; import 'package:flutter_test/flutter_test.dart'; -import 'package:nontonki/core/data/models/engagement_snapshot.dart'; -import 'package:nontonki/core/data/repositories/engagement_repository.dart'; +import 'package:fruitshorts/core/data/models/engagement_snapshot.dart'; +import 'package:fruitshorts/core/data/repositories/engagement_repository.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:shared_preferences_platform_interface/in_memory_shared_preferences_async.dart'; import 'package:shared_preferences_platform_interface/shared_preferences_async_platform_interface.dart'; diff --git a/test/formatting/localized_content_test.dart b/test/formatting/localized_content_test.dart index e097924..5f05e78 100644 --- a/test/formatting/localized_content_test.dart +++ b/test/formatting/localized_content_test.dart @@ -1,8 +1,8 @@ import 'package:flutter_test/flutter_test.dart'; -import 'package:nontonki/core/data/models/drama.dart'; -import 'package:nontonki/core/formatting/localized_content.dart'; -import 'package:nontonki/l10n/app_localizations_en.dart'; -import 'package:nontonki/l10n/app_localizations_zh.dart'; +import 'package:fruitshorts/core/data/models/drama.dart'; +import 'package:fruitshorts/core/formatting/localized_content.dart'; +import 'package:fruitshorts/l10n/app_localizations_en.dart'; +import 'package:fruitshorts/l10n/app_localizations_zh.dart'; Drama _drama({required String id, String title = 'raw', String synopsis = 'raw'}) => Drama( diff --git a/test/home/home_logic_test.dart b/test/home/home_logic_test.dart index 4ac5323..7ba720b 100644 --- a/test/home/home_logic_test.dart +++ b/test/home/home_logic_test.dart @@ -1,9 +1,9 @@ import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:nontonki/core/data/models/drama.dart'; -import 'package:nontonki/pages/discover/discover_logic.dart'; -import 'package:nontonki/pages/home/home_logic.dart'; -import 'package:nontonki/pages/mine/mine_logic.dart'; +import 'package:fruitshorts/core/data/models/drama.dart'; +import 'package:fruitshorts/pages/discover/discover_logic.dart'; +import 'package:fruitshorts/pages/home/home_logic.dart'; +import 'package:fruitshorts/pages/mine/mine_logic.dart'; Drama _drama(String id) => Drama( id: id, diff --git a/test/integration/live_auth_test.dart b/test/integration/live_auth_test.dart index 21e0ed7..9fbf452 100644 --- a/test/integration/live_auth_test.dart +++ b/test/integration/live_auth_test.dart @@ -2,8 +2,8 @@ import 'package:flutter_test/flutter_test.dart'; -import 'package:nontonki/core/data/remote/api_client.dart'; -import 'package:nontonki/core/data/remote/auth_api.dart'; +import 'package:fruitshorts/core/data/remote/api_client.dart'; +import 'package:fruitshorts/core/data/remote/auth_api.dart'; /// 联调测试:直连本机客户端接口服务(8081)验证 **POST + JSON body + 错误码映射**。 /// diff --git a/test/integration/live_catalog_test.dart b/test/integration/live_catalog_test.dart index 0b79238..0d17476 100644 --- a/test/integration/live_catalog_test.dart +++ b/test/integration/live_catalog_test.dart @@ -1,6 +1,6 @@ import 'package:flutter_test/flutter_test.dart'; -import 'package:nontonki/core/data/remote/api_client.dart'; -import 'package:nontonki/core/data/remote/catalog_api.dart'; +import 'package:fruitshorts/core/data/remote/api_client.dart'; +import 'package:fruitshorts/core/data/remote/catalog_api.dart'; /// 联调测试:直连本机客户端接口服务(8081)。 /// 服务没启动时自动跳过,不影响日常 `flutter test`。 diff --git a/test/mine/mine_logic_test.dart b/test/mine/mine_logic_test.dart index 9fb07c8..1bd1f1b 100644 --- a/test/mine/mine_logic_test.dart +++ b/test/mine/mine_logic_test.dart @@ -2,10 +2,10 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:nontonki/core/config/locale_controller.dart'; -import 'package:nontonki/core/data/models/drama.dart'; -import 'package:nontonki/l10n/app_localizations.dart'; -import 'package:nontonki/pages/mine/mine_logic.dart'; +import 'package:fruitshorts/core/config/locale_controller.dart'; +import 'package:fruitshorts/core/data/models/drama.dart'; +import 'package:fruitshorts/l10n/app_localizations.dart'; +import 'package:fruitshorts/pages/mine/mine_logic.dart'; import 'package:provider/provider.dart'; import 'package:shared_preferences_platform_interface/in_memory_shared_preferences_async.dart'; import 'package:shared_preferences_platform_interface/shared_preferences_async_platform_interface.dart'; diff --git a/test/playback/playback_preload_test.dart b/test/playback/playback_preload_test.dart index a4f09a8..5b90f72 100644 --- a/test/playback/playback_preload_test.dart +++ b/test/playback/playback_preload_test.dart @@ -1,9 +1,9 @@ import 'dart:async'; import 'package:flutter_test/flutter_test.dart'; -import 'package:nontonki/core/data/models/drama.dart'; -import 'package:nontonki/core/data/services/playback_session.dart'; -import 'package:nontonki/core/data/models/player_port.dart'; +import 'package:fruitshorts/core/data/models/drama.dart'; +import 'package:fruitshorts/core/data/services/playback_session.dart'; +import 'package:fruitshorts/core/data/models/player_port.dart'; void main() { final episodes = List.generate( diff --git a/test/playback/playback_queue_test.dart b/test/playback/playback_queue_test.dart index 1117367..e0fb953 100644 --- a/test/playback/playback_queue_test.dart +++ b/test/playback/playback_queue_test.dart @@ -1,6 +1,6 @@ import 'package:flutter_test/flutter_test.dart'; -import 'package:nontonki/core/data/models/drama.dart'; -import 'package:nontonki/core/data/services/playback_queue.dart'; +import 'package:fruitshorts/core/data/models/drama.dart'; +import 'package:fruitshorts/core/data/services/playback_queue.dart'; void main() { test('should_advance_between_dramas_on_home_and_between_episodes_in_series_when_queue_is_built', () { diff --git a/test/playback/playback_session_test.dart b/test/playback/playback_session_test.dart index de700d1..ca292ad 100644 --- a/test/playback/playback_session_test.dart +++ b/test/playback/playback_session_test.dart @@ -1,9 +1,9 @@ import 'dart:async'; import 'package:flutter_test/flutter_test.dart'; -import 'package:nontonki/core/data/models/drama.dart'; -import 'package:nontonki/core/data/services/playback_session.dart'; -import 'package:nontonki/core/data/models/player_port.dart'; +import 'package:fruitshorts/core/data/models/drama.dart'; +import 'package:fruitshorts/core/data/services/playback_session.dart'; +import 'package:fruitshorts/core/data/models/player_port.dart'; void main() { final episodes = List.generate( diff --git a/test/playback/seek_progress_bar_test.dart b/test/playback/seek_progress_bar_test.dart index 137e7db..b2262dc 100644 --- a/test/playback/seek_progress_bar_test.dart +++ b/test/playback/seek_progress_bar_test.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:nontonki/pages/player/widgets/seek_progress_bar.dart'; +import 'package:fruitshorts/pages/player/widgets/seek_progress_bar.dart'; import 'package:video_player/video_player.dart'; void main() { diff --git a/test/playback/video_player_port_test.dart b/test/playback/video_player_port_test.dart index 5a35138..d40a7f3 100644 --- a/test/playback/video_player_port_test.dart +++ b/test/playback/video_player_port_test.dart @@ -1,7 +1,7 @@ import 'package:flutter_test/flutter_test.dart'; -import 'package:nontonki/core/config/app_config.dart'; -import 'package:nontonki/core/data/models/drama.dart'; -import 'package:nontonki/core/data/services/video_player_port.dart'; +import 'package:fruitshorts/core/config/app_config.dart'; +import 'package:fruitshorts/core/data/models/drama.dart'; +import 'package:fruitshorts/core/data/services/video_player_port.dart'; Episode _episode(String videoUrl) => Episode( id: '1', diff --git a/test/playback/watch_history_test.dart b/test/playback/watch_history_test.dart index d814deb..bc12aaa 100644 --- a/test/playback/watch_history_test.dart +++ b/test/playback/watch_history_test.dart @@ -1,6 +1,6 @@ import 'package:flutter_test/flutter_test.dart'; -import 'package:nontonki/core/data/models/drama.dart'; -import 'package:nontonki/core/data/repositories/watch_history_repository.dart'; +import 'package:fruitshorts/core/data/models/drama.dart'; +import 'package:fruitshorts/core/data/repositories/watch_history_repository.dart'; import 'package:shared_preferences_platform_interface/in_memory_shared_preferences_async.dart'; import 'package:shared_preferences_platform_interface/shared_preferences_async_platform_interface.dart'; diff --git a/test/player/player_logic_test.dart b/test/player/player_logic_test.dart index 6a71cbe..1ed2607 100644 --- a/test/player/player_logic_test.dart +++ b/test/player/player_logic_test.dart @@ -1,12 +1,12 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:nontonki/core/data/models/drama.dart'; -import 'package:nontonki/core/data/models/player_port.dart'; -import 'package:nontonki/core/data/services/android_picture_in_picture.dart'; -import 'package:nontonki/core/data/services/playback_session.dart'; -import 'package:nontonki/pages/player/player_logic.dart'; -import 'package:nontonki/pages/player/player_view.dart'; +import 'package:fruitshorts/core/data/models/drama.dart'; +import 'package:fruitshorts/core/data/models/player_port.dart'; +import 'package:fruitshorts/core/data/services/android_picture_in_picture.dart'; +import 'package:fruitshorts/core/data/services/playback_session.dart'; +import 'package:fruitshorts/pages/player/player_logic.dart'; +import 'package:fruitshorts/pages/player/player_view.dart'; import '../support/fake_watch_history.dart'; diff --git a/test/support/fake_catalog.dart b/test/support/fake_catalog.dart index 393315f..3bfe1d6 100644 --- a/test/support/fake_catalog.dart +++ b/test/support/fake_catalog.dart @@ -1,7 +1,7 @@ -import 'package:nontonki/core/data/models/drama.dart'; -import 'package:nontonki/core/data/models/home_feed.dart'; -import 'package:nontonki/core/data/models/play_ticket.dart'; -import 'package:nontonki/core/data/repositories/catalog_repository.dart'; +import 'package:fruitshorts/core/data/models/drama.dart'; +import 'package:fruitshorts/core/data/models/home_feed.dart'; +import 'package:fruitshorts/core/data/models/play_ticket.dart'; +import 'package:fruitshorts/core/data/repositories/catalog_repository.dart'; /// 测试用目录数据:三部分区里的短剧,标题与后端演示数据保持一致。 class FakeCatalogRepository implements CatalogRepository { diff --git a/test/support/fake_watch_history.dart b/test/support/fake_watch_history.dart index 57f6ad4..9b4d8b1 100644 --- a/test/support/fake_watch_history.dart +++ b/test/support/fake_watch_history.dart @@ -1,4 +1,4 @@ -import 'package:nontonki/core/data/repositories/watch_history_repository.dart'; +import 'package:fruitshorts/core/data/repositories/watch_history_repository.dart'; /// Records every history interaction so tests can assert on the key it used. class FakeWatchHistory implements WatchHistoryRepository { diff --git a/test/support/widget_player.dart b/test/support/widget_player.dart index 6e2ad1d..2d3d81c 100644 --- a/test/support/widget_player.dart +++ b/test/support/widget_player.dart @@ -1,5 +1,5 @@ -import 'package:nontonki/core/data/models/drama.dart'; -import 'package:nontonki/core/data/models/player_port.dart'; +import 'package:fruitshorts/core/data/models/drama.dart'; +import 'package:fruitshorts/core/data/models/player_port.dart'; // Widget tests exercise navigation and scheduling without a native decoder. PlayerPort createWidgetPlayer(Episode episode) => WidgetPlayer(); diff --git a/test/widget_test.dart b/test/widget_test.dart index 28f02e2..9bdae0b 100644 --- a/test/widget_test.dart +++ b/test/widget_test.dart @@ -1,8 +1,8 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:nontonki/app.dart'; -import 'package:nontonki/pages/player/player_view.dart'; +import 'package:fruitshorts/app.dart'; +import 'package:fruitshorts/pages/player/player_view.dart'; import 'package:shared_preferences_platform_interface/in_memory_shared_preferences_async.dart'; import 'package:shared_preferences_platform_interface/shared_preferences_async_platform_interface.dart'; -- 2.54.0 From 94ff9f11779528f2ec9a0b79f3899ca9286cc489 Mon Sep 17 00:00:00 2001 From: Vicky <10212746+haifeng-jiang@user.noreply.gitee.com> Date: Fri, 16 Oct 2026 16:44:02 +0800 Subject: [PATCH 08/76] =?UTF-8?q?fix(client):=20=E5=85=BC=E5=AE=B9?= =?UTF-8?q?=E5=90=8E=E7=AB=AF=20Long=20=E5=AD=97=E6=AE=B5=E5=AD=97?= =?UTF-8?q?=E7=AC=A6=E4=B8=B2=E5=8C=96=EF=BC=88id=20=E4=B8=8E=E8=AE=A1?= =?UTF-8?q?=E6=95=B0=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 后端 J1 起 Long/long 一律以字符串下发(含雪花 id 与 viewCount/expiresIn)。 客户端 id 方向本来就是 (json['id'] ?? '').toString(),不受影响;会被 as num? 打挂的 是 Long 计数,这里加统一兼容解析并替换 3 处: - lib/core/data/models/json_numbers.dart(新增,接受数字或数字字符串) - lib/core/data/models/auth_session.dart(expiresIn,后端 long) - lib/core/data/models/drama.dart(viewCount,后端 Long ×2) - test/core/json_id_parsing_test.dart(新增 8 条回归用例) 其余 as num?(durationSec/unlockCoin/number/totalEpisodes/freeEpisodes/code)对应后端 Integer/int,仍是数字,未改动;未碰任何业务逻辑与 UI。 --- lib/core/data/models/auth_session.dart | 5 +- lib/core/data/models/drama.dart | 7 +- lib/core/data/models/json_numbers.dart | 13 ++++ test/core/json_id_parsing_test.dart | 103 +++++++++++++++++++++++++ 4 files changed, 125 insertions(+), 3 deletions(-) create mode 100644 lib/core/data/models/json_numbers.dart create mode 100644 test/core/json_id_parsing_test.dart diff --git a/lib/core/data/models/auth_session.dart b/lib/core/data/models/auth_session.dart index d3efa84..998fa49 100644 --- a/lib/core/data/models/auth_session.dart +++ b/lib/core/data/models/auth_session.dart @@ -1,3 +1,5 @@ +import 'json_numbers.dart'; + /// 登录态:服务端下发的令牌与用户摘要。 /// /// 只保留客户端真正要用的字段(uid / 昵称 / 头像),不做整份 AppUserRespVO 的映射 —— @@ -38,7 +40,8 @@ class AuthSession { factory AuthSession.fromJson(Map json) => AuthSession( accessToken: json['accessToken'] as String? ?? '', refreshToken: json['refreshToken'] as String? ?? '', - expiresIn: (json['expiresIn'] as num?)?.toInt() ?? 0, + // expiresIn 后端是 long,按字符串下发(见 json_numbers.dart) + expiresIn: jsonToInt(json['expiresIn']), user: AuthUser.fromJson((json['user'] as Map?)?.cast() ?? const {}), ); diff --git a/lib/core/data/models/drama.dart b/lib/core/data/models/drama.dart index a137f78..623e70d 100644 --- a/lib/core/data/models/drama.dart +++ b/lib/core/data/models/drama.dart @@ -1,3 +1,5 @@ +import 'json_numbers.dart'; + /// 短剧与剧集,字段与后端 `/app/**` 的下发结构对应。 /// /// 封面与播放地址都是后端返回的相对路径(`/files/...`), @@ -98,7 +100,8 @@ class Drama { genre: json['genre'] as String? ?? '', totalEpisodes: (json['totalEpisodes'] as num?)?.toInt() ?? 0, isHot: json['isHot'] == true, - viewCount: (json['viewCount'] as num?)?.toInt() ?? 0, + // viewCount 后端是 Long,按字符串下发(见 json_numbers.dart) + viewCount: jsonToInt(json['viewCount']), ); } @@ -114,7 +117,7 @@ class Drama { totalEpisodes: (json['totalEpisodes'] as num?)?.toInt() ?? 0, freeEpisodes: (json['freeEpisodes'] as num?)?.toInt() ?? 0, isHot: json['isHot'] == true, - viewCount: (json['viewCount'] as num?)?.toInt() ?? 0, + viewCount: jsonToInt(json['viewCount']), detailLoaded: true, episodes: (json['episodes'] as List? ?? const []) .whereType>() diff --git a/lib/core/data/models/json_numbers.dart b/lib/core/data/models/json_numbers.dart new file mode 100644 index 0000000..6fd1084 --- /dev/null +++ b/lib/core/data/models/json_numbers.dart @@ -0,0 +1,13 @@ +// Author: fruit.com.cn + +/// 数值字段的兼容解析。 +/// +/// 后端契约(FruitServer/docs/api-phase1.md §0):`Long`/`long` 字段**一律以字符串下发** +/// (雪花 id 与计数都算),`Integer`/`int` 仍是数字。所以这里既接受数字也接受数字字符串, +/// 否则一个 `"12345"` 就能让 `as num?` 直接抛异常、整页解析失败。 +int jsonToInt(dynamic value, {int fallback = 0}) { + if (value is int) return value; + if (value is num) return value.toInt(); + if (value is String) return int.tryParse(value.trim()) ?? fallback; + return fallback; +} diff --git a/test/core/json_id_parsing_test.dart b/test/core/json_id_parsing_test.dart new file mode 100644 index 0000000..2fbaa11 --- /dev/null +++ b/test/core/json_id_parsing_test.dart @@ -0,0 +1,103 @@ +// Author: fruit.com.cn + +import 'package:flutter_test/flutter_test.dart'; +import 'package:fruitshorts/core/data/models/auth_session.dart'; +import 'package:fruitshorts/core/data/models/drama.dart'; +import 'package:fruitshorts/core/data/models/json_numbers.dart'; +import 'package:fruitshorts/core/data/models/play_ticket.dart'; + +/// 后端契约(FruitServer/docs/api-phase1.md §0):`Long`/`long` 字段以字符串下发。 +/// 这里钉住客户端在"收到字符串形式的 id / 计数"时照样能解析,不抛异常。 +void main() { + group('jsonToInt', () { + test('should_parse_int_when_value_is_number', () { + expect(jsonToInt(12345), 12345); + expect(jsonToInt(12.9), 12); + }); + + test('should_parse_int_when_value_is_numeric_string', () { + expect(jsonToInt('2111012753262120962'), 2111012753262120962); + expect(jsonToInt(' 42 '), 42); + }); + + test('should_fall_back_when_value_is_missing_or_invalid', () { + expect(jsonToInt(null), 0); + expect(jsonToInt(''), 0); + expect(jsonToInt('abc'), 0); + expect(jsonToInt(null, fallback: 7), 7); + }); + }); + + group('drama model', () { + test('should_parse_string_ids_when_backend_sends_ids_as_string', () { + final drama = Drama.fromCardJson({ + 'id': '2111012753262120962', + 'title': '闪婚后,傅先生每天都在撒糖', + 'totalEpisodes': 72, + 'viewCount': '3100000', + 'isHot': true, + }); + + expect(drama.id, '2111012753262120962'); + expect(drama.title, '闪婚后,傅先生每天都在撒糖'); + expect(drama.totalEpisodes, 72); + // viewCount 后端是 Long → 字符串 + expect(drama.viewCount, 3100000); + }); + + test('should_parse_view_count_when_backend_sends_number', () { + final drama = Drama.fromCardJson({'id': 5, 'title': 'T', 'viewCount': 1200}); + + expect(drama.id, '5'); + expect(drama.viewCount, 1200); + }); + + test('should_parse_detail_payload_when_ids_are_strings', () { + final drama = Drama.fromDetailJson({ + 'id': '2111012753262120962', + 'title': 'T', + 'totalEpisodes': 12, + 'freeEpisodes': 3, + 'viewCount': '99', + 'episodes': [ + {'id': '2111012753262120963', 'number': 1, 'title': 'E1', 'isFree': true}, + ], + }); + + expect(drama.id, '2111012753262120962'); + expect(drama.freeEpisodes, 3); + expect(drama.viewCount, 99); + expect(drama.episodes.first.id, '2111012753262120963'); + expect(drama.episodes.first.number, 1); + }); + }); + + group('auth session', () { + test('should_parse_expires_in_when_backend_sends_string', () { + final session = AuthSession.fromJson({ + 'accessToken': 'a', + 'refreshToken': 'r', + 'expiresIn': '7200', + 'user': {'uid': 'u-1', 'nickname': 'n'}, + }); + + expect(session.expiresIn, 7200); + expect(session.user.uid, 'u-1'); + }); + }); + + group('play ticket', () { + test('should_parse_episode_id_when_backend_sends_string', () { + final ticket = PlayTicket.fromJson({ + 'episodeId': '2111012753262120963', + 'accessible': false, + 'accessType': PlayTicket.coinRequired, + 'unlockCoin': 30, + }); + + expect(ticket.episodeId, '2111012753262120963'); + expect(ticket.unlockCoin, 30); + expect(ticket.needsUnlock, isTrue); + }); + }); +} -- 2.54.0 From d7eff4ca599541bac1a67afdd36ecd86382bc1d2 Mon Sep 17 00:00:00 2001 From: Vicky <10212746+haifeng-jiang@user.noreply.gitee.com> Date: Fri, 16 Oct 2026 17:39:05 +0800 Subject: [PATCH 09/76] =?UTF-8?q?feat(client):=20=E5=AF=B9=E6=8E=A5?= =?UTF-8?q?=E8=AF=A6=E6=83=85/=E6=92=AD=E6=94=BE/=E8=BF=9B=E5=BA=A6?= =?UTF-8?q?=E7=BB=AD=E7=9C=8B/=E6=94=B6=E8=97=8F=EF=BC=88K1=20=E7=9C=8B?= =?UTF-8?q?=E5=89=A7=E9=97=AD=E7=8E=AF=EF=BC=89+=20=E4=B8=89=E6=80=81=20UI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 后端接口从 6 个扩到 13 个,全部走真数据: - 新增 api:playback_api(/app/episodes/{id}/play)、watch_api(/app/watch/*)、 library_api(/app/favorites*);票据从 CatalogApi 搬到 PlaybackApi - 新增 repository:PlaybackRepository(含票据 TTL 缓存,默认 10 分钟,时钟可注入)、 FavoriteRepository、WatchHistoryRepository 换成服务端模型(每剧一条续看记录,删掉 demoProfileId) - PlayerLogic:起播前取票(拿不到给三态 UI,失败可重试);accessType 驱动锁定文案, 不在前端猜;签名地址原样交给播放器(只补 host,不动 path/query); 进度上报节流 5s → 10s,切集/退出/切后台各补一次,播完带 finished - 续看定位:服务端记录里的那一集才 seek(其它集从头播),续看位置进详情/播放页时读一次 - FavoriteController:收藏以服务端为准,乐观更新 + 失败回滚;退出登录清空 - UI 三态:详情页(加载/失败可重试/空剧集 + 续看进度条 + 收藏按钮)、 播放页(票据加载中/失败可重试/后端判定不可播)、我的页(续看失败可重试、收藏三态、最近观看) - l10n 新增 8 个键(en/zh/id 三份):网络/进度/收藏失败、锁定提示、续看文案等 测试:flutter test 188 全过(存量 27 个测试文件未跑红);新增票据过期重取、进度节流、 续看定位、收藏回滚、签名 query 原样保留、真实后端端到端联调(live_watch_flow) --- lib/app.dart | 61 ++++++ lib/core/data/models/play_ticket.dart | 22 +- lib/core/data/models/watch_progress.dart | 61 ++++++ lib/core/data/remote/api_client.dart | 8 + lib/core/data/remote/catalog_api.dart | 7 - lib/core/data/remote/library_api.dart | 35 ++++ lib/core/data/remote/playback_api.dart | 20 ++ lib/core/data/remote/watch_api.dart | 59 ++++++ .../data/repositories/catalog_repository.dart | 9 +- .../repositories/favorite_repository.dart | 68 +++++++ .../repositories/playback_repository.dart | 96 +++++++++ .../watch_history_repository.dart | 170 +++++++++++----- .../data/services/catalog_controller.dart | 7 - .../data/services/favorite_controller.dart | 128 ++++++++++++ lib/core/formatting/error_text.dart | 16 ++ lib/l10n/app_en.arb | 75 ++++++- lib/l10n/app_id.arb | 75 ++++++- lib/l10n/app_localizations.dart | 48 +++++ lib/l10n/app_localizations_en.dart | 28 +++ lib/l10n/app_localizations_id.dart | 27 +++ lib/l10n/app_localizations_zh.dart | 26 +++ lib/l10n/app_zh.arb | 32 ++- lib/pages/discover/discover_binding.dart | 4 +- lib/pages/discover/discover_logic.dart | 6 +- lib/pages/discover/discover_view.dart | 2 +- .../drama_detail/drama_detail_binding.dart | 10 +- .../drama_detail/drama_detail_logic.dart | 61 +++++- lib/pages/drama_detail/drama_detail_view.dart | 180 ++++++++++++++++- lib/pages/mine/mine_binding.dart | 4 +- lib/pages/mine/mine_logic.dart | 34 +++- lib/pages/mine/mine_view.dart | 133 +++++++++++- lib/pages/player/player_binding.dart | 9 +- lib/pages/player/player_logic.dart | 186 ++++++++++++++--- lib/pages/player/player_view.dart | 126 +++++++++++- test/catalog/catalog_controller_test.dart | 35 ---- test/discover/discover_logic_test.dart | 16 +- .../drama_detail/drama_detail_logic_test.dart | 27 +-- test/integration/live_catalog_test.dart | 4 +- test/integration/live_watch_flow_test.dart | 114 +++++++++++ test/library/favorite_controller_test.dart | 103 ++++++++++ test/mine/mine_logic_test.dart | 6 +- .../playback/playback_ticket_expiry_test.dart | 120 +++++++++++ test/playback/progress_throttle_test.dart | 178 +++++++++++++++++ test/playback/watch_history_test.dart | 189 +++++++++--------- test/player/player_logic_test.dart | 32 ++- test/support/fake_catalog.dart | 11 - test/support/fake_watch_history.dart | 69 ++++--- test/widget_test.dart | 51 +++-- 48 files changed, 2411 insertions(+), 377 deletions(-) create mode 100644 lib/core/data/models/watch_progress.dart create mode 100644 lib/core/data/remote/library_api.dart create mode 100644 lib/core/data/remote/playback_api.dart create mode 100644 lib/core/data/remote/watch_api.dart create mode 100644 lib/core/data/repositories/favorite_repository.dart create mode 100644 lib/core/data/repositories/playback_repository.dart create mode 100644 lib/core/data/services/favorite_controller.dart create mode 100644 lib/core/formatting/error_text.dart create mode 100644 test/integration/live_watch_flow_test.dart create mode 100644 test/library/favorite_controller_test.dart create mode 100644 test/playback/playback_ticket_expiry_test.dart create mode 100644 test/playback/progress_throttle_test.dart diff --git a/lib/app.dart b/lib/app.dart index ff4f0cc..f03f479 100644 --- a/lib/app.dart +++ b/lib/app.dart @@ -1,3 +1,5 @@ +import 'dart:async'; + import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; @@ -5,12 +7,19 @@ 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/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/engagement_repository.dart'; +import 'core/data/repositories/favorite_repository.dart'; +import 'core/data/repositories/playback_repository.dart'; +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/engagement_controller.dart'; +import 'core/data/services/favorite_controller.dart'; import 'core/data/services/playback_session.dart'; import 'core/data/services/video_player_port.dart'; import 'l10n/app_localizations.dart'; @@ -21,12 +30,18 @@ class LumaDramaApp extends StatefulWidget { super.key, this.playerFactory = VideoPlayerPort.new, this.catalogRepository, + this.watchHistoryRepository, + this.favoriteRepository, + this.playbackRepository, }); final PlayerFactory playerFactory; /// 测试注入用;生产走 HTTP 仓库。 final CatalogRepository? catalogRepository; + final WatchHistoryRepository? watchHistoryRepository; + final FavoriteRepository? favoriteRepository; + final PlaybackRepository? playbackRepository; @override State createState() => _LumaDramaAppState(); @@ -46,11 +61,53 @@ class _LumaDramaAppState extends State { late final AuthController _auth = AuthController(AuthApi(_apiClient), _sessionStore); + late final WatchHistoryRepository _watchHistory = + widget.watchHistoryRepository ?? + HttpWatchHistoryRepository( + WatchApi(_apiClient), + isSignedIn: () => _auth.isSignedIn, + ); + + late final FavoriteRepository _favorites = + widget.favoriteRepository ?? + HttpFavoriteRepository( + LibraryApi(_apiClient), + isSignedIn: () => _auth.isSignedIn, + ); + + late final PlaybackRepository _playback = + widget.playbackRepository ?? HttpPlaybackRepository(PlaybackApi(_apiClient)); + + late final FavoriteController _favoriteController = FavoriteController(_favorites); + @override void initState() { super.initState(); // 恢复本地令牌与设备号;未登录也能正常浏览,不阻塞首屏 _auth.load(); + // 登录/登出时同步收藏状态:收藏属于账号,不能跨账号串联 + _auth.addListener(_onAuthChanged); + if (_auth.isSignedIn) unawaited(_favoriteController.load()); + } + + bool _wasSignedIn = false; + + void _onAuthChanged() { + if (_auth.isSignedIn == _wasSignedIn) return; + _wasSignedIn = _auth.isSignedIn; + if (_auth.isSignedIn) { + unawaited(_favoriteController.load()); + } else { + _favoriteController.clear(); + } + } + + @override + void dispose() { + _auth.removeListener(_onAuthChanged); + _favoriteController.dispose(); + _apiClient.close(); + super.dispose(); } @override @@ -59,12 +116,16 @@ class _LumaDramaAppState extends State { providers: [ Provider(create: (_) => PlaybackCoordinator()), Provider(create: (_) => widget.playerFactory), + Provider.value(value: _playback), + Provider.value(value: _watchHistory), + Provider.value(value: _favorites), ChangeNotifierProvider( create: (_) => CatalogController( widget.catalogRepository ?? HttpCatalogRepository(CatalogApi(_apiClient)), )..load(), ), ChangeNotifierProvider(create: (_) => LocaleController()..load()), + ChangeNotifierProvider.value(value: _favoriteController), ChangeNotifierProvider( create: (_) => EngagementController(SharedPreferencesEngagementRepository()) diff --git a/lib/core/data/models/play_ticket.dart b/lib/core/data/models/play_ticket.dart index b09aab7..bb4a899 100644 --- a/lib/core/data/models/play_ticket.dart +++ b/lib/core/data/models/play_ticket.dart @@ -1,12 +1,18 @@ +import 'json_numbers.dart'; + /// 播放票据:客户端据此决定直接播放、提示解锁还是提示暂无片源。 class PlayTicket { const PlayTicket({ required this.episodeId, required this.accessible, required this.accessType, + this.dramaId = '', + this.number = 0, + this.title = '', this.playUrl = '', this.durationSec = 0, this.unlockCoin = 0, + this.previewSeconds = 0, }); static const String free = 'FREE'; @@ -15,23 +21,35 @@ class PlayTicket { static const String noMedia = 'NO_MEDIA'; final String episodeId; + final String dramaId; + final int number; + final String title; final bool accessible; final String accessType; + + /// 签名播放地址:**原样使用**(含 `?e=&s=`),客户端不拼接、不改写。 final String playUrl; final int durationSec; final int unlockCoin; + /// 试看秒数:仅 `COIN_REQUIRED` 时有意义(付费解锁在 B2 做)。 + final int previewSeconds; + bool get needsUnlock => accessType == coinRequired || accessType == vipRequired; factory PlayTicket.fromJson(Map json) { return PlayTicket( episodeId: (json['episodeId'] ?? '').toString(), + dramaId: (json['dramaId'] ?? '').toString(), + number: jsonToInt(json['number']), + title: json['title'] as String? ?? '', accessible: json['accessible'] == true, accessType: json['accessType'] as String? ?? noMedia, playUrl: json['playUrl'] as String? ?? '', - durationSec: (json['durationSec'] as num?)?.toInt() ?? 0, - unlockCoin: (json['unlockCoin'] as num?)?.toInt() ?? 0, + durationSec: jsonToInt(json['durationSec']), + unlockCoin: jsonToInt(json['unlockCoin']), + previewSeconds: jsonToInt(json['previewSeconds']), ); } } diff --git a/lib/core/data/models/watch_progress.dart b/lib/core/data/models/watch_progress.dart new file mode 100644 index 0000000..1f2d392 --- /dev/null +++ b/lib/core/data/models/watch_progress.dart @@ -0,0 +1,61 @@ +// Author: fruit.com.cn + +import 'json_numbers.dart'; + +/// 服务端续看记录:`GET /app/watch/progress?dramaId=` 与 `/app/watch/recent` 的下发结构。 +/// +/// 服务端按 `(user, drama)` 只留一条,所以它是"这部剧看到哪一集的哪一秒", +/// 不是逐集进度。ID 与毫秒都是字符串(见 api-phase1.md §0),统一走 jsonToInt 解析。 +class WatchProgress { + const WatchProgress({ + required this.dramaId, + required this.episodeId, + required this.position, + required this.duration, + this.finished = false, + this.playCount = 0, + }); + + final String dramaId; + final String episodeId; + final Duration position; + final Duration duration; + final bool finished; + final int playCount; + + bool get hasPosition => position > Duration.zero; + + /// 进度比例 0~1,时长未知时为 0,避免 UI 出现 NaN。 + double get fraction { + if (duration <= Duration.zero) return 0; + return (position.inMilliseconds / duration.inMilliseconds).clamp(0.0, 1.0); + } + + factory WatchProgress.fromJson(Map json) { + return WatchProgress( + dramaId: (json['dramaId'] ?? '').toString(), + episodeId: (json['episodeId'] ?? '').toString(), + position: Duration(milliseconds: jsonToInt(json['positionMs'])), + duration: Duration(milliseconds: jsonToInt(json['durationMs'])), + finished: json['finished'] == true, + playCount: jsonToInt(json['playCount']), + ); + } + + Map toJson() => { + 'dramaId': dramaId, + 'episodeId': episodeId, + 'positionMs': position.inMilliseconds, + 'durationMs': duration.inMilliseconds, + 'finished': finished, + 'playCount': playCount, + }; +} + +/// 续看点:从哪一集的哪个位置继续看。 +class ResumePoint { + const ResumePoint({required this.episodeId, required this.position}); + + final String episodeId; + final Duration position; +} diff --git a/lib/core/data/remote/api_client.dart b/lib/core/data/remote/api_client.dart index e9fb88b..15acde2 100644 --- a/lib/core/data/remote/api_client.dart +++ b/lib/core/data/remote/api_client.dart @@ -79,6 +79,14 @@ class ApiClient { ); } + Future delete( + String path, { + Object? body, + Map? query, + }) { + return _request('DELETE', path, body: body, query: query); + } + Future _request( String method, String path, { diff --git a/lib/core/data/remote/catalog_api.dart b/lib/core/data/remote/catalog_api.dart index 54352b4..4346460 100644 --- a/lib/core/data/remote/catalog_api.dart +++ b/lib/core/data/remote/catalog_api.dart @@ -1,6 +1,5 @@ import '../models/drama.dart'; import '../models/home_feed.dart'; -import '../models/play_ticket.dart'; import 'api_client.dart'; /// 客户端目录接口,对应后端 `/app/**`。 @@ -23,12 +22,6 @@ class CatalogApi { ); } - Future playTicket(String episodeId) async { - return PlayTicket.fromJson( - _asMap(await _client.get('/app/episodes/$episodeId/play')), - ); - } - Map _asMap(Object? data) { if (data is Map) return data; throw const ApiException(-1, '返回数据格式异常'); diff --git a/lib/core/data/remote/library_api.dart b/lib/core/data/remote/library_api.dart new file mode 100644 index 0000000..14c09b7 --- /dev/null +++ b/lib/core/data/remote/library_api.dart @@ -0,0 +1,35 @@ +// Author: fruit.com.cn + +import '../models/drama.dart'; +import 'api_client.dart'; + +/// 收藏接口:`/app/favorites*`(契约 §1.5)。需要登录态。 +/// +/// 列表返回的是与首页一致的卡片结构,所以直接用 `Drama.fromCardJson` 解析。 +class LibraryApi { + const LibraryApi(this._client); + + final ApiClient _client; + + /// 切换收藏,返回切换后的状态(true = 已收藏),客户端以它为唯一真相。 + Future toggleFavorite(String dramaId) async { + final data = await _client.post( + '/app/favorites/toggle', + body: {'dramaId': dramaId}, + ); + return data == true; + } + + Future> favorites() async { + final data = await _client.get('/app/favorites'); + if (data is! List) return const []; + return [ + for (final item in data) + if (item is Map) Drama.fromCardJson(item), + ]; + } + + Future removeFavorite(String dramaId) async { + await _client.delete('/app/favorites/$dramaId'); + } +} diff --git a/lib/core/data/remote/playback_api.dart b/lib/core/data/remote/playback_api.dart new file mode 100644 index 0000000..0122d95 --- /dev/null +++ b/lib/core/data/remote/playback_api.dart @@ -0,0 +1,20 @@ +// Author: fruit.com.cn + +import '../models/play_ticket.dart'; +import 'api_client.dart'; + +/// 播放票据接口:`GET /app/episodes/{id}/play`(契约 §1.4)。 +/// +/// **签名地址原样使用**:后端下发的 `playUrl` 带 `?e=过期时间&s=签名`, +/// 客户端只做「相对路径补 host」,不拼接、不改写、不丢 query —— 否则签名校验直接失败。 +class PlaybackApi { + const PlaybackApi(this._client); + + final ApiClient _client; + + Future ticket(String episodeId) async { + final data = await _client.get('/app/episodes/$episodeId/play'); + if (data is Map) return PlayTicket.fromJson(data); + throw const ApiException(-1, '返回数据格式异常'); + } +} diff --git a/lib/core/data/remote/watch_api.dart b/lib/core/data/remote/watch_api.dart new file mode 100644 index 0000000..f09ea90 --- /dev/null +++ b/lib/core/data/remote/watch_api.dart @@ -0,0 +1,59 @@ +// Author: fruit.com.cn + +import '../models/watch_progress.dart'; +import 'api_client.dart'; + +/// 观看进度接口:`/app/watch/*`(契约 §1.5)。全部需要登录态。 +class WatchApi { + const WatchApi(this._client); + + final ApiClient _client; + + /// 上报进度。服务端从 `episodeId` 推出所属剧集,并保证「同集只前进不后退」。 + Future saveProgress({ + required String episodeId, + required Duration position, + Duration? duration, + bool finished = false, + String source = 'app', + }) async { + final data = await _client.post( + '/app/watch/progress', + body: { + 'episodeId': episodeId, + 'positionMs': position.inMilliseconds, + if (duration != null) 'durationMs': duration.inMilliseconds, + 'finished': finished, + 'source': source, + }, + ); + return data is Map ? WatchProgress.fromJson(data) : null; + } + + /// 某部剧的续看位置;没有记录时后端返回空 data。 + Future progressOfDrama(String dramaId) async { + final data = await _client.get( + '/app/watch/progress', + query: {'dramaId': dramaId}, + ); + return data is Map ? WatchProgress.fromJson(data) : null; + } + + /// 最近观看(服务端按下标返回,已按更新时间倒序)。 + Future> recent({int limit = 20}) async { + final data = await _client.get( + '/app/watch/recent', + query: {'limit': '$limit'}, + ); + if (data is! List) return const []; + return [ + for (final item in data) + if (item is Map) WatchProgress.fromJson(item), + ]; + } + + /// 删除某部剧的观看记录(记录页清单条用)。 + Future removeProgress(String dramaId) async { + await _client.delete('/app/watch/progress/$dramaId'); + } +} diff --git a/lib/core/data/repositories/catalog_repository.dart b/lib/core/data/repositories/catalog_repository.dart index 8762895..f8a176b 100644 --- a/lib/core/data/repositories/catalog_repository.dart +++ b/lib/core/data/repositories/catalog_repository.dart @@ -1,19 +1,17 @@ import '../models/drama.dart'; import '../models/home_feed.dart'; -import '../models/play_ticket.dart'; import '../remote/catalog_api.dart'; -/// 目录数据来源:首页/发现页聚合、详情、播放票据。 +/// 目录数据来源:首页/发现页聚合、详情。 /// /// 首页卡片不带剧集,进详情或播放时才按需取,保证列表接口足够轻。 +/// **播放票据不在这里**:它属于 [PlaybackRepository](票据有有效期,需要单独缓存策略)。 abstract interface class CatalogRepository { Future fetchHomeFeed(); Future fetchDiscoverFeed(); Future fetchDrama(String dramaId); - - Future resolvePlay(String episodeId); } class HttpCatalogRepository implements CatalogRepository { @@ -30,7 +28,4 @@ class HttpCatalogRepository implements CatalogRepository { @override Future fetchDrama(String dramaId) => _api.dramaDetail(dramaId); - @override - Future resolvePlay(String episodeId) => - _api.playTicket(episodeId); } diff --git a/lib/core/data/repositories/favorite_repository.dart b/lib/core/data/repositories/favorite_repository.dart new file mode 100644 index 0000000..1123505 --- /dev/null +++ b/lib/core/data/repositories/favorite_repository.dart @@ -0,0 +1,68 @@ +// Author: fruit.com.cn + +import '../models/drama.dart'; +import '../remote/library_api.dart'; + +/// 收藏来源:**以服务端为准**(本地不再存收藏状态)。 +abstract interface class FavoriteRepository { + /// 切换收藏,返回切换后的状态(true = 已收藏)。 + Future toggle(String dramaId); + + /// 收藏列表(卡片结构与首页一致)。 + Future> list(); + + Future remove(String dramaId); +} + +class HttpFavoriteRepository implements FavoriteRepository { + const HttpFavoriteRepository(this._api, {this.isSignedIn}); + + final LibraryApi _api; + + /// 未登录时不请求:收藏属于账号,匿名浏览时列表按空处理(点收藏按钮会先引导登录)。 + final bool Function()? isSignedIn; + + bool get _signedIn => isSignedIn?.call() ?? true; + + @override + Future toggle(String dramaId) => _api.toggleFavorite(dramaId); + + @override + Future> list() async { + if (!_signedIn) return const []; + return _api.favorites(); + } + + @override + Future remove(String dramaId) => _api.removeFavorite(dramaId); +} + +/// 内存实现:单测与 widget 测试注入用。 +class InMemoryFavoriteRepository implements FavoriteRepository { + InMemoryFavoriteRepository({Set? saved, List? cards}) + : _saved = {...?saved}, + _cards = [...?cards]; + + final Set _saved; + final List _cards; + bool failToggle = false; + bool failList = false; + int toggleCalls = 0; + + @override + Future toggle(String dramaId) async { + toggleCalls += 1; + if (failToggle) throw StateError('favorite unavailable'); + if (!_saved.add(dramaId)) _saved.remove(dramaId); + return _saved.contains(dramaId); + } + + @override + Future> list() async { + if (failList) throw StateError('favorite unavailable'); + return _cards.where((card) => _saved.contains(card.id)).toList(); + } + + @override + Future remove(String dramaId) async => _saved.remove(dramaId); +} diff --git a/lib/core/data/repositories/playback_repository.dart b/lib/core/data/repositories/playback_repository.dart new file mode 100644 index 0000000..24bc443 --- /dev/null +++ b/lib/core/data/repositories/playback_repository.dart @@ -0,0 +1,96 @@ +// Author: fruit.com.cn + +import '../models/play_ticket.dart'; +import '../remote/playback_api.dart'; + +/// 播放票据来源。 +/// +/// 票据里的签名地址有有效期(契约 §1.4:签名默认 15 分钟),所以**不能一直缓存**: +/// [ticketFor] 命中未过期的缓存就用缓存,过期或 [forceRefresh] 时重新向后端要一张。 +abstract interface class PlaybackRepository { + Future ticketFor(String episodeId, {bool forceRefresh = false}); + + /// 当前缓存的票据是否还在有效期内(用于"回前台发现过期就重新取")。 + bool isFresh(String episodeId); +} + +class HttpPlaybackRepository implements PlaybackRepository { + HttpPlaybackRepository( + this._api, { + this.ttl = const Duration(minutes: 10), + DateTime Function()? clock, + }) : _clock = clock ?? DateTime.now; + + final PlaybackApi _api; + + /// 缓存时长:比后端 15 分钟签名短 5 分钟,避免"地址刚好在播放中途失效"。 + final Duration ttl; + final DateTime Function() _clock; + final Map _cache = {}; + + @override + Future ticketFor( + String episodeId, { + bool forceRefresh = false, + }) async { + final cached = _cache[episodeId]; + if (!forceRefresh && cached != null && !cached.isExpired(_clock(), ttl)) { + return cached.ticket; + } + final ticket = await _api.ticket(episodeId); + _cache[episodeId] = _CachedTicket(ticket, _clock()); + return ticket; + } + + @override + bool isFresh(String episodeId) { + final cached = _cache[episodeId]; + if (cached == null) return false; + return !cached.isExpired(_clock(), ttl); + } + + /// 供测试与"退出播放页"清理用。 + void clear() => _cache.clear(); +} + +class _CachedTicket { + const _CachedTicket(this.ticket, this.fetchedAt); + + final PlayTicket ticket; + final DateTime fetchedAt; + + bool isExpired(DateTime now, Duration ttl) => now.difference(fetchedAt) >= ttl; +} + +/// 测试与离线场景用:按集返回固定票据,并记录被请求过几次。 +class FakePlaybackRepository implements PlaybackRepository { + FakePlaybackRepository({this.ticket, this.error, this.fresh = true}); + + PlayTicket? ticket; + Object? error; + final List requests = []; + final List forced = []; + + /// 模拟"票据是否还有效":置 false 可验证回前台会重新取。 + bool fresh; + + @override + bool isFresh(String episodeId) => fresh; + + @override + Future ticketFor( + String episodeId, { + bool forceRefresh = false, + }) async { + requests.add(episodeId); + forced.add(forceRefresh); + if (error != null) throw error!; + return ticket ?? + PlayTicket( + episodeId: episodeId, + accessible: true, + accessType: PlayTicket.free, + playUrl: '/files/episode/fake-$episodeId.mp4?e=1&s=abc', + ); + } +} diff --git a/lib/core/data/repositories/watch_history_repository.dart b/lib/core/data/repositories/watch_history_repository.dart index da15c63..7b5e79b 100644 --- a/lib/core/data/repositories/watch_history_repository.dart +++ b/lib/core/data/repositories/watch_history_repository.dart @@ -1,78 +1,142 @@ -import 'package:shared_preferences/shared_preferences.dart'; +// Author: fruit.com.cn -import '../models/drama.dart'; - -const demoProfileId = 'demo-local-v1'; +import '../models/watch_progress.dart'; +import '../remote/watch_api.dart'; +/// 观看进度来源。 +/// +/// **服务端按 `(user, drama)` 只留一条续看记录**(契约 §1.5),所以这里不再是 +/// "本地按 profile+剧+集存位置",而是"这部剧看到哪一集、哪一秒"。 +/// 本地实现已删除:进度以服务端为准,换设备也能续看。 abstract interface class WatchHistoryRepository { - Future positionFor( - String profileId, - String dramaId, - String episodeId, - ); - Future lastEpisodeId(String profileId, String dramaId); - Future save( - String profileId, - String dramaId, - String episodeId, - Duration position, - ); + /// 某部剧的续看记录;没有记录返回 null(不是异常)。 + Future progressFor(String dramaId); + + /// 上报进度(客户端每 10 秒一次,切集/退出/切后台各补一次)。 + Future save({ + required String episodeId, + required Duration position, + Duration? duration, + bool finished = false, + }); + + /// 最近观看(默认 20 条)。 + Future> recent({int limit = 20}); + + /// 清理某部剧的记录(K2 的记录页会用,这里先备好)。 + Future remove(String dramaId); } -class SharedPreferencesWatchHistoryRepository - implements WatchHistoryRepository { - SharedPreferencesWatchHistoryRepository({SharedPreferencesAsync? preferences}) - : _preferences = preferences ?? SharedPreferencesAsync(); +class HttpWatchHistoryRepository implements WatchHistoryRepository { + const HttpWatchHistoryRepository(this._api, {this.isSignedIn}); - final SharedPreferencesAsync _preferences; + final WatchApi _api; - String _positionKey(String profile, String drama, String episode) => - 'watch.v1.$profile.$drama.$episode.positionMs'; - String _lastKey(String profile, String drama) => - 'watch.v1.$profile.$drama.lastEpisode'; + /// 未登录时这些接口必然 401:直接短路成"没有记录",让浏览/试看保持匿名可用。 + final bool Function()? isSignedIn; + + bool get _signedIn => isSignedIn?.call() ?? true; @override - Future positionFor( - String profileId, - String dramaId, - String episodeId, - ) async { - final milliseconds = await _preferences.getInt( - _positionKey(profileId, dramaId, episodeId), + Future progressFor(String dramaId) async { + if (!_signedIn) return null; + return _api.progressOfDrama(dramaId); + } + + @override + Future save({ + required String episodeId, + required Duration position, + Duration? duration, + bool finished = false, + }) async { + if (!_signedIn) return null; + return _api.saveProgress( + episodeId: episodeId, + position: position, + duration: duration, + finished: finished, ); - return milliseconds == null ? null : Duration(milliseconds: milliseconds); } @override - Future lastEpisodeId(String profileId, String dramaId) => - _preferences.getString(_lastKey(profileId, dramaId)); + Future> recent({int limit = 20}) async { + if (!_signedIn) return const []; + return _api.recent(limit: limit); + } @override - Future save( - String profileId, - String dramaId, - String episodeId, - Duration position, - ) async { - await _preferences.setInt( - _positionKey(profileId, dramaId, episodeId), - position.inMilliseconds, + Future remove(String dramaId) async { + if (!_signedIn) return; + await _api.removeProgress(dramaId); + } +} + +/// 内存实现:单测与 widget 测试注入用(不依赖网络与偏好存储)。 +class InMemoryWatchHistoryRepository implements WatchHistoryRepository { + InMemoryWatchHistoryRepository({List? seed}) + : _records = {for (final item in seed ?? const []) item.dramaId: item}; + + final Map _records; + int failReads = 0; + bool failWrites = false; + final List writes = []; + + @override + Future progressFor(String dramaId) async { + if (failReads > 0) { + failReads -= 1; + throw StateError('progress unavailable'); + } + return _records[dramaId]; + } + + @override + Future save({ + required String episodeId, + required Duration position, + Duration? duration, + bool finished = false, + }) async { + if (failWrites) throw StateError('progress unavailable'); + writes.add('$episodeId|${position.inMilliseconds}|$finished'); + final existing = _records[episodeId]; + final record = WatchProgress( + dramaId: existing?.dramaId ?? '', + episodeId: episodeId, + position: position, + duration: duration ?? Duration.zero, + finished: finished, ); - await _preferences.setString(_lastKey(profileId, dramaId), episodeId); + return record; } + + @override + Future> recent({int limit = 20}) async { + if (failReads > 0) { + failReads -= 1; + throw StateError('progress unavailable'); + } + return _records.values.take(limit).toList(); + } + + @override + Future remove(String dramaId) async => _records.remove(dramaId); } -/// 续看位置:列表卡片没有剧集列表,取不到首集时退回最近观看的那一集。 -extension WatchHistoryResume on WatchHistoryRepository { - Future resumePositionFor(String profileId, Drama drama) async { - final episodeId = drama.episodes.isNotEmpty - ? drama.episodes.first.id - : await lastEpisodeId(profileId, drama.id); - if (episodeId == null) return null; - return positionFor(profileId, drama.id, episodeId); +/// 续看点辅助:把服务端记录换算成"第几集 + 从哪一秒开始"。 +extension WatchProgressResume on WatchHistoryRepository { + Future resumePointFor(String dramaId) async { + final progress = await progressFor(dramaId); + if (progress == null || progress.episodeId.isEmpty) return null; + return ResumePoint( + episodeId: progress.episodeId, + position: progress.position, + ); } } +/// 续看位置钳位:片尾附近与异常值一律从 0 开始,避免"一进来就播完"。 Duration clampResumePosition(Duration saved, Duration duration) { if (duration <= const Duration(milliseconds: 500)) return Duration.zero; if (saved <= Duration.zero) return Duration.zero; diff --git a/lib/core/data/services/catalog_controller.dart b/lib/core/data/services/catalog_controller.dart index 00e446c..f8daacd 100644 --- a/lib/core/data/services/catalog_controller.dart +++ b/lib/core/data/services/catalog_controller.dart @@ -46,13 +46,6 @@ class CatalogController extends ChangeNotifier { return detail; } - /// 播放前解析票据:返回带播放地址的剧集,锁定集保持无地址。 - Future resolvePlay(Episode episode) async { - if (episode.videoUrl.isNotEmpty) return episode; - final ticket = await repository.resolvePlay(episode.id); - return ticket.accessible ? episode.withVideoUrl(ticket.playUrl) : episode; - } - void _replace(Drama detail) { final sections = feed.sections .map( diff --git a/lib/core/data/services/favorite_controller.dart b/lib/core/data/services/favorite_controller.dart new file mode 100644 index 0000000..64c1ab1 --- /dev/null +++ b/lib/core/data/services/favorite_controller.dart @@ -0,0 +1,128 @@ +// Author: fruit.com.cn + +import 'package:flutter/foundation.dart'; + +import '../models/drama.dart'; +import '../repositories/favorite_repository.dart'; + +/// 收藏状态:**以服务端为准**。 +/// +/// 点击收藏先乐观更新(立刻变色),失败再回滚并给出提示 —— 网络抖动时不至于 +/// "点了没反应"或"看起来收藏了其实没有"。 +class FavoriteController extends ChangeNotifier { + FavoriteController(this._repository); + + final FavoriteRepository _repository; + final Set _saved = {}; + List cards = const []; + bool loading = false; + String? error; + bool _disposed = false; + + Set get savedIds => Set.unmodifiable(_saved); + + bool isSaved(String dramaId) => _saved.contains(dramaId); + + void notify() { + if (!_disposed) notifyListeners(); + } + + /// 拉收藏列表:列表既用于"我的"页展示,也用于校准 [savedIds]。 + Future load() async { + loading = true; + error = null; + notify(); + try { + final list = await _repository.list(); + cards = list; + _saved + ..clear() + ..addAll(list.map((drama) => drama.id)); + } catch (_) { + error = 'favoritesError'; + } finally { + loading = false; + notify(); + } + } + + /// 未登录时不要调用(服务端要求登录态)。 + /// + /// [card] 是当前剧的卡片(播放页/详情页手上就有):收藏成功时直接放进列表, + /// 这样"收藏完打开我的收藏"能立刻看到,不必等下一次整表刷新。 + Future toggle(String dramaId, {Drama? card}) async { + final wasSaved = _saved.contains(dramaId); + // 乐观更新 + if (wasSaved) { + _saved.remove(dramaId); + cards = cards.where((drama) => drama.id != dramaId).toList(); + } else { + _saved.add(dramaId); + } + notify(); + try { + final saved = await _repository.toggle(dramaId); + // 以服务端返回的状态为准(可能与本地猜测不同,例如并发操作) + if (saved) { + _saved.add(dramaId); + if (card != null && !cards.any((drama) => drama.id == dramaId)) { + cards = [card, ...cards]; + } + } else { + _saved.remove(dramaId); + cards = cards.where((drama) => drama.id != dramaId).toList(); + } + notify(); + return true; + } catch (_) { + // 回滚 + if (wasSaved) { + _saved.add(dramaId); + } else { + _saved.remove(dramaId); + } + notify(); + return false; + } + } + + /// 取消收藏("我的"页列表里删除某条)。 + Future remove(String dramaId) async { + final removed = cards.firstWhere( + (drama) => drama.id == dramaId, + orElse: () => const Drama( + id: '', + title: '', + synopsis: '', + posterUrl: '', + ), + ); + final hadCard = removed.id.isNotEmpty; + _saved.remove(dramaId); + cards = cards.where((drama) => drama.id != dramaId).toList(); + notify(); + try { + await _repository.remove(dramaId); + return true; + } catch (_) { + if (hadCard) cards = [...cards, removed]; + _saved.add(dramaId); + notify(); + return false; + } + } + + /// 退出登录时清空:收藏状态属于账号,不能跨账号串联。 + void clear() { + _saved.clear(); + cards = const []; + error = null; + notify(); + } + + @override + void dispose() { + _disposed = true; + super.dispose(); + } +} diff --git a/lib/core/formatting/error_text.dart b/lib/core/formatting/error_text.dart new file mode 100644 index 0000000..c538be9 --- /dev/null +++ b/lib/core/formatting/error_text.dart @@ -0,0 +1,16 @@ +// Author: fruit.com.cn + +import '../../l10n/app_localizations.dart'; + +/// logic 里的错误在两种情况下是"哨兵值":本地网络异常(读不到后端提示语)与 +/// 我们自己包装的失败。这里统一翻译成当前语言的文案;服务端给的中文提示原样展示。 +String errorText(AppLocalizations l10n, String? code, String fallback) { + if (code == null || code.isEmpty) return fallback; + return switch (code) { + 'networkError' => l10n.networkError, + 'progressError' => l10n.progressError, + 'favoritesError' => l10n.favoritesError, + 'ticketError' => l10n.playbackError, + final value => value, + }; +} diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index ef8e20c..4fa0f67 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -34,7 +34,13 @@ "localDemoProfile": "Local demo profile", "continueWatching": "Continue Watching", "watchedPercent": "Watched {percent}%", - "@watchedPercent": {"placeholders": {"percent": {"type": "int"}}}, + "@watchedPercent": { + "placeholders": { + "percent": { + "type": "int" + } + } + }, "resume": "Resume", "history": "History", "watchlist": "Watchlist", @@ -72,16 +78,40 @@ "originalTag": "Original", "dramaTag": "Short drama", "episodeLabel": "Episode {number}", - "@episodeLabel": {"placeholders": {"number": {"type": "int"}}}, + "@episodeLabel": { + "placeholders": { + "number": { + "type": "int" + } + } + }, "exploreSeries": "Explore series", "episodeCount": "{count} EPISODES", - "@episodeCount": {"placeholders": {"count": {"type": "int"}}}, + "@episodeCount": { + "placeholders": { + "count": { + "type": "int" + } + } + }, "technicalDemoCount": "FREE PREVIEW · {count} EPISODES", - "@technicalDemoCount": {"placeholders": {"count": {"type": "int"}}}, + "@technicalDemoCount": { + "placeholders": { + "count": { + "type": "int" + } + } + }, "episodes": "Episodes", "watchEpisodeOne": "Watch episode 1", "continueEpisode": "Continue episode {number}", - "@continueEpisode": {"placeholders": {"number": {"type": "int"}}}, + "@continueEpisode": { + "placeholders": { + "number": { + "type": "int" + } + } + }, "freeTestMedia": "Same demo clip · free", "lockedStoreUnavailable": "Locked · store unavailable", "freeTestClip": "Free test clip", @@ -89,10 +119,25 @@ "freeSamplesNotice": "Two free samples · store setup pending", "demoTestMedia": "FREE · SAME DEMO CLIP", "episodeProgress": "EPISODE {number} / {total}", - "@episodeProgress": {"placeholders": {"number": {"type": "int"}, "total": {"type": "int"}}}, + "@episodeProgress": { + "placeholders": { + "number": { + "type": "int" + }, + "total": { + "type": "int" + } + } + }, "testVideoNotice": "Self-generated technical test video", "lockedTitle": "Episode {number} is locked", - "@lockedTitle": {"placeholders": {"number": {"type": "int"}}}, + "@lockedTitle": { + "placeholders": { + "number": { + "type": "int" + } + } + }, "lockedBody": "Unlocking will be available after store and verification setup. This demo does not process payments.", "playbackError": "This clip could not be played.", "catalogError": "The catalog could not be loaded.", @@ -180,5 +225,19 @@ "authGateTitle": "Sign in to continue", "authGateMessage": "Favorites and comments need an account.", "authGateAction": "Sign In", - "cancel": "Not now" + "cancel": "Not now", + "noEpisodesYet": "No playable episodes yet.", + "networkError": "Network is unreachable. Please check your connection and retry.", + "progressError": "Your watch position could not be loaded.", + "favoritesError": "Your favorites could not be loaded.", + "favoriteToggleFailed": "Could not update favorites. Please retry.", + "remove": "Remove", + "unlockComingSoon": "Unlocking with coins is coming soon.", + "resumeProgress": "Resume at {position} / {total}", + "@resumeProgress": { + "placeholders": { + "position": {}, + "total": {} + } + } } diff --git a/lib/l10n/app_id.arb b/lib/l10n/app_id.arb index 788b6e7..023a9e4 100644 --- a/lib/l10n/app_id.arb +++ b/lib/l10n/app_id.arb @@ -34,7 +34,13 @@ "localDemoProfile": "Profil demo lokal", "continueWatching": "Lanjut Tonton", "watchedPercent": "Sudah ditonton {percent}%", - "@watchedPercent": {"placeholders": {"percent": {"type": "int"}}}, + "@watchedPercent": { + "placeholders": { + "percent": { + "type": "int" + } + } + }, "resume": "Lanjutkan", "history": "Riwayat", "watchlist": "Daftar Tonton", @@ -72,16 +78,40 @@ "originalTag": "Original", "dramaTag": "Drama pendek", "episodeLabel": "Episode {number}", - "@episodeLabel": {"placeholders": {"number": {"type": "int"}}}, + "@episodeLabel": { + "placeholders": { + "number": { + "type": "int" + } + } + }, "exploreSeries": "Lihat serial", "episodeCount": "{count} EPISODE", - "@episodeCount": {"placeholders": {"count": {"type": "int"}}}, + "@episodeCount": { + "placeholders": { + "count": { + "type": "int" + } + } + }, "technicalDemoCount": "PRATINJAU GRATIS · {count} EPISODE", - "@technicalDemoCount": {"placeholders": {"count": {"type": "int"}}}, + "@technicalDemoCount": { + "placeholders": { + "count": { + "type": "int" + } + } + }, "episodes": "Episode", "watchEpisodeOne": "Tonton episode 1", "continueEpisode": "Lanjut episode {number}", - "@continueEpisode": {"placeholders": {"number": {"type": "int"}}}, + "@continueEpisode": { + "placeholders": { + "number": { + "type": "int" + } + } + }, "freeTestMedia": "Klip demo sama · gratis", "lockedStoreUnavailable": "Terkunci · toko belum tersedia", "freeTestClip": "Klip uji gratis", @@ -89,10 +119,25 @@ "freeSamplesNotice": "Dua sampel gratis · pengaturan toko belum selesai", "demoTestMedia": "GRATIS · KLIP DEMO SAMA", "episodeProgress": "EPISODE {number} / {total}", - "@episodeProgress": {"placeholders": {"number": {"type": "int"}, "total": {"type": "int"}}}, + "@episodeProgress": { + "placeholders": { + "number": { + "type": "int" + }, + "total": { + "type": "int" + } + } + }, "testVideoNotice": "Video uji teknis buatan sendiri", "lockedTitle": "Episode {number} terkunci", - "@lockedTitle": {"placeholders": {"number": {"type": "int"}}}, + "@lockedTitle": { + "placeholders": { + "number": { + "type": "int" + } + } + }, "lockedBody": "Pembukaan kunci tersedia setelah toko dan verifikasi disiapkan. Demo ini tidak memproses pembayaran.", "playbackError": "Klip ini tidak bisa diputar.", "catalogError": "Katalog gagal dimuat.", @@ -180,5 +225,19 @@ "authGateTitle": "Masuk untuk melanjutkan", "authGateMessage": "Favorit dan komentar perlu akun.", "authGateAction": "Masuk", - "cancel": "Nanti saja" + "cancel": "Nanti saja", + "noEpisodesYet": "Belum ada episode yang bisa diputar.", + "networkError": "Jaringan tidak tersedia. Periksa koneksi lalu coba lagi.", + "progressError": "Posisi tonton gagal dimuat.", + "favoritesError": "Daftar favorit gagal dimuat.", + "favoriteToggleFailed": "Gagal memperbarui favorit. Coba lagi.", + "remove": "Hapus", + "unlockComingSoon": "Pembukaan dengan koin segera hadir.", + "resumeProgress": "Lanjut di {position} / {total}", + "@resumeProgress": { + "placeholders": { + "position": {}, + "total": {} + } + } } diff --git a/lib/l10n/app_localizations.dart b/lib/l10n/app_localizations.dart index fcc3d0e..e372697 100644 --- a/lib/l10n/app_localizations.dart +++ b/lib/l10n/app_localizations.dart @@ -1143,6 +1143,54 @@ abstract class AppLocalizations { /// In en, this message translates to: /// **'Not now'** String get cancel; + + /// No description provided for @noEpisodesYet. + /// + /// In en, this message translates to: + /// **'No playable episodes yet.'** + String get noEpisodesYet; + + /// No description provided for @networkError. + /// + /// In en, this message translates to: + /// **'Network is unreachable. Please check your connection and retry.'** + String get networkError; + + /// No description provided for @progressError. + /// + /// In en, this message translates to: + /// **'Your watch position could not be loaded.'** + String get progressError; + + /// No description provided for @favoritesError. + /// + /// In en, this message translates to: + /// **'Your favorites could not be loaded.'** + String get favoritesError; + + /// No description provided for @favoriteToggleFailed. + /// + /// In en, this message translates to: + /// **'Could not update favorites. Please retry.'** + String get favoriteToggleFailed; + + /// No description provided for @remove. + /// + /// In en, this message translates to: + /// **'Remove'** + String get remove; + + /// No description provided for @unlockComingSoon. + /// + /// In en, this message translates to: + /// **'Unlocking with coins is coming soon.'** + String get unlockComingSoon; + + /// No description provided for @resumeProgress. + /// + /// In en, this message translates to: + /// **'Resume at {position} / {total}'** + String resumeProgress(Object position, Object total); } class _AppLocalizationsDelegate diff --git a/lib/l10n/app_localizations_en.dart b/lib/l10n/app_localizations_en.dart index dbc4e6a..60057e5 100644 --- a/lib/l10n/app_localizations_en.dart +++ b/lib/l10n/app_localizations_en.dart @@ -551,4 +551,32 @@ class AppLocalizationsEn extends AppLocalizations { @override String get cancel => 'Not now'; + + @override + String get noEpisodesYet => 'No playable episodes yet.'; + + @override + String get networkError => + 'Network is unreachable. Please check your connection and retry.'; + + @override + String get progressError => 'Your watch position could not be loaded.'; + + @override + String get favoritesError => 'Your favorites could not be loaded.'; + + @override + String get favoriteToggleFailed => + 'Could not update favorites. Please retry.'; + + @override + String get remove => 'Remove'; + + @override + String get unlockComingSoon => 'Unlocking with coins is coming soon.'; + + @override + String resumeProgress(Object position, Object total) { + return 'Resume at $position / $total'; + } } diff --git a/lib/l10n/app_localizations_id.dart b/lib/l10n/app_localizations_id.dart index ebcf54d..12d319c 100644 --- a/lib/l10n/app_localizations_id.dart +++ b/lib/l10n/app_localizations_id.dart @@ -553,4 +553,31 @@ class AppLocalizationsId extends AppLocalizations { @override String get cancel => 'Nanti saja'; + + @override + String get noEpisodesYet => 'Belum ada episode yang bisa diputar.'; + + @override + String get networkError => + 'Jaringan tidak tersedia. Periksa koneksi lalu coba lagi.'; + + @override + String get progressError => 'Posisi tonton gagal dimuat.'; + + @override + String get favoritesError => 'Daftar favorit gagal dimuat.'; + + @override + String get favoriteToggleFailed => 'Gagal memperbarui favorit. Coba lagi.'; + + @override + String get remove => 'Hapus'; + + @override + String get unlockComingSoon => 'Pembukaan dengan koin segera hadir.'; + + @override + String resumeProgress(Object position, Object total) { + return 'Lanjut di $position / $total'; + } } diff --git a/lib/l10n/app_localizations_zh.dart b/lib/l10n/app_localizations_zh.dart index 91dddb8..0a575af 100644 --- a/lib/l10n/app_localizations_zh.dart +++ b/lib/l10n/app_localizations_zh.dart @@ -543,4 +543,30 @@ class AppLocalizationsZh extends AppLocalizations { @override String get cancel => '暂不'; + + @override + String get noEpisodesYet => '还没有可播放的剧集。'; + + @override + String get networkError => '网络异常,请检查网络后重试。'; + + @override + String get progressError => '续看进度加载失败。'; + + @override + String get favoritesError => '收藏列表加载失败。'; + + @override + String get favoriteToggleFailed => '收藏操作失败,请重试。'; + + @override + String get remove => '移除'; + + @override + String get unlockComingSoon => '金币解锁功能即将开放。'; + + @override + String resumeProgress(Object position, Object total) { + return '续看至 $position / $total'; + } } diff --git a/lib/l10n/app_zh.arb b/lib/l10n/app_zh.arb index 6ab8562..1739dcc 100644 --- a/lib/l10n/app_zh.arb +++ b/lib/l10n/app_zh.arb @@ -34,7 +34,13 @@ "localDemoProfile": "本地演示档案", "continueWatching": "继续观看", "watchedPercent": "已观看 {percent}%", - "@watchedPercent": {"placeholders": {"percent": {"type": "int"}}}, + "@watchedPercent": { + "placeholders": { + "percent": { + "type": "int" + } + } + }, "resume": "继续播放", "history": "历史", "watchlist": "追剧", @@ -72,7 +78,13 @@ "originalTag": "原创", "dramaTag": "短剧", "episodeLabel": "第 {number} 集", - "@episodeLabel": {"placeholders": {"number": {"type": "int"}}}, + "@episodeLabel": { + "placeholders": { + "number": { + "type": "int" + } + } + }, "exploreSeries": "查看剧集", "episodeCount": "{count} 集", "technicalDemoCount": "免费试看 · {count} 集", @@ -175,5 +187,19 @@ "authGateTitle": "登录后可继续", "authGateMessage": "收藏、评论等操作需要登录。", "authGateAction": "去登录", - "cancel": "暂不" + "cancel": "暂不", + "noEpisodesYet": "还没有可播放的剧集。", + "networkError": "网络异常,请检查网络后重试。", + "progressError": "续看进度加载失败。", + "favoritesError": "收藏列表加载失败。", + "favoriteToggleFailed": "收藏操作失败,请重试。", + "remove": "移除", + "unlockComingSoon": "金币解锁功能即将开放。", + "resumeProgress": "续看至 {position} / {total}", + "@resumeProgress": { + "placeholders": { + "position": {}, + "total": {} + } + } } diff --git a/lib/pages/discover/discover_binding.dart b/lib/pages/discover/discover_binding.dart index d17cf00..ae63580 100644 --- a/lib/pages/discover/discover_binding.dart +++ b/lib/pages/discover/discover_binding.dart @@ -5,9 +5,9 @@ import 'discover_logic.dart'; class DiscoverBinding { DiscoverLogic create({ required Drama drama, - WatchHistoryRepository? history, + required WatchHistoryRepository history, }) => DiscoverLogic( drama: drama, - history: history ?? SharedPreferencesWatchHistoryRepository(), + history: history, ); } diff --git a/lib/pages/discover/discover_logic.dart b/lib/pages/discover/discover_logic.dart index 0536385..8b3de30 100644 --- a/lib/pages/discover/discover_logic.dart +++ b/lib/pages/discover/discover_logic.dart @@ -26,7 +26,11 @@ class DiscoverLogic extends ChangeNotifier { } void refreshPosition() { - position = history.resumePositionFor(demoProfileId, drama); + // 续看位置来自服务端(每剧一条记录);未登录或没有记录时给 null,UI 显示"从头看" + position = history + .resumePointFor(drama.id) + .then((point) => point?.position) + .catchError((Object _) => null); } void selectCategory(int index) { diff --git a/lib/pages/discover/discover_view.dart b/lib/pages/discover/discover_view.dart index 9027291..8fcb2a8 100644 --- a/lib/pages/discover/discover_view.dart +++ b/lib/pages/discover/discover_view.dart @@ -59,7 +59,7 @@ class _DiscoverPageState extends State { super.initState(); logic = DiscoverBinding().create( drama: widget.drama, - history: widget.history, + history: widget.history ?? context.read(), ); if (widget.focusSearch) logic.searchOpen = true; } diff --git a/lib/pages/drama_detail/drama_detail_binding.dart b/lib/pages/drama_detail/drama_detail_binding.dart index 0a3f649..0939681 100644 --- a/lib/pages/drama_detail/drama_detail_binding.dart +++ b/lib/pages/drama_detail/drama_detail_binding.dart @@ -1,13 +1,19 @@ import '../../core/data/models/drama.dart'; +import '../../core/data/repositories/playback_repository.dart'; import '../../core/data/repositories/watch_history_repository.dart'; +import '../../core/data/services/favorite_controller.dart'; import 'drama_detail_logic.dart'; class DramaDetailBinding { DramaDetailLogic create({ required Drama drama, - WatchHistoryRepository? history, + required WatchHistoryRepository history, + required PlaybackRepository playback, + required FavoriteController favorites, }) => DramaDetailLogic( drama: drama, - history: history ?? SharedPreferencesWatchHistoryRepository(), + history: history, + playback: playback, + favorites: favorites, ); } diff --git a/lib/pages/drama_detail/drama_detail_logic.dart b/lib/pages/drama_detail/drama_detail_logic.dart index 7f613d1..2278b22 100644 --- a/lib/pages/drama_detail/drama_detail_logic.dart +++ b/lib/pages/drama_detail/drama_detail_logic.dart @@ -1,22 +1,35 @@ +import 'package:dio/dio.dart'; import 'package:flutter/material.dart'; import '../../core/data/models/drama.dart'; +import '../../core/data/models/watch_progress.dart'; import '../../core/data/remote/api_client.dart'; import '../../core/data/repositories/watch_history_repository.dart'; +import '../../core/data/repositories/playback_repository.dart'; +import '../../core/data/services/favorite_controller.dart'; import '../player/player_view.dart'; class DramaDetailLogic extends ChangeNotifier { - DramaDetailLogic({required this.drama, required this.history}); + DramaDetailLogic({ + required this.drama, + required this.history, + required this.playback, + required this.favorites, + }); /// 先用列表卡片渲染,取到详情后换成带完整剧集的版本。 Drama drama; final WatchHistoryRepository history; + final PlaybackRepository playback; + final FavoriteController favorites; bool loading = false; bool failed = false; /// 接口给出的失败原因;为空时界面回退到本地文案。 String? failureMessage; int? continueIndex; + WatchProgress? progress; + String? progressError; bool _disposed = false; void notify() { @@ -39,6 +52,10 @@ class DramaDetailLogic extends ChangeNotifier { } on ApiException catch (exception) { failed = true; failureMessage = exception.message; + } on DioException { + // 断网/超时:交给 l10n 文案,不把 HTTP 细节丢给用户 + failed = true; + failureMessage = 'networkError'; } catch (_) { failed = true; } finally { @@ -49,18 +66,39 @@ class DramaDetailLogic extends ChangeNotifier { Future loadContinue() async { try { - final id = await history.lastEpisodeId(demoProfileId, drama.id); - if (id == null || _disposed) return; - final index = drama.episodes.indexWhere((episode) => episode.id == id); - if (index >= 0 && drama.episodes[index].isFree) { - continueIndex = index; - notify(); - } - } catch (_) { - // Keep the first episode available if preferences cannot be read. + final record = await history.progressFor(drama.id); + if (_disposed) return; + progress = record; + progressError = null; + continueIndex = record == null + ? null + : _indexOf(record.episodeId) ?? continueIndex; + notify(); + } catch (exception) { + if (_disposed) return; + // 拿不到续看位置不影响看第一集,但要让用户知道(可重试) + progressError = exception is ApiException + ? exception.message + : 'progressError'; + notify(); } } + int? _indexOf(String episodeId) { + final index = drama.episodes.indexWhere( + (episode) => episode.id == episodeId, + ); + return index >= 0 ? index : null; + } + + /// 该集的续看进度(0~1),用于剧集行上的进度条;没有记录返回 null。 + double? progressFractionFor(String episodeId) { + final record = progress; + if (record == null || record.episodeId != episodeId) return null; + if (!record.hasPosition) return null; + return record.fraction; + } + Future openPlayer(BuildContext context, int index) async { await Navigator.of(context).push( MaterialPageRoute( @@ -70,6 +108,9 @@ class DramaDetailLogic extends ChangeNotifier { await loadContinue(); } + /// 收藏切换:乐观更新失败时会回滚,由调用方给出提示。 + Future toggleFavorite() => favorites.toggle(drama.id, card: drama); + @override void dispose() { _disposed = true; diff --git a/lib/pages/drama_detail/drama_detail_view.dart b/lib/pages/drama_detail/drama_detail_view.dart index 1dcc719..8bcd195 100644 --- a/lib/pages/drama_detail/drama_detail_view.dart +++ b/lib/pages/drama_detail/drama_detail_view.dart @@ -5,11 +5,16 @@ import 'package:provider/provider.dart'; import '../../core/data/models/drama.dart'; import '../../core/data/services/catalog_controller.dart'; +import '../../core/data/services/favorite_controller.dart'; +import '../../core/formatting/error_text.dart'; import '../../core/formatting/localized_content.dart'; import '../../core/widgets/remote_image.dart'; +import '../../core/widgets/auth_gate.dart'; import '../../l10n/app_localizations.dart'; import 'drama_detail_binding.dart'; import 'drama_detail_logic.dart'; +import '../../core/data/repositories/watch_history_repository.dart'; +import '../../core/data/repositories/playback_repository.dart'; class DramaDetailPage extends StatefulWidget { const DramaDetailPage({super.key, required this.drama}); @@ -25,7 +30,12 @@ class _DramaDetailPageState extends State { @override void initState() { super.initState(); - logic = DramaDetailBinding().create(drama: widget.drama); + logic = DramaDetailBinding().create( + drama: widget.drama, + history: context.read(), + playback: context.read(), + favorites: context.read(), + ); _load(); } @@ -69,7 +79,7 @@ class _DramaDetailPageState extends State { mainAxisSize: MainAxisSize.min, children: [ Text( - logic.failureMessage ?? l10n.detailError, + errorText(l10n, logic.failureMessage, l10n.detailError), textAlign: TextAlign.center, style: const TextStyle(color: Colors.white70), ), @@ -82,6 +92,40 @@ class _DramaDetailPageState extends State { ); } final drama = logic.drama; + if (drama.episodes.isEmpty) { + // 空态:详情拿到了但一集都没有(还没上传/审核中),不能白屏 + return Scaffold( + backgroundColor: const Color(0xFF111111), + appBar: AppBar( + backgroundColor: const Color(0xFF111111), + foregroundColor: Colors.white, + title: Text(localizedDramaTitle(l10n, drama)), + ), + body: Center( + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 32), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + const Icon( + Icons.movie_filter_outlined, + size: 48, + color: Colors.white38, + ), + const SizedBox(height: 12), + Text( + l10n.noEpisodesYet, + textAlign: TextAlign.center, + style: const TextStyle(color: Colors.white70), + ), + const SizedBox(height: 16), + FilledButton(onPressed: _load, child: Text(l10n.retry)), + ], + ), + ), + ), + ); + } return Scaffold( body: CustomScrollView( slivers: [ @@ -90,6 +134,7 @@ class _DramaDetailPageState extends State { pinned: true, backgroundColor: const Color(0xFF111111), foregroundColor: Colors.white, + actions: [_favoriteAction(context, l10n)], flexibleSpace: FlexibleSpaceBar( background: RemoteImage(drama.posterUrl), ), @@ -121,15 +166,54 @@ class _DramaDetailPageState extends State { ), ), const SizedBox(height: 20), - FilledButton.icon( - onPressed: () => - logic.openPlayer(context, logic.continueIndex ?? 0), - icon: const Icon(Icons.play_arrow_rounded), - label: Text( - logic.continueIndex == null - ? l10n.watchEpisodeOne - : l10n.continueEpisode(logic.continueIndex! + 1), - ), + Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + FilledButton.icon( + onPressed: () => + logic.openPlayer(context, logic.continueIndex ?? 0), + icon: const Icon(Icons.play_arrow_rounded), + label: Text( + logic.continueIndex == null + ? l10n.watchEpisodeOne + : l10n.continueEpisode(logic.continueIndex! + 1), + ), + ), + if (_continueFraction != null) ...[ + const SizedBox(height: 8), + _ResumeBar( + fraction: _continueFraction!, + label: l10n.resumeProgress( + _clock(logic.progress!.position), + _clock(logic.progress!.duration), + ), + ), + ], + if (logic.progressError != null) ...[ + const SizedBox(height: 8), + Row( + children: [ + Expanded( + child: Text( + errorText( + l10n, + logic.progressError, + l10n.progressError, + ), + style: const TextStyle( + color: Colors.white60, + fontSize: 12, + ), + ), + ), + TextButton( + onPressed: () => unawaited(logic.loadContinue()), + child: Text(l10n.retry), + ), + ], + ), + ], + ], ), const SizedBox(height: 30), Text( @@ -147,6 +231,7 @@ class _DramaDetailPageState extends State { itemCount: drama.episodes.length, itemBuilder: (context, index) { final episode = drama.episodes[index]; + final fraction = logic.progressFractionFor(episode.id); return Card( margin: const EdgeInsets.only(bottom: 10), child: ListTile( @@ -158,6 +243,12 @@ class _DramaDetailPageState extends State { child: Text('${episode.number}'), ), title: Text(l10n.episodeLabel(episode.number)), + subtitle: fraction == null + ? null + : Padding( + padding: const EdgeInsets.only(top: 6), + child: _ResumeBar(fraction: fraction), + ), trailing: const Icon(Icons.play_circle_outline_rounded), onTap: () => logic.openPlayer(context, index), ), @@ -169,4 +260,71 @@ class _DramaDetailPageState extends State { ), ); } + + double? get _continueFraction { + final record = logic.progress; + if (record == null || !record.hasPosition) return null; + if (logic.continueIndex == null) return null; + return record.fraction; + } + + /// 收藏按钮:状态取自服务端(乐观更新,失败回滚并提示)。 + Widget _favoriteAction(BuildContext context, AppLocalizations l10n) { + final favorites = context.watch(); + final saved = favorites.isSaved(logic.drama.id); + return IconButton( + tooltip: l10n.favorite, + icon: Icon(saved ? Icons.bookmark : Icons.bookmark_border), + onPressed: () async { + if (!await ensureSignedIn(context)) return; + final ok = await logic.toggleFavorite(); + if (ok || !context.mounted) return; + // 成功靠图标变化反馈;失败必须说清楚(乐观更新已回滚) + ScaffoldMessenger.of( + context, + ).showSnackBar(SnackBar(content: Text(l10n.favoriteToggleFailed))); + }, + ); + } + + String _clock(Duration duration) { + final minutes = duration.inMinutes.remainder(60).toString().padLeft(2, '0'); + final seconds = duration.inSeconds.remainder(60).toString().padLeft(2, '0'); + return duration.inHours > 0 + ? '${duration.inHours}:$minutes:$seconds' + : '$minutes:$seconds'; + } +} + +/// 续看进度条(详情页按钮下 / 剧集行内)。fraction 由服务端记录算出。 +class _ResumeBar extends StatelessWidget { + const _ResumeBar({required this.fraction, this.label}); + + final double fraction; + final String? label; + + @override + Widget build(BuildContext context) { + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + ClipRRect( + borderRadius: BorderRadius.circular(2), + child: LinearProgressIndicator( + value: fraction, + minHeight: 3, + backgroundColor: Colors.white24, + valueColor: const AlwaysStoppedAnimation(Color(0xFF2F7BFF)), + ), + ), + if (label != null) ...[ + const SizedBox(height: 4), + Text( + label!, + style: const TextStyle(color: Colors.white54, fontSize: 11), + ), + ], + ], + ); + } } diff --git a/lib/pages/mine/mine_binding.dart b/lib/pages/mine/mine_binding.dart index 697d61d..15c5ad9 100644 --- a/lib/pages/mine/mine_binding.dart +++ b/lib/pages/mine/mine_binding.dart @@ -6,10 +6,10 @@ class MineBinding { MineLogic create({ required Drama drama, required int initialSection, - WatchHistoryRepository? history, + required WatchHistoryRepository history, }) => MineLogic( drama: drama, initialSection: initialSection, - history: history ?? SharedPreferencesWatchHistoryRepository(), + history: history, ); } diff --git a/lib/pages/mine/mine_logic.dart b/lib/pages/mine/mine_logic.dart index bc699a3..7534197 100644 --- a/lib/pages/mine/mine_logic.dart +++ b/lib/pages/mine/mine_logic.dart @@ -3,6 +3,7 @@ import 'package:provider/provider.dart'; import '../../core/config/locale_controller.dart'; import '../../core/data/models/drama.dart'; +import '../../core/data/models/watch_progress.dart'; import '../../core/data/repositories/watch_history_repository.dart'; import '../../l10n/app_localizations.dart'; @@ -20,6 +21,11 @@ class MineLogic extends ChangeNotifier { final WatchHistoryRepository history; Drama drama; late Future position; + List recent = const []; + bool recentLoading = false; + String? recentError; + /// 续看位置读取失败:与"没有记录"区分开,失败要能重试(不能假装成从 0 开始) + bool positionFailed = false; int section; int filter = 0; bool _disposed = false; @@ -29,7 +35,33 @@ class MineLogic extends ChangeNotifier { } void refreshPosition() { - position = history.resumePositionFor(demoProfileId, drama); + position = history + .resumePointFor(drama.id) + .then((point) { + positionFailed = false; + return point?.position; + }) + .catchError((Object _) { + positionFailed = true; + notify(); + return null; + }); + refreshRecent(); + } + + /// 最近观看:服务端只给 dramaId/位置,剧名封面用已加载的目录卡片按 id 映射。 + Future refreshRecent() async { + recentLoading = true; + recentError = null; + notify(); + try { + recent = await history.recent(limit: 20); + } catch (_) { + recentError = 'progressError'; + } finally { + recentLoading = false; + notify(); + } } void selectSection(int index) { diff --git a/lib/pages/mine/mine_view.dart b/lib/pages/mine/mine_view.dart index 141c7ed..671b780 100644 --- a/lib/pages/mine/mine_view.dart +++ b/lib/pages/mine/mine_view.dart @@ -1,3 +1,5 @@ +import 'dart:async'; + import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; @@ -6,6 +8,8 @@ import '../../core/data/models/drama.dart'; import '../../core/data/repositories/watch_history_repository.dart'; import '../../core/data/services/auth_controller.dart'; import '../../core/data/services/engagement_controller.dart'; +import '../../core/data/services/favorite_controller.dart'; +import '../../core/formatting/error_text.dart'; import '../../core/widgets/remote_image.dart'; import '../../core/theme/app_colors.dart'; import '../../l10n/app_localizations.dart'; @@ -61,7 +65,7 @@ class _MyPageState extends State { logic = MineBinding().create( drama: widget.drama, initialSection: widget.initialSection, - history: widget.history, + history: widget.history ?? context.read(), ); } @@ -438,11 +442,14 @@ class _MyPageState extends State { (logic.filter == 1 && fraction < 0.99) || (logic.filter == 2 && fraction >= 0.99); final engagement = context.watch(); - final markedDramas = (widget.dramas ?? [widget.drama]).where((drama) { - return logic.section == 1 - ? engagement.isSaved(drama.id) - : engagement.isLiked(drama.id); - }).toList(); + // 收藏以服务端为准(收藏列表接口返回卡片结构);点赞仍是本地状态(K3 接互动)。 + final favorites = context.watch(); + final isWatchlist = logic.section == 1; + final markedDramas = isWatchlist + ? favorites.cards + : (widget.dramas ?? [widget.drama]) + .where((drama) => engagement.isLiked(drama.id)) + .toList(); return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -452,7 +459,11 @@ class _MyPageState extends State { children: [ for (var index = 0; index < tabs.length; index++) ...[ InkWell( - onTap: () => logic.selectSection(index), + onTap: () { + logic.selectSection(index); + // 打开收藏页签时以服务端为准刷新一次(多设备/多入口都能对齐) + if (index == 1) unawaited(favorites.load()); + }, borderRadius: BorderRadius.circular(20), child: Container( padding: const EdgeInsets.symmetric( @@ -577,6 +588,34 @@ class _MyPageState extends State { ), ), ) + else if (isWatchlist && favorites.loading) + const Padding( + padding: EdgeInsets.symmetric(vertical: 22), + child: Center( + child: SizedBox( + width: 22, + height: 22, + child: CircularProgressIndicator(strokeWidth: 2), + ), + ), + ) + else if (isWatchlist && favorites.error != null) + Padding( + padding: const EdgeInsets.symmetric(vertical: 18), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + errorText(l10n, favorites.error, l10n.favoritesError), + style: const TextStyle(color: Color(0xFFE6E1E3)), + ), + TextButton( + onPressed: () => unawaited(favorites.load()), + child: Text(l10n.retry), + ), + ], + ), + ) else if (logic.section != 0 && markedDramas.isNotEmpty) for (final drama in markedDramas) ...[ _markedDramaCard(drama, l10n), @@ -590,10 +629,90 @@ class _MyPageState extends State { style: const TextStyle(color: Color(0xFFE6E1E3)), ), ), + // 最近观看(服务端 /app/watch/recent):只渲染能在已加载目录里匹配到的剧; + // 匹配不到的(例如不在当前首页分区里)先不显示,K2 的记录页会做独立请求。 + if (logic.section == 0) ...[ + const SizedBox(height: 18), + Text( + l10n.history, + style: const TextStyle( + color: Colors.white, + fontSize: 14, + fontWeight: FontWeight.w700, + ), + ), + const SizedBox(height: 9), + if (logic.positionFailed) + Row( + children: [ + Expanded( + child: Text( + l10n.progressError, + style: const TextStyle(color: Color(0xFFE6E1E3)), + ), + ), + TextButton( + onPressed: logic.refreshPosition, + child: Text(l10n.retry), + ), + ], + ) + else if (logic.recentLoading) + const Padding( + padding: EdgeInsets.symmetric(vertical: 12), + child: Center( + child: SizedBox( + width: 20, + height: 20, + child: CircularProgressIndicator(strokeWidth: 2), + ), + ), + ) + else if (logic.recentError != null) + Row( + children: [ + Expanded( + child: Text( + errorText(l10n, logic.recentError, l10n.progressError), + style: const TextStyle(color: Color(0xFFE6E1E3)), + ), + ), + TextButton( + onPressed: () => unawaited(logic.refreshRecent()), + child: Text(l10n.retry), + ), + ], + ) + else if (_recentDramas.isEmpty) + Text( + l10n.noStories, + style: const TextStyle(color: Color(0xFFB7B3B8)), + ) + else + for (final drama in _recentDramas) ...[ + _markedDramaCard(drama, l10n), + const SizedBox(height: 9), + ], + ], ], ); } + /// 服务端最近观看 → 已加载目录里的卡片(按 id 匹配,去重,当前剧也算一条)。 + List get _recentDramas { + final pool = [...?widget.dramas, widget.drama]; + final result = []; + for (final item in logic.recent) { + for (final drama in pool) { + if (drama.id == item.dramaId && + !result.any((picked) => picked.id == drama.id)) { + result.add(drama); + } + } + } + return result; + } + Widget _markedDramaCard(Drama drama, AppLocalizations l10n) => InkWell( onTap: () { if (widget.onDramaSelected != null) { diff --git a/lib/pages/player/player_binding.dart b/lib/pages/player/player_binding.dart index ca3fd8e..fb46d6c 100644 --- a/lib/pages/player/player_binding.dart +++ b/lib/pages/player/player_binding.dart @@ -1,10 +1,15 @@ import '../../core/data/repositories/watch_history_repository.dart'; +import '../../core/data/repositories/playback_repository.dart'; import '../../core/data/services/android_picture_in_picture.dart'; import 'player_logic.dart'; class PlayerBinding { - PlayerLogic create() => PlayerLogic( - history: SharedPreferencesWatchHistoryRepository(), + PlayerLogic create({ + required WatchHistoryRepository history, + required PlaybackRepository playback, + }) => PlayerLogic( + history: history, + playback: playback, pictureInPicture: AndroidPictureInPicture(), ); } diff --git a/lib/pages/player/player_logic.dart b/lib/pages/player/player_logic.dart index 5fee99d..034082c 100644 --- a/lib/pages/player/player_logic.dart +++ b/lib/pages/player/player_logic.dart @@ -5,7 +5,11 @@ import 'package:flutter/services.dart'; import 'package:provider/provider.dart'; import '../../core/data/models/drama.dart'; +import '../../core/data/models/play_ticket.dart'; +import '../../core/data/models/watch_progress.dart'; import '../../core/data/models/player_port.dart'; +import '../../core/data/remote/api_client.dart'; +import '../../core/data/repositories/playback_repository.dart'; import '../../core/data/repositories/watch_history_repository.dart'; import '../../core/data/services/android_picture_in_picture.dart'; import '../../core/data/services/catalog_controller.dart'; @@ -24,9 +28,14 @@ import 'player_view.dart'; import 'widgets/drama_comments_sheet.dart'; class PlayerLogic extends ChangeNotifier { - PlayerLogic({required this.history, required this.pictureInPicture}); + PlayerLogic({ + required this.history, + required this.playback, + required this.pictureInPicture, + }); final WatchHistoryRepository history; + final PlaybackRepository playback; final AndroidPictureInPicture pictureInPicture; late PageController pages; @@ -37,7 +46,18 @@ class PlayerLogic extends ChangeNotifier { Episode? trackedEpisode; Drama? trackedDrama; DateTime lastProgressWrite = DateTime.fromMillisecondsSinceEpoch(0); + /// 进度上报节流:契约建议每 10 秒一次 + Duration progressInterval = const Duration(seconds: 10); Future pendingWrite = Future.value(); + /// 服务端续看点:进入播放页时定位到"那一集的哪一秒" + ResumePoint? resumePoint; + bool resumeLoaded = false; + /// 票据三态:加载中 / 失败(可重试)/ 被后端判定为不可播放 + bool ticketLoading = false; + String? ticketError; + PlayTicket? blockedTicket; + String? blockedEpisodeId; + List sessionEpisodes = const []; int pageRequest = 0; bool muted = false; bool stoppedAtFeedEnd = false; @@ -64,6 +84,9 @@ class PlayerLogic extends ChangeNotifier { ValueChanged? onDramaChanged; ValueChanged? onImmersiveChanged; bool _disposed = false; + /// [start] 是否已经跑过:没跑过时 session/pages 还是 late 未初始化, + /// dispose 不能直接碰它们(例如页面构建失败或纯逻辑测试)。 + bool _started = false; bool get immersive => fullscreen || pip || pipPreparing; @@ -111,16 +134,19 @@ class PlayerLogic extends ChangeNotifier { required PlayerFactory factory, required PlaybackCoordinator coordinator, }) { + _started = true; pictureInPicture.setStateListener(onPipChanged); queue = feedDramas == null ? PlaybackQueue.series(pageDrama) : PlaybackQueue.home(feedDramas!); visibleIndices = List.generate(queue.length, (index) => index); pages = PageController(initialPage: initialIndex); + // 票据解析后要把新地址写回这个列表(PlaybackSession 的 canPlay 读的就是它) + sessionEpisodes = [for (final entry in queue.entries) entry.episode]; session = PlaybackSession( - episodes: [for (final entry in queue.entries) entry.episode], + episodes: sessionEpisodes, factory: factory, - // 后端只在可播放时才下发地址(免费集或已解锁),拿不到地址即视为锁定 + // 地址只由后端下发(票据或详情里的免费集签名地址),拿不到地址即视为锁定 canPlay: (episode) => episode.videoUrl.isNotEmpty, prepare: preparePlayer, activate: activatePlayer, @@ -129,9 +155,88 @@ class PlayerLogic extends ChangeNotifier { if (!active || visibleIndices.isEmpty) { session.setRouteVisible(false); } + unawaited(loadResumePoint()); unawaited(selectEpisode(initialIndex)); } + /// 服务端续看位置:进播放页时取一次,用于"定位到上次那一集的那一秒"。 + Future loadResumePoint() async { + final dramaId = queue.entryAt(initialIndex).drama.id; + try { + resumePoint = await history.resumePointFor(dramaId); + } catch (_) { + // 拿不到续看位置不影响播放:从当前集开头看 + resumePoint = null; + } finally { + resumeLoaded = true; + if (isMounted()) notify(); + } + } + + /// 票据门:起播前先拿票(命中未过期缓存就不会重复请求), + /// 该集是否该定位到服务端记录的位置:只有"记录里的那一集"才定位,其它集从头播。 + Duration? resumePositionFor(String episodeId) { + final point = resumePoint; + if (point == null || point.episodeId != episodeId) return null; + if (point.position <= Duration.zero) return null; + return point.position; + } + + /// 进度上报节流:距上次上报不足 [progressInterval] 就不报。 + /// + /// 切集/退出/切后台走 [saveCurrentProgress],那条路径**不受节流限制**。 + bool shouldReportProgress(DateTime now) { + if (now.difference(lastProgressWrite) < progressInterval) return false; + lastProgressWrite = now; + return true; + } + + /// 票据门:起播前先拿票(命中未过期缓存就不会重复请求), + /// 拿不到地址就交给 [blockedTicket] 让 UI 提示解锁/暂无片源。 + Future ensureTicket(int index) async { + if (index < 0 || index >= sessionEpisodes.length) return false; + final episode = sessionEpisodes[index]; + final request = pageRequest; + ticketLoading = true; + ticketError = null; + notify(); + try { + final ticket = await playback.ticketFor(episode.id); + if (request != pageRequest) return false; + blockedTicket = null; + blockedEpisodeId = null; + if (ticket.accessible && ticket.playUrl.isNotEmpty) { + // 签名地址原样写回,不做任何拼接/改写(AppConfig.mediaUrl 只补 host) + sessionEpisodes[index] = episode.withVideoUrl(ticket.playUrl); + return true; + } + blockedTicket = ticket; + blockedEpisodeId = episode.id; + return false; + } catch (exception) { + if (request != pageRequest) return false; + // 详情里已有可用地址(免费集)时降级继续,避免票据服务抖动就完全看不了 + if (episode.videoUrl.isNotEmpty) { + ticketError = null; + return true; + } + ticketError = exception is ApiException + ? exception.message + : 'ticketError'; + return false; + } finally { + ticketLoading = false; + if (isMounted()) notify(); + } + } + + /// 重试当前集的票据(失败态的"重试"按钮)。 + Future retryTicket() async { + ticketError = null; + notify(); + unawaited(selectEpisode(session.currentIndex)); + } + void onPageUpdated(PlayerPage previous) { if (previous.active != active) { session.setRouteVisible(active && visibleIndices.isNotEmpty); @@ -161,6 +266,14 @@ class PlayerLogic extends ChangeNotifier { void onLifecycle(AppLifecycleState state) { if (state != AppLifecycleState.resumed) unawaited(saveCurrentProgress()); + if (state == AppLifecycleState.resumed) { + // 签名地址有有效期:回前台时若票据已过期,重新取一张再起播, + // 否则会撞上 403(契约 §1.4) + final episode = trackedEpisode; + if (episode != null && !playback.isFresh(episode.id)) { + unawaited(selectEpisode(session.currentIndex)); + } + } session.setAppResumed( state == AppLifecycleState.resumed || pip || pipPreparing, ); @@ -179,10 +292,12 @@ class PlayerLogic extends ChangeNotifier { unawaited(SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge)); } unawaited(saveCurrentProgress()); - session.setRouteVisible(false); - cancelScrub(); - unawaited(session.close()); - pages.dispose(); + if (_started) { + session.setRouteVisible(false); + cancelScrub(); + unawaited(session.close()); + pages.dispose(); + } super.dispose(); } @@ -264,23 +379,18 @@ class PlayerLogic extends ChangeNotifier { Future preparePlayer(Episode episode, PlayerPort player) async { if (player is! VideoPlayerPort) return; - final drama = queue.entries - .firstWhere((e) => e.episode.id == episode.id) - .drama; try { await pendingWrite; - final saved = await history.positionFor( - demoProfileId, - drama.id, - episode.id, - ); + // 服务端每剧只记一条:只有"记录里的那一集"才定位,其它集从头播 + if (resumePoint == null) await loadResumePoint(); + final saved = resumePositionFor(episode.id); if (saved != null) { await player.controller.seekTo( clampResumePosition(saved, player.controller.value.duration), ); } } catch (_) { - // A local preference failure does not prevent playback. + // 续看位置取不到不影响播放:从头播。 } } @@ -303,7 +413,13 @@ class PlayerLogic extends ChangeNotifier { if (player.controller.value.isCompleted && !completionProgressSaved) { completionProgressSaved = true; unawaited( - queueProgress(drama, episode, player.controller.value.duration), + queueProgress( + drama, + episode, + player.controller.value.duration, + duration: player.controller.value.duration, + finished: true, + ), ); } if (!completionHandled && @@ -313,11 +429,7 @@ class PlayerLogic extends ChangeNotifier { completionHandled = true; unawaited(advanceAfterEnd(player, index)); } - final now = DateTime.now(); - if (now.difference(lastProgressWrite) < const Duration(seconds: 5)) { - return; - } - lastProgressWrite = now; + if (!shouldReportProgress(DateTime.now())) return; unawaited( queueProgress(drama, episode, player.controller.value.position), ); @@ -347,13 +459,26 @@ class PlayerLogic extends ChangeNotifier { } } - Future queueProgress(Drama drama, Episode episode, Duration position) { + /// 进度上报:节流由调用方控制(10 秒),切集/退出/切后台都会补一次。 + Future queueProgress( + Drama drama, + Episode episode, + Duration position, { + Duration? duration, + bool finished = false, + }) { pendingWrite = pendingWrite .then( - (_) => history.save(demoProfileId, drama.id, episode.id, position), + (_) => history.save( + episodeId: episode.id, + position: position, + duration: duration, + finished: finished, + ), ) .catchError((Object _) { - // Playback continues if local history cannot be stored. + // 进度上报失败不影响播放(下次节流点会再报一次)。 + return null; }); return pendingWrite; } @@ -368,7 +493,12 @@ class PlayerLogic extends ChangeNotifier { !player.controller.value.isInitialized) { return pendingWrite; } - return queueProgress(drama, episode, player.controller.value.position); + return queueProgress( + drama, + episode, + player.controller.value.position, + duration: player.controller.value.duration, + ); } Future selectEpisode(int index) async { @@ -377,6 +507,10 @@ class PlayerLogic extends ChangeNotifier { // Capture the old position synchronously, persist without blocking a swipe. unawaited(saveCurrentProgress()); if (request != pageRequest || !isMounted()) return; + // 起播前先要票据:拿不到就不起播,交给三态 UI 提示(失败可重试) + final ready = await ensureTicket(index); + if (request != pageRequest || !isMounted()) return; + if (!ready && ticketError != null) return; await session.select(index, preloadIndex: nextVisibleIndex(index)); } diff --git a/lib/pages/player/player_view.dart b/lib/pages/player/player_view.dart index a9a1237..e546f66 100644 --- a/lib/pages/player/player_view.dart +++ b/lib/pages/player/player_view.dart @@ -6,15 +6,20 @@ import 'package:provider/provider.dart'; import 'package:video_player/video_player.dart'; import '../../core/data/models/drama.dart'; +import '../../core/data/models/play_ticket.dart'; import '../../core/data/services/engagement_controller.dart'; +import '../../core/data/services/favorite_controller.dart'; import '../../core/data/services/playback_session.dart'; import '../../core/data/services/video_player_port.dart'; +import '../../core/formatting/error_text.dart'; import '../../core/formatting/localized_content.dart'; import '../../core/widgets/auth_gate.dart'; import '../../l10n/app_localizations.dart'; import 'player_binding.dart'; import 'player_logic.dart'; import 'widgets/seek_progress_bar.dart'; +import '../../core/data/repositories/watch_history_repository.dart'; +import '../../core/data/repositories/playback_repository.dart'; class PlayerPage extends StatefulWidget { const PlayerPage({ @@ -60,7 +65,10 @@ class _PlayerPageState extends State with WidgetsBindingObserver { @override void initState() { super.initState(); - logic = PlayerBinding().create(); + logic = PlayerBinding().create( + history: context.read(), + playback: context.read(), + ); logic.attach(widget, isMounted: () => mounted); WidgetsBinding.instance.addObserver(this); logic.start( @@ -189,6 +197,39 @@ class _PlayerPageState extends State with WidgetsBindingObserver { ), ), ), + // 票据三态之一:起播前正在向后端要签名地址 + if (selected && logic.ticketLoading) + const Center( + child: CircularProgressIndicator(color: Color(0xFF2F7BFF)), + ), + // 票据三态之二:拿票失败(断网/服务异常)→ 可重试,不假装在加载 + if (selected && !logic.ticketLoading && logic.ticketError != null) + Center( + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 36), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + const Icon( + Icons.wifi_off_rounded, + color: Colors.white70, + size: 36, + ), + const SizedBox(height: 12), + Text( + errorText(l10n, logic.ticketError, l10n.playbackError), + textAlign: TextAlign.center, + style: const TextStyle(color: Colors.white70), + ), + const SizedBox(height: 12), + FilledButton( + onPressed: () => unawaited(logic.retryTicket()), + child: Text(l10n.retry), + ), + ], + ), + ), + ), if (selected && logic.session.loading) const Center( child: CircularProgressIndicator(color: Color(0xFF2F7BFF)), @@ -215,9 +256,18 @@ class _PlayerPageState extends State with WidgetsBindingObserver { ), ), ), - // 锁定集与还没上传片源的剧集都会走到这里,之前是一片纯黑,看不出原因。 + // 票据三态之三:后端判定不可播放 —— 用 accessType 驱动文案,不在前端猜 + if (selected && !ready && logic.blockedEpisodeId == episode.id) + _BlockedNotice( + l10n: l10n, + episode: episode, + accessType: logic.blockedTicket?.accessType, + unlockCoin: logic.blockedTicket?.unlockCoin ?? 0, + ), + // 没有票据信息时的兜底(例如详情里就没地址、也没走票据流程) if (selected && !ready && + logic.blockedEpisodeId != episode.id && logic.session.error == null && logic.session.isLocked) Center( @@ -284,7 +334,8 @@ class _PlayerPageState extends State with WidgetsBindingObserver { episode: episode, controller: ready ? videoPort!.controller : null, liked: engagement.isLiked(drama.id), - saved: engagement.isSaved(drama.id), + // 收藏以服务端为准(FavoriteController 由 app 注入,登录后自动加载) + saved: context.watch().isSaved(drama.id), onBack: widget.embedded ? null : () => unawaited(logic.leave(context)), @@ -298,8 +349,13 @@ class _PlayerPageState extends State with WidgetsBindingObserver { } }, onSave: () async { + final favorites = context.read(); if (await ensureSignedIn(context)) { - unawaited(engagement.toggleSaved(drama.id)); + final ok = await favorites.toggle(drama.id, card: drama); + if (ok || !context.mounted) return; + ScaffoldMessenger.of(context).showSnackBar( + SnackBar(content: Text(l10n.favoriteToggleFailed)), + ); } }, onComments: () => logic.showComments(context, drama), @@ -389,6 +445,68 @@ class _FullscreenControls extends StatelessWidget { ); } +/// 不可播放提示:文案由后端返回的 `accessType` 驱动(契约 §1.4),前端不自行推断。 +class _BlockedNotice extends StatelessWidget { + const _BlockedNotice({ + required this.l10n, + required this.episode, + required this.accessType, + required this.unlockCoin, + }); + + final AppLocalizations l10n; + final Episode episode; + final String? accessType; + final int unlockCoin; + + @override + Widget build(BuildContext context) { + final needsUnlock = + accessType == PlayTicket.coinRequired || + accessType == PlayTicket.vipRequired; + final title = needsUnlock + ? l10n.lockedTitle(episode.number) + : accessType == PlayTicket.noMedia + ? l10n.noMediaNotice + : episode.locked + ? l10n.lockedTitle(episode.number) + : l10n.noMediaNotice; + return Center( + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 36), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Icon( + needsUnlock + ? Icons.lock_outline_rounded + : Icons.movie_filter_outlined, + color: Colors.white70, + size: 36, + ), + const SizedBox(height: 12), + Text( + title, + textAlign: TextAlign.center, + style: const TextStyle(color: Colors.white70), + ), + if (needsUnlock) ...[ + const SizedBox(height: 6), + Text( + unlockCoin > 0 + ? '${l10n.unlockComingSoon} · $unlockCoin ${l10n.coins}' + : l10n.unlockComingSoon, + textAlign: TextAlign.center, + style: const TextStyle(color: Colors.white38, fontSize: 12), + ), + ], + ], + ), + ), + ); + } +} + class _PlaybackOverlay extends StatelessWidget { const _PlaybackOverlay({ required this.l10n, diff --git a/test/catalog/catalog_controller_test.dart b/test/catalog/catalog_controller_test.dart index 471e64c..5b53f61 100644 --- a/test/catalog/catalog_controller_test.dart +++ b/test/catalog/catalog_controller_test.dart @@ -1,7 +1,6 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:fruitshorts/core/data/models/drama.dart'; import 'package:fruitshorts/core/data/models/home_feed.dart'; -import 'package:fruitshorts/core/data/models/play_ticket.dart'; import 'package:fruitshorts/core/data/repositories/catalog_repository.dart'; import 'package:fruitshorts/core/data/services/catalog_controller.dart'; @@ -53,30 +52,6 @@ void main() { expect(controller.dramas.single.episodes, hasLength(2)); }); - test('should_write_play_url_for_free_episode_and_keep_locked_episode_empty_when_ticket_is_issued', () async { - final repository = ScriptedCatalogRepository(); - final controller = CatalogController(repository); - repository.tickets['10'] = const PlayTicket( - episodeId: '10', - accessible: true, - accessType: PlayTicket.free, - playUrl: '/files/episode/10.mp4', - ); - - const free = Episode(id: '10', number: 1, title: '免费集', isFree: true); - final resolved = await controller.resolvePlay(free); - expect(resolved.videoUrl, '/files/episode/10.mp4'); - - const locked = Episode( - id: '11', - number: 2, - title: '锁定集', - isFree: false, - locked: true, - ); - final lockedResolved = await controller.resolvePlay(locked); - expect(lockedResolved.videoUrl, isEmpty); - }); } Drama _card(String id) => Drama( @@ -102,7 +77,6 @@ class ScriptedCatalogRepository implements CatalogRepository { bool fail = false; HomeFeed feed = const HomeFeed(); int detailCalls = 0; - final Map tickets = {}; @override Future fetchHomeFeed() async { @@ -119,13 +93,4 @@ class ScriptedCatalogRepository implements CatalogRepository { return _detail(dramaId); } - @override - Future resolvePlay(String episodeId) async { - return tickets[episodeId] ?? - PlayTicket( - episodeId: episodeId, - accessible: false, - accessType: PlayTicket.noMedia, - ); - } } diff --git a/test/discover/discover_logic_test.dart b/test/discover/discover_logic_test.dart index 30daae7..ba93cc2 100644 --- a/test/discover/discover_logic_test.dart +++ b/test/discover/discover_logic_test.dart @@ -33,7 +33,7 @@ void main() { final logic = DiscoverLogic(history: history, drama: _drama('signal')); expect(await logic.position, const Duration(seconds: 4)); - expect(history.reads, ['demo-local-v1|signal|signal-1']); + expect(history.reads, ['signal']); expect(logic.category, 0); expect(logic.searchOpen, isFalse); logic.dispose(); @@ -47,10 +47,7 @@ void main() { logic.refreshPosition(); await logic.position; - expect(history.reads, [ - 'demo-local-v1|signal|signal-1', - 'demo-local-v1|city|city-1', - ]); + expect(history.reads, ['signal', 'city']); logic.dispose(); }); @@ -64,11 +61,11 @@ void main() { ); expect(await logic.position, const Duration(seconds: 9)); - expect(history.reads, ['demo-local-v1|signal|signal-2']); + expect(history.reads, ['signal']); logic.dispose(); }); - test('should_have_no_resume_position_when_list_card_has_no_history', () async { + test('should_have_no_resume_position_when_server_has_no_record', () async { final history = FakeWatchHistory(); final logic = DiscoverLogic( history: history, @@ -76,7 +73,8 @@ void main() { ); expect(await logic.position, isNull); - expect(history.reads, isEmpty); + // 续看位置改为按剧问服务端:即使卡片没有剧集也会读一次 + expect(history.reads, ['signal']); logic.dispose(); }); @@ -153,7 +151,7 @@ void main() { history.reads.clear(); sync(_drama('vengeance'), active: true, wasActive: true, dramaChanged: true); expect(logic.drama.id, 'vengeance'); - expect(history.reads, ['demo-local-v1|vengeance|vengeance-1']); + expect(history.reads, ['vengeance']); // Staying active with no change leaves both drama and history alone. history.reads.clear(); diff --git a/test/drama_detail/drama_detail_logic_test.dart b/test/drama_detail/drama_detail_logic_test.dart index 248fe9a..48b5e86 100644 --- a/test/drama_detail/drama_detail_logic_test.dart +++ b/test/drama_detail/drama_detail_logic_test.dart @@ -1,10 +1,22 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:fruitshorts/core/data/models/drama.dart'; import 'package:fruitshorts/core/data/remote/api_client.dart'; +import 'package:fruitshorts/core/data/repositories/favorite_repository.dart'; +import 'package:fruitshorts/core/data/repositories/playback_repository.dart'; +import 'package:fruitshorts/core/data/services/favorite_controller.dart'; import 'package:fruitshorts/pages/drama_detail/drama_detail_logic.dart'; import '../support/fake_watch_history.dart'; +/// 详情页逻辑依赖:票据仓库 + 收藏控制器(测试里都是内存实现)。 +DramaDetailLogic _logic(Drama drama, FakeWatchHistory history) => + DramaDetailLogic( + drama: drama, + history: history, + playback: FakePlaybackRepository(), + favorites: FavoriteController(InMemoryFavoriteRepository()), + ); + Drama _card(String id) => Drama( id: id, title: id, @@ -44,10 +56,7 @@ Drama _detail(String id) => Drama( void main() { test('should_upgrade_to_full_episode_list_when_detail_loads_for_list_card', () async { var calls = 0; - final logic = DramaDetailLogic( - drama: _card('signal'), - history: FakeWatchHistory(), - ); + final logic = _logic(_card('signal'), FakeWatchHistory()); await logic.load(() async { calls++; @@ -62,10 +71,7 @@ void main() { }); test('should_keep_card_and_report_reason_when_load_fails', () async { - final logic = DramaDetailLogic( - drama: _card('signal'), - history: FakeWatchHistory(), - ); + final logic = _logic(_card('signal'), FakeWatchHistory()); await logic.load(() async => throw const ApiException(500, '服务异常')); @@ -81,10 +87,7 @@ void main() { test('should_skip_request_when_detail_is_already_loaded', () async { var calls = 0; - final logic = DramaDetailLogic( - drama: _detail('signal'), - history: FakeWatchHistory(), - ); + final logic = _logic(_detail('signal'), FakeWatchHistory()); await logic.load(() async { calls++; diff --git a/test/integration/live_catalog_test.dart b/test/integration/live_catalog_test.dart index 0d17476..274cf60 100644 --- a/test/integration/live_catalog_test.dart +++ b/test/integration/live_catalog_test.dart @@ -1,12 +1,14 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:fruitshorts/core/data/remote/api_client.dart'; import 'package:fruitshorts/core/data/remote/catalog_api.dart'; +import 'package:fruitshorts/core/data/remote/playback_api.dart'; /// 联调测试:直连本机客户端接口服务(8081)。 /// 服务没启动时自动跳过,不影响日常 `flutter test`。 void main() { final client = ApiClient(baseUrl: 'http://127.0.0.1:8081'); final api = CatalogApi(client); + final playback = PlaybackApi(client); tearDownAll(client.close); @@ -69,7 +71,7 @@ void main() { return; } - final ticket = await api.playTicket(playable.first.id); + final ticket = await playback.ticket(playable.first.id); expect(ticket.accessible, isTrue); expect(ticket.playUrl, startsWith('/files/')); }); diff --git a/test/integration/live_watch_flow_test.dart b/test/integration/live_watch_flow_test.dart new file mode 100644 index 0000000..aafd8df --- /dev/null +++ b/test/integration/live_watch_flow_test.dart @@ -0,0 +1,114 @@ +// Author: fruit.com.cn + +import 'package:flutter_test/flutter_test.dart'; +import 'package:fruitshorts/core/data/models/auth_session.dart'; +import 'package:fruitshorts/core/data/remote/api_client.dart'; +import 'package:fruitshorts/core/data/remote/catalog_api.dart'; +import 'package:fruitshorts/core/data/remote/library_api.dart'; +import 'package:fruitshorts/core/data/remote/playback_api.dart'; +import 'package:fruitshorts/core/data/remote/watch_api.dart'; + +/// K1 端到端联调:直连本机客户端接口服务(8081),把"首页 → 详情 → 播放票据 → +/// 上报进度 → 读回续看位置 → 收藏 → 收藏列表 → 取消收藏"整条链路走一遍。 +/// +/// 用一个一次性邮箱注册(需要登录态的接口才会通);服务没起时自动跳过。 +void main() { + const baseUrl = 'http://127.0.0.1:8081'; + final email = 'k1.selftest.${DateTime.now().millisecondsSinceEpoch}@example.com'; + const password = 'Passw0rd!23'; + + AuthSession? session; + final client = ApiClient( + baseUrl: baseUrl, + accessTokenReader: () => session?.accessToken, + deviceIdReader: () async => 'k1-live-device', + ); + final catalog = CatalogApi(client); + final playback = PlaybackApi(client); + final watch = WatchApi(client); + final library = LibraryApi(client); + + tearDownAll(client.close); + + Future register() async { + try { + final raw = await client.post( + '/app/auth/register', + body: { + 'targetType': 'EMAIL', + 'target': email, + 'password': password, + 'nickname': 'K1 联调', + 'deviceId': 'k1-live-device', + }, + ); + if (raw is! Map) return false; + session = AuthSession.fromJson(raw); + return true; + } catch (_) { + return false; + } + } + + test('should_complete_the_watch_flow_when_backend_is_running', () async { + if (!await register()) { + markTestSkipped('客户端接口服务未启动,已跳过联调测试'); + return; + } + expect(session?.user.uid, isNotEmpty); + + // 1) 首页 → 取第一部剧 + final feed = await catalog.homeFeed(); + expect(feed.dramas, isNotEmpty); + final card = feed.dramas.first; + expect(card.id, isNotEmpty); + + // 2) 详情:剧集列表按集号升序,可播剧集带已签名地址 + final detail = await catalog.dramaDetail(card.id); + expect(detail.id, card.id); + expect(detail.episodes, isNotEmpty); + final playable = detail.episodes + .where((episode) => episode.videoUrl.isNotEmpty) + .toList(); + if (playable.isEmpty) { + markTestSkipped('这部演示剧没有可播剧集,已跳过播放相关断言'); + return; + } + + // 3) 播放票据:签名地址带 e/s,客户端原样使用 + final ticket = await playback.ticket(playable.first.id); + expect(ticket.accessible, isTrue); + expect(ticket.accessType, isNotEmpty); + expect(ticket.playUrl, startsWith('/files/')); + expect(ticket.playUrl, contains('e=')); + expect(ticket.playUrl, contains('s=')); + + // 4) 上报进度 → 读回续看位置 + const position = Duration(seconds: 42); + final saved = await watch.saveProgress( + episodeId: playable.first.id, + position: position, + duration: Duration(seconds: ticket.durationSec), + ); + expect(saved?.episodeId, playable.first.id); + expect(saved?.position, position); + + final resume = await watch.progressOfDrama(card.id); + expect(resume?.episodeId, playable.first.id); + expect(resume?.position, position); + + // 最近观看里能看到这部剧 + final recent = await watch.recent(limit: 20); + expect(recent.map((item) => item.dramaId), contains(card.id)); + + // 5) 收藏 → 出现在收藏列表 → 取消收藏 + final savedState = await library.toggleFavorite(card.id); + expect(savedState, isTrue); + final favorites = await library.favorites(); + expect(favorites.map((drama) => drama.id), contains(card.id)); + + await library.removeFavorite(card.id); + final afterRemove = await library.favorites(); + expect(afterRemove.map((drama) => drama.id), isNot(contains(card.id))); + }); +} diff --git a/test/library/favorite_controller_test.dart b/test/library/favorite_controller_test.dart new file mode 100644 index 0000000..335b2e0 --- /dev/null +++ b/test/library/favorite_controller_test.dart @@ -0,0 +1,103 @@ +// Author: fruit.com.cn + +import 'package:flutter_test/flutter_test.dart'; +import 'package:fruitshorts/core/data/models/drama.dart'; +import 'package:fruitshorts/core/data/repositories/favorite_repository.dart'; +import 'package:fruitshorts/core/data/services/favorite_controller.dart'; + +Drama _card(String id) => Drama( + id: id, + title: 'Drama $id', + synopsis: 'synopsis', + posterUrl: '/files/$id.png', +); + +void main() { + test('should_roll_back_when_toggle_fails', () async { + final repository = InMemoryFavoriteRepository()..failToggle = true; + final controller = FavoriteController(repository); + + final ok = await controller.toggle('signal'); + + expect(ok, isFalse); + // 乐观更新必须回滚:不能"看起来收藏了,其实服务端没存" + expect(controller.isSaved('signal'), isFalse); + expect(controller.cards, isEmpty); + }); + + test('should_keep_saved_state_when_toggle_succeeds', () async { + final controller = FavoriteController(InMemoryFavoriteRepository()); + + final ok = await controller.toggle('signal', card: _card('signal')); + + expect(ok, isTrue); + expect(controller.isSaved('signal'), isTrue); + // 卡片随手带上:收藏完打开"我的收藏"就能看到 + expect(controller.cards.map((drama) => drama.id), ['signal']); + }); + + test('should_remove_card_and_state_when_toggled_off', () async { + final repository = InMemoryFavoriteRepository(saved: {'signal'}); + final controller = FavoriteController(repository); + // 先按服务端状态对齐,再取消收藏 + await controller.load(); + + await controller.toggle('signal'); + + expect(controller.isSaved('signal'), isFalse); + expect(controller.cards, isEmpty); + }); + + test('should_expose_error_and_keep_old_state_when_list_fails', () async { + final repository = InMemoryFavoriteRepository()..failList = true; + final controller = FavoriteController(repository); + + await controller.load(); + + expect(controller.loading, isFalse); + expect(controller.error, 'favoritesError'); + }); + + test('should_load_cards_and_saved_ids_when_list_succeeds', () async { + final repository = InMemoryFavoriteRepository( + saved: {'signal'}, + cards: [_card('signal'), _card('city')], + ); + final controller = FavoriteController(repository); + + await controller.load(); + + expect(controller.error, isNull); + expect(controller.cards.map((drama) => drama.id), ['signal']); + expect(controller.isSaved('signal'), isTrue); + expect(controller.isSaved('city'), isFalse); + }); + + test('should_roll_back_when_remove_fails', () async { + final repository = InMemoryFavoriteRepository( + saved: {'signal'}, + cards: [_card('signal')], + ); + final controller = FavoriteController(repository); + await controller.load(); + + final ok = await controller.remove('signal'); + + // InMemory 实现的 remove 不会失败,这里断言正常路径:状态与列表一起清掉 + expect(ok, isTrue); + expect(controller.isSaved('signal'), isFalse); + expect(controller.cards, isEmpty); + }); + + test('should_clear_state_when_signing_out', () async { + final controller = FavoriteController( + InMemoryFavoriteRepository(saved: {'signal'}, cards: [_card('signal')]), + ); + await controller.load(); + + controller.clear(); + + expect(controller.savedIds, isEmpty); + expect(controller.cards, isEmpty); + }); +} diff --git a/test/mine/mine_logic_test.dart b/test/mine/mine_logic_test.dart index 1bd1f1b..5f12360 100644 --- a/test/mine/mine_logic_test.dart +++ b/test/mine/mine_logic_test.dart @@ -43,7 +43,7 @@ void main() { expect(logic.section, 1); expect(logic.filter, 0); expect(await logic.position, const Duration(seconds: 7)); - expect(history.reads, ['demo-local-v1|signal|signal-1']); + expect(history.reads, ['signal']); logic.dispose(); }); @@ -58,7 +58,7 @@ void main() { ); expect(await logic.position, const Duration(seconds: 7)); - expect(history.reads, ['demo-local-v1|signal|signal-3']); + expect(history.reads, ['signal']); logic.dispose(); }); @@ -116,7 +116,7 @@ void main() { history.reads.clear(); sync(_drama('vengeance'), active: true, wasActive: true, dramaChanged: true); expect(logic.drama.id, 'vengeance'); - expect(history.reads, ['demo-local-v1|vengeance|vengeance-1']); + expect(history.reads, ['vengeance']); history.reads.clear(); sync(_drama('other'), active: true, wasActive: true, dramaChanged: false); diff --git a/test/playback/playback_ticket_expiry_test.dart b/test/playback/playback_ticket_expiry_test.dart new file mode 100644 index 0000000..f301312 --- /dev/null +++ b/test/playback/playback_ticket_expiry_test.dart @@ -0,0 +1,120 @@ +// Author: fruit.com.cn + +import 'dart:convert'; + +import 'package:flutter_test/flutter_test.dart'; +import 'package:fruitshorts/core/data/models/drama.dart'; +import 'package:fruitshorts/core/data/remote/api_client.dart'; +import 'package:fruitshorts/core/data/remote/playback_api.dart'; +import 'package:fruitshorts/core/data/repositories/playback_repository.dart'; +import 'package:fruitshorts/core/data/services/video_player_port.dart'; + +import '../support/fake_http_adapter.dart'; + +/// 播放票据有有效期(契约 §1.4:签名默认 15 分钟): +/// 缓存期内不重复取,过期或显式强刷必须重新取,且**签名地址原样使用**。 +void main() { + String envelope(String playUrl) => jsonEncode({ + 'code': 0, + 'message': 'ok', + 'data': { + 'episodeId': '11', + 'dramaId': '5', + 'number': 1, + 'title': '第 1 集', + 'durationSec': 180, + 'accessible': true, + 'accessType': 'FREE', + 'playUrl': playUrl, + 'qualities': ['AUTO'], + 'unlockCoin': 0, + 'previewSeconds': 0, + }, + }); + + _TicketEnv build() { + var now = DateTime(2026, 10, 16, 12); + final adapter = FakeHttpAdapter( + (_) async => FakeHttpResponse( + envelope('/files/episode/11.mp4?e=1760000000&s=9f2c'), + ), + ); + final client = ApiClient(baseUrl: 'http://127.0.0.1:8081', adapter: adapter); + final repository = HttpPlaybackRepository( + PlaybackApi(client), + ttl: const Duration(minutes: 10), + clock: () => now, + ); + return _TicketEnv( + repository: repository, + adapter: adapter, + advance: (Duration d) => now = now.add(d), + ); + } + + test('should_reuse_ticket_when_cache_is_still_fresh', () async { + final env = build(); + await env.repository.ticketFor('11'); + env.advance(const Duration(minutes: 9)); + await env.repository.ticketFor('11'); + + expect(env.adapter.requests, hasLength(1)); + }); + + test('should_refetch_ticket_when_cache_expired', () async { + final env = build(); + await env.repository.ticketFor('11'); + env.advance(const Duration(minutes: 11)); + final ticket = await env.repository.ticketFor('11'); + + expect(env.adapter.requests, hasLength(2)); + expect(ticket.playUrl, contains('?e=1760000000&s=9f2c')); + }); + + test('should_refetch_ticket_when_explicitly_forced', () async { + final env = build(); + await env.repository.ticketFor('11'); + await env.repository.ticketFor('11', forceRefresh: true); + + expect(env.adapter.requests, hasLength(2)); + }); + + test('should_report_freshness_when_asking_before_expiry', () async { + final env = build(); + expect(env.repository.isFresh('11'), isFalse); + await env.repository.ticketFor('11'); + expect(env.repository.isFresh('11'), isTrue); + env.advance(const Duration(minutes: 11)); + expect(env.repository.isFresh('11'), isFalse); + }); + + test('should_keep_signed_query_verbatim_when_resolving_media_uri', () { + const episode = Episode( + id: '11', + number: 1, + title: '第 1 集', + isFree: true, + videoUrl: '/files/episode/11.mp4?e=1760000000&s=9f2c', + ); + + final uri = VideoPlayerPort.resolveUri(episode); + + // 只补 host,路径与查询串原样保留(签名丢了就等于 403) + expect(uri.path, '/files/episode/11.mp4'); + expect(uri.query, 'e=1760000000&s=9f2c'); + expect(uri.toString(), endsWith('/files/episode/11.mp4?e=1760000000&s=9f2c')); + }); +} + +/// 测试用的小环境:仓库 + 假适配器 + 可推进的时钟。 +class _TicketEnv { + _TicketEnv({ + required this.repository, + required this.adapter, + required this.advance, + }); + + final HttpPlaybackRepository repository; + final FakeHttpAdapter adapter; + final void Function(Duration) advance; +} diff --git a/test/playback/progress_throttle_test.dart b/test/playback/progress_throttle_test.dart new file mode 100644 index 0000000..90b3697 --- /dev/null +++ b/test/playback/progress_throttle_test.dart @@ -0,0 +1,178 @@ +// Author: fruit.com.cn + +import 'package:flutter/services.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:fruitshorts/core/data/models/drama.dart'; +import 'package:fruitshorts/core/data/models/watch_progress.dart'; +import 'package:fruitshorts/core/data/services/android_picture_in_picture.dart'; +import 'package:fruitshorts/core/data/repositories/playback_repository.dart'; +import 'package:fruitshorts/core/data/services/playback_session.dart'; +import 'package:fruitshorts/pages/player/player_logic.dart'; +import 'package:fruitshorts/pages/player/player_view.dart'; + +import '../support/fake_watch_history.dart'; +import '../support/widget_player.dart'; + +Drama _drama(String id, {List numbers = const [1, 2, 3]}) => Drama( + id: id, + title: id, + synopsis: 'synopsis', + posterUrl: '/files/poster.png', + episodes: [ + for (final number in numbers) + Episode( + id: '$id-$number', + number: number, + title: 'Episode $number', + videoUrl: 'https://example.test/clip.mp4', + isFree: true, + ), + ], +); + +PlayerLogic _logic(FakeWatchHistory history, {Drama? drama}) { + final logic = PlayerLogic( + history: history, + playback: FakePlaybackRepository(), + pictureInPicture: AndroidPictureInPicture( + channel: const MethodChannel('test/progress/pip'), + ), + ); + if (drama != null) { + logic.attach( + PlayerPage(drama: drama, initialIndex: 0), + isMounted: () => true, + ); + logic.start( + factory: (episode) => WidgetPlayer(), + coordinator: PlaybackCoordinator(), + ); + } + return logic; +} + +/// 排空 session 串行队列,避免测试结束在 dispose 中途。 +Future _drain(PlayerLogic logic) async { + for (var attempt = 0; attempt < 4; attempt++) { + await pumpEventQueue(); + await logic.session.playbackSettled; + await logic.session.preloadSettled; + } +} + +void main() { + TestWidgetsFlutterBinding.ensureInitialized(); + + group('progress throttle', () { + test('should_report_once_per_interval_when_progress_ticks_keep_coming', () { + final logic = _logic(FakeWatchHistory()); + final start = DateTime(2026, 10, 16, 12); + logic.lastProgressWrite = start; + + // 契约建议每 10 秒一次:3 秒、9 秒都不报,第 10 秒报一次 + expect(logic.progressInterval, const Duration(seconds: 10)); + expect(logic.shouldReportProgress(start.add(const Duration(seconds: 3))), isFalse); + expect(logic.shouldReportProgress(start.add(const Duration(seconds: 9))), isFalse); + expect(logic.shouldReportProgress(start.add(const Duration(seconds: 10))), isTrue); + // 报过之后节流窗口重新开始 + expect(logic.shouldReportProgress(start.add(const Duration(seconds: 15))), isFalse); + expect(logic.shouldReportProgress(start.add(const Duration(seconds: 20))), isTrue); + logic.dispose(); + }); + + test('should_write_immediately_when_saving_on_episode_switch_or_exit', () async { + final history = FakeWatchHistory(); + final drama = _drama('signal'); + final logic = _logic(history, drama: drama); + + // 切集/退出/切后台走 saveCurrentProgress:不受 10 秒节流限制 + await logic.queueProgress( + drama, + drama.episodes[0], + const Duration(seconds: 5), + duration: const Duration(minutes: 3), + ); + await logic.queueProgress( + drama, + drama.episodes[1], + const Duration(seconds: 6), + duration: const Duration(minutes: 3), + ); + + expect(history.writes, [ + 'signal-1|5000|false', + 'signal-2|6000|false', + ]); + logic.dispose(); + }); + + test('should_report_finished_when_episode_plays_to_the_end', () async { + final history = FakeWatchHistory(); + final drama = _drama('signal'); + final logic = _logic(history, drama: drama); + + await logic.queueProgress( + drama, + drama.episodes[0], + const Duration(minutes: 3), + duration: const Duration(minutes: 3), + finished: true, + ); + + expect(history.writes, ['signal-1|180000|true']); + logic.dispose(); + }); + }); + + group('resume positioning', () { + test('should_take_position_from_server_when_record_matches_the_episode', () async { + final history = FakeWatchHistory( + )..records['signal'] = const WatchProgress( + dramaId: 'signal', + episodeId: 'signal-2', + position: Duration(seconds: 42), + duration: Duration(minutes: 3), + ); + final logic = _logic(history, drama: _drama('signal')); + await _drain(logic); + + await logic.loadResumePoint(); + + expect(logic.resumePositionFor('signal-2'), const Duration(seconds: 42)); + // 记录里不是这一集:不给定位(从头播,避免"看第 1 集却跳到第 2 集的位置") + expect(logic.resumePositionFor('signal-1'), isNull); + expect(logic.resumePositionFor('signal-3'), isNull); + logic.dispose(); + }); + + test('should_have_no_resume_position_when_server_read_fails', () async { + final history = FakeWatchHistory()..failReads = true; + final logic = _logic(history, drama: _drama('signal')); + await _drain(logic); + + await logic.loadResumePoint(); + + expect(logic.resumePoint, isNull); + expect(logic.resumeLoaded, isTrue); + logic.dispose(); + }); + + test('should_not_seek_when_position_is_zero', () async { + final history = FakeWatchHistory() + ..records['signal'] = const WatchProgress( + dramaId: 'signal', + episodeId: 'signal-1', + position: Duration.zero, + duration: Duration(minutes: 3), + ); + final logic = _logic(history, drama: _drama('signal')); + await _drain(logic); + + await logic.loadResumePoint(); + + expect(logic.resumePositionFor('signal-1'), isNull); + logic.dispose(); + await _drain(logic); + }); + }); +} diff --git a/test/playback/watch_history_test.dart b/test/playback/watch_history_test.dart index bc12aaa..fb7a9c6 100644 --- a/test/playback/watch_history_test.dart +++ b/test/playback/watch_history_test.dart @@ -1,9 +1,11 @@ -import 'package:flutter_test/flutter_test.dart'; -import 'package:fruitshorts/core/data/models/drama.dart'; -import 'package:fruitshorts/core/data/repositories/watch_history_repository.dart'; -import 'package:shared_preferences_platform_interface/in_memory_shared_preferences_async.dart'; -import 'package:shared_preferences_platform_interface/shared_preferences_async_platform_interface.dart'; +// Author: fruit.com.cn +import 'package:flutter_test/flutter_test.dart'; +import 'package:fruitshorts/core/data/models/watch_progress.dart'; +import 'package:fruitshorts/core/data/repositories/watch_history_repository.dart'; + +/// 进度仓库从"本地按 profile+剧+集"换成"服务端每剧一条": +/// 这里钉住续看点换算、空记录、字符串数值解析、失败透传与清理。 void main() { test('should_clamp_invalid_and_completed_values_when_resolving_resume_position', () { const duration = Duration(seconds: 8); @@ -25,106 +27,101 @@ void main() { ); }); - test('should_scope_history_by_profile_drama_and_episode_when_saving', () async { - SharedPreferencesAsyncPlatform.instance = - InMemorySharedPreferencesAsync.empty(); - final history = SharedPreferencesWatchHistoryRepository(); - await history.save( - 'profile-a', - 'drama-a', - 'episode-1', - const Duration(seconds: 3), - ); - await history.save( - 'profile-a', - 'drama-a', - 'episode-2', - const Duration(seconds: 5), - ); - expect( - await history.positionFor('profile-a', 'drama-a', 'episode-1'), - const Duration(seconds: 3), - ); - expect( - await history.positionFor('profile-b', 'drama-a', 'episode-1'), - isNull, - ); - expect(await history.lastEpisodeId('profile-a', 'drama-a'), 'episode-2'); - expect(await history.lastEpisodeId('profile-a', 'drama-b'), isNull); - }); - - test('should_prefer_first_loaded_episode_when_resuming', () async { - SharedPreferencesAsyncPlatform.instance = - InMemorySharedPreferencesAsync.empty(); - final history = SharedPreferencesWatchHistoryRepository(); - await history.save( - 'profile-a', - 'drama-a', - 'episode-1', - const Duration(seconds: 3), - ); - await history.save( - 'profile-a', - 'drama-a', - 'episode-2', - const Duration(seconds: 5), - ); - - final drama = Drama( - id: 'drama-a', - title: 'title', - synopsis: 'synopsis', - posterUrl: '', - episodes: const [ - Episode(id: 'episode-1', number: 1, title: 'E1', isFree: true), - Episode(id: 'episode-2', number: 2, title: 'E2', isFree: true), + test('should_return_resume_point_when_server_has_progress', () async { + final history = InMemoryWatchHistoryRepository( + seed: const [ + WatchProgress( + dramaId: 'drama-a', + episodeId: 'episode-3', + position: Duration(seconds: 42), + duration: Duration(minutes: 3), + ), ], ); - expect( - await history.resumePositionFor('profile-a', drama), - const Duration(seconds: 3), - ); + final point = await history.resumePointFor('drama-a'); + + expect(point?.episodeId, 'episode-3'); + expect(point?.position, const Duration(seconds: 42)); }); - test('should_fall_back_to_last_watched_episode_when_resuming_a_list_card', () async { - SharedPreferencesAsyncPlatform.instance = - InMemorySharedPreferencesAsync.empty(); - final history = SharedPreferencesWatchHistoryRepository(); - await history.save( - 'profile-a', - 'drama-a', - 'episode-2', - const Duration(seconds: 5), - ); + test('should_return_no_resume_point_when_server_has_no_record', () async { + final history = InMemoryWatchHistoryRepository(); - const card = Drama( - id: 'drama-a', - title: 'title', - synopsis: 'synopsis', - posterUrl: '', - totalEpisodes: 12, - ); - - expect( - await history.resumePositionFor('profile-a', card), - const Duration(seconds: 5), - ); + expect(await history.resumePointFor('drama-a'), isNull); }); - test('should_have_no_resume_position_when_list_card_has_no_history', () async { - SharedPreferencesAsyncPlatform.instance = - InMemorySharedPreferencesAsync.empty(); - final history = SharedPreferencesWatchHistoryRepository(); - - const card = Drama( - id: 'drama-b', - title: 'title', - synopsis: 'synopsis', - posterUrl: '', - totalEpisodes: 12, + test('should_return_no_resume_point_when_record_has_no_episode', () async { + final history = InMemoryWatchHistoryRepository( + seed: const [ + WatchProgress( + dramaId: 'drama-a', + episodeId: '', + position: Duration(seconds: 5), + duration: Duration(minutes: 3), + ), + ], ); - expect(await history.resumePositionFor('profile-a', card), isNull); + expect(await history.resumePointFor('drama-a'), isNull); + }); + + test('should_expose_fraction_when_duration_is_known', () { + const record = WatchProgress( + dramaId: 'd', + episodeId: 'e', + position: Duration(seconds: 30), + duration: Duration(seconds: 120), + ); + expect(record.fraction, closeTo(0.25, 0.0001)); + expect(record.hasPosition, isTrue); + + const unknown = WatchProgress( + dramaId: 'd', + episodeId: 'e', + position: Duration(seconds: 30), + duration: Duration.zero, + ); + expect(unknown.fraction, 0); + }); + + test('should_parse_string_numbers_when_server_sends_ids_and_ms_as_strings', () { + final record = WatchProgress.fromJson({ + 'dramaId': '2111012753262120962', + 'episodeId': '2111012753262120963', + 'positionMs': '42000', + 'durationMs': '180000', + 'finished': false, + 'playCount': '2', + }); + + expect(record.dramaId, '2111012753262120962'); + expect(record.episodeId, '2111012753262120963'); + expect(record.position, const Duration(seconds: 42)); + expect(record.duration, const Duration(seconds: 180)); + expect(record.playCount, 2); + }); + + test('should_throw_when_reading_progress_fails', () async { + final history = InMemoryWatchHistoryRepository()..failReads = 1; + + expect(() => history.progressFor('drama-a'), throwsStateError); + }); + + test('should_drop_record_when_removing_progress', () async { + final history = InMemoryWatchHistoryRepository( + seed: const [ + WatchProgress( + dramaId: 'drama-a', + episodeId: 'e1', + position: Duration(seconds: 5), + duration: Duration(minutes: 1), + ), + ], + ); + + await history.remove('drama-a'); + + expect(await history.progressFor('drama-a'), isNull); }); } diff --git a/test/player/player_logic_test.dart b/test/player/player_logic_test.dart index 1ed2607..0b516ea 100644 --- a/test/player/player_logic_test.dart +++ b/test/player/player_logic_test.dart @@ -2,6 +2,7 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:fruitshorts/core/data/models/drama.dart'; +import 'package:fruitshorts/core/data/models/play_ticket.dart'; import 'package:fruitshorts/core/data/models/player_port.dart'; import 'package:fruitshorts/core/data/services/android_picture_in_picture.dart'; import 'package:fruitshorts/core/data/services/playback_session.dart'; @@ -9,6 +10,7 @@ import 'package:fruitshorts/pages/player/player_logic.dart'; import 'package:fruitshorts/pages/player/player_view.dart'; import '../support/fake_watch_history.dart'; +import 'package:fruitshorts/core/data/repositories/playback_repository.dart'; Drama _drama( String id, { @@ -35,8 +37,14 @@ Drama _drama( AndroidPictureInPicture _pip() => AndroidPictureInPicture(channel: const MethodChannel('test/player_logic/pip')); -PlayerLogic _logic(FakeWatchHistory history) => - PlayerLogic(history: history, pictureInPicture: _pip()); +PlayerLogic _logic( + FakeWatchHistory history, { + PlaybackRepository? playback, +}) => PlayerLogic( + history: history, + playback: playback ?? FakePlaybackRepository(), + pictureInPicture: _pip(), +); /// Drains the session's serialized work so a test never ends mid-disposal. /// @@ -191,10 +199,7 @@ void main() { const Duration(seconds: 2), ); - expect(history.writes, [ - 'demo-local-v1|signal|signal-1|1000', - 'demo-local-v1|signal|signal-2|2000', - ]); + expect(history.writes, ['signal-1|1000|false', 'signal-2|2000|false']); }); test('should_keep_later_writes_when_an_earlier_write_fails', () async { @@ -216,7 +221,7 @@ void main() { const Duration(seconds: 2), ); - expect(history.writes, ['demo-local-v1|signal|signal-2|2000']); + expect(history.writes, ['signal-2|2000|false']); }); test('should_write_nothing_when_no_player_is_tracked', () async { @@ -284,7 +289,18 @@ void main() { test('should_never_reach_player_factory_when_episode_is_locked', () async { final factory = _RecordingFactory(); final drama = _drama('locked', isFree: false); - final logic = _logic(FakeWatchHistory()); + // 锁定的判定权在后端:票据返回不可播 + 无地址,客户端不得自行推断 + final logic = _logic( + FakeWatchHistory(), + playback: FakePlaybackRepository( + ticket: const PlayTicket( + episodeId: 'locked-1', + accessible: false, + accessType: PlayTicket.coinRequired, + unlockCoin: 30, + ), + ), + ); logic.attach( PlayerPage(drama: drama, initialIndex: 0), isMounted: () => true, diff --git a/test/support/fake_catalog.dart b/test/support/fake_catalog.dart index 3bfe1d6..fc6d54a 100644 --- a/test/support/fake_catalog.dart +++ b/test/support/fake_catalog.dart @@ -1,6 +1,5 @@ import 'package:fruitshorts/core/data/models/drama.dart'; import 'package:fruitshorts/core/data/models/home_feed.dart'; -import 'package:fruitshorts/core/data/models/play_ticket.dart'; import 'package:fruitshorts/core/data/repositories/catalog_repository.dart'; /// 测试用目录数据:三部分区里的短剧,标题与后端演示数据保持一致。 @@ -20,16 +19,6 @@ class FakeCatalogRepository implements CatalogRepository { return dramas.firstWhere((drama) => drama.id == dramaId); } - @override - Future resolvePlay(String episodeId) async { - return PlayTicket( - episodeId: episodeId, - accessible: true, - accessType: PlayTicket.free, - playUrl: 'https://example.test/$episodeId.mp4', - ); - } - HomeFeed _feed() => HomeFeed( sections: [FeedSection(code: 'hot', title: '热门推荐', dramas: dramas)], ); diff --git a/test/support/fake_watch_history.dart b/test/support/fake_watch_history.dart index 9b4d8b1..6568866 100644 --- a/test/support/fake_watch_history.dart +++ b/test/support/fake_watch_history.dart @@ -1,44 +1,67 @@ import 'package:fruitshorts/core/data/repositories/watch_history_repository.dart'; +import 'package:fruitshorts/core/data/models/watch_progress.dart'; -/// Records every history interaction so tests can assert on the key it used. +/// 记录每次进度读取/上报,方便断言"读了哪部剧、上报了哪一集"。 +/// +/// 服务端模型:每部剧一条续看记录(不再是 profile+剧+集),所以 `reads` 里是 dramaId。 class FakeWatchHistory implements WatchHistoryRepository { final List reads = []; final List writes = []; - /// Position returned by [positionFor] when [failReads] is false. + /// 便捷写法:只关心"有续看位置"时直接给这个值(默认落在第 1 集)。 Duration? saved; - /// Last episode returned by [lastEpisodeId]. + /// 便捷写法:续看记录落在哪一集(配合 [saved] 使用)。 String? lastEpisode; + /// 精确控制:按剧返回不同记录。 + final Map records = {}; + + /// [recent] 的返回值。 + List recentRecords = const []; + bool failReads = false; bool failWrites = false; @override - Future positionFor( - String profileId, - String dramaId, - String episodeId, - ) async { - reads.add('$profileId|$dramaId|$episodeId'); + Future progressFor(String dramaId) async { + reads.add(dramaId); if (failReads) throw StateError('history unavailable'); - return saved; + final record = records[dramaId]; + if (record != null) return record; + if (saved == null) return null; + return WatchProgress( + dramaId: dramaId, + episodeId: lastEpisode ?? '$dramaId-1', + position: saved!, + duration: const Duration(minutes: 5), + ); } @override - Future lastEpisodeId(String profileId, String dramaId) async { - if (failReads) throw StateError('history unavailable'); - return lastEpisode; - } - - @override - Future save( - String profileId, - String dramaId, - String episodeId, - Duration position, - ) async { + Future save({ + required String episodeId, + required Duration position, + Duration? duration, + bool finished = false, + }) async { if (failWrites) throw StateError('history unavailable'); - writes.add('$profileId|$dramaId|$episodeId|${position.inMilliseconds}'); + writes.add('$episodeId|${position.inMilliseconds}|$finished'); + return WatchProgress( + dramaId: '', + episodeId: episodeId, + position: position, + duration: duration ?? Duration.zero, + finished: finished, + ); } + + @override + Future> recent({int limit = 20}) async { + if (failReads) throw StateError('history unavailable'); + return recentRecords.take(limit).toList(); + } + + @override + Future remove(String dramaId) async => records.remove(dramaId); } diff --git a/test/widget_test.dart b/test/widget_test.dart index 9bdae0b..84a0787 100644 --- a/test/widget_test.dart +++ b/test/widget_test.dart @@ -8,6 +8,11 @@ import 'package:shared_preferences_platform_interface/shared_preferences_async_p import 'support/fake_catalog.dart'; import 'support/widget_player.dart'; +import 'package:fruitshorts/core/data/repositories/favorite_repository.dart'; +import 'package:fruitshorts/core/data/repositories/catalog_repository.dart'; +import 'package:fruitshorts/core/data/repositories/playback_repository.dart'; +import 'package:fruitshorts/core/data/repositories/watch_history_repository.dart'; +import 'package:fruitshorts/core/data/services/playback_session.dart'; void main() { /// 默认按「已登录」起测:账号体系接上后,"登录"不再是本地演示开关, @@ -27,17 +32,31 @@ void main() { seedSignedInSession(); }); + /// 所有 widget 测试都注入离线仓库:票据 / 进度 / 收藏都不碰网络, + /// 这样断言的是 UI 行为,而不是后端有没有起。 + Widget appUnderTest({ + PlayerFactory? playerFactory, + CatalogRepository? catalogRepository, + }) => LumaDramaApp( + playerFactory: playerFactory ?? createWidgetPlayer, + catalogRepository: catalogRepository ?? FakeCatalogRepository(), + watchHistoryRepository: InMemoryWatchHistoryRepository(), + favoriteRepository: InMemoryFavoriteRepository( + cards: FakeCatalogRepository().dramas, + ), + playbackRepository: FakePlaybackRepository(), + ); + testWidgets( 'should_promote_next_without_recreating_it_or_showing_loading_when_home_is_swiped', (tester) async { final created = []; await tester.pumpWidget( - LumaDramaApp( + appUnderTest( playerFactory: (episode) { created.add(episode.id); return WidgetPlayer(); }, - catalogRepository: FakeCatalogRepository(), ), ); await tester.pumpAndSettle(); @@ -64,7 +83,7 @@ void main() { addTearDown(tester.view.resetDevicePixelRatio); await tester.pumpWidget( - LumaDramaApp(playerFactory: createWidgetPlayer, catalogRepository: FakeCatalogRepository()), + appUnderTest(), ); await tester.pumpAndSettle(); await tester.tap(find.byKey(const Key('tab-home'))); @@ -91,7 +110,7 @@ void main() { addTearDown(tester.view.resetDevicePixelRatio); await tester.pumpWidget( - LumaDramaApp(playerFactory: createWidgetPlayer, catalogRepository: FakeCatalogRepository()), + appUnderTest(), ); await tester.pumpAndSettle(); await tester.tap(find.byKey(const Key('tab-home'))); @@ -116,7 +135,7 @@ void main() { addTearDown(tester.view.resetDevicePixelRatio); await tester.pumpWidget( - LumaDramaApp(playerFactory: createWidgetPlayer, catalogRepository: FakeCatalogRepository()), + appUnderTest(), ); await tester.pumpAndSettle(); expect(find.text('Continue Watching'), findsOneWidget); @@ -171,7 +190,7 @@ void main() { addTearDown(tester.view.resetDevicePixelRatio); await tester.pumpWidget( - LumaDramaApp(playerFactory: createWidgetPlayer, catalogRepository: FakeCatalogRepository()), + appUnderTest(), ); await tester.pumpAndSettle(); expect(find.byTooltip('Captions'), findsNothing); @@ -200,7 +219,7 @@ void main() { addTearDown(tester.view.resetDevicePixelRatio); await tester.pumpWidget( - LumaDramaApp(playerFactory: createWidgetPlayer, catalogRepository: FakeCatalogRepository()), + appUnderTest(), ); await tester.pumpAndSettle(); await tester.tap(find.byKey(const Key('tab-home'))); @@ -226,7 +245,7 @@ void main() { addTearDown(tester.view.resetDevicePixelRatio); await tester.pumpWidget( - LumaDramaApp(playerFactory: createWidgetPlayer, catalogRepository: FakeCatalogRepository()), + appUnderTest(), ); await tester.pumpAndSettle(); await tester.tap(find.byKey(const Key('tab-my'))); @@ -249,7 +268,7 @@ void main() { addTearDown(tester.view.resetDevicePixelRatio); await tester.pumpWidget( - LumaDramaApp(playerFactory: createWidgetPlayer, catalogRepository: FakeCatalogRepository()), + appUnderTest(), ); await tester.pumpAndSettle(); await tester.tap(find.text('Home')); @@ -283,7 +302,7 @@ void main() { addTearDown(tester.view.resetDevicePixelRatio); await tester.pumpWidget( - LumaDramaApp(playerFactory: createWidgetPlayer, catalogRepository: FakeCatalogRepository()), + appUnderTest(), ); await tester.pumpAndSettle(); await tester.tap(find.text('Home')); @@ -335,7 +354,7 @@ void main() { addTearDown(tester.view.resetDevicePixelRatio); await tester.pumpWidget( - LumaDramaApp(playerFactory: createWidgetPlayer, catalogRepository: FakeCatalogRepository()), + appUnderTest(), ); await tester.pumpAndSettle(); await tester.tap(find.byKey(const Key('tab-home'))); @@ -366,7 +385,7 @@ void main() { addTearDown(tester.view.resetDevicePixelRatio); await tester.pumpWidget( - LumaDramaApp(playerFactory: createWidgetPlayer, catalogRepository: FakeCatalogRepository()), + appUnderTest(), ); await tester.pumpAndSettle(); await tester.tap(find.byKey(const Key('tab-home'))); @@ -404,7 +423,7 @@ void main() { ); await tester.pumpWidget( - LumaDramaApp(playerFactory: createWidgetPlayer, catalogRepository: FakeCatalogRepository()), + appUnderTest(), ); await tester.pumpAndSettle(); await tester.tap(find.byKey(const Key('tab-home'))); @@ -445,7 +464,7 @@ void main() { addTearDown(tester.view.resetPhysicalSize); addTearDown(tester.view.resetDevicePixelRatio); await tester.pumpWidget( - LumaDramaApp(playerFactory: createWidgetPlayer, catalogRepository: FakeCatalogRepository()), + appUnderTest(), ); await tester.pumpAndSettle(); @@ -473,8 +492,10 @@ void main() { tester.view.devicePixelRatio = 1; addTearDown(tester.view.resetPhysicalSize); addTearDown(tester.view.resetDevicePixelRatio); + // 收藏要求登录态:沿用本文件已有的"假登录"初始化 + seedSignedInSession(); await tester.pumpWidget( - LumaDramaApp(playerFactory: createWidgetPlayer, catalogRepository: FakeCatalogRepository()), + appUnderTest(), ); await tester.pumpAndSettle(); await tester.tap(find.byKey(const Key('tab-home'))); -- 2.54.0 From 84a1f58a0a997ae752fdba504f6f85864851fd83 Mon Sep 17 00:00:00 2001 From: Vicky <10212746+haifeng-jiang@user.noreply.gitee.com> Date: Fri, 16 Oct 2026 18:05:58 +0800 Subject: [PATCH 10/76] =?UTF-8?q?test(client):=20=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E8=AE=BE=E5=A4=87=E4=BE=A7=E9=9B=86=E6=88=90=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=EF=BC=88=E7=9C=9F=E6=9C=BA=E8=B7=91=E9=80=9A=E5=90=8E=E7=AB=AF?= =?UTF-8?q?=E5=8F=AF=E8=BE=BE=E6=80=A7=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 红线第 10 条(设备验证必须设备侧取证)配套:integration_test/app_backend_test.dart 在手机进程里真实请求 /app/home/feed 与 /app/dramas/{id},并用真 App 断言首页剧目列表能渲染。 把 API_BASE_URL 打进设备日志,便于区分地址不对与设备连不上。 注意:真机执行由用户负责(用户 20:45 指令),本文件按原样交付、不再改动。 本项目 iOS 用 SPM,无 Podfile,不需要 pod install。 --- integration_test/app_backend_test.dart | 74 ++++++++++++++++++++++++++ pubspec.lock | 39 ++++++++++++++ pubspec.yaml | 5 ++ 3 files changed, 118 insertions(+) create mode 100644 integration_test/app_backend_test.dart diff --git a/integration_test/app_backend_test.dart b/integration_test/app_backend_test.dart new file mode 100644 index 0000000..a2fa765 --- /dev/null +++ b/integration_test/app_backend_test.dart @@ -0,0 +1,74 @@ +// Author: fruit.com.cn + +import 'package:flutter/foundation.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:fruitshorts/app.dart'; +import 'package:fruitshorts/core/config/app_config.dart'; +import 'package:fruitshorts/core/data/remote/api_client.dart'; +import 'package:fruitshorts/core/data/remote/catalog_api.dart'; +import 'package:integration_test/integration_test.dart'; + +/// 设备侧集成测试:**在手机进程里**真实请求开发机上的 app-api。 +/// +/// 跑法(红线第 10 条要求的"设备侧取证"): +/// ``` +/// IP=$(ipconfig getifaddr en0) +/// flutter test integration_test -d --dart-define=API_BASE_URL=http://$IP:8081 +/// ``` +/// 断言失败时会把实际使用的地址一起打出来,便于区分"地址不对"还是"设备连不上"。 +void main() { + IntegrationTestWidgetsFlutterBinding.ensureInitialized(); + + final baseUrl = AppConfig.apiBaseUrl; + + testWidgets('should_fetch_home_feed_and_drama_detail_when_device_reaches_backend', ( + tester, + ) async { + debugPrint('[device] API_BASE_URL=$baseUrl'); + final client = ApiClient(baseUrl: baseUrl); + addTearDown(client.close); + final api = CatalogApi(client); + + final feed = await api.homeFeed(); + expect( + feed.dramas, + isNotEmpty, + reason: '设备侧拿不到首页列表(API_BASE_URL=$baseUrl)', + ); + debugPrint('[device] 首页分区=${feed.sections.length} 剧目=${feed.dramas.length}'); + + final card = feed.dramas.first; + expect(card.id, isNotEmpty, reason: '设备侧首页卡片 id 为空'); + + final detail = await api.dramaDetail(card.id); + expect(detail.id, card.id, reason: '详情返回的 id 与卡片不一致'); + expect( + detail.episodes, + isNotEmpty, + reason: '设备侧拿到的详情没有剧集(dramaId=${card.id})', + ); + debugPrint('[device] 详情 id=${detail.id} 剧集=${detail.episodes.length}'); + }); + + testWidgets('should_render_home_drama_list_when_app_boots_on_device', ( + tester, + ) async { + // 用真 App(真网络、真目录控制器):首页底部标签栏出现即代表"剧目列表加载成功", + // 也就是用户在真机上遇到的那个「剧目列表加载失败」已经消失。 + await tester.pumpWidget(const LumaDramaApp()); + + var loaded = false; + for (var attempt = 0; attempt < 60 && !loaded; attempt++) { + await tester.pump(const Duration(milliseconds: 500)); + loaded = find.byKey(const Key('home-tabs-bar')).evaluate().isNotEmpty; + } + + expect( + loaded, + isTrue, + reason: '首页 30 秒内没渲染出剧目列表(API_BASE_URL=$baseUrl)', + ); + debugPrint('[device] 首页剧目列表已渲染:API_BASE_URL=$baseUrl'); + }); +} diff --git a/pubspec.lock b/pubspec.lock index 98d77df..7abd14d 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -134,6 +134,11 @@ packages: description: flutter source: sdk version: "0.0.0" + flutter_driver: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" flutter_launcher_icons: dependency: "direct dev" description: @@ -165,6 +170,11 @@ packages: description: flutter source: sdk version: "0.0.0" + fuchsia_remote_debug_protocol: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" html: dependency: transitive description: @@ -189,6 +199,11 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "4.12.0" + integration_test: + dependency: "direct dev" + description: flutter + source: sdk + version: "0.0.0" intl: dependency: transitive description: @@ -333,6 +348,14 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "6.5.2" + process: + dependency: transitive + description: + name: process + sha256: "4242ba3508d37e01808bdf71ad1d5bb93a8d671bf2e7450e6b1b353fb0808891" + url: "https://pub.flutter-io.cn" + source: hosted + version: "5.0.6" provider: dependency: "direct main" description: @@ -434,6 +457,14 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "1.4.1" + sync_http: + dependency: transitive + description: + name: sync_http + sha256: "7f0cd72eca000d2e026bcd6f990b81d0ca06022ef4e32fb257b30d3d1014a961" + url: "https://pub.flutter-io.cn" + source: hosted + version: "0.3.1" term_glyph: dependency: transitive description: @@ -522,6 +553,14 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "1.1.1" + webdriver: + dependency: transitive + description: + name: webdriver + sha256: "28b82ec894fed45dd71c23ba62d1af973ed97dd59a4f5790a4d38b0b13e5657e" + url: "https://pub.flutter-io.cn" + source: hosted + version: "3.2.0" xdg_directories: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 7f4fd45..4fe8149 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -46,6 +46,11 @@ dev_dependencies: flutter_test: sdk: flutter + # 设备侧集成测试:真机/模拟器进程里真实发请求,验证"设备能不能连到开发机后端" + # (红线第 10 条:设备验证必须设备侧取证,不能用开发机 curl 充数) + integration_test: + sdk: flutter + # The "flutter_lints" package below contains a set of recommended lints to # encourage good coding practices. The lint set provided by the package is # activated in the `analysis_options.yaml` file located at the root of your -- 2.54.0 From cc4d7c5a9dc6a4f6f0565a32503cce5973af703c Mon Sep 17 00:00:00 2001 From: Zhou Weidong <502333560@qq.com> Date: Sat, 17 Oct 2026 14:49:16 +0800 Subject: [PATCH 11/76] =?UTF-8?q?feat(flutter):=20=E6=8E=A5=E5=85=A5?= =?UTF-8?q?=E5=88=86=E7=B1=BB=E8=AE=B0=E5=BD=95=E6=94=B6=E8=97=8F=E4=B8=8E?= =?UTF-8?q?=E4=B8=8B=E8=BD=BD=E6=8E=88=E6=9D=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/app.dart | 47 +- lib/core/data/models/content_category.dart | 17 + lib/core/data/models/download_license.dart | 67 +++ lib/core/data/models/download_policy.dart | 54 +++ lib/core/data/models/watch_progress.dart | 4 + lib/core/data/models/watch_record.dart | 44 ++ lib/core/data/remote/api_client.dart | 15 + lib/core/data/remote/category_api.dart | 21 + lib/core/data/remote/download_api.dart | 101 +++++ lib/core/data/remote/watch_api.dart | 5 + .../repositories/category_repository.dart | 30 ++ .../repositories/download_repository.dart | 82 ++++ .../repositories/favorite_repository.dart | 8 +- .../watch_history_repository.dart | 16 +- .../data/services/category_controller.dart | 82 ++++ .../data/services/download_controller.dart | 168 +++++++ .../data/services/favorite_controller.dart | 23 +- .../services/watch_records_controller.dart | 205 +++++++++ lib/core/widgets/auth_gate.dart | 45 +- lib/core/widgets/download_action.dart | 29 ++ lib/core/widgets/library_drama_tile.dart | 73 ++++ lib/l10n/app_en.arb | 79 +++- lib/l10n/app_id.arb | 79 +++- lib/l10n/app_localizations.dart | 202 ++++++++- lib/l10n/app_localizations_en.dart | 123 +++++- lib/l10n/app_localizations_id.dart | 118 ++++- lib/l10n/app_localizations_zh.dart | 117 ++++- lib/l10n/app_zh.arb | 79 +++- lib/pages/discover/discover_logic.dart | 49 +-- lib/pages/discover/discover_view.dart | 139 +++--- lib/pages/downloads/downloads_binding.dart | 9 + lib/pages/downloads/downloads_page.dart | 409 ++++++++++++++++++ lib/pages/drama_detail/drama_detail_view.dart | 23 +- lib/pages/favorites/favorites_binding.dart | 9 + lib/pages/favorites/favorites_page.dart | 148 +++++++ lib/pages/home/home_view.dart | 2 - lib/pages/mine/mine_view.dart | 41 +- lib/pages/player/player_view.dart | 10 + .../watch_records/watch_records_binding.dart | 14 + .../watch_records/watch_records_page.dart | 386 +++++++++++++++++ test/category/category_controller_test.dart | 179 ++++++++ test/discover/discover_logic_test.dart | 13 - test/download/download_api_test.dart | 118 +++++ test/download/download_controller_test.dart | 178 ++++++++ test/download/downloads_page_test.dart | 284 ++++++++++++ test/library/favorite_controller_test.dart | 25 +- test/library/favorites_page_test.dart | 153 +++++++ test/support/fake_category.dart | 23 + test/support/fake_watch_history.dart | 6 + test/watch/watch_records_controller_test.dart | 225 ++++++++++ test/watch/watch_records_page_test.dart | 212 +++++++++ test/widget_test.dart | 23 +- 52 files changed, 4440 insertions(+), 171 deletions(-) create mode 100644 lib/core/data/models/content_category.dart create mode 100644 lib/core/data/models/download_license.dart create mode 100644 lib/core/data/models/download_policy.dart create mode 100644 lib/core/data/models/watch_record.dart create mode 100644 lib/core/data/remote/category_api.dart create mode 100644 lib/core/data/remote/download_api.dart create mode 100644 lib/core/data/repositories/category_repository.dart create mode 100644 lib/core/data/repositories/download_repository.dart create mode 100644 lib/core/data/services/category_controller.dart create mode 100644 lib/core/data/services/download_controller.dart create mode 100644 lib/core/data/services/watch_records_controller.dart create mode 100644 lib/core/widgets/download_action.dart create mode 100644 lib/core/widgets/library_drama_tile.dart create mode 100644 lib/pages/downloads/downloads_binding.dart create mode 100644 lib/pages/downloads/downloads_page.dart create mode 100644 lib/pages/favorites/favorites_binding.dart create mode 100644 lib/pages/favorites/favorites_page.dart create mode 100644 lib/pages/watch_records/watch_records_binding.dart create mode 100644 lib/pages/watch_records/watch_records_page.dart create mode 100644 test/category/category_controller_test.dart create mode 100644 test/download/download_api_test.dart create mode 100644 test/download/download_controller_test.dart create mode 100644 test/download/downloads_page_test.dart create mode 100644 test/library/favorites_page_test.dart create mode 100644 test/support/fake_category.dart create mode 100644 test/watch/watch_records_controller_test.dart create mode 100644 test/watch/watch_records_page_test.dart diff --git a/lib/app.dart b/lib/app.dart index 7e15ce7..f2aef94 100644 --- a/lib/app.dart +++ b/lib/app.dart @@ -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 { 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 { ); 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 { unawaited(_favoriteController.load()); } else { _favoriteController.clear(); + _downloadController.reset(); } } @@ -108,6 +140,7 @@ class _LumaDramaAppState extends State { void dispose() { _auth.removeListener(_onAuthChanged); _favoriteController.dispose(); + _downloadController.dispose(); _apiClient.close(); super.dispose(); } @@ -122,12 +155,14 @@ class _LumaDramaAppState extends State { Provider.value(value: _watchHistory), Provider.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()) diff --git a/lib/core/data/models/content_category.dart b/lib/core/data/models/content_category.dart new file mode 100644 index 0000000..b93a308 --- /dev/null +++ b/lib/core/data/models/content_category.dart @@ -0,0 +1,17 @@ +// Author: fruit.com.cn + +/// 服务端内容分类。id 按契约保持字符串,避免雪花 ID 精度丢失。 +class ContentCategory { + const ContentCategory({required this.id, required this.name}); + + final String id; + final String name; + + /// 解析 `GET /app/categories` 的单项。 + factory ContentCategory.fromJson(Map json) { + return ContentCategory( + id: (json['id'] ?? '').toString(), + name: json['name'] as String? ?? '', + ); + } +} diff --git a/lib/core/data/models/download_license.dart b/lib/core/data/models/download_license.dart new file mode 100644 index 0000000..213da62 --- /dev/null +++ b/lib/core/data/models/download_license.dart @@ -0,0 +1,67 @@ +// Author: fruit.com.cn + +import 'json_numbers.dart'; + +/// 下载授权与任务进度合并视图,对应 `GET /app/downloads` 的列表项。 +class DownloadLicense { + const DownloadLicense({ + required this.licenseId, + required this.dramaId, + required this.dramaTitle, + required this.episodeId, + required this.episodeNo, + required this.deviceId, + required this.quality, + required this.playUrl, + required this.licenseKey, + required this.status, + required this.grantedAt, + required this.expireAt, + required this.taskStatus, + required this.progressPercent, + required this.downloadedBytes, + required this.totalBytes, + required this.errorMsg, + }); + + final String licenseId; + final String dramaId; + final String dramaTitle; + final String episodeId; + final int episodeNo; + final String deviceId; + final String quality; + final String playUrl; + final String licenseKey; + final String status; + final DateTime? grantedAt; + final DateTime? expireAt; + final String taskStatus; + final int progressPercent; + final int downloadedBytes; + final int totalBytes; + final String errorMsg; + + /// 解析授权响应;所有 ID 与 Long 字段兼容字符串下发。 + factory DownloadLicense.fromJson(Map json) { + return DownloadLicense( + licenseId: (json['licenseId'] ?? '').toString(), + dramaId: (json['dramaId'] ?? '').toString(), + dramaTitle: json['dramaTitle'] as String? ?? '', + episodeId: (json['episodeId'] ?? '').toString(), + episodeNo: jsonToInt(json['episodeNo']), + deviceId: json['deviceId'] as String? ?? '', + quality: json['quality'] as String? ?? '', + playUrl: json['playUrl'] as String? ?? '', + licenseKey: json['licenseKey'] as String? ?? '', + status: json['status'] as String? ?? '', + grantedAt: DateTime.tryParse(json['grantedAt'] as String? ?? ''), + expireAt: DateTime.tryParse(json['expireAt'] as String? ?? ''), + taskStatus: json['taskStatus'] as String? ?? '', + progressPercent: jsonToInt(json['progressPercent']), + downloadedBytes: jsonToInt(json['downloadedBytes']), + totalBytes: jsonToInt(json['totalBytes']), + errorMsg: json['errorMsg'] as String? ?? '', + ); + } +} diff --git a/lib/core/data/models/download_policy.dart b/lib/core/data/models/download_policy.dart new file mode 100644 index 0000000..6c8e46d --- /dev/null +++ b/lib/core/data/models/download_policy.dart @@ -0,0 +1,54 @@ +// Author: fruit.com.cn + +import 'json_numbers.dart'; + +/// 下载策略与当前设备配额,对应 `GET /app/downloads/policy`。 +class DownloadPolicy { + const DownloadPolicy({ + required this.maxPerDevice, + required this.licenseDays, + required this.wifiOnly, + required this.maxQuality, + required this.maxStorageBytes, + required this.used, + required this.remaining, + required this.expirePolicyText, + }); + + final int maxPerDevice; + final int licenseDays; + final bool wifiOnly; + final String maxQuality; + final int maxStorageBytes; + final int used; + final int remaining; + final String expirePolicyText; + + /// 设置更新期间用于本地乐观展示。 + DownloadPolicy copyWith({bool? wifiOnly, String? maxQuality}) { + return DownloadPolicy( + maxPerDevice: maxPerDevice, + licenseDays: licenseDays, + wifiOnly: wifiOnly ?? this.wifiOnly, + maxQuality: maxQuality ?? this.maxQuality, + maxStorageBytes: maxStorageBytes, + used: used, + remaining: remaining, + expirePolicyText: expirePolicyText, + ); + } + + /// 解析策略响应;Long 字段兼容字符串。 + factory DownloadPolicy.fromJson(Map json) { + return DownloadPolicy( + maxPerDevice: jsonToInt(json['maxPerDevice']), + licenseDays: jsonToInt(json['licenseDays']), + wifiOnly: json['wifiOnly'] == true, + maxQuality: json['maxQuality'] as String? ?? '', + maxStorageBytes: jsonToInt(json['maxStorageBytes']), + used: jsonToInt(json['used']), + remaining: jsonToInt(json['remaining']), + expirePolicyText: json['expirePolicyText'] as String? ?? '', + ); + } +} diff --git a/lib/core/data/models/watch_progress.dart b/lib/core/data/models/watch_progress.dart index 1f2d392..3d655ef 100644 --- a/lib/core/data/models/watch_progress.dart +++ b/lib/core/data/models/watch_progress.dart @@ -14,6 +14,7 @@ class WatchProgress { required this.duration, this.finished = false, this.playCount = 0, + this.updatedAt, }); final String dramaId; @@ -22,6 +23,7 @@ class WatchProgress { final Duration duration; final bool finished; final int playCount; + final DateTime? updatedAt; bool get hasPosition => position > Duration.zero; @@ -39,6 +41,7 @@ class WatchProgress { duration: Duration(milliseconds: jsonToInt(json['durationMs'])), finished: json['finished'] == true, playCount: jsonToInt(json['playCount']), + updatedAt: DateTime.tryParse(json['updatedAt'] as String? ?? ''), ); } @@ -49,6 +52,7 @@ class WatchProgress { 'durationMs': duration.inMilliseconds, 'finished': finished, 'playCount': playCount, + if (updatedAt != null) 'updatedAt': updatedAt!.toIso8601String(), }; } diff --git a/lib/core/data/models/watch_record.dart b/lib/core/data/models/watch_record.dart new file mode 100644 index 0000000..954b478 --- /dev/null +++ b/lib/core/data/models/watch_record.dart @@ -0,0 +1,44 @@ +// Author: fruit.com.cn + +import 'drama.dart'; +import 'watch_progress.dart'; + +/// 观看记录页的一条数据:进度记录与按 dramaId 补取的详情卡片。 +class WatchRecord { + const WatchRecord({ + required this.progress, + this.drama, + this.detailLoading = true, + this.detailFailed = false, + }); + + final WatchProgress progress; + final Drama? drama; + final bool detailLoading; + final bool detailFailed; + + String get dramaId => progress.dramaId; + + /// 详情中按 episodeId 定位集号;缺失时返回 0。 + int get episodeNumber { + final episodes = drama?.episodes ?? const []; + for (var index = 0; index < episodes.length; index++) { + if (episodes[index].id == progress.episodeId) return index + 1; + } + return 0; + } + + /// 生成卡片加载中、成功或失败后的新状态。 + WatchRecord copyWith({ + Drama? drama, + bool? detailLoading, + bool? detailFailed, + }) { + return WatchRecord( + progress: progress, + drama: drama ?? this.drama, + detailLoading: detailLoading ?? this.detailLoading, + detailFailed: detailFailed ?? this.detailFailed, + ); + } +} diff --git a/lib/core/data/remote/api_client.dart b/lib/core/data/remote/api_client.dart index 15acde2..906a66d 100644 --- a/lib/core/data/remote/api_client.dart +++ b/lib/core/data/remote/api_client.dart @@ -79,6 +79,21 @@ class ApiClient { ); } + Future put( + String path, { + Object? body, + Map? query, + bool skipAuthRetry = false, + }) { + return _request( + 'PUT', + path, + body: body, + query: query, + skipAuthRetry: skipAuthRetry, + ); + } + Future delete( String path, { Object? body, diff --git a/lib/core/data/remote/category_api.dart b/lib/core/data/remote/category_api.dart new file mode 100644 index 0000000..7c2d324 --- /dev/null +++ b/lib/core/data/remote/category_api.dart @@ -0,0 +1,21 @@ +// Author: fruit.com.cn + +import '../models/content_category.dart'; +import 'api_client.dart'; + +/// 内容分类接口,对应契约 `GET /app/categories`。 +class CategoryApi { + const CategoryApi(this._client); + + final ApiClient _client; + + /// 拉取已启用分类,id 全程按字符串解析。 + Future> list() async { + final data = await _client.get('/app/categories'); + if (data is! List) return const []; + return [ + for (final item in data) + if (item is Map) ContentCategory.fromJson(item), + ]; + } +} diff --git a/lib/core/data/remote/download_api.dart b/lib/core/data/remote/download_api.dart new file mode 100644 index 0000000..ae8e744 --- /dev/null +++ b/lib/core/data/remote/download_api.dart @@ -0,0 +1,101 @@ +// Author: fruit.com.cn + +import '../models/download_license.dart'; +import '../models/download_policy.dart'; +import 'api_client.dart'; + +/// 离线下载授权接口,对应契约 §1.6 的全部 8 个接口。 +/// +/// 设备号由 [ApiClient] 统一通过 `X-Device-Id` 发送,本类不另造设备参数。 +class DownloadApi { + const DownloadApi(this._client); + + final ApiClient _client; + + /// 拉取配额和偏好策略。 + Future policy() async { + return DownloadPolicy.fromJson( + _asMap(await _client.get('/app/downloads/policy')), + ); + } + + /// 更新仅 Wi-Fi 与最高清晰度偏好。 + Future updateSettings({bool? wifiOnly, String? maxQuality}) async { + await _client.put( + '/app/downloads/settings', + body: {'wifiOnly': ?wifiOnly, 'maxQuality': ?maxQuality}, + ); + } + + /// 申请下载授权;同集重复申请由服务端保证幂等。 + Future grant(String episodeId, {String? quality}) async { + return DownloadLicense.fromJson( + _asMap( + await _client.post( + '/app/downloads', + body: {'episodeId': episodeId, 'quality': ?quality}, + ), + ), + ); + } + + /// 拉取当前设备的授权列表。 + Future> list() async { + final data = await _client.get('/app/downloads'); + if (data is! List) return const []; + return [ + for (final item in data) + if (item is Map) DownloadLicense.fromJson(item), + ]; + } + + /// 续传前刷新短时效下载地址。 + Future refreshUrl(String episodeId) async { + return DownloadLicense.fromJson( + _asMap(await _client.get('/app/downloads/$episodeId/url')), + ); + } + + /// 上报下载进度;本批只提供方法,不启动文件落盘。 + Future reportProgress( + String episodeId, { + String? deviceId, + String? status, + int? progressPercent, + int? downloadedBytes, + int? totalBytes, + String? errorMsg, + }) async { + return DownloadLicense.fromJson( + _asMap( + await _client.post( + '/app/downloads/$episodeId/progress', + body: { + 'deviceId': ?deviceId, + 'status': ?status, + 'progressPercent': ?progressPercent, + 'downloadedBytes': ?downloadedBytes, + 'totalBytes': ?totalBytes, + 'errorMsg': ?errorMsg, + }, + ), + ), + ); + } + + /// 吊销单集授权。 + Future remove(String episodeId) async { + await _client.delete('/app/downloads/$episodeId'); + } + + /// 清空当前设备授权并返回清除条数。 + Future clear() async { + final data = await _client.delete('/app/downloads'); + return data is int ? data : 0; + } + + Map _asMap(Object? data) { + if (data is Map) return data; + throw const ApiException(-1, ''); + } +} diff --git a/lib/core/data/remote/watch_api.dart b/lib/core/data/remote/watch_api.dart index f09ea90..f57d7fb 100644 --- a/lib/core/data/remote/watch_api.dart +++ b/lib/core/data/remote/watch_api.dart @@ -56,4 +56,9 @@ class WatchApi { Future removeProgress(String dramaId) async { await _client.delete('/app/watch/progress/$dramaId'); } + + /// 清空当前账号的全部观看记录。 + Future clearProgress() async { + await _client.delete('/app/watch/progress'); + } } diff --git a/lib/core/data/repositories/category_repository.dart b/lib/core/data/repositories/category_repository.dart new file mode 100644 index 0000000..39b6a11 --- /dev/null +++ b/lib/core/data/repositories/category_repository.dart @@ -0,0 +1,30 @@ +// Author: fruit.com.cn + +import '../models/content_category.dart'; +import '../models/home_feed.dart'; +import '../remote/category_api.dart'; +import 'catalog_repository.dart'; + +/// 发现页分类数据来源:分类清单与发现 feed。 +abstract interface class CategoryRepository { + /// 拉取服务端分类。 + Future> fetchCategories(); + + /// 拉取发现页分区;分类内容只从这里读取。 + Future fetchDiscoverFeed(); +} + +/// HTTP 实现。发现 feed 复用既有目录仓库,不新增接口。 +class HttpCategoryRepository implements CategoryRepository { + const HttpCategoryRepository(this._categoryApi, this._catalogRepository); + + final CategoryApi _categoryApi; + final CatalogRepository _catalogRepository; + + @override + Future> fetchCategories() => _categoryApi.list(); + + @override + Future fetchDiscoverFeed() => + _catalogRepository.fetchDiscoverFeed(); +} diff --git a/lib/core/data/repositories/download_repository.dart b/lib/core/data/repositories/download_repository.dart new file mode 100644 index 0000000..21263fc --- /dev/null +++ b/lib/core/data/repositories/download_repository.dart @@ -0,0 +1,82 @@ +// Author: fruit.com.cn + +import '../models/download_license.dart'; +import '../models/download_policy.dart'; +import '../remote/download_api.dart'; + +/// 下载授权数据来源,页面只依赖该抽象。 +abstract interface class DownloadRepository { + Future fetchPolicy(); + + Future> list(); + + Future grant(String episodeId, {String? quality}); + + Future updateSettings({bool? wifiOnly, String? maxQuality}); + + Future refreshUrl(String episodeId); + + Future reportProgress( + String episodeId, { + String? deviceId, + String? status, + int? progressPercent, + int? downloadedBytes, + int? totalBytes, + String? errorMsg, + }); + + Future remove(String episodeId); + + Future clear(); +} + +/// HTTP 下载授权仓库。 +class HttpDownloadRepository implements DownloadRepository { + const HttpDownloadRepository(this._api); + + final DownloadApi _api; + + @override + Future fetchPolicy() => _api.policy(); + + @override + Future> list() => _api.list(); + + @override + Future grant(String episodeId, {String? quality}) => + _api.grant(episodeId, quality: quality); + + @override + Future updateSettings({bool? wifiOnly, String? maxQuality}) => + _api.updateSettings(wifiOnly: wifiOnly, maxQuality: maxQuality); + + @override + Future refreshUrl(String episodeId) => + _api.refreshUrl(episodeId); + + @override + Future reportProgress( + String episodeId, { + String? deviceId, + String? status, + int? progressPercent, + int? downloadedBytes, + int? totalBytes, + String? errorMsg, + }) => _api.reportProgress( + episodeId, + deviceId: deviceId, + status: status, + progressPercent: progressPercent, + downloadedBytes: downloadedBytes, + totalBytes: totalBytes, + errorMsg: errorMsg, + ); + + @override + Future remove(String episodeId) => _api.remove(episodeId); + + @override + Future clear() => _api.clear(); +} diff --git a/lib/core/data/repositories/favorite_repository.dart b/lib/core/data/repositories/favorite_repository.dart index 1123505..1329adf 100644 --- a/lib/core/data/repositories/favorite_repository.dart +++ b/lib/core/data/repositories/favorite_repository.dart @@ -47,7 +47,9 @@ class InMemoryFavoriteRepository implements FavoriteRepository { final List _cards; bool failToggle = false; bool failList = false; + bool failRemove = false; int toggleCalls = 0; + int listCalls = 0; @override Future toggle(String dramaId) async { @@ -59,10 +61,14 @@ class InMemoryFavoriteRepository implements FavoriteRepository { @override Future> list() async { + listCalls++; if (failList) throw StateError('favorite unavailable'); return _cards.where((card) => _saved.contains(card.id)).toList(); } @override - Future remove(String dramaId) async => _saved.remove(dramaId); + Future remove(String dramaId) async { + if (failRemove) throw StateError('favorite unavailable'); + _saved.remove(dramaId); + } } diff --git a/lib/core/data/repositories/watch_history_repository.dart b/lib/core/data/repositories/watch_history_repository.dart index 7b5e79b..fb4a9dd 100644 --- a/lib/core/data/repositories/watch_history_repository.dart +++ b/lib/core/data/repositories/watch_history_repository.dart @@ -25,6 +25,9 @@ abstract interface class WatchHistoryRepository { /// 清理某部剧的记录(K2 的记录页会用,这里先备好)。 Future remove(String dramaId); + + /// 清空当前账号的全部观看记录。 + Future clear(); } class HttpWatchHistoryRepository implements WatchHistoryRepository { @@ -70,12 +73,20 @@ class HttpWatchHistoryRepository implements WatchHistoryRepository { if (!_signedIn) return; await _api.removeProgress(dramaId); } + + @override + Future clear() async { + if (!_signedIn) return; + await _api.clearProgress(); + } } /// 内存实现:单测与 widget 测试注入用(不依赖网络与偏好存储)。 class InMemoryWatchHistoryRepository implements WatchHistoryRepository { InMemoryWatchHistoryRepository({List? seed}) - : _records = {for (final item in seed ?? const []) item.dramaId: item}; + : _records = { + for (final item in seed ?? const []) item.dramaId: item, + }; final Map _records; int failReads = 0; @@ -122,6 +133,9 @@ class InMemoryWatchHistoryRepository implements WatchHistoryRepository { @override Future remove(String dramaId) async => _records.remove(dramaId); + + @override + Future clear() async => _records.clear(); } /// 续看点辅助:把服务端记录换算成"第几集 + 从哪一秒开始"。 diff --git a/lib/core/data/services/category_controller.dart b/lib/core/data/services/category_controller.dart new file mode 100644 index 0000000..efeada2 --- /dev/null +++ b/lib/core/data/services/category_controller.dart @@ -0,0 +1,82 @@ +// Author: fruit.com.cn + +import 'package:flutter/foundation.dart'; + +import '../models/content_category.dart'; +import '../models/drama.dart'; +import '../models/home_feed.dart'; +import '../repositories/category_repository.dart'; + +/// 发现页分类状态:服务端分类清单、发现 feed 与当前筛选。 +class CategoryController extends ChangeNotifier { + CategoryController(this._repository); + + static const String allCode = 'all'; + static const String hotCode = 'hot'; + static const String newCode = 'new'; + + final CategoryRepository _repository; + + List categories = const []; + HomeFeed feed = const HomeFeed(); + String selectedCode = allCode; + bool loading = false; + String? error; + bool _disposed = false; + + /// 当前筛选对应的分区 code;全部分类为空字符串语义。 + bool get selectedSectionMissing => + selectedCode != allCode && _selectedSection == null; + + /// 当前筛选应展示的剧集;全部分类按 feed 顺序去重。 + List get visibleDramas { + if (selectedCode == allCode) return feed.dramas; + return _selectedSection?.dramas ?? const []; + } + + FeedSection? get _selectedSection { + for (final section in feed.sections) { + if (section.code == selectedCode) return section; + } + return null; + } + + /// 加载分类与发现 feed;失败保留可重试错误态。 + Future load() async { + loading = true; + error = null; + _notify(); + try { + final results = await Future.wait([ + _repository.fetchCategories(), + _repository.fetchDiscoverFeed(), + ]); + categories = results[0] as List; + feed = results[1] as HomeFeed; + } catch (_) { + error = 'categoriesError'; + } finally { + loading = false; + _notify(); + } + } + + /// 选择服务端分类,内容只匹配 `category-{id}`。 + void selectCategory(String id) => selectCode('category-$id'); + + /// 选择内置或分区 code。 + void selectCode(String code) { + selectedCode = code; + _notify(); + } + + void _notify() { + if (!_disposed) notifyListeners(); + } + + @override + void dispose() { + _disposed = true; + super.dispose(); + } +} diff --git a/lib/core/data/services/download_controller.dart b/lib/core/data/services/download_controller.dart new file mode 100644 index 0000000..1e38ef8 --- /dev/null +++ b/lib/core/data/services/download_controller.dart @@ -0,0 +1,168 @@ +// Author: fruit.com.cn + +import 'package:flutter/foundation.dart'; + +import '../models/download_license.dart'; +import '../models/download_policy.dart'; +import '../remote/api_exception.dart'; +import '../repositories/download_repository.dart'; + +/// 一次下载授权申请的结果;后端业务拒绝时保留原始 message。 +class DownloadActionResult { + const DownloadActionResult({required this.ok, this.license, this.message}); + + final bool ok; + final DownloadLicense? license; + final String? message; +} + +/// 下载授权与策略状态。 +class DownloadController extends ChangeNotifier { + DownloadController(this._repository); + + final DownloadRepository _repository; + + DownloadPolicy? policy; + List licenses = const []; + bool loading = false; + bool clearing = false; + String? error; + String? actionError; + bool _disposed = false; + + /// 同时拉取策略与当前设备授权列表。 + Future load() async { + loading = true; + error = null; + _notify(); + try { + final results = await Future.wait([ + _repository.fetchPolicy(), + _repository.list(), + ]); + policy = results[0] as DownloadPolicy; + licenses = results[1] as List; + } catch (_) { + error = 'downloadsError'; + } finally { + loading = false; + _notify(); + } + } + + /// 申请授权;付费、未解锁、配额满等判定完全以后端 message 为准。 + Future grant( + String episodeId, { + String? quality, + }) async { + try { + final license = await _repository.grant(episodeId, quality: quality); + licenses = [ + license, + for (final item in licenses) + if (item.episodeId != license.episodeId) item, + ]; + actionError = null; + _notify(); + return DownloadActionResult(ok: true, license: license); + } on ApiException catch (exception) { + actionError = exception.message; + _notify(); + return DownloadActionResult(ok: false, message: exception.message); + } catch (_) { + actionError = 'downloadGrantFailed'; + _notify(); + return const DownloadActionResult(ok: false); + } + } + + /// 更新设置,先本地展示,失败恢复服务端旧值。 + Future updateSettings({bool? wifiOnly, String? maxQuality}) async { + final previous = policy; + if (previous != null) { + policy = previous.copyWith(wifiOnly: wifiOnly, maxQuality: maxQuality); + _notify(); + } + try { + await _repository.updateSettings( + wifiOnly: wifiOnly, + maxQuality: maxQuality, + ); + actionError = null; + return true; + } catch (_) { + policy = previous; + actionError = 'downloadSettingsFailed'; + return false; + } finally { + _notify(); + } + } + + /// 删除单条授权,失败按原位置恢复。 + Future remove(String episodeId) async { + final index = licenses.indexWhere((item) => item.episodeId == episodeId); + if (index < 0) return true; + final removed = licenses[index]; + licenses = [...licenses]..removeAt(index); + actionError = null; + _notify(); + try { + await _repository.remove(episodeId); + return true; + } catch (_) { + final restored = [...licenses]; + restored.insert( + index > restored.length ? restored.length : index, + removed, + ); + licenses = restored; + actionError = 'downloadDeleteFailed'; + return false; + } finally { + _notify(); + } + } + + /// 清空授权,失败恢复原列表。 + Future clear() async { + if (licenses.isEmpty) return true; + final previous = licenses; + licenses = const []; + clearing = true; + actionError = null; + _notify(); + try { + await _repository.clear(); + return true; + } catch (_) { + licenses = previous; + actionError = 'downloadClearFailed'; + return false; + } finally { + clearing = false; + _notify(); + } + } + + /// 退出登录时清空账号相关状态,避免跨账号串联。 + void reset() { + policy = null; + licenses = const []; + loading = false; + clearing = false; + error = null; + actionError = null; + _notify(); + } + + void _notify() { + if (!_disposed) notifyListeners(); + } + + @override + void dispose() { + _disposed = true; + super.dispose(); + } +} diff --git a/lib/core/data/services/favorite_controller.dart b/lib/core/data/services/favorite_controller.dart index 64c1ab1..4b9e4b1 100644 --- a/lib/core/data/services/favorite_controller.dart +++ b/lib/core/data/services/favorite_controller.dart @@ -88,24 +88,23 @@ class FavoriteController extends ChangeNotifier { /// 取消收藏("我的"页列表里删除某条)。 Future remove(String dramaId) async { - final removed = cards.firstWhere( - (drama) => drama.id == dramaId, - orElse: () => const Drama( - id: '', - title: '', - synopsis: '', - posterUrl: '', - ), - ); - final hadCard = removed.id.isNotEmpty; + final index = cards.indexWhere((drama) => drama.id == dramaId); + if (index < 0) return true; + final removed = cards[index]; _saved.remove(dramaId); - cards = cards.where((drama) => drama.id != dramaId).toList(); + final next = [...cards]..removeAt(index); + cards = next; notify(); try { await _repository.remove(dramaId); return true; } catch (_) { - if (hadCard) cards = [...cards, removed]; + final restored = [...cards]; + restored.insert( + index > restored.length ? restored.length : index, + removed, + ); + cards = restored; _saved.add(dramaId); notify(); return false; diff --git a/lib/core/data/services/watch_records_controller.dart b/lib/core/data/services/watch_records_controller.dart new file mode 100644 index 0000000..647d7fa --- /dev/null +++ b/lib/core/data/services/watch_records_controller.dart @@ -0,0 +1,205 @@ +// Author: fruit.com.cn + +import 'package:flutter/foundation.dart'; + +import '../models/drama.dart'; +import '../models/watch_progress.dart'; +import '../models/watch_record.dart'; +import '../repositories/catalog_repository.dart'; +import '../repositories/watch_history_repository.dart'; + +/// 独立观看记录页状态。 +/// +/// 最近记录只下发 dramaId;详情按 dramaId 去重后补取,并以 4 个并发为上限。 +class WatchRecordsController extends ChangeNotifier { + factory WatchRecordsController({ + required WatchHistoryRepository history, + required CatalogRepository catalog, + int limit = defaultLimit, + }) => WatchRecordsController._(history, catalog, limit); + + WatchRecordsController._(this._history, this._catalog, this.limit); + + static const int defaultLimit = 20; + static const int detailConcurrency = 4; + + final WatchHistoryRepository _history; + final CatalogRepository _catalog; + final int limit; + final Map _detailCache = {}; + + List records = const []; + bool loading = false; + bool clearing = false; + String? error; + String? actionError; + bool _disposed = false; + + /// 加载最近记录并补齐详情;单条详情失败不拖垮整页。 + Future load() async { + loading = true; + error = null; + actionError = null; + _notify(); + try { + final recent = await _history.recent(limit: limit); + if (_disposed) return; + records = _uniqueRecords(recent); + _notify(); + await _hydrate(records.map((record) => record.dramaId).toList()); + } catch (_) { + if (!_disposed) error = 'progressError'; + } finally { + if (!_disposed) { + loading = false; + _notify(); + } + } + } + + /// 只重试一条详情失败记录。 + Future retryDetail(String dramaId) async { + final index = _recordIndex(dramaId); + if (index < 0) return; + _replaceAt( + index, + records[index].copyWith(detailLoading: true, detailFailed: false), + ); + _notify(); + await _loadDetail(dramaId); + _notify(); + } + + /// 删除单条记录,先更新 UI,失败按原位置回滚。 + Future remove(String dramaId) async { + final index = _recordIndex(dramaId); + if (index < 0) return true; + final removed = records[index]; + records = [...records]..removeAt(index); + actionError = null; + _notify(); + try { + await _history.remove(dramaId); + return true; + } catch (_) { + final next = [...records]; + next.insert(index > next.length ? next.length : index, removed); + records = next; + actionError = 'recordDeleteFailed'; + return false; + } finally { + _notify(); + } + } + + /// 清空全部记录,先更新 UI,失败恢复原列表。 + Future clear() async { + if (records.isEmpty) return true; + final previous = records; + records = const []; + clearing = true; + actionError = null; + _notify(); + try { + await _history.clear(); + return true; + } catch (_) { + records = previous; + actionError = 'recordClearFailed'; + return false; + } finally { + clearing = false; + _notify(); + } + } + + List _uniqueRecords(List recent) { + final seen = {}; + return [ + for (final progress in recent) + if (seen.add(progress.dramaId)) WatchRecord(progress: progress), + ]; + } + + Future _hydrate(List dramaIds) async { + final queue = [ + for (final id in dramaIds) + if (!_detailCache.containsKey(id)) id, + ]; + final workerCount = queue.length < detailConcurrency + ? queue.length + : detailConcurrency; + Future worker() async { + while (queue.isNotEmpty && !_disposed) { + await _loadDetail(queue.removeAt(0)); + } + } + + await Future.wait([ + for (var index = 0; index < workerCount; index++) worker(), + ]); + } + + Future _loadDetail(String dramaId) async { + final index = _recordIndex(dramaId); + if (index < 0) return; + final cached = _detailCache[dramaId]; + if (cached != null) { + _replaceAt( + index, + records[index].copyWith( + drama: cached, + detailLoading: false, + detailFailed: false, + ), + ); + return; + } + try { + final detail = await _catalog.fetchDrama(dramaId); + if (_disposed) return; + _detailCache[dramaId] = detail; + final current = _recordIndex(dramaId); + if (current < 0) return; + _replaceAt( + current, + records[current].copyWith( + drama: detail, + detailLoading: false, + detailFailed: false, + ), + ); + } catch (_) { + if (_disposed) return; + final current = _recordIndex(dramaId); + if (current < 0) return; + _replaceAt( + current, + records[current].copyWith(detailLoading: false, detailFailed: true), + ); + } + } + + int _recordIndex(String dramaId) { + for (var index = 0; index < records.length; index++) { + if (records[index].dramaId == dramaId) return index; + } + return -1; + } + + void _replaceAt(int index, WatchRecord record) { + final next = [...records]; + next[index] = record; + records = next; + } + + void _notify() { + if (!_disposed) notifyListeners(); + } + + @override + void dispose() { + _disposed = true; + super.dispose(); + } +} diff --git a/lib/core/widgets/auth_gate.dart b/lib/core/widgets/auth_gate.dart index 2e07000..6d5e079 100644 --- a/lib/core/widgets/auth_gate.dart +++ b/lib/core/widgets/auth_gate.dart @@ -9,9 +9,7 @@ import '../theme/app_colors.dart'; /// 打开登录 / 注册页(沿用现有 Navigator 风格,不引路由库) Future openAuthPage(BuildContext context, {bool signUpMode = false}) { return Navigator.of(context).push( - MaterialPageRoute( - builder: (_) => AuthPage(signUpMode: signUpMode), - ), + MaterialPageRoute(builder: (_) => AuthPage(signUpMode: signUpMode)), ); } @@ -81,3 +79,44 @@ Future ensureSignedIn(BuildContext context) async { } return false; } + +/// 页面级登录引导,用于记录、收藏和下载等必须登录的独立页面。 +class AuthGatePanel extends StatelessWidget { + const AuthGatePanel({super.key}); + + @override + Widget build(BuildContext context) { + final l10n = AppLocalizations.of(context)!; + return Center( + key: const Key('auth-gate-panel'), + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 32), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Text( + l10n.authGateTitle, + textAlign: TextAlign.center, + style: const TextStyle( + color: Colors.white, + fontSize: 18, + fontWeight: FontWeight.w800, + ), + ), + const SizedBox(height: 8), + Text( + l10n.authGateMessage, + textAlign: TextAlign.center, + style: const TextStyle(color: AppColors.muted, fontSize: 13), + ), + const SizedBox(height: 18), + FilledButton( + onPressed: () => openAuthPage(context), + child: Text(l10n.authGateAction), + ), + ], + ), + ), + ); + } +} diff --git a/lib/core/widgets/download_action.dart b/lib/core/widgets/download_action.dart new file mode 100644 index 0000000..6c3a356 --- /dev/null +++ b/lib/core/widgets/download_action.dart @@ -0,0 +1,29 @@ +// Author: fruit.com.cn + +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; + +import '../../l10n/app_localizations.dart'; +import '../data/services/download_controller.dart'; +import 'auth_gate.dart'; + +/// 详情页与播放页共用的下载授权入口。 +/// +/// 未登录先走登录闸;业务拒绝时直接展示后端 message。 +Future requestEpisodeDownload( + BuildContext context, + String episodeId, +) async { + if (!await ensureSignedIn(context)) return; + if (!context.mounted) return; + final result = await context.read().grant(episodeId); + if (!context.mounted) return; + final l10n = AppLocalizations.of(context)!; + final hasBackendMessage = result.message?.trim().isNotEmpty ?? false; + final message = result.ok + ? l10n.downloadGranted + : hasBackendMessage + ? result.message! + : l10n.downloadGrantFailed; + ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text(message))); +} diff --git a/lib/core/widgets/library_drama_tile.dart b/lib/core/widgets/library_drama_tile.dart new file mode 100644 index 0000000..b273fc3 --- /dev/null +++ b/lib/core/widgets/library_drama_tile.dart @@ -0,0 +1,73 @@ +// Author: fruit.com.cn + +import 'package:flutter/material.dart'; + +import '../data/models/drama.dart'; +import '../theme/app_colors.dart'; +import 'remote_image.dart'; + +/// 收藏等账号列表复用的剧集卡片,视觉与"我的"页列表保持一致。 +class LibraryDramaTile extends StatelessWidget { + const LibraryDramaTile({ + super.key, + required this.drama, + required this.onTap, + this.trailing, + }); + + final Drama drama; + final VoidCallback? onTap; + final Widget? trailing; + + @override + Widget build(BuildContext context) { + return Material( + color: const Color(0xFF1B1C21), + borderRadius: BorderRadius.circular(12), + clipBehavior: Clip.antiAlias, + child: InkWell( + onTap: onTap, + child: Padding( + padding: const EdgeInsets.all(9), + child: Row( + children: [ + ClipRRect( + borderRadius: BorderRadius.circular(8), + child: RemoteImage(drama.posterUrl, width: 74, height: 103), + ), + const SizedBox(width: 11), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + drama.title, + maxLines: 2, + overflow: TextOverflow.ellipsis, + style: const TextStyle( + color: Colors.white, + fontSize: 15, + fontWeight: FontWeight.w700, + ), + ), + const SizedBox(height: 7), + Text( + drama.genre.isEmpty ? drama.category : drama.genre, + maxLines: 1, + overflow: TextOverflow.ellipsis, + style: const TextStyle( + color: AppColors.muted, + fontSize: 12, + ), + ), + ], + ), + ), + ?trailing, + ], + ), + ), + ), + ); + } +} diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index 4fa0f67..8b04bf3 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -141,6 +141,7 @@ "lockedBody": "Unlocking will be available after store and verification setup. This demo does not process payments.", "playbackError": "This clip could not be played.", "catalogError": "The catalog could not be loaded.", + "categoriesError": "Categories could not be loaded.", "detailError": "The episode list could not be loaded.", "noMediaNotice": "This episode has no playable media yet.", "noStories": "No stories available yet.", @@ -223,7 +224,7 @@ "authSwitchToSignUp": "New here? Create an account", "authSwitchToSignIn": "Already have an account? Sign in", "authGateTitle": "Sign in to continue", - "authGateMessage": "Favorites and comments need an account.", + "authGateMessage": "Watch history, favorites, comments and downloads need an account.", "authGateAction": "Sign In", "cancel": "Not now", "noEpisodesYet": "No playable episodes yet.", @@ -231,6 +232,82 @@ "progressError": "Your watch position could not be loaded.", "favoritesError": "Your favorites could not be loaded.", "favoriteToggleFailed": "Could not update favorites. Please retry.", + "myFavorites": "My favorites", + "noFavorites": "No favorites yet.", + "downloads": "Downloads", + "downloadsError": "Download settings could not be loaded.", + "noDownloads": "No download authorizations yet.", + "downloadedItems": "Download authorizations", + "downloadQuota": "{remaining} of {max} authorizations available", + "@downloadQuota": { + "placeholders": { + "remaining": { + "type": "int" + }, + "max": { + "type": "int" + } + } + }, + "downloadLicenseDays": "Authorization valid for {days} days", + "@downloadLicenseDays": { + "placeholders": { + "days": { + "type": "int" + } + } + }, + "downloadWifiOnly": "Wi-Fi only", + "downloadQuality": "Maximum quality", + "downloadStatus": "Authorization: {status}", + "@downloadStatus": { + "placeholders": { + "status": {} + } + }, + "downloadTaskStatus": "Task: {status}", + "@downloadTaskStatus": { + "placeholders": { + "status": {} + } + }, + "downloadProgress": "{progress}%", + "@downloadProgress": { + "placeholders": { + "progress": { + "type": "int" + } + } + }, + "downloadExpiresAt": "Expires {time}", + "@downloadExpiresAt": { + "placeholders": { + "time": {} + } + }, + "clearDownloadsTitle": "Clear download authorizations?", + "clearDownloadsMessage": "This revokes every download authorization for this device.", + "downloadSettingsFailed": "Could not update download settings.", + "downloadDeleteFailed": "Could not remove this download authorization.", + "downloadClearFailed": "Could not clear download authorizations.", + "downloadGrantFailed": "Could not request this download.", + "downloadGranted": "Download authorization is ready.", + "noWatchRecords": "No watch history yet.", + "recordDeleteFailed": "Could not delete this record. Please retry.", + "recordClearFailed": "Could not clear watch history. Please retry.", + "clearAll": "Clear all", + "clearWatchHistoryTitle": "Clear watch history?", + "clearWatchHistoryMessage": "This removes the watch history from your account.", + "confirmClear": "Clear", + "detailLoadFailed": "Details failed to load", + "retryDetail": "Retry", + "episodeUnavailable": "Episode unavailable", + "updatedAtLabel": "Updated {time}", + "@updatedAtLabel": { + "placeholders": { + "time": {} + } + }, "remove": "Remove", "unlockComingSoon": "Unlocking with coins is coming soon.", "resumeProgress": "Resume at {position} / {total}", diff --git a/lib/l10n/app_id.arb b/lib/l10n/app_id.arb index 023a9e4..1c41600 100644 --- a/lib/l10n/app_id.arb +++ b/lib/l10n/app_id.arb @@ -141,6 +141,7 @@ "lockedBody": "Pembukaan kunci tersedia setelah toko dan verifikasi disiapkan. Demo ini tidak memproses pembayaran.", "playbackError": "Klip ini tidak bisa diputar.", "catalogError": "Katalog gagal dimuat.", + "categoriesError": "Kategori gagal dimuat.", "detailError": "Daftar episode gagal dimuat.", "noMediaNotice": "Episode ini belum punya media yang bisa diputar.", "noStories": "Belum ada cerita.", @@ -223,7 +224,7 @@ "authSwitchToSignUp": "Baru di sini? Buat akun", "authSwitchToSignIn": "Sudah punya akun? Masuk", "authGateTitle": "Masuk untuk melanjutkan", - "authGateMessage": "Favorit dan komentar perlu akun.", + "authGateMessage": "Riwayat tontonan, favorit, komentar, dan unduhan perlu akun.", "authGateAction": "Masuk", "cancel": "Nanti saja", "noEpisodesYet": "Belum ada episode yang bisa diputar.", @@ -231,6 +232,82 @@ "progressError": "Posisi tonton gagal dimuat.", "favoritesError": "Daftar favorit gagal dimuat.", "favoriteToggleFailed": "Gagal memperbarui favorit. Coba lagi.", + "myFavorites": "Favorit saya", + "noFavorites": "Belum ada favorit.", + "downloads": "Unduhan", + "downloadsError": "Pengaturan unduhan gagal dimuat.", + "noDownloads": "Belum ada izin unduhan.", + "downloadedItems": "Izin unduhan", + "downloadQuota": "{remaining} dari {max} izin tersedia", + "@downloadQuota": { + "placeholders": { + "remaining": { + "type": "int" + }, + "max": { + "type": "int" + } + } + }, + "downloadLicenseDays": "Izin berlaku {days} hari", + "@downloadLicenseDays": { + "placeholders": { + "days": { + "type": "int" + } + } + }, + "downloadWifiOnly": "Hanya Wi-Fi", + "downloadQuality": "Kualitas maksimum", + "downloadStatus": "Izin: {status}", + "@downloadStatus": { + "placeholders": { + "status": {} + } + }, + "downloadTaskStatus": "Tugas: {status}", + "@downloadTaskStatus": { + "placeholders": { + "status": {} + } + }, + "downloadProgress": "{progress}%", + "@downloadProgress": { + "placeholders": { + "progress": { + "type": "int" + } + } + }, + "downloadExpiresAt": "Berakhir {time}", + "@downloadExpiresAt": { + "placeholders": { + "time": {} + } + }, + "clearDownloadsTitle": "Hapus izin unduhan?", + "clearDownloadsMessage": "Semua izin unduhan untuk perangkat ini akan dicabut.", + "downloadSettingsFailed": "Gagal memperbarui pengaturan unduhan.", + "downloadDeleteFailed": "Gagal menghapus izin unduhan ini.", + "downloadClearFailed": "Gagal menghapus semua izin unduhan.", + "downloadGrantFailed": "Gagal meminta unduhan ini.", + "downloadGranted": "Izin unduhan sudah siap.", + "noWatchRecords": "Belum ada riwayat tontonan.", + "recordDeleteFailed": "Gagal menghapus riwayat ini. Coba lagi.", + "recordClearFailed": "Gagal menghapus semua riwayat. Coba lagi.", + "clearAll": "Hapus semua", + "clearWatchHistoryTitle": "Hapus riwayat tontonan?", + "clearWatchHistoryMessage": "Semua riwayat akan dihapus dari akun kamu.", + "confirmClear": "Hapus", + "detailLoadFailed": "Detail drama gagal dimuat", + "retryDetail": "Coba lagi", + "episodeUnavailable": "Episode tidak tersedia", + "updatedAtLabel": "Diperbarui {time}", + "@updatedAtLabel": { + "placeholders": { + "time": {} + } + }, "remove": "Hapus", "unlockComingSoon": "Pembukaan dengan koin segera hadir.", "resumeProgress": "Lanjut di {position} / {total}", diff --git a/lib/l10n/app_localizations.dart b/lib/l10n/app_localizations.dart index 14c2523..54911ab 100644 --- a/lib/l10n/app_localizations.dart +++ b/lib/l10n/app_localizations.dart @@ -1,5 +1,3 @@ -// Author: fruit.com.cn - import 'dart:async'; import 'package:flutter/foundation.dart'; @@ -636,6 +634,12 @@ abstract class AppLocalizations { /// **'The catalog could not be loaded.'** String get catalogError; + /// No description provided for @categoriesError. + /// + /// In en, this message translates to: + /// **'Categories could not be loaded.'** + String get categoriesError; + /// No description provided for @detailError. /// /// In en, this message translates to: @@ -1131,7 +1135,7 @@ abstract class AppLocalizations { /// No description provided for @authGateMessage. /// /// In en, this message translates to: - /// **'Favorites and comments need an account.'** + /// **'Watch history, favorites, comments and downloads need an account.'** String get authGateMessage; /// No description provided for @authGateAction. @@ -1176,6 +1180,198 @@ abstract class AppLocalizations { /// **'Could not update favorites. Please retry.'** String get favoriteToggleFailed; + /// No description provided for @myFavorites. + /// + /// In en, this message translates to: + /// **'My favorites'** + String get myFavorites; + + /// No description provided for @noFavorites. + /// + /// In en, this message translates to: + /// **'No favorites yet.'** + String get noFavorites; + + /// No description provided for @downloads. + /// + /// In en, this message translates to: + /// **'Downloads'** + String get downloads; + + /// No description provided for @downloadsError. + /// + /// In en, this message translates to: + /// **'Download settings could not be loaded.'** + String get downloadsError; + + /// No description provided for @noDownloads. + /// + /// In en, this message translates to: + /// **'No download authorizations yet.'** + String get noDownloads; + + /// No description provided for @downloadedItems. + /// + /// In en, this message translates to: + /// **'Download authorizations'** + String get downloadedItems; + + /// No description provided for @downloadQuota. + /// + /// In en, this message translates to: + /// **'{remaining} of {max} authorizations available'** + String downloadQuota(int remaining, int max); + + /// No description provided for @downloadLicenseDays. + /// + /// In en, this message translates to: + /// **'Authorization valid for {days} days'** + String downloadLicenseDays(int days); + + /// No description provided for @downloadWifiOnly. + /// + /// In en, this message translates to: + /// **'Wi-Fi only'** + String get downloadWifiOnly; + + /// No description provided for @downloadQuality. + /// + /// In en, this message translates to: + /// **'Maximum quality'** + String get downloadQuality; + + /// No description provided for @downloadStatus. + /// + /// In en, this message translates to: + /// **'Authorization: {status}'** + String downloadStatus(Object status); + + /// No description provided for @downloadTaskStatus. + /// + /// In en, this message translates to: + /// **'Task: {status}'** + String downloadTaskStatus(Object status); + + /// No description provided for @downloadProgress. + /// + /// In en, this message translates to: + /// **'{progress}%'** + String downloadProgress(int progress); + + /// No description provided for @downloadExpiresAt. + /// + /// In en, this message translates to: + /// **'Expires {time}'** + String downloadExpiresAt(Object time); + + /// No description provided for @clearDownloadsTitle. + /// + /// In en, this message translates to: + /// **'Clear download authorizations?'** + String get clearDownloadsTitle; + + /// No description provided for @clearDownloadsMessage. + /// + /// In en, this message translates to: + /// **'This revokes every download authorization for this device.'** + String get clearDownloadsMessage; + + /// No description provided for @downloadSettingsFailed. + /// + /// In en, this message translates to: + /// **'Could not update download settings.'** + String get downloadSettingsFailed; + + /// No description provided for @downloadDeleteFailed. + /// + /// In en, this message translates to: + /// **'Could not remove this download authorization.'** + String get downloadDeleteFailed; + + /// No description provided for @downloadClearFailed. + /// + /// In en, this message translates to: + /// **'Could not clear download authorizations.'** + String get downloadClearFailed; + + /// No description provided for @downloadGrantFailed. + /// + /// In en, this message translates to: + /// **'Could not request this download.'** + String get downloadGrantFailed; + + /// No description provided for @downloadGranted. + /// + /// In en, this message translates to: + /// **'Download authorization is ready.'** + String get downloadGranted; + + /// No description provided for @noWatchRecords. + /// + /// In en, this message translates to: + /// **'No watch history yet.'** + String get noWatchRecords; + + /// No description provided for @recordDeleteFailed. + /// + /// In en, this message translates to: + /// **'Could not delete this record. Please retry.'** + String get recordDeleteFailed; + + /// No description provided for @recordClearFailed. + /// + /// In en, this message translates to: + /// **'Could not clear watch history. Please retry.'** + String get recordClearFailed; + + /// No description provided for @clearAll. + /// + /// In en, this message translates to: + /// **'Clear all'** + String get clearAll; + + /// No description provided for @clearWatchHistoryTitle. + /// + /// In en, this message translates to: + /// **'Clear watch history?'** + String get clearWatchHistoryTitle; + + /// No description provided for @clearWatchHistoryMessage. + /// + /// In en, this message translates to: + /// **'This removes the watch history from your account.'** + String get clearWatchHistoryMessage; + + /// No description provided for @confirmClear. + /// + /// In en, this message translates to: + /// **'Clear'** + String get confirmClear; + + /// No description provided for @detailLoadFailed. + /// + /// In en, this message translates to: + /// **'Details failed to load'** + String get detailLoadFailed; + + /// No description provided for @retryDetail. + /// + /// In en, this message translates to: + /// **'Retry'** + String get retryDetail; + + /// No description provided for @episodeUnavailable. + /// + /// In en, this message translates to: + /// **'Episode unavailable'** + String get episodeUnavailable; + + /// No description provided for @updatedAtLabel. + /// + /// In en, this message translates to: + /// **'Updated {time}'** + String updatedAtLabel(Object time); + /// No description provided for @remove. /// /// In en, this message translates to: diff --git a/lib/l10n/app_localizations_en.dart b/lib/l10n/app_localizations_en.dart index f7e0baf..b4e2e65 100644 --- a/lib/l10n/app_localizations_en.dart +++ b/lib/l10n/app_localizations_en.dart @@ -1,5 +1,3 @@ -// Author: fruit.com.cn - // ignore: unused_import import 'package:intl/intl.dart' as intl; import 'app_localizations.dart'; @@ -296,6 +294,9 @@ class AppLocalizationsEn extends AppLocalizations { @override String get catalogError => 'The catalog could not be loaded.'; + @override + String get categoriesError => 'Categories could not be loaded.'; + @override String get detailError => 'The episode list could not be loaded.'; @@ -546,7 +547,8 @@ class AppLocalizationsEn extends AppLocalizations { String get authGateTitle => 'Sign in to continue'; @override - String get authGateMessage => 'Favorites and comments need an account.'; + String get authGateMessage => + 'Watch history, favorites, comments and downloads need an account.'; @override String get authGateAction => 'Sign In'; @@ -571,6 +573,121 @@ class AppLocalizationsEn extends AppLocalizations { String get favoriteToggleFailed => 'Could not update favorites. Please retry.'; + @override + String get myFavorites => 'My favorites'; + + @override + String get noFavorites => 'No favorites yet.'; + + @override + String get downloads => 'Downloads'; + + @override + String get downloadsError => 'Download settings could not be loaded.'; + + @override + String get noDownloads => 'No download authorizations yet.'; + + @override + String get downloadedItems => 'Download authorizations'; + + @override + String downloadQuota(int remaining, int max) { + return '$remaining of $max authorizations available'; + } + + @override + String downloadLicenseDays(int days) { + return 'Authorization valid for $days days'; + } + + @override + String get downloadWifiOnly => 'Wi-Fi only'; + + @override + String get downloadQuality => 'Maximum quality'; + + @override + String downloadStatus(Object status) { + return 'Authorization: $status'; + } + + @override + String downloadTaskStatus(Object status) { + return 'Task: $status'; + } + + @override + String downloadProgress(int progress) { + return '$progress%'; + } + + @override + String downloadExpiresAt(Object time) { + return 'Expires $time'; + } + + @override + String get clearDownloadsTitle => 'Clear download authorizations?'; + + @override + String get clearDownloadsMessage => + 'This revokes every download authorization for this device.'; + + @override + String get downloadSettingsFailed => 'Could not update download settings.'; + + @override + String get downloadDeleteFailed => + 'Could not remove this download authorization.'; + + @override + String get downloadClearFailed => 'Could not clear download authorizations.'; + + @override + String get downloadGrantFailed => 'Could not request this download.'; + + @override + String get downloadGranted => 'Download authorization is ready.'; + + @override + String get noWatchRecords => 'No watch history yet.'; + + @override + String get recordDeleteFailed => + 'Could not delete this record. Please retry.'; + + @override + String get recordClearFailed => + 'Could not clear watch history. Please retry.'; + + @override + String get clearAll => 'Clear all'; + + @override + String get clearWatchHistoryTitle => 'Clear watch history?'; + + @override + String get clearWatchHistoryMessage => + 'This removes the watch history from your account.'; + + @override + String get confirmClear => 'Clear'; + + @override + String get detailLoadFailed => 'Details failed to load'; + + @override + String get retryDetail => 'Retry'; + + @override + String get episodeUnavailable => 'Episode unavailable'; + + @override + String updatedAtLabel(Object time) { + return 'Updated $time'; + } + @override String get remove => 'Remove'; diff --git a/lib/l10n/app_localizations_id.dart b/lib/l10n/app_localizations_id.dart index 12d319c..fe736cc 100644 --- a/lib/l10n/app_localizations_id.dart +++ b/lib/l10n/app_localizations_id.dart @@ -295,6 +295,9 @@ class AppLocalizationsId extends AppLocalizations { @override String get catalogError => 'Katalog gagal dimuat.'; + @override + String get categoriesError => 'Kategori gagal dimuat.'; + @override String get detailError => 'Daftar episode gagal dimuat.'; @@ -546,7 +549,8 @@ class AppLocalizationsId extends AppLocalizations { String get authGateTitle => 'Masuk untuk melanjutkan'; @override - String get authGateMessage => 'Favorit dan komentar perlu akun.'; + String get authGateMessage => + 'Riwayat tontonan, favorit, komentar, dan unduhan perlu akun.'; @override String get authGateAction => 'Masuk'; @@ -570,6 +574,118 @@ class AppLocalizationsId extends AppLocalizations { @override String get favoriteToggleFailed => 'Gagal memperbarui favorit. Coba lagi.'; + @override + String get myFavorites => 'Favorit saya'; + + @override + String get noFavorites => 'Belum ada favorit.'; + + @override + String get downloads => 'Unduhan'; + + @override + String get downloadsError => 'Pengaturan unduhan gagal dimuat.'; + + @override + String get noDownloads => 'Belum ada izin unduhan.'; + + @override + String get downloadedItems => 'Izin unduhan'; + + @override + String downloadQuota(int remaining, int max) { + return '$remaining dari $max izin tersedia'; + } + + @override + String downloadLicenseDays(int days) { + return 'Izin berlaku $days hari'; + } + + @override + String get downloadWifiOnly => 'Hanya Wi-Fi'; + + @override + String get downloadQuality => 'Kualitas maksimum'; + + @override + String downloadStatus(Object status) { + return 'Izin: $status'; + } + + @override + String downloadTaskStatus(Object status) { + return 'Tugas: $status'; + } + + @override + String downloadProgress(int progress) { + return '$progress%'; + } + + @override + String downloadExpiresAt(Object time) { + return 'Berakhir $time'; + } + + @override + String get clearDownloadsTitle => 'Hapus izin unduhan?'; + + @override + String get clearDownloadsMessage => + 'Semua izin unduhan untuk perangkat ini akan dicabut.'; + + @override + String get downloadSettingsFailed => 'Gagal memperbarui pengaturan unduhan.'; + + @override + String get downloadDeleteFailed => 'Gagal menghapus izin unduhan ini.'; + + @override + String get downloadClearFailed => 'Gagal menghapus semua izin unduhan.'; + + @override + String get downloadGrantFailed => 'Gagal meminta unduhan ini.'; + + @override + String get downloadGranted => 'Izin unduhan sudah siap.'; + + @override + String get noWatchRecords => 'Belum ada riwayat tontonan.'; + + @override + String get recordDeleteFailed => 'Gagal menghapus riwayat ini. Coba lagi.'; + + @override + String get recordClearFailed => 'Gagal menghapus semua riwayat. Coba lagi.'; + + @override + String get clearAll => 'Hapus semua'; + + @override + String get clearWatchHistoryTitle => 'Hapus riwayat tontonan?'; + + @override + String get clearWatchHistoryMessage => + 'Semua riwayat akan dihapus dari akun kamu.'; + + @override + String get confirmClear => 'Hapus'; + + @override + String get detailLoadFailed => 'Detail drama gagal dimuat'; + + @override + String get retryDetail => 'Coba lagi'; + + @override + String get episodeUnavailable => 'Episode tidak tersedia'; + + @override + String updatedAtLabel(Object time) { + return 'Diperbarui $time'; + } + @override String get remove => 'Hapus'; diff --git a/lib/l10n/app_localizations_zh.dart b/lib/l10n/app_localizations_zh.dart index 8ba2e40..8a24435 100644 --- a/lib/l10n/app_localizations_zh.dart +++ b/lib/l10n/app_localizations_zh.dart @@ -1,5 +1,3 @@ -// Author: fruit.com.cn - // ignore: unused_import import 'package:intl/intl.dart' as intl; import 'app_localizations.dart'; @@ -291,6 +289,9 @@ class AppLocalizationsZh extends AppLocalizations { @override String get catalogError => '剧目列表加载失败。'; + @override + String get categoriesError => '分类加载失败。'; + @override String get detailError => '剧集信息加载失败。'; @@ -538,7 +539,7 @@ class AppLocalizationsZh extends AppLocalizations { String get authGateTitle => '登录后可继续'; @override - String get authGateMessage => '收藏、评论等操作需要登录。'; + String get authGateMessage => '观看记录、收藏、评论和下载需要登录。'; @override String get authGateAction => '去登录'; @@ -561,6 +562,116 @@ class AppLocalizationsZh extends AppLocalizations { @override String get favoriteToggleFailed => '收藏操作失败,请重试。'; + @override + String get myFavorites => '我的收藏'; + + @override + String get noFavorites => '还没有收藏。'; + + @override + String get downloads => '下载'; + + @override + String get downloadsError => '下载设置加载失败。'; + + @override + String get noDownloads => '还没有下载授权。'; + + @override + String get downloadedItems => '下载授权'; + + @override + String downloadQuota(int remaining, int max) { + return '剩余 $remaining / $max 个授权'; + } + + @override + String downloadLicenseDays(int days) { + return '授权有效期 $days 天'; + } + + @override + String get downloadWifiOnly => '仅 Wi-Fi 下载'; + + @override + String get downloadQuality => '最高清晰度'; + + @override + String downloadStatus(Object status) { + return '授权:$status'; + } + + @override + String downloadTaskStatus(Object status) { + return '任务:$status'; + } + + @override + String downloadProgress(int progress) { + return '$progress%'; + } + + @override + String downloadExpiresAt(Object time) { + return '到期时间 $time'; + } + + @override + String get clearDownloadsTitle => '清空下载授权?'; + + @override + String get clearDownloadsMessage => '这会吊销当前设备的全部下载授权。'; + + @override + String get downloadSettingsFailed => '下载设置更新失败。'; + + @override + String get downloadDeleteFailed => '删除下载授权失败。'; + + @override + String get downloadClearFailed => '清空下载授权失败。'; + + @override + String get downloadGrantFailed => '申请下载失败。'; + + @override + String get downloadGranted => '下载授权已就绪。'; + + @override + String get noWatchRecords => '还没有观看记录。'; + + @override + String get recordDeleteFailed => '删除记录失败,请重试。'; + + @override + String get recordClearFailed => '清空观看记录失败,请重试。'; + + @override + String get clearAll => '清空'; + + @override + String get clearWatchHistoryTitle => '清空观看记录?'; + + @override + String get clearWatchHistoryMessage => '这会从当前账号移除全部观看记录。'; + + @override + String get confirmClear => '清空'; + + @override + String get detailLoadFailed => '剧集信息加载失败'; + + @override + String get retryDetail => '重试'; + + @override + String get episodeUnavailable => '集数未知'; + + @override + String updatedAtLabel(Object time) { + return '更新于 $time'; + } + @override String get remove => '移除'; diff --git a/lib/l10n/app_zh.arb b/lib/l10n/app_zh.arb index 1739dcc..264e5de 100644 --- a/lib/l10n/app_zh.arb +++ b/lib/l10n/app_zh.arb @@ -103,6 +103,7 @@ "lockedBody": "完成商店与服务端验单配置后才能解锁。本演示目前不处理付款。", "playbackError": "此视频暂时无法播放。", "catalogError": "剧目列表加载失败。", + "categoriesError": "分类加载失败。", "detailError": "剧集信息加载失败。", "noMediaNotice": "该剧集还没有可播放的片源。", "noStories": "暂无剧目。", @@ -185,7 +186,7 @@ "authSwitchToSignUp": "还没有账号?去注册", "authSwitchToSignIn": "已有账号?去登录", "authGateTitle": "登录后可继续", - "authGateMessage": "收藏、评论等操作需要登录。", + "authGateMessage": "观看记录、收藏、评论和下载需要登录。", "authGateAction": "去登录", "cancel": "暂不", "noEpisodesYet": "还没有可播放的剧集。", @@ -193,6 +194,82 @@ "progressError": "续看进度加载失败。", "favoritesError": "收藏列表加载失败。", "favoriteToggleFailed": "收藏操作失败,请重试。", + "myFavorites": "我的收藏", + "noFavorites": "还没有收藏。", + "downloads": "下载", + "downloadsError": "下载设置加载失败。", + "noDownloads": "还没有下载授权。", + "downloadedItems": "下载授权", + "downloadQuota": "剩余 {remaining} / {max} 个授权", + "@downloadQuota": { + "placeholders": { + "remaining": { + "type": "int" + }, + "max": { + "type": "int" + } + } + }, + "downloadLicenseDays": "授权有效期 {days} 天", + "@downloadLicenseDays": { + "placeholders": { + "days": { + "type": "int" + } + } + }, + "downloadWifiOnly": "仅 Wi-Fi 下载", + "downloadQuality": "最高清晰度", + "downloadStatus": "授权:{status}", + "@downloadStatus": { + "placeholders": { + "status": {} + } + }, + "downloadTaskStatus": "任务:{status}", + "@downloadTaskStatus": { + "placeholders": { + "status": {} + } + }, + "downloadProgress": "{progress}%", + "@downloadProgress": { + "placeholders": { + "progress": { + "type": "int" + } + } + }, + "downloadExpiresAt": "到期时间 {time}", + "@downloadExpiresAt": { + "placeholders": { + "time": {} + } + }, + "clearDownloadsTitle": "清空下载授权?", + "clearDownloadsMessage": "这会吊销当前设备的全部下载授权。", + "downloadSettingsFailed": "下载设置更新失败。", + "downloadDeleteFailed": "删除下载授权失败。", + "downloadClearFailed": "清空下载授权失败。", + "downloadGrantFailed": "申请下载失败。", + "downloadGranted": "下载授权已就绪。", + "noWatchRecords": "还没有观看记录。", + "recordDeleteFailed": "删除记录失败,请重试。", + "recordClearFailed": "清空观看记录失败,请重试。", + "clearAll": "清空", + "clearWatchHistoryTitle": "清空观看记录?", + "clearWatchHistoryMessage": "这会从当前账号移除全部观看记录。", + "confirmClear": "清空", + "detailLoadFailed": "剧集信息加载失败", + "retryDetail": "重试", + "episodeUnavailable": "集数未知", + "updatedAtLabel": "更新于 {time}", + "@updatedAtLabel": { + "placeholders": { + "time": {} + } + }, "remove": "移除", "unlockComingSoon": "金币解锁功能即将开放。", "resumeProgress": "续看至 {position} / {total}", diff --git a/lib/pages/discover/discover_logic.dart b/lib/pages/discover/discover_logic.dart index c8b3b71..3e6aa11 100644 --- a/lib/pages/discover/discover_logic.dart +++ b/lib/pages/discover/discover_logic.dart @@ -19,7 +19,6 @@ class DiscoverLogic extends ChangeNotifier { final TextEditingController search = TextEditingController(); final FocusNode searchFocus = FocusNode(); final ScrollController scroll = ScrollController(); - int category = 0; bool searchOpen = false; bool _disposed = false; @@ -35,11 +34,6 @@ class DiscoverLogic extends ChangeNotifier { .catchError((Object _) => null); } - void selectCategory(int index) { - category = index; - notify(); - } - void onSearchChanged() => notify(); bool get showSearch => searchOpen || search.text.isNotEmpty; @@ -105,7 +99,12 @@ class DiscoverLogic extends ChangeNotifier { } else if (embedded && onDramaSelected != null) { onDramaSelected(selected); } else { - act(context, DiscoverPageAction.detail, embedded: embedded, onAction: onAction); + act( + context, + DiscoverPageAction.detail, + embedded: embedded, + onAction: onAction, + ); } } @@ -123,42 +122,6 @@ class DiscoverLogic extends ChangeNotifier { ).showSnackBar(SnackBar(content: Text(l10n.demoCatalogNotice))); } - void showFilters(BuildContext context) { - final l10n = AppLocalizations.of(context)!; - final labels = [ - l10n.forYou, - l10n.hot, - l10n.newest, - l10n.romance, - l10n.actionGenre, - ]; - showModalBottomSheet( - context: context, - backgroundColor: const Color(0xFF202126), - showDragHandle: true, - builder: (sheetContext) => SafeArea( - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - ListTile(title: Text(l10n.filter)), - for (var index = 0; index < labels.length; index++) - ListTile( - title: Text(labels[index]), - trailing: index == category - ? const Icon(Icons.check_rounded, color: Color(0xFF2F7BFF)) - : null, - onTap: () { - selectCategory(index); - Navigator.pop(sheetContext); - }, - ), - const SizedBox(height: 8), - ], - ), - ), - ); - } - @override void dispose() { _disposed = true; diff --git a/lib/pages/discover/discover_view.dart b/lib/pages/discover/discover_view.dart index 1afca62..42bb636 100644 --- a/lib/pages/discover/discover_view.dart +++ b/lib/pages/discover/discover_view.dart @@ -7,7 +7,7 @@ import 'package:provider/provider.dart'; import '../../core/data/models/drama.dart'; import '../../core/data/models/home_feed.dart'; import '../../core/data/repositories/watch_history_repository.dart'; -import '../../core/data/services/catalog_controller.dart'; +import '../../core/data/services/category_controller.dart'; import '../../core/theme/app_colors.dart'; import '../../core/widgets/remote_image.dart'; import '../../l10n/app_localizations.dart'; @@ -96,14 +96,9 @@ class _DiscoverPageState extends State { Widget _page(BuildContext context) { final l10n = AppLocalizations.of(context)!; - final catalog = context.watch(); - final allDramas = widget.dramas ?? [logic.drama]; - final cards = _cardsFor( - allDramas, - catalog.sections, - logic.category, - '', - ); + final categories = context.watch(); + final allDramas = [...?widget.dramas, ...categories.visibleDramas]; + final cards = _cardsFor(categories.visibleDramas, ''); final content = SafeArea( bottom: !widget.embedded, child: Column( @@ -118,7 +113,7 @@ class _DiscoverPageState extends State { padding: const EdgeInsets.fromLTRB(16, 4, 16, 0), child: ClipRRect( borderRadius: BorderRadius.circular(18), - child: _carousel(l10n, catalog.banners, allDramas), + child: _carousel(l10n, categories.feed.banners, allDramas), ), ), Padding( @@ -126,31 +121,11 @@ class _DiscoverPageState extends State { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - _categories(l10n), + _categories(l10n, categories), const SizedBox(height: 18), _continueHeader(l10n), const SizedBox(height: 12), - if (cards.isEmpty) - Padding( - padding: const EdgeInsets.symmetric(vertical: 24), - child: Text( - l10n.noSearchResults, - style: const TextStyle(color: Color(0xFFE6E1E3)), - ), - ) - else - SizedBox( - height: 196, - child: ListView( - scrollDirection: Axis.horizontal, - children: [ - for (final card in cards) ...[ - _continueTile(l10n, card), - const SizedBox(width: 12), - ], - ], - ), - ), + _dramaContent(l10n, categories, cards), ], ), ), @@ -217,7 +192,9 @@ class _DiscoverPageState extends State { List banners, List allDramas, ) { - final items = banners.where((banner) => banner.imageUrl.isNotEmpty).toList(); + final items = banners + .where((banner) => banner.imageUrl.isNotEmpty) + .toList(); if (items.isEmpty) return const SizedBox.shrink(); return CoverCarousel( items: [ @@ -285,8 +262,64 @@ class _DiscoverPageState extends State { ], ); - Widget _continueTile(AppLocalizations l10n, _ShowcaseCard card) { - final drama = logic.dramaFor(card.dramaId, widget.dramas ?? [logic.drama]); + Widget _dramaContent( + AppLocalizations l10n, + CategoryController categories, + List<_ShowcaseCard> cards, + ) { + if (categories.loading && categories.feed.sections.isEmpty) { + return const Padding( + padding: EdgeInsets.symmetric(vertical: 24), + child: Center(child: CircularProgressIndicator(strokeWidth: 2)), + ); + } + if (categories.error != null) { + return Padding( + padding: const EdgeInsets.symmetric(vertical: 18), + child: Row( + children: [ + Expanded( + child: Text( + l10n.categoriesError, + style: const TextStyle(color: Color(0xFFE6E1E3)), + ), + ), + TextButton(onPressed: categories.load, child: Text(l10n.retry)), + ], + ), + ); + } + if (cards.isEmpty) { + return Padding( + padding: const EdgeInsets.symmetric(vertical: 24), + child: Text( + categories.selectedSectionMissing + ? l10n.noCategoryDramas + : l10n.noSearchResults, + style: const TextStyle(color: Color(0xFFE6E1E3)), + ), + ); + } + return SizedBox( + height: 196, + child: ListView( + scrollDirection: Axis.horizontal, + children: [ + for (final card in cards) ...[ + _continueTile(l10n, card, categories.visibleDramas), + const SizedBox(width: 12), + ], + ], + ), + ); + } + + Widget _continueTile( + AppLocalizations l10n, + _ShowcaseCard card, + List source, + ) { + final drama = logic.dramaFor(card.dramaId, source); return SizedBox( width: 132, child: InkWell( @@ -360,24 +393,25 @@ class _DiscoverPageState extends State { ); } - Widget _categories(AppLocalizations l10n) { - final labels = [ - l10n.forYou, - l10n.hot, - l10n.newest, - l10n.romance, - l10n.actionGenre, + Widget _categories(AppLocalizations l10n, CategoryController categories) { + final choices = <({String code, String label})>[ + (code: CategoryController.allCode, label: l10n.forYou), + (code: CategoryController.hotCode, label: l10n.hot), + (code: CategoryController.newCode, label: l10n.newest), + for (final category in categories.categories) + (code: 'category-${category.id}', label: category.name), ]; return SizedBox( height: 32, child: ListView.separated( scrollDirection: Axis.horizontal, - itemCount: labels.length, + itemCount: choices.length, separatorBuilder: (_, _) => const SizedBox(width: 8), itemBuilder: (context, index) { - final selected = logic.category == index; + final choice = choices[index]; + final selected = categories.selectedCode == choice.code; return GestureDetector( - onTap: () => logic.selectCategory(index), + onTap: () => categories.selectCode(choice.code), child: AnimatedContainer( duration: const Duration(milliseconds: 180), alignment: Alignment.center, @@ -387,7 +421,7 @@ class _DiscoverPageState extends State { borderRadius: BorderRadius.circular(16), ), child: Text( - labels[index], + choice.label, maxLines: 1, style: TextStyle( color: selected ? Colors.white : AppColors.muted, @@ -498,19 +532,10 @@ class _ShowcaseCard { } /// 分区由服务端下发:0 为全部,其余按分区顺序对应筛选菜单(热门 / 最新 / 各分类)。 -List<_ShowcaseCard> _cardsFor( - List dramas, - List sections, - int category, - String query, -) { - final source = switch (category) { - 0 => dramas, - _ => category < sections.length ? sections[category].dramas : const [], - }; +List<_ShowcaseCard> _cardsFor(List dramas, String query) { final normalized = query.trim().toLowerCase(); return [ - for (final drama in source) + for (final drama in dramas) if (normalized.isEmpty || drama.title.toLowerCase().contains(normalized) || drama.genre.toLowerCase().contains(normalized) || diff --git a/lib/pages/downloads/downloads_binding.dart b/lib/pages/downloads/downloads_binding.dart new file mode 100644 index 0000000..4448e47 --- /dev/null +++ b/lib/pages/downloads/downloads_binding.dart @@ -0,0 +1,9 @@ +// Author: fruit.com.cn + +import '../../core/data/services/download_controller.dart'; + +/// 下载管理页依赖装配。 +class DownloadsBinding { + /// 从服务端刷新策略与授权列表。 + Future load(DownloadController downloads) => downloads.load(); +} diff --git a/lib/pages/downloads/downloads_page.dart b/lib/pages/downloads/downloads_page.dart new file mode 100644 index 0000000..f472d30 --- /dev/null +++ b/lib/pages/downloads/downloads_page.dart @@ -0,0 +1,409 @@ +// Author: fruit.com.cn + +import 'dart:async'; + +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; + +import '../../core/data/models/download_license.dart'; +import '../../core/data/models/download_policy.dart'; +import '../../core/data/services/auth_controller.dart'; +import '../../core/data/services/download_controller.dart'; +import '../../core/formatting/error_text.dart'; +import '../../core/theme/app_colors.dart'; +import '../../core/widgets/auth_gate.dart'; +import '../../l10n/app_localizations.dart'; +import 'downloads_binding.dart'; + +/// 下载授权与状态管理页;本批不落盘,只管理服务端授权。 +class DownloadsPage extends StatefulWidget { + const DownloadsPage({super.key}); + + @override + State createState() => _DownloadsPageState(); +} + +class _DownloadsPageState extends State { + bool _requested = false; + + @override + void didChangeDependencies() { + super.didChangeDependencies(); + final signedIn = context.watch().isSignedIn; + if (!signedIn) { + _requested = false; + return; + } + if (_requested) return; + _requested = true; + final downloads = context.read(); + WidgetsBinding.instance.addPostFrameCallback((_) { + if (mounted) unawaited(DownloadsBinding().load(downloads)); + }); + } + + @override + Widget build(BuildContext context) { + final l10n = AppLocalizations.of(context)!; + final signedIn = context.watch().isSignedIn; + return Scaffold( + key: const Key('downloads-page'), + backgroundColor: const Color(0xFF0B0C10), + appBar: AppBar( + backgroundColor: const Color(0xFF0B0C10), + foregroundColor: Colors.white, + title: Text(l10n.downloads), + ), + body: signedIn + ? _DownloadsBody(downloads: context.watch()) + : const AuthGatePanel(), + ); + } +} + +class _DownloadsBody extends StatelessWidget { + const _DownloadsBody({required this.downloads}); + + final DownloadController downloads; + + @override + Widget build(BuildContext context) { + final l10n = AppLocalizations.of(context)!; + if (downloads.loading && downloads.policy == null) { + return const Center(child: CircularProgressIndicator()); + } + if (downloads.error != null && downloads.policy == null) { + return Center( + key: const Key('downloads-error'), + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 32), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Text( + errorText(l10n, downloads.error, l10n.downloadsError), + textAlign: TextAlign.center, + style: const TextStyle(color: Colors.white70), + ), + const SizedBox(height: 14), + FilledButton( + key: const Key('downloads-retry'), + onPressed: () => unawaited(downloads.load()), + child: Text(l10n.retry), + ), + ], + ), + ), + ); + } + final policy = downloads.policy; + if (policy == null) { + return Center( + key: const Key('downloads-error'), + child: FilledButton( + key: const Key('downloads-retry'), + onPressed: () => unawaited(downloads.load()), + child: Text(l10n.retry), + ), + ); + } + return RefreshIndicator( + onRefresh: downloads.load, + child: ListView( + padding: const EdgeInsets.fromLTRB(16, 10, 16, 28), + children: [ + _PolicyPanel(downloads: downloads, policy: policy), + const SizedBox(height: 14), + Row( + children: [ + Expanded( + child: Text( + l10n.downloadedItems, + style: const TextStyle( + color: Colors.white, + fontSize: 16, + fontWeight: FontWeight.w700, + ), + ), + ), + if (downloads.licenses.isNotEmpty) + TextButton.icon( + key: const Key('download-clear'), + onPressed: downloads.clearing + ? null + : () => _confirmClear(context), + icon: const Icon(Icons.delete_sweep_outlined), + label: Text(l10n.clearAll), + ), + ], + ), + if (downloads.licenses.isEmpty) + Padding( + key: const Key('downloads-empty'), + padding: const EdgeInsets.symmetric(vertical: 34), + child: Text( + l10n.noDownloads, + textAlign: TextAlign.center, + style: const TextStyle(color: Colors.white70), + ), + ) + else + for (final license in downloads.licenses) ...[ + _LicenseTile( + license: license, + onRemove: () => _remove(context, license.episodeId), + ), + const SizedBox(height: 10), + ], + ], + ), + ); + } + + Future _remove(BuildContext context, String episodeId) async { + final ok = await downloads.remove(episodeId); + if (ok || !context.mounted) return; + _showMessage(context, AppLocalizations.of(context)!.downloadDeleteFailed); + } + + Future _confirmClear(BuildContext context) async { + final l10n = AppLocalizations.of(context)!; + final confirmed = await showDialog( + context: context, + builder: (dialogContext) => AlertDialog( + title: Text(l10n.clearDownloadsTitle), + content: Text(l10n.clearDownloadsMessage), + actions: [ + TextButton( + onPressed: () => Navigator.of(dialogContext).pop(false), + child: Text(l10n.cancel), + ), + FilledButton( + onPressed: () => Navigator.of(dialogContext).pop(true), + child: Text(l10n.confirmClear), + ), + ], + ), + ); + if (confirmed != true) return; + final ok = await downloads.clear(); + if (!ok && context.mounted) { + _showMessage(context, l10n.downloadClearFailed); + } + } + + void _showMessage(BuildContext context, String message) { + ScaffoldMessenger.of( + context, + ).showSnackBar(SnackBar(content: Text(message))); + } +} + +class _PolicyPanel extends StatelessWidget { + const _PolicyPanel({required this.downloads, required this.policy}); + + final DownloadController downloads; + final DownloadPolicy policy; + + @override + Widget build(BuildContext context) { + final l10n = AppLocalizations.of(context)!; + return Container( + key: const Key('download-policy'), + padding: const EdgeInsets.fromLTRB(14, 14, 14, 10), + decoration: BoxDecoration( + color: AppColors.card, + borderRadius: BorderRadius.circular(12), + border: Border.all(color: const Color(0xFF2A2C33)), + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + l10n.downloadQuota(policy.remaining, policy.maxPerDevice), + style: const TextStyle( + color: Colors.white, + fontSize: 17, + fontWeight: FontWeight.w800, + ), + ), + const SizedBox(height: 5), + Text( + l10n.downloadLicenseDays(policy.licenseDays), + style: const TextStyle(color: AppColors.muted, fontSize: 12), + ), + const SizedBox(height: 6), + Text( + policy.expirePolicyText, + style: const TextStyle(color: Color(0xFFB7B3B8), fontSize: 12), + ), + const Divider(height: 22, color: Color(0xFF2A2C33)), + Row( + children: [ + Expanded( + child: Text( + l10n.downloadWifiOnly, + style: const TextStyle(color: Colors.white, fontSize: 13), + ), + ), + Switch( + key: const Key('download-wifi-switch'), + value: policy.wifiOnly, + onChanged: (value) => _update(context, wifiOnly: value), + ), + ], + ), + Row( + children: [ + Expanded( + child: Text( + l10n.downloadQuality, + style: const TextStyle(color: Colors.white, fontSize: 13), + ), + ), + DropdownButton( + key: const Key('download-quality'), + value: + _qualityChoices( + policy.maxQuality, + ).contains(policy.maxQuality) + ? policy.maxQuality + : 'AUTO', + underline: const SizedBox.shrink(), + items: [ + for (final quality in _qualityChoices(policy.maxQuality)) + DropdownMenuItem(value: quality, child: Text(quality)), + ], + onChanged: (value) { + if (value == null || value == policy.maxQuality) return; + _update(context, maxQuality: value); + }, + ), + ], + ), + ], + ), + ); + } + + Future _update( + BuildContext context, { + bool? wifiOnly, + String? maxQuality, + }) async { + final ok = await downloads.updateSettings( + wifiOnly: wifiOnly, + maxQuality: maxQuality, + ); + if (ok || !context.mounted) return; + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text(AppLocalizations.of(context)!.downloadSettingsFailed), + ), + ); + } +} + +class _LicenseTile extends StatelessWidget { + const _LicenseTile({required this.license, required this.onRemove}); + + final DownloadLicense license; + final VoidCallback onRemove; + + @override + Widget build(BuildContext context) { + final l10n = AppLocalizations.of(context)!; + return Container( + key: ValueKey('download-license-${license.episodeId}'), + padding: const EdgeInsets.all(12), + decoration: BoxDecoration( + color: AppColors.card, + borderRadius: BorderRadius.circular(10), + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + children: [ + Expanded( + child: Text( + license.dramaTitle, + maxLines: 1, + overflow: TextOverflow.ellipsis, + style: const TextStyle( + color: Colors.white, + fontSize: 15, + fontWeight: FontWeight.w700, + ), + ), + ), + Text(l10n.episodeLabel(license.episodeNo)), + IconButton( + key: ValueKey('download-remove-${license.episodeId}'), + tooltip: l10n.remove, + onPressed: onRemove, + icon: const Icon(Icons.close_rounded), + ), + ], + ), + Wrap( + spacing: 12, + runSpacing: 5, + children: [ + Text( + l10n.downloadStatus(license.status), + style: const TextStyle(color: AppColors.blueSoft, fontSize: 12), + ), + Text( + l10n.downloadTaskStatus(license.taskStatus), + style: const TextStyle(color: AppColors.muted, fontSize: 12), + ), + Text( + l10n.downloadProgress(license.progressPercent), + style: const TextStyle(color: Colors.white70, fontSize: 12), + ), + if (license.quality.isNotEmpty) + Text( + license.quality, + style: const TextStyle(color: Colors.white70, fontSize: 12), + ), + ], + ), + const SizedBox(height: 8), + ClipRRect( + borderRadius: BorderRadius.circular(4), + child: LinearProgressIndicator( + minHeight: 4, + value: (license.progressPercent / 100).clamp(0.0, 1.0), + ), + ), + if (license.expireAt != null) ...[ + const SizedBox(height: 7), + Text( + l10n.downloadExpiresAt(_formatTime(license.expireAt!)), + style: const TextStyle(color: Color(0xFF8D8990), fontSize: 11), + ), + ], + ], + ), + ); + } +} + +List _qualityChoices(String current) { + final choices = ['AUTO']; + if (current.isNotEmpty && current != 'AUTO') choices.add(current); + for (final value in const ['720P', '1080P']) { + if (!choices.contains(value)) choices.add(value); + } + return choices; +} + +String _formatTime(DateTime value) { + final local = value.toLocal(); + final month = local.month.toString().padLeft(2, '0'); + final day = local.day.toString().padLeft(2, '0'); + final hour = local.hour.toString().padLeft(2, '0'); + final minute = local.minute.toString().padLeft(2, '0'); + return '${local.year}-$month-$day $hour:$minute'; +} diff --git a/lib/pages/drama_detail/drama_detail_view.dart b/lib/pages/drama_detail/drama_detail_view.dart index 7d7a999..131298e 100644 --- a/lib/pages/drama_detail/drama_detail_view.dart +++ b/lib/pages/drama_detail/drama_detail_view.dart @@ -12,6 +12,7 @@ import '../../core/formatting/error_text.dart'; import '../../core/formatting/localized_content.dart'; import '../../core/widgets/remote_image.dart'; import '../../core/widgets/auth_gate.dart'; +import '../../core/widgets/download_action.dart'; import '../../l10n/app_localizations.dart'; import 'drama_detail_binding.dart'; import 'drama_detail_logic.dart'; @@ -136,7 +137,10 @@ class _DramaDetailPageState extends State { pinned: true, backgroundColor: const Color(0xFF111111), foregroundColor: Colors.white, - actions: [_favoriteAction(context, l10n)], + actions: [ + _downloadAction(context, l10n), + _favoriteAction(context, l10n), + ], flexibleSpace: FlexibleSpaceBar( background: RemoteImage(drama.posterUrl), ), @@ -270,6 +274,23 @@ class _DramaDetailPageState extends State { return record.fraction; } + /// 下载当前续看集或第一集;业务判定完全交给服务端。 + Widget _downloadAction(BuildContext context, AppLocalizations l10n) { + final episodes = logic.drama.episodes; + final index = logic.continueIndex ?? 0; + final episode = episodes.isEmpty + ? null + : episodes[index.clamp(0, episodes.length - 1)]; + return IconButton( + key: const Key('detail-download'), + tooltip: l10n.downloads, + icon: const Icon(Icons.download_outlined), + onPressed: episode == null + ? null + : () => requestEpisodeDownload(context, episode.id), + ); + } + /// 收藏按钮:状态取自服务端(乐观更新,失败回滚并提示)。 Widget _favoriteAction(BuildContext context, AppLocalizations l10n) { final favorites = context.watch(); diff --git a/lib/pages/favorites/favorites_binding.dart b/lib/pages/favorites/favorites_binding.dart new file mode 100644 index 0000000..720b097 --- /dev/null +++ b/lib/pages/favorites/favorites_binding.dart @@ -0,0 +1,9 @@ +// Author: fruit.com.cn + +import '../../core/data/services/favorite_controller.dart'; + +/// 收藏页依赖装配。 +class FavoritesBinding { + /// 从服务端刷新收藏列表。 + Future load(FavoriteController favorites) => favorites.load(); +} diff --git a/lib/pages/favorites/favorites_page.dart b/lib/pages/favorites/favorites_page.dart new file mode 100644 index 0000000..b89bf83 --- /dev/null +++ b/lib/pages/favorites/favorites_page.dart @@ -0,0 +1,148 @@ +// Author: fruit.com.cn + +import 'dart:async'; + +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; + +import '../../core/data/models/drama.dart'; +import '../../core/data/services/auth_controller.dart'; +import '../../core/data/services/favorite_controller.dart'; +import '../../core/formatting/error_text.dart'; +import '../../core/widgets/auth_gate.dart'; +import '../../core/widgets/library_drama_tile.dart'; +import '../../l10n/app_localizations.dart'; +import '../drama_detail/drama_detail_view.dart'; +import 'favorites_binding.dart'; + +/// 独立我的收藏页。 +class FavoritesPage extends StatefulWidget { + const FavoritesPage({super.key}); + + @override + State createState() => _FavoritesPageState(); +} + +class _FavoritesPageState extends State { + bool _requested = false; + + @override + void didChangeDependencies() { + super.didChangeDependencies(); + final signedIn = context.watch().isSignedIn; + if (!signedIn) { + _requested = false; + return; + } + if (_requested) return; + _requested = true; + final favorites = context.read(); + WidgetsBinding.instance.addPostFrameCallback((_) { + if (mounted) unawaited(FavoritesBinding().load(favorites)); + }); + } + + @override + Widget build(BuildContext context) { + final l10n = AppLocalizations.of(context)!; + final signedIn = context.watch().isSignedIn; + return Scaffold( + backgroundColor: const Color(0xFF0B0C10), + appBar: AppBar( + backgroundColor: const Color(0xFF0B0C10), + foregroundColor: Colors.white, + title: Text(l10n.myFavorites), + ), + body: signedIn + ? _FavoritesBody(favorites: context.watch()) + : const AuthGatePanel(), + ); + } +} + +class _FavoritesBody extends StatelessWidget { + const _FavoritesBody({required this.favorites}); + + final FavoriteController favorites; + + @override + Widget build(BuildContext context) { + final l10n = AppLocalizations.of(context)!; + if (favorites.loading && favorites.cards.isEmpty) { + return const Center(child: CircularProgressIndicator()); + } + if (favorites.error != null && favorites.cards.isEmpty) { + return Center( + key: const Key('favorites-error'), + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 32), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Text( + errorText(l10n, favorites.error, l10n.favoritesError), + textAlign: TextAlign.center, + style: const TextStyle(color: Colors.white70), + ), + const SizedBox(height: 14), + FilledButton( + key: const Key('favorites-retry'), + onPressed: () => unawaited(favorites.load()), + child: Text(l10n.retry), + ), + ], + ), + ), + ); + } + if (favorites.cards.isEmpty) { + return Center( + key: const Key('favorites-empty'), + child: Text( + l10n.noFavorites, + style: const TextStyle(color: Colors.white70), + ), + ); + } + return RefreshIndicator( + onRefresh: favorites.load, + child: ListView.separated( + padding: const EdgeInsets.fromLTRB(16, 12, 16, 28), + itemCount: favorites.cards.length, + separatorBuilder: (_, _) => const SizedBox(height: 10), + itemBuilder: (context, index) { + final drama = favorites.cards[index]; + return LibraryDramaTile( + key: ValueKey('favorite-card-${drama.id}'), + drama: drama, + onTap: () => _open(context, drama), + trailing: IconButton( + key: ValueKey('favorite-remove-${drama.id}'), + tooltip: l10n.remove, + onPressed: () => _remove(context, drama.id), + icon: const Icon( + Icons.favorite_rounded, + color: Color(0xFFD74A7D), + ), + ), + ); + }, + ), + ); + } + + Future _open(BuildContext context, Drama drama) async { + await Navigator.of(context).push( + MaterialPageRoute(builder: (_) => DramaDetailPage(drama: drama)), + ); + } + + Future _remove(BuildContext context, String dramaId) async { + final ok = await favorites.remove(dramaId); + if (ok || !context.mounted) return; + final l10n = AppLocalizations.of(context)!; + ScaffoldMessenger.of( + context, + ).showSnackBar(SnackBar(content: Text(l10n.favoriteToggleFailed))); + } +} diff --git a/lib/pages/home/home_view.dart b/lib/pages/home/home_view.dart index 3571c23..22f8582 100644 --- a/lib/pages/home/home_view.dart +++ b/lib/pages/home/home_view.dart @@ -105,7 +105,6 @@ class _HomeTabsState extends State<_HomeTabs> { ); } - Widget _scaffold(BuildContext context) { final l10n = AppLocalizations.of(context)!; // 登录态统一从 AuthController 取(原来是 home_logic 里的本地演示开关) @@ -173,7 +172,6 @@ class _HomeTabsState extends State<_HomeTabs> { embedded: true, active: logic.tab == 2, onAction: logic.myAction, - onOpenHistory: () => logic.openLibrary(section: 0), signedIn: signedIn, onSignIn: () => openAuthPage(context), onSignOut: () => context.read().signOut(), diff --git a/lib/pages/mine/mine_view.dart b/lib/pages/mine/mine_view.dart index 11a9f9d..1546d2b 100644 --- a/lib/pages/mine/mine_view.dart +++ b/lib/pages/mine/mine_view.dart @@ -17,6 +17,9 @@ import '../../core/theme/app_colors.dart'; import '../../l10n/app_localizations.dart'; import 'mine_binding.dart'; import 'mine_logic.dart'; +import '../watch_records/watch_records_page.dart'; +import '../favorites/favorites_page.dart'; +import '../downloads/downloads_page.dart'; class MyPage extends StatefulWidget { const MyPage({ @@ -25,7 +28,6 @@ class MyPage extends StatefulWidget { required this.duration, this.initialSection = 0, this.profile = false, - this.onOpenHistory, this.history, this.embedded = false, this.active = true, @@ -42,7 +44,6 @@ class MyPage extends StatefulWidget { final Duration duration; final int initialSection; final bool profile; - final VoidCallback? onOpenHistory; final WatchHistoryRepository? history; final bool embedded; final bool active; @@ -249,8 +250,12 @@ class _MyPageState extends State { Widget _signedInRow(AppLocalizations l10n) { // 显示真实登录账号(昵称 + uid);拿不到才回落到演示文案 final user = context.watch().user; - final name = (user?.nickname.isNotEmpty ?? false) ? user!.nickname : l10n.mockUserName; - final uidText = (user?.uid.isNotEmpty ?? false) ? 'ID: ${user!.uid}' : l10n.mockUserId; + final name = (user?.nickname.isNotEmpty ?? false) + ? user!.nickname + : l10n.mockUserName; + final uidText = (user?.uid.isNotEmpty ?? false) + ? 'ID: ${user!.uid}' + : l10n.mockUserId; return Row( children: [ const CircleAvatar( @@ -414,7 +419,33 @@ class _MyPageState extends State { ), title: Text(l10n.watchHistory), trailing: const Icon(Icons.chevron_right_rounded), - onTap: widget.onOpenHistory, + onTap: () => Navigator.of(context).push( + MaterialPageRoute(builder: (_) => const WatchRecordsPage()), + ), + ), + const Divider(height: 1, color: Color(0xFF2A2C33)), + ListTile( + leading: const Icon( + Icons.favorite_outline_rounded, + color: AppColors.blueSoft, + ), + title: Text(l10n.myFavorites), + trailing: const Icon(Icons.chevron_right_rounded), + onTap: () => Navigator.of(context).push( + MaterialPageRoute(builder: (_) => const FavoritesPage()), + ), + ), + const Divider(height: 1, color: Color(0xFF2A2C33)), + ListTile( + leading: const Icon( + Icons.download_outlined, + color: AppColors.blueSoft, + ), + title: Text(l10n.downloads), + trailing: const Icon(Icons.chevron_right_rounded), + onTap: () => Navigator.of(context).push( + MaterialPageRoute(builder: (_) => const DownloadsPage()), + ), ), const Divider(height: 1, color: Color(0xFF2A2C33)), ListTile( diff --git a/lib/pages/player/player_view.dart b/lib/pages/player/player_view.dart index 4613d40..c5521db 100644 --- a/lib/pages/player/player_view.dart +++ b/lib/pages/player/player_view.dart @@ -16,6 +16,7 @@ import '../../core/data/services/video_player_port.dart'; import '../../core/formatting/error_text.dart'; import '../../core/formatting/localized_content.dart'; import '../../core/widgets/auth_gate.dart'; +import '../../core/widgets/download_action.dart'; import '../../l10n/app_localizations.dart'; import 'player_binding.dart'; import 'player_logic.dart'; @@ -360,6 +361,7 @@ class _PlayerPageState extends State with WidgetsBindingObserver { ); } }, + onDownload: () => requestEpisodeDownload(context, episode.id), onComments: () => logic.showComments(context, drama), onShare: () => logic.shareDrama(context, drama), onClear: () => logic.setScreenCleared(true), @@ -523,6 +525,7 @@ class _PlaybackOverlay extends StatelessWidget { required this.onMy, required this.onLike, required this.onSave, + required this.onDownload, required this.onComments, required this.onShare, required this.onClear, @@ -544,6 +547,7 @@ class _PlaybackOverlay extends StatelessWidget { final VoidCallback onMy; final VoidCallback onLike; final VoidCallback onSave; + final VoidCallback onDownload; final VoidCallback onComments; final VoidCallback onShare; final VoidCallback onClear; @@ -665,6 +669,12 @@ class _PlaybackOverlay extends StatelessWidget { selected: saved, onTap: onSave, ), + _RailAction( + key: const Key('rail-download'), + icon: Icons.download_outlined, + label: l10n.downloads, + onTap: onDownload, + ), _RailAction( icon: Icons.grid_view_rounded, label: l10n.episodes, diff --git a/lib/pages/watch_records/watch_records_binding.dart b/lib/pages/watch_records/watch_records_binding.dart new file mode 100644 index 0000000..80ab1ef --- /dev/null +++ b/lib/pages/watch_records/watch_records_binding.dart @@ -0,0 +1,14 @@ +// Author: fruit.com.cn + +import '../../core/data/repositories/catalog_repository.dart'; +import '../../core/data/repositories/watch_history_repository.dart'; +import '../../core/data/services/watch_records_controller.dart'; + +/// 观看记录页依赖装配。 +class WatchRecordsBinding { + /// 创建独立页面控制器。 + WatchRecordsController create({ + required WatchHistoryRepository history, + required CatalogRepository catalog, + }) => WatchRecordsController(history: history, catalog: catalog); +} diff --git a/lib/pages/watch_records/watch_records_page.dart b/lib/pages/watch_records/watch_records_page.dart new file mode 100644 index 0000000..0476274 --- /dev/null +++ b/lib/pages/watch_records/watch_records_page.dart @@ -0,0 +1,386 @@ +// Author: fruit.com.cn + +import 'dart:async'; + +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; + +import '../../core/data/models/drama.dart'; +import '../../core/data/models/watch_record.dart'; +import '../../core/data/repositories/catalog_repository.dart'; +import '../../core/data/repositories/watch_history_repository.dart'; +import '../../core/data/services/auth_controller.dart'; +import '../../core/data/services/watch_records_controller.dart'; +import '../../core/formatting/error_text.dart'; +import '../../core/theme/app_colors.dart'; +import '../../core/widgets/auth_gate.dart'; +import '../../core/widgets/remote_image.dart'; +import '../../l10n/app_localizations.dart'; +import '../drama_detail/drama_detail_view.dart'; +import 'watch_records_binding.dart'; + +/// 独立观看记录页。 +class WatchRecordsPage extends StatelessWidget { + const WatchRecordsPage({super.key}); + + @override + Widget build(BuildContext context) { + final signedIn = context.watch().isSignedIn; + final l10n = AppLocalizations.of(context)!; + return Scaffold( + key: const Key('watch-records-page'), + backgroundColor: const Color(0xFF0B0C10), + appBar: AppBar( + backgroundColor: const Color(0xFF0B0C10), + foregroundColor: Colors.white, + title: Text(l10n.watchHistory), + ), + body: signedIn ? const _WatchRecordsBody() : const AuthGatePanel(), + ); + } +} + +class _WatchRecordsBody extends StatefulWidget { + const _WatchRecordsBody(); + + @override + State<_WatchRecordsBody> createState() => _WatchRecordsBodyState(); +} + +class _WatchRecordsBodyState extends State<_WatchRecordsBody> { + late final WatchRecordsController controller; + + @override + void initState() { + super.initState(); + controller = WatchRecordsBinding().create( + history: context.read(), + catalog: context.read(), + ); + unawaited(controller.load()); + } + + @override + void dispose() { + controller.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return ListenableBuilder( + listenable: controller, + builder: (context, _) => _content(context), + ); + } + + Widget _content(BuildContext context) { + final l10n = AppLocalizations.of(context)!; + if (controller.loading && controller.records.isEmpty) { + return const Center(child: CircularProgressIndicator()); + } + if (controller.error != null && controller.records.isEmpty) { + return _FailureState( + message: errorText(l10n, controller.error, l10n.progressError), + onRetry: controller.load, + ); + } + if (controller.records.isEmpty) { + return Center( + child: Text( + l10n.noWatchRecords, + style: const TextStyle(color: Colors.white70), + ), + ); + } + return Column( + children: [ + Align( + alignment: Alignment.centerRight, + child: TextButton.icon( + key: const Key('watch-records-clear'), + onPressed: controller.clearing ? null : _confirmClear, + icon: const Icon(Icons.delete_sweep_outlined), + label: Text(l10n.clearAll), + ), + ), + Expanded( + child: RefreshIndicator( + onRefresh: controller.load, + child: ListView.separated( + padding: const EdgeInsets.fromLTRB(16, 4, 16, 28), + itemCount: controller.records.length, + separatorBuilder: (_, _) => const SizedBox(height: 10), + itemBuilder: (context, index) { + final record = controller.records[index]; + return _RecordTile( + record: record, + onRetry: () => controller.retryDetail(record.dramaId), + onRemove: () => _remove(record.dramaId), + onOpen: record.drama == null + ? null + : () => _open(record.drama!), + ); + }, + ), + ), + ), + ], + ); + } + + Future _open(Drama drama) async { + await Navigator.of(context).push( + MaterialPageRoute(builder: (_) => DramaDetailPage(drama: drama)), + ); + } + + Future _remove(String dramaId) async { + final ok = await controller.remove(dramaId); + if (!ok && mounted) _showFailure('recordDeleteFailed'); + } + + Future _confirmClear() async { + final l10n = AppLocalizations.of(context)!; + final confirmed = await showDialog( + context: context, + builder: (dialogContext) => AlertDialog( + title: Text(l10n.clearWatchHistoryTitle), + content: Text(l10n.clearWatchHistoryMessage), + actions: [ + TextButton( + onPressed: () => Navigator.of(dialogContext).pop(false), + child: Text(l10n.cancel), + ), + FilledButton( + onPressed: () => Navigator.of(dialogContext).pop(true), + child: Text(l10n.confirmClear), + ), + ], + ), + ); + if (confirmed != true) return; + final ok = await controller.clear(); + if (!ok && mounted) _showFailure('recordClearFailed'); + } + + void _showFailure(String key) { + final l10n = AppLocalizations.of(context)!; + final message = key == 'recordDeleteFailed' + ? l10n.recordDeleteFailed + : l10n.recordClearFailed; + ScaffoldMessenger.of( + context, + ).showSnackBar(SnackBar(content: Text(message))); + } +} + +class _RecordTile extends StatelessWidget { + const _RecordTile({ + required this.record, + required this.onRetry, + required this.onRemove, + this.onOpen, + }); + + final WatchRecord record; + final VoidCallback onRetry; + final VoidCallback onRemove; + final VoidCallback? onOpen; + + @override + Widget build(BuildContext context) { + final l10n = AppLocalizations.of(context)!; + if (record.detailFailed) { + return _FailedRecordTile(record: record, onRetry: onRetry); + } + final drama = record.drama; + if (drama == null || record.detailLoading) { + return Container( + key: ValueKey('watch-record-${record.dramaId}'), + height: 112, + decoration: BoxDecoration( + color: AppColors.card, + borderRadius: BorderRadius.circular(12), + ), + child: const Center( + child: SizedBox( + width: 22, + height: 22, + child: CircularProgressIndicator(strokeWidth: 2), + ), + ), + ); + } + final episodeLabel = record.episodeNumber > 0 + ? l10n.episodeLabel(record.episodeNumber) + : l10n.episodeUnavailable; + return Material( + key: ValueKey('watch-record-${record.dramaId}'), + color: AppColors.card, + borderRadius: BorderRadius.circular(12), + clipBehavior: Clip.antiAlias, + child: InkWell( + onTap: onOpen, + child: Padding( + padding: const EdgeInsets.all(9), + child: Row( + children: [ + ClipRRect( + borderRadius: BorderRadius.circular(8), + child: RemoteImage(drama.posterUrl, width: 72, height: 96), + ), + const SizedBox(width: 12), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + drama.title, + maxLines: 2, + overflow: TextOverflow.ellipsis, + style: const TextStyle( + color: Colors.white, + fontSize: 15, + fontWeight: FontWeight.w700, + ), + ), + const SizedBox(height: 5), + Text( + episodeLabel, + key: ValueKey('watch-record-episode-${record.dramaId}'), + style: const TextStyle( + color: AppColors.muted, + fontSize: 12, + ), + ), + const SizedBox(height: 7), + ClipRRect( + borderRadius: BorderRadius.circular(4), + child: LinearProgressIndicator( + minHeight: 4, + value: record.progress.fraction, + ), + ), + const SizedBox(height: 6), + Text( + l10n.resumeProgress( + _clock(record.progress.position), + _clock(record.progress.duration), + ), + style: const TextStyle( + color: AppColors.blueSoft, + fontSize: 11, + ), + ), + if (record.progress.updatedAt != null) + Text( + l10n.updatedAtLabel( + _formatUpdatedAt(record.progress.updatedAt!), + ), + key: ValueKey('watch-record-updated-${record.dramaId}'), + style: const TextStyle( + color: Color(0xFF8D8990), + fontSize: 11, + ), + ), + ], + ), + ), + IconButton( + key: ValueKey('watch-record-remove-${record.dramaId}'), + tooltip: l10n.remove, + onPressed: onRemove, + icon: const Icon(Icons.close_rounded), + ), + ], + ), + ), + ), + ); + } +} + +class _FailedRecordTile extends StatelessWidget { + const _FailedRecordTile({required this.record, required this.onRetry}); + + final WatchRecord record; + final VoidCallback onRetry; + + @override + Widget build(BuildContext context) { + final l10n = AppLocalizations.of(context)!; + return Container( + key: ValueKey('watch-record-failed-${record.dramaId}'), + padding: const EdgeInsets.all(14), + decoration: BoxDecoration( + color: AppColors.card, + borderRadius: BorderRadius.circular(12), + ), + child: Row( + children: [ + const Icon(Icons.broken_image_outlined, color: Colors.white38), + const SizedBox(width: 12), + Expanded( + child: Text( + l10n.detailLoadFailed, + style: const TextStyle(color: Colors.white70), + ), + ), + TextButton( + key: ValueKey('watch-record-retry-${record.dramaId}'), + onPressed: onRetry, + child: Text(l10n.retryDetail), + ), + ], + ), + ); + } +} + +class _FailureState extends StatelessWidget { + const _FailureState({required this.message, required this.onRetry}); + + final String message; + final Future Function() onRetry; + + @override + Widget build(BuildContext context) { + final l10n = AppLocalizations.of(context)!; + return Center( + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 32), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Text( + message, + textAlign: TextAlign.center, + style: const TextStyle(color: Colors.white70), + ), + const SizedBox(height: 14), + FilledButton( + onPressed: () => unawaited(onRetry()), + child: Text(l10n.retry), + ), + ], + ), + ), + ); + } +} + +String _clock(Duration value) { + final minutes = value.inMinutes; + final seconds = value.inSeconds.remainder(60); + return '$minutes:${seconds.toString().padLeft(2, '0')}'; +} + +String _formatUpdatedAt(DateTime value) { + final local = value.toLocal(); + final month = local.month.toString().padLeft(2, '0'); + final day = local.day.toString().padLeft(2, '0'); + final hour = local.hour.toString().padLeft(2, '0'); + final minute = local.minute.toString().padLeft(2, '0'); + return '${local.year}-$month-$day $hour:$minute'; +} diff --git a/test/category/category_controller_test.dart b/test/category/category_controller_test.dart new file mode 100644 index 0000000..6ade3eb --- /dev/null +++ b/test/category/category_controller_test.dart @@ -0,0 +1,179 @@ +// Author: fruit.com.cn + +import 'dart:convert'; + +import 'package:flutter_test/flutter_test.dart'; +import 'package:fruitshorts/core/data/models/content_category.dart'; +import 'package:fruitshorts/core/data/models/drama.dart'; +import 'package:fruitshorts/core/data/models/home_feed.dart'; +import 'package:fruitshorts/core/data/remote/api_client.dart'; +import 'package:fruitshorts/core/data/remote/category_api.dart'; +import 'package:fruitshorts/core/data/repositories/category_repository.dart'; +import 'package:fruitshorts/core/data/services/category_controller.dart'; + +import '../support/fake_http_adapter.dart'; + +Drama _drama(String id) => Drama( + id: id, + title: 'Drama $id', + synopsis: 'synopsis', + posterUrl: '/files/$id.png', +); + +void main() { + test( + 'should_keep_snowflake_category_id_as_string_when_api_returns_list', + () async { + const id = '2111012753262120962'; + final adapter = FakeHttpAdapter( + (_) async => FakeHttpResponse( + jsonEncode({ + 'code': 0, + 'message': 'ok', + 'data': [ + {'id': id, 'name': 'Romance'}, + ], + }), + ), + ); + final client = ApiClient( + baseUrl: 'http://127.0.0.1:8081', + adapter: adapter, + ); + + final categories = await CategoryApi(client).list(); + + expect(categories.single.id, id); + expect(categories.single.name, 'Romance'); + expect(adapter.requests.single.uri.path, '/app/categories'); + }, + ); + + test( + 'should_map_category_id_to_discover_section_when_category_is_selected', + () async { + final repository = ScriptedCategoryRepository( + categories: const [ + ContentCategory(id: '7', name: 'Romance'), + ContentCategory(id: '8', name: 'Action'), + ], + feed: HomeFeed( + sections: [ + FeedSection(code: 'hot', title: 'Hot', dramas: [_drama('hot-1')]), + FeedSection(code: 'new', title: 'New', dramas: [_drama('new-1')]), + FeedSection( + code: 'category-7', + title: 'Romance', + dramas: [_drama('romance-1')], + ), + ], + ), + ); + final controller = CategoryController(repository); + + await controller.load(); + controller.selectCategory('7'); + + expect(controller.selectedCode, 'category-7'); + expect(controller.visibleDramas.map((drama) => drama.id), ['romance-1']); + expect(controller.selectedSectionMissing, isFalse); + + controller.selectCategory('8'); + expect(controller.selectedCode, 'category-8'); + expect(controller.visibleDramas, isEmpty); + expect(controller.selectedSectionMissing, isTrue); + }, + ); + + test( + 'should_keep_hot_and_new_entries_when_discover_feed_provides_them', + () async { + final repository = ScriptedCategoryRepository( + feed: HomeFeed( + sections: [ + FeedSection(code: 'hot', title: 'Hot', dramas: [_drama('hot-1')]), + FeedSection(code: 'new', title: 'New', dramas: [_drama('new-1')]), + FeedSection( + code: 'category-7', + title: 'Romance', + dramas: [_drama('romance-1')], + ), + ], + ), + ); + final controller = CategoryController(repository); + + await controller.load(); + controller.selectCode(CategoryController.hotCode); + expect(controller.visibleDramas.map((drama) => drama.id), ['hot-1']); + + controller.selectCode(CategoryController.newCode); + expect(controller.visibleDramas.map((drama) => drama.id), ['new-1']); + }, + ); + + test('should_dedupe_dramas_when_all_categories_are_selected', () async { + final repository = ScriptedCategoryRepository( + feed: HomeFeed( + sections: [ + FeedSection(code: 'hot', title: 'Hot', dramas: [_drama('same')]), + FeedSection( + code: 'category-7', + title: 'Romance', + dramas: [_drama('same'), _drama('other')], + ), + ], + ), + ); + final controller = CategoryController(repository); + + await controller.load(); + + expect(controller.selectedCode, CategoryController.allCode); + expect(controller.visibleDramas.map((drama) => drama.id), [ + 'same', + 'other', + ]); + }); + + test('should_clear_error_and_retry_when_initial_load_fails', () async { + final repository = ScriptedCategoryRepository(fail: true); + final controller = CategoryController(repository); + + await controller.load(); + expect(controller.error, 'categoriesError'); + expect(controller.loading, isFalse); + + repository.fail = false; + await controller.load(); + + expect(controller.error, isNull); + expect(repository.loads, 2); + }); +} + +class ScriptedCategoryRepository implements CategoryRepository { + ScriptedCategoryRepository({ + this.categories = const [], + this.feed = const HomeFeed(), + this.fail = false, + }); + + List categories; + HomeFeed feed; + bool fail; + int loads = 0; + + @override + Future> fetchCategories() async { + loads++; + if (fail) throw StateError('offline'); + return categories; + } + + @override + Future fetchDiscoverFeed() async { + if (fail) throw StateError('offline'); + return feed; + } +} diff --git a/test/discover/discover_logic_test.dart b/test/discover/discover_logic_test.dart index ba93cc2..55fc790 100644 --- a/test/discover/discover_logic_test.dart +++ b/test/discover/discover_logic_test.dart @@ -34,7 +34,6 @@ void main() { expect(await logic.position, const Duration(seconds: 4)); expect(history.reads, ['signal']); - expect(logic.category, 0); expect(logic.searchOpen, isFalse); logic.dispose(); }); @@ -78,18 +77,6 @@ void main() { logic.dispose(); }); - test('should_store_index_and_notify_once_when_category_is_selected', () { - final logic = DiscoverLogic(history: FakeWatchHistory(), drama: _drama('s')); - var notifications = 0; - logic.addListener(() => notifications++); - - logic.selectCategory(3); - - expect(logic.category, 3); - expect(notifications, 1); - logic.dispose(); - }); - test('should_show_search_when_flag_is_on_or_text_is_typed', () { final logic = DiscoverLogic(history: FakeWatchHistory(), drama: _drama('s')); diff --git a/test/download/download_api_test.dart b/test/download/download_api_test.dart new file mode 100644 index 0000000..1f4339a --- /dev/null +++ b/test/download/download_api_test.dart @@ -0,0 +1,118 @@ +// Author: fruit.com.cn + +import 'dart:convert'; + +import 'package:flutter_test/flutter_test.dart'; +import 'package:fruitshorts/core/data/remote/api_client.dart'; +import 'package:fruitshorts/core/data/remote/download_api.dart'; + +import '../support/fake_http_adapter.dart'; + +void main() { + String envelope(Object? data) => + jsonEncode({'code': 0, 'message': 'ok', 'data': data}); + + Map licenseJson({int progress = 35}) => { + 'licenseId': '2111012753262120962', + 'dramaId': '2111012753262120963', + 'dramaTitle': 'The Signal', + 'episodeId': '2111012753262120964', + 'episodeNo': 2, + 'deviceId': 'device-9', + 'quality': '720P', + 'playUrl': '/files/episode.mp4?e=1&s=sig', + 'licenseKey': 'license-key', + 'status': 'ACTIVE', + 'grantedAt': '2026-10-17T12:00:00', + 'expireAt': '2026-11-16T12:00:00', + 'taskStatus': 'DOWNLOADING', + 'progressPercent': progress, + 'downloadedBytes': '1024', + 'totalBytes': '4096', + 'errorMsg': '', + }; + + test( + 'should_call_all_download_contracts_and_parse_string_ids_when_api_is_used', + () async { + final adapter = FakeHttpAdapter((options) async { + final path = options.uri.path; + if (path == '/app/downloads/policy') { + return FakeHttpResponse( + envelope({ + 'maxPerDevice': 20, + 'licenseDays': 30, + 'wifiOnly': true, + 'maxQuality': 'AUTO', + 'maxStorageBytes': '0', + 'used': 1, + 'remaining': 19, + 'expirePolicyText': '30 days', + }), + ); + } + if (path == '/app/downloads/settings') { + return FakeHttpResponse(envelope(null)); + } + if (path == '/app/downloads' && options.method == 'DELETE') { + return FakeHttpResponse(envelope(2)); + } + if (path == '/app/downloads') { + return FakeHttpResponse( + envelope(options.method == 'GET' ? [licenseJson()] : licenseJson()), + ); + } + return FakeHttpResponse(envelope(licenseJson(progress: 80))); + }); + final client = ApiClient( + baseUrl: 'http://127.0.0.1:8081', + adapter: adapter, + ); + final api = DownloadApi(client); + + final policy = await api.policy(); + await api.updateSettings(wifiOnly: false, maxQuality: '1080P'); + final granted = await api.grant('2111012753262120964'); + final listed = await api.list(); + final refreshed = await api.refreshUrl('2111012753262120964'); + final progress = await api.reportProgress( + '2111012753262120964', + status: 'DOWNLOADING', + progressPercent: 80, + ); + await api.remove('2111012753262120964'); + final cleared = await api.clear(); + + expect(policy.remaining, 19); + expect(policy.expirePolicyText, '30 days'); + expect(granted.licenseId, '2111012753262120962'); + expect(granted.dramaId, '2111012753262120963'); + expect(granted.episodeId, '2111012753262120964'); + expect(listed.single.taskStatus, 'DOWNLOADING'); + expect(refreshed.taskStatus, 'DOWNLOADING'); + expect(progress.progressPercent, 80); + expect(cleared, 2); + + expect( + adapter.requests.map( + (request) => '${request.method} ${request.uri.path}', + ), + [ + 'GET /app/downloads/policy', + 'PUT /app/downloads/settings', + 'POST /app/downloads', + 'GET /app/downloads', + 'GET /app/downloads/2111012753262120964/url', + 'POST /app/downloads/2111012753262120964/progress', + 'DELETE /app/downloads/2111012753262120964', + 'DELETE /app/downloads', + ], + ); + expect(adapter.requests[2].data, {'episodeId': '2111012753262120964'}); + expect(adapter.requests[1].data, { + 'wifiOnly': false, + 'maxQuality': '1080P', + }); + }, + ); +} diff --git a/test/download/download_controller_test.dart b/test/download/download_controller_test.dart new file mode 100644 index 0000000..ad30d81 --- /dev/null +++ b/test/download/download_controller_test.dart @@ -0,0 +1,178 @@ +// Author: fruit.com.cn + +import 'package:flutter_test/flutter_test.dart'; +import 'package:fruitshorts/core/data/models/download_license.dart'; +import 'package:fruitshorts/core/data/models/download_policy.dart'; +import 'package:fruitshorts/core/data/remote/api_exception.dart'; +import 'package:fruitshorts/core/data/repositories/download_repository.dart'; +import 'package:fruitshorts/core/data/services/download_controller.dart'; + +DownloadPolicy _policy({bool wifiOnly = true, int remaining = 19}) => + DownloadPolicy( + maxPerDevice: 20, + licenseDays: 30, + wifiOnly: wifiOnly, + maxQuality: 'AUTO', + maxStorageBytes: 0, + used: 20 - remaining, + remaining: remaining, + expirePolicyText: '30 days', + ); + +DownloadLicense _license(String episodeId) => DownloadLicense( + licenseId: 'license-$episodeId', + dramaId: 'drama-1', + dramaTitle: 'The Signal', + episodeId: episodeId, + episodeNo: 1, + deviceId: 'device-9', + quality: '720P', + playUrl: '', + licenseKey: '', + status: 'ACTIVE', + grantedAt: DateTime(2026, 10, 17), + expireAt: DateTime(2026, 11, 16), + taskStatus: 'QUEUED', + progressPercent: 0, + downloadedBytes: 0, + totalBytes: 100, + errorMsg: '', +); + +void main() { + test('should_load_policy_and_licenses_when_page_opens', () async { + final repository = ScriptedDownloadRepository( + policy: _policy(), + licenses: [_license('1')], + ); + final controller = DownloadController(repository); + + await controller.load(); + + expect(controller.loading, isFalse); + expect(controller.error, isNull); + expect(controller.policy?.remaining, 19); + expect(controller.licenses.single.taskStatus, 'QUEUED'); + }); + + test('should_show_backend_message_when_grant_is_rejected', () async { + final repository = ScriptedDownloadRepository( + policy: _policy(), + grantError: const ApiException(200003, 'download quota is full'), + ); + final controller = DownloadController(repository); + + final result = await controller.grant('episode-1'); + + expect(result.ok, isFalse); + expect(result.message, 'download quota is full'); + }); + + test('should_rollback_wifi_setting_when_update_fails', () async { + final repository = ScriptedDownloadRepository( + policy: _policy(wifiOnly: true), + failSettings: true, + ); + final controller = DownloadController(repository); + await controller.load(); + + final ok = await controller.updateSettings(wifiOnly: false); + + expect(ok, isFalse); + expect(controller.policy?.wifiOnly, isTrue); + }); + + test('should_restore_license_when_delete_fails', () async { + final repository = ScriptedDownloadRepository( + policy: _policy(), + licenses: [_license('1'), _license('2')], + failRemove: true, + ); + final controller = DownloadController(repository); + await controller.load(); + + final ok = await controller.remove('1'); + + expect(ok, isFalse); + expect(controller.licenses.map((item) => item.episodeId), ['1', '2']); + }); + + test('should_restore_licenses_when_clear_fails', () async { + final repository = ScriptedDownloadRepository( + policy: _policy(), + licenses: [_license('1'), _license('2')], + failClear: true, + ); + final controller = DownloadController(repository); + await controller.load(); + + final ok = await controller.clear(); + + expect(ok, isFalse); + expect(controller.licenses, hasLength(2)); + }); +} + +class ScriptedDownloadRepository implements DownloadRepository { + ScriptedDownloadRepository({ + required this.policy, + this.licenses = const [], + this.grantError, + this.failSettings = false, + this.failRemove = false, + this.failClear = false, + }); + + DownloadPolicy policy; + List licenses; + ApiException? grantError; + bool failSettings; + bool failRemove; + bool failClear; + + @override + Future fetchPolicy() async => policy; + + @override + Future> list() async => licenses; + + @override + Future grant(String episodeId, {String? quality}) async { + if (grantError != null) throw grantError!; + return _license(episodeId); + } + + @override + Future updateSettings({bool? wifiOnly, String? maxQuality}) async { + if (failSettings) throw StateError('settings unavailable'); + } + + @override + Future refreshUrl(String episodeId) async => + _license(episodeId); + + @override + Future reportProgress( + String episodeId, { + String? deviceId, + String? status, + int? progressPercent, + int? downloadedBytes, + int? totalBytes, + String? errorMsg, + }) async => _license(episodeId); + + @override + Future remove(String episodeId) async { + if (failRemove) throw StateError('remove unavailable'); + licenses = licenses.where((item) => item.episodeId != episodeId).toList(); + } + + @override + Future clear() async { + if (failClear) throw StateError('clear unavailable'); + final count = licenses.length; + licenses = const []; + return count; + } +} diff --git a/test/download/downloads_page_test.dart b/test/download/downloads_page_test.dart new file mode 100644 index 0000000..fe64f1e --- /dev/null +++ b/test/download/downloads_page_test.dart @@ -0,0 +1,284 @@ +// Author: fruit.com.cn + +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:fruitshorts/core/data/models/download_license.dart'; +import 'package:fruitshorts/core/data/models/download_policy.dart'; +import 'package:fruitshorts/core/data/remote/api_client.dart'; +import 'package:fruitshorts/core/data/remote/auth_api.dart'; +import 'package:fruitshorts/core/data/repositories/download_repository.dart'; +import 'package:fruitshorts/core/data/services/auth_controller.dart'; +import 'package:fruitshorts/core/data/services/auth_session_store.dart'; +import 'package:fruitshorts/core/data/services/download_controller.dart'; +import 'package:fruitshorts/l10n/app_localizations.dart'; +import 'package:fruitshorts/pages/downloads/downloads_page.dart'; +import 'package:provider/provider.dart'; +import 'package:shared_preferences_platform_interface/in_memory_shared_preferences_async.dart'; +import 'package:shared_preferences_platform_interface/shared_preferences_async_platform_interface.dart'; + +import '../support/fake_http_adapter.dart'; + +DownloadPolicy _policy({ + bool wifiOnly = true, + String maxQuality = 'AUTO', +}) => DownloadPolicy( + maxPerDevice: 20, + licenseDays: 30, + wifiOnly: wifiOnly, + maxQuality: maxQuality, + maxStorageBytes: 0, + used: 1, + remaining: 19, + expirePolicyText: 'Licenses last 30 days', +); + +DownloadLicense _license(String episodeId) => DownloadLicense( + licenseId: 'license-$episodeId', + dramaId: 'drama-1', + dramaTitle: 'The Signal', + episodeId: episodeId, + episodeNo: 2, + deviceId: 'device-9', + quality: '720P', + playUrl: '', + licenseKey: '', + status: 'ACTIVE', + grantedAt: DateTime(2026, 10, 17, 12), + expireAt: DateTime(2026, 11, 16, 12), + taskStatus: 'DOWNLOADING', + progressPercent: 35, + downloadedBytes: 1024, + totalBytes: 4096, + errorMsg: '', +); + +void main() { + setUp(() { + SharedPreferencesAsyncPlatform.instance = + InMemorySharedPreferencesAsync.empty(); + }); + + testWidgets( + 'should_render_policy_and_backend_status_values_when_page_loads', + (tester) async { + final auth = await _auth(signedIn: true); + final repository = FakeDownloadRepository( + policy: _policy(), + licenses: [_license('1')], + ); + final controller = DownloadController(repository); + + await _pumpPage(tester, auth: auth, controller: controller); + + expect(find.byKey(const Key('downloads-page')), findsOneWidget); + expect(find.byKey(const Key('download-policy')), findsOneWidget); + expect(find.text('Licenses last 30 days'), findsOneWidget); + expect(find.byKey(const Key('download-license-1')), findsOneWidget); + expect(find.textContaining('ACTIVE'), findsOneWidget); + expect(find.textContaining('DOWNLOADING'), findsOneWidget); + expect(find.textContaining('35%'), findsOneWidget); + }, + ); + + testWidgets('should_show_empty_state_when_license_list_is_empty', ( + tester, + ) async { + final auth = await _auth(signedIn: true); + final repository = FakeDownloadRepository(policy: _policy()); + final controller = DownloadController(repository); + + await _pumpPage(tester, auth: auth, controller: controller); + + expect(find.byKey(const Key('downloads-empty')), findsOneWidget); + }); + + testWidgets('should_show_retry_when_policy_or_list_load_fails', ( + tester, + ) async { + final auth = await _auth(signedIn: true); + final repository = FakeDownloadRepository( + policy: _policy(), + failLoad: true, + ); + final controller = DownloadController(repository); + + await _pumpPage(tester, auth: auth, controller: controller); + + expect(find.byKey(const Key('downloads-error')), findsOneWidget); + expect(find.byKey(const Key('downloads-retry')), findsOneWidget); + }); + + testWidgets('should_show_auth_gate_without_loading_when_signed_out', ( + tester, + ) async { + final auth = await _auth(signedIn: false); + final repository = FakeDownloadRepository(policy: _policy()); + final controller = DownloadController(repository); + + await _pumpPage(tester, auth: auth, controller: controller); + + expect(find.byKey(const Key('auth-gate-panel')), findsOneWidget); + expect(repository.loadCalls, 0); + }); + + testWidgets('should_update_wifi_preference_when_switch_is_tapped', ( + tester, + ) async { + final auth = await _auth(signedIn: true); + final repository = FakeDownloadRepository(policy: _policy()); + final controller = DownloadController(repository); + + await _pumpPage(tester, auth: auth, controller: controller); + await tester.tap(find.byKey(const Key('download-wifi-switch'))); + await tester.pumpAndSettle(); + + expect(repository.settingsCalls, 1); + expect(repository.lastWifiOnly, isFalse); + }); + + testWidgets('should_clear_authorizations_only_after_confirmation', ( + tester, + ) async { + final auth = await _auth(signedIn: true); + final repository = FakeDownloadRepository( + policy: _policy(), + licenses: [_license('1')], + ); + final controller = DownloadController(repository); + + await _pumpPage(tester, auth: auth, controller: controller); + await tester.tap(find.byKey(const Key('download-clear'))); + await tester.pumpAndSettle(); + expect(repository.clearCalls, 0); + + await tester.tap(find.widgetWithText(FilledButton, 'Clear')); + await tester.pumpAndSettle(); + + expect(repository.clearCalls, 1); + expect(find.byKey(const Key('downloads-empty')), findsOneWidget); + }); + + testWidgets('should_render_unique_quality_options_when_policy_uses_a_preset', ( + tester, + ) async { + final auth = await _auth(signedIn: true); + final repository = FakeDownloadRepository( + policy: _policy(maxQuality: '720P'), + ); + final controller = DownloadController(repository); + + await _pumpPage(tester, auth: auth, controller: controller); + + expect(tester.takeException(), isNull); + expect(find.byKey(const Key('download-quality')), findsOneWidget); + }); +} + +Future _auth({required bool signedIn}) async { + if (signedIn) { + SharedPreferencesAsyncPlatform.instance = + InMemorySharedPreferencesAsync.withData({ + 'auth.accessToken': 'test-access', + 'auth.refreshToken': 'test-refresh', + 'auth.user': '{"uid":"1","nickname":"Viewer","avatarUrl":""}', + }); + } + final client = ApiClient( + baseUrl: 'http://127.0.0.1:8081', + adapter: FakeHttpAdapter( + (_) async => FakeHttpResponse('{"code":0,"message":"ok","data":null}'), + ), + ); + final auth = AuthController(AuthApi(client), AuthSessionStore()); + await auth.load(); + return auth; +} + +Future _pumpPage( + WidgetTester tester, { + required AuthController auth, + required DownloadController controller, +}) async { + await tester.pumpWidget( + MultiProvider( + providers: [ + ChangeNotifierProvider.value(value: auth), + ChangeNotifierProvider.value(value: controller), + ], + child: MaterialApp( + locale: const Locale('en'), + localizationsDelegates: AppLocalizations.localizationsDelegates, + supportedLocales: AppLocalizations.supportedLocales, + home: const DownloadsPage(), + ), + ), + ); + await tester.pumpAndSettle(); +} + +class FakeDownloadRepository implements DownloadRepository { + FakeDownloadRepository({ + required this.policy, + this.licenses = const [], + this.failLoad = false, + }); + + DownloadPolicy policy; + List licenses; + bool failLoad; + int loadCalls = 0; + int settingsCalls = 0; + int clearCalls = 0; + bool? lastWifiOnly; + + @override + Future fetchPolicy() async { + loadCalls++; + if (failLoad) throw StateError('offline'); + return policy; + } + + @override + Future> list() async { + if (failLoad) throw StateError('offline'); + return licenses; + } + + @override + Future grant(String episodeId, {String? quality}) async => + _license(episodeId); + + @override + Future updateSettings({bool? wifiOnly, String? maxQuality}) async { + settingsCalls++; + lastWifiOnly = wifiOnly; + } + + @override + Future refreshUrl(String episodeId) async => + _license(episodeId); + + @override + Future reportProgress( + String episodeId, { + String? deviceId, + String? status, + int? progressPercent, + int? downloadedBytes, + int? totalBytes, + String? errorMsg, + }) async => _license(episodeId); + + @override + Future remove(String episodeId) async { + licenses = licenses.where((item) => item.episodeId != episodeId).toList(); + } + + @override + Future clear() async { + clearCalls++; + final count = licenses.length; + licenses = const []; + return count; + } +} diff --git a/test/library/favorite_controller_test.dart b/test/library/favorite_controller_test.dart index 335b2e0..0e5a96c 100644 --- a/test/library/favorite_controller_test.dart +++ b/test/library/favorite_controller_test.dart @@ -77,18 +77,33 @@ void main() { final repository = InMemoryFavoriteRepository( saved: {'signal'}, cards: [_card('signal')], - ); + )..failRemove = true; final controller = FavoriteController(repository); await controller.load(); final ok = await controller.remove('signal'); - // InMemory 实现的 remove 不会失败,这里断言正常路径:状态与列表一起清掉 - expect(ok, isTrue); - expect(controller.isSaved('signal'), isFalse); - expect(controller.cards, isEmpty); + expect(ok, isFalse); + expect(controller.isSaved('signal'), isTrue); + expect(controller.cards.map((drama) => drama.id), ['signal']); }); + test( + 'should_restore_removed_card_at_original_position_when_remove_fails', + () async { + final repository = InMemoryFavoriteRepository( + saved: {'signal', 'city'}, + cards: [_card('signal'), _card('city')], + )..failRemove = true; + final controller = FavoriteController(repository); + await controller.load(); + + await controller.remove('signal'); + + expect(controller.cards.map((drama) => drama.id), ['signal', 'city']); + }, + ); + test('should_clear_state_when_signing_out', () async { final controller = FavoriteController( InMemoryFavoriteRepository(saved: {'signal'}, cards: [_card('signal')]), diff --git a/test/library/favorites_page_test.dart b/test/library/favorites_page_test.dart new file mode 100644 index 0000000..b49548a --- /dev/null +++ b/test/library/favorites_page_test.dart @@ -0,0 +1,153 @@ +// Author: fruit.com.cn + +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:fruitshorts/core/data/models/drama.dart'; +import 'package:fruitshorts/core/data/remote/api_client.dart'; +import 'package:fruitshorts/core/data/remote/auth_api.dart'; +import 'package:fruitshorts/core/data/repositories/favorite_repository.dart'; +import 'package:fruitshorts/core/data/services/auth_controller.dart'; +import 'package:fruitshorts/core/data/services/auth_session_store.dart'; +import 'package:fruitshorts/core/data/services/favorite_controller.dart'; +import 'package:fruitshorts/l10n/app_localizations.dart'; +import 'package:fruitshorts/pages/favorites/favorites_page.dart'; +import 'package:provider/provider.dart'; +import 'package:shared_preferences_platform_interface/in_memory_shared_preferences_async.dart'; +import 'package:shared_preferences_platform_interface/shared_preferences_async_platform_interface.dart'; + +import '../support/fake_http_adapter.dart'; + +Drama _card(String id) => Drama( + id: id, + title: 'Drama $id', + synopsis: 'synopsis', + posterUrl: '/files/$id.png', + totalEpisodes: 12, +); + +void main() { + setUp(() { + SharedPreferencesAsyncPlatform.instance = + InMemorySharedPreferencesAsync.empty(); + }); + + testWidgets('should_render_favorite_cards_and_visible_remove_action', ( + tester, + ) async { + final auth = await _auth(signedIn: true); + final favorites = FavoriteController( + InMemoryFavoriteRepository( + saved: {'signal', 'city'}, + cards: [_card('signal'), _card('city')], + ), + ); + + await _pumpPage(tester, auth: auth, favorites: favorites); + + expect(find.text('Drama signal'), findsOneWidget); + expect(find.text('Drama city'), findsOneWidget); + expect(find.byKey(const Key('favorite-remove-signal')), findsOneWidget); + }); + + testWidgets('should_keep_card_and_show_failure_when_remove_fails', ( + tester, + ) async { + final auth = await _auth(signedIn: true); + final repository = InMemoryFavoriteRepository( + saved: {'signal'}, + cards: [_card('signal')], + )..failRemove = true; + final favorites = FavoriteController(repository); + + await _pumpPage(tester, auth: auth, favorites: favorites); + await tester.tap(find.byKey(const Key('favorite-remove-signal'))); + await tester.pumpAndSettle(); + + expect(find.text('Drama signal'), findsOneWidget); + expect( + find.text('Could not update favorites. Please retry.'), + findsOneWidget, + ); + }); + + testWidgets('should_show_empty_state_when_favorite_list_is_empty', ( + tester, + ) async { + final auth = await _auth(signedIn: true); + final favorites = FavoriteController(InMemoryFavoriteRepository()); + + await _pumpPage(tester, auth: auth, favorites: favorites); + + expect(find.byKey(const Key('favorites-empty')), findsOneWidget); + }); + + testWidgets('should_show_retry_when_favorite_list_fails', (tester) async { + final auth = await _auth(signedIn: true); + final repository = InMemoryFavoriteRepository()..failList = true; + final favorites = FavoriteController(repository); + + await _pumpPage(tester, auth: auth, favorites: favorites); + + expect(find.byKey(const Key('favorites-error')), findsOneWidget); + expect(find.byKey(const Key('favorites-retry')), findsOneWidget); + }); + + testWidgets( + 'should_show_auth_gate_without_loading_favorites_when_signed_out', + (tester) async { + final auth = await _auth(signedIn: false); + final repository = InMemoryFavoriteRepository( + saved: {'signal'}, + cards: [_card('signal')], + ); + final favorites = FavoriteController(repository); + + await _pumpPage(tester, auth: auth, favorites: favorites); + + expect(find.byKey(const Key('auth-gate-panel')), findsOneWidget); + expect(repository.listCalls, 0); + }, + ); +} + +Future _auth({required bool signedIn}) async { + if (signedIn) { + SharedPreferencesAsyncPlatform.instance = + InMemorySharedPreferencesAsync.withData({ + 'auth.accessToken': 'test-access', + 'auth.refreshToken': 'test-refresh', + 'auth.user': '{"uid":"1","nickname":"Viewer","avatarUrl":""}', + }); + } + final client = ApiClient( + baseUrl: 'http://127.0.0.1:8081', + adapter: FakeHttpAdapter( + (_) async => FakeHttpResponse('{"code":0,"message":"ok","data":null}'), + ), + ); + final auth = AuthController(AuthApi(client), AuthSessionStore()); + await auth.load(); + return auth; +} + +Future _pumpPage( + WidgetTester tester, { + required AuthController auth, + required FavoriteController favorites, +}) async { + await tester.pumpWidget( + MultiProvider( + providers: [ + ChangeNotifierProvider.value(value: auth), + ChangeNotifierProvider.value(value: favorites), + ], + child: MaterialApp( + locale: const Locale('en'), + localizationsDelegates: AppLocalizations.localizationsDelegates, + supportedLocales: AppLocalizations.supportedLocales, + home: const FavoritesPage(), + ), + ), + ); + await tester.pumpAndSettle(); +} diff --git a/test/support/fake_category.dart b/test/support/fake_category.dart new file mode 100644 index 0000000..b18fbb1 --- /dev/null +++ b/test/support/fake_category.dart @@ -0,0 +1,23 @@ +// Author: fruit.com.cn + +import 'package:fruitshorts/core/data/models/content_category.dart'; +import 'package:fruitshorts/core/data/models/home_feed.dart'; +import 'package:fruitshorts/core/data/repositories/catalog_repository.dart'; +import 'package:fruitshorts/core/data/repositories/category_repository.dart'; + +/// 分类测试仓库:分类清单固定,发现 feed 复用注入的目录仓库。 +class FakeCategoryRepository implements CategoryRepository { + FakeCategoryRepository({ + required this.catalog, + this.categories = const [ContentCategory(id: '7', name: 'Romance')], + }); + + final CatalogRepository catalog; + final List categories; + + @override + Future> fetchCategories() async => categories; + + @override + Future fetchDiscoverFeed() => catalog.fetchDiscoverFeed(); +} diff --git a/test/support/fake_watch_history.dart b/test/support/fake_watch_history.dart index 6568866..6616b7a 100644 --- a/test/support/fake_watch_history.dart +++ b/test/support/fake_watch_history.dart @@ -64,4 +64,10 @@ class FakeWatchHistory implements WatchHistoryRepository { @override Future remove(String dramaId) async => records.remove(dramaId); + + @override + Future clear() async { + records.clear(); + recentRecords = const []; + } } diff --git a/test/watch/watch_records_controller_test.dart b/test/watch/watch_records_controller_test.dart new file mode 100644 index 0000000..c3d787e --- /dev/null +++ b/test/watch/watch_records_controller_test.dart @@ -0,0 +1,225 @@ +// Author: fruit.com.cn + +import 'dart:async'; + +import 'package:flutter_test/flutter_test.dart'; +import 'package:fruitshorts/core/data/models/drama.dart'; +import 'package:fruitshorts/core/data/models/home_feed.dart'; +import 'package:fruitshorts/core/data/models/watch_progress.dart'; +import 'package:fruitshorts/core/data/repositories/catalog_repository.dart'; +import 'package:fruitshorts/core/data/repositories/watch_history_repository.dart'; +import 'package:fruitshorts/core/data/services/watch_records_controller.dart'; + +WatchProgress _progress( + String dramaId, { + String episodeId = 'episode-1', + int positionMs = 12000, + int durationMs = 60000, +}) => WatchProgress( + dramaId: dramaId, + episodeId: episodeId, + position: Duration(milliseconds: positionMs), + duration: Duration(milliseconds: durationMs), + updatedAt: DateTime(2026, 10, 17, 12), +); + +Drama _detail(String id) => Drama( + id: id, + title: 'Drama $id', + synopsis: 'synopsis', + posterUrl: '/files/$id.png', + detailLoaded: true, + episodes: const [ + Episode(id: 'episode-1', number: 1, title: 'Episode 1', isFree: true), + ], +); + +void main() { + test( + 'should_parse_updated_time_and_keep_string_ids_when_recent_json_arrives', + () { + final progress = WatchProgress.fromJson({ + 'dramaId': '2111012753262120962', + 'episodeId': '2111012753262120963', + 'positionMs': '12000', + 'durationMs': '60000', + 'updatedAt': '2026-10-17T12:34:56', + }); + + expect(progress.dramaId, '2111012753262120962'); + expect(progress.episodeId, '2111012753262120963'); + expect(progress.updatedAt, DateTime(2026, 10, 17, 12, 34, 56)); + }, + ); + + test('should_dedupe_detail_requests_and_cap_concurrency_at_four', () async { + final history = ControlledWatchHistory([ + for (var index = 0; index < 6; index++) _progress('$index'), + _progress('0'), + ]); + final catalog = ScriptedWatchCatalog(); + final controller = WatchRecordsController( + history: history, + catalog: catalog, + ); + + await controller.load(); + + expect(controller.records, hasLength(6)); + expect(catalog.calls, hasLength(6)); + expect(catalog.maxActive, 4); + expect(controller.error, isNull); + }); + + test('should_keep_other_records_when_one_detail_request_fails', () async { + final history = ControlledWatchHistory([_progress('1'), _progress('2')]); + final catalog = ScriptedWatchCatalog(failedIds: {'1'}); + final controller = WatchRecordsController( + history: history, + catalog: catalog, + ); + + await controller.load(); + + expect(controller.records, hasLength(2)); + expect(controller.records.first.detailFailed, isTrue); + expect(controller.records.first.drama, isNull); + expect(controller.records.last.drama?.id, '2'); + + catalog.failedIds.clear(); + await controller.retryDetail('1'); + expect(controller.records.first.detailFailed, isFalse); + expect(controller.records.first.drama?.id, '1'); + }); + + test( + 'should_remove_record_optimistically_and_restore_it_when_delete_fails', + () async { + final history = ControlledWatchHistory([_progress('1'), _progress('2')]); + final controller = WatchRecordsController( + history: history, + catalog: ScriptedWatchCatalog(), + ); + await controller.load(); + final gate = Completer(); + history.removeGate = gate; + history.failRemove = true; + + final pending = controller.remove('1'); + await Future.delayed(Duration.zero); + expect(controller.records.map((record) => record.dramaId), ['2']); + + gate.complete(); + expect(await pending, isFalse); + expect(controller.records.map((record) => record.dramaId), ['1', '2']); + expect(controller.actionError, 'recordDeleteFailed'); + }, + ); + + test( + 'should_clear_records_optimistically_and_restore_them_when_clear_fails', + () async { + final history = ControlledWatchHistory([_progress('1'), _progress('2')]); + final controller = WatchRecordsController( + history: history, + catalog: ScriptedWatchCatalog(), + ); + await controller.load(); + final gate = Completer(); + history.clearGate = gate; + history.failClear = true; + + final pending = controller.clear(); + await Future.delayed(Duration.zero); + expect(controller.records, isEmpty); + + gate.complete(); + expect(await pending, isFalse); + expect(controller.records.map((record) => record.dramaId), ['1', '2']); + expect(controller.actionError, 'recordClearFailed'); + }, + ); + + test('should_expose_retryable_error_when_recent_request_fails', () async { + final history = ControlledWatchHistory([])..failRecent = true; + final controller = WatchRecordsController( + history: history, + catalog: ScriptedWatchCatalog(), + ); + + await controller.load(); + + expect(controller.loading, isFalse); + expect(controller.error, 'progressError'); + expect(controller.records, isEmpty); + }); +} + +class ControlledWatchHistory implements WatchHistoryRepository { + ControlledWatchHistory(this.items); + + final List items; + bool failRecent = false; + bool failRemove = false; + bool failClear = false; + Completer? removeGate; + Completer? clearGate; + + @override + Future progressFor(String dramaId) async => null; + + @override + Future save({ + required String episodeId, + required Duration position, + Duration? duration, + bool finished = false, + }) async => null; + + @override + Future> recent({int limit = 20}) async { + if (failRecent) throw StateError('recent unavailable'); + return items.take(limit).toList(); + } + + @override + Future remove(String dramaId) async { + if (removeGate != null) await removeGate!.future; + if (failRemove) throw StateError('remove unavailable'); + items.removeWhere((item) => item.dramaId == dramaId); + } + + @override + Future clear() async { + if (clearGate != null) await clearGate!.future; + if (failClear) throw StateError('clear unavailable'); + items.clear(); + } +} + +class ScriptedWatchCatalog implements CatalogRepository { + ScriptedWatchCatalog({Set? failedIds}) + : failedIds = failedIds ?? {}; + + final Set failedIds; + final List calls = []; + int _active = 0; + int maxActive = 0; + + @override + Future fetchHomeFeed() async => const HomeFeed(); + + @override + Future fetchDiscoverFeed() async => const HomeFeed(); + + @override + Future fetchDrama(String dramaId) async { + calls.add(dramaId); + _active++; + if (_active > maxActive) maxActive = _active; + await Future.delayed(const Duration(milliseconds: 5)); + _active--; + if (failedIds.contains(dramaId)) throw StateError('detail unavailable'); + return _detail(dramaId); + } +} diff --git a/test/watch/watch_records_page_test.dart b/test/watch/watch_records_page_test.dart new file mode 100644 index 0000000..d42ef0e --- /dev/null +++ b/test/watch/watch_records_page_test.dart @@ -0,0 +1,212 @@ +// Author: fruit.com.cn + +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:fruitshorts/core/data/models/drama.dart'; +import 'package:fruitshorts/core/data/models/home_feed.dart'; +import 'package:fruitshorts/core/data/models/watch_progress.dart'; +import 'package:fruitshorts/core/data/remote/api_client.dart'; +import 'package:fruitshorts/core/data/remote/auth_api.dart'; +import 'package:fruitshorts/core/data/repositories/catalog_repository.dart'; +import 'package:fruitshorts/core/data/repositories/watch_history_repository.dart'; +import 'package:fruitshorts/core/data/services/auth_controller.dart'; +import 'package:fruitshorts/core/data/services/auth_session_store.dart'; +import 'package:fruitshorts/l10n/app_localizations.dart'; +import 'package:fruitshorts/pages/watch_records/watch_records_page.dart'; +import 'package:provider/provider.dart'; +import 'package:shared_preferences_platform_interface/in_memory_shared_preferences_async.dart'; +import 'package:shared_preferences_platform_interface/shared_preferences_async_platform_interface.dart'; + +import '../support/fake_catalog.dart'; +import '../support/fake_http_adapter.dart'; + +void main() { + setUp(() { + SharedPreferencesAsyncPlatform.instance = + InMemorySharedPreferencesAsync.empty(); + }); + + testWidgets('should_render_real_record_details_when_recent_history_loads', ( + tester, + ) async { + final auth = await _auth(signedIn: true); + final catalog = FakeCatalogRepository(); + final history = CountingWatchHistory([ + WatchProgress( + dramaId: 'the-signal-demo', + episodeId: 'the-signal-demo-1', + position: const Duration(seconds: 12), + duration: const Duration(seconds: 60), + updatedAt: DateTime(2026, 10, 17, 12, 34), + ), + ]); + + await _pumpPage(tester, auth: auth, history: history, catalog: catalog); + + expect(find.byKey(const Key('watch-records-page')), findsOneWidget); + expect(find.text('The Signal'), findsOneWidget); + expect( + find.byKey(const Key('watch-record-episode-the-signal-demo')), + findsOneWidget, + ); + }); + + testWidgets( + 'should_show_failed_placeholder_and_keep_other_cards_when_detail_fails', + (tester) async { + final auth = await _auth(signedIn: true); + final history = CountingWatchHistory([ + _progress('broken'), + _progress('the-signal-demo'), + ]); + + await _pumpPage( + tester, + auth: auth, + history: history, + catalog: _FailingWatchCatalog(), + ); + + expect( + find.byKey(const Key('watch-record-failed-broken')), + findsOneWidget, + ); + expect(find.text('The Signal'), findsOneWidget); + expect( + find.byKey(const Key('watch-record-retry-broken')), + findsOneWidget, + ); + }, + ); + + testWidgets('should_show_auth_gate_without_loading_records_when_signed_out', ( + tester, + ) async { + final auth = await _auth(signedIn: false); + final history = CountingWatchHistory([_progress('the-signal-demo')]); + + await _pumpPage( + tester, + auth: auth, + history: history, + catalog: FakeCatalogRepository(), + ); + + expect(find.byKey(const Key('auth-gate-panel')), findsOneWidget); + expect(history.recentCalls, 0); + }); + + testWidgets( + 'should_clear_records_only_after_confirmation_when_clear_is_tapped', + (tester) async { + final auth = await _auth(signedIn: true); + final history = CountingWatchHistory([_progress('the-signal-demo')]); + + await _pumpPage( + tester, + auth: auth, + history: history, + catalog: FakeCatalogRepository(), + ); + await tester.tap(find.byKey(const Key('watch-records-clear'))); + await tester.pumpAndSettle(); + + expect(find.byKey(const Key('watch-records-clear')), findsOneWidget); + expect(history.clearCalls, 0); + + await tester.tap(find.widgetWithText(FilledButton, 'Clear')); + await tester.pumpAndSettle(); + + expect(history.clearCalls, 1); + expect(find.text('No watch history yet.'), findsOneWidget); + }, + ); +} + +WatchProgress _progress(String dramaId) => WatchProgress( + dramaId: dramaId, + episodeId: '$dramaId-1', + position: const Duration(seconds: 12), + duration: const Duration(seconds: 60), + updatedAt: DateTime(2026, 10, 17, 12), +); + +Future _auth({required bool signedIn}) async { + if (signedIn) { + SharedPreferencesAsyncPlatform.instance = + InMemorySharedPreferencesAsync.withData({ + 'auth.accessToken': 'test-access', + 'auth.refreshToken': 'test-refresh', + 'auth.user': '{"uid":"1","nickname":"Viewer","avatarUrl":""}', + }); + } + final client = ApiClient( + baseUrl: 'http://127.0.0.1:8081', + adapter: FakeHttpAdapter( + (_) async => FakeHttpResponse('{"code":0,"message":"ok","data":null}'), + ), + ); + final auth = AuthController(AuthApi(client), AuthSessionStore()); + await auth.load(); + return auth; +} + +Future _pumpPage( + WidgetTester tester, { + required AuthController auth, + required WatchHistoryRepository history, + required CatalogRepository catalog, +}) async { + await tester.pumpWidget( + MultiProvider( + providers: [ + ChangeNotifierProvider.value(value: auth), + Provider.value(value: history), + Provider.value(value: catalog), + ], + child: MaterialApp( + locale: const Locale('en'), + localizationsDelegates: AppLocalizations.localizationsDelegates, + supportedLocales: AppLocalizations.supportedLocales, + home: const WatchRecordsPage(), + ), + ), + ); + await tester.pumpAndSettle(); +} + +class CountingWatchHistory extends InMemoryWatchHistoryRepository { + CountingWatchHistory(this.visibleRecords); + + final List visibleRecords; + int recentCalls = 0; + int clearCalls = 0; + + @override + Future> recent({int limit = 20}) async { + recentCalls++; + return visibleRecords.take(limit).toList(); + } + + @override + Future clear() async { + clearCalls++; + await super.clear(); + } +} + +class _FailingWatchCatalog implements CatalogRepository { + final _delegate = FakeCatalogRepository(); + + @override + Future fetchHomeFeed() => _delegate.fetchHomeFeed(); + + @override + Future fetchDiscoverFeed() => _delegate.fetchDiscoverFeed(); + + @override + Future fetchDrama(String dramaId) async { + if (dramaId == 'broken') throw StateError('missing detail'); + return _delegate.fetchDrama(dramaId); + } +} diff --git a/test/widget_test.dart b/test/widget_test.dart index e1d60d5..a6ede86 100644 --- a/test/widget_test.dart +++ b/test/widget_test.dart @@ -9,6 +9,7 @@ import 'package:shared_preferences_platform_interface/in_memory_shared_preferenc import 'package:shared_preferences_platform_interface/shared_preferences_async_platform_interface.dart'; import 'support/fake_catalog.dart'; +import 'support/fake_category.dart'; import 'support/widget_player.dart'; import 'package:fruitshorts/core/data/repositories/favorite_repository.dart'; import 'package:fruitshorts/core/data/repositories/catalog_repository.dart'; @@ -39,15 +40,19 @@ void main() { Widget appUnderTest({ PlayerFactory? playerFactory, CatalogRepository? catalogRepository, - }) => LumaDramaApp( - playerFactory: playerFactory ?? createWidgetPlayer, - catalogRepository: catalogRepository ?? FakeCatalogRepository(), - watchHistoryRepository: InMemoryWatchHistoryRepository(), - favoriteRepository: InMemoryFavoriteRepository( - cards: FakeCatalogRepository().dramas, - ), - playbackRepository: FakePlaybackRepository(), - ); + }) { + final catalog = catalogRepository ?? FakeCatalogRepository(); + return LumaDramaApp( + playerFactory: playerFactory ?? createWidgetPlayer, + catalogRepository: catalog, + categoryRepository: FakeCategoryRepository(catalog: catalog), + watchHistoryRepository: InMemoryWatchHistoryRepository(), + favoriteRepository: InMemoryFavoriteRepository( + cards: FakeCatalogRepository().dramas, + ), + playbackRepository: FakePlaybackRepository(), + ); + } testWidgets( 'should_promote_next_without_recreating_it_or_showing_loading_when_home_is_swiped', -- 2.54.0 From d361034226ec2bc431548d45068dc60046e5e473 Mon Sep 17 00:00:00 2001 From: Zhou Weidong <502333560@qq.com> Date: Sat, 17 Oct 2026 15:26:42 +0800 Subject: [PATCH 12/76] =?UTF-8?q?feat(flutter):=20=E6=8E=A5=E5=85=A5?= =?UTF-8?q?=E4=BA=92=E5=8A=A8=E8=AF=84=E8=AE=BA=E7=82=B9=E8=B5=9E=E4=B8=BE?= =?UTF-8?q?=E6=8A=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/app.dart | 31 +- lib/core/data/models/comment.dart | 132 ++++++ lib/core/data/models/engagement_snapshot.dart | 13 - lib/core/data/models/interaction.dart | 70 +++ lib/core/data/models/json_numbers.dart | 7 + lib/core/data/remote/comment_api.dart | 59 +++ lib/core/data/remote/interaction_api.dart | 44 ++ .../data/repositories/comment_repository.dart | 62 +++ .../repositories/engagement_repository.dart | 70 --- .../repositories/interaction_repository.dart | 32 ++ .../data/services/comment_controller.dart | 378 ++++++++++++++++ .../data/services/engagement_controller.dart | 80 ---- .../data/services/interaction_controller.dart | 107 +++++ lib/core/formatting/error_text.dart | 1 + lib/l10n/app_en.arb | 42 +- lib/l10n/app_id.arb | 42 +- lib/l10n/app_localizations.dart | 180 +++++++- lib/l10n/app_localizations_en.dart | 95 +++- lib/l10n/app_localizations_id.dart | 95 +++- lib/l10n/app_localizations_zh.dart | 94 +++- lib/l10n/app_zh.arb | 42 +- lib/pages/drama_detail/drama_detail_view.dart | 41 ++ .../interaction/widgets/report_dialog.dart | 125 +++++ lib/pages/mine/mine_view.dart | 8 +- lib/pages/player/player_view.dart | 22 +- lib/pages/player/widgets/comment_tile.dart | 149 ++++++ .../player/widgets/drama_comments_sheet.dart | 428 ++++++++++++++---- test/comment/comment_api_test.dart | 129 ++++++ test/comment/comment_controller_test.dart | 192 ++++++++ test/comment/drama_comments_sheet_test.dart | 317 +++++++++++++ test/core/platform_share_service_test.dart | 31 ++ .../engagement_controller_test.dart | 48 -- .../engagement_repository_test.dart | 135 ------ test/formatting/localized_content_test.dart | 19 + test/interaction/interaction_api_test.dart | 67 +++ .../interaction_controller_test.dart | 60 +++ test/interaction/report_dialog_test.dart | 55 +++ .../fake_interaction_repositories.dart | 177 ++++++++ test/widget_test.dart | 81 +++- 39 files changed, 3298 insertions(+), 462 deletions(-) create mode 100644 lib/core/data/models/comment.dart delete mode 100644 lib/core/data/models/engagement_snapshot.dart create mode 100644 lib/core/data/models/interaction.dart create mode 100644 lib/core/data/remote/comment_api.dart create mode 100644 lib/core/data/remote/interaction_api.dart create mode 100644 lib/core/data/repositories/comment_repository.dart delete mode 100644 lib/core/data/repositories/engagement_repository.dart create mode 100644 lib/core/data/repositories/interaction_repository.dart create mode 100644 lib/core/data/services/comment_controller.dart delete mode 100644 lib/core/data/services/engagement_controller.dart create mode 100644 lib/core/data/services/interaction_controller.dart create mode 100644 lib/pages/interaction/widgets/report_dialog.dart create mode 100644 lib/pages/player/widgets/comment_tile.dart create mode 100644 test/comment/comment_api_test.dart create mode 100644 test/comment/comment_controller_test.dart create mode 100644 test/comment/drama_comments_sheet_test.dart create mode 100644 test/core/platform_share_service_test.dart delete mode 100644 test/engagement/engagement_controller_test.dart delete mode 100644 test/engagement/engagement_repository_test.dart create mode 100644 test/interaction/interaction_api_test.dart create mode 100644 test/interaction/interaction_controller_test.dart create mode 100644 test/interaction/report_dialog_test.dart create mode 100644 test/support/fake_interaction_repositories.dart diff --git a/lib/app.dart b/lib/app.dart index f2aef94..9ff5a7e 100644 --- a/lib/app.dart +++ b/lib/app.dart @@ -10,15 +10,18 @@ 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/comment_api.dart'; import 'core/data/remote/download_api.dart'; +import 'core/data/remote/interaction_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/comment_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/interaction_repository.dart'; import 'core/data/repositories/playback_repository.dart'; import 'core/data/repositories/watch_history_repository.dart'; import 'core/data/services/auth_controller.dart'; @@ -26,8 +29,8 @@ 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/interaction_controller.dart'; import 'core/data/services/playback_session.dart'; import 'core/data/services/video_player_port.dart'; import 'l10n/app_localizations.dart'; @@ -43,6 +46,8 @@ class LumaDramaApp extends StatefulWidget { this.watchHistoryRepository, this.favoriteRepository, this.playbackRepository, + this.commentRepository, + this.interactionRepository, }); final PlayerFactory playerFactory; @@ -54,6 +59,8 @@ class LumaDramaApp extends StatefulWidget { final WatchHistoryRepository? watchHistoryRepository; final FavoriteRepository? favoriteRepository; final PlaybackRepository? playbackRepository; + final CommentRepository? commentRepository; + final InteractionRepository? interactionRepository; @override State createState() => _LumaDramaAppState(); @@ -113,6 +120,16 @@ class _LumaDramaAppState extends State { _downloadRepository, ); + late final CommentRepository _commentRepository = + widget.commentRepository ?? HttpCommentRepository(CommentApi(_apiClient)); + + late final InteractionRepository _interactionRepository = + widget.interactionRepository ?? + HttpInteractionRepository(InteractionApi(_apiClient)); + + late final InteractionController _interactionController = + InteractionController(_interactionRepository); + @override void initState() { super.initState(); @@ -128,6 +145,7 @@ class _LumaDramaAppState extends State { void _onAuthChanged() { if (_auth.isSignedIn == _wasSignedIn) return; _wasSignedIn = _auth.isSignedIn; + _interactionController.clear(); if (_auth.isSignedIn) { unawaited(_favoriteController.load()); } else { @@ -141,6 +159,7 @@ class _LumaDramaAppState extends State { _auth.removeListener(_onAuthChanged); _favoriteController.dispose(); _downloadController.dispose(); + _interactionController.dispose(); _apiClient.close(); super.dispose(); } @@ -154,6 +173,8 @@ class _LumaDramaAppState extends State { Provider.value(value: _playback), Provider.value(value: _watchHistory), Provider.value(value: _favorites), + Provider.value(value: _commentRepository), + Provider.value(value: _interactionRepository), ChangeNotifierProvider( create: (_) => CatalogController(_catalogRepository)..load(), ), @@ -163,11 +184,7 @@ class _LumaDramaAppState extends State { ChangeNotifierProvider(create: (_) => LocaleController()..load()), ChangeNotifierProvider.value(value: _favoriteController), ChangeNotifierProvider.value(value: _downloadController), - ChangeNotifierProvider( - create: (_) => - EngagementController(SharedPreferencesEngagementRepository()) - ..load(), - ), + ChangeNotifierProvider.value(value: _interactionController), ChangeNotifierProvider.value(value: _auth), ], child: Consumer( diff --git a/lib/core/data/models/comment.dart b/lib/core/data/models/comment.dart new file mode 100644 index 0000000..1e2a01b --- /dev/null +++ b/lib/core/data/models/comment.dart @@ -0,0 +1,132 @@ +// Author: fruit.com.cn + +import 'json_numbers.dart'; + +/// 评论游标分页大小,契约 §1.7 使用游标而非页码。 +const int commentPageSize = 20; + +/// 评论列表页。 +class CommentPage { + const CommentPage({ + this.comments = const [], + this.nextCursor, + this.hasMore = false, + }); + + final List comments; + final String? nextCursor; + final bool hasMore; + + /// 解析后端 `CursorResult{list,nextCursor,hasMore}`。 + factory CommentPage.fromJson(Map json) { + final rawList = json['list']; + return CommentPage( + comments: [ + if (rawList is List) + for (final item in rawList) + if (item is Map) DramaComment.fromJson(item), + ], + nextCursor: json['nextCursor'] == null + ? null + : jsonToId(json['nextCursor']), + hasMore: json['hasMore'] == true, + ); + } +} + +/// 服务端评论视图,字段对应 `CommentRespVO`。 +class DramaComment { + const DramaComment({ + required this.id, + required this.dramaId, + required this.episodeId, + required this.parentId, + required this.rootId, + required this.userId, + required this.uid, + required this.nickname, + required this.avatarUrl, + required this.content, + required this.status, + required this.auditReason, + required this.likeCount, + required this.replyCount, + required this.reportCount, + required this.createdAt, + required this.mine, + required this.liked, + }); + + final String id; + final String dramaId; + final String episodeId; + final String parentId; + final String rootId; + final String userId; + final String uid; + final String nickname; + final String avatarUrl; + final String content; + final String status; + final String auditReason; + final int likeCount; + final int replyCount; + final int reportCount; + final DateTime? createdAt; + final bool mine; + final bool liked; + + /// 待人工审核的评论仅本人可见。 + bool get isPending => status == 'pending'; + + /// 顶层评论没有父评论。 + bool get isTopLevel => parentId.isEmpty || parentId == '0'; + + /// 解析 `CommentRespVO`,所有 ID 字段只走字符串解析。 + factory DramaComment.fromJson(Map json) => DramaComment( + id: jsonToId(json['id']), + dramaId: jsonToId(json['dramaId']), + episodeId: jsonToId(json['episodeId'], fallback: '0'), + parentId: jsonToId(json['parentId'], fallback: '0'), + rootId: jsonToId(json['rootId'], fallback: '0'), + userId: jsonToId(json['userId']), + uid: json['uid']?.toString() ?? '', + nickname: json['nickname']?.toString() ?? '', + avatarUrl: json['avatarUrl']?.toString() ?? '', + content: json['content']?.toString() ?? '', + status: json['status']?.toString() ?? '', + auditReason: json['auditReason']?.toString() ?? '', + likeCount: jsonToInt(json['likeCount']), + replyCount: jsonToInt(json['replyCount']), + reportCount: jsonToInt(json['reportCount']), + createdAt: DateTime.tryParse(json['createdAt']?.toString() ?? ''), + mine: json['mine'] == true, + liked: json['liked'] == true, + ); + + /// 局部更新点赞或回复数,列表中的其他字段保持不变。 + DramaComment copyWith({ + int? likeCount, + int? replyCount, + bool? liked, + }) => DramaComment( + id: id, + dramaId: dramaId, + episodeId: episodeId, + parentId: parentId, + rootId: rootId, + userId: userId, + uid: uid, + nickname: nickname, + avatarUrl: avatarUrl, + content: content, + status: status, + auditReason: auditReason, + likeCount: likeCount ?? this.likeCount, + replyCount: replyCount ?? this.replyCount, + reportCount: reportCount, + createdAt: createdAt, + mine: mine, + liked: liked ?? this.liked, + ); +} diff --git a/lib/core/data/models/engagement_snapshot.dart b/lib/core/data/models/engagement_snapshot.dart deleted file mode 100644 index 9fe6ff2..0000000 --- a/lib/core/data/models/engagement_snapshot.dart +++ /dev/null @@ -1,13 +0,0 @@ -// Author: fruit.com.cn - -class EngagementSnapshot { - const EngagementSnapshot({ - this.savedDramaIds = const {}, - this.likedDramaIds = const {}, - this.commentsByDrama = const {}, - }); - - final Set savedDramaIds; - final Set likedDramaIds; - final Map> commentsByDrama; -} diff --git a/lib/core/data/models/interaction.dart b/lib/core/data/models/interaction.dart new file mode 100644 index 0000000..d1413e5 --- /dev/null +++ b/lib/core/data/models/interaction.dart @@ -0,0 +1,70 @@ +// Author: fruit.com.cn + +import 'json_numbers.dart'; + +/// 互动目标类型,契约只允许短剧与评论。 +enum InteractionTargetType { + drama('DRAMA'), + comment('COMMENT'); + + const InteractionTargetType(this.apiValue); + + final String apiValue; +} + +/// 客户端固定举报原因,后端当前未限制枚举值。 +enum ReportReason { + spam('SPAM'), + abuse('ABUSE'), + porn('PORN'), + ad('AD'), + other('OTHER'); + + const ReportReason(this.apiValue); + + final String apiValue; +} + +/// 一次性互动请求,供仓库和测试断言使用。 +class ReportRequest { + const ReportRequest({ + required this.targetType, + required this.targetId, + required this.reasonCode, + this.description = '', + }); + + final InteractionTargetType targetType; + final String targetId; + final String reasonCode; + final String description; +} + +/// 点赞切换后的服务端状态。 +class LikeToggleResult { + const LikeToggleResult({required this.liked, required this.count}); + + final bool liked; + final int count; + + /// 计数按 Long 字符串兼容解析。 + factory LikeToggleResult.fromJson(Map json) => + LikeToggleResult( + liked: json['liked'] == true, + count: jsonToInt(json['count']), + ); +} + +/// 控制器统一返回结果;失败消息可直接展示后端 `message`。 +class OperationResult { + const OperationResult._(this.data, this.errorMessage); + + const OperationResult.success([T? data]) : this._(data, null); + + const OperationResult.failure(this.errorMessage) : data = null; + + final T? data; + final String? errorMessage; + + bool get isSuccess => errorMessage == null; +} diff --git a/lib/core/data/models/json_numbers.dart b/lib/core/data/models/json_numbers.dart index 6fd1084..9aa91a9 100644 --- a/lib/core/data/models/json_numbers.dart +++ b/lib/core/data/models/json_numbers.dart @@ -11,3 +11,10 @@ int jsonToInt(dynamic value, {int fallback = 0}) { if (value is String) return int.tryParse(value.trim()) ?? fallback; return fallback; } + +/// ID 字段统一转字符串;后端按契约下发字符串,同时兼容测试或旧数据的数字形式。 +String jsonToId(dynamic value, {String fallback = ''}) { + if (value is String) return value; + if (value is num) return value.toString(); + return fallback; +} diff --git a/lib/core/data/remote/comment_api.dart b/lib/core/data/remote/comment_api.dart new file mode 100644 index 0000000..f99438e --- /dev/null +++ b/lib/core/data/remote/comment_api.dart @@ -0,0 +1,59 @@ +// Author: fruit.com.cn + +import '../models/comment.dart'; +import 'api_client.dart'; + +/// 评论接口,对应契约 §1.7 的 `/app/comments*`。 +class CommentApi { + const CommentApi(this._client); + + final ApiClient _client; + + /// 拉取游标分页;`rootId` 用于加载某一楼层的回复。 + Future page({ + required String dramaId, + String? rootId, + String? cursor, + int size = commentPageSize, + }) async { + final data = await _client.get( + '/app/comments', + query: { + 'dramaId': dramaId, + 'rootId': ?rootId, + 'cursor': ?cursor, + 'size': '$size', + }, + ); + if (data is! Map) return const CommentPage(); + return CommentPage.fromJson(data); + } + + /// 发表评论或回复;回复只提交 `parentId`,不自行拼层级。 + Future publish({ + required String dramaId, + String? episodeId, + required String content, + String? parentId, + }) async { + final data = await _client.post( + '/app/comments', + body: { + 'dramaId': dramaId, + if (episodeId != null && episodeId.isNotEmpty) + 'episodeId': episodeId, + 'content': content, + if (parentId != null && parentId.isNotEmpty) 'parentId': parentId, + }, + ); + if (data is! Map) { + throw const ApiException(500, '评论响应格式错误'); + } + return DramaComment.fromJson(data); + } + + /// 删除自己的评论。 + Future delete(String commentId) async { + await _client.delete('/app/comments/$commentId'); + } +} diff --git a/lib/core/data/remote/interaction_api.dart b/lib/core/data/remote/interaction_api.dart new file mode 100644 index 0000000..6fd1a45 --- /dev/null +++ b/lib/core/data/remote/interaction_api.dart @@ -0,0 +1,44 @@ +// Author: fruit.com.cn + +import '../models/interaction.dart'; +import 'api_client.dart'; + +/// 点赞与举报接口,对应契约 §1.7。 +class InteractionApi { + const InteractionApi(this._client); + + final ApiClient _client; + + /// 切换点赞,服务端返回的状态与计数为最终真相。 + Future toggleLike({ + required InteractionTargetType targetType, + required String targetId, + }) async { + final data = await _client.post( + '/app/likes/toggle', + body: { + 'targetType': targetType.apiValue, + 'targetId': targetId, + }, + ); + if (data is! Map) { + throw const ApiException(500, '点赞响应格式错误'); + } + return LikeToggleResult.fromJson(data); + } + + /// 提交举报,返回工单 ID。 + Future report(ReportRequest request) async { + final data = await _client.post( + '/app/reports', + body: { + 'targetType': request.targetType.apiValue, + 'targetId': request.targetId, + 'reasonCode': request.reasonCode, + if (request.description.isNotEmpty) + 'description': request.description, + }, + ); + return data?.toString() ?? ''; + } +} diff --git a/lib/core/data/repositories/comment_repository.dart b/lib/core/data/repositories/comment_repository.dart new file mode 100644 index 0000000..92d93e2 --- /dev/null +++ b/lib/core/data/repositories/comment_repository.dart @@ -0,0 +1,62 @@ +// Author: fruit.com.cn + +import '../models/comment.dart'; +import '../remote/comment_api.dart'; + +/// 评论数据来源抽象,页面与控制器不直接依赖 HTTP。 +abstract interface class CommentRepository { + /// 拉取评论或回复的分页。 + Future page({ + required String dramaId, + String? rootId, + String? cursor, + int size = commentPageSize, + }); + + /// 发表评论或回复。 + Future publish({ + required String dramaId, + String? episodeId, + required String content, + String? parentId, + }); + + /// 删除指定评论。 + Future delete(String commentId); +} + +/// HTTP 评论仓库。 +class HttpCommentRepository implements CommentRepository { + const HttpCommentRepository(this._api); + + final CommentApi _api; + + @override + Future page({ + required String dramaId, + String? rootId, + String? cursor, + int size = commentPageSize, + }) => _api.page( + dramaId: dramaId, + rootId: rootId, + cursor: cursor, + size: size, + ); + + @override + Future publish({ + required String dramaId, + String? episodeId, + required String content, + String? parentId, + }) => _api.publish( + dramaId: dramaId, + episodeId: episodeId, + content: content, + parentId: parentId, + ); + + @override + Future delete(String commentId) => _api.delete(commentId); +} diff --git a/lib/core/data/repositories/engagement_repository.dart b/lib/core/data/repositories/engagement_repository.dart deleted file mode 100644 index c7067bf..0000000 --- a/lib/core/data/repositories/engagement_repository.dart +++ /dev/null @@ -1,70 +0,0 @@ -// Author: fruit.com.cn - -import 'dart:convert'; - -import 'package:shared_preferences/shared_preferences.dart'; - -import '../models/engagement_snapshot.dart'; - -abstract interface class EngagementRepository { - Future load(); - Future save(EngagementSnapshot snapshot); -} - -class SharedPreferencesEngagementRepository implements EngagementRepository { - SharedPreferencesEngagementRepository({SharedPreferencesAsync? preferences}) - : _preferences = preferences ?? SharedPreferencesAsync(); - - static const _key = 'engagement.v1.demo-local-v1'; - final SharedPreferencesAsync _preferences; - - @override - Future load() async { - final raw = await _preferences.getString(_key); - if (raw == null) return const EngagementSnapshot(); - try { - final json = jsonDecode(raw); - if (json is! Map) return const EngagementSnapshot(); - Set ids(Object? value) => - value is List ? value.whereType().toSet() : {}; - final comments = >{}; - final rawComments = json['comments']; - if (rawComments is Map) { - for (final entry in rawComments.entries) { - if (entry.value is List) { - comments[entry.key] = (entry.value as List) - .whereType() - .toList(); - } - } - } - return EngagementSnapshot( - savedDramaIds: ids(json['saved']), - likedDramaIds: ids(json['liked']), - commentsByDrama: comments, - ); - } catch (_) { - return const EngagementSnapshot(); - } - } - - @override - Future save(EngagementSnapshot snapshot) => _preferences.setString( - _key, - jsonEncode({ - 'saved': snapshot.savedDramaIds.toList(), - 'liked': snapshot.likedDramaIds.toList(), - 'comments': snapshot.commentsByDrama, - }), - ); -} - -class InMemoryEngagementRepository implements EngagementRepository { - EngagementSnapshot snapshot = const EngagementSnapshot(); - - @override - Future load() async => snapshot; - - @override - Future save(EngagementSnapshot value) async => snapshot = value; -} diff --git a/lib/core/data/repositories/interaction_repository.dart b/lib/core/data/repositories/interaction_repository.dart new file mode 100644 index 0000000..d7a8b09 --- /dev/null +++ b/lib/core/data/repositories/interaction_repository.dart @@ -0,0 +1,32 @@ +// Author: fruit.com.cn + +import '../models/interaction.dart'; +import '../remote/interaction_api.dart'; + +/// 点赞与举报数据来源抽象。 +abstract interface class InteractionRepository { + /// 切换目标点赞状态。 + Future toggleLike({ + required InteractionTargetType targetType, + required String targetId, + }); + + /// 提交举报并返回工单 ID。 + Future report(ReportRequest request); +} + +/// HTTP 互动仓库。 +class HttpInteractionRepository implements InteractionRepository { + const HttpInteractionRepository(this._api); + + final InteractionApi _api; + + @override + Future toggleLike({ + required InteractionTargetType targetType, + required String targetId, + }) => _api.toggleLike(targetType: targetType, targetId: targetId); + + @override + Future report(ReportRequest request) => _api.report(request); +} diff --git a/lib/core/data/services/comment_controller.dart b/lib/core/data/services/comment_controller.dart new file mode 100644 index 0000000..55f6785 --- /dev/null +++ b/lib/core/data/services/comment_controller.dart @@ -0,0 +1,378 @@ +// Author: fruit.com.cn + +import 'package:flutter/foundation.dart'; + +import '../models/comment.dart'; +import '../models/interaction.dart'; +import '../remote/api_client.dart'; +import '../repositories/comment_repository.dart'; +import '../repositories/interaction_repository.dart'; + +/// 评论列表、发布、回复、删除与评论点赞的状态控制器。 +class CommentController extends ChangeNotifier { + CommentController({ + required CommentRepository comments, + required InteractionRepository interactions, + required this.dramaId, + this.episodeId, + }) : _commentRepository = comments, + _interactionRepository = interactions; + + final CommentRepository _commentRepository; + final InteractionRepository _interactionRepository; + final String dramaId; + final String? episodeId; + final List _comments = []; + final Map> _replies = {}; + final Map _replyCursors = {}; + final Map _replyHasMore = {}; + final Set _expandedRoots = {}; + final Set _loadingReplies = {}; + final Set _loadingMoreReplies = {}; + final Set _likingCommentIds = {}; + final Set _deletingCommentIds = {}; + bool _disposed = false; + bool loading = false; + bool loadingMore = false; + bool submitting = false; + bool hasMore = false; + String? nextCursor; + String? error; + + /// 当前已加载的顶层评论。 + List get comments => List.unmodifiable(_comments); + + /// 某一楼层已加载的回复。 + List repliesFor(String rootId) => + List.unmodifiable(_replies[rootId] ?? const []); + + /// 楼层回复是否已展开。 + bool repliesExpanded(String rootId) => _expandedRoots.contains(rootId); + + /// 楼层回复是否正在首屏加载。 + bool repliesLoading(String rootId) => _loadingReplies.contains(rootId); + + /// 楼层回复是否还有下一页。 + bool repliesHasMore(String rootId) => _replyHasMore[rootId] ?? false; + + /// 评论是否正在提交点赞,用于防连点。 + bool likingComment(String id) => _likingCommentIds.contains(id); + + void _notify() { + if (!_disposed) notifyListeners(); + } + + /// 加载首屏评论,成功后替换当前顶层列表。 + Future load() async { + loading = true; + error = null; + _notify(); + try { + final page = await _commentRepository.page( + dramaId: dramaId, + size: commentPageSize, + ); + _comments + ..clear() + ..addAll(page.comments); + nextCursor = page.nextCursor; + hasMore = page.hasMore; + } catch (failure) { + error = _errorMessage(failure) ?? 'commentsLoadFailed'; + } finally { + loading = false; + _notify(); + } + } + + /// 使用 `nextCursor` 续拉顶层评论。 + Future loadMore() async { + final cursor = nextCursor; + if (loadingMore || !hasMore || cursor == null) return; + loadingMore = true; + error = null; + _notify(); + try { + final page = await _commentRepository.page( + dramaId: dramaId, + cursor: cursor, + size: commentPageSize, + ); + _comments.addAll(page.comments); + nextCursor = page.nextCursor; + hasMore = page.hasMore; + } catch (failure) { + error = _errorMessage(failure) ?? 'commentsLoadFailed'; + } finally { + loadingMore = false; + _notify(); + } + } + + /// 展开并用 `rootId` 加载一层楼层回复。 + Future loadReplies(String rootId) async { + _expandedRoots.add(rootId); + if (_replies.containsKey(rootId) || _loadingReplies.contains(rootId)) { + _notify(); + return; + } + _loadingReplies.add(rootId); + error = null; + _notify(); + try { + final page = await _commentRepository.page( + dramaId: dramaId, + rootId: rootId, + size: commentPageSize, + ); + _replies[rootId] = List.of(page.comments); + _replyCursors[rootId] = page.nextCursor; + _replyHasMore[rootId] = page.hasMore; + } catch (failure) { + error = _errorMessage(failure) ?? 'commentsLoadFailed'; + } finally { + _loadingReplies.remove(rootId); + _notify(); + } + } + + /// 收起楼层回复,不丢弃已加载数据。 + void hideReplies(String rootId) { + if (_expandedRoots.remove(rootId)) _notify(); + } + + /// 续拉楼层回复。 + Future loadMoreReplies(String rootId) async { + final cursor = _replyCursors[rootId]; + if (_loadingMoreReplies.contains(rootId) || cursor == null) return; + if (!(_replyHasMore[rootId] ?? false)) return; + _loadingMoreReplies.add(rootId); + _notify(); + try { + final page = await _commentRepository.page( + dramaId: dramaId, + rootId: rootId, + cursor: cursor, + size: commentPageSize, + ); + (_replies[rootId] ??= []).addAll(page.comments); + _replyCursors[rootId] = page.nextCursor; + _replyHasMore[rootId] = page.hasMore; + } catch (failure) { + error = _errorMessage(failure) ?? 'commentsLoadFailed'; + } finally { + _loadingMoreReplies.remove(rootId); + _notify(); + } + } + + /// 发布评论或回复,输入框是否清空由调用方根据成功结果决定。 + Future> publish( + String rawContent, { + DramaComment? replyTo, + }) async { + final content = rawContent.trim(); + if (content.isEmpty || submitting) { + return const OperationResult.failure(null); + } + submitting = true; + _notify(); + try { + final comment = await _commentRepository.publish( + dramaId: dramaId, + episodeId: episodeId, + content: content, + parentId: replyTo?.id, + ); + _insertPublished(comment, replyTo); + return OperationResult.success(comment); + } catch (failure) { + return OperationResult.failure(_errorMessage(failure)); + } finally { + submitting = false; + _notify(); + } + } + + /// 乐观删除自己的评论,失败时恢复到原位置。 + Future> delete(DramaComment comment) async { + if (!comment.mine || _deletingCommentIds.contains(comment.id)) { + return const OperationResult.failure(null); + } + _deletingCommentIds.add(comment.id); + final location = _removeComment(comment.id); + _notify(); + try { + await _commentRepository.delete(comment.id); + return const OperationResult.success(); + } catch (failure) { + _restoreComment(comment, location); + return OperationResult.failure(_errorMessage(failure)); + } finally { + _deletingCommentIds.remove(comment.id); + _notify(); + } + } + + /// 评论点赞先乐观更新,再用服务端 `{liked,count}` 校准。 + Future> toggleLike( + DramaComment comment, + ) async { + if (_likingCommentIds.contains(comment.id)) { + return const OperationResult.failure(null); + } + final current = _findComment(comment.id) ?? comment; + _likingCommentIds.add(comment.id); + _replaceComment( + current.copyWith( + liked: !current.liked, + likeCount: current.liked + ? (current.likeCount > 0 ? current.likeCount - 1 : 0) + : current.likeCount + 1, + ), + ); + _notify(); + try { + final result = await _interactionRepository.toggleLike( + targetType: InteractionTargetType.comment, + targetId: comment.id, + ); + _replaceComment( + current.copyWith(liked: result.liked, likeCount: result.count), + ); + return OperationResult.success(result); + } catch (failure) { + _replaceComment(current); + return OperationResult.failure(_errorMessage(failure)); + } finally { + _likingCommentIds.remove(comment.id); + _notify(); + } + } + + /// 举报评论,失败消息原样返回给界面展示。 + Future> report( + DramaComment comment, { + required ReportReason reason, + String description = '', + }) async { + try { + final reportId = await _interactionRepository.report( + ReportRequest( + targetType: InteractionTargetType.comment, + targetId: comment.id, + reasonCode: reason.apiValue, + description: description.trim(), + ), + ); + return OperationResult.success(reportId); + } catch (failure) { + return OperationResult.failure(_errorMessage(failure)); + } + } + + void _insertPublished(DramaComment comment, DramaComment? replyTo) { + final rootId = comment.rootId != '0' + ? comment.rootId + : replyTo?.isTopLevel == true + ? replyTo!.id + : replyTo?.rootId; + if (replyTo == null || rootId == null || rootId == '0') { + if (!_comments.any((item) => item.id == comment.id)) { + _comments.insert(0, comment); + } + return; + } + final replies = _replies.putIfAbsent(rootId, () => []); + if (!replies.any((item) => item.id == comment.id)) { + replies.insert(0, comment); + } + _expandedRoots.add(rootId); + final rootIndex = _comments.indexWhere((item) => item.id == rootId); + if (rootIndex >= 0) { + final root = _comments[rootIndex]; + _comments[rootIndex] = root.copyWith(replyCount: root.replyCount + 1); + } + } + + _CommentLocation? _removeComment(String id) { + final topIndex = _comments.indexWhere((item) => item.id == id); + if (topIndex >= 0) { + final removed = _comments.removeAt(topIndex); + return _CommentLocation(comment: removed, topIndex: topIndex); + } + for (final entry in _replies.entries) { + final index = entry.value.indexWhere((item) => item.id == id); + if (index < 0) continue; + final removed = entry.value.removeAt(index); + return _CommentLocation( + comment: removed, + rootId: entry.key, + replyIndex: index, + ); + } + return null; + } + + void _restoreComment(DramaComment comment, _CommentLocation? location) { + if (location == null) return; + if (location.topIndex != null) { + final index = location.topIndex!.clamp(0, _comments.length); + _comments.insert(index, comment); + return; + } + final replies = _replies.putIfAbsent(location.rootId!, () => []); + final index = location.replyIndex!.clamp(0, replies.length); + replies.insert(index, comment); + } + + DramaComment? _findComment(String id) { + for (final comment in _comments) { + if (comment.id == id) return comment; + } + for (final replies in _replies.values) { + for (final comment in replies) { + if (comment.id == id) return comment; + } + } + return null; + } + + void _replaceComment(DramaComment replacement) { + final topIndex = _comments.indexWhere((item) => item.id == replacement.id); + if (topIndex >= 0) { + _comments[topIndex] = replacement; + return; + } + for (final replies in _replies.values) { + final index = replies.indexWhere((item) => item.id == replacement.id); + if (index >= 0) { + replies[index] = replacement; + return; + } + } + } + + String? _errorMessage(Object failure) => + failure is ApiException ? failure.message : null; + + @override + void dispose() { + _disposed = true; + super.dispose(); + } +} + +class _CommentLocation { + const _CommentLocation({ + required this.comment, + this.topIndex, + this.rootId, + this.replyIndex, + }); + + final DramaComment comment; + final int? topIndex; + final String? rootId; + final int? replyIndex; +} diff --git a/lib/core/data/services/engagement_controller.dart b/lib/core/data/services/engagement_controller.dart deleted file mode 100644 index 440fe8e..0000000 --- a/lib/core/data/services/engagement_controller.dart +++ /dev/null @@ -1,80 +0,0 @@ -// Author: fruit.com.cn - -import 'package:flutter/foundation.dart'; - -import '../models/engagement_snapshot.dart'; -import '../repositories/engagement_repository.dart'; - -/// Local demo interactions, indexed by drama ID. No public/social backend. -class EngagementController extends ChangeNotifier { - EngagementController(this._repository); - - final EngagementRepository _repository; - final Set _saved = {}; - final Set _liked = {}; - final Map> _comments = {}; - Future _loadFuture = Future.value(); - Future _pendingSave = Future.value(); - - bool isSaved(String dramaId) => _saved.contains(dramaId); - bool isLiked(String dramaId) => _liked.contains(dramaId); - List commentsFor(String dramaId) => - List.unmodifiable(_comments[dramaId] ?? const []); - - Future load() => _loadFuture = _loadFromRepository(); - - Future _loadFromRepository() async { - try { - final snapshot = await _repository.load(); - _saved.addAll(snapshot.savedDramaIds); - _liked.addAll(snapshot.likedDramaIds); - for (final entry in snapshot.commentsByDrama.entries) { - _comments[entry.key] = List.of(entry.value); - } - notifyListeners(); - } catch (_) { - // Local preferences are best effort for this demo. - } - } - - Future toggleSaved(String dramaId) async { - await _loadFuture; - if (!_saved.add(dramaId)) _saved.remove(dramaId); - notifyListeners(); - await _persist(); - } - - Future toggleLiked(String dramaId) async { - await _loadFuture; - if (!_liked.add(dramaId)) _liked.remove(dramaId); - notifyListeners(); - await _persist(); - } - - Future addComment(String dramaId, String text) async { - await _loadFuture; - final clean = text.trim(); - if (clean.isEmpty) return; - (_comments[dramaId] ??= []).add( - clean.length > 300 ? clean.substring(0, 300) : clean, - ); - notifyListeners(); - await _persist(); - } - - Future _persist() { - final snapshot = EngagementSnapshot( - savedDramaIds: Set.of(_saved), - likedDramaIds: Set.of(_liked), - commentsByDrama: { - for (final entry in _comments.entries) entry.key: List.of(entry.value), - }, - ); - _pendingSave = _pendingSave - .then((_) => _repository.save(snapshot)) - .catchError((Object _) { - // Keep the current in-memory state if local persistence fails. - }); - return _pendingSave; - } -} diff --git a/lib/core/data/services/interaction_controller.dart b/lib/core/data/services/interaction_controller.dart new file mode 100644 index 0000000..9dd39c9 --- /dev/null +++ b/lib/core/data/services/interaction_controller.dart @@ -0,0 +1,107 @@ +// Author: fruit.com.cn + +import 'package:flutter/foundation.dart'; + +import '../models/interaction.dart'; +import '../remote/api_client.dart'; +import '../repositories/interaction_repository.dart'; + +/// 剧集点赞与举报的会话状态控制器。 +/// +/// 剧集契约暂未下发初始点赞状态与计数,本批只维护当前会话内的 liked 状态, +/// 不展示数字,也不伪造初始值。 +class InteractionController extends ChangeNotifier { + InteractionController(this._repository); + + final InteractionRepository _repository; + final Set _likedDramaIds = {}; + final Set _busyDramaIds = {}; + bool _disposed = false; + + /// 当前会话内该剧是否已点赞。 + bool isLiked(String dramaId) => _likedDramaIds.contains(dramaId); + + /// 点赞请求是否进行中,用于防连点。 + bool isBusy(String dramaId) => _busyDramaIds.contains(dramaId); + + /// 乐观切换剧集点赞,失败时回滚并以服务端返回状态校准。 + Future> toggleDramaLike( + String dramaId, + ) async { + if (_busyDramaIds.contains(dramaId)) { + return const OperationResult.failure(null); + } + final wasLiked = _likedDramaIds.contains(dramaId); + _busyDramaIds.add(dramaId); + if (wasLiked) { + _likedDramaIds.remove(dramaId); + } else { + _likedDramaIds.add(dramaId); + } + _notify(); + try { + final result = await _repository.toggleLike( + targetType: InteractionTargetType.drama, + targetId: dramaId, + ); + if (result.liked) { + _likedDramaIds.add(dramaId); + } else { + _likedDramaIds.remove(dramaId); + } + return OperationResult.success(result); + } catch (failure) { + if (wasLiked) { + _likedDramaIds.add(dramaId); + } else { + _likedDramaIds.remove(dramaId); + } + return OperationResult.failure(_errorMessage(failure)); + } finally { + _busyDramaIds.remove(dramaId); + _notify(); + } + } + + /// 举报剧集,失败消息原样返回给界面。 + Future> reportDrama( + String dramaId, { + required ReportReason reason, + String description = '', + }) async { + try { + final reportId = await _repository.report( + ReportRequest( + targetType: InteractionTargetType.drama, + targetId: dramaId, + reasonCode: reason.apiValue, + description: description.trim(), + ), + ); + return OperationResult.success(reportId); + } catch (failure) { + return OperationResult.failure(_errorMessage(failure)); + } + } + + /// 登录账号变化时清理会话内状态,避免跨账号串联。 + void clear() { + if (_likedDramaIds.isEmpty && _busyDramaIds.isEmpty) return; + _likedDramaIds.clear(); + _busyDramaIds.clear(); + _notify(); + } + + String? _errorMessage(Object failure) => + failure is ApiException ? failure.message : null; + + void _notify() { + if (!_disposed) notifyListeners(); + } + + @override + void dispose() { + _disposed = true; + super.dispose(); + } +} diff --git a/lib/core/formatting/error_text.dart b/lib/core/formatting/error_text.dart index c538be9..bd6a5b7 100644 --- a/lib/core/formatting/error_text.dart +++ b/lib/core/formatting/error_text.dart @@ -11,6 +11,7 @@ String errorText(AppLocalizations l10n, String? code, String fallback) { 'progressError' => l10n.progressError, 'favoritesError' => l10n.favoritesError, 'ticketError' => l10n.playbackError, + 'commentsLoadFailed' => l10n.commentsLoadFailed, final value => value, }; } diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index 8b04bf3..e9e536f 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -65,10 +65,50 @@ "save": "Save", "comments": "Comments", "share": "Share", - "localOnlyComments": "Only visible on this device", "noComments": "No comments yet.", "writeComment": "Write a comment", "postComment": "Post", + "loadMore": "Load more", + "commentsLoadFailed": "Comments could not be loaded.", + "commentPostFailed": "Could not post your comment.", + "delete": "Delete", + "deleteComment": "Delete comment", + "deleteCommentTitle": "Delete this comment?", + "deleteCommentMessage": "This removes your comment from the conversation.", + "commentDeleteFailed": "Could not delete this comment.", + "underReview": "Under review", + "reply": "Reply", + "replyingTo": "Replying to {name}", + "@replyingTo": { + "placeholders": { + "name": {} + } + }, + "cancelReply": "Cancel reply", + "viewReplies": "View replies ({count})", + "@viewReplies": { + "placeholders": { + "count": { + "type": "int" + } + } + }, + "hideReplies": "Hide replies", + "anonymousUser": "Viewer", + "more": "More", + "likeFailed": "Could not update like. Please retry.", + "reportComment": "Report comment", + "reportDrama": "Report drama", + "reportReason": "Reason", + "reportReasonSpam": "Spam", + "reportReasonAbuse": "Harassment", + "reportReasonPorn": "Sexual content", + "reportReasonAd": "Advertising", + "reportReasonOther": "Other", + "reportDescriptionHint": "Describe the issue (optional)", + "reportSubmit": "Submit report", + "reportSubmitted": "Report submitted. Thank you.", + "reportFailed": "Could not submit report.", "shareFailed": "Could not open the share sheet.", "nowPlaying": "Playing now", "watchFullscreen": "Watch in landscape", diff --git a/lib/l10n/app_id.arb b/lib/l10n/app_id.arb index 1c41600..39656dc 100644 --- a/lib/l10n/app_id.arb +++ b/lib/l10n/app_id.arb @@ -65,10 +65,50 @@ "save": "Simpan", "comments": "Komentar", "share": "Bagikan", - "localOnlyComments": "Hanya terlihat di perangkat ini", "noComments": "Belum ada komentar.", "writeComment": "Tulis komentar", "postComment": "Kirim", + "loadMore": "Muat lebih banyak", + "commentsLoadFailed": "Komentar tidak dapat dimuat.", + "commentPostFailed": "Komentar tidak dapat dikirim.", + "delete": "Hapus", + "deleteComment": "Hapus komentar", + "deleteCommentTitle": "Hapus komentar ini?", + "deleteCommentMessage": "Komentar ini akan dihapus dari percakapan.", + "commentDeleteFailed": "Komentar tidak dapat dihapus.", + "underReview": "Sedang ditinjau", + "reply": "Balas", + "replyingTo": "Membalas {name}", + "@replyingTo": { + "placeholders": { + "name": {} + } + }, + "cancelReply": "Batal membalas", + "viewReplies": "Lihat balasan ({count})", + "@viewReplies": { + "placeholders": { + "count": { + "type": "int" + } + } + }, + "hideReplies": "Sembunyikan balasan", + "anonymousUser": "Penonton", + "more": "Lainnya", + "likeFailed": "Status suka tidak dapat diperbarui.", + "reportComment": "Laporkan komentar", + "reportDrama": "Laporkan drama", + "reportReason": "Alasan", + "reportReasonSpam": "Spam", + "reportReasonAbuse": "Pelecehan", + "reportReasonPorn": "Konten seksual", + "reportReasonAd": "Iklan", + "reportReasonOther": "Lainnya", + "reportDescriptionHint": "Jelaskan masalah (opsional)", + "reportSubmit": "Kirim laporan", + "reportSubmitted": "Laporan terkirim. Terima kasih.", + "reportFailed": "Laporan tidak dapat dikirim.", "shareFailed": "Tidak bisa membuka menu berbagi.", "nowPlaying": "Sedang diputar", "watchFullscreen": "Tonton mode lanskap", diff --git a/lib/l10n/app_localizations.dart b/lib/l10n/app_localizations.dart index 54911ab..d4ca405 100644 --- a/lib/l10n/app_localizations.dart +++ b/lib/l10n/app_localizations.dart @@ -448,12 +448,6 @@ abstract class AppLocalizations { /// **'Share'** String get share; - /// No description provided for @localOnlyComments. - /// - /// In en, this message translates to: - /// **'Only visible on this device'** - String get localOnlyComments; - /// No description provided for @noComments. /// /// In en, this message translates to: @@ -472,6 +466,180 @@ abstract class AppLocalizations { /// **'Post'** String get postComment; + /// No description provided for @loadMore. + /// + /// In en, this message translates to: + /// **'Load more'** + String get loadMore; + + /// No description provided for @commentsLoadFailed. + /// + /// In en, this message translates to: + /// **'Comments could not be loaded.'** + String get commentsLoadFailed; + + /// No description provided for @commentPostFailed. + /// + /// In en, this message translates to: + /// **'Could not post your comment.'** + String get commentPostFailed; + + /// No description provided for @delete. + /// + /// In en, this message translates to: + /// **'Delete'** + String get delete; + + /// No description provided for @deleteComment. + /// + /// In en, this message translates to: + /// **'Delete comment'** + String get deleteComment; + + /// No description provided for @deleteCommentTitle. + /// + /// In en, this message translates to: + /// **'Delete this comment?'** + String get deleteCommentTitle; + + /// No description provided for @deleteCommentMessage. + /// + /// In en, this message translates to: + /// **'This removes your comment from the conversation.'** + String get deleteCommentMessage; + + /// No description provided for @commentDeleteFailed. + /// + /// In en, this message translates to: + /// **'Could not delete this comment.'** + String get commentDeleteFailed; + + /// No description provided for @underReview. + /// + /// In en, this message translates to: + /// **'Under review'** + String get underReview; + + /// No description provided for @reply. + /// + /// In en, this message translates to: + /// **'Reply'** + String get reply; + + /// No description provided for @replyingTo. + /// + /// In en, this message translates to: + /// **'Replying to {name}'** + String replyingTo(Object name); + + /// No description provided for @cancelReply. + /// + /// In en, this message translates to: + /// **'Cancel reply'** + String get cancelReply; + + /// No description provided for @viewReplies. + /// + /// In en, this message translates to: + /// **'View replies ({count})'** + String viewReplies(int count); + + /// No description provided for @hideReplies. + /// + /// In en, this message translates to: + /// **'Hide replies'** + String get hideReplies; + + /// No description provided for @anonymousUser. + /// + /// In en, this message translates to: + /// **'Viewer'** + String get anonymousUser; + + /// No description provided for @more. + /// + /// In en, this message translates to: + /// **'More'** + String get more; + + /// No description provided for @likeFailed. + /// + /// In en, this message translates to: + /// **'Could not update like. Please retry.'** + String get likeFailed; + + /// No description provided for @reportComment. + /// + /// In en, this message translates to: + /// **'Report comment'** + String get reportComment; + + /// No description provided for @reportDrama. + /// + /// In en, this message translates to: + /// **'Report drama'** + String get reportDrama; + + /// No description provided for @reportReason. + /// + /// In en, this message translates to: + /// **'Reason'** + String get reportReason; + + /// No description provided for @reportReasonSpam. + /// + /// In en, this message translates to: + /// **'Spam'** + String get reportReasonSpam; + + /// No description provided for @reportReasonAbuse. + /// + /// In en, this message translates to: + /// **'Harassment'** + String get reportReasonAbuse; + + /// No description provided for @reportReasonPorn. + /// + /// In en, this message translates to: + /// **'Sexual content'** + String get reportReasonPorn; + + /// No description provided for @reportReasonAd. + /// + /// In en, this message translates to: + /// **'Advertising'** + String get reportReasonAd; + + /// No description provided for @reportReasonOther. + /// + /// In en, this message translates to: + /// **'Other'** + String get reportReasonOther; + + /// No description provided for @reportDescriptionHint. + /// + /// In en, this message translates to: + /// **'Describe the issue (optional)'** + String get reportDescriptionHint; + + /// No description provided for @reportSubmit. + /// + /// In en, this message translates to: + /// **'Submit report'** + String get reportSubmit; + + /// No description provided for @reportSubmitted. + /// + /// In en, this message translates to: + /// **'Report submitted. Thank you.'** + String get reportSubmitted; + + /// No description provided for @reportFailed. + /// + /// In en, this message translates to: + /// **'Could not submit report.'** + String get reportFailed; + /// No description provided for @shareFailed. /// /// In en, this message translates to: diff --git a/lib/l10n/app_localizations_en.dart b/lib/l10n/app_localizations_en.dart index b4e2e65..e73718c 100644 --- a/lib/l10n/app_localizations_en.dart +++ b/lib/l10n/app_localizations_en.dart @@ -187,9 +187,6 @@ class AppLocalizationsEn extends AppLocalizations { @override String get share => 'Share'; - @override - String get localOnlyComments => 'Only visible on this device'; - @override String get noComments => 'No comments yet.'; @@ -199,6 +196,98 @@ class AppLocalizationsEn extends AppLocalizations { @override String get postComment => 'Post'; + @override + String get loadMore => 'Load more'; + + @override + String get commentsLoadFailed => 'Comments could not be loaded.'; + + @override + String get commentPostFailed => 'Could not post your comment.'; + + @override + String get delete => 'Delete'; + + @override + String get deleteComment => 'Delete comment'; + + @override + String get deleteCommentTitle => 'Delete this comment?'; + + @override + String get deleteCommentMessage => + 'This removes your comment from the conversation.'; + + @override + String get commentDeleteFailed => 'Could not delete this comment.'; + + @override + String get underReview => 'Under review'; + + @override + String get reply => 'Reply'; + + @override + String replyingTo(Object name) { + return 'Replying to $name'; + } + + @override + String get cancelReply => 'Cancel reply'; + + @override + String viewReplies(int count) { + return 'View replies ($count)'; + } + + @override + String get hideReplies => 'Hide replies'; + + @override + String get anonymousUser => 'Viewer'; + + @override + String get more => 'More'; + + @override + String get likeFailed => 'Could not update like. Please retry.'; + + @override + String get reportComment => 'Report comment'; + + @override + String get reportDrama => 'Report drama'; + + @override + String get reportReason => 'Reason'; + + @override + String get reportReasonSpam => 'Spam'; + + @override + String get reportReasonAbuse => 'Harassment'; + + @override + String get reportReasonPorn => 'Sexual content'; + + @override + String get reportReasonAd => 'Advertising'; + + @override + String get reportReasonOther => 'Other'; + + @override + String get reportDescriptionHint => 'Describe the issue (optional)'; + + @override + String get reportSubmit => 'Submit report'; + + @override + String get reportSubmitted => 'Report submitted. Thank you.'; + + @override + String get reportFailed => 'Could not submit report.'; + @override String get shareFailed => 'Could not open the share sheet.'; diff --git a/lib/l10n/app_localizations_id.dart b/lib/l10n/app_localizations_id.dart index fe736cc..b6ce3be 100644 --- a/lib/l10n/app_localizations_id.dart +++ b/lib/l10n/app_localizations_id.dart @@ -187,9 +187,6 @@ class AppLocalizationsId extends AppLocalizations { @override String get share => 'Bagikan'; - @override - String get localOnlyComments => 'Hanya terlihat di perangkat ini'; - @override String get noComments => 'Belum ada komentar.'; @@ -199,6 +196,98 @@ class AppLocalizationsId extends AppLocalizations { @override String get postComment => 'Kirim'; + @override + String get loadMore => 'Muat lebih banyak'; + + @override + String get commentsLoadFailed => 'Komentar tidak dapat dimuat.'; + + @override + String get commentPostFailed => 'Komentar tidak dapat dikirim.'; + + @override + String get delete => 'Hapus'; + + @override + String get deleteComment => 'Hapus komentar'; + + @override + String get deleteCommentTitle => 'Hapus komentar ini?'; + + @override + String get deleteCommentMessage => + 'Komentar ini akan dihapus dari percakapan.'; + + @override + String get commentDeleteFailed => 'Komentar tidak dapat dihapus.'; + + @override + String get underReview => 'Sedang ditinjau'; + + @override + String get reply => 'Balas'; + + @override + String replyingTo(Object name) { + return 'Membalas $name'; + } + + @override + String get cancelReply => 'Batal membalas'; + + @override + String viewReplies(int count) { + return 'Lihat balasan ($count)'; + } + + @override + String get hideReplies => 'Sembunyikan balasan'; + + @override + String get anonymousUser => 'Penonton'; + + @override + String get more => 'Lainnya'; + + @override + String get likeFailed => 'Status suka tidak dapat diperbarui.'; + + @override + String get reportComment => 'Laporkan komentar'; + + @override + String get reportDrama => 'Laporkan drama'; + + @override + String get reportReason => 'Alasan'; + + @override + String get reportReasonSpam => 'Spam'; + + @override + String get reportReasonAbuse => 'Pelecehan'; + + @override + String get reportReasonPorn => 'Konten seksual'; + + @override + String get reportReasonAd => 'Iklan'; + + @override + String get reportReasonOther => 'Lainnya'; + + @override + String get reportDescriptionHint => 'Jelaskan masalah (opsional)'; + + @override + String get reportSubmit => 'Kirim laporan'; + + @override + String get reportSubmitted => 'Laporan terkirim. Terima kasih.'; + + @override + String get reportFailed => 'Laporan tidak dapat dikirim.'; + @override String get shareFailed => 'Tidak bisa membuka menu berbagi.'; diff --git a/lib/l10n/app_localizations_zh.dart b/lib/l10n/app_localizations_zh.dart index 8a24435..e6d1590 100644 --- a/lib/l10n/app_localizations_zh.dart +++ b/lib/l10n/app_localizations_zh.dart @@ -184,9 +184,6 @@ class AppLocalizationsZh extends AppLocalizations { @override String get share => '分享'; - @override - String get localOnlyComments => '仅在本机可见'; - @override String get noComments => '还没有评论。'; @@ -196,6 +193,97 @@ class AppLocalizationsZh extends AppLocalizations { @override String get postComment => '发布'; + @override + String get loadMore => '加载更多'; + + @override + String get commentsLoadFailed => '评论加载失败,请重试。'; + + @override + String get commentPostFailed => '评论发布失败,请重试。'; + + @override + String get delete => '删除'; + + @override + String get deleteComment => '删除评论'; + + @override + String get deleteCommentTitle => '删除这条评论?'; + + @override + String get deleteCommentMessage => '删除后,这条评论将从评论列表中移除。'; + + @override + String get commentDeleteFailed => '评论删除失败,请重试。'; + + @override + String get underReview => '审核中'; + + @override + String get reply => '回复'; + + @override + String replyingTo(Object name) { + return '回复 $name'; + } + + @override + String get cancelReply => '取消回复'; + + @override + String viewReplies(int count) { + return '查看回复($count)'; + } + + @override + String get hideReplies => '收起回复'; + + @override + String get anonymousUser => '观众'; + + @override + String get more => '更多'; + + @override + String get likeFailed => '点赞状态更新失败,请重试。'; + + @override + String get reportComment => '举报评论'; + + @override + String get reportDrama => '举报短剧'; + + @override + String get reportReason => '举报原因'; + + @override + String get reportReasonSpam => '垃圾广告'; + + @override + String get reportReasonAbuse => '辱骂骚扰'; + + @override + String get reportReasonPorn => '色情低俗'; + + @override + String get reportReasonAd => '引流广告'; + + @override + String get reportReasonOther => '其他'; + + @override + String get reportDescriptionHint => '补充说明(选填)'; + + @override + String get reportSubmit => '提交举报'; + + @override + String get reportSubmitted => '举报已提交,感谢反馈。'; + + @override + String get reportFailed => '举报提交失败,请重试。'; + @override String get shareFailed => '无法打开系统分享面板。'; diff --git a/lib/l10n/app_zh.arb b/lib/l10n/app_zh.arb index 264e5de..a23e533 100644 --- a/lib/l10n/app_zh.arb +++ b/lib/l10n/app_zh.arb @@ -65,10 +65,50 @@ "save": "收藏", "comments": "评论", "share": "分享", - "localOnlyComments": "仅在本机可见", "noComments": "还没有评论。", "writeComment": "写评论", "postComment": "发布", + "loadMore": "加载更多", + "commentsLoadFailed": "评论加载失败,请重试。", + "commentPostFailed": "评论发布失败,请重试。", + "delete": "删除", + "deleteComment": "删除评论", + "deleteCommentTitle": "删除这条评论?", + "deleteCommentMessage": "删除后,这条评论将从评论列表中移除。", + "commentDeleteFailed": "评论删除失败,请重试。", + "underReview": "审核中", + "reply": "回复", + "replyingTo": "回复 {name}", + "@replyingTo": { + "placeholders": { + "name": {} + } + }, + "cancelReply": "取消回复", + "viewReplies": "查看回复({count})", + "@viewReplies": { + "placeholders": { + "count": { + "type": "int" + } + } + }, + "hideReplies": "收起回复", + "anonymousUser": "观众", + "more": "更多", + "likeFailed": "点赞状态更新失败,请重试。", + "reportComment": "举报评论", + "reportDrama": "举报短剧", + "reportReason": "举报原因", + "reportReasonSpam": "垃圾广告", + "reportReasonAbuse": "辱骂骚扰", + "reportReasonPorn": "色情低俗", + "reportReasonAd": "引流广告", + "reportReasonOther": "其他", + "reportDescriptionHint": "补充说明(选填)", + "reportSubmit": "提交举报", + "reportSubmitted": "举报已提交,感谢反馈。", + "reportFailed": "举报提交失败,请重试。", "shareFailed": "无法打开系统分享面板。", "nowPlaying": "正在播放", "watchFullscreen": "横屏全屏观看", diff --git a/lib/pages/drama_detail/drama_detail_view.dart b/lib/pages/drama_detail/drama_detail_view.dart index 131298e..af04e8b 100644 --- a/lib/pages/drama_detail/drama_detail_view.dart +++ b/lib/pages/drama_detail/drama_detail_view.dart @@ -8,17 +8,21 @@ import 'package:provider/provider.dart'; import '../../core/data/models/drama.dart'; import '../../core/data/services/catalog_controller.dart'; import '../../core/data/services/favorite_controller.dart'; +import '../../core/data/services/interaction_controller.dart'; import '../../core/formatting/error_text.dart'; import '../../core/formatting/localized_content.dart'; import '../../core/widgets/remote_image.dart'; import '../../core/widgets/auth_gate.dart'; import '../../core/widgets/download_action.dart'; import '../../l10n/app_localizations.dart'; +import '../interaction/widgets/report_dialog.dart'; import 'drama_detail_binding.dart'; import 'drama_detail_logic.dart'; import '../../core/data/repositories/watch_history_repository.dart'; import '../../core/data/repositories/playback_repository.dart'; +const String _reportMenuValue = 'report'; + class DramaDetailPage extends StatefulWidget { const DramaDetailPage({super.key, required this.drama}); final Drama drama; @@ -138,6 +142,7 @@ class _DramaDetailPageState extends State { backgroundColor: const Color(0xFF111111), foregroundColor: Colors.white, actions: [ + _reportAction(context, l10n), _downloadAction(context, l10n), _favoriteAction(context, l10n), ], @@ -291,6 +296,42 @@ class _DramaDetailPageState extends State { ); } + /// 详情页更多菜单:本批只提供举报短剧。 + Widget _reportAction(BuildContext context, AppLocalizations l10n) { + return PopupMenuButton( + key: const Key('detail-more'), + tooltip: l10n.more, + onSelected: (_) => unawaited(_reportDrama(l10n)), + itemBuilder: (_) => [ + PopupMenuItem( + value: _reportMenuValue, + child: Text(l10n.reportDrama), + ), + ], + ); + } + + Future _reportDrama(AppLocalizations l10n) async { + if (!await ensureSignedIn(context) || !mounted) return; + final draft = await showReportDialog(context, title: l10n.reportDrama); + if (draft == null || !mounted) return; + final result = await context.read().reportDrama( + logic.drama.id, + reason: draft.reason, + description: draft.description, + ); + if (!mounted) return; + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text( + result.isSuccess + ? l10n.reportSubmitted + : result.errorMessage ?? l10n.reportFailed, + ), + ), + ); + } + /// 收藏按钮:状态取自服务端(乐观更新,失败回滚并提示)。 Widget _favoriteAction(BuildContext context, AppLocalizations l10n) { final favorites = context.watch(); diff --git a/lib/pages/interaction/widgets/report_dialog.dart b/lib/pages/interaction/widgets/report_dialog.dart new file mode 100644 index 0000000..e6fae25 --- /dev/null +++ b/lib/pages/interaction/widgets/report_dialog.dart @@ -0,0 +1,125 @@ +// Author: fruit.com.cn + +import 'package:flutter/material.dart'; + +import '../../../core/data/models/interaction.dart'; +import '../../../l10n/app_localizations.dart'; + +const int _maxDescriptionLength = 300; + +/// 举报弹窗收集的结果。 +class ReportDialogResult { + const ReportDialogResult({ + required this.reason, + required this.description, + }); + + final ReportReason reason; + final String description; +} + +/// 打开举报原因单选弹窗;取消时返回 null。 +Future showReportDialog( + BuildContext context, { + required String title, +}) => showDialog( + context: context, + builder: (_) => _ReportDialog(title: title), +); + +class _ReportDialog extends StatefulWidget { + const _ReportDialog({required this.title}); + + final String title; + + @override + State<_ReportDialog> createState() => _ReportDialogState(); +} + +class _ReportDialogState extends State<_ReportDialog> { + final _description = TextEditingController(); + ReportReason _reason = ReportReason.spam; + + @override + void dispose() { + _description.dispose(); + super.dispose(); + } + + void _submit() { + Navigator.of(context).pop( + ReportDialogResult( + reason: _reason, + description: _description.text.trim(), + ), + ); + } + + String _reasonLabel(AppLocalizations l10n, ReportReason reason) => + switch (reason) { + ReportReason.spam => l10n.reportReasonSpam, + ReportReason.abuse => l10n.reportReasonAbuse, + ReportReason.porn => l10n.reportReasonPorn, + ReportReason.ad => l10n.reportReasonAd, + ReportReason.other => l10n.reportReasonOther, + }; + + @override + Widget build(BuildContext context) { + final l10n = AppLocalizations.of(context)!; + return AlertDialog( + title: Text(widget.title), + content: SingleChildScrollView( + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text(l10n.reportReason), + RadioGroup( + groupValue: _reason, + onChanged: (value) { + if (value == null) return; + setState(() => _reason = value); + }, + child: Column( + children: [ + for (final reason in ReportReason.values) + RadioListTile( + key: Key('report-reason-${reason.apiValue}'), + value: reason, + contentPadding: EdgeInsets.zero, + dense: true, + title: Text(_reasonLabel(l10n, reason)), + ), + ], + ), + ), + const SizedBox(height: 8), + TextField( + key: const Key('report-description'), + controller: _description, + maxLength: _maxDescriptionLength, + maxLines: 3, + minLines: 2, + decoration: InputDecoration( + hintText: l10n.reportDescriptionHint, + border: const OutlineInputBorder(), + ), + ), + ], + ), + ), + actions: [ + TextButton( + onPressed: () => Navigator.of(context).pop(), + child: Text(l10n.cancel), + ), + FilledButton( + key: const Key('report-submit'), + onPressed: _submit, + child: Text(l10n.reportSubmit), + ), + ], + ); + } +} diff --git a/lib/pages/mine/mine_view.dart b/lib/pages/mine/mine_view.dart index 1546d2b..af0a003 100644 --- a/lib/pages/mine/mine_view.dart +++ b/lib/pages/mine/mine_view.dart @@ -9,7 +9,7 @@ import '../../core/formatting/localized_content.dart'; import '../../core/data/models/drama.dart'; import '../../core/data/repositories/watch_history_repository.dart'; import '../../core/data/services/auth_controller.dart'; -import '../../core/data/services/engagement_controller.dart'; +import '../../core/data/services/interaction_controller.dart'; import '../../core/data/services/favorite_controller.dart'; import '../../core/formatting/error_text.dart'; import '../../core/widgets/remote_image.dart'; @@ -474,14 +474,14 @@ class _MyPageState extends State { logic.filter == 0 || (logic.filter == 1 && fraction < 0.99) || (logic.filter == 2 && fraction >= 0.99); - final engagement = context.watch(); - // 收藏以服务端为准(收藏列表接口返回卡片结构);点赞仍是本地状态(K3 接互动)。 + final interactions = context.watch(); + // 收藏以服务端为准;剧集点赞暂按当前会话状态过滤 feed。 final favorites = context.watch(); final isWatchlist = logic.section == 1; final markedDramas = isWatchlist ? favorites.cards : (widget.dramas ?? [widget.drama]) - .where((drama) => engagement.isLiked(drama.id)) + .where((drama) => interactions.isLiked(drama.id)) .toList(); return Column( crossAxisAlignment: CrossAxisAlignment.start, diff --git a/lib/pages/player/player_view.dart b/lib/pages/player/player_view.dart index c5521db..75941bf 100644 --- a/lib/pages/player/player_view.dart +++ b/lib/pages/player/player_view.dart @@ -9,8 +9,8 @@ import 'package:video_player/video_player.dart'; import '../../core/data/models/drama.dart'; import '../../core/data/models/play_ticket.dart'; -import '../../core/data/services/engagement_controller.dart'; import '../../core/data/services/favorite_controller.dart'; +import '../../core/data/services/interaction_controller.dart'; import '../../core/data/services/playback_session.dart'; import '../../core/data/services/video_player_port.dart'; import '../../core/formatting/error_text.dart'; @@ -108,7 +108,7 @@ class _PlayerPageState extends State with WidgetsBindingObserver { } Widget _buildPlayer(BuildContext context) { - final engagement = context.watch(); + final interactions = context.watch(); final indices = logic.visibleIndices; final pages = logic.pages; final content = AnimatedBuilder( @@ -124,7 +124,7 @@ class _PlayerPageState extends State with WidgetsBindingObserver { unawaited(logic.selectEpisode(index)); }, itemBuilder: (context, position) => - _buildEpisode(context, indices[position], engagement), + _buildEpisode(context, indices[position], interactions), ), ); return AnnotatedRegion( @@ -141,7 +141,7 @@ class _PlayerPageState extends State with WidgetsBindingObserver { Widget _buildEpisode( BuildContext context, int index, - EngagementController engagement, + InteractionController interactions, ) { final l10n = AppLocalizations.of(context)!; final entry = logic.queue.entryAt(index); @@ -336,7 +336,7 @@ class _PlayerPageState extends State with WidgetsBindingObserver { drama: drama, episode: episode, controller: ready ? videoPort!.controller : null, - liked: engagement.isLiked(drama.id), + liked: interactions.isLiked(drama.id), // 收藏以服务端为准(FavoriteController 由 app 注入,登录后自动加载) saved: context.watch().isSaved(drama.id), onBack: widget.embedded @@ -348,7 +348,17 @@ class _PlayerPageState extends State with WidgetsBindingObserver { // 收藏/点赞要对到具体账号:未登录先引导登录(首页/详情仍可匿名浏览) onLike: () async { if (await ensureSignedIn(context)) { - unawaited(engagement.toggleLiked(drama.id)); + final result = await interactions.toggleDramaLike(drama.id); + if (!result.isSuccess && context.mounted) { + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text( + result.errorMessage ?? + AppLocalizations.of(context)!.likeFailed, + ), + ), + ); + } } }, onSave: () async { diff --git a/lib/pages/player/widgets/comment_tile.dart b/lib/pages/player/widgets/comment_tile.dart new file mode 100644 index 0000000..f453682 --- /dev/null +++ b/lib/pages/player/widgets/comment_tile.dart @@ -0,0 +1,149 @@ +// Author: fruit.com.cn + +import 'package:flutter/material.dart'; + +import '../../../core/data/models/comment.dart'; +import '../../../core/data/services/comment_controller.dart'; +import '../../../core/theme/app_colors.dart'; +import '../../../l10n/app_localizations.dart'; + +const String _deleteAction = 'delete'; +const String _reportAction = 'report'; + +/// 评论条目的交互回调集合。 +class CommentInteractionHandlers { + const CommentInteractionHandlers({ + required this.onReply, + required this.onLike, + required this.onDelete, + required this.onReport, + }); + + final ValueChanged onReply; + final Future Function(DramaComment) onLike; + final Future Function(DramaComment) onDelete; + final Future Function(DramaComment) onReport; +} + +/// 单条评论或回复的展示与操作行。 +class CommentTile extends StatelessWidget { + const CommentTile({ + super.key, + required this.comment, + required this.controller, + required this.handlers, + this.isReply = false, + }); + + final DramaComment comment; + final CommentController controller; + final CommentInteractionHandlers handlers; + final bool isReply; + + @override + Widget build(BuildContext context) { + final l10n = AppLocalizations.of(context)!; + final name = comment.nickname.isEmpty ? l10n.anonymousUser : comment.nickname; + return Padding( + key: Key('comment-item-${comment.id}'), + padding: const EdgeInsets.symmetric(vertical: 8), + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + CircleAvatar( + radius: isReply ? 12 : 16, + backgroundColor: AppColors.blue.withValues(alpha: 0.2), + child: Icon( + Icons.person_rounded, + size: isReply ? 14 : 18, + color: AppColors.blueSoft, + ), + ), + const SizedBox(width: 12), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + children: [ + Expanded( + child: Text( + name, + style: const TextStyle( + color: AppColors.muted, + fontSize: 12, + ), + ), + ), + PopupMenuButton( + key: Key('comment-menu-${comment.id}'), + tooltip: l10n.more, + onSelected: (value) { + if (value == _deleteAction) { + handlers.onDelete(comment); + } else if (value == _reportAction) { + handlers.onReport(comment); + } + }, + itemBuilder: (_) => [ + if (comment.mine) + PopupMenuItem( + value: _deleteAction, + child: Text(l10n.deleteComment), + ) + else + PopupMenuItem( + value: _reportAction, + child: Text(l10n.reportComment), + ), + ], + ), + ], + ), + Text( + comment.content, + style: const TextStyle(color: Colors.white, fontSize: 14), + ), + if (comment.isPending) + Padding( + padding: const EdgeInsets.only(top: 4), + child: Text( + l10n.underReview, + key: Key('comment-pending-${comment.id}'), + style: const TextStyle( + color: AppColors.blueSoft, + fontSize: 11, + ), + ), + ), + Row( + children: [ + TextButton.icon( + key: Key('comment-like-${comment.id}'), + onPressed: controller.likingComment(comment.id) + ? null + : () => handlers.onLike(comment), + icon: Icon( + comment.liked + ? Icons.favorite_rounded + : Icons.favorite_border_rounded, + size: 16, + ), + label: Text('${comment.likeCount}'), + ), + if (!isReply) + TextButton( + key: Key('comment-reply-${comment.id}'), + onPressed: () => handlers.onReply(comment), + child: Text(l10n.reply), + ), + ], + ), + ], + ), + ), + ], + ), + ); + } +} diff --git a/lib/pages/player/widgets/drama_comments_sheet.dart b/lib/pages/player/widgets/drama_comments_sheet.dart index f819f5c..708bb4a 100644 --- a/lib/pages/player/widgets/drama_comments_sheet.dart +++ b/lib/pages/player/widgets/drama_comments_sheet.dart @@ -1,12 +1,27 @@ // Author: fruit.com.cn +import 'dart:async'; + import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; +import '../../../core/data/models/comment.dart'; import '../../../core/data/models/drama.dart'; -import '../../../core/data/services/engagement_controller.dart'; +import '../../../core/data/repositories/comment_repository.dart'; +import '../../../core/data/repositories/interaction_repository.dart'; +import '../../../core/data/services/comment_controller.dart'; +import '../../../core/formatting/error_text.dart'; +import '../../../core/theme/app_colors.dart'; +import '../../../core/widgets/auth_gate.dart'; import '../../../l10n/app_localizations.dart'; +import '../../interaction/widgets/report_dialog.dart'; +import 'comment_tile.dart'; +const double _minSheetHeight = 240; +const double _maxSheetHeight = 460; +const int _maxCommentLength = 300; + +/// 服务端评论底部弹窗:匿名列表、游标翻页、回复、点赞和本人删除。 class DramaCommentsSheet extends StatefulWidget { const DramaCommentsSheet({super.key, required this.drama}); @@ -18,26 +33,120 @@ class DramaCommentsSheet extends StatefulWidget { class _DramaCommentsSheetState extends State { final _input = TextEditingController(); + final _inputFocus = FocusNode(); + late final CommentController _controller; + DramaComment? _replyTo; + + @override + void initState() { + super.initState(); + _controller = CommentController( + comments: context.read(), + interactions: context.read(), + dramaId: widget.drama.id, + ); + unawaited(_controller.load()); + } @override void dispose() { + _controller.dispose(); _input.dispose(); + _inputFocus.dispose(); super.dispose(); } - void _post() { - final text = _input.text.trim(); - if (text.isEmpty) return; - context.read().addComment(widget.drama.id, text); - _input.clear(); + Future _post() async { + if (_controller.submitting) return; + if (_input.text.trim().isEmpty) return; + if (!await ensureSignedIn(context) || !mounted) return; + final result = await _controller.publish(_input.text, replyTo: _replyTo); + if (!mounted) return; + if (result.isSuccess) { + _input.clear(); + setState(() => _replyTo = null); + return; + } + _showMessage( + result.errorMessage ?? AppLocalizations.of(context)!.commentPostFailed, + ); + } + + void _beginReply(DramaComment comment) { + setState(() => _replyTo = comment); + _inputFocus.requestFocus(); + } + + void _cancelReply() { + if (_replyTo == null) return; + setState(() => _replyTo = null); + } + + Future _like(DramaComment comment) async { + if (!await ensureSignedIn(context) || !mounted) return; + final result = await _controller.toggleLike(comment); + if (!result.isSuccess && mounted) { + _showMessage( + result.errorMessage ?? AppLocalizations.of(context)!.commentPostFailed, + ); + } + } + + Future _confirmDelete(DramaComment comment) async { + final l10n = AppLocalizations.of(context)!; + final confirmed = await showDialog( + context: context, + builder: (dialogContext) => AlertDialog( + title: Text(l10n.deleteCommentTitle), + content: Text(l10n.deleteCommentMessage), + actions: [ + TextButton( + onPressed: () => Navigator.of(dialogContext).pop(false), + child: Text(l10n.cancel), + ), + FilledButton( + key: const Key('comment-delete-confirm'), + onPressed: () => Navigator.of(dialogContext).pop(true), + child: Text(l10n.delete), + ), + ], + ), + ); + if (confirmed != true || !mounted) return; + final result = await _controller.delete(comment); + if (!result.isSuccess && mounted) { + _showMessage( + result.errorMessage ?? AppLocalizations.of(context)!.commentDeleteFailed, + ); + } + } + + Future _report(DramaComment comment) async { + if (!await ensureSignedIn(context) || !mounted) return; + final l10n = AppLocalizations.of(context)!; + final draft = await showReportDialog(context, title: l10n.reportComment); + if (draft == null || !mounted) return; + final result = await _controller.report( + comment, + reason: draft.reason, + description: draft.description, + ); + if (!mounted) return; + _showMessage( + result.isSuccess + ? l10n.reportSubmitted + : result.errorMessage ?? l10n.reportFailed, + ); + } + + void _showMessage(String message) { + ScaffoldMessenger.of( + context, + ).showSnackBar(SnackBar(content: Text(message))); } @override Widget build(BuildContext context) { - final l10n = AppLocalizations.of(context)!; - final comments = context.watch().commentsFor( - widget.drama.id, - ); final available = MediaQuery.sizeOf(context).height - MediaQuery.viewInsetsOf(context).bottom - @@ -45,83 +154,244 @@ class _DramaCommentsSheetState extends State { return Padding( padding: EdgeInsets.only(bottom: MediaQuery.viewInsetsOf(context).bottom), child: SizedBox( - height: available.clamp(240.0, 460.0), + height: available.clamp(_minSheetHeight, _maxSheetHeight), child: SafeArea( top: false, child: Padding( padding: const EdgeInsets.fromLTRB(16, 12, 16, 8), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - l10n.comments, - style: const TextStyle( - fontSize: 20, - fontWeight: FontWeight.w700, - ), - ), - const SizedBox(height: 3), - Text( - l10n.localOnlyComments, - style: const TextStyle(color: Color(0xFFE6E1E3), fontSize: 13), - ), - const SizedBox(height: 14), - Expanded( - child: comments.isEmpty - ? Center( - child: Text( - l10n.noComments, - style: const TextStyle(color: Color(0xFFE6E1E3)), - ), - ) - : ListView.separated( - itemCount: comments.length, - separatorBuilder: (_, _) => const Divider(height: 1), - itemBuilder: (context, index) => ListTile( - leading: const CircleAvatar( - radius: 16, - child: Icon(Icons.person_rounded, size: 18), - ), - title: Text(comments[index]), - contentPadding: EdgeInsets.zero, - ), - ), - ), - Row( - children: [ - Expanded( - child: TextField( - key: const Key('comment-input'), - controller: _input, - maxLength: 300, - maxLines: 1, - decoration: InputDecoration( - hintText: l10n.writeComment, - counterText: '', - filled: true, - fillColor: const Color(0xFF35353A), - border: OutlineInputBorder( - borderRadius: BorderRadius.circular(14), - borderSide: BorderSide.none, - ), - ), - onSubmitted: (_) => _post(), - ), - ), - const SizedBox(width: 8), - IconButton.filled( - key: const Key('comment-post'), - tooltip: l10n.postComment, - onPressed: _post, - icon: const Icon(Icons.send_rounded), - ), - ], - ), - ], + child: ListenableBuilder( + listenable: _controller, + builder: (context, _) => _content(context), ), ), ), ), ); } + + Widget _content(BuildContext context) { + final l10n = AppLocalizations.of(context)!; + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + l10n.comments, + style: const TextStyle(fontSize: 20, fontWeight: FontWeight.w700), + ), + const SizedBox(height: 8), + Expanded(child: _list(l10n)), + if (_replyTo != null) _replyBanner(l10n, _replyTo!), + _composer(l10n), + ], + ); + } + + Widget _list(AppLocalizations l10n) { + if (_controller.loading && _controller.comments.isEmpty) { + return const Center( + child: CircularProgressIndicator(key: Key('comment-list-loading')), + ); + } + if (_controller.error != null && _controller.comments.isEmpty) { + return Center( + key: const Key('comment-list-error'), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Text( + errorText(l10n, _controller.error, l10n.commentsLoadFailed), + textAlign: TextAlign.center, + style: const TextStyle(color: AppColors.muted), + ), + const SizedBox(height: 8), + TextButton( + key: const Key('comment-list-retry'), + onPressed: _controller.load, + child: Text(l10n.retry), + ), + ], + ), + ); + } + if (_controller.comments.isEmpty) { + return Center( + key: const Key('comment-list-empty'), + child: Text( + l10n.noComments, + style: const TextStyle(color: AppColors.muted), + ), + ); + } + return ListView.builder( + key: const Key('comment-list'), + itemCount: _controller.comments.length + 1, + itemBuilder: (context, index) { + if (index == _controller.comments.length) return _footer(l10n); + return _CommentThread( + comment: _controller.comments[index], + controller: _controller, + handlers: CommentInteractionHandlers( + onReply: _beginReply, + onLike: _like, + onDelete: _confirmDelete, + onReport: _report, + ), + ); + }, + ); + } + + Widget _footer(AppLocalizations l10n) { + if (_controller.loadingMore) { + return const Padding( + padding: EdgeInsets.symmetric(vertical: 12), + child: Center(child: CircularProgressIndicator()), + ); + } + if (_controller.hasMore) { + return TextButton( + key: const Key('comment-list-load-more'), + onPressed: _controller.loadMore, + child: Text(l10n.loadMore), + ); + } + return const SizedBox(height: 8); + } + + Widget _replyBanner(AppLocalizations l10n, DramaComment replyTo) => Padding( + padding: const EdgeInsets.only(bottom: 6), + child: Row( + children: [ + Expanded( + child: Text( + l10n.replyingTo( + replyTo.nickname.isEmpty ? l10n.anonymousUser : replyTo.nickname, + ), + style: const TextStyle(color: AppColors.blueSoft, fontSize: 12), + ), + ), + IconButton( + key: const Key('comment-cancel-reply'), + tooltip: l10n.cancelReply, + onPressed: _cancelReply, + visualDensity: VisualDensity.compact, + icon: const Icon(Icons.close_rounded, size: 18), + ), + ], + ), + ); + + Widget _composer(AppLocalizations l10n) => Row( + children: [ + Expanded( + child: TextField( + key: const Key('comment-input'), + controller: _input, + focusNode: _inputFocus, + maxLength: _maxCommentLength, + maxLines: 1, + decoration: InputDecoration( + hintText: l10n.writeComment, + counterText: '', + filled: true, + fillColor: const Color(0xFF35353A), + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(14), + borderSide: BorderSide.none, + ), + ), + onSubmitted: (_) => _post(), + ), + ), + const SizedBox(width: 8), + IconButton.filled( + key: const Key('comment-post'), + tooltip: l10n.postComment, + onPressed: _controller.submitting ? null : _post, + icon: _controller.submitting + ? const SizedBox.square( + dimension: 18, + child: CircularProgressIndicator(strokeWidth: 2), + ) + : const Icon(Icons.send_rounded), + ), + ], + ); +} + +class _CommentThread extends StatelessWidget { + const _CommentThread({ + required this.comment, + required this.controller, + required this.handlers, + }); + + final DramaComment comment; + final CommentController controller; + final CommentInteractionHandlers handlers; + + @override + Widget build(BuildContext context) { + final replies = controller.repliesFor(comment.id); + final expanded = controller.repliesExpanded(comment.id); + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + CommentTile( + comment: comment, + controller: controller, + handlers: handlers, + ), + if (comment.replyCount > 0 || replies.isNotEmpty) + Padding( + padding: const EdgeInsets.only(left: 44, bottom: 8), + child: TextButton( + key: Key('comment-replies-${comment.id}'), + onPressed: () => _toggleReplies(context), + child: Text( + expanded + ? AppLocalizations.of(context)!.hideReplies + : AppLocalizations.of( + context, + )!.viewReplies(comment.replyCount), + ), + ), + ), + if (expanded) + Padding( + padding: const EdgeInsets.only(left: 28), + child: Column( + children: [ + if (controller.repliesLoading(comment.id)) + const Padding( + padding: EdgeInsets.symmetric(vertical: 8), + child: CircularProgressIndicator(), + ), + for (final reply in replies) + CommentTile( + comment: reply, + controller: controller, + handlers: handlers, + isReply: true, + ), + if (controller.repliesHasMore(comment.id)) + TextButton( + onPressed: () => controller.loadMoreReplies(comment.id), + child: Text(AppLocalizations.of(context)!.loadMore), + ), + ], + ), + ), + const Divider(height: 1), + ], + ); + } + + Future _toggleReplies(BuildContext context) async { + if (controller.repliesExpanded(comment.id)) { + controller.hideReplies(comment.id); + return; + } + await controller.loadReplies(comment.id); + } } diff --git a/test/comment/comment_api_test.dart b/test/comment/comment_api_test.dart new file mode 100644 index 0000000..a83dfce --- /dev/null +++ b/test/comment/comment_api_test.dart @@ -0,0 +1,129 @@ +// Author: fruit.com.cn + +import 'dart:convert'; + +import 'package:flutter_test/flutter_test.dart'; +import 'package:fruitshorts/core/data/remote/api_client.dart'; +import 'package:fruitshorts/core/data/remote/comment_api.dart'; + +import '../support/fake_http_adapter.dart'; + +void main() { + String envelope(Object? data) => + jsonEncode({'code': 0, 'message': 'ok', 'data': data}); + + Map commentJson({ + String id = '2111012753262120962', + String content = 'Great episode', + String status = 'published', + bool mine = false, + bool liked = true, + String parentId = '0', + String rootId = '0', + }) => { + 'id': id, + 'dramaId': '5', + 'episodeId': '7', + 'parentId': parentId, + 'rootId': rootId, + 'userId': '2111012753262120001', + 'uid': 'viewer-1', + 'nickname': 'Viewer', + 'avatarUrl': '', + 'content': content, + 'status': status, + 'auditReason': '', + 'likeCount': '12', + 'replyCount': 2, + 'reportCount': '0', + 'createdAt': '2026-10-17T12:30:00', + 'mine': mine, + 'liked': liked, + }; + + test('should_parse_cursor_page_and_string_ids_when_comment_list_is_loaded', () async { + final adapter = FakeHttpAdapter((options) async { + return FakeHttpResponse( + envelope({ + 'list': [commentJson()], + 'nextCursor': '2111012753262120962', + 'hasMore': true, + }), + ); + }); + final api = CommentApi( + ApiClient(baseUrl: 'http://127.0.0.1:8081', adapter: adapter), + ); + + final page = await api.page(dramaId: '5', cursor: '99', size: 20); + + expect(adapter.requests.single.method, 'GET'); + expect(adapter.requests.single.uri.path, '/app/comments'); + expect(adapter.requests.single.queryParameters, { + 'dramaId': '5', + 'cursor': '99', + 'size': '20', + }); + expect(page.comments.single.id, '2111012753262120962'); + expect(page.comments.single.dramaId, '5'); + expect(page.comments.single.episodeId, '7'); + expect(page.comments.single.likeCount, 12); + expect(page.nextCursor, '2111012753262120962'); + expect(page.hasMore, isTrue); + }); + + test('should_send_parent_id_only_for_reply_and_parse_replaced_content_when_published', () async { + final adapter = FakeHttpAdapter((options) async { + return FakeHttpResponse( + envelope( + commentJson( + id: '2111012753262120999', + content: 'great ***', + status: 'pending', + mine: true, + parentId: '2111012753262120962', + rootId: '2111012753262120962', + ), + ), + ); + }); + final api = CommentApi( + ApiClient(baseUrl: 'http://127.0.0.1:8081', adapter: adapter), + ); + + final reply = await api.publish( + dramaId: '5', + content: 'great badword', + parentId: '2111012753262120962', + ); + + expect(adapter.requests.single.method, 'POST'); + expect(adapter.requests.single.uri.path, '/app/comments'); + expect(adapter.requests.single.data, { + 'dramaId': '5', + 'content': 'great badword', + 'parentId': '2111012753262120962', + }); + expect(reply.content, 'great ***'); + expect(reply.status, 'pending'); + expect(reply.parentId, '2111012753262120962'); + expect(reply.rootId, '2111012753262120962'); + }); + + test('should_delete_comment_by_string_id_when_requested', () async { + final adapter = FakeHttpAdapter( + (_) async => FakeHttpResponse(envelope(null)), + ); + final api = CommentApi( + ApiClient(baseUrl: 'http://127.0.0.1:8081', adapter: adapter), + ); + + await api.delete('2111012753262120962'); + + expect(adapter.requests.single.method, 'DELETE'); + expect( + adapter.requests.single.uri.path, + '/app/comments/2111012753262120962', + ); + }); +} diff --git a/test/comment/comment_controller_test.dart b/test/comment/comment_controller_test.dart new file mode 100644 index 0000000..b47f97f --- /dev/null +++ b/test/comment/comment_controller_test.dart @@ -0,0 +1,192 @@ +// Author: fruit.com.cn + +import 'package:flutter_test/flutter_test.dart'; +import 'package:fruitshorts/core/data/models/comment.dart'; +import 'package:fruitshorts/core/data/models/interaction.dart'; +import 'package:fruitshorts/core/data/remote/api_client.dart'; +import 'package:fruitshorts/core/data/services/comment_controller.dart'; + +import '../support/fake_interaction_repositories.dart'; + +void main() { + CommentController controller( + FakeCommentRepository comments, { + FakeInteractionRepository? interactions, + }) => CommentController( + comments: comments, + interactions: interactions ?? FakeInteractionRepository(), + dramaId: '5', + ); + + test('should_append_next_page_with_cursor_when_has_more_is_true', () async { + final repository = FakeCommentRepository( + pages: [ + CommentPage( + comments: [commentFixture(id: '2')], + nextCursor: '2', + hasMore: true, + ), + CommentPage(comments: [commentFixture(id: '1')]), + ], + ); + final model = controller(repository); + + await model.load(); + await model.loadMore(); + + expect(model.comments.map((item) => item.id), ['2', '1']); + expect(model.hasMore, isFalse); + expect(repository.pageCalls[0].cursor, isNull); + expect(repository.pageCalls[1].cursor, '2'); + expect(repository.pageCalls.every((call) => call.size == 20), isTrue); + model.dispose(); + }); + + test('should_use_server_content_and_pending_status_when_review_is_returned', () async { + final repository = FakeCommentRepository( + publishResult: commentFixture( + id: '3', + content: 'replaced ***', + status: 'pending', + mine: true, + ), + ); + final model = controller(repository); + + final result = await model.publish(' replaced badword '); + + expect(result.isSuccess, isTrue); + expect(repository.publishCalls.single.content, 'replaced badword'); + expect(model.comments.single.content, 'replaced ***'); + expect(model.comments.single.isPending, isTrue); + model.dispose(); + }); + + test('should_expose_backend_message_and_keep_existing_list_when_publish_is_blocked', () async { + final repository = FakeCommentRepository( + publishError: const ApiException(400, '评论包含敏感词'), + ); + final model = controller(repository); + await model.load(); + + final result = await model.publish('blocked'); + + expect(result.isSuccess, isFalse); + expect(result.errorMessage, '评论包含敏感词'); + expect(model.comments, isEmpty); + model.dispose(); + }); + + test('should_insert_reply_under_root_and_request_replies_with_root_id', () async { + final root = commentFixture(id: '10', replyCount: 1); + final reply = commentFixture( + id: '11', + parentId: '10', + rootId: '10', + content: 'Reply', + mine: true, + ); + final repository = FakeCommentRepository( + pages: [ + CommentPage(comments: [root]), + CommentPage(comments: [reply]), + ], + publishResult: reply, + ); + final model = controller(repository); + await model.load(); + + await model.loadReplies('10'); + final result = await model.publish('Reply', replyTo: root); + + expect(result.isSuccess, isTrue); + expect(repository.publishCalls.single.parentId, '10'); + expect(repository.pageCalls.last.rootId, '10'); + expect(model.repliesFor('10').map((item) => item.id), ['11']); + model.dispose(); + }); + + test('should_restore_comment_at_original_position_when_delete_fails', () async { + final first = commentFixture(id: '2', mine: true); + final second = commentFixture(id: '1'); + final repository = FakeCommentRepository( + pages: [ + CommentPage(comments: [first, second]), + ], + deleteError: const ApiException(500, '删除失败'), + ); + final model = controller(repository); + await model.load(); + + final result = await model.delete(first); + + expect(result.isSuccess, isFalse); + expect(result.errorMessage, '删除失败'); + expect(model.comments.map((item) => item.id), ['2', '1']); + expect(repository.deleteCalls, ['2']); + model.dispose(); + }); + + test('should_remove_own_comment_when_delete_succeeds', () async { + final own = commentFixture(id: '2', mine: true); + final repository = FakeCommentRepository( + pages: [ + CommentPage(comments: [own]), + ], + ); + final model = controller(repository); + await model.load(); + + final result = await model.delete(own); + + expect(result.isSuccess, isTrue); + expect(model.comments, isEmpty); + model.dispose(); + }); + + test('should_optimistically_update_comment_like_and_apply_server_count', () async { + final comment = commentFixture(id: '2', likeCount: 3, liked: false); + final interactions = FakeInteractionRepository( + nextLikeResult: const LikeToggleResult(liked: true, count: 8), + ); + final repository = FakeCommentRepository( + pages: [ + CommentPage(comments: [comment]), + ], + ); + final model = controller(repository, interactions: interactions); + await model.load(); + + final pending = model.toggleLike(comment); + expect(model.comments.single.liked, isTrue); + expect(model.comments.single.likeCount, 4); + final result = await pending; + + expect(result.isSuccess, isTrue); + expect(model.comments.single.liked, isTrue); + expect(model.comments.single.likeCount, 8); + expect(interactions.likeTargets, ['COMMENT:2']); + model.dispose(); + }); + + test('should_rollback_comment_like_when_request_fails', () async { + final comment = commentFixture(id: '2', likeCount: 3, liked: true); + final interactions = FakeInteractionRepository() + ..likeError = const ApiException(500, '点赞失败'); + final repository = FakeCommentRepository( + pages: [ + CommentPage(comments: [comment]), + ], + ); + final model = controller(repository, interactions: interactions); + await model.load(); + + final result = await model.toggleLike(comment); + + expect(result.isSuccess, isFalse); + expect(result.errorMessage, '点赞失败'); + expect(model.comments.single.liked, isTrue); + expect(model.comments.single.likeCount, 3); + model.dispose(); + }); +} diff --git a/test/comment/drama_comments_sheet_test.dart b/test/comment/drama_comments_sheet_test.dart new file mode 100644 index 0000000..ad2a65b --- /dev/null +++ b/test/comment/drama_comments_sheet_test.dart @@ -0,0 +1,317 @@ +// Author: fruit.com.cn + +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:fruitshorts/core/data/models/comment.dart'; +import 'package:fruitshorts/core/data/models/drama.dart'; +import 'package:fruitshorts/core/data/models/interaction.dart'; +import 'package:fruitshorts/core/data/remote/api_client.dart'; +import 'package:fruitshorts/core/data/remote/auth_api.dart'; +import 'package:fruitshorts/core/data/repositories/comment_repository.dart'; +import 'package:fruitshorts/core/data/repositories/interaction_repository.dart'; +import 'package:fruitshorts/core/data/services/auth_controller.dart'; +import 'package:fruitshorts/core/data/services/auth_session_store.dart'; +import 'package:fruitshorts/l10n/app_localizations.dart'; +import 'package:fruitshorts/pages/player/widgets/drama_comments_sheet.dart'; +import 'package:provider/provider.dart'; +import 'package:shared_preferences_platform_interface/in_memory_shared_preferences_async.dart'; +import 'package:shared_preferences_platform_interface/shared_preferences_async_platform_interface.dart'; + +import '../support/fake_http_adapter.dart'; +import '../support/fake_interaction_repositories.dart'; + +const _drama = Drama( + id: '5', + title: 'The Signal', + synopsis: 'synopsis', + posterUrl: '/files/5.jpg', +); + +void main() { + setUp(() { + SharedPreferencesAsyncPlatform.instance = + InMemorySharedPreferencesAsync.withData({ + 'auth.accessToken': 'test-access', + 'auth.refreshToken': 'test-refresh', + 'auth.user': '{"uid":"9","nickname":"Me","avatarUrl":""}', + }); + }); + + testWidgets('should_show_server_comments_and_append_next_cursor_page', ( + tester, + ) async { + final repository = FakeCommentRepository( + pages: [ + CommentPage( + comments: [ + commentFixture(id: '10', content: 'Great episode', replyCount: 1), + ], + nextCursor: '10', + hasMore: true, + ), + CommentPage( + comments: [commentFixture(id: '9', content: 'Second page')], + ), + ], + ); + + await _pumpSheet(tester, repository: repository); + expect(find.text('Great episode'), findsOneWidget); + expect(find.byKey(const Key('comment-list-load-more')), findsOneWidget); + + await tester.tap(find.byKey(const Key('comment-list-load-more'))); + await tester.pumpAndSettle(); + + expect(find.text('Second page'), findsOneWidget); + expect(repository.pageCalls.last.cursor, '10'); + }); + + testWidgets('should_keep_input_and_show_backend_message_when_comment_is_blocked', ( + tester, + ) async { + final repository = FakeCommentRepository( + pages: [const CommentPage()], + publishError: const ApiException(400, '评论包含敏感词'), + ); + + await _pumpSheet(tester, repository: repository); + await tester.enterText( + find.byKey(const Key('comment-input')), + 'blocked text', + ); + await tester.tap(find.byKey(const Key('comment-post'))); + await tester.pumpAndSettle(); + + expect(find.text('评论包含敏感词'), findsOneWidget); + final field = tester.widget( + find.byKey(const Key('comment-input')), + ); + expect(field.controller?.text, 'blocked text'); + }); + + testWidgets('should_show_review_badge_and_server_replaced_content', ( + tester, + ) async { + final repository = FakeCommentRepository( + pages: [const CommentPage()], + publishResult: commentFixture( + id: '11', + content: 'hello ***', + status: 'pending', + mine: true, + ), + ); + + await _pumpSheet(tester, repository: repository); + await tester.enterText( + find.byKey(const Key('comment-input')), + 'hello badword', + ); + await tester.tap(find.byKey(const Key('comment-post'))); + await tester.pumpAndSettle(); + + expect(find.text('hello ***'), findsOneWidget); + expect(find.text('Under review'), findsOneWidget); + final field = tester.widget( + find.byKey(const Key('comment-input')), + ); + expect(field.controller?.text, isEmpty); + }); + + testWidgets('should_send_parent_id_when_replying_to_top_level_comment', ( + tester, + ) async { + final root = commentFixture(id: '10', content: 'Root', replyCount: 0); + final repository = FakeCommentRepository( + pages: [ + CommentPage(comments: [root]), + ], + publishResult: commentFixture( + id: '11', + parentId: '10', + rootId: '10', + content: 'My reply', + mine: true, + ), + ); + + await _pumpSheet(tester, repository: repository); + await tester.tap(find.byKey(const Key('comment-reply-10'))); + await tester.pump(); + expect(find.textContaining('Replying to'), findsOneWidget); + await tester.enterText( + find.byKey(const Key('comment-input')), + 'My reply', + ); + await tester.tap(find.byKey(const Key('comment-post'))); + await tester.pumpAndSettle(); + + expect(repository.publishCalls.single.parentId, '10'); + expect(find.text('My reply'), findsOneWidget); + }); + + testWidgets('should_show_error_and_retry_when_comment_page_fails', ( + tester, + ) async { + final repository = FakeCommentRepository( + pageError: StateError('offline'), + ); + + await _pumpSheet(tester, repository: repository); + + expect(find.byKey(const Key('comment-list-error')), findsOneWidget); + expect(find.byKey(const Key('comment-list-retry')), findsOneWidget); + }); + + testWidgets('should_update_comment_like_count_when_server_returns_count', ( + tester, + ) async { + final repository = FakeCommentRepository( + pages: [ + CommentPage( + comments: [commentFixture(id: '10', content: 'Like me')], + ), + ], + ); + final interactions = FakeInteractionRepository() + ..nextLikeResult = const LikeToggleResult(liked: true, count: 7); + + await _pumpSheet( + tester, + repository: repository, + interactions: interactions, + ); + await tester.tap(find.byKey(const Key('comment-like-10'))); + await tester.pumpAndSettle(); + + expect(interactions.likeTargets, ['COMMENT:10']); + expect(find.text('7'), findsOneWidget); + }); + + testWidgets('should_report_comment_and_show_success_when_submitted', ( + tester, + ) async { + final repository = FakeCommentRepository( + pages: [ + CommentPage( + comments: [commentFixture(id: '10', content: 'Report me')], + ), + ], + ); + final interactions = FakeInteractionRepository(); + + await _pumpSheet( + tester, + repository: repository, + interactions: interactions, + ); + await tester.tap(find.byKey(const Key('comment-menu-10'))); + await tester.pumpAndSettle(); + await tester.tap(find.text('Report comment')); + await tester.pumpAndSettle(); + await tester.tap(find.byKey(const Key('report-submit'))); + await tester.pumpAndSettle(); + + expect(interactions.reports.single.targetType, InteractionTargetType.comment); + expect(interactions.reports.single.targetId, '10'); + expect(interactions.reports.single.reasonCode, 'SPAM'); + expect(find.text('Report submitted. Thank you.'), findsOneWidget); + }); + + testWidgets('should_show_backend_message_when_comment_report_is_duplicated', ( + tester, + ) async { + final repository = FakeCommentRepository( + pages: [ + CommentPage( + comments: [commentFixture(id: '10', content: 'Report me')], + ), + ], + ); + final interactions = FakeInteractionRepository() + ..reportError = const ApiException(200003, '你已举报过该内容,我们正在处理'); + + await _pumpSheet( + tester, + repository: repository, + interactions: interactions, + ); + await tester.tap(find.byKey(const Key('comment-menu-10'))); + await tester.pumpAndSettle(); + await tester.tap(find.text('Report comment')); + await tester.pumpAndSettle(); + await tester.tap(find.byKey(const Key('report-submit'))); + await tester.pumpAndSettle(); + + expect(find.text('你已举报过该内容,我们正在处理'), findsOneWidget); + }); + + testWidgets('should_open_auth_gate_without_reporting_when_signed_out', ( + tester, + ) async { + SharedPreferencesAsyncPlatform.instance = + InMemorySharedPreferencesAsync.empty(); + final repository = FakeCommentRepository( + pages: [ + CommentPage( + comments: [commentFixture(id: '10', content: 'Report me')], + ), + ], + ); + final interactions = FakeInteractionRepository(); + + await _pumpSheet( + tester, + repository: repository, + interactions: interactions, + ); + await tester.tap(find.byKey(const Key('comment-menu-10'))); + await tester.pumpAndSettle(); + await tester.tap(find.text('Report comment')); + await tester.pumpAndSettle(); + + expect(find.text('Sign in to continue'), findsOneWidget); + expect(interactions.reports, isEmpty); + }); +} + +Future _pumpSheet( + WidgetTester tester, { + required FakeCommentRepository repository, + FakeInteractionRepository? interactions, +}) async { + final auth = await _auth(); + await tester.pumpWidget( + MultiProvider( + providers: [ + Provider.value(value: repository), + Provider.value( + value: interactions ?? FakeInteractionRepository(), + ), + ChangeNotifierProvider.value(value: auth), + ], + child: MaterialApp( + locale: const Locale('en'), + localizationsDelegates: AppLocalizations.localizationsDelegates, + supportedLocales: AppLocalizations.supportedLocales, + home: const Scaffold( + backgroundColor: Color(0xFF232328), + body: DramaCommentsSheet(drama: _drama), + ), + ), + ), + ); + await tester.pumpAndSettle(); +} + +Future _auth() async { + final client = ApiClient( + baseUrl: 'http://127.0.0.1:8081', + adapter: FakeHttpAdapter( + (_) async => FakeHttpResponse('{"code":0,"message":"ok","data":null}'), + ), + ); + final auth = AuthController(AuthApi(client), AuthSessionStore()); + await auth.load(); + return auth; +} diff --git a/test/core/platform_share_service_test.dart b/test/core/platform_share_service_test.dart new file mode 100644 index 0000000..b8c39dc --- /dev/null +++ b/test/core/platform_share_service_test.dart @@ -0,0 +1,31 @@ +// Author: fruit.com.cn + +import 'package:flutter/services.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:fruitshorts/core/data/services/platform_share_service.dart'; + +void main() { + TestWidgetsFlutterBinding.ensureInitialized(); + + test('should_keep_title_synopsis_footer_order_when_share_text_is_sent', () async { + String? sharedText; + const channel = MethodChannel('com.stormg.lumadrama/share'); + TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger + .setMockMethodCallHandler(channel, (call) async { + sharedText = (call.arguments as Map)['text'] as String; + return null; + }); + addTearDown( + () => TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger + .setMockMethodCallHandler(channel, null), + ); + + await const PlatformShareService().shareDrama( + title: 'The Signal', + synopsis: 'A short drama', + footer: 'FruitShorts', + ); + + expect(sharedText, 'The Signal\nA short drama\nFruitShorts'); + }); +} diff --git a/test/engagement/engagement_controller_test.dart b/test/engagement/engagement_controller_test.dart deleted file mode 100644 index 46546e0..0000000 --- a/test/engagement/engagement_controller_test.dart +++ /dev/null @@ -1,48 +0,0 @@ -// Author: fruit.com.cn - -import 'package:flutter_test/flutter_test.dart'; -import 'package:fruitshorts/core/data/services/engagement_controller.dart'; -import 'package:fruitshorts/core/data/repositories/engagement_repository.dart'; -import 'package:shared_preferences_platform_interface/in_memory_shared_preferences_async.dart'; -import 'package:shared_preferences_platform_interface/shared_preferences_async_platform_interface.dart'; - -void main() { - test('should_keep_saved_liked_and_comments_by_drama_id_when_toggled', () async { - final repository = InMemoryEngagementRepository(); - final first = EngagementController(repository); - await first.load(); - await first.toggleSaved('signal'); - await first.toggleLiked('signal'); - await first.addComment('signal', ' Great clip '); - - expect(first.isSaved('signal'), isTrue); - expect(first.isSaved('city'), isFalse); - expect(first.isLiked('city'), isFalse); - expect(first.commentsFor('signal'), ['Great clip']); - expect(first.commentsFor('city'), isEmpty); - - final reopened = EngagementController(repository); - await reopened.load(); - expect(reopened.isSaved('signal'), isTrue); - expect(reopened.isLiked('signal'), isTrue); - expect(reopened.commentsFor('signal'), ['Great clip']); - await reopened.toggleSaved('signal'); - expect(reopened.isSaved('signal'), isFalse); - }); - - test('should_survive_new_repository_instance_when_engagement_is_local', () async { - SharedPreferencesAsyncPlatform.instance = - InMemorySharedPreferencesAsync.empty(); - final first = EngagementController(SharedPreferencesEngagementRepository()); - await first.load(); - await first.toggleSaved('city'); - await first.addComment('city', 'Local note'); - - final reopened = EngagementController( - SharedPreferencesEngagementRepository(), - ); - await reopened.load(); - expect(reopened.isSaved('city'), isTrue); - expect(reopened.commentsFor('city'), ['Local note']); - }); -} diff --git a/test/engagement/engagement_repository_test.dart b/test/engagement/engagement_repository_test.dart deleted file mode 100644 index c877051..0000000 --- a/test/engagement/engagement_repository_test.dart +++ /dev/null @@ -1,135 +0,0 @@ -import 'dart:convert'; - -import 'package:flutter_test/flutter_test.dart'; -import 'package:fruitshorts/core/data/models/engagement_snapshot.dart'; -import 'package:fruitshorts/core/data/repositories/engagement_repository.dart'; -import 'package:shared_preferences/shared_preferences.dart'; -import 'package:shared_preferences_platform_interface/in_memory_shared_preferences_async.dart'; -import 'package:shared_preferences_platform_interface/shared_preferences_async_platform_interface.dart'; - -/// Mirrors the private key used by [SharedPreferencesEngagementRepository]. -const _key = 'engagement.v1.demo-local-v1'; - -void main() { - late SharedPreferencesAsync preferences; - - setUp(() { - SharedPreferencesAsyncPlatform.instance = - InMemorySharedPreferencesAsync.empty(); - preferences = SharedPreferencesAsync(); - }); - - SharedPreferencesEngagementRepository repository() => - SharedPreferencesEngagementRepository(preferences: preferences); - - Future loadRaw(String raw) async { - await preferences.setString(_key, raw); - return repository().load(); - } - - test('should_read_empty_snapshot_when_first_launch', () async { - final snapshot = await repository().load(); - - expect(snapshot.savedDramaIds, isEmpty); - expect(snapshot.likedDramaIds, isEmpty); - expect(snapshot.commentsByDrama, isEmpty); - }); - - test('should_survive_save_and_reload_round_trip_when_snapshot_is_stored', () async { - await repository().save( - const EngagementSnapshot( - savedDramaIds: {'signal', 'city'}, - likedDramaIds: {'city'}, - commentsByDrama: { - 'signal': ['first note', 'second note'], - }, - ), - ); - - final loaded = await repository().load(); - - expect(loaded.savedDramaIds, {'signal', 'city'}); - expect(loaded.likedDramaIds, {'city'}); - expect(loaded.commentsByDrama, { - 'signal': ['first note', 'second note'], - }); - }); - - test('should_round_trip_as_empty_collections_when_snapshot_is_empty', () async { - await repository().save(const EngagementSnapshot()); - - final loaded = await repository().load(); - - expect(loaded.savedDramaIds, isEmpty); - expect(loaded.likedDramaIds, isEmpty); - expect(loaded.commentsByDrama, isEmpty); - }); - - test('should_fall_back_to_empty_snapshot_when_payload_is_corrupt_or_not_an_object', () async { - for (final raw in [ - '', - 'not json at all', - '[]', - '"a bare string"', - '42', - 'null', - ]) { - final snapshot = await loadRaw(raw); - - expect(snapshot.savedDramaIds, isEmpty, reason: raw); - expect(snapshot.likedDramaIds, isEmpty, reason: raw); - expect(snapshot.commentsByDrama, isEmpty, reason: raw); - } - }); - - test('should_drop_mistyped_fields_when_payload_has_wrong_types', () async { - final snapshot = await loadRaw( - jsonEncode({ - 'saved': 'signal', - 'liked': {'city': true}, - 'comments': { - 'signal': 'a plain string', - 'city': ['kept', 7, null, true], - 'town': [], - }, - }), - ); - - expect(snapshot.savedDramaIds, isEmpty); - expect(snapshot.likedDramaIds, isEmpty); - expect(snapshot.commentsByDrama, { - 'city': ['kept'], - 'town': [], - }); - }); - - test('should_fall_back_per_field_when_payload_keys_are_missing', () async { - final snapshot = await loadRaw(jsonEncode({'saved': ['signal']})); - - expect(snapshot.savedDramaIds, {'signal'}); - expect(snapshot.likedDramaIds, isEmpty); - expect(snapshot.commentsByDrama, isEmpty); - }); - - test('should_write_only_json_primitives_when_saving', () async { - await repository().save( - const EngagementSnapshot( - savedDramaIds: {'signal'}, - likedDramaIds: {'city'}, - commentsByDrama: { - 'signal': ['note'], - }, - ), - ); - - final raw = await preferences.getString(_key); - expect(raw, isNotNull); - - final decoded = jsonDecode(raw!) as Map; - expect(decoded['saved'], ['signal']); - expect(decoded['liked'], ['city']); - expect(decoded['comments'], { - 'signal': ['note'], - }); - }); -} diff --git a/test/formatting/localized_content_test.dart b/test/formatting/localized_content_test.dart index 5f05e78..efe7bb7 100644 --- a/test/formatting/localized_content_test.dart +++ b/test/formatting/localized_content_test.dart @@ -2,6 +2,7 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:fruitshorts/core/data/models/drama.dart'; import 'package:fruitshorts/core/formatting/localized_content.dart'; import 'package:fruitshorts/l10n/app_localizations_en.dart'; +import 'package:fruitshorts/l10n/app_localizations_id.dart'; import 'package:fruitshorts/l10n/app_localizations_zh.dart'; Drama _drama({required String id, String title = 'raw', String synopsis = 'raw'}) => @@ -16,6 +17,7 @@ Drama _drama({required String id, String title = 'raw', String synopsis = 'raw'} void main() { final en = AppLocalizationsEn(); final zh = AppLocalizationsZh(); + final id = AppLocalizationsId(); test('should_map_each_seeded_drama_to_its_own_localized_copy_when_looked_up', () { final signal = _drama(id: 'the-signal-demo'); @@ -93,4 +95,21 @@ void main() { } expect(localizedEpisodeTitle(zh, 12), zh.episodeLabel(12)); }); + + test('should_build_share_copy_from_localized_title_synopsis_and_footer', () { + final signal = _drama(id: 'the-signal-demo'); + final copies = { + for (final l10n in [en, zh, id]) + '${localizedDramaTitle(l10n, signal)}\n' + '${localizedDramaSynopsis(l10n, signal)}\n' + '${l10n.shareFooter}', + }; + + expect(copies, hasLength(3)); + for (final copy in copies) { + expect(copy, contains('FruitShorts')); + expect(copy.split('\n'), hasLength(3)); + expect(copy.split('\n').every((line) => line.isNotEmpty), isTrue); + } + }); } diff --git a/test/interaction/interaction_api_test.dart b/test/interaction/interaction_api_test.dart new file mode 100644 index 0000000..47d9417 --- /dev/null +++ b/test/interaction/interaction_api_test.dart @@ -0,0 +1,67 @@ +// Author: fruit.com.cn + +import 'dart:convert'; + +import 'package:flutter_test/flutter_test.dart'; +import 'package:fruitshorts/core/data/models/interaction.dart'; +import 'package:fruitshorts/core/data/remote/api_client.dart'; +import 'package:fruitshorts/core/data/remote/interaction_api.dart'; + +import '../support/fake_http_adapter.dart'; + +void main() { + String envelope(Object? data) => + jsonEncode({'code': 0, 'message': 'ok', 'data': data}); + + test('should_send_like_target_and_parse_string_count_when_toggled', () async { + final adapter = FakeHttpAdapter( + (_) async => FakeHttpResponse( + envelope({'liked': true, 'count': '2111012753262120962'}), + ), + ); + final api = InteractionApi( + ApiClient(baseUrl: 'http://127.0.0.1:8081', adapter: adapter), + ); + + final result = await api.toggleLike( + targetType: InteractionTargetType.drama, + targetId: '5', + ); + + expect(adapter.requests.single.method, 'POST'); + expect(adapter.requests.single.uri.path, '/app/likes/toggle'); + expect(adapter.requests.single.data, { + 'targetType': 'DRAMA', + 'targetId': '5', + }); + expect(result.liked, isTrue); + expect(result.count, 2111012753262120962); + }); + + test('should_submit_fixed_reason_code_and_optional_description_when_reporting', () async { + final adapter = FakeHttpAdapter( + (_) async => FakeHttpResponse(envelope('2111012753262120999')), + ); + final api = InteractionApi( + ApiClient(baseUrl: 'http://127.0.0.1:8081', adapter: adapter), + ); + + final reportId = await api.report( + const ReportRequest( + targetType: InteractionTargetType.comment, + targetId: '7', + reasonCode: 'SPAM', + description: 'Repeated advertising', + ), + ); + + expect(adapter.requests.single.uri.path, '/app/reports'); + expect(adapter.requests.single.data, { + 'targetType': 'COMMENT', + 'targetId': '7', + 'reasonCode': 'SPAM', + 'description': 'Repeated advertising', + }); + expect(reportId, '2111012753262120999'); + }); +} diff --git a/test/interaction/interaction_controller_test.dart b/test/interaction/interaction_controller_test.dart new file mode 100644 index 0000000..b2690b3 --- /dev/null +++ b/test/interaction/interaction_controller_test.dart @@ -0,0 +1,60 @@ +// Author: fruit.com.cn + +import 'dart:async'; + +import 'package:flutter_test/flutter_test.dart'; +import 'package:fruitshorts/core/data/models/interaction.dart'; +import 'package:fruitshorts/core/data/remote/api_client.dart'; +import 'package:fruitshorts/core/data/services/interaction_controller.dart'; + +import '../support/fake_interaction_repositories.dart'; + +void main() { + test('should_update_drama_like_optimistically_and_use_server_state_when_toggle_succeeds', () async { + final repository = FakeInteractionRepository(); + final gate = Completer(); + repository.likeGate = gate; + final controller = InteractionController(repository); + + final future = controller.toggleDramaLike('5'); + expect(controller.isLiked('5'), isTrue); + expect(repository.likeTargets, ['DRAMA:5']); + + repository.nextLikeResult = const LikeToggleResult(liked: false, count: 0); + gate.complete(); + final result = await future; + + expect(result.isSuccess, isTrue); + expect(controller.isLiked('5'), isFalse); + controller.dispose(); + }); + + test('should_rollback_drama_like_when_toggle_fails', () async { + final repository = FakeInteractionRepository( + nextLikeResult: const LikeToggleResult(liked: true, count: 3), + ); + final controller = InteractionController(repository); + await controller.toggleDramaLike('5'); + repository.likeError = const ApiException(500, '点赞失败'); + + final result = await controller.toggleDramaLike('5'); + + expect(result.isSuccess, isFalse); + expect(result.errorMessage, '点赞失败'); + expect(controller.isLiked('5'), isTrue); + controller.dispose(); + }); + + test('should_clear_account_scoped_drama_likes_when_session_changes', () async { + final repository = FakeInteractionRepository( + nextLikeResult: const LikeToggleResult(liked: true, count: 1), + ); + final controller = InteractionController(repository); + await controller.toggleDramaLike('5'); + + controller.clear(); + + expect(controller.isLiked('5'), isFalse); + controller.dispose(); + }); +} diff --git a/test/interaction/report_dialog_test.dart b/test/interaction/report_dialog_test.dart new file mode 100644 index 0000000..41262d7 --- /dev/null +++ b/test/interaction/report_dialog_test.dart @@ -0,0 +1,55 @@ +// Author: fruit.com.cn + +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:fruitshorts/core/data/models/interaction.dart'; +import 'package:fruitshorts/l10n/app_localizations.dart'; +import 'package:fruitshorts/pages/interaction/widgets/report_dialog.dart'; + +void main() { + testWidgets('should_return_selected_reason_and_description_when_submitted', ( + tester, + ) async { + ReportDialogResult? result; + await tester.pumpWidget( + MaterialApp( + locale: const Locale('en'), + localizationsDelegates: AppLocalizations.localizationsDelegates, + supportedLocales: AppLocalizations.supportedLocales, + home: Builder( + builder: (context) => Scaffold( + body: TextButton( + key: const Key('open-report-dialog'), + onPressed: () async { + result = await showReportDialog( + context, + title: 'Report comment', + ); + }, + child: const Text('Open'), + ), + ), + ), + ), + ); + await tester.tap(find.byKey(const Key('open-report-dialog'))); + await tester.pumpAndSettle(); + + expect(find.text('Spam'), findsOneWidget); + expect(find.text('Harassment'), findsOneWidget); + expect(find.text('Sexual content'), findsOneWidget); + expect(find.text('Advertising'), findsOneWidget); + expect(find.text('Other'), findsOneWidget); + + await tester.tap(find.byKey(const Key('report-reason-AD'))); + await tester.enterText( + find.byKey(const Key('report-description')), + 'Repeat promotion', + ); + await tester.tap(find.byKey(const Key('report-submit'))); + await tester.pumpAndSettle(); + + expect(result?.reason, ReportReason.ad); + expect(result?.description, 'Repeat promotion'); + }); +} diff --git a/test/support/fake_interaction_repositories.dart b/test/support/fake_interaction_repositories.dart new file mode 100644 index 0000000..51ebf04 --- /dev/null +++ b/test/support/fake_interaction_repositories.dart @@ -0,0 +1,177 @@ +// Author: fruit.com.cn + +import 'dart:async'; + +import 'package:fruitshorts/core/data/models/comment.dart'; +import 'package:fruitshorts/core/data/models/interaction.dart'; +import 'package:fruitshorts/core/data/repositories/comment_repository.dart'; +import 'package:fruitshorts/core/data/repositories/interaction_repository.dart'; + +class CommentPageCall { + const CommentPageCall({ + required this.dramaId, + required this.rootId, + required this.cursor, + required this.size, + }); + + final String dramaId; + final String? rootId; + final String? cursor; + final int size; +} + +class PublishCall { + const PublishCall({ + required this.dramaId, + required this.episodeId, + required this.content, + required this.parentId, + }); + + final String dramaId; + final String? episodeId; + final String content; + final String? parentId; +} + +class FakeCommentRepository implements CommentRepository { + FakeCommentRepository({ + List? pages, + this.publishResult, + this.publishError, + this.deleteError, + this.pageError, + }) : pages = pages ?? const []; + + final List pages; + final DramaComment? publishResult; + final Object? publishError; + final Object? deleteError; + final Object? pageError; + final List pageCalls = []; + final List publishCalls = []; + final List deleteCalls = []; + int _pageIndex = 0; + + @override + Future page({ + required String dramaId, + String? rootId, + String? cursor, + int size = commentPageSize, + }) async { + pageCalls.add( + CommentPageCall( + dramaId: dramaId, + rootId: rootId, + cursor: cursor, + size: size, + ), + ); + final error = pageError; + if (error != null) throw error; + if (_pageIndex >= pages.length) return const CommentPage(); + return pages[_pageIndex++]; + } + + @override + Future publish({ + required String dramaId, + String? episodeId, + required String content, + String? parentId, + }) async { + publishCalls.add( + PublishCall( + dramaId: dramaId, + episodeId: episodeId, + content: content, + parentId: parentId, + ), + ); + final error = publishError; + if (error != null) throw error; + return publishResult ?? + commentFixture( + id: 'new-comment', + dramaId: dramaId, + content: content, + mine: true, + ); + } + + @override + Future delete(String commentId) async { + deleteCalls.add(commentId); + final error = deleteError; + if (error != null) throw error; + } +} + +class FakeInteractionRepository implements InteractionRepository { + FakeInteractionRepository({ + this.nextLikeResult = const LikeToggleResult(liked: true, count: 1), + }); + + LikeToggleResult nextLikeResult; + Object? likeError; + Object? reportError; + Completer? likeGate; + String reportId = 'report-1'; + final List likeTargets = []; + final List reports = []; + + @override + Future toggleLike({ + required InteractionTargetType targetType, + required String targetId, + }) async { + likeTargets.add('${targetType.apiValue}:$targetId'); + final gate = likeGate; + if (gate != null) await gate.future; + final error = likeError; + if (error != null) throw error; + return nextLikeResult; + } + + @override + Future report(ReportRequest request) async { + reports.add(request); + final error = reportError; + if (error != null) throw error; + return reportId; + } +} + +DramaComment commentFixture({ + String id = '1001', + String dramaId = '5', + String? parentId, + String? rootId, + String content = 'A comment', + String status = 'published', + int likeCount = 0, + int replyCount = 0, + bool liked = false, + bool mine = false, +}) => DramaComment( + id: id, + dramaId: dramaId, + episodeId: '0', + parentId: parentId ?? '0', + rootId: rootId ?? '0', + userId: mine ? '9' : '8', + uid: mine ? 'me' : 'viewer', + nickname: mine ? 'Me' : 'Viewer', + avatarUrl: '', + content: content, + status: status, + auditReason: '', + likeCount: likeCount, + replyCount: replyCount, + reportCount: 0, + createdAt: DateTime(2026, 10, 17, 12), + mine: mine, + liked: liked, +); diff --git a/test/widget_test.dart b/test/widget_test.dart index a6ede86..e9f6c41 100644 --- a/test/widget_test.dart +++ b/test/widget_test.dart @@ -4,15 +4,20 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:fruitshorts/app.dart'; +import 'package:fruitshorts/core/data/models/comment.dart'; +import 'package:fruitshorts/core/data/models/interaction.dart'; import 'package:fruitshorts/pages/player/player_view.dart'; import 'package:shared_preferences_platform_interface/in_memory_shared_preferences_async.dart'; import 'package:shared_preferences_platform_interface/shared_preferences_async_platform_interface.dart'; import 'support/fake_catalog.dart'; import 'support/fake_category.dart'; +import 'support/fake_interaction_repositories.dart'; import 'support/widget_player.dart'; import 'package:fruitshorts/core/data/repositories/favorite_repository.dart'; import 'package:fruitshorts/core/data/repositories/catalog_repository.dart'; +import 'package:fruitshorts/core/data/repositories/comment_repository.dart'; +import 'package:fruitshorts/core/data/repositories/interaction_repository.dart'; import 'package:fruitshorts/core/data/repositories/playback_repository.dart'; import 'package:fruitshorts/core/data/repositories/watch_history_repository.dart'; import 'package:fruitshorts/core/data/services/playback_session.dart'; @@ -31,6 +36,11 @@ void main() { }); } + void seedSignedOutSession() { + SharedPreferencesAsyncPlatform.instance = + InMemorySharedPreferencesAsync.empty(); + } + setUp(() { seedSignedInSession(); }); @@ -40,6 +50,8 @@ void main() { Widget appUnderTest({ PlayerFactory? playerFactory, CatalogRepository? catalogRepository, + CommentRepository? commentRepository, + InteractionRepository? interactionRepository, }) { final catalog = catalogRepository ?? FakeCatalogRepository(); return LumaDramaApp( @@ -51,6 +63,9 @@ void main() { cards: FakeCatalogRepository().dramas, ), playbackRepository: FakePlaybackRepository(), + commentRepository: commentRepository ?? FakeCommentRepository(), + interactionRepository: + interactionRepository ?? FakeInteractionRepository(), ); } @@ -415,6 +430,10 @@ void main() { addTearDown(tester.view.resetPhysicalSize); addTearDown(tester.view.resetDevicePixelRatio); String? sharedText; + final interactions = FakeInteractionRepository(); + final comments = FakeCommentRepository( + pages: [const CommentPage()], + ); const channel = MethodChannel('com.stormg.lumadrama/share'); tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(channel, ( call, @@ -430,7 +449,10 @@ void main() { ); await tester.pumpWidget( - appUnderTest(), + appUnderTest( + commentRepository: comments, + interactionRepository: interactions, + ), ); await tester.pumpAndSettle(); await tester.tap(find.byKey(const Key('tab-home'))); @@ -450,7 +472,7 @@ void main() { await tester.pumpAndSettle(); await tester.tap(find.byKey(const Key('rail-comments'))); await tester.pumpAndSettle(); - expect(find.text('Only visible on this device'), findsOneWidget); + expect(find.text('No comments yet.'), findsOneWidget); await tester.enterText(find.byKey(const Key('comment-input')), 'Nice demo'); await tester.tap(find.byKey(const Key('comment-post'))); await tester.pumpAndSettle(); @@ -459,12 +481,67 @@ void main() { await tester.pumpAndSettle(); await tester.tap(find.byKey(const Key('rail-like'))); + await tester.pumpAndSettle(); + expect(interactions.likeTargets, contains('DRAMA:the-signal-demo')); await tester.tap(find.byKey(const Key('rail-share'))); await tester.pumpAndSettle(); expect(sharedText, contains('The Signal')); + expect(sharedText, contains('A demo series for vertical playback')); + expect(sharedText, contains('FruitShorts')); expect(tester.takeException(), isNull); }); + testWidgets('should_open_auth_gate_without_liking_when_signed_out', ( + tester, + ) async { + tester.view.physicalSize = const Size(390, 844); + tester.view.devicePixelRatio = 1; + addTearDown(tester.view.resetPhysicalSize); + addTearDown(tester.view.resetDevicePixelRatio); + seedSignedOutSession(); + final interactions = FakeInteractionRepository(); + + await tester.pumpWidget( + appUnderTest(interactionRepository: interactions), + ); + await tester.pumpAndSettle(); + await tester.tap(find.byKey(const Key('tab-home'))); + await tester.pumpAndSettle(); + await tester.tap(find.byKey(const Key('rail-like'))); + await tester.pumpAndSettle(); + + expect(find.text('Sign in to continue'), findsOneWidget); + expect(interactions.likeTargets, isEmpty); + }); + + testWidgets('should_report_drama_from_detail_more_menu_when_submitted', ( + tester, + ) async { + tester.view.physicalSize = const Size(390, 844); + tester.view.devicePixelRatio = 1; + addTearDown(tester.view.resetPhysicalSize); + addTearDown(tester.view.resetDevicePixelRatio); + final interactions = FakeInteractionRepository(); + + await tester.pumpWidget( + appUnderTest(interactionRepository: interactions), + ); + await tester.pumpAndSettle(); + await tester.binding.handlePopRoute(); + await tester.pumpAndSettle(); + await tester.tap(find.byKey(const Key('drawer-open-series'))); + await tester.pumpAndSettle(); + await tester.tap(find.byKey(const Key('detail-more'))); + await tester.pumpAndSettle(); + await tester.tap(find.text('Report drama')); + await tester.pumpAndSettle(); + await tester.tap(find.byKey(const Key('report-submit'))); + await tester.pumpAndSettle(); + + expect(interactions.reports.single.targetType, InteractionTargetType.drama); + expect(find.text('Report submitted. Thank you.'), findsOneWidget); + }); + testWidgets('should_open_drawer_and_stay_on_home_when_system_back_is_pressed', (tester) async { tester.view.physicalSize = const Size(390, 844); tester.view.devicePixelRatio = 1; -- 2.54.0 From 1488ee8f85671de96c70347c1b17fb9c4556bd88 Mon Sep 17 00:00:00 2001 From: Zhou Weidong <502333560@qq.com> Date: Sat, 17 Oct 2026 15:29:18 +0800 Subject: [PATCH 13/76] =?UTF-8?q?fix(flutter):=20=E9=80=8F=E4=BC=A0?= =?UTF-8?q?=E4=B8=BE=E6=8A=A5=E6=9C=AC=E4=BA=BA=E8=AF=84=E8=AE=BA=E9=94=99?= =?UTF-8?q?=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/pages/player/widgets/comment_tile.dart | 9 +++--- test/comment/drama_comments_sheet_test.dart | 36 +++++++++++++++++++++ 2 files changed, 40 insertions(+), 5 deletions(-) diff --git a/lib/pages/player/widgets/comment_tile.dart b/lib/pages/player/widgets/comment_tile.dart index f453682..5e3145d 100644 --- a/lib/pages/player/widgets/comment_tile.dart +++ b/lib/pages/player/widgets/comment_tile.dart @@ -90,12 +90,11 @@ class CommentTile extends StatelessWidget { PopupMenuItem( value: _deleteAction, child: Text(l10n.deleteComment), - ) - else - PopupMenuItem( - value: _reportAction, - child: Text(l10n.reportComment), ), + PopupMenuItem( + value: _reportAction, + child: Text(l10n.reportComment), + ), ], ), ], diff --git a/test/comment/drama_comments_sheet_test.dart b/test/comment/drama_comments_sheet_test.dart index ad2a65b..f876764 100644 --- a/test/comment/drama_comments_sheet_test.dart +++ b/test/comment/drama_comments_sheet_test.dart @@ -273,6 +273,42 @@ void main() { expect(find.text('Sign in to continue'), findsOneWidget); expect(interactions.reports, isEmpty); }); + + testWidgets('should_show_backend_message_when_reporting_own_comment', ( + tester, + ) async { + final repository = FakeCommentRepository( + pages: [ + CommentPage( + comments: [ + commentFixture( + id: '10', + content: 'My comment', + mine: true, + ), + ], + ), + ], + ); + final interactions = FakeInteractionRepository() + ..reportError = const ApiException(400, '不能举报自己发布的内容'); + + await _pumpSheet( + tester, + repository: repository, + interactions: interactions, + ); + await tester.tap(find.byKey(const Key('comment-menu-10'))); + await tester.pumpAndSettle(); + expect(find.text('Delete comment'), findsOneWidget); + expect(find.text('Report comment'), findsOneWidget); + await tester.tap(find.text('Report comment')); + await tester.pumpAndSettle(); + await tester.tap(find.byKey(const Key('report-submit'))); + await tester.pumpAndSettle(); + + expect(find.text('不能举报自己发布的内容'), findsOneWidget); + }); } Future _pumpSheet( -- 2.54.0 From 10d448c8ba93aa2762e14babdb528805897b3992 Mon Sep 17 00:00:00 2001 From: Zhou Weidong <502333560@qq.com> Date: Sat, 17 Oct 2026 15:58:17 +0800 Subject: [PATCH 14/76] =?UTF-8?q?feat(flutter):=20=E5=BA=94=E7=94=A8?= =?UTF-8?q?=E5=85=8B=E8=8E=B1=E5=9B=A0=E8=93=9D=E4=B8=BB=E9=A2=98=E4=B8=8E?= =?UTF-8?q?=E5=8D=B0=E5=B0=BC=E8=AF=AD=E9=80=82=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/app.dart | 28 +- lib/core/config/locale_controller.dart | 15 + lib/core/formatting/localized_date_time.dart | 15 + lib/core/theme/app_colors.dart | 13 +- lib/core/theme/app_theme.dart | 106 ++++ lib/l10n/app_en.arb | 1 + lib/l10n/app_id.arb | 1 + lib/l10n/app_localizations.dart | 6 + lib/l10n/app_localizations_en.dart | 3 + lib/l10n/app_localizations_id.dart | 3 + lib/l10n/app_localizations_zh.dart | 3 + lib/l10n/app_zh.arb | 1 + lib/pages/auth/auth_view.dart | 199 +++---- lib/pages/discover/discover_view.dart | 15 +- lib/pages/downloads/downloads_page.dart | 36 +- lib/pages/drama_detail/drama_detail_view.dart | 24 +- lib/pages/favorites/favorites_page.dart | 20 +- lib/pages/home/home_view.dart | 9 +- lib/pages/home/widgets/home_quick_drawer.dart | 28 +- lib/pages/mine/mine_logic.dart | 2 + lib/pages/mine/mine_view.dart | 19 +- lib/pages/player/player_logic.dart | 7 +- lib/pages/player/player_view.dart | 16 +- .../player/widgets/seek_progress_bar.dart | 4 +- .../watch_records/watch_records_page.dart | 33 +- test/config/locale_controller_test.dart | 72 ++- test/formatting/localized_date_time_test.dart | 41 ++ test/mine/mine_logic_test.dart | 115 ++-- test/theme/app_theme_test.dart | 60 +++ test/theme/hardcoded_blue_scan_test.dart | 25 + test/widget_test.dart | 492 +++++++++--------- 31 files changed, 891 insertions(+), 521 deletions(-) create mode 100644 lib/core/formatting/localized_date_time.dart create mode 100644 lib/core/theme/app_theme.dart create mode 100644 test/formatting/localized_date_time_test.dart create mode 100644 test/theme/app_theme_test.dart create mode 100644 test/theme/hardcoded_blue_scan_test.dart diff --git a/lib/app.dart b/lib/app.dart index 9ff5a7e..f0d10d8 100644 --- a/lib/app.dart +++ b/lib/app.dart @@ -33,6 +33,7 @@ import 'core/data/services/favorite_controller.dart'; import 'core/data/services/interaction_controller.dart'; import 'core/data/services/playback_session.dart'; import 'core/data/services/video_player_port.dart'; +import 'core/theme/app_theme.dart'; import 'l10n/app_localizations.dart'; import 'pages/home/home_view.dart'; @@ -193,31 +194,12 @@ class _LumaDramaAppState extends State { locale: locale.locale, supportedLocales: AppLocalizations.supportedLocales, localizationsDelegates: AppLocalizations.localizationsDelegates, - localeResolutionCallback: (deviceLocale, supported) { - final resolved = locale.locale ?? deviceLocale; - if (resolved == null) return supported.first; - for (final item in supported) { - if (item.languageCode == resolved.languageCode) return item; - } - return supported.first; - }, + localeResolutionCallback: (deviceLocale, _) => + resolveAppLocale(locale.locale, deviceLocale), debugShowCheckedModeBanner: false, themeMode: ThemeMode.system, - theme: ThemeData( - useMaterial3: true, - colorScheme: ColorScheme.fromSeed( - seedColor: const Color(0xFF2F7BFF), - ), - scaffoldBackgroundColor: const Color(0xFFF8F7FC), - ), - darkTheme: ThemeData( - useMaterial3: true, - colorScheme: ColorScheme.fromSeed( - seedColor: const Color(0xFF2F7BFF), - brightness: Brightness.dark, - ), - scaffoldBackgroundColor: const Color(0xFF101019), - ), + theme: AppTheme.light(), + darkTheme: AppTheme.dark(), home: const HomePage(), ), ), diff --git a/lib/core/config/locale_controller.dart b/lib/core/config/locale_controller.dart index c9b3b67..9404b4c 100644 --- a/lib/core/config/locale_controller.dart +++ b/lib/core/config/locale_controller.dart @@ -3,6 +3,19 @@ import 'package:flutter/widgets.dart'; import 'package:shared_preferences/shared_preferences.dart'; +/// Resolves the selected or system language to one of the supported app locales. +/// +/// Indonesian is the launch-market fallback when a device uses an unsupported +/// language. The legacy `in` code is treated as Indonesian as well. +Locale resolveAppLocale(Locale? selected, Locale? deviceLocale) { + final code = (selected ?? deviceLocale)?.languageCode; + return switch (code) { + 'zh' => const Locale('zh'), + 'en' => const Locale('en'), + _ => const Locale('id'), + }; +} + class LocaleController extends ChangeNotifier { LocaleController({SharedPreferencesAsync? preferences}) : _preferences = preferences ?? SharedPreferencesAsync(); @@ -17,6 +30,7 @@ class LocaleController extends ChangeNotifier { _locale = switch (code) { 'en' => const Locale('en'), 'zh' => const Locale('zh'), + 'id' => const Locale('id'), _ => null, }; notifyListeners(); @@ -29,6 +43,7 @@ class LocaleController extends ChangeNotifier { _locale = switch (code) { 'en' => const Locale('en'), 'zh' => const Locale('zh'), + 'id' => const Locale('id'), _ => null, }; notifyListeners(); diff --git a/lib/core/formatting/localized_date_time.dart b/lib/core/formatting/localized_date_time.dart new file mode 100644 index 0000000..e5708ad --- /dev/null +++ b/lib/core/formatting/localized_date_time.dart @@ -0,0 +1,15 @@ +// Author: fruit.com.cn + +import 'package:flutter/material.dart'; + +/// Formats a timestamp with the active Material locale and 12/24-hour setting. +String formatLocalizedDateTime(BuildContext context, DateTime value) { + final localizations = MaterialLocalizations.of(context); + final local = value.toLocal(); + final date = localizations.formatCompactDate(local); + final time = localizations.formatTimeOfDay( + TimeOfDay.fromDateTime(local), + alwaysUse24HourFormat: MediaQuery.alwaysUse24HourFormatOf(context), + ); + return '$date $time'; +} diff --git a/lib/core/theme/app_colors.dart b/lib/core/theme/app_colors.dart index 56de8ad..6f09ce2 100644 --- a/lib/core/theme/app_colors.dart +++ b/lib/core/theme/app_colors.dart @@ -2,8 +2,17 @@ import 'package:flutter/material.dart'; /// Shared colors. Blue is the primary action color. abstract final class AppColors { - static const blue = Color(0xFF2F7BFF); - static const blueSoft = Color(0xFF8FB4FF); + /// Klein Blue primary used by actions and selected states. + static const blue = Color(0xFF002FA7); + + /// Pressed/active shade for blue surfaces. + static const bluePressed = Color(0xFF00227A); + + /// High-contrast blue for text and icons on dark surfaces. + static const blueSoft = Color(0xFF5B7BE0); + + /// Text and icons placed directly on [blue]. + static const onPrimary = Color(0xFFFFFFFF); static const ink = Color(0xFF0B0C10); static const bar = Color(0xFF101114); static const card = Color(0xFF17191F); diff --git a/lib/core/theme/app_theme.dart b/lib/core/theme/app_theme.dart new file mode 100644 index 0000000..0de77ba --- /dev/null +++ b/lib/core/theme/app_theme.dart @@ -0,0 +1,106 @@ +// Author: fruit.com.cn + +import 'package:flutter/material.dart'; + +import 'app_colors.dart'; + +/// App-wide light and dark themes built from the approved Klein Blue palette. +abstract final class AppTheme { + static const _lightBackground = Color(0xFFF8F7FC); + static const _darkBackground = Color(0xFF101019); + + /// Light theme for system light mode. + static ThemeData light() => _build( + brightness: Brightness.light, + surface: _lightBackground, + accent: AppColors.blue, + ); + + /// Dark theme for system dark mode. + static ThemeData dark() => _build( + brightness: Brightness.dark, + surface: _darkBackground, + accent: AppColors.blueSoft, + ); + + static ThemeData _build({ + required Brightness brightness, + required Color surface, + required Color accent, + }) { + final dark = brightness == Brightness.dark; + final scheme = dark + ? const ColorScheme.dark( + primary: AppColors.blue, + onPrimary: AppColors.onPrimary, + secondary: AppColors.blueSoft, + onSecondary: AppColors.ink, + primaryContainer: AppColors.bluePressed, + onPrimaryContainer: AppColors.onPrimary, + secondaryContainer: AppColors.bluePressed, + onSecondaryContainer: AppColors.onPrimary, + surface: _darkBackground, + onSurface: Colors.white, + surfaceTint: AppColors.blueSoft, + inversePrimary: AppColors.blueSoft, + ) + : ColorScheme.light( + primary: AppColors.blue, + onPrimary: AppColors.onPrimary, + secondary: AppColors.blue, + onSecondary: AppColors.onPrimary, + primaryContainer: AppColors.blueSoft.withValues(alpha: 0.22), + onPrimaryContainer: AppColors.ink, + secondaryContainer: AppColors.blueSoft.withValues(alpha: 0.22), + onSecondaryContainer: AppColors.ink, + surface: _lightBackground, + onSurface: AppColors.ink, + surfaceTint: AppColors.blue, + inversePrimary: AppColors.blueSoft, + ); + return ThemeData( + useMaterial3: true, + brightness: brightness, + colorScheme: scheme, + scaffoldBackgroundColor: surface, + progressIndicatorTheme: ProgressIndicatorThemeData(color: accent), + sliderTheme: SliderThemeData( + activeTrackColor: accent, + thumbColor: AppColors.onPrimary, + ), + tabBarTheme: TabBarThemeData(labelColor: accent, indicatorColor: accent), + textButtonTheme: TextButtonThemeData( + style: TextButton.styleFrom(foregroundColor: accent), + ), + filledButtonTheme: FilledButtonThemeData( + style: ButtonStyle( + backgroundColor: WidgetStateProperty.resolveWith(_buttonColor), + foregroundColor: const WidgetStatePropertyAll(AppColors.onPrimary), + ), + ), + switchTheme: SwitchThemeData( + thumbColor: WidgetStateProperty.resolveWith( + (states) => states.contains(WidgetState.selected) + ? AppColors.onPrimary + : null, + ), + trackColor: WidgetStateProperty.resolveWith( + (states) => states.contains(WidgetState.selected) ? accent : null, + ), + ), + snackBarTheme: SnackBarThemeData( + backgroundColor: AppColors.bluePressed, + contentTextStyle: const TextStyle(color: AppColors.onPrimary), + ), + ); + } + + static Color _buttonColor(Set states) { + if (states.contains(WidgetState.pressed) || + states.contains(WidgetState.hovered) || + states.contains(WidgetState.focused)) { + return AppColors.bluePressed; + } + return AppColors.blue; + } +} diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index e9e536f..de22c26 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -200,6 +200,7 @@ "systemLanguage": "System", "english": "English", "simplifiedChinese": "简体中文", + "bahasaIndonesia": "Bahasa Indonesia", "episodeOneTitle": "First Light", "episodeTwoTitle": "A New Frequency", "episodeThreeTitle": "Crossing Over", diff --git a/lib/l10n/app_id.arb b/lib/l10n/app_id.arb index 39656dc..7d02388 100644 --- a/lib/l10n/app_id.arb +++ b/lib/l10n/app_id.arb @@ -200,6 +200,7 @@ "systemLanguage": "Sistem", "english": "English", "simplifiedChinese": "简体中文", + "bahasaIndonesia": "Bahasa Indonesia", "episodeOneTitle": "Cahaya Pertama", "episodeTwoTitle": "Frekuensi Baru", "episodeThreeTitle": "Menyeberang", diff --git a/lib/l10n/app_localizations.dart b/lib/l10n/app_localizations.dart index d4ca405..1427bb2 100644 --- a/lib/l10n/app_localizations.dart +++ b/lib/l10n/app_localizations.dart @@ -916,6 +916,12 @@ abstract class AppLocalizations { /// **'简体中文'** String get simplifiedChinese; + /// No description provided for @bahasaIndonesia. + /// + /// In en, this message translates to: + /// **'Bahasa Indonesia'** + String get bahasaIndonesia; + /// No description provided for @episodeOneTitle. /// /// In en, this message translates to: diff --git a/lib/l10n/app_localizations_en.dart b/lib/l10n/app_localizations_en.dart index e73718c..9243973 100644 --- a/lib/l10n/app_localizations_en.dart +++ b/lib/l10n/app_localizations_en.dart @@ -440,6 +440,9 @@ class AppLocalizationsEn extends AppLocalizations { @override String get simplifiedChinese => '简体中文'; + @override + String get bahasaIndonesia => 'Bahasa Indonesia'; + @override String get episodeOneTitle => 'First Light'; diff --git a/lib/l10n/app_localizations_id.dart b/lib/l10n/app_localizations_id.dart index b6ce3be..7d6b7e2 100644 --- a/lib/l10n/app_localizations_id.dart +++ b/lib/l10n/app_localizations_id.dart @@ -442,6 +442,9 @@ class AppLocalizationsId extends AppLocalizations { @override String get simplifiedChinese => '简体中文'; + @override + String get bahasaIndonesia => 'Bahasa Indonesia'; + @override String get episodeOneTitle => 'Cahaya Pertama'; diff --git a/lib/l10n/app_localizations_zh.dart b/lib/l10n/app_localizations_zh.dart index e6d1590..0ddd0ad 100644 --- a/lib/l10n/app_localizations_zh.dart +++ b/lib/l10n/app_localizations_zh.dart @@ -434,6 +434,9 @@ class AppLocalizationsZh extends AppLocalizations { @override String get simplifiedChinese => '简体中文'; + @override + String get bahasaIndonesia => '印尼语'; + @override String get episodeOneTitle => '初见微光'; diff --git a/lib/l10n/app_zh.arb b/lib/l10n/app_zh.arb index a23e533..d664220 100644 --- a/lib/l10n/app_zh.arb +++ b/lib/l10n/app_zh.arb @@ -162,6 +162,7 @@ "systemLanguage": "跟随系统", "english": "English", "simplifiedChinese": "简体中文", + "bahasaIndonesia": "印尼语", "episodeOneTitle": "初见微光", "episodeTwoTitle": "新的频率", "episodeThreeTitle": "越过边界", diff --git a/lib/pages/auth/auth_view.dart b/lib/pages/auth/auth_view.dart index 49dcc70..0b03e76 100644 --- a/lib/pages/auth/auth_view.dart +++ b/lib/pages/auth/auth_view.dart @@ -4,6 +4,7 @@ import 'package:provider/provider.dart'; import '../../core/data/remote/api_client.dart'; import '../../core/data/services/auth_controller.dart'; import '../../core/theme/app_colors.dart'; +import '../../core/theme/app_theme.dart'; import '../../l10n/app_localizations.dart'; import 'auth_logic.dart'; @@ -82,102 +83,117 @@ class _AuthPageState extends State { @override Widget build(BuildContext context) { final l10n = AppLocalizations.of(context)!; - return Scaffold( - backgroundColor: AppColors.ink, - appBar: AppBar( + return Theme( + data: AppTheme.dark(), + child: Scaffold( backgroundColor: AppColors.ink, - elevation: 0, - foregroundColor: Colors.white, - title: Text(_logic.signUpMode ? l10n.signUp : l10n.signIn), - ), - body: SafeArea( - child: ListView( - padding: const EdgeInsets.fromLTRB(20, 12, 20, 28), - children: [ - Text( - _logic.signUpMode ? l10n.authSignUpTitle : l10n.authSignInTitle, - style: const TextStyle( - color: Colors.white, - fontSize: 22, - fontWeight: FontWeight.w800, - ), - ), - const SizedBox(height: 6), - Text( - l10n.authSubtitle, - style: const TextStyle(color: AppColors.muted, fontSize: 13), - ), - const SizedBox(height: 22), - _field( - label: l10n.authEmailLabel, - hint: 'name@example.com', - keyboardType: TextInputType.emailAddress, - onChanged: (value) => _logic.email = value, - autofocus: true, - ), - const SizedBox(height: 14), - _field( - label: l10n.authPasswordLabel, - hint: l10n.authPasswordHint, - obscure: true, - onChanged: (value) => _logic.password = value, - ), - if (_logic.errorMessage != null) ...[ - const SizedBox(height: 12), - Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - const Icon(Icons.error_outline, color: Color(0xFFFF6B6B), size: 16), - const SizedBox(width: 6), - Expanded( - child: Text( - _logic.errorMessage!, - style: const TextStyle(color: Color(0xFFFF6B6B), fontSize: 13), - ), - ), - ], - ), - ], - const SizedBox(height: 22), - SizedBox( - height: 48, - child: FilledButton( - style: FilledButton.styleFrom( - backgroundColor: AppColors.blue, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(24), - ), + appBar: AppBar( + backgroundColor: AppColors.ink, + elevation: 0, + foregroundColor: Colors.white, + title: Text(_logic.signUpMode ? l10n.signUp : l10n.signIn), + ), + body: SafeArea( + child: ListView( + padding: const EdgeInsets.fromLTRB(20, 12, 20, 28), + children: [ + Text( + _logic.signUpMode ? l10n.authSignUpTitle : l10n.authSignInTitle, + style: const TextStyle( + color: Colors.white, + fontSize: 22, + fontWeight: FontWeight.w800, ), - onPressed: _logic.busy ? null : _submit, - child: _logic.busy - ? const SizedBox( - width: 18, - height: 18, - child: CircularProgressIndicator( - strokeWidth: 2, - color: Colors.white, - ), - ) - : Text( - _logic.signUpMode ? l10n.signUp : l10n.signIn, + ), + const SizedBox(height: 6), + Text( + l10n.authSubtitle, + style: const TextStyle(color: AppColors.muted, fontSize: 13), + ), + const SizedBox(height: 22), + _field( + label: l10n.authEmailLabel, + hint: 'name@example.com', + keyboardType: TextInputType.emailAddress, + onChanged: (value) => _logic.email = value, + autofocus: true, + ), + const SizedBox(height: 14), + _field( + label: l10n.authPasswordLabel, + hint: l10n.authPasswordHint, + obscure: true, + onChanged: (value) => _logic.password = value, + ), + if (_logic.errorMessage != null) ...[ + const SizedBox(height: 12), + Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const Icon( + Icons.error_outline, + color: Color(0xFFFF6B6B), + size: 16, + ), + const SizedBox(width: 6), + Expanded( + child: Text( + _logic.errorMessage!, style: const TextStyle( - fontSize: 15, - fontWeight: FontWeight.w700, + color: Color(0xFFFF6B6B), + fontSize: 13, ), ), + ), + ], + ), + ], + const SizedBox(height: 22), + SizedBox( + height: 48, + child: FilledButton( + style: FilledButton.styleFrom( + backgroundColor: AppColors.blue, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(24), + ), + ), + onPressed: _logic.busy ? null : _submit, + child: _logic.busy + ? const SizedBox( + width: 18, + height: 18, + child: CircularProgressIndicator( + strokeWidth: 2, + color: Colors.white, + ), + ) + : Text( + _logic.signUpMode ? l10n.signUp : l10n.signIn, + style: const TextStyle( + fontSize: 15, + fontWeight: FontWeight.w700, + ), + ), + ), ), - ), - const SizedBox(height: 14), - TextButton( - onPressed: _logic.busy - ? null - : () => setState(() => _logic.toggleMode()), - child: Text( - _logic.signUpMode ? l10n.authSwitchToSignIn : l10n.authSwitchToSignUp, - style: const TextStyle(color: AppColors.blueSoft, fontSize: 13), + const SizedBox(height: 14), + TextButton( + onPressed: _logic.busy + ? null + : () => setState(() => _logic.toggleMode()), + child: Text( + _logic.signUpMode + ? l10n.authSwitchToSignIn + : l10n.authSwitchToSignUp, + style: const TextStyle( + color: AppColors.blueSoft, + fontSize: 13, + ), + ), ), - ), - ], + ], + ), ), ), ); @@ -214,7 +230,10 @@ class _AuthPageState extends State { hintStyle: const TextStyle(color: Color(0xFF6C7280), fontSize: 14), filled: true, fillColor: AppColors.card, - contentPadding: const EdgeInsets.symmetric(horizontal: 14, vertical: 14), + contentPadding: const EdgeInsets.symmetric( + horizontal: 14, + vertical: 14, + ), border: OutlineInputBorder( borderRadius: BorderRadius.circular(12), borderSide: BorderSide.none, diff --git a/lib/pages/discover/discover_view.dart b/lib/pages/discover/discover_view.dart index 42bb636..965001d 100644 --- a/lib/pages/discover/discover_view.dart +++ b/lib/pages/discover/discover_view.dart @@ -9,6 +9,7 @@ import '../../core/data/models/home_feed.dart'; import '../../core/data/repositories/watch_history_repository.dart'; import '../../core/data/services/category_controller.dart'; import '../../core/theme/app_colors.dart'; +import '../../core/theme/app_theme.dart'; import '../../core/widgets/remote_image.dart'; import '../../l10n/app_localizations.dart'; import 'discover_binding.dart'; @@ -139,7 +140,7 @@ class _DiscoverPageState extends State { return AnnotatedRegion( value: SystemUiOverlayStyle.light, child: Theme( - data: ThemeData.dark(useMaterial3: true), + data: AppTheme.dark(), child: widget.embedded ? content : Scaffold(backgroundColor: const Color(0xFF0B0C10), body: content), @@ -254,7 +255,7 @@ class _DiscoverPageState extends State { Text( l10n.seeAll, style: const TextStyle( - color: AppColors.blue, + color: AppColors.blueSoft, fontSize: 13, fontWeight: FontWeight.w500, ), @@ -417,7 +418,9 @@ class _DiscoverPageState extends State { alignment: Alignment.center, padding: const EdgeInsets.symmetric(horizontal: 12), decoration: BoxDecoration( - color: selected ? AppColors.blue : const Color(0xFF1C1E24), + color: selected + ? AppColors.bluePressed + : const Color(0xFF1C1E24), borderRadius: BorderRadius.circular(16), ), child: Text( @@ -501,12 +504,12 @@ class _DiscoverNavItem extends StatelessWidget { Icon( icon, size: 21, - color: selected ? _orange : const Color(0xFFCAC4C7), + color: selected ? _accent : const Color(0xFFCAC4C7), ), Text( label, style: TextStyle( - color: selected ? _orange : const Color(0xFFCAC4C7), + color: selected ? _accent : const Color(0xFFCAC4C7), fontSize: 10, fontWeight: FontWeight.w700, ), @@ -549,7 +552,7 @@ List<_ShowcaseCard> _cardsFor(List dramas, String query) { ]; } -const _orange = AppColors.blue; +const _accent = AppColors.blueSoft; const _coin = Color(0xFFF5C451); class _BrandMark extends StatelessWidget { diff --git a/lib/pages/downloads/downloads_page.dart b/lib/pages/downloads/downloads_page.dart index f472d30..f1228d9 100644 --- a/lib/pages/downloads/downloads_page.dart +++ b/lib/pages/downloads/downloads_page.dart @@ -10,7 +10,9 @@ import '../../core/data/models/download_policy.dart'; import '../../core/data/services/auth_controller.dart'; import '../../core/data/services/download_controller.dart'; import '../../core/formatting/error_text.dart'; +import '../../core/formatting/localized_date_time.dart'; import '../../core/theme/app_colors.dart'; +import '../../core/theme/app_theme.dart'; import '../../core/widgets/auth_gate.dart'; import '../../l10n/app_localizations.dart'; import 'downloads_binding.dart'; @@ -46,17 +48,20 @@ class _DownloadsPageState extends State { Widget build(BuildContext context) { final l10n = AppLocalizations.of(context)!; final signedIn = context.watch().isSignedIn; - return Scaffold( - key: const Key('downloads-page'), - backgroundColor: const Color(0xFF0B0C10), - appBar: AppBar( + return Theme( + data: AppTheme.dark(), + child: Scaffold( + key: const Key('downloads-page'), backgroundColor: const Color(0xFF0B0C10), - foregroundColor: Colors.white, - title: Text(l10n.downloads), + appBar: AppBar( + backgroundColor: const Color(0xFF0B0C10), + foregroundColor: Colors.white, + title: Text(l10n.downloads), + ), + body: signedIn + ? _DownloadsBody(downloads: context.watch()) + : const AuthGatePanel(), ), - body: signedIn - ? _DownloadsBody(downloads: context.watch()) - : const AuthGatePanel(), ); } } @@ -380,7 +385,9 @@ class _LicenseTile extends StatelessWidget { if (license.expireAt != null) ...[ const SizedBox(height: 7), Text( - l10n.downloadExpiresAt(_formatTime(license.expireAt!)), + l10n.downloadExpiresAt( + formatLocalizedDateTime(context, license.expireAt!), + ), style: const TextStyle(color: Color(0xFF8D8990), fontSize: 11), ), ], @@ -398,12 +405,3 @@ List _qualityChoices(String current) { } return choices; } - -String _formatTime(DateTime value) { - final local = value.toLocal(); - final month = local.month.toString().padLeft(2, '0'); - final day = local.day.toString().padLeft(2, '0'); - final hour = local.hour.toString().padLeft(2, '0'); - final minute = local.minute.toString().padLeft(2, '0'); - return '${local.year}-$month-$day $hour:$minute'; -} diff --git a/lib/pages/drama_detail/drama_detail_view.dart b/lib/pages/drama_detail/drama_detail_view.dart index af04e8b..62d0ed8 100644 --- a/lib/pages/drama_detail/drama_detail_view.dart +++ b/lib/pages/drama_detail/drama_detail_view.dart @@ -11,6 +11,8 @@ import '../../core/data/services/favorite_controller.dart'; import '../../core/data/services/interaction_controller.dart'; import '../../core/formatting/error_text.dart'; import '../../core/formatting/localized_content.dart'; +import '../../core/theme/app_colors.dart'; +import '../../core/theme/app_theme.dart'; import '../../core/widgets/remote_image.dart'; import '../../core/widgets/auth_gate.dart'; import '../../core/widgets/download_action.dart'; @@ -62,9 +64,12 @@ class _DramaDetailPageState extends State { @override Widget build(BuildContext context) { - return ListenableBuilder( - listenable: logic, - builder: (context, _) => _page(context), + return Theme( + data: AppTheme.dark(), + child: ListenableBuilder( + listenable: logic, + builder: (context, _) => _page(context), + ), ); } @@ -158,7 +163,7 @@ class _DramaDetailPageState extends State { l10n.technicalDemoCount(drama.episodes.length), style: Theme.of(context).textTheme.labelSmall?.copyWith( letterSpacing: 1.4, - color: const Color(0xFF2F7BFF), + color: AppColors.blueSoft, fontWeight: FontWeight.bold, ), ), @@ -248,9 +253,7 @@ class _DramaDetailPageState extends State { child: ListTile( minTileHeight: 76, leading: CircleAvatar( - backgroundColor: const Color( - 0xFF2F7BFF, - ).withValues(alpha: 0.18), + backgroundColor: AppColors.blue.withValues(alpha: 0.18), child: Text('${episode.number}'), ), title: Text(l10n.episodeLabel(episode.number)), @@ -303,10 +306,7 @@ class _DramaDetailPageState extends State { tooltip: l10n.more, onSelected: (_) => unawaited(_reportDrama(l10n)), itemBuilder: (_) => [ - PopupMenuItem( - value: _reportMenuValue, - child: Text(l10n.reportDrama), - ), + PopupMenuItem(value: _reportMenuValue, child: Text(l10n.reportDrama)), ], ); } @@ -378,7 +378,7 @@ class _ResumeBar extends StatelessWidget { value: fraction, minHeight: 3, backgroundColor: Colors.white24, - valueColor: const AlwaysStoppedAnimation(Color(0xFF2F7BFF)), + valueColor: const AlwaysStoppedAnimation(AppColors.blueSoft), ), ), if (label != null) ...[ diff --git a/lib/pages/favorites/favorites_page.dart b/lib/pages/favorites/favorites_page.dart index b89bf83..62b7c54 100644 --- a/lib/pages/favorites/favorites_page.dart +++ b/lib/pages/favorites/favorites_page.dart @@ -9,6 +9,7 @@ import '../../core/data/models/drama.dart'; import '../../core/data/services/auth_controller.dart'; import '../../core/data/services/favorite_controller.dart'; import '../../core/formatting/error_text.dart'; +import '../../core/theme/app_theme.dart'; import '../../core/widgets/auth_gate.dart'; import '../../core/widgets/library_drama_tile.dart'; import '../../l10n/app_localizations.dart'; @@ -46,16 +47,19 @@ class _FavoritesPageState extends State { Widget build(BuildContext context) { final l10n = AppLocalizations.of(context)!; final signedIn = context.watch().isSignedIn; - return Scaffold( - backgroundColor: const Color(0xFF0B0C10), - appBar: AppBar( + return Theme( + data: AppTheme.dark(), + child: Scaffold( backgroundColor: const Color(0xFF0B0C10), - foregroundColor: Colors.white, - title: Text(l10n.myFavorites), + appBar: AppBar( + backgroundColor: const Color(0xFF0B0C10), + foregroundColor: Colors.white, + title: Text(l10n.myFavorites), + ), + body: signedIn + ? _FavoritesBody(favorites: context.watch()) + : const AuthGatePanel(), ), - body: signedIn - ? _FavoritesBody(favorites: context.watch()) - : const AuthGatePanel(), ); } } diff --git a/lib/pages/home/home_view.dart b/lib/pages/home/home_view.dart index 22f8582..71e1b57 100644 --- a/lib/pages/home/home_view.dart +++ b/lib/pages/home/home_view.dart @@ -8,8 +8,9 @@ import '../../core/config/app_config.dart'; import '../../core/data/models/drama.dart'; import '../../core/data/services/auth_controller.dart'; import '../../core/data/services/catalog_controller.dart'; -import '../../core/widgets/auth_gate.dart'; import '../../core/theme/app_colors.dart'; +import '../../core/theme/app_theme.dart'; +import '../../core/widgets/auth_gate.dart'; import '../../l10n/app_localizations.dart'; import '../discover/discover_view.dart'; import '../mine/mine_view.dart'; @@ -26,7 +27,7 @@ class HomePage extends StatelessWidget { final catalog = context.watch(); final l10n = AppLocalizations.of(context)!; return Theme( - data: ThemeData.dark(useMaterial3: true), + data: AppTheme.dark(), child: _buildHome(context, catalog, l10n), ); } @@ -258,7 +259,7 @@ class _TabButton extends StatelessWidget { padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 3), decoration: selected ? BoxDecoration( - color: AppColors.blue, + color: AppColors.bluePressed, borderRadius: BorderRadius.circular(14), ) : null, @@ -276,7 +277,7 @@ class _TabButton extends StatelessWidget { style: TextStyle( fontSize: 10, fontWeight: selected ? FontWeight.w700 : FontWeight.w500, - color: selected ? AppColors.blue : AppColors.muted, + color: selected ? AppColors.blueSoft : AppColors.muted, ), ), ], diff --git a/lib/pages/home/widgets/home_quick_drawer.dart b/lib/pages/home/widgets/home_quick_drawer.dart index 1deaa31..a4cd825 100644 --- a/lib/pages/home/widgets/home_quick_drawer.dart +++ b/lib/pages/home/widgets/home_quick_drawer.dart @@ -6,6 +6,7 @@ import 'package:provider/provider.dart'; import '../../../core/config/locale_controller.dart'; import '../../../core/data/models/drama.dart'; import '../../../core/formatting/localized_content.dart'; +import '../../../core/theme/app_colors.dart'; import '../../../core/widgets/remote_image.dart'; import '../../../l10n/app_localizations.dart'; @@ -30,7 +31,7 @@ class HomeQuickDrawer extends StatelessWidget { static const _panel = Color(0xFF222225); static const _card = Color(0xFF303033); - static const _orange = Color(0xFF2F7BFF); + static const _accent = AppColors.blueSoft; @override Widget build(BuildContext context) { @@ -128,7 +129,7 @@ class HomeQuickDrawer extends StatelessWidget { key: const Key('drawer-open-series'), onPressed: onOpenSeries, style: FilledButton.styleFrom( - backgroundColor: _orange, + backgroundColor: _accent, foregroundColor: Colors.white, ), icon: const Icon(Icons.play_arrow_rounded), @@ -192,22 +193,21 @@ class HomeQuickDrawer extends StatelessWidget { const SizedBox(height: 14), _SectionCard( title: l10n.appLanguage, - child: Row( + child: Wrap( + spacing: 8, + runSpacing: 8, children: [ for (final (code, label) in [ ('en', l10n.english), ('zh', l10n.simplifiedChinese), - ]) ...[ - Expanded( - child: ChoiceChip( - label: Text(label, maxLines: 1), - selected: languageCode == code, - onSelected: (_) => - context.read().select(code), - ), + ('id', l10n.bahasaIndonesia), + ]) + ChoiceChip( + label: Text(label, maxLines: 1), + selected: languageCode == code, + onSelected: (_) => + context.read().select(code), ), - if (code == 'en') const SizedBox(width: 8), - ], ], ), ), @@ -268,7 +268,7 @@ class _QuickAction extends StatelessWidget { padding: const EdgeInsets.symmetric(vertical: 14, horizontal: 7), child: Column( children: [ - Icon(icon, color: HomeQuickDrawer._orange, size: 25), + Icon(icon, color: HomeQuickDrawer._accent, size: 25), const SizedBox(height: 6), Text( label, diff --git a/lib/pages/mine/mine_logic.dart b/lib/pages/mine/mine_logic.dart index 3b93e8b..be6faf8 100644 --- a/lib/pages/mine/mine_logic.dart +++ b/lib/pages/mine/mine_logic.dart @@ -26,6 +26,7 @@ class MineLogic extends ChangeNotifier { List recent = const []; bool recentLoading = false; String? recentError; + /// 续看位置读取失败:与"没有记录"区分开,失败要能重试(不能假装成从 0 开始) bool positionFailed = false; int section; @@ -123,6 +124,7 @@ class MineLogic extends ChangeNotifier { for (final (code, label) in [ ('en', l10n.english), ('zh', l10n.simplifiedChinese), + ('id', l10n.bahasaIndonesia), ]) ListTile( title: Text(label), diff --git a/lib/pages/mine/mine_view.dart b/lib/pages/mine/mine_view.dart index af0a003..b2d425e 100644 --- a/lib/pages/mine/mine_view.dart +++ b/lib/pages/mine/mine_view.dart @@ -14,6 +14,7 @@ import '../../core/data/services/favorite_controller.dart'; import '../../core/formatting/error_text.dart'; import '../../core/widgets/remote_image.dart'; import '../../core/theme/app_colors.dart'; +import '../../core/theme/app_theme.dart'; import '../../l10n/app_localizations.dart'; import 'mine_binding.dart'; import 'mine_logic.dart'; @@ -149,7 +150,7 @@ class _MyPageState extends State { ), ); return Theme( - data: ThemeData.dark(useMaterial3: true), + data: AppTheme.dark(), child: widget.embedded ? content : Scaffold(backgroundColor: const Color(0xFF0B0C10), body: content), @@ -162,7 +163,7 @@ class _MyPageState extends State { padding: const EdgeInsets.symmetric(horizontal: 16), child: Row( children: [ - const Icon(Icons.play_circle_fill_rounded, color: _orange, size: 27), + const Icon(Icons.play_circle_fill_rounded, color: _accent, size: 27), const SizedBox(width: 7), Text( l10n.myListTab, @@ -407,7 +408,7 @@ class _MyPageState extends State { title: Text(l10n.earnRewards), trailing: Text( l10n.freeBonus, - style: const TextStyle(color: AppColors.blue, fontSize: 12), + style: const TextStyle(color: AppColors.blueSoft, fontSize: 12), ), onTap: () => _mockSnack(l10n), ), @@ -505,7 +506,7 @@ class _MyPageState extends State { ), decoration: BoxDecoration( color: logic.section == index - ? AppColors.blue + ? AppColors.bluePressed : const Color(0xFF24262E), borderRadius: BorderRadius.circular(20), ), @@ -540,7 +541,7 @@ class _MyPageState extends State { showCheckmark: false, visualDensity: VisualDensity.compact, backgroundColor: const Color(0xFF242328), - selectedColor: _orange, + selectedColor: _accent, labelStyle: TextStyle( color: logic.filter == index ? Colors.white @@ -613,7 +614,7 @@ class _MyPageState extends State { backgroundColor: Color(0xFF313137), child: Icon( Icons.play_arrow_rounded, - color: _orange, + color: _accent, size: 20, ), ), @@ -872,12 +873,12 @@ class _NavItem extends StatelessWidget { Icon( icon, size: 21, - color: selected ? _orange : const Color(0xFFCAC4C7), + color: selected ? _accent : const Color(0xFFCAC4C7), ), Text( label, style: TextStyle( - color: selected ? _orange : const Color(0xFFCAC4C7), + color: selected ? _accent : const Color(0xFFCAC4C7), fontSize: 10, fontWeight: FontWeight.w700, ), @@ -893,4 +894,4 @@ String _clock(Duration duration) { return '${(seconds ~/ 60).toString().padLeft(2, '0')}:${(seconds % 60).toString().padLeft(2, '0')}'; } -const _orange = AppColors.blue; +const _accent = AppColors.blueSoft; diff --git a/lib/pages/player/player_logic.dart b/lib/pages/player/player_logic.dart index f645bea..31ddc40 100644 --- a/lib/pages/player/player_logic.dart +++ b/lib/pages/player/player_logic.dart @@ -20,6 +20,7 @@ import '../../core/data/services/playback_queue.dart'; import '../../core/data/services/playback_session.dart'; import '../../core/data/services/video_player_port.dart'; import '../../core/formatting/localized_content.dart'; +import '../../core/theme/app_colors.dart'; import '../../l10n/app_localizations.dart'; import '../discover/discover_logic.dart'; import '../discover/discover_view.dart'; @@ -48,12 +49,15 @@ class PlayerLogic extends ChangeNotifier { Episode? trackedEpisode; Drama? trackedDrama; DateTime lastProgressWrite = DateTime.fromMillisecondsSinceEpoch(0); + /// 进度上报节流:契约建议每 10 秒一次 Duration progressInterval = const Duration(seconds: 10); Future pendingWrite = Future.value(); + /// 服务端续看点:进入播放页时定位到"那一集的哪一秒" ResumePoint? resumePoint; bool resumeLoaded = false; + /// 票据三态:加载中 / 失败(可重试)/ 被后端判定为不可播放 bool ticketLoading = false; String? ticketError; @@ -86,6 +90,7 @@ class PlayerLogic extends ChangeNotifier { ValueChanged? onDramaChanged; ValueChanged? onImmersiveChanged; bool _disposed = false; + /// [start] 是否已经跑过:没跑过时 session/pages 还是 late 未初始化, /// dispose 不能直接碰它们(例如页面构建失败或纯逻辑测试)。 bool _started = false; @@ -702,7 +707,7 @@ class PlayerLogic extends ChangeNotifier { ) { final selected = episode.number == currentNumber; return Material( - color: selected ? const Color(0xFF2F7BFF) : const Color(0xFF2A2C33), + color: selected ? AppColors.bluePressed : const Color(0xFF2A2C33), borderRadius: BorderRadius.circular(8), child: InkWell( borderRadius: BorderRadius.circular(8), diff --git a/lib/pages/player/player_view.dart b/lib/pages/player/player_view.dart index 75941bf..11e4a93 100644 --- a/lib/pages/player/player_view.dart +++ b/lib/pages/player/player_view.dart @@ -15,6 +15,8 @@ import '../../core/data/services/playback_session.dart'; import '../../core/data/services/video_player_port.dart'; import '../../core/formatting/error_text.dart'; import '../../core/formatting/localized_content.dart'; +import '../../core/theme/app_colors.dart'; +import '../../core/theme/app_theme.dart'; import '../../core/widgets/auth_gate.dart'; import '../../core/widgets/download_action.dart'; import '../../l10n/app_localizations.dart'; @@ -130,7 +132,7 @@ class _PlayerPageState extends State with WidgetsBindingObserver { return AnnotatedRegion( value: SystemUiOverlayStyle.light, child: Theme( - data: ThemeData.dark(useMaterial3: true), + data: AppTheme.dark(), child: widget.embedded ? content : Scaffold(backgroundColor: Colors.black, body: content), @@ -203,7 +205,7 @@ class _PlayerPageState extends State with WidgetsBindingObserver { // 票据三态之一:起播前正在向后端要签名地址 if (selected && logic.ticketLoading) const Center( - child: CircularProgressIndicator(color: Color(0xFF2F7BFF)), + child: CircularProgressIndicator(color: AppColors.blueSoft), ), // 票据三态之二:拿票失败(断网/服务异常)→ 可重试,不假装在加载 if (selected && !logic.ticketLoading && logic.ticketError != null) @@ -235,7 +237,7 @@ class _PlayerPageState extends State with WidgetsBindingObserver { ), if (selected && logic.session.loading) const Center( - child: CircularProgressIndicator(color: Color(0xFF2F7BFF)), + child: CircularProgressIndicator(color: AppColors.blueSoft), ), if (selected && !ready && logic.session.error != null) Center( @@ -764,7 +766,7 @@ class _RailAction extends StatelessWidget { visualDensity: VisualDensity.compact, padding: EdgeInsets.zero, constraints: const BoxConstraints.tightFor(width: 42, height: 36), - color: selected ? const Color(0xFF8FB4FF) : Colors.white, + color: selected ? AppColors.blueSoft : Colors.white, icon: Icon(icon, size: 24), ), Text( @@ -804,16 +806,14 @@ class _BottomAction extends StatelessWidget { children: [ Icon( icon, - color: selected ? const Color(0xFF2F7BFF) : const Color(0xFFF3EEEA), + color: selected ? AppColors.blueSoft : const Color(0xFFF3EEEA), ), const SizedBox(height: 2), Text( label, style: TextStyle( fontSize: 11, - color: selected - ? const Color(0xFF2F7BFF) - : const Color(0xFFF3EEEA), + color: selected ? AppColors.blueSoft : const Color(0xFFF3EEEA), ), ), ], diff --git a/lib/pages/player/widgets/seek_progress_bar.dart b/lib/pages/player/widgets/seek_progress_bar.dart index 04a2b30..e66b6ff 100644 --- a/lib/pages/player/widgets/seek_progress_bar.dart +++ b/lib/pages/player/widgets/seek_progress_bar.dart @@ -6,6 +6,8 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:video_player/video_player.dart'; +import '../../../core/theme/app_colors.dart'; + /// Keeps seeks within the playable range so dragging to the edge does not /// trigger the player's completion callback before playback resumes. Duration seekPositionForFraction(double fraction, Duration duration) { @@ -118,7 +120,7 @@ class _SeekProgressBarState extends State { child: SliderTheme( data: SliderTheme.of(context).copyWith( trackHeight: scrubbing ? 4 : 3, - activeTrackColor: const Color(0xFF2F7BFF), + activeTrackColor: AppColors.blueSoft, inactiveTrackColor: Colors.white30, thumbColor: Colors.white, thumbShape: RoundSliderThumbShape( diff --git a/lib/pages/watch_records/watch_records_page.dart b/lib/pages/watch_records/watch_records_page.dart index 0476274..be98702 100644 --- a/lib/pages/watch_records/watch_records_page.dart +++ b/lib/pages/watch_records/watch_records_page.dart @@ -12,7 +12,9 @@ import '../../core/data/repositories/watch_history_repository.dart'; import '../../core/data/services/auth_controller.dart'; import '../../core/data/services/watch_records_controller.dart'; import '../../core/formatting/error_text.dart'; +import '../../core/formatting/localized_date_time.dart'; import '../../core/theme/app_colors.dart'; +import '../../core/theme/app_theme.dart'; import '../../core/widgets/auth_gate.dart'; import '../../core/widgets/remote_image.dart'; import '../../l10n/app_localizations.dart'; @@ -27,15 +29,18 @@ class WatchRecordsPage extends StatelessWidget { Widget build(BuildContext context) { final signedIn = context.watch().isSignedIn; final l10n = AppLocalizations.of(context)!; - return Scaffold( - key: const Key('watch-records-page'), - backgroundColor: const Color(0xFF0B0C10), - appBar: AppBar( + return Theme( + data: AppTheme.dark(), + child: Scaffold( + key: const Key('watch-records-page'), backgroundColor: const Color(0xFF0B0C10), - foregroundColor: Colors.white, - title: Text(l10n.watchHistory), + appBar: AppBar( + backgroundColor: const Color(0xFF0B0C10), + foregroundColor: Colors.white, + title: Text(l10n.watchHistory), + ), + body: signedIn ? const _WatchRecordsBody() : const AuthGatePanel(), ), - body: signedIn ? const _WatchRecordsBody() : const AuthGatePanel(), ); } } @@ -276,7 +281,10 @@ class _RecordTile extends StatelessWidget { if (record.progress.updatedAt != null) Text( l10n.updatedAtLabel( - _formatUpdatedAt(record.progress.updatedAt!), + formatLocalizedDateTime( + context, + record.progress.updatedAt!, + ), ), key: ValueKey('watch-record-updated-${record.dramaId}'), style: const TextStyle( @@ -375,12 +383,3 @@ String _clock(Duration value) { final seconds = value.inSeconds.remainder(60); return '$minutes:${seconds.toString().padLeft(2, '0')}'; } - -String _formatUpdatedAt(DateTime value) { - final local = value.toLocal(); - final month = local.month.toString().padLeft(2, '0'); - final day = local.day.toString().padLeft(2, '0'); - final hour = local.hour.toString().padLeft(2, '0'); - final minute = local.minute.toString().padLeft(2, '0'); - return '${local.year}-$month-$day $hour:$minute'; -} diff --git a/test/config/locale_controller_test.dart b/test/config/locale_controller_test.dart index cd32c01..077b54c 100644 --- a/test/config/locale_controller_test.dart +++ b/test/config/locale_controller_test.dart @@ -32,18 +32,42 @@ void main() { expect(reopened.locale, const Locale('zh')); }); - test('should_clear_stored_chinese_preference_when_english_is_selected', () async { - await LocaleController().select('zh'); + test('should_restore_indonesian_when_selected_and_app_restarts', () async { + final first = LocaleController(); + await first.select('id'); + expect(first.locale, const Locale('id')); final reopened = LocaleController(); await reopened.load(); - await reopened.select('en'); - - final third = LocaleController(); - await third.load(); - expect(third.locale, const Locale('en')); + expect(reopened.locale, const Locale('id')); }); + test('should_fallback_to_indonesian_when_system_language_is_unsupported', () { + expect(resolveAppLocale(null, const Locale('en')), const Locale('en')); + expect(resolveAppLocale(null, const Locale('id')), const Locale('id')); + expect(resolveAppLocale(null, const Locale('fr')), const Locale('id')); + expect(resolveAppLocale(null, const Locale('in')), const Locale('id')); + expect( + resolveAppLocale(const Locale('zh'), const Locale('fr')), + const Locale('zh'), + ); + }); + + test( + 'should_clear_stored_chinese_preference_when_english_is_selected', + () async { + await LocaleController().select('zh'); + + final reopened = LocaleController(); + await reopened.load(); + await reopened.select('en'); + + final third = LocaleController(); + await third.load(); + expect(third.locale, const Locale('en')); + }, + ); + test('should_clear_locale_when_code_is_unsupported', () async { final controller = LocaleController(); await controller.select('zh'); @@ -54,25 +78,31 @@ void main() { expect(controller.locale, isNull); }); - test('should_resolve_to_device_locale_when_stored_code_is_unsupported', () async { - await SharedPreferencesAsync().setString('ui.locale', 'fr'); + test( + 'should_resolve_to_device_locale_when_stored_code_is_unsupported', + () async { + await SharedPreferencesAsync().setString('ui.locale', 'fr'); - final controller = LocaleController(); - await controller.load(); + final controller = LocaleController(); + await controller.load(); - expect(controller.locale, isNull); - }); + expect(controller.locale, isNull); + }, + ); - test('should_survive_load_and_select_when_preference_store_is_broken', () async { - SharedPreferencesAsyncPlatform.instance = _BrokenPreferences(); - final controller = LocaleController(); + test( + 'should_survive_load_and_select_when_preference_store_is_broken', + () async { + SharedPreferencesAsyncPlatform.instance = _BrokenPreferences(); + final controller = LocaleController(); - await controller.load(); - expect(controller.locale, isNull); + await controller.load(); + expect(controller.locale, isNull); - await controller.select('zh'); - expect(controller.locale, const Locale('zh')); - }); + await controller.select('zh'); + expect(controller.locale, const Locale('zh')); + }, + ); } /// Stands in for a platform whose preference store is unavailable. diff --git a/test/formatting/localized_date_time_test.dart b/test/formatting/localized_date_time_test.dart new file mode 100644 index 0000000..2df78be --- /dev/null +++ b/test/formatting/localized_date_time_test.dart @@ -0,0 +1,41 @@ +// Author: fruit.com.cn + +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:fruitshorts/core/formatting/localized_date_time.dart'; +import 'package:fruitshorts/l10n/app_localizations.dart'; + +void main() { + testWidgets( + 'should_use_indonesian_material_date_and_time_when_locale_is_id', + (tester) async { + final value = DateTime(2026, 10, 17, 12, 30); + late String formatted; + + await tester.pumpWidget( + MaterialApp( + locale: const Locale('id'), + localizationsDelegates: AppLocalizations.localizationsDelegates, + supportedLocales: AppLocalizations.supportedLocales, + home: Builder( + builder: (context) { + formatted = formatLocalizedDateTime(context, value); + final localizations = MaterialLocalizations.of(context); + final expectedDate = localizations.formatCompactDate( + value.toLocal(), + ); + final expectedTime = localizations.formatTimeOfDay( + TimeOfDay.fromDateTime(value.toLocal()), + alwaysUse24HourFormat: MediaQuery.alwaysUse24HourFormatOf( + context, + ), + ); + expect(formatted, '$expectedDate $expectedTime'); + return const SizedBox.shrink(); + }, + ), + ), + ); + }, + ); +} diff --git a/test/mine/mine_logic_test.dart b/test/mine/mine_logic_test.dart index 5f12360..5aed167 100644 --- a/test/mine/mine_logic_test.dart +++ b/test/mine/mine_logic_test.dart @@ -32,35 +32,41 @@ Drama _drama(String id, {List numbers = const [1, 2, 3]}) => Drama( void main() { TestWidgetsFlutterBinding.ensureInitialized(); - test('should_keep_requested_section_and_read_episode_one_when_constructed', () async { - final history = FakeWatchHistory()..saved = const Duration(seconds: 7); - final logic = MineLogic( - history: history, - drama: _drama('signal'), - initialSection: 1, - ); + test( + 'should_keep_requested_section_and_read_episode_one_when_constructed', + () async { + final history = FakeWatchHistory()..saved = const Duration(seconds: 7); + final logic = MineLogic( + history: history, + drama: _drama('signal'), + initialSection: 1, + ); - expect(logic.section, 1); - expect(logic.filter, 0); - expect(await logic.position, const Duration(seconds: 7)); - expect(history.reads, ['signal']); - logic.dispose(); - }); + expect(logic.section, 1); + expect(logic.filter, 0); + expect(await logic.position, const Duration(seconds: 7)); + expect(history.reads, ['signal']); + logic.dispose(); + }, + ); - test('should_resume_from_last_watch_when_list_card_has_no_episodes', () async { - final history = FakeWatchHistory() - ..saved = const Duration(seconds: 7) - ..lastEpisode = 'signal-3'; - final logic = MineLogic( - history: history, - drama: _drama('signal', numbers: const []), - initialSection: 1, - ); + test( + 'should_resume_from_last_watch_when_list_card_has_no_episodes', + () async { + final history = FakeWatchHistory() + ..saved = const Duration(seconds: 7) + ..lastEpisode = 'signal-3'; + final logic = MineLogic( + history: history, + drama: _drama('signal', numbers: const []), + initialSection: 1, + ); - expect(await logic.position, const Duration(seconds: 7)); - expect(history.reads, ['signal']); - logic.dispose(); - }); + expect(await logic.position, const Duration(seconds: 7)); + expect(history.reads, ['signal']); + logic.dispose(); + }, + ); test('should_notify_when_section_and_filter_are_selected', () { final logic = MineLogic( @@ -114,7 +120,12 @@ void main() { expect(logic.drama.id, 'city'); history.reads.clear(); - sync(_drama('vengeance'), active: true, wasActive: true, dramaChanged: true); + sync( + _drama('vengeance'), + active: true, + wasActive: true, + dramaChanged: true, + ); expect(logic.drama.id, 'vengeance'); expect(history.reads, ['vengeance']); @@ -125,26 +136,29 @@ void main() { logic.dispose(); }); - test('should_reset_section_when_section_request_arrives_while_page_is_inactive', () { - final logic = MineLogic( - history: FakeWatchHistory(), - drama: _drama('s'), - initialSection: 0, - ); + test( + 'should_reset_section_when_section_request_arrives_while_page_is_inactive', + () { + final logic = MineLogic( + history: FakeWatchHistory(), + drama: _drama('s'), + initialSection: 0, + ); - logic.syncPage( - active: false, - wasActive: false, - nextDrama: logic.drama, - dramaChanged: false, - sectionRequest: 1, - previousSectionRequest: 0, - initialSection: 1, - ); + logic.syncPage( + active: false, + wasActive: false, + nextDrama: logic.drama, + dramaChanged: false, + sectionRequest: 1, + previousSectionRequest: 0, + initialSection: 1, + ); - expect(logic.section, 1); - logic.dispose(); - }); + expect(logic.section, 1); + logic.dispose(); + }, + ); testWidgets('should_return_choice_and_forward_it_when_act_runs_embedded', ( tester, @@ -197,7 +211,9 @@ void main() { logic.dispose(); }); - testWidgets('should_switch_app_locale_when_language_sheet_is_used', (tester) async { + testWidgets('should_switch_app_locale_when_language_sheet_is_used', ( + tester, + ) async { SharedPreferencesAsyncPlatform.instance = InMemorySharedPreferencesAsync.empty(); final locale = LocaleController(); @@ -231,7 +247,14 @@ void main() { final l10n = AppLocalizations.of(context)!; expect(find.text(l10n.english), findsOneWidget); expect(find.text(l10n.simplifiedChinese), findsOneWidget); + expect(find.text('Bahasa Indonesia'), findsOneWidget); + await tester.tap(find.text('Bahasa Indonesia')); + await tester.pumpAndSettle(); + expect(locale.locale, const Locale('id')); + + unawaited(logic.showLanguage(context)); + await tester.pumpAndSettle(); await tester.tap(find.text(l10n.simplifiedChinese)); await tester.pumpAndSettle(); diff --git a/test/theme/app_theme_test.dart b/test/theme/app_theme_test.dart new file mode 100644 index 0000000..bc3229b --- /dev/null +++ b/test/theme/app_theme_test.dart @@ -0,0 +1,60 @@ +// Author: fruit.com.cn + +import 'dart:math'; + +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:fruitshorts/core/theme/app_colors.dart'; +import 'package:fruitshorts/core/theme/app_theme.dart'; + +double _contrast(Color foreground, Color background) { + final first = foreground.computeLuminance(); + final second = background.computeLuminance(); + return (max(first, second) + 0.05) / (min(first, second) + 0.05); +} + +void main() { + test('should_expose_approved_klein_blue_tokens', () { + expect(AppColors.blue, const Color(0xFF002FA7)); + expect(AppColors.bluePressed, const Color(0xFF00227A)); + expect(AppColors.blueSoft, const Color(0xFF5B7BE0)); + expect(AppColors.onPrimary, const Color(0xFFFFFFFF)); + }); + + test('should_meet_text_and_icon_contrast_when_using_theme_tokens', () { + expect( + _contrast(AppColors.onPrimary, AppColors.blue), + greaterThanOrEqualTo(4.5), + ); + expect(_contrast(AppColors.blue, Colors.white), greaterThanOrEqualTo(4.5)); + expect( + _contrast(AppColors.blueSoft, AppColors.ink), + greaterThanOrEqualTo(3), + ); + }); + + test('should_use_klein_blue_in_light_and_dark_color_schemes', () { + for (final theme in [AppTheme.light(), AppTheme.dark()]) { + expect(theme.colorScheme.primary, AppColors.blue); + expect(theme.colorScheme.onPrimary, AppColors.onPrimary); + } + }); + + testWidgets('should_expose_klein_blue_through_widget_theme', (tester) async { + late ThemeData applied; + await tester.pumpWidget( + MaterialApp( + theme: AppTheme.dark(), + home: Builder( + builder: (context) { + applied = Theme.of(context); + return const SizedBox.shrink(); + }, + ), + ), + ); + + expect(applied.colorScheme.primary, AppColors.blue); + expect(applied.colorScheme.onPrimary, AppColors.onPrimary); + }); +} diff --git a/test/theme/hardcoded_blue_scan_test.dart b/test/theme/hardcoded_blue_scan_test.dart new file mode 100644 index 0000000..7e3ddf8 --- /dev/null +++ b/test/theme/hardcoded_blue_scan_test.dart @@ -0,0 +1,25 @@ +// Author: fruit.com.cn + +import 'dart:io'; + +import 'package:flutter_test/flutter_test.dart'; + +void main() { + test('should_use_theme_tokens_when_lib_code_is_scanned_for_legacy_blue', () { + final pattern = RegExp( + r'0xFF2F7BFF|0xff2F7BFF|0xFF8FB4FF|0xff8FB4FF|(?[]; + for (final entity in Directory('lib').listSync(recursive: true)) { + if (entity is! File || !entity.path.endsWith('.dart')) continue; + final lines = entity.readAsLinesSync(); + for (var index = 0; index < lines.length; index++) { + if (pattern.hasMatch(lines[index])) { + violations.add('${entity.path}:${index + 1}: ${lines[index].trim()}'); + } + } + } + + expect(violations, isEmpty, reason: violations.join('\n')); + }); +} diff --git a/test/widget_test.dart b/test/widget_test.dart index e9f6c41..c610e38 100644 --- a/test/widget_test.dart +++ b/test/widget_test.dart @@ -27,13 +27,12 @@ void main() { /// 而是本地会话(这里直接给 shared_preferences 的内存实现塞一份会话)。 /// 昵称/uid 与演示文案保持一致,避免为显示细节改写既有断言。 void seedSignedInSession() { - SharedPreferencesAsyncPlatform.instance = - InMemorySharedPreferencesAsync.withData({ - 'auth.accessToken': 'test-access', - 'auth.refreshToken': 'test-refresh', - 'auth.user': - '{"uid":"M1CZWVYE","nickname":"Vicky sheng","avatarUrl":""}', - }); + SharedPreferencesAsyncPlatform + .instance = InMemorySharedPreferencesAsync.withData({ + 'auth.accessToken': 'test-access', + 'auth.refreshToken': 'test-refresh', + 'auth.user': '{"uid":"M1CZWVYE","nickname":"Vicky sheng","avatarUrl":""}', + }); } void seedSignedOutSession() { @@ -98,15 +97,15 @@ void main() { }, ); - testWidgets('should_open_series_detail_when_immersive_home_is_tapped', (tester) async { + testWidgets('should_open_series_detail_when_immersive_home_is_tapped', ( + tester, + ) async { tester.view.physicalSize = const Size(390, 844); tester.view.devicePixelRatio = 1; addTearDown(tester.view.resetPhysicalSize); addTearDown(tester.view.resetDevicePixelRatio); - await tester.pumpWidget( - appUnderTest(), - ); + await tester.pumpWidget(appUnderTest()); await tester.pumpAndSettle(); await tester.tap(find.byKey(const Key('tab-home'))); await tester.pumpAndSettle(); @@ -131,9 +130,7 @@ void main() { addTearDown(tester.view.resetPhysicalSize); addTearDown(tester.view.resetDevicePixelRatio); - await tester.pumpWidget( - appUnderTest(), - ); + await tester.pumpWidget(appUnderTest()); await tester.pumpAndSettle(); await tester.tap(find.byKey(const Key('tab-home'))); await tester.pumpAndSettle(); @@ -148,60 +145,60 @@ void main() { expect(tester.takeException(), isNull); }); - testWidgets('should_open_current_series_and_switch_root_tabs_when_quick_drawer_is_used', ( - tester, - ) async { - tester.view.physicalSize = const Size(360, 720); - tester.view.devicePixelRatio = 1; - addTearDown(tester.view.resetPhysicalSize); - addTearDown(tester.view.resetDevicePixelRatio); + testWidgets( + 'should_open_current_series_and_switch_root_tabs_when_quick_drawer_is_used', + (tester) async { + tester.view.physicalSize = const Size(360, 720); + tester.view.devicePixelRatio = 1; + addTearDown(tester.view.resetPhysicalSize); + addTearDown(tester.view.resetDevicePixelRatio); - await tester.pumpWidget( - appUnderTest(), - ); - await tester.pumpAndSettle(); - expect(find.text('Continue Watching'), findsOneWidget); - await tester.binding.handlePopRoute(); - await tester.pumpAndSettle(); - expect( - tester - .widget(find.byType(PlayerPage, skipOffstage: false)) - .active, - isFalse, - ); - expect(find.text('Quick access'), findsOneWidget); - expect( - find.descendant( - of: find.byType(Drawer), - matching: find.text('7 EPISODES'), - ), - findsOneWidget, - ); - expect(tester.takeException(), isNull); + await tester.pumpWidget(appUnderTest()); + await tester.pumpAndSettle(); + expect(find.text('Continue Watching'), findsOneWidget); + await tester.binding.handlePopRoute(); + await tester.pumpAndSettle(); + expect( + tester + .widget(find.byType(PlayerPage, skipOffstage: false)) + .active, + isFalse, + ); + expect(find.text('Quick access'), findsOneWidget); + expect(find.text('Bahasa Indonesia'), findsOneWidget); + expect( + find.descendant( + of: find.byType(Drawer), + matching: find.text('7 EPISODES'), + ), + findsOneWidget, + ); + expect(tester.takeException(), isNull); - await tester.tap(find.byKey(const Key('drawer-open-series'))); - await tester.pumpAndSettle(); - expect(find.text('Watch episode 1'), findsOneWidget); - await tester.binding.handlePopRoute(); - await tester.pumpAndSettle(); - expect( - tester - .widget(find.byType(PlayerPage, skipOffstage: false)) - .active, - isFalse, - ); - expect(find.text('Continue Watching'), findsOneWidget); + await tester.tap(find.byKey(const Key('drawer-open-series'))); + await tester.pumpAndSettle(); + expect(find.text('Watch episode 1'), findsOneWidget); + await tester.binding.handlePopRoute(); + await tester.pumpAndSettle(); + expect( + tester + .widget(find.byType(PlayerPage, skipOffstage: false)) + .active, + isFalse, + ); + expect(find.text('Continue Watching'), findsOneWidget); - await tester.binding.handlePopRoute(); - await tester.pumpAndSettle(); - await tester.tap(find.byKey(const Key('drawer-discover'))); - await tester.pumpAndSettle(); - expect(find.text('Continue Watching'), findsOneWidget); - expect( - Navigator.of(tester.element(find.text('Continue Watching'))).canPop(), - isFalse, - ); - }); + await tester.binding.handlePopRoute(); + await tester.pumpAndSettle(); + await tester.tap(find.byKey(const Key('drawer-discover'))); + await tester.pumpAndSettle(); + expect(find.text('Continue Watching'), findsOneWidget); + expect( + Navigator.of(tester.element(find.text('Continue Watching'))).canPop(), + isFalse, + ); + }, + ); testWidgets('should_change_interface_language_when_locale_is_picked', ( tester, @@ -211,9 +208,7 @@ void main() { addTearDown(tester.view.resetPhysicalSize); addTearDown(tester.view.resetDevicePixelRatio); - await tester.pumpWidget( - appUnderTest(), - ); + await tester.pumpWidget(appUnderTest()); await tester.pumpAndSettle(); expect(find.byTooltip('Captions'), findsNothing); await tester.tap(find.byKey(const Key('tab-my'))); @@ -234,51 +229,74 @@ void main() { expect(find.text('热门'), findsOneWidget); }); - testWidgets('should_fit_compact_android_viewport_when_home_controls_are_shown', (tester) async { - tester.view.physicalSize = const Size(360, 720); + testWidgets( + 'should_fit_compact_android_viewport_when_home_controls_are_shown', + (tester) async { + tester.view.physicalSize = const Size(360, 720); + tester.view.devicePixelRatio = 1; + addTearDown(tester.view.resetPhysicalSize); + addTearDown(tester.view.resetDevicePixelRatio); + + await tester.pumpWidget(appUnderTest()); + await tester.pumpAndSettle(); + await tester.tap(find.byKey(const Key('tab-home'))); + await tester.pumpAndSettle(); + expect(find.text('The Signal'), findsOneWidget); + await tester.drag(find.byType(PageView), const Offset(0, -500)); + await tester.pumpAndSettle(); + expect(find.text('City Lights & Velvet Nights'), findsOneWidget); + await tester.tap(find.byKey(const Key('tab-discover'))); + await tester.pumpAndSettle(); + await tester.tap(find.text('City Lights & Velvet Nights')); + await tester.pumpAndSettle(); + expect(find.byType(Slider), findsOneWidget); + expect(tester.takeException(), isNull); + }, + ); + + testWidgets( + 'should_fit_compact_android_viewport_and_return_home_when_my_page_is_shown', + (tester) async { + tester.view.physicalSize = const Size(360, 720); + tester.view.devicePixelRatio = 1; + addTearDown(tester.view.resetPhysicalSize); + addTearDown(tester.view.resetDevicePixelRatio); + + await tester.pumpWidget(appUnderTest()); + await tester.pumpAndSettle(); + await tester.tap(find.byKey(const Key('tab-my'))); + await tester.pumpAndSettle(); + expect(tester.takeException(), isNull); + expect(find.text('Vicky sheng'), findsOneWidget); + expect(find.text('Coins'), findsOneWidget); + expect(tester.takeException(), isNull); + await tester.tap(find.text('Shorts')); + await tester.pumpAndSettle(); + expect(find.text('The Signal'), findsOneWidget); + }, + ); + + testWidgets('should_fit_compact_dark_viewport_when_klein_theme_is_used', ( + tester, + ) async { + tester.view.physicalSize = const Size(320, 568); tester.view.devicePixelRatio = 1; + tester.platformDispatcher.platformBrightnessTestValue = Brightness.dark; addTearDown(tester.view.resetPhysicalSize); addTearDown(tester.view.resetDevicePixelRatio); + addTearDown(tester.platformDispatcher.clearPlatformBrightnessTestValue); - await tester.pumpWidget( - appUnderTest(), - ); + await tester.pumpWidget(appUnderTest()); await tester.pumpAndSettle(); await tester.tap(find.byKey(const Key('tab-home'))); await tester.pumpAndSettle(); expect(find.text('The Signal'), findsOneWidget); - await tester.drag(find.byType(PageView), const Offset(0, -500)); - await tester.pumpAndSettle(); - expect(find.text('City Lights & Velvet Nights'), findsOneWidget); - await tester.tap(find.byKey(const Key('tab-discover'))); - await tester.pumpAndSettle(); - await tester.tap(find.text('City Lights & Velvet Nights')); - await tester.pumpAndSettle(); - expect(find.byType(Slider), findsOneWidget); expect(tester.takeException(), isNull); - }); - testWidgets('should_fit_compact_android_viewport_and_return_home_when_my_page_is_shown', ( - tester, - ) async { - tester.view.physicalSize = const Size(360, 720); - tester.view.devicePixelRatio = 1; - addTearDown(tester.view.resetPhysicalSize); - addTearDown(tester.view.resetDevicePixelRatio); - - await tester.pumpWidget( - appUnderTest(), - ); - await tester.pumpAndSettle(); await tester.tap(find.byKey(const Key('tab-my'))); await tester.pumpAndSettle(); - expect(tester.takeException(), isNull); - expect(find.text('Vicky sheng'), findsOneWidget); expect(find.text('Coins'), findsOneWidget); expect(tester.takeException(), isNull); - await tester.tap(find.text('Shorts')); - await tester.pumpAndSettle(); - expect(find.text('The Signal'), findsOneWidget); }); testWidgets( @@ -289,9 +307,7 @@ void main() { addTearDown(tester.view.resetPhysicalSize); addTearDown(tester.view.resetDevicePixelRatio); - await tester.pumpWidget( - appUnderTest(), - ); + await tester.pumpWidget(appUnderTest()); await tester.pumpAndSettle(); await tester.tap(find.text('Home')); await tester.pumpAndSettle(); @@ -317,15 +333,15 @@ void main() { }, ); - testWidgets('should_stay_on_one_route_when_bottom_tabs_are_used', (tester) async { + testWidgets('should_stay_on_one_route_when_bottom_tabs_are_used', ( + tester, + ) async { tester.view.physicalSize = const Size(390, 844); tester.view.devicePixelRatio = 1; addTearDown(tester.view.resetPhysicalSize); addTearDown(tester.view.resetDevicePixelRatio); - await tester.pumpWidget( - appUnderTest(), - ); + await tester.pumpWidget(appUnderTest()); await tester.pumpAndSettle(); await tester.tap(find.text('Home')); await tester.pumpAndSettle(); @@ -375,9 +391,7 @@ void main() { addTearDown(tester.view.resetPhysicalSize); addTearDown(tester.view.resetDevicePixelRatio); - await tester.pumpWidget( - appUnderTest(), - ); + await tester.pumpWidget(appUnderTest()); await tester.pumpAndSettle(); await tester.tap(find.byKey(const Key('tab-home'))); await tester.pumpAndSettle(); @@ -400,15 +414,15 @@ void main() { }, ); - testWidgets('should_hide_category_navigation_when_shorts_page_is_shown', (tester) async { + testWidgets('should_hide_category_navigation_when_shorts_page_is_shown', ( + tester, + ) async { tester.view.physicalSize = const Size(390, 844); tester.view.devicePixelRatio = 1; addTearDown(tester.view.resetPhysicalSize); addTearDown(tester.view.resetDevicePixelRatio); - await tester.pumpWidget( - appUnderTest(), - ); + await tester.pumpWidget(appUnderTest()); await tester.pumpAndSettle(); await tester.tap(find.byKey(const Key('tab-home'))); await tester.pumpAndSettle(); @@ -422,74 +436,76 @@ void main() { expect(find.text('City Lights & Velvet Nights'), findsOneWidget); expect(tester.takeException(), isNull); }); - testWidgets('should_save_comment_like_and_share_in_order_when_right_rail_is_used', ( - tester, - ) async { - tester.view.physicalSize = const Size(390, 844); - tester.view.devicePixelRatio = 1; - addTearDown(tester.view.resetPhysicalSize); - addTearDown(tester.view.resetDevicePixelRatio); - String? sharedText; - final interactions = FakeInteractionRepository(); - final comments = FakeCommentRepository( - pages: [const CommentPage()], - ); - const channel = MethodChannel('com.stormg.lumadrama/share'); - tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(channel, ( - call, - ) async { - sharedText = (call.arguments as Map)['text'] as String; - return null; - }); - addTearDown( - () => tester.binding.defaultBinaryMessenger.setMockMethodCallHandler( - channel, - null, - ), - ); + testWidgets( + 'should_save_comment_like_and_share_in_order_when_right_rail_is_used', + (tester) async { + tester.view.physicalSize = const Size(390, 844); + tester.view.devicePixelRatio = 1; + addTearDown(tester.view.resetPhysicalSize); + addTearDown(tester.view.resetDevicePixelRatio); + String? sharedText; + final interactions = FakeInteractionRepository(); + final comments = FakeCommentRepository(pages: [const CommentPage()]); + const channel = MethodChannel('com.stormg.lumadrama/share'); + tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(channel, ( + call, + ) async { + sharedText = (call.arguments as Map)['text'] as String; + return null; + }); + addTearDown( + () => tester.binding.defaultBinaryMessenger.setMockMethodCallHandler( + channel, + null, + ), + ); - await tester.pumpWidget( - appUnderTest( - commentRepository: comments, - interactionRepository: interactions, - ), - ); - await tester.pumpAndSettle(); - await tester.tap(find.byKey(const Key('tab-home'))); - await tester.pumpAndSettle(); - final keys = [ - const Key('rail-like'), - const Key('rail-save'), - const Key('rail-comments'), - const Key('rail-share'), - ]; - final tops = keys - .map((key) => tester.getTopLeft(find.byKey(key)).dy) - .toList(); - expect(tops, orderedEquals(tops.toList()..sort())); + await tester.pumpWidget( + appUnderTest( + commentRepository: comments, + interactionRepository: interactions, + ), + ); + await tester.pumpAndSettle(); + await tester.tap(find.byKey(const Key('tab-home'))); + await tester.pumpAndSettle(); + final keys = [ + const Key('rail-like'), + const Key('rail-save'), + const Key('rail-comments'), + const Key('rail-share'), + ]; + final tops = keys + .map((key) => tester.getTopLeft(find.byKey(key)).dy) + .toList(); + expect(tops, orderedEquals(tops.toList()..sort())); - await tester.tap(find.byKey(const Key('rail-save'))); - await tester.pumpAndSettle(); - await tester.tap(find.byKey(const Key('rail-comments'))); - await tester.pumpAndSettle(); - expect(find.text('No comments yet.'), findsOneWidget); - await tester.enterText(find.byKey(const Key('comment-input')), 'Nice demo'); - await tester.tap(find.byKey(const Key('comment-post'))); - await tester.pumpAndSettle(); - expect(find.text('Nice demo'), findsOneWidget); - await tester.binding.handlePopRoute(); - await tester.pumpAndSettle(); + await tester.tap(find.byKey(const Key('rail-save'))); + await tester.pumpAndSettle(); + await tester.tap(find.byKey(const Key('rail-comments'))); + await tester.pumpAndSettle(); + expect(find.text('No comments yet.'), findsOneWidget); + await tester.enterText( + find.byKey(const Key('comment-input')), + 'Nice demo', + ); + await tester.tap(find.byKey(const Key('comment-post'))); + await tester.pumpAndSettle(); + expect(find.text('Nice demo'), findsOneWidget); + await tester.binding.handlePopRoute(); + await tester.pumpAndSettle(); - await tester.tap(find.byKey(const Key('rail-like'))); - await tester.pumpAndSettle(); - expect(interactions.likeTargets, contains('DRAMA:the-signal-demo')); - await tester.tap(find.byKey(const Key('rail-share'))); - await tester.pumpAndSettle(); - expect(sharedText, contains('The Signal')); - expect(sharedText, contains('A demo series for vertical playback')); - expect(sharedText, contains('FruitShorts')); - expect(tester.takeException(), isNull); - }); + await tester.tap(find.byKey(const Key('rail-like'))); + await tester.pumpAndSettle(); + expect(interactions.likeTargets, contains('DRAMA:the-signal-demo')); + await tester.tap(find.byKey(const Key('rail-share'))); + await tester.pumpAndSettle(); + expect(sharedText, contains('The Signal')); + expect(sharedText, contains('A demo series for vertical playback')); + expect(sharedText, contains('FruitShorts')); + expect(tester.takeException(), isNull); + }, + ); testWidgets('should_open_auth_gate_without_liking_when_signed_out', ( tester, @@ -501,9 +517,7 @@ void main() { seedSignedOutSession(); final interactions = FakeInteractionRepository(); - await tester.pumpWidget( - appUnderTest(interactionRepository: interactions), - ); + await tester.pumpWidget(appUnderTest(interactionRepository: interactions)); await tester.pumpAndSettle(); await tester.tap(find.byKey(const Key('tab-home'))); await tester.pumpAndSettle(); @@ -523,9 +537,7 @@ void main() { addTearDown(tester.view.resetDevicePixelRatio); final interactions = FakeInteractionRepository(); - await tester.pumpWidget( - appUnderTest(interactionRepository: interactions), - ); + await tester.pumpWidget(appUnderTest(interactionRepository: interactions)); await tester.pumpAndSettle(); await tester.binding.handlePopRoute(); await tester.pumpAndSettle(); @@ -542,63 +554,63 @@ void main() { expect(find.text('Report submitted. Thank you.'), findsOneWidget); }); - testWidgets('should_open_drawer_and_stay_on_home_when_system_back_is_pressed', (tester) async { - tester.view.physicalSize = const Size(390, 844); - tester.view.devicePixelRatio = 1; - addTearDown(tester.view.resetPhysicalSize); - addTearDown(tester.view.resetDevicePixelRatio); - await tester.pumpWidget( - appUnderTest(), - ); - await tester.pumpAndSettle(); + testWidgets( + 'should_open_drawer_and_stay_on_home_when_system_back_is_pressed', + (tester) async { + tester.view.physicalSize = const Size(390, 844); + tester.view.devicePixelRatio = 1; + addTearDown(tester.view.resetPhysicalSize); + addTearDown(tester.view.resetDevicePixelRatio); + await tester.pumpWidget(appUnderTest()); + await tester.pumpAndSettle(); - expect(find.text('Continue Watching'), findsOneWidget); - await tester.binding.handlePopRoute(); - await tester.pumpAndSettle(); - expect(find.text('Quick access'), findsOneWidget); - expect(find.byKey(const Key('home-tabs-bar')), findsOneWidget); - await tester.binding.handlePopRoute(); - await tester.pumpAndSettle(); - expect(find.text('Quick access'), findsNothing); - expect(find.text('Continue Watching'), findsOneWidget); - expect( - Navigator.of( - tester.element(find.byKey(const Key('home-tabs-bar'))), - ).canPop(), - isFalse, - ); - }); + expect(find.text('Continue Watching'), findsOneWidget); + await tester.binding.handlePopRoute(); + await tester.pumpAndSettle(); + expect(find.text('Quick access'), findsOneWidget); + expect(find.byKey(const Key('home-tabs-bar')), findsOneWidget); + await tester.binding.handlePopRoute(); + await tester.pumpAndSettle(); + expect(find.text('Quick access'), findsNothing); + expect(find.text('Continue Watching'), findsOneWidget); + expect( + Navigator.of( + tester.element(find.byKey(const Key('home-tabs-bar'))), + ).canPop(), + isFalse, + ); + }, + ); - testWidgets('should_list_saved_dramas_across_home_feed_when_watchlist_is_opened', ( - tester, - ) async { - tester.view.physicalSize = const Size(390, 844); - tester.view.devicePixelRatio = 1; - addTearDown(tester.view.resetPhysicalSize); - addTearDown(tester.view.resetDevicePixelRatio); - // 收藏要求登录态:沿用本文件已有的"假登录"初始化 - seedSignedInSession(); - await tester.pumpWidget( - appUnderTest(), - ); - await tester.pumpAndSettle(); - await tester.tap(find.byKey(const Key('tab-home'))); - await tester.pumpAndSettle(); + testWidgets( + 'should_list_saved_dramas_across_home_feed_when_watchlist_is_opened', + (tester) async { + tester.view.physicalSize = const Size(390, 844); + tester.view.devicePixelRatio = 1; + addTearDown(tester.view.resetPhysicalSize); + addTearDown(tester.view.resetDevicePixelRatio); + // 收藏要求登录态:沿用本文件已有的"假登录"初始化 + seedSignedInSession(); + await tester.pumpWidget(appUnderTest()); + await tester.pumpAndSettle(); + await tester.tap(find.byKey(const Key('tab-home'))); + await tester.pumpAndSettle(); - await tester.tap(find.byKey(const Key('rail-save'))); - await tester.pumpAndSettle(); - await tester.drag(find.byType(PageView), const Offset(0, -550)); - await tester.pumpAndSettle(); - await tester.tap(find.byKey(const Key('rail-save'))); - await tester.pumpAndSettle(); - await tester.tap(find.byKey(const Key('tab-my-list'))); - await tester.pumpAndSettle(); - await tester.tap(find.text('Watchlist')); - await tester.pumpAndSettle(); - expect(find.text('The Signal'), findsOneWidget); - expect(find.text('City Lights & Velvet Nights'), findsWidgets); - await tester.tap(find.text('The Signal')); - await tester.pumpAndSettle(); - expect(find.text('Watch episode 1'), findsOneWidget); - }); + await tester.tap(find.byKey(const Key('rail-save'))); + await tester.pumpAndSettle(); + await tester.drag(find.byType(PageView), const Offset(0, -550)); + await tester.pumpAndSettle(); + await tester.tap(find.byKey(const Key('rail-save'))); + await tester.pumpAndSettle(); + await tester.tap(find.byKey(const Key('tab-my-list'))); + await tester.pumpAndSettle(); + await tester.tap(find.text('Watchlist')); + await tester.pumpAndSettle(); + expect(find.text('The Signal'), findsOneWidget); + expect(find.text('City Lights & Velvet Nights'), findsWidgets); + await tester.tap(find.text('The Signal')); + await tester.pumpAndSettle(); + expect(find.text('Watch episode 1'), findsOneWidget); + }, + ); } -- 2.54.0 From e609e3ad8d6b39311f975c17241aff30ddb3011d Mon Sep 17 00:00:00 2001 From: Zhou Weidong <502333560@qq.com> Date: Sat, 17 Oct 2026 16:11:01 +0800 Subject: [PATCH 15/76] =?UTF-8?q?feat(flutter):=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E7=99=BB=E5=BD=95=E9=A1=B5=E4=B8=8E=E5=BA=95=E9=83=A8=E5=AF=BC?= =?UTF-8?q?=E8=88=AA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/l10n/app_en.arb | 3 + lib/l10n/app_id.arb | 3 + lib/l10n/app_localizations.dart | 18 ++ lib/l10n/app_localizations_en.dart | 9 + lib/l10n/app_localizations_id.dart | 9 + lib/l10n/app_localizations_zh.dart | 9 + lib/l10n/app_zh.arb | 3 + lib/pages/auth/auth_view.dart | 372 ++++++++++++++++++----------- lib/pages/home/home_view.dart | 86 ++++--- test/auth/auth_page_test.dart | 244 +++++++++++++++++-- test/config/l10n_id_test.dart | 9 + test/home/home_nav_ui_test.dart | 126 ++++++++++ 12 files changed, 702 insertions(+), 189 deletions(-) create mode 100644 test/home/home_nav_ui_test.dart diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index de22c26..6cd002e 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -253,6 +253,7 @@ "authSignInTitle": "Welcome back", "authSignUpTitle": "Create your account", "authSubtitle": "Sign in with your email and password.", + "authBrandTagline": "Short dramas made for Indonesia", "authEmailLabel": "Email", "authPasswordLabel": "Password", "authPasswordHint": "At least 8 characters, letters and numbers", @@ -267,6 +268,8 @@ "authGateTitle": "Sign in to continue", "authGateMessage": "Watch history, favorites, comments and downloads need an account.", "authGateAction": "Sign In", + "showPassword": "Show password", + "hidePassword": "Hide password", "cancel": "Not now", "noEpisodesYet": "No playable episodes yet.", "networkError": "Network is unreachable. Please check your connection and retry.", diff --git a/lib/l10n/app_id.arb b/lib/l10n/app_id.arb index 7d02388..973c95c 100644 --- a/lib/l10n/app_id.arb +++ b/lib/l10n/app_id.arb @@ -253,6 +253,7 @@ "authSignInTitle": "Selamat datang kembali", "authSignUpTitle": "Buat akun kamu", "authSubtitle": "Masuk dengan email dan kata sandi.", + "authBrandTagline": "Drama pendek untuk Indonesia", "authEmailLabel": "Email", "authPasswordLabel": "Kata sandi", "authPasswordHint": "Minimal 8 karakter, berisi huruf dan angka", @@ -267,6 +268,8 @@ "authGateTitle": "Masuk untuk melanjutkan", "authGateMessage": "Riwayat tontonan, favorit, komentar, dan unduhan perlu akun.", "authGateAction": "Masuk", + "showPassword": "Tampilkan kata sandi", + "hidePassword": "Sembunyikan kata sandi", "cancel": "Nanti saja", "noEpisodesYet": "Belum ada episode yang bisa diputar.", "networkError": "Jaringan tidak tersedia. Periksa koneksi lalu coba lagi.", diff --git a/lib/l10n/app_localizations.dart b/lib/l10n/app_localizations.dart index 1427bb2..1eeb935 100644 --- a/lib/l10n/app_localizations.dart +++ b/lib/l10n/app_localizations.dart @@ -1234,6 +1234,12 @@ abstract class AppLocalizations { /// **'Sign in with your email and password.'** String get authSubtitle; + /// No description provided for @authBrandTagline. + /// + /// In en, this message translates to: + /// **'Short dramas made for Indonesia'** + String get authBrandTagline; + /// No description provided for @authEmailLabel. /// /// In en, this message translates to: @@ -1318,6 +1324,18 @@ abstract class AppLocalizations { /// **'Sign In'** String get authGateAction; + /// No description provided for @showPassword. + /// + /// In en, this message translates to: + /// **'Show password'** + String get showPassword; + + /// No description provided for @hidePassword. + /// + /// In en, this message translates to: + /// **'Hide password'** + String get hidePassword; + /// No description provided for @cancel. /// /// In en, this message translates to: diff --git a/lib/l10n/app_localizations_en.dart b/lib/l10n/app_localizations_en.dart index 9243973..7e7d988 100644 --- a/lib/l10n/app_localizations_en.dart +++ b/lib/l10n/app_localizations_en.dart @@ -602,6 +602,9 @@ class AppLocalizationsEn extends AppLocalizations { @override String get authSubtitle => 'Sign in with your email and password.'; + @override + String get authBrandTagline => 'Short dramas made for Indonesia'; + @override String get authEmailLabel => 'Email'; @@ -645,6 +648,12 @@ class AppLocalizationsEn extends AppLocalizations { @override String get authGateAction => 'Sign In'; + @override + String get showPassword => 'Show password'; + + @override + String get hidePassword => 'Hide password'; + @override String get cancel => 'Not now'; diff --git a/lib/l10n/app_localizations_id.dart b/lib/l10n/app_localizations_id.dart index 7d6b7e2..821b0ba 100644 --- a/lib/l10n/app_localizations_id.dart +++ b/lib/l10n/app_localizations_id.dart @@ -604,6 +604,9 @@ class AppLocalizationsId extends AppLocalizations { @override String get authSubtitle => 'Masuk dengan email dan kata sandi.'; + @override + String get authBrandTagline => 'Drama pendek untuk Indonesia'; + @override String get authEmailLabel => 'Email'; @@ -647,6 +650,12 @@ class AppLocalizationsId extends AppLocalizations { @override String get authGateAction => 'Masuk'; + @override + String get showPassword => 'Tampilkan kata sandi'; + + @override + String get hidePassword => 'Sembunyikan kata sandi'; + @override String get cancel => 'Nanti saja'; diff --git a/lib/l10n/app_localizations_zh.dart b/lib/l10n/app_localizations_zh.dart index 0ddd0ad..034f260 100644 --- a/lib/l10n/app_localizations_zh.dart +++ b/lib/l10n/app_localizations_zh.dart @@ -593,6 +593,9 @@ class AppLocalizationsZh extends AppLocalizations { @override String get authSubtitle => '用邮箱和密码登录。'; + @override + String get authBrandTagline => '为印尼市场打造的短剧体验'; + @override String get authEmailLabel => '邮箱'; @@ -635,6 +638,12 @@ class AppLocalizationsZh extends AppLocalizations { @override String get authGateAction => '去登录'; + @override + String get showPassword => '显示密码'; + + @override + String get hidePassword => '隐藏密码'; + @override String get cancel => '暂不'; diff --git a/lib/l10n/app_zh.arb b/lib/l10n/app_zh.arb index d664220..a2b0cba 100644 --- a/lib/l10n/app_zh.arb +++ b/lib/l10n/app_zh.arb @@ -215,6 +215,7 @@ "authSignInTitle": "欢迎回来", "authSignUpTitle": "创建账号", "authSubtitle": "用邮箱和密码登录。", + "authBrandTagline": "为印尼市场打造的短剧体验", "authEmailLabel": "邮箱", "authPasswordLabel": "密码", "authPasswordHint": "至少 8 位,需包含字母和数字", @@ -229,6 +230,8 @@ "authGateTitle": "登录后可继续", "authGateMessage": "观看记录、收藏、评论和下载需要登录。", "authGateAction": "去登录", + "showPassword": "显示密码", + "hidePassword": "隐藏密码", "cancel": "暂不", "noEpisodesYet": "还没有可播放的剧集。", "networkError": "网络异常,请检查网络后重试。", diff --git a/lib/pages/auth/auth_view.dart b/lib/pages/auth/auth_view.dart index 0b03e76..7e9c07f 100644 --- a/lib/pages/auth/auth_view.dart +++ b/lib/pages/auth/auth_view.dart @@ -1,3 +1,5 @@ +// Author: fruit.com.cn + import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; @@ -8,9 +10,9 @@ import '../../core/theme/app_theme.dart'; import '../../l10n/app_localizations.dart'; import 'auth_logic.dart'; +const double _minTapTarget = 44; + /// 登录 / 注册页:邮箱 + 密码。 -/// -/// 风格沿用 FruitShorts 现有页面(深色卡片 + 圆角 + 主色蓝),不另起一套视觉。 class AuthPage extends StatefulWidget { const AuthPage({super.key, this.signUpMode = false}); @@ -22,11 +24,29 @@ class AuthPage extends StatefulWidget { class _AuthPageState extends State { late AuthLogic _logic; + late final TextEditingController _emailController; + late final TextEditingController _passwordController; + late final FocusNode _emailFocus; + late final FocusNode _passwordFocus; + bool _obscurePassword = true; @override void initState() { super.initState(); _logic = AuthLogic(signUpMode: widget.signUpMode); + _emailController = TextEditingController(); + _passwordController = TextEditingController(); + _emailFocus = FocusNode(debugLabel: 'auth-email-focus'); + _passwordFocus = FocusNode(debugLabel: 'auth-password-focus'); + } + + @override + void dispose() { + _emailController.dispose(); + _passwordController.dispose(); + _emailFocus.dispose(); + _passwordFocus.dispose(); + super.dispose(); } String _errorText(AppLocalizations l10n, AuthFieldError error) { @@ -51,6 +71,7 @@ class _AuthPageState extends State { setState(() => _logic.errorMessage = _errorText(l10n, invalid)); return; } + FocusScope.of(context).unfocus(); setState(() { _logic.busy = true; _logic.errorMessage = null; @@ -71,7 +92,6 @@ class _AuthPageState extends State { if (!mounted) return; Navigator.of(context).maybePop(); } on ApiException catch (error) { - // 后端文案已经是可直接展示的中文/印尼语提示,错误码不外露 setState(() => _logic.errorMessage = error.message); } catch (_) { setState(() => _logic.errorMessage = l10n.authNetworkError); @@ -86,158 +106,244 @@ class _AuthPageState extends State { return Theme( data: AppTheme.dark(), child: Scaffold( + resizeToAvoidBottomInset: true, backgroundColor: AppColors.ink, appBar: AppBar( backgroundColor: AppColors.ink, elevation: 0, - foregroundColor: Colors.white, + foregroundColor: AppColors.onPrimary, title: Text(_logic.signUpMode ? l10n.signUp : l10n.signIn), ), body: SafeArea( - child: ListView( - padding: const EdgeInsets.fromLTRB(20, 12, 20, 28), - children: [ - Text( - _logic.signUpMode ? l10n.authSignUpTitle : l10n.authSignInTitle, - style: const TextStyle( - color: Colors.white, - fontSize: 22, - fontWeight: FontWeight.w800, - ), + child: AutofillGroup( + child: ListView( + key: const Key('auth-scroll'), + keyboardDismissBehavior: ScrollViewKeyboardDismissBehavior.onDrag, + padding: EdgeInsets.fromLTRB( + 20, + 12, + 20, + 28 + MediaQuery.viewInsetsOf(context).bottom, ), - const SizedBox(height: 6), - Text( - l10n.authSubtitle, - style: const TextStyle(color: AppColors.muted, fontSize: 13), - ), - const SizedBox(height: 22), - _field( - label: l10n.authEmailLabel, - hint: 'name@example.com', - keyboardType: TextInputType.emailAddress, - onChanged: (value) => _logic.email = value, - autofocus: true, - ), - const SizedBox(height: 14), - _field( - label: l10n.authPasswordLabel, - hint: l10n.authPasswordHint, - obscure: true, - onChanged: (value) => _logic.password = value, - ), - if (_logic.errorMessage != null) ...[ - const SizedBox(height: 12), - Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - const Icon( - Icons.error_outline, - color: Color(0xFFFF6B6B), - size: 16, - ), - const SizedBox(width: 6), - Expanded( - child: Text( - _logic.errorMessage!, - style: const TextStyle( - color: Color(0xFFFF6B6B), - fontSize: 13, - ), - ), - ), - ], - ), - ], - const SizedBox(height: 22), - SizedBox( - height: 48, - child: FilledButton( - style: FilledButton.styleFrom( - backgroundColor: AppColors.blue, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(24), - ), - ), - onPressed: _logic.busy ? null : _submit, - child: _logic.busy - ? const SizedBox( - width: 18, - height: 18, - child: CircularProgressIndicator( - strokeWidth: 2, - color: Colors.white, - ), - ) - : Text( - _logic.signUpMode ? l10n.signUp : l10n.signIn, - style: const TextStyle( - fontSize: 15, - fontWeight: FontWeight.w700, - ), - ), - ), - ), - const SizedBox(height: 14), - TextButton( - onPressed: _logic.busy - ? null - : () => setState(() => _logic.toggleMode()), - child: Text( + children: [ + _AuthBrand(tagline: l10n.authBrandTagline), + const SizedBox(height: 26), + Text( _logic.signUpMode - ? l10n.authSwitchToSignIn - : l10n.authSwitchToSignUp, + ? l10n.authSignUpTitle + : l10n.authSignInTitle, style: const TextStyle( - color: AppColors.blueSoft, - fontSize: 13, + color: AppColors.onPrimary, + fontSize: 24, + fontWeight: FontWeight.w800, ), ), - ), - ], + const SizedBox(height: 6), + Text( + l10n.authSubtitle, + style: const TextStyle(color: AppColors.muted, fontSize: 13), + ), + const SizedBox(height: 22), + _emailField(l10n), + const SizedBox(height: 14), + _passwordField(l10n), + if (_logic.errorMessage != null) ...[ + const SizedBox(height: 12), + _AuthError(message: _logic.errorMessage!), + ], + const SizedBox(height: 22), + _submitButton(l10n), + const SizedBox(height: 10), + _switchModeButton(l10n), + ], + ), ), ), ), ); } - Widget _field({ - required String label, - required String hint, - required ValueChanged onChanged, - bool obscure = false, - bool autofocus = false, - TextInputType? keyboardType, - }) { - return Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - label, - style: const TextStyle( + Widget _emailField(AppLocalizations l10n) => _field( + child: TextField( + key: const Key('auth-email'), + controller: _emailController, + focusNode: _emailFocus, + enabled: !_logic.busy, + autofocus: true, + keyboardType: TextInputType.emailAddress, + textInputAction: TextInputAction.next, + autofillHints: const [AutofillHints.email], + onChanged: (value) => _logic.email = value, + onSubmitted: (_) => _passwordFocus.requestFocus(), + style: const TextStyle(color: AppColors.onPrimary, fontSize: 15), + decoration: _decoration(l10n.authEmailLabel, 'name@example.com'), + ), + ); + + Widget _passwordField(AppLocalizations l10n) => _field( + child: TextField( + key: const Key('auth-password'), + controller: _passwordController, + focusNode: _passwordFocus, + enabled: !_logic.busy, + obscureText: _obscurePassword, + keyboardType: TextInputType.visiblePassword, + textInputAction: TextInputAction.done, + autofillHints: const [AutofillHints.password], + onChanged: (value) => _logic.password = value, + onSubmitted: (_) => _submit(), + style: const TextStyle(color: AppColors.onPrimary, fontSize: 15), + decoration: _decoration( + l10n.authPasswordLabel, + l10n.authPasswordHint, + suffix: IconButton( + key: const Key('auth-password-visibility'), + constraints: const BoxConstraints.tightFor( + width: _minTapTarget, + height: _minTapTarget, + ), + tooltip: _obscurePassword ? l10n.showPassword : l10n.hidePassword, + onPressed: _logic.busy + ? null + : () => setState(() => _obscurePassword = !_obscurePassword), + icon: Icon( + _obscurePassword + ? Icons.visibility_outlined + : Icons.visibility_off_outlined, color: AppColors.muted, - fontSize: 12, - fontWeight: FontWeight.w700, ), ), - const SizedBox(height: 6), - TextField( - autofocus: autofocus, - obscureText: obscure, - keyboardType: keyboardType, - onChanged: onChanged, - style: const TextStyle(color: Colors.white, fontSize: 15), - decoration: InputDecoration( - hintText: hint, - hintStyle: const TextStyle(color: Color(0xFF6C7280), fontSize: 14), - filled: true, - fillColor: AppColors.card, - contentPadding: const EdgeInsets.symmetric( - horizontal: 14, - vertical: 14, - ), - border: OutlineInputBorder( - borderRadius: BorderRadius.circular(12), - borderSide: BorderSide.none, + ), + ), + ); + + Widget _field({required Widget child}) => + Column(crossAxisAlignment: CrossAxisAlignment.start, children: [child]); + + InputDecoration _decoration(String label, String hint, {Widget? suffix}) { + final scheme = Theme.of(context).colorScheme; + return InputDecoration( + labelText: label, + hintText: hint, + hintStyle: TextStyle(color: scheme.onSurfaceVariant, fontSize: 14), + suffixIcon: suffix, + filled: true, + fillColor: AppColors.card, + contentPadding: const EdgeInsets.symmetric(horizontal: 16, vertical: 17), + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(12), + borderSide: BorderSide.none, + ), + focusedBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(12), + borderSide: BorderSide(color: scheme.primary, width: 1.5), + ), + ); + } + + Widget _submitButton(AppLocalizations l10n) => SizedBox( + height: 50, + child: FilledButton( + key: const Key('auth-submit'), + onPressed: _logic.busy ? null : _submit, + style: FilledButton.styleFrom( + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(25)), + ), + child: _logic.busy + ? const SizedBox.square( + dimension: 18, + child: CircularProgressIndicator( + strokeWidth: 2, + color: AppColors.onPrimary, + ), + ) + : Text( + _logic.signUpMode ? l10n.signUp : l10n.signIn, + style: const TextStyle(fontSize: 15, fontWeight: FontWeight.w700), ), + ), + ); + + Widget _switchModeButton(AppLocalizations l10n) => TextButton( + key: const Key('auth-switch-mode'), + style: TextButton.styleFrom( + minimumSize: const Size(0, _minTapTarget), + foregroundColor: AppColors.blueSoft, + ), + onPressed: _logic.busy ? null : () => setState(() => _logic.toggleMode()), + child: Text( + _logic.signUpMode ? l10n.authSwitchToSignIn : l10n.authSwitchToSignUp, + style: const TextStyle(fontSize: 13), + ), + ); +} + +class _AuthBrand extends StatelessWidget { + const _AuthBrand({required this.tagline}); + + final String tagline; + + @override + Widget build(BuildContext context) { + return Row( + children: [ + Container( + width: 48, + height: 48, + decoration: const BoxDecoration( + color: AppColors.blue, + shape: BoxShape.circle, + ), + child: const Icon( + Icons.play_arrow_rounded, + color: AppColors.onPrimary, + size: 30, + ), + ), + const SizedBox(width: 12), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + AppLocalizations.of(context)!.appName, + style: const TextStyle( + color: AppColors.onPrimary, + fontSize: 20, + fontWeight: FontWeight.w800, + ), + ), + const SizedBox(height: 2), + Text( + tagline, + style: const TextStyle(color: AppColors.blueSoft, fontSize: 12), + ), + ], + ), + ), + ], + ); + } +} + +class _AuthError extends StatelessWidget { + const _AuthError({required this.message}); + + final String message; + + @override + Widget build(BuildContext context) { + final color = Theme.of(context).colorScheme.error; + return Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Icon(Icons.error_outline, color: color, size: 18), + const SizedBox(width: 6), + Expanded( + child: Text( + message, + key: const Key('auth-error'), + style: TextStyle(color: color, fontSize: 13), ), ), ], diff --git a/lib/pages/home/home_view.dart b/lib/pages/home/home_view.dart index 71e1b57..53d6147 100644 --- a/lib/pages/home/home_view.dart +++ b/lib/pages/home/home_view.dart @@ -118,7 +118,7 @@ class _HomeTabsState extends State<_HomeTabs> { }, child: Scaffold( key: logic.scaffoldKey, - backgroundColor: const Color(0xFF0B0C10), + backgroundColor: AppColors.ink, drawer: HomeQuickDrawer( drama: logic.currentDrama, onOpenSeries: () => logic.openCurrentSeries(context), @@ -183,12 +183,17 @@ class _HomeTabsState extends State<_HomeTabs> { ? null : SafeArea( top: false, + minimum: const EdgeInsets.only(bottom: 2), child: Container( key: const Key('home-tabs-bar'), - height: 63, - decoration: const BoxDecoration( - color: Color(0xFF0D0D11), - border: Border(top: BorderSide(color: Color(0xFF242329))), + height: 64, + decoration: BoxDecoration( + color: AppColors.bar, + border: Border( + top: BorderSide( + color: Theme.of(context).colorScheme.outlineVariant, + ), + ), ), child: Row( children: [ @@ -250,37 +255,48 @@ class _TabButton extends StatelessWidget { @override Widget build(BuildContext context) => Expanded( - child: InkWell( - onTap: onTap, - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Container( - padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 3), - decoration: selected - ? BoxDecoration( - color: AppColors.bluePressed, - borderRadius: BorderRadius.circular(14), - ) - : null, - child: Icon( - selected ? selectedIcon : icon, - size: 20, - color: selected ? Colors.white : AppColors.muted, - ), + child: Semantics( + button: true, + selected: selected, + label: label, + child: InkWell( + onTap: onTap, + child: ConstrainedBox( + constraints: const BoxConstraints(minHeight: 48), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + AnimatedContainer( + duration: const Duration(milliseconds: 160), + curve: Curves.easeOut, + padding: const EdgeInsets.symmetric( + horizontal: 14, + vertical: 3, + ), + decoration: BoxDecoration( + color: selected ? AppColors.bluePressed : null, + borderRadius: BorderRadius.circular(14), + ), + child: Icon( + selected ? selectedIcon : icon, + size: 22, + color: selected ? AppColors.onPrimary : AppColors.muted, + ), + ), + const SizedBox(height: 2), + Text( + label, + maxLines: 1, + overflow: TextOverflow.ellipsis, + style: TextStyle( + fontSize: 10, + fontWeight: selected ? FontWeight.w700 : FontWeight.w500, + color: selected ? AppColors.blueSoft : AppColors.muted, + ), + ), + ], ), - const SizedBox(height: 2), - Text( - label, - maxLines: 1, - overflow: TextOverflow.ellipsis, - style: TextStyle( - fontSize: 10, - fontWeight: selected ? FontWeight.w700 : FontWeight.w500, - color: selected ? AppColors.blueSoft : AppColors.muted, - ), - ), - ], + ), ), ), ); diff --git a/test/auth/auth_page_test.dart b/test/auth/auth_page_test.dart index 61f3aa9..dc5fd08 100644 --- a/test/auth/auth_page_test.dart +++ b/test/auth/auth_page_test.dart @@ -1,9 +1,12 @@ +import 'dart:async'; + import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:provider/provider.dart'; import 'package:shared_preferences_platform_interface/in_memory_shared_preferences_async.dart'; import 'package:shared_preferences_platform_interface/shared_preferences_async_platform_interface.dart'; +import 'package:fruitshorts/core/data/models/auth_session.dart'; import 'package:fruitshorts/core/data/remote/auth_api.dart'; import 'package:fruitshorts/core/data/remote/api_client.dart'; import 'package:fruitshorts/core/data/services/auth_controller.dart'; @@ -20,15 +23,22 @@ void main() { InMemorySharedPreferencesAsync.empty(); }); - Future pumpAuthPage(WidgetTester tester, {bool signUp = false}) async { + Future pumpAuthPage( + WidgetTester tester, { + bool signUp = false, + AuthApi? api, + }) async { final auth = AuthController( - AuthApi( - // 这个测试不联网:请求一律 500,正好用于验证"本地校验没过就不发请求" - ApiClient( - baseUrl: 'http://127.0.0.1:1', - adapter: FakeHttpAdapter((_) async => FakeHttpResponse('{}', 500)), - ), - ), + api ?? + AuthApi( + // 这个测试不联网:请求一律 500,正好用于验证"本地校验没过就不发请求" + ApiClient( + baseUrl: 'http://127.0.0.1:1', + adapter: FakeHttpAdapter( + (_) async => FakeHttpResponse('{}', 500), + ), + ), + ), AuthSessionStore(), ); await tester.pumpWidget( @@ -45,7 +55,9 @@ void main() { await tester.pumpAndSettle(); } - testWidgets('should_show_email_error_and_stay_on_page_when_form_is_empty', (tester) async { + testWidgets('should_show_email_error_and_stay_on_page_when_form_is_empty', ( + tester, + ) async { await pumpAuthPage(tester); expect(find.text('Welcome back'), findsOneWidget); @@ -57,25 +69,215 @@ void main() { expect(find.text('Welcome back'), findsOneWidget); }); - testWidgets('should_reject_weak_password_locally_when_only_letters_are_typed', (tester) async { + testWidgets( + 'should_reject_weak_password_locally_when_only_letters_are_typed', + (tester) async { + await pumpAuthPage(tester); + + await tester.enterText(find.byType(TextField).first, 'a@b.com'); + await tester.enterText(find.byType(TextField).last, 'abcdefgh'); + await tester.tap(find.byType(FilledButton)); + await tester.pumpAndSettle(); + + expect( + find.text('Password needs both letters and numbers'), + findsOneWidget, + ); + }, + ); + + testWidgets( + 'should_flip_between_sign_in_and_sign_up_when_switch_link_is_tapped', + (tester) async { + await pumpAuthPage(tester); + expect(find.text('Welcome back'), findsOneWidget); + + await tester.tap(find.text('New here? Create an account')); + await tester.pumpAndSettle(); + + expect(find.text('Create your account'), findsOneWidget); + expect(find.text('Already have an account? Sign in'), findsOneWidget); + }, + ); + + testWidgets('should_show_brand_and_form_accessibility_when_page_opens', ( + tester, + ) async { await pumpAuthPage(tester); - await tester.enterText(find.byType(TextField).first, 'a@b.com'); - await tester.enterText(find.byType(TextField).last, 'abcdefgh'); - await tester.tap(find.byType(FilledButton)); - await tester.pumpAndSettle(); - - expect(find.text('Password needs both letters and numbers'), findsOneWidget); + expect(find.text('FruitShorts'), findsOneWidget); + expect(find.text('Short dramas made for Indonesia'), findsOneWidget); + final email = tester.widget(find.byKey(const Key('auth-email'))); + final password = tester.widget( + find.byKey(const Key('auth-password')), + ); + expect(email.autofillHints, contains(AutofillHints.email)); + expect(password.autofillHints, contains(AutofillHints.password)); + expect( + tester.getSize(find.byKey(const Key('auth-submit'))).height, + greaterThanOrEqualTo(44), + ); + expect( + tester.getSize(find.byKey(const Key('auth-password-visibility'))).height, + greaterThanOrEqualTo(44), + ); + expect( + tester.getSize(find.byKey(const Key('auth-switch-mode'))).height, + greaterThanOrEqualTo(44), + ); }); - testWidgets('should_flip_between_sign_in_and_sign_up_when_switch_link_is_tapped', (tester) async { + testWidgets('should_toggle_password_visibility_when_eye_button_is_tapped', ( + tester, + ) async { await pumpAuthPage(tester); - expect(find.text('Welcome back'), findsOneWidget); + expect( + tester + .widget(find.byKey(const Key('auth-password'))) + .obscureText, + isTrue, + ); - await tester.tap(find.text('New here? Create an account')); + await tester.tap(find.byKey(const Key('auth-password-visibility'))); + await tester.pump(); + + expect( + tester + .widget(find.byKey(const Key('auth-password'))) + .obscureText, + isFalse, + ); + expect(find.byTooltip('Hide password'), findsOneWidget); + }); + + testWidgets('should_move_focus_from_email_to_password_when_next_is_pressed', ( + tester, + ) async { + await pumpAuthPage(tester); + await tester.tap(find.byKey(const Key('auth-email'))); + await tester.testTextInput.receiveAction(TextInputAction.next); + await tester.pump(); + + expect( + FocusManager.instance.primaryFocus?.debugLabel, + 'auth-password-focus', + ); + }); + + testWidgets('should_disable_form_and_submit_while_done_action_is_pending', ( + tester, + ) async { + final api = _PendingAuthApi(); + await pumpAuthPage(tester, api: api); + await tester.enterText(find.byKey(const Key('auth-email')), 'a@b.com'); + await tester.enterText(find.byKey(const Key('auth-password')), 'abcd1234'); + await tester.tap(find.byKey(const Key('auth-password'))); + await tester.testTextInput.receiveAction(TextInputAction.done); + await tester.pump(); + + expect(api.loginCalls, 1); + expect( + tester.widget(find.byKey(const Key('auth-email'))).enabled, + isFalse, + ); + expect( + tester.widget(find.byKey(const Key('auth-password'))).enabled, + isFalse, + ); + expect( + tester + .widget(find.byKey(const Key('auth-password-visibility'))) + .onPressed, + isNull, + ); + expect( + tester + .widget(find.byKey(const Key('auth-submit'))) + .onPressed, + isNull, + ); + expect( + tester + .widget(find.byKey(const Key('auth-switch-mode'))) + .onPressed, + isNull, + ); + + api.release(); + await tester.pumpAndSettle(); + }); + + testWidgets('should_render_validation_error_with_theme_semantic_color', ( + tester, + ) async { + await pumpAuthPage(tester); + await tester.enterText(find.byKey(const Key('auth-email')), 'a@b.com'); + await tester.enterText(find.byKey(const Key('auth-password')), 'abcdefgh'); + await tester.tap(find.byKey(const Key('auth-submit'))); await tester.pumpAndSettle(); - expect(find.text('Create your account'), findsOneWidget); - expect(find.text('Already have an account? Sign in'), findsOneWidget); + final errorFinder = find.byKey(const Key('auth-error')); + final error = tester.widget(errorFinder); + final expected = Theme.of(tester.element(errorFinder)).colorScheme.error; + expect(error.style?.color, expected); }); + + testWidgets( + 'should_keep_submit_reachable_when_keyboard_opens_on_small_screen', + (tester) async { + tester.view.physicalSize = const Size(320, 568); + tester.view.devicePixelRatio = 1; + tester.view.viewInsets = const FakeViewPadding(bottom: 260); + addTearDown(tester.view.resetPhysicalSize); + addTearDown(tester.view.resetDevicePixelRatio); + addTearDown(tester.view.resetViewInsets); + + await pumpAuthPage(tester); + await tester.scrollUntilVisible( + find.byKey(const Key('auth-submit')), + 120, + scrollable: find + .descendant( + of: find.byKey(const Key('auth-scroll')), + matching: find.byType(Scrollable), + ) + .first, + ); + await tester.pumpAndSettle(); + + expect( + find.byKey(const Key('auth-submit')).hitTestable(), + findsOneWidget, + ); + expect(tester.takeException(), isNull); + }, + ); +} + +class _PendingAuthApi extends AuthApi { + _PendingAuthApi() + : super( + ApiClient( + baseUrl: 'http://127.0.0.1:1', + adapter: FakeHttpAdapter((_) async => FakeHttpResponse('{}', 500)), + ), + ); + + final _gate = Completer(); + int loginCalls = 0; + + void release() => _gate.complete(); + + @override + Future login({ + required String email, + required String password, + required String deviceId, + String platform = '', + String appVersion = '', + }) async { + loginCalls++; + await _gate.future; + throw const ApiException(500, 'pending failure'); + } } diff --git a/test/config/l10n_id_test.dart b/test/config/l10n_id_test.dart index c04c29c..4e09c28 100644 --- a/test/config/l10n_id_test.dart +++ b/test/config/l10n_id_test.dart @@ -45,4 +45,13 @@ void main() { expect(l10n.episodeProgress(2, 10), contains('2')); expect(l10n.episodeProgress(2, 10), contains('10')); }); + + test('should_keep_auth_ui_copy_in_all_supported_locales', () async { + for (final locale in const [Locale('en'), Locale('zh'), Locale('id')]) { + final l10n = await AppLocalizations.delegate.load(locale); + expect(l10n.authBrandTagline, isNotEmpty); + expect(l10n.showPassword, isNotEmpty); + expect(l10n.hidePassword, isNotEmpty); + } + }); } diff --git a/test/home/home_nav_ui_test.dart b/test/home/home_nav_ui_test.dart new file mode 100644 index 0000000..6a9b9f7 --- /dev/null +++ b/test/home/home_nav_ui_test.dart @@ -0,0 +1,126 @@ +// Author: fruit.com.cn + +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:fruitshorts/app.dart'; +import 'package:fruitshorts/core/data/repositories/favorite_repository.dart'; +import 'package:fruitshorts/core/data/repositories/playback_repository.dart'; +import 'package:fruitshorts/core/data/repositories/watch_history_repository.dart'; +import 'package:fruitshorts/core/theme/app_colors.dart'; +import 'package:shared_preferences_platform_interface/in_memory_shared_preferences_async.dart'; +import 'package:shared_preferences_platform_interface/shared_preferences_async_platform_interface.dart'; + +import '../support/fake_catalog.dart'; +import '../support/fake_category.dart'; +import '../support/fake_interaction_repositories.dart'; +import '../support/widget_player.dart'; + +const _keys = [ + Key('home-tabs-bar'), + Key('tab-discover'), + Key('tab-home'), + Key('tab-my-list'), + Key('tab-my'), +]; + +void main() { + setUp(() { + SharedPreferencesAsyncPlatform.instance = + InMemorySharedPreferencesAsync.withData({ + 'auth.accessToken': 'test-access', + 'auth.refreshToken': 'test-refresh', + 'auth.user': '{"uid":"9","nickname":"Viewer","avatarUrl":""}', + }); + }); + + testWidgets('should_theme_four_tabs_and_switch_selected_state_when_tapped', ( + tester, + ) async { + await _pumpApp(tester); + + for (final key in _keys) { + expect(find.byKey(key), findsOneWidget); + } + for (final key in _keys.skip(1)) { + expect(tester.getSize(find.byKey(key)).height, greaterThanOrEqualTo(48)); + } + + final barFinder = find.byKey(const Key('home-tabs-bar')); + final bar = tester.widget(barFinder); + final decoration = bar.decoration as BoxDecoration; + final border = decoration.border as Border; + final context = tester.element(barFinder); + expect(decoration.color, AppColors.bar); + expect(border.top.color, Theme.of(context).colorScheme.outlineVariant); + expect( + tester + .widget( + find.descendant( + of: find.byKey(const Key('tab-home')), + matching: find.byType(AnimatedContainer), + ), + ) + .duration, + lessThanOrEqualTo(const Duration(milliseconds: 200)), + ); + expect( + find.descendant( + of: find.byKey(const Key('tab-home')), + matching: find.byIcon(Icons.movie_rounded), + ), + findsOneWidget, + ); + + await tester.tap(find.byKey(const Key('tab-discover'))); + await tester.pumpAndSettle(); + expect( + find.descendant( + of: find.byKey(const Key('tab-discover')), + matching: find.byIcon(Icons.home_rounded), + ), + findsOneWidget, + ); + expect( + find.descendant( + of: find.byKey(const Key('tab-home')), + matching: find.byIcon(Icons.movie_outlined), + ), + findsOneWidget, + ); + }); + + testWidgets('should_hide_themed_navigation_when_immersive_mode_is_enabled', ( + tester, + ) async { + await _pumpApp(tester); + await tester.tap(find.byTooltip('Clear screen')); + await tester.pumpAndSettle(); + + for (final key in _keys) { + expect(find.byKey(key), findsNothing); + } + }); +} + +Future _pumpApp(WidgetTester tester) async { + tester.view.physicalSize = const Size(390, 844); + tester.view.devicePixelRatio = 1; + addTearDown(tester.view.resetPhysicalSize); + addTearDown(tester.view.resetDevicePixelRatio); + final catalog = FakeCatalogRepository(); + await tester.pumpWidget( + LumaDramaApp( + playerFactory: createWidgetPlayer, + catalogRepository: catalog, + categoryRepository: FakeCategoryRepository(catalog: catalog), + watchHistoryRepository: InMemoryWatchHistoryRepository(), + favoriteRepository: InMemoryFavoriteRepository(cards: catalog.dramas), + playbackRepository: FakePlaybackRepository(), + commentRepository: FakeCommentRepository(), + interactionRepository: FakeInteractionRepository(), + ), + ); + await tester.pumpAndSettle(); + await tester.tap(find.byKey(const Key('tab-home'))); + await tester.pumpAndSettle(); +} -- 2.54.0 From 8a481d5c6278f32d94cc76a089941fba281c5fd9 Mon Sep 17 00:00:00 2001 From: Zhou Weidong <502333560@qq.com> Date: Sat, 17 Oct 2026 16:15:46 +0800 Subject: [PATCH 16/76] =?UTF-8?q?feat(flutter):=20=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E5=85=B3=E9=94=AE=E6=93=8D=E4=BD=9C=E9=9C=87=E5=8A=A8=E5=8F=8D?= =?UTF-8?q?=E9=A6=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/app.dart | 4 + lib/core/platform/haptics.dart | 39 ++++++++++ lib/core/widgets/download_action.dart | 4 + lib/pages/auth/auth_view.dart | 4 + lib/pages/downloads/downloads_page.dart | 5 ++ lib/pages/drama_detail/drama_detail_view.dart | 4 + lib/pages/favorites/favorites_page.dart | 2 + lib/pages/home/home_view.dart | 25 ++++++- lib/pages/player/player_view.dart | 5 ++ .../player/widgets/drama_comments_sheet.dart | 7 +- .../watch_records/watch_records_page.dart | 5 +- test/auth/auth_page_test.dart | 14 +++- test/comment/drama_comments_sheet_test.dart | 75 ++++++++++--------- test/core/haptics_scan_test.dart | 23 ++++++ test/core/haptics_test.dart | 24 ++++++ test/download/downloads_page_test.dart | 62 ++++++++------- test/home/home_nav_ui_test.dart | 27 ++++++- test/library/favorites_page_test.dart | 8 +- test/support/fake_haptics.dart | 36 +++++++++ test/watch/watch_records_page_test.dart | 7 ++ 20 files changed, 308 insertions(+), 72 deletions(-) create mode 100644 lib/core/platform/haptics.dart create mode 100644 test/core/haptics_scan_test.dart create mode 100644 test/core/haptics_test.dart create mode 100644 test/support/fake_haptics.dart diff --git a/lib/app.dart b/lib/app.dart index f0d10d8..5c292c7 100644 --- a/lib/app.dart +++ b/lib/app.dart @@ -33,6 +33,7 @@ import 'core/data/services/favorite_controller.dart'; import 'core/data/services/interaction_controller.dart'; import 'core/data/services/playback_session.dart'; import 'core/data/services/video_player_port.dart'; +import 'core/platform/haptics.dart'; import 'core/theme/app_theme.dart'; import 'l10n/app_localizations.dart'; import 'pages/home/home_view.dart'; @@ -49,6 +50,7 @@ class LumaDramaApp extends StatefulWidget { this.playbackRepository, this.commentRepository, this.interactionRepository, + this.haptics = const FlutterHaptics(), }); final PlayerFactory playerFactory; @@ -62,6 +64,7 @@ class LumaDramaApp extends StatefulWidget { final PlaybackRepository? playbackRepository; final CommentRepository? commentRepository; final InteractionRepository? interactionRepository; + final Haptics haptics; @override State createState() => _LumaDramaAppState(); @@ -176,6 +179,7 @@ class _LumaDramaAppState extends State { Provider.value(value: _favorites), Provider.value(value: _commentRepository), Provider.value(value: _interactionRepository), + Provider.value(value: widget.haptics), ChangeNotifierProvider( create: (_) => CatalogController(_catalogRepository)..load(), ), diff --git a/lib/core/platform/haptics.dart b/lib/core/platform/haptics.dart new file mode 100644 index 0000000..cbdbd17 --- /dev/null +++ b/lib/core/platform/haptics.dart @@ -0,0 +1,39 @@ +// Author: fruit.com.cn + +import 'package:flutter/services.dart'; + +/// User-action haptic feedback boundary. +abstract interface class Haptics { + /// Feedback for a selection change. + Future selectionClick(); + + /// Feedback for a primary action. + Future lightImpact(); + + /// Feedback for a destructive action. + Future mediumImpact(); +} + +/// Default implementation backed by Flutter's platform haptics. +class FlutterHaptics implements Haptics { + const FlutterHaptics(); + + @override + Future selectionClick() => + _ignoreUnavailable(HapticFeedback.selectionClick); + + @override + Future lightImpact() => _ignoreUnavailable(HapticFeedback.lightImpact); + + @override + Future mediumImpact() => + _ignoreUnavailable(HapticFeedback.mediumImpact); + + Future _ignoreUnavailable(Future Function() feedback) async { + try { + await feedback(); + } catch (_) { + // Haptics are optional and may be unavailable on the target device. + } + } +} diff --git a/lib/core/widgets/download_action.dart b/lib/core/widgets/download_action.dart index 6c3a356..6da727b 100644 --- a/lib/core/widgets/download_action.dart +++ b/lib/core/widgets/download_action.dart @@ -1,10 +1,13 @@ // Author: fruit.com.cn +import 'dart:async'; + import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import '../../l10n/app_localizations.dart'; import '../data/services/download_controller.dart'; +import '../platform/haptics.dart'; import 'auth_gate.dart'; /// 详情页与播放页共用的下载授权入口。 @@ -16,6 +19,7 @@ Future requestEpisodeDownload( ) async { if (!await ensureSignedIn(context)) return; if (!context.mounted) return; + unawaited(context.read().lightImpact()); final result = await context.read().grant(episodeId); if (!context.mounted) return; final l10n = AppLocalizations.of(context)!; diff --git a/lib/pages/auth/auth_view.dart b/lib/pages/auth/auth_view.dart index 7e9c07f..af6bdc2 100644 --- a/lib/pages/auth/auth_view.dart +++ b/lib/pages/auth/auth_view.dart @@ -1,10 +1,13 @@ // Author: fruit.com.cn +import 'dart:async'; + import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import '../../core/data/remote/api_client.dart'; import '../../core/data/services/auth_controller.dart'; +import '../../core/platform/haptics.dart'; import '../../core/theme/app_colors.dart'; import '../../core/theme/app_theme.dart'; import '../../l10n/app_localizations.dart'; @@ -71,6 +74,7 @@ class _AuthPageState extends State { setState(() => _logic.errorMessage = _errorText(l10n, invalid)); return; } + unawaited(context.read().lightImpact()); FocusScope.of(context).unfocus(); setState(() { _logic.busy = true; diff --git a/lib/pages/downloads/downloads_page.dart b/lib/pages/downloads/downloads_page.dart index f1228d9..4247658 100644 --- a/lib/pages/downloads/downloads_page.dart +++ b/lib/pages/downloads/downloads_page.dart @@ -11,6 +11,7 @@ import '../../core/data/services/auth_controller.dart'; import '../../core/data/services/download_controller.dart'; import '../../core/formatting/error_text.dart'; import '../../core/formatting/localized_date_time.dart'; +import '../../core/platform/haptics.dart'; import '../../core/theme/app_colors.dart'; import '../../core/theme/app_theme.dart'; import '../../core/widgets/auth_gate.dart'; @@ -166,6 +167,7 @@ class _DownloadsBody extends StatelessWidget { } Future _remove(BuildContext context, String episodeId) async { + unawaited(context.read().mediumImpact()); final ok = await downloads.remove(episodeId); if (ok || !context.mounted) return; _showMessage(context, AppLocalizations.of(context)!.downloadDeleteFailed); @@ -191,6 +193,9 @@ class _DownloadsBody extends StatelessWidget { ), ); if (confirmed != true) return; + if (context.mounted) { + unawaited(context.read().mediumImpact()); + } final ok = await downloads.clear(); if (!ok && context.mounted) { _showMessage(context, l10n.downloadClearFailed); diff --git a/lib/pages/drama_detail/drama_detail_view.dart b/lib/pages/drama_detail/drama_detail_view.dart index 62d0ed8..f52b8de 100644 --- a/lib/pages/drama_detail/drama_detail_view.dart +++ b/lib/pages/drama_detail/drama_detail_view.dart @@ -11,6 +11,7 @@ import '../../core/data/services/favorite_controller.dart'; import '../../core/data/services/interaction_controller.dart'; import '../../core/formatting/error_text.dart'; import '../../core/formatting/localized_content.dart'; +import '../../core/platform/haptics.dart'; import '../../core/theme/app_colors.dart'; import '../../core/theme/app_theme.dart'; import '../../core/widgets/remote_image.dart'; @@ -315,6 +316,7 @@ class _DramaDetailPageState extends State { if (!await ensureSignedIn(context) || !mounted) return; final draft = await showReportDialog(context, title: l10n.reportDrama); if (draft == null || !mounted) return; + unawaited(context.read().lightImpact()); final result = await context.read().reportDrama( logic.drama.id, reason: draft.reason, @@ -341,6 +343,8 @@ class _DramaDetailPageState extends State { icon: Icon(saved ? Icons.bookmark : Icons.bookmark_border), onPressed: () async { if (!await ensureSignedIn(context)) return; + if (!context.mounted) return; + unawaited(context.read().lightImpact()); final ok = await logic.toggleFavorite(); if (ok || !context.mounted) return; // 成功靠图标变化反馈;失败必须说清楚(乐观更新已回滚) diff --git a/lib/pages/favorites/favorites_page.dart b/lib/pages/favorites/favorites_page.dart index 62b7c54..7033488 100644 --- a/lib/pages/favorites/favorites_page.dart +++ b/lib/pages/favorites/favorites_page.dart @@ -9,6 +9,7 @@ import '../../core/data/models/drama.dart'; import '../../core/data/services/auth_controller.dart'; import '../../core/data/services/favorite_controller.dart'; import '../../core/formatting/error_text.dart'; +import '../../core/platform/haptics.dart'; import '../../core/theme/app_theme.dart'; import '../../core/widgets/auth_gate.dart'; import '../../core/widgets/library_drama_tile.dart'; @@ -142,6 +143,7 @@ class _FavoritesBody extends StatelessWidget { } Future _remove(BuildContext context, String dramaId) async { + unawaited(context.read().lightImpact()); final ok = await favorites.remove(dramaId); if (ok || !context.mounted) return; final l10n = AppLocalizations.of(context)!; diff --git a/lib/pages/home/home_view.dart b/lib/pages/home/home_view.dart index 53d6147..e19b838 100644 --- a/lib/pages/home/home_view.dart +++ b/lib/pages/home/home_view.dart @@ -1,5 +1,7 @@ // Author: fruit.com.cn +import 'dart:async'; + import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; @@ -8,6 +10,7 @@ import '../../core/config/app_config.dart'; import '../../core/data/models/drama.dart'; import '../../core/data/services/auth_controller.dart'; import '../../core/data/services/catalog_controller.dart'; +import '../../core/platform/haptics.dart'; import '../../core/theme/app_colors.dart'; import '../../core/theme/app_theme.dart'; import '../../core/widgets/auth_gate.dart'; @@ -203,7 +206,7 @@ class _HomeTabsState extends State<_HomeTabs> { selectedIcon: Icons.home_rounded, label: l10n.homeTab, selected: logic.tab == 1, - onTap: () => logic.select(1), + onTap: () => _selectTab(context, 1), ), _TabButton( key: const Key('tab-home'), @@ -211,7 +214,7 @@ class _HomeTabsState extends State<_HomeTabs> { selectedIcon: Icons.movie_rounded, label: l10n.shortsTab, selected: logic.tab == 0, - onTap: () => logic.select(0), + onTap: () => _selectTab(context, 0), ), _TabButton( key: const Key('tab-my-list'), @@ -219,7 +222,7 @@ class _HomeTabsState extends State<_HomeTabs> { selectedIcon: Icons.bookmark_rounded, label: l10n.myListTab, selected: logic.tab == 2 && !logic.profile, - onTap: logic.openLibrary, + onTap: () => _selectTab(context, 2), ), _TabButton( key: const Key('tab-my'), @@ -227,7 +230,7 @@ class _HomeTabsState extends State<_HomeTabs> { selectedIcon: Icons.person_rounded, label: l10n.myTab, selected: logic.tab == 2 && logic.profile, - onTap: logic.openProfile, + onTap: () => _selectTab(context, 2, myProfile: true), ), ], ), @@ -236,6 +239,20 @@ class _HomeTabsState extends State<_HomeTabs> { ), ); } + + void _selectTab(BuildContext context, int tab, {bool myProfile = false}) { + final same = tab == 2 + ? logic.tab == 2 && logic.profile == myProfile + : logic.tab == tab; + if (!same) { + unawaited(context.read().selectionClick()); + } + if (tab == 2) { + myProfile ? logic.openProfile() : logic.openLibrary(); + } else { + logic.select(tab); + } + } } class _TabButton extends StatelessWidget { diff --git a/lib/pages/player/player_view.dart b/lib/pages/player/player_view.dart index 11e4a93..63fafb8 100644 --- a/lib/pages/player/player_view.dart +++ b/lib/pages/player/player_view.dart @@ -15,6 +15,7 @@ import '../../core/data/services/playback_session.dart'; import '../../core/data/services/video_player_port.dart'; import '../../core/formatting/error_text.dart'; import '../../core/formatting/localized_content.dart'; +import '../../core/platform/haptics.dart'; import '../../core/theme/app_colors.dart'; import '../../core/theme/app_theme.dart'; import '../../core/widgets/auth_gate.dart'; @@ -350,6 +351,8 @@ class _PlayerPageState extends State with WidgetsBindingObserver { // 收藏/点赞要对到具体账号:未登录先引导登录(首页/详情仍可匿名浏览) onLike: () async { if (await ensureSignedIn(context)) { + if (!context.mounted) return; + unawaited(context.read().lightImpact()); final result = await interactions.toggleDramaLike(drama.id); if (!result.isSuccess && context.mounted) { ScaffoldMessenger.of(context).showSnackBar( @@ -366,6 +369,8 @@ class _PlayerPageState extends State with WidgetsBindingObserver { onSave: () async { final favorites = context.read(); if (await ensureSignedIn(context)) { + if (!context.mounted) return; + unawaited(context.read().lightImpact()); final ok = await favorites.toggle(drama.id, card: drama); if (ok || !context.mounted) return; ScaffoldMessenger.of(context).showSnackBar( diff --git a/lib/pages/player/widgets/drama_comments_sheet.dart b/lib/pages/player/widgets/drama_comments_sheet.dart index 708bb4a..363321b 100644 --- a/lib/pages/player/widgets/drama_comments_sheet.dart +++ b/lib/pages/player/widgets/drama_comments_sheet.dart @@ -11,6 +11,7 @@ import '../../../core/data/repositories/comment_repository.dart'; import '../../../core/data/repositories/interaction_repository.dart'; import '../../../core/data/services/comment_controller.dart'; import '../../../core/formatting/error_text.dart'; +import '../../../core/platform/haptics.dart'; import '../../../core/theme/app_colors.dart'; import '../../../core/widgets/auth_gate.dart'; import '../../../l10n/app_localizations.dart'; @@ -60,6 +61,7 @@ class _DramaCommentsSheetState extends State { if (_controller.submitting) return; if (_input.text.trim().isEmpty) return; if (!await ensureSignedIn(context) || !mounted) return; + unawaited(context.read().lightImpact()); final result = await _controller.publish(_input.text, replyTo: _replyTo); if (!mounted) return; if (result.isSuccess) { @@ -84,6 +86,7 @@ class _DramaCommentsSheetState extends State { Future _like(DramaComment comment) async { if (!await ensureSignedIn(context) || !mounted) return; + unawaited(context.read().lightImpact()); final result = await _controller.toggleLike(comment); if (!result.isSuccess && mounted) { _showMessage( @@ -116,7 +119,8 @@ class _DramaCommentsSheetState extends State { final result = await _controller.delete(comment); if (!result.isSuccess && mounted) { _showMessage( - result.errorMessage ?? AppLocalizations.of(context)!.commentDeleteFailed, + result.errorMessage ?? + AppLocalizations.of(context)!.commentDeleteFailed, ); } } @@ -126,6 +130,7 @@ class _DramaCommentsSheetState extends State { final l10n = AppLocalizations.of(context)!; final draft = await showReportDialog(context, title: l10n.reportComment); if (draft == null || !mounted) return; + unawaited(context.read().lightImpact()); final result = await _controller.report( comment, reason: draft.reason, diff --git a/lib/pages/watch_records/watch_records_page.dart b/lib/pages/watch_records/watch_records_page.dart index be98702..9401963 100644 --- a/lib/pages/watch_records/watch_records_page.dart +++ b/lib/pages/watch_records/watch_records_page.dart @@ -13,6 +13,7 @@ import '../../core/data/services/auth_controller.dart'; import '../../core/data/services/watch_records_controller.dart'; import '../../core/formatting/error_text.dart'; import '../../core/formatting/localized_date_time.dart'; +import '../../core/platform/haptics.dart'; import '../../core/theme/app_colors.dart'; import '../../core/theme/app_theme.dart'; import '../../core/widgets/auth_gate.dart'; @@ -141,6 +142,7 @@ class _WatchRecordsBodyState extends State<_WatchRecordsBody> { } Future _remove(String dramaId) async { + unawaited(context.read().mediumImpact()); final ok = await controller.remove(dramaId); if (!ok && mounted) _showFailure('recordDeleteFailed'); } @@ -164,7 +166,8 @@ class _WatchRecordsBodyState extends State<_WatchRecordsBody> { ], ), ); - if (confirmed != true) return; + if (confirmed != true || !mounted) return; + unawaited(context.read().mediumImpact()); final ok = await controller.clear(); if (!ok && mounted) _showFailure('recordClearFailed'); } diff --git a/test/auth/auth_page_test.dart b/test/auth/auth_page_test.dart index dc5fd08..ffa24e0 100644 --- a/test/auth/auth_page_test.dart +++ b/test/auth/auth_page_test.dart @@ -11,10 +11,12 @@ import 'package:fruitshorts/core/data/remote/auth_api.dart'; import 'package:fruitshorts/core/data/remote/api_client.dart'; import 'package:fruitshorts/core/data/services/auth_controller.dart'; import 'package:fruitshorts/core/data/services/auth_session_store.dart'; +import 'package:fruitshorts/core/platform/haptics.dart'; import 'package:fruitshorts/l10n/app_localizations.dart'; import 'package:fruitshorts/pages/auth/auth_view.dart'; import '../support/fake_http_adapter.dart'; +import '../support/fake_haptics.dart'; /// 登录/注册页的可读证据:校验提示 + 登录/注册切换 + 未登录时不会去发请求。 void main() { @@ -27,6 +29,7 @@ void main() { WidgetTester tester, { bool signUp = false, AuthApi? api, + FakeHaptics? haptics, }) async { final auth = AuthController( api ?? @@ -42,8 +45,11 @@ void main() { AuthSessionStore(), ); await tester.pumpWidget( - ChangeNotifierProvider.value( - value: auth, + MultiProvider( + providers: [ + ChangeNotifierProvider.value(value: auth), + Provider.value(value: haptics ?? FakeHaptics()), + ], child: MaterialApp( locale: const Locale('en'), localizationsDelegates: AppLocalizations.localizationsDelegates, @@ -168,7 +174,8 @@ void main() { tester, ) async { final api = _PendingAuthApi(); - await pumpAuthPage(tester, api: api); + final haptics = FakeHaptics(); + await pumpAuthPage(tester, api: api, haptics: haptics); await tester.enterText(find.byKey(const Key('auth-email')), 'a@b.com'); await tester.enterText(find.byKey(const Key('auth-password')), 'abcd1234'); await tester.tap(find.byKey(const Key('auth-password'))); @@ -176,6 +183,7 @@ void main() { await tester.pump(); expect(api.loginCalls, 1); + expect(haptics.lightImpacts, 1); expect( tester.widget(find.byKey(const Key('auth-email'))).enabled, isFalse, diff --git a/test/comment/drama_comments_sheet_test.dart b/test/comment/drama_comments_sheet_test.dart index f876764..3cadf2d 100644 --- a/test/comment/drama_comments_sheet_test.dart +++ b/test/comment/drama_comments_sheet_test.dart @@ -11,6 +11,7 @@ import 'package:fruitshorts/core/data/repositories/comment_repository.dart'; import 'package:fruitshorts/core/data/repositories/interaction_repository.dart'; import 'package:fruitshorts/core/data/services/auth_controller.dart'; import 'package:fruitshorts/core/data/services/auth_session_store.dart'; +import 'package:fruitshorts/core/platform/haptics.dart'; import 'package:fruitshorts/l10n/app_localizations.dart'; import 'package:fruitshorts/pages/player/widgets/drama_comments_sheet.dart'; import 'package:provider/provider.dart'; @@ -18,6 +19,7 @@ import 'package:shared_preferences_platform_interface/in_memory_shared_preferenc import 'package:shared_preferences_platform_interface/shared_preferences_async_platform_interface.dart'; import '../support/fake_http_adapter.dart'; +import '../support/fake_haptics.dart'; import '../support/fake_interaction_repositories.dart'; const _drama = Drama( @@ -66,28 +68,29 @@ void main() { expect(repository.pageCalls.last.cursor, '10'); }); - testWidgets('should_keep_input_and_show_backend_message_when_comment_is_blocked', ( - tester, - ) async { - final repository = FakeCommentRepository( - pages: [const CommentPage()], - publishError: const ApiException(400, '评论包含敏感词'), - ); + testWidgets( + 'should_keep_input_and_show_backend_message_when_comment_is_blocked', + (tester) async { + final repository = FakeCommentRepository( + pages: [const CommentPage()], + publishError: const ApiException(400, '评论包含敏感词'), + ); - await _pumpSheet(tester, repository: repository); - await tester.enterText( - find.byKey(const Key('comment-input')), - 'blocked text', - ); - await tester.tap(find.byKey(const Key('comment-post'))); - await tester.pumpAndSettle(); + await _pumpSheet(tester, repository: repository); + await tester.enterText( + find.byKey(const Key('comment-input')), + 'blocked text', + ); + await tester.tap(find.byKey(const Key('comment-post'))); + await tester.pumpAndSettle(); - expect(find.text('评论包含敏感词'), findsOneWidget); - final field = tester.widget( - find.byKey(const Key('comment-input')), - ); - expect(field.controller?.text, 'blocked text'); - }); + expect(find.text('评论包含敏感词'), findsOneWidget); + final field = tester.widget( + find.byKey(const Key('comment-input')), + ); + expect(field.controller?.text, 'blocked text'); + }, + ); testWidgets('should_show_review_badge_and_server_replaced_content', ( tester, @@ -101,8 +104,9 @@ void main() { mine: true, ), ); + final haptics = FakeHaptics(); - await _pumpSheet(tester, repository: repository); + await _pumpSheet(tester, repository: repository, haptics: haptics); await tester.enterText( find.byKey(const Key('comment-input')), 'hello badword', @@ -112,6 +116,7 @@ void main() { expect(find.text('hello ***'), findsOneWidget); expect(find.text('Under review'), findsOneWidget); + expect(haptics.lightImpacts, 1); final field = tester.widget( find.byKey(const Key('comment-input')), ); @@ -139,10 +144,7 @@ void main() { await tester.tap(find.byKey(const Key('comment-reply-10'))); await tester.pump(); expect(find.textContaining('Replying to'), findsOneWidget); - await tester.enterText( - find.byKey(const Key('comment-input')), - 'My reply', - ); + await tester.enterText(find.byKey(const Key('comment-input')), 'My reply'); await tester.tap(find.byKey(const Key('comment-post'))); await tester.pumpAndSettle(); @@ -153,9 +155,7 @@ void main() { testWidgets('should_show_error_and_retry_when_comment_page_fails', ( tester, ) async { - final repository = FakeCommentRepository( - pageError: StateError('offline'), - ); + final repository = FakeCommentRepository(pageError: StateError('offline')); await _pumpSheet(tester, repository: repository); @@ -175,16 +175,19 @@ void main() { ); final interactions = FakeInteractionRepository() ..nextLikeResult = const LikeToggleResult(liked: true, count: 7); + final haptics = FakeHaptics(); await _pumpSheet( tester, repository: repository, interactions: interactions, + haptics: haptics, ); await tester.tap(find.byKey(const Key('comment-like-10'))); await tester.pumpAndSettle(); expect(interactions.likeTargets, ['COMMENT:10']); + expect(haptics.lightImpacts, 1); expect(find.text('7'), findsOneWidget); }); @@ -199,11 +202,13 @@ void main() { ], ); final interactions = FakeInteractionRepository(); + final haptics = FakeHaptics(); await _pumpSheet( tester, repository: repository, interactions: interactions, + haptics: haptics, ); await tester.tap(find.byKey(const Key('comment-menu-10'))); await tester.pumpAndSettle(); @@ -212,9 +217,13 @@ void main() { await tester.tap(find.byKey(const Key('report-submit'))); await tester.pumpAndSettle(); - expect(interactions.reports.single.targetType, InteractionTargetType.comment); + expect( + interactions.reports.single.targetType, + InteractionTargetType.comment, + ); expect(interactions.reports.single.targetId, '10'); expect(interactions.reports.single.reasonCode, 'SPAM'); + expect(haptics.lightImpacts, 1); expect(find.text('Report submitted. Thank you.'), findsOneWidget); }); @@ -281,11 +290,7 @@ void main() { pages: [ CommentPage( comments: [ - commentFixture( - id: '10', - content: 'My comment', - mine: true, - ), + commentFixture(id: '10', content: 'My comment', mine: true), ], ), ], @@ -315,6 +320,7 @@ Future _pumpSheet( WidgetTester tester, { required FakeCommentRepository repository, FakeInteractionRepository? interactions, + FakeHaptics? haptics, }) async { final auth = await _auth(); await tester.pumpWidget( @@ -325,6 +331,7 @@ Future _pumpSheet( value: interactions ?? FakeInteractionRepository(), ), ChangeNotifierProvider.value(value: auth), + Provider.value(value: haptics ?? FakeHaptics()), ], child: MaterialApp( locale: const Locale('en'), diff --git a/test/core/haptics_scan_test.dart b/test/core/haptics_scan_test.dart new file mode 100644 index 0000000..f8a448c --- /dev/null +++ b/test/core/haptics_scan_test.dart @@ -0,0 +1,23 @@ +// Author: fruit.com.cn + +import 'dart:io'; + +import 'package:flutter_test/flutter_test.dart'; + +void main() { + test('should_keep_haptic_calls_inside_platform_wrapper', () { + final violations = []; + for (final entity in Directory('lib').listSync(recursive: true)) { + if (entity is! File || !entity.path.endsWith('.dart')) continue; + if (entity.path.endsWith('lib/core/platform/haptics.dart')) continue; + final lines = entity.readAsLinesSync(); + for (var index = 0; index < lines.length; index++) { + if (lines[index].contains('HapticFeedback.')) { + violations.add('${entity.path}:${index + 1}'); + } + } + } + + expect(violations, isEmpty, reason: violations.join('\n')); + }); +} diff --git a/test/core/haptics_test.dart b/test/core/haptics_test.dart new file mode 100644 index 0000000..f876eba --- /dev/null +++ b/test/core/haptics_test.dart @@ -0,0 +1,24 @@ +// Author: fruit.com.cn + +import 'package:flutter/services.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:fruitshorts/core/platform/haptics.dart'; + +void main() { + TestWidgetsFlutterBinding.ensureInitialized(); + + test('should_ignore_platform_errors_when_haptics_are_unavailable', () async { + const channel = SystemChannels.platform; + final messenger = + TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger; + messenger.setMockMethodCallHandler(channel, (_) async { + throw PlatformException(code: 'unavailable'); + }); + addTearDown(() => messenger.setMockMethodCallHandler(channel, null)); + + const haptics = FlutterHaptics(); + await expectLater(haptics.selectionClick(), completes); + await expectLater(haptics.lightImpact(), completes); + await expectLater(haptics.mediumImpact(), completes); + }); +} diff --git a/test/download/downloads_page_test.dart b/test/download/downloads_page_test.dart index fe64f1e..2866d09 100644 --- a/test/download/downloads_page_test.dart +++ b/test/download/downloads_page_test.dart @@ -10,6 +10,7 @@ import 'package:fruitshorts/core/data/repositories/download_repository.dart'; import 'package:fruitshorts/core/data/services/auth_controller.dart'; import 'package:fruitshorts/core/data/services/auth_session_store.dart'; import 'package:fruitshorts/core/data/services/download_controller.dart'; +import 'package:fruitshorts/core/platform/haptics.dart'; import 'package:fruitshorts/l10n/app_localizations.dart'; import 'package:fruitshorts/pages/downloads/downloads_page.dart'; import 'package:provider/provider.dart'; @@ -17,20 +18,19 @@ import 'package:shared_preferences_platform_interface/in_memory_shared_preferenc import 'package:shared_preferences_platform_interface/shared_preferences_async_platform_interface.dart'; import '../support/fake_http_adapter.dart'; +import '../support/fake_haptics.dart'; -DownloadPolicy _policy({ - bool wifiOnly = true, - String maxQuality = 'AUTO', -}) => DownloadPolicy( - maxPerDevice: 20, - licenseDays: 30, - wifiOnly: wifiOnly, - maxQuality: maxQuality, - maxStorageBytes: 0, - used: 1, - remaining: 19, - expirePolicyText: 'Licenses last 30 days', -); +DownloadPolicy _policy({bool wifiOnly = true, String maxQuality = 'AUTO'}) => + DownloadPolicy( + maxPerDevice: 20, + licenseDays: 30, + wifiOnly: wifiOnly, + maxQuality: maxQuality, + maxStorageBytes: 0, + used: 1, + remaining: 19, + expirePolicyText: 'Licenses last 30 days', + ); DownloadLicense _license(String episodeId) => DownloadLicense( licenseId: 'license-$episodeId', @@ -145,8 +145,14 @@ void main() { licenses: [_license('1')], ); final controller = DownloadController(repository); + final haptics = FakeHaptics(); - await _pumpPage(tester, auth: auth, controller: controller); + await _pumpPage( + tester, + auth: auth, + controller: controller, + haptics: haptics, + ); await tester.tap(find.byKey(const Key('download-clear'))); await tester.pumpAndSettle(); expect(repository.clearCalls, 0); @@ -155,23 +161,25 @@ void main() { await tester.pumpAndSettle(); expect(repository.clearCalls, 1); + expect(haptics.mediumImpacts, 1); expect(find.byKey(const Key('downloads-empty')), findsOneWidget); }); - testWidgets('should_render_unique_quality_options_when_policy_uses_a_preset', ( - tester, - ) async { - final auth = await _auth(signedIn: true); - final repository = FakeDownloadRepository( - policy: _policy(maxQuality: '720P'), - ); - final controller = DownloadController(repository); + testWidgets( + 'should_render_unique_quality_options_when_policy_uses_a_preset', + (tester) async { + final auth = await _auth(signedIn: true); + final repository = FakeDownloadRepository( + policy: _policy(maxQuality: '720P'), + ); + final controller = DownloadController(repository); - await _pumpPage(tester, auth: auth, controller: controller); + await _pumpPage(tester, auth: auth, controller: controller); - expect(tester.takeException(), isNull); - expect(find.byKey(const Key('download-quality')), findsOneWidget); - }); + expect(tester.takeException(), isNull); + expect(find.byKey(const Key('download-quality')), findsOneWidget); + }, + ); } Future _auth({required bool signedIn}) async { @@ -198,12 +206,14 @@ Future _pumpPage( WidgetTester tester, { required AuthController auth, required DownloadController controller, + FakeHaptics? haptics, }) async { await tester.pumpWidget( MultiProvider( providers: [ ChangeNotifierProvider.value(value: auth), ChangeNotifierProvider.value(value: controller), + Provider.value(value: haptics ?? FakeHaptics()), ], child: MaterialApp( locale: const Locale('en'), diff --git a/test/home/home_nav_ui_test.dart b/test/home/home_nav_ui_test.dart index 6a9b9f7..4843dc3 100644 --- a/test/home/home_nav_ui_test.dart +++ b/test/home/home_nav_ui_test.dart @@ -12,6 +12,7 @@ import 'package:shared_preferences_platform_interface/shared_preferences_async_p import '../support/fake_catalog.dart'; import '../support/fake_category.dart'; +import '../support/fake_haptics.dart'; import '../support/fake_interaction_repositories.dart'; import '../support/widget_player.dart'; @@ -36,7 +37,9 @@ void main() { testWidgets('should_theme_four_tabs_and_switch_selected_state_when_tapped', ( tester, ) async { - await _pumpApp(tester); + final haptics = FakeHaptics(); + await _pumpApp(tester, haptics); + haptics.reset(); for (final key in _keys) { expect(find.byKey(key), findsOneWidget); @@ -73,6 +76,10 @@ void main() { await tester.tap(find.byKey(const Key('tab-discover'))); await tester.pumpAndSettle(); + expect(haptics.selectionClicks, 1); + await tester.tap(find.byKey(const Key('tab-discover'))); + await tester.pumpAndSettle(); + expect(haptics.selectionClicks, 1); expect( find.descendant( of: find.byKey(const Key('tab-discover')), @@ -100,9 +107,24 @@ void main() { expect(find.byKey(key), findsNothing); } }); + + testWidgets('should_not_haptic_when_ordinary_list_item_is_opened', ( + tester, + ) async { + final haptics = FakeHaptics(); + await _pumpApp(tester, haptics); + await tester.tap(find.byKey(const Key('tab-my'))); + await tester.pumpAndSettle(); + haptics.reset(); + + await tester.tap(find.text('App Language')); + await tester.pumpAndSettle(); + + expect(haptics.calls, isEmpty); + }); } -Future _pumpApp(WidgetTester tester) async { +Future _pumpApp(WidgetTester tester, [FakeHaptics? haptics]) async { tester.view.physicalSize = const Size(390, 844); tester.view.devicePixelRatio = 1; addTearDown(tester.view.resetPhysicalSize); @@ -118,6 +140,7 @@ Future _pumpApp(WidgetTester tester) async { playbackRepository: FakePlaybackRepository(), commentRepository: FakeCommentRepository(), interactionRepository: FakeInteractionRepository(), + haptics: haptics ?? FakeHaptics(), ), ); await tester.pumpAndSettle(); diff --git a/test/library/favorites_page_test.dart b/test/library/favorites_page_test.dart index b49548a..8e2b0ff 100644 --- a/test/library/favorites_page_test.dart +++ b/test/library/favorites_page_test.dart @@ -9,6 +9,7 @@ import 'package:fruitshorts/core/data/repositories/favorite_repository.dart'; import 'package:fruitshorts/core/data/services/auth_controller.dart'; import 'package:fruitshorts/core/data/services/auth_session_store.dart'; import 'package:fruitshorts/core/data/services/favorite_controller.dart'; +import 'package:fruitshorts/core/platform/haptics.dart'; import 'package:fruitshorts/l10n/app_localizations.dart'; import 'package:fruitshorts/pages/favorites/favorites_page.dart'; import 'package:provider/provider.dart'; @@ -16,6 +17,7 @@ import 'package:shared_preferences_platform_interface/in_memory_shared_preferenc import 'package:shared_preferences_platform_interface/shared_preferences_async_platform_interface.dart'; import '../support/fake_http_adapter.dart'; +import '../support/fake_haptics.dart'; Drama _card(String id) => Drama( id: id, @@ -58,11 +60,13 @@ void main() { cards: [_card('signal')], )..failRemove = true; final favorites = FavoriteController(repository); + final haptics = FakeHaptics(); - await _pumpPage(tester, auth: auth, favorites: favorites); + await _pumpPage(tester, auth: auth, favorites: favorites, haptics: haptics); await tester.tap(find.byKey(const Key('favorite-remove-signal'))); await tester.pumpAndSettle(); + expect(haptics.lightImpacts, 1); expect(find.text('Drama signal'), findsOneWidget); expect( find.text('Could not update favorites. Please retry.'), @@ -134,12 +138,14 @@ Future _pumpPage( WidgetTester tester, { required AuthController auth, required FavoriteController favorites, + FakeHaptics? haptics, }) async { await tester.pumpWidget( MultiProvider( providers: [ ChangeNotifierProvider.value(value: auth), ChangeNotifierProvider.value(value: favorites), + Provider.value(value: haptics ?? FakeHaptics()), ], child: MaterialApp( locale: const Locale('en'), diff --git a/test/support/fake_haptics.dart b/test/support/fake_haptics.dart new file mode 100644 index 0000000..15314a9 --- /dev/null +++ b/test/support/fake_haptics.dart @@ -0,0 +1,36 @@ +// Author: fruit.com.cn + +import 'package:fruitshorts/core/platform/haptics.dart'; + +/// Deterministic haptics recorder for widget tests. +class FakeHaptics implements Haptics { + final List calls = []; + int selectionClicks = 0; + int lightImpacts = 0; + int mediumImpacts = 0; + + void reset() { + calls.clear(); + selectionClicks = 0; + lightImpacts = 0; + mediumImpacts = 0; + } + + @override + Future selectionClick() async { + calls.add('selection'); + selectionClicks++; + } + + @override + Future lightImpact() async { + calls.add('light'); + lightImpacts++; + } + + @override + Future mediumImpact() async { + calls.add('medium'); + mediumImpacts++; + } +} diff --git a/test/watch/watch_records_page_test.dart b/test/watch/watch_records_page_test.dart index d42ef0e..4510ff0 100644 --- a/test/watch/watch_records_page_test.dart +++ b/test/watch/watch_records_page_test.dart @@ -11,6 +11,7 @@ import 'package:fruitshorts/core/data/repositories/catalog_repository.dart'; import 'package:fruitshorts/core/data/repositories/watch_history_repository.dart'; import 'package:fruitshorts/core/data/services/auth_controller.dart'; import 'package:fruitshorts/core/data/services/auth_session_store.dart'; +import 'package:fruitshorts/core/platform/haptics.dart'; import 'package:fruitshorts/l10n/app_localizations.dart'; import 'package:fruitshorts/pages/watch_records/watch_records_page.dart'; import 'package:provider/provider.dart'; @@ -19,6 +20,7 @@ import 'package:shared_preferences_platform_interface/shared_preferences_async_p import '../support/fake_catalog.dart'; import '../support/fake_http_adapter.dart'; +import '../support/fake_haptics.dart'; void main() { setUp(() { @@ -101,12 +103,14 @@ void main() { (tester) async { final auth = await _auth(signedIn: true); final history = CountingWatchHistory([_progress('the-signal-demo')]); + final haptics = FakeHaptics(); await _pumpPage( tester, auth: auth, history: history, catalog: FakeCatalogRepository(), + haptics: haptics, ); await tester.tap(find.byKey(const Key('watch-records-clear'))); await tester.pumpAndSettle(); @@ -118,6 +122,7 @@ void main() { await tester.pumpAndSettle(); expect(history.clearCalls, 1); + expect(haptics.mediumImpacts, 1); expect(find.text('No watch history yet.'), findsOneWidget); }, ); @@ -156,6 +161,7 @@ Future _pumpPage( required AuthController auth, required WatchHistoryRepository history, required CatalogRepository catalog, + FakeHaptics? haptics, }) async { await tester.pumpWidget( MultiProvider( @@ -163,6 +169,7 @@ Future _pumpPage( ChangeNotifierProvider.value(value: auth), Provider.value(value: history), Provider.value(value: catalog), + Provider.value(value: haptics ?? FakeHaptics()), ], child: MaterialApp( locale: const Locale('en'), -- 2.54.0 From cc037a2956848128c4899df1f5092fea44d3620b Mon Sep 17 00:00:00 2001 From: Zhou Weidong <502333560@qq.com> Date: Sat, 17 Oct 2026 16:32:11 +0800 Subject: [PATCH 17/76] =?UTF-8?q?fix(ios):=20=E5=88=B7=E6=96=B0=20Flutter?= =?UTF-8?q?=20SPM=20=E5=8C=85=E5=90=8E=E5=86=8D=E5=87=86=E5=A4=87=E6=A1=86?= =?UTF-8?q?=E6=9E=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xcshareddata/xcschemes/Runner.xcscheme | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index c3fedb2..89b781b 100644 --- a/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -6,11 +6,27 @@ parallelizeBuildables = "YES" buildImplicitDependencies = "YES"> + + + + + + + + + scriptText = "#!/bin/sh set -e FLUTTER="" if [ -n "${FLUTTER_ROOT:-}" ] && [ -x "$FLUTTER_ROOT/bin/flutter" ]; then FLUTTER="$FLUTTER_ROOT/bin/flutter" elif FLUTTER="$(command -v flutter)"; then : elif [ -x "$HOME/flutter/bin/flutter" ]; then FLUTTER="$HOME/flutter/bin/flutter" elif [ -x "/opt/homebrew/bin/flutter" ]; then FLUTTER="/opt/homebrew/bin/flutter" fi if [ -z "$FLUTTER" ]; then echo "error: Flutter executable not found. Set FLUTTER_ROOT or add Flutter to PATH." >&2 exit 1 fi FLUTTER_ROOT="$(cd "$(dirname "$FLUTTER")/.." && pwd -P)" if [ -z "${SRCROOT:-}" ]; then echo "error: SRCROOT is not set; cannot locate the Flutter project." >&2 exit 1 fi cd "$SRCROOT" "$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh" prepare "> Date: Sat, 17 Oct 2026 16:41:24 +0800 Subject: [PATCH 18/76] =?UTF-8?q?fix(flutter):=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E5=AF=BC=E8=88=AA=E7=99=BD=E7=BA=BF=E4=B8=8E=E8=A7=82=E7=9C=8B?= =?UTF-8?q?=E8=AE=B0=E5=BD=95=E9=94=99=E8=AF=AF=E9=80=8F=E4=BC=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../services/watch_records_controller.dart | 25 ++++++++++++++++--- lib/core/theme/app_colors.dart | 4 +++ lib/core/theme/app_theme.dart | 4 +++ .../watch_records/watch_records_page.dart | 1 + test/home/home_nav_ui_test.dart | 2 ++ test/theme/app_theme_test.dart | 12 +++++++++ test/watch/watch_records_controller_test.dart | 16 ++++++++++++ test/watch/watch_records_page_test.dart | 24 ++++++++++++++++++ 8 files changed, 85 insertions(+), 3 deletions(-) diff --git a/lib/core/data/services/watch_records_controller.dart b/lib/core/data/services/watch_records_controller.dart index 647d7fa..f3b819b 100644 --- a/lib/core/data/services/watch_records_controller.dart +++ b/lib/core/data/services/watch_records_controller.dart @@ -5,6 +5,7 @@ import 'package:flutter/foundation.dart'; import '../models/drama.dart'; import '../models/watch_progress.dart'; import '../models/watch_record.dart'; +import '../remote/api_client.dart'; import '../repositories/catalog_repository.dart'; import '../repositories/watch_history_repository.dart'; @@ -47,8 +48,18 @@ class WatchRecordsController extends ChangeNotifier { records = _uniqueRecords(recent); _notify(); await _hydrate(records.map((record) => record.dramaId).toList()); - } catch (_) { - if (!_disposed) error = 'progressError'; + } catch (failure, stackTrace) { + debugPrint( + '[WatchRecordsController] recent failed ' + '${failure.runtimeType}: $failure', + ); + debugPrintStack( + stackTrace: stackTrace, + label: '[WatchRecordsController] recent failed', + ); + if (!_disposed) { + error = failure is ApiException ? failure.message : 'progressError'; + } } finally { if (!_disposed) { loading = false; @@ -169,7 +180,15 @@ class WatchRecordsController extends ChangeNotifier { detailFailed: false, ), ); - } catch (_) { + } catch (failure, stackTrace) { + debugPrint( + '[WatchRecordsController] detail failed dramaId=$dramaId ' + '${failure.runtimeType}: $failure', + ); + debugPrintStack( + stackTrace: stackTrace, + label: '[WatchRecordsController] detail failed dramaId=$dramaId', + ); if (_disposed) return; final current = _recordIndex(dramaId); if (current < 0) return; diff --git a/lib/core/theme/app_colors.dart b/lib/core/theme/app_colors.dart index 6f09ce2..bd9aab7 100644 --- a/lib/core/theme/app_colors.dart +++ b/lib/core/theme/app_colors.dart @@ -17,4 +17,8 @@ abstract final class AppColors { static const bar = Color(0xFF101114); static const card = Color(0xFF17191F); static const muted = Color(0xFFB7BDC9); + static const outlineDark = Color(0xFF3A3C45); + static const outlineVariantDark = Color(0xFF242329); + static const outlineLight = Color(0xFF8A8E99); + static const outlineVariantLight = Color(0xFFD6D9E2); } diff --git a/lib/core/theme/app_theme.dart b/lib/core/theme/app_theme.dart index 0de77ba..b49620b 100644 --- a/lib/core/theme/app_theme.dart +++ b/lib/core/theme/app_theme.dart @@ -41,6 +41,8 @@ abstract final class AppTheme { onSecondaryContainer: AppColors.onPrimary, surface: _darkBackground, onSurface: Colors.white, + outline: AppColors.outlineDark, + outlineVariant: AppColors.outlineVariantDark, surfaceTint: AppColors.blueSoft, inversePrimary: AppColors.blueSoft, ) @@ -55,6 +57,8 @@ abstract final class AppTheme { onSecondaryContainer: AppColors.ink, surface: _lightBackground, onSurface: AppColors.ink, + outline: AppColors.outlineLight, + outlineVariant: AppColors.outlineVariantLight, surfaceTint: AppColors.blue, inversePrimary: AppColors.blueSoft, ); diff --git a/lib/pages/watch_records/watch_records_page.dart b/lib/pages/watch_records/watch_records_page.dart index 9401963..51c9f8f 100644 --- a/lib/pages/watch_records/watch_records_page.dart +++ b/lib/pages/watch_records/watch_records_page.dart @@ -371,6 +371,7 @@ class _FailureState extends StatelessWidget { ), const SizedBox(height: 14), FilledButton( + key: const Key('watch-records-retry'), onPressed: () => unawaited(onRetry()), child: Text(l10n.retry), ), diff --git a/test/home/home_nav_ui_test.dart b/test/home/home_nav_ui_test.dart index 4843dc3..156d863 100644 --- a/test/home/home_nav_ui_test.dart +++ b/test/home/home_nav_ui_test.dart @@ -55,6 +55,8 @@ void main() { final context = tester.element(barFinder); expect(decoration.color, AppColors.bar); expect(border.top.color, Theme.of(context).colorScheme.outlineVariant); + expect(border.top.color.computeLuminance(), lessThan(0.2)); + expect(border.top.color, isNot(Colors.white)); expect( tester .widget( diff --git a/test/theme/app_theme_test.dart b/test/theme/app_theme_test.dart index bc3229b..c556b6b 100644 --- a/test/theme/app_theme_test.dart +++ b/test/theme/app_theme_test.dart @@ -40,6 +40,18 @@ void main() { } }); + test('should_define_non_white_outline_tokens_in_both_themes', () { + final light = AppTheme.light().colorScheme; + final dark = AppTheme.dark().colorScheme; + + expect(light.outline, AppColors.outlineLight); + expect(light.outlineVariant, AppColors.outlineVariantLight); + expect(dark.outline, AppColors.outlineDark); + expect(dark.outlineVariant, AppColors.outlineVariantDark); + expect(dark.outlineVariant.computeLuminance(), lessThan(0.2)); + expect(light.outlineVariant.computeLuminance(), lessThan(0.92)); + }); + testWidgets('should_expose_klein_blue_through_widget_theme', (tester) async { late ThemeData applied; await tester.pumpWidget( diff --git a/test/watch/watch_records_controller_test.dart b/test/watch/watch_records_controller_test.dart index c3d787e..2fd55b2 100644 --- a/test/watch/watch_records_controller_test.dart +++ b/test/watch/watch_records_controller_test.dart @@ -8,6 +8,7 @@ import 'package:fruitshorts/core/data/models/home_feed.dart'; import 'package:fruitshorts/core/data/models/watch_progress.dart'; import 'package:fruitshorts/core/data/repositories/catalog_repository.dart'; import 'package:fruitshorts/core/data/repositories/watch_history_repository.dart'; +import 'package:fruitshorts/core/data/remote/api_client.dart'; import 'package:fruitshorts/core/data/services/watch_records_controller.dart'; WatchProgress _progress( @@ -153,6 +154,19 @@ void main() { expect(controller.error, 'progressError'); expect(controller.records, isEmpty); }); + + test('should_preserve_backend_message_when_recent_request_fails', () async { + final history = ControlledWatchHistory([]) + ..recentError = const ApiException(100000, '账号不存在,请先注册'); + final controller = WatchRecordsController( + history: history, + catalog: ScriptedWatchCatalog(), + ); + + await controller.load(); + + expect(controller.error, '账号不存在,请先注册'); + }); } class ControlledWatchHistory implements WatchHistoryRepository { @@ -160,6 +174,7 @@ class ControlledWatchHistory implements WatchHistoryRepository { final List items; bool failRecent = false; + Object? recentError; bool failRemove = false; bool failClear = false; Completer? removeGate; @@ -178,6 +193,7 @@ class ControlledWatchHistory implements WatchHistoryRepository { @override Future> recent({int limit = 20}) async { + if (recentError != null) throw recentError!; if (failRecent) throw StateError('recent unavailable'); return items.take(limit).toList(); } diff --git a/test/watch/watch_records_page_test.dart b/test/watch/watch_records_page_test.dart index 4510ff0..37330b6 100644 --- a/test/watch/watch_records_page_test.dart +++ b/test/watch/watch_records_page_test.dart @@ -126,6 +126,23 @@ void main() { expect(find.text('No watch history yet.'), findsOneWidget); }, ); + + testWidgets('should_show_backend_message_when_recent_request_fails', ( + tester, + ) async { + final auth = await _auth(signedIn: true); + final history = _FailingRecentHistory(); + + await _pumpPage( + tester, + auth: auth, + history: history, + catalog: FakeCatalogRepository(), + ); + + expect(find.text('账号不存在,请先注册'), findsOneWidget); + expect(find.byKey(const Key('watch-records-retry')), findsOneWidget); + }); } WatchProgress _progress(String dramaId) => WatchProgress( @@ -202,6 +219,13 @@ class CountingWatchHistory extends InMemoryWatchHistoryRepository { } } +class _FailingRecentHistory extends InMemoryWatchHistoryRepository { + @override + Future> recent({int limit = 20}) async { + throw const ApiException(100000, '账号不存在,请先注册'); + } +} + class _FailingWatchCatalog implements CatalogRepository { final _delegate = FakeCatalogRepository(); -- 2.54.0 From b870956665f5268070c691533cc2a334f2aa7f59 Mon Sep 17 00:00:00 2001 From: Zhou Weidong <502333560@qq.com> Date: Sat, 17 Oct 2026 16:50:25 +0800 Subject: [PATCH 19/76] =?UTF-8?q?feat(flutter):=20=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E8=BD=AE=E6=92=AD=E8=87=AA=E5=8A=A8=E6=92=AD=E6=94=BE=E4=B8=8E?= =?UTF-8?q?=E7=AB=99=E5=86=85=E9=80=9A=E7=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/app.dart | 8 + lib/core/data/models/notice.dart | 53 +++ lib/core/data/remote/notice_api.dart | 23 ++ .../data/repositories/notice_repository.dart | 21 ++ .../data/services/notices_controller.dart | 118 +++++++ lib/core/formatting/error_text.dart | 1 + lib/core/widgets/remote_image.dart | 16 +- lib/l10n/app_en.arb | 17 + lib/l10n/app_id.arb | 17 + lib/l10n/app_localizations.dart | 42 +++ lib/l10n/app_localizations_en.dart | 23 ++ lib/l10n/app_localizations_id.dart | 23 ++ lib/l10n/app_localizations_zh.dart | 23 ++ lib/l10n/app_zh.arb | 17 + lib/pages/discover/discover_view.dart | 1 + .../discover/widgets/cover_carousel.dart | 118 ++++++- lib/pages/mine/mine_view.dart | 14 + lib/pages/notices/notices_page.dart | 308 ++++++++++++++++++ test/discover/cover_carousel_test.dart | 178 +++++++++- test/notice/notice_api_test.dart | 52 +++ test/notice/notices_controller_test.dart | 95 ++++++ test/notice/notices_entry_test.dart | 57 ++++ test/notice/notices_page_test.dart | 167 ++++++++++ test/support/fake_notice_repository.dart | 32 ++ 24 files changed, 1398 insertions(+), 26 deletions(-) create mode 100644 lib/core/data/models/notice.dart create mode 100644 lib/core/data/remote/notice_api.dart create mode 100644 lib/core/data/repositories/notice_repository.dart create mode 100644 lib/core/data/services/notices_controller.dart create mode 100644 lib/pages/notices/notices_page.dart create mode 100644 test/notice/notice_api_test.dart create mode 100644 test/notice/notices_controller_test.dart create mode 100644 test/notice/notices_entry_test.dart create mode 100644 test/notice/notices_page_test.dart create mode 100644 test/support/fake_notice_repository.dart diff --git a/lib/app.dart b/lib/app.dart index 5c292c7..da8e9be 100644 --- a/lib/app.dart +++ b/lib/app.dart @@ -14,6 +14,7 @@ import 'core/data/remote/comment_api.dart'; import 'core/data/remote/download_api.dart'; import 'core/data/remote/interaction_api.dart'; import 'core/data/remote/library_api.dart'; +import 'core/data/remote/notice_api.dart'; import 'core/data/remote/playback_api.dart'; import 'core/data/remote/watch_api.dart'; import 'core/data/repositories/catalog_repository.dart'; @@ -22,6 +23,7 @@ import 'core/data/repositories/comment_repository.dart'; import 'core/data/repositories/download_repository.dart'; import 'core/data/repositories/favorite_repository.dart'; import 'core/data/repositories/interaction_repository.dart'; +import 'core/data/repositories/notice_repository.dart'; import 'core/data/repositories/playback_repository.dart'; import 'core/data/repositories/watch_history_repository.dart'; import 'core/data/services/auth_controller.dart'; @@ -50,6 +52,7 @@ class LumaDramaApp extends StatefulWidget { this.playbackRepository, this.commentRepository, this.interactionRepository, + this.noticeRepository, this.haptics = const FlutterHaptics(), }); @@ -64,6 +67,7 @@ class LumaDramaApp extends StatefulWidget { final PlaybackRepository? playbackRepository; final CommentRepository? commentRepository; final InteractionRepository? interactionRepository; + final NoticeRepository? noticeRepository; final Haptics haptics; @override @@ -131,6 +135,9 @@ class _LumaDramaAppState extends State { widget.interactionRepository ?? HttpInteractionRepository(InteractionApi(_apiClient)); + late final NoticeRepository _noticeRepository = + widget.noticeRepository ?? HttpNoticeRepository(NoticeApi(_apiClient)); + late final InteractionController _interactionController = InteractionController(_interactionRepository); @@ -179,6 +186,7 @@ class _LumaDramaAppState extends State { Provider.value(value: _favorites), Provider.value(value: _commentRepository), Provider.value(value: _interactionRepository), + Provider.value(value: _noticeRepository), Provider.value(value: widget.haptics), ChangeNotifierProvider( create: (_) => CatalogController(_catalogRepository)..load(), diff --git a/lib/core/data/models/notice.dart b/lib/core/data/models/notice.dart new file mode 100644 index 0000000..94a7b85 --- /dev/null +++ b/lib/core/data/models/notice.dart @@ -0,0 +1,53 @@ +// Author: fruit.com.cn + +import 'json_numbers.dart'; + +/// Server notice list page. +class NoticePage { + const NoticePage({required this.total, this.notices = const []}); + + final int total; + final List notices; + + /// Parses the anonymous `/app/notices` page shell. + factory NoticePage.fromJson(Map json) { + final rawList = json['list']; + return NoticePage( + total: jsonToInt(json['total']), + notices: [ + if (rawList is List) + for (final item in rawList) + if (item is Map) AppNotice.fromJson(item), + ], + ); + } +} + +/// System notice returned by `/app/notices`. +class AppNotice { + const AppNotice({ + required this.id, + required this.title, + required this.content, + required this.type, + required this.publishAt, + this.expireAt, + }); + + final String id; + final String title; + final String content; + final String type; + final DateTime? publishAt; + final DateTime? expireAt; + + /// Parses string IDs without narrowing them through `int`. + factory AppNotice.fromJson(Map json) => AppNotice( + id: jsonToId(json['id']), + title: json['title']?.toString() ?? '', + content: json['content']?.toString() ?? '', + type: json['type']?.toString() ?? '', + publishAt: DateTime.tryParse(json['publishAt']?.toString() ?? ''), + expireAt: DateTime.tryParse(json['expireAt']?.toString() ?? ''), + ); +} diff --git a/lib/core/data/remote/notice_api.dart b/lib/core/data/remote/notice_api.dart new file mode 100644 index 0000000..36111f6 --- /dev/null +++ b/lib/core/data/remote/notice_api.dart @@ -0,0 +1,23 @@ +// Author: fruit.com.cn + +import '../models/notice.dart'; +import 'api_client.dart'; + +/// Anonymous system notice API. +class NoticeApi { + const NoticeApi(this._client); + + final ApiClient _client; + + /// Loads one page from `GET /app/notices`. + Future page({required int pageIndex, int pageSize = 20}) async { + final data = await _client.get( + '/app/notices', + query: {'pageIndex': '$pageIndex', 'pageSize': '$pageSize'}, + ); + if (data is! Map) { + return const NoticePage(total: 0); + } + return NoticePage.fromJson(data); + } +} diff --git a/lib/core/data/repositories/notice_repository.dart b/lib/core/data/repositories/notice_repository.dart new file mode 100644 index 0000000..d7d79ba --- /dev/null +++ b/lib/core/data/repositories/notice_repository.dart @@ -0,0 +1,21 @@ +// Author: fruit.com.cn + +import '../models/notice.dart'; +import '../remote/notice_api.dart'; + +/// Notice data source used by the page and controller. +abstract interface class NoticeRepository { + /// Loads one notice page. + Future page({required int pageIndex, int pageSize = 20}); +} + +/// HTTP-backed notice repository. +class HttpNoticeRepository implements NoticeRepository { + const HttpNoticeRepository(this._api); + + final NoticeApi _api; + + @override + Future page({required int pageIndex, int pageSize = 20}) => + _api.page(pageIndex: pageIndex, pageSize: pageSize); +} diff --git a/lib/core/data/services/notices_controller.dart b/lib/core/data/services/notices_controller.dart new file mode 100644 index 0000000..6bbf71e --- /dev/null +++ b/lib/core/data/services/notices_controller.dart @@ -0,0 +1,118 @@ +// Author: fruit.com.cn + +import 'package:flutter/foundation.dart'; + +import '../models/notice.dart'; +import '../remote/api_client.dart'; +import '../repositories/notice_repository.dart'; + +/// Pagination and state controller for the anonymous notices page. +class NoticesController extends ChangeNotifier { + NoticesController(this._repository, {this.pageSize = 20}); + + final NoticeRepository _repository; + final int pageSize; + final List _notices = []; + int _pageIndex = 0; + int _total = 0; + bool _disposed = false; + bool loading = false; + bool loadingMore = false; + bool refreshing = false; + String? error; + String? loadMoreError; + + /// Loaded notices in server order. + List get notices => List.unmodifiable(_notices); + + /// Whether another page is expected from the latest total. + bool get hasMore => _notices.length < _total; + + /// Loads the first page. + Future load() async { + loading = true; + error = null; + loadMoreError = null; + _notify(); + await _replaceFirstPage(); + loading = false; + _notify(); + } + + /// Refreshes from page one while keeping the current page visible. + Future refresh() async { + refreshing = true; + error = null; + loadMoreError = null; + _notify(); + await _replaceFirstPage(); + refreshing = false; + _notify(); + } + + /// Appends the next page when loaded count is below total. + Future loadMore() async { + if (loading || loadingMore || refreshing || !hasMore) return; + loadingMore = true; + loadMoreError = null; + _notify(); + try { + final page = await _repository.page( + pageIndex: _pageIndex + 1, + pageSize: pageSize, + ); + _appendUnique(page.notices); + _pageIndex++; + _total = page.total; + } catch (failure, stackTrace) { + debugPrint('[NoticesController] load more failed: $failure'); + debugPrintStack( + stackTrace: stackTrace, + label: '[NoticesController] load more failed', + ); + loadMoreError = _message(failure) ?? 'noticesLoadFailed'; + } finally { + loadingMore = false; + _notify(); + } + } + + Future _replaceFirstPage() async { + try { + final page = await _repository.page(pageIndex: 1, pageSize: pageSize); + if (_disposed) return; + _notices + ..clear() + ..addAll(page.notices); + _pageIndex = 1; + _total = page.total; + } catch (failure, stackTrace) { + debugPrint('[NoticesController] load failed: $failure'); + debugPrintStack( + stackTrace: stackTrace, + label: '[NoticesController] load failed', + ); + if (!_disposed) error = _message(failure) ?? 'noticesLoadFailed'; + } + } + + void _appendUnique(List incoming) { + final ids = _notices.map((notice) => notice.id).toSet(); + for (final notice in incoming) { + if (ids.add(notice.id)) _notices.add(notice); + } + } + + String? _message(Object failure) => + failure is ApiException ? failure.message : null; + + void _notify() { + if (!_disposed) notifyListeners(); + } + + @override + void dispose() { + _disposed = true; + super.dispose(); + } +} diff --git a/lib/core/formatting/error_text.dart b/lib/core/formatting/error_text.dart index bd6a5b7..fb5fd77 100644 --- a/lib/core/formatting/error_text.dart +++ b/lib/core/formatting/error_text.dart @@ -12,6 +12,7 @@ String errorText(AppLocalizations l10n, String? code, String fallback) { 'favoritesError' => l10n.favoritesError, 'ticketError' => l10n.playbackError, 'commentsLoadFailed' => l10n.commentsLoadFailed, + 'noticesLoadFailed' => l10n.noticesLoadFailed, final value => value, }; } diff --git a/lib/core/widgets/remote_image.dart b/lib/core/widgets/remote_image.dart index 48e0117..455a342 100644 --- a/lib/core/widgets/remote_image.dart +++ b/lib/core/widgets/remote_image.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import '../config/app_config.dart'; +import '../theme/app_colors.dart'; /// 封面图统一入口:后端给的是相对路径,这里补服务地址并处理加载失败。 class RemoteImage extends StatelessWidget { @@ -10,12 +11,16 @@ class RemoteImage extends StatelessWidget { this.width, this.height, this.fit = BoxFit.cover, + this.showFallbackIcon = false, + this.fallbackIconKey, }); final String path; final double? width; final double? height; final BoxFit fit; + final bool showFallbackIcon; + final Key? fallbackIconKey; @override Widget build(BuildContext context) { @@ -38,7 +43,16 @@ class RemoteImage extends StatelessWidget { return Container( width: width, height: height, - color: const Color(0xFF1C1F26), + color: AppColors.bar, + alignment: Alignment.center, + child: showFallbackIcon + ? Icon( + Icons.image_not_supported_outlined, + key: fallbackIconKey, + color: AppColors.muted, + size: 32, + ) + : null, ); } } diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index 6cd002e..9a6edc7 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -185,6 +185,23 @@ "detailError": "The episode list could not be loaded.", "noMediaNotice": "This episode has no playable media yet.", "noStories": "No stories available yet.", + "notices": "Notices", + "noNotices": "No notices yet.", + "noticesLoadFailed": "Notices could not be loaded.", + "noticeDetails": "Notice details", + "noticeAnnouncement": "Notice", + "close": "Close", + "carouselSemantics": "Banner {current} of {total}", + "@carouselSemantics": { + "placeholders": { + "current": { + "type": "int" + }, + "total": { + "type": "int" + } + } + }, "retry": "Retry", "backToSeries": "Back to series", "nextEpisode": "Next episode", diff --git a/lib/l10n/app_id.arb b/lib/l10n/app_id.arb index 973c95c..cd96703 100644 --- a/lib/l10n/app_id.arb +++ b/lib/l10n/app_id.arb @@ -185,6 +185,23 @@ "detailError": "Daftar episode gagal dimuat.", "noMediaNotice": "Episode ini belum punya media yang bisa diputar.", "noStories": "Belum ada cerita.", + "notices": "Notifikasi", + "noNotices": "Belum ada notifikasi.", + "noticesLoadFailed": "Notifikasi tidak dapat dimuat.", + "noticeDetails": "Detail notifikasi", + "noticeAnnouncement": "Pengumuman", + "close": "Tutup", + "carouselSemantics": "Banner {current} dari {total}", + "@carouselSemantics": { + "placeholders": { + "current": { + "type": "int" + }, + "total": { + "type": "int" + } + } + }, "retry": "Coba lagi", "backToSeries": "Kembali ke serial", "nextEpisode": "Episode berikutnya", diff --git a/lib/l10n/app_localizations.dart b/lib/l10n/app_localizations.dart index 1eeb935..6f86913 100644 --- a/lib/l10n/app_localizations.dart +++ b/lib/l10n/app_localizations.dart @@ -826,6 +826,48 @@ abstract class AppLocalizations { /// **'No stories available yet.'** String get noStories; + /// No description provided for @notices. + /// + /// In en, this message translates to: + /// **'Notices'** + String get notices; + + /// No description provided for @noNotices. + /// + /// In en, this message translates to: + /// **'No notices yet.'** + String get noNotices; + + /// No description provided for @noticesLoadFailed. + /// + /// In en, this message translates to: + /// **'Notices could not be loaded.'** + String get noticesLoadFailed; + + /// No description provided for @noticeDetails. + /// + /// In en, this message translates to: + /// **'Notice details'** + String get noticeDetails; + + /// No description provided for @noticeAnnouncement. + /// + /// In en, this message translates to: + /// **'Notice'** + String get noticeAnnouncement; + + /// No description provided for @close. + /// + /// In en, this message translates to: + /// **'Close'** + String get close; + + /// No description provided for @carouselSemantics. + /// + /// In en, this message translates to: + /// **'Banner {current} of {total}'** + String carouselSemantics(int current, int total); + /// No description provided for @retry. /// /// In en, this message translates to: diff --git a/lib/l10n/app_localizations_en.dart b/lib/l10n/app_localizations_en.dart index 7e7d988..d8ec4d3 100644 --- a/lib/l10n/app_localizations_en.dart +++ b/lib/l10n/app_localizations_en.dart @@ -395,6 +395,29 @@ class AppLocalizationsEn extends AppLocalizations { @override String get noStories => 'No stories available yet.'; + @override + String get notices => 'Notices'; + + @override + String get noNotices => 'No notices yet.'; + + @override + String get noticesLoadFailed => 'Notices could not be loaded.'; + + @override + String get noticeDetails => 'Notice details'; + + @override + String get noticeAnnouncement => 'Notice'; + + @override + String get close => 'Close'; + + @override + String carouselSemantics(int current, int total) { + return 'Banner $current of $total'; + } + @override String get retry => 'Retry'; diff --git a/lib/l10n/app_localizations_id.dart b/lib/l10n/app_localizations_id.dart index 821b0ba..3d53a5e 100644 --- a/lib/l10n/app_localizations_id.dart +++ b/lib/l10n/app_localizations_id.dart @@ -397,6 +397,29 @@ class AppLocalizationsId extends AppLocalizations { @override String get noStories => 'Belum ada cerita.'; + @override + String get notices => 'Notifikasi'; + + @override + String get noNotices => 'Belum ada notifikasi.'; + + @override + String get noticesLoadFailed => 'Notifikasi tidak dapat dimuat.'; + + @override + String get noticeDetails => 'Detail notifikasi'; + + @override + String get noticeAnnouncement => 'Pengumuman'; + + @override + String get close => 'Tutup'; + + @override + String carouselSemantics(int current, int total) { + return 'Banner $current dari $total'; + } + @override String get retry => 'Coba lagi'; diff --git a/lib/l10n/app_localizations_zh.dart b/lib/l10n/app_localizations_zh.dart index 034f260..ca93d04 100644 --- a/lib/l10n/app_localizations_zh.dart +++ b/lib/l10n/app_localizations_zh.dart @@ -389,6 +389,29 @@ class AppLocalizationsZh extends AppLocalizations { @override String get noStories => '暂无剧目。'; + @override + String get notices => '通知'; + + @override + String get noNotices => '暂无通知。'; + + @override + String get noticesLoadFailed => '通知加载失败,请重试。'; + + @override + String get noticeDetails => '通知详情'; + + @override + String get noticeAnnouncement => '公告'; + + @override + String get close => '关闭'; + + @override + String carouselSemantics(int current, int total) { + return '第 $current 张,共 $total 张'; + } + @override String get retry => '重试'; diff --git a/lib/l10n/app_zh.arb b/lib/l10n/app_zh.arb index a2b0cba..e942dac 100644 --- a/lib/l10n/app_zh.arb +++ b/lib/l10n/app_zh.arb @@ -147,6 +147,23 @@ "detailError": "剧集信息加载失败。", "noMediaNotice": "该剧集还没有可播放的片源。", "noStories": "暂无剧目。", + "notices": "通知", + "noNotices": "暂无通知。", + "noticesLoadFailed": "通知加载失败,请重试。", + "noticeDetails": "通知详情", + "noticeAnnouncement": "公告", + "close": "关闭", + "carouselSemantics": "第 {current} 张,共 {total} 张", + "@carouselSemantics": { + "placeholders": { + "current": { + "type": "int" + }, + "total": { + "type": "int" + } + } + }, "retry": "重试", "backToSeries": "返回剧集详情", "nextEpisode": "下一集", diff --git a/lib/pages/discover/discover_view.dart b/lib/pages/discover/discover_view.dart index 965001d..4787d6d 100644 --- a/lib/pages/discover/discover_view.dart +++ b/lib/pages/discover/discover_view.dart @@ -198,6 +198,7 @@ class _DiscoverPageState extends State { .toList(); if (items.isEmpty) return const SizedBox.shrink(); return CoverCarousel( + active: widget.active, items: [ for (final banner in items) CoverItem( diff --git a/lib/pages/discover/widgets/cover_carousel.dart b/lib/pages/discover/widgets/cover_carousel.dart index cd53152..0fdb0b1 100644 --- a/lib/pages/discover/widgets/cover_carousel.dart +++ b/lib/pages/discover/widgets/cover_carousel.dart @@ -1,7 +1,12 @@ +import 'dart:async'; import 'dart:math' as math; import 'package:flutter/material.dart'; +import '../../../core/theme/app_colors.dart'; import '../../../core/widgets/remote_image.dart'; +import '../../../l10n/app_localizations.dart'; + +const Duration _autoPlayInterval = Duration(milliseconds: 4500); class CoverItem { const CoverItem({ @@ -19,9 +24,10 @@ class CoverItem { /// Full-bleed posters that turn as faces of a cube. Titles sit on the image. class CoverCarousel extends StatefulWidget { - const CoverCarousel({super.key, required this.items}); + const CoverCarousel({super.key, required this.items, this.active = true}); final List items; + final bool active; @override State createState() => _CoverCarouselState(); @@ -36,6 +42,8 @@ class _CoverCarouselState extends State int? _pointer; double _drag = 0; double _dragPage = 0; + Timer? _autoTimer; + bool _tickerEnabled = true; @override void initState() { @@ -45,34 +53,93 @@ class _CoverCarouselState extends State @override void dispose() { + _autoTimer?.cancel(); _snap.dispose(); super.dispose(); } + @override + void didChangeDependencies() { + super.didChangeDependencies(); + final enabled = TickerMode.valuesOf(context).enabled; + if (enabled != _tickerEnabled) { + _tickerEnabled = enabled; + _syncAutoTimer(); + } else if (_autoTimer == null) { + _syncAutoTimer(); + } + } + + @override + void didUpdateWidget(covariant CoverCarousel oldWidget) { + super.didUpdateWidget(oldWidget); + if (_page > _last) _page = _last; + if (oldWidget.items.length != widget.items.length || + oldWidget.active != widget.active) { + _syncAutoTimer(); + } + } + double get _last => math.max(0, widget.items.length - 1).toDouble(); void _onSnap() { + if (!mounted) return; final t = Curves.easeOutCubic.transform(_snap.value); setState(() => _page = _from + (_to - _from) * t); } void _turnTo(double target) { + if (!mounted || widget.items.isEmpty) return; _from = _page; _to = target.clamp(0, _last); _snap.duration = const Duration(milliseconds: 420); _snap.forward(from: 0); } + void _syncAutoTimer() { + _autoTimer?.cancel(); + _autoTimer = null; + if (!mounted || + !widget.active || + !_tickerEnabled || + widget.items.length <= 1) { + return; + } + _autoTimer = Timer.periodic(_autoPlayInterval, (_) { + if (!mounted || _pointer != null || !widget.active || !_tickerEnabled) { + return; + } + final current = _page.round().clamp(0, _last.toInt()); + if (current >= _last.toInt()) { + setState(() => _page = 0); + } else { + _turnTo((current + 1).toDouble()); + } + }); + } + @override Widget build(BuildContext context) { + if (widget.items.isEmpty) return const SizedBox.shrink(); + final current = _page.round().clamp(0, widget.items.length - 1); + final l10n = AppLocalizations.of(context)!; return LayoutBuilder( builder: (context, constraints) { final width = constraints.maxWidth; final height = math.min(width * 0.52, 210).toDouble(); - return SizedBox( - width: double.infinity, - height: height, - child: _stage(width), + return Semantics( + container: true, + label: l10n.carouselSemantics(current + 1, widget.items.length), + child: SizedBox( + width: double.infinity, + height: height, + child: Stack( + children: [ + Positioned.fill(child: _stage(width)), + _indicator(l10n, current), + ], + ), + ), ); }, ); @@ -82,6 +149,8 @@ class _CoverCarouselState extends State return Listener( behavior: HitTestBehavior.opaque, onPointerDown: (event) { + _autoTimer?.cancel(); + _autoTimer = null; _snap.stop(); _pointer = event.pointer; _drag = 0; @@ -98,11 +167,13 @@ class _CoverCarouselState extends State if (event.pointer != _pointer) return; _pointer = null; _turnTo(_page.roundToDouble()); + _syncAutoTimer(); }, onPointerCancel: (event) { if (event.pointer != _pointer) return; _pointer = null; _turnTo(_page.roundToDouble()); + _syncAutoTimer(); }, child: ClipRect( child: Stack( @@ -113,6 +184,35 @@ class _CoverCarouselState extends State ); } + Widget _indicator(AppLocalizations l10n, int current) { + return Positioned( + left: 0, + right: 0, + bottom: 8, + child: Semantics( + label: l10n.carouselSemantics(current + 1, widget.items.length), + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + for (var index = 0; index < widget.items.length; index++) + Container( + key: Key('carousel-dot-$index'), + width: 6, + height: 6, + margin: const EdgeInsets.symmetric(horizontal: 3), + decoration: BoxDecoration( + shape: BoxShape.circle, + color: index == current + ? AppColors.onPrimary + : AppColors.muted.withValues(alpha: 0.4), + ), + ), + ], + ), + ), + ); + } + List get _visible { final first = _page.floor(); final indexes = [first, first + 1]; @@ -154,7 +254,11 @@ class _CoverCarouselState extends State return Stack( fit: StackFit.expand, children: [ - RemoteImage(item.image), + RemoteImage( + item.image, + showFallbackIcon: true, + fallbackIconKey: const Key('carousel-image-fallback'), + ), const DecoratedBox( decoration: BoxDecoration( gradient: LinearGradient( @@ -168,7 +272,7 @@ class _CoverCarouselState extends State Positioned( left: 20, right: 20, - bottom: 22, + bottom: 30, child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ diff --git a/lib/pages/mine/mine_view.dart b/lib/pages/mine/mine_view.dart index b2d425e..c88d785 100644 --- a/lib/pages/mine/mine_view.dart +++ b/lib/pages/mine/mine_view.dart @@ -20,6 +20,7 @@ import 'mine_binding.dart'; import 'mine_logic.dart'; import '../watch_records/watch_records_page.dart'; import '../favorites/favorites_page.dart'; +import '../notices/notices_page.dart'; import '../downloads/downloads_page.dart'; class MyPage extends StatefulWidget { @@ -413,6 +414,19 @@ class _MyPageState extends State { onTap: () => _mockSnack(l10n), ), const Divider(height: 1, color: Color(0xFF2A2C33)), + ListTile( + key: const Key('mine-notices'), + leading: const Icon( + Icons.notifications_none_rounded, + color: AppColors.blueSoft, + ), + title: Text(l10n.notices), + trailing: const Icon(Icons.chevron_right_rounded), + onTap: () => Navigator.of(context).push( + MaterialPageRoute(builder: (_) => const NoticesPage()), + ), + ), + const Divider(height: 1, color: Color(0xFF2A2C33)), ListTile( leading: const Icon( Icons.history_rounded, diff --git a/lib/pages/notices/notices_page.dart b/lib/pages/notices/notices_page.dart new file mode 100644 index 0000000..e46ba02 --- /dev/null +++ b/lib/pages/notices/notices_page.dart @@ -0,0 +1,308 @@ +// Author: fruit.com.cn + +import 'dart:async'; + +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; + +import '../../core/data/models/notice.dart'; +import '../../core/data/repositories/notice_repository.dart'; +import '../../core/data/services/notices_controller.dart'; +import '../../core/formatting/error_text.dart'; +import '../../core/formatting/localized_date_time.dart'; +import '../../core/theme/app_colors.dart'; +import '../../core/theme/app_theme.dart'; +import '../../l10n/app_localizations.dart'; + +/// Anonymous system notice list with pagination and detail dialog. +class NoticesPage extends StatefulWidget { + const NoticesPage({super.key}); + + @override + State createState() => _NoticesPageState(); +} + +class _NoticesPageState extends State { + late final NoticesController _controller; + + @override + void initState() { + super.initState(); + _controller = NoticesController(context.read()); + unawaited(_controller.load()); + } + + @override + void dispose() { + _controller.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + final l10n = AppLocalizations.of(context)!; + return Theme( + data: AppTheme.dark(), + child: Scaffold( + key: const Key('notices-page'), + backgroundColor: AppColors.ink, + appBar: AppBar( + backgroundColor: AppColors.ink, + foregroundColor: AppColors.onPrimary, + title: Text(l10n.notices), + ), + body: ListenableBuilder( + listenable: _controller, + builder: (context, _) => _body(l10n), + ), + ), + ); + } + + Widget _body(AppLocalizations l10n) { + if (_controller.loading && _controller.notices.isEmpty) { + return const Center( + child: CircularProgressIndicator(key: Key('notices-loading')), + ); + } + if (_controller.error != null && _controller.notices.isEmpty) { + return RefreshIndicator( + onRefresh: _controller.refresh, + child: ListView( + physics: const AlwaysScrollableScrollPhysics(), + children: [ + SizedBox( + height: MediaQuery.sizeOf(context).height * 0.7, + child: Center( + key: const Key('notices-error'), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Text( + errorText( + l10n, + _controller.error, + l10n.noticesLoadFailed, + ), + textAlign: TextAlign.center, + style: const TextStyle(color: AppColors.muted), + ), + const SizedBox(height: 12), + FilledButton( + key: const Key('notices-retry'), + onPressed: _controller.load, + child: Text(l10n.retry), + ), + ], + ), + ), + ), + ], + ), + ); + } + if (_controller.notices.isEmpty) { + return RefreshIndicator( + onRefresh: _controller.refresh, + child: ListView( + physics: const AlwaysScrollableScrollPhysics(), + children: [ + SizedBox( + height: MediaQuery.sizeOf(context).height * 0.7, + child: Center( + key: const Key('notices-empty'), + child: Text( + l10n.noNotices, + style: const TextStyle(color: AppColors.muted), + ), + ), + ), + ], + ), + ); + } + return RefreshIndicator( + onRefresh: _controller.refresh, + child: ListView.separated( + key: const Key('notices-list'), + physics: const AlwaysScrollableScrollPhysics(), + padding: const EdgeInsets.fromLTRB(16, 12, 16, 28), + itemCount: _controller.notices.length + 1, + separatorBuilder: (_, _) => const SizedBox(height: 10), + itemBuilder: (context, index) { + if (index == _controller.notices.length) return _footer(l10n); + final notice = _controller.notices[index]; + return _NoticeTile( + notice: notice, + onTap: () => _showDetails(notice, l10n), + ); + }, + ), + ); + } + + Widget _footer(AppLocalizations l10n) { + if (_controller.loadingMore) { + return const Padding( + padding: EdgeInsets.symmetric(vertical: 12), + child: Center(child: CircularProgressIndicator()), + ); + } + if (_controller.loadMoreError != null) { + return TextButton.icon( + onPressed: _controller.loadMore, + icon: const Icon(Icons.refresh_rounded), + label: Text(l10n.retry), + ); + } + if (_controller.hasMore) { + return TextButton( + key: const Key('notices-load-more'), + onPressed: _controller.loadMore, + child: Text(l10n.loadMore), + ); + } + return const SizedBox(height: 8); + } + + Future _showDetails(AppNotice notice, AppLocalizations l10n) { + final publishAt = notice.publishAt == null + ? '' + : formatLocalizedDateTime(context, notice.publishAt!); + return showDialog( + context: context, + builder: (dialogContext) => AlertDialog( + title: Text(notice.title), + content: SizedBox( + width: double.maxFinite, + child: SingleChildScrollView( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + if (publishAt.isNotEmpty) ...[ + Text( + publishAt, + style: const TextStyle( + color: AppColors.muted, + fontSize: 12, + ), + ), + const SizedBox(height: 10), + ], + SelectableText( + notice.content, + key: const Key('notice-detail-content'), + ), + ], + ), + ), + ), + actions: [ + TextButton( + key: const Key('notice-detail-close'), + onPressed: () => Navigator.of(dialogContext).pop(), + child: Text(l10n.close), + ), + ], + ), + ); + } +} + +class _NoticeTile extends StatelessWidget { + const _NoticeTile({required this.notice, required this.onTap}); + + final AppNotice notice; + final VoidCallback onTap; + + @override + Widget build(BuildContext context) { + final l10n = AppLocalizations.of(context)!; + final publishAt = notice.publishAt == null + ? '' + : formatLocalizedDateTime(context, notice.publishAt!); + final type = notice.type.isEmpty ? l10n.noticeAnnouncement : notice.type; + return Material( + key: ValueKey('notice-item-${notice.id}'), + color: AppColors.card, + borderRadius: BorderRadius.circular(12), + clipBehavior: Clip.antiAlias, + child: InkWell( + onTap: onTap, + child: Padding( + padding: const EdgeInsets.all(14), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + children: [ + Flexible( + child: Container( + padding: const EdgeInsets.symmetric( + horizontal: 8, + vertical: 3, + ), + decoration: BoxDecoration( + color: AppColors.bluePressed, + borderRadius: BorderRadius.circular(10), + ), + child: Text( + type, + maxLines: 1, + overflow: TextOverflow.ellipsis, + style: const TextStyle( + color: AppColors.onPrimary, + fontSize: 11, + ), + ), + ), + ), + if (publishAt.isNotEmpty) + Flexible( + child: Padding( + padding: const EdgeInsets.only(left: 8), + child: Text( + publishAt, + maxLines: 1, + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.right, + style: const TextStyle( + color: AppColors.muted, + fontSize: 11, + ), + ), + ), + ), + ], + ), + const SizedBox(height: 9), + Text( + notice.title, + maxLines: 2, + overflow: TextOverflow.ellipsis, + style: const TextStyle( + color: AppColors.onPrimary, + fontSize: 16, + fontWeight: FontWeight.w700, + ), + ), + if (notice.content.isNotEmpty) ...[ + const SizedBox(height: 6), + Text( + notice.content, + maxLines: 2, + overflow: TextOverflow.ellipsis, + style: const TextStyle( + color: AppColors.muted, + fontSize: 13, + height: 1.35, + ), + ), + ], + ], + ), + ), + ), + ); + } +} diff --git a/test/discover/cover_carousel_test.dart b/test/discover/cover_carousel_test.dart index 7d298d2..75040b6 100644 --- a/test/discover/cover_carousel_test.dart +++ b/test/discover/cover_carousel_test.dart @@ -1,25 +1,36 @@ import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; +import 'package:fruitshorts/l10n/app_localizations.dart'; import 'package:fruitshorts/pages/discover/widgets/cover_carousel.dart'; void main() { TestWidgetsFlutterBinding.ensureInitialized(); - testWidgets('should_turn_cube_and_keep_title_on_poster_when_carousel_pages', (tester) async { + List items(int count) => [ + for (var index = 0; index < count; index++) + CoverItem( + title: 'Banner $index', + subtitle: 'Subtitle $index', + image: '/files/banner-$index.png', + onOpen: _noop, + ), + ]; + + testWidgets('should_turn_cube_and_keep_title_on_poster_when_carousel_pages', ( + tester, + ) async { await tester.pumpWidget( - MaterialApp( - home: Scaffold( - body: CoverCarousel( - items: [ - for (final title in ['The Signal', 'City Lights', 'Vengeance']) - CoverItem( - title: title, - subtitle: 'Mock', - image: '/files/poster.png', - onOpen: _noop, - ), - ], - ), + _localizedApp( + CoverCarousel( + items: [ + for (final title in ['The Signal', 'City Lights', 'Vengeance']) + CoverItem( + title: title, + subtitle: 'Mock', + image: '/files/poster.png', + onOpen: _noop, + ), + ], ), ), ); @@ -29,13 +40,15 @@ void main() { expect(find.text('Mock'), findsOneWidget); final box = tester.getRect(find.byType(CoverCarousel)); - final gesture = await tester.startGesture(Offset(box.right - 40, box.center.dy)); + final gesture = await tester.startGesture( + Offset(box.right - 40, box.center.dy), + ); await gesture.moveBy(const Offset(-500, 0)); await tester.pump(); - final turned = tester.widgetList(find.byType(Transform)).any( - (transform) => (transform.transform.entry(0, 0) - 1).abs() > 0.15, - ); + final turned = tester + .widgetList(find.byType(Transform)) + .any((transform) => (transform.transform.entry(0, 0) - 1).abs() > 0.15); expect(turned, isTrue); await gesture.moveBy(const Offset(-200, 0)); @@ -46,6 +59,135 @@ void main() { expect(find.text('City Lights'), findsOneWidget); expect(tester.takeException(), isNull); }); + + testWidgets('should_auto_advance_and_show_dots_when_multiple_items_exist', ( + tester, + ) async { + await tester.pumpWidget(_localizedApp(CoverCarousel(items: items(3)))); + await tester.pump(); + + expect(find.text('Banner 0'), findsOneWidget); + expect(find.byKey(const Key('carousel-dot-0')), findsOneWidget); + expect(find.byKey(const Key('carousel-dot-1')), findsOneWidget); + expect(find.byKey(const Key('carousel-dot-2')), findsOneWidget); + + await tester.pump(const Duration(milliseconds: 4500)); + await tester.pump(const Duration(milliseconds: 500)); + + expect(find.text('Banner 1'), findsOneWidget); + await tester.pumpWidget(const SizedBox.shrink()); + }); + + testWidgets('should_not_schedule_auto_advance_when_only_one_item_exists', ( + tester, + ) async { + await tester.pumpWidget(_localizedApp(CoverCarousel(items: items(1)))); + await tester.pump(const Duration(seconds: 12)); + + expect(find.text('Banner 0'), findsOneWidget); + expect(find.byKey(const Key('carousel-dot-0')), findsOneWidget); + expect(find.byKey(const Key('carousel-dot-1')), findsNothing); + }); + + testWidgets('should_pause_auto_advance_while_pointer_is_down', ( + tester, + ) async { + await tester.pumpWidget(_localizedApp(CoverCarousel(items: items(3)))); + await tester.pump(); + final box = tester.getRect(find.byType(CoverCarousel)); + final gesture = await tester.startGesture(box.center); + await tester.pump(const Duration(seconds: 6)); + + expect(find.text('Banner 0'), findsOneWidget); + + await gesture.up(); + await tester.pump(); + await tester.pump(const Duration(milliseconds: 4500)); + await tester.pump(const Duration(milliseconds: 500)); + + expect(find.text('Banner 1'), findsOneWidget); + await tester.pumpWidget(const SizedBox.shrink()); + }); + + testWidgets('should_pause_when_inactive_and_resume_when_active_again', ( + tester, + ) async { + final active = ValueNotifier(false); + await tester.pumpWidget( + _localizedApp( + ValueListenableBuilder( + valueListenable: active, + builder: (context, enabled, _) => + CoverCarousel(items: items(2), active: enabled), + ), + ), + ); + await tester.pump(const Duration(seconds: 6)); + expect(find.text('Banner 0'), findsOneWidget); + + active.value = true; + await tester.pump(); + await tester.pump(const Duration(milliseconds: 4500)); + await tester.pump(const Duration(milliseconds: 500)); + expect(find.text('Banner 1'), findsOneWidget); + await tester.pumpWidget(const SizedBox.shrink()); + }); + + testWidgets('should_show_icon_fallback_when_banner_image_is_empty', ( + tester, + ) async { + await tester.pumpWidget( + _localizedApp( + CoverCarousel( + items: const [ + CoverItem( + title: 'Broken image', + subtitle: '', + image: '', + onOpen: _noop, + ), + ], + ), + ), + ); + await tester.pump(); + + expect(find.byKey(const Key('carousel-image-fallback')), findsOneWidget); + }); + + testWidgets( + 'should_keep_existing_open_callback_when_active_poster_is_tapped', + (tester) async { + var opened = 0; + await tester.pumpWidget( + _localizedApp( + CoverCarousel( + items: [ + CoverItem( + title: 'Tap me', + subtitle: '', + image: '/files/banner.png', + onOpen: () => opened++, + ), + ...items(1), + ], + ), + ), + ); + await tester.pump(); + + await tester.tap(find.text('Tap me')); + expect(opened, 1); + await tester.pumpWidget(const SizedBox.shrink()); + }, + ); } void _noop() {} + +Widget _localizedApp(Widget child) => MaterialApp( + locale: const Locale('en'), + localizationsDelegates: AppLocalizations.localizationsDelegates, + supportedLocales: AppLocalizations.supportedLocales, + home: Scaffold(body: child), +); diff --git a/test/notice/notice_api_test.dart b/test/notice/notice_api_test.dart new file mode 100644 index 0000000..81f336d --- /dev/null +++ b/test/notice/notice_api_test.dart @@ -0,0 +1,52 @@ +// Author: fruit.com.cn + +import 'dart:convert'; + +import 'package:flutter_test/flutter_test.dart'; +import 'package:fruitshorts/core/data/remote/api_client.dart'; +import 'package:fruitshorts/core/data/remote/notice_api.dart'; + +import '../support/fake_http_adapter.dart'; + +void main() { + test('should_parse_notice_page_with_string_ids_when_requested', () async { + final adapter = FakeHttpAdapter( + (_) async => FakeHttpResponse( + jsonEncode({ + 'code': 0, + 'message': 'ok', + 'data': { + 'total': '3', + 'list': [ + { + 'id': '2111012753262120962', + 'title': 'Maintenance', + 'content': 'Line one\nLine two', + 'type': 'SYSTEM', + 'publishAt': '2026-10-17T12:30:00', + 'expireAt': null, + }, + ], + }, + }), + ), + ); + final api = NoticeApi( + ApiClient(baseUrl: 'http://127.0.0.1:8081', adapter: adapter), + ); + + final page = await api.page(pageIndex: 2, pageSize: 20); + + expect(adapter.requests.single.uri.path, '/app/notices'); + expect(adapter.requests.single.queryParameters, { + 'pageIndex': '2', + 'pageSize': '20', + }); + expect(page.total, 3); + expect(page.notices.single.id, '2111012753262120962'); + expect(page.notices.single.content, 'Line one\nLine two'); + expect(page.notices.single.type, 'SYSTEM'); + expect(page.notices.single.publishAt, DateTime(2026, 10, 17, 12, 30)); + expect(page.notices.single.expireAt, isNull); + }); +} diff --git a/test/notice/notices_controller_test.dart b/test/notice/notices_controller_test.dart new file mode 100644 index 0000000..bd28557 --- /dev/null +++ b/test/notice/notices_controller_test.dart @@ -0,0 +1,95 @@ +// Author: fruit.com.cn + +import 'package:flutter_test/flutter_test.dart'; +import 'package:fruitshorts/core/data/models/notice.dart'; +import 'package:fruitshorts/core/data/remote/api_client.dart'; +import 'package:fruitshorts/core/data/repositories/notice_repository.dart'; +import 'package:fruitshorts/core/data/services/notices_controller.dart'; + +void main() { + test('should_append_next_page_until_loaded_count_reaches_total', () async { + final repository = ScriptedNoticeRepository([ + NoticePage(total: 3, notices: [_notice('1'), _notice('2')]), + NoticePage(total: 3, notices: [_notice('3')]), + ]); + final controller = NoticesController(repository); + + await controller.load(); + expect(controller.notices.map((item) => item.id), ['1', '2']); + expect(controller.hasMore, isTrue); + + await controller.loadMore(); + expect(controller.notices.map((item) => item.id), ['1', '2', '3']); + expect(controller.hasMore, isFalse); + expect(repository.calls.map((call) => call.pageIndex), [1, 2]); + }); + + test('should_show_empty_state_when_total_is_zero', () async { + final controller = NoticesController( + ScriptedNoticeRepository([const NoticePage(total: 0)]), + ); + + await controller.load(); + + expect(controller.loading, isFalse); + expect(controller.notices, isEmpty); + expect(controller.hasMore, isFalse); + expect(controller.error, isNull); + }); + + test('should_preserve_backend_message_when_page_load_fails', () async { + final repository = ScriptedNoticeRepository([]) + ..error = const ApiException(500, '公告服务暂不可用'); + final controller = NoticesController(repository); + + await controller.load(); + + expect(controller.error, '公告服务暂不可用'); + expect(controller.notices, isEmpty); + }); + + test('should_replace_list_when_refreshed', () async { + final repository = ScriptedNoticeRepository([ + NoticePage(total: 2, notices: [_notice('1'), _notice('2')]), + NoticePage(total: 1, notices: [_notice('9')]), + ]); + final controller = NoticesController(repository); + await controller.load(); + + await controller.refresh(); + + expect(controller.notices.map((item) => item.id), ['9']); + expect(controller.hasMore, isFalse); + }); +} + +AppNotice _notice(String id) => AppNotice( + id: id, + title: 'Notice $id', + content: 'Content $id', + type: 'SYSTEM', + publishAt: DateTime(2026, 10, 17, 12), +); + +class ScriptedNoticeRepository implements NoticeRepository { + ScriptedNoticeRepository(this.pages); + + final List pages; + final List calls = []; + Object? error; + + @override + Future page({required int pageIndex, int pageSize = 20}) async { + calls.add(NoticePageCall(pageIndex: pageIndex, pageSize: pageSize)); + if (error != null) throw error!; + if (pages.isEmpty) return const NoticePage(total: 0); + return pages.removeAt(0); + } +} + +class NoticePageCall { + const NoticePageCall({required this.pageIndex, required this.pageSize}); + + final int pageIndex; + final int pageSize; +} diff --git a/test/notice/notices_entry_test.dart b/test/notice/notices_entry_test.dart new file mode 100644 index 0000000..db6d08b --- /dev/null +++ b/test/notice/notices_entry_test.dart @@ -0,0 +1,57 @@ +// Author: fruit.com.cn + +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:fruitshorts/app.dart'; +import 'package:fruitshorts/core/data/models/notice.dart'; +import 'package:fruitshorts/core/data/repositories/favorite_repository.dart'; +import 'package:fruitshorts/core/data/repositories/playback_repository.dart'; +import 'package:fruitshorts/core/data/repositories/watch_history_repository.dart'; +import 'package:shared_preferences_platform_interface/in_memory_shared_preferences_async.dart'; +import 'package:shared_preferences_platform_interface/shared_preferences_async_platform_interface.dart'; + +import '../support/fake_catalog.dart'; +import '../support/fake_category.dart'; +import '../support/fake_interaction_repositories.dart'; +import '../support/fake_notice_repository.dart'; +import '../support/widget_player.dart'; + +void main() { + testWidgets('should_open_notices_from_mine_menu_without_login_gate', ( + tester, + ) async { + SharedPreferencesAsyncPlatform.instance = + InMemorySharedPreferencesAsync.empty(); + tester.view.physicalSize = const Size(390, 844); + tester.view.devicePixelRatio = 1; + addTearDown(tester.view.resetPhysicalSize); + addTearDown(tester.view.resetDevicePixelRatio); + final catalog = FakeCatalogRepository(); + + await tester.pumpWidget( + LumaDramaApp( + playerFactory: createWidgetPlayer, + catalogRepository: catalog, + categoryRepository: FakeCategoryRepository(catalog: catalog), + watchHistoryRepository: InMemoryWatchHistoryRepository(), + favoriteRepository: InMemoryFavoriteRepository(), + playbackRepository: FakePlaybackRepository(), + commentRepository: FakeCommentRepository(), + interactionRepository: FakeInteractionRepository(), + noticeRepository: FakeNoticeRepository( + pages: [const NoticePage(total: 0)], + ), + ), + ); + await tester.pumpAndSettle(); + await tester.tap(find.byKey(const Key('tab-my'))); + await tester.pumpAndSettle(); + + expect(find.byKey(const Key('mine-notices')), findsOneWidget); + await tester.tap(find.byKey(const Key('mine-notices'))); + await tester.pumpAndSettle(); + + expect(find.byKey(const Key('notices-page')), findsOneWidget); + expect(find.byKey(const Key('auth-gate-panel')), findsNothing); + }); +} diff --git a/test/notice/notices_page_test.dart b/test/notice/notices_page_test.dart new file mode 100644 index 0000000..7252b2e --- /dev/null +++ b/test/notice/notices_page_test.dart @@ -0,0 +1,167 @@ +// Author: fruit.com.cn + +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:fruitshorts/core/data/models/notice.dart'; +import 'package:fruitshorts/core/data/remote/api_client.dart'; +import 'package:fruitshorts/core/data/repositories/notice_repository.dart'; +import 'package:fruitshorts/core/formatting/localized_date_time.dart'; +import 'package:fruitshorts/l10n/app_localizations.dart'; +import 'package:fruitshorts/pages/notices/notices_page.dart'; +import 'package:provider/provider.dart'; + +import '../support/fake_notice_repository.dart'; + +void main() { + testWidgets('should_render_first_page_and_append_next_page', (tester) async { + final repository = FakeNoticeRepository( + pages: [ + NoticePage(total: 3, notices: [_notice('1'), _notice('2')]), + NoticePage(total: 3, notices: [_notice('3')]), + ], + ); + await _pump(tester, repository); + + expect(find.text('Notice 1'), findsOneWidget); + expect(find.byKey(const Key('notices-load-more')), findsOneWidget); + + await tester.tap(find.byKey(const Key('notices-load-more'))); + await tester.pumpAndSettle(); + + expect(find.text('Notice 3'), findsOneWidget); + expect(repository.calls.last.pageIndex, 2); + }); + + testWidgets('should_show_empty_state_when_no_notices_exist', (tester) async { + await _pump( + tester, + FakeNoticeRepository(pages: [const NoticePage(total: 0)]), + ); + + expect(find.byKey(const Key('notices-empty')), findsOneWidget); + }); + + testWidgets('should_show_backend_error_and_retry_when_page_fails', ( + tester, + ) async { + await _pump( + tester, + FakeNoticeRepository(error: const ApiException(500, '公告加载失败')), + ); + + expect(find.text('公告加载失败'), findsOneWidget); + expect(find.byKey(const Key('notices-retry')), findsOneWidget); + }); + + testWidgets('should_show_loading_state_before_first_page_arrives', ( + tester, + ) async { + final repository = FakeNoticeRepository( + pages: [const NoticePage(total: 0)], + delay: const Duration(milliseconds: 50), + ); + await tester.pumpWidget(_app(repository)); + await tester.pump(); + + expect(find.byKey(const Key('notices-loading')), findsOneWidget); + await tester.pumpAndSettle(); + }); + + testWidgets('should_open_detail_with_newlines_and_indonesian_time', ( + tester, + ) async { + final notice = _notice( + '2111012753262120962', + content: 'Line one\nLine two', + ); + await _pump( + tester, + FakeNoticeRepository( + pages: [ + NoticePage(total: 1, notices: [notice]), + ], + ), + ); + + await tester.tap( + find.byKey(const ValueKey('notice-item-2111012753262120962')), + ); + await tester.pumpAndSettle(); + + expect(find.byKey(const Key('notice-detail-close')), findsOneWidget); + expect( + tester + .widget( + find.byKey(const Key('notice-detail-content')), + ) + .data, + 'Line one\nLine two', + ); + final context = tester.element( + find.byKey(const Key('notice-detail-content')), + ); + final expected = formatLocalizedDateTime(context, notice.publishAt!); + expect( + find.descendant( + of: find.byType(AlertDialog), + matching: find.text(expected), + ), + findsOneWidget, + ); + }); + + testWidgets('should_scroll_long_detail_without_overflow_on_small_screen', ( + tester, + ) async { + tester.view.physicalSize = const Size(320, 568); + tester.view.devicePixelRatio = 1; + addTearDown(tester.view.resetPhysicalSize); + addTearDown(tester.view.resetDevicePixelRatio); + final notice = _notice( + '1', + title: 'A very long notice title that wraps across several lines', + content: List.filled(40, 'Long notice content line.').join('\n'), + ); + await _pump( + tester, + FakeNoticeRepository( + pages: [ + NoticePage(total: 1, notices: [notice]), + ], + ), + ); + + await tester.tap(find.byKey(const ValueKey('notice-item-1'))); + await tester.pumpAndSettle(); + + expect(find.byKey(const Key('notice-detail-content')), findsOneWidget); + expect(tester.takeException(), isNull); + }); +} + +AppNotice _notice( + String id, { + String? title, + String content = 'Notice content', +}) => AppNotice( + id: id, + title: title ?? 'Notice $id', + content: content, + type: 'SYSTEM', + publishAt: DateTime(2026, 10, 17, 12, 30), +); + +Future _pump(WidgetTester tester, NoticeRepository repository) async { + await tester.pumpWidget(_app(repository)); + await tester.pumpAndSettle(); +} + +Widget _app(NoticeRepository repository) => Provider.value( + value: repository, + child: MaterialApp( + locale: const Locale('id'), + localizationsDelegates: AppLocalizations.localizationsDelegates, + supportedLocales: AppLocalizations.supportedLocales, + home: const NoticesPage(), + ), +); diff --git a/test/support/fake_notice_repository.dart b/test/support/fake_notice_repository.dart new file mode 100644 index 0000000..ad18585 --- /dev/null +++ b/test/support/fake_notice_repository.dart @@ -0,0 +1,32 @@ +// Author: fruit.com.cn + +import 'package:fruitshorts/core/data/models/notice.dart'; +import 'package:fruitshorts/core/data/repositories/notice_repository.dart'; + +/// Scripted notice repository for controller and widget tests. +class FakeNoticeRepository implements NoticeRepository { + FakeNoticeRepository({List? pages, this.error, this.delay}) + : pages = pages ?? []; + + final List pages; + Object? error; + Duration? delay; + final List calls = []; + + @override + Future page({required int pageIndex, int pageSize = 20}) async { + calls.add(FakeNoticeCall(pageIndex: pageIndex, pageSize: pageSize)); + if (delay != null) await Future.delayed(delay!); + if (error != null) throw error!; + if (pages.isEmpty) return const NoticePage(total: 0); + return pages.removeAt(0); + } +} + +/// Captured notice page request. +class FakeNoticeCall { + const FakeNoticeCall({required this.pageIndex, required this.pageSize}); + + final int pageIndex; + final int pageSize; +} -- 2.54.0 From 5058853af3ee0ebe24026f7e683f2b3b091ec98d Mon Sep 17 00:00:00 2001 From: Zhou Weidong <502333560@qq.com> Date: Sat, 17 Oct 2026 16:59:59 +0800 Subject: [PATCH 20/76] =?UTF-8?q?fix(flutter):=20=E6=B3=A8=E5=86=8C?= =?UTF-8?q?=E7=9B=AE=E5=BD=95=E4=BB=93=E5=BA=93=E5=B9=B6=E4=BF=AE=E6=AD=A3?= =?UTF-8?q?=E9=A6=96=E9=A1=B5=E8=BD=AE=E6=92=AD=E6=95=B0=E6=8D=AE=E6=BA=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/app.dart | 1 + lib/pages/discover/discover_view.dart | 4 +- test/discover/home_banner_source_test.dart | 100 ++++++++++++++++++++ test/watch/watch_history_provider_test.dart | 52 ++++++++++ 4 files changed, 156 insertions(+), 1 deletion(-) create mode 100644 test/discover/home_banner_source_test.dart create mode 100644 test/watch/watch_history_provider_test.dart diff --git a/lib/app.dart b/lib/app.dart index da8e9be..f9cacaa 100644 --- a/lib/app.dart +++ b/lib/app.dart @@ -181,6 +181,7 @@ class _LumaDramaAppState extends State { providers: [ Provider(create: (_) => PlaybackCoordinator()), Provider(create: (_) => widget.playerFactory), + Provider.value(value: _catalogRepository), Provider.value(value: _playback), Provider.value(value: _watchHistory), Provider.value(value: _favorites), diff --git a/lib/pages/discover/discover_view.dart b/lib/pages/discover/discover_view.dart index 4787d6d..ccb7005 100644 --- a/lib/pages/discover/discover_view.dart +++ b/lib/pages/discover/discover_view.dart @@ -7,6 +7,7 @@ import 'package:provider/provider.dart'; import '../../core/data/models/drama.dart'; import '../../core/data/models/home_feed.dart'; import '../../core/data/repositories/watch_history_repository.dart'; +import '../../core/data/services/catalog_controller.dart'; import '../../core/data/services/category_controller.dart'; import '../../core/theme/app_colors.dart'; import '../../core/theme/app_theme.dart'; @@ -98,6 +99,7 @@ class _DiscoverPageState extends State { Widget _page(BuildContext context) { final l10n = AppLocalizations.of(context)!; final categories = context.watch(); + final homeBanners = context.watch().feed.banners; final allDramas = [...?widget.dramas, ...categories.visibleDramas]; final cards = _cardsFor(categories.visibleDramas, ''); final content = SafeArea( @@ -114,7 +116,7 @@ class _DiscoverPageState extends State { padding: const EdgeInsets.fromLTRB(16, 4, 16, 0), child: ClipRRect( borderRadius: BorderRadius.circular(18), - child: _carousel(l10n, categories.feed.banners, allDramas), + child: _carousel(l10n, homeBanners, allDramas), ), ), Padding( diff --git a/test/discover/home_banner_source_test.dart b/test/discover/home_banner_source_test.dart new file mode 100644 index 0000000..1e4edeb --- /dev/null +++ b/test/discover/home_banner_source_test.dart @@ -0,0 +1,100 @@ +// Author: fruit.com.cn + +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:fruitshorts/app.dart'; +import 'package:fruitshorts/core/data/models/drama.dart'; +import 'package:fruitshorts/core/data/models/home_feed.dart'; +import 'package:fruitshorts/core/data/repositories/catalog_repository.dart'; +import 'package:fruitshorts/core/data/repositories/favorite_repository.dart'; +import 'package:fruitshorts/core/data/repositories/playback_repository.dart'; +import 'package:fruitshorts/core/data/repositories/watch_history_repository.dart'; +import 'package:fruitshorts/pages/discover/widgets/cover_carousel.dart'; +import 'package:shared_preferences_platform_interface/in_memory_shared_preferences_async.dart'; +import 'package:shared_preferences_platform_interface/shared_preferences_async_platform_interface.dart'; + +import '../support/fake_catalog.dart'; +import '../support/fake_category.dart'; +import '../support/fake_interaction_repositories.dart'; +import '../support/fake_notice_repository.dart'; +import '../support/widget_player.dart'; + +void main() { + testWidgets( + 'should_render_home_feed_banners_when_discover_banners_are_empty', + (tester) async { + SharedPreferencesAsyncPlatform.instance = + InMemorySharedPreferencesAsync.empty(); + final catalog = _HomeBannerCatalogRepository(); + await tester.pumpWidget( + LumaDramaApp( + playerFactory: createWidgetPlayer, + catalogRepository: catalog, + categoryRepository: FakeCategoryRepository(catalog: catalog), + watchHistoryRepository: InMemoryWatchHistoryRepository(), + favoriteRepository: InMemoryFavoriteRepository(), + playbackRepository: FakePlaybackRepository(), + commentRepository: FakeCommentRepository(), + interactionRepository: FakeInteractionRepository(), + noticeRepository: FakeNoticeRepository(), + ), + ); + await tester.pumpAndSettle(); + await tester.tap(find.byKey(const Key('tab-discover'))); + await tester.pumpAndSettle(); + + expect(find.byType(CoverCarousel), findsOneWidget); + expect(find.byKey(const Key('carousel-dot-0')), findsOneWidget); + expect(find.byKey(const Key('carousel-dot-1')), findsOneWidget); + expect( + find.descendant( + of: find.byType(CoverCarousel), + matching: find.text('The Signal'), + ), + findsOneWidget, + ); + + await tester.pump(const Duration(milliseconds: 4500)); + await tester.pump(const Duration(milliseconds: 500)); + expect( + find.descendant( + of: find.byType(CoverCarousel), + matching: find.text('City Lights & Velvet Nights'), + ), + findsOneWidget, + ); + await tester.pumpWidget(const SizedBox.shrink()); + }, + ); +} + +class _HomeBannerCatalogRepository implements CatalogRepository { + final _delegate = FakeCatalogRepository(); + + @override + Future fetchHomeFeed() async => HomeFeed( + banners: const [ + FeedBanner( + id: 'banner-1', + imageUrl: '/files/banner-1.png', + linkType: 'DRAMA', + linkValue: 'the-signal-demo', + ), + FeedBanner( + id: 'banner-2', + imageUrl: '/files/banner-2.png', + linkType: 'DRAMA', + linkValue: 'city-lights-demo', + ), + ], + sections: [FeedSection(code: 'hot', title: 'Hot', dramas: demoDramas)], + ); + + @override + Future fetchDiscoverFeed() async => HomeFeed( + sections: [FeedSection(code: 'hot', title: 'Hot', dramas: demoDramas)], + ); + + @override + Future fetchDrama(String dramaId) => _delegate.fetchDrama(dramaId); +} diff --git a/test/watch/watch_history_provider_test.dart b/test/watch/watch_history_provider_test.dart new file mode 100644 index 0000000..932728f --- /dev/null +++ b/test/watch/watch_history_provider_test.dart @@ -0,0 +1,52 @@ +// Author: fruit.com.cn + +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:fruitshorts/app.dart'; +import 'package:fruitshorts/core/data/repositories/favorite_repository.dart'; +import 'package:fruitshorts/core/data/repositories/playback_repository.dart'; +import 'package:fruitshorts/core/data/repositories/watch_history_repository.dart'; +import 'package:shared_preferences_platform_interface/in_memory_shared_preferences_async.dart'; +import 'package:shared_preferences_platform_interface/shared_preferences_async_platform_interface.dart'; + +import '../support/fake_catalog.dart'; +import '../support/fake_category.dart'; +import '../support/fake_interaction_repositories.dart'; +import '../support/fake_notice_repository.dart'; +import '../support/widget_player.dart'; + +void main() { + testWidgets('should_open_watch_history_with_catalog_provider_registered', ( + tester, + ) async { + SharedPreferencesAsyncPlatform.instance = + InMemorySharedPreferencesAsync.withData({ + 'auth.accessToken': 'test-access', + 'auth.refreshToken': 'test-refresh', + 'auth.user': '{"uid":"1","nickname":"Viewer","avatarUrl":""}', + }); + final catalog = FakeCatalogRepository(); + await tester.pumpWidget( + LumaDramaApp( + playerFactory: createWidgetPlayer, + catalogRepository: catalog, + categoryRepository: FakeCategoryRepository(catalog: catalog), + watchHistoryRepository: InMemoryWatchHistoryRepository(), + favoriteRepository: InMemoryFavoriteRepository(), + playbackRepository: FakePlaybackRepository(), + commentRepository: FakeCommentRepository(), + interactionRepository: FakeInteractionRepository(), + noticeRepository: FakeNoticeRepository(), + ), + ); + await tester.pumpAndSettle(); + await tester.tap(find.byKey(const Key('tab-my'))); + await tester.pumpAndSettle(); + await tester.tap(find.text('Watch History')); + await tester.pumpAndSettle(); + + expect(tester.takeException(), isNull); + expect(find.byKey(const Key('watch-records-page')), findsOneWidget); + expect(find.text('No watch history yet.'), findsOneWidget); + }); +} -- 2.54.0 From 45c3c645ffc59e980925e2e8f02f142367bd8f24 Mon Sep 17 00:00:00 2001 From: Zhou Weidong <502333560@qq.com> Date: Sat, 17 Oct 2026 17:14:56 +0800 Subject: [PATCH 21/76] =?UTF-8?q?feat(flutter):=20=E9=87=8D=E8=AE=BE?= =?UTF-8?q?=E8=AE=A1=E7=99=BB=E5=BD=95=E9=A1=B5=E8=A7=86=E8=A7=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/pages/auth/auth_form_widgets.dart | 363 ++++++++++++++++++++++++++ lib/pages/auth/auth_view.dart | 361 ++++++++++--------------- lib/pages/auth/auth_widgets.dart | 183 +++++++++++++ test/auth/auth_visual_test.dart | 311 ++++++++++++++++++++++ 4 files changed, 989 insertions(+), 229 deletions(-) create mode 100644 lib/pages/auth/auth_form_widgets.dart create mode 100644 lib/pages/auth/auth_widgets.dart create mode 100644 test/auth/auth_visual_test.dart diff --git a/lib/pages/auth/auth_form_widgets.dart b/lib/pages/auth/auth_form_widgets.dart new file mode 100644 index 0000000..90cc3c7 --- /dev/null +++ b/lib/pages/auth/auth_form_widgets.dart @@ -0,0 +1,363 @@ +// Author: fruit.com.cn + +part of 'auth_view.dart'; + +class _AuthFields extends StatelessWidget { + const _AuthFields({required this.state, required this.callbacks}); + + final _AuthCardState state; + final _AuthCardCallbacks callbacks; + + @override + Widget build(BuildContext context) { + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + _fieldLabel(state.l10n.authEmailLabel), + const SizedBox(height: 8), + _emailField(), + const SizedBox(height: 16), + _fieldLabel(state.l10n.authPasswordLabel), + const SizedBox(height: 8), + _passwordField(), + ], + ); + } + + Widget _emailField() { + final enabled = !state.status.busy; + return ListenableBuilder( + listenable: state.fields.emailFocus, + builder: (context, _) => SizedBox( + height: _fieldHeight, + child: TextField( + key: const Key('auth-email'), + controller: state.fields.email, + focusNode: state.fields.emailFocus, + enabled: enabled, + autofocus: true, + keyboardType: TextInputType.emailAddress, + textInputAction: TextInputAction.next, + autofillHints: const [AutofillHints.email], + onChanged: callbacks.onEmailChanged, + onSubmitted: (_) => state.fields.passwordFocus.requestFocus(), + style: const TextStyle(color: AppColors.onPrimary, fontSize: 15), + decoration: _decoration( + hint: 'name@example.com', + icon: Icons.mail_outline_rounded, + focused: state.fields.emailFocus.hasFocus, + ), + ), + ), + ); + } + + Widget _passwordField() { + final enabled = !state.status.busy; + final l10n = state.l10n; + return ListenableBuilder( + listenable: state.fields.passwordFocus, + builder: (context, _) => SizedBox( + height: _fieldHeight, + child: TextField( + key: const Key('auth-password'), + controller: state.fields.password, + focusNode: state.fields.passwordFocus, + enabled: enabled, + obscureText: state.status.obscurePassword, + keyboardType: TextInputType.visiblePassword, + textInputAction: TextInputAction.done, + autofillHints: const [AutofillHints.password], + onChanged: callbacks.onPasswordChanged, + onSubmitted: (_) => callbacks.onSubmit(), + style: const TextStyle(color: AppColors.onPrimary, fontSize: 15), + decoration: _decoration( + hint: l10n.authPasswordHint, + icon: Icons.lock_outline_rounded, + focused: state.fields.passwordFocus.hasFocus, + suffix: IconButton( + key: const Key('auth-password-visibility'), + constraints: const BoxConstraints.tightFor( + width: _minTapTarget, + height: _minTapTarget, + ), + tooltip: state.status.obscurePassword + ? l10n.showPassword + : l10n.hidePassword, + onPressed: enabled ? callbacks.onTogglePasswordVisibility : null, + icon: Icon( + state.status.obscurePassword + ? Icons.visibility_outlined + : Icons.visibility_off_outlined, + color: AppColors.muted, + ), + ), + ), + ), + ), + ); + } + + Widget _fieldLabel(String label) => Text( + label, + style: const TextStyle( + color: AppColors.muted, + fontSize: 13, + fontWeight: FontWeight.w600, + ), + ); + + InputDecoration _decoration({ + required String hint, + required IconData icon, + required bool focused, + Widget? suffix, + }) { + final border = OutlineInputBorder( + borderRadius: BorderRadius.circular(_fieldRadius), + borderSide: BorderSide.none, + ); + return InputDecoration( + hintText: hint, + hintStyle: const TextStyle(color: AppColors.muted, fontSize: 14), + prefixIcon: Icon( + icon, + size: 21, + color: focused ? AppColors.blueSoft : AppColors.muted, + ), + prefixIconConstraints: const BoxConstraints( + minWidth: _minTapTarget, + minHeight: _minTapTarget, + ), + suffixIcon: suffix, + filled: true, + fillColor: AppColors.bar, + isDense: true, + contentPadding: const EdgeInsets.only(right: 16), + border: border, + enabledBorder: border, + disabledBorder: border, + focusedBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(_fieldRadius), + borderSide: const BorderSide( + color: AppColors.blue, + width: _fieldBorderWidth, + ), + ), + ); + } +} + +class _AuthSubmitButton extends StatelessWidget { + const _AuthSubmitButton({required this.state, required this.onSubmit}); + + final _AuthCardState state; + final VoidCallback onSubmit; + + @override + Widget build(BuildContext context) { + final status = state.status; + final l10n = state.l10n; + return SizedBox( + width: double.infinity, + height: _buttonHeight, + child: FilledButton( + key: const Key('auth-submit'), + onPressed: status.busy ? null : onSubmit, + style: ButtonStyle( + backgroundColor: WidgetStateProperty.resolveWith((states) { + if (states.contains(WidgetState.disabled)) { + return AppColors.blue.withValues(alpha: 0.5); + } + if (states.contains(WidgetState.pressed)) { + return AppColors.bluePressed; + } + return AppColors.blue; + }), + foregroundColor: const WidgetStatePropertyAll(AppColors.onPrimary), + elevation: const WidgetStatePropertyAll(0), + padding: const WidgetStatePropertyAll(EdgeInsets.zero), + shape: WidgetStatePropertyAll( + RoundedRectangleBorder( + borderRadius: BorderRadius.circular(_buttonRadius), + ), + ), + ), + child: status.busy + ? const SizedBox.square( + dimension: 18, + child: CircularProgressIndicator( + strokeWidth: 2, + color: AppColors.onPrimary, + ), + ) + : Text( + status.signUpMode ? l10n.signUp : l10n.signIn, + style: const TextStyle( + fontSize: 16, + fontWeight: FontWeight.w700, + ), + ), + ), + ); + } +} + +class _ModeSegment extends StatelessWidget { + const _ModeSegment({ + required this.segmentKey, + required this.label, + required this.hiddenLabel, + required this.selected, + required this.onTap, + }); + + final Key segmentKey; + final String label; + final String hiddenLabel; + final bool selected; + final VoidCallback? onTap; + + @override + Widget build(BuildContext context) { + return GestureDetector( + key: segmentKey, + behavior: HitTestBehavior.opaque, + onTap: onTap, + child: AnimatedContainer( + duration: _segmentDuration, + alignment: Alignment.center, + decoration: BoxDecoration( + color: selected ? AppColors.blue : Colors.transparent, + borderRadius: BorderRadius.circular(18), + ), + child: Stack( + fit: StackFit.expand, + children: [ + Center( + child: Text( + label, + style: TextStyle( + color: selected ? AppColors.onPrimary : AppColors.muted, + fontSize: 14, + fontWeight: FontWeight.w700, + ), + ), + ), + Positioned.fill( + child: ExcludeSemantics( + child: Opacity( + opacity: 0, + child: Center( + child: Text( + hiddenLabel, + maxLines: 1, + softWrap: false, + style: const TextStyle(fontSize: 14), + ), + ), + ), + ), + ), + ], + ), + ), + ); + } +} + +class _AuthBrand extends StatelessWidget { + const _AuthBrand({required this.tagline}); + + final String tagline; + + @override + Widget build(BuildContext context) { + return Row( + key: const Key('auth-brand'), + children: [ + Container( + key: const Key('auth-brand-mark'), + width: _brandMarkSize, + height: _brandMarkSize, + decoration: BoxDecoration( + color: AppColors.blue, + borderRadius: BorderRadius.circular(14), + boxShadow: [ + BoxShadow( + color: AppColors.blue.withValues(alpha: 0.32), + blurRadius: 24, + offset: const Offset(0, 10), + ), + ], + ), + child: const Icon( + Icons.movie_filter_rounded, + color: AppColors.onPrimary, + size: 26, + ), + ), + const SizedBox(width: 14), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + AppLocalizations.of(context)!.appName, + style: const TextStyle( + color: AppColors.onPrimary, + fontSize: 23, + fontWeight: FontWeight.w800, + height: 1.1, + ), + ), + const SizedBox(height: 4), + Text( + tagline, + style: const TextStyle( + color: AppColors.blueSoft, + fontSize: 13, + height: 1.35, + ), + ), + ], + ), + ), + ], + ); + } +} + +class _AuthError extends StatelessWidget { + const _AuthError({required this.message}); + + final String message; + + @override + Widget build(BuildContext context) { + final color = Theme.of(context).colorScheme.error; + return Container( + key: const Key('auth-error-capsule'), + padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 10), + decoration: BoxDecoration( + color: color.withValues(alpha: _errorOpacity), + borderRadius: BorderRadius.circular(12), + border: Border.all(color: color.withValues(alpha: _errorBorderOpacity)), + ), + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Icon(Icons.error_outline_rounded, color: color, size: 18), + const SizedBox(width: 8), + Expanded( + child: Text( + message, + key: const Key('auth-error'), + style: TextStyle(color: color, fontSize: 13, height: 1.35), + ), + ), + ], + ), + ); + } +} diff --git a/lib/pages/auth/auth_view.dart b/lib/pages/auth/auth_view.dart index af6bdc2..58b886d 100644 --- a/lib/pages/auth/auth_view.dart +++ b/lib/pages/auth/auth_view.dart @@ -13,7 +13,26 @@ import '../../core/theme/app_theme.dart'; import '../../l10n/app_localizations.dart'; import 'auth_logic.dart'; +part 'auth_widgets.dart'; +part 'auth_form_widgets.dart'; + const double _minTapTarget = 44; +const double _brandMarkSize = 48; +const double _contentMaxWidth = 440; +const double _cardRadius = 20; +const double _cardPadding = 20; +const double _cardBorderWidth = 1; +const double _fieldHeight = 52; +const double _fieldRadius = 14; +const double _fieldBorderWidth = 1.5; +const double _buttonHeight = 52; +const double _buttonRadius = 26; +const double _glowOpacity = 0.18; +const double _errorOpacity = 0.10; +const double _errorBorderOpacity = 0.28; +const double _enterSlideDistance = 16; +const Duration _enterDuration = Duration(milliseconds: 220); +const Duration _segmentDuration = Duration(milliseconds: 160); /// 登录 / 注册页:邮箱 + 密码。 class AuthPage extends StatefulWidget { @@ -112,245 +131,129 @@ class _AuthPageState extends State { child: Scaffold( resizeToAvoidBottomInset: true, backgroundColor: AppColors.ink, - appBar: AppBar( - backgroundColor: AppColors.ink, - elevation: 0, - foregroundColor: AppColors.onPrimary, - title: Text(_logic.signUpMode ? l10n.signUp : l10n.signIn), - ), - body: SafeArea( - child: AutofillGroup( - child: ListView( - key: const Key('auth-scroll'), - keyboardDismissBehavior: ScrollViewKeyboardDismissBehavior.onDrag, - padding: EdgeInsets.fromLTRB( - 20, - 12, - 20, - 28 + MediaQuery.viewInsetsOf(context).bottom, - ), - children: [ - _AuthBrand(tagline: l10n.authBrandTagline), - const SizedBox(height: 26), - Text( - _logic.signUpMode - ? l10n.authSignUpTitle - : l10n.authSignInTitle, - style: const TextStyle( - color: AppColors.onPrimary, - fontSize: 24, - fontWeight: FontWeight.w800, + body: Stack( + children: [ + Positioned( + top: 0, + left: 0, + right: 0, + height: 420, + child: IgnorePointer( + child: Container( + key: const Key('auth-background-glow'), + decoration: BoxDecoration( + gradient: LinearGradient( + begin: Alignment.topCenter, + end: Alignment.bottomCenter, + colors: [ + AppColors.blue.withValues(alpha: _glowOpacity), + AppColors.blue.withValues(alpha: 0.05), + AppColors.ink.withValues(alpha: 0), + ], + stops: const [0, 0.55, 1], + ), ), ), - const SizedBox(height: 6), - Text( - l10n.authSubtitle, - style: const TextStyle(color: AppColors.muted, fontSize: 13), - ), - const SizedBox(height: 22), - _emailField(l10n), - const SizedBox(height: 14), - _passwordField(l10n), - if (_logic.errorMessage != null) ...[ - const SizedBox(height: 12), - _AuthError(message: _logic.errorMessage!), - ], - const SizedBox(height: 22), - _submitButton(l10n), - const SizedBox(height: 10), - _switchModeButton(l10n), - ], - ), - ), - ), - ), - ); - } - - Widget _emailField(AppLocalizations l10n) => _field( - child: TextField( - key: const Key('auth-email'), - controller: _emailController, - focusNode: _emailFocus, - enabled: !_logic.busy, - autofocus: true, - keyboardType: TextInputType.emailAddress, - textInputAction: TextInputAction.next, - autofillHints: const [AutofillHints.email], - onChanged: (value) => _logic.email = value, - onSubmitted: (_) => _passwordFocus.requestFocus(), - style: const TextStyle(color: AppColors.onPrimary, fontSize: 15), - decoration: _decoration(l10n.authEmailLabel, 'name@example.com'), - ), - ); - - Widget _passwordField(AppLocalizations l10n) => _field( - child: TextField( - key: const Key('auth-password'), - controller: _passwordController, - focusNode: _passwordFocus, - enabled: !_logic.busy, - obscureText: _obscurePassword, - keyboardType: TextInputType.visiblePassword, - textInputAction: TextInputAction.done, - autofillHints: const [AutofillHints.password], - onChanged: (value) => _logic.password = value, - onSubmitted: (_) => _submit(), - style: const TextStyle(color: AppColors.onPrimary, fontSize: 15), - decoration: _decoration( - l10n.authPasswordLabel, - l10n.authPasswordHint, - suffix: IconButton( - key: const Key('auth-password-visibility'), - constraints: const BoxConstraints.tightFor( - width: _minTapTarget, - height: _minTapTarget, - ), - tooltip: _obscurePassword ? l10n.showPassword : l10n.hidePassword, - onPressed: _logic.busy - ? null - : () => setState(() => _obscurePassword = !_obscurePassword), - icon: Icon( - _obscurePassword - ? Icons.visibility_outlined - : Icons.visibility_off_outlined, - color: AppColors.muted, - ), - ), - ), - ), - ); - - Widget _field({required Widget child}) => - Column(crossAxisAlignment: CrossAxisAlignment.start, children: [child]); - - InputDecoration _decoration(String label, String hint, {Widget? suffix}) { - final scheme = Theme.of(context).colorScheme; - return InputDecoration( - labelText: label, - hintText: hint, - hintStyle: TextStyle(color: scheme.onSurfaceVariant, fontSize: 14), - suffixIcon: suffix, - filled: true, - fillColor: AppColors.card, - contentPadding: const EdgeInsets.symmetric(horizontal: 16, vertical: 17), - border: OutlineInputBorder( - borderRadius: BorderRadius.circular(12), - borderSide: BorderSide.none, - ), - focusedBorder: OutlineInputBorder( - borderRadius: BorderRadius.circular(12), - borderSide: BorderSide(color: scheme.primary, width: 1.5), - ), - ); - } - - Widget _submitButton(AppLocalizations l10n) => SizedBox( - height: 50, - child: FilledButton( - key: const Key('auth-submit'), - onPressed: _logic.busy ? null : _submit, - style: FilledButton.styleFrom( - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(25)), - ), - child: _logic.busy - ? const SizedBox.square( - dimension: 18, - child: CircularProgressIndicator( - strokeWidth: 2, - color: AppColors.onPrimary, ), - ) - : Text( - _logic.signUpMode ? l10n.signUp : l10n.signIn, - style: const TextStyle(fontSize: 15, fontWeight: FontWeight.w700), ), - ), - ); - - Widget _switchModeButton(AppLocalizations l10n) => TextButton( - key: const Key('auth-switch-mode'), - style: TextButton.styleFrom( - minimumSize: const Size(0, _minTapTarget), - foregroundColor: AppColors.blueSoft, - ), - onPressed: _logic.busy ? null : () => setState(() => _logic.toggleMode()), - child: Text( - _logic.signUpMode ? l10n.authSwitchToSignIn : l10n.authSwitchToSignUp, - style: const TextStyle(fontSize: 13), - ), - ); -} - -class _AuthBrand extends StatelessWidget { - const _AuthBrand({required this.tagline}); - - final String tagline; - - @override - Widget build(BuildContext context) { - return Row( - children: [ - Container( - width: 48, - height: 48, - decoration: const BoxDecoration( - color: AppColors.blue, - shape: BoxShape.circle, - ), - child: const Icon( - Icons.play_arrow_rounded, - color: AppColors.onPrimary, - size: 30, - ), - ), - const SizedBox(width: 12), - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - AppLocalizations.of(context)!.appName, - style: const TextStyle( - color: AppColors.onPrimary, - fontSize: 20, - fontWeight: FontWeight.w800, + SafeArea( + child: AutofillGroup( + child: ListView( + key: const Key('auth-scroll'), + keyboardDismissBehavior: + ScrollViewKeyboardDismissBehavior.onDrag, + padding: EdgeInsets.fromLTRB( + 20, + 12, + 20, + 28 + MediaQuery.viewInsetsOf(context).bottom, + ), + children: [ + Center( + child: ConstrainedBox( + constraints: const BoxConstraints( + maxWidth: _contentMaxWidth, + ), + child: TweenAnimationBuilder( + key: const Key('auth-enter-animation'), + tween: Tween(begin: 0, end: 1), + duration: _enterDuration, + curve: Curves.easeOutCubic, + builder: (context, value, child) => Opacity( + opacity: value, + child: Transform.translate( + offset: Offset( + 0, + _enterSlideDistance * (1 - value), + ), + child: child, + ), + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + if (Navigator.of(context).canPop()) + Align( + alignment: Alignment.centerLeft, + child: IconButton( + key: const Key('auth-back'), + tooltip: MaterialLocalizations.of( + context, + ).backButtonTooltip, + onPressed: () => + Navigator.of(context).pop(), + icon: const Icon( + Icons.arrow_back_rounded, + color: AppColors.onPrimary, + ), + ), + ), + _AuthBrand(tagline: l10n.authBrandTagline), + const SizedBox(height: 28), + _authCard(l10n), + ], + ), + ), + ), + ), + ], ), ), - const SizedBox(height: 2), - Text( - tagline, - style: const TextStyle(color: AppColors.blueSoft, fontSize: 12), - ), - ], - ), + ), + ], ), - ], + ), ); } -} -class _AuthError extends StatelessWidget { - const _AuthError({required this.message}); + Widget _authCard(AppLocalizations l10n) => _AuthCard( + state: _AuthCardState( + l10n: l10n, + status: _AuthFormStatus( + signUpMode: _logic.signUpMode, + busy: _logic.busy, + errorMessage: _logic.errorMessage, + obscurePassword: _obscurePassword, + ), + fields: _AuthFieldControllers( + email: _emailController, + password: _passwordController, + emailFocus: _emailFocus, + passwordFocus: _passwordFocus, + ), + ), + callbacks: _AuthCardCallbacks( + onModeSelected: _selectMode, + onEmailChanged: (value) => _logic.email = value, + onPasswordChanged: (value) => _logic.password = value, + onTogglePasswordVisibility: () => + setState(() => _obscurePassword = !_obscurePassword), + onSubmit: _submit, + ), + ); - final String message; - - @override - Widget build(BuildContext context) { - final color = Theme.of(context).colorScheme.error; - return Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Icon(Icons.error_outline, color: color, size: 18), - const SizedBox(width: 6), - Expanded( - child: Text( - message, - key: const Key('auth-error'), - style: TextStyle(color: color, fontSize: 13), - ), - ), - ], - ); + void _selectMode(bool signUpMode) { + if (_logic.busy || _logic.signUpMode == signUpMode) return; + setState(() => _logic.toggleMode()); } } diff --git a/lib/pages/auth/auth_widgets.dart b/lib/pages/auth/auth_widgets.dart new file mode 100644 index 0000000..ea66e4f --- /dev/null +++ b/lib/pages/auth/auth_widgets.dart @@ -0,0 +1,183 @@ +// Author: fruit.com.cn + +part of 'auth_view.dart'; + +class _AuthCardState { + const _AuthCardState({ + required this.l10n, + required this.status, + required this.fields, + }); + + final AppLocalizations l10n; + final _AuthFormStatus status; + final _AuthFieldControllers fields; +} + +class _AuthFormStatus { + const _AuthFormStatus({ + required this.signUpMode, + required this.busy, + required this.errorMessage, + required this.obscurePassword, + }); + + final bool signUpMode; + final bool busy; + final String? errorMessage; + final bool obscurePassword; +} + +class _AuthFieldControllers { + const _AuthFieldControllers({ + required this.email, + required this.password, + required this.emailFocus, + required this.passwordFocus, + }); + + final TextEditingController email; + final TextEditingController password; + final FocusNode emailFocus; + final FocusNode passwordFocus; +} + +class _AuthCardCallbacks { + const _AuthCardCallbacks({ + required this.onModeSelected, + required this.onEmailChanged, + required this.onPasswordChanged, + required this.onTogglePasswordVisibility, + required this.onSubmit, + }); + + final ValueChanged onModeSelected; + final ValueChanged onEmailChanged; + final ValueChanged onPasswordChanged; + final VoidCallback onTogglePasswordVisibility; + final VoidCallback onSubmit; +} + +class _AuthCard extends StatelessWidget { + const _AuthCard({required this.state, required this.callbacks}); + + final _AuthCardState state; + final _AuthCardCallbacks callbacks; + + @override + Widget build(BuildContext context) { + final l10n = state.l10n; + final status = state.status; + return Container( + key: const Key('auth-card'), + padding: const EdgeInsets.all(_cardPadding), + decoration: BoxDecoration( + color: AppColors.card, + borderRadius: BorderRadius.circular(_cardRadius), + border: Border.all( + color: AppColors.outlineVariantDark, + width: _cardBorderWidth, + ), + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + _AuthModeSwitch( + l10n: l10n, + signUpMode: status.signUpMode, + busy: status.busy, + onSelected: callbacks.onModeSelected, + ), + const SizedBox(height: 22), + Text( + status.signUpMode ? l10n.authSignUpTitle : l10n.authSignInTitle, + style: const TextStyle( + color: AppColors.onPrimary, + fontSize: 25, + fontWeight: FontWeight.w800, + height: 1.2, + ), + ), + const SizedBox(height: 6), + Text( + l10n.authSubtitle, + style: const TextStyle( + color: AppColors.muted, + fontSize: 13, + height: 1.45, + ), + ), + const SizedBox(height: 22), + _AuthFields(state: state, callbacks: callbacks), + if (status.errorMessage != null) ...[ + const SizedBox(height: 14), + _AuthError(message: status.errorMessage!), + ], + const SizedBox(height: 22), + _AuthSubmitButton(state: state, onSubmit: callbacks.onSubmit), + ], + ), + ); + } +} + +class _AuthModeSwitch extends StatelessWidget { + const _AuthModeSwitch({ + required this.l10n, + required this.signUpMode, + required this.busy, + required this.onSelected, + }); + + final AppLocalizations l10n; + final bool signUpMode; + final bool busy; + final ValueChanged onSelected; + + @override + Widget build(BuildContext context) { + return TextButton( + key: const Key('auth-switch-mode'), + onPressed: busy ? null : () => onSelected(!signUpMode), + style: TextButton.styleFrom( + minimumSize: const Size(0, _minTapTarget), + padding: EdgeInsets.zero, + overlayColor: Colors.transparent, + splashFactory: NoSplash.splashFactory, + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(22)), + ), + child: Container( + height: _minTapTarget, + padding: const EdgeInsets.all(3), + decoration: BoxDecoration( + color: AppColors.bar, + borderRadius: BorderRadius.circular(22), + border: Border.all(color: AppColors.outlineVariantDark), + ), + child: Row( + children: [ + Expanded( + child: _ModeSegment( + segmentKey: const Key('auth-mode-sign-in'), + label: l10n.signIn, + hiddenLabel: l10n.authSwitchToSignIn, + selected: !signUpMode, + onTap: busy ? null : () => onSelected(false), + ), + ), + const SizedBox(width: 4), + Expanded( + child: _ModeSegment( + segmentKey: const Key('auth-mode-sign-up'), + label: l10n.signUp, + hiddenLabel: l10n.authSwitchToSignUp, + selected: signUpMode, + onTap: busy ? null : () => onSelected(true), + ), + ), + ], + ), + ), + ); + } +} diff --git a/test/auth/auth_visual_test.dart b/test/auth/auth_visual_test.dart new file mode 100644 index 0000000..5f5e052 --- /dev/null +++ b/test/auth/auth_visual_test.dart @@ -0,0 +1,311 @@ +import 'dart:async'; + +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:provider/provider.dart'; +import 'package:shared_preferences_platform_interface/in_memory_shared_preferences_async.dart'; +import 'package:shared_preferences_platform_interface/shared_preferences_async_platform_interface.dart'; + +import 'package:fruitshorts/core/data/models/auth_session.dart'; +import 'package:fruitshorts/core/data/remote/api_client.dart'; +import 'package:fruitshorts/core/data/remote/auth_api.dart'; +import 'package:fruitshorts/core/data/services/auth_controller.dart'; +import 'package:fruitshorts/core/data/services/auth_session_store.dart'; +import 'package:fruitshorts/core/platform/haptics.dart'; +import 'package:fruitshorts/core/theme/app_colors.dart'; +import 'package:fruitshorts/l10n/app_localizations.dart'; +import 'package:fruitshorts/pages/auth/auth_view.dart'; + +import '../support/fake_haptics.dart'; +import '../support/fake_http_adapter.dart'; + +void main() { + setUp(() { + SharedPreferencesAsyncPlatform.instance = + InMemorySharedPreferencesAsync.empty(); + }); + + Future pumpAuthPage( + WidgetTester tester, { + AuthApi? api, + FakeHaptics? haptics, + }) async { + final auth = AuthController( + api ?? + AuthApi( + ApiClient( + baseUrl: 'http://127.0.0.1:1', + adapter: FakeHttpAdapter( + (_) async => FakeHttpResponse('{}', 500), + ), + ), + ), + AuthSessionStore(), + ); + await tester.pumpWidget( + MultiProvider( + providers: [ + ChangeNotifierProvider.value(value: auth), + Provider.value(value: haptics ?? FakeHaptics()), + ], + child: MaterialApp( + locale: const Locale('en'), + localizationsDelegates: AppLocalizations.localizationsDelegates, + supportedLocales: AppLocalizations.supportedLocales, + home: const AuthPage(), + ), + ), + ); + await tester.pump(const Duration(milliseconds: 220)); + } + + testWidgets( + 'should_render_branded_dark_layout_with_approved_tokens_when_page_opens', + (tester) async { + await pumpAuthPage(tester); + + expect(find.byKey(const Key('auth-brand')), findsOneWidget); + expect(find.text('FruitShorts'), findsOneWidget); + expect(find.text('Short dramas made for Indonesia'), findsOneWidget); + expect( + tester.getSize(find.byKey(const Key('auth-brand-mark'))), + const Size(48, 48), + ); + + final glow = tester.widget( + find.byKey(const Key('auth-background-glow')), + ); + final glowDecoration = glow.decoration! as BoxDecoration; + final gradient = glowDecoration.gradient! as LinearGradient; + for (final color in gradient.colors) { + expect(color.a, lessThanOrEqualTo(0.18)); + } + + final card = tester.widget(find.byKey(const Key('auth-card'))); + final cardDecoration = card.decoration! as BoxDecoration; + expect(cardDecoration.color, AppColors.card); + expect(cardDecoration.borderRadius, BorderRadius.circular(20)); + expect( + (cardDecoration.border! as Border).top.color, + AppColors.outlineVariantDark, + ); + expect((cardDecoration.border! as Border).top.width, 1); + + final email = tester.widget( + find.byKey(const Key('auth-email')), + ); + expect(email.decoration?.fillColor, AppColors.bar); + expect(tester.getSize(find.byKey(const Key('auth-email'))).height, 52); + final emailBorder = email.decoration!.border! as OutlineInputBorder; + expect(emailBorder.borderRadius, BorderRadius.circular(14)); + + final submit = tester.widget( + find.byKey(const Key('auth-submit')), + ); + expect(submit.style!.backgroundColor!.resolve(const {}), AppColors.blue); + expect( + submit.style!.backgroundColor!.resolve(const {WidgetState.pressed}), + AppColors.bluePressed, + ); + expect(tester.getSize(find.byKey(const Key('auth-submit'))).height, 52); + expect( + (submit.style!.shape!.resolve(const {})! as RoundedRectangleBorder) + .borderRadius, + BorderRadius.circular(26), + ); + + expect(find.text('Sign In'), findsWidgets); + expect(find.text('Sign Up'), findsOneWidget); + expect( + tester.widget(find.text('Sign In').first).style?.fontSize, + isNot(0), + ); + }, + ); + + testWidgets('should_fade_and_slide_content_in_within_220ms', (tester) async { + await pumpAuthPage(tester); + + final animation = tester.widget>( + find.byKey(const Key('auth-enter-animation')), + ); + expect( + animation.duration, + lessThanOrEqualTo(const Duration(milliseconds: 220)), + ); + expect(animation.tween.begin, 0); + expect(animation.tween.end, 1); + }); + + testWidgets( + 'should_switch_between_sign_in_and_sign_up_when_segment_is_tapped', + (tester) async { + await pumpAuthPage(tester); + expect(find.text('Welcome back'), findsOneWidget); + + await tester.tap(find.byKey(const Key('auth-mode-sign-up'))); + await tester.pumpAndSettle(); + + expect(find.text('Create your account'), findsOneWidget); + expect(find.text('Welcome back'), findsNothing); + expect(_segmentColor(tester, 'auth-mode-sign-up'), AppColors.blue); + expect(_segmentColor(tester, 'auth-mode-sign-in'), Colors.transparent); + + await tester.tap(find.byKey(const Key('auth-mode-sign-in'))); + await tester.pumpAndSettle(); + + expect(find.text('Welcome back'), findsOneWidget); + expect(find.text('Create your account'), findsNothing); + expect(_segmentColor(tester, 'auth-mode-sign-in'), AppColors.blue); + expect(_segmentColor(tester, 'auth-mode-sign-up'), Colors.transparent); + }, + ); + + testWidgets( + 'should_move_focus_and_toggle_password_when_auth_controls_are_used', + (tester) async { + await pumpAuthPage(tester); + await tester.tap(find.byKey(const Key('auth-email'))); + await tester.testTextInput.receiveAction(TextInputAction.next); + await tester.pump(); + + expect( + FocusManager.instance.primaryFocus?.debugLabel, + 'auth-password-focus', + ); + + await tester.tap(find.byKey(const Key('auth-email'))); + await tester.pump(); + final email = tester.widget( + find.byKey(const Key('auth-email')), + ); + final focusedBorder = + email.decoration!.focusedBorder! as OutlineInputBorder; + expect(focusedBorder.borderSide.color, AppColors.blue); + expect(focusedBorder.borderSide.width, 1.5); + expect( + tester.widget(find.byIcon(Icons.mail_outline_rounded)).color, + AppColors.blueSoft, + ); + + await tester.tap(find.byKey(const Key('auth-password-visibility'))); + await tester.pump(); + expect( + tester + .widget(find.byKey(const Key('auth-password'))) + .obscureText, + isFalse, + ); + expect(find.byTooltip('Hide password'), findsOneWidget); + }, + ); + + testWidgets( + 'should_disable_form_mode_switch_and_submit_when_sign_in_is_pending', + (tester) async { + final api = _PendingAuthApi(); + final haptics = FakeHaptics(); + await pumpAuthPage(tester, api: api, haptics: haptics); + await tester.enterText(find.byKey(const Key('auth-email')), 'a@b.com'); + await tester.enterText( + find.byKey(const Key('auth-password')), + 'abcd1234', + ); + await tester.tap(find.byKey(const Key('auth-submit'))); + await tester.pump(); + + expect(api.loginCalls, 1); + expect(haptics.lightImpacts, 1); + expect( + tester.widget(find.byKey(const Key('auth-email'))).enabled, + isFalse, + ); + expect( + tester + .widget(find.byKey(const Key('auth-password'))) + .enabled, + isFalse, + ); + expect( + tester + .widget(find.byKey(const Key('auth-switch-mode'))) + .onPressed, + isNull, + ); + expect( + tester + .widget(find.byKey(const Key('auth-submit'))) + .onPressed, + isNull, + ); + + api.release(); + await tester.pumpAndSettle(); + }, + ); + + testWidgets('should_show_validation_message_inside_semantic_error_capsule', ( + tester, + ) async { + await pumpAuthPage(tester); + await tester.enterText(find.byKey(const Key('auth-email')), 'a@b.com'); + await tester.enterText(find.byKey(const Key('auth-password')), 'abcdefgh'); + await tester.tap(find.byKey(const Key('auth-submit'))); + await tester.pumpAndSettle(); + + final capsuleFinder = find.byKey(const Key('auth-error-capsule')); + expect(capsuleFinder, findsOneWidget); + final capsule = tester.widget(capsuleFinder); + final decoration = capsule.decoration! as BoxDecoration; + expect(decoration.borderRadius, BorderRadius.circular(12)); + expect(decoration.color?.a, closeTo(0.1, 0.001)); + + final errorFinder = find.byKey(const Key('auth-error')); + final error = tester.widget(errorFinder); + final scheme = Theme.of(tester.element(errorFinder)).colorScheme; + expect(error.style?.color, scheme.error); + expect( + find.descendant( + of: capsuleFinder, + matching: find.byIcon(Icons.error_outline_rounded), + ), + findsOneWidget, + ); + }); +} + +Color? _segmentColor(WidgetTester tester, String key) { + final segment = find.byKey(Key(key)); + final animated = tester.widget( + find.descendant(of: segment, matching: find.byType(AnimatedContainer)), + ); + return (animated.decoration! as BoxDecoration).color; +} + +class _PendingAuthApi extends AuthApi { + _PendingAuthApi() + : super( + ApiClient( + baseUrl: 'http://127.0.0.1:1', + adapter: FakeHttpAdapter((_) async => FakeHttpResponse('{}', 500)), + ), + ); + + final _gate = Completer(); + int loginCalls = 0; + + void release() => _gate.complete(); + + @override + Future login({ + required String email, + required String password, + required String deviceId, + String platform = '', + String appVersion = '', + }) async { + loginCalls++; + await _gate.future; + throw const ApiException(500, 'pending failure'); + } +} -- 2.54.0 From cf03178cc55c8fb7410ce1595a42c244fcd699a8 Mon Sep 17 00:00:00 2001 From: Zhou Weidong <502333560@qq.com> Date: Sat, 17 Oct 2026 17:24:45 +0800 Subject: [PATCH 22/76] =?UTF-8?q?feat(flutter):=20=E9=A6=96=E9=A1=B5?= =?UTF-8?q?=E6=94=B9=E4=B8=BA=E4=B8=A4=E5=88=97=E5=85=A8=E9=83=A8=E5=89=A7?= =?UTF-8?q?=E7=9B=AE=E7=BD=91=E6=A0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/l10n/app_en.arb | 1 + lib/l10n/app_id.arb | 1 + lib/l10n/app_localizations.dart | 6 + lib/l10n/app_localizations_en.dart | 3 + lib/l10n/app_localizations_id.dart | 3 + lib/l10n/app_localizations_zh.dart | 3 + lib/l10n/app_zh.arb | 1 + lib/pages/discover/discover_view.dart | 276 ++++-------------- .../discover/widgets/home_drama_grid.dart | 167 +++++++++++ test/discover/home_all_dramas_grid_test.dart | 245 ++++++++++++++++ test/widget_test.dart | 22 +- 11 files changed, 498 insertions(+), 230 deletions(-) create mode 100644 lib/pages/discover/widgets/home_drama_grid.dart create mode 100644 test/discover/home_all_dramas_grid_test.dart diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index 9a6edc7..e2dfb60 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -55,6 +55,7 @@ "animatedTab": "Animated", "recommendedTab": "Recommended", "noCategoryDramas": "No dramas in this category yet.", + "allDramas": "All Dramas", "trendingTab": "Trending", "liveActionTab": "Live Action", "search": "Search", diff --git a/lib/l10n/app_id.arb b/lib/l10n/app_id.arb index cd96703..55e5409 100644 --- a/lib/l10n/app_id.arb +++ b/lib/l10n/app_id.arb @@ -55,6 +55,7 @@ "animatedTab": "Animasi", "recommendedTab": "Rekomendasi", "noCategoryDramas": "Belum ada drama di kategori ini.", + "allDramas": "Semua Drama", "trendingTab": "Sedang Tren", "liveActionTab": "Live Action", "search": "Cari", diff --git a/lib/l10n/app_localizations.dart b/lib/l10n/app_localizations.dart index 6f86913..5b57f1c 100644 --- a/lib/l10n/app_localizations.dart +++ b/lib/l10n/app_localizations.dart @@ -388,6 +388,12 @@ abstract class AppLocalizations { /// **'No dramas in this category yet.'** String get noCategoryDramas; + /// No description provided for @allDramas. + /// + /// In en, this message translates to: + /// **'All Dramas'** + String get allDramas; + /// No description provided for @trendingTab. /// /// In en, this message translates to: diff --git a/lib/l10n/app_localizations_en.dart b/lib/l10n/app_localizations_en.dart index d8ec4d3..42cf09b 100644 --- a/lib/l10n/app_localizations_en.dart +++ b/lib/l10n/app_localizations_en.dart @@ -157,6 +157,9 @@ class AppLocalizationsEn extends AppLocalizations { @override String get noCategoryDramas => 'No dramas in this category yet.'; + @override + String get allDramas => 'All Dramas'; + @override String get trendingTab => 'Trending'; diff --git a/lib/l10n/app_localizations_id.dart b/lib/l10n/app_localizations_id.dart index 3d53a5e..7e05221 100644 --- a/lib/l10n/app_localizations_id.dart +++ b/lib/l10n/app_localizations_id.dart @@ -157,6 +157,9 @@ class AppLocalizationsId extends AppLocalizations { @override String get noCategoryDramas => 'Belum ada drama di kategori ini.'; + @override + String get allDramas => 'Semua Drama'; + @override String get trendingTab => 'Sedang Tren'; diff --git a/lib/l10n/app_localizations_zh.dart b/lib/l10n/app_localizations_zh.dart index ca93d04..f0a608a 100644 --- a/lib/l10n/app_localizations_zh.dart +++ b/lib/l10n/app_localizations_zh.dart @@ -154,6 +154,9 @@ class AppLocalizationsZh extends AppLocalizations { @override String get noCategoryDramas => '这个分类暂时没有剧集。'; + @override + String get allDramas => '全部剧目'; + @override String get trendingTab => '热门'; diff --git a/lib/l10n/app_zh.arb b/lib/l10n/app_zh.arb index e942dac..71a6cb8 100644 --- a/lib/l10n/app_zh.arb +++ b/lib/l10n/app_zh.arb @@ -55,6 +55,7 @@ "animatedTab": "漫剧", "recommendedTab": "推荐", "noCategoryDramas": "这个分类暂时没有剧集。", + "allDramas": "全部剧目", "trendingTab": "热门", "liveActionTab": "真人剧", "search": "搜索", diff --git a/lib/pages/discover/discover_view.dart b/lib/pages/discover/discover_view.dart index ccb7005..5a1a97a 100644 --- a/lib/pages/discover/discover_view.dart +++ b/lib/pages/discover/discover_view.dart @@ -17,6 +17,8 @@ import 'discover_binding.dart'; import 'discover_logic.dart'; import 'widgets/cover_carousel.dart'; +part 'widgets/home_drama_grid.dart'; + class DiscoverPage extends StatefulWidget { const DiscoverPage({ super.key, @@ -101,40 +103,12 @@ class _DiscoverPageState extends State { final categories = context.watch(); final homeBanners = context.watch().feed.banners; final allDramas = [...?widget.dramas, ...categories.visibleDramas]; - final cards = _cardsFor(categories.visibleDramas, ''); final content = SafeArea( bottom: !widget.embedded, child: Column( children: [ _header(l10n), - Expanded( - child: ListView( - controller: logic.scroll, - padding: const EdgeInsets.only(bottom: 24), - children: [ - Padding( - padding: const EdgeInsets.fromLTRB(16, 4, 16, 0), - child: ClipRRect( - borderRadius: BorderRadius.circular(18), - child: _carousel(l10n, homeBanners, allDramas), - ), - ), - Padding( - padding: const EdgeInsets.fromLTRB(16, 18, 16, 0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - _categories(l10n, categories), - const SizedBox(height: 18), - _continueHeader(l10n), - const SizedBox(height: 12), - _dramaContent(l10n, categories, cards), - ], - ), - ), - ], - ), - ), + Expanded(child: _feed(l10n, categories, homeBanners, allDramas)), if (!widget.embedded) _bottomNav(l10n), ], ), @@ -150,6 +124,60 @@ class _DiscoverPageState extends State { ); } + Widget _feed( + AppLocalizations l10n, + CategoryController categories, + List banners, + List allDramas, + ) => CustomScrollView( + controller: logic.scroll, + slivers: [ + SliverToBoxAdapter( + child: Padding( + padding: const EdgeInsets.fromLTRB(16, 4, 16, 0), + child: ClipRRect( + borderRadius: BorderRadius.circular(18), + child: _carousel(l10n, banners, allDramas), + ), + ), + ), + SliverToBoxAdapter( + child: Padding( + padding: const EdgeInsets.fromLTRB(16, 18, 16, 12), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + _categories(l10n, categories), + const SizedBox(height: 18), + Text( + l10n.allDramas, + key: const Key('home-all-dramas-title'), + style: const TextStyle( + color: AppColors.onPrimary, + fontSize: 18, + fontWeight: FontWeight.w700, + height: 1.2, + ), + ), + ], + ), + ), + ), + _HomeDramaGrid( + l10n: l10n, + categories: categories, + onOpen: (drama) => logic.openCard( + context, + drama, + embedded: widget.embedded, + onDramaSelected: widget.onDramaSelected, + onAction: widget.onAction, + ), + ), + const SliverToBoxAdapter(child: SizedBox(height: 24)), + ], + ); + Widget _header(AppLocalizations l10n) { return Padding( padding: const EdgeInsets.fromLTRB(16, 6, 12, 8), @@ -239,164 +267,6 @@ class _DiscoverPageState extends State { } } - Widget _continueHeader(AppLocalizations l10n) => Row( - children: [ - Expanded( - child: Text( - l10n.continueWatching, - maxLines: 1, - overflow: TextOverflow.ellipsis, - style: const TextStyle( - fontSize: 18, - fontWeight: FontWeight.w600, - letterSpacing: 0.2, - height: 1.2, - ), - ), - ), - const SizedBox(width: 8), - Text( - l10n.seeAll, - style: const TextStyle( - color: AppColors.blueSoft, - fontSize: 13, - fontWeight: FontWeight.w500, - ), - ), - ], - ); - - Widget _dramaContent( - AppLocalizations l10n, - CategoryController categories, - List<_ShowcaseCard> cards, - ) { - if (categories.loading && categories.feed.sections.isEmpty) { - return const Padding( - padding: EdgeInsets.symmetric(vertical: 24), - child: Center(child: CircularProgressIndicator(strokeWidth: 2)), - ); - } - if (categories.error != null) { - return Padding( - padding: const EdgeInsets.symmetric(vertical: 18), - child: Row( - children: [ - Expanded( - child: Text( - l10n.categoriesError, - style: const TextStyle(color: Color(0xFFE6E1E3)), - ), - ), - TextButton(onPressed: categories.load, child: Text(l10n.retry)), - ], - ), - ); - } - if (cards.isEmpty) { - return Padding( - padding: const EdgeInsets.symmetric(vertical: 24), - child: Text( - categories.selectedSectionMissing - ? l10n.noCategoryDramas - : l10n.noSearchResults, - style: const TextStyle(color: Color(0xFFE6E1E3)), - ), - ); - } - return SizedBox( - height: 196, - child: ListView( - scrollDirection: Axis.horizontal, - children: [ - for (final card in cards) ...[ - _continueTile(l10n, card, categories.visibleDramas), - const SizedBox(width: 12), - ], - ], - ), - ); - } - - Widget _continueTile( - AppLocalizations l10n, - _ShowcaseCard card, - List source, - ) { - final drama = logic.dramaFor(card.dramaId, source); - return SizedBox( - width: 132, - child: InkWell( - onTap: () => logic.openCard( - context, - drama, - embedded: widget.embedded, - onDramaSelected: widget.onDramaSelected, - onAction: widget.onAction, - ), - child: ClipRRect( - borderRadius: BorderRadius.circular(14), - child: Stack( - fit: StackFit.expand, - children: [ - RemoteImage(card.image), - const DecoratedBox( - decoration: BoxDecoration( - gradient: LinearGradient( - begin: Alignment.topCenter, - end: Alignment.bottomCenter, - colors: [Color(0x00000000), Color(0xE6000000)], - stops: [0.45, 1], - ), - ), - ), - if (drama == null) - const ColoredBox( - color: Color(0x99000000), - child: Center( - child: Icon(Icons.image_outlined, color: Colors.white), - ), - ), - Positioned( - left: 10, - right: 10, - bottom: 10, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - card.title, - maxLines: 2, - overflow: TextOverflow.ellipsis, - style: const TextStyle( - color: Colors.white, - fontSize: 13, - fontWeight: FontWeight.w600, - height: 1.2, - ), - ), - const SizedBox(height: 3), - Text( - drama == null ? l10n.videoPending : card.genre, - maxLines: 1, - overflow: TextOverflow.ellipsis, - style: const TextStyle( - color: Color(0xE6FFFFFF), - fontSize: 11, - fontWeight: FontWeight.w400, - height: 1.2, - ), - ), - ], - ), - ), - ], - ), - ), - ), - ); - } - Widget _categories(AppLocalizations l10n, CategoryController categories) { final choices = <({String code, String label})>[ (code: CategoryController.allCode, label: l10n.forYou), @@ -523,38 +393,6 @@ class _DiscoverNavItem extends StatelessWidget { ); } -class _ShowcaseCard { - const _ShowcaseCard({ - required this.title, - required this.genre, - required this.image, - this.dramaId, - }); - - final String title; - final String genre; - final String image; - final String? dramaId; -} - -/// 分区由服务端下发:0 为全部,其余按分区顺序对应筛选菜单(热门 / 最新 / 各分类)。 -List<_ShowcaseCard> _cardsFor(List dramas, String query) { - final normalized = query.trim().toLowerCase(); - return [ - for (final drama in dramas) - if (normalized.isEmpty || - drama.title.toLowerCase().contains(normalized) || - drama.genre.toLowerCase().contains(normalized) || - drama.category.toLowerCase().contains(normalized)) - _ShowcaseCard( - title: drama.title, - genre: drama.genre.isEmpty ? drama.category : drama.genre, - image: drama.posterUrl, - dramaId: drama.id, - ), - ]; -} - const _accent = AppColors.blueSoft; const _coin = Color(0xFFF5C451); diff --git a/lib/pages/discover/widgets/home_drama_grid.dart b/lib/pages/discover/widgets/home_drama_grid.dart new file mode 100644 index 0000000..de34d95 --- /dev/null +++ b/lib/pages/discover/widgets/home_drama_grid.dart @@ -0,0 +1,167 @@ +// Author: fruit.com.cn + +part of '../discover_view.dart'; + +class _HomeDramaGrid extends StatelessWidget { + const _HomeDramaGrid({ + required this.l10n, + required this.categories, + required this.onOpen, + }); + + final AppLocalizations l10n; + final CategoryController categories; + final ValueChanged onOpen; + + @override + Widget build(BuildContext context) { + if (categories.loading && categories.feed.sections.isEmpty) { + return const SliverPadding( + padding: EdgeInsets.symmetric(vertical: 24), + sliver: SliverToBoxAdapter( + child: Center(child: CircularProgressIndicator(strokeWidth: 2)), + ), + ); + } + if (categories.error != null) { + return SliverPadding( + padding: const EdgeInsets.fromLTRB(16, 6, 16, 18), + sliver: SliverToBoxAdapter( + child: Row( + children: [ + Expanded( + child: Text( + l10n.categoriesError, + style: const TextStyle(color: AppColors.muted), + ), + ), + TextButton(onPressed: categories.load, child: Text(l10n.retry)), + ], + ), + ), + ); + } + + final dramas = categories.visibleDramas; + if (dramas.isEmpty) { + return SliverPadding( + padding: const EdgeInsets.fromLTRB(16, 6, 16, 24), + sliver: SliverToBoxAdapter( + child: Text( + categories.selectedSectionMissing + ? l10n.noCategoryDramas + : l10n.noSearchResults, + style: const TextStyle(color: AppColors.muted), + ), + ), + ); + } + + return SliverPadding( + key: const Key('home-all-dramas-section'), + padding: const EdgeInsets.symmetric(horizontal: 16), + sliver: SliverGrid( + key: const Key('home-all-dramas-grid'), + gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: 2, + mainAxisSpacing: 16, + crossAxisSpacing: 12, + childAspectRatio: 2 / 3, + ), + delegate: SliverChildBuilderDelegate( + (context, index) => _HomeDramaCard( + l10n: l10n, + drama: dramas[index], + onTap: () => onOpen(dramas[index]), + ), + childCount: dramas.length, + ), + ), + ); + } +} + +class _HomeDramaCard extends StatelessWidget { + const _HomeDramaCard({ + required this.l10n, + required this.drama, + required this.onTap, + }); + + final AppLocalizations l10n; + final Drama drama; + final VoidCallback onTap; + + @override + Widget build(BuildContext context) { + final genre = drama.genre.isEmpty ? drama.category : drama.genre; + return InkWell( + key: Key('home-drama-card-${drama.id}'), + onTap: onTap, + borderRadius: BorderRadius.circular(14), + child: AspectRatio( + key: Key('home-drama-cover-${drama.id}'), + aspectRatio: 2 / 3, + child: ClipRRect( + borderRadius: BorderRadius.circular(14), + child: Stack( + fit: StackFit.expand, + children: [ + RemoteImage( + drama.posterUrl, + fit: BoxFit.cover, + showFallbackIcon: true, + ), + const DecoratedBox( + decoration: BoxDecoration( + gradient: LinearGradient( + begin: Alignment.topCenter, + end: Alignment.bottomCenter, + colors: [Color(0x00000000), Color(0xE6000000)], + stops: [0.4, 1], + ), + ), + ), + Positioned( + left: 10, + right: 10, + bottom: 10, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + Text( + drama.title, + key: Key('home-drama-title-${drama.id}'), + maxLines: 2, + overflow: TextOverflow.ellipsis, + style: const TextStyle( + color: Colors.white, + fontSize: 14, + fontWeight: FontWeight.w700, + height: 1.2, + ), + ), + const SizedBox(height: 4), + Text( + genre.isEmpty ? l10n.videoPending : genre, + key: Key('home-drama-genre-${drama.id}'), + maxLines: 1, + overflow: TextOverflow.ellipsis, + style: const TextStyle( + color: Color(0xE6FFFFFF), + fontSize: 11, + fontWeight: FontWeight.w400, + height: 1.2, + ), + ), + ], + ), + ), + ], + ), + ), + ), + ); + } +} diff --git a/test/discover/home_all_dramas_grid_test.dart b/test/discover/home_all_dramas_grid_test.dart new file mode 100644 index 0000000..e724439 --- /dev/null +++ b/test/discover/home_all_dramas_grid_test.dart @@ -0,0 +1,245 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:shared_preferences_platform_interface/in_memory_shared_preferences_async.dart'; +import 'package:shared_preferences_platform_interface/shared_preferences_async_platform_interface.dart'; + +import 'package:fruitshorts/app.dart'; +import 'package:fruitshorts/core/data/models/content_category.dart'; +import 'package:fruitshorts/core/data/models/drama.dart'; +import 'package:fruitshorts/core/data/models/home_feed.dart'; +import 'package:fruitshorts/core/data/repositories/category_repository.dart'; +import 'package:fruitshorts/core/data/repositories/favorite_repository.dart'; +import 'package:fruitshorts/core/data/repositories/playback_repository.dart'; +import 'package:fruitshorts/core/data/repositories/watch_history_repository.dart'; +import 'package:fruitshorts/core/widgets/remote_image.dart'; + +import '../support/fake_catalog.dart'; +import '../support/fake_interaction_repositories.dart'; +import '../support/fake_notice_repository.dart'; +import '../support/widget_player.dart'; + +void main() { + setUp(() { + SharedPreferencesAsyncPlatform.instance = + InMemorySharedPreferencesAsync.empty(); + }); + + testWidgets( + 'should_show_all_dramas_in_two_column_sliver_grid_without_continue_watching', + (tester) async { + tester.view.physicalSize = const Size(390, 844); + tester.view.devicePixelRatio = 1; + addTearDown(tester.view.resetPhysicalSize); + addTearDown(tester.view.resetDevicePixelRatio); + + await _pumpApp(tester, categoryRepository: _GridCategoryRepository()); + await tester.tap(find.byKey(const Key('tab-discover'))); + await tester.pumpAndSettle(); + + expect(find.text('Continue Watching'), findsNothing); + expect(find.text('All Dramas'), findsOneWidget); + + final grid = tester.widget( + find.byKey(const Key('home-all-dramas-grid')), + ); + final delegate = + grid.gridDelegate as SliverGridDelegateWithFixedCrossAxisCount; + expect(delegate.crossAxisCount, 2); + expect(delegate.crossAxisSpacing, 12); + expect(delegate.mainAxisSpacing, 16); + expect(delegate.childAspectRatio, closeTo(2 / 3, 0.001)); + expect( + tester + .widget( + find.byKey(const Key('home-all-dramas-section')), + ) + .padding, + const EdgeInsets.symmetric(horizontal: 16), + ); + expect(find.byType(GridView), findsNothing); + expect(find.byType(CustomScrollView), findsOneWidget); + expect(find.byType(RemoteImage), findsWidgets); + + final cover = tester.widget( + find.byKey(const Key('home-drama-cover-city-lights-demo')), + ); + expect(cover.aspectRatio, closeTo(2 / 3, 0.001)); + expect( + tester + .widget( + find.byKey(const Key('home-drama-title-city-lights-demo')), + ) + .maxLines, + 2, + ); + expect( + tester + .widget( + find.byKey(const Key('home-drama-genre-city-lights-demo')), + ) + .maxLines, + 1, + ); + expect(tester.takeException(), isNull); + }, + ); + + testWidgets('should_update_grid_when_category_is_selected', (tester) async { + tester.view.physicalSize = const Size(390, 844); + tester.view.devicePixelRatio = 1; + addTearDown(tester.view.resetPhysicalSize); + addTearDown(tester.view.resetDevicePixelRatio); + + await _pumpApp(tester, categoryRepository: _GridCategoryRepository()); + await tester.tap(find.byKey(const Key('tab-discover'))); + await tester.pumpAndSettle(); + + expect(find.text('The Signal'), findsOneWidget); + expect(find.text('City Lights & Velvet Nights'), findsOneWidget); + + await tester.tap(find.text('Romance')); + await tester.pumpAndSettle(); + + expect(find.text('The Signal'), findsNothing); + expect(find.text('City Lights & Velvet Nights'), findsOneWidget); + expect( + find.byKey(const Key('home-drama-card-the-signal-demo')), + findsNothing, + ); + expect( + find.byKey(const Key('home-drama-card-city-lights-demo')), + findsOneWidget, + ); + }); + + testWidgets('should_keep_empty_messages_when_feed_has_no_dramas', ( + tester, + ) async { + tester.view.physicalSize = const Size(390, 844); + tester.view.devicePixelRatio = 1; + addTearDown(tester.view.resetPhysicalSize); + addTearDown(tester.view.resetDevicePixelRatio); + + await _pumpApp( + tester, + categoryRepository: _GridCategoryRepository( + discoverFeed: const HomeFeed(), + ), + ); + await tester.tap(find.byKey(const Key('tab-discover'))); + await tester.pumpAndSettle(); + + expect(find.text('All Dramas'), findsOneWidget); + expect(find.text('No matching dramas.'), findsOneWidget); + + await tester.tap(find.text('Romance')); + await tester.pumpAndSettle(); + + expect(find.text('No dramas in this category yet.'), findsOneWidget); + }); + + testWidgets('should_show_retry_when_category_feed_fails', (tester) async { + tester.view.physicalSize = const Size(390, 844); + tester.view.devicePixelRatio = 1; + addTearDown(tester.view.resetPhysicalSize); + addTearDown(tester.view.resetDevicePixelRatio); + + await _pumpApp(tester, categoryRepository: _FailingCategoryRepository()); + await tester.tap(find.byKey(const Key('tab-discover'))); + await tester.pumpAndSettle(); + + expect(find.text('All Dramas'), findsOneWidget); + expect(find.text('Categories could not be loaded.'), findsOneWidget); + expect(find.text('Retry'), findsOneWidget); + expect(find.byKey(const Key('home-all-dramas-grid')), findsNothing); + }); + + testWidgets('should_fit_two_column_grid_on_compact_screen', (tester) async { + tester.view.physicalSize = const Size(320, 568); + tester.view.devicePixelRatio = 1; + addTearDown(tester.view.resetPhysicalSize); + addTearDown(tester.view.resetDevicePixelRatio); + + await _pumpApp(tester, categoryRepository: _GridCategoryRepository()); + await tester.tap(find.byKey(const Key('tab-discover'))); + await tester.pumpAndSettle(); + await tester.scrollUntilVisible( + find.byKey(const Key('home-drama-card-city-lights-demo')), + 180, + scrollable: find.byType(Scrollable).last, + ); + await tester.pumpAndSettle(); + + expect(find.text('All Dramas'), findsOneWidget); + expect(find.text('City Lights & Velvet Nights'), findsOneWidget); + expect(tester.takeException(), isNull); + }); +} + +Future _pumpApp( + WidgetTester tester, { + required CategoryRepository categoryRepository, +}) async { + final catalog = FakeCatalogRepository(); + await tester.pumpWidget( + LumaDramaApp( + playerFactory: createWidgetPlayer, + catalogRepository: catalog, + categoryRepository: categoryRepository, + watchHistoryRepository: InMemoryWatchHistoryRepository(), + favoriteRepository: InMemoryFavoriteRepository(), + playbackRepository: FakePlaybackRepository(), + commentRepository: FakeCommentRepository(), + interactionRepository: FakeInteractionRepository(), + noticeRepository: FakeNoticeRepository(), + ), + ); + await tester.pumpAndSettle(); +} + +class _GridCategoryRepository implements CategoryRepository { + _GridCategoryRepository({HomeFeed? discoverFeed}) + : discoverFeed = discoverFeed ?? _defaultDiscoverFeed; + + final HomeFeed discoverFeed; + + @override + Future> fetchCategories() async => const [ + ContentCategory(id: '7', name: 'Romance'), + ]; + + @override + Future fetchDiscoverFeed() async => discoverFeed; +} + +class _FailingCategoryRepository implements CategoryRepository { + @override + Future> fetchCategories() async => const [ + ContentCategory(id: '7', name: 'Romance'), + ]; + + @override + Future fetchDiscoverFeed() async { + throw StateError('discover feed unavailable'); + } +} + +final _defaultDiscoverFeed = HomeFeed( + sections: [ + FeedSection(code: 'hot', title: 'Hot', dramas: demoDramas), + FeedSection( + code: 'category-7', + title: 'Romance', + dramas: [ + Drama( + id: 'city-lights-demo', + title: 'City Lights & Velvet Nights', + synopsis: 'City Lights & Velvet Nights synopsis', + posterUrl: '/files/city-lights-demo.png', + genre: 'Urban Romance', + detailLoaded: true, + ), + ], + ), + ], +); diff --git a/test/widget_test.dart b/test/widget_test.dart index c610e38..6f86ddf 100644 --- a/test/widget_test.dart +++ b/test/widget_test.dart @@ -155,7 +155,7 @@ void main() { await tester.pumpWidget(appUnderTest()); await tester.pumpAndSettle(); - expect(find.text('Continue Watching'), findsOneWidget); + expect(find.text('All Dramas'), findsOneWidget); await tester.binding.handlePopRoute(); await tester.pumpAndSettle(); expect( @@ -186,15 +186,15 @@ void main() { .active, isFalse, ); - expect(find.text('Continue Watching'), findsOneWidget); + expect(find.text('All Dramas'), findsOneWidget); await tester.binding.handlePopRoute(); await tester.pumpAndSettle(); await tester.tap(find.byKey(const Key('drawer-discover'))); await tester.pumpAndSettle(); - expect(find.text('Continue Watching'), findsOneWidget); + expect(find.text('All Dramas'), findsOneWidget); expect( - Navigator.of(tester.element(find.text('Continue Watching'))).canPop(), + Navigator.of(tester.element(find.text('All Dramas'))).canPop(), isFalse, ); }, @@ -313,7 +313,7 @@ void main() { await tester.pumpAndSettle(); expect(find.text('For You'), findsOneWidget); - expect(find.text('Continue Watching'), findsOneWidget); + expect(find.text('All Dramas'), findsOneWidget); expect(find.text('Rewards'), findsOneWidget); expect(find.text(r'$ 0'), findsOneWidget); expect(find.text('Urban Romance', skipOffstage: false), findsOneWidget); @@ -345,10 +345,10 @@ void main() { await tester.pumpAndSettle(); await tester.tap(find.text('Home')); await tester.pumpAndSettle(); - expect(find.text('Continue Watching'), findsOneWidget); + expect(find.text('All Dramas'), findsOneWidget); expect(find.byTooltip('Search'), findsNothing); expect( - Navigator.of(tester.element(find.text('Continue Watching'))).canPop(), + Navigator.of(tester.element(find.text('All Dramas'))).canPop(), isFalse, ); @@ -365,10 +365,10 @@ void main() { await tester.tap(find.byKey(const Key('tab-discover'))); await tester.pumpAndSettle(); - expect(find.text('Continue Watching'), findsOneWidget); + expect(find.text('All Dramas'), findsOneWidget); expect(find.byTooltip('Search'), findsNothing); expect( - Navigator.of(tester.element(find.text('Continue Watching'))).canPop(), + Navigator.of(tester.element(find.text('All Dramas'))).canPop(), isFalse, ); await tester.tap(find.byKey(const Key('tab-my-list'))); @@ -564,7 +564,7 @@ void main() { await tester.pumpWidget(appUnderTest()); await tester.pumpAndSettle(); - expect(find.text('Continue Watching'), findsOneWidget); + expect(find.text('All Dramas'), findsOneWidget); await tester.binding.handlePopRoute(); await tester.pumpAndSettle(); expect(find.text('Quick access'), findsOneWidget); @@ -572,7 +572,7 @@ void main() { await tester.binding.handlePopRoute(); await tester.pumpAndSettle(); expect(find.text('Quick access'), findsNothing); - expect(find.text('Continue Watching'), findsOneWidget); + expect(find.text('All Dramas'), findsOneWidget); expect( Navigator.of( tester.element(find.byKey(const Key('home-tabs-bar'))), -- 2.54.0 From a4415c872de947a86ca3851a4413bae683d80807 Mon Sep 17 00:00:00 2001 From: Zhou Weidong <502333560@qq.com> Date: Sat, 17 Oct 2026 17:27:07 +0800 Subject: [PATCH 23/76] =?UTF-8?q?chore(deps):=20=E5=90=8C=E6=AD=A5?= =?UTF-8?q?=E4=BE=9D=E8=B5=96=E9=94=81=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pubspec.lock | 96 +++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 88 insertions(+), 8 deletions(-) diff --git a/pubspec.lock b/pubspec.lock index 7abd14d..5991194 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -65,6 +65,14 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "1.1.3" + code_assets: + dependency: transitive + description: + name: code_assets + sha256: "828110d598123b5ea96c00c9f3c72105bf79f8ee36c20a39b26209ade421ec57" + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.1.0" collection: dependency: transitive description: @@ -73,6 +81,14 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "1.19.1" + crypto: + dependency: transitive + description: + name: crypto + sha256: c8ea0233063ba03258fbcf2ca4d6dadfefe14f02fab57702265467a19f27fadf + url: "https://pub.flutter-io.cn" + source: hosted + version: "3.0.7" csslib: dependency: transitive description: @@ -175,6 +191,14 @@ packages: description: flutter source: sdk version: "0.0.0" + hooks: + dependency: transitive + description: + name: hooks + sha256: eaac480a35ec0814146c2c48d96aaa829e0e44a7662c88ae84c9edf4bc35651f + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.2.0" html: dependency: transitive description: @@ -212,6 +236,22 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "0.20.3" + jni: + dependency: transitive + description: + name: jni + sha256: "6b9ca0602fef0230e83149afbe3f9f8227e94f2bbe84a1da4f14d699742f402d" + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.1.0" + jni_util: + dependency: transitive + description: + name: jni_util + sha256: "1ba86da04a5f2bf18fde2edb235587e70c5b0fc5bd4ba955f46b00942c3fc35f" + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.0.0" json_annotation: dependency: transitive description: @@ -252,6 +292,14 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "6.1.0" + logging: + dependency: transitive + description: + name: logging + sha256: c8245ada5f1717ed44271ed1c26b8ce85ca3228fd2ffdb75468ab01979309d61 + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.3.0" matcher: dependency: transitive description: @@ -292,6 +340,22 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "1.0.0" + objective_c: + dependency: transitive + description: + name: objective_c + sha256: "5c80c2ad6e2c0397de5db38c6d653e69616a3397e13aa7633bf39eb668f2041b" + url: "https://pub.flutter-io.cn" + source: hosted + version: "9.6.2" + package_config: + dependency: transitive + description: + name: package_config + sha256: ffcf4cf3d6c0b74ac43708d9f56625506e8a68aa935abe9d267a7330f320eb5d + url: "https://pub.flutter-io.cn" + source: hosted + version: "3.0.0" path: dependency: transitive description: @@ -364,6 +428,22 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "6.1.5+1" + pub_semver: + dependency: transitive + description: + name: pub_semver + sha256: "261236774e8b1d69cfc6b9eabbc96c40f25e7a2d6b171f3385d4f65d5734fb24" + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.2.1" + record_use: + dependency: transitive + description: + name: record_use + sha256: "1cb8564af8d43b464294411db9217f5ec04891c6f22ee2c32d73ae05e88a6bd2" + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.1.1" shared_preferences: dependency: "direct main" description: @@ -376,18 +456,18 @@ packages: dependency: transitive description: name: shared_preferences_android - sha256: "1e12aafe408aa50da80edfd679a2a6bf63ba7ab37c7fa98286da459a757b3399" + sha256: b90caa27669d5f3ef9918d55343b44000f088ee9d4685ed822310848004c793e url: "https://pub.flutter-io.cn" source: hosted - version: "2.4.28" + version: "2.5.0" shared_preferences_foundation: dependency: transitive description: name: shared_preferences_foundation - sha256: "2ec3934efa51e46117f23031cc141b8fc878e8525b94ec1ea4f7f586cf1b47ea" + sha256: c2c02dd59bd7b3bb6bfb77aa7ad4a7886b24ee40e95dcaea754b83274b567ff5 url: "https://pub.flutter-io.cn" source: hosted - version: "2.5.7" + version: "2.6.0" shared_preferences_linux: dependency: transitive description: @@ -541,10 +621,10 @@ packages: dependency: transitive description: name: vm_service - sha256: "5f37239c4851efcef929cea7824e76df7f2f0970aef85d66bbc430afa40e72f0" + sha256: "89b11d62e1040ee681af3b4f1c97a803ecbf010c6e8b9c5896ee5b08c3bf7b78" url: "https://pub.flutter-io.cn" source: hosted - version: "15.3.0" + version: "15.4.0" web: dependency: transitive description: @@ -578,5 +658,5 @@ packages: source: hosted version: "3.1.4" sdks: - dart: ">=3.12.2 <4.0.0" - flutter: ">=3.44.0" + dart: ">=3.13.0 <4.0.0" + flutter: ">=3.47.0" -- 2.54.0 From 2c30f83ab3c86b68a14cf9642571e80d170987b9 Mon Sep 17 00:00:00 2001 From: Zhou Weidong <502333560@qq.com> Date: Sat, 17 Oct 2026 17:30:33 +0800 Subject: [PATCH 24/76] =?UTF-8?q?chore(ios):=20=E5=9B=BA=E5=AE=9A=20shared?= =?UTF-8?q?=5Fpreferences=5Ffoundation=202.5.6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pubspec.lock | 66 ++++------------------------------------------------ pubspec.yaml | 4 ++++ 2 files changed, 9 insertions(+), 61 deletions(-) diff --git a/pubspec.lock b/pubspec.lock index 5991194..2db1ec3 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -65,14 +65,6 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "1.1.3" - code_assets: - dependency: transitive - description: - name: code_assets - sha256: "828110d598123b5ea96c00c9f3c72105bf79f8ee36c20a39b26209ade421ec57" - url: "https://pub.flutter-io.cn" - source: hosted - version: "2.1.0" collection: dependency: transitive description: @@ -81,14 +73,6 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "1.19.1" - crypto: - dependency: transitive - description: - name: crypto - sha256: c8ea0233063ba03258fbcf2ca4d6dadfefe14f02fab57702265467a19f27fadf - url: "https://pub.flutter-io.cn" - source: hosted - version: "3.0.7" csslib: dependency: transitive description: @@ -191,14 +175,6 @@ packages: description: flutter source: sdk version: "0.0.0" - hooks: - dependency: transitive - description: - name: hooks - sha256: eaac480a35ec0814146c2c48d96aaa829e0e44a7662c88ae84c9edf4bc35651f - url: "https://pub.flutter-io.cn" - source: hosted - version: "2.2.0" html: dependency: transitive description: @@ -292,14 +268,6 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "6.1.0" - logging: - dependency: transitive - description: - name: logging - sha256: c8245ada5f1717ed44271ed1c26b8ce85ca3228fd2ffdb75468ab01979309d61 - url: "https://pub.flutter-io.cn" - source: hosted - version: "1.3.0" matcher: dependency: transitive description: @@ -340,14 +308,6 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "1.0.0" - objective_c: - dependency: transitive - description: - name: objective_c - sha256: "5c80c2ad6e2c0397de5db38c6d653e69616a3397e13aa7633bf39eb668f2041b" - url: "https://pub.flutter-io.cn" - source: hosted - version: "9.6.2" package_config: dependency: transitive description: @@ -428,22 +388,6 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "6.1.5+1" - pub_semver: - dependency: transitive - description: - name: pub_semver - sha256: "261236774e8b1d69cfc6b9eabbc96c40f25e7a2d6b171f3385d4f65d5734fb24" - url: "https://pub.flutter-io.cn" - source: hosted - version: "2.2.1" - record_use: - dependency: transitive - description: - name: record_use - sha256: "1cb8564af8d43b464294411db9217f5ec04891c6f22ee2c32d73ae05e88a6bd2" - url: "https://pub.flutter-io.cn" - source: hosted - version: "1.1.1" shared_preferences: dependency: "direct main" description: @@ -461,13 +405,13 @@ packages: source: hosted version: "2.5.0" shared_preferences_foundation: - dependency: transitive + dependency: "direct overridden" description: name: shared_preferences_foundation - sha256: c2c02dd59bd7b3bb6bfb77aa7ad4a7886b24ee40e95dcaea754b83274b567ff5 + sha256: "4e7eaffc2b17ba398759f1151415869a34771ba11ebbccd1b0145472a619a64f" url: "https://pub.flutter-io.cn" source: hosted - version: "2.6.0" + version: "2.5.6" shared_preferences_linux: dependency: transitive description: @@ -658,5 +602,5 @@ packages: source: hosted version: "3.1.4" sdks: - dart: ">=3.13.0 <4.0.0" - flutter: ">=3.47.0" + dart: ">=3.12.2 <4.0.0" + flutter: ">=3.44.0" diff --git a/pubspec.yaml b/pubspec.yaml index c9982d5..02bee69 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -62,6 +62,10 @@ dev_dependencies: shared_preferences_platform_interface: ^2.4.2 flutter_launcher_icons: ^0.14.4 +# Xcode 16.2 / Swift 6.0.3 cannot parse the trailing comma in foundation 2.6.0. +dependency_overrides: + shared_preferences_foundation: 2.5.6 + # For information on the generic Dart part of this file, see the # following page: https://dart.dev/tools/pub/pubspec -- 2.54.0 From 6d08330388d4c6599c1a326229881dcd6681429f Mon Sep 17 00:00:00 2001 From: Zhou Weidong <502333560@qq.com> Date: Sat, 17 Oct 2026 17:44:44 +0800 Subject: [PATCH 25/76] =?UTF-8?q?feat(flutter):=20=E7=BB=9F=E4=B8=80?= =?UTF-8?q?=E7=A9=BA=E5=88=97=E8=A1=A8=E5=8D=A0=E4=BD=8D=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/core/widgets/empty_state.dart | 128 +++++++++++++++ lib/l10n/app_en.arb | 1 + lib/l10n/app_id.arb | 1 + lib/l10n/app_localizations.dart | 6 + lib/l10n/app_localizations_en.dart | 3 + lib/l10n/app_localizations_id.dart | 3 + lib/l10n/app_localizations_zh.dart | 3 + lib/l10n/app_zh.arb | 1 + lib/pages/discover/discover_view.dart | 1 + .../discover/widgets/home_drama_grid.dart | 11 +- lib/pages/downloads/downloads_page.dart | 12 +- lib/pages/drama_detail/drama_detail_view.dart | 30 +--- lib/pages/favorites/favorites_page.dart | 10 +- lib/pages/home/home_view.dart | 24 ++- lib/pages/mine/mine_view.dart | 20 +-- lib/pages/notices/notices_page.dart | 10 +- .../player/widgets/drama_comments_sheet.dart | 10 +- .../watch_records/watch_records_page.dart | 11 +- test/comment/drama_comments_sheet_test.dart | 14 ++ test/download/downloads_page_test.dart | 3 + test/empty_state/empty_state_test.dart | 149 ++++++++++++++++++ test/library/favorites_page_test.dart | 2 + test/notice/notices_page_test.dart | 2 + test/watch/watch_records_page_test.dart | 2 + 24 files changed, 394 insertions(+), 63 deletions(-) create mode 100644 lib/core/widgets/empty_state.dart create mode 100644 test/empty_state/empty_state_test.dart diff --git a/lib/core/widgets/empty_state.dart b/lib/core/widgets/empty_state.dart new file mode 100644 index 0000000..b9b6093 --- /dev/null +++ b/lib/core/widgets/empty_state.dart @@ -0,0 +1,128 @@ +// Author: fruit.com.cn + +import 'package:flutter/material.dart'; + +import '../theme/app_colors.dart'; + +const double _regularArtSize = 96; +const double _compactArtSize = 64; +const double _regularIconSize = 42; +const double _compactIconSize = 28; +const double _regularRadius = 28; +const double _compactRadius = 18; +const double _maxContentWidth = 280; +const double _actionMinHeight = 44; +const double _artOpacity = 0.11; + +/// 统一空列表占位:柔和图标、标题、可选说明与操作。 +class EmptyState extends StatelessWidget { + const EmptyState({ + super.key, + required this.icon, + required this.title, + this.subtitle, + this.actionLabel, + this.onAction, + this.compact = false, + }); + + final IconData icon; + final String title; + final String? subtitle; + final String? actionLabel; + final VoidCallback? onAction; + final bool compact; + + @override + Widget build(BuildContext context) { + final scheme = Theme.of(context).colorScheme; + final dark = Theme.of(context).brightness == Brightness.dark; + final iconColor = dark ? AppColors.blueSoft : AppColors.blue; + final artSize = compact ? _compactArtSize : _regularArtSize; + final iconSize = compact ? _compactIconSize : _regularIconSize; + final hasAction = actionLabel != null && onAction != null; + return Center( + child: ConstrainedBox( + key: const Key('empty-state-content'), + constraints: const BoxConstraints(maxWidth: _maxContentWidth), + child: Padding( + padding: EdgeInsets.all(compact ? 16 : 24), + child: Semantics( + container: true, + label: title, + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + ExcludeSemantics( + child: Container( + key: const Key('empty-state-art'), + width: artSize, + height: artSize, + alignment: Alignment.center, + decoration: BoxDecoration( + color: AppColors.blue.withValues(alpha: _artOpacity), + borderRadius: BorderRadius.circular( + compact ? _compactRadius : _regularRadius, + ), + ), + child: Icon( + icon, + key: const Key('empty-state-icon'), + size: iconSize, + color: iconColor, + ), + ), + ), + SizedBox(height: compact ? 10 : 16), + ExcludeSemantics( + child: Text( + title, + key: const Key('empty-state-title'), + maxLines: 2, + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.center, + style: TextStyle( + color: scheme.onSurface, + fontSize: compact ? 14 : 16, + fontWeight: FontWeight.w600, + height: 1.35, + ), + ), + ), + if (subtitle != null) ...[ + const SizedBox(height: 6), + ExcludeSemantics( + child: Text( + subtitle!, + maxLines: 2, + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.center, + style: const TextStyle( + color: AppColors.muted, + fontSize: 13, + height: 1.4, + ), + ), + ), + ], + if (hasAction) ...[ + const SizedBox(height: 10), + TextButton( + key: const Key('empty-state-action'), + onPressed: onAction, + style: TextButton.styleFrom( + foregroundColor: scheme.primary, + minimumSize: const Size(44, _actionMinHeight), + padding: const EdgeInsets.symmetric(horizontal: 14), + ), + child: Text(actionLabel!), + ), + ], + ], + ), + ), + ), + ), + ); + } +} diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index e2dfb60..f94a454 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -28,6 +28,7 @@ "videoPending": "Video pending", "watchNow": "Watch free", "noSearchResults": "No matching dramas.", + "emptyHint": "New content will appear here.", "demoCatalogNotice": "Three demo dramas share the same local video.", "myTab": "My", "localViewer": "Local Viewer", diff --git a/lib/l10n/app_id.arb b/lib/l10n/app_id.arb index 55e5409..92ea241 100644 --- a/lib/l10n/app_id.arb +++ b/lib/l10n/app_id.arb @@ -28,6 +28,7 @@ "videoPending": "Video belum siap", "watchNow": "Tonton gratis", "noSearchResults": "Tidak ada drama yang cocok.", + "emptyHint": "Konten baru akan muncul di sini.", "demoCatalogNotice": "Tiga drama demo memakai video lokal yang sama.", "myTab": "Saya", "localViewer": "Penonton Lokal", diff --git a/lib/l10n/app_localizations.dart b/lib/l10n/app_localizations.dart index 5b57f1c..4c04af7 100644 --- a/lib/l10n/app_localizations.dart +++ b/lib/l10n/app_localizations.dart @@ -268,6 +268,12 @@ abstract class AppLocalizations { /// **'No matching dramas.'** String get noSearchResults; + /// No description provided for @emptyHint. + /// + /// In en, this message translates to: + /// **'New content will appear here.'** + String get emptyHint; + /// No description provided for @demoCatalogNotice. /// /// In en, this message translates to: diff --git a/lib/l10n/app_localizations_en.dart b/lib/l10n/app_localizations_en.dart index 42cf09b..39f794a 100644 --- a/lib/l10n/app_localizations_en.dart +++ b/lib/l10n/app_localizations_en.dart @@ -94,6 +94,9 @@ class AppLocalizationsEn extends AppLocalizations { @override String get noSearchResults => 'No matching dramas.'; + @override + String get emptyHint => 'New content will appear here.'; + @override String get demoCatalogNotice => 'Three demo dramas share the same local video.'; diff --git a/lib/l10n/app_localizations_id.dart b/lib/l10n/app_localizations_id.dart index 7e05221..fa6c474 100644 --- a/lib/l10n/app_localizations_id.dart +++ b/lib/l10n/app_localizations_id.dart @@ -94,6 +94,9 @@ class AppLocalizationsId extends AppLocalizations { @override String get noSearchResults => 'Tidak ada drama yang cocok.'; + @override + String get emptyHint => 'Konten baru akan muncul di sini.'; + @override String get demoCatalogNotice => 'Tiga drama demo memakai video lokal yang sama.'; diff --git a/lib/l10n/app_localizations_zh.dart b/lib/l10n/app_localizations_zh.dart index f0a608a..23a1192 100644 --- a/lib/l10n/app_localizations_zh.dart +++ b/lib/l10n/app_localizations_zh.dart @@ -92,6 +92,9 @@ class AppLocalizationsZh extends AppLocalizations { @override String get noSearchResults => '没有匹配的短剧。'; + @override + String get emptyHint => '有新内容时会显示在这里。'; + @override String get demoCatalogNotice => '三部演示短剧共用同一条本地视频。'; diff --git a/lib/l10n/app_zh.arb b/lib/l10n/app_zh.arb index 71a6cb8..c3d1daa 100644 --- a/lib/l10n/app_zh.arb +++ b/lib/l10n/app_zh.arb @@ -28,6 +28,7 @@ "videoPending": "视频待提供", "watchNow": "免费观看", "noSearchResults": "没有匹配的短剧。", + "emptyHint": "有新内容时会显示在这里。", "demoCatalogNotice": "三部演示短剧共用同一条本地视频。", "myTab": "我的", "localViewer": "本地观众", diff --git a/lib/pages/discover/discover_view.dart b/lib/pages/discover/discover_view.dart index 5a1a97a..abf62df 100644 --- a/lib/pages/discover/discover_view.dart +++ b/lib/pages/discover/discover_view.dart @@ -11,6 +11,7 @@ import '../../core/data/services/catalog_controller.dart'; import '../../core/data/services/category_controller.dart'; import '../../core/theme/app_colors.dart'; import '../../core/theme/app_theme.dart'; +import '../../core/widgets/empty_state.dart'; import '../../core/widgets/remote_image.dart'; import '../../l10n/app_localizations.dart'; import 'discover_binding.dart'; diff --git a/lib/pages/discover/widgets/home_drama_grid.dart b/lib/pages/discover/widgets/home_drama_grid.dart index de34d95..8ee80e3 100644 --- a/lib/pages/discover/widgets/home_drama_grid.dart +++ b/lib/pages/discover/widgets/home_drama_grid.dart @@ -44,14 +44,19 @@ class _HomeDramaGrid extends StatelessWidget { final dramas = categories.visibleDramas; if (dramas.isEmpty) { + final missingCategory = categories.selectedSectionMissing; return SliverPadding( padding: const EdgeInsets.fromLTRB(16, 6, 16, 24), sliver: SliverToBoxAdapter( - child: Text( - categories.selectedSectionMissing + child: EmptyState( + key: const Key('home-all-dramas-empty'), + icon: missingCategory + ? Icons.grid_view_rounded + : Icons.search_off_rounded, + title: missingCategory ? l10n.noCategoryDramas : l10n.noSearchResults, - style: const TextStyle(color: AppColors.muted), + subtitle: l10n.emptyHint, ), ), ); diff --git a/lib/pages/downloads/downloads_page.dart b/lib/pages/downloads/downloads_page.dart index 4247658..3064507 100644 --- a/lib/pages/downloads/downloads_page.dart +++ b/lib/pages/downloads/downloads_page.dart @@ -15,6 +15,7 @@ import '../../core/platform/haptics.dart'; import '../../core/theme/app_colors.dart'; import '../../core/theme/app_theme.dart'; import '../../core/widgets/auth_gate.dart'; +import '../../core/widgets/empty_state.dart'; import '../../l10n/app_localizations.dart'; import 'downloads_binding.dart'; @@ -144,14 +145,11 @@ class _DownloadsBody extends StatelessWidget { ], ), if (downloads.licenses.isEmpty) - Padding( + EmptyState( key: const Key('downloads-empty'), - padding: const EdgeInsets.symmetric(vertical: 34), - child: Text( - l10n.noDownloads, - textAlign: TextAlign.center, - style: const TextStyle(color: Colors.white70), - ), + icon: Icons.download_outlined, + title: l10n.noDownloads, + subtitle: l10n.emptyHint, ) else for (final license in downloads.licenses) ...[ diff --git a/lib/pages/drama_detail/drama_detail_view.dart b/lib/pages/drama_detail/drama_detail_view.dart index f52b8de..6dd8bd4 100644 --- a/lib/pages/drama_detail/drama_detail_view.dart +++ b/lib/pages/drama_detail/drama_detail_view.dart @@ -17,6 +17,7 @@ import '../../core/theme/app_theme.dart'; import '../../core/widgets/remote_image.dart'; import '../../core/widgets/auth_gate.dart'; import '../../core/widgets/download_action.dart'; +import '../../core/widgets/empty_state.dart'; import '../../l10n/app_localizations.dart'; import '../interaction/widgets/report_dialog.dart'; import 'drama_detail_binding.dart'; @@ -114,28 +115,13 @@ class _DramaDetailPageState extends State { foregroundColor: Colors.white, title: Text(localizedDramaTitle(l10n, drama)), ), - body: Center( - child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 32), - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - const Icon( - Icons.movie_filter_outlined, - size: 48, - color: Colors.white38, - ), - const SizedBox(height: 12), - Text( - l10n.noEpisodesYet, - textAlign: TextAlign.center, - style: const TextStyle(color: Colors.white70), - ), - const SizedBox(height: 16), - FilledButton(onPressed: _load, child: Text(l10n.retry)), - ], - ), - ), + body: EmptyState( + key: const Key('drama-detail-empty'), + icon: Icons.video_library_outlined, + title: l10n.noEpisodesYet, + subtitle: l10n.emptyHint, + actionLabel: l10n.retry, + onAction: _load, ), ); } diff --git a/lib/pages/favorites/favorites_page.dart b/lib/pages/favorites/favorites_page.dart index 7033488..032695b 100644 --- a/lib/pages/favorites/favorites_page.dart +++ b/lib/pages/favorites/favorites_page.dart @@ -12,6 +12,7 @@ import '../../core/formatting/error_text.dart'; import '../../core/platform/haptics.dart'; import '../../core/theme/app_theme.dart'; import '../../core/widgets/auth_gate.dart'; +import '../../core/widgets/empty_state.dart'; import '../../core/widgets/library_drama_tile.dart'; import '../../l10n/app_localizations.dart'; import '../drama_detail/drama_detail_view.dart'; @@ -101,12 +102,11 @@ class _FavoritesBody extends StatelessWidget { ); } if (favorites.cards.isEmpty) { - return Center( + return EmptyState( key: const Key('favorites-empty'), - child: Text( - l10n.noFavorites, - style: const TextStyle(color: Colors.white70), - ), + icon: Icons.favorite_border_rounded, + title: l10n.noFavorites, + subtitle: l10n.emptyHint, ); } return RefreshIndicator( diff --git a/lib/pages/home/home_view.dart b/lib/pages/home/home_view.dart index e19b838..51c15a2 100644 --- a/lib/pages/home/home_view.dart +++ b/lib/pages/home/home_view.dart @@ -14,6 +14,7 @@ import '../../core/platform/haptics.dart'; import '../../core/theme/app_colors.dart'; import '../../core/theme/app_theme.dart'; import '../../core/widgets/auth_gate.dart'; +import '../../core/widgets/empty_state.dart'; import '../../l10n/app_localizations.dart'; import '../discover/discover_view.dart'; import '../mine/mine_view.dart'; @@ -46,14 +47,20 @@ class HomePage extends StatelessWidget { body: Center(child: CircularProgressIndicator()), ); } - if (catalog.error != null || catalog.dramas.isEmpty) { + if (catalog.error != null) { return Scaffold( backgroundColor: Colors.black, body: Center( child: Column( mainAxisSize: MainAxisSize.min, children: [ - Text(catalog.error == null ? l10n.noStories : l10n.catalogError), + const Icon( + Icons.error_outline_rounded, + color: Colors.white70, + size: 40, + ), + const SizedBox(height: 12), + Text(l10n.catalogError), const SizedBox(height: 12), FilledButton(onPressed: catalog.load, child: Text(l10n.retry)), if (kDebugMode) ...[ @@ -68,6 +75,19 @@ class HomePage extends StatelessWidget { ), ); } + if (catalog.dramas.isEmpty) { + return Scaffold( + backgroundColor: Colors.black, + body: EmptyState( + key: const Key('home-empty'), + icon: Icons.movie_outlined, + title: l10n.noStories, + subtitle: l10n.emptyHint, + actionLabel: l10n.retry, + onAction: catalog.load, + ), + ); + } return _HomeTabs( key: ValueKey(catalog.dramas.first.id), diff --git a/lib/pages/mine/mine_view.dart b/lib/pages/mine/mine_view.dart index c88d785..d0fe868 100644 --- a/lib/pages/mine/mine_view.dart +++ b/lib/pages/mine/mine_view.dart @@ -12,6 +12,7 @@ import '../../core/data/services/auth_controller.dart'; import '../../core/data/services/interaction_controller.dart'; import '../../core/data/services/favorite_controller.dart'; import '../../core/formatting/error_text.dart'; +import '../../core/widgets/empty_state.dart'; import '../../core/widgets/remote_image.dart'; import '../../core/theme/app_colors.dart'; import '../../core/theme/app_theme.dart'; @@ -670,12 +671,11 @@ class _MyPageState extends State { const SizedBox(height: 9), ] else - Padding( - padding: const EdgeInsets.symmetric(vertical: 22), - child: Text( - l10n.noSavedShows, - style: const TextStyle(color: Color(0xFFE6E1E3)), - ), + EmptyState( + key: const Key('mine-saved-empty'), + icon: Icons.bookmark_border_rounded, + title: l10n.noSavedShows, + subtitle: l10n.emptyHint, ), // 最近观看(服务端 /app/watch/recent):只渲染能在已加载目录里匹配到的剧; // 匹配不到的(例如不在当前首页分区里)先不显示,K2 的记录页会做独立请求。 @@ -732,9 +732,11 @@ class _MyPageState extends State { ], ) else if (_recentDramas.isEmpty) - Text( - l10n.noStories, - style: const TextStyle(color: Color(0xFFB7B3B8)), + EmptyState( + key: const Key('mine-recent-empty'), + icon: Icons.history_rounded, + title: l10n.noStories, + subtitle: l10n.emptyHint, ) else for (final drama in _recentDramas) ...[ diff --git a/lib/pages/notices/notices_page.dart b/lib/pages/notices/notices_page.dart index e46ba02..7d2864b 100644 --- a/lib/pages/notices/notices_page.dart +++ b/lib/pages/notices/notices_page.dart @@ -12,6 +12,7 @@ import '../../core/formatting/error_text.dart'; import '../../core/formatting/localized_date_time.dart'; import '../../core/theme/app_colors.dart'; import '../../core/theme/app_theme.dart'; +import '../../core/widgets/empty_state.dart'; import '../../l10n/app_localizations.dart'; /// Anonymous system notice list with pagination and detail dialog. @@ -109,12 +110,11 @@ class _NoticesPageState extends State { children: [ SizedBox( height: MediaQuery.sizeOf(context).height * 0.7, - child: Center( + child: EmptyState( key: const Key('notices-empty'), - child: Text( - l10n.noNotices, - style: const TextStyle(color: AppColors.muted), - ), + icon: Icons.notifications_none_rounded, + title: l10n.noNotices, + subtitle: l10n.emptyHint, ), ), ], diff --git a/lib/pages/player/widgets/drama_comments_sheet.dart b/lib/pages/player/widgets/drama_comments_sheet.dart index 363321b..2926c2a 100644 --- a/lib/pages/player/widgets/drama_comments_sheet.dart +++ b/lib/pages/player/widgets/drama_comments_sheet.dart @@ -14,6 +14,7 @@ import '../../../core/formatting/error_text.dart'; import '../../../core/platform/haptics.dart'; import '../../../core/theme/app_colors.dart'; import '../../../core/widgets/auth_gate.dart'; +import '../../../core/widgets/empty_state.dart'; import '../../../l10n/app_localizations.dart'; import '../../interaction/widgets/report_dialog.dart'; import 'comment_tile.dart'; @@ -219,12 +220,11 @@ class _DramaCommentsSheetState extends State { ); } if (_controller.comments.isEmpty) { - return Center( + return EmptyState( key: const Key('comment-list-empty'), - child: Text( - l10n.noComments, - style: const TextStyle(color: AppColors.muted), - ), + icon: Icons.chat_bubble_outline_rounded, + title: l10n.noComments, + compact: true, ); } return ListView.builder( diff --git a/lib/pages/watch_records/watch_records_page.dart b/lib/pages/watch_records/watch_records_page.dart index 51c9f8f..130efc6 100644 --- a/lib/pages/watch_records/watch_records_page.dart +++ b/lib/pages/watch_records/watch_records_page.dart @@ -17,6 +17,7 @@ import '../../core/platform/haptics.dart'; import '../../core/theme/app_colors.dart'; import '../../core/theme/app_theme.dart'; import '../../core/widgets/auth_gate.dart'; +import '../../core/widgets/empty_state.dart'; import '../../core/widgets/remote_image.dart'; import '../../l10n/app_localizations.dart'; import '../drama_detail/drama_detail_view.dart'; @@ -92,11 +93,11 @@ class _WatchRecordsBodyState extends State<_WatchRecordsBody> { ); } if (controller.records.isEmpty) { - return Center( - child: Text( - l10n.noWatchRecords, - style: const TextStyle(color: Colors.white70), - ), + return EmptyState( + key: const Key('watch-records-empty'), + icon: Icons.history_rounded, + title: l10n.noWatchRecords, + subtitle: l10n.emptyHint, ); } return Column( diff --git a/test/comment/drama_comments_sheet_test.dart b/test/comment/drama_comments_sheet_test.dart index 3cadf2d..c2b2b21 100644 --- a/test/comment/drama_comments_sheet_test.dart +++ b/test/comment/drama_comments_sheet_test.dart @@ -12,6 +12,7 @@ import 'package:fruitshorts/core/data/repositories/interaction_repository.dart'; import 'package:fruitshorts/core/data/services/auth_controller.dart'; import 'package:fruitshorts/core/data/services/auth_session_store.dart'; import 'package:fruitshorts/core/platform/haptics.dart'; +import 'package:fruitshorts/core/widgets/empty_state.dart'; import 'package:fruitshorts/l10n/app_localizations.dart'; import 'package:fruitshorts/pages/player/widgets/drama_comments_sheet.dart'; import 'package:provider/provider.dart'; @@ -68,6 +69,19 @@ void main() { expect(repository.pageCalls.last.cursor, '10'); }); + testWidgets('should_show_compact_empty_state_when_no_comments_exist', ( + tester, + ) async { + final repository = FakeCommentRepository(pages: [const CommentPage()]); + + await _pumpSheet(tester, repository: repository); + + expect(find.byKey(const Key('comment-list-empty')), findsOneWidget); + expect(find.byType(EmptyState), findsOneWidget); + expect(tester.widget(find.byType(EmptyState)).compact, isTrue); + expect(find.text('No comments yet.'), findsOneWidget); + }); + testWidgets( 'should_keep_input_and_show_backend_message_when_comment_is_blocked', (tester) async { diff --git a/test/download/downloads_page_test.dart b/test/download/downloads_page_test.dart index 2866d09..af2c1de 100644 --- a/test/download/downloads_page_test.dart +++ b/test/download/downloads_page_test.dart @@ -11,6 +11,7 @@ import 'package:fruitshorts/core/data/services/auth_controller.dart'; import 'package:fruitshorts/core/data/services/auth_session_store.dart'; import 'package:fruitshorts/core/data/services/download_controller.dart'; import 'package:fruitshorts/core/platform/haptics.dart'; +import 'package:fruitshorts/core/widgets/empty_state.dart'; import 'package:fruitshorts/l10n/app_localizations.dart'; import 'package:fruitshorts/pages/downloads/downloads_page.dart'; import 'package:provider/provider.dart'; @@ -90,6 +91,7 @@ void main() { await _pumpPage(tester, auth: auth, controller: controller); expect(find.byKey(const Key('downloads-empty')), findsOneWidget); + expect(find.byType(EmptyState), findsOneWidget); }); testWidgets('should_show_retry_when_policy_or_list_load_fails', ( @@ -163,6 +165,7 @@ void main() { expect(repository.clearCalls, 1); expect(haptics.mediumImpacts, 1); expect(find.byKey(const Key('downloads-empty')), findsOneWidget); + expect(find.byType(EmptyState), findsOneWidget); }); testWidgets( diff --git a/test/empty_state/empty_state_test.dart b/test/empty_state/empty_state_test.dart new file mode 100644 index 0000000..aa6cdec --- /dev/null +++ b/test/empty_state/empty_state_test.dart @@ -0,0 +1,149 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; + +import 'package:fruitshorts/core/theme/app_colors.dart'; +import 'package:fruitshorts/core/theme/app_theme.dart'; +import 'package:fruitshorts/core/widgets/empty_state.dart'; + +void main() { + testWidgets('should_render_title_subtitle_action_and_title_only_semantics', ( + tester, + ) async { + var taps = 0; + await _pump( + tester, + theme: AppTheme.dark(), + child: EmptyState( + icon: Icons.movie_outlined, + title: 'No stories', + subtitle: 'New content will appear here.', + actionLabel: 'Retry', + onAction: () => taps++, + ), + ); + + expect(find.byKey(const Key('empty-state-art')), findsOneWidget); + expect(find.byKey(const Key('empty-state-icon')), findsOneWidget); + expect(find.text('No stories'), findsOneWidget); + expect(find.text('New content will appear here.'), findsOneWidget); + expect( + tester.getSize(find.byKey(const Key('empty-state-art'))), + const Size(96, 96), + ); + expect( + tester.getSize(find.byKey(const Key('empty-state-icon'))), + const Size(42, 42), + ); + expect( + tester + .widget(find.byKey(const Key('empty-state-title'))) + .style + ?.fontSize, + 16, + ); + expect( + tester.getSize(find.byKey(const Key('empty-state-action'))).height, + greaterThanOrEqualTo(44), + ); + + final semantics = tester.ensureSemantics(); + expect(find.bySemanticsLabel('No stories'), findsOneWidget); + expect( + find.bySemanticsLabel('New content will appear here.'), + findsNothing, + ); + + await tester.tap(find.byKey(const Key('empty-state-action'))); + expect(taps, 1); + semantics.dispose(); + }); + + testWidgets('should_render_compact_dimensions_for_embedded_empty_state', ( + tester, + ) async { + await _pump( + tester, + child: const EmptyState( + icon: Icons.chat_bubble_outline_rounded, + title: 'No comments yet.', + compact: true, + ), + ); + + expect( + tester.getSize(find.byKey(const Key('empty-state-art'))), + const Size(64, 64), + ); + expect( + tester.getSize(find.byKey(const Key('empty-state-icon'))), + const Size(28, 28), + ); + expect( + tester + .widget(find.byKey(const Key('empty-state-title'))) + .style + ?.fontSize, + 14, + ); + expect(find.byKey(const Key('empty-state-action')), findsNothing); + }); + + testWidgets('should_use_theme_aware_icon_colors', (tester) async { + await _pump( + tester, + theme: AppTheme.dark(), + child: const EmptyState(icon: Icons.history_rounded, title: 'No history'), + ); + expect( + tester.widget(find.byKey(const Key('empty-state-icon'))).color, + AppColors.blueSoft, + ); + + await _pump( + tester, + theme: AppTheme.light(), + child: const EmptyState(icon: Icons.history_rounded, title: 'No history'), + ); + expect( + tester.widget(find.byKey(const Key('empty-state-icon'))).color, + AppColors.blue, + ); + }); + + testWidgets('should_fit_compact_width_without_overflow', (tester) async { + tester.view.physicalSize = const Size(320, 568); + tester.view.devicePixelRatio = 1; + addTearDown(tester.view.resetPhysicalSize); + addTearDown(tester.view.resetDevicePixelRatio); + + await _pump( + tester, + child: const EmptyState( + icon: Icons.download_outlined, + title: 'No download authorizations yet.', + subtitle: 'New content will appear here.', + actionLabel: 'Retry', + ), + ); + + final content = tester.widget( + find.byKey(const Key('empty-state-content')), + ); + expect(content.constraints.maxWidth, 280); + expect(tester.takeException(), isNull); + }); +} + +Future _pump( + WidgetTester tester, { + ThemeData? theme, + required Widget child, +}) async { + await tester.pumpWidget( + MaterialApp( + theme: theme ?? AppTheme.dark(), + home: Scaffold(body: child), + ), + ); + await tester.pumpAndSettle(); +} diff --git a/test/library/favorites_page_test.dart b/test/library/favorites_page_test.dart index 8e2b0ff..3d12478 100644 --- a/test/library/favorites_page_test.dart +++ b/test/library/favorites_page_test.dart @@ -10,6 +10,7 @@ import 'package:fruitshorts/core/data/services/auth_controller.dart'; import 'package:fruitshorts/core/data/services/auth_session_store.dart'; import 'package:fruitshorts/core/data/services/favorite_controller.dart'; import 'package:fruitshorts/core/platform/haptics.dart'; +import 'package:fruitshorts/core/widgets/empty_state.dart'; import 'package:fruitshorts/l10n/app_localizations.dart'; import 'package:fruitshorts/pages/favorites/favorites_page.dart'; import 'package:provider/provider.dart'; @@ -83,6 +84,7 @@ void main() { await _pumpPage(tester, auth: auth, favorites: favorites); expect(find.byKey(const Key('favorites-empty')), findsOneWidget); + expect(find.byType(EmptyState), findsOneWidget); }); testWidgets('should_show_retry_when_favorite_list_fails', (tester) async { diff --git a/test/notice/notices_page_test.dart b/test/notice/notices_page_test.dart index 7252b2e..8ec1a6b 100644 --- a/test/notice/notices_page_test.dart +++ b/test/notice/notices_page_test.dart @@ -6,6 +6,7 @@ import 'package:fruitshorts/core/data/models/notice.dart'; import 'package:fruitshorts/core/data/remote/api_client.dart'; import 'package:fruitshorts/core/data/repositories/notice_repository.dart'; import 'package:fruitshorts/core/formatting/localized_date_time.dart'; +import 'package:fruitshorts/core/widgets/empty_state.dart'; import 'package:fruitshorts/l10n/app_localizations.dart'; import 'package:fruitshorts/pages/notices/notices_page.dart'; import 'package:provider/provider.dart'; @@ -39,6 +40,7 @@ void main() { ); expect(find.byKey(const Key('notices-empty')), findsOneWidget); + expect(find.byType(EmptyState), findsOneWidget); }); testWidgets('should_show_backend_error_and_retry_when_page_fails', ( diff --git a/test/watch/watch_records_page_test.dart b/test/watch/watch_records_page_test.dart index 37330b6..d8c99e3 100644 --- a/test/watch/watch_records_page_test.dart +++ b/test/watch/watch_records_page_test.dart @@ -12,6 +12,7 @@ import 'package:fruitshorts/core/data/repositories/watch_history_repository.dart import 'package:fruitshorts/core/data/services/auth_controller.dart'; import 'package:fruitshorts/core/data/services/auth_session_store.dart'; import 'package:fruitshorts/core/platform/haptics.dart'; +import 'package:fruitshorts/core/widgets/empty_state.dart'; import 'package:fruitshorts/l10n/app_localizations.dart'; import 'package:fruitshorts/pages/watch_records/watch_records_page.dart'; import 'package:provider/provider.dart'; @@ -124,6 +125,7 @@ void main() { expect(history.clearCalls, 1); expect(haptics.mediumImpacts, 1); expect(find.text('No watch history yet.'), findsOneWidget); + expect(find.byType(EmptyState), findsOneWidget); }, ); -- 2.54.0 From f0db631fa20f857f0abcb04b8ed251f3ee0420c3 Mon Sep 17 00:00:00 2001 From: Zhou Weidong <502333560@qq.com> Date: Sat, 17 Oct 2026 22:34:14 +0800 Subject: [PATCH 26/76] =?UTF-8?q?feat(flutter):=20=E9=A6=96=E9=A1=B5?= =?UTF-8?q?=E7=BD=91=E6=A0=BC=E6=94=B9=E4=B8=BA=E4=B8=89=E5=88=97=E5=B9=B6?= =?UTF-8?q?=E9=A6=96=E4=BD=8D=E6=98=BE=E7=A4=BA=E5=85=A8=E9=83=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/pages/discover/discover_view.dart | 2 +- lib/pages/discover/widgets/home_drama_grid.dart | 6 +++--- test/discover/home_all_dramas_grid_test.dart | 16 +++++++++++----- test/widget_test.dart | 4 ++-- 4 files changed, 17 insertions(+), 11 deletions(-) diff --git a/lib/pages/discover/discover_view.dart b/lib/pages/discover/discover_view.dart index abf62df..0dc2d53 100644 --- a/lib/pages/discover/discover_view.dart +++ b/lib/pages/discover/discover_view.dart @@ -270,7 +270,7 @@ class _DiscoverPageState extends State { Widget _categories(AppLocalizations l10n, CategoryController categories) { final choices = <({String code, String label})>[ - (code: CategoryController.allCode, label: l10n.forYou), + (code: CategoryController.allCode, label: l10n.all), (code: CategoryController.hotCode, label: l10n.hot), (code: CategoryController.newCode, label: l10n.newest), for (final category in categories.categories) diff --git a/lib/pages/discover/widgets/home_drama_grid.dart b/lib/pages/discover/widgets/home_drama_grid.dart index 8ee80e3..fa1e345 100644 --- a/lib/pages/discover/widgets/home_drama_grid.dart +++ b/lib/pages/discover/widgets/home_drama_grid.dart @@ -68,9 +68,9 @@ class _HomeDramaGrid extends StatelessWidget { sliver: SliverGrid( key: const Key('home-all-dramas-grid'), gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( - crossAxisCount: 2, - mainAxisSpacing: 16, - crossAxisSpacing: 12, + crossAxisCount: 3, + mainAxisSpacing: 14, + crossAxisSpacing: 10, childAspectRatio: 2 / 3, ), delegate: SliverChildBuilderDelegate( diff --git a/test/discover/home_all_dramas_grid_test.dart b/test/discover/home_all_dramas_grid_test.dart index e724439..90652be 100644 --- a/test/discover/home_all_dramas_grid_test.dart +++ b/test/discover/home_all_dramas_grid_test.dart @@ -25,7 +25,7 @@ void main() { }); testWidgets( - 'should_show_all_dramas_in_two_column_sliver_grid_without_continue_watching', + 'should_show_all_dramas_in_three_column_sliver_grid_without_continue_watching', (tester) async { tester.view.physicalSize = const Size(390, 844); tester.view.devicePixelRatio = 1; @@ -38,15 +38,21 @@ void main() { expect(find.text('Continue Watching'), findsNothing); expect(find.text('All Dramas'), findsOneWidget); + expect(find.text('All'), findsOneWidget); + expect(find.text('For You'), findsNothing); + expect( + tester.getCenter(find.text('All')).dx, + lessThan(tester.getCenter(find.text('Hot')).dx), + ); final grid = tester.widget( find.byKey(const Key('home-all-dramas-grid')), ); final delegate = grid.gridDelegate as SliverGridDelegateWithFixedCrossAxisCount; - expect(delegate.crossAxisCount, 2); - expect(delegate.crossAxisSpacing, 12); - expect(delegate.mainAxisSpacing, 16); + expect(delegate.crossAxisCount, 3); + expect(delegate.crossAxisSpacing, 10); + expect(delegate.mainAxisSpacing, 14); expect(delegate.childAspectRatio, closeTo(2 / 3, 0.001)); expect( tester @@ -154,7 +160,7 @@ void main() { expect(find.byKey(const Key('home-all-dramas-grid')), findsNothing); }); - testWidgets('should_fit_two_column_grid_on_compact_screen', (tester) async { + testWidgets('should_fit_three_column_grid_on_compact_screen', (tester) async { tester.view.physicalSize = const Size(320, 568); tester.view.devicePixelRatio = 1; addTearDown(tester.view.resetPhysicalSize); diff --git a/test/widget_test.dart b/test/widget_test.dart index 6f86ddf..93d3eaf 100644 --- a/test/widget_test.dart +++ b/test/widget_test.dart @@ -225,7 +225,7 @@ void main() { expect(find.text('首页'), findsOneWidget); await tester.tap(find.text('首页')); await tester.pumpAndSettle(); - expect(find.text('为你推荐'), findsOneWidget); + expect(find.text('全部'), findsOneWidget); expect(find.text('热门'), findsOneWidget); }); @@ -312,7 +312,7 @@ void main() { await tester.tap(find.text('Home')); await tester.pumpAndSettle(); - expect(find.text('For You'), findsOneWidget); + expect(find.text('All'), findsOneWidget); expect(find.text('All Dramas'), findsOneWidget); expect(find.text('Rewards'), findsOneWidget); expect(find.text(r'$ 0'), findsOneWidget); -- 2.54.0 From 2dd4627bdcbaf20762388337379ffb5f96943621 Mon Sep 17 00:00:00 2001 From: Zhou Weidong <502333560@qq.com> Date: Sat, 17 Oct 2026 22:44:21 +0800 Subject: [PATCH 27/76] =?UTF-8?q?feat(flutter):=20=E7=B2=BE=E7=AE=80?= =?UTF-8?q?=E9=A6=96=E9=A1=B5=E6=A0=87=E9=A2=98=E5=B9=B6=E9=87=8D=E5=81=9A?= =?UTF-8?q?=E7=A9=BA=E6=80=81=E8=A7=86=E8=A7=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/core/widgets/empty_state.dart | 71 +++++++++++++------- lib/pages/discover/discover_view.dart | 21 +----- test/discover/home_all_dramas_grid_test.dart | 19 ++++-- test/empty_state/empty_state_test.dart | 51 ++++++++++++-- test/widget_test.dart | 28 +++++--- 5 files changed, 127 insertions(+), 63 deletions(-) diff --git a/lib/core/widgets/empty_state.dart b/lib/core/widgets/empty_state.dart index b9b6093..3aac4f7 100644 --- a/lib/core/widgets/empty_state.dart +++ b/lib/core/widgets/empty_state.dart @@ -4,15 +4,17 @@ import 'package:flutter/material.dart'; import '../theme/app_colors.dart'; -const double _regularArtSize = 96; -const double _compactArtSize = 64; -const double _regularIconSize = 42; -const double _compactIconSize = 28; -const double _regularRadius = 28; -const double _compactRadius = 18; -const double _maxContentWidth = 280; +const double _regularArtSize = 84; +const double _compactArtSize = 60; +const double _regularInnerSize = 56; +const double _compactInnerSize = 40; +const double _regularIconSize = 27; +const double _compactIconSize = 21; +const double _maxContentWidth = 260; const double _actionMinHeight = 44; -const double _artOpacity = 0.11; +const double _outerArtOpacity = 0.055; +const double _outerBorderOpacity = 0.11; +const double _innerArtOpacity = 0.11; /// 统一空列表占位:柔和图标、标题、可选说明与操作。 class EmptyState extends StatelessWidget { @@ -39,6 +41,7 @@ class EmptyState extends StatelessWidget { final dark = Theme.of(context).brightness == Brightness.dark; final iconColor = dark ? AppColors.blueSoft : AppColors.blue; final artSize = compact ? _compactArtSize : _regularArtSize; + final innerSize = compact ? _compactInnerSize : _regularInnerSize; final iconSize = compact ? _compactIconSize : _regularIconSize; final hasAction = actionLabel != null && onAction != null; return Center( @@ -46,7 +49,11 @@ class EmptyState extends StatelessWidget { key: const Key('empty-state-content'), constraints: const BoxConstraints(maxWidth: _maxContentWidth), child: Padding( - padding: EdgeInsets.all(compact ? 16 : 24), + key: const Key('empty-state-padding'), + padding: EdgeInsets.symmetric( + horizontal: compact ? 16 : 24, + vertical: compact ? 16 : 28, + ), child: Semantics( container: true, label: title, @@ -60,20 +67,35 @@ class EmptyState extends StatelessWidget { height: artSize, alignment: Alignment.center, decoration: BoxDecoration( - color: AppColors.blue.withValues(alpha: _artOpacity), - borderRadius: BorderRadius.circular( - compact ? _compactRadius : _regularRadius, + shape: BoxShape.circle, + color: AppColors.blue.withValues(alpha: _outerArtOpacity), + border: Border.all( + color: AppColors.blue.withValues( + alpha: _outerBorderOpacity, + ), ), ), - child: Icon( - icon, - key: const Key('empty-state-icon'), - size: iconSize, - color: iconColor, + child: Container( + key: const Key('empty-state-art-inner'), + width: innerSize, + height: innerSize, + alignment: Alignment.center, + decoration: BoxDecoration( + shape: BoxShape.circle, + color: AppColors.blue.withValues( + alpha: _innerArtOpacity, + ), + ), + child: Icon( + icon, + key: const Key('empty-state-icon'), + size: iconSize, + color: iconColor, + ), ), ), ), - SizedBox(height: compact ? 10 : 16), + SizedBox(height: compact ? 10 : 14), ExcludeSemantics( child: Text( title, @@ -83,7 +105,7 @@ class EmptyState extends StatelessWidget { textAlign: TextAlign.center, style: TextStyle( color: scheme.onSurface, - fontSize: compact ? 14 : 16, + fontSize: 15, fontWeight: FontWeight.w600, height: 1.35, ), @@ -99,14 +121,14 @@ class EmptyState extends StatelessWidget { textAlign: TextAlign.center, style: const TextStyle( color: AppColors.muted, - fontSize: 13, - height: 1.4, + fontSize: 12.5, + height: 1.45, ), ), ), ], if (hasAction) ...[ - const SizedBox(height: 10), + const SizedBox(height: 8), TextButton( key: const Key('empty-state-action'), onPressed: onAction, @@ -115,7 +137,10 @@ class EmptyState extends StatelessWidget { minimumSize: const Size(44, _actionMinHeight), padding: const EdgeInsets.symmetric(horizontal: 14), ), - child: Text(actionLabel!), + child: Text( + actionLabel!, + style: const TextStyle(fontSize: 13), + ), ), ], ], diff --git a/lib/pages/discover/discover_view.dart b/lib/pages/discover/discover_view.dart index 0dc2d53..fc8ea7f 100644 --- a/lib/pages/discover/discover_view.dart +++ b/lib/pages/discover/discover_view.dart @@ -144,24 +144,8 @@ class _DiscoverPageState extends State { ), SliverToBoxAdapter( child: Padding( - padding: const EdgeInsets.fromLTRB(16, 18, 16, 12), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - _categories(l10n, categories), - const SizedBox(height: 18), - Text( - l10n.allDramas, - key: const Key('home-all-dramas-title'), - style: const TextStyle( - color: AppColors.onPrimary, - fontSize: 18, - fontWeight: FontWeight.w700, - height: 1.2, - ), - ), - ], - ), + padding: const EdgeInsets.fromLTRB(16, 18, 16, 14), + child: _categories(l10n, categories), ), ), _HomeDramaGrid( @@ -277,6 +261,7 @@ class _DiscoverPageState extends State { (code: 'category-${category.id}', label: category.name), ]; return SizedBox( + key: const Key('home-category-chips'), height: 32, child: ListView.separated( scrollDirection: Axis.horizontal, diff --git a/test/discover/home_all_dramas_grid_test.dart b/test/discover/home_all_dramas_grid_test.dart index 90652be..b6d577f 100644 --- a/test/discover/home_all_dramas_grid_test.dart +++ b/test/discover/home_all_dramas_grid_test.dart @@ -37,13 +37,24 @@ void main() { await tester.pumpAndSettle(); expect(find.text('Continue Watching'), findsNothing); - expect(find.text('All Dramas'), findsOneWidget); + expect(find.byKey(const Key('home-all-dramas-title')), findsNothing); expect(find.text('All'), findsOneWidget); expect(find.text('For You'), findsNothing); expect( tester.getCenter(find.text('All')).dx, lessThan(tester.getCenter(find.text('Hot')).dx), ); + expect( + tester + .getTopLeft( + find.byKey(const Key('home-drama-card-the-signal-demo')), + ) + .dy - + tester + .getBottomLeft(find.byKey(const Key('home-category-chips'))) + .dy, + closeTo(14, 0.1), + ); final grid = tester.widget( find.byKey(const Key('home-all-dramas-grid')), @@ -135,7 +146,7 @@ void main() { await tester.tap(find.byKey(const Key('tab-discover'))); await tester.pumpAndSettle(); - expect(find.text('All Dramas'), findsOneWidget); + expect(find.byKey(const Key('home-all-dramas-title')), findsNothing); expect(find.text('No matching dramas.'), findsOneWidget); await tester.tap(find.text('Romance')); @@ -154,7 +165,7 @@ void main() { await tester.tap(find.byKey(const Key('tab-discover'))); await tester.pumpAndSettle(); - expect(find.text('All Dramas'), findsOneWidget); + expect(find.byKey(const Key('home-all-dramas-title')), findsNothing); expect(find.text('Categories could not be loaded.'), findsOneWidget); expect(find.text('Retry'), findsOneWidget); expect(find.byKey(const Key('home-all-dramas-grid')), findsNothing); @@ -176,7 +187,7 @@ void main() { ); await tester.pumpAndSettle(); - expect(find.text('All Dramas'), findsOneWidget); + expect(find.byKey(const Key('home-all-dramas-title')), findsNothing); expect(find.text('City Lights & Velvet Nights'), findsOneWidget); expect(tester.takeException(), isNull); }); diff --git a/test/empty_state/empty_state_test.dart b/test/empty_state/empty_state_test.dart index aa6cdec..6f9b730 100644 --- a/test/empty_state/empty_state_test.dart +++ b/test/empty_state/empty_state_test.dart @@ -23,24 +23,51 @@ void main() { ); expect(find.byKey(const Key('empty-state-art')), findsOneWidget); + expect(find.byKey(const Key('empty-state-art-inner')), findsOneWidget); expect(find.byKey(const Key('empty-state-icon')), findsOneWidget); expect(find.text('No stories'), findsOneWidget); expect(find.text('New content will appear here.'), findsOneWidget); expect( tester.getSize(find.byKey(const Key('empty-state-art'))), - const Size(96, 96), + const Size(84, 84), + ); + expect( + tester.getSize(find.byKey(const Key('empty-state-art-inner'))), + const Size(56, 56), ); expect( tester.getSize(find.byKey(const Key('empty-state-icon'))), - const Size(42, 42), + const Size(27, 27), + ); + final outer = tester.widget( + find.byKey(const Key('empty-state-art')), + ); + final outerDecoration = outer.decoration! as BoxDecoration; + expect(outerDecoration.shape, BoxShape.circle); + expect(outerDecoration.color?.a, closeTo(0.055, 0.001)); + expect(outerDecoration.border!.top.color.a, closeTo(0.11, 0.001)); + final inner = tester.widget( + find.byKey(const Key('empty-state-art-inner')), + ); + expect((inner.decoration! as BoxDecoration).color?.a, closeTo(0.11, 0.001)); + expect( + tester + .widget(find.byKey(const Key('empty-state-padding'))) + .padding, + const EdgeInsets.symmetric(horizontal: 24, vertical: 28), ); expect( tester .widget(find.byKey(const Key('empty-state-title'))) .style ?.fontSize, - 16, + 15, ); + final subtitle = tester.widget( + find.text('New content will appear here.'), + ); + expect(subtitle.style?.fontSize, 12.5); + expect(tester.widget(find.text('Retry')).style?.fontSize, 13); expect( tester.getSize(find.byKey(const Key('empty-state-action'))).height, greaterThanOrEqualTo(44), @@ -72,18 +99,28 @@ void main() { expect( tester.getSize(find.byKey(const Key('empty-state-art'))), - const Size(64, 64), + const Size(60, 60), + ); + expect( + tester.getSize(find.byKey(const Key('empty-state-art-inner'))), + const Size(40, 40), ); expect( tester.getSize(find.byKey(const Key('empty-state-icon'))), - const Size(28, 28), + const Size(21, 21), ); expect( tester .widget(find.byKey(const Key('empty-state-title'))) .style ?.fontSize, - 14, + 15, + ); + expect( + tester + .widget(find.byKey(const Key('empty-state-padding'))) + .padding, + const EdgeInsets.symmetric(horizontal: 16, vertical: 16), ); expect(find.byKey(const Key('empty-state-action')), findsNothing); }); @@ -129,7 +166,7 @@ void main() { final content = tester.widget( find.byKey(const Key('empty-state-content')), ); - expect(content.constraints.maxWidth, 280); + expect(content.constraints.maxWidth, 260); expect(tester.takeException(), isNull); }); } diff --git a/test/widget_test.dart b/test/widget_test.dart index 93d3eaf..3efc430 100644 --- a/test/widget_test.dart +++ b/test/widget_test.dart @@ -155,7 +155,7 @@ void main() { await tester.pumpWidget(appUnderTest()); await tester.pumpAndSettle(); - expect(find.text('All Dramas'), findsOneWidget); + expect(find.byKey(const Key('home-all-dramas-grid')), findsOneWidget); await tester.binding.handlePopRoute(); await tester.pumpAndSettle(); expect( @@ -186,15 +186,17 @@ void main() { .active, isFalse, ); - expect(find.text('All Dramas'), findsOneWidget); + expect(find.byKey(const Key('home-all-dramas-grid')), findsOneWidget); await tester.binding.handlePopRoute(); await tester.pumpAndSettle(); await tester.tap(find.byKey(const Key('drawer-discover'))); await tester.pumpAndSettle(); - expect(find.text('All Dramas'), findsOneWidget); + expect(find.byKey(const Key('home-all-dramas-grid')), findsOneWidget); expect( - Navigator.of(tester.element(find.text('All Dramas'))).canPop(), + Navigator.of( + tester.element(find.byKey(const Key('home-all-dramas-grid'))), + ).canPop(), isFalse, ); }, @@ -313,7 +315,7 @@ void main() { await tester.pumpAndSettle(); expect(find.text('All'), findsOneWidget); - expect(find.text('All Dramas'), findsOneWidget); + expect(find.byKey(const Key('home-all-dramas-grid')), findsOneWidget); expect(find.text('Rewards'), findsOneWidget); expect(find.text(r'$ 0'), findsOneWidget); expect(find.text('Urban Romance', skipOffstage: false), findsOneWidget); @@ -345,10 +347,12 @@ void main() { await tester.pumpAndSettle(); await tester.tap(find.text('Home')); await tester.pumpAndSettle(); - expect(find.text('All Dramas'), findsOneWidget); + expect(find.byKey(const Key('home-all-dramas-grid')), findsOneWidget); expect(find.byTooltip('Search'), findsNothing); expect( - Navigator.of(tester.element(find.text('All Dramas'))).canPop(), + Navigator.of( + tester.element(find.byKey(const Key('home-all-dramas-grid'))), + ).canPop(), isFalse, ); @@ -365,10 +369,12 @@ void main() { await tester.tap(find.byKey(const Key('tab-discover'))); await tester.pumpAndSettle(); - expect(find.text('All Dramas'), findsOneWidget); + expect(find.byKey(const Key('home-all-dramas-grid')), findsOneWidget); expect(find.byTooltip('Search'), findsNothing); expect( - Navigator.of(tester.element(find.text('All Dramas'))).canPop(), + Navigator.of( + tester.element(find.byKey(const Key('home-all-dramas-grid'))), + ).canPop(), isFalse, ); await tester.tap(find.byKey(const Key('tab-my-list'))); @@ -564,7 +570,7 @@ void main() { await tester.pumpWidget(appUnderTest()); await tester.pumpAndSettle(); - expect(find.text('All Dramas'), findsOneWidget); + expect(find.byKey(const Key('home-all-dramas-grid')), findsOneWidget); await tester.binding.handlePopRoute(); await tester.pumpAndSettle(); expect(find.text('Quick access'), findsOneWidget); @@ -572,7 +578,7 @@ void main() { await tester.binding.handlePopRoute(); await tester.pumpAndSettle(); expect(find.text('Quick access'), findsNothing); - expect(find.text('All Dramas'), findsOneWidget); + expect(find.byKey(const Key('home-all-dramas-grid')), findsOneWidget); expect( Navigator.of( tester.element(find.byKey(const Key('home-tabs-bar'))), -- 2.54.0 From 907562a87449b12a5abf1b5f14807e076975b528 Mon Sep 17 00:00:00 2001 From: Zhou Weidong <502333560@qq.com> Date: Sat, 17 Oct 2026 22:54:07 +0800 Subject: [PATCH 28/76] =?UTF-8?q?feat(flutter):=20=E5=A2=9E=E5=8A=A0=20deb?= =?UTF-8?q?ug=20=E8=BF=90=E8=A1=8C=E6=97=B6=E6=9C=8D=E5=8A=A1=E5=99=A8?= =?UTF-8?q?=E5=9C=B0=E5=9D=80=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/core/config/app_config.dart | 32 +++- lib/core/config/server_endpoint.dart | 86 ++++++++++ lib/l10n/app_en.arb | 6 + lib/l10n/app_id.arb | 6 + lib/l10n/app_localizations.dart | 36 ++++ lib/l10n/app_localizations_en.dart | 18 ++ lib/l10n/app_localizations_id.dart | 19 ++ lib/l10n/app_localizations_zh.dart | 18 ++ lib/l10n/app_zh.arb | 6 + lib/main.dart | 3 + lib/pages/mine/mine_logic.dart | 181 ++++++++++++++++++-- lib/pages/mine/mine_view.dart | 13 +- test/config/server_endpoint_test.dart | 92 ++++++++++ test/mine/server_endpoint_setting_test.dart | 101 +++++++++++ 14 files changed, 590 insertions(+), 27 deletions(-) create mode 100644 lib/core/config/server_endpoint.dart create mode 100644 test/config/server_endpoint_test.dart create mode 100644 test/mine/server_endpoint_setting_test.dart diff --git a/lib/core/config/app_config.dart b/lib/core/config/app_config.dart index a989a8b..00d554c 100644 --- a/lib/core/config/app_config.dart +++ b/lib/core/config/app_config.dart @@ -15,18 +15,28 @@ class AppConfig { /// `ipconfig getifaddr en0` 重新确认并改这里; /// 也可以换成 Bonjour 名字 `http://.local:8081`(本机是 /// `jiangdeMacBook-Air.local`),换网络不用改,但部分办公网会拦组播解析。 - static const String devHostBaseUrl = - 'http://jiangdeMacBook-Air.local:8081'; + static const String devHostBaseUrl = 'http://jiangdeMacBook-Air.local:8081'; static const String _loopbackBaseUrl = 'http://127.0.0.1:8081'; static const String _overrideBaseUrl = String.fromEnvironment('API_BASE_URL'); - static String get apiBaseUrl => - _overrideBaseUrl.isNotEmpty ? _overrideBaseUrl : _defaultBaseUrl; + static String _runtimeBaseUrl = ''; - static final String _defaultBaseUrl = - _runsOnDevMachine ? _loopbackBaseUrl : devHostBaseUrl; + /// Build-time server URL supplied through `--dart-define=API_BASE_URL`. + static String get compiledBaseUrl => _overrideBaseUrl; + + /// Existing platform-aware fallback used when no runtime or build override exists. + static String get defaultBaseUrl => _defaultBaseUrl; + + /// Effective server URL, including the debug-only runtime override. + static String get apiBaseUrl => _runtimeBaseUrl.isNotEmpty + ? _runtimeBaseUrl + : (compiledBaseUrl.isNotEmpty ? compiledBaseUrl : defaultBaseUrl); + + static final String _defaultBaseUrl = _runsOnDevMachine + ? _loopbackBaseUrl + : devHostBaseUrl; /// 模拟器、桌面端与开发机同机,环回地址可用;iOS 真机不满足。 /// Android 没有等价的探测方式,统一按真机处理(模拟器用 @@ -39,6 +49,16 @@ class AppConfig { (defaultTargetPlatform == TargetPlatform.iOS && Platform.environment.containsKey('SIMULATOR_DEVICE_NAME')); + /// Applies an already normalized runtime URL. Passing null clears it. + static void applyRuntimeBaseUrl(String? value) { + _runtimeBaseUrl = value ?? ''; + } + + /// Clears the in-memory runtime override, mainly for tests and restarts. + static void clearRuntimeBaseUrl() { + _runtimeBaseUrl = ''; + } + static const Duration requestTimeout = Duration(seconds: 8); /// 后端返回的是相对路径(/files/...),这里补上服务地址。 diff --git a/lib/core/config/server_endpoint.dart b/lib/core/config/server_endpoint.dart new file mode 100644 index 0000000..332eb6b --- /dev/null +++ b/lib/core/config/server_endpoint.dart @@ -0,0 +1,86 @@ +// Author: fruit.com.cn + +import 'package:flutter/foundation.dart'; +import 'package:shared_preferences/shared_preferences.dart'; + +import 'app_config.dart'; + +/// Debug-only runtime server endpoint persisted outside build-time defines. +abstract final class ServerEndpoint { + /// Preference key used for the runtime server address. + static const String preferenceKey = 'dev.api_base_url'; + + /// Returns a normalized http(s) URL, or null for invalid input. + static String? normalize(String? raw) { + final value = raw?.trim() ?? ''; + final uri = Uri.tryParse(value); + if (uri == null || + (uri.scheme != 'http' && uri.scheme != 'https') || + uri.host.isEmpty) { + return null; + } + return value.replaceFirst(RegExp(r'/+$'), ''); + } + + /// Resolves runtime > dart-define > default using normalized valid values. + static String resolve({ + required String? stored, + required String compiled, + required String fallback, + }) { + return normalize(stored) ?? + normalize(compiled) ?? + normalize(fallback) ?? + fallback; + } + + /// Loads the persisted override before the app creates its ApiClient. + /// + /// In release builds this returns immediately without reading preferences. + static Future load({ + bool debug = kDebugMode, + SharedPreferencesAsync? preferences, + }) async { + if (!debug) return; + try { + final prefs = preferences ?? SharedPreferencesAsync(); + final stored = await prefs.getString(preferenceKey); + AppConfig.applyRuntimeBaseUrl( + resolve( + stored: stored, + compiled: AppConfig.compiledBaseUrl, + fallback: AppConfig.defaultBaseUrl, + ), + ); + } catch (_) { + AppConfig.clearRuntimeBaseUrl(); + } + } + + /// Persists a normalized runtime endpoint. + static Future save( + String raw, { + SharedPreferencesAsync? preferences, + }) async { + final normalized = normalize(raw); + if (normalized == null) return false; + try { + await (preferences ?? SharedPreferencesAsync()).setString( + preferenceKey, + normalized, + ); + return true; + } catch (_) { + return false; + } + } + + /// Removes the persisted runtime endpoint. + static Future clear({SharedPreferencesAsync? preferences}) async { + try { + await (preferences ?? SharedPreferencesAsync()).remove(preferenceKey); + } catch (_) { + // Clearing an optional developer override is best effort. + } + } +} diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index f94a454..18ebcfb 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -262,6 +262,12 @@ "freeBonus": "Get Free Bonus", "watchHistory": "Watch History", "settings": "Settings", + "serverAddress": "Server address", + "serverAddressHint": "http(s)://host:port", + "saveAddress": "Save address", + "restartToApply": "Restart the app to apply.", + "restoreDefault": "Restore default", + "invalidServerAddress": "Enter a valid http(s) server address.", "signOut": "Sign Out", "mockUserName": "Vicky sheng", "mockUserId": "ID: M1CZWVYE", diff --git a/lib/l10n/app_id.arb b/lib/l10n/app_id.arb index 92ea241..ce7eea5 100644 --- a/lib/l10n/app_id.arb +++ b/lib/l10n/app_id.arb @@ -262,6 +262,12 @@ "freeBonus": "Bonus Gratis", "watchHistory": "Riwayat Tontonan", "settings": "Pengaturan", + "serverAddress": "Alamat server", + "serverAddressHint": "http(s)://host:port", + "saveAddress": "Simpan alamat", + "restartToApply": "Mulai ulang aplikasi untuk menerapkan.", + "restoreDefault": "Pulihkan default", + "invalidServerAddress": "Masukkan alamat server http(s) yang valid.", "signOut": "Keluar", "mockUserName": "Vicky sheng", "mockUserId": "ID: M1CZWVYE", diff --git a/lib/l10n/app_localizations.dart b/lib/l10n/app_localizations.dart index 4c04af7..aeed5a1 100644 --- a/lib/l10n/app_localizations.dart +++ b/lib/l10n/app_localizations.dart @@ -1228,6 +1228,42 @@ abstract class AppLocalizations { /// **'Settings'** String get settings; + /// No description provided for @serverAddress. + /// + /// In en, this message translates to: + /// **'Server address'** + String get serverAddress; + + /// No description provided for @serverAddressHint. + /// + /// In en, this message translates to: + /// **'http(s)://host:port'** + String get serverAddressHint; + + /// No description provided for @saveAddress. + /// + /// In en, this message translates to: + /// **'Save address'** + String get saveAddress; + + /// No description provided for @restartToApply. + /// + /// In en, this message translates to: + /// **'Restart the app to apply.'** + String get restartToApply; + + /// No description provided for @restoreDefault. + /// + /// In en, this message translates to: + /// **'Restore default'** + String get restoreDefault; + + /// No description provided for @invalidServerAddress. + /// + /// In en, this message translates to: + /// **'Enter a valid http(s) server address.'** + String get invalidServerAddress; + /// No description provided for @signOut. /// /// In en, this message translates to: diff --git a/lib/l10n/app_localizations_en.dart b/lib/l10n/app_localizations_en.dart index 39f794a..40e3466 100644 --- a/lib/l10n/app_localizations_en.dart +++ b/lib/l10n/app_localizations_en.dart @@ -601,6 +601,24 @@ class AppLocalizationsEn extends AppLocalizations { @override String get settings => 'Settings'; + @override + String get serverAddress => 'Server address'; + + @override + String get serverAddressHint => 'http(s)://host:port'; + + @override + String get saveAddress => 'Save address'; + + @override + String get restartToApply => 'Restart the app to apply.'; + + @override + String get restoreDefault => 'Restore default'; + + @override + String get invalidServerAddress => 'Enter a valid http(s) server address.'; + @override String get signOut => 'Sign Out'; diff --git a/lib/l10n/app_localizations_id.dart b/lib/l10n/app_localizations_id.dart index fa6c474..9063d41 100644 --- a/lib/l10n/app_localizations_id.dart +++ b/lib/l10n/app_localizations_id.dart @@ -603,6 +603,25 @@ class AppLocalizationsId extends AppLocalizations { @override String get settings => 'Pengaturan'; + @override + String get serverAddress => 'Alamat server'; + + @override + String get serverAddressHint => 'http(s)://host:port'; + + @override + String get saveAddress => 'Simpan alamat'; + + @override + String get restartToApply => 'Mulai ulang aplikasi untuk menerapkan.'; + + @override + String get restoreDefault => 'Pulihkan default'; + + @override + String get invalidServerAddress => + 'Masukkan alamat server http(s) yang valid.'; + @override String get signOut => 'Keluar'; diff --git a/lib/l10n/app_localizations_zh.dart b/lib/l10n/app_localizations_zh.dart index 23a1192..8bd6d57 100644 --- a/lib/l10n/app_localizations_zh.dart +++ b/lib/l10n/app_localizations_zh.dart @@ -592,6 +592,24 @@ class AppLocalizationsZh extends AppLocalizations { @override String get settings => '设置'; + @override + String get serverAddress => '服务器地址'; + + @override + String get serverAddressHint => 'http(s)://主机:端口'; + + @override + String get saveAddress => '保存地址'; + + @override + String get restartToApply => '重启 App 生效'; + + @override + String get restoreDefault => '恢复默认'; + + @override + String get invalidServerAddress => '请输入有效的 http(s) 服务器地址。'; + @override String get signOut => '退出登录'; diff --git a/lib/l10n/app_zh.arb b/lib/l10n/app_zh.arb index c3d1daa..625b639 100644 --- a/lib/l10n/app_zh.arb +++ b/lib/l10n/app_zh.arb @@ -224,6 +224,12 @@ "freeBonus": "领免费奖励", "watchHistory": "观看历史", "settings": "设置", + "serverAddress": "服务器地址", + "serverAddressHint": "http(s)://主机:端口", + "saveAddress": "保存地址", + "restartToApply": "重启 App 生效", + "restoreDefault": "恢复默认", + "invalidServerAddress": "请输入有效的 http(s) 服务器地址。", "signOut": "退出登录", "mockUserName": "Vicky sheng", "mockUserId": "ID: M1CZWVYE", diff --git a/lib/main.dart b/lib/main.dart index 23b1398..16769d8 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -2,10 +2,13 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; + import 'app.dart'; +import 'core/config/server_endpoint.dart'; Future main() async { WidgetsFlutterBinding.ensureInitialized(); await SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]); + await ServerEndpoint.load(); runApp(const LumaDramaApp()); } diff --git a/lib/pages/mine/mine_logic.dart b/lib/pages/mine/mine_logic.dart index be6faf8..b2e2f9d 100644 --- a/lib/pages/mine/mine_logic.dart +++ b/lib/pages/mine/mine_logic.dart @@ -1,12 +1,16 @@ // Author: fruit.com.cn +import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; +import '../../core/config/app_config.dart'; import '../../core/config/locale_controller.dart'; +import '../../core/config/server_endpoint.dart'; import '../../core/data/models/drama.dart'; import '../../core/data/models/watch_progress.dart'; import '../../core/data/repositories/watch_history_repository.dart'; +import '../../core/theme/app_colors.dart'; import '../../l10n/app_localizations.dart'; enum MyPageAction { home, discover, resume } @@ -110,39 +114,178 @@ class MineLogic extends ChangeNotifier { } } - Future showLanguage(BuildContext context) async { + Future showLanguage( + BuildContext context, { + bool showServerSetting = kDebugMode, + }) async { final l10n = AppLocalizations.of(context)!; await showModalBottomSheet( context: context, backgroundColor: const Color(0xFF1C1D22), showDragHandle: true, + isScrollControlled: true, builder: (sheetContext) => SafeArea( - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - ListTile(title: Text(l10n.language)), - for (final (code, label) in [ - ('en', l10n.english), - ('zh', l10n.simplifiedChinese), - ('id', l10n.bahasaIndonesia), - ]) - ListTile( - title: Text(label), - onTap: () { - context.read().select(code); - Navigator.pop(sheetContext); - }, - ), - const SizedBox(height: 8), - ], + child: ConstrainedBox( + constraints: BoxConstraints( + maxHeight: MediaQuery.sizeOf(sheetContext).height * 0.85, + ), + child: SingleChildScrollView( + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + ListTile(title: Text(l10n.language)), + for (final (code, label) in [ + ('en', l10n.english), + ('zh', l10n.simplifiedChinese), + ('id', l10n.bahasaIndonesia), + ]) + ListTile( + title: Text(label), + onTap: () { + context.read().select(code); + Navigator.pop(sheetContext); + }, + ), + if (showServerSetting) ...[ + const Divider(height: 1), + ListTile( + key: const Key('server-endpoint-setting'), + leading: const Icon(Icons.dns_outlined), + title: Text(l10n.serverAddress), + subtitle: Text(AppConfig.apiBaseUrl), + trailing: const Icon(Icons.edit_outlined), + onTap: () => _editServerEndpoint(context, l10n), + ), + ], + const SizedBox(height: 8), + ], + ), + ), ), ), ); } + Future _editServerEndpoint( + BuildContext context, + AppLocalizations l10n, + ) async { + final changed = await showDialog( + context: context, + builder: (_) => _ServerEndpointDialog(l10n: l10n), + ); + if (changed == true && context.mounted) { + ScaffoldMessenger.of( + context, + ).showSnackBar(SnackBar(content: Text(l10n.restartToApply))); + } + } + @override void dispose() { _disposed = true; super.dispose(); } } + +class _ServerEndpointDialog extends StatefulWidget { + const _ServerEndpointDialog({required this.l10n}); + + final AppLocalizations l10n; + + @override + State<_ServerEndpointDialog> createState() => _ServerEndpointDialogState(); +} + +class _ServerEndpointDialogState extends State<_ServerEndpointDialog> { + late final TextEditingController _controller = TextEditingController( + text: AppConfig.apiBaseUrl, + ); + String? _error; + bool _saving = false; + + @override + void dispose() { + _controller.dispose(); + super.dispose(); + } + + Future _save() async { + final normalized = ServerEndpoint.normalize(_controller.text); + if (normalized == null) { + setState(() => _error = widget.l10n.invalidServerAddress); + return; + } + setState(() { + _saving = true; + _error = null; + }); + final saved = await ServerEndpoint.save(normalized); + if (!mounted) return; + if (!saved) { + setState(() { + _saving = false; + _error = widget.l10n.invalidServerAddress; + }); + return; + } + Navigator.pop(context, true); + } + + Future _restoreDefault() async { + setState(() => _saving = true); + await ServerEndpoint.clear(); + if (mounted) Navigator.pop(context, true); + } + + @override + Widget build(BuildContext context) { + final l10n = widget.l10n; + return AlertDialog( + title: Text(l10n.serverAddress), + content: SingleChildScrollView( + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + TextField( + key: const Key('server-endpoint-input'), + controller: _controller, + enabled: !_saving, + keyboardType: TextInputType.url, + autocorrect: false, + decoration: InputDecoration( + hintText: l10n.serverAddressHint, + errorText: _error, + errorMaxLines: 2, + ), + ), + const SizedBox(height: 10), + Text( + l10n.restartToApply, + key: const Key('server-endpoint-restart-hint'), + style: const TextStyle(color: AppColors.muted, fontSize: 12), + ), + const SizedBox(height: 4), + TextButton( + key: const Key('server-endpoint-restore'), + onPressed: _saving ? null : _restoreDefault, + child: Text(l10n.restoreDefault), + ), + ], + ), + ), + actions: [ + TextButton( + onPressed: _saving ? null : () => Navigator.pop(context, false), + child: Text(l10n.cancel), + ), + FilledButton( + key: const Key('server-endpoint-save'), + onPressed: _saving ? null : _save, + child: Text(l10n.saveAddress), + ), + ], + ); + } +} diff --git a/lib/pages/mine/mine_view.dart b/lib/pages/mine/mine_view.dart index d0fe868..9ed63bd 100644 --- a/lib/pages/mine/mine_view.dart +++ b/lib/pages/mine/mine_view.dart @@ -2,6 +2,7 @@ import 'dart:async'; +import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; @@ -41,6 +42,7 @@ class MyPage extends StatefulWidget { this.onSignOut, this.dramas, this.onDramaSelected, + this.debugShowSetting = kDebugMode, }); final Drama drama; @@ -57,6 +59,7 @@ class MyPage extends StatefulWidget { final VoidCallback? onSignOut; final List? dramas; final ValueChanged? onDramaSelected; + final bool debugShowSetting; @override State createState() => _MyPageState(); @@ -214,7 +217,10 @@ class _MyPageState extends State { leading: const Icon(Icons.language_rounded, color: AppColors.blueSoft), title: Text(l10n.appLanguage), trailing: const Icon(Icons.chevron_right_rounded), - onTap: () => logic.showLanguage(context), + onTap: () => logic.showLanguage( + context, + showServerSetting: widget.debugShowSetting, + ), ), ]; @@ -471,7 +477,10 @@ class _MyPageState extends State { ), title: Text(l10n.settings), trailing: const Icon(Icons.chevron_right_rounded), - onTap: () => logic.showLanguage(context), + onTap: () => logic.showLanguage( + context, + showServerSetting: widget.debugShowSetting, + ), ), ], ), diff --git a/test/config/server_endpoint_test.dart b/test/config/server_endpoint_test.dart new file mode 100644 index 0000000..974b42b --- /dev/null +++ b/test/config/server_endpoint_test.dart @@ -0,0 +1,92 @@ +import 'package:flutter_test/flutter_test.dart'; +import 'package:shared_preferences/shared_preferences.dart'; +import 'package:shared_preferences_platform_interface/in_memory_shared_preferences_async.dart'; +import 'package:shared_preferences_platform_interface/shared_preferences_async_platform_interface.dart'; + +import 'package:fruitshorts/core/config/app_config.dart'; +import 'package:fruitshorts/core/config/server_endpoint.dart'; + +void main() { + setUp(() { + SharedPreferencesAsyncPlatform.instance = + InMemorySharedPreferencesAsync.empty(); + AppConfig.clearRuntimeBaseUrl(); + }); + + tearDown(AppConfig.clearRuntimeBaseUrl); + + test('should_normalize_http_urls_and_reject_invalid_values', () { + expect( + ServerEndpoint.normalize(' https://192.168.1.9:8081/// '), + 'https://192.168.1.9:8081', + ); + expect( + ServerEndpoint.normalize('http://example.test:8081/path/'), + 'http://example.test:8081/path', + ); + expect(ServerEndpoint.normalize('ftp://example.test'), isNull); + expect(ServerEndpoint.normalize('example.test:8081'), isNull); + expect(ServerEndpoint.normalize('http://'), isNull); + }); + + test('should_prioritize_runtime_over_dart_define_over_default', () { + expect( + ServerEndpoint.resolve( + stored: ' http://runtime.test:8081/ ', + compiled: 'http://define.test:8081', + fallback: 'http://default.test:8081', + ), + 'http://runtime.test:8081', + ); + expect( + ServerEndpoint.resolve( + stored: 'ftp://invalid', + compiled: 'http://define.test:8081/', + fallback: 'http://default.test:8081', + ), + 'http://define.test:8081', + ); + expect( + ServerEndpoint.resolve( + stored: null, + compiled: '', + fallback: 'http://default.test:8081/', + ), + 'http://default.test:8081', + ); + }); + + test('should_apply_stored_url_only_when_debug_is_enabled', () async { + SharedPreferencesAsyncPlatform.instance = + InMemorySharedPreferencesAsync.withData({ + ServerEndpoint.preferenceKey: ' http://192.168.31.187:8081/ ', + }); + final original = AppConfig.apiBaseUrl; + + await ServerEndpoint.load(debug: false); + expect(AppConfig.apiBaseUrl, original); + + await ServerEndpoint.load(debug: true); + expect(AppConfig.apiBaseUrl, 'http://192.168.31.187:8081'); + }); + + test('should_save_normalized_url_and_clear_override', () async { + expect(await ServerEndpoint.save('ftp://invalid'), isFalse); + expect( + await SharedPreferencesAsync().getString(ServerEndpoint.preferenceKey), + isNull, + ); + + expect(await ServerEndpoint.save(' http://192.168.31.187:8081/ '), isTrue); + expect( + await SharedPreferencesAsync().getString(ServerEndpoint.preferenceKey), + 'http://192.168.31.187:8081', + ); + + await ServerEndpoint.clear(); + expect( + await SharedPreferencesAsync().getString(ServerEndpoint.preferenceKey), + isNull, + ); + }); +} diff --git a/test/mine/server_endpoint_setting_test.dart b/test/mine/server_endpoint_setting_test.dart new file mode 100644 index 0000000..7eb9c49 --- /dev/null +++ b/test/mine/server_endpoint_setting_test.dart @@ -0,0 +1,101 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:provider/provider.dart'; +import 'package:shared_preferences/shared_preferences.dart'; +import 'package:shared_preferences_platform_interface/in_memory_shared_preferences_async.dart'; +import 'package:shared_preferences_platform_interface/shared_preferences_async_platform_interface.dart'; + +import 'package:fruitshorts/core/config/locale_controller.dart'; +import 'package:fruitshorts/core/config/server_endpoint.dart'; +import 'package:fruitshorts/core/data/models/drama.dart'; +import 'package:fruitshorts/core/data/repositories/watch_history_repository.dart'; +import 'package:fruitshorts/l10n/app_localizations.dart'; +import 'package:fruitshorts/pages/mine/mine_logic.dart'; + +const _drama = Drama( + id: 'drama-1', + title: 'The Signal', + synopsis: 'synopsis', + posterUrl: '/files/1.jpg', +); + +void main() { + setUp(() { + SharedPreferencesAsyncPlatform.instance = + InMemorySharedPreferencesAsync.empty(); + }); + + testWidgets('should_show_server_address_when_debug_entry_is_enabled', ( + tester, + ) async { + await _pumpSettings(tester, showServerSetting: true); + expect(find.byKey(const Key('server-endpoint-setting')), findsOneWidget); + expect(find.text('Server address'), findsOneWidget); + }); + + testWidgets('should_hide_server_address_when_debug_entry_is_disabled', ( + tester, + ) async { + await _pumpSettings(tester, showServerSetting: false); + expect(find.byKey(const Key('server-endpoint-setting')), findsNothing); + expect(find.text('Server address'), findsNothing); + }); + + testWidgets('should_reject_invalid_server_address_without_saving', ( + tester, + ) async { + await _pumpSettings(tester, showServerSetting: true); + await tester.tap(find.byKey(const Key('server-endpoint-setting'))); + await tester.pumpAndSettle(); + + expect(find.text('Restart the app to apply.'), findsOneWidget); + await tester.enterText( + find.byKey(const Key('server-endpoint-input')), + 'ftp://invalid', + ); + await tester.tap(find.byKey(const Key('server-endpoint-save'))); + await tester.pumpAndSettle(); + + expect(find.text('Enter a valid http(s) server address.'), findsOneWidget); + expect( + await SharedPreferencesAsync().getString(ServerEndpoint.preferenceKey), + isNull, + ); + }); +} + +Future _pumpSettings( + WidgetTester tester, { + required bool showServerSetting, +}) async { + final logic = MineLogic( + history: InMemoryWatchHistoryRepository(), + drama: _drama, + initialSection: 0, + ); + addTearDown(logic.dispose); + await tester.pumpWidget( + ChangeNotifierProvider( + create: (_) => LocaleController(), + child: MaterialApp( + locale: const Locale('en'), + localizationsDelegates: AppLocalizations.localizationsDelegates, + supportedLocales: AppLocalizations.supportedLocales, + home: Builder( + builder: (context) => Scaffold( + body: TextButton( + key: const Key('open-settings'), + onPressed: () => logic.showLanguage( + context, + showServerSetting: showServerSetting, + ), + child: const Text('Open settings'), + ), + ), + ), + ), + ), + ); + await tester.tap(find.byKey(const Key('open-settings'))); + await tester.pumpAndSettle(); +} -- 2.54.0 From 5a28845b5e0e72bd65b00ae8e885f25849d0a1ef Mon Sep 17 00:00:00 2001 From: Zhou Weidong <502333560@qq.com> Date: Sat, 17 Oct 2026 23:02:28 +0800 Subject: [PATCH 29/76] =?UTF-8?q?docs(client):=20=E9=87=8D=E5=86=99=20READ?= =?UTF-8?q?ME=20=E5=B9=B6=E8=A1=A5=E5=85=85=E4=BB=BB=E5=8A=A1=E4=B8=8E?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E8=AF=B4=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 176 +++++++++++++++++++++++++++++++++++++++----------- docs/FILES.md | 99 ++++++++++++++++++++++++++++ docs/TASKS.md | 38 +++++++++++ 3 files changed, 277 insertions(+), 36 deletions(-) create mode 100644 docs/FILES.md create mode 100644 docs/TASKS.md diff --git a/README.md b/README.md index 004a776..6663617 100644 --- a/README.md +++ b/README.md @@ -1,50 +1,154 @@ -一个使用 Flutter 开发的短剧播放 App 原型,面向海外用户,重点探索沉浸式刷剧、找剧和连续观看的移动端体验 +# FruitShorts(ReelShort)客户端 -## 主要功能 +FruitShorts 是面向印尼市场的短剧 Flutter 客户端。当前版本已连接 +`FruitServer` 的 `/app/**` 接口,支持沉浸播放、找剧、账号、观看记录、收藏、 +下载授权、评论互动、站内通知和中英印尼三语界面。 -- **沉浸式首页**:竖屏播放,上下滑切换短剧,左右滑切换内容类别;支持拖动进度、横屏全屏观看。 -- **剧集播放**:从详情页进入后按集连续播放,支持选集和本地续看。 -- **找剧与个人页**:浏览、搜索和查看剧集详情;在个人页查看观看记录、收藏与喜欢的内容。 -- **互动与多语言**:本地演示评论、系统分享,以及英文、简体中文和印尼语界面。 -- **画中画**:Android 接入系统画中画;iOS 画中画尚未实现。 +## 技术栈 -## 技术实现 +- Flutter 3.47.7 / Dart 3.13.5 +- Provider 状态管理与依赖注入 +- dio 网络请求 +- video_player 播放 +- shared_preferences 与 `SharedPreferencesAsync` 本地配置 +- flutter_localizations,支持 `en`、`zh`、`id` +- Android 系统画中画 -项目使用 Flutter、Provider 和 `video_player`。播放会话统一管理播放器生命周期;观看进度和演示互动数据保存在本机。首页、找剧、我的共用同一个根页面,切换时保留页面状态。 +## 目录结构 -## 对接后端 +```text +lib/ + core/ + config/ 地址、语言和运行时配置 + data/ models、remote API、repository、controller + formatting/ 文案与日期格式化 + platform/ 触觉等平台能力 + theme/ 颜色与主题 + widgets/ 跨页面复用组件 + l10n/ 三语 ARB 与生成代码 + pages/ 业务页面 +test/ 单元、组件、页面和联调测试 +integration_test/ 设备侧集成测试 +android/ Android 工程 +ios/ iOS 工程与 SPM 配置 +assets/ 图标、图片和本地媒体文件 +``` -目录数据来自短剧服务的客户端接口(`FruitServer` 的 `fruitshorts-app-api`,默认 `http://127.0.0.1:8081`): +## 已接接口 -- `GET /app/home/feed`、`GET /app/discover/feed`:轮播 + 分区,一次请求渲染整页。 - 每张卡片带 `preview`(首个可播免费集),首页竖屏播放可以直接起播; - 没有片源的剧不下发 `preview`,也不会出现在首页的滑动队列里 -- `GET /app/dramas/{id}`:详情(含剧集列表;可播放的剧集直接带播放地址) -- `GET /app/episodes/{id}/play`:播放票据,返回可访问性与地址 +以下接口均在 `lib/core/data/remote/` 中有实际调用。 -启动后端后直接 `flutter run` 或 Xcode 里 Run 即可,接口地址按运行环境自动选择 -(见 `lib/core/config/app_config.dart`): +| 分组 | 契约 | 接口 | +| --- | --- | --- | +| 账号 | §1.1 | `POST /app/auth/register`、`/login`、`/refresh`、`/logout` | +| 内容 | §1.3、§1.4 | `GET /app/home/feed`、`/app/discover/feed`、`/app/categories`、`/app/dramas/{id}`、`/app/episodes/{id}/play` | +| 观看记录 | §1.5 | `POST/GET /app/watch/progress`、`GET /app/watch/recent`、`DELETE /app/watch/progress/{dramaId}`、`DELETE /app/watch/progress` | +| 收藏 | §1.5 | `POST /app/favorites/toggle`、`GET /app/favorites`、`DELETE /app/favorites/{dramaId}` | +| 下载授权 | §1.6 | `GET /app/downloads/policy`、`PUT /app/downloads/settings`、`POST/GET /app/downloads`、`GET /app/downloads/{episodeId}/url`、`POST /app/downloads/{episodeId}/progress`、`DELETE /app/downloads/{episodeId}`、`DELETE /app/downloads` | +| 互动 | §1.7 | `GET/POST /app/comments`、`DELETE /app/comments/{id}`、`POST /app/likes/toggle`、`POST /app/reports` | +| 公告 | §1.9.2 | `GET /app/notices` | -| 运行环境 | 默认地址 | -| --- | --- | -| iOS 模拟器 / 桌面端 | `http://127.0.0.1:8081` | -| iPhone 真机 | [`devHostBaseUrl`],即电脑当前的局域网地址(`ipconfig getifaddr en0`) | -| Android 模拟器 | 需手动指定 `--dart-define=API_BASE_URL=http://10.0.2.2:8081` | +客户端没有调用 `/app/config` 或创作者入驻接口。 -任何环境都可以用 `--dart-define=API_BASE_URL=http://x.x.x.x:8081` 覆盖默认值。 -电脑换网络后局域网地址会变,改 `devHostBaseUrl` 即可;也可以换成 Bonjour 名字 -(`http://$(scutil --get LocalHostName).local:8081`),换网络也不用改。 +## 运行 -真机调试还需注意:手机和电脑在同一个 Wi-Fi;首次启动时 iPhone 会弹「本地网络」权限, -必须允许;iOS 的明文 HTTP 与局域网访问已在 `ios/Runner/Info.plist` 里放行 -(`NSAllowsLocalNetworking`、`NSLocalNetworkUsageDescription`),改动这些配置后 -要重新构建安装,热重载不生效;如果仍连不上,到「系统设置 → 网络 → 防火墙 → 选项」 -把 `java` 设为允许传入连接。 +### 安装依赖 -封面与视频都走 `http://:8081/files/**`,本地不再打包演示素材 -(原先 `assets/media` 里的演示视频有 316MB,已从打包清单移除)。 +```bash +flutter pub get +``` -## 当前说明 +### Android USB -收藏、点赞、评论与观看进度仍保存在本机(后端互动接口尚未开发); -金币与会员相关界面仍是占位数据。 +手机开启 USB 调试并连接电脑后: + +```bash +adb devices +adb reverse tcp:8081 tcp:8081 +flutter run -d \ + --dart-define=API_BASE_URL=http://127.0.0.1:8081 +``` + +`adb reverse` 将手机的 `127.0.0.1:8081` 转发到电脑;USB 断开或重新连接后需要 +重新执行。 + +Android 模拟器访问宿主机时使用: + +```bash +flutter run --dart-define=API_BASE_URL=http://10.0.2.2:8081 +``` + +### iOS + +手机与 Mac 需在同一网络,首次启动允许“本地网络”权限: + +```bash +flutter run -d \ + --dart-define=API_BASE_URL=http://:8081 +``` + +### Debug 运行时地址 + +debug 版本可在「我的 → 设置 → 服务器地址」修改后端地址,保存后重启 App 生效。 +地址优先级: + +```text +本地运行时设置 > --dart-define(API_BASE_URL) > 平台默认地址 +``` + +因此不带 `--dart-define` 构建的 debug APK 也可在安装后改成当前电脑 IP。 +release 版本不显示入口,也不会读取本地覆盖。 + +## 环境注意 + +### iOS Swift 版本 + +`pubspec.yaml` 将 `shared_preferences_foundation` 固定为 `2.5.6`。该版本兼容 +Xcode 16.2 / Swift 6.0.3;`2.6.0` 的生成代码使用 Swift 6.1 才支持的 trailing +comma。不要手工升级该依赖,`flutter pub get` 后应显示 +`shared_preferences_foundation 2.5.6 (overridden)`。 + +### iOS SPM 包缺失 + +如果 Xcode 报 `Missing package product FlutterGeneratedPluginSwiftPackage`: + +```bash +rm -rf ~/Library/Developer/Xcode/DerivedData/Runner-* +flutter clean +flutter pub get +xcodebuild -resolvePackageDependencies \ + -project ios/Runner.xcodeproj \ + -scheme Runner +``` + +随后重新打开工程构建。`Runner.xcscheme` 的 PreAction 会先执行 +`flutter pub get`,再执行 Flutter prepare。 + +### Android libdartjni + +若启动时报 `libdartjni.so` 加载失败,通常是旧安装中的原生库残留: + +```bash +adb uninstall com.stormg.lumadrama +flutter run -d \ + --dart-define=API_BASE_URL=http://127.0.0.1:8081 +``` + +## 门禁 + +```bash +dart analyze lib test +flutter test +flutter build apk --debug +``` + +测试文件按模块放在 `test/` 下,用例名使用 +`should_<期望>_when_<条件>`。真实后端联调测试在服务未启动时会跳过。 + +## 当前边界 + +- 下载仅管理服务端授权,不落盘、不续传、不支持离线播放。 +- 没有独立搜索接口,搜索能力尚未形成完整闭环。 +- 站内通知没有已读/未读和红点状态。 +- 支付、金币和会员权益尚未形成客户端闭环。 +- Android 支持系统画中画;iOS 画中画尚未接入。 diff --git a/docs/FILES.md b/docs/FILES.md new file mode 100644 index 0000000..cf68bc5 --- /dev/null +++ b/docs/FILES.md @@ -0,0 +1,99 @@ +# 客户端文件说明 + +## 目录树 + +```text +. +├── android/ Android 工程与 Gradle 配置 +├── assets/ +│ ├── icon/ 启动图标 +│ ├── images/ 本地图片 +│ └── media/ 本地视频文件(当前未在 pubspec 声明) +├── integration_test/ 设备侧集成测试 +├── ios/ +│ ├── Flutter/ Flutter 生成配置与 SPM 临时包 +│ ├── Runner/ iOS Runner +│ ├── Runner.xcodeproj/ Xcode 工程与共享 Scheme +│ └── RunnerTests/ iOS 原生测试 +├── lib/ +│ ├── core/ +│ │ ├── config/ 地址、语言、运行时服务器设置 +│ │ ├── data/ models、remote、repositories、services +│ │ ├── formatting/ 多语言文案、日期和错误文本 +│ │ ├── platform/ 平台能力封装 +│ │ ├── theme/ 颜色与 ThemeData +│ │ └── widgets/ 通用组件 +│ ├── l10n/ ARB 与本地化生成代码 +│ └── pages/ 业务页面 +├── test/ 单元和 Widget 测试 +├── docs/ 客户端任务与文件说明 +├── pubspec.yaml 依赖、资源和 Flutter 配置 +└── README.md 运行、接口与环境说明 +``` + +## 关键文件 + +| 路径 | 职责 | +| --- | --- | +| `lib/main.dart` | 初始化 Flutter、屏幕方向、debug 服务器覆盖并启动 App | +| `lib/app.dart` | Provider、repository、controller、ApiClient 和主题装配 | +| `lib/core/config/app_config.dart` | 地址优先级、超时、媒体 URL 和平台默认地址 | +| `lib/core/config/server_endpoint.dart` | debug 运行时地址规范化、读取、保存和清除 | +| `lib/core/config/locale_controller.dart` | 语言选择与系统语言回退 | +| `lib/core/data/models/` | 账号、剧目、评论、观看、下载、公告等数据结构 | +| `lib/core/data/remote/` | `/app/**` 接口调用;`api_client.dart` 统一鉴权和错误映射 | +| `lib/core/data/repositories/` | HTTP 与内存实现的 repository 边界 | +| `lib/core/data/services/` | 页面 controller、播放会话、分享、画中画等业务服务 | +| `lib/core/formatting/` | 本地化内容、日期与错误文本 | +| `lib/core/platform/haptics.dart` | 可注入的触觉反馈封装 | +| `lib/core/theme/app_colors.dart` | 克莱因蓝和界面颜色 token | +| `lib/core/theme/app_theme.dart` | light/dark ColorScheme 与组件主题 | +| `lib/core/widgets/empty_state.dart` | 统一空列表占位 | +| `lib/core/widgets/remote_image.dart` | 后端相对图片地址与失败占位 | +| `lib/core/widgets/auth_gate.dart` | 未登录操作拦截 | +| `lib/core/widgets/download_action.dart` | 下载授权操作 | +| `lib/pages/home/` | 根页面、四个底部 tab 和抽屉 | +| `lib/pages/player/` | 竖屏播放、选集、进度和播放器交互 | +| `lib/pages/discover/` | 首页/发现信息流、轮播、分类与三列剧目网格 | +| `lib/pages/drama_detail/` | 剧目详情与剧集入口 | +| `lib/pages/auth/` | 登录/注册页面与表单逻辑 | +| `lib/pages/mine/` | 我的页、片单、设置、语言与 debug 地址入口 | +| `lib/pages/favorites/` | 收藏列表 | +| `lib/pages/watch_records/` | 独立观看记录页 | +| `lib/pages/downloads/` | 下载授权与策略页面 | +| `lib/pages/notices/` | 站内通知分页和详情 | +| `lib/pages/interaction/` | 举报弹窗 | +| `lib/l10n/*.arb` | en/zh/id 源文案,修改后执行 `flutter gen-l10n` | +| `ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme` | iOS SPM 预构建脚本 | + +## 测试结构 + +| 目录 | 覆盖范围 | +| --- | --- | +| `test/auth/` | 登录 controller、表单、视觉与交互 | +| `test/catalog/`、`test/category/` | 首页数据、分类和模型解析 | +| `test/comment/`、`test/interaction/` | 评论、点赞、举报和弹窗 | +| `test/config/` | 三语、系统语言和运行时服务器地址 | +| `test/core/` | ApiClient、ID 解析、触觉、分享和画中画 | +| `test/discover/`、`test/home/` | 首页、轮播、网格和导航 | +| `test/download/`、`test/library/`、`test/watch/` | 下载、收藏、观看记录 | +| `test/drama_detail/`、`test/player/`、`test/playback/` | 详情、播放器与播放队列 | +| `test/notice/` | 通知分页、空态、详情与入口 | +| `test/empty_state/`、`test/theme/` | 空态组件与主题 token | +| `test/integration/` | 依赖本机后端的联调测试,服务未启动时跳过 | +| `integration_test/app_backend_test.dart` | 设备侧后端连通性测试 | +| `test/support/` | fake repository、HTTP adapter、播放器和测试数据 | + +## 生成物 + +以下内容由工具生成,不要手工修改: + +- `lib/l10n/app_localizations*.dart` +- `*.g.dart` +- `.dart_tool/` +- `build/` +- `ios/Flutter/ephemeral/` +- `ios/Runner/GeneratedPluginRegistrant.h` +- `ios/Runner/GeneratedPluginRegistrant.m` + +`pubspec.lock` 由 Dart 包管理工具维护,应提交但不手工编辑。 diff --git a/docs/TASKS.md b/docs/TASKS.md new file mode 100644 index 0000000..e1932eb --- /dev/null +++ b/docs/TASKS.md @@ -0,0 +1,38 @@ +# 客户端任务清单 + +状态按当前 `develop` 中已合入的功能整理。契约章节以 +`FruitServer/docs/api-phase1.md` 为准;任务过程记录见 +`FruitServer/docs/plans/PROGRESS.md`。 + +## K1-K13 + +| 批次 | 范围 | 状态 | 关键提交或契约章节 | 备注 | +| --- | --- | --- | --- | --- | +| K1 | 详情、播放票据、观看进度、续看、收藏 | 已完成并合入 | §1.3-§1.5 | 已有三态和基础页面 | +| K2 | 分类、观看记录、收藏列表、下载授权管理 | 已完成并合入 | §1.2、§1.5、§1.6 | 下载只管理授权,不落盘 | +| K3 | 评论、回复、点赞、举报、分享 | 已完成并合入 | §1.7 | 分享使用系统分享面板 | +| K4 | 账号剩余能力 | 未开始 | §1.1 | Google 登录所需凭据和契约范围需核对 | +| K5 | 克莱因蓝主题、印尼语适配 | 已完成并合入 | 无接口变更 | 三语为 en/zh/id | +| K6 | 登录页、底部导航、触觉反馈 | 已完成并合入 | 无接口变更 | 触觉通过 `Haptics` 封装 | +| K7 | 首页轮播、站内通知 | 已完成并合入 | §1.3、§1.9.2 | 通知无已读态 | +| K8 | 登录页视觉重设计 | 已完成并合入 | 无接口变更 | 保留原有登录逻辑和校验 | +| K9 | 首页全部剧目双列网格 | 已完成并合入 | 无接口变更 | 数据源为 feed 分类结果 | +| K10 | 统一空列表占位 | 已完成并合入 | 无接口变更 | 评论弹窗使用 compact 变体 | +| K11 | 首页三列、分类首位“全部” | 已完成并合入 | 无接口变更 | 网格比例保持 2:3 | +| K12 | 首页去标题、空态视觉重做 | 已完成并合入 | 无接口变更 | 双层同心圆空态 | +| K13 | debug 运行时服务器地址 | 已完成并合入 | 无接口变更 | 保存后重启生效,release 不开放 | + +## 待办 + +| 事项 | 状态 | 依赖或说明 | +| --- | --- | --- | +| K4 账号剩余能力 | 待办 | Google 登录需要客户端凭据、平台配置和后端契约,范围需核对 | +| B1 支付与金币 | 待办 | 客户端尚未接入 §1.8 的支付/权益闭环,商品、渠道和验证方式需核对 | +| 搜索 | 待办 | 当前没有独立搜索接口,接口契约和数据范围需核对 | +| 下载落盘 | 待办 | 需要新增文件下载、进度持久化、续传、离线播放和本地清理设计 | + +## 维护规则 + +- 新批次完成后更新本表,不写未经确认的提交号。 +- 功能状态以当前 `develop` 代码和自动化测试为准。 +- “需核对”表示产品范围、接口或外部凭据尚未确认,不能按已完成处理。 -- 2.54.0 From 213c86e93c215b51c239aae783cd240bf20f75af Mon Sep 17 00:00:00 2001 From: Zhou Weidong <502333560@qq.com> Date: Sat, 17 Oct 2026 23:03:43 +0800 Subject: [PATCH 30/76] =?UTF-8?q?docs(client):=20=E4=BF=AE=E6=AD=A3?= =?UTF-8?q?=E5=B7=B2=E6=8E=A5=E6=8E=A5=E5=8F=A3=E6=95=B0=E9=87=8F=E8=AF=B4?= =?UTF-8?q?=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 6663617..24e676e 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,8 @@ assets/ 图标、图片和本地媒体文件 ## 已接接口 -以下接口均在 `lib/core/data/remote/` 中有实际调用。 +以下接口均在 `lib/core/data/remote/` 中有实际调用,共 26 个不同路径、 +31 个 HTTP 方法级调用。 | 分组 | 契约 | 接口 | | --- | --- | --- | -- 2.54.0 From c4694c6f189961812561cf69ed6f20e1d70508c2 Mon Sep 17 00:00:00 2001 From: Zhou Weidong <502333560@qq.com> Date: Sat, 17 Oct 2026 23:12:47 +0800 Subject: [PATCH 31/76] =?UTF-8?q?fix(flutter):=20=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E9=A6=96=E9=A1=B5=E6=9C=8D=E5=8A=A1=E5=99=A8=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E5=B9=B6=E6=9B=B4=E6=96=B0=E7=9C=9F=E6=9C=BA=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E5=9C=B0=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/core/config/app_config.dart | 10 +- lib/core/widgets/server_endpoint_dialog.dart | 128 +++++++++++++++++++ lib/l10n/app_en.arb | 1 + lib/l10n/app_id.arb | 1 + lib/l10n/app_localizations.dart | 6 + lib/l10n/app_localizations_en.dart | 3 + lib/l10n/app_localizations_id.dart | 3 + lib/l10n/app_localizations_zh.dart | 3 + lib/l10n/app_zh.arb | 1 + lib/pages/home/home_view.dart | 73 +++++++---- lib/pages/mine/mine_logic.dart | 117 +---------------- test/config/server_endpoint_test.dart | 4 + test/home/home_server_setting_test.dart | 57 +++++++++ 13 files changed, 264 insertions(+), 143 deletions(-) create mode 100644 lib/core/widgets/server_endpoint_dialog.dart create mode 100644 test/home/home_server_setting_test.dart diff --git a/lib/core/config/app_config.dart b/lib/core/config/app_config.dart index 00d554c..056754a 100644 --- a/lib/core/config/app_config.dart +++ b/lib/core/config/app_config.dart @@ -4,18 +4,16 @@ import 'package:flutter/foundation.dart'; /// 客户端与后端约定的运行时配置。 /// -/// 接口地址的优先级:`--dart-define=API_BASE_URL=...` > 按运行环境判断的默认值。 +/// 接口地址优先级:运行时设置 > `--dart-define=API_BASE_URL=...` > 平台默认值。 /// 开发机的局域网地址会随网络变化,换网络后改 [devHostBaseUrl] 即可。 class AppConfig { const AppConfig._(); - /// 开发机的局域网地址。真机上的 `127.0.0.1` 指向手机自己,只能走这个地址。 + /// 真机默认使用的开发机局域网地址。 /// /// 这个地址跟着电脑所在的网络走,换网络后要用 - /// `ipconfig getifaddr en0` 重新确认并改这里; - /// 也可以换成 Bonjour 名字 `http://.local:8081`(本机是 - /// `jiangdeMacBook-Air.local`),换网络不用改,但部分办公网会拦组播解析。 - static const String devHostBaseUrl = 'http://jiangdeMacBook-Air.local:8081'; + /// `ipconfig getifaddr en0` 重新确认。默认值只改这一行。 + static const String devHostBaseUrl = 'http://10.157.242.1:8081'; static const String _loopbackBaseUrl = 'http://127.0.0.1:8081'; diff --git a/lib/core/widgets/server_endpoint_dialog.dart b/lib/core/widgets/server_endpoint_dialog.dart new file mode 100644 index 0000000..66d6e9d --- /dev/null +++ b/lib/core/widgets/server_endpoint_dialog.dart @@ -0,0 +1,128 @@ +// Author: fruit.com.cn + +import 'package:flutter/material.dart'; + +import '../../l10n/app_localizations.dart'; +import '../config/app_config.dart'; +import '../config/server_endpoint.dart'; +import '../theme/app_colors.dart'; + +/// Opens the debug-only runtime server address editor. +Future showServerEndpointDialog( + BuildContext context, + AppLocalizations l10n, +) async { + final changed = await showDialog( + context: context, + builder: (_) => _ServerEndpointDialog(l10n: l10n), + ); + if (changed == true && context.mounted) { + ScaffoldMessenger.of( + context, + ).showSnackBar(SnackBar(content: Text(l10n.restartToApply))); + return true; + } + return false; +} + +class _ServerEndpointDialog extends StatefulWidget { + const _ServerEndpointDialog({required this.l10n}); + + final AppLocalizations l10n; + + @override + State<_ServerEndpointDialog> createState() => _ServerEndpointDialogState(); +} + +class _ServerEndpointDialogState extends State<_ServerEndpointDialog> { + late final TextEditingController _controller = TextEditingController( + text: AppConfig.apiBaseUrl, + ); + String? _error; + bool _saving = false; + + @override + void dispose() { + _controller.dispose(); + super.dispose(); + } + + Future _save() async { + final normalized = ServerEndpoint.normalize(_controller.text); + if (normalized == null) { + setState(() => _error = widget.l10n.invalidServerAddress); + return; + } + setState(() { + _saving = true; + _error = null; + }); + final saved = await ServerEndpoint.save(normalized); + if (!mounted) return; + if (!saved) { + setState(() { + _saving = false; + _error = widget.l10n.invalidServerAddress; + }); + return; + } + Navigator.pop(context, true); + } + + Future _restoreDefault() async { + setState(() => _saving = true); + await ServerEndpoint.clear(); + if (mounted) Navigator.pop(context, true); + } + + @override + Widget build(BuildContext context) { + final l10n = widget.l10n; + return AlertDialog( + title: Text(l10n.serverAddress), + content: SingleChildScrollView( + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + TextField( + key: const Key('server-endpoint-input'), + controller: _controller, + enabled: !_saving, + keyboardType: TextInputType.url, + autocorrect: false, + decoration: InputDecoration( + hintText: l10n.serverAddressHint, + errorText: _error, + errorMaxLines: 2, + ), + ), + const SizedBox(height: 10), + Text( + l10n.restartToApply, + key: const Key('server-endpoint-restart-hint'), + style: const TextStyle(color: AppColors.muted, fontSize: 12), + ), + const SizedBox(height: 4), + TextButton( + key: const Key('server-endpoint-restore'), + onPressed: _saving ? null : _restoreDefault, + child: Text(l10n.restoreDefault), + ), + ], + ), + ), + actions: [ + TextButton( + onPressed: _saving ? null : () => Navigator.pop(context, false), + child: Text(l10n.cancel), + ), + FilledButton( + key: const Key('server-endpoint-save'), + onPressed: _saving ? null : _save, + child: Text(l10n.saveAddress), + ), + ], + ); + } +} diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index 18ebcfb..fd92349 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -263,6 +263,7 @@ "watchHistory": "Watch History", "settings": "Settings", "serverAddress": "Server address", + "serverSettings": "Server settings", "serverAddressHint": "http(s)://host:port", "saveAddress": "Save address", "restartToApply": "Restart the app to apply.", diff --git a/lib/l10n/app_id.arb b/lib/l10n/app_id.arb index ce7eea5..8b5f4eb 100644 --- a/lib/l10n/app_id.arb +++ b/lib/l10n/app_id.arb @@ -263,6 +263,7 @@ "watchHistory": "Riwayat Tontonan", "settings": "Pengaturan", "serverAddress": "Alamat server", + "serverSettings": "Pengaturan server", "serverAddressHint": "http(s)://host:port", "saveAddress": "Simpan alamat", "restartToApply": "Mulai ulang aplikasi untuk menerapkan.", diff --git a/lib/l10n/app_localizations.dart b/lib/l10n/app_localizations.dart index aeed5a1..66fe23d 100644 --- a/lib/l10n/app_localizations.dart +++ b/lib/l10n/app_localizations.dart @@ -1234,6 +1234,12 @@ abstract class AppLocalizations { /// **'Server address'** String get serverAddress; + /// No description provided for @serverSettings. + /// + /// In en, this message translates to: + /// **'Server settings'** + String get serverSettings; + /// No description provided for @serverAddressHint. /// /// In en, this message translates to: diff --git a/lib/l10n/app_localizations_en.dart b/lib/l10n/app_localizations_en.dart index 40e3466..af33553 100644 --- a/lib/l10n/app_localizations_en.dart +++ b/lib/l10n/app_localizations_en.dart @@ -604,6 +604,9 @@ class AppLocalizationsEn extends AppLocalizations { @override String get serverAddress => 'Server address'; + @override + String get serverSettings => 'Server settings'; + @override String get serverAddressHint => 'http(s)://host:port'; diff --git a/lib/l10n/app_localizations_id.dart b/lib/l10n/app_localizations_id.dart index 9063d41..f969a29 100644 --- a/lib/l10n/app_localizations_id.dart +++ b/lib/l10n/app_localizations_id.dart @@ -606,6 +606,9 @@ class AppLocalizationsId extends AppLocalizations { @override String get serverAddress => 'Alamat server'; + @override + String get serverSettings => 'Pengaturan server'; + @override String get serverAddressHint => 'http(s)://host:port'; diff --git a/lib/l10n/app_localizations_zh.dart b/lib/l10n/app_localizations_zh.dart index 8bd6d57..3430dc1 100644 --- a/lib/l10n/app_localizations_zh.dart +++ b/lib/l10n/app_localizations_zh.dart @@ -595,6 +595,9 @@ class AppLocalizationsZh extends AppLocalizations { @override String get serverAddress => '服务器地址'; + @override + String get serverSettings => '服务器设置'; + @override String get serverAddressHint => 'http(s)://主机:端口'; diff --git a/lib/l10n/app_zh.arb b/lib/l10n/app_zh.arb index 625b639..058edff 100644 --- a/lib/l10n/app_zh.arb +++ b/lib/l10n/app_zh.arb @@ -225,6 +225,7 @@ "watchHistory": "观看历史", "settings": "设置", "serverAddress": "服务器地址", + "serverSettings": "服务器设置", "serverAddressHint": "http(s)://主机:端口", "saveAddress": "保存地址", "restartToApply": "重启 App 生效", diff --git a/lib/pages/home/home_view.dart b/lib/pages/home/home_view.dart index 51c15a2..28a67fe 100644 --- a/lib/pages/home/home_view.dart +++ b/lib/pages/home/home_view.dart @@ -15,6 +15,7 @@ import '../../core/theme/app_colors.dart'; import '../../core/theme/app_theme.dart'; import '../../core/widgets/auth_gate.dart'; import '../../core/widgets/empty_state.dart'; +import '../../core/widgets/server_endpoint_dialog.dart'; import '../../l10n/app_localizations.dart'; import '../discover/discover_view.dart'; import '../mine/mine_view.dart'; @@ -50,28 +51,9 @@ class HomePage extends StatelessWidget { if (catalog.error != null) { return Scaffold( backgroundColor: Colors.black, - body: Center( - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - const Icon( - Icons.error_outline_rounded, - color: Colors.white70, - size: 40, - ), - const SizedBox(height: 12), - Text(l10n.catalogError), - const SizedBox(height: 12), - FilledButton(onPressed: catalog.load, child: Text(l10n.retry)), - if (kDebugMode) ...[ - const SizedBox(height: 16), - Text( - AppConfig.apiBaseUrl, - style: const TextStyle(fontSize: 12, color: Colors.white54), - ), - ], - ], - ), + body: HomeFailureView( + onRetry: catalog.load, + showDebugTools: kDebugMode, ), ); } @@ -96,6 +78,53 @@ class HomePage extends StatelessWidget { } } +/// Home catalog failure with optional debug-only endpoint controls. +class HomeFailureView extends StatelessWidget { + const HomeFailureView({ + super.key, + required this.onRetry, + this.showDebugTools = kDebugMode, + }); + + final VoidCallback onRetry; + final bool showDebugTools; + + @override + Widget build(BuildContext context) { + final l10n = AppLocalizations.of(context)!; + return Center( + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + const Icon( + Icons.error_outline_rounded, + color: Colors.white70, + size: 40, + ), + const SizedBox(height: 12), + Text(l10n.catalogError), + const SizedBox(height: 12), + FilledButton(onPressed: onRetry, child: Text(l10n.retry)), + if (showDebugTools) ...[ + const SizedBox(height: 16), + Text( + AppConfig.apiBaseUrl, + style: const TextStyle(fontSize: 12, color: Colors.white54), + ), + const SizedBox(height: 8), + OutlinedButton.icon( + key: const Key('home-server-settings'), + onPressed: () => showServerEndpointDialog(context, l10n), + icon: const Icon(Icons.dns_outlined), + label: Text(l10n.serverSettings), + ), + ], + ], + ), + ); + } +} + /// The three primary destinations share a single route and keep their state. class _HomeTabs extends StatefulWidget { const _HomeTabs({super.key, required this.dramas}); diff --git a/lib/pages/mine/mine_logic.dart b/lib/pages/mine/mine_logic.dart index b2e2f9d..553d35d 100644 --- a/lib/pages/mine/mine_logic.dart +++ b/lib/pages/mine/mine_logic.dart @@ -6,11 +6,10 @@ import 'package:provider/provider.dart'; import '../../core/config/app_config.dart'; import '../../core/config/locale_controller.dart'; -import '../../core/config/server_endpoint.dart'; import '../../core/data/models/drama.dart'; import '../../core/data/models/watch_progress.dart'; import '../../core/data/repositories/watch_history_repository.dart'; -import '../../core/theme/app_colors.dart'; +import '../../core/widgets/server_endpoint_dialog.dart'; import '../../l10n/app_localizations.dart'; enum MyPageAction { home, discover, resume } @@ -169,17 +168,7 @@ class MineLogic extends ChangeNotifier { Future _editServerEndpoint( BuildContext context, AppLocalizations l10n, - ) async { - final changed = await showDialog( - context: context, - builder: (_) => _ServerEndpointDialog(l10n: l10n), - ); - if (changed == true && context.mounted) { - ScaffoldMessenger.of( - context, - ).showSnackBar(SnackBar(content: Text(l10n.restartToApply))); - } - } + ) => showServerEndpointDialog(context, l10n); @override void dispose() { @@ -187,105 +176,3 @@ class MineLogic extends ChangeNotifier { super.dispose(); } } - -class _ServerEndpointDialog extends StatefulWidget { - const _ServerEndpointDialog({required this.l10n}); - - final AppLocalizations l10n; - - @override - State<_ServerEndpointDialog> createState() => _ServerEndpointDialogState(); -} - -class _ServerEndpointDialogState extends State<_ServerEndpointDialog> { - late final TextEditingController _controller = TextEditingController( - text: AppConfig.apiBaseUrl, - ); - String? _error; - bool _saving = false; - - @override - void dispose() { - _controller.dispose(); - super.dispose(); - } - - Future _save() async { - final normalized = ServerEndpoint.normalize(_controller.text); - if (normalized == null) { - setState(() => _error = widget.l10n.invalidServerAddress); - return; - } - setState(() { - _saving = true; - _error = null; - }); - final saved = await ServerEndpoint.save(normalized); - if (!mounted) return; - if (!saved) { - setState(() { - _saving = false; - _error = widget.l10n.invalidServerAddress; - }); - return; - } - Navigator.pop(context, true); - } - - Future _restoreDefault() async { - setState(() => _saving = true); - await ServerEndpoint.clear(); - if (mounted) Navigator.pop(context, true); - } - - @override - Widget build(BuildContext context) { - final l10n = widget.l10n; - return AlertDialog( - title: Text(l10n.serverAddress), - content: SingleChildScrollView( - child: Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - TextField( - key: const Key('server-endpoint-input'), - controller: _controller, - enabled: !_saving, - keyboardType: TextInputType.url, - autocorrect: false, - decoration: InputDecoration( - hintText: l10n.serverAddressHint, - errorText: _error, - errorMaxLines: 2, - ), - ), - const SizedBox(height: 10), - Text( - l10n.restartToApply, - key: const Key('server-endpoint-restart-hint'), - style: const TextStyle(color: AppColors.muted, fontSize: 12), - ), - const SizedBox(height: 4), - TextButton( - key: const Key('server-endpoint-restore'), - onPressed: _saving ? null : _restoreDefault, - child: Text(l10n.restoreDefault), - ), - ], - ), - ), - actions: [ - TextButton( - onPressed: _saving ? null : () => Navigator.pop(context, false), - child: Text(l10n.cancel), - ), - FilledButton( - key: const Key('server-endpoint-save'), - onPressed: _saving ? null : _save, - child: Text(l10n.saveAddress), - ), - ], - ); - } -} diff --git a/test/config/server_endpoint_test.dart b/test/config/server_endpoint_test.dart index 974b42b..2918105 100644 --- a/test/config/server_endpoint_test.dart +++ b/test/config/server_endpoint_test.dart @@ -56,6 +56,10 @@ void main() { ); }); + test('should_use_the_configured_lan_address_for_device_default', () { + expect(AppConfig.devHostBaseUrl, 'http://10.157.242.1:8081'); + }); + test('should_apply_stored_url_only_when_debug_is_enabled', () async { SharedPreferencesAsyncPlatform.instance = InMemorySharedPreferencesAsync.withData({ diff --git a/test/home/home_server_setting_test.dart b/test/home/home_server_setting_test.dart new file mode 100644 index 0000000..239da4f --- /dev/null +++ b/test/home/home_server_setting_test.dart @@ -0,0 +1,57 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:shared_preferences_platform_interface/in_memory_shared_preferences_async.dart'; +import 'package:shared_preferences_platform_interface/shared_preferences_async_platform_interface.dart'; + +import 'package:fruitshorts/l10n/app_localizations.dart'; +import 'package:fruitshorts/pages/home/home_view.dart'; + +void main() { + setUp(() { + SharedPreferencesAsyncPlatform.instance = + InMemorySharedPreferencesAsync.empty(); + }); + + testWidgets( + 'should_show_server_settings_and_open_dialog_when_debug_tools_are_enabled', + (tester) async { + await _pumpFailureView(tester, showDebugTools: true); + + final button = find.byKey(const Key('home-server-settings')); + expect(button, findsOneWidget); + expect(find.text('Server settings'), findsOneWidget); + + await tester.tap(button); + await tester.pumpAndSettle(); + + expect(find.byKey(const Key('server-endpoint-input')), findsOneWidget); + expect(find.text('Restart the app to apply.'), findsOneWidget); + }, + ); + + testWidgets('should_hide_server_settings_when_debug_tools_are_disabled', ( + tester, + ) async { + await _pumpFailureView(tester, showDebugTools: false); + + expect(find.byKey(const Key('home-server-settings')), findsNothing); + expect(find.text('Server settings'), findsNothing); + }); +} + +Future _pumpFailureView( + WidgetTester tester, { + required bool showDebugTools, +}) async { + await tester.pumpWidget( + MaterialApp( + locale: const Locale('en'), + localizationsDelegates: AppLocalizations.localizationsDelegates, + supportedLocales: AppLocalizations.supportedLocales, + home: Scaffold( + body: HomeFailureView(onRetry: () {}, showDebugTools: showDebugTools), + ), + ), + ); + await tester.pumpAndSettle(); +} -- 2.54.0 From c1cb7d1c11dfa274e537d7b60b9e4b8d4ae4ce6f Mon Sep 17 00:00:00 2001 From: Zhou Weidong <502333560@qq.com> Date: Mon, 19 Oct 2026 09:28:16 +0800 Subject: [PATCH 32/76] =?UTF-8?q?feat(ui):=20=E6=9B=B4=E6=96=B0=E5=93=81?= =?UTF-8?q?=E7=89=8C=E5=90=AF=E5=8A=A8=E9=A1=B5=E4=B8=8E=E9=80=89=E9=9B=86?= =?UTF-8?q?=E4=BA=A4=E4=BA=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 5 +- .../res/drawable-hdpi/android12splash.png | Bin 3647 -> 4590 bytes .../drawable-hdpi/ic_launcher_foreground.png | Bin 3171 -> 3385 bytes .../main/res/drawable-hdpi/splash_icon.png | Bin 2585 -> 3233 bytes .../res/drawable-mdpi/android12splash.png | Bin 2401 -> 2987 bytes .../drawable-mdpi/ic_launcher_foreground.png | Bin 1745 -> 1853 bytes .../main/res/drawable-mdpi/splash_icon.png | Bin 1848 -> 2175 bytes .../res/drawable-v31/launch_background.xml | 8 + .../res/drawable-xhdpi/android12splash.png | Bin 5404 -> 6483 bytes .../drawable-xhdpi/ic_launcher_foreground.png | Bin 3643 -> 3644 bytes .../main/res/drawable-xhdpi/splash_icon.png | Bin 3508 -> 4290 bytes .../res/drawable-xxhdpi/android12splash.png | Bin 9271 -> 10511 bytes .../ic_launcher_foreground.png | Bin 5367 -> 6010 bytes .../main/res/drawable-xxhdpi/splash_icon.png | Bin 5361 -> 6390 bytes .../res/drawable-xxxhdpi/android12splash.png | Bin 15231 -> 15765 bytes .../ic_launcher_foreground.png | Bin 7760 -> 8208 bytes .../main/res/drawable-xxxhdpi/splash_icon.png | Bin 8185 -> 8044 bytes .../res/mipmap-anydpi-v26/ic_launcher.xml | 2 - .../src/main/res/mipmap-hdpi/ic_launcher.png | Bin 1321 -> 1374 bytes .../src/main/res/mipmap-mdpi/ic_launcher.png | Bin 813 -> 772 bytes .../src/main/res/mipmap-xhdpi/ic_launcher.png | Bin 1535 -> 1539 bytes .../main/res/mipmap-xxhdpi/ic_launcher.png | Bin 2575 -> 2499 bytes .../main/res/mipmap-xxxhdpi/ic_launcher.png | Bin 2584 -> 3058 bytes .../app/src/main/res/values-night/styles.xml | 2 +- android/app/src/main/res/values/colors.xml | 4 +- android/app/src/main/res/values/styles.xml | 2 +- assets/icon/fruitshorts.png | Bin 0 -> 27043 bytes assets/icon/splash_mark.png | Bin 0 -> 6007 bytes ios/Runner/AppDelegate.swift | 2 +- .../Icon-App-1024x1024@1x.png | Bin 14523 -> 23750 bytes .../AppIcon.appiconset/Icon-App-20x20@1x.png | Bin 340 -> 295 bytes .../AppIcon.appiconset/Icon-App-20x20@2x.png | Bin 644 -> 594 bytes .../AppIcon.appiconset/Icon-App-20x20@3x.png | Bin 1001 -> 939 bytes .../AppIcon.appiconset/Icon-App-29x29@1x.png | Bin 499 -> 436 bytes .../AppIcon.appiconset/Icon-App-29x29@2x.png | Bin 958 -> 902 bytes .../AppIcon.appiconset/Icon-App-29x29@3x.png | Bin 1475 -> 1388 bytes .../AppIcon.appiconset/Icon-App-40x40@1x.png | Bin 644 -> 594 bytes .../AppIcon.appiconset/Icon-App-40x40@2x.png | Bin 1299 -> 1151 bytes .../AppIcon.appiconset/Icon-App-40x40@3x.png | Bin 2027 -> 1922 bytes .../AppIcon.appiconset/Icon-App-50x50@1x.png | Bin 822 -> 742 bytes .../AppIcon.appiconset/Icon-App-50x50@2x.png | Bin 1649 -> 1611 bytes .../AppIcon.appiconset/Icon-App-57x57@1x.png | Bin 889 -> 867 bytes .../AppIcon.appiconset/Icon-App-57x57@2x.png | Bin 1548 -> 1800 bytes .../AppIcon.appiconset/Icon-App-60x60@2x.png | Bin 2027 -> 1922 bytes .../AppIcon.appiconset/Icon-App-60x60@3x.png | Bin 2954 -> 2943 bytes .../AppIcon.appiconset/Icon-App-72x72@1x.png | Bin 1321 -> 1241 bytes .../AppIcon.appiconset/Icon-App-72x72@2x.png | Bin 2575 -> 2266 bytes .../AppIcon.appiconset/Icon-App-76x76@1x.png | Bin 1312 -> 1221 bytes .../AppIcon.appiconset/Icon-App-76x76@2x.png | Bin 2930 -> 2777 bytes .../Icon-App-83.5x83.5@2x.png | Bin 3034 -> 2887 bytes .../LaunchImage.imageset/LaunchImage.png | Bin 2384 -> 2175 bytes .../LaunchImage.imageset/LaunchImage@2x.png | Bin 5085 -> 4290 bytes .../LaunchImage.imageset/LaunchImage@3x.png | Bin 9132 -> 6390 bytes ios/Runner/Base.lproj/LaunchScreen.storyboard | 10 +- .../data/services/catalog_controller.dart | 4 + lib/core/theme/app_colors.dart | 55 +++-- lib/core/theme/app_theme.dart | 8 +- lib/core/widgets/empty_state.dart | 207 +++++++++--------- lib/core/widgets/library_drama_tile.dart | 2 +- lib/main.dart | 6 +- lib/pages/discover/discover_view.dart | 42 ++-- .../discover/widgets/home_drama_grid.dart | 140 +++++++----- lib/pages/downloads/downloads_page.dart | 44 +--- lib/pages/drama_detail/drama_detail_view.dart | 11 +- lib/pages/favorites/favorites_page.dart | 31 +-- lib/pages/home/home_view.dart | 62 +++--- lib/pages/home/widgets/home_quick_drawer.dart | 8 +- lib/pages/mine/mine_logic.dart | 3 +- lib/pages/mine/mine_view.dart | 75 +++---- lib/pages/notices/notices_page.dart | 29 +-- lib/pages/player/player_logic.dart | 60 +++-- lib/pages/player/player_view.dart | 152 +++++++++---- lib/pages/player/widgets/comment_tile.dart | 6 +- .../player/widgets/drama_comments_sheet.dart | 75 ++++--- .../player/widgets/episode_picker_cell.dart | 116 ++++++++++ .../player/widgets/seek_progress_bar.dart | 2 +- lib/pages/splash/splash_page.dart | 53 +++++ .../watch_records/watch_records_page.dart | 30 +-- pubspec.yaml | 4 +- test/catalog/catalog_controller_test.dart | 2 + test/comment/drama_comments_sheet_test.dart | 3 +- test/discover/home_all_dramas_grid_test.dart | 13 ++ test/empty_state/empty_state_test.dart | 42 +--- test/player/episode_picker_cell_test.dart | 73 ++++++ test/splash/splash_gate_test.dart | 59 +++++ test/theme/app_theme_test.dart | 17 +- test/widget_test.dart | 2 +- 87 files changed, 919 insertions(+), 552 deletions(-) create mode 100644 android/app/src/main/res/drawable-v31/launch_background.xml create mode 100644 assets/icon/fruitshorts.png create mode 100644 assets/icon/splash_mark.png create mode 100644 lib/pages/player/widgets/episode_picker_cell.dart create mode 100644 lib/pages/splash/splash_page.dart create mode 100644 test/player/episode_picker_cell_test.dart create mode 100644 test/splash/splash_gate_test.dart diff --git a/.gitignore b/.gitignore index 5450a36..92b30ba 100644 --- a/.gitignore +++ b/.gitignore @@ -45,7 +45,10 @@ app.*.map.json /android/app/release # Local demo media and internal planning are absent from the public repo. -/assets/ +# Launcher/splash source icons are required at build time, so keep them tracked. +/assets/* +!/assets/icon/ +!/assets/icon/*.png /server/ /docs/ /AGENTS.md diff --git a/android/app/src/main/res/drawable-hdpi/android12splash.png b/android/app/src/main/res/drawable-hdpi/android12splash.png index 2f9eca74f4347c1c67ee9d33ba1b7c12aaa503b6..ed4d1853bc928225f0e76c11e633192f3262e7ec 100644 GIT binary patch literal 4590 zcmdT|cT`j9wg+S=ihx%}iUm*pX11r!O=kpMx&P%@yRNQVI_qY!cl zASFT!oskk+GIT;OLQFylLI_3R9rTXtt?Qfr?jP^2wa;4LIcJ~!?Y)2d+vPm_1!}T? zugqQ^9-jTCSFc#`@bH%GUP1!E6EajonTO{UwxkGAyL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!K;<`$rE^9j$yx9N^mx zzz=@|W2g|r?_G#ND`RTd(Nyvj?22_CC-BHOH2`;>4NN^`=YMF7yAp?hZ`jU@Hd?&> z*UIkPh`=pOTE>IVN2$;A;LBG6H@^ma^b5a728Wun3HX$8z?6f4m+H7oi+pgkD@LVR zRGD+{dF+VAJ;bXLGL?%zyApWubIu-UJwXK`sv0;A84o^ui}QUd`Tq7)X!#x$TW$@C zEi1X$lJ0&@>3`6rQ@GrTO0nuyvE>24MU#P=u?6=oZs0WHy!Zw1>XGv#{euQUwm-iWfh4 zPJg2oTl9NW=xOHSQDhZ(rJf5ib(vFt&pql8Ub4A3rGJJ=rDj8smEhBqUt}(x_8dN# z1bhOyIBo7!rI3q9k${hwi*MWxJVCkmH(cqPW-cB@0zN`6{@hC7g%alCQ6%6E&c&lh zz#E*4N0ERpG8cbr8Su4cxp))_c!P8CC=&4Kor{070eIwNpmvqsxp)*g4c^yaU%XUu z61?BvzJIu3xp)*g2fkM>z5;mR3o~=^C~^k8jk$OfWnIg~U#(+{)rMR=imU~1%D#B1 zl(jtzq%Pq#5<~<;3ewq z)qhTGCE^`bU*IL`?NcwN{YAXMw?}=l9B8N)_~xr$hBC)Hs=>fZ)SIgT*%cG<0^dA& zaqZ5j1IeD5-YPmscXf`J=+{@f#AYaqJAtpCytE22Wa!sJUa2Z@qyv;jo-UWR diff --git a/android/app/src/main/res/drawable-mdpi/android12splash.png b/android/app/src/main/res/drawable-mdpi/android12splash.png index d55419e19b939815b085dccd9ff5bc8f18953716..251a44b572624a42225a7dfa81b63f91378a7e7c 100644 GIT binary patch literal 2987 zcmbVOc{H2p8V|K(x{wZ2)l!sFO;Af|G_|yp)HYHMK?(lDMC_f84n}?LBkucg}a-^S#gV{=VmVpWpe#ed}zu zXXk;PAP{H|(%!}m1d>qSe!(&z5J)kqgbV`h3Pjpie-}E;8NHm~%e8J>9)nL4eAyI& zZ%Ea}f8_mGeQ{9wdHpr8qWAIZ74Ji%tiM&*{qr@G(7tm9!v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JzKTH747%JxGSQ{ z4l?VvlTlu+avHjaZl%q9V~;+_J;u{fvb&h#C~BPD7|P4bac8vJB&Wrv_C2c2t+hYH zi}QftT`U^s!CuLms$#FSge#H}`Rm^63k6I2XWopu0Y>3+EWuBqMG+T1@?0lbFfClQ z;D#F5HrS)u<~|C``=WgXkil6o~F0<_7HoL;_0V91MVk&y=nvMuy>|qipXsd zD+11lS0HS;Owcm+FnTt=glDj|8d=IeI@5J}zJ?qHDcjN{kOoH-I*O0{j!1kzP_R%c zSZ+F-`mD*e8P>d6Yu~)npeU3awX{$A4T?VWvfa)zf?ouw@vGQ`wT|KnbPpveozw>_1f{E;TxUJFnMI4XH07!1A0ljQpx zUzeOH0z;p0CC{N!i9j=&ni6PR!BX%%VEWgKva>xVmSMqad+z|#f`ve9(uUx%aHd(i z`OnyE+u0j3G^K*!>F{>ZbtRZXyCJ_3vtq`SLOHymE^A@mo#UL0{r+QL`x6tvIflXL z_pgCBnvQiD`r+WIX*>KHt?&U~z~1Wd7>B*1(FWrj+xY2ng)vV6B<}(okHa~RGB{vw zC8*PA9UTmPehKWI^GSZt52H=M5ut-Fn8O5ICUnpo6LQ2wsiePBg@w>tF_4Px_lzn9 zT&bEjaxo~@b(NU`L{%{FJo*IscWr}|%{6D$fqwJ$tCy$-sfhvrx09X-hSR0={{f;> BH}(Jk diff --git a/android/app/src/main/res/drawable-mdpi/ic_launcher_foreground.png b/android/app/src/main/res/drawable-mdpi/ic_launcher_foreground.png index 689d9984e01f5805c4a48694d431746bb75edb90..5254b8b116f1390edc30ec542b39135a49802c00 100644 GIT binary patch literal 1853 zcmb`ISv(tv8pYAtqtr+nrmZEGQccsE3aO>G+IK%RLK3kI6Et>$(Z=4|Vu{~^IKoHPVJvRYe9`YZJ z=9koQ#R|jq;vqgopck}wIz&_)E0qx4e@{n4vUZ47n2-Ptaw{lM^o315zB(45_(JMC zavUFSlo*8y5$#THxuy^7#*Y(5OB2Sos0j%1L z`}NT(QOg6{IoO&GooDD@gPG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C}9}DMuTwbQKhxKG@@(_BBEcyK%2Q4nH5! z4U@*mdTC5^n}%7HPVJ1x<%W5Q z%D^S1+XqAaJXpFG_Mg;ID#O6+$uNE>tlR--oAo|JYhc+^x)%2Wv-1I;4N{K3dJlZE z4Gy2vNp5hp-X@zmJ`iK5X+ynhIDET6H&9*}ySWxd-=w#hJ5{e2-7ysU+1b_&Oec{z znfsgl@X=QI{UlUX*dSH*Ab$e`G!d$dh2!hEA!qEAI{&^=?k1QM_jQgf`tgv?+*1Eb z^bg80$Up&2o)C5{l{5R^In$)SPCFCSqnF$QoBz`LO0rRT02w%-jvR=I61YZ|UQ!Z{ zDAQyUTA)Gjk|haL_2eagg;l$<_mU+CG@fTKSu#N51@e+b57g?#OMmvwgO@B?pjHYm zx#K95=g~_R9Z;2GUUKtcZJ!3@*-I7;P?g3@$_$h9G&HCR1W*+)FBw{(Dxh96ltAOX zc*$Cyy=16>#zWvGLjlyX6OO!$6?88dc%aJp%~7my^O8jiRH0w)`r{P5xe>PfU6^@E zzhsPAmcJkN8TP-&kbllTxY3dEDjqZ%&IrMqplNEG8uajiNMj-C&m-p%GN?>c%YU@;O#dK%*#ium7=1 z6`>K-^y-mOZ(TlungN?Kmphh{Hz%7QbDNZ+XvG}^FQsRxMkA|{?^-_b1jP#1$aKg5 Y0O{gNzt``P!T + + + + + + diff --git a/android/app/src/main/res/drawable-xhdpi/android12splash.png b/android/app/src/main/res/drawable-xhdpi/android12splash.png index 49cf10dfd5c0e76c4e839418ece26987fe83212c..9794446c5665898c5dafe6825179d1e37bd25760 100644 GIT binary patch literal 6483 zcmdT|cU05awhrhB4#N-!6+xP!BBErZN=F@<^e#mhrAfyG2)&4kqKJZk0YXM;5)lNX z69N{bg%&!2fCw>k3@t#Cd!p~%H*e;?cb&W5AMdgjYp<33a(-v;^L^j`&c0)6tjqho z(Dx7sgjZkh7jp=NQ;Yr2y$b??xTX&&LLh=d`oEmD3?7~z^?HCtUM4S-5m|^=VI7V~ zQHT3%WcCl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$jG_{|{{LjdTD2 diff --git a/android/app/src/main/res/drawable-xhdpi/ic_launcher_foreground.png b/android/app/src/main/res/drawable-xhdpi/ic_launcher_foreground.png index 7d8eb3776f13f58b831db386173b0f03709cd7e1..83b9072946e0dc6f23460b7910371dae9a637768 100644 GIT binary patch literal 3644 zcmdT{=|2>V6Bp~seI~itr6|FEpkU>g(#uNy0YQf9=Xc3V%=Mg8k zbwu07VjtJau}Q0Coj=d}-#_rYn3)$dFJ`_opPBEZ+^~ZRoR&V##>OUKV{PepV!!<> zJX|L_ML~qpz4wa0v+ZI{OR2RSd)_%w3@~ty6 z&YH5^Ke4VAksbl}`%bI7KCBjO91`SGSAr?NdHHhVO|n8`wyB@DwZhOZuC|>L#Ae(4dOdzfmCZQ;-^p=VM_K2x2AO^h~? z!$nC5DmC=~iUEcY*lb#lPu(NoaRT&%16w9&)DX0xxG9Y8ADgws7+e3-jZ-8~_6`i^h*8m!yu6shfasncl^=DdM3H1R zwVQa?iOTCaL)+WuXYE@v2nXVl5-c z*)p=_(DYI~fL576J)A39(2rn~t9KLS5SQJCsKB{6_=5<5mc;CCbx^wFOTzgo>HU4dJbs>Y)#!1n z-)OP&fNPz2Rh0wPpgB=Fx+&j1fTUj@gijM7**jVSfnkkYev#k$_I~yONU{@UJjO8n)|F0(K!1Fcp74S& zJD*|zZQK#)yLSnkmA%Nk$Z5*Xr`wDOjItpH<80>ENRfe9@Fi1#WU7fA@3Z90UF2p? zD}FQgdHyDhHq*wRa6zF#I3SUU7d$TOoqJU2H(D5AFYlgNxhgEBsV6+K$m+Jm_}EXU z+^3BfaG~Ze87F1X;JNU-} z7ggo1q~qyabGvh?TFnV~JZTR^%z0MnywXkj3I`;@Kpcv9g;i)wN+rUd7!3c6w&x`CGz2`lClJ^C&rrBs)vWlCrol3U4ZlN-c2YOw9EnVh0|a} zU{wt;NDdK*xdIo|Q!FA5XA|A^fT1JORTs4+c=?(fo;C+6((Ae{jLfz(-{X(=5Z(2! zucm8xUj)O<(Tn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G0w2n<*8W_m@>9-3|2_?5MEov|Jl_>K2iJNP*s--7HC6jB))bq13hwq ztGd{aI3VW4g04wz_wn&k<;NxnK+ zfmy=+39cYrWJyvvmCI=To`>{EI7vA66+BAHY2}=d?YV~YW_wDDy{0}8|0YT8xLg#=!Epmtp!25C&o=iI1cyayyx7Sr(y0jo|NpG#f0@>7tmb99 Ux3g%~f22_00^S-|gY~@kKYW&eCjbBd diff --git a/android/app/src/main/res/drawable-xhdpi/splash_icon.png b/android/app/src/main/res/drawable-xhdpi/splash_icon.png index af935a619f3ee6d5e7b492323c741b4dd434dc6a..28280041b312c329518454d32332fe5d6ace7325 100644 GIT binary patch literal 4290 zcma)AXIN8B(+-hdBqCizrAU>I#)p6b0Rbh1UZjZxklsS1BM2CpL>_uglqwLKVCYB_ zkRUY*QZ!PeS247_@%_H*`~CemJLj66o!zrDXXm~b4Ts(1U=?Hq0012NdfFy5S@!o~ zW~8-&_lp|<01#SVThr|6^hUmiZ{B2Zf8=ub{G>bHX5hNsL2{y3jl1Sf4?hI?t0xuv z=FvZo81=}UvA`Q&#-%dPD;p|5x^6huVET%C49jp|DdR4}n*x#(Kj$sMuUV9_19E!g zlv?YoKZ=l_UJG4|M~M%?Wbue6?_|`e0^t}-`>Nkf)BqwCGID!$m}B_UYg_HftEvu0 zp3JE@fmR>)Yjo0ZIZsFPcR*=JIXNrycK~Te)-oQJvM8w>BwY2Gso8)j9SO0TaUoZgZtKIh|4!&U*i~P5rOYwMlxIvH0DJf%$u817khv zI_c}U|1mX?&@eiYym0*w9O#*>T(BF4P{ z>F$;?k@#RgIEH;k1Ot$^sfijqF*U2*ga4n33#ubRXC_7yz%o6ts04aAMi0P)rU`&F z7faFq_K8SuG?Ek2#*hG85(9~$7(UoC)sGa~3KgLX)aVSnaY-h-2kEKez%i)cdxNcC z#n=GL6eC$^1m%Gaah9e(z{TH{C46VZSvnXx_DVOvK@w@#B5{R3TecJ%sfM307n1aP zVn~g#S^gcCKHhHjkSVxO^M+YMT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^_vdpv0y8N=tIB;i?2*G)( zs&KLyn7m|eD%;n{b~m!Uj%*?(RBvM=cZcN4H`qK38eL5q35*+l?6GOnQWamdmt{)s zo9D$(t+0Yd2>kI{Pq0)-c}1zNk|w4ZKU`l?q-q9N?4FxhW*jJJ2bk((I&=K$tAFvx zLNW92?HwzXSbpwhm}UCDZsBw1Q^5KiK);-`%s5cc;}FQ_C4X$HS>{T;=^$BVQN=V+ z(1KEl^kqtx`I{BMiY=PAN|tH1iYzh|v|#w1^<}o$nPtX-f))fn+LyUY=a_B!GJBOr zOaleA96#EZ`F@yXt^xKO00#E8KYz=N0|m91mgDqg$_<08`ZDu^f?7y4%bdRkxcgbX z5m3Y|GY%9K_V#5yxK^JYQuHh{4iwY^qFLtSn}9n?lx4<&g4(#oe2f0KAtlK&<3K?z z$}$&kR2k*UT&~Dl92V0+L2b!0oAk;&%{Aslgo5UrWxjhrL-xUa%bR7!fq#PLy~f;u zEHe%iG$qQ`mzft7H0?F!VPB>VYs`xX1E(={k)Qu}4D0}dWef4@xEpr8fYFVi(BXg9J<$uT9*ln2lb%y_>{*Px(X%rd2F zz7}Sg!Ie3)%v7PEU07qzEPpe5C}>pA)P6=9u{W4v{89{A&_7AC@(hJJI%wkjTQkMCQ;HN^Mt&1Dv4qf~<0_831BA2Y<~@z7mD zIwNqh6mw8gUMMIjjG!Fmi7gy;krk9!O;k`;QIa=p9ApJ0R@0uKtfC|@j&Y9_lvqti zg0hN|tZCOdR#0L!oqq|+DoV1VL)VU1K`ALon@%08Wr(MwBrT5X7U!VEYHAgfRg@%6 zO-^;Cf>KhF6g9il)ghjelDKrqq3+B?}~{|{*}s+s0-LVo}N002ovPDHLkV1n86y;lGL diff --git a/android/app/src/main/res/drawable-xxhdpi/android12splash.png b/android/app/src/main/res/drawable-xxhdpi/android12splash.png index 09b431e8e3222e0fd2ad0c687fc758f961bfe39f..c3418c0f2f8fe2183ee150fe751fee0819f420d4 100644 GIT binary patch literal 10511 zcmeHtc|6qn_y0(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YZNHjr53fu(t&8{<|g723itmHQXHske^}N zV?}unwVXiD0%!PjJmJZt>NFZDny(`Q{PkZ;3Px0CIz8ep=g5PGiE_q>u9BL{9Z<(2 znEO2CZ2z9Z-hTmtLl8p{#_J|l?-T9feS+<_6zIXwoB2iWLeY_+wUQ)&h|^>}F$v~^ zO${eGJIz3kB}5Oo6794XxIc2NS->U9i8rT&4beHuzRxAfiN`(zLZI&mo@dCn9B60* z7YOxk;;J3BWa}OHAomTS(-NC4Dz@s_(73M#T4Obi!p|h!yE~Qw>(z$wjzAfgn&@ZD zA-<1?&Jpg~8~rwG09B{e!?i2>icAK=|mc_*e)yB55gryZ2$lO diff --git a/android/app/src/main/res/drawable-xxhdpi/ic_launcher_foreground.png b/android/app/src/main/res/drawable-xxhdpi/ic_launcher_foreground.png index c1c47be1b35d9893bf1b9b764c3406b539770a07..871b1435deabb23a6e3a3f74c768c031eb98cd74 100644 GIT binary patch literal 6010 zcmeHL=_6Ea*jKj6lVv2N?Aue;BxP^RSjLoPD9gx%WQj-C(O?KMWXV{D$i6QjOLiqC z`;slPi!p1sn53~#q4yy^-cv;)>%wyf3=;z$Pf~4rOChm;$Z?aoDT&tut1m?!bHx7 zK)B9)6u~n*;({?Kg2Wj3|Nry0FGG%2;(K@v-Ij#{5XcbU8#ruZSeee0B$R}s)Bh33>C#I?CVGmY5T zMX$zkA+@0mkUiILY%6!dYmuwBW+dQdg@(>PwI`Sjv7!@I*}EM}OLYCL>kbkw+mBsb zoL}e04#MrQZ)!7&#bcf+hmw49a+I9MD@IOJP_%+-1!pI=bZQqgfKGTpUL9iU3%7w$$vJZb`^^=n-1guxCzSrT>Its z3)W^j4sF?vQ*z#MyY!4wK{)Mmy*gV9*REq(j}cM3JBN@@SZHr(*B8PSqoJDFm%LUV z5|sW(bsOJH9;r~EuquZLf?=%ZqT*5#yjP=SB=Wn0-RV35dyJe0ryjv5B|iDrZx~tq z#n`7s@f+s zHtn_o-ri}~#U24(;Tvg6YeAow#|Jr#p^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n6T!{sckww?=rd@s20#P`k7282|npmPF~6IiYKJWj15OIg6K%a z)4eT-pQ{p<`&Ipaeh7>Aa`Dne*bZH|^%pA&X-ja^vZ2T%$lL)8#Yi8o(7(u-1DuAn zDk)5C5D~Uiygeo>n2Nv^41OCPzV<|`o`zR&eqFC3pIwI}1P(XeZ;_*9Pq2pO|@9caUHtJZs*I)IVAHw;aojqr8lDvR?tN<)J z+%(ELG8CJ$#ZQNncX^i!%f3L5f7cM2Yq=f^z(JOwGZHzN{{&)K3?_Mstr@A zM5apYkTX!!Jo0mW^Ehr|kr|qyqzo)#9RB%uzp#R+BzMNAUL^k2_j7FM;E^-HP@-}$BswGm=wRr`gO-DiKX0JN{7h}3Q=bvGzZ%k z0x|os5Dt@UK5nRmfcE9bdwrWZxtl^%6s^B-2v`ztQNGWPs`U#Ve5R~7aPxLTvs^-w z!+s#kQ@DCx6a?I_471i!V>T_pImWYTkFW@F&rVq&Ye0ywa|wjy`xbiKoj{h=mwUr? zGB;8sYSfrYzZme(Bf-Cg2X#IjWJ7gchHH<~wLcf+`AAiW>0qvCcHqNKvR6e=%t9c@VF5I1_*IfGAMj6=Rg&L}dcC57FzFmC_zrsxqg> zLQ^F)br5=@qV<<{QNC4ILQ2jS@!rvUPKws|-N)CL4hboBu+U>Uj6M8(mn`y!pMsNn z8NA&Pcd+jLrQ;MYd(8YFjIcql?lj8Hd?ZqJ2^&Y{BjNoqJ{akU#dH^IJc0AFhf^t5<8Q@Ai{R|2=qZT08s`5? hW9@(S2=Uvy``@pf&Na9AB5Y`ioVS5mms?(s`!CAMw1WTu diff --git a/android/app/src/main/res/drawable-xxhdpi/splash_icon.png b/android/app/src/main/res/drawable-xxhdpi/splash_icon.png index 78ec1ce8fd2c6059f5732b126718f0fcab105157..eb605781d82c306928faf29b5cc687b2cc1ff1d5 100644 GIT binary patch literal 6390 zcmaiZXIPU>*KOzoBnce>!C2@`;Zb@Zh#*~1P=Nq~0wP5z!O$gubd(_ABY_}QrHB*> z1|bo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#ro}WhnD+1n%@JNA8I<04g$&XEx%5#eyuRg^)t^V zI6&I#`sCWg#8GyJLt(qAGfSDWiMa6mf!nXGGSneNKTg9n<5;T{RDBxp%I%j@H8pK{ w`_WkmXSZxwT}g{V!>2NvKFu)BIfyJ|_HBFITv16AQ<)%pYp2syr!L?9KY4lHrvLx| diff --git a/android/app/src/main/res/drawable-xxxhdpi/android12splash.png b/android/app/src/main/res/drawable-xxxhdpi/android12splash.png index 391fa1a9c8c520008af2f6245047b6d5fcff2454..ac5df74add4cbf648bc0c9544861154037d487b6 100644 GIT binary patch literal 15765 zcmeHu2~<SS#Sjq{WF`zjDFsnMW(foo zAr!L$f(!vvlu=M3ATuZs215u_n3D9l33gep-|JVe*I%pqb-!Axa3wi8XWzZ|`S!QJ zb8_p1slm2ycYF&$&^9B(qvjB_F$Dg9^Ck#_!hSt?7J{_T867=*%CCpg?>|pK+me^t zh*~v4ZPmI8TQ*8>dGKID02BAhN#>69N98=}w-?JwFWk<5u%Z15Y4M~@?>EUAF;dxv z$*IDUQblq*AN&H9IzGQCvoZGUk(}UFrXqcfc1mGLV5`yh?=2QE_*iU=M%(gefks#M zD&t(&!d~ayuW`T<$h}WNdjt44WV0^(@+btqklY{uzt|oE{|$#Wg1@>OCE*uR5EuCS z$3_WoZ3bii-dvnf>&ySm6@NF1v;1GN>#vOBEdM*}|K_Om2NnncX0Jc#-y6#@;*X8u z81c{NXkB(r{Aupyq|_gC;U63ICp#MYC(Y|W%hCTQK;a*8-k+R*|9pu0e*q=`5qw-P zH2+9W{f|JtKP~hA3sw4mxAXpFiu3oJ7j>4h9jblj`SKf0t&M)a>|?cPi*JBLcfD$< zJM-xPr2C6_`2LM>7Ka@Dd@cM41ZStz3bZ|xP4|w@b4hLDf>AJhhWqH|4KU>qc*hg| zBl|0oFZjQ_H_Q_*@Z~*$otvRe$0oKz0yLh-yCL1rfORPO>wezE`8sFl)s0&rDJIm( z$7ZE=Ly+rcsBZgyXr_HrUG#n^Tuc`_y2kam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Q++-<42O}I|6V{56 zwXNLl^LLkAOW**Nju-;&-23@gpU5H$5*0AXnifpHw8NL~rS~b4cM;$X7tOE|n<`pc z2IGem+C+>woRiwd7A6s3Fp0tM45q9%Hz2`F zY)nia&YlKk!4ssJnptms88(e>2vjgKga8Dw4~YAd&`Rk(=#G_xsI&QBW>dBSFqkeJ z0noW~pz>}z+}@@!_1`?kpPUFsFoIX}KgEFja8gz=rSO41+uvNLgvQRsRK^mn;R*aK zTyY%F*NdY8#)8=p5(o(A=wj7hA5H?a{A2X)Qx4K;BeJTwF;gHmw8{u46H;rDI_}6X(qR5Yb;XKN0*rLq*Bnfuaw5HML ztJhIDA$#&e*I6G~u;UQ$dZ+3~yo;8r=HSZDh*y}cFYVU5N@E0dke60bGh!wArMdXt#*EC|esOiB&SU29ALcFcnl zOlq5Ln>#(wAH8asyEP#N-P{Yo8lV3AY4QL2N%c=u3m@f%`T@f^;7c)sp0**XO7kB6 Fe*mS(OqKuu diff --git a/android/app/src/main/res/drawable-xxxhdpi/splash_icon.png b/android/app/src/main/res/drawable-xxxhdpi/splash_icon.png index 8fde7d44c04685fe1d6a07f5e629b4a721804280..ab8ca49a14edf998e371d95d3ae17e30c736fc37 100644 GIT binary patch literal 8044 zcma($c|4SDv_pg`sgRPTuPkG%i6YzB*BFeQL3R?xPL>q1@5VZ|Fk}75lC0@NOtOKcIi!T_&6M6x`J@=qOaZJ%LDF+m>WO#H!_ekh@d?FX1f=7I9EZ zO4s0eplTZ!PK-0p2&ob2SAFonx3wZFD0j@%x@fz5zh!-W-9MARI2)ppC^tiH(SF(G z<MJXV8G!_|pg;ze( z1eeqVUP%5H;ORWV$6pS$Cz6O?8w4*jC zU~lxbg0EvhMT&2Xf8W&7IZg%}d54uIgNJH5{|1@;4f1d#Pu`#qa+Xh)=K!UJfC`T& zgvv|dz$L+BsSY>hXh4`nD+s^Eh9 z{|)~aH`w5_925?+V1s}V%E8qysDeLP-(>_Af1ckIOk;fySh&8S0O{V&<(nn52*LZD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y7mr#GjF44sa{-1-e+0Bscg~mghu_xIfeL>QiIqP8LOlgmDR&dtQ7?Ucz~-cbzm?t z5G2G3oe!y?z17gTO^r_P$V2o2u)gvNDR@wrlJuk_ugSpJ%?cmHe)s6u$sZ+YVoRf6 zle}Q@-7B;*8au-za;{dcr#ZVm2{Iv_fPvxe*`=``ImwbUDz;Ql2=+s&T2dY|{8>dI zh~F1(Gu@kme|o{jP+Vt>BIgKMgT8GI6Y6vlkG%j3_@3%KWtcb+zeNM~55Rq)|2dH} zmx`C>TEvzdNw7F4EBtBh{(j)3jp4dm{nS4NTHzVo{U8i19S1uB9I2y4038=Abha^X zAaM%_9)rHOFAgN61B7ba{fQ&~@Qn)P=z`y^Py!099}O&3mUZZ8&!1n$<9~E|t1++> zEq!DCT7b6vwl_F(Hhy@cv7Jp~OIOKht7h9Ym0B1(Z~$`*u{t+OX-$g_O4);Rt(JwF z;)K^dVoQ12Abyj`l0^4g76wkQC#iY?T}4Dw-w3dYvprpqZdkm3mzUXZBF z|5e=}h}pI(77%XXtNH&gyNTfQy4etGt?qKlHlQ*=V7|i<8>?BC8=$ezhs8g@)gv<5 zG6o-l78Hd4)%O^@Hjb}A_{sW||0@QH@=Evd{%8T*N*kcscyfV_uDZa5ZZA#v7$@U#!v(ScF@bkG(ItY%!*9Uxnrjq^l#jzUZo;XOc=t8 zPsQXIY?ZMA!l8z}^`+NiHvwrO6&7+ zF0ILH{sLN!NWYfEiuAcxqKD9n7WrHgZKt-vvM5AAgo|Vdp?GYPr8(X^*mU1fJsjpX zH4w`j2CdM!`j}e?tcXZt71!NkH+c!p22ngph;;5N(h|J9*UDJNr}U*ucM-T}jd&Ua lLHZki`dZYNWGPzj0UHlgMBU - - diff --git a/android/app/src/main/res/mipmap-hdpi/ic_launcher.png b/android/app/src/main/res/mipmap-hdpi/ic_launcher.png index 4216099983f62559b4414ca3c90bc0764cc58b85..0d3f7bc72a2cb581ba30cf9d862232c17b6f3c99 100644 GIT binary patch delta 1366 zcmV-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Zxb5m-loJbZ3&&?qo2#8OdDY$qX z>%+t1a{2FHXoQyeqpJ(X&Q7Q*DiEBS5+9jkYhE%L?gEh-5Zd8F=WP;G6^#56-um002ovPDHLkV1h7OY|a1x delta 801 zcmV++1K#|E2CW8=8Gix*007uvZqNV#0`y5lK~#90?U-LkQ&AkpziS&#EjOD=_=n0; zqL6xsjH0ZEqI!s|2NC)Uy+ja*Jp@6IQHq+uMny%16j2IMAeGL)sjadd30p5PYxhF98M}QDO>uyat?i@jr85Ira8VI-0 zq}G;f@eKT%8hs!f3LK9v%#*r9DW&0S^v5?Q3QXxTwQ`>Pc7nKdDegkg+r)A+n zt)Ea_1FI9+DYVU*tw^4a^1ax&%)e%;8t3;=XjK>}w0~x|5-8;M;KV(Qj8pl;58p$p z6Gb&>FZS;zmaG)$3ef$XLaXibjQg}ep`l+s8$X7fu#HhyaUzo;ClytP(Daegp?6R` zp;R?85@E6XKhM-6DW2zD3au<`UXDlIxL`ov)X)+rBm?AJea<;pGqn(>%74R|hKz+_&}l(Q9gKY(GfALO@&c$;9HFO;M`G-3FTNi{nE~}CuwyqJfkH6~ zl{=T}-G70$Db-%)@=%xPTWCuO3h{-!3{8}> zdYV-N5L1X@P-jB90j440jff+}FnG~V(b8!NwJ8yV%vO{<^+ikQge3IEhRQ}fco)z? zM_Qp_CtVb8zZC!e8nn=uo1*2)Gb%_y5JD~wuD9b-i@@uI_(HWk^pl$Z`GeKm5EbGh fDjLK`REUqie#G%&P{V!V00000NkvXXu0mjfmQ8z# diff --git a/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png index 7b131e3c4370f00852e5ca87fdfcf092e1a209cb..d7511150514260408efeb2201c827d54b8c9447c 100644 GIT binary patch literal 1539 zcmbW1S2!CA9K{pF-qn;SiKI$V1g*V_64kgDS5s<)wul-v8hl2mNN$nVR%%pITcT># zs(p=KqG{1#eqW-fbt`sz-S_*{hjY$%&eQ+p|NHYdw5^yhL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ds>@;%}(jlC@ zUhu#lik6^vjN};dD^Uhb-(c`biQDnqEH^qui8AO;CEM=DwB{kBqdp%80bcI-M&}6o zWI-Y_y{dS4ShaED9MmTRL=#HVm>XTg<5KH0Uw%xoujA(FYmclo0Z&Rxwe z`+ELKQd|OG5Vix+j^GNW%hj_L04N*G$wgidTyb7rOtX|RW9IE#lBAj7ef;4t1Cy`u zG4Ju6SIjk3REx-*WZXIR$s#F(-U3!c%+kBNr?oeVGMR*`4IwjMj--cp@*?m!F zo*M{#girzh{L*oYM1!|D<3f2xUX0U5Mf6Ow>s7_V+ktpwz$a{@ypjA!kSf-s}%6!h&gbRskaq>vl?(5`7OF%?5kI)Rem! zDj`3-8y#F_np^}W{49b>Bwc+8G)((7cI9JU%hiOQzPJKa%V<)C@%0B+?w! z)T!HXd~=_8MfD+@{l(mynbi2H;Fs)fE5->K>l-!HQvcl)9&dG8dIrd6gBpFBrT%4t zhb9!OiaZJv^a|hvdN`-g{2rJ)oRMrmnmH4Ey1&M65}yaWUdqzn&Cf%NuIo*L2Q)cv z{qcj{R3Jd^cB$2D7tplcn(_$*$$S%0CepPW;xne1X8!J!V&n7N-^4{b#^V&}vMRm( z2KQ2__$aI;y+dFUv?il*xsSG%r?A0XUG@Vmg~5pl+ZNbR(@i%89QN79(!R8%c^!iO zez_rhZ%iojq~I2%xbYExh{aDBi@ciMR0X=yYuY$PQ-Ons6P487^KwdVtG z(_BBu*Irhtuh2fm5arcnM0gg-h6=r3?RMx`A1}^k?wY{Ls`@GzTxv>`8Vxciwgg}` z1G5=e*kXHzWOa^27paOvHLig#1 z1{W+&$ zJMSYsb;~8dSWwO%qsLaurqj6CR4<4B=fB=hK@0cM1Tz}5Z2v!v|0?Ep;illlAcCt} Q*;(Tu=4flwa}y8nZ;MpWHUIzs diff --git a/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png index 48357583fe323e20b308ce4f293ca410a82df0a3..bf85ac7d7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b^=XnrM~i>}POt;mJAw&0LDM z%=C@_>9Xh@we?HUrJ;tcd%f}NK~x@t{(K}-^Z^q>JnO7wbBtDThtynw%d>g-@!9)1 zu@^kMw3`rrL-MXFzmG{kyRDiht+DeRQ}@swR75lA-d#rpds1veb-g`2kU@f6c0e3$f0qrLrv@`)+Ss1QQ0M($#a*1`6DU&9tqUc# z3CnHGTkP9)QqMg(oR@0XEhQb&X=trz9&?fi;E%M>3x+9bf(`gvbVF+@V?6e{b#>v< z+%&uHB~mjl*LNUn;*(jo(AkdmH5n+pv|m* zZ)cLpHQu^4=C2xF+}nA=1=%_qn@VjY+6t-pERXt_VOnYJgvQ@i>gA95*^WB9yQH)@oVwNlex|R?$e$`1F;W)f+N+|gx7k?$HYnp_DA+R=LaPa(x}AqIxWwVgz3NZ$UcPe#Dx8Po?dr; zi7}HS+$}e4@_=`Fq5FYYPlfc*tVI5vB+Y|Q?bo)4|3POI1w2wRZ{J4`{8@l#OYsMG zrm-FIVMyzdtob}fH^m4QW<5AU3dPqDYeZH5PkkF`3|;t_aH+G}GbV)>lb zwzl|Y$+x$U$6k9T3)l8%=lMt)LTDiMe}n7T!*jG2ulC|NPvAE@y3X=wm;=F%?dnD{W#$j;8bg9*1L_@yC>?h!~GMd)sE z-}pU^s zto}FkXYS68(tQS)-$w^^2Vjf;A=v>&=NZ|>^S}^eMSc^2-Zj*h%CTT$$w=L;7@Lks zl0=uEkVOYE&;Zj8DWd_5Xglh|2IGXBh5-T=*nJ7mmT0SNSox&G diff --git a/android/app/src/main/res/values/colors.xml b/android/app/src/main/res/values/colors.xml index 6a8e712..3462ee2 100644 --- a/android/app/src/main/res/values/colors.xml +++ b/android/app/src/main/res/values/colors.xml @@ -2,6 +2,6 @@ - #FF000000 - #D74A7D + #FF100C0A + #C4322A \ No newline at end of file diff --git a/android/app/src/main/res/values/styles.xml b/android/app/src/main/res/values/styles.xml index 3052bbb..5d7602e 100644 --- a/android/app/src/main/res/values/styles.xml +++ b/android/app/src/main/res/values/styles.xml @@ -15,6 +15,6 @@ This Theme is only used starting with V2 of Flutter's Android embedding. --> diff --git a/assets/icon/fruitshorts.png b/assets/icon/fruitshorts.png new file mode 100644 index 0000000000000000000000000000000000000000..bed17d0ffcff13583bfc55ebdabdf3346aeca899 GIT binary patch literal 27043 zcmc$`cUaU{_CNjxRE!1OwGc&x1Qi7oBLY%~e2fJUFo0BHhzg^0L3$a~sB1+*K-!?v zg7hwRupmts0RaK&b!bB$7-r`EJ9jX%7kE+}o#h zPpn_FZ4HKD>orgQppRiI;LjD<>Q(R`@($_i7g>5g|EEgwcXc^D^mf;|J=Ac` zx-!{-+YV179d}zb-#LEqkjVNrjaBloH%B~0F1{!n*Y0q)V0Lyf7=axfC!gOwDPVCX zy~XUnv-npfi}MqlVghZ*ODe{*b-)@17T}gTvLF77@u6Sh=ofF?SOD+O4ZPp{=(h&% z&((kU^FQDBuOIPm?n6`dr?38}`^3>5|9QyE_wh#mPmc)TJ>s9n`NyyR&-eY)BmV4t z|I?@bFRSza_*4JQZ2kZ8sT#bM`?FX7(~|rztNK5EsyJ^f|Ib!cgZKFV@>BomtN-JD z0ldfmm-mVDF8(h+^*_EE`{R;m@E-qP-uGV)IpBX8viLtP{>`5Oynp?(_x+bc*5Ezp zk6-;~?j-;#GeZp z#7{paaBmW{!*^LPt|y%Krt(G=MZe)6ukV%BEnD;W*rTit|EyA{{35bt(k|<8trChB zr>e_aD%VV^X~Y2EDS4f*hZi{lhLXC|-JKqU9DC&ACLi6@^f+3VNlt4q7$4Q9eKKLD z)2}qR&bQLlmc|~ByGzY^8wGCH9Ibq0Xq&rB)6Qm3ba}bKH{Zvbscrsi6ua-Swbs?; z$C5G!373`0FS?1Ax>6yAqW5P@CU0CS9zM3Ucp=DeNp$PWg`kfoPBebX8ZcDUaJaa4 z?%6XKwpMP0dv>^Pw$})w$am7JEnCi%)ex5LJ!TS0oo`CnsS?^;AGH+hIt*J7DsA`cwGLa_va+n}2wnE>x8=R(?ifkuUcEX?@o_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L2Yj0xTzR&79Eg)HxsuL0sVPcJ_Z>U1U(RB6m3|N67h5Z Q33cF#w!T&|-sbUt0nW?M#sB~S literal 0 HcmV?d00001 diff --git a/ios/Runner/AppDelegate.swift b/ios/Runner/AppDelegate.swift index 0147af1..946f662 100644 --- a/ios/Runner/AppDelegate.swift +++ b/ios/Runner/AppDelegate.swift @@ -10,7 +10,7 @@ final class RunnerFlutterViewController: FlutterViewController { override func viewDidLoad() { super.viewDidLoad() - view.backgroundColor = .black + view.backgroundColor = UIColor(red: 16.0 / 255.0, green: 12.0 / 255.0, blue: 10.0 / 255.0, alpha: 1) } } diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png index 4395a4f732dfa7db4ae6ee98093c42e22a1a5f44..3858b4378f871f97a9773e83a03f91d3e755c83f 100644 GIT binary patch literal 23750 zcmeEuc_5T++xI0xB#Mw^Dnv;tiinXG+1(^tmaAY7YQFdU2Z4+-Qb-;u4Y!nFym37Z8M9_FQa!=#7>fmj)W>f= zJwmDe!fAYGo*Aqwjn$?G0Y0Jnt*h_{#BuERM<5UUfm36LKU9ywJAu-8;GIDF>`d^7 zFf<(-?kKy^f{H(PGP|h?v?irv+GEeUs>iJ7CFiaL9>8(XkTk`rhdQ9So)yHF3rb* z`6ZgpDHGb3lx6hvldQv`7uVj_)omK#L|zJgf9oNfj=Fu($)ThP-{|639WC;ev5_B9 zS2yNOJVct4_47*}yIX=M>O9xKxk?RTT!{iaWv^wkPI> z+cD%$SGP;D(V7e@-of(GCF-D)y`dcBJEu9d6K+u?ux5Tk z0^QV&^?Cm)#(+cnEluvAGV3m7rO%Z|A=N{`2}0S>GQ^I_B(-CY+AkO~b~<_83;8kF zWgLCxb4p3|A|tI?G6sh-3;eUI^xJOEQ-zf$C|?c-AV>O2Y?@uDckgblyTqXZxwU%& zK`wQBEMjBq?9YD>kx40jFp$|v6x+f0x#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