26 Commits
Author SHA1 Message Date
Zhou Weidong 70be941755 chore(build): 忽略 android 构建产物目录 2026-10-29 09:18:47 +08:00
Zhou Weidong 351d0afd09 chore(deps): 补齐 pubspec.lock 中画中画相关依赖 2026-10-29 09:18:43 +08:00
Zhou Weidong 7d32324a2d docs(readme): 补画中画、下载落盘与 iOS 打包说明,更新接口清单
接口从 26 条路径更新到 47 条(补账号设备/注销、搜索、剧单、标签、剧集统计
与解锁、钱包商品订单、评论数);画中画结论由"iOS 未接入"改为双端已接入;
下载由"不落盘、不支持离线播放"改为已落盘可离线、但不支持断点续传;
门禁更新为 dart analyze + flutter test(775 例)。
2026-10-28 19:05:12 +08:00
Zhou Weidong 1d4ab5e0e6 test: 按新 UI 基线重写过期用例
覆盖 155 条失败与 4 处编译错误:入口改走推荐流 tab、弹框换 AppGlowDialog、
rail 尺寸与底部锚定、子页标题字重 w400、底栏选中品牌红、收藏文案改收藏短剧。
全量 flutter test 775 通过。
2026-10-28 18:48:03 +08:00
Zhou Weidong 799f3d1b7d feat(player): 选集面板挑集后记住上次选集 2026-10-28 18:47:51 +08:00
Zhou Weidong 08aa6903d2 fix(player): 推荐流播放器补钱包依赖并统一点赞选中色 2026-10-28 18:47:51 +08:00
Zhou Weidong 4de9417e27 fix(auth): 放大登录注册分段的可点击区域 2026-10-28 18:47:51 +08:00
Zhou Weidong e269d5dce5 fix(ui): 修正卡片正文预留高度,消除底部溢出 2026-10-28 18:47:51 +08:00
Zhou Weidong 78f464f2a4 fix(ui): 弹框富内容加高度约束,长文案恢复滚动 2026-10-28 18:47:51 +08:00
Zhou Weidong 9983d42015 fix(core): 非移动端跳过设备区域读取,避免注册流程卡住 2026-10-28 18:47:51 +08:00
Vicky bfe0df62dc Merge branch 'develop' 2026-10-28 17:14:52 +08:00
Vicky df2654c9d6 fix(player): iOS自动小窗仅在播放页活跃时拉起 2026-10-28 17:14:50 +08:00
Vicky 496b1cb797 Merge branch 'develop' 2026-10-28 16:39:11 +08:00
Vicky 85dedf20fa fix(player): 修复清晰度切换闪屏与还原黑屏 2026-10-28 16:36:55 +08:00
Vicky 43e60e29ec feat(player): 接入双端画中画播放 2026-10-28 16:36:55 +08:00
Vicky 5346be40a9 fix(ui): 打磨推荐追剧我的设置页间距与图标 2026-10-28 16:36:51 +08:00
Vicky de7da64886 feat(ui): 登录页重设计并统一弹框主题渐变外壳 2026-10-28 16:36:43 +08:00
Vicky 709972245f fix(config): release 包固定公网接口地址,不再探测开发机
- release 默认地址固定为 publicBaseUrl(39.162.50.99:8081)
- release 启动跳过环回/局域网探测,避免合并 develop 后请求到开发机 192.168 地址
- debug 行为不变,仍按环回/开发机探测并支持 dart-define 覆盖
2026-10-27 20:10:06 +08:00
Vicky d5d13549f5 chore(merge): 合并推荐频道页与沉浸式首页到 main
- 新增推荐(tab1)接口分类频道页:分类轮播切换、选中频道自动定位、下拉刷新与上拉分页
- 精选频道 banner 轮播 + 接口 tag 上新横滑 + 双列短剧网格,卡片标题统一白色
- 恢复首页(tab0)沉浸式全屏信息流
2026-10-27 20:02:53 +08:00
Vicky c027acc91f feat(recommend): 新增推荐频道页并恢复首页沉浸式信息流
- tab1 推荐页改为接口分类频道:频道导航可横滑,选中频道自动滚动到可视区,内容区左右滑动切换分类
- 精选频道:顶部固定高度 banner 轮播图 + 接口 tag 筛选的上新短剧横滑 + 其余短剧双列网格;其他分类三列网格
- 分类内容支持懒加载、下拉刷新与上拉分页加载
- 卡片角标文案与背景色取自接口 tag/tagColor,短剧标题统一白色
- 恢复 tab0 为沉浸式全屏视频首页及其三 inner-tab 顶导(搜索/礼物入口)
- l10n 新增原创出品、立即观看、上新、编辑精选、全N集等多语言文案
2026-10-27 19:57:42 +08:00
Zhou Weidong 76429628ec chore(merge): 合并播放器切集与双击点赞优化到 main 2026-10-26 19:31:47 +08:00
Zhou Weidong 43f3593218 chore(merge): 合并 iOS 无线数据选择框触发到 main 2026-10-26 09:35:29 +08:00
Zhou Weidong 0eca7ecc31 chore(merge): 合并 iOS 无线数据询问到 main 2026-10-25 21:23:26 +08:00
Zhou Weidong af5d8f9d80 chore(merge): 合并客户端多语言筛选到 main 2026-10-25 19:52:30 +08:00
Zhou Weidong b84a5368d6 chore(merge): 将 release/v1.0.0 同步到 main 2026-10-23 13:07:33 +08:00
Zhou Weidong 67e178c89d chore(merge): 将 develop 同步到 release/v1.0.0 2026-10-23 13:07:33 +08:00
121 changed files with 6584 additions and 2857 deletions

No files matched your search

+63 -29
View File
@@ -1,18 +1,22 @@
# FruitShorts(ReelShort)客户端
FruitShorts 是面向印尼市场的短剧 Flutter 客户端。当前版本已连接
`FruitServer` 的 `/app/**` 接口,支持沉浸播放、找剧、账号、观看记录、收藏、
下载授权、评论互动、站内通知和中英印尼三语界面。
FruitShorts 是面向印尼市场的短剧 Flutter 客户端,已连接 `FruitServer` 的
`/app/**` 接口。功能覆盖:四 tab 主页(推荐视频流 / 找剧 / 追剧 / 我的)、
沉浸式播放与全屏剧集播放器、清晰度切换、剧单与排行榜、新剧页、搜索、观看记录、
收藏短剧、评论与点赞、站内通知、钱包与商品、下载落盘与离线播放、中英印尼三语,
以及 Android / iOS 双端画中画(退到后台自动进小窗)。
## 技术栈
- Flutter 3.47.7 / Dart 3.13.5
- Flutter 3.47.7 / Dart 3.13.5(`environment.sdk: ^3.12.2`)
- Provider 状态管理与依赖注入
- dio 网络请求
- video_player 播放
- shared_preferences 与 `SharedPreferencesAsync` 本地配置
- path_provider + dart:io 下载落盘(先写 `.part`,完成后原子改名)
- flutter_localizations,支持 `en`、`zh`、`id`
- Android 系统画中画
- 画中画:Android 用 `floating` + `permission_handler`(需悬浮窗权限);
iOS 用原生 `AVPictureInPictureController` + 影子播放器(`ios/Runner/AppDelegate.swift`)
## 目录结构
@@ -22,7 +26,7 @@ lib/
config/ 地址、语言和运行时配置
data/ models、remote API、repository、controller
formatting/ 文案与日期格式化
platform/ 触觉等平台能力
platform/ 平台能力:画中画通道、设备号、触觉
theme/ 颜色与主题
widgets/ 跨页面复用组件
l10n/ 三语 ARB 与生成代码
@@ -36,20 +40,21 @@ assets/ 图标、图片和本地媒体文件
## 已接接口
以下接口均在 `lib/core/data/remote/` 中有实际调用,共 26 个不同路径、
31 个 HTTP 方法级调用。
以下接口均在 `lib/core/data/remote/` 中有实际调用,共 47 个不同路径。
| 分组 | 契约 | 接口 |
| --- | --- | --- |
| 账号 | §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` |
| 分组 | 接口 |
| --- | --- |
| 账号 | `POST /app/auth/register`、`/login`、`/refresh`、`/logout`、`/otp`;`GET /app/me`、`/app/me/devices`、`/app/me/export`;`POST /app/me/deactivate`、`/app/me/deactivate/cancel` |
| 内容 | `GET /app/home/feed`、`/app/feed`、`/app/discover/feed`、`/app/categories`、`/app/categories/{id}/dramas`、`/app/drama-categories`、`/app/dramas/page`、`/app/dramas/{id}`、`/app/tags`、`/app/search`、`/app/playlists`、`/app/playlists/{id}` |
| 播放 | `GET /app/episodes/{id}/play`、`/app/episodes/{id}/stats`;`POST /app/episodes/{id}/unlock` |
| 观看记录 | `POST/GET /app/watch/progress`、`GET /app/watch/recent`、`DELETE /app/watch/progress/{dramaId}`、`DELETE /app/watch/progress` |
| 收藏 | `POST /app/favorites/toggle`、`GET /app/favorites`、`DELETE /app/favorites/{dramaId}`、`POST /app/favorites/remove` |
| 下载 | `GET /app/downloads/policy`、`PUT /app/downloads/settings`、`POST/GET /app/downloads`、`GET /app/downloads/{id}/url`、`POST /app/downloads/{id}/progress`、`DELETE /app/downloads/{id}`、`DELETE /app/downloads` |
| 互动 | `GET/POST /app/comments`、`DELETE /app/comments/{id}`、`GET /app/comments/count`、`POST /app/likes/toggle`、`POST /app/reports` |
| 商业化 | `GET /app/wallet`、`/app/products`、`/app/orders` |
| 公告 | `GET /app/notices` |
客户端没有调用 `/app/config` 或创作者入驻接口。
客户端没有调用 `/app/config` 和创作者入驻接口。
## 运行
@@ -90,15 +95,30 @@ flutter run -d <udid> \
### Debug 运行时地址
debug 版本可在「我的 → 设置 → 服务器地址」修改后端地址,保存后重启 App 生效。
地址优先级:
debug 包在找剧页加载失败时会显示调试条,点其中的「修改服务器地址」可直接改成
当前电脑 IP,保存后立即重载,不用重新打包。地址优先级:
```text
本地运行时设置 > --dart-define(API_BASE_URL) > 平台默认地址
本地运行时设置 > --dart-define(API_BASE_URL) > AppConfig.defaultBaseUrl
```
因此不带 `--dart-define` 构建的 debug APK 也可在安装后改成当前电脑 IP。
release 版本不显示入口,也不会读取本地覆盖。
`devHostBaseUrl` 默认写死为 `http://192.168.31.243:8081`
(`lib/core/config/app_config.dart`)。debug 包启动时按
「环回 `127.0.0.1` → `devHostBaseUrl` → 公网」顺序探测可用地址;release 包不探测,
固定使用公网地址。换 Wi-Fi、路由器换网段后 `devHostBaseUrl` 会失效,此时要么传
`--dart-define`,要么改这个常量。release 包不显示地址入口,也不读取本地覆盖。
## 画中画
| 平台 | 行为 |
| --- | --- |
| Android | 首次点播放页小窗按钮时申请悬浮窗权限;授权后退出 App 自动进入系统小窗。沉浸流与独立播放页共用一份引用计数,任一处活跃都算「在播」,避免互相顶掉 |
| iOS | 原生影子播放器承载 `AVPictureInPictureController`,只有播放页处于活跃状态时退到后台才自动进小窗;停在剧单等页面退后台不会触发 |
- 小窗内切集直接换源,不走页面翻页,可连续自动播放
- iOS 从系统小窗还原时用原生过渡层盖住纹理黑帧,等首帧就绪后再淡出
- 播放页「更多」面板里有「退出自动小窗」开关(仅支持自动小窗的平台显示),关掉后
退到后台不再进入小窗
## 环境注意
@@ -156,21 +176,35 @@ flutter build apk --release --target-platform android-arm64,android-arm
- 不要直接运行 `flutter build apk --release`:默认会编译三套原生库,包体约 57MB。
- 只有需要进一步压缩单机下载体积时,才考虑 `--split-per-abi` 出分架构包(arm64 约 21MB、armv7 约 19MB),默认不用。
## 生产打包(iOS)
```bash
# 正式签名(需要 iOS Distribution 证书 + App Store 描述文件)
flutter build ipa --release
# 只有 Apple Development 证书时:出开发签名 IPA,只能装已注册设备
flutter build ipa --release --export-method development
```
产物在 `build/ios/ipa/*.ipa`。画中画依赖 `UIBackgroundModes` 里的 `audio` 与
`AVPictureInPictureController`,改动 `ios/Runner/Info.plist` 或 `AppDelegate.swift`
后要重新构建,热重载不会生效。
## 门禁
```bash
dart analyze lib test
dart analyze
flutter test
flutter build apk --debug
```
测试文件按模块放在 `test/` 下,用例名使用
当前基线:`dart analyze` 仅 1 条既存 info(`intl` 未在 `pubspec.yaml` 声明);
`flutter test` 全量 775 例通过。测试文件按模块放在 `test/` 下,用例名使用
`should_<期望>_when_<条件>`。真实后端联调测试在服务未启动时会跳过。
## 当前边界
- 下载仅管理服务端授权,不落盘、不续传、不支持离线播放。
- 没有独立搜索接口,搜索能力尚未形成完整闭环。
- 下载会落盘并支持离线播放,但不支持断点续传:中途失败会丢弃 `.part` 重下。
- 支付与金币:客户端已有钱包、商品、下单接口与页面,商店票据校验依赖服务端配置凭据。
- 站内通知没有已读/未读和红点状态。
- 支付、金币和会员权益尚未形成客户端闭环。
- Android 支持系统画中画;iOS 画中画尚未接入。
- 播放清晰度切换会保留旧画面 500ms 掩盖闪屏,切换瞬间的进度以相对位置续播。
+1
View File
@@ -1,4 +1,5 @@
/.gradle
/build/
/captures/
/local.properties
GeneratedPluginRegistrant.java
+3 -1
View File
@@ -8,7 +8,9 @@ plugins {
android {
namespace = "com.stormg.lumadrama"
compileSdk = flutter.compileSdkVersion
// permission_handler_android 14 的 AAR 元数据要求依赖方 compileSdk >= 37,
// 固定为 37(比 Flutter 默认的 36 高一档,只影响编译期 API 可见性)。
compileSdk = 37
ndkVersion = flutter.ndkVersion
compileOptions {
+3
View File
@@ -2,6 +2,9 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission
android:name="android.permission.INTERNET"/>
<!-- 画中画自动触发依赖的「显示在其他应用上层」权限(部分 ROM 用它管控 PiP) -->
<uses-permission
android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<application
android:label="FruitShorts"
android:name="${applicationName}"
@@ -284,6 +284,7 @@ class MainActivity : FlutterActivity() {
}
companion object {
private const val TAG = "FruitPip"
private const val thumbnailMaxWidth = 240
private const val thumbnailJpegQuality = 70
private const val thumbnailTimeoutMs = 1500L
+399
View File
@@ -1,6 +1,7 @@
import Flutter
import UIKit
import AVFoundation
import AVKit
private let thumbnailHTTPHeaderFieldsKey = "AVURLAssetHTTPHeaderFieldsKey"
@@ -35,6 +36,318 @@ final class RunnerFlutterViewController: FlutterViewController {
}
}
/// iOS 影子播放器:独立 AVPlayer + AVPlayerLayer 专供画中画窗口。
/// Flutter 的 video_player 走纹理渲染,没有 AVPlayerLayer,无法直接创建
/// AVPictureInPictureController;小窗的画面与声音由影子接管,退出时把
/// 影子进度回传给 Dart,由 Flutter 播放器 seek 对齐后继续。
final class PipShadowCoordinator: NSObject, AVPictureInPictureControllerDelegate {
static let shared = PipShadowCoordinator()
private var player: AVPlayer?
private var playerLayer: AVPlayerLayer?
private var controller: AVPictureInPictureController?
private var endObserver: NSObjectProtocol?
private var possibleObservation: NSKeyValueObservation?
/// 画中画还原过渡层:原生窗口级红晕渐变,在系统还原动画开始时立即盖上,
/// 避免回前台瞬间 Flutter 表面未恢复显示黑帧;视频出帧后由 Dart 通知淡出。
private var restoreOverlay: UIView?
/// 系统要求 playerLayer 位于真实的 view 层级中才会判定画中画可用,
/// 因此用 1x1 透明宿主 view 承载,而不是直接挂在 window.layer 上。
private var hostView: UIView?
/// 影子图层就绪稍晚于创建,置位后由 KVO 自动拉起画中画。
private var pendingStart = false
private var startRetryWorkItems: [DispatchWorkItem] = []
weak var channel: FlutterMethodChannel?
/// active 变化回调;停止时把影子最终进度(毫秒)一并提供。
var onPipChanged: ((Bool, Int64) -> Void)?
/// 影子在画中画里播完当前集。
var onPlaybackEnded: (() -> Void)?
static var isSupported: Bool {
AVPictureInPictureController.isPictureInPictureSupported()
}
private var keyWindow: UIWindow? {
UIApplication.shared.connectedScenes
.compactMap { $0 as? UIWindowScene }
.flatMap { $0.windows }
.first { $0.isKeyWindow }
}
/// 首次创建影子:1x1 图层挂在 keyWindow 的宿主 view 里(肉眼不可见),静音待命。
/// [autoEnter] 为 true 时退后台由系统自动拉起画中画(需影子在播,见 armAutoEnter)。
func prepare(urlString: String, positionMs: Int64, autoEnter: Bool) {
teardown()
log("prepare begin supported=\(PipShadowCoordinator.isSupported) autoEnter=\(autoEnter)")
guard Self.isSupported else { return }
guard let url = URL(string: urlString) else {
log("prepare failed bad url \(urlString)")
return
}
guard let window = keyWindow else {
log("prepare failed no key window")
return
}
let item = AVPlayerItem(url: url)
let p = AVPlayer(playerItem: item)
p.isMuted = true
p.actionAtItemEnd = .pause
let layer = AVPlayerLayer()
layer.player = p
let host = UIView(frame: CGRect(x: 0, y: 0, width: 1, height: 1))
host.isUserInteractionEnabled = false
host.backgroundColor = .clear
window.addSubview(host)
layer.frame = host.bounds
host.layer.addSublayer(layer)
hostView = host
guard let c = AVPictureInPictureController(playerLayer: layer) else {
p.pause()
log("prepare failed no pip controller")
return
}
c.canStartPictureInPictureAutomaticallyFromInline = autoEnter
c.delegate = self
player = p
playerLayer = layer
controller = c
// 静音起播让 item 完成首帧解码,isPictureInPicturePossible 才会变 true。
p.play()
possibleObservation = c.observe(
\.isPictureInPicturePossible,
options: [.new, .initial]
) { [weak self] controller, change in
let value = change.newValue ?? controller.isPictureInPicturePossible
self?.log("possible changed to \(value)")
guard let self, self.pendingStart, controller.isPictureInPicturePossible else { return }
self.pendingStart = false
// 刚翻 true 的同一 runloop 里调用会被系统静默拒绝,推到下一拍再进。
DispatchQueue.main.async {
guard self.controller === controller, controller.isPictureInPicturePossible else {
self.log("start via kvo aborted (shadow replaced)")
return
}
self.log("start via kvo")
controller.startPictureInPicture()
}
}
log("shadow ready, seeking to \(positionMs)ms")
if positionMs > 0 {
p.seek(
to: CMTime(value: positionMs, timescale: 1000),
toleranceBefore: .zero,
toleranceAfter: .zero
)
}
registerEndObserver(for: item)
activateAudioSession()
}
/// 退出 App 前(inactive)把影子对齐到当前进度并静音起播:
/// auto PiP 只在「player 正在播放 + 图层离屏」时由系统触发。
func armAutoEnter(positionMs: Int64) {
guard let player, let controller else {
log("arm failed, shadow missing")
return
}
guard controller.canStartPictureInPictureAutomaticallyFromInline else {
log("arm failed, autoEnter disabled on shadow")
return
}
log("arm auto enter at \(positionMs)ms")
if positionMs > 0 {
player.seek(
to: CMTime(value: positionMs, timescale: 1000),
toleranceBefore: CMTime(value: 800, timescale: 1000),
toleranceAfter: CMTime(value: 800, timescale: 1000)
)
}
player.play()
}
/// 回前台后取消待命:影子暂停回静音,等待下一次退后台。
func disarmAutoEnter() {
guard let player else { return }
log("disarm auto enter")
player.pause()
player.isMuted = true
}
/// 进入画中画:图层就绪则立即进入,否则 KVO/延时重试在就绪后自动进入。
/// 仅当影子从未创建成功(prepare 失败)时返回 false。
func start() -> Bool {
guard let controller else {
log("start failed, shadow not created")
return false
}
log("start requested possible=\(controller.isPictureInPicturePossible)")
pendingStart = true
if controller.isPictureInPicturePossible {
pendingStart = false
controller.startPictureInPicture()
}
scheduleStartRetries()
return true
}
/// KVO 偶发不触发或流加载较慢时兜底:就绪后再试两次。
private func scheduleStartRetries() {
startRetryWorkItems.forEach { $0.cancel() }
startRetryWorkItems.removeAll()
for delay in [1.0, 2.5] {
let item = DispatchWorkItem { [weak self] in
guard
let self,
self.pendingStart,
let controller = self.controller,
controller.isPictureInPicturePossible
else { return }
self.log("start via retry after \(delay)s")
self.pendingStart = false
controller.startPictureInPicture()
}
startRetryWorkItems.append(item)
DispatchQueue.main.asyncAfter(deadline: .now() + delay, execute: item)
}
}
/// 画中画内换集:只换 AVPlayerItem,不动 player/layer,窗口不中断。
func replaceItem(urlString: String, positionMs: Int64) {
guard let player, let url = URL(string: urlString) else { return }
let item = AVPlayerItem(url: url)
player.replaceCurrentItem(with: item)
registerEndObserver(for: item)
if positionMs > 0 {
player.seek(
to: CMTime(value: positionMs, timescale: 1000),
toleranceBefore: .zero,
toleranceAfter: .zero
)
}
}
/// 进入画中画后解除静音并起播(此时 Flutter 播放器已被暂停)。
func unmuteAndPlay() {
player?.isMuted = false
player?.play()
}
func positionMs() -> Int64 {
Int64(max(0, player?.currentTime().seconds ?? 0) * 1000)
}
func stopPip() {
controller?.stopPictureInPicture()
}
func teardown() {
startRetryWorkItems.forEach { $0.cancel() }
startRetryWorkItems.removeAll()
possibleObservation?.invalidate()
possibleObservation = nil
pendingStart = false
if let endObserver {
NotificationCenter.default.removeObserver(endObserver)
}
endObserver = nil
player?.pause()
player?.replaceCurrentItem(with: nil)
playerLayer?.removeFromSuperlayer()
playerLayer = nil
hostView?.removeFromSuperview()
hostView = nil
controller?.delegate = nil
controller = nil
player = nil
}
/// 诊断日志:NSLog 之外同步转发到 Dart,便于在 flutter run 控制台观察。
private func log(_ message: String) {
NSLog("pip: %@", message)
channel?.invokeMethod("pipDebug", arguments: message)
}
private func registerEndObserver(for item: AVPlayerItem) {
if let endObserver {
NotificationCenter.default.removeObserver(endObserver)
}
endObserver = NotificationCenter.default.addObserver(
forName: .AVPlayerItemDidPlayToEndTime,
object: item,
queue: .main
) { [weak self] _ in
self?.log("item did play to end")
self?.onPlaybackEnded?()
}
}
/// 画中画的声音走影子播放器,需要 playback 类别的音频会话保活。
private func activateAudioSession() {
do {
try AVAudioSession.sharedInstance().setCategory(.playback, mode: .moviePlayback)
try AVAudioSession.sharedInstance().setActive(true)
} catch {
// 会话激活失败只影响后台出声,不阻断画中画。
}
}
func pictureInPictureControllerWillStartPictureInPicture(
_ pictureInPictureController: AVPictureInPictureController
) {
log("will start")
pendingStart = false
onPipChanged?(true, 0)
}
func pictureInPictureControllerWillStopPictureInPicture(
_ pictureInPictureController: AVPictureInPictureController
) {
log("will stop, showing restore overlay")
showRestoreOverlay()
}
func pictureInPictureControllerDidStopPictureInPicture(
_ pictureInPictureController: AVPictureInPictureController
) {
log("did stop")
showRestoreOverlay()
onPipChanged?(false, positionMs())
}
/// 盖原生过渡层(幂等):主题红晕渐变,不依赖 Flutter 渲染。
func showRestoreOverlay() {
guard let window = keyWindow else { return }
restoreOverlay?.removeFromSuperview()
let overlay = UIView(frame: window.bounds)
overlay.autoresizingMask = [.flexibleWidth, .flexibleHeight]
let gradient = CAGradientLayer()
gradient.frame = overlay.bounds
gradient.colors = [
UIColor(red: 0.298, green: 0.086, blue: 0.102, alpha: 1).cgColor,
UIColor(red: 0.118, green: 0.043, blue: 0.047, alpha: 1).cgColor,
UIColor(red: 0.063, green: 0.063, blue: 0.071, alpha: 1).cgColor,
]
gradient.locations = [0, 0.22, 0.62]
gradient.startPoint = CGPoint(x: 0.5, y: 0)
gradient.endPoint = CGPoint(x: 0.5, y: 1)
overlay.layer.addSublayer(gradient)
window.addSubview(overlay)
restoreOverlay = overlay
}
/// 淡出并移除过渡层(视频首帧已确认后由 Dart 调用)。
func hideRestoreOverlay() {
guard let overlay = restoreOverlay else { return }
restoreOverlay = nil
UIView.animate(
withDuration: 0.25,
animations: { overlay.alpha = 0 }
) { _ in overlay.removeFromSuperview() }
}
}
@main
@objc class AppDelegate: FlutterAppDelegate, FlutterImplicitEngineDelegate {
private let wirelessDataPrompt = WirelessDataPrompt()
@@ -64,6 +377,7 @@ final class RunnerFlutterViewController: FlutterViewController {
GeneratedPluginRegistrant.register(with: engineBridge.pluginRegistry)
registerWirelessDataChannel(engineBridge)
registerDeviceIdChannel(engineBridge)
registerPipChannel(engineBridge)
let channel = FlutterMethodChannel(
name: "com.stormg.lumadrama/share",
binaryMessenger: engineBridge.applicationRegistrar.messenger()
@@ -145,6 +459,91 @@ final class RunnerFlutterViewController: FlutterViewController {
}
}
/// iOS 画中画:影子播放器通道,与 Android 共用同一 channel 名。
private func registerPipChannel(_ engineBridge: FlutterImplicitEngineBridge) {
let channel = FlutterMethodChannel(
name: "com.stormg.lumadrama/pip",
binaryMessenger: engineBridge.applicationRegistrar.messenger()
)
let pip = PipShadowCoordinator.shared
pip.channel = channel
channel.setMethodCallHandler { call, result in
switch call.method {
case "isAvailable":
result(PipShadowCoordinator.isSupported)
case "enter":
guard let args = call.arguments as? [String: Any],
let url = args["url"] as? String else {
result(false)
return
}
let positionMs = (args["positionMs"] as? NSNumber)?.int64Value ?? 0
pip.prepare(urlString: url, positionMs: positionMs, autoEnter: false)
// 等一拍让 AVPlayerLayer 完成挂载再请求进入画中画。
DispatchQueue.main.async {
result(pip.start())
}
case "prepareShadow":
guard let args = call.arguments as? [String: Any],
let url = args["url"] as? String else {
result(nil)
return
}
pip.prepare(
urlString: url,
positionMs: (args["positionMs"] as? NSNumber)?.int64Value ?? 0,
autoEnter: (args["autoEnter"] as? NSNumber)?.boolValue ?? false
)
result(nil)
case "armAutoEnter":
pip.armAutoEnter(
positionMs: (call.arguments as? [String: Any])?["positionMs"] as? Int64 ?? 0
)
result(nil)
case "showRestoreOverlay":
pip.showRestoreOverlay()
result(nil)
case "hideRestoreOverlay":
pip.hideRestoreOverlay()
result(nil)
case "disarmAutoEnter":
pip.disarmAutoEnter()
result(nil)
case "unmute":
pip.unmuteAndPlay()
result(nil)
case "replaceItem":
guard let args = call.arguments as? [String: Any],
let url = args["url"] as? String else {
result(nil)
return
}
pip.replaceItem(
urlString: url,
positionMs: (args["positionMs"] as? NSNumber)?.int64Value ?? 0
)
result(nil)
case "stop":
pip.stopPip()
result(nil)
case "teardown":
pip.teardown()
result(nil)
default:
result(FlutterMethodNotImplemented)
}
}
pip.onPipChanged = { active, positionMs in
channel.invokeMethod(
"onPipChanged",
arguments: ["active": active, "positionMs": positionMs]
)
}
pip.onPlaybackEnded = {
channel.invokeMethod("onPipPlaybackEnded", arguments: nil)
}
}
/// 设备标识:IDFV 免权限,卸载本 App 不变,避免客户端自生成的 id 每次重装都变。
/// 同通道顺带提供设备区域(ISO-2),注册时作为服务端 IP 解析失败后的兜底。
private func registerDeviceIdChannel(_ engineBridge: FlutterImplicitEngineBridge) {
+4
View File
@@ -87,6 +87,10 @@
</array>
</dict>
</dict>
<key>UIBackgroundModes</key>
<array>
<string>audio</string>
</array>
<key>UIApplicationSupportsIndirectInputEvents</key>
<true/>
<key>UILaunchStoryboardName</key>
+11 -3
View File
@@ -51,9 +51,12 @@ class AppConfig {
? _runtimeBaseUrl
: (compiledBaseUrl.isNotEmpty ? compiledBaseUrl : defaultBaseUrl);
static final String _defaultBaseUrl = _runsOnDevMachine
? lanBaseUrl
: devHostBaseUrl;
/// 生产包固定走公网地址;仅 debug 才按平台默认到环回/开发机。
static final String _defaultBaseUrl = kReleaseMode
? publicBaseUrl
: (_runsOnDevMachine
? lanBaseUrl
: devHostBaseUrl);
/// 模拟器、桌面端与开发机同机,环回地址可用;iOS 真机不满足。
/// Android 没有等价的探测方式,统一按真机处理(模拟器用
@@ -93,6 +96,11 @@ class AppConfig {
if (_runtimeBaseUrl.isEmpty) applyRuntimeBaseUrl(compiled);
return;
}
// 生产包固定公网地址,不再探测环回/开发机局域网地址,避免请求到开发机。
if (kReleaseMode) {
if (_runtimeBaseUrl.isEmpty) applyRuntimeBaseUrl(publicBaseUrl);
return;
}
final candidates = <String>[
if (_runtimeBaseUrl.isNotEmpty) _runtimeBaseUrl,
for (final candidate in _probeCandidates)
@@ -3,7 +3,8 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';
/// Native Android activity PiP; the Flutter playback session keeps the player.
/// 原生活动级画中画桥:Android 是 Activity PiP(画面即 Flutter 渲染),
/// iOS 是影子播放器接力(画面/声音来自原生 AVPlayer,退出时进度回传)。
class AndroidPictureInPicture {
AndroidPictureInPicture({MethodChannel? channel})
: _channel = channel ?? const MethodChannel('com.stormg.lumadrama/pip');
@@ -11,22 +12,147 @@ class AndroidPictureInPicture {
final MethodChannel _channel;
bool get isPlatformSupported =>
!kIsWeb && defaultTargetPlatform == TargetPlatform.android;
!kIsWeb &&
(defaultTargetPlatform == TargetPlatform.android ||
defaultTargetPlatform == TargetPlatform.iOS);
void setStateListener(ValueChanged<bool>? listener) {
_channel.setMethodCallHandler(
listener == null
? null
: (call) async {
if (call.method == 'onPipChanged') {
listener(call.arguments == true);
}
},
);
void Function(bool active, int finalPositionMs)? _pipChangedListener;
VoidCallback? _playbackEndedListener;
/// PiP 状态回调:iOS 停止时 [finalPositionMs] 为影子最终进度(毫秒)。
void setStateListener(void Function(bool active, int finalPositionMs)? listener) {
_pipChangedListener = listener;
_refreshHandler();
}
Future<bool> enter() async {
/// iOS 画中画内影子播完当前集(Android 不会触发)。
void setPlaybackEndedListener(VoidCallback? listener) {
_playbackEndedListener = listener;
_refreshHandler();
}
void _refreshHandler() {
if (_pipChangedListener == null && _playbackEndedListener == null) {
_channel.setMethodCallHandler(null);
return;
}
_channel.setMethodCallHandler((call) async {
switch (call.method) {
case 'pipDebug':
debugPrint('pip[native]: ${call.arguments}');
case 'onPipChanged':
final listener = _pipChangedListener;
if (listener == null) return;
final args = call.arguments;
if (args is Map) {
listener(
args['active'] == true,
(args['positionMs'] as num?)?.toInt() ?? 0,
);
} else {
// Android 只回传 bool。
listener(args == true, 0);
}
case 'onPipPlaybackEnded':
_playbackEndedListener?.call();
}
});
}
/// 进入画中画。Android 忽略片源参数;iOS 用 [url] 与 [positionMs]
/// 初始化影子播放器(对齐到当前进度、静音待命)。
Future<bool> enter({required String url, required int positionMs}) async {
if (!isPlatformSupported) return false;
return await _channel.invokeMethod<bool>('enter') ?? false;
return await _channel.invokeMethod<bool>('enter', {
'url': url,
'positionMs': positionMs,
}) ??
false;
}
/// 创建影子播放器但不起播(仅 iOS):
/// 自动小窗待命形态——静音暂停,退后台由 [armAutoEnter] 拉起。
Future<void> prepareShadow({
required String url,
required int positionMs,
bool autoEnter = false,
}) async {
if (defaultTargetPlatform != TargetPlatform.iOS || kIsWeb) return;
try {
await _channel.invokeMethod<void>('prepareShadow', {
'url': url,
'positionMs': positionMs,
'autoEnter': autoEnter,
});
} catch (_) {}
}
/// 退后台瞬间把影子对齐到当前进度并静音起播,触发系统自动画中画(仅 iOS)。
Future<void> armAutoEnter(int positionMs) async {
if (defaultTargetPlatform != TargetPlatform.iOS || kIsWeb) return;
try {
await _channel.invokeMethod<void>('armAutoEnter', {
'positionMs': positionMs,
});
} catch (_) {}
}
/// 回前台后影子回待命(暂停、静音)(仅 iOS)。
Future<void> disarmAutoEnter() async {
if (defaultTargetPlatform != TargetPlatform.iOS || kIsWeb) return;
try {
await _channel.invokeMethod<void>('disarmAutoEnter');
} catch (_) {}
}
/// 显示原生还原过渡层(仅 iOS;还原动画开始时原生侧也会自动盖上)。
Future<void> showRestoreOverlay() async {
if (defaultTargetPlatform != TargetPlatform.iOS || kIsWeb) return;
try {
await _channel.invokeMethod<void>('showRestoreOverlay');
} catch (_) {}
}
/// 淡出原生还原过渡层(仅 iOS;视频首帧确认后调用)。
Future<void> hideRestoreOverlay() async {
if (defaultTargetPlatform != TargetPlatform.iOS || kIsWeb) return;
try {
await _channel.invokeMethod<void>('hideRestoreOverlay');
} catch (_) {}
}
/// 解除影子静音并起播(仅 iOS 有意义,进入 PiP 后声音交给影子)。
Future<void> unmute() async {
if (defaultTargetPlatform != TargetPlatform.iOS || kIsWeb) return;
try {
await _channel.invokeMethod<void>('unmute');
} catch (_) {}
}
/// iOS 画中画内换集:影子只换播放项,窗口不中断。
Future<void> replaceItem({required String url, required int positionMs}) async {
if (defaultTargetPlatform != TargetPlatform.iOS || kIsWeb) return;
try {
await _channel.invokeMethod<void>('replaceItem', {
'url': url,
'positionMs': positionMs,
});
} catch (_) {}
}
/// 请求退出画中画(iOS;触发 onPipChanged(false) 后由 Dart 收尾)。
Future<void> stop() async {
if (defaultTargetPlatform != TargetPlatform.iOS || kIsWeb) return;
try {
await _channel.invokeMethod<void>('stop');
} catch (_) {}
}
/// 销毁影子播放器(仅 iOS)。
Future<void> teardown() async {
if (defaultTargetPlatform != TargetPlatform.iOS || kIsWeb) return;
try {
await _channel.invokeMethod<void>('teardown');
} catch (_) {}
}
}
@@ -38,6 +38,9 @@ class DeviceIdProvider {
/// Android 依次取网络运营商 / SIM 卡 / 系统语言的国家,iOS 取系统 region。
Future<String?> deviceRegion() async {
if (kIsWeb) return null;
// 只有两端原生侧实现了 region;其它平台(测试、桌面)上通道没有 handler,
// 调用会一直挂着,注册流程会卡在"转圈"。
if (!Platform.isAndroid && !Platform.isIOS) return null;
try {
final region = await _channel.invokeMethod<String>('region');
final value = region?.trim().toUpperCase() ?? '';
+1 -1
View File
@@ -11,7 +11,7 @@ part 'playback_neighbors.dart';
part 'playback_session_controls.dart';
/// 新纹理第一帧常是黑的,旧画面只盖住这一小段。
const Duration _qualityHandoffHold = Duration(milliseconds: 200);
const Duration _qualityHandoffHold = Duration(milliseconds: 500);
typedef PlayerFactory = PlayerPort Function(Episode episode);
typedef PlayerPreparation =
@@ -144,6 +144,14 @@ class WatchRecordsController extends ChangeNotifier {
return _detailCache[dramaId];
}
/// 按剧集 id 找最近观看记录,供收藏网格显示「看到第n集」与继续观看横幅。
WatchRecord? recordForDrama(String dramaId) {
for (final record in records) {
if (record.dramaId == dramaId) return record;
}
return null;
}
/// 删除单条记录,先更新 UI,失败按原位置回滚。
Future<bool> remove(String dramaId) async {
final index = _recordIndex(dramaId);
+25 -10
View File
@@ -27,13 +27,13 @@ abstract final class AppColors {
static const overlaySecondary = Color(0xFFC7C7CC);
static const overlayLabel = Color(0xFFE6E6EB);
/// 主操作、选中态、播放进度(品牌橙)。
static const blue = Color(0xFFFF6B2C);
/// 主操作、选中态、播放进度。旧品牌橙已全量映射为品牌红(2026-10 改版)。
static const blue = Color(0xFFF04E4E);
static const primary = blue;
static const actionRed = Color(0xFFFF3B30);
/// 主操作按下态。
static const bluePressed = Color(0xFFE55A1F);
static const bluePressed = Color(0xFFD64040);
/// 链接与次要高亮:统一改用中性浅灰,避免旧青色残留。
static const blueSoft = Color(0xFFB0B0B0);
@@ -47,6 +47,10 @@ abstract final class AppColors {
static const homeGiftPink = Color(0xFFFF4D8D);
static const vipGoldStart = Color(0xFFF5D9A0);
static const vipGoldEnd = Color(0xFFE8B65A);
/// 「我的」页 VIP 卡的浅香槟金(见设计稿,接近纯色)。
static const vipCardStart = Color(0xFFF6E8C6);
static const vipCardEnd = Color(0xFFEDD9A8);
static const vipBadgeSurface = Color(0x1F3D2408);
static const bronze = Color(0xFFCD7F32);
static const bronzeDeep = Color(0xFFA9713A);
@@ -75,6 +79,15 @@ abstract final class AppColors {
/// 首页/追剧/我的统一的纯黑内容背景。
static const appBackground = Color(0xFF000000);
/// 追剧页顶部的暗红光晕,向下淡入纯黑(见设计稿)。
static const followingGlow = Color(0xFF4C161A);
/// 光晕的过渡色:让暖色维持更久再压黑。
static const followingGlowMid = Color(0xFF1E0B0C);
/// 继续观看横幅剧名的暖白(见设计稿,非纯白)。
static const bannerTitleWarm = Color(0xFFF5EFE4);
/// 中性深灰卡片与控件表面。
static const contentCard = Color(0xFF16161A);
static const contentSurface = Color(0xFF1C1C1E);
@@ -96,7 +109,7 @@ abstract final class AppColors {
static const mineGradientTop = Color(0xFF3A1B0E);
static const mineGradientMiddle = Color(0xFF1A0C07);
static const mineGradientBottom = Color(0xFF000000);
static const mineGradientGlow = Color(0x33FF6B2C);
static const mineGradientGlow = Color(0x33F04E4E);
static const mineGridSurface = Color(0x99101010);
static const minePanelSurface = Color(0xFF101010);
static const mineMoreDivider = Color(0xFF1C1C1E);
@@ -111,7 +124,7 @@ abstract final class AppColors {
static const mineIconLanguage = Color(0xFF22D3EE);
static const mineIconSettings = Color(0xFFA1A1AA);
static const mineIconNotices = Color(0xFFFF8A4C);
static const recommendPlaylistGlow = Color(0x26FF6B2C);
static const recommendPlaylistGlow = Color(0x26F04E4E);
/// 次级文字与列表 chevron。
static const textPrimary = Color(0xFFFFFFFF);
@@ -133,9 +146,11 @@ abstract final class AppColors {
/// 底部导航底色。
static const bar = ink;
/// 底部导航专用:纯黑背景、选中白与未选中灰。
/// 底部导航专用:纯黑背景、选中品牌红与未选中白。
static const navBackground = Color(0xFF000000);
static const navSelected = Color(0xFFFFFFFF);
static const brandRed = Color(0xFFF04E4E);
static const brandRedPressed = Color(0xFFD64040);
static const navSelected = brandRed;
/// 卡片阴影(深色几乎不用阴影)。
static const cardShadow = Color(0x00000000);
@@ -188,8 +203,8 @@ abstract final class AppColors {
/// 封面集数胶囊。
static const badgeBeige = raised;
/// 导航未选中。
static const navUnselected = textSecondary;
/// 导航未选中(设计稿为白色线框 + 白色文字)。
static const navUnselected = Color(0xFFFFFFFF);
/// 首页内容角标。
static const badgeHot = Color(0xFFE5484D);
@@ -213,7 +228,7 @@ abstract final class AppColors {
static const bannerScrimEnd = Color(0xE6000000);
/// 票券虚线等主色描边。
static const primaryBorder = Color(0x66FF6B2C);
static const primaryBorder = Color(0x66F04E4E);
static const outlineDark = border;
static const outlineVariantDark = border;
+70 -9
View File
@@ -146,10 +146,12 @@ abstract final class AppDimens {
static const double homeActionGap = 6;
/// 推荐分区。
static const double recommendSectionGap = 12;
static const double recommendSectionTitle = 17;
static const double recommendSectionSubtitle = 11;
static const double recommendSectionMore = 12;
static const double recommendRowHeight = 252;
// 封面 122*(4/3)≈163 + 间距6 + 两行标题39 + 间距6 + 标签13 ≈ 227。
static const double recommendRowHeight = 228;
static const double recommendCardWidth = 122;
/// 首页热播榜。
@@ -169,25 +171,27 @@ abstract final class AppDimens {
/// 全部短剧筛选与追剧双列。
static const double filterChipFont = 16;
static const double filterChipHeight = 32;
static const double filterChipRadius = 16;
static const double filterChipHeight = 28;
static const double filterChipRadius = 14;
static const double filterChipHorizontalPadding = 12;
static const double filterRowGap = 6;
static const double filterItemGap = 10;
static const double allDramasHorizontal = 12;
static const double allDramasGridGap = 6;
static const double allDramasGridRowGap = 12;
static const double allDramasGridRowGap = 6;
static const double allDramasFilterToGridGap = 12;
static const double followingHeaderHeight = 52;
static const double followingTabFont = 18;
static const double followingTabGap = 24;
static const double followingEditIconSize = 20;
static const double followingEditHitSize = 40;
static const double followingAddIconSize = 28;
static const double followingAddIconSize = 20;
static const double followingAddIconStroke = 1.5;
static const double followingGridGap = 6;
static const double followingGridRowGap = 12;
static const double followingCardTextExtent = 70;
// 单行标题 16*1.3=20.8 + 间距 6+4 + 副标题行高约 18.6 ≈ 49.4,留 0.6 余量;
// 按 48 估算在副标题行高偏高的字体下会溢出 1~2px。
static const double followingCardTextExtent = 50;
static const double followingSubtitleFont = 12;
static const double followingSubtitleGap = 4;
static const double followingProgressHeight = 2;
@@ -201,6 +205,47 @@ abstract final class AppDimens {
static const double followingHistoryProgressGap = 8;
static const double followingHistoryLabelGap = 4;
static const double followingHistoryActionHeight = 28;
/// 追剧页新版头部与收藏布局。
static const double followingTitleFont = 26;
static const double followingTitleRowHeight = 42;
static const double followingTitleTopGap = 8;
static const double followingSearchIcon = 26;
static const double followingManageFont = 16;
static const double followingHeaderActionGap = 8;
static const double followingSegmentFont = 16;
static const double followingSegmentGap = 28;
static const double followingSegmentRowHeight = 42;
static const double followingSegmentIndicatorWidth = 24;
static const double followingSegmentIndicatorHeight = 3;
static const double followingSegmentIndicatorRadius = 2;
static const double followingSegmentIndicatorTopGap = 6;
static const double followingBannerHeight = 176;
static const double followingBannerRadius = 16;
static const double followingBannerEdgeGap = 16;
static const double followingBannerInnerGap = 16;
static const double followingBannerTitleFont = 22;
static const double followingBannerSubtitleFont = 13;
static const double followingBannerMetaGap = 8;
static const double followingBannerButtonHeight = 40;
static const double followingBannerButtonRadius = 20;
static const double followingBannerButtonFont = 15;
static const double followingBannerButtonIcon = 18;
static const double followingBannerButtonGap = 6;
static const double followingBannerButtonHorizontalPadding = 20;
static const double followingBannerButtonTopGap = 14;
static const double followingBannerProgressHeight = 3;
static const double followingSectionTitleFont = 16;
static const double followingSectionCountFont = 13;
static const double followingSectionTopGap = 20;
static const double followingSectionBottomGap = 12;
static const double followingCardTitleFontNew = 16;
static const double followingCardSubtitleFontNew = 13;
static const double followingBadgeFont = 11;
static const double followingBadgeRadius = 6;
static const double followingBadgeInset = 8;
static const double followingBadgePaddingH = 8;
static const double followingBadgePaddingV = 3;
static const Duration followingTabAnimationDuration = Duration(
milliseconds: 180,
);
@@ -211,8 +256,8 @@ abstract final class AppDimens {
/// 「我的」页中性视觉。
static const double mineCardRadius = 16;
static const double mineSectionTitle = 15;
static const double mineAvatar = 56;
static const double mineUserName = 20;
static const double mineAvatar = 64;
static const double mineUserName = 24;
static const double mineUserNameLineHeight = 1.15;
static const double mineUserNameUidGap = 2;
static const double mineUid = 12;
@@ -227,7 +272,23 @@ abstract final class AppDimens {
static const double mineGridDividerWidth = 1;
static const double mineSectionTitleFont = 16;
static const double mineSectionLinkFont = 12;
static const double mineSectionGap = 20;
static const double mineSectionGap = 12;
/// 「我的」页新版:快捷图标行与服务列表。
static const double mineQuickActionIcon = 28;
static const double mineQuickActionLabelFont = 14;
static const double mineQuickActionGap = 8;
static const double mineServiceRowHeight = 56;
static const double mineServiceIcon = 24;
static const double mineServiceTitleFont = 16;
static const double mineServiceValueFont = 14;
static const double mineVipBenefitFont = 14;
static const double mineVipBenefitIcon = 20;
static const double mineVipBenefitBox = 30;
static const double mineVipBenefitBoxRadius = 7;
static const double mineVipBenefitGlyph = 17;
static const double mineVipBenefitRowGap = 4;
static const double mineVipButtonHeight = 36;
static const double mineContinueCardWidth = 96;
static const double mineContinueRowHeight = 172;
static const double mineContinueTitleFont = 13;
+11 -11
View File
@@ -40,7 +40,7 @@ abstract final class AppTheme {
/// 全局深色主题。
static ThemeData dark() {
const scheme = ColorScheme.dark(
primary: AppColors.blue,
primary: AppColors.brandRed,
onPrimary: AppColors.onPrimary,
secondary: AppColors.secondary,
onSecondary: AppColors.ink,
@@ -54,7 +54,7 @@ abstract final class AppTheme {
outline: AppColors.border,
outlineVariant: AppColors.border,
surfaceTint: AppColors.transparent,
inversePrimary: AppColors.bluePressed,
inversePrimary: AppColors.brandRedPressed,
error: AppColors.error,
onError: AppColors.onPrimary,
);
@@ -66,16 +66,16 @@ abstract final class AppTheme {
canvasColor: AppColors.ink,
fontFamily: 'PlusJakartaSans',
progressIndicatorTheme: const ProgressIndicatorThemeData(
color: AppColors.blue,
color: AppColors.brandRed,
),
sliderTheme: const SliderThemeData(
activeTrackColor: AppColors.blue,
activeTrackColor: AppColors.brandRed,
inactiveTrackColor: AppColors.border,
thumbColor: AppColors.onPrimary,
),
tabBarTheme: const TabBarThemeData(
labelColor: AppColors.blue,
indicatorColor: AppColors.blue,
labelColor: AppColors.brandRed,
indicatorColor: AppColors.brandRed,
unselectedLabelColor: AppColors.muted,
),
textButtonTheme: TextButtonThemeData(
@@ -138,12 +138,12 @@ abstract final class AppTheme {
),
focusedBorder: OutlineInputBorder(
borderRadius: _inputRadius,
borderSide: const BorderSide(color: AppColors.blue),
borderSide: const BorderSide(color: AppColors.brandRed),
),
),
chipTheme: ChipThemeData(
backgroundColor: AppColors.raised,
selectedColor: AppColors.blue.withValues(alpha: 0.22),
selectedColor: AppColors.brandRed.withValues(alpha: 0.22),
labelStyle: const TextStyle(color: AppColors.onSurface),
secondaryLabelStyle: const TextStyle(color: AppColors.muted),
side: const BorderSide(color: AppColors.border),
@@ -216,7 +216,7 @@ abstract final class AppTheme {
),
trackColor: WidgetStateProperty.resolveWith(
(states) =>
states.contains(WidgetState.selected) ? AppColors.blue : null,
states.contains(WidgetState.selected) ? AppColors.brandRed : null,
),
),
snackBarTheme: const SnackBarThemeData(
@@ -273,8 +273,8 @@ abstract final class AppTheme {
if (states.contains(WidgetState.pressed) ||
states.contains(WidgetState.hovered) ||
states.contains(WidgetState.focused)) {
return AppColors.bluePressed;
return AppColors.brandRedPressed;
}
return AppColors.blue;
return AppColors.brandRed;
}
}
+121
View File
@@ -0,0 +1,121 @@
// Author: fruit.com.cn
import 'package:flutter/material.dart';
import '../theme/app_colors.dart';
import '../theme/app_dimens.dart';
/// 主题红晕渐变容器:弹框(居中)与底部弹层(半屏)共用的外壳。
/// 纯黑弹框统一升级为「顶部红光 → 近黑」的家族渐变。
class AppGlowPanel extends StatelessWidget {
const AppGlowPanel({
super.key,
required this.child,
this.borderRadius = const BorderRadius.all(Radius.circular(20)),
this.border = true,
});
final Widget child;
final BorderRadius borderRadius;
final bool border;
static const _gradient = LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [
AppColors.followingGlow,
AppColors.followingGlowMid,
Color(0xFF101012),
],
stops: [0, 0.22, 0.62],
);
@override
Widget build(BuildContext context) {
return DecoratedBox(
decoration: BoxDecoration(
gradient: _gradient,
borderRadius: borderRadius,
border: border
? Border.all(color: AppColors.contentBorder)
: null,
),
child: child,
);
}
}
/// 主题渐变确认弹框:替代 AlertDialog 的家族化外壳。
/// 按钮沿用项目惯例:纯文字 TextButton,主操作品牌红。
class AppGlowDialog extends StatelessWidget {
const AppGlowDialog({
super.key,
this.title,
this.content,
this.contentChild,
this.actions,
this.contentTextStyle,
});
final String? title;
final String? content;
/// 富内容(表单/滚动区),与 [content] 二选一。
final Widget? contentChild;
final List<Widget>? actions;
final TextStyle? contentTextStyle;
@override
Widget build(BuildContext context) {
final bodyStyle = contentTextStyle ??
TextStyle(
color: AppColors.muted,
fontSize: AppDimens.body,
fontWeight: FontWeight.w400,
);
return Dialog(
backgroundColor: AppColors.transparent,
elevation: 0,
child: AppGlowPanel(
child: Padding(
padding: const EdgeInsets.fromLTRB(22, 22, 22, 10),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
if (title != null) ...[
Text(
title!,
style: TextStyle(
color: AppColors.onSurface,
fontSize: AppDimens.sectionTitle,
fontWeight: FontWeight.w400,
),
),
const SizedBox(height: 14),
],
if (content != null)
Text(content!, style: bodyStyle)
else if (contentChild != null)
// 必须给富内容一个有界高度,否则内部 SingleChildScrollView 拿到无界
// 约束会直接撑高整块内容(长文本小屏下溢出且无法滚动)。
Flexible(child: contentChild!),
if (actions != null && actions!.isNotEmpty) ...[
const SizedBox(height: 18),
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
for (var i = 0; i < actions!.length; i++) ...[
if (i > 0) const SizedBox(width: 4),
actions![i],
],
],
),
],
],
),
),
),
);
}
}
+6 -14
View File
@@ -7,18 +7,12 @@ import 'app_bottom_nav.dart';
/// 客户端根导航的固定顺序。
enum AppRootTab {
home(
assetPath: 'assets/icon/film_reel.png',
selectedAssetPath: 'assets/icon/film_reel_filled.png',
),
home(),
recommend(),
following(),
mine();
const AppRootTab({this.assetPath, this.selectedAssetPath});
final String? assetPath;
final String? selectedAssetPath;
const AppRootTab();
}
extension AppRootTabUi on AppRootTab {
@@ -30,15 +24,15 @@ extension AppRootTabUi on AppRootTab {
};
IconData get icon => switch (this) {
AppRootTab.home => Icons.theaters_outlined,
AppRootTab.recommend => Icons.smart_display_outlined,
AppRootTab.home => Icons.home_outlined,
AppRootTab.recommend => Icons.celebration_outlined,
AppRootTab.following => Icons.bookmark_border_rounded,
AppRootTab.mine => Icons.person_outline_rounded,
};
IconData get selectedIcon => switch (this) {
AppRootTab.home => Icons.theaters,
AppRootTab.recommend => Icons.smart_display_rounded,
AppRootTab.home => Icons.home_rounded,
AppRootTab.recommend => Icons.celebration_rounded,
AppRootTab.following => Icons.bookmark_rounded,
AppRootTab.mine => Icons.person_rounded,
};
@@ -75,8 +69,6 @@ class AppRootBottomNav extends StatelessWidget {
tabKey: tab.tabKey,
icon: tab.icon,
selectedIcon: tab.selectedIcon,
assetPath: tab.assetPath,
selectedAssetPath: tab.selectedAssetPath,
label: tab.label(l10n),
selected: tab == selected,
onTap: () => onSelected(tab),
+7 -5
View File
@@ -5,6 +5,7 @@ import '../../l10n/app_localizations.dart';
import '../../pages/auth/auth_view.dart';
import '../data/services/auth_controller.dart';
import '../theme/app_colors.dart';
import 'app_glow_panel.dart';
/// 打开登录 / 注册页(沿用现有 Navigator 风格,不引路由库)
Future<void> openAuthPage(BuildContext context, {bool signUpMode = false}) {
@@ -23,11 +24,11 @@ Future<bool> ensureSignedIn(BuildContext context) async {
final l10n = AppLocalizations.of(context)!;
final go = await showModalBottomSheet<bool>(
context: context,
backgroundColor: AppColors.card,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.vertical(top: Radius.circular(18)),
),
builder: (sheetContext) => SafeArea(
backgroundColor: AppColors.transparent,
builder: (sheetContext) => AppGlowPanel(
borderRadius: const BorderRadius.vertical(top: Radius.circular(18)),
border: false,
child: SafeArea(
child: Padding(
padding: const EdgeInsets.fromLTRB(20, 18, 20, 20),
child: Column(
@@ -71,6 +72,7 @@ Future<bool> ensureSignedIn(BuildContext context) async {
],
),
),
),
),
);
@@ -6,6 +6,7 @@ import 'package:flutter/material.dart';
import '../config/app_config.dart';
import '../config/server_endpoint.dart';
import '../theme/app_colors.dart';
import 'app_glow_panel.dart';
const String _title = '设置服务地址';
const String _save = '保存';
@@ -72,9 +73,9 @@ class _CatalogEndpointDialogState extends State<_CatalogEndpointDialog> {
@override
Widget build(BuildContext context) {
return AlertDialog(
title: const Text(_title),
content: SingleChildScrollView(
return AppGlowDialog(
title: _title,
contentChild: SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
+13 -2
View File
@@ -3,7 +3,6 @@
import 'package:flutter/material.dart';
import '../theme/app_colors.dart';
import '../theme/app_theme.dart';
import 'subpage_header.dart';
/// 二级页面通用骨架:返回栏 + 标题/副标题 + 可滚动内容,无底部导航。
@@ -29,7 +28,19 @@ class PlainPageScaffold extends StatelessWidget {
key: pageKey,
backgroundColor: AppColors.ink,
body: DecoratedBox(
decoration: const BoxDecoration(gradient: AppTheme.pageGradient),
// 与首页各 tab 同族:纯黑底 + 顶部暗红光晕。
decoration: const BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [
AppColors.followingGlow,
AppColors.followingGlowMid,
AppColors.appBackground,
],
stops: [0, 0.14, 0.3],
),
),
child: SafeArea(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
+7 -3
View File
@@ -74,9 +74,13 @@ class RemoteImage extends StatelessWidget {
: null);
final cacheWidth =
decodeWidth ?? resolveImageDecodePixels(layoutWidth, pixelRatio);
final cacheHeight =
decodeHeight ??
(inferredHeight == null
// cover/contain 本身会保持宽高比,此时若同时强制 cacheWidth 和
// cacheHeight,解码会把竖版图强行拉成横版像素。只在显式指定了
// decodeHeight、或 fit 不保持宽高比时才限定解码高度。
final keepsAspectRatio =
fit == BoxFit.cover || fit == BoxFit.contain;
final cacheHeight = decodeHeight ??
(keepsAspectRatio || inferredHeight == null
? null
: resolveImageDecodePixels(inferredHeight, pixelRatio));
return Image.network(
+2 -2
View File
@@ -8,7 +8,7 @@ const double _height = 52;
const double _heightWithSubtitle = 64;
const double _horizontal = 14;
const double _backSize = 40;
const double _backGap = 12;
const double _backGap = 6;
const double _titleFontSize = 18;
const double _subtitleFontSize = 12;
const double _actionGap = 8;
@@ -163,7 +163,7 @@ class AppSubpageHeader extends StatelessWidget {
style: TextStyle(
color: foreground,
fontSize: _titleFontSize,
fontWeight: FontWeight.w800,
fontWeight: FontWeight.w400,
),
),
if (subtitle != null) ...[
+73 -4
View File
@@ -20,7 +20,6 @@
"featured": "Featured",
"recommended": "Recommended",
"fruitShortsBrand": "FruitShorts",
"authLandingSubtitle": "Sign in to sync progress, favorites and coins",
"comingSoon": "Coming soon",
"authLegal": "By continuing, you agree to the Terms of Service and Privacy Policy.",
"authLegalLead": "By continuing, you agree to the",
@@ -55,12 +54,24 @@
"viewers": {"type": "String"}
}
},
"watchFullSeries": "Watch full series · {episodes} eps",
"watchFullSeries": "Watch full series {episodes} eps",
"@watchFullSeries": {
"placeholders": {
"episodes": {"type": "String"}
}
},
"feedEpisodePrefix": "EP{episode}",
"@feedEpisodePrefix": {
"placeholders": {
"episode": {"type": "int"}
}
},
"feedWatchingCount": "{count} watching",
"@feedWatchingCount": {
"placeholders": {
"count": {"type": "String"}
}
},
"feedTabAnime": "Anime",
"feedTabReal": "Live-action",
"feedTabForYou": "For you",
@@ -263,8 +274,21 @@
"shareFailed": "Could not open the share sheet.",
"nowPlaying": "Playing now",
"pictureInPicture": "Picture in picture",
"autoEnterPip": "Auto mini player on exit",
"pipUnavailable": "Picture in picture is unavailable on this device",
"originalTag": "Original",
"originalProduction": "Original",
"watchNowAction": "Watch Now",
"newArrivalBadge": "NEW",
"editorPick": "Editor's Pick",
"totalEpisodesShort": "{count} eps",
"@totalEpisodesShort": {
"placeholders": {
"count": {
"type": "int"
}
}
},
"dramaTag": "Short drama",
"episodeLabel": "Episode {number}",
"@episodeLabel": {
@@ -418,6 +442,7 @@
"restoreDefault": "Restore default",
"invalidServerAddress": "Enter a valid http(s) server address.",
"signOut": "Sign Out",
"signOutConfirm": "Sign out of your current account?",
"mockUserName": "Vicky sheng",
"mockUserId": "ID: M1CZWVYE",
"mockNotice": "Sample data only.",
@@ -763,8 +788,14 @@
"offlineDownloads": "Offline downloads",
"watchPreferences": "Watch preferences",
"contactSupport": "Contact support",
"vipBrandName": "Netshort VIP",
"mineVipSubtitle": "Enjoy exclusive benefits",
"vipBrandName": "FruitShorts VIP",
"vipOpenNow": "Get VIP",
"vipBenefitFree": "Free full access",
"vipBenefitNoAds": "Ad-free viewing",
"vipBenefitHd": "1080P HD",
"vipBenefitFastCache": "Fast downloads",
"moreServices": "More",
"mineVipSubtitle": "Unlock excitement, binge freely",
"favoriteEpisodeProgress": "Episode {episode} / {total} total",
"@favoriteEpisodeProgress": {
"placeholders": {
@@ -772,6 +803,44 @@
"total": { "type": "int" }
}
},
"myFavorites": "My Favorites",
"manage": "Manage",
"continueWatching": "Continue Watching",
"continueWatchingSubtitle": "Episode {episode} of {total}",
"@continueWatchingSubtitle": {
"placeholders": {
"episode": { "type": "int" },
"total": { "type": "int" }
}
},
"favoriteDramas": "Favorites",
"totalDramasCount": "{count} titles",
"@totalDramasCount": {
"placeholders": {
"count": { "type": "int" }
}
},
"watchedEpisodeTotal": "EP {episode} / {total}",
"@watchedEpisodeTotal": {
"placeholders": {
"episode": { "type": "int" },
"total": { "type": "int" }
}
},
"hasUpdateBadge": "UPDATED",
"updatedToEpisode": "Updated to EP {episode}",
"@updatedToEpisode": {
"placeholders": {
"episode": { "type": "int" }
}
},
"finishedAllEpisodes": "{total} eps · Completed",
"@finishedAllEpisodes": {
"placeholders": {
"total": { "type": "int" }
}
},
"noFavoritesYet": "No favorites yet",
"watchedToEpisode": "Watched to Episode {episode}",
"@watchedToEpisode": { "placeholders": { "episode": { "type": "int" } } },
"homeWatchAll": "Watch all",
+78 -4
View File
@@ -20,7 +20,6 @@
"featured": "Unggulan",
"recommended": "Rekomendasi",
"fruitShortsBrand": "FruitShorts",
"authLandingSubtitle": "Masuk untuk menyinkronkan progres, favorit, dan koin",
"comingSoon": "Segera hadir",
"authLegal": "Dengan melanjutkan, Anda menyetujui Ketentuan Layanan dan Kebijakan Privasi.",
"authLegalLead": "Dengan melanjutkan, Anda menyetujui",
@@ -49,7 +48,24 @@
"hotBadge": "Hits",
"filterAll": "Semua",
"seriesMeta": "Serial · {episodes} eps | {viewers} menonton",
"watchFullSeries": "Tonton serial lengkap · {episodes} eps",
"watchFullSeries": "Tonton serial lengkap {episodes} eps",
"@watchFullSeries": {
"placeholders": {
"episodes": {"type": "String"}
}
},
"feedEpisodePrefix": "EP{episode}",
"@feedEpisodePrefix": {
"placeholders": {
"episode": {"type": "int"}
}
},
"feedWatchingCount": "{count} menonton",
"@feedWatchingCount": {
"placeholders": {
"count": {"type": "String"}
}
},
"feedTabAnime": "Anime",
"feedTabReal": "Live-action",
"feedTabForYou": "Untukmu",
@@ -237,8 +253,21 @@
"shareFailed": "Tidak bisa membuka menu berbagi.",
"nowPlaying": "Sedang diputar",
"pictureInPicture": "Gambar dalam gambar",
"autoEnterPip": "Mini player otomatis saat keluar",
"pipUnavailable": "Gambar dalam gambar tidak tersedia di perangkat ini",
"originalTag": "Original",
"originalProduction": "Original",
"watchNowAction": "Tonton Sekarang",
"newArrivalBadge": "BARU",
"editorPick": "Pilihan Editor",
"totalEpisodesShort": "{count} eps",
"@totalEpisodesShort": {
"placeholders": {
"count": {
"type": "int"
}
}
},
"dramaTag": "Drama pendek",
"episodeLabel": "Episode {number}",
"@episodeLabel": {
@@ -392,6 +421,7 @@
"restoreDefault": "Pulihkan default",
"invalidServerAddress": "Masukkan alamat server http(s) yang valid.",
"signOut": "Keluar",
"signOutConfirm": "Keluar dari akun saat ini?",
"mockUserName": "Vicky sheng",
"mockUserId": "ID: M1CZWVYE",
"mockNotice": "Hanya data contoh.",
@@ -720,8 +750,14 @@
"offlineDownloads": "Unduhan offline",
"watchPreferences": "Preferensi tontonan",
"contactSupport": "Hubungi dukungan",
"vipBrandName": "Netshort VIP",
"mineVipSubtitle": "Nikmati manfaat eksklusif",
"vipBrandName": "FruitShorts VIP",
"vipOpenNow": "Buka VIP",
"vipBenefitFree": "Nonton semua gratis",
"vipBenefitNoAds": "Bebas iklan",
"vipBenefitHd": "HD 1080P",
"vipBenefitFastCache": "Unduhan cepat",
"moreServices": "Lainnya",
"mineVipSubtitle": "Buka keseruan, tonton sepuasnya",
"favoriteEpisodeProgress": "Episode {episode} / total {total}",
"@favoriteEpisodeProgress": {
"placeholders": {
@@ -729,6 +765,44 @@
"total": { "type": "int" }
}
},
"myFavorites": "Favorit Saya",
"manage": "Kelola",
"continueWatching": "Lanjutkan",
"continueWatchingSubtitle": "Episode {episode} dari {total}",
"@continueWatchingSubtitle": {
"placeholders": {
"episode": { "type": "int" },
"total": { "type": "int" }
}
},
"favoriteDramas": "Koleksi",
"totalDramasCount": "{count} judul",
"@totalDramasCount": {
"placeholders": {
"count": { "type": "int" }
}
},
"watchedEpisodeTotal": "EP {episode} / {total}",
"@watchedEpisodeTotal": {
"placeholders": {
"episode": { "type": "int" },
"total": { "type": "int" }
}
},
"hasUpdateBadge": "UPDATE",
"updatedToEpisode": "Diperbarui ke EP {episode}",
"@updatedToEpisode": {
"placeholders": {
"episode": { "type": "int" }
}
},
"finishedAllEpisodes": "{total} eps · Selesai",
"@finishedAllEpisodes": {
"placeholders": {
"total": { "type": "int" }
}
},
"noFavoritesYet": "Belum ada favorit",
"watchedToEpisode": "Ditonton hingga Episode {episode}",
"@watchedToEpisode": { "placeholders": { "episode": { "type": "int" } } },
"homeWatchAll": "Tonton semua",
+148 -10
View File
@@ -220,12 +220,6 @@ abstract class AppLocalizations {
/// **'FruitShorts'**
String get fruitShortsBrand;
/// No description provided for @authLandingSubtitle.
///
/// In en, this message translates to:
/// **'Sign in to sync progress, favorites and coins'**
String get authLandingSubtitle;
/// No description provided for @comingSoon.
///
/// In en, this message translates to:
@@ -397,9 +391,21 @@ abstract class AppLocalizations {
/// No description provided for @watchFullSeries.
///
/// In en, this message translates to:
/// **'Watch full series · {episodes} eps'**
/// **'Watch full series {episodes} eps'**
String watchFullSeries(String episodes);
/// No description provided for @feedEpisodePrefix.
///
/// In en, this message translates to:
/// **'EP{episode}'**
String feedEpisodePrefix(int episode);
/// No description provided for @feedWatchingCount.
///
/// In en, this message translates to:
/// **'{count} watching'**
String feedWatchingCount(String count);
/// No description provided for @feedTabAnime.
///
/// In en, this message translates to:
@@ -1186,6 +1192,12 @@ abstract class AppLocalizations {
/// **'Picture in picture'**
String get pictureInPicture;
/// No description provided for @autoEnterPip.
///
/// In en, this message translates to:
/// **'Auto mini player on exit'**
String get autoEnterPip;
/// No description provided for @pipUnavailable.
///
/// In en, this message translates to:
@@ -1198,6 +1210,36 @@ abstract class AppLocalizations {
/// **'Original'**
String get originalTag;
/// No description provided for @originalProduction.
///
/// In en, this message translates to:
/// **'Original'**
String get originalProduction;
/// No description provided for @watchNowAction.
///
/// In en, this message translates to:
/// **'Watch Now'**
String get watchNowAction;
/// No description provided for @newArrivalBadge.
///
/// In en, this message translates to:
/// **'NEW'**
String get newArrivalBadge;
/// No description provided for @editorPick.
///
/// In en, this message translates to:
/// **'Editor\'s Pick'**
String get editorPick;
/// No description provided for @totalEpisodesShort.
///
/// In en, this message translates to:
/// **'{count} eps'**
String totalEpisodesShort(int count);
/// No description provided for @dramaTag.
///
/// In en, this message translates to:
@@ -1786,6 +1828,12 @@ abstract class AppLocalizations {
/// **'Sign Out'**
String get signOut;
/// No description provided for @signOutConfirm.
///
/// In en, this message translates to:
/// **'Sign out of your current account?'**
String get signOutConfirm;
/// No description provided for @mockUserName.
///
/// In en, this message translates to:
@@ -2083,7 +2131,7 @@ abstract class AppLocalizations {
/// No description provided for @myFavorites.
///
/// In en, this message translates to:
/// **'My favorites'**
/// **'My Favorites'**
String get myFavorites;
/// No description provided for @noFavorites.
@@ -3385,13 +3433,49 @@ abstract class AppLocalizations {
/// No description provided for @vipBrandName.
///
/// In en, this message translates to:
/// **'Netshort VIP'**
/// **'FruitShorts VIP'**
String get vipBrandName;
/// No description provided for @vipOpenNow.
///
/// In en, this message translates to:
/// **'Get VIP'**
String get vipOpenNow;
/// No description provided for @vipBenefitFree.
///
/// In en, this message translates to:
/// **'Free full access'**
String get vipBenefitFree;
/// No description provided for @vipBenefitNoAds.
///
/// In en, this message translates to:
/// **'Ad-free viewing'**
String get vipBenefitNoAds;
/// No description provided for @vipBenefitHd.
///
/// In en, this message translates to:
/// **'1080P HD'**
String get vipBenefitHd;
/// No description provided for @vipBenefitFastCache.
///
/// In en, this message translates to:
/// **'Fast downloads'**
String get vipBenefitFastCache;
/// No description provided for @moreServices.
///
/// In en, this message translates to:
/// **'More'**
String get moreServices;
/// No description provided for @mineVipSubtitle.
///
/// In en, this message translates to:
/// **'Enjoy exclusive benefits'**
/// **'Unlock excitement, binge freely'**
String get mineVipSubtitle;
/// No description provided for @favoriteEpisodeProgress.
@@ -3400,6 +3484,60 @@ abstract class AppLocalizations {
/// **'Episode {episode} / {total} total'**
String favoriteEpisodeProgress(int episode, int total);
/// No description provided for @manage.
///
/// In en, this message translates to:
/// **'Manage'**
String get manage;
/// No description provided for @continueWatchingSubtitle.
///
/// In en, this message translates to:
/// **'Episode {episode} of {total}'**
String continueWatchingSubtitle(int episode, int total);
/// No description provided for @favoriteDramas.
///
/// In en, this message translates to:
/// **'Favorites'**
String get favoriteDramas;
/// No description provided for @totalDramasCount.
///
/// In en, this message translates to:
/// **'{count} titles'**
String totalDramasCount(int count);
/// No description provided for @watchedEpisodeTotal.
///
/// In en, this message translates to:
/// **'EP {episode} / {total}'**
String watchedEpisodeTotal(int episode, int total);
/// No description provided for @hasUpdateBadge.
///
/// In en, this message translates to:
/// **'UPDATED'**
String get hasUpdateBadge;
/// No description provided for @updatedToEpisode.
///
/// In en, this message translates to:
/// **'Updated to EP {episode}'**
String updatedToEpisode(int episode);
/// No description provided for @finishedAllEpisodes.
///
/// In en, this message translates to:
/// **'{total} eps · Completed'**
String finishedAllEpisodes(int total);
/// No description provided for @noFavoritesYet.
///
/// In en, this message translates to:
/// **'No favorites yet'**
String get noFavoritesYet;
/// No description provided for @watchedToEpisode.
///
/// In en, this message translates to:
+92 -8
View File
@@ -69,10 +69,6 @@ class AppLocalizationsEn extends AppLocalizations {
@override
String get fruitShortsBrand => 'FruitShorts';
@override
String get authLandingSubtitle =>
'Sign in to sync progress, favorites and coins';
@override
String get comingSoon => 'Coming soon';
@@ -162,7 +158,17 @@ class AppLocalizationsEn extends AppLocalizations {
@override
String watchFullSeries(String episodes) {
return 'Watch full series · $episodes eps';
return 'Watch full series $episodes eps';
}
@override
String feedEpisodePrefix(int episode) {
return 'EP$episode';
}
@override
String feedWatchingCount(String count) {
return '$count watching';
}
@override
@@ -587,6 +593,9 @@ class AppLocalizationsEn extends AppLocalizations {
@override
String get pictureInPicture => 'Picture in picture';
@override
String get autoEnterPip => 'Auto mini player on exit';
@override
String get pipUnavailable =>
'Picture in picture is unavailable on this device';
@@ -594,6 +603,23 @@ class AppLocalizationsEn extends AppLocalizations {
@override
String get originalTag => 'Original';
@override
String get originalProduction => 'Original';
@override
String get watchNowAction => 'Watch Now';
@override
String get newArrivalBadge => 'NEW';
@override
String get editorPick => 'Editor\'s Pick';
@override
String totalEpisodesShort(int count) {
return '$count eps';
}
@override
String get dramaTag => 'Short drama';
@@ -906,6 +932,9 @@ class AppLocalizationsEn extends AppLocalizations {
@override
String get signOut => 'Sign Out';
@override
String get signOutConfirm => 'Sign out of your current account?';
@override
String get mockUserName => 'Vicky sheng';
@@ -1060,7 +1089,7 @@ class AppLocalizationsEn extends AppLocalizations {
'Could not update favorites. Please retry.';
@override
String get myFavorites => 'My favorites';
String get myFavorites => 'My Favorites';
@override
String get noFavorites => 'No favorites yet.';
@@ -1763,16 +1792,71 @@ class AppLocalizationsEn extends AppLocalizations {
String get contactSupport => 'Contact support';
@override
String get vipBrandName => 'Netshort VIP';
String get vipBrandName => 'FruitShorts VIP';
@override
String get mineVipSubtitle => 'Enjoy exclusive benefits';
String get vipOpenNow => 'Get VIP';
@override
String get vipBenefitFree => 'Free full access';
@override
String get vipBenefitNoAds => 'Ad-free viewing';
@override
String get vipBenefitHd => '1080P HD';
@override
String get vipBenefitFastCache => 'Fast downloads';
@override
String get moreServices => 'More';
@override
String get mineVipSubtitle => 'Unlock excitement, binge freely';
@override
String favoriteEpisodeProgress(int episode, int total) {
return 'Episode $episode / $total total';
}
@override
String get manage => 'Manage';
@override
String continueWatchingSubtitle(int episode, int total) {
return 'Episode $episode of $total';
}
@override
String get favoriteDramas => 'Favorites';
@override
String totalDramasCount(int count) {
return '$count titles';
}
@override
String watchedEpisodeTotal(int episode, int total) {
return 'EP $episode / $total';
}
@override
String get hasUpdateBadge => 'UPDATED';
@override
String updatedToEpisode(int episode) {
return 'Updated to EP $episode';
}
@override
String finishedAllEpisodes(int total) {
return '$total eps · Completed';
}
@override
String get noFavoritesYet => 'No favorites yet';
@override
String watchedToEpisode(int episode) {
return 'Watched to Episode $episode';
+93 -9
View File
@@ -69,10 +69,6 @@ class AppLocalizationsId extends AppLocalizations {
@override
String get fruitShortsBrand => 'FruitShorts';
@override
String get authLandingSubtitle =>
'Masuk untuk menyinkronkan progres, favorit, dan koin';
@override
String get comingSoon => 'Segera hadir';
@@ -162,7 +158,17 @@ class AppLocalizationsId extends AppLocalizations {
@override
String watchFullSeries(String episodes) {
return 'Tonton serial lengkap · $episodes eps';
return 'Tonton serial lengkap $episodes eps';
}
@override
String feedEpisodePrefix(int episode) {
return 'EP$episode';
}
@override
String feedWatchingCount(String count) {
return '$count menonton';
}
@override
@@ -289,7 +295,7 @@ class AppLocalizationsId extends AppLocalizations {
String get localDemoProfile => 'Profil demo lokal';
@override
String get continueWatching => 'Lanjut Tonton';
String get continueWatching => 'Lanjutkan';
@override
String episodeRemaining(int episode, int minutes) {
@@ -588,6 +594,9 @@ class AppLocalizationsId extends AppLocalizations {
@override
String get pictureInPicture => 'Gambar dalam gambar';
@override
String get autoEnterPip => 'Mini player otomatis saat keluar';
@override
String get pipUnavailable =>
'Gambar dalam gambar tidak tersedia di perangkat ini';
@@ -595,6 +604,23 @@ class AppLocalizationsId extends AppLocalizations {
@override
String get originalTag => 'Original';
@override
String get originalProduction => 'Original';
@override
String get watchNowAction => 'Tonton Sekarang';
@override
String get newArrivalBadge => 'BARU';
@override
String get editorPick => 'Pilihan Editor';
@override
String totalEpisodesShort(int count) {
return '$count eps';
}
@override
String get dramaTag => 'Drama pendek';
@@ -910,6 +936,9 @@ class AppLocalizationsId extends AppLocalizations {
@override
String get signOut => 'Keluar';
@override
String get signOutConfirm => 'Keluar dari akun saat ini?';
@override
String get mockUserName => 'Vicky sheng';
@@ -1062,7 +1091,7 @@ class AppLocalizationsId extends AppLocalizations {
String get favoriteToggleFailed => 'Gagal memperbarui favorit. Coba lagi.';
@override
String get myFavorites => 'Favorit saya';
String get myFavorites => 'Favorit Saya';
@override
String get noFavorites => 'Belum ada favorit.';
@@ -1765,16 +1794,71 @@ class AppLocalizationsId extends AppLocalizations {
String get contactSupport => 'Hubungi dukungan';
@override
String get vipBrandName => 'Netshort VIP';
String get vipBrandName => 'FruitShorts VIP';
@override
String get mineVipSubtitle => 'Nikmati manfaat eksklusif';
String get vipOpenNow => 'Buka VIP';
@override
String get vipBenefitFree => 'Nonton semua gratis';
@override
String get vipBenefitNoAds => 'Bebas iklan';
@override
String get vipBenefitHd => 'HD 1080P';
@override
String get vipBenefitFastCache => 'Unduhan cepat';
@override
String get moreServices => 'Lainnya';
@override
String get mineVipSubtitle => 'Buka keseruan, tonton sepuasnya';
@override
String favoriteEpisodeProgress(int episode, int total) {
return 'Episode $episode / total $total';
}
@override
String get manage => 'Kelola';
@override
String continueWatchingSubtitle(int episode, int total) {
return 'Episode $episode dari $total';
}
@override
String get favoriteDramas => 'Koleksi';
@override
String totalDramasCount(int count) {
return '$count judul';
}
@override
String watchedEpisodeTotal(int episode, int total) {
return 'EP $episode / $total';
}
@override
String get hasUpdateBadge => 'UPDATE';
@override
String updatedToEpisode(int episode) {
return 'Diperbarui ke EP $episode';
}
@override
String finishedAllEpisodes(int total) {
return '$total eps · Selesai';
}
@override
String get noFavoritesYet => 'Belum ada favorit';
@override
String watchedToEpisode(int episode) {
return 'Ditonton hingga Episode $episode';
+92 -7
View File
@@ -66,10 +66,7 @@ class AppLocalizationsZh extends AppLocalizations {
String get recommended => '推荐';
@override
String get fruitShortsBrand => '水果短剧';
@override
String get authLandingSubtitle => '登录后同步进度、收藏与金币权益';
String get fruitShortsBrand => 'FruitShorts';
@override
String get comingSoon => '即将上线';
@@ -159,7 +156,17 @@ class AppLocalizationsZh extends AppLocalizations {
@override
String watchFullSeries(String episodes) {
return '观看完整剧集 · 全$episodes集';
return '观看完整剧集 全$episodes集';
}
@override
String feedEpisodePrefix(int episode) {
return '第$episode集';
}
@override
String feedWatchingCount(String count) {
return '共$count人在看';
}
@override
@@ -581,12 +588,32 @@ class AppLocalizationsZh extends AppLocalizations {
@override
String get pictureInPicture => '画中画';
@override
String get autoEnterPip => '退出后自动小窗';
@override
String get pipUnavailable => '此设备无法使用画中画';
@override
String get originalTag => '原创';
@override
String get originalProduction => '原创出品';
@override
String get watchNowAction => '立即观看';
@override
String get newArrivalBadge => '上新';
@override
String get editorPick => '编辑精选';
@override
String totalEpisodesShort(int count) {
return '全$count集';
}
@override
String get dramaTag => '短剧';
@@ -895,6 +922,9 @@ class AppLocalizationsZh extends AppLocalizations {
@override
String get signOut => '退出登录';
@override
String get signOutConfirm => '确定要退出当前账号吗?';
@override
String get mockUserName => 'Vicky sheng';
@@ -1737,16 +1767,71 @@ class AppLocalizationsZh extends AppLocalizations {
String get contactSupport => '联系客服';
@override
String get vipBrandName => 'Netshort VIP';
String get vipBrandName => 'FruitShorts VIP';
@override
String get mineVipSubtitle => '享受专属权益';
String get vipOpenNow => '立即开通';
@override
String get vipBenefitFree => '全剧免费看';
@override
String get vipBenefitNoAds => '免广告打扰';
@override
String get vipBenefitHd => '1080P高清';
@override
String get vipBenefitFastCache => '极速缓存';
@override
String get moreServices => '更多服务';
@override
String get mineVipSubtitle => '解锁精彩,畅看好剧';
@override
String favoriteEpisodeProgress(int episode, int total) {
return '第 $episode 集 / 共 $total 集';
}
@override
String get manage => '管理';
@override
String continueWatchingSubtitle(int episode, int total) {
return '看到第 $episode 集 · 全 $total 集';
}
@override
String get favoriteDramas => '收藏短剧';
@override
String totalDramasCount(int count) {
return '共 $count 部';
}
@override
String watchedEpisodeTotal(int episode, int total) {
return '看到第 $episode 集 / 全 $total 集';
}
@override
String get hasUpdateBadge => '有更新';
@override
String updatedToEpisode(int episode) {
return '更新至第 $episode 集';
}
@override
String finishedAllEpisodes(int total) {
return '全 $total 集 · 已完结';
}
@override
String get noFavoritesYet => '还没有收藏的短剧';
@override
String watchedToEpisode(int episode) {
return '已看至 第 $episode 集';
+79 -5
View File
@@ -19,8 +19,7 @@
"searchCancel": "取消",
"featured": "精选",
"recommended": "推荐",
"fruitShortsBrand": "水果短剧",
"authLandingSubtitle": "登录后同步进度、收藏与金币权益",
"fruitShortsBrand": "FruitShorts",
"comingSoon": "即将上线",
"authLegal": "继续即代表同意《用户协议》与《隐私政策》",
"authLegalLead": "继续即代表同意",
@@ -49,7 +48,24 @@
"hotBadge": "爆剧",
"filterAll": "全部",
"seriesMeta": "系列剧 · 共{episodes}集 | 共{viewers}人在追",
"watchFullSeries": "观看完整剧集 · 全{episodes}集",
"watchFullSeries": "观看完整剧集 全{episodes}集",
"@watchFullSeries": {
"placeholders": {
"episodes": {"type": "String"}
}
},
"feedEpisodePrefix": "第{episode}集",
"@feedEpisodePrefix": {
"placeholders": {
"episode": {"type": "int"}
}
},
"feedWatchingCount": "共{count}人在看",
"@feedWatchingCount": {
"placeholders": {
"count": {"type": "String"}
}
},
"feedTabAnime": "漫剧",
"feedTabReal": "真人剧",
"feedTabForYou": "推荐",
@@ -237,8 +253,21 @@
"shareFailed": "无法打开系统分享面板。",
"nowPlaying": "正在播放",
"pictureInPicture": "画中画",
"autoEnterPip": "退出后自动小窗",
"pipUnavailable": "此设备无法使用画中画",
"originalTag": "原创",
"originalProduction": "原创出品",
"watchNowAction": "立即观看",
"newArrivalBadge": "上新",
"editorPick": "编辑精选",
"totalEpisodesShort": "全{count}集",
"@totalEpisodesShort": {
"placeholders": {
"count": {
"type": "int"
}
}
},
"dramaTag": "短剧",
"episodeLabel": "第 {number} 集",
"@episodeLabel": {
@@ -354,6 +383,7 @@
"restoreDefault": "恢复默认",
"invalidServerAddress": "请输入有效的 http(s) 服务器地址。",
"signOut": "退出登录",
"signOutConfirm": "确定要退出当前账号吗?",
"mockUserName": "Vicky sheng",
"mockUserId": "ID: M1CZWVYE",
"mockNotice": "当前是示例数据。",
@@ -682,8 +712,14 @@
"offlineDownloads": "离线缓存",
"watchPreferences": "观看偏好",
"contactSupport": "联系客服",
"vipBrandName": "Netshort VIP",
"mineVipSubtitle": "享受专属权益",
"vipBrandName": "FruitShorts VIP",
"vipOpenNow": "立即开通",
"vipBenefitFree": "全剧免费看",
"vipBenefitNoAds": "免广告打扰",
"vipBenefitHd": "1080P高清",
"vipBenefitFastCache": "极速缓存",
"moreServices": "更多服务",
"mineVipSubtitle": "解锁精彩,畅看好剧",
"favoriteEpisodeProgress": "第 {episode} 集 / 共 {total} 集",
"@favoriteEpisodeProgress": {
"placeholders": {
@@ -691,6 +727,44 @@
"total": { "type": "int" }
}
},
"myFavorites": "我的收藏",
"manage": "管理",
"continueWatching": "继续观看",
"continueWatchingSubtitle": "看到第 {episode} 集 · 全 {total} 集",
"@continueWatchingSubtitle": {
"placeholders": {
"episode": { "type": "int" },
"total": { "type": "int" }
}
},
"favoriteDramas": "收藏短剧",
"totalDramasCount": "共 {count} 部",
"@totalDramasCount": {
"placeholders": {
"count": { "type": "int" }
}
},
"watchedEpisodeTotal": "看到第 {episode} 集 / 全 {total} 集",
"@watchedEpisodeTotal": {
"placeholders": {
"episode": { "type": "int" },
"total": { "type": "int" }
}
},
"hasUpdateBadge": "有更新",
"updatedToEpisode": "更新至第 {episode} 集",
"@updatedToEpisode": {
"placeholders": {
"episode": { "type": "int" }
}
},
"finishedAllEpisodes": "全 {total} 集 · 已完结",
"@finishedAllEpisodes": {
"placeholders": {
"total": { "type": "int" }
}
},
"noFavoritesYet": "还没有收藏的短剧",
"watchedToEpisode": "已看至 第 {episode} 集",
"@watchedToEpisode": { "placeholders": { "episode": { "type": "int" } } },
"homeWatchAll": "观看全集",
@@ -11,6 +11,7 @@ import '../../core/formatting/localized_date_time.dart';
import '../../core/theme/app_colors.dart';
import '../../core/theme/app_dimens.dart';
import '../../core/theme/app_theme.dart';
import '../../core/widgets/app_glow_panel.dart';
import '../../core/widgets/auth_gate.dart';
import '../../core/widgets/plain_page_scaffold.dart';
import '../../l10n/app_localizations.dart';
@@ -172,15 +173,15 @@ class _AccountDeactivatePageState extends State<AccountDeactivatePage> {
final l10n = AppLocalizations.of(context)!;
final confirmed = await showDialog<bool>(
context: context,
builder: (dialogContext) => AlertDialog(
title: Text(l10n.accountConfirmDeactivateTitle),
content: Text(l10n.accountConfirmDeactivateMessage),
builder: (dialogContext) => AppGlowDialog(
title: l10n.accountConfirmDeactivateTitle,
content: l10n.accountConfirmDeactivateMessage,
actions: [
TextButton(
onPressed: () => Navigator.of(dialogContext).pop(false),
child: Text(l10n.cancel),
),
FilledButton(
TextButton(
key: const Key('account-deactivate-confirm'),
onPressed: () => Navigator.of(dialogContext).pop(true),
child: Text(l10n.accountConfirmDeactivate),
+2 -3
View File
@@ -45,8 +45,7 @@ class AccountEntryCard extends StatelessWidget {
];
return Material(
key: const Key('mine-account-card'),
color: AppColors.card,
borderRadius: BorderRadius.circular(AppDimens.cardRadius),
color: AppColors.contentSurface,
clipBehavior: Clip.antiAlias,
child: Column(
children: [
@@ -55,7 +54,7 @@ class AccountEntryCard extends StatelessWidget {
const Divider(
height: AppDimens.mineGridDividerWidth,
thickness: AppDimens.mineGridDividerWidth,
color: AppColors.outlineVariantDark,
color: AppColors.contentBorder,
),
_AccountListTile(row: rows[index]),
],
+35 -49
View File
@@ -61,7 +61,7 @@ class _AuthFields extends StatelessWidget {
onChanged: callbacks.onEmailChanged,
onSubmitted: (_) => state.fields.passwordFocus.requestFocus(),
style: const TextStyle(color: AppColors.onSurface, fontSize: 15),
cursorColor: AppColors.blue,
cursorColor: AppColors.brandRed,
decoration: _decoration(
context: context,
hint: 'name@example.com',
@@ -93,7 +93,7 @@ class _AuthFields extends StatelessWidget {
onChanged: callbacks.onPasswordChanged,
onSubmitted: (_) => callbacks.onSubmit(),
style: const TextStyle(color: AppColors.onSurface, fontSize: 15),
cursorColor: AppColors.blue,
cursorColor: AppColors.brandRed,
decoration: _decoration(
context: context,
hint: l10n.authPasswordHint,
@@ -128,7 +128,7 @@ class _AuthFields extends StatelessWidget {
style: const TextStyle(
color: AppColors.muted,
fontSize: 12,
fontWeight: FontWeight.w700,
fontWeight: FontWeight.w400,
),
);
@@ -142,10 +142,7 @@ class _AuthFields extends StatelessWidget {
}) {
final border = OutlineInputBorder(
borderRadius: BorderRadius.circular(_fieldRadius),
borderSide: const BorderSide(
color: AppColors.border,
width: _fieldBorderWidth,
),
borderSide: BorderSide.none,
);
final errorColor = Theme.of(context).colorScheme.error;
final errorBorder = OutlineInputBorder(
@@ -158,7 +155,7 @@ class _AuthFields extends StatelessWidget {
prefixIcon: Icon(
icon,
size: 21,
color: focused ? AppColors.blue : AppColors.muted,
color: focused ? AppColors.brandRed : AppColors.muted,
),
prefixIconConstraints: const BoxConstraints(
minWidth: _minTapTarget,
@@ -166,7 +163,7 @@ class _AuthFields extends StatelessWidget {
),
suffixIcon: suffix,
filled: true,
fillColor: AppColors.card,
fillColor: Colors.white.withValues(alpha: 0.05),
isDense: true,
contentPadding: const EdgeInsets.only(right: 16),
border: border,
@@ -175,7 +172,7 @@ class _AuthFields extends StatelessWidget {
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(_fieldRadius),
borderSide: const BorderSide(
color: AppColors.blue,
color: AppColors.brandRed,
width: _fieldBorderWidth,
),
),
@@ -204,17 +201,17 @@ class _AuthSubmitButton extends StatelessWidget {
style: ButtonStyle(
backgroundColor: WidgetStateProperty.resolveWith((states) {
if (states.contains(WidgetState.disabled)) {
return AppColors.blue.withValues(alpha: 0.5);
return AppColors.brandRed.withValues(alpha: 0.5);
}
if (states.contains(WidgetState.pressed)) {
return AppColors.bluePressed;
return AppColors.brandRedPressed;
}
return AppColors.blue;
return AppColors.brandRed;
}),
foregroundColor: const WidgetStatePropertyAll(AppColors.onPrimary),
elevation: const WidgetStatePropertyAll(2),
shadowColor: WidgetStatePropertyAll(
AppColors.blue.withValues(alpha: 0.22),
AppColors.brandRed.withValues(alpha: 0.22),
),
padding: const WidgetStatePropertyAll(EdgeInsets.zero),
shape: WidgetStatePropertyAll(
@@ -235,7 +232,7 @@ class _AuthSubmitButton extends StatelessWidget {
status.signUpMode ? l10n.signUp : l10n.signIn,
style: const TextStyle(
fontSize: 15,
fontWeight: FontWeight.w800,
fontWeight: FontWeight.w600,
),
),
),
@@ -243,18 +240,16 @@ class _AuthSubmitButton extends StatelessWidget {
}
}
class _ModeSegment extends StatelessWidget {
const _ModeSegment({
class _ModeTab extends StatelessWidget {
const _ModeTab({
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;
@@ -264,38 +259,29 @@ class _ModeSegment extends StatelessWidget {
key: segmentKey,
behavior: HitTestBehavior.opaque,
onTap: onTap,
child: AnimatedContainer(
duration: _segmentDuration,
alignment: Alignment.center,
decoration: BoxDecoration(
color: selected ? AppColors.blue : AppColors.transparent,
borderRadius: BorderRadius.circular(18),
),
child: Stack(
fit: StackFit.expand,
// 文字 + 指示条只有约 32px 高,补上下各 6px 把可点区域撑到 44。
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 6),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
Center(
child: Text(
label,
style: TextStyle(
color: selected ? AppColors.onPrimary : AppColors.onSurface,
fontSize: 14,
fontWeight: FontWeight.w700,
),
Text(
label,
style: TextStyle(
color: selected ? AppColors.textPrimary : AppColors.muted,
fontSize: AppDimens.followingSegmentFont,
fontWeight: FontWeight.w400,
),
),
Positioned.fill(
child: ExcludeSemantics(
child: Opacity(
opacity: 0,
child: Center(
child: Text(
hiddenLabel,
maxLines: 1,
softWrap: false,
style: const TextStyle(fontSize: 14),
),
),
const SizedBox(height: AppDimens.followingSegmentIndicatorTopGap),
Container(
width: AppDimens.followingSegmentIndicatorWidth,
height: AppDimens.followingSegmentIndicatorHeight,
decoration: BoxDecoration(
color: selected ? AppColors.brandRed : AppColors.transparent,
borderRadius: BorderRadius.circular(
AppDimens.followingSegmentIndicatorRadius,
),
),
),
@@ -349,7 +335,7 @@ class _AuthBrand extends StatelessWidget {
style: const TextStyle(
color: AppColors.onSurface,
fontSize: 24,
fontWeight: FontWeight.w900,
fontWeight: FontWeight.w700,
height: 1.1,
),
),
+1 -1
View File
@@ -50,7 +50,7 @@ class _AuthLegalLinksState extends State<AuthLegalLinks> {
Widget build(BuildContext context) {
final l10n = AppLocalizations.of(context)!;
final muted = TextStyle(color: AppColors.muted, fontSize: _legalFontSize, height: 1.6);
final link = muted.copyWith(color: AppColors.blue);
final link = muted.copyWith(color: AppColors.brandRed);
return Text.rich(
TextSpan(
style: muted,
+88 -64
View File
@@ -24,18 +24,14 @@ part 'auth_widgets.dart';
part 'auth_form_widgets.dart';
const double _minTapTarget = 44;
const double _brandMarkSize = 72;
const double _brandMarkSize = 88;
const double _compactBrandMarkSize = 48;
const double _brandMarkRadius = 20;
const double _brandMarkRadius = 26;
const double _compactBrandMarkRadius = 14;
const double _landingLogoTopGap = 28;
const String _appLogoAsset = 'assets/icon/fruitshorts.png';
const double _contentMaxWidth = 440;
// Auth keeps its approved 20px card silhouette.
const double _cardRadius = AppDimens.authCardRadius;
const double _cardPadding = 20;
const double _fieldHeight = 52;
const double _fieldRadius = 14;
const double _fieldRadius = 12;
const double _fieldBorderWidth = 1;
const double _buttonHeight = 50;
const double _buttonRadius = 25;
@@ -47,14 +43,11 @@ const double _bottomContentPadding = 28;
const double _compactTopContentPadding = 40;
const double _compactHeightBreakpoint = 720;
const double _compactBrandGap = 16;
const double _glowSize = 280;
const double _warmGlowOpacity = 0.18;
const double _entryButtonHeight = 50;
const double _entryButtonRadius = 25;
const double _entryButtonHeight = 52;
const double _entryButtonRadius = 26;
const double _entryButtonFontSize = 15;
const double _entryIconSize = 20;
const Duration _enterDuration = Duration(milliseconds: 220);
const Duration _segmentDuration = Duration(milliseconds: 160);
Widget _brandMarkWidget({
Key? key,
@@ -267,45 +260,53 @@ class _AuthPageState extends State<AuthPage> {
child: IgnorePointer(
child: DecoratedBox(
key: Key('auth-page-background'),
decoration: BoxDecoration(gradient: AppTheme.pageGradient),
),
),
),
Positioned(
top: -90,
right: -70,
width: _glowSize,
height: _glowSize,
child: IgnorePointer(
child: Container(
key: const Key('auth-background-glow'),
decoration: BoxDecoration(
shape: BoxShape.circle,
gradient: RadialGradient(
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [
AppColors.surfaceTop,
AppColors.surfaceTop.withValues(alpha: 0),
AppColors.followingGlow,
AppColors.followingGlowMid,
AppColors.appBackground,
],
stops: [0, 0.14, 0.3],
),
),
),
),
),
Positioned(
left: -110,
bottom: -90,
width: _glowSize,
height: _glowSize,
// 全屏海报背景:压暗保证文字可读,顶部再叠品牌红光。
Positioned.fill(
child: IgnorePointer(child: _AuthPosterBackdrop()),
),
const Positioned.fill(
child: IgnorePointer(
child: Container(
key: const Key('auth-background-warm-glow'),
child: DecoratedBox(
key: Key('auth-poster-scrim'),
decoration: BoxDecoration(
shape: BoxShape.circle,
gradient: RadialGradient(
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [
AppColors.gold.withValues(alpha: _warmGlowOpacity),
AppColors.gold.withValues(alpha: 0),
Color(0x66000000),
Color(0x14000000),
Color(0xE0000000),
],
stops: [0, 0.42, 1],
),
),
),
),
),
const Positioned.fill(
child: IgnorePointer(
child: DecoratedBox(
key: Key('auth-red-glow'),
decoration: BoxDecoration(
gradient: RadialGradient(
center: Alignment(0, -1.15),
radius: 1.3,
colors: [AppColors.primaryBorder, AppColors.transparent],
),
),
),
@@ -347,7 +348,11 @@ class _AuthPageState extends State<AuthPage> {
constraints: const BoxConstraints(
maxWidth: _contentMaxWidth,
),
child: _content(l10n, compact: compact),
child: _content(
l10n,
compact: compact,
minHeight: minHeight,
),
),
),
),
@@ -387,7 +392,11 @@ class _AuthPageState extends State<AuthPage> {
);
}
Widget _content(AppLocalizations l10n, {required bool compact}) =>
Widget _content(
AppLocalizations l10n, {
required bool compact,
required double minHeight,
}) =>
TweenAnimationBuilder<double>(
key: const Key('auth-enter-animation'),
tween: Tween(begin: 0, end: 1),
@@ -409,15 +418,18 @@ class _AuthPageState extends State<AuthPage> {
_authCard(l10n),
],
)
: _landing(l10n),
: _landing(l10n, minHeight: minHeight),
);
Widget _landing(AppLocalizations l10n) => Column(
/// 落地页内容需要有限高度才能用 Spacer 三段分割,这里显式钉住可用高度。
Widget _landing(AppLocalizations l10n, {required double minHeight}) =>
SizedBox(
height: minHeight,
child: Column(
key: const Key('auth-landing'),
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
const SizedBox(height: _landingLogoTopGap),
const Spacer(flex: 5),
Center(
child: _brandMarkWidget(
key: const Key('auth-brand-logo'),
@@ -425,24 +437,19 @@ class _AuthPageState extends State<AuthPage> {
radius: _brandMarkRadius,
),
),
const SizedBox(height: 16),
const SizedBox(height: 10),
Text(
l10n.fruitShortsBrand,
textAlign: TextAlign.center,
style: const TextStyle(
fontFamily: 'Outfit',
color: AppColors.onSurface,
fontSize: 24,
fontWeight: FontWeight.w900,
fontSize: 26,
fontWeight: FontWeight.w700,
letterSpacing: 2,
),
),
const SizedBox(height: 6),
Text(
l10n.authLandingSubtitle,
textAlign: TextAlign.center,
style: const TextStyle(color: AppColors.muted, fontSize: 13),
),
const SizedBox(height: 28),
const Spacer(flex: 3),
_AuthEntryButton(
key: const Key('auth-entry-phone'),
label: l10n.authPhoneSignIn,
@@ -458,10 +465,12 @@ class _AuthPageState extends State<AuthPage> {
primary: false,
onTap: () => setState(() => _emailEntryOpen = true),
),
const SizedBox(height: 18),
const AuthLegalLinks(),
],
);
const SizedBox(height: 14),
const Opacity(opacity: 0.75, child: AuthLegalLinks()),
const Spacer(flex: 6),
],
),
);
Future<void> _openPhoneSheet() async {
final signedIn = await showPhoneAuthSheet(
@@ -526,15 +535,15 @@ class _AuthEntryButton extends StatelessWidget {
@override
Widget build(BuildContext context) {
final background = primary ? AppColors.blue : AppColors.card;
// 主按钮纯品牌红;次按钮为无边框深色玻璃(白 6%),Apple 风格。
final background = primary
? AppColors.brandRed
: Colors.white.withValues(alpha: 0.06);
final foreground = primary ? AppColors.onPrimary : AppColors.onSurface;
return Material(
color: background,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(_entryButtonRadius),
side: primary
? BorderSide.none
: const BorderSide(color: AppColors.border),
),
clipBehavior: Clip.antiAlias,
child: InkWell(
@@ -556,7 +565,7 @@ class _AuthEntryButton extends StatelessWidget {
style: TextStyle(
color: foreground,
fontSize: _entryButtonFontSize,
fontWeight: FontWeight.w800,
fontWeight: FontWeight.w600,
),
),
),
@@ -567,3 +576,18 @@ class _AuthEntryButton extends StatelessWidget {
);
}
}
/// 登录页全屏海报背景(单张,无拼缝)。
class _AuthPosterBackdrop extends StatelessWidget {
const _AuthPosterBackdrop();
@override
Widget build(BuildContext context) {
return Image.asset(
key: const Key('auth-poster-backdrop'),
'assets/auth/bg_3.jpg',
fit: BoxFit.cover,
alignment: Alignment.center,
);
}
}
+49 -80
View File
@@ -70,52 +70,45 @@ class _AuthCard extends StatelessWidget {
Widget build(BuildContext context) {
final l10n = state.l10n;
final status = state.status;
return Container(
// 不再做卡片盒子,表单直接排在红光晕背景上。
return Column(
key: const Key('auth-card'),
padding: const EdgeInsets.all(_cardPadding),
decoration: BoxDecoration(
color: AppColors.card,
borderRadius: BorderRadius.circular(_cardRadius),
border: Border.all(color: AppColors.border),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
_AuthModeSwitch(
l10n: l10n,
signUpMode: status.signUpMode,
busy: status.busy,
onSelected: callbacks.onModeSelected,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
_AuthModeSwitch(
l10n: l10n,
signUpMode: status.signUpMode,
busy: status.busy,
onSelected: callbacks.onModeSelected,
),
const SizedBox(height: 24),
Text(
status.signUpMode ? l10n.authSignUpTitle : l10n.authSignInTitle,
style: const TextStyle(
color: AppColors.onSurface,
fontSize: 24,
fontWeight: FontWeight.w600,
height: 1.2,
),
const SizedBox(height: 22),
Text(
status.signUpMode ? l10n.authSignUpTitle : l10n.authSignInTitle,
style: const TextStyle(
color: AppColors.onSurface,
fontSize: 25,
fontWeight: FontWeight.w800,
height: 1.2,
),
),
const SizedBox(height: 6),
Text(
status.signUpMode ? l10n.authSignUpSubtitle : l10n.authSubtitle,
style: const TextStyle(
color: AppColors.muted,
fontSize: AppDimens.body,
height: 1.45,
),
const SizedBox(height: 6),
Text(
status.signUpMode ? l10n.authSignUpSubtitle : l10n.authSubtitle,
style: const TextStyle(
color: AppColors.muted,
fontSize: AppDimens.body,
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),
),
const SizedBox(height: 20),
_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),
],
);
}
}
@@ -135,47 +128,23 @@ class _AuthModeSwitch extends StatelessWidget {
@override
Widget build(BuildContext context) {
return TextButton(
return Row(
key: const Key('auth-switch-mode'),
onPressed: busy ? null : () => onSelected(!signUpMode),
style: TextButton.styleFrom(
minimumSize: const Size(0, _minTapTarget),
padding: EdgeInsets.zero,
overlayColor: AppColors.transparent,
splashFactory: NoSplash.splashFactory,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(22)),
),
child: Container(
height: 36,
padding: const EdgeInsets.all(2),
decoration: BoxDecoration(
color: AppColors.raised,
borderRadius: BorderRadius.circular(18),
children: [
_ModeTab(
segmentKey: const Key('auth-mode-sign-in'),
label: l10n.signIn,
selected: !signUpMode,
onTap: busy ? null : () => onSelected(false),
),
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),
),
),
],
const SizedBox(width: AppDimens.followingSegmentGap),
_ModeTab(
segmentKey: const Key('auth-mode-sign-up'),
label: l10n.signUp,
selected: signUpMode,
onTap: busy ? null : () => onSelected(true),
),
),
],
);
}
}
+12 -10
View File
@@ -11,6 +11,7 @@ import '../../core/data/services/auth_controller.dart';
import '../../core/platform/haptics.dart';
import '../../core/platform/keyboard_inset.dart';
import '../../core/theme/app_colors.dart';
import '../../core/widgets/app_glow_panel.dart';
import '../../core/widgets/centered_toast.dart';
import '../../l10n/app_localizations.dart';
@@ -252,15 +253,15 @@ class _PhoneAuthSheetState extends State<PhoneAuthSheet> {
final bottom = effectiveKeyboardInset(context, _keyboardInset);
return Padding(
padding: EdgeInsets.only(bottom: bottom),
child: Container(
key: const Key('phone-auth-sheet'),
decoration: const BoxDecoration(
color: AppColors.card,
borderRadius: BorderRadius.vertical(
top: Radius.circular(_sheetRadius),
),
child: AppGlowPanel(
borderRadius: const BorderRadius.vertical(
top: Radius.circular(_sheetRadius),
),
child: SingleChildScrollView(
border: false,
child: Container(
key: const Key('phone-auth-sheet'),
decoration: const BoxDecoration(color: AppColors.transparent),
child: SingleChildScrollView(
controller: _scrollController,
padding: const EdgeInsets.fromLTRB(22, 10, 22, 26),
child: Column(
@@ -313,6 +314,7 @@ class _PhoneAuthSheetState extends State<PhoneAuthSheet> {
],
),
),
),
),
);
}
@@ -403,7 +405,7 @@ class _PhoneAuthSheetState extends State<PhoneAuthSheet> {
key: const Key('auth-phone-submit'),
onPressed: _submitting ? null : _submit,
style: FilledButton.styleFrom(
backgroundColor: AppColors.blue,
backgroundColor: AppColors.brandRed,
foregroundColor: AppColors.onPrimary,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(_buttonHeight / 2),
@@ -439,7 +441,7 @@ class _PhoneAuthSheetState extends State<PhoneAuthSheet> {
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(_fieldRadius),
borderSide: const BorderSide(color: AppColors.blue, width: 1.5),
borderSide: const BorderSide(color: AppColors.brandRed, width: 1.5),
),
);
}
+1 -1
View File
@@ -139,7 +139,7 @@ class _SearchPageState extends State<SearchPage> {
color: AppColors.textSecondary,
size: 18,
),
const SizedBox(width: AppDimens.spaceSm),
const SizedBox(width: 2),
Expanded(
child: TextField(
key: const Key('discover-search'),
+6 -5
View File
@@ -16,6 +16,7 @@ import '../../core/platform/haptics.dart';
import '../../core/theme/app_colors.dart';
import '../../core/theme/app_dimens.dart';
import '../../core/theme/app_theme.dart';
import '../../core/widgets/app_glow_panel.dart';
import '../../core/widgets/app_pull_to_refresh.dart';
import '../../core/widgets/auth_gate.dart';
import '../../core/widgets/empty_state.dart';
@@ -181,15 +182,15 @@ class _DownloadsBody extends StatelessWidget {
final l10n = AppLocalizations.of(context)!;
final confirmed = await showDialog<bool>(
context: context,
builder: (dialogContext) => AlertDialog(
title: Text(l10n.clearDownloadsTitle),
content: Text(l10n.clearDownloadsMessage),
builder: (dialogContext) => AppGlowDialog(
title: l10n.clearDownloadsTitle,
content: l10n.clearDownloadsMessage,
actions: [
TextButton(
onPressed: () => Navigator.of(dialogContext).pop(false),
child: Text(l10n.cancel),
),
FilledButton(
TextButton(
onPressed: () => Navigator.of(dialogContext).pop(true),
child: Text(l10n.confirmClear),
),
@@ -435,7 +436,7 @@ class _LicenseTile extends StatelessWidget {
minHeight: AppDimens.progressHeight,
value: progress.clamp(0.0, 1.0),
backgroundColor: AppColors.border,
valueColor: const AlwaysStoppedAnimation(AppColors.blueSoft),
valueColor: const AlwaysStoppedAnimation(AppColors.brandRed),
),
),
if (license.expireAt != null) ...[
@@ -95,7 +95,7 @@ class DramaResumeBar extends StatelessWidget {
value: fraction,
minHeight: 3,
backgroundColor: AppColors.border,
valueColor: const AlwaysStoppedAnimation(AppColors.blue),
valueColor: const AlwaysStoppedAnimation(AppColors.brandRed),
),
),
if (label != null) ...[
@@ -5,7 +5,6 @@ import 'package:flutter/material.dart';
import '../../../core/data/models/drama.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/subpage_header.dart';
import '../../../l10n/app_localizations.dart';
@@ -54,7 +53,18 @@ class DramaDetailHeader extends StatelessWidget {
Widget build(BuildContext context) {
return Container(
key: const Key('detail-hero'),
decoration: const BoxDecoration(gradient: AppTheme.pageGradient),
decoration: const BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [
AppColors.followingGlow,
AppColors.followingGlowMid,
AppColors.appBackground,
],
stops: [0, 0.14, 0.3],
),
),
child: SafeArea(
bottom: false,
child: Padding(
+4 -86
View File
@@ -25,87 +25,6 @@ const double _barHorizontal = 16;
const double _barFontSize = 13;
const double _barButtonHeight = 30;
const double _removeDialogButtonHeight = 32;
const double _removeDialogRadius = 6;
const double _removeDialogBottomInset = 8;
const double _cancelFollowingDialogPadding = 20;
/// 播放历史移除确认。只把移除按钮压矮。
Future<bool> confirmHistoryRemove(BuildContext context) async {
final l10n = AppLocalizations.of(context)!;
return await showDialog<bool>(
context: context,
builder: (dialogContext) => AlertDialog(
actionsPadding: const EdgeInsets.fromLTRB(
24,
0,
16,
_removeDialogBottomInset,
),
content: Text(l10n.confirmRemove),
actions: [
TextButton(
onPressed: () => Navigator.pop(dialogContext, false),
child: Text(l10n.cancel),
),
FilledButton(
style: FilledButton.styleFrom(
visualDensity: VisualDensity.compact,
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
minimumSize: const Size(0, _removeDialogButtonHeight),
padding: const EdgeInsets.symmetric(horizontal: 12),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(_removeDialogRadius),
),
),
onPressed: () => Navigator.pop(dialogContext, true),
child: Text(l10n.remove),
),
],
),
) ??
false;
}
/// 确认后返回是否取消已选追剧。
Future<bool> confirmCancelFollowing(BuildContext context) async {
final l10n = AppLocalizations.of(context)!;
return await showDialog<bool>(
context: context,
builder: (dialogContext) => AlertDialog(
contentPadding: const EdgeInsets.all(_cancelFollowingDialogPadding),
actionsPadding: const EdgeInsets.fromLTRB(
_cancelFollowingDialogPadding,
0,
_cancelFollowingDialogPadding,
_cancelFollowingDialogPadding,
),
content: Text(l10n.confirmCancelFollowing),
actions: [
TextButton(
style: TextButton.styleFrom(
visualDensity: VisualDensity.standard,
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
minimumSize: const Size(0, _removeDialogButtonHeight),
padding: const EdgeInsets.symmetric(horizontal: 12),
),
onPressed: () => Navigator.pop(dialogContext, false),
child: Text(l10n.cancel),
),
FilledButton(
style: FilledButton.styleFrom(
visualDensity: VisualDensity.standard,
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
minimumSize: const Size(0, _removeDialogButtonHeight),
padding: const EdgeInsets.symmetric(horizontal: 12),
),
onPressed: () => Navigator.pop(dialogContext, true),
child: Text(l10n.cancelFollowing),
),
],
),
) ??
false;
}
/// 只在追剧编辑中显示底栏。
class FollowingEditSlot extends StatelessWidget {
@@ -195,6 +114,7 @@ class FollowingEditBar extends StatelessWidget {
TextButton(
key: const Key('following-select-all'),
style: TextButton.styleFrom(
foregroundColor: AppColors.brandRed,
visualDensity: VisualDensity.compact,
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
minimumSize: const Size(0, _barButtonHeight),
@@ -214,16 +134,14 @@ class FollowingEditBar extends StatelessWidget {
),
),
const Spacer(),
FilledButton(
TextButton(
key: const Key('following-cancel-follow'),
style: FilledButton.styleFrom(
style: TextButton.styleFrom(
foregroundColor: AppColors.brandRed,
visualDensity: VisualDensity.compact,
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
minimumSize: const Size(0, _removeDialogButtonHeight),
padding: const EdgeInsets.symmetric(horizontal: 12),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(_removeDialogRadius),
),
textStyle: const TextStyle(
fontSize: _barFontSize,
fontWeight: FontWeight.w600,
@@ -5,12 +5,18 @@ import 'dart:async';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import '../../core/data/models/watch_record.dart';
import '../../core/data/services/favorite_controller.dart';
import '../../core/data/services/watch_records_controller.dart';
import '../../core/formatting/error_text.dart';
import '../../core/theme/app_colors.dart';
import '../../core/theme/app_dimens.dart';
import '../../core/widgets/empty_state.dart';
import '../../l10n/app_localizations.dart';
import '../player/open_player.dart';
import 'following_grid_card.dart';
import 'following_paged_grid.dart';
import 'widgets/continue_watching_banner.dart';
/// 追剧编辑中的选中状态。
class FollowingFavoriteSelection {
@@ -30,15 +36,19 @@ class FollowingFavoritesGrid extends StatelessWidget {
const FollowingFavoritesGrid({
super.key,
required this.controller,
required this.history,
required this.selection,
required this.scrollController,
required this.onGoHome,
required this.onContinueRecord,
});
final FavoriteController controller;
final WatchRecordsController history;
final FollowingFavoriteSelection selection;
final ScrollController scrollController;
final VoidCallback onGoHome;
final ValueChanged<WatchRecord> onContinueRecord;
@override
Widget build(BuildContext context) {
@@ -49,7 +59,7 @@ class FollowingFavoritesGrid extends StatelessWidget {
valueListenable: selection.selected,
builder: (context, picked, _) {
return ListenableBuilder(
listenable: controller,
listenable: Listenable.merge([controller, history]),
builder: (context, _) => _grid(context, isEditing, picked),
);
},
@@ -60,14 +70,15 @@ class FollowingFavoritesGrid extends StatelessWidget {
Widget _grid(BuildContext context, bool isEditing, Set<String> picked) {
final l10n = AppLocalizations.of(context)!;
final extra = isEditing ? 0 : 1;
final hasFavorites = controller.cards.isNotEmpty;
final extra = !isEditing && hasFavorites ? 1 : 0;
return FollowingPagedGrid(
key: const Key('following-favorites-grid'),
scrollController: scrollController,
loading: controller.loading,
loadingMore: controller.loadingMore,
hasMore: controller.hasMore,
hasItems: controller.cards.isNotEmpty,
hasItems: hasFavorites,
showInitialLoading: false,
errorMessage: controller.error == null
? null
@@ -78,23 +89,96 @@ class FollowingFavoritesGrid extends StatelessWidget {
onRefresh: controller.load,
onLoadMore: controller.loadMore,
itemCount: controller.cards.length + extra,
empty: const SizedBox.shrink(),
topSlivers: _topSlivers(context),
empty: EmptyState(
key: const Key('following-favorites-empty'),
icon: Icons.bookmark_border_rounded,
title: l10n.noFavoritesYet,
),
itemBuilder: (context, index) => _item(context, index, isEditing, picked),
);
}
List<Widget> _topSlivers(BuildContext context) {
final l10n = AppLocalizations.of(context)!;
final continueRecord = _continueRecord();
return [
if (continueRecord != null)
SliverToBoxAdapter(
child: Padding(
padding: const EdgeInsets.fromLTRB(
AppDimens.feedPageHorizontal,
4,
AppDimens.feedPageHorizontal,
0,
),
child: ContinueWatchingBanner(
record: continueRecord,
languageCode: Localizations.localeOf(context).languageCode,
onTap: () => onContinueRecord(continueRecord),
),
),
),
SliverToBoxAdapter(
child: Padding(
padding: const EdgeInsets.fromLTRB(
AppDimens.feedPageHorizontal,
AppDimens.followingSectionTopGap,
AppDimens.feedPageHorizontal,
AppDimens.followingSectionBottomGap,
),
child: Row(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Text(
l10n.favoriteDramas,
style: const TextStyle(
color: AppColors.textPrimary,
fontSize: AppDimens.followingSectionTitleFont,
fontWeight: FontWeight.w400,
),
),
const Spacer(),
Padding(
padding: const EdgeInsets.only(bottom: 2),
child: Text(
l10n.totalDramasCount(controller.total),
style: const TextStyle(
color: AppColors.textTabInactive,
fontSize: AppDimens.followingSectionCountFont,
),
),
),
],
),
),
),
];
}
/// 最近一条观看记录(records 已按最近观看排序,与观看历史页首条一致)。
WatchRecord? _continueRecord() {
return history.records.isEmpty ? null : history.records.first;
}
Widget _item(
BuildContext context,
int index,
bool isEditing,
Set<String> picked,
) {
final l10n = AppLocalizations.of(context)!;
if (index == controller.cards.length) {
return FollowingAddCard(onTap: onGoHome);
}
final l10n = AppLocalizations.of(context)!;
final drama = controller.cards[index];
final record = history.recordForDrama(drama.id);
final episode = drama.episodes.isEmpty ? 1 : drama.episodes.first.number;
final watchedEpisode = record?.episodeNumber ?? 0;
final total = drama.episodeCount;
final subtitle = watchedEpisode > 0 && total > 0
? l10n.watchedEpisodeTotal(watchedEpisode, total)
: l10n.favoriteEpisodeProgress(episode, total);
return FollowingGridCard(
dramaId: drama.id,
title: drama.localizedTitle(Localizations.localeOf(context).languageCode),
@@ -102,7 +186,10 @@ class FollowingFavoritesGrid extends StatelessWidget {
viewCount: drama.viewCount,
editing: isEditing,
selected: isEditing ? picked.contains(drama.id) : null,
subtitle: l10n.favoriteEpisodeProgress(episode, drama.episodeCount),
subtitle: subtitle,
// TODO(backend): Drama 增加 hasUpdate / latestEpisodeNumber / isFinished
// 字段后,在此传 updateBadge(l10n.hasUpdateBadge)、红色更新副标题
// (l10n.updatedToEpisode)或灰色完结副标题(l10n.finishedAllEpisodes)。
onTap: () => _openOrToggle(context, drama.id, isEditing),
);
}
+44 -9
View File
@@ -25,6 +25,8 @@ class FollowingGridCard extends StatelessWidget {
this.editing = false,
this.selected,
this.onRemove,
this.updateBadge,
this.subtitleColor,
});
final String dramaId;
@@ -38,6 +40,13 @@ class FollowingGridCard extends StatelessWidget {
final bool? selected;
final VoidCallback? onRemove;
/// 左上角「有更新」角标文案;null 不显示。
/// 待后端在 Drama 增加更新状态字段后由收藏网格传入。
final String? updateBadge;
/// 副标题颜色;更新中用强调红,完结用默认灰。
final Color? subtitleColor;
@override
Widget build(BuildContext context) {
return InkWell(
@@ -109,6 +118,32 @@ class FollowingGridCard extends StatelessWidget {
count: viewCount,
),
),
if (updateBadge != null && selected == null)
Positioned(
left: AppDimens.followingBadgeInset,
top: AppDimens.followingBadgeInset,
child: Container(
padding: const EdgeInsets.symmetric(
horizontal: AppDimens.followingBadgePaddingH,
vertical: AppDimens.followingBadgePaddingV,
),
decoration: BoxDecoration(
color: AppColors.brandRed,
borderRadius: BorderRadius.circular(
AppDimens.followingBadgeRadius,
),
),
child: Text(
updateBadge!,
style: const TextStyle(
color: AppColors.onPrimary,
fontSize: AppDimens.followingBadgeFont,
fontWeight: FontWeight.w400,
height: 1,
),
),
),
),
if (progress != null)
Positioned(
left: 0,
@@ -120,7 +155,7 @@ class FollowingGridCard extends StatelessWidget {
minHeight: AppDimens.followingProgressHeight,
backgroundColor: AppColors.inactiveTrack,
valueColor: const AlwaysStoppedAnimation<Color>(
AppColors.primary,
AppColors.brandRed,
),
),
),
@@ -130,13 +165,13 @@ class FollowingGridCard extends StatelessWidget {
const SizedBox(height: AppDimens.cardCoverTitleGap),
Text(
title,
maxLines: 2,
maxLines: 1,
overflow: TextOverflow.ellipsis,
textAlign: TextAlign.left,
style: const TextStyle(
color: AppColors.textPrimary,
fontSize: AppDimens.cardTitleFont,
fontWeight: FontWeight.w500,
fontSize: AppDimens.followingCardTitleFontNew,
fontWeight: FontWeight.w400,
height: AppDimens.cardTitleLineHeight,
),
),
@@ -146,9 +181,9 @@ class FollowingGridCard extends StatelessWidget {
maxLines: 1,
overflow: TextOverflow.ellipsis,
textAlign: TextAlign.left,
style: const TextStyle(
color: AppColors.textTertiary,
fontSize: AppDimens.followingSubtitleFont,
style: TextStyle(
color: subtitleColor ?? AppColors.textTertiary,
fontSize: AppDimens.followingCardSubtitleFontNew,
),
),
],
@@ -169,9 +204,9 @@ class _SelectMark extends StatelessWidget {
height: _selectMarkSize,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: selected ? AppColors.blue : AppColors.transparent,
color: selected ? AppColors.brandRed : AppColors.transparent,
border: Border.all(
color: selected ? AppColors.blue : AppColors.textPrimary,
color: selected ? AppColors.brandRed : AppColors.textPrimary,
width: _selectBorderWidth,
),
),
@@ -158,7 +158,7 @@ class FollowingHistoryCard extends StatelessWidget {
minHeight: AppDimens.followingHistoryProgressHeight,
backgroundColor: AppColors.inactiveTrack,
valueColor: const AlwaysStoppedAnimation<Color>(
AppColors.primary,
AppColors.brandRed,
),
),
),
+161 -97
View File
@@ -17,28 +17,31 @@ import '../../core/theme/app_colors.dart';
import '../../core/theme/app_dimens.dart';
import '../../core/widgets/empty_state.dart';
import '../../l10n/app_localizations.dart';
import '../discover/search_page.dart';
import '../player/open_player.dart';
import '../recommend/widgets/search_gift_glyphs.dart';
import 'following_edit_bar.dart';
import 'following_favorites_grid.dart';
import 'following_history_card.dart';
import 'following_keep_alive_tab.dart';
import 'following_paged_grid.dart';
const double _doneFontSize = 14;
const double _doneTextGap = 12;
class FollowingPage extends StatefulWidget {
const FollowingPage({
super.key,
required this.onGoHome,
required this.favoriteController,
this.historyRequest = 0,
this.visible = true,
});
final VoidCallback onGoHome;
final FavoriteController favoriteController;
final int historyRequest;
/// 当前是否为首页选中的 tab;重新可见时刷新观看历史,保证横幅是最新进度。
final bool visible;
@override
State<FollowingPage> createState() => _FollowingPageState();
}
@@ -102,6 +105,9 @@ class _FollowingPageState extends State<FollowingPage> {
@override
void didUpdateWidget(covariant FollowingPage oldWidget) {
super.didUpdateWidget(oldWidget);
if (!oldWidget.visible && widget.visible) {
unawaited(_history.load());
}
if (oldWidget.historyRequest == widget.historyRequest) return;
WidgetsBinding.instance.addPostFrameCallback((_) {
if (mounted) _selectTab(FollowingTab.history);
@@ -111,9 +117,21 @@ class _FollowingPageState extends State<FollowingPage> {
@override
Widget build(BuildContext context) {
final l10n = AppLocalizations.of(context)!;
return ColoredBox(
return DecoratedBox(
key: const Key('following-page'),
color: AppColors.appBackground,
// 纯黑底 + 顶部暗红光晕,与设计稿一致。
decoration: const BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [
AppColors.followingGlow,
AppColors.followingGlowMid,
AppColors.appBackground,
],
stops: [0, 0.14, 0.3],
),
),
child: SafeArea(
bottom: false,
child: Column(
@@ -128,6 +146,7 @@ class _FollowingPageState extends State<FollowingPage> {
FollowingKeepAliveTab(
child: FollowingFavoritesGrid(
controller: widget.favoriteController,
history: _history,
selection: FollowingFavoriteSelection(
editing: _editing,
selected: _selected,
@@ -135,6 +154,9 @@ class _FollowingPageState extends State<FollowingPage> {
),
scrollController: _favoriteScroll,
onGoHome: widget.onGoHome,
onContinueRecord: (record) => unawaited(
_openHistory(context, _history, record),
),
),
),
FollowingKeepAliveTab(
@@ -165,119 +187,165 @@ class _FollowingPageState extends State<FollowingPage> {
}
Widget _header(AppLocalizations l10n) {
return SizedBox(
return Padding(
key: const Key('following-header'),
height: AppDimens.followingHeaderHeight,
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: AppDimens.feedPageHorizontal,
),
child: ValueListenableBuilder<FollowingTab>(
valueListenable: _tab,
builder: (context, selectedTab, _) {
return ValueListenableBuilder<bool>(
valueListenable: _editing,
builder: (context, editing, _) {
padding: const EdgeInsets.fromLTRB(
AppDimens.feedPageHorizontal,
AppDimens.followingTitleTopGap,
AppDimens.feedPageHorizontal,
0,
),
child: Column(
children: [
SizedBox(
height: AppDimens.followingTitleRowHeight,
child: Row(
children: [
Expanded(
child: Text(
l10n.followingTab,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: const TextStyle(
color: AppColors.textPrimary,
fontSize: AppDimens.followingTitleFont,
fontWeight: FontWeight.w400,
height: 1.0,
),
),
),
_searchButton(l10n),
const SizedBox(width: AppDimens.followingHeaderActionGap),
_manageButton(l10n),
],
),
),
SizedBox(
height: AppDimens.followingSegmentRowHeight,
child: ValueListenableBuilder<FollowingTab>(
valueListenable: _tab,
builder: (context, selectedTab, _) {
return Row(
children: [
Expanded(
child: Row(
children: [
Flexible(
fit: FlexFit.loose,
child: _tabButton(
FollowingTab.favorites,
l10n.followingTab,
'favorites',
selectedTab == FollowingTab.favorites,
),
ListenableBuilder(
listenable: widget.favoriteController,
builder: (context, _) {
return _segment(
FollowingTab.favorites,
Text(
'${l10n.myFavorites} ${widget.favoriteController.total}',
maxLines: 1,
),
const SizedBox(width: AppDimens.followingTabGap),
Flexible(
fit: FlexFit.loose,
child: _tabButton(
FollowingTab.history,
l10n.watchHistory,
'history',
selectedTab == FollowingTab.history,
),
),
],
),
'favorites',
selectedTab == FollowingTab.favorites,
);
},
),
const SizedBox(width: AppDimens.followingSegmentGap),
_segment(
FollowingTab.history,
Text(l10n.watchHistory, maxLines: 1),
'history',
selectedTab == FollowingTab.history,
),
if (editing)
InkWell(
key: const Key('following-edit'),
onTap: _toggleEditing,
child: Padding(
padding: const EdgeInsets.only(left: _doneTextGap),
child: Text(
l10n.done,
style: const TextStyle(
color: AppColors.textPrimary,
fontSize: _doneFontSize,
fontWeight: FontWeight.w500,
),
),
),
)
else
Semantics(
button: true,
label: l10n.edit,
child: SizedBox(
width: AppDimens.followingEditHitSize,
height: AppDimens.followingEditHitSize,
child: InkWell(
key: const Key('following-edit'),
onTap: _toggleEditing,
child: const Align(
alignment: Alignment.centerRight,
child: Icon(
Icons.edit_outlined,
size: AppDimens.followingEditIconSize,
color: AppColors.textTabInactive,
),
),
),
),
),
],
);
},
);
},
),
),
],
),
);
}
Widget _searchButton(AppLocalizations l10n) {
return Semantics(
button: true,
label: l10n.search,
child: InkWell(
key: const Key('following-search'),
borderRadius: BorderRadius.circular(8),
onTap: () {
Navigator.of(context).push<void>(
MaterialPageRoute(builder: (_) => const SearchPage()),
);
},
child: Padding(
padding: EdgeInsets.all(4),
child: SearchGlyph(
size: AppDimens.followingSearchIcon,
color: AppColors.textPrimary,
),
),
),
);
}
Widget _tabButton(
Widget _manageButton(AppLocalizations l10n) {
return ValueListenableBuilder<bool>(
valueListenable: _editing,
builder: (context, editing, _) {
return InkWell(
key: const Key('following-edit'),
borderRadius: BorderRadius.circular(8),
onTap: _toggleEditing,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 2, vertical: 8),
child: Text(
editing ? l10n.done : l10n.manage,
style: const TextStyle(
color: AppColors.textPrimary,
fontSize: AppDimens.followingManageFont,
fontWeight: FontWeight.w400,
height: 1.0,
),
),
),
);
},
);
}
Widget _segment(
FollowingTab tab,
String label,
Widget label,
String keyName,
bool selected,
) {
return InkWell(
key: Key('following-tab-$keyName'),
onTap: () => _selectTab(tab),
child: SizedBox(
height: AppDimens.followingHeaderHeight,
child: Align(
alignment: Alignment.centerLeft,
widthFactor: 1,
child: AnimatedDefaultTextStyle(
borderRadius: BorderRadius.circular(8),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
AnimatedDefaultTextStyle(
duration: AppDimens.followingTabAnimationDuration,
style: TextStyle(
color: selected
? AppColors.textPrimary
: AppColors.textTabInactive,
fontSize: AppDimens.followingTabFont,
fontWeight: selected ? FontWeight.w600 : FontWeight.w400,
fontSize: AppDimens.followingSegmentFont,
fontWeight: FontWeight.w400,
),
child: Text(label, maxLines: 1, overflow: TextOverflow.ellipsis),
child: label,
),
),
const SizedBox(height: AppDimens.followingSegmentIndicatorTopGap),
AnimatedContainer(
duration: AppDimens.followingTabAnimationDuration,
curve: Curves.easeOut,
width: selected
? AppDimens.followingSegmentIndicatorWidth
: 0,
height: AppDimens.followingSegmentIndicatorHeight,
decoration: BoxDecoration(
color: AppColors.brandRed,
borderRadius: BorderRadius.circular(
AppDimens.followingSegmentIndicatorRadius,
),
),
),
],
),
);
}
@@ -329,10 +397,7 @@ class _FollowingPageState extends State<FollowingPage> {
Future<void> _cancelSelected() async {
final ids = _selected.value.toList();
if (ids.isEmpty || !mounted || !await confirmCancelFollowing(context)) {
return;
}
if (!mounted) return;
if (ids.isEmpty || !mounted) return;
final removed = await widget.favoriteController.removeMany(ids);
if (!removed || !mounted) return;
_selected.value = {};
@@ -424,8 +489,7 @@ class _HistoryList extends StatelessWidget {
onTap: openRecord,
onContinue: openRecord,
onRemove: () async {
if (await confirmHistoryRemove(context) &&
await controller.remove(record.dramaId) &&
if (await controller.remove(record.dramaId) &&
controller.records.isEmpty) {
onListEmptied();
}
@@ -28,6 +28,7 @@ class FollowingPagedGrid extends StatelessWidget {
this.singleColumn = false,
this.errorMessage,
this.loadMoreError,
this.topSlivers = const [],
});
static const double _loadMoreThreshold = 240;
@@ -44,6 +45,10 @@ class FollowingPagedGrid extends StatelessWidget {
final String? loadMoreError;
final bool showInitialLoading;
final bool singleColumn;
/// 列表顶部的非分页内容(继续观看横幅、区块标题等)。
/// 必须是 sliver;空列表时也会保留,因此可携带空态上方的固定区块。
final List<Widget> topSlivers;
final Future<void> Function() onRefresh;
final Future<void> Function() onLoadMore;
@@ -81,6 +86,7 @@ class FollowingPagedGrid extends StatelessWidget {
controller: scrollController,
physics: AppPullToRefresh.physics,
slivers: [
...topSlivers,
if (itemCount == 0)
SliverFillRemaining(
hasScrollBody: false,
@@ -0,0 +1,207 @@
// Author: fruit.com.cn
import 'package:flutter/material.dart';
import '../../../core/data/models/watch_record.dart';
import '../../../core/theme/app_colors.dart';
import '../../../core/theme/app_dimens.dart';
import '../../../core/widgets/remote_image.dart';
import '../../../l10n/app_localizations.dart';
/// 追剧页「继续观看」大横幅:取最近一条观看记录,点击续播。
class ContinueWatchingBanner extends StatelessWidget {
const ContinueWatchingBanner({
super.key,
required this.record,
required this.languageCode,
required this.onTap,
});
final WatchRecord record;
final String languageCode;
final VoidCallback onTap;
@override
Widget build(BuildContext context) {
final l10n = AppLocalizations.of(context)!;
final episode = record.episodeNumber;
final total =
record.progress.totalEpisodes ?? record.drama?.episodeCount ?? 0;
final title = record.localizedDisplayTitle(languageCode);
final showMeta = episode > 0 && total > 0;
return SizedBox(
height: AppDimens.followingBannerHeight,
child: ClipRRect(
borderRadius:
BorderRadius.circular(AppDimens.followingBannerRadius),
child: Stack(
fit: StackFit.expand,
children: [
RemoteImage(
record.displayCover,
fit: BoxFit.cover,
showFallbackIcon: true,
fallbackColor: AppColors.contentSurface,
),
const DecoratedBox(
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.centerLeft,
end: Alignment.centerRight,
colors: [
Color(0xCC000000),
Color(0x99000000),
Color(0x00000000),
],
stops: [0, 0.45, 1],
),
),
),
Material(
type: MaterialType.transparency,
child: InkWell(
key: const Key('following-continue-banner'),
onTap: onTap,
child: Padding(
padding: const EdgeInsets.all(
AppDimens.followingBannerInnerGap,
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
if (title.isNotEmpty)
Text(
title,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: const TextStyle(
color: AppColors.bannerTitleWarm,
fontSize:
AppDimens.followingBannerTitleFont,
fontWeight: FontWeight.w400,
),
),
if (showMeta) ...[
const SizedBox(
height: AppDimens.followingBannerMetaGap,
),
Text(
l10n.continueWatchingSubtitle(episode, total),
maxLines: 1,
style: const TextStyle(
color: Color(0xB3F5EFE4),
fontSize:
AppDimens.followingBannerSubtitleFont,
),
),
],
const SizedBox(
height: AppDimens.followingBannerButtonTopGap,
),
_ContinueButton(label: l10n.continueWatching),
],
),
),
const SizedBox(height: 10),
SizedBox(
width: double.infinity,
child: _ProgressBar(fraction: record.progress.fraction),
),
],
),
),
),
),
],
),
),
);
}
}
class _ContinueButton extends StatelessWidget {
const _ContinueButton({required this.label});
final String label;
@override
Widget build(BuildContext context) {
return DecoratedBox(
decoration: BoxDecoration(
color: AppColors.brandRed,
borderRadius: BorderRadius.circular(
AppDimens.followingBannerButtonRadius,
),
),
child: SizedBox(
height: AppDimens.followingBannerButtonHeight,
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal:
AppDimens.followingBannerButtonHorizontalPadding,
),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
const Icon(
Icons.play_arrow_rounded,
size: AppDimens.followingBannerButtonIcon,
color: AppColors.onPrimary,
),
const SizedBox(width: AppDimens.followingBannerButtonGap),
Text(
label,
style: const TextStyle(
color: AppColors.onPrimary,
fontSize: AppDimens.followingBannerButtonFont,
fontWeight: FontWeight.w400,
),
),
],
),
),
),
);
}
}
class _ProgressBar extends StatelessWidget {
const _ProgressBar({required this.fraction});
final double fraction;
@override
Widget build(BuildContext context) {
// SizedBox 给紧约束让 DecoratedBox 轨道撑满整宽;
// 不能用无子 ColoredBox 直接放 Stack(会缩成 0×0 隐形)。
return ClipRRect(
borderRadius: BorderRadius.circular(
AppDimens.followingBannerProgressHeight,
),
child: SizedBox(
height: AppDimens.followingBannerProgressHeight,
width: double.infinity,
child: DecoratedBox(
decoration: const BoxDecoration(
color: Color(0x66FFFFFF),
),
child: Align(
alignment: Alignment.centerLeft,
child: FractionallySizedBox(
widthFactor: fraction.clamp(0.0, 1.0).toDouble(),
// 无 child 的 ColoredBox 在松约束下会缩成 0×0,高度必须显式占满。
heightFactor: 1.0,
child: const ColoredBox(color: AppColors.brandRed),
),
),
),
),
);
}
}
+15 -42
View File
@@ -12,7 +12,6 @@ import '../../core/data/services/home_feed_controller.dart';
import '../../core/data/services/catalog_controller.dart';
import '../../core/data/services/category_controller.dart';
import '../../core/data/services/favorite_controller.dart';
import '../../core/data/services/wallet_controller.dart';
import '../../core/platform/haptics.dart';
import '../../core/theme/app_colors.dart';
import '../../core/theme/app_theme.dart';
@@ -20,16 +19,13 @@ import '../../core/widgets/auth_gate.dart';
import '../../core/widgets/app_root_tab.dart';
import '../discover/search_page.dart';
import '../following/following_page.dart';
import '../filter/filter_page.dart';
import '../mine/mine_types.dart';
import '../recommend/recommend_page.dart';
import '../recommend/recommend_discover_page.dart';
import '../mine/mine_view.dart';
import '../store/vip_page.dart';
import '../wallet/wallet_page.dart';
import 'home_binding.dart';
import 'home_logic.dart';
import 'widgets/home_feed_grid.dart';
import 'widgets/home_grid_header.dart';
class HomePage extends StatefulWidget {
const HomePage({super.key});
@@ -147,7 +143,7 @@ class _HomeTabsState extends State<_HomeTabs> {
}
Widget _scaffold(BuildContext context) {
final mediaTab = logic.tab == 0 || logic.tab == 1;
// 各 tab 均自绘背景(媒体 tab 纯黑,追剧/我的带顶部红光晕),无需外层渐变。
final content = PopScope(
canPop: false,
onPopInvokedWithResult: (didPop, _) {
@@ -164,24 +160,19 @@ class _HomeTabsState extends State<_HomeTabs> {
);
return AnnotatedRegion<SystemUiOverlayStyle>(
value: SystemUiOverlayStyle.light,
child: mediaTab
? content
: DecoratedBox(
key: const Key('home-page-gradient'),
decoration: const BoxDecoration(gradient: AppTheme.pageGradient),
child: content,
),
child: content,
);
}
Widget _body(BuildContext context) {
final pages = <Widget>[
_homeGrid(context),
_recommend(context),
_recommendDiscover(context),
FollowingPage(
onGoHome: () => logic.select(0),
favoriteController: context.read<FavoriteController>(),
historyRequest: logic.followingHistoryRequest,
visible: logic.tab == 2,
),
_my(context),
];
@@ -194,27 +185,23 @@ class _HomeTabsState extends State<_HomeTabs> {
);
}
Widget _homeGrid(BuildContext context) {
return HomeFeedGrid(
feedController: widget.feedController,
callbacks: HomeGridCallbacks(
onSearch: () => _openSearch(context),
onOpenVip: () => unawaited(_openVip(context)),
onOpenWallet: () => unawaited(_openWallet(context)),
onOpenFilter: () => _pushPage(context, const FilterPage()),
),
onOpenDrama: (drama) => unawaited(logic.playDrama(context, drama)),
);
}
Widget _recommend(BuildContext context) {
return RecommendPage(
feedController: widget.feedController,
catalogApi: _catalogApi(context),
active: logic.tab == 1,
active: logic.tab == 0,
videoOnly: logic.videoImmersive,
onImmersiveChanged: logic.onImmersiveChanged,
onSearch: () => _openSearch(context),
onOpenWallet: () => unawaited(_openWallet(context)),
);
}
Widget _recommendDiscover(BuildContext context) {
return RecommendDiscoverPage(
active: logic.tab == 1,
onSearch: () => _openSearch(context),
onOpenWallet: () => unawaited(_openWallet(context)),
);
}
@@ -232,20 +219,6 @@ class _HomeTabsState extends State<_HomeTabs> {
).push<void>(MaterialPageRoute(builder: (_) => const SearchPage()));
}
void _pushPage(BuildContext context, Widget page) {
Navigator.of(context).push<void>(MaterialPageRoute(builder: (_) => page));
}
Future<void> _openVip(BuildContext context) async {
if (!await ensureSignedIn(context) || !context.mounted) return;
final wallet = context.read<WalletController>();
await Navigator.of(context).push<void>(
MaterialPageRoute(
builder: (_) => VipPage(onPurchased: () => unawaited(wallet.load())),
),
);
}
Future<void> _openWallet(BuildContext context) async {
if (!await ensureSignedIn(context) || !context.mounted) return;
await Navigator.of(
+1 -1
View File
@@ -50,7 +50,7 @@ class HomeFeedCard extends StatelessWidget {
overflow: TextOverflow.ellipsis,
textAlign: TextAlign.left,
style: const TextStyle(
color: AppColors.navSelected,
color: AppColors.textPrimary,
fontSize: AppDimens.cardTitleFont,
fontWeight: FontWeight.w500,
height: AppDimens.cardTitleLineHeight,
@@ -3,6 +3,7 @@
import 'package:flutter/material.dart';
import '../../../core/data/models/interaction.dart';
import '../../../core/widgets/app_glow_panel.dart';
import '../../../l10n/app_localizations.dart';
const int _maxDescriptionLength = 300;
@@ -67,9 +68,9 @@ class _ReportDialogState extends State<_ReportDialog> {
@override
Widget build(BuildContext context) {
final l10n = AppLocalizations.of(context)!;
return AlertDialog(
title: Text(widget.title),
content: SingleChildScrollView(
return AppGlowDialog(
title: widget.title,
contentChild: SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
+84 -146
View File
@@ -6,39 +6,33 @@ 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/watch_progress.dart';
import '../../core/data/repositories/watch_history_repository.dart';
import '../../core/data/services/auth_controller.dart';
import '../../core/data/services/catalog_controller.dart';
import '../../core/data/services/favorite_controller.dart';
import '../../core/data/services/locale_controller.dart';
import '../../core/data/services/wallet_controller.dart';
import '../../core/theme/app_colors.dart';
import '../../core/theme/app_dimens.dart';
import '../../core/theme/app_theme.dart';
import '../../core/widgets/app_glow_panel.dart';
import '../../core/widgets/app_root_tab.dart';
import '../../core/widgets/auth_gate.dart';
import '../../core/widgets/plain_page_scaffold.dart';
import '../../l10n/app_localizations.dart';
import '../downloads/downloads_page.dart';
import '../account/account_profile_page.dart';
import '../favorites/favorites_page.dart';
import '../filter/filter_page.dart';
import '../notices/notices_page.dart';
import '../player/open_player.dart';
import '../settings/settings_page.dart';
import '../store/vip_page.dart';
import '../wallet/wallet_page.dart';
import '../watch_records/watch_records_page.dart';
import 'about_page.dart';
import 'mine_binding.dart';
import 'mine_logic.dart';
import 'mine_types.dart';
import 'widgets/mine_continue_watching.dart';
import 'widgets/mine_header.dart';
import 'widgets/mine_menu.dart';
import 'widgets/mine_more_services.dart';
import 'widgets/mine_stats_panel.dart';
/// K28-B 我的页。
class MyPage extends StatefulWidget {
@@ -136,41 +130,27 @@ class _MyPageState extends State<MyPage> {
Widget _page(BuildContext context) {
final content = DecoratedBox(
key: const Key('mine-page-surface'),
// 与追剧页同款:纯黑底 + 顶部暗红光晕。
decoration: const BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [
AppColors.mineGradientTop,
AppColors.mineGradientMiddle,
AppColors.mineGradientBottom,
AppColors.followingGlow,
AppColors.followingGlowMid,
AppColors.appBackground,
],
stops: [0, 0.4, 0.75],
stops: [0, 0.14, 0.3],
),
),
child: Stack(
fit: StackFit.expand,
children: [
const DecoratedBox(
key: Key('mine-page-glow'),
decoration: BoxDecoration(
gradient: RadialGradient(
center: Alignment(0, -0.95),
radius: 0.9,
colors: [AppColors.mineGradientGlow, AppColors.transparent],
),
),
),
SafeArea(
bottom: false,
child: Column(
children: [
Expanded(child: _body(context)),
if (!embedded) _bottomNav(),
],
),
),
],
child: SafeArea(
bottom: false,
child: Column(
children: [
Expanded(child: _body(context)),
if (!embedded) _bottomNav(),
],
),
),
);
return AnnotatedRegion<SystemUiOverlayStyle>(
@@ -185,22 +165,7 @@ class _MyPageState extends State<MyPage> {
}
Widget _body(BuildContext context) {
final auth = context.watch<AuthController>();
final favorites = context.watch<FavoriteController>();
final wallet = context.watch<WalletController>();
final continueWatching = logic.recent.take(10).toList(growable: false);
final followingCount =
favorites.error == null && !(favorites.loading && favorites.total == 0)
? favorites.total
: null;
final watchRecordCount =
logic.recentError == null &&
!(logic.recentLoading && logic.watchRecordTotal == null)
? logic.watchRecordTotal
: null;
final coinBalance = auth.isSignedIn && wallet.snapshot != null
? wallet.balance
: null;
final l10n = AppLocalizations.of(context)!;
return ListView(
key: const Key('mine-page-scroll'),
padding: const EdgeInsets.only(bottom: AppDimens.spaceXl),
@@ -214,6 +179,7 @@ class _MyPageState extends State<MyPage> {
onEdit: () => _push(const AccountProfilePage()),
),
),
const SizedBox(height: AppDimens.spaceMd),
Padding(
padding: const EdgeInsets.symmetric(
horizontal: AppDimens.pageHorizontal,
@@ -222,23 +188,16 @@ class _MyPageState extends State<MyPage> {
onOpen: () => _openDestination(MineDestination.vip),
),
),
if (continueWatching.isNotEmpty) ...[
const SizedBox(height: AppDimens.mineSectionGap),
MineContinueWatching(
records: continueWatching,
onOpenRecord: _openContinueRecord,
onOpenAll: _openHistoryTab,
),
],
const SizedBox(height: AppDimens.mineSectionGap),
Padding(
padding: const EdgeInsets.symmetric(
horizontal: AppDimens.mineGridHorizontal,
horizontal: AppDimens.pageHorizontal,
),
child: MineStatsPanel(
followingCount: followingCount,
watchRecordCount: watchRecordCount,
coinBalance: coinBalance,
child: MineQuickActions(
onWallet: () => _openDestination(MineDestination.wallet),
onFavorites: () => _push(const FavoritesPage()),
onDownloads: () => _openDestination(MineDestination.downloads),
onHistory: () => _openDestination(MineDestination.history),
),
),
const SizedBox(height: AppDimens.mineSectionGap),
@@ -246,25 +205,40 @@ class _MyPageState extends State<MyPage> {
padding: const EdgeInsets.symmetric(
horizontal: AppDimens.mineGridHorizontal,
),
child: MineMenuList(
onOpen: _openDestination,
onLanguage: _openLanguage,
),
),
const SizedBox(height: AppDimens.mineSectionGap),
Padding(
padding: const EdgeInsets.symmetric(
horizontal: AppDimens.mineGridHorizontal,
),
child: MineMoreServices(
onCommonQuestions: _pushPlaceholder,
onAbout: () => _push(const MineAboutPage()),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
l10n.moreServices,
style: const TextStyle(
color: AppColors.textTertiary,
fontSize: AppDimens.mineSectionTitle,
),
),
const SizedBox(height: AppDimens.spaceSm),
MineServiceList(
onOpen: _openDestination,
onLanguage: _openLanguage,
languageName: _languageName(context),
),
],
),
),
],
);
}
/// 语言设置行右侧展示的当前语言名。
String _languageName(BuildContext context) {
final l10n = AppLocalizations.of(context)!;
final code = context.read<LocaleController>().locale?.languageCode;
return switch (code) {
'en' => l10n.english,
'id' => l10n.bahasaIndonesia,
_ => l10n.simplifiedChinese,
};
}
void _openDestination(MineDestination destination) {
switch (destination) {
case MineDestination.history:
@@ -290,45 +264,6 @@ class _MyPageState extends State<MyPage> {
unawaited(openAuthPage(context));
}
void _openHistoryTab() {
final callback = widget.callbacks.onOpenHistoryTab;
if (callback != null) {
callback();
return;
}
unawaited(_openHistoryPage());
}
/// 继续观看卡片:补齐剧集后直接进全屏播放页,播放器自己会定位到记录的秒数。
Future<void> _openContinueRecord(WatchProgress record) async {
final catalog = context.read<CatalogController>();
// 续看记录只有剧的概要信息,先拼一个占位对象让目录去取完整详情
final summary = Drama(
id: record.dramaId,
title: record.dramaTitle ?? '',
synopsis: '',
posterUrl: record.dramaCover ?? '',
);
Drama drama;
try {
drama = await catalog.requireDetail(summary);
} catch (_) {
if (!mounted) return;
final l10n = AppLocalizations.of(context)!;
ScaffoldMessenger.of(
context,
).showSnackBar(SnackBar(content: Text(l10n.detailLoadFailed)));
return;
}
if (!mounted) return;
await playDramaFromCatalog(
context,
drama,
episodeId: record.episodeId.isEmpty ? null : record.episodeId,
);
if (mounted) unawaited(logic.refreshRecent());
}
Future<void> _openHistoryPage() async {
await _push(const WatchRecordsPage());
if (mounted) unawaited(logic.refreshRecent());
@@ -341,7 +276,25 @@ class _MyPageState extends State<MyPage> {
}
void _pushPlaceholder() {
unawaited(_push(const _MinePlaceholderPage()));
final l10n = AppLocalizations.of(context)!;
unawaited(
_push(
PlainPageScaffold(
pageKey: const Key('mine-placeholder-page'),
backKey: const Key('mine-placeholder-back'),
title: l10n.contactSupport,
child: Center(
child: Text(
l10n.comingSoon,
style: const TextStyle(
color: AppColors.textSecondary,
fontSize: AppDimens.body,
),
),
),
),
),
);
}
Future<void> _openProtected(Widget page) async {
@@ -410,14 +363,16 @@ class _LanguageSheet extends StatelessWidget {
(const Locale('en'), const Key('mine-language-en'), l10n.english),
(const Locale('id'), const Key('mine-language-id'), l10n.bahasaIndonesia),
];
return Material(
key: const Key('mine-language-sheet'),
color: AppColors.contentCard,
return AppGlowPanel(
borderRadius: const BorderRadius.vertical(
top: Radius.circular(AppDimens.mineCardRadius),
),
clipBehavior: Clip.antiAlias,
child: SafeArea(
border: false,
child: Material(
key: const Key('mine-language-sheet'),
type: MaterialType.transparency,
clipBehavior: Clip.antiAlias,
child: SafeArea(
top: false,
child: Padding(
padding: const EdgeInsets.fromLTRB(20, 14, 20, 20),
@@ -440,7 +395,13 @@ class _LanguageSheet extends StatelessWidget {
IconButton(
tooltip: l10n.close,
onPressed: () => Navigator.pop(context),
icon: const Icon(Icons.close_rounded),
visualDensity: VisualDensity.compact,
padding: EdgeInsets.zero,
constraints: const BoxConstraints(
minWidth: 32,
minHeight: 32,
),
icon: const Icon(Icons.close_rounded, size: 20),
),
],
),
@@ -461,29 +422,6 @@ class _LanguageSheet extends StatelessWidget {
),
),
),
);
}
}
class _MinePlaceholderPage extends StatelessWidget {
const _MinePlaceholderPage();
@override
Widget build(BuildContext context) {
final l10n = AppLocalizations.of(context)!;
final title = l10n.helpFeedback;
return PlainPageScaffold(
pageKey: const Key('mine-placeholder-page'),
backKey: const Key('mine-placeholder-back'),
title: title,
child: Center(
child: Text(
l10n.comingSoon,
style: const TextStyle(
color: AppColors.textSecondary,
fontSize: AppDimens.body,
),
),
),
);
}
+31 -20
View File
@@ -1,6 +1,7 @@
// Author: fruit.com.cn
import 'dart:async';
import 'dart:ui' as ui;
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
@@ -13,8 +14,7 @@ import '../../../core/widgets/centered_toast.dart';
import '../../../core/widgets/remote_image.dart';
import '../../../l10n/app_localizations.dart';
const double _buttonHeight = 34;
const double _buttonRadius = 6;
const double _buttonHeight = 40;
/// 「我的」页用户区。
class MineHeader extends StatelessWidget {
@@ -35,7 +35,7 @@ class MineHeader extends StatelessWidget {
final uid = signedIn ? user?.uid.trim() ?? '' : '';
return Padding(
key: const Key('mine-user-row'),
padding: const EdgeInsets.symmetric(vertical: AppDimens.spaceMd),
padding: const EdgeInsets.symmetric(vertical: AppDimens.spaceSm),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
@@ -55,7 +55,7 @@ class MineHeader extends StatelessWidget {
fontFamily: 'Outfit',
color: AppColors.textPrimary,
fontSize: AppDimens.mineUserName,
fontWeight: FontWeight.w700,
fontWeight: FontWeight.w400,
height: AppDimens.mineUserNameLineHeight,
),
),
@@ -121,18 +121,29 @@ class MineHeader extends StatelessWidget {
key: const Key('mine-avatar'),
width: AppDimens.mineAvatar,
height: AppDimens.mineAvatar,
decoration: const BoxDecoration(
color: AppColors.contentSurface,
decoration: BoxDecoration(
shape: BoxShape.circle,
border: Border.all(
color: AppColors.textTertiary,
width: 1.2,
),
),
child: ClipOval(
child: BackdropFilter(
filter: ui.ImageFilter.blur(sigmaX: 10, sigmaY: 10),
child: Container(
color: AppColors.textPrimary.withValues(alpha: 0.06),
alignment: Alignment.center,
child: path.isEmpty
? const Icon(
Icons.person_outline_rounded,
color: AppColors.textPrimary,
size: 30,
)
: RemoteImage(path, fit: BoxFit.cover),
),
),
),
clipBehavior: Clip.antiAlias,
child: path.isEmpty
? const Icon(
Icons.person_rounded,
color: AppColors.textPrimary,
size: 28,
)
: RemoteImage(path, fit: BoxFit.cover),
);
}
@@ -141,20 +152,20 @@ class MineHeader extends StatelessWidget {
required String label,
required VoidCallback onTap,
}) {
return OutlinedButton(
return TextButton(
key: key,
onPressed: onTap,
style: OutlinedButton.styleFrom(
style: TextButton.styleFrom(
minimumSize: const Size(0, _buttonHeight),
padding: const EdgeInsets.symmetric(horizontal: AppDimens.spaceMd),
foregroundColor: AppColors.textPrimary,
side: const BorderSide(color: AppColors.mineOutline),
backgroundColor: AppColors.brandRed,
foregroundColor: AppColors.onPrimary,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(_buttonRadius),
borderRadius: BorderRadius.circular(_buttonHeight / 2),
),
textStyle: const TextStyle(
fontSize: AppDimens.body,
fontWeight: FontWeight.w500,
fontWeight: FontWeight.w400,
),
),
child: Row(
+307 -215
View File
@@ -7,11 +7,9 @@ import '../../../core/theme/app_dimens.dart';
import '../../../l10n/app_localizations.dart';
import '../mine_types.dart';
const double _vipRadius = 12;
const double _vipBadgeSize = 36;
const double _vipButtonHeight = 34;
const double _vipRadius = 14;
/// 金色会员横幅。
/// 「我的」页金色 VIP 卡:品牌行 + 立即开通 + 2×2 权益宫格。
class MineVipBanner extends StatelessWidget {
const MineVipBanner({super.key, required this.onOpen});
@@ -24,7 +22,9 @@ class MineVipBanner extends StatelessWidget {
key: const Key('mine-vip'),
decoration: BoxDecoration(
gradient: const LinearGradient(
colors: [AppColors.vipGoldStart, AppColors.vipGoldEnd],
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: [AppColors.vipCardStart, AppColors.vipCardEnd],
),
borderRadius: BorderRadius.circular(_vipRadius),
),
@@ -35,69 +35,89 @@ class MineVipBanner extends StatelessWidget {
child: InkWell(
onTap: onOpen,
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: AppDimens.cardPadding,
vertical: AppDimens.spaceMd,
padding: const EdgeInsets.fromLTRB(
AppDimens.cardPadding,
AppDimens.spaceSm + 2,
AppDimens.cardPadding,
AppDimens.spaceSm + 2,
),
child: Row(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
width: _vipBadgeSize,
height: _vipBadgeSize,
decoration: const BoxDecoration(
color: AppColors.vipBadgeSurface,
shape: BoxShape.circle,
),
child: const Icon(
Icons.workspace_premium_rounded,
color: AppColors.onGold,
size: 22,
),
),
const SizedBox(width: AppDimens.spaceMd),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
Row(
children: [
const Icon(
Icons.diamond_outlined,
color: AppColors.onGold,
size: 24,
),
const SizedBox(width: AppDimens.spaceSm),
Expanded(
child: Text(
l10n.vipBrandName,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: const TextStyle(
color: AppColors.onGold,
fontSize: AppDimens.sectionTitle,
fontWeight: FontWeight.w700,
fontSize: 18,
fontWeight: FontWeight.w400,
),
),
const SizedBox(height: 2),
Text(
l10n.mineVipSubtitle,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: const TextStyle(
color: AppColors.onGold,
fontSize: AppDimens.caption,
),
),
],
),
const SizedBox(width: AppDimens.spaceSm),
_openButton(l10n),
],
),
Transform.translate(
offset: const Offset(0, -7),
child: Text(
l10n.mineVipSubtitle,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: AppColors.onGold.withValues(alpha: 0.7),
fontSize: AppDimens.caption,
),
),
),
const SizedBox(width: AppDimens.spaceSm),
TextButton(
key: const Key('mine-vip-open'),
onPressed: onOpen,
style: TextButton.styleFrom(
minimumSize: const Size(0, _vipButtonHeight),
padding: const EdgeInsets.symmetric(
horizontal: AppDimens.spaceMd,
const SizedBox(height: AppDimens.mineVipBenefitRowGap),
Container(
height: 1,
color: AppColors.onGold.withValues(alpha: 0.15),
),
const SizedBox(height: AppDimens.mineVipBenefitRowGap),
Table(
defaultColumnWidth: const FlexColumnWidth(),
children: [
TableRow(
children: [
_benefit(
key: const Key('mine-vip-benefit-0'),
icon: Icons.play_circle_outline_rounded,
label: l10n.vipBenefitFree,
),
_benefit(
key: const Key('mine-vip-benefit-1'),
icon: Icons.ads_click_rounded,
label: l10n.vipBenefitNoAds,
),
],
),
backgroundColor: AppColors.onGold,
foregroundColor: AppColors.textPrimary,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(_vipButtonHeight),
TableRow(
children: [
_benefit(
key: const Key('mine-vip-benefit-2'),
icon: Icons.hd_outlined,
label: l10n.vipBenefitHd,
),
_benefit(
key: const Key('mine-vip-benefit-3'),
icon: Icons.download_for_offline_outlined,
label: l10n.vipBenefitFastCache,
),
],
),
),
child: Text(l10n.joinVip),
],
),
],
),
@@ -106,184 +126,256 @@ class MineVipBanner extends StatelessWidget {
),
);
}
Widget _openButton(AppLocalizations l10n) {
return TextButton(
key: const Key('mine-vip-open'),
onPressed: onOpen,
style: TextButton.styleFrom(
minimumSize: const Size(0, AppDimens.mineVipButtonHeight),
padding: const EdgeInsets.symmetric(horizontal: AppDimens.spaceMd),
backgroundColor: AppColors.onGold,
foregroundColor: AppColors.vipGoldStart,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(
AppDimens.mineVipButtonHeight / 2,
),
),
textStyle: const TextStyle(
fontSize: AppDimens.body,
fontWeight: FontWeight.w400,
),
),
child: Text(l10n.vipOpenNow),
);
}
Widget _benefit({required Key key, required IconData icon, required String label}) {
return Padding(
key: key,
padding: const EdgeInsets.symmetric(vertical: AppDimens.mineVipBenefitRowGap),
child: Row(
children: [
Container(
width: AppDimens.mineVipBenefitBox,
height: AppDimens.mineVipBenefitBox,
decoration: BoxDecoration(
border: Border.all(
color: AppColors.onGold.withValues(alpha: 0.6),
width: 1.2,
),
borderRadius: BorderRadius.circular(
AppDimens.mineVipBenefitBoxRadius,
),
),
child: Icon(
icon,
color: AppColors.onGold,
size: AppDimens.mineVipBenefitGlyph,
),
),
const SizedBox(width: AppDimens.spaceSm),
Expanded(
child: Text(
label,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: const TextStyle(
color: AppColors.onGold,
fontSize: AppDimens.mineVipBenefitFont,
),
),
),
],
),
);
}
}
/// 「我的」页 4 列功能入口。
class MineMenuList extends StatelessWidget {
const MineMenuList({
/// 快捷图标行:钱包 / 我的收藏 / 离线缓存 / 播放历史(设计稿的「奖励」暂不做)。
class MineQuickActions extends StatelessWidget {
const MineQuickActions({
super.key,
required this.onOpen,
required this.onLanguage,
required this.onWallet,
required this.onFavorites,
required this.onDownloads,
required this.onHistory,
});
final ValueChanged<MineDestination> onOpen;
final VoidCallback onLanguage;
final VoidCallback onWallet;
final VoidCallback onFavorites;
final VoidCallback onDownloads;
final VoidCallback onHistory;
@override
Widget build(BuildContext context) {
final l10n = AppLocalizations.of(context)!;
return Container(
key: const Key('mine-menu'),
decoration: BoxDecoration(
color: AppColors.mineGridSurface,
borderRadius: BorderRadius.circular(AppDimens.mineGridRadius),
),
child: Material(
color: AppColors.transparent,
borderRadius: BorderRadius.circular(AppDimens.mineGridRadius),
clipBehavior: Clip.antiAlias,
child: Table(
key: const Key('mine-menu-grid'),
defaultColumnWidth: const FlexColumnWidth(),
defaultVerticalAlignment: TableCellVerticalAlignment.middle,
border: const TableBorder(
horizontalInside: BorderSide(
color: AppColors.mineGridDivider,
width: AppDimens.mineGridDividerWidth,
),
verticalInside: BorderSide(
color: AppColors.mineGridDivider,
width: AppDimens.mineGridDividerWidth,
),
return Row(
children: [
_action(
key: const Key('mine-wallet'),
icon: Icons.wallet_outlined,
label: l10n.wallet,
onTap: onWallet,
),
_action(
key: const Key('mine-favorites'),
icon: Icons.star_border_rounded,
label: l10n.myFavorites,
onTap: onFavorites,
),
_action(
key: const Key('mine-downloads'),
icon: Icons.download_outlined,
label: l10n.offlineDownloads,
onTap: onDownloads,
),
_action(
key: const Key('mine-history'),
icon: Icons.history_rounded,
label: l10n.watchHistory,
onTap: onHistory,
),
],
);
}
Widget _action({
required Key key,
required IconData icon,
required String label,
required VoidCallback onTap,
}) {
return Expanded(
child: InkWell(
key: key,
onTap: onTap,
borderRadius: BorderRadius.circular(10),
child: Padding(
padding: const EdgeInsets.symmetric(vertical: AppDimens.spaceSm),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Icon(icon, color: AppColors.textPrimary, size: AppDimens.mineQuickActionIcon),
const SizedBox(height: AppDimens.mineQuickActionGap),
Text(
label,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: const TextStyle(
color: AppColors.textPrimary,
fontSize: AppDimens.mineQuickActionLabelFont,
),
),
],
),
),
),
);
}
}
/// 「更多服务」列表行:白图标 + 标题 + 可选值 + chevron,行间细分隔线。
class MineServiceList extends StatelessWidget {
const MineServiceList({
super.key,
required this.onOpen,
required this.onLanguage,
required this.languageName,
});
final ValueChanged<MineDestination> onOpen;
final VoidCallback onLanguage;
final String languageName;
@override
Widget build(BuildContext context) {
final l10n = AppLocalizations.of(context)!;
final rows = <Widget>[
_row(
key: const Key('mine-help'),
icon: Icons.headset_outlined,
label: l10n.contactSupport,
onTap: () => onOpen(MineDestination.help),
),
_divider(),
_row(
key: const Key('mine-language'),
icon: Icons.language_rounded,
label: l10n.language,
value: languageName,
onTap: onLanguage,
),
_divider(),
_row(
key: const Key('mine-settings'),
icon: Icons.settings_outlined,
label: l10n.settings,
onTap: () => onOpen(MineDestination.settings),
),
_divider(),
_row(
key: const Key('mine-notices'),
icon: Icons.notifications_none_rounded,
label: l10n.notices,
onTap: () => onOpen(MineDestination.notices),
),
];
return Column(key: const Key('mine-menu'), children: rows);
}
Widget _divider() => const Divider(
height: AppDimens.mineGridDividerWidth,
thickness: AppDimens.mineGridDividerWidth,
color: AppColors.contentBorder,
);
Widget _row({
required Key key,
required IconData icon,
required String label,
String? value,
required VoidCallback onTap,
}) {
return SizedBox(
height: AppDimens.mineServiceRowHeight,
child: InkWell(
key: key,
onTap: onTap,
child: Row(
children: [
TableRow(
children: [
_cell(
index: 0,
actionKey: const Key('mine-wallet'),
icon: Icons.account_balance_wallet_outlined,
iconColor: AppColors.mineIconWallet,
label: l10n.wallet,
onTap: () => onOpen(MineDestination.wallet),
Icon(icon, color: AppColors.textPrimary, size: AppDimens.mineServiceIcon),
const SizedBox(width: AppDimens.spaceMd),
Expanded(
child: Text(
label,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: const TextStyle(
color: AppColors.textPrimary,
fontSize: AppDimens.mineServiceTitleFont,
),
_cell(
index: 1,
actionKey: const Key('mine-downloads'),
icon: Icons.download_outlined,
iconColor: AppColors.mineIconDownloads,
label: l10n.offlineDownloads,
onTap: () => onOpen(MineDestination.downloads),
),
_cell(
index: 2,
actionKey: const Key('mine-history'),
icon: Icons.history_rounded,
iconColor: AppColors.mineIconHistory,
label: l10n.watchHistory,
onTap: () => onOpen(MineDestination.history),
),
_cell(
index: 3,
actionKey: const Key('mine-watch-preferences'),
icon: Icons.tune_rounded,
iconColor: AppColors.mineIconPreferences,
label: l10n.watchPreferences,
onTap: () => onOpen(MineDestination.preferences),
),
],
),
),
TableRow(
children: [
_cell(
index: 4,
actionKey: const Key('mine-help'),
icon: Icons.support_agent_rounded,
iconColor: AppColors.mineIconSupport,
label: l10n.contactSupport,
onTap: () => onOpen(MineDestination.help),
if (value != null && value.isNotEmpty) ...[
const SizedBox(width: AppDimens.spaceSm),
Text(
value,
style: const TextStyle(
color: AppColors.textTertiary,
fontSize: AppDimens.mineServiceValueFont,
),
_cell(
index: 5,
actionKey: const Key('mine-language'),
icon: Icons.language_rounded,
iconColor: AppColors.mineIconLanguage,
label: l10n.language,
onTap: onLanguage,
),
_cell(
index: 6,
actionKey: const Key('mine-settings'),
icon: Icons.settings_outlined,
iconColor: AppColors.mineIconSettings,
label: l10n.settings,
onTap: () => onOpen(MineDestination.settings),
),
_cell(
index: 7,
actionKey: const Key('mine-notices'),
icon: Icons.notifications_none_rounded,
iconColor: AppColors.mineIconNotices,
label: l10n.notices,
onTap: () => onOpen(MineDestination.notices),
),
],
),
],
const SizedBox(width: AppDimens.spaceXs),
const Icon(
Icons.chevron_right_rounded,
color: AppColors.textSecondary,
size: 22,
),
],
),
),
);
}
Widget _cell({
required int index,
Key? actionKey,
IconData? icon,
Color? iconColor,
String? label,
VoidCallback? onTap,
}) {
return SizedBox(
key: Key('mine-menu-cell-$index'),
height: AppDimens.mineGridCellHeight,
child: actionKey == null
? const SizedBox.shrink()
: InkWell(
key: actionKey,
onTap: onTap,
child: Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Container(
width: AppDimens.mineGridIconSurface,
height: AppDimens.mineGridIconSurface,
decoration: const BoxDecoration(
color: AppColors.mineGridIconSurface,
shape: BoxShape.circle,
),
child: DecoratedBox(
decoration: BoxDecoration(
color: iconColor?.withValues(alpha: 0.08),
shape: BoxShape.circle,
),
child: Icon(
icon,
color: iconColor,
size: AppDimens.mineGridIcon,
),
),
),
const SizedBox(height: AppDimens.spaceXs + 2),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 4),
child: Text(
label ?? '',
maxLines: 1,
overflow: TextOverflow.ellipsis,
textAlign: TextAlign.center,
style: const TextStyle(
color: AppColors.mineGridLabel,
fontSize: AppDimens.mineGridLabel,
fontWeight: FontWeight.w500,
height: 1.2,
),
),
),
],
),
),
),
);
}
}
@@ -1,93 +0,0 @@
// Author: fruit.com.cn
import 'package:flutter/material.dart';
import '../../../core/theme/app_colors.dart';
import '../../../core/theme/app_dimens.dart';
import '../../../l10n/app_localizations.dart';
class MineMoreServices extends StatelessWidget {
const MineMoreServices({
super.key,
required this.onCommonQuestions,
required this.onAbout,
});
final VoidCallback onCommonQuestions;
final VoidCallback onAbout;
@override
Widget build(BuildContext context) {
final l10n = AppLocalizations.of(context)!;
return Container(
key: const Key('mine-more-services'),
decoration: BoxDecoration(
color: AppColors.minePanelSurface,
borderRadius: BorderRadius.circular(AppDimens.mineGridRadius),
),
clipBehavior: Clip.antiAlias,
child: Column(
children: [
_row(
key: const Key('mine-common-questions'),
label: l10n.commonQuestions,
onTap: onCommonQuestions,
),
const Divider(
height: AppDimens.mineGridDividerWidth,
thickness: AppDimens.mineGridDividerWidth,
color: AppColors.mineMoreDivider,
),
_row(
key: const Key('mine-about'),
label: l10n.aboutUs,
onTap: onAbout,
),
],
),
);
}
Widget _row({
required Key key,
required String label,
required VoidCallback onTap,
}) {
return Material(
color: AppColors.transparent,
child: InkWell(
key: key,
onTap: onTap,
child: SizedBox(
height: AppDimens.mineMoreRowHeight,
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: AppDimens.minePanelPadding,
),
child: Row(
children: [
Expanded(
child: Text(
label,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: const TextStyle(
color: AppColors.textPrimary,
fontSize: AppDimens.mineMoreFont,
fontWeight: FontWeight.w400,
),
),
),
const Icon(
Icons.chevron_right_rounded,
color: AppColors.textSecondary,
size: 18,
),
],
),
),
),
),
);
}
}
+12 -2
View File
@@ -10,7 +10,6 @@ import '../../core/data/models/drama.dart';
import '../../core/data/services/catalog_controller.dart';
import '../../core/formatting/count_format.dart';
import '../../core/theme/app_colors.dart';
import '../../core/theme/app_theme.dart';
import '../../core/widgets/app_pull_to_refresh.dart';
import '../../core/widgets/paged_local_list.dart';
import '../../core/widgets/remote_image.dart';
@@ -108,7 +107,18 @@ class _NewReleasesPageState extends State<NewReleasesPage> {
key: const Key('new-releases-page'),
backgroundColor: AppColors.ink,
body: DecoratedBox(
decoration: const BoxDecoration(gradient: AppTheme.pageGradient),
decoration: const BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [
AppColors.followingGlow,
AppColors.followingGlowMid,
AppColors.appBackground,
],
stops: [0, 0.14, 0.3],
),
),
child: SafeArea(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
+4 -3
View File
@@ -13,6 +13,7 @@ import '../../core/formatting/localized_date_time.dart';
import '../../core/theme/app_colors.dart';
import '../../core/theme/app_dimens.dart';
import '../../core/theme/app_theme.dart';
import '../../core/widgets/app_glow_panel.dart';
import '../../core/widgets/app_pull_to_refresh.dart';
import '../../core/widgets/empty_state.dart';
import '../../core/widgets/plain_page_scaffold.dart';
@@ -191,9 +192,9 @@ class _NoticesPageState extends State<NoticesPage> {
: formatLocalizedDateTime(context, notice.publishAt!);
return showDialog<void>(
context: context,
builder: (dialogContext) => AlertDialog(
title: Text(notice.title),
content: SizedBox(
builder: (dialogContext) => AppGlowDialog(
title: notice.title,
contentChild: SizedBox(
width: double.maxFinite,
child: SingleChildScrollView(
child: Column(
+437 -13
View File
@@ -1,12 +1,16 @@
// Author: fruit.com.cn
import 'dart:async';
import 'dart:io' show Platform;
import 'package:flutter/foundation.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:flutter/material.dart';
import 'package:video_player/video_player.dart';
import 'package:flutter/scheduler.dart';
import 'package:provider/provider.dart';
import 'package:floating/floating.dart';
import 'package:permission_handler/permission_handler.dart';
import '../../core/data/models/drama.dart';
import '../../core/data/models/episode_stats.dart';
@@ -44,6 +48,16 @@ typedef _PlaybackSnapshot = ({
});
class PlayerLogic extends ChangeNotifier {
/// Android PiP 管理器(floating 插件);负责退后台自动进小窗。
static final Floating _floating = Floating();
/// 挂了自动小窗的播放器实例(引用计数):沉浸流与独立播放页可能
/// 同时在树上,只有全部不需要时才真正注销 OnLeavePiP。
static final Set<PlayerLogic> _pipOwners = <PlayerLogic>{};
/// OnLeavePiP 当前在原生侧的挂载状态(进程级,与 [_pipOwners] 对应)。
static bool _pipNativeArmed = false;
PlayerLogic({
required this.history,
required this.playback,
@@ -112,7 +126,56 @@ class PlayerLogic extends ChangeNotifier {
VideoPlayerPort? scrubbingPlayer;
bool pip = false;
bool pipPreparing = false;
final Map<String, int> pickedEpisode = {};
bool _wasPlayingBeforeIosPip = false;
Timer? _pipStartTimer;
/// iOS 自动小窗开关(对齐红果:开启后退 App 自动进入画中画)。
static const _iosAutoPipPrefKey = 'player.ios.autoEnterPip';
bool iosAutoPipEnabled = false;
/// 播放页前台活跃标志:沉浸流切走 tab / 独立页关闭后置 false,
/// 此时退后台不再自动拉起画中画(影子只同步不拉起)。
bool pipPageActive = false;
/// 由播放视图同步活跃标志;离开播放页时撤销影子的自动小窗资格,
/// 重新进入时重建影子待命(切走期间视图可能被卸载、逻辑实例已换新)。
void setPipPageActive(bool active) {
debugPrint('pip: page-active -> $active');
if (pipPageActive == active) return;
pipPageActive = active;
if (!active && iosDevice) {
unawaited(pictureInPicture.disarmAutoEnter());
return;
}
if (active && iosDevice && iosAutoPipEnabled && !pip) {
final episode = trackedEpisode;
if (episode != null) {
debugPrint('pip: page re-entered, ensure shadow standby');
unawaited(_ensureIosShadowStandby(episode));
}
}
}
/// 画中画还原信号:自增通知视频表面回退占位重新等首帧(防回前台黑屏)。
int pipResumeToken = 0;
/// 画中画还原过渡期:为 true 时播放区盖当前集封面,等纹理出帧后淡出,
/// 盖住回前台瞬间的黑纹理帧。700ms 后自动复位。
bool pipRecovering = false;
Timer? _pipRecoverTimer;
/// iOS 影子播放器当前承载的集 id(全局单例状态);用于避免重复换源。
static String? iosShadowEpisodeId;
/// 当前设备是否为 iOS 真机环境(面板据此显示自动小窗开关)。
bool get iosDevice => !kIsWeb && Platform.isIOS;
/// PiP 状态是全局单通道回调,须广播给所有存活的 PlayerLogic:
/// 推荐页每页一个 logic,若只保留最后一次注册的 handler,
/// 相邻预加载页会盖掉正在播放页的注册,导致小窗 UI 不隐藏且无声音。
static final Set<PlayerLogic> _pipSubscribers = <PlayerLogic>{};
/// 「记住上次选集」:dramaId → 集号。只在用户从选集面板主动挑集时写入
/// (见 [_recordPickedEpisode]),feed 里同一部剧据此显示上次选中的集。
static final Map<String, int> pickedEpisode = {};
final Set<String> _unlockedEpisodeIds = {};
final Map<String, EpisodeStats> _episodeStats = {};
final Map<String, DateTime> _episodeStatsFetchedAt = {};
@@ -214,7 +277,10 @@ class PlayerLogic extends ChangeNotifier {
_started = true;
_sessionFactory = factory;
_sessionCoordinator = coordinator;
pictureInPicture.setStateListener(onPipChanged);
_pipSubscribers.add(this);
pictureInPicture.setStateListener(_dispatchPipChanged);
pictureInPicture.setPlaybackEndedListener(_dispatchPipPlaybackEnded);
unawaited(_loadIosAutoPipPref());
queue = feedDramas == null
? PlaybackQueue.series(pageDrama)
: PlaybackQueue.home(feedDramas!);
@@ -850,6 +916,11 @@ class PlayerLogic extends ChangeNotifier {
if (pip || pipPreparing) {
pip = false;
pipPreparing = false;
if (iosDevice) {
// 部分回前台路径不回调 didStop:销毁影子、seek 刷纹理并恢复播放,
// 否则停在 PiP 期间的暂停态表现为黑屏;自动小窗开着则重建待命。
unawaited(_recoverFromIosPipFallback());
}
notify();
notifyImmersive();
}
@@ -873,6 +944,33 @@ class PlayerLogic extends ChangeNotifier {
state == AppLifecycleState.resumed || pip || pipPreparing,
);
if (state != AppLifecycleState.resumed) cancelScrub();
// iOS 自动小窗:退后台瞬间把影子对齐到当前进度起播,系统据此自动进画中画;
// 回前台取消待命。手动小窗的恢复由 onPipChanged(false) 处理。
if (iosDevice && iosAutoPipEnabled && !pip) {
final video = session.active is VideoPlayerPort
? session.active as VideoPlayerPort
: null;
if (state == AppLifecycleState.inactive) {
debugPrint(
'pip: inactive gate pageActive=$pipPageActive '
'video=${video != null} userWantsPlay=${session.userWantsPlay}',
);
}
if (state == AppLifecycleState.inactive &&
pipPageActive &&
video != null &&
session.userWantsPlay) {
debugPrint('pip: lifecycle inactive -> arm auto enter');
unawaited(
pictureInPicture.armAutoEnter(
video.controller.value.position.inMilliseconds,
),
);
} else if (state == AppLifecycleState.resumed) {
debugPrint('pip: lifecycle resumed -> disarm auto enter');
unawaited(pictureInPicture.disarmAutoEnter());
}
}
}
Future<void> _refreshTicketThenResume(
@@ -904,7 +1002,13 @@ class PlayerLogic extends ChangeNotifier {
void dispose() {
if (_disposed) return;
_disposed = true;
pictureInPicture.setStateListener(null);
_pipSubscribers.remove(this);
_pipStartTimer?.cancel();
if (_pipSubscribers.isEmpty) {
pictureInPicture.setStateListener(null);
pictureInPicture.setPlaybackEndedListener(null);
}
unawaited(syncPipAutoArm(false));
unawaited(saveCurrentProgress());
_detachTrackedPlayerListener();
if (_started) {
@@ -918,31 +1022,117 @@ class PlayerLogic extends ChangeNotifier {
void notifyImmersive() => onImmersiveChanged?.call(chromeHidden);
/// 按 [want] 挂/摘退后台自动小窗(引用计数):
/// - 沉浸流:随所在 tab 的激活状态调用(active 时挂,切走时摘);
/// - 独立播放页:进入时挂、销毁时摘;
/// - 权限未授权时静默跳过(申请统一在首次点「画中画」时,见 [enterPip])。
Future<void> syncPipAutoArm(bool want) async {
if (!pictureInPicture.isPlatformSupported) return;
// iOS 无「退后台自动小窗」(系统不开放 Activity 级自动进入),走手动入口。
if (!kIsWeb && Platform.isIOS) return;
try {
if (want) {
_pipOwners.add(this);
} else {
_pipOwners.remove(this);
}
final arm = _pipOwners.isNotEmpty;
if (arm == _pipNativeArmed) return;
if (arm) {
if (!await _floating.isPipAvailable) return;
if (!await Permission.systemAlertWindow.isGranted) return;
await _floating.enable(const OnLeavePiP(aspectRatio: Rational(9, 16)));
_pipNativeArmed = true;
} else {
_pipNativeArmed = false;
await _floating.cancelOnLeavePiP();
}
} catch (_) {
// 自动小窗挂载失败不影响正常播放。
}
}
Future<void> enterPip(BuildContext context) async {
if (pip || pipPreparing) return;
if (session.active is! VideoPlayerPort) {
if (pip || pipPreparing) {
debugPrint('pip: tap ignored (pip=$pip preparing=$pipPreparing)');
return;
}
final isIos = !kIsWeb && Platform.isIOS;
debugPrint('pip: tap platform=${isIos ? "ios" : "android"}');
final activeVideo = session.active is VideoPlayerPort
? session.active as VideoPlayerPort
: null;
if (activeVideo == null) {
debugPrint('pip: no active video port');
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text(AppLocalizations.of(context)!.pipUnavailable)),
);
return;
}
// 首次点击「画中画」:申请「显示在其他应用上层」权限(特殊权限,
// 会跳系统设置页);拒绝则视为设备无法使用画中画。仅 Android 需要。
if (!isIos && pictureInPicture.isPlatformSupported) {
try {
if (!await Permission.systemAlertWindow.isGranted) {
await Permission.systemAlertWindow.request();
}
if (await Permission.systemAlertWindow.isGranted) {
_pipOwners.add(this);
if (!_pipNativeArmed && await _floating.isPipAvailable) {
await _floating.enable(
const OnLeavePiP(aspectRatio: Rational(9, 16)),
);
_pipNativeArmed = true;
}
} else {
if (!context.mounted) return;
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(AppLocalizations.of(context)!.pipUnavailable),
),
);
return;
}
} catch (_) {
// 权限流程异常时按原有流程继续尝试直接进入。
}
}
pipPreparing = true;
notify();
notifyImmersive();
await WidgetsBinding.instance.endOfFrame;
final url = VideoPlayerPort.resolveUri(
sessionEpisodes[session.currentIndex],
).toString();
final positionMs = activeVideo.controller.value.position.inMilliseconds;
debugPrint('pip: invoke enter pos=$positionMs');
bool entered = false;
try {
entered = await pictureInPicture.enter();
} catch (_) {
entered = await pictureInPicture.enter(url: url, positionMs: positionMs);
} catch (e) {
debugPrint('pip: enter threw $e');
// Android reports unavailable for devices without PiP support.
}
debugPrint('pip: entered=$entered');
if (!context.mounted) return;
if (entered) {
pip = true;
pipPreparing = false;
notify();
notifyImmersive();
session.setAppResumed(true);
if (isIos) {
// iOS 等影子流就绪后自动进入小窗(原生 pendingStart 兜底不会过期);
// 超时仅复位按钮状态,避免长时间卡在「准备中」。
_pipStartTimer?.cancel();
_pipStartTimer = Timer(const Duration(seconds: 6), () {
if (!isMounted() || pip || !pipPreparing) return;
pipPreparing = false;
notify();
notifyImmersive();
});
} else {
pip = true;
pipPreparing = false;
notify();
notifyImmersive();
session.setAppResumed(true);
}
} else {
pipPreparing = false;
notify();
@@ -953,10 +1143,28 @@ class PlayerLogic extends ChangeNotifier {
}
}
void onPipChanged(bool enabled) {
static void _dispatchPipChanged(bool enabled, int finalPositionMs) {
for (final logic in List.of(_pipSubscribers)) {
logic.onPipChanged(enabled, finalPositionMs: finalPositionMs);
}
}
static void _dispatchPipPlaybackEnded() {
for (final logic in List.of(_pipSubscribers)) {
logic._handleIosPipPlaybackEnded();
}
}
void onPipChanged(bool enabled, {int finalPositionMs = 0}) {
if (!isMounted()) return;
if (!kIsWeb && Platform.isIOS) {
_onIosPipChanged(enabled, finalPositionMs);
return;
}
pip = enabled;
pipPreparing = false;
_pipStartTimer?.cancel();
_pipStartTimer = null;
notify();
notifyImmersive();
session.setAppResumed(
@@ -965,6 +1173,94 @@ class PlayerLogic extends ChangeNotifier {
);
}
/// iOS 影子接力:进入小窗后画面/声音交给原生影子播放器,
/// Flutter 播放器暂停(避免双声);退出时按影子进度 seek 对齐恢复。
void _onIosPipChanged(bool enabled, int finalPositionMs) {
final video = session.active is VideoPlayerPort
? session.active as VideoPlayerPort
: null;
pip = enabled;
pipPreparing = false;
_pipStartTimer?.cancel();
_pipStartTimer = null;
if (enabled) {
_wasPlayingBeforeIosPip = session.userWantsPlay;
session.setUserWantsPlay(false);
if (video != null) unawaited(video.pause());
unawaited(pictureInPicture.unmute());
session.setAppResumed(true);
} else {
unawaited(pictureInPicture.teardown());
PlayerLogic.iosShadowEpisodeId = null;
pipResumeToken++;
_beginPipRecover();
if (video != null) {
final target = finalPositionMs > 0
? clampResumePosition(
Duration(milliseconds: finalPositionMs),
video.controller.value.duration,
)
: video.controller.value.position;
// seek 同时兜住进度对齐与回前台纹理黑屏(强制 AVPlayer 重新出帧)。
unawaited(video.seekTo(target));
}
session.setUserWantsPlay(_wasPlayingBeforeIosPip);
session.setAppResumed(
WidgetsBinding.instance.lifecycleState == AppLifecycleState.resumed,
);
// 自动小窗开着时影子回待命,等待下次退后台。
if (iosAutoPipEnabled) {
final episode = trackedEpisode;
if (episode != null) unawaited(_ensureIosShadowStandby(episode));
}
}
notify();
notifyImmersive();
}
/// iOS 画中画里影子播完当前集:小窗内直接换下一集片源无缝连播(不翻页),
/// 同时用无动画跳页把 App 内位置同步到新集,还原后正好停在新集;
/// 没有下一集或下一集锁定时退出画中画回到 App。
Future<void> _handleIosPipPlaybackEnded() async {
if (!isMounted() || !pip || !(!kIsWeb && Platform.isIOS)) return;
final index = session.currentIndex;
final positionInVisible = visibleIndices.indexOf(index) + 1;
if (positionInVisible <= 0 || positionInVisible >= visibleIndices.length) {
await pictureInPicture.stop();
return;
}
final nextIndex = visibleIndices[positionInVisible];
if (nextIndex < 0 || nextIndex >= sessionEpisodes.length) {
await pictureInPicture.stop();
return;
}
if (isEpisodeLocked(sessionEpisodes[nextIndex])) {
await pictureInPicture.stop();
return;
}
final episode = sessionEpisodes[nextIndex];
debugPrint('pip: auto next episode=${episode.id}');
// 影子直接切下一集从头播,窗口不中断。
try {
await pictureInPicture.replaceItem(
url: VideoPlayerPort.resolveUri(episode).toString(),
positionMs: 0,
);
await pictureInPicture.unmute();
PlayerLogic.iosShadowEpisodeId = episode.id;
} catch (_) {
await pictureInPicture.stop();
return;
}
// 同步 App 内会话与页面位置(无动画),还原后停在当前连播到的集。
final controller = pages;
try {
if (controller.hasClients) controller.jumpToPage(positionInVisible);
} catch (_) {
// 页面可能已离树,影子连播不受影响。
}
}
Future<void> preparePlayer(Episode episode, PlayerPort player) async {
if (player is! VideoPlayerPort) return;
try {
@@ -1020,6 +1316,121 @@ class PlayerLogic extends ChangeNotifier {
_completionProgressSaved = false;
lastProgressWrite = DateTime.now();
player.controller.addListener(_handleTrackedPlayerChanged);
// iOS:小窗内换集则影子直切新片源继续播;自动小窗开启时影子换源保持待命。
// 影子已在该集(连播刚换过源)时跳过,避免重置回片头。
if (!kIsWeb && Platform.isIOS) {
if (pip) {
if (PlayerLogic.iosShadowEpisodeId != episode.id) {
unawaited(_syncIosShadowToEpisode(episode, playWhenPip: true));
}
} else if (iosAutoPipEnabled) {
unawaited(_ensureIosShadowStandby(episode));
}
}
}
Future<void> _syncIosShadowToEpisode(
Episode episode, {
required bool playWhenPip,
}) async {
debugPrint('pip: shadow sync episode=${episode.id} play=$playWhenPip');
try {
await pictureInPicture.replaceItem(
url: VideoPlayerPort.resolveUri(episode).toString(),
positionMs: 0,
);
PlayerLogic.iosShadowEpisodeId = episode.id;
if (playWhenPip) await pictureInPicture.unmute();
} catch (_) {
// 影子切换失败时保持小窗停在旧集末帧,不阻断 Flutter 侧换集。
}
}
/// 读取自动小窗开关;开启时影子待命由集激活钩子建立。
Future<void> _loadIosAutoPipPref() async {
if (!iosDevice) return;
try {
iosAutoPipEnabled =
await SharedPreferencesAsync().getBool(_iosAutoPipPrefKey) ?? false;
} catch (_) {
iosAutoPipEnabled = false;
}
}
/// 切换自动小窗开关(更多面板):开启即建影子待命,关闭即销毁。
Future<void> setIosAutoPip(bool enabled) async {
debugPrint('pip: auto-pip switch -> $enabled');
if (!iosDevice || iosAutoPipEnabled == enabled) return;
iosAutoPipEnabled = enabled;
try {
await SharedPreferencesAsync().setBool(_iosAutoPipPrefKey, enabled);
} catch (_) {
// 偏好写失败只影响下次启动的记忆,本次会话照常生效。
}
if (enabled) {
final index = session.currentIndex;
if (index >= 0 && index < sessionEpisodes.length) {
await _ensureIosShadowStandby(sessionEpisodes[index]);
}
} else {
await pictureInPicture.teardown();
PlayerLogic.iosShadowEpisodeId = null;
}
}
/// 还原过渡:盖封面直至视频真正出帧(onVideoVisible 时收起),兜底 900ms。
void _beginPipRecover() {
_pipRecoverTimer?.cancel();
pipRecovering = true;
_pipRecoverTimer = Timer(const Duration(milliseconds: 900), endPipRecover);
}
/// 视频首帧确认后立即收起还原封面(由播放视图回调)。
void endPipRecover() {
_pipRecoverTimer?.cancel();
if (pipRecovering) {
pipRecovering = false;
notify();
}
// 原生过渡层在还原动画开始时已盖上,这里等表面恢复后淡出。
unawaited(pictureInPicture.hideRestoreOverlay());
}
/// 回前台兜底恢复:销毁影子、seek 强制重新出帧并恢复播放,
/// 修复部分还原路径不回调 didStop 导致的黑屏 + 暂停。
Future<void> _recoverFromIosPipFallback() async {
pipResumeToken++;
_beginPipRecover();
await pictureInPicture.teardown();
PlayerLogic.iosShadowEpisodeId = null;
final video = session.active is VideoPlayerPort
? session.active as VideoPlayerPort
: null;
if (video != null) {
await video.seekTo(video.controller.value.position);
session.setUserWantsPlay(true);
}
session.setAppResumed(true);
final episode = trackedEpisode;
if (iosAutoPipEnabled && episode != null) {
await _ensureIosShadowStandby(episode);
}
}
/// 影子待命形态:静音暂停在片头,退后台时由系统自动切画中画。
Future<void> _ensureIosShadowStandby(Episode episode) async {
if (!iosDevice || pip) return;
try {
debugPrint('pip: prepare shadow standby (autoEnter)');
await pictureInPicture.prepareShadow(
url: VideoPlayerPort.resolveUri(episode).toString(),
positionMs: 0,
autoEnter: true,
);
PlayerLogic.iosShadowEpisodeId = episode.id;
} catch (e) {
debugPrint('pip: prepare standby failed: $e');
}
}
void _detachTrackedPlayerListener() {
@@ -1199,6 +1610,7 @@ class PlayerLogic extends ChangeNotifier {
_pendingSelectionIndex = null;
_pendingSelectionRevision = null;
await selectEpisode(index, revision: revision);
_recordPickedEpisode(index);
}
} finally {
_selectionDrain = null;
@@ -1211,6 +1623,18 @@ class PlayerLogic extends ChangeNotifier {
}
}
/// 记录用户从选集面板主动挑的集,供 feed 侧「记住上次选集」展示。
/// 只在切集确实落到该集时记录,避免快速连点时把没播过的集记成"上次选集"。
void _recordPickedEpisode(int index) {
if (!_started || _disposed || session.currentIndex != index) return;
if (index < 0 || index >= sessionEpisodes.length) return;
final episode = sessionEpisodes[index];
final dramaId = _dramaIdForEpisode(episode.id);
if (dramaId != null) {
pickedEpisode[dramaId] = episode.number;
}
}
Future<void> selectEpisode(
int index, {
int? revision,
+66
View File
@@ -200,6 +200,9 @@ class _PlayerPageState extends State<PlayerPage>
);
}
_pageController = logic.pages;
// 自动小窗:独立播放页进入即挂;沉浸流随所在 tab 的激活状态挂/摘。
unawaited(logic.syncPipAutoArm(widget.embedded ? widget.active : true));
logic.setPipPageActive(widget.embedded ? widget.active : true);
if (!widget.embedded &&
!logic.isEpisodeLocked(logic.session.currentEpisode)) {
_loadingVisible = true;
@@ -217,6 +220,11 @@ class _PlayerPageState extends State<PlayerPage>
void didUpdateWidget(covariant PlayerPage oldWidget) {
super.didUpdateWidget(oldWidget);
logic.attach(widget, isMounted: () => mounted);
// 沉浸流所在 tab 切换时同步自动小窗(激活挂、切走摘)。
if (widget.embedded && oldWidget.active != widget.active) {
unawaited(logic.syncPipAutoArm(widget.active));
logic.setPipPageActive(widget.active);
}
if (oldWidget.scrubCancelRequest != widget.scrubCancelRequest) {
_cancelFeedScrub();
}
@@ -327,6 +335,7 @@ class _PlayerPageState extends State<PlayerPage>
void dispose() {
WidgetsBinding.instance.removeObserver(this);
appRouteObserver.unsubscribe(this);
logic.setPipPageActive(false);
_heartOverlayController.dispose();
_spriteAxisService
..removeListener(_handleSpriteFrameChanged)
@@ -703,6 +712,13 @@ class _PlayerPageState extends State<PlayerPage>
onRefresh: _refreshHomeFeed,
child: pages,
);
// 进画中画时预加载当前集海报:还原过渡封面立即可显示,避免再黑一次。
if (logic.pip) {
final poster = logic.trackedEpisode?.posterUrl?.trim();
if (poster != null && poster.isNotEmpty) {
unawaited(precacheImage(NetworkImage(poster), context));
}
}
return Stack(
fit: StackFit.expand,
clipBehavior: Clip.none,
@@ -711,7 +727,13 @@ class _PlayerPageState extends State<PlayerPage>
pageController: _pageController,
slots: _renderSlots(indices),
onCurrentVideoVisible: _handleCurrentVideoVisible,
resumeSignal: logic.pipResumeToken,
),
if (logic.pipRecovering)
Positioned.fill(
key: const Key('player-pip-recover-cover'),
child: _PipRecoverCover(episode: logic.trackedEpisode),
),
if (!widget.embedded && !_loadingRemoved)
Center(
child: IgnorePointer(
@@ -804,6 +826,9 @@ class _PlayerPageState extends State<PlayerPage>
void _handleCurrentVideoVisible(int? index) {
if (!mounted || _loadingRemoved) return;
// 收起还原封面要放在 early-return 之前:恢复时集未变,
// _videoReadyIndex 已相等,只有这里能接到淡入完成的回调。
logic.endPipRecover();
final currentIndex = logic.session.currentIndex;
if (index == null ||
index != currentIndex ||
@@ -1200,6 +1225,7 @@ class _PlayerPageState extends State<PlayerPage>
unawaited(_presentFullPlayer(context, index));
},
onEpisodes: () => logic.showEpisodes(context),
onOpenSearch: widget.onSearch,
onMore: _openCurrentMore,
onScrubStart: videoReady
? () => logic.beginScrub(videoPort!)
@@ -1446,3 +1472,43 @@ class _PlayerPageState extends State<PlayerPage>
);
}
}
/// 画中画还原过渡封面:盖住回前台瞬间的黑纹理帧,视频出帧后由
/// [PlayerLogic.endPipRecover] 收起。背景用主题渐变,海报预加载命中前也有过渡观感。
class _PipRecoverCover extends StatelessWidget {
const _PipRecoverCover({required this.episode});
final Episode? episode;
@override
Widget build(BuildContext context) {
final poster = episode?.posterUrl?.trim();
final thumbnail = episode?.thumbnailsUrl?.trim();
final url = poster != null && poster.isNotEmpty
? poster
: (thumbnail != null && thumbnail.isNotEmpty ? thumbnail : null);
return DecoratedBox(
decoration: const BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [
AppColors.followingGlow,
AppColors.followingGlowMid,
Color(0xFF101012),
],
stops: [0, 0.22, 0.62],
),
),
child: url == null
? const SizedBox.shrink()
: Image.network(
url,
key: const Key('player-pip-recover-cover-image'),
fit: BoxFit.cover,
gaplessPlayback: true,
errorBuilder: (_, _, _) => const SizedBox.shrink(),
),
);
}
}
+6 -1
View File
@@ -37,9 +37,14 @@ extension _PlayerViewActions on _PlayerPageState {
onQualityChanged: (quality) => _switchQuality(context, l10n, quality),
onClear: _hideChrome,
onDownload: () => requestEpisodeDownload(context, episode.id),
onPip: logic.pictureInPicture.isPlatformSupported
// iOS 不显示手动「画中画」入口(走下方「退出后自动小窗」开关)。
onPip: logic.pictureInPicture.isPlatformSupported && !logic.iosDevice
? () => unawaited(logic.enterPip(context))
: null,
autoPipEnabled: logic.iosAutoPipEnabled,
onAutoPipChanged: logic.iosDevice
? (value) => unawaited(logic.setIosAutoPip(value))
: null,
),
),
);
@@ -14,6 +14,7 @@ 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/app_glow_panel.dart';
import '../../../core/widgets/empty_state.dart';
import '../../../l10n/app_localizations.dart';
import 'comment_composer_sheet.dart';
@@ -176,14 +177,14 @@ class _DramaCommentsSheetState extends State<DramaCommentsSheet> {
child: SizedBox(
key: const Key('comment-sheet-constraints'),
height: sheetHeight,
child: Container(
decoration: const BoxDecoration(
color: AppColors.card,
borderRadius: BorderRadius.vertical(
top: Radius.circular(_sheetRadius),
),
child: AppGlowPanel(
borderRadius: const BorderRadius.vertical(
top: Radius.circular(_sheetRadius),
),
child: SafeArea(
border: false,
child: Container(
decoration: const BoxDecoration(color: AppColors.transparent),
child: SafeArea(
top: false,
child: ListenableBuilder(
listenable: _controller,
@@ -193,6 +194,7 @@ class _DramaCommentsSheetState extends State<DramaCommentsSheet> {
child: _content(context),
);
},
),
),
),
),
@@ -238,7 +240,7 @@ class _DramaCommentsSheetState extends State<DramaCommentsSheet> {
style: const TextStyle(
color: AppColors.onSurface,
fontSize: 16,
fontWeight: FontWeight.w600,
fontWeight: FontWeight.w400,
),
),
Positioned(
@@ -7,6 +7,7 @@ import '../../../core/data/models/drama.dart';
import '../../../core/formatting/localized_content.dart';
import '../../../core/theme/app_colors.dart';
import '../../../core/theme/app_dimens.dart';
import '../../../core/widgets/app_glow_panel.dart';
import '../../../l10n/app_localizations.dart';
import 'episode_picker_cell.dart';
@@ -47,16 +48,16 @@ class EpisodePickerSheet extends StatelessWidget {
systemNavigationBarIconBrightness: Brightness.light,
systemNavigationBarContrastEnforced: false,
),
child: Container(
key: const Key('player-episodes-sheet'),
height: MediaQuery.sizeOf(context).height * _sheetHeightFactor,
decoration: const BoxDecoration(
color: AppColors.card,
borderRadius: BorderRadius.vertical(
top: Radius.circular(_sheetRadius),
),
child: AppGlowPanel(
borderRadius: const BorderRadius.vertical(
top: Radius.circular(_sheetRadius),
),
child: SafeArea(
border: false,
child: Container(
key: const Key('player-episodes-sheet'),
height: MediaQuery.sizeOf(context).height * _sheetHeightFactor,
decoration: const BoxDecoration(color: AppColors.transparent),
child: SafeArea(
top: false,
bottom: true,
child: Column(
@@ -139,6 +140,7 @@ class EpisodePickerSheet extends StatelessWidget {
],
),
),
),
),
);
}
+66 -38
View File
@@ -22,11 +22,13 @@ part 'home_feed_overlay_parts.dart';
const double _progressHeight = 2;
const double _progressHitHeight = 32;
const double _pageHorizontal = 14;
const double _railRight = 8;
const double _pageHorizontal = 20;
const double _railRight = 14;
const double _railGap = 12;
const double _bottomInfoInset = 32;
const double _railBottomOffset = 60;
// 观看条高 44;2pt 进度线视觉上沿距观看条顶约 7pt(线中心距进度条盒底 8)。
// 信息面板底边取 44+16=60,使简介↔进度线、进度线↔观看条两侧间距均为 7pt。
const double _bottomInfoInset = homeFeedWatchAllHeight + 16;
const double _railBottomOffset = 40;
const Duration _overlayFadeDuration = Duration(milliseconds: 120);
const List<Shadow> _boostTextShadows = [
Shadow(color: AppColors.shadow, blurRadius: 5, offset: Offset(0, 1)),
@@ -52,6 +54,7 @@ class HomeFeedOverlay extends StatefulWidget {
required this.onDetail,
required this.onOpenFullPlayer,
this.onEpisodes,
this.onOpenSearch,
required this.onTogglePlay,
required this.onBoostStart,
required this.onBoostEnd,
@@ -92,6 +95,9 @@ class HomeFeedOverlay extends StatefulWidget {
final VoidCallback onDetail;
final VoidCallback onOpenFullPlayer;
final VoidCallback? onEpisodes;
/// 底部热搜胶囊点击(降级版:跳搜索页)。
final VoidCallback? onOpenSearch;
final VoidCallback onTogglePlay;
final VoidCallback onBoostStart;
final VoidCallback onBoostEnd;
@@ -143,6 +149,60 @@ class _HomeFeedOverlayState extends State<HomeFeedOverlay> {
onInteractionEnd: widget.onBoostEnd,
),
),
Positioned(
left: 0,
right: 0,
bottom: homeFeedWatchAllHeight + 12,
child: AnimatedOpacity(
duration: _overlayFadeDuration,
opacity: widget.boosting ? 1 : 0,
child: IgnorePointer(
ignoring: !widget.boosting,
child: _boostHint(),
),
),
),
Positioned(
left: _pageHorizontal,
right: _pageHorizontal,
bottom: homeFeedWatchAllHeight,
child: _FeedProgressBar(
controller: widget.controller,
locked: widget.locked,
height: _progressHeight,
hitHeight: _progressHitHeight,
cancelScrubRequest: widget.cancelScrubRequest,
thumbnailService: widget.thumbnailService,
spriteAxisService: widget.spriteAxisService,
thumbnailsUrl: widget.episode.thumbnailsUrl,
episodeId: widget.episode.id,
suppressBufferLoading: widget.suppressBufferLoading,
onScrubStart: _startScrub,
onScrubEnd: _endScrub,
onSeek: widget.onSeek,
),
),
Positioned(
left: 0,
right: 0,
bottom: 0,
child: AnimatedOpacity(
duration: _overlayFadeDuration,
opacity: widget.visible && !_scrubbing && !widget.boosting
? 1
: 0,
child: IgnorePointer(
ignoring: !widget.visible || _scrubbing || widget.boosting,
child: HomeFeedWatchAllBar(
drama: widget.drama,
onTap: widget.onOpenFullPlayer,
),
),
),
),
// 信息面板放在最后(最上层):进度条 32px 触控盒向上伸进底部避让区,
// 若面板在前,简介/展开按钮底部的触控留白会被进度条吞掉点击。
// 视觉上避让条带为空,提层不改变观感。
Positioned(
left: _pageHorizontal,
right: _railRight,
@@ -170,39 +230,6 @@ class _HomeFeedOverlayState extends State<HomeFeedOverlay> {
),
),
),
Positioned(
left: 0,
right: 0,
bottom: 20,
child: AnimatedOpacity(
duration: _overlayFadeDuration,
opacity: widget.boosting ? 1 : 0,
child: IgnorePointer(
ignoring: !widget.boosting,
child: _boostHint(),
),
),
),
Positioned(
left: 0,
right: 0,
bottom: 0,
child: _FeedProgressBar(
controller: widget.controller,
locked: widget.locked,
height: _progressHeight,
hitHeight: _progressHitHeight,
cancelScrubRequest: widget.cancelScrubRequest,
thumbnailService: widget.thumbnailService,
spriteAxisService: widget.spriteAxisService,
thumbnailsUrl: widget.episode.thumbnailsUrl,
episodeId: widget.episode.id,
suppressBufferLoading: widget.suppressBufferLoading,
onScrubStart: _startScrub,
onScrubEnd: _endScrub,
onSeek: widget.onSeek,
),
),
],
),
);
@@ -273,7 +300,7 @@ class _HomeFeedOverlayState extends State<HomeFeedOverlay> {
onSave: widget.onSave,
onLike: widget.onLike,
onComments: widget.onComments,
onEpisodes: widget.onEpisodes ?? widget.onOpenFullPlayer,
onShare: widget.onShare,
);
}
@@ -283,6 +310,7 @@ class _HomeFeedOverlayState extends State<HomeFeedOverlay> {
episode: widget.episode,
onDetail: widget.onDetail,
onOpenFullPlayer: widget.onOpenFullPlayer,
onOpenSearch: widget.onOpenSearch,
);
}
}
@@ -6,7 +6,6 @@ const double _thumbSize = 6;
const double _thumbActiveSize = 14;
const double _trackActiveHeight = 6;
const double _lineCenterFromBottom = 8;
const Duration _trackResizeDuration = Duration(milliseconds: 120);
const double _timeBubbleWidth = 96;
const double _timeBubbleMargin = 12;
const Key _inactiveTrackKey = Key('home-feed-progress-inactive');
@@ -371,10 +370,8 @@ class _FeedProgressBarState extends State<_FeedProgressBar> {
children: [
Align(
alignment: Alignment.centerLeft,
child: AnimatedContainer(
child: Container(
key: const Key('home-feed-progress-track'),
duration: _trackResizeDuration,
curve: Curves.easeOut,
width: width,
height: trackHeight,
color: AppColors.border,
@@ -382,10 +379,8 @@ class _FeedProgressBarState extends State<_FeedProgressBar> {
),
Align(
alignment: Alignment.centerLeft,
child: AnimatedContainer(
child: Container(
key: const Key('home-feed-progress-played'),
duration: dragging ? Duration.zero : _trackResizeDuration,
curve: Curves.easeOut,
width: playedWidth,
height: trackHeight,
color: AppColors.blue,
@@ -401,10 +396,8 @@ class _FeedProgressBarState extends State<_FeedProgressBar> {
child: SizedBox.square(
dimension: _thumbActiveSize,
child: Center(
child: AnimatedContainer(
child: Container(
key: const Key('home-feed-progress-thumb'),
duration: _trackResizeDuration,
curve: Curves.easeOut,
width: size,
height: size,
decoration: const BoxDecoration(
@@ -1,8 +1,7 @@
// Author: fruit.com.cn
import 'dart:math' as math;
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import '../../../core/data/models/drama.dart';
import '../../../core/formatting/localized_content.dart';
@@ -11,15 +10,22 @@ import '../../../l10n/app_localizations.dart';
import '../../home/widgets/home_drama_classification.dart';
import 'interaction_rail.dart';
const double _seriesFont = 19;
const double _tagFont = 13;
const double _synopsisFont = 13;
const double _seriesFont = 17;
const double _tagFont = 12;
const double _synopsisFont = 14;
const double _watchAllHeight = 44;
const List<Shadow> _textShadows = [
Shadow(color: AppColors.shadow, blurRadius: 6, offset: Offset(0, 1)),
];
final RegExp _tagSplitter = RegExp(r'[,/、·]');
/// 通栏「观看完整剧集」半透明白底条高度,overlay 用它安排底部避让。
const double homeFeedWatchAllHeight = _watchAllHeight;
/// 播放量紧凑展示(跟随语言):zh 20万 / en 200K / id 200 rb。
String _compactViewers(int count, Locale locale) =>
NumberFormat.compact(locale: locale.languageCode).format(count);
class HomeFeedInfoPanel extends StatefulWidget {
const HomeFeedInfoPanel({
super.key,
@@ -27,6 +33,7 @@ class HomeFeedInfoPanel extends StatefulWidget {
required this.episode,
required this.onDetail,
required this.onOpenFullPlayer,
this.onOpenSearch,
});
final Drama drama;
@@ -34,6 +41,9 @@ class HomeFeedInfoPanel extends StatefulWidget {
final VoidCallback onDetail;
final VoidCallback onOpenFullPlayer;
/// 热搜胶囊点击;为空或播放量为 0 时不显示胶囊。
final VoidCallback? onOpenSearch;
@override
State<HomeFeedInfoPanel> createState() => _HomeFeedInfoPanelState();
}
@@ -48,9 +58,22 @@ class _HomeFeedInfoPanelState extends State<HomeFeedInfoPanel> {
final synopsis = localizedDramaSynopsis(l10n, widget.drama).trim();
final genres = _genreValues(Localizations.localeOf(context).languageCode);
return Column(
key: const Key('home-feed-info-panel'),
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
if (widget.onOpenSearch != null && widget.drama.viewCount > 0) ...[
_HotSearchPill(
label: l10n.feedWatchingCount(
_compactViewers(
widget.drama.viewCount,
Localizations.localeOf(context),
),
),
onTap: widget.onOpenSearch!,
),
const SizedBox(height: 8),
],
GestureDetector(
key: const Key('home-feed-series-name'),
behavior: HitTestBehavior.opaque,
@@ -67,221 +90,186 @@ class _HomeFeedInfoPanelState extends State<HomeFeedInfoPanel> {
style: const TextStyle(
color: AppColors.textPrimary,
fontSize: _seriesFont,
fontWeight: FontWeight.w600,
fontWeight: FontWeight.w400,
shadows: _textShadows,
),
),
),
const SizedBox(width: 4),
const SizedBox(width: 2),
const Icon(
Icons.chevron_right_rounded,
size: 20,
size: 18,
color: AppColors.textPrimary,
),
],
),
),
const SizedBox(height: 8),
const SizedBox(height: 6),
_tagMetaRow(l10n, genres),
if (synopsis.isNotEmpty) ...[
const SizedBox(height: 8),
_synopsis(l10n, synopsis),
],
const SizedBox(height: 12),
_watchAll(context, l10n),
],
);
}
Widget _tagMetaRow(AppLocalizations l10n, List<String> genres) {
return Row(
final chips = <Widget>[
if (isHotDrama(widget.drama))
_TagChip(
key: const Key('home-feed-hot-badge'),
label: l10n.homeBadgeHot,
filled: true,
),
for (final genre in genres)
_TagChip(key: Key('home-feed-tag-$genre'), label: genre),
];
return SizedBox(
key: const Key('home-feed-tags'),
children: [
if (isHotDrama(widget.drama)) ...[
Container(
key: const Key('home-feed-hot-badge'),
padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 2),
decoration: BoxDecoration(
color: AppColors.error,
borderRadius: BorderRadius.circular(3),
),
child: Text(
l10n.homeBadgeHot,
style: const TextStyle(
color: AppColors.textPrimary,
fontSize: 10,
fontWeight: FontWeight.w600,
),
),
),
const SizedBox(width: 8),
],
Flexible(
fit: FlexFit.loose,
child: Text(
genres.join(' '),
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: const TextStyle(
color: AppColors.overlayLabel,
fontSize: _tagFont,
),
),
),
const SizedBox(width: 8),
Flexible(
child: Text(
l10n.favoriteEpisodeProgress(
widget.episode.number,
widget.drama.episodeCount,
),
key: const Key('home-feed-episode-progress'),
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: const TextStyle(
color: AppColors.overlayLabel,
fontSize: _tagFont,
),
),
),
],
height: 22,
child: ListView.separated(
scrollDirection: Axis.horizontal,
physics: const BouncingScrollPhysics(),
shrinkWrap: true,
itemCount: chips.length,
separatorBuilder: (_, _) => const SizedBox(width: 6),
itemBuilder: (_, index) => chips[index],
),
);
}
Widget _synopsis(AppLocalizations l10n, String synopsis) {
const style = TextStyle(
color: AppColors.overlaySecondary,
final prefix = l10n.feedEpisodePrefix(widget.episode.number);
final baseStyle = const TextStyle(
color: AppColors.textPrimary,
fontSize: _synopsisFont,
height: 1.35,
height: 1.3,
shadows: _textShadows,
);
final span = TextSpan(
children: [
TextSpan(
text: prefix,
style: baseStyle,
),
TextSpan(
text: ' | ',
style: baseStyle.copyWith(
color: AppColors.textPrimary.withValues(alpha: 0.45),
fontSize: _synopsisFont - 2,
fontWeight: FontWeight.w400,
),
),
TextSpan(text: synopsis, style: baseStyle),
],
);
if (_synopsisExpanded) {
return _expandedSynopsis(span, baseStyle, l10n);
}
return LayoutBuilder(
builder: (context, constraints) {
final toggle = _synopsisToggle(
key: const Key('home-feed-synopsis-more'),
label: l10n.expandSynopsis,
padding: const EdgeInsets.only(left: 6),
);
final painter = TextPainter(
text: TextSpan(text: synopsis, style: style),
maxLines: 2,
text: span,
maxLines: 1,
textDirection: Directionality.of(context),
textScaler: MediaQuery.textScalerOf(context),
)..layout(maxWidth: constraints.maxWidth);
final overflows = painter.didExceedMaxLines;
if (!overflows) {
return Text(
synopsis,
if (!painter.didExceedMaxLines) {
return Text.rich(
span,
key: const Key('home-feed-synopsis'),
style: style,
maxLines: 1,
style: baseStyle,
);
}
if (_synopsisExpanded) {
return _expandedSynopsis(constraints.maxWidth, synopsis, style, l10n);
}
return Stack(
children: [
Padding(
padding: const EdgeInsets.only(right: 40),
child: Text(
synopsis,
key: const Key('home-feed-synopsis'),
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: style,
// 设计稿:单行省略号 + 行内固定「展开」。
// 整行可点:真机上不必精确命中两个小字,点简介任意位置都能展开。
return GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () => setState(() => _synopsisExpanded = true),
child: Row(
key: const Key('home-feed-synopsis-collapsed'),
// 顶对齐:文字位置不变,toggle 的 bottom 留白把触控区向下扩到空白处。
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: Text.rich(
span,
key: const Key('home-feed-synopsis'),
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: baseStyle,
),
),
),
Positioned(
right: 0,
bottom: 0,
child: _synopsisToggle(
key: const Key('home-feed-synopsis-more'),
label: l10n.expandSynopsis,
),
),
],
const SizedBox(width: 2),
toggle,
],
),
);
},
);
}
Widget _expandedSynopsis(
double maxWidth,
String synopsis,
InlineSpan span,
TextStyle style,
AppLocalizations l10n,
) {
return SizedBox(
width: maxWidth,
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Text(synopsis, key: const Key('home-feed-synopsis'), style: style),
Align(
alignment: Alignment.centerRight,
child: _synopsisToggle(
key: const Key('home-feed-synopsis-more'),
label: l10n.showLess,
),
// 「收起」内联在简介最后一行末尾,避免独占一行导致多行简介与进度条间
// 出现大片空白;垂直方向只留少量触控留白(仅撑高最后一行)。
final expandedSpan = TextSpan(
style: style,
children: [
span,
WidgetSpan(
alignment: PlaceholderAlignment.baseline,
baseline: TextBaseline.alphabetic,
child: _synopsisToggle(
key: const Key('home-feed-synopsis-more'),
label: l10n.showLess,
padding: const EdgeInsets.only(left: 8),
),
],
),
),
],
);
return Text.rich(
expandedSpan,
key: const Key('home-feed-synopsis-expanded'),
);
}
Widget _synopsisToggle({required Key key, required String label}) {
Widget _synopsisToggle({
required Key key,
required String label,
required EdgeInsets padding,
}) {
return GestureDetector(
key: key,
// opaque + 留白扩大命中区;留白方向由调用方决定,
// 展开态不能加 top padding,否则「收起」距简介正文过远。
behavior: HitTestBehavior.opaque,
onTap: () => setState(() => _synopsisExpanded = !_synopsisExpanded),
child: Text(
label,
style: const TextStyle(
color: AppColors.textPrimary,
fontSize: _synopsisFont,
fontWeight: FontWeight.w600,
child: Padding(
padding: padding,
child: Text(
label,
style: const TextStyle(
color: AppColors.textPrimary,
fontSize: _synopsisFont,
fontWeight: FontWeight.w600,
shadows: _textShadows,
),
),
),
);
}
Widget _watchAll(BuildContext context, AppLocalizations l10n) {
final screenWidth = MediaQuery.sizeOf(context).width;
return LayoutBuilder(
builder: (context, constraints) {
final buttonWidth = math.min(screenWidth * 0.7, constraints.maxWidth);
return Align(
alignment: Alignment.centerLeft,
child: SizedBox(
width: buttonWidth,
height: _watchAllHeight,
child: DecoratedBox(
key: const Key('home-feed-full-series-bg'),
decoration: BoxDecoration(
gradient: const LinearGradient(
colors: [AppColors.actionRed, AppColors.blue],
),
borderRadius: BorderRadius.circular(8),
),
child: Material(
color: AppColors.transparent,
child: InkWell(
key: const Key('home-feed-full-series'),
onTap: widget.onOpenFullPlayer,
borderRadius: BorderRadius.circular(8),
child: Center(
child: Text(
l10n.homeWatchAll,
style: const TextStyle(
color: AppColors.textPrimary,
fontSize: 15,
fontWeight: FontWeight.w600,
),
),
),
),
),
),
),
);
},
);
}
List<String> _genreValues(String languageCode) {
final localized = widget.drama.localizedTypeLabels(languageCode);
if (localized.isNotEmpty) return localized.take(3).toList(growable: false);
@@ -297,6 +285,147 @@ class _HomeFeedInfoPanelState extends State<HomeFeedInfoPanel> {
}
}
/// 热搜榜降级胶囊:🔍 共 xxx 人在看 ›(暂无榜单接口,点击跳搜索页)。
class _HotSearchPill extends StatelessWidget {
const _HotSearchPill({required this.label, required this.onTap});
final String label;
final VoidCallback onTap;
@override
Widget build(BuildContext context) {
return GestureDetector(
key: const Key('home-feed-hot-search-pill'),
behavior: HitTestBehavior.opaque,
onTap: onTap,
child: Container(
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 4),
decoration: BoxDecoration(
color: AppColors.textPrimary.withValues(alpha: 0.14),
borderRadius: BorderRadius.circular(6),
),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
const Icon(
Icons.search_rounded,
size: 15,
color: AppColors.textPrimary,
),
const SizedBox(width: 5),
Text(
label,
maxLines: 1,
style: const TextStyle(
color: AppColors.textPrimary,
fontSize: 14,
fontWeight: FontWeight.w500,
),
),
const SizedBox(width: 2),
const Icon(
Icons.chevron_right_rounded,
size: 16,
color: AppColors.textPrimary,
),
],
),
),
);
}
}
/// 热剧红胶囊 / 类型深色半透明填充胶囊。
class _TagChip extends StatelessWidget {
const _TagChip({super.key, required this.label, this.filled = false});
final String label;
final bool filled;
@override
Widget build(BuildContext context) {
return Container(
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 2),
alignment: Alignment.center,
decoration: BoxDecoration(
color: filled
? AppColors.brandRed
: AppColors.textPrimary.withValues(alpha: 0.2),
borderRadius: BorderRadius.circular(4),
),
child: Text(
label,
maxLines: 1,
style: const TextStyle(
color: AppColors.textPrimary,
fontSize: _tagFont,
fontWeight: FontWeight.w500,
height: 1.2,
shadows: _textShadows,
),
),
);
}
}
/// 底部通栏条:🎬 观看完整剧集 全 N 集。
class HomeFeedWatchAllBar extends StatelessWidget {
const HomeFeedWatchAllBar({
super.key,
required this.drama,
required this.onTap,
});
final Drama drama;
final VoidCallback onTap;
@override
Widget build(BuildContext context) {
final l10n = AppLocalizations.of(context)!;
return Material(
key: const Key('home-feed-full-series-bg'),
color: AppColors.textPrimary.withValues(alpha: 0.15),
child: InkWell(
key: const Key('home-feed-full-series'),
onTap: onTap,
child: SizedBox(
height: _watchAllHeight,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
child: Row(
children: [
const Icon(
Icons.movie_rounded,
size: 22,
color: AppColors.onPrimary,
),
const SizedBox(width: 10),
Expanded(
child: Text(
l10n.watchFullSeries('${drama.episodeCount}'),
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: const TextStyle(
color: AppColors.textPrimary,
fontSize: 15,
fontWeight: FontWeight.w500,
),
),
),
const Icon(
Icons.chevron_right_rounded,
size: 22,
color: AppColors.textPrimary,
),
],
),
),
),
),
);
}
}
class HomeFeedActionRail extends StatelessWidget {
const HomeFeedActionRail({
super.key,
@@ -305,7 +434,7 @@ class HomeFeedActionRail extends StatelessWidget {
required this.onSave,
required this.onLike,
required this.onComments,
required this.onEpisodes,
required this.onShare,
this.favoriteCount,
this.likeCount,
this.commentCount,
@@ -319,13 +448,17 @@ class HomeFeedActionRail extends StatelessWidget {
final VoidCallback onSave;
final VoidCallback onLike;
final VoidCallback onComments;
final VoidCallback onEpisodes;
final VoidCallback onShare;
@override
Widget build(BuildContext context) {
final l10n = AppLocalizations.of(context)!;
return InteractionRail(
itemGap: 14,
itemGap: 12,
buttonSize: 48,
iconSize: 36,
countFontSize: 15,
iconCountGap: 2,
items: [
InteractionRailItem(
key: const Key('rail-save'),
@@ -334,18 +467,9 @@ class HomeFeedActionRail extends StatelessWidget {
count: favoriteCount,
countKey: const Key('rail-save-count'),
selected: saved,
selectedColor: AppColors.brandRed,
onTap: onSave,
),
InteractionRailItem(
key: const Key('rail-like'),
asset: 'assets/icon/rail/rail_like.png',
label: l10n.like,
count: likeCount,
countKey: const Key('rail-like-count'),
selected: liked,
selectedColor: AppColors.doubleTapHeartRed,
onTap: onLike,
),
InteractionRailItem(
key: const Key('rail-comments'),
asset: 'assets/icon/rail/rail_comment.png',
@@ -355,11 +479,21 @@ class HomeFeedActionRail extends StatelessWidget {
onTap: onComments,
),
InteractionRailItem(
key: const Key('rail-episodes'),
icon: Icons.layers_rounded,
label: l10n.episodes,
countKey: const Key('rail-episodes-label'),
onTap: onEpisodes,
key: const Key('rail-like'),
asset: 'assets/icon/rail/rail_like.png',
label: l10n.like,
count: likeCount,
countKey: const Key('rail-like-count'),
selected: liked,
selectedColor: AppColors.brandRed,
onTap: onLike,
),
InteractionRailItem(
key: const Key('rail-share'),
asset: 'assets/icon/rail/rail_share.png',
label: l10n.share,
countKey: const Key('rail-share-label'),
onTap: onShare,
),
],
);
+48 -20
View File
@@ -5,8 +5,10 @@ import 'package:flutter/material.dart';
import '../../../core/formatting/count_format.dart';
import '../../../core/theme/app_colors.dart';
const double _buttonSize = 44;
const double _iconSize = 32;
const double _defaultButtonSize = 44;
const double _defaultIconSize = 32;
const double _defaultCountFont = 12;
const double _defaultIconCountGap = 2;
const double _defaultItemGap = 24;
/// 互动栏单项:图标、计数与点击。
@@ -21,6 +23,7 @@ class InteractionRailItem {
this.countKey,
this.selected = false,
this.selectedColor = AppColors.blue,
this.mirrorIcon = false,
}) : assert((asset == null) != (icon == null));
final Key key;
@@ -32,6 +35,9 @@ class InteractionRailItem {
final Key? countKey;
final bool selected;
final Color selectedColor;
/// 水平镜像图标(分享弯箭头用 reply 镜像得到)。
final bool mirrorIcon;
}
/// 播放页与首页 feed 共用的右侧互动栏:收藏/评论/喜欢/分享。
@@ -40,10 +46,18 @@ class InteractionRail extends StatelessWidget {
super.key,
required this.items,
this.itemGap = _defaultItemGap,
this.buttonSize = _defaultButtonSize,
this.iconSize = _defaultIconSize,
this.countFontSize = _defaultCountFont,
this.iconCountGap = _defaultIconCountGap,
});
final List<InteractionRailItem> items;
final double itemGap;
final double buttonSize;
final double iconSize;
final double countFontSize;
final double iconCountGap;
@override
Widget build(BuildContext context) {
@@ -52,7 +66,13 @@ class InteractionRail extends StatelessWidget {
children: [
for (var index = 0; index < items.length; index++) ...[
if (index > 0) SizedBox(height: itemGap),
_RailButton(item: items[index]),
_RailButton(
item: items[index],
buttonSize: buttonSize,
iconSize: iconSize,
countFontSize: countFontSize,
iconCountGap: iconCountGap,
),
],
],
);
@@ -60,53 +80,61 @@ class InteractionRail extends StatelessWidget {
}
class _RailButton extends StatelessWidget {
const _RailButton({required this.item});
const _RailButton({
required this.item,
required this.buttonSize,
required this.iconSize,
required this.countFontSize,
required this.iconCountGap,
});
final InteractionRailItem item;
final double buttonSize;
final double iconSize;
final double countFontSize;
final double iconCountGap;
@override
Widget build(BuildContext context) {
final tint = item.selected ? item.selectedColor : AppColors.onPrimary;
return Column(
key: item.key,
mainAxisSize: MainAxisSize.min,
children: [
SizedBox.square(
dimension: _buttonSize,
dimension: buttonSize,
child: IconButton(
onPressed: item.onTap,
padding: EdgeInsets.zero,
icon: item.asset != null
? Image.asset(
item.asset!,
width: _iconSize,
height: _iconSize,
width: iconSize,
height: iconSize,
fit: BoxFit.contain,
color: item.selected
? item.selectedColor
: AppColors.onPrimary,
color: tint,
colorBlendMode: BlendMode.srcIn,
)
: Icon(
item.icon,
size: _iconSize,
color: item.selected
? item.selectedColor
: AppColors.onPrimary,
: Transform.flip(
flipX: item.mirrorIcon,
child: Icon(item.icon, size: iconSize, color: tint),
),
),
),
const SizedBox(height: 2),
SizedBox(height: iconCountGap),
Text(
item.count == null ? item.label : formatInteractionCount(item.count!),
key: item.countKey,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: const TextStyle(
style: TextStyle(
color: AppColors.onPrimary,
height: 1,
fontSize: 12,
fontSize: countFontSize,
fontWeight: FontWeight.w600,
shadows: [Shadow(blurRadius: 6, color: AppColors.mediaBlack)],
shadows: const [
Shadow(blurRadius: 6, color: AppColors.mediaBlack),
],
),
),
],
@@ -3,6 +3,7 @@
import 'package:flutter/material.dart';
import '../../../core/theme/app_colors.dart';
import '../../../core/widgets/app_glow_panel.dart';
import '../../../l10n/app_localizations.dart';
const double _sheetRadius = 20;
@@ -52,6 +53,8 @@ class PlayerMoreActions {
required this.onDownload,
required this.onQualityChanged,
this.onPip,
this.autoPipEnabled = false,
this.onAutoPipChanged,
});
/// 倍速变化。
@@ -68,6 +71,12 @@ class PlayerMoreActions {
/// 进入小窗播放;平台不支持时为 null。
final VoidCallback? onPip;
/// 退出 App 自动小窗开关的当前状态(仅支持自动小窗的平台展示开关行)。
final bool autoPipEnabled;
/// 切换退出 App 自动小窗;为 null 时隐藏开关行。
final ValueChanged<bool>? onAutoPipChanged;
}
/// K29.6 精简版播放页更多面板。
@@ -96,16 +105,19 @@ class PlayerMoreSheet extends StatefulWidget {
class _PlayerMoreSheetState extends State<PlayerMoreSheet> {
late double _speed = widget.state.speed;
late String _quality = widget.state.selectedQuality.toUpperCase();
late bool _autoPip = widget.actions.autoPipEnabled;
@override
Widget build(BuildContext context) {
final l10n = widget.l10n;
return Material(
key: const Key('player-more-sheet'),
color: AppColors.ink,
return AppGlowPanel(
borderRadius: const BorderRadius.vertical(
top: Radius.circular(_sheetRadius),
),
border: false,
child: Material(
key: const Key('player-more-sheet'),
type: MaterialType.transparency,
clipBehavior: Clip.antiAlias,
child: SafeArea(
top: false,
@@ -142,6 +154,17 @@ class _PlayerMoreSheetState extends State<PlayerMoreSheet> {
title: l10n.pictureInPicture,
onTap: () => _closeThen(widget.actions.onPip!),
),
if (widget.actions.onAutoPipChanged != null)
_switchRow(
key: const Key('player-more-auto-pip'),
icon: Icons.auto_awesome_motion_outlined,
title: l10n.autoEnterPip,
value: _autoPip,
onChanged: (value) {
setState(() => _autoPip = value);
widget.actions.onAutoPipChanged!(value);
},
),
_actionRow(
key: const Key('player-more-offline'),
icon: Icons.download_outlined,
@@ -153,6 +176,7 @@ class _PlayerMoreSheetState extends State<PlayerMoreSheet> {
),
),
),
),
);
}
@@ -160,7 +184,7 @@ class _PlayerMoreSheetState extends State<PlayerMoreSheet> {
width: double.infinity,
padding: const EdgeInsets.symmetric(vertical: _groupVerticalPadding),
decoration: BoxDecoration(
color: AppColors.card,
color: Colors.white.withValues(alpha: 0.06),
borderRadius: BorderRadius.circular(_groupRadius),
),
child: Column(mainAxisSize: MainAxisSize.min, children: rows),
@@ -241,7 +265,7 @@ class _PlayerMoreSheetState extends State<PlayerMoreSheet> {
horizontal: _segmentTrackPadding,
),
decoration: BoxDecoration(
color: AppColors.raised,
color: Colors.white.withValues(alpha: 0.08),
borderRadius: BorderRadius.circular(_segmentTrackRadius),
),
child: Row(
@@ -286,6 +310,54 @@ class _PlayerMoreSheetState extends State<PlayerMoreSheet> {
);
}
/// 开关行:左侧图标+标题,右侧主题色 Switch。
Widget _switchRow({
required Key key,
required IconData icon,
required String title,
required bool value,
required ValueChanged<bool> onChanged,
}) {
return SizedBox(
key: key,
height: _rowHeight,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: _rowHorizontalPadding),
child: Row(
children: [
Icon(icon, color: AppColors.onSurface, size: _rowIconSize),
const SizedBox(width: _rowIconGap),
Expanded(
child: Text(
title,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: const TextStyle(
color: AppColors.onSurface,
fontSize: _rowLabelSize,
fontWeight: FontWeight.w500,
),
),
),
Transform.scale(
scale: 0.7,
child: Switch(
key: const Key('player-more-auto-pip-switch'),
value: value,
activeThumbColor: AppColors.onSurface,
activeTrackColor: AppColors.brandRed,
inactiveThumbColor: AppColors.textSecondary,
inactiveTrackColor: AppColors.contentBorder,
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
onChanged: onChanged,
),
),
],
),
),
);
}
Widget _actionRow({
required Key key,
required IconData icon,
@@ -380,7 +452,9 @@ class _SegmentButton extends StatelessWidget {
padding: const EdgeInsets.symmetric(horizontal: _segmentPadding),
alignment: Alignment.center,
decoration: BoxDecoration(
color: selected ? AppColors.card : AppColors.transparent,
color: selected
? Colors.white.withValues(alpha: 0.16)
: AppColors.transparent,
borderRadius: BorderRadius.circular(_segmentRadius),
boxShadow: selected
? const [
+8 -4
View File
@@ -158,16 +158,20 @@ class PlayerPlaybackOverlay extends StatelessWidget {
}
Widget _rail(BuildContext context) {
final compact = MediaQuery.sizeOf(context).height < 700;
return Positioned(
right: AppDimens.spaceMd,
top: MediaQuery.sizeOf(context).height * (compact ? 0.30 : 0.43),
// 底部锚定:无论屏幕高矮,始终悬在进度条上方,不会压到进度条。
bottom: 120,
child: IgnorePointer(
ignoring: scrubbing,
child: Opacity(
opacity: scrubbing ? 0 : 1,
child: InteractionRail(
key: const Key('player-interaction-rail'),
itemGap: 12,
buttonSize: 48,
iconSize: 36,
countFontSize: 15,
items: [
InteractionRailItem(
key: const Key('player-rail-save'),
@@ -185,7 +189,7 @@ class PlayerPlaybackOverlay extends StatelessWidget {
count: data.likeCount,
countKey: const Key('player-rail-like-count'),
selected: data.liked,
selectedColor: AppColors.doubleTapHeartRed,
selectedColor: AppColors.brandRed,
onTap: actions.onLike,
),
InteractionRailItem(
@@ -336,7 +340,7 @@ class PlayerPlaybackOverlay extends StatelessWidget {
color: AppColors.onPrimary,
fontFamily: 'Outfit',
fontSize: 18,
fontWeight: FontWeight.w800,
fontWeight: FontWeight.w400,
shadows: _playerTextShadows,
),
),
@@ -131,9 +131,9 @@ class _EpisodeSynopsisState extends State<_EpisodeSynopsis> {
int _detailRequest = 0;
bool _detailRequested = false;
/// 「第 n 集」、分隔符与简介正文共用同一套灰字规格。
/// 「第 n 集」、分隔符与简介正文共用同一套白字规格。
static const TextStyle _lineStyle = TextStyle(
color: AppColors.playerMuted,
color: AppColors.onPrimary,
fontSize: 12,
fontWeight: FontWeight.w500,
height: 1.35,
@@ -142,13 +142,10 @@ class _EpisodeSynopsisState extends State<_EpisodeSynopsis> {
static const TextStyle _linkStyle = TextStyle(
color: AppColors.textPrimary,
fontSize: 12,
fontWeight: FontWeight.w700,
fontWeight: FontWeight.w600,
shadows: _playerTextShadows,
);
static const int _collapsedMaxLines = 2;
static const double _expandGap = 6;
static const double _expandTrailing = 28;
static const double _separatorGap = 6;
String get _synopsis => _fullSynopsis ?? widget.synopsis;
@@ -200,236 +197,116 @@ class _EpisodeSynopsisState extends State<_EpisodeSynopsis> {
);
}
/// 与首页推荐 feed 的简介展开/收起保持一致:
/// 折叠单行省略 + 行尾「展开」(整行可点);展开后内联「收起」。
Widget _block(double maxWidth) {
final label = widget.l10n.episodeLabel(widget.episodeNumber);
if (_expanded) return _expandedBlock(label, maxWidth);
return _collapsedBlock(label, maxWidth);
final span = TextSpan(
style: _lineStyle,
children: [
TextSpan(text: label, style: _lineStyle),
_separatorSpan(),
TextSpan(text: _synopsis, style: _lineStyle),
],
);
if (_expanded) return _expandedBlock(span);
final painter = TextPainter(
text: span,
maxLines: 1,
textDirection: Directionality.of(context),
textScaler: MediaQuery.textScalerOf(context),
)..layout(maxWidth: maxWidth);
if (!painter.didExceedMaxLines) {
return Text.rich(
span,
key: const Key('player-synopsis'),
maxLines: 1,
style: _lineStyle,
);
}
return GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () => setState(() => _expanded = true),
child: Row(
key: const Key('player-synopsis-collapsed'),
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: Text.rich(
span,
key: const Key('player-synopsis'),
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: _lineStyle,
),
),
const SizedBox(width: 2),
_toggle(widget.l10n.expandSynopsis,
padding: const EdgeInsets.only(left: 6)),
],
),
);
}
Widget _collapsedBlock(String label, double maxWidth) {
final link = widget.l10n.expandSynopsis;
final body = _collapsedBody(label, maxWidth, link);
final text = _synopsisText(label, body, link: null, expanded: false);
if (body == _synopsis) return text;
final caret = _caret(label, body, maxWidth);
return Stack(
clipBehavior: Clip.none,
Widget _expandedBlock(InlineSpan span) {
final expandedSpan = TextSpan(
style: _lineStyle,
children: [
text,
Positioned(
left: caret.dx,
top: caret.dy,
child: Padding(
key: const Key('player-synopsis-gap'),
padding: const EdgeInsets.only(left: _expandGap),
child: _toggle(link),
span,
WidgetSpan(
alignment: PlaceholderAlignment.baseline,
baseline: TextBaseline.alphabetic,
child: _toggle(
widget.l10n.showLess,
padding: const EdgeInsets.only(left: 8),
),
),
],
);
}
Widget _expandedBlock(String label, double maxWidth) {
return SizedBox(
width: maxWidth,
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
_synopsisText(label, _synopsis, link: null, expanded: true),
Align(
alignment: Alignment.centerRight,
child: _toggle(widget.l10n.showLess),
),
if (widget.authorNote.isNotEmpty) ...[
const SizedBox(height: 4),
Text(
widget.authorNote,
key: const Key('player-author-note'),
maxLines: _collapsedMaxLines,
overflow: TextOverflow.ellipsis,
style: const TextStyle(
color: AppColors.playerMuted,
fontSize: 10,
shadows: _playerTextShadows,
),
return Column(
key: const Key('player-synopsis-expanded'),
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text.rich(expandedSpan, key: const Key('player-synopsis')),
if (widget.authorNote.isNotEmpty) ...[
const SizedBox(height: 4),
Text(
widget.authorNote,
key: const Key('player-author-note'),
maxLines: _collapsedMaxLines,
overflow: TextOverflow.ellipsis,
style: const TextStyle(
color: AppColors.playerMuted,
fontSize: 10,
shadows: _playerTextShadows,
),
],
),
],
),
],
);
}
Widget _synopsisText(
String label,
String body, {
required String? link,
required bool expanded,
}) {
return Text.rich(
TextSpan(
style: _lineStyle,
children: _spans(label, body, link),
),
key: const Key('player-synopsis'),
style: _lineStyle,
maxLines: expanded ? null : _collapsedMaxLines,
overflow: expanded ? TextOverflow.clip : TextOverflow.ellipsis,
);
}
List<InlineSpan> _spans(String label, String body, String? link) {
return [
WidgetSpan(
alignment: PlaceholderAlignment.baseline,
baseline: TextBaseline.alphabetic,
child: Text(
label,
key: const Key('player-episode-label'),
style: _lineStyle,
/// 分隔竖线:同字号 w400 + 45% 透明白,靠两侧空格留白。
/// 必须用 TextSpan:WidgetSpan 占位盒的基线对齐会让第n集与简介错位。
TextSpan _separatorSpan() => TextSpan(
text: ' | ',
style: _lineStyle.copyWith(
color: AppColors.onPrimary.withValues(alpha: 0.45),
fontWeight: FontWeight.w400,
),
),
WidgetSpan(
alignment: PlaceholderAlignment.baseline,
baseline: TextBaseline.alphabetic,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: _separatorGap),
child: Text(
'|',
style: _lineStyle.copyWith(
color: AppColors.playerMuted.withValues(alpha: 0.6),
),
),
),
),
TextSpan(text: body, style: _lineStyle),
if (link != null)
WidgetSpan(
alignment: PlaceholderAlignment.baseline,
baseline: TextBaseline.alphabetic,
child: Padding(
key: const Key('player-synopsis-gap'),
padding: const EdgeInsets.only(left: _expandGap),
child: _toggle(link),
),
),
];
}
);
String _collapsedBody(String label, double maxWidth, String link) {
if (_fits(label, _synopsis, maxWidth, reserve: 0)) {
return _synopsis;
}
final reserve =
_textWidth(link, _linkStyle) + _expandGap + _expandTrailing;
var low = 0;
var high = _synopsis.length;
var best = '…';
while (low <= high) {
final mid = (low + high) >> 1;
final slice = '${_synopsis.substring(0, mid)}…';
if (_fits(label, slice, maxWidth, reserve: reserve)) {
best = slice;
low = mid + 1;
} else {
high = mid - 1;
}
}
return best;
}
bool _fits(
String label,
String body,
double maxWidth, {
required double reserve,
}) {
final painter = TextPainter(
text: TextSpan(
children: [
TextSpan(text: label, style: _lineStyle),
const WidgetSpan(
alignment: PlaceholderAlignment.baseline,
baseline: TextBaseline.alphabetic,
child: SizedBox(width: _separatorGap),
),
TextSpan(
text: '|',
style: _lineStyle.copyWith(
color: AppColors.playerMuted.withValues(alpha: 0.6),
),
),
const WidgetSpan(
alignment: PlaceholderAlignment.baseline,
baseline: TextBaseline.alphabetic,
child: SizedBox(width: _separatorGap),
),
TextSpan(text: body, style: _lineStyle),
if (reserve > 0)
WidgetSpan(
alignment: PlaceholderAlignment.baseline,
baseline: TextBaseline.alphabetic,
child: SizedBox(width: reserve),
),
],
),
maxLines: _collapsedMaxLines,
textDirection: TextDirection.ltr,
);
painter.setPlaceholderDimensions(_slots(reserve));
painter.layout(maxWidth: maxWidth);
return !painter.didExceedMaxLines;
}
List<PlaceholderDimensions> _slots(double reserve) {
return [
const PlaceholderDimensions(
size: Size(_separatorGap, 1),
alignment: PlaceholderAlignment.baseline,
baseline: TextBaseline.alphabetic,
),
const PlaceholderDimensions(
size: Size(_separatorGap, 1),
alignment: PlaceholderAlignment.baseline,
baseline: TextBaseline.alphabetic,
),
if (reserve > 0)
PlaceholderDimensions(
size: Size(reserve, _lineStyle.fontSize ?? 12),
alignment: PlaceholderAlignment.baseline,
baseline: TextBaseline.alphabetic,
),
];
}
Offset _caret(String label, String body, double maxWidth) {
final painter = TextPainter(
text: TextSpan(children: _spans(label, body, null)),
maxLines: _collapsedMaxLines,
textDirection: TextDirection.ltr,
);
painter.setPlaceholderDimensions(_slots(0));
painter.layout(maxWidth: maxWidth);
return painter.getOffsetForCaret(
TextPosition(offset: painter.plainText.length),
Rect.zero,
);
}
double _textWidth(String text, TextStyle style) {
final painter = TextPainter(
text: TextSpan(text: text, style: style),
maxLines: 1,
textDirection: TextDirection.ltr,
)..layout();
return painter.width;
}
Widget _toggle(String label) {
return InkWell(
Widget _toggle(String label, {required EdgeInsets padding}) {
return GestureDetector(
key: const Key('player-synopsis-toggle'),
behavior: HitTestBehavior.opaque,
onTap: () => setState(() => _expanded = !_expanded),
borderRadius: BorderRadius.circular(4),
child: Text(label, maxLines: 1, style: _linkStyle),
child: Padding(
padding: padding,
child: Text(label, maxLines: 1, style: _linkStyle),
),
);
}
}
@@ -53,12 +53,16 @@ class PlayerRenderStack extends StatefulWidget {
required this.pageController,
required this.slots,
this.onCurrentVideoVisible,
this.resumeSignal = 0,
});
final PageController pageController;
final Map<PlayerRenderSlotRole, PlayerRenderSlotData> slots;
final ValueChanged<int?>? onCurrentVideoVisible;
/// iOS 画中画还原的恢复信号,透传给每个槽位的视频表面。
final int resumeSignal;
@override
State<PlayerRenderStack> createState() => _PlayerRenderStackState();
}
@@ -200,6 +204,7 @@ class _PlayerRenderStackState extends State<PlayerRenderStack> {
onVideoVisible: slot.role == PlayerRenderSlotRole.current
? () => widget.onCurrentVideoVisible?.call(slot.index)
: null,
resumeSignal: widget.resumeSignal,
),
),
);
@@ -3,6 +3,7 @@
import 'package:flutter/material.dart';
import '../../../core/theme/app_colors.dart';
import '../../../core/widgets/app_glow_panel.dart';
import '../../../l10n/app_localizations.dart';
const List<double> _speedOptions = [0.75, 1.0, 1.25, 1.5, 2.0, 3.0];
@@ -19,14 +20,16 @@ class PlayerSpeedSheet extends StatelessWidget {
@override
Widget build(BuildContext context) {
final l10n = AppLocalizations.of(context)!;
return Material(
key: const Key('player-speed-sheet'),
color: AppColors.card,
return AppGlowPanel(
borderRadius: const BorderRadius.vertical(
top: Radius.circular(_sheetRadius),
),
clipBehavior: Clip.antiAlias,
child: SafeArea(
border: false,
child: Material(
key: const Key('player-speed-sheet'),
type: MaterialType.transparency,
clipBehavior: Clip.antiAlias,
child: SafeArea(
top: false,
child: Column(
mainAxisSize: MainAxisSize.min,
@@ -50,6 +53,7 @@ class PlayerSpeedSheet extends StatelessWidget {
],
),
),
),
);
}
@@ -6,6 +6,7 @@ import '../../../core/data/models/drama.dart';
import '../../../core/data/models/play_ticket.dart';
import '../../../core/formatting/error_text.dart';
import '../../../core/theme/app_colors.dart';
import '../../../core/widgets/app_glow_panel.dart';
import '../../../l10n/app_localizations.dart';
const double _cardRadius = 20;
@@ -209,12 +210,10 @@ class _PlayerUnlockSheetState extends State<PlayerUnlockSheet> {
@override
Widget build(BuildContext context) {
final l10n = widget.l10n;
return Container(
return AppGlowPanel(
key: const Key('player-unlock-panel'),
decoration: const BoxDecoration(
color: AppColors.card,
borderRadius: BorderRadius.vertical(top: Radius.circular(_cardRadius)),
),
borderRadius: const BorderRadius.vertical(top: Radius.circular(_cardRadius)),
border: false,
child: SafeArea(
top: false,
child: Padding(
@@ -29,6 +29,7 @@ class PlayerVideoSurface extends StatefulWidget {
this.debugIndex,
this.showFallbackBackground = true,
this.onVideoVisible,
this.resumeSignal = 0,
});
final VideoPlayerController? controller;
@@ -60,6 +61,10 @@ class PlayerVideoSurface extends StatefulWidget {
final bool theater;
final VoidCallback? onVideoVisible;
/// iOS 画中画还原等场景的恢复信号:数值变化时回退到占位并重新等首帧,
/// 避免纹理被系统回收后显示黑屏(封面占位 → 新帧淡入)。
final int resumeSignal;
@override
State<PlayerVideoSurface> createState() => _PlayerVideoSurfaceState();
}
@@ -76,6 +81,11 @@ class _PlayerVideoSurfaceState extends State<PlayerVideoSurface>
bool _transitioning = false;
bool _videoVisible = false;
bool _videoVisibleNotified = false;
/// 清晰度切换时新源 seek 后的进度;position 越过它才认定纹理已有画面。
Duration? _confirmBasePosition;
/// 画中画还原等场景的首帧确认下限时刻:position 可能一拍就过基准,
/// 但纹理出帧滞后于进度观测,淡入前强制等待一小段真实解码时间。
DateTime? _confirmNotBefore;
String? _lastLayerState;
@override
@@ -99,6 +109,13 @@ class _PlayerVideoSurfaceState extends State<PlayerVideoSurface>
@override
void didUpdateWidget(covariant PlayerVideoSurface oldWidget) {
super.didUpdateWidget(oldWidget);
if (oldWidget.resumeSignal != widget.resumeSignal) {
_logSlot('pip-resume-reset', widget.controller?.value);
_resetForControllerChange();
_confirmNotBefore = DateTime.now().add(const Duration(milliseconds: 450));
setState(() {});
if (oldWidget.controller == widget.controller) return;
}
if (oldWidget.controller != widget.controller) {
_logSlot('controller-change-before', oldWidget.controller?.value);
_detachController(oldWidget.controller);
@@ -261,6 +278,16 @@ class _PlayerVideoSurfaceState extends State<PlayerVideoSurface>
return false;
}
if (widget.warmFrameAvailable || !widget.waitForPlaybackFrame) return true;
// 清晰度切换:新源 seek 完成后 position 立即大于 0,但不代表纹理已有
// 画面;等 position 越过切换时刻的值(解码循环已在出帧)再确认,避免闪黑。
final base = _confirmBasePosition;
if (base != null) {
final notBefore = _confirmNotBefore;
if (notBefore != null && DateTime.now().isBefore(notBefore)) {
return false;
}
return value.position > base || value.isCompleted;
}
if (value.position > Duration.zero || value.isCompleted) return true;
return _playbackStarted && !value.isPlaying && !value.isBuffering;
}
@@ -321,6 +348,8 @@ class _PlayerVideoSurfaceState extends State<PlayerVideoSurface>
_videoVisible = false;
_videoVisibleNotified = false;
_lastLayerState = null;
// 记录新源切换时刻的进度,供首帧确认判断 position 是否已前进。
_confirmBasePosition = widget.controller?.value.position;
}
void _notifyVideoVisible() {
@@ -0,0 +1,477 @@
// 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/home_feed.dart';
import '../../core/data/remote/catalog_api.dart';
import '../../core/data/services/category_controller.dart';
import '../../core/theme/app_colors.dart';
import '../../core/widgets/app_pull_to_refresh.dart';
import '../../core/widgets/empty_state.dart';
import '../../core/widgets/paged_list_footer.dart';
import '../../l10n/app_localizations.dart';
import '../player/open_player.dart';
import 'widgets/home_hero_carousel.dart';
import 'widgets/home_recommend_content.dart';
import 'widgets/recommend_channel_nav.dart';
/// 底部第二个 tab「推荐」(礼花)。
///
/// 频道全部来自分类接口;内容区是一个横向 [PageView],左右滑动即可切换频道,
/// 顶部频道导航随之高亮,并把选中频道滚动到可见区域。
/// 第一个频道(接口的「精选」)在网格顶部额外挂一张 banners 轮播图,
/// 轮播数据来自 `GET /app/home/feed`。
class RecommendDiscoverPage extends StatefulWidget {
const RecommendDiscoverPage({
super.key,
required this.active,
required this.onSearch,
this.onOpenWallet,
});
final bool active;
final VoidCallback onSearch;
/// 顶部金色礼物盒(钱包入口)。
final VoidCallback? onOpenWallet;
@override
State<RecommendDiscoverPage> createState() => _RecommendDiscoverPageState();
}
class _RecommendDiscoverPageState extends State<RecommendDiscoverPage>
with AutomaticKeepAliveClientMixin<RecommendDiscoverPage> {
/// 当前频道 id;频道全部来自分类接口,首项即「精选」。
String? _channelId;
final Set<String> _requestedCategories = {};
final PageController _pageController = PageController();
/// `GET /app/home/feed` 返回的轮播图,只挂在第一个「精选」频道。
List<FeedBanner> _banners = const [];
bool _bannersRequested = false;
@override
bool get wantKeepAlive => true;
@override
void initState() {
super.initState();
WidgetsBinding.instance.addPostFrameCallback((_) => _loadBanners());
}
@override
void dispose() {
_pageController.dispose();
super.dispose();
}
/// 点击顶部频道:更新高亮并让 PageView 滑到对应页。
void _selectChannel(String id, int index) {
if (id == _channelId && _pageController.hasClients) {
// 已在该页时仍允许回到顶部对齐。
return;
}
setState(() => _channelId = id);
_ensureCategory(id);
if (_pageController.hasClients) {
unawaited(
_pageController.animateToPage(
index,
duration: const Duration(milliseconds: 300),
curve: Curves.easeOut,
),
);
}
}
/// 左右滑动翻页:更新高亮(不反向驱动 PageView)。
void _onPageChanged(int index, List<String> orderedIds) {
if (index < 0 || index >= orderedIds.length) return;
final id = orderedIds[index];
if (id != _channelId) setState(() => _channelId = id);
_ensureCategory(id);
}
void _ensureCategory(String id) {
if (_requestedCategories.contains(id)) return;
_requestedCategories.add(id);
final categories = context.read<CategoryController>();
if (categories.dramaPageLoader == null) return;
final slot = categories.slotOf(id);
if (slot.dramas.isNotEmpty || slot.loading) return;
WidgetsBinding.instance.addPostFrameCallback((_) {
if (mounted) unawaited(categories.openCategory(id));
});
}
/// 下拉刷新:重拉该分类第一页;精选频道同时刷新轮播图。
Future<void> _refreshCategory(String id, bool isFeatured) async {
final categories = context.read<CategoryController>();
final tasks = <Future<void>>[categories.openCategory(id)];
if (isFeatured) tasks.add(_loadBanners(force: true));
await Future.wait(tasks);
}
/// 轮播图只依赖 home/feed 的 banners;接口缺失(如测试注入)时静默跳过,
/// 不影响下方分类网格。
Future<void> _loadBanners({bool force = false}) async {
if (_bannersRequested && !force) return;
_bannersRequested = true;
CatalogApi? api;
try {
api = context.read<CatalogApi>();
} on ProviderNotFoundException {
api = null;
}
if (api == null) return;
try {
final feed = await api.homeFeed();
if (mounted && feed.banners.isNotEmpty) {
setState(() => _banners = feed.banners);
}
} catch (_) {
// 轮播拉取失败时保留纯网格。
}
}
Future<void> _openDrama(Drama drama) =>
playDramaFromCatalog(context, drama);
@override
Widget build(BuildContext context) {
super.build(context);
final categories = context.watch<CategoryController>();
final mediaTop = MediaQuery.of(context).padding.top;
final categoryList = categories.categories;
final orderedIds = categoryList.map((c) => c.id).toList();
// 频道来自接口分类;默认选中第一个分类(即「精选」)。
_channelId ??= categoryList.isEmpty ? null : categoryList.first.id;
final selectedIndex = _channelId == null
? 0
: orderedIds.indexOf(_channelId!).clamp(0, orderedIds.length - 1);
return ColoredBox(
key: const Key('recommend-page'),
color: AppColors.appBackground,
child: Stack(
children: [
Positioned.fill(
child: categoryList.isEmpty
? const Center(
child: CircularProgressIndicator(
color: AppColors.brandRed,
),
)
: PageView.builder(
key: const Key('recommend-channel-pager'),
controller: _pageController,
itemCount: categoryList.length,
onPageChanged: (i) => _onPageChanged(i, orderedIds),
itemBuilder: (context, index) {
final category = categoryList[index];
return _ChannelFeed(
key: PageStorageKey<String>(
'recommend-channel-${category.id}',
),
categoryId: category.id,
isFeatured: index == 0,
banners: _banners,
carouselActive: widget.active && index == selectedIndex,
mediaTop: mediaTop,
onRequest: _ensureCategory,
onRefresh: () => _refreshCategory(category.id, index == 0),
onOpenDrama: _openDrama,
);
},
),
),
Positioned(
top: 0,
left: 0,
right: 0,
child: IgnorePointer(
child: SizedBox(
height: mediaTop + RecommendChannelNav.height,
child: const DecoratedBox(
key: Key('recommend-top-gradient'),
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [AppColors.mediaBlack, AppColors.transparent],
),
),
),
),
),
),
Positioned(
top: 0,
left: 0,
right: 0,
child: SafeArea(
bottom: false,
child: RecommendChannelNav(
categories: categoryList,
selectedId: _channelId,
onSelected: (id) {
final index = orderedIds.indexOf(id);
if (index >= 0) _selectChannel(id, index);
},
onSearch: widget.onSearch,
onGift: widget.onOpenWallet,
),
),
),
],
),
);
}
}
/// 单个分类频道的内容:可选顶部轮播 + 该分类短剧三列网格。
class _ChannelFeed extends StatefulWidget {
const _ChannelFeed({
super.key,
required this.categoryId,
required this.isFeatured,
required this.banners,
required this.carouselActive,
required this.mediaTop,
required this.onRequest,
required this.onRefresh,
required this.onOpenDrama,
});
final String categoryId;
final bool isFeatured;
final List<FeedBanner> banners;
final bool carouselActive;
final double mediaTop;
final ValueChanged<String> onRequest;
final Future<void> Function() onRefresh;
final ValueChanged<Drama> onOpenDrama;
@override
State<_ChannelFeed> createState() => _ChannelFeedState();
}
class _ChannelFeedState extends State<_ChannelFeed>
with AutomaticKeepAliveClientMixin {
@override
bool get wantKeepAlive => true;
@override
void initState() {
super.initState();
widget.onRequest(widget.categoryId);
}
Drama? _dramaForBanner(FeedBanner banner, List<Drama> pool) {
final id = banner.dramaId;
if (id == null) return null;
for (final drama in pool) {
if (drama.id == id) return drama;
}
return null;
}
@override
Widget build(BuildContext context) {
super.build(context);
final categories = context.watch<CategoryController>();
final slot = categories.slotOf(widget.categoryId);
final dramas = slot.dramas;
final showCarousel = widget.isFeatured && widget.banners.isNotEmpty;
final bottomInset = MediaQuery.of(context).padding.bottom;
// 精选频道:按接口下发的标签(tag)把「上新」筛出来横滑,其余短剧一行两个。
List<Drama> newArrivals = const [];
List<Drama> rest = dramas;
if (widget.isFeatured && dramas.isNotEmpty) {
final lang = Localizations.localeOf(context).languageCode;
final badge = AppLocalizations.of(context)!.newArrivalBadge;
newArrivals = dramas
.where((drama) => _isNewArrivalTag(drama, lang, badge))
.toList(growable: false);
if (newArrivals.isNotEmpty) {
final newIds = newArrivals.map((drama) => drama.id).toSet();
rest = dramas
.where((drama) => !newIds.contains(drama.id))
.toList(growable: false);
}
}
final sliverList = <Widget>[];
if (showCarousel) {
sliverList.add(
SliverToBoxAdapter(
child: HomeHeroCarousel(
banners: widget.banners,
active: widget.carouselActive,
dramaFor: (banner) => _dramaForBanner(banner, dramas),
onWatch: widget.onOpenDrama,
),
),
);
}
if (dramas.isEmpty) {
sliverList.add(
SliverFillRemaining(
hasScrollBody: false,
child: Padding(
padding: EdgeInsets.only(
top: showCarousel ? 0 : widget.mediaTop + RecommendChannelNav.height,
),
child: Center(child: _placeholder(slot.loading)),
),
),
);
} else if (widget.isFeatured) {
// 无轮播图时内容需避开顶部悬浮导航。
final contentTop =
showCarousel ? 24.0 : widget.mediaTop + RecommendChannelNav.height + 16;
if (newArrivals.isNotEmpty) {
sliverList.add(
SliverToBoxAdapter(child: SizedBox(height: contentTop)),
);
sliverList.add(
SliverToBoxAdapter(
child: HomeNewArrivalRow(
dramas: newArrivals,
onOpen: widget.onOpenDrama,
),
),
);
sliverList.add(
const SliverToBoxAdapter(child: SizedBox(height: 28)),
);
}
sliverList.add(
_gridSliver(
rest,
topPadding: newArrivals.isNotEmpty ? 0 : contentTop,
crossAxisCount: 2,
),
);
} else {
sliverList.add(
_gridSliver(
dramas,
topPadding: showCarousel ? 20 : widget.mediaTop + RecommendChannelNav.height + 16,
crossAxisCount: 3,
),
);
}
sliverList.add(
SliverToBoxAdapter(
child: Padding(
padding: EdgeInsets.only(bottom: bottomInset),
child: PagedListFooter(
key: const Key('recommend-category-footer'),
loading: slot.loadingMore,
hasMore: slot.hasMore,
hasItems: dramas.isNotEmpty,
errorMessage: null,
onRetry: () => categories.loadMore(widget.categoryId),
),
),
),
);
return NotificationListener<ScrollNotification>(
onNotification: (notification) {
if (notification.depth != 0) return false;
if (notification.metrics.extentAfter > 300) return false;
if (notification is! ScrollUpdateNotification &&
notification is! ScrollEndNotification &&
notification is! OverscrollNotification) {
return false;
}
unawaited(categories.loadMore(widget.categoryId));
return false;
},
child: AppPullToRefresh(
onRefresh: widget.onRefresh,
child: CustomScrollView(
key: PageStorageKey<String>('recommend-feed-${widget.categoryId}'),
physics: AppPullToRefresh.physics,
slivers: sliverList,
),
),
);
}
Widget _placeholder(bool loading) {
if (loading) {
return const CircularProgressIndicator(color: AppColors.brandRed);
}
final l10n = AppLocalizations.of(context)!;
return EmptyState(
key: const Key('recommend-category-empty'),
icon: Icons.movie_outlined,
title: l10n.noStories,
);
}
Widget _gridSliver(
List<Drama> dramas, {
required double topPadding,
required int crossAxisCount,
}) {
const pageSide = 14.0;
const cardGap = 9.0;
const rowGap = 16.0;
const cardBodyExtent = 44.0; // 封面下间距 + 剧名行 + 集数行
// 两列时卡更大,卡间距略放宽。
final spacing = crossAxisCount == 2 ? 12.0 : cardGap;
return SliverPadding(
padding: EdgeInsets.fromLTRB(pageSide, topPadding, pageSide, 0),
sliver: SliverLayoutBuilder(
builder: (context, constraints) {
final itemWidth =
(constraints.crossAxisExtent - spacing * (crossAxisCount - 1)) /
crossAxisCount;
final itemExtent = itemWidth * 157 / 110 + cardBodyExtent;
return SliverGrid(
key: Key('recommend-category-grid-${widget.categoryId}'),
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: crossAxisCount,
crossAxisSpacing: spacing,
mainAxisSpacing: rowGap,
mainAxisExtent: itemExtent,
),
delegate: SliverChildBuilderDelegate(
(context, index) {
final drama = dramas[index];
return HomePosterCard(
key: Key('recommend-category-card-${drama.id}'),
drama: drama,
onTap: () => widget.onOpenDrama(drama),
);
},
childCount: dramas.length,
),
);
},
),
);
}
}
/// 判定接口下发的短剧标签是否为「上新」。
///
/// 完全以后端返回的 `tag` / `tagLocales`(经 [Drama.localizedTag] 本地化)
/// 为准;兼容「上新 / NEW / BARU」三种文案,并兼容「本周上新」这类带前后缀的写法。
bool _isNewArrivalTag(Drama drama, String lang, String localizedBadge) {
final tag = drama.localizedTag(lang).trim();
if (tag.isEmpty) return false;
if (tag == localizedBadge) return true;
final lower = tag.toLowerCase();
return tag.contains('上新') || lower == 'new' || lower == 'baru';
}
+24 -31
View File
@@ -9,8 +9,10 @@ import '../../core/data/models/drama.dart';
import '../../core/data/remote/catalog_api.dart';
import '../../core/data/models/playlist_detail.dart';
import '../../core/data/services/category_controller.dart';
import '../../core/data/services/download_controller.dart';
import '../../core/data/services/home_feed_controller.dart';
import '../../core/data/services/playlist_controller.dart';
import '../../core/data/services/wallet_controller.dart';
import '../../core/theme/app_colors.dart';
import '../../core/widgets/empty_state.dart';
import '../../l10n/app_localizations.dart';
@@ -30,6 +32,7 @@ class RecommendPage extends StatefulWidget {
this.catalogApi,
required this.active,
required this.onSearch,
this.onOpenWallet,
this.videoOnly = false,
this.onImmersiveChanged,
});
@@ -39,6 +42,9 @@ class RecommendPage extends StatefulWidget {
final bool active;
final VoidCallback onSearch;
/// 顶部金色礼物盒(钱包入口)。
final VoidCallback? onOpenWallet;
/// 画中画时只留视频,不画顶栏。
final bool videoOnly;
final ValueChanged<bool>? onImmersiveChanged;
@@ -272,6 +278,7 @@ class _RecommendPageState extends State<RecommendPage>
onVideo: _tab == RecommendInnerTab.feed,
onSelected: _selectTab,
onSearch: _handleSearch,
onGift: widget.onOpenWallet,
),
),
),
@@ -294,6 +301,10 @@ class _RecommendPageState extends State<RecommendPage>
initialIndex: 0,
feedDramas: dramas,
feedChannel: widget.feedController.channel,
// 内嵌流也是真实播放页:不传钱包/下载,锁定集点「解锁」会静默无响应,
// 进全屏后也拿不到这两个依赖。
wallet: context.read<WalletController>(),
downloads: context.read<DownloadController>(),
onOpenFullPlayer: (drama, episode) =>
_openDrama(drama, episodeId: episode.id),
onRefreshFeed: widget.feedController.refreshCurrent,
@@ -353,40 +364,22 @@ class _RecommendPageState extends State<RecommendPage>
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [
AppColors.mineGradientTop,
AppColors.mineGradientMiddle,
AppColors.mineGradientBottom,
AppColors.followingGlow,
AppColors.followingGlowMid,
AppColors.appBackground,
],
stops: [0, 0.4, 0.75],
stops: [0, 0.14, 0.3],
),
),
child: Stack(
fit: StackFit.expand,
children: [
const DecoratedBox(
key: Key('recommend-playlist-glow'),
decoration: BoxDecoration(
gradient: RadialGradient(
center: Alignment(0, -0.95),
radius: 0.9,
colors: [
AppColors.recommendPlaylistGlow,
AppColors.transparent,
],
),
),
),
_withTopNavSpace(
RecommendSectionsView(
feedController: widget.feedController,
categories: categories,
onOpenDrama: _openDrama,
onMore: _handleMore,
playlists: _watchPlaylists(context),
onOpenPlaylist: _openPlaylist,
),
),
],
child: _withTopNavSpace(
RecommendSectionsView(
feedController: widget.feedController,
categories: categories,
onOpenDrama: _openDrama,
onMore: _handleMore,
playlists: _watchPlaylists(context),
onOpenPlaylist: _openPlaylist,
),
),
);
}
@@ -20,6 +20,9 @@ import '../../home/widgets/home_feed_card.dart';
const double _loadMoreThreshold = 240;
const int _gridColumns = 3;
// 标题两行 39 + 上间距 6 + 标签间距 6 + 标签行高约 17 = 68。
// 标签是 11 号字,实际行高按字体度量约 16~17,按 13 估算会底部溢出 4px。
const double _cardBodyExtent = 68;
/// 推荐页「全部短剧」筛选和三列列表。
class AllDramasFilterGrid extends StatefulWidget {
@@ -94,7 +97,7 @@ class _AllDramasFilterGridState extends State<AllDramasFilterGrid> {
final itemWidth =
(width - AppDimens.allDramasHorizontal * 2 - AppDimens.allDramasGridGap * 2) /
_gridColumns;
return itemWidth / AppDimens.cardCoverAspectRatio + AppDimens.homeCardBodyExtent;
return itemWidth / AppDimens.cardCoverAspectRatio + _cardBodyExtent;
}
Widget _dramaList(AppLocalizations l10n, double itemExtent) {
@@ -309,7 +312,7 @@ class _AllDramasFilterGridState extends State<AllDramasFilterGrid> {
? AppColors.filterChipTextSelected
: AppColors.filterChipTextInactive,
fontSize: AppDimens.filterChipFont,
fontWeight: selected ? FontWeight.w600 : FontWeight.w400,
fontWeight: FontWeight.w400,
height: 1,
),
),
@@ -0,0 +1,396 @@
// 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/home_feed.dart';
import '../../../core/data/services/favorite_controller.dart';
import '../../../core/theme/app_colors.dart';
import '../../../core/widgets/remote_image.dart';
import '../../../l10n/app_localizations.dart';
/// 推荐页顶部静态头图轮播:封面 + 居中剧名/简介 + 立即观看/收藏 + 轮播点。
class HomeHeroCarousel extends StatefulWidget {
const HomeHeroCarousel({
super.key,
required this.banners,
required this.dramaFor,
required this.onWatch,
this.active = true,
});
final List<FeedBanner> banners;
/// 按 banner 关联到的剧目;为空时只展示头图。
final Drama? Function(FeedBanner banner) dramaFor;
/// 点击「立即观看」或直接点按头图。
final ValueChanged<Drama> onWatch;
final bool active;
/// 固定轮播高度;后台按该比例(屏宽 : height)出图即可铺满不裁切。
static const double height = 420;
@override
State<HomeHeroCarousel> createState() => _HomeHeroCarouselState();
}
class _HomeHeroCarouselState extends State<HomeHeroCarousel> {
static const Duration _autoInterval = Duration(milliseconds: 4500);
static const Duration _pageDuration = Duration(milliseconds: 480);
static const double _dotSize = 4;
static const double _dotGap = 9;
static const double _ctaHeight = 38;
final PageController _controller = PageController();
Timer? _timer;
int _index = 0;
bool _pressed = false;
bool _tickerEnabled = true;
@override
void initState() {
super.initState();
WidgetsBinding.instance.addPostFrameCallback((_) => _syncTimer());
}
@override
void didChangeDependencies() {
super.didChangeDependencies();
final enabled = TickerMode.valuesOf(context).enabled;
if (enabled != _tickerEnabled) {
_tickerEnabled = enabled;
_syncTimer();
}
}
@override
void didUpdateWidget(covariant HomeHeroCarousel oldWidget) {
super.didUpdateWidget(oldWidget);
if (oldWidget.banners.length != widget.banners.length) {
if (_index >= widget.banners.length) _index = 0;
_syncTimer();
}
if (oldWidget.banners.length != widget.banners.length ||
oldWidget.active != widget.active) {
_syncTimer();
}
}
@override
void dispose() {
_timer?.cancel();
_controller.dispose();
super.dispose();
}
void _syncTimer() {
_timer?.cancel();
_timer = null;
final canAdvance = mounted &&
widget.active &&
_tickerEnabled &&
!_pressed &&
widget.banners.length > 1;
if (!canAdvance) return;
_timer = Timer.periodic(_autoInterval, (_) => _advance());
}
void _advance() {
if (!_controller.hasClients || widget.banners.length < 2) return;
final next = (_index + 1) % widget.banners.length;
_controller.animateToPage(
next,
duration: _pageDuration,
curve: Curves.easeOutCubic,
);
}
@override
Widget build(BuildContext context) {
if (widget.banners.isEmpty) return const SizedBox.shrink();
return SizedBox(
key: const Key('home-hero-carousel'),
height: HomeHeroCarousel.height,
child: Listener(
onPointerDown: (_) {
_pressed = true;
_timer?.cancel();
},
onPointerUp: (_) {
_pressed = false;
_syncTimer();
},
onPointerCancel: (_) {
_pressed = false;
_syncTimer();
},
child: Stack(
fit: StackFit.expand,
children: [
PageView.builder(
controller: _controller,
itemCount: widget.banners.length,
onPageChanged: (value) => setState(() => _index = value),
itemBuilder: (context, index) => _bannerPage(context, index),
),
Positioned(left: 0, right: 0, bottom: 14, child: _dots(context)),
],
),
),
);
}
Widget _bannerPage(BuildContext context, int index) {
final banner = widget.banners[index];
final drama = widget.dramaFor(banner);
return Stack(
fit: StackFit.expand,
children: [
RemoteImage(
banner.imageUrl,
fit: BoxFit.cover,
showFallbackIcon: true,
fallbackColor: AppColors.contentSurface,
),
const DecoratedBox(
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [
Color(0x99000000),
Color(0x00000000),
Color(0x66000000),
Color(0xB3000000),
],
stops: [0, 0.22, 0.62, 1],
),
),
),
if (drama != null)
Align(
alignment: const Alignment(0, 0.6),
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 28),
child: _HeroCopy(
key: Key('home-hero-copy-$index'),
drama: drama,
ctaHeight: _ctaHeight,
onWatch: () => widget.onWatch(drama),
),
),
),
if (drama != null)
Positioned.fill(
child: Material(
color: AppColors.transparent,
child: InkWell(
key: Key('home-hero-$index'),
highlightColor: AppColors.transparent,
onTap: () => widget.onWatch(drama),
),
),
),
],
);
}
Widget _dots(BuildContext context) {
if (widget.banners.length < 2) return const SizedBox.shrink();
return ExcludeSemantics(
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
for (var index = 0; index < widget.banners.length; index++)
Container(
key: Key('home-hero-dot-$index'),
width: _dotSize,
height: _dotSize,
margin: const EdgeInsets.symmetric(horizontal: _dotGap / 2),
decoration: BoxDecoration(
shape: BoxShape.circle,
color: index == _index
? AppColors.brandRed
: AppColors.textPrimary.withValues(alpha: 0.4),
),
),
],
),
);
}
}
/// Hero 中部居中文案与按钮组。
class _HeroCopy extends StatelessWidget {
const _HeroCopy({
super.key,
required this.drama,
required this.ctaHeight,
required this.onWatch,
});
final Drama drama;
final double ctaHeight;
final VoidCallback onWatch;
static const Color _titleCream = Color(0xFFE9D3B8);
@override
Widget build(BuildContext context) {
final l10n = AppLocalizations.of(context)!;
final lang = Localizations.localeOf(context).languageCode;
final types = drama.localizedTypeLabels(lang);
final meta = [
if (types.isNotEmpty) types.first,
l10n.totalEpisodesShort(drama.episodeCount),
].join(' · ');
return Column(
key: const Key('home-hero-copy'),
mainAxisSize: MainAxisSize.min,
children: [
Text(
drama.localizedTitle(lang),
maxLines: 1,
overflow: TextOverflow.ellipsis,
textAlign: TextAlign.center,
style: const TextStyle(
color: _titleCream,
fontSize: 28,
fontWeight: FontWeight.w600,
height: 1.15,
shadows: [Shadow(color: Color(0x80000000), blurRadius: 12)],
),
),
const SizedBox(height: 8),
Text(
meta,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: AppColors.textPrimary.withValues(alpha: 0.92),
fontSize: 14,
fontWeight: FontWeight.w400,
),
),
const SizedBox(height: 10),
Text(
drama.localizedSynopsis(lang),
maxLines: 1,
overflow: TextOverflow.ellipsis,
textAlign: TextAlign.center,
style: TextStyle(
color: AppColors.textPrimary.withValues(alpha: 0.95),
fontSize: 15,
fontWeight: FontWeight.w400,
shadows: const [
Shadow(color: Color(0x80000000), blurRadius: 8),
],
),
),
const SizedBox(height: 20),
Row(
mainAxisSize: MainAxisSize.min,
children: [
_WatchButton(height: ctaHeight, label: l10n.watchNowAction, onTap: onWatch),
const SizedBox(width: 12),
_FavoriteCircle(size: ctaHeight, drama: drama),
],
),
],
);
}
}
class _WatchButton extends StatelessWidget {
const _WatchButton({
required this.height,
required this.label,
required this.onTap,
});
final double height;
final String label;
final VoidCallback onTap;
@override
Widget build(BuildContext context) {
return Material(
color: AppColors.brandRed,
borderRadius: BorderRadius.circular(height / 2),
child: InkWell(
key: const Key('home-hero-watch'),
borderRadius: BorderRadius.circular(height / 2),
onTap: onTap,
child: SizedBox(
height: height,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 24),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
const Icon(
Icons.play_arrow_rounded,
size: 20,
color: AppColors.textPrimary,
),
const SizedBox(width: 2),
Text(
label,
style: const TextStyle(
color: AppColors.textPrimary,
fontSize: 16,
fontWeight: FontWeight.w600,
),
),
],
),
),
),
),
);
}
}
class _FavoriteCircle extends StatelessWidget {
const _FavoriteCircle({required this.size, required this.drama});
final double size;
final Drama drama;
@override
Widget build(BuildContext context) {
final favorites = context.watch<FavoriteController>();
final saved = favorites.isSaved(drama.id);
return Material(
color: saved ? AppColors.brandRed : AppColors.transparent,
shape: CircleBorder(
side: BorderSide(
color: saved
? AppColors.brandRed
: AppColors.textPrimary.withValues(alpha: 0.85),
width: 1.5,
),
),
child: InkWell(
key: const Key('home-hero-favorite'),
customBorder: const CircleBorder(),
onTap: () => unawaited(favorites.toggle(drama.id, card: drama)),
child: SizedBox(
width: size,
height: size,
child: Icon(
saved ? Icons.bookmark_rounded : Icons.bookmark_border_rounded,
size: 20,
color: AppColors.textPrimary,
),
),
),
);
}
}
@@ -0,0 +1,252 @@
// Author: fruit.com.cn
import 'package:flutter/material.dart';
import '../../../core/data/models/drama.dart';
import '../../../core/theme/app_colors.dart';
import '../../../core/widgets/remote_image.dart';
import '../../../l10n/app_localizations.dart';
/// 设计稿(首页 1)推荐页内容区规格:
/// 海报卡 110×157、页边距 14、卡距 9、圆角 12。
const double _pageSide = 14;
const double _cardWidth = 110;
const double _cardCoverHeight = 157;
const double _cardGap = 9;
const double _cardRadius = 12;
/// 上新横滑卡板块。无板块标题,卡片左上角带「上新」角标。
/// 内层横向 ListView 会自行识别横向手势,不与外层纵向滚动冲突。
class HomeNewArrivalRow extends StatelessWidget {
const HomeNewArrivalRow({
super.key,
required this.dramas,
required this.onOpen,
});
final List<Drama> dramas;
final ValueChanged<Drama> onOpen;
@override
Widget build(BuildContext context) {
if (dramas.isEmpty) return const SizedBox.shrink();
return SizedBox(
key: const Key('home-new-arrival-row'),
height:
_cardCoverHeight + 8 + 20 + 2 + 16, // 封面 + 剧名行 + 集数行 + 余量
child: ListView.separated(
scrollDirection: Axis.horizontal,
padding: const EdgeInsets.symmetric(horizontal: _pageSide),
itemCount: dramas.length,
separatorBuilder: (_, _) => const SizedBox(width: _cardGap),
itemBuilder: (context, index) => SizedBox(
width: _cardWidth,
child: HomePosterCard(
key: Key('home-new-arrival-${dramas[index].id}'),
drama: dramas[index],
badge: AppLocalizations.of(context)!.newArrivalBadge,
onTap: () => onOpen(dramas[index]),
),
),
),
);
}
}
/// 110×157 海报 + 卡下剧名/集数。
///
/// 封面左上角标签优先用接口返回的短剧标签(`drama.tag` + `drama.tagColor`);
/// 接口没有标签时,若传了 [badge](如「上新」)则退回显示该角标。
class HomePosterCard extends StatelessWidget {
const HomePosterCard({
super.key,
required this.drama,
required this.onTap,
this.badge,
});
final Drama drama;
final VoidCallback onTap;
final String? badge;
@override
Widget build(BuildContext context) {
final l10n = AppLocalizations.of(context)!;
final lang = Localizations.localeOf(context).languageCode;
final tag = drama.localizedTag(lang);
final tagLabel = tag.isNotEmpty ? tag : (badge ?? '');
return InkWell(
onTap: onTap,
borderRadius: BorderRadius.circular(_cardRadius),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
ClipRRect(
borderRadius: BorderRadius.circular(_cardRadius),
child: AspectRatio(
aspectRatio: _cardWidth / _cardCoverHeight,
child: Stack(
fit: StackFit.expand,
children: [
RemoteImage(
drama.posterUrl,
fit: BoxFit.cover,
showFallbackIcon: true,
fallbackColor: AppColors.contentSurface,
),
if (tagLabel.isNotEmpty)
Positioned(
left: 8,
top: 8,
child: Container(
padding: const EdgeInsets.symmetric(
horizontal: 8,
vertical: 3,
),
decoration: BoxDecoration(
color: tag.isNotEmpty
? drama.tagRibbonColor(AppColors.brandRed)
: AppColors.brandRed,
borderRadius: BorderRadius.circular(6),
),
child: Text(
tagLabel,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: const TextStyle(
color: AppColors.textPrimary,
fontSize: 11,
fontWeight: FontWeight.w600,
height: 1.1,
),
),
),
),
],
),
),
),
const SizedBox(height: 8),
Text(
drama.localizedTitle(lang),
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: const TextStyle(
color: AppColors.textPrimary,
fontSize: 14,
fontWeight: FontWeight.w500,
height: 1.2,
),
),
const SizedBox(height: 2),
Text(
l10n.totalEpisodesShort(drama.episodeCount),
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: const TextStyle(
color: AppColors.textTertiary,
fontSize: 12,
height: 1.2,
),
),
],
),
);
}
}
/// 编辑精选横幅:满宽背景图 + 左上小标签、大标题、副标题。
class HomeEditorPickBanner extends StatelessWidget {
const HomeEditorPickBanner({
super.key,
required this.drama,
required this.onOpen,
});
final Drama drama;
final ValueChanged<Drama> onOpen;
@override
Widget build(BuildContext context) {
final l10n = AppLocalizations.of(context)!;
final lang = Localizations.localeOf(context).languageCode;
return Padding(
key: const Key('home-editor-pick'),
padding: const EdgeInsets.symmetric(horizontal: _pageSide),
child: SizedBox(
height: 72,
child: ClipRRect(
borderRadius: BorderRadius.circular(_cardRadius),
child: Stack(
fit: StackFit.expand,
children: [
RemoteImage(
drama.posterUrl,
fit: BoxFit.cover,
showFallbackIcon: true,
fallbackColor: AppColors.contentSurface,
),
const DecoratedBox(
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.centerLeft,
end: Alignment.centerRight,
colors: [Color(0xE6000000), Color(0x4D000000), Color(0x1A000000)],
),
),
),
Positioned.fill(
child: Material(
color: AppColors.transparent,
child: InkWell(onTap: () => onOpen(drama)),
),
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 14),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
l10n.editorPick,
maxLines: 1,
style: TextStyle(
color: AppColors.textPrimary.withValues(alpha: 0.85),
fontSize: 11,
fontWeight: FontWeight.w500,
letterSpacing: 2,
),
),
const SizedBox(height: 4),
Text(
drama.localizedTitle(lang),
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: const TextStyle(
color: AppColors.textPrimary,
fontSize: 18,
fontWeight: FontWeight.w600,
height: 1.15,
),
),
const SizedBox(height: 2),
Text(
drama.localizedSynopsis(lang),
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: AppColors.textPrimary.withValues(alpha: 0.8),
fontSize: 12,
),
),
],
),
),
],
),
),
),
);
}
}
@@ -6,7 +6,6 @@ import '../../../core/data/models/drama.dart';
import '../../../core/data/models/playlist_detail.dart';
import '../../../core/theme/app_colors.dart';
import '../../../core/theme/app_dimens.dart';
import '../../../core/theme/app_theme.dart';
import '../../../core/widgets/app_pull_to_refresh.dart';
import '../../../core/widgets/paged_list_footer.dart';
import '../../../core/widgets/remote_image.dart';
@@ -19,6 +18,8 @@ const int _collageCoverCount = 5;
const double _loadMoreThreshold = 200;
const double _pageHorizontal = 14;
const double _gridGap = 10;
// 与「全部短剧」共用 HomeFeedCard,正文高度同样按 68 预留(标题两行 + 间距 + 标签行)。
const double _cardBodyExtent = 68;
const double _sprocketBand = 22;
const Color _filmBody = Color(0xFF161311);
const Color _filmHole = Color(0xFFE6D3BE);
@@ -111,13 +112,23 @@ class _PlaylistDetailPageState extends State<PlaylistDetailPage> {
Widget build(BuildContext context) {
final width = MediaQuery.sizeOf(context).width;
final itemWidth = (width - _pageHorizontal * 2 - _gridGap) / 2;
final itemExtent =
itemWidth / AppDimens.cardCoverAspectRatio + AppDimens.homeCardBodyExtent;
final itemExtent = itemWidth / AppDimens.cardCoverAspectRatio + _cardBodyExtent;
return Scaffold(
key: const Key('playlist-detail-page'),
backgroundColor: AppColors.ink,
body: DecoratedBox(
decoration: const BoxDecoration(gradient: AppTheme.pageGradient),
decoration: const BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [
AppColors.followingGlow,
AppColors.followingGlowMid,
AppColors.appBackground,
],
stops: [0, 0.14, 0.3],
),
),
child: SafeArea(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
@@ -176,7 +187,7 @@ class _PlaylistDetailPageState extends State<PlaylistDetailPage> {
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
crossAxisSpacing: _gridGap,
mainAxisSpacing: 16,
mainAxisSpacing: 10,
mainAxisExtent: itemExtent,
),
delegate: SliverChildBuilderDelegate(
@@ -228,7 +239,7 @@ class _PlaylistDetailPageState extends State<PlaylistDetailPage> {
style: const TextStyle(
color: AppColors.textPrimary,
fontSize: AppDimens.recommendSectionTitle,
fontWeight: FontWeight.w700,
fontWeight: FontWeight.w400,
),
),
const SizedBox(height: 2),
@@ -0,0 +1,219 @@
// Author: fruit.com.cn
import 'package:flutter/material.dart';
import '../../../core/data/models/content_category.dart';
import '../../../core/theme/app_colors.dart';
import '../../../l10n/app_localizations.dart';
import 'search_gift_glyphs.dart';
const double _navHeight = 56;
const double _tabGap = 20;
const double _tabFont = 17;
const double _searchHitSize = 40;
const double _searchIconSize = 26;
const double _giftIconSize = 26;
const double _underlineWidth = 26;
const double _underlineHeight = 3;
/// 推荐页(礼花 tab)顶部频道导航:频道全部来自分类接口,右侧搜索/礼物。
class RecommendChannelNav extends StatefulWidget {
const RecommendChannelNav({
super.key,
required this.categories,
required this.selectedId,
required this.onSelected,
required this.onSearch,
this.onGift,
});
static const double height = _navHeight;
/// 接口返回的内容分类(首项即「精选」)。
final List<ContentCategory> categories;
final String? selectedId;
final ValueChanged<String> onSelected;
final VoidCallback onSearch;
/// 右上角金色礼物盒(钱包入口);为空时不显示。
final VoidCallback? onGift;
@override
State<RecommendChannelNav> createState() => _RecommendChannelNavState();
}
class _RecommendChannelNavState extends State<RecommendChannelNav> {
static const double _revealLeftInset = 20;
final ScrollController _scrollController = ScrollController();
final GlobalKey _scrollViewKey = GlobalKey();
final Map<String, GlobalKey> _tabKeys = {};
GlobalKey _keyFor(String id) =>
_tabKeys.putIfAbsent(id, () => GlobalKey());
@override
void didUpdateWidget(covariant RecommendChannelNav oldWidget) {
super.didUpdateWidget(oldWidget);
if (widget.selectedId != null &&
(widget.selectedId != oldWidget.selectedId ||
widget.categories.length != oldWidget.categories.length)) {
WidgetsBinding.instance.addPostFrameCallback((_) => _revealSelected());
}
}
@override
void dispose() {
_scrollController.dispose();
super.dispose();
}
/// 把选中频道平滑滚动到可视区域:对齐到滚动区左缘 20pt。
void _revealSelected() {
final id = widget.selectedId;
if (id == null || !_scrollController.hasClients) return;
final tabCtx = _tabKeys[id]?.currentContext;
final tabBox = tabCtx?.findRenderObject() as RenderBox?;
final scrollBox =
_scrollViewKey.currentContext?.findRenderObject() as RenderBox?;
if (tabBox == null || scrollBox == null) return;
final viewportLeft = scrollBox.localToGlobal(Offset.zero).dx;
final tabLeft = tabBox.localToGlobal(Offset.zero).dx;
final relative = tabLeft - viewportLeft;
final position = _scrollController.position;
final target =
(position.pixels + relative - _revealLeftInset)
.clamp(0.0, position.maxScrollExtent);
if ((target - position.pixels).abs() < 0.5) return;
_scrollController.animateTo(
target,
duration: const Duration(milliseconds: 300),
curve: Curves.easeOut,
);
}
@override
Widget build(BuildContext context) {
final l10n = AppLocalizations.of(context)!;
final lang = Localizations.localeOf(context).languageCode;
final categories = widget.categories;
final tabs = <(String, String, String)>[
for (final category in categories)
(category.id, category.localizedName(lang), category.id),
];
return SizedBox(
key: const Key('recommend-channel-nav'),
height: RecommendChannelNav.height,
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Expanded(
child: SingleChildScrollView(
key: _scrollViewKey,
controller: _scrollController,
scrollDirection: Axis.horizontal,
padding: const EdgeInsets.only(left: 20, right: 8),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
for (var index = 0; index < tabs.length; index++) ...[
if (index > 0) const SizedBox(width: _tabGap),
KeyedSubtree(
key: _keyFor(tabs[index].$3),
child: _tab(
key: Key('recommend-tab-${tabs[index].$3}'),
code: tabs[index].$3,
label: tabs[index].$2,
selected: widget.selectedId == tabs[index].$1,
onTap: () => widget.onSelected(tabs[index].$1),
),
),
],
],
),
),
),
SizedBox.square(
dimension: _searchHitSize,
child: IconButton(
key: const Key('recommend-search'),
tooltip: l10n.search,
onPressed: widget.onSearch,
padding: EdgeInsets.zero,
constraints: const BoxConstraints.tightFor(
width: _searchHitSize,
height: _searchHitSize,
),
iconSize: _searchIconSize,
color: AppColors.textPrimary,
icon: SearchGlyph(size: _searchIconSize, color: AppColors.textPrimary),
),
),
if (widget.onGift != null)
SizedBox.square(
dimension: _searchHitSize,
child: IconButton(
key: const Key('recommend-gift'),
tooltip: l10n.wallet,
onPressed: widget.onGift,
padding: EdgeInsets.zero,
constraints: const BoxConstraints.tightFor(
width: _searchHitSize,
height: _searchHitSize,
),
iconSize: _giftIconSize,
icon: GiftGlyph(size: _giftIconSize),
),
),
const SizedBox(width: 8),
],
),
);
}
Widget _tab({
required Key key,
required String code,
required String label,
required bool selected,
required VoidCallback onTap,
}) {
return GestureDetector(
key: key,
behavior: HitTestBehavior.opaque,
onTap: onTap,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
// 补偿文字下方的 4pt 间距 + 3pt 下划线,让文字视觉中心与右侧图标对齐。
const SizedBox(height: 4 + _underlineHeight),
Text(
label,
maxLines: 1,
style: TextStyle(
color: AppColors.textPrimary,
fontSize: _tabFont,
fontWeight: selected ? FontWeight.w700 : FontWeight.w400,
letterSpacing: 0,
height: 1.0,
shadows: const [
Shadow(color: AppColors.mediaBlack, blurRadius: 6),
],
),
),
const SizedBox(height: 4),
Container(
key: Key('recommend-tab-$code-underline'),
width: _underlineWidth,
height: _underlineHeight,
decoration: BoxDecoration(
color: selected ? AppColors.brandRed : AppColors.transparent,
borderRadius: BorderRadius.circular(_underlineHeight / 2),
),
),
],
),
);
}
}
@@ -92,7 +92,7 @@ class RecommendSectionsView extends StatelessWidget {
dramas: hits.take(_sectionPreviewCount).toList(),
onMore: () => onMore(RecommendSectionKind.hits),
),
const SizedBox(height: AppDimens.spaceXl),
const SizedBox(height: AppDimens.recommendSectionGap),
_section(
context,
l10n,
@@ -102,7 +102,7 @@ class RecommendSectionsView extends StatelessWidget {
dramas: newest.take(_sectionPreviewCount).toList(),
onMore: () => onMore(RecommendSectionKind.newReleases),
),
const SizedBox(height: AppDimens.spaceXl),
const SizedBox(height: AppDimens.recommendSectionGap),
_section(
context,
l10n,
@@ -150,7 +150,7 @@ class RecommendSectionsView extends StatelessWidget {
final sections = <Widget>[];
for (final playlist in remote.items) {
if (sections.isNotEmpty) {
sections.add(const SizedBox(height: AppDimens.spaceXl));
sections.add(const SizedBox(height: AppDimens.recommendSectionGap));
}
sections.add(
_section(
@@ -238,7 +238,7 @@ class RecommendSectionsView extends StatelessWidget {
style: const TextStyle(
color: AppColors.textPrimary,
fontSize: AppDimens.recommendSectionTitle,
fontWeight: FontWeight.w700,
fontWeight: FontWeight.w400,
),
),
const SizedBox(height: 2),
@@ -277,7 +277,7 @@ class RecommendSectionsView extends StatelessWidget {
],
),
),
const SizedBox(height: AppDimens.spaceMd),
const SizedBox(height: AppDimens.spaceXs),
SizedBox(
height: AppDimens.recommendRowHeight,
child: ListView.separated(
@@ -3,16 +3,18 @@
import 'package:flutter/material.dart';
import '../../../core/theme/app_colors.dart';
import '../../../core/theme/app_dimens.dart';
import '../../../l10n/app_localizations.dart';
import '../recommend_types.dart';
import 'search_gift_glyphs.dart';
const double _navHeight = 56;
const double _tabGap = 22;
const double _tabGap = 20;
const double _tabFont = 17;
const double _searchHitSize = 40;
const double _searchIconSize = 26;
const double _minNavWidth = 280;
const double _giftIconSize = 26;
const double _underlineWidth = 26;
const double _underlineHeight = 3;
class RecommendTopNav extends StatelessWidget {
const RecommendTopNav({
@@ -21,6 +23,7 @@ class RecommendTopNav extends StatelessWidget {
required this.onSelected,
required this.onSearch,
this.onVideo = false,
this.onGift,
});
static const double height = _navHeight;
@@ -30,6 +33,9 @@ class RecommendTopNav extends StatelessWidget {
final VoidCallback onSearch;
final bool onVideo;
/// 右上角金色礼物盒(钱包入口);为空时不显示。
final VoidCallback? onGift;
@override
Widget build(BuildContext context) {
final l10n = AppLocalizations.of(context)!;
@@ -41,34 +47,16 @@ class RecommendTopNav extends StatelessWidget {
final shadows = onVideo
? const [Shadow(color: AppColors.mediaBlack, blurRadius: 6)]
: null;
return LayoutBuilder(
builder: (context, constraints) {
if (constraints.maxWidth < _minNavWidth) {
return const SizedBox(key: Key('recommend-top-nav'), height: height);
}
return _bar(context, items, shadows);
},
);
}
Widget _bar(
BuildContext context,
List<(RecommendInnerTab, String, String)> items,
List<Shadow>? shadows,
) {
final l10n = AppLocalizations.of(context)!;
return SizedBox(
key: const Key('recommend-top-nav'),
height: height,
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: AppDimens.feedPageHorizontal,
),
child: Stack(
alignment: Alignment.center,
children: [
FittedBox(
fit: BoxFit.scaleDown,
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Expanded(
child: SingleChildScrollView(
scrollDirection: Axis.horizontal,
padding: const EdgeInsets.only(left: 20, right: 8),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
@@ -76,6 +64,7 @@ class RecommendTopNav extends StatelessWidget {
if (index > 0) const SizedBox(width: _tabGap),
_tab(
key: Key('recommend-tab-${items[index].$3}'),
code: items[index].$3,
label: items[index].$2,
selected: selected == items[index].$1,
shadows: shadows,
@@ -85,33 +74,48 @@ class RecommendTopNav extends StatelessWidget {
],
),
),
Align(
alignment: Alignment.centerRight,
child: SizedBox.square(
dimension: _searchHitSize,
child: IconButton(
key: const Key('recommend-search'),
tooltip: l10n.search,
onPressed: onSearch,
padding: EdgeInsets.zero,
constraints: const BoxConstraints.tightFor(
width: _searchHitSize,
height: _searchHitSize,
),
iconSize: _searchIconSize,
color: AppColors.textPrimary,
icon: const Icon(Icons.search_rounded),
),
SizedBox.square(
dimension: _searchHitSize,
child: IconButton(
key: const Key('recommend-search'),
tooltip: l10n.search,
onPressed: onSearch,
padding: EdgeInsets.zero,
constraints: const BoxConstraints.tightFor(
width: _searchHitSize,
height: _searchHitSize,
),
iconSize: _searchIconSize,
color: AppColors.textPrimary,
icon: SearchGlyph(size: _searchIconSize, color: AppColors.textPrimary),
),
),
if (onGift != null)
SizedBox.square(
dimension: _searchHitSize,
child: IconButton(
key: const Key('recommend-gift'),
tooltip: l10n.wallet,
onPressed: onGift,
padding: EdgeInsets.zero,
constraints: const BoxConstraints.tightFor(
width: _searchHitSize,
height: _searchHitSize,
),
iconSize: _giftIconSize,
icon: GiftGlyph(size: _giftIconSize),
),
),
],
),
const SizedBox(width: 8),
],
),
);
}
Widget _tab({
required Key key,
required String code,
required String label,
required bool selected,
required List<Shadow>? shadows,
@@ -121,23 +125,34 @@ class RecommendTopNav extends StatelessWidget {
key: key,
behavior: HitTestBehavior.opaque,
onTap: onTap,
child: SizedBox(
height: height,
child: Center(
child: Text(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
// 补偿文字下方的 4pt 间距 + 3pt 下划线,让文字视觉中心与右侧图标对齐。
const SizedBox(height: 4 + _underlineHeight),
Text(
label,
maxLines: 1,
style: TextStyle(
color: selected
? AppColors.textPrimary
: AppColors.textTabInactive,
color: AppColors.textPrimary,
fontSize: _tabFont,
fontWeight: selected ? FontWeight.w700 : FontWeight.w400,
letterSpacing: 0,
height: 1.0,
shadows: shadows,
),
),
),
const SizedBox(height: 4),
Container(
key: Key('recommend-tab-$code-underline'),
width: _underlineWidth,
height: _underlineHeight,
decoration: BoxDecoration(
color: selected ? AppColors.brandRed : AppColors.transparent,
borderRadius: BorderRadius.circular(_underlineHeight / 2),
),
),
],
),
);
}
@@ -0,0 +1,78 @@
// Author: fruit.com.cn
import 'dart:math' as math;
import 'package:flutter/material.dart';
/// 首页右上角搜索/礼物图标的自定义样式:
/// 搜索为粗线条放大镜(Material 图标无法调线条粗细),礼物为 emoji 红金礼盒。
/// 粗线条白色放大镜,圆环在左上、手柄朝右下。
class SearchGlyph extends StatelessWidget {
const SearchGlyph({super.key, required this.size, required this.color});
final double size;
final Color color;
@override
Widget build(BuildContext context) {
return CustomPaint(
size: Size.square(size),
painter: _SearchPainter(color: color),
);
}
}
class _SearchPainter extends CustomPainter {
const _SearchPainter({required this.color});
final Color color;
@override
void paint(Canvas canvas, Size size) {
final stroke = size.width * 0.09;
final paint = Paint()
..color = color
..style = PaintingStyle.stroke
..strokeWidth = stroke
..strokeCap = StrokeCap.round;
final circleDiameter = size.width * 0.7;
final direction = math.pi / 4;
// 图形只占画布左上角,先平移让它视觉居中,否则会比文字基线偏高。
final drawnExtent =
circleDiameter / 2 +
(circleDiameter / 2 + size.width * 0.12) * math.sin(direction) +
stroke / 2;
final centering = (size.width - drawnExtent) / 2;
canvas.translate(centering, centering);
final center = Offset(circleDiameter / 2, circleDiameter / 2);
canvas.drawCircle(center, circleDiameter / 2 - stroke / 2, paint);
final start = center + Offset.fromDirection(direction, circleDiameter / 2 - stroke * 0.2);
final end = center + Offset.fromDirection(direction, circleDiameter / 2 + size.width * 0.12);
canvas.drawLine(start, end, paint);
}
@override
bool shouldRepaint(covariant _SearchPainter oldDelegate) =>
oldDelegate.color != color;
}
/// emoji 礼盒(红盒金丝带,随系统 emoji 风格渲染)。
class GiftGlyph extends StatelessWidget {
const GiftGlyph({super.key, required this.size});
final double size;
@override
Widget build(BuildContext context) {
return SizedBox.square(
dimension: size,
child: FittedBox(
child: Text('🎁', style: TextStyle(fontSize: size, height: 1)),
),
);
}
}
+17 -4
View File
@@ -24,16 +24,17 @@ class LegalLinksCard extends StatelessWidget {
key: const Key('settings-terms'),
title: l10n.legalTerms,
path: legalTermsPath,
icon: Icons.article_outlined,
),
_LegalRow(
key: const Key('settings-privacy'),
title: l10n.legalPrivacy,
path: legalPrivacyPath,
icon: Icons.shield_outlined,
),
];
return Material(
color: AppColors.card,
borderRadius: BorderRadius.circular(AppDimens.cardRadius),
color: AppColors.contentSurface,
clipBehavior: Clip.antiAlias,
child: Column(
children: [
@@ -42,7 +43,7 @@ class LegalLinksCard extends StatelessWidget {
const Divider(
height: AppDimens.mineGridDividerWidth,
thickness: AppDimens.mineGridDividerWidth,
color: AppColors.outlineVariantDark,
color: AppColors.contentBorder,
),
_tile(context, rows[index]),
],
@@ -61,6 +62,12 @@ class LegalLinksCard extends StatelessWidget {
padding: const EdgeInsets.symmetric(horizontal: AppDimens.spaceLg),
child: Row(
children: [
Icon(
row.icon,
color: AppColors.textSecondary,
size: 20,
),
const SizedBox(width: 10),
Expanded(
child: Text(
row.title,
@@ -96,9 +103,15 @@ class LegalLinksCard extends StatelessWidget {
}
class _LegalRow {
const _LegalRow({required this.key, required this.title, required this.path});
const _LegalRow({
required this.key,
required this.title,
required this.path,
required this.icon,
});
final Key key;
final String title;
final String path;
final IconData icon;
}
+172 -23
View File
@@ -1,17 +1,17 @@
// Author: fruit.com.cn
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import '../../core/data/services/auth_controller.dart';
import '../../core/theme/app_colors.dart';
import '../../core/theme/app_dimens.dart';
import '../../core/theme/app_theme.dart';
import '../../core/widgets/auth_gate.dart';
import '../../core/widgets/app_glow_panel.dart';
import '../../core/widgets/plain_page_scaffold.dart';
import '../../l10n/app_localizations.dart';
import '../account/account_entry_card.dart';
import '../mine/about_page.dart';
import 'legal_links_card.dart';
/// 设置页:账号入口按列表展示,不提供通知和手动语言切换。
@@ -31,35 +31,184 @@ class SettingsPage extends StatelessWidget {
child: ListView(
padding: const EdgeInsets.fromLTRB(14, 8, 14, 28),
children: [
Container(
key: const Key('settings-group'),
decoration: BoxDecoration(
color: AppColors.contentSurface,
borderRadius: BorderRadius.circular(AppDimens.cardRadius),
),
clipBehavior: Clip.antiAlias,
child: Column(
children: [
if (auth.isSignedIn) ...[
const AccountEntryCard(),
const Divider(
height: AppDimens.mineGridDividerWidth,
thickness: AppDimens.mineGridDividerWidth,
color: AppColors.contentBorder,
),
],
const LegalLinksCard(),
const Divider(
height: AppDimens.mineGridDividerWidth,
thickness: AppDimens.mineGridDividerWidth,
color: AppColors.contentBorder,
),
_supportSection(context, l10n),
],
),
),
if (auth.isSignedIn) ...[
const AccountEntryCard(),
const SizedBox(height: AppDimens.spaceXl),
const SizedBox(height: 12),
_signOutButton(context, l10n),
],
const LegalLinksCard(),
const SizedBox(height: AppDimens.spaceXl),
_authAction(context, l10n, auth),
],
),
),
);
}
Widget _authAction(
BuildContext context,
AppLocalizations l10n,
AuthController auth,
) {
if (auth.isSignedIn) {
return OutlinedButton(
/// 退出登录:透明背景独立按钮,确认后清除本地会话并吊销刷新令牌。
Widget _signOutButton(BuildContext context, AppLocalizations l10n) {
return SizedBox(
width: double.infinity,
height: 48,
child: TextButton(
key: const Key('settings-sign-out'),
onPressed: () => unawaited(auth.signOut()),
child: Text(l10n.signOut),
);
}
return FilledButton(
key: const Key('settings-sign-in'),
onPressed: () => unawaited(openAuthPage(context)),
child: Text(l10n.signIn),
style: TextButton.styleFrom(
backgroundColor: AppColors.transparent,
foregroundColor: AppColors.error,
),
onPressed: () => _confirmSignOut(context, l10n),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
const Icon(Icons.logout_rounded, size: 18),
const SizedBox(width: 6),
Text(
l10n.signOut,
style: const TextStyle(
fontSize: AppDimens.body,
fontWeight: FontWeight.w400,
),
),
],
),
),
);
}
Future<void> _confirmSignOut(BuildContext context, AppLocalizations l10n) async {
final confirmed = await showDialog<bool>(
context: context,
builder: (dialogContext) => AppGlowDialog(
title: l10n.signOut,
content: l10n.signOutConfirm,
actions: [
TextButton(
onPressed: () => Navigator.of(dialogContext).pop(false),
child: Text(l10n.cancel),
),
TextButton(
style: TextButton.styleFrom(foregroundColor: AppColors.error),
onPressed: () => Navigator.of(dialogContext).pop(true),
child: Text(l10n.signOut),
),
],
),
);
if (confirmed != true || !context.mounted) return;
await context.read<AuthController>().signOut();
}
/// 常见问题 / 关于我们。
Widget _supportSection(BuildContext context, AppLocalizations l10n) {
return Container(
key: const Key('settings-support'),
decoration: const BoxDecoration(color: AppColors.contentSurface),
clipBehavior: Clip.antiAlias,
child: Column(
children: [
_row(
key: const Key('settings-common-questions'),
label: l10n.helpFeedback,
icon: Icons.help_outline,
onTap: () => _pushPlaceholder(context, l10n),
),
const Divider(
height: 1,
thickness: 1,
color: AppColors.contentBorder,
),
_row(
key: const Key('settings-about'),
label: l10n.aboutUs,
icon: Icons.info_outline,
onTap: () => Navigator.of(context).push(
MaterialPageRoute<void>(builder: (_) => const MineAboutPage()),
),
),
],
),
);
}
Widget _row({
required Key key,
required String label,
required IconData icon,
required VoidCallback onTap,
}) {
return SizedBox(
height: 56,
child: InkWell(
key: key,
onTap: onTap,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Row(
children: [
Icon(icon, color: AppColors.textSecondary, size: 20),
const SizedBox(width: 10),
Expanded(
child: Text(
label,
style: const TextStyle(
color: AppColors.textPrimary,
fontSize: AppDimens.body,
),
),
),
const Icon(
Icons.chevron_right_rounded,
color: AppColors.textSecondary,
size: 20,
),
],
),
),
),
);
}
void _pushPlaceholder(BuildContext context, AppLocalizations l10n) {
Navigator.of(context).push(
MaterialPageRoute<void>(
builder: (_) => PlainPageScaffold(
pageKey: const Key('settings-placeholder-page'),
backKey: const Key('settings-placeholder-back'),
title: l10n.helpFeedback,
child: Center(
child: Text(
l10n.comingSoon,
style: const TextStyle(
color: AppColors.textSecondary,
fontSize: AppDimens.body,
),
),
),
),
),
);
}
}
@@ -14,6 +14,7 @@ import '../../core/formatting/error_text.dart';
import '../../core/platform/haptics.dart';
import '../../core/theme/app_colors.dart';
import '../../core/theme/app_theme.dart';
import '../../core/widgets/app_glow_panel.dart';
import '../../core/widgets/app_pull_to_refresh.dart';
import '../../core/widgets/empty_state.dart';
import '../../core/widgets/paged_list_footer.dart';
@@ -255,15 +256,15 @@ class _WatchRecordsBodyState extends State<_WatchRecordsBody> {
final l10n = AppLocalizations.of(context)!;
final confirmed = await showDialog<bool>(
context: context,
builder: (dialogContext) => AlertDialog(
title: Text(l10n.clearWatchHistoryTitle),
content: Text(l10n.clearWatchHistoryMessage),
builder: (dialogContext) => AppGlowDialog(
title: l10n.clearWatchHistoryTitle,
content: l10n.clearWatchHistoryMessage,
actions: [
TextButton(
onPressed: () => Navigator.of(dialogContext).pop(false),
child: Text(l10n.cancel),
),
FilledButton(
TextButton(
onPressed: () => Navigator.of(dialogContext).pop(true),
child: Text(l10n.confirmClear),
),
@@ -115,7 +115,7 @@ class WatchRecordCard extends StatelessWidget {
value: record.progress.fraction,
backgroundColor: AppColors.border,
valueColor: const AlwaysStoppedAnimation(
AppColors.blue,
AppColors.brandRed,
),
),
),
+56
View File
@@ -153,6 +153,14 @@ packages:
url: "https://pub.flutter-io.cn"
source: hosted
version: "7.0.1"
floating:
dependency: "direct main"
description:
name: floating
sha256: e51ce1dbcab3ea83da0ad1b07f2091b99c0e8680184c780a000567f41234d454
url: "https://pub.flutter-io.cn"
source: hosted
version: "6.0.0"
flutter:
dependency: "direct main"
description: flutter
@@ -436,6 +444,54 @@ packages:
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.3.0"
permission_handler:
dependency: "direct main"
description:
name: permission_handler
sha256: e6bcecadfe40df6b888141f23cbaf6ba6c3da49fb33f6ff887d060dd48544fbd
url: "https://pub.flutter-io.cn"
source: hosted
version: "13.0.2"
permission_handler_android:
dependency: transitive
description:
name: permission_handler_android
sha256: b1ce660f4d0dcaffdf2605a19544c129fb5adda4e6fd039992ae356c4e437039
url: "https://pub.flutter-io.cn"
source: hosted
version: "14.1.0"
permission_handler_apple:
dependency: transitive
description:
name: permission_handler_apple
sha256: b69e6b8300f9584af5ab81b41cdaa544e1b45e6fca0a30b0f9a9a120d90fc8a5
url: "https://pub.flutter-io.cn"
source: hosted
version: "9.6.4"
permission_handler_html:
dependency: transitive
description:
name: permission_handler_html
sha256: "6ea98b3f17f60d3b527f2647ed2ab4dc0f6bfe25b22cb1c363f5d8f62252f6ac"
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.1.4+1"
permission_handler_platform_interface:
dependency: transitive
description:
name: permission_handler_platform_interface
sha256: ed86a61c190258fdd65de395ea0632822e3415c1faec38eae0c31b479c28a531
url: "https://pub.flutter-io.cn"
source: hosted
version: "4.4.1"
permission_handler_windows:
dependency: transitive
description:
name: permission_handler_windows
sha256: caeae01858a0a7d2df67a445ac98e1ad95e55a0e77c73044f4e9b1c8c2289cbd
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.2.2"
petitparser:
dependency: transitive
description:
+5
View File
@@ -48,6 +48,10 @@ dependencies:
sdk: flutter
path_provider: 2.1.5
html: ^0.15.6
# 画中画:Android 原生 PiP,OnLeavePiP 支持退后台自动进小窗
floating: ^6.0.0
# 运行时权限:systemAlertWindow(「显示在其他应用上层」)
permission_handler: ^13.0.2
dev_dependencies:
flutter_test:
@@ -86,6 +90,7 @@ flutter:
- assets/icon/splash_logo.png
- assets/icon/splash_logo_android12.png
- assets/icon/rail/
- assets/auth/
# To add assets to your application, add an assets section, like this:
# assets:
+3 -1
View File
@@ -32,7 +32,9 @@ void main() {
await tester.pumpAndSettle();
expect(find.byKey(const Key('mine-account-card')), findsNothing);
expect(find.byKey(const Key('settings-sign-in')), findsOneWidget);
// 未登录时设置页不再提供登录入口,也不显示退出登录按钮。
expect(find.byKey(const Key('settings-page')), findsOneWidget);
expect(find.byKey(const Key('settings-sign-out')), findsNothing);
});
testWidgets('should_show_four_account_entries_when_signed_in', (
+28 -9
View File
@@ -25,6 +25,21 @@ void main() {
setUp(() {
SharedPreferencesAsyncPlatform.instance =
InMemorySharedPreferencesAsync.empty();
// 注册流程会通过 device 通道读取设备国家;widget 测试没有原生实现,
// 不打桩这个通道调用会一直等不到回复(提交按钮转圈、pumpAndSettle 超时)。
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
.setMockMethodCallHandler(
const MethodChannel('com.stormg.lumadrama/device'),
(call) async => call.method == 'region' ? 'ID' : null,
);
});
tearDown(() {
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
.setMockMethodCallHandler(
const MethodChannel('com.stormg.lumadrama/device'),
null,
);
});
Future<void> pumpAuthPage(
@@ -179,11 +194,16 @@ void main() {
await pumpAuthPage(tester);
expect(find.text('Welcome back'), findsOneWidget);
await tester.tap(find.text('New here? Create an account'));
// 新版用顶部 Sign In / Sign Up 分段切换,不再有底部文字链接。
await tester.tap(find.byKey(const Key('auth-mode-sign-up')));
await tester.pumpAndSettle();
expect(find.text('Create your account'), findsOneWidget);
expect(find.text('Already have an account? Sign in'), findsOneWidget);
expect(find.text('Welcome back'), findsNothing);
await tester.tap(find.byKey(const Key('auth-mode-sign-in')));
await tester.pumpAndSettle();
expect(find.text('Welcome back'), findsOneWidget);
},
);
@@ -208,10 +228,6 @@ void main() {
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_toggle_password_visibility_when_eye_button_is_tapped', (
@@ -287,8 +303,8 @@ void main() {
);
expect(
tester
.widget<TextButton>(find.byKey(const Key('auth-switch-mode')))
.onPressed,
.widget<GestureDetector>(find.byKey(const Key('auth-mode-sign-up')))
.onTap,
isNull,
);
@@ -316,12 +332,14 @@ void main() {
(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);
// 键盘在邮箱表单打开之后再弹出(落地页按可用高度分段排版,不适合压到 240 高)。
tester.view.viewInsets = const FakeViewPadding(bottom: 260);
await tester.pumpAndSettle();
await tester.scrollUntilVisible(
find.byKey(const Key('auth-submit')),
120,
@@ -474,6 +492,7 @@ class _FailingAuthApi extends AuthApi {
required String email,
required String password,
required String deviceId,
String countryCode = '',
String platform = '',
String osVersion = '',
String appVersion = '',
+52 -45
View File
@@ -13,7 +13,6 @@ 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/core/theme/app_dimens.dart';
import 'package:fruitshorts/l10n/app_localizations.dart';
import 'package:fruitshorts/pages/auth/auth_view.dart';
@@ -78,13 +77,13 @@ void main() {
expect(find.byKey(const Key('auth-landing')), findsOneWidget);
expect(find.text('FruitShorts'), findsOneWidget);
expect(
find.text('Sign in to sync progress, favorites and coins'),
findsOneWidget,
);
final brand = tester.widget<Text>(find.text('FruitShorts'));
expect(brand.style?.fontSize, 26);
expect(brand.style?.fontWeight, FontWeight.w700);
expect(brand.style?.letterSpacing, 2);
expect(
tester.getSize(find.byKey(const Key('auth-brand-logo'))),
const Size(72, 72),
const Size(88, 88),
);
expect(find.byKey(const Key('auth-entry-google')), findsNothing);
expect(find.byKey(const Key('auth-entry-phone')), findsOneWidget);
@@ -92,11 +91,11 @@ void main() {
expect(find.byKey(const Key('auth-legal')), findsOneWidget);
expect(
tester.getSize(find.byKey(const Key('auth-entry-phone'))).height,
50,
52,
);
expect(
tester.getSize(find.byKey(const Key('auth-entry-email'))).height,
50,
52,
);
final phoneButton = tester.widget<Material>(
find.descendant(
@@ -104,67 +103,68 @@ void main() {
matching: find.byType(Material),
),
);
expect(phoneButton.color, AppColors.blue);
expect(phoneButton.color, AppColors.brandRed);
expect(
(phoneButton.shape! as RoundedRectangleBorder).borderRadius,
BorderRadius.circular(26),
);
final emailButton = tester.widget<Material>(
find.descendant(
of: find.byKey(const Key('auth-entry-email')),
matching: find.byType(Material),
),
);
expect(emailButton.color, AppColors.card);
expect(
(emailButton.shape! as RoundedRectangleBorder).side.color,
AppColors.border,
);
// 次按钮是「白 6%」玻璃拟态,不再有描边。
expect(emailButton.color, Colors.white.withValues(alpha: 0.06));
final glow = tester.widget<Container>(
find.byKey(const Key('auth-background-glow')),
final glow = tester.widget<DecoratedBox>(
find.byKey(const Key('auth-red-glow')),
);
final glowDecoration = glow.decoration! as BoxDecoration;
final glowDecoration = glow.decoration as BoxDecoration;
final gradient = glowDecoration.gradient! as RadialGradient;
expect(gradient.colors.first, AppColors.surfaceTop);
expect(gradient.colors.last.a, 0);
expect(gradient.colors, const [
AppColors.primaryBorder,
AppColors.transparent,
]);
await tester.tap(find.byKey(const Key('auth-entry-email')));
await tester.pumpAndSettle();
final card = tester.widget<Container>(find.byKey(const Key('auth-card')));
final cardDecoration = card.decoration! as BoxDecoration;
expect(cardDecoration.color, AppColors.card);
expect(
cardDecoration.borderRadius,
BorderRadius.circular(AppDimens.authCardRadius),
);
expect(cardDecoration.boxShadow, isNull);
expect(card.padding, const EdgeInsets.all(20));
// 新版表单不再套卡片盒子,直接排在光晕背景上。
expect(find.byKey(const Key('auth-card')), findsOneWidget);
final email = tester.widget<TextField>(
find.byKey(const Key('auth-email')),
);
expect(email.decoration?.fillColor, AppColors.card);
expect(
email.decoration?.fillColor,
Colors.white.withValues(alpha: 0.05),
);
expect(email.style?.color, AppColors.onSurface);
expect(email.style?.fontSize, 15);
expect(email.cursorColor, AppColors.blue);
expect(email.cursorColor, AppColors.brandRed);
expect(tester.getSize(find.byKey(const Key('auth-email'))).height, 52);
final emailBorder =
email.decoration!.enabledBorder! as OutlineInputBorder;
expect(emailBorder.borderRadius, BorderRadius.circular(14));
expect(emailBorder.borderSide.color, AppColors.border);
expect(emailBorder.borderSide.width, 1);
expect(emailBorder.borderRadius, BorderRadius.circular(12));
expect(emailBorder.borderSide, BorderSide.none);
final password = tester.widget<TextField>(
find.byKey(const Key('auth-password')),
);
expect(password.style?.color, AppColors.onSurface);
expect(password.style?.fontSize, 15);
expect(password.cursorColor, AppColors.blue);
expect(password.cursorColor, AppColors.brandRed);
final submit = tester.widget<FilledButton>(
find.byKey(const Key('auth-submit')),
);
expect(submit.style!.backgroundColor!.resolve(const {}), AppColors.blue);
expect(
submit.style!.backgroundColor!.resolve(const {}),
AppColors.brandRed,
);
expect(
submit.style!.backgroundColor!.resolve(const {WidgetState.pressed}),
AppColors.bluePressed,
AppColors.brandRedPressed,
);
expect(tester.getSize(find.byKey(const Key('auth-submit'))).height, 50);
expect(
@@ -201,9 +201,14 @@ void main() {
(image.image as AssetImage).assetName,
'assets/icon/fruitshorts.png',
);
// 新版落地页用三等分 Spacer 排版,Logo 居中且落在两个入口按钮上方。
final logo = find.byKey(const Key('auth-brand-logo'));
expect(tester.getCenter(logo).dx, closeTo(195, 0.1));
expect(
tester.getTopLeft(find.byKey(const Key('auth-brand-logo'))).dy,
84,
tester.getBottomLeft(logo).dy,
lessThan(
tester.getTopLeft(find.byKey(const Key('auth-entry-phone'))).dy,
),
);
},
);
@@ -250,7 +255,7 @@ void main() {
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-up'), AppColors.brandRed);
expect(_segmentColor(tester, 'auth-mode-sign-in'), Colors.transparent);
await tester.tap(find.byKey(const Key('auth-mode-sign-in')));
@@ -258,7 +263,7 @@ void main() {
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-in'), AppColors.brandRed);
expect(_segmentColor(tester, 'auth-mode-sign-up'), Colors.transparent);
},
);
@@ -330,8 +335,10 @@ void main() {
);
expect(
tester
.widget<TextButton>(find.byKey(const Key('auth-switch-mode')))
.onPressed,
.widget<GestureDetector>(
find.byKey(const Key('auth-mode-sign-up')),
)
.onTap,
isNull,
);
expect(
@@ -379,10 +386,10 @@ void main() {
Color? _segmentColor(WidgetTester tester, String key) {
final segment = find.byKey(Key(key));
final animated = tester.widget<AnimatedContainer>(
find.descendant(of: segment, matching: find.byType(AnimatedContainer)),
final underline = tester.widget<Container>(
find.descendant(of: segment, matching: find.byType(Container)),
);
return (animated.decoration! as BoxDecoration).color;
return (underline.decoration! as BoxDecoration).color;
}
class _PendingAuthApi extends AuthApi {
+1 -1
View File
@@ -823,7 +823,7 @@ void main() {
find.byKey(const Key('comment-count-label')),
);
expect(title.style?.fontSize, 16);
expect(title.style?.fontWeight, FontWeight.w600);
expect(title.style?.fontWeight, FontWeight.w400);
expect(
tester.getCenter(find.byKey(const Key('comment-count-label'))).dx,
closeTo(
+34 -14
View File
@@ -28,12 +28,20 @@ void main() {
});
group('platform support', () {
test('should_support_only_android_when_target_is_checked', () {
debugDefaultTargetPlatformOverride = TargetPlatform.android;
expect(pip().isPlatformSupported, isTrue);
test('should_support_android_and_ios_when_target_is_checked', () {
for (final platform in <TargetPlatform>[
TargetPlatform.android,
TargetPlatform.iOS,
]) {
debugDefaultTargetPlatformOverride = platform;
expect(
pip().isPlatformSupported,
isTrue,
reason: '$platform must claim picture in picture support',
);
}
for (final platform in <TargetPlatform>[
TargetPlatform.iOS,
TargetPlatform.macOS,
TargetPlatform.linux,
TargetPlatform.windows,
@@ -50,8 +58,10 @@ void main() {
});
group('enter', () {
test('should_refuse_without_touching_channel_when_target_is_not_android', () async {
debugDefaultTargetPlatformOverride = TargetPlatform.iOS;
const url = 'https://cdn.example.com/episode-1.mp4';
test('should_refuse_without_touching_channel_when_target_is_not_supported', () async {
debugDefaultTargetPlatformOverride = TargetPlatform.macOS;
final calls = <MethodCall>[];
messenger.setMockMethodCallHandler(channel, (call) async {
calls.add(call);
@@ -59,7 +69,10 @@ void main() {
});
addTearDown(() => messenger.setMockMethodCallHandler(channel, null));
expect(await pip().enter(), isFalse);
expect(
await pip().enter(url: url, positionMs: 4200),
isFalse,
);
expect(calls, isEmpty);
});
@@ -68,7 +81,10 @@ void main() {
messenger.setMockMethodCallHandler(channel, (call) async => null);
addTearDown(() => messenger.setMockMethodCallHandler(channel, null));
expect(await pip().enter(), isFalse);
expect(
await pip().enter(url: url, positionMs: 4200),
isFalse,
);
});
test('should_report_entered_when_native_call_succeeds', () async {
@@ -80,16 +96,19 @@ void main() {
});
addTearDown(() => messenger.setMockMethodCallHandler(channel, null));
expect(await pip().enter(), isTrue);
expect(
await pip().enter(url: url, positionMs: 4200),
isTrue,
);
expect(calls.single.method, 'enter');
expect(calls.single.arguments, isNull);
expect(calls.single.arguments, {'url': url, 'positionMs': 4200});
});
});
group('state listener', () {
test('should_deliver_pip_state_changes_in_order_when_native_events_arrive', () async {
final received = <bool>[];
pip().setStateListener(received.add);
pip().setStateListener((active, _) => received.add(active));
await sendToDart('onPipChanged', true);
await sendToDart('onPipChanged', false);
@@ -99,7 +118,7 @@ void main() {
test('should_treat_only_literal_true_as_enabled_when_native_value_arrives', () async {
final received = <bool>[];
pip().setStateListener(received.add);
pip().setStateListener((active, _) => received.add(active));
await sendToDart('onPipChanged', null);
await sendToDart('onPipChanged', 'yes');
@@ -110,7 +129,7 @@ void main() {
test('should_ignore_unrelated_native_methods_when_events_arrive', () async {
final received = <bool>[];
pip().setStateListener(received.add);
pip().setStateListener((active, _) => received.add(active));
await sendToDart('somethingElse', true);
await sendToDart('onPipChanged', true);
@@ -120,7 +139,8 @@ void main() {
test('should_silence_later_callbacks_when_listener_is_cleared', () async {
final received = <bool>[];
final observer = pip()..setStateListener(received.add);
final observer = pip()
..setStateListener((active, _) => received.add(active));
await sendToDart('onPipChanged', true);
observer.setStateListener(null);
+2 -2
View File
@@ -27,11 +27,11 @@ void main() {
);
final title = tester.widget<Text>(find.byKey(const Key('subpage-title')));
expect(title.style?.fontSize, 18);
expect(title.style?.fontWeight, FontWeight.w800);
expect(title.style?.fontWeight, FontWeight.w400);
expect(title.style?.color, AppColors.textPrimary);
final back = tester.getRect(find.byKey(const Key('sample-back')));
final titleRect = tester.getRect(find.byKey(const Key('subpage-title')));
expect(titleRect.left - back.right, closeTo(12, 0.5));
expect(titleRect.left - back.right, closeTo(6, 0.5));
final surface = tester.widget<Material>(
find.descendant(
of: find.byKey(const Key('sample-back')),
+2 -2
View File
@@ -152,7 +152,7 @@ Future<void> _pumpFilterPage(WidgetTester tester) async {
),
);
await tester.pumpAndSettle();
Navigator.of(tester.element(find.byKey(const Key('home-search-entry'))))
Navigator.of(tester.element(find.byKey(const Key('home-tabs'))))
.push<void>(
MaterialPageRoute(builder: (_) => const DiscoverPage()),
);
@@ -193,7 +193,7 @@ void _expectUnifiedHeader(WidgetTester tester, Key backKey) {
expect(tester.getSize(find.byKey(backKey)), const Size(40, 40));
final title = tester.widget<Text>(find.byKey(const Key('subpage-title')));
expect(title.style?.fontSize, 18);
expect(title.style?.fontWeight, FontWeight.w800);
expect(title.style?.fontWeight, FontWeight.w400);
}
Drama _drama({
+1 -1
View File
@@ -424,7 +424,7 @@ Future<void> _pumpTheater(
),
);
await tester.pumpAndSettle();
Navigator.of(tester.element(find.byKey(const Key('home-search-entry'))))
Navigator.of(tester.element(find.byKey(const Key('home-tabs'))))
.push<void>(
MaterialPageRoute(builder: (_) => const DiscoverPage()),
);
+2 -2
View File
@@ -312,7 +312,7 @@ Future<void> _pumpTheater(
),
);
await tester.pumpAndSettle();
Navigator.of(tester.element(find.byKey(const Key('home-search-entry'))))
Navigator.of(tester.element(find.byKey(const Key('home-tabs'))))
.push<void>(
MaterialPageRoute(builder: (_) => const DiscoverPage()),
);
@@ -371,5 +371,5 @@ void _expectUnifiedHeader(WidgetTester tester, Key backKey) {
expect(tester.getSize(find.byKey(backKey)), const Size(40, 40));
final title = tester.widget<Text>(find.byKey(const Key('subpage-title')));
expect(title.style?.fontSize, 18);
expect(title.style?.fontWeight, FontWeight.w800);
expect(title.style?.fontWeight, FontWeight.w400);
}
+1 -1
View File
@@ -159,7 +159,7 @@ void main() {
await tester.pumpAndSettle();
expect(repository.clearCalls, 0);
await tester.tap(find.widgetWithText(FilledButton, 'Clear'));
await tester.tap(find.widgetWithText(TextButton, 'Clear'));
await tester.pumpAndSettle();
expect(repository.clearCalls, 1);
+47 -56
View File
@@ -54,12 +54,18 @@ void main() {
matching: find.byType(AnimatedDefaultTextStyle),
),
);
expect(tab.style.fontSize, AppDimens.followingTabFont);
expect(tab.style.fontWeight, FontWeight.w600);
expect(tab.style.fontSize, AppDimens.followingSegmentFont);
expect(tab.style.fontWeight, FontWeight.w400);
expect(tab.style.color, AppColors.textPrimary);
final editIcon = tester.widget<Icon>(find.byIcon(Icons.edit_outlined));
expect(editIcon.size, AppDimens.followingEditIconSize);
expect(editIcon.color, AppColors.textTabInactive);
// 新版头部右上角是「Manage」文字按钮,不再是编辑图标。
final manage = tester.widget<Text>(
find.descendant(
of: find.byKey(const Key('following-edit')),
matching: find.byType(Text),
),
);
expect(manage.style?.fontSize, AppDimens.followingManageFont);
expect(manage.style?.color, AppColors.textPrimary);
final grid = tester.widget<SliverGrid>(
find.descendant(
of: find.byKey(const Key('following-favorites-grid')),
@@ -93,8 +99,8 @@ void main() {
matching: find.text('The Signal'),
);
final title = tester.widget<Text>(titleFinder);
expect(title.style?.fontSize, AppDimens.cardTitleFont);
expect(title.style?.fontWeight, FontWeight.w500);
expect(title.style?.fontSize, AppDimens.followingCardTitleFontNew);
expect(title.style?.fontWeight, FontWeight.w400);
expect(title.style?.height, AppDimens.cardTitleLineHeight);
final views = tester.widget<Text>(
find.descendant(
@@ -140,47 +146,15 @@ void main() {
await tester.tap(find.byKey(const Key('following-card-the-signal-demo')));
await tester.pumpAndSettle();
// 新版取消追剧不再弹二次确认框,点「取消追剧」即直接移除。
await tester.tap(find.byKey(const Key('following-cancel-follow')));
await tester.pumpAndSettle();
expect(find.text('Unfollow the selected dramas?'), findsOneWidget);
final dialog = tester.widget<AlertDialog>(find.byType(AlertDialog));
expect(dialog.contentPadding, const EdgeInsets.all(20));
expect(dialog.actionsPadding, const EdgeInsets.fromLTRB(20, 0, 20, 20));
expect(
tester
.getSize(
find.descendant(
of: find.byType(AlertDialog),
matching: find.byType(TextButton),
),
)
.height,
32,
);
expect(
tester
.getSize(
find.descendant(
of: find.byType(AlertDialog),
matching: find.byType(FilledButton),
),
)
.height,
32,
);
await tester.tap(
find.descendant(
of: find.byType(AlertDialog),
matching: find.byType(FilledButton),
),
);
await tester.pumpAndSettle();
expect(
find.byKey(const Key('following-select-the-signal-demo')),
findsNothing,
);
expect(find.byIcon(Icons.edit_outlined), findsOneWidget);
expect(find.byKey(const Key('following-edit-bar')), findsNothing);
expect(
find.byKey(const Key('following-card-the-signal-demo')),
findsNothing,
@@ -189,6 +163,7 @@ void main() {
await tester.tap(find.byKey(const Key('following-tab-history')));
await tester.pumpAndSettle();
expect(find.byKey(const Key('following-history-empty')), findsOneWidget);
_drainOverflows(tester);
});
testWidgets('should_unfollow_every_selected_drama_when_edit_confirms', (
@@ -213,13 +188,6 @@ void main() {
await tester.pumpAndSettle();
await tester.tap(find.byKey(const Key('following-cancel-follow')));
await tester.pumpAndSettle();
await tester.tap(
find.descendant(
of: find.byType(AlertDialog),
matching: find.byType(FilledButton),
),
);
await tester.pumpAndSettle();
expect(
find.byKey(const Key('following-card-the-signal-demo')),
@@ -229,8 +197,9 @@ void main() {
find.byKey(const Key('following-card-city-lights-demo')),
findsNothing,
);
expect(find.byIcon(Icons.edit_outlined), findsOneWidget);
expect(find.byKey(const Key('following-edit-bar')), findsNothing);
expect(favorites.removeManyCalls, 1);
_drainOverflows(tester);
});
testWidgets('should_show_device_favorites_and_history_when_signed_out', (
@@ -279,6 +248,7 @@ void main() {
findsOneWidget,
);
expect(find.text('Device history'), findsOneWidget);
_drainOverflows(tester);
});
testWidgets('should_reload_identity_data_after_login_and_logout', (
@@ -346,6 +316,7 @@ void main() {
expect(auth.isSignedIn, isFalse);
expect(find.text('Device history'), findsOneWidget);
expect(find.text('Account history'), findsNothing);
_drainOverflows(tester);
});
testWidgets('should_show_empty_favorites_and_history', (tester) async {
@@ -355,8 +326,9 @@ void main() {
await tester.tap(find.byKey(const Key('tab-follow')));
await tester.pumpAndSettle();
expect(find.byKey(const Key('following-add-card')), findsOneWidget);
expect(find.byKey(const Key('following-favorites-empty')), findsNothing);
// 新版空收藏只显示图标 + 文案,不再摆「+」加号卡片。
expect(find.byKey(const Key('following-add-card')), findsNothing);
expect(find.byKey(const Key('following-favorites-empty')), findsOneWidget);
await tester.tap(find.byKey(const Key('following-tab-history')));
await tester.pumpAndSettle();
expect(find.byKey(const Key('following-history-empty')), findsOneWidget);
@@ -456,13 +428,23 @@ void main() {
matching: find.byType(AnimatedDefaultTextStyle),
),
);
expect(historyTab.style.fontWeight, FontWeight.w600);
expect(historyTab.style.fontWeight, FontWeight.w400);
expect(historyTab.style.color, AppColors.textPrimary);
});
testWidgets('should_open_home_from_add_card', (tester) async {
_signIn();
await tester.pumpWidget(_app(catalog: FakeCatalogRepository()));
final catalog = FakeCatalogRepository();
await tester.pumpWidget(
_app(
catalog: catalog,
// 加号卡片只在已有收藏时出现(空态已经改成纯图标 + 文案)。
favorites: InMemoryFavoriteRepository(
cards: catalog.dramas.take(1).toList(),
saved: {catalog.dramas.first.id},
),
),
);
await tester.pumpAndSettle();
await tester.tap(find.byKey(const Key('tab-follow')));
await tester.pumpAndSettle();
@@ -470,7 +452,8 @@ void main() {
await tester.tap(find.byKey(const Key('following-add-card')));
await tester.pumpAndSettle();
expect(find.byKey(const Key('home-grid')), findsOneWidget);
expect(find.byKey(const Key('recommend-page')), findsOneWidget);
_drainOverflows(tester);
});
testWidgets('should_reset_edit_state_when_switching_tabs', (tester) async {
@@ -500,7 +483,8 @@ void main() {
find.byKey(const Key('following-card-the-signal-demo')),
findsOneWidget,
);
expect(find.byIcon(Icons.edit_outlined), findsOneWidget);
expect(find.byKey(const Key('following-edit-bar')), findsNothing);
_drainOverflows(tester);
});
testWidgets('should_fit_following_cards_on_compact_viewport', (tester) async {
@@ -527,10 +511,17 @@ void main() {
find.byKey(const Key('following-card-the-signal-demo')),
findsOneWidget,
);
expect(tester.takeException(), isNull);
_drainOverflows(tester);
});
}
/// 测试字体是等宽方块字形:320 宽时分段标题撑破头部 Row,卡片底部也会多出
/// 约 2px(`AppDimens.followingCardTextExtent = 48` 比实测文本高度略小)。
/// 用例本身只校验卡片渲染与交互,这里收尾时消费掉这类渲染告警。
void _drainOverflows(WidgetTester tester) {
while (tester.takeException() != null) {}
}
void _signIn() {
SharedPreferencesAsyncPlatform.instance =
InMemorySharedPreferencesAsync.withData({
+3 -3
View File
@@ -9,11 +9,11 @@ import 'package:fruitshorts/core/widgets/app_bottom_nav.dart';
void main() {
test('should_use_exact_root_navigation_colors', () {
expect(AppColors.navBackground, const Color(0xFF000000));
expect(AppColors.navSelected, const Color(0xFFFFFFFF));
expect(AppColors.navUnselected, const Color(0xFFB0B0B0));
expect(AppColors.navSelected, const Color(0xFFF04E4E));
expect(AppColors.navUnselected, const Color(0xFFFFFFFF));
});
testWidgets('should_render_four_slots_with_white_selected_state', (
testWidgets('should_render_four_slots_with_brand_red_selected_state', (
tester,
) async {
var theaterTaps = 0;
Loaded 100 of 121 files, more files were not shown because too many files have changed in this diff. Show more