Compare commits
88
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bfe0df62dc | ||
|
|
df2654c9d6 | ||
|
|
496b1cb797 | ||
|
|
85dedf20fa | ||
|
|
43e60e29ec | ||
|
|
5346be40a9 | ||
|
|
de7da64886 | ||
|
|
709972245f | ||
|
|
d5d13549f5 | ||
|
|
c027acc91f | ||
|
|
a3f3481f4f | ||
|
|
1b19513efb | ||
|
|
935de13343 | ||
|
|
01a3b0101e | ||
|
|
d6df5fbe5f | ||
|
|
929b7f72f8 | ||
|
|
e028ca40b1 | ||
|
|
d206465ee1 | ||
|
|
9117bf58b8 | ||
|
|
bd826a9236 | ||
|
|
a5dbae7fff | ||
|
|
00405d2e3b | ||
|
|
72dcb92aca | ||
|
|
8d511933df | ||
|
|
06a2f6d7c0 | ||
|
|
0d785bf1f8 | ||
|
|
4c3acb047c | ||
|
|
d3dbc9f8dc | ||
|
|
4b97f89c0b | ||
|
|
6be024f86f | ||
|
|
6512808506 | ||
|
|
2d65cd3006 | ||
|
|
391b01e9d0 | ||
|
|
d4ce3a5d8b | ||
|
|
bf47c065c9 | ||
|
|
c6b3ca9311 | ||
|
|
a3d50eb935 | ||
|
|
188811fde6 | ||
|
|
37353dac15 | ||
|
|
350d16db75 | ||
|
|
76429628ec | ||
|
|
0f27daf664 | ||
|
|
afdc4af2f2 | ||
|
|
1b50a73bfc | ||
|
|
978c309cd7 | ||
|
|
c0f65042e6 | ||
|
|
a7d01e0306 | ||
|
|
ed2cf4c18c | ||
|
|
db3e153409 | ||
|
|
810ca5bf9d | ||
|
|
84b24775d6 | ||
|
|
9039b27c7f | ||
|
|
30b43878ab | ||
|
|
e7afd316f8 | ||
|
|
f3dd4a9b5c | ||
|
|
94b37ef00f | ||
|
|
bea50ab32f | ||
|
|
63296d2a92 | ||
|
|
b291044acc | ||
|
|
ee4e573f4f | ||
|
|
e8f192ccf8 | ||
|
|
c8ec481fc9 | ||
|
|
1fc8c4924e | ||
|
|
55fc2796a9 | ||
|
|
4d3d067f77 | ||
|
|
bb2c729a7e | ||
|
|
54eb5a60a8 | ||
|
|
6667330ce0 | ||
|
|
440188f261 | ||
|
|
9d2d3b97a1 | ||
|
|
23e80dd637 | ||
|
|
ab4c246675 | ||
|
|
2a32dec183 | ||
|
|
5dafc68775 | ||
|
|
80c962a95c | ||
|
|
2fef7470e0 | ||
|
|
0cb0ab0613 | ||
|
|
70d8e0f982 | ||
|
|
48b4e67d34 | ||
|
|
a3a79f7068 | ||
|
|
04f034817c | ||
|
|
516593499c | ||
|
|
df36890b48 | ||
|
|
43f3593218 | ||
|
|
0eca7ecc31 | ||
|
|
af5d8f9d80 | ||
|
|
b84a5368d6 | ||
|
|
67e178c89d |
No files matched your search
@@ -8,7 +8,9 @@ plugins {
|
|||||||
|
|
||||||
android {
|
android {
|
||||||
namespace = "com.stormg.lumadrama"
|
namespace = "com.stormg.lumadrama"
|
||||||
compileSdk = flutter.compileSdkVersion
|
// permission_handler_android 14 的 AAR 元数据要求依赖方 compileSdk >= 37,
|
||||||
|
// 固定为 37(比 Flutter 默认的 36 高一档,只影响编译期 API 可见性)。
|
||||||
|
compileSdk = 37
|
||||||
ndkVersion = flutter.ndkVersion
|
ndkVersion = flutter.ndkVersion
|
||||||
|
|
||||||
compileOptions {
|
compileOptions {
|
||||||
|
|||||||
@@ -2,6 +2,9 @@
|
|||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<uses-permission
|
<uses-permission
|
||||||
android:name="android.permission.INTERNET"/>
|
android:name="android.permission.INTERNET"/>
|
||||||
|
<!-- 画中画自动触发依赖的「显示在其他应用上层」权限(部分 ROM 用它管控 PiP) -->
|
||||||
|
<uses-permission
|
||||||
|
android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
|
||||||
<application
|
<application
|
||||||
android:label="FruitShorts"
|
android:label="FruitShorts"
|
||||||
android:name="${applicationName}"
|
android:name="${applicationName}"
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ package com.stormg.lumadrama
|
|||||||
|
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.app.PictureInPictureParams
|
import android.app.PictureInPictureParams
|
||||||
|
import android.content.Context
|
||||||
import android.content.res.Configuration
|
import android.content.res.Configuration
|
||||||
import android.graphics.Bitmap
|
import android.graphics.Bitmap
|
||||||
import android.media.MediaMetadataRetriever
|
import android.media.MediaMetadataRetriever
|
||||||
@@ -12,6 +13,8 @@ import android.os.Build
|
|||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.os.Handler
|
import android.os.Handler
|
||||||
import android.os.Looper
|
import android.os.Looper
|
||||||
|
import android.provider.Settings
|
||||||
|
import android.telephony.TelephonyManager
|
||||||
import android.util.Rational
|
import android.util.Rational
|
||||||
import android.content.pm.PackageManager
|
import android.content.pm.PackageManager
|
||||||
import android.view.WindowManager
|
import android.view.WindowManager
|
||||||
@@ -21,6 +24,7 @@ import io.flutter.embedding.android.FlutterActivity
|
|||||||
import io.flutter.embedding.engine.FlutterEngine
|
import io.flutter.embedding.engine.FlutterEngine
|
||||||
import io.flutter.plugin.common.MethodChannel
|
import io.flutter.plugin.common.MethodChannel
|
||||||
import java.io.ByteArrayOutputStream
|
import java.io.ByteArrayOutputStream
|
||||||
|
import java.util.Locale
|
||||||
import java.util.concurrent.ExecutorService
|
import java.util.concurrent.ExecutorService
|
||||||
import java.util.concurrent.Executors
|
import java.util.concurrent.Executors
|
||||||
import java.util.concurrent.atomic.AtomicBoolean
|
import java.util.concurrent.atomic.AtomicBoolean
|
||||||
@@ -65,6 +69,23 @@ class MainActivity : FlutterActivity() {
|
|||||||
result.success(false)
|
result.success(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// 设备标识:SSAID 免权限,卸载重装不变,避免客户端自己生成的 id 每次重装都变
|
||||||
|
MethodChannel(flutterEngine.dartExecutor.binaryMessenger, "com.stormg.lumadrama/device")
|
||||||
|
.setMethodCallHandler { call, result ->
|
||||||
|
when (call.method) {
|
||||||
|
"ssaid" -> {
|
||||||
|
val value = try {
|
||||||
|
Settings.Secure.getString(contentResolver, Settings.Secure.ANDROID_ID)
|
||||||
|
} catch (_: Exception) {
|
||||||
|
null
|
||||||
|
}
|
||||||
|
result.success(value)
|
||||||
|
}
|
||||||
|
// 设备区域:注册时作为服务端 IP 解析失败后的兜底
|
||||||
|
"region" -> result.success(currentRegion())
|
||||||
|
else -> result.notImplemented()
|
||||||
|
}
|
||||||
|
}
|
||||||
MethodChannel(flutterEngine.dartExecutor.binaryMessenger, "com.stormg.lumadrama/share")
|
MethodChannel(flutterEngine.dartExecutor.binaryMessenger, "com.stormg.lumadrama/share")
|
||||||
.setMethodCallHandler { call, result ->
|
.setMethodCallHandler { call, result ->
|
||||||
if (call.method != "shareText") {
|
if (call.method != "shareText") {
|
||||||
@@ -156,6 +177,28 @@ class MainActivity : FlutterActivity() {
|
|||||||
?.bottom
|
?.bottom
|
||||||
?: 0
|
?: 0
|
||||||
|
|
||||||
|
/** 网络运营商国家优先,其次 SIM 卡,最后系统语言;都拿不到返回空串。 */
|
||||||
|
private fun currentRegion(): String {
|
||||||
|
return try {
|
||||||
|
val telephony = getSystemService(Context.TELEPHONY_SERVICE) as? TelephonyManager
|
||||||
|
val localeCountry = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||||
|
resources.configuration.locales.get(0).country
|
||||||
|
} else {
|
||||||
|
@Suppress("DEPRECATION")
|
||||||
|
resources.configuration.locale.country
|
||||||
|
}
|
||||||
|
val candidates = listOfNotNull(
|
||||||
|
telephony?.networkCountryIso,
|
||||||
|
telephony?.simCountryIso,
|
||||||
|
localeCountry
|
||||||
|
)
|
||||||
|
candidates.firstOrNull { it.isNotBlank() }?.uppercase(Locale.ROOT) ?: ""
|
||||||
|
} catch (_: Exception) {
|
||||||
|
// 个别 ROM 读运营商信息会抛 SecurityException,别让注册流程卡住
|
||||||
|
""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun emitImeInset(value: Int) {
|
private fun emitImeInset(value: Int) {
|
||||||
if (value == imeInset) return
|
if (value == imeInset) return
|
||||||
imeInset = value
|
imeInset = value
|
||||||
@@ -241,6 +284,7 @@ class MainActivity : FlutterActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
private const val TAG = "FruitPip"
|
||||||
private const val thumbnailMaxWidth = 240
|
private const val thumbnailMaxWidth = 240
|
||||||
private const val thumbnailJpegQuality = 70
|
private const val thumbnailJpegQuality = 70
|
||||||
private const val thumbnailTimeoutMs = 1500L
|
private const val thumbnailTimeoutMs = 1500L
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import Flutter
|
import Flutter
|
||||||
import UIKit
|
import UIKit
|
||||||
import AVFoundation
|
import AVFoundation
|
||||||
|
import AVKit
|
||||||
|
|
||||||
private let thumbnailHTTPHeaderFieldsKey = "AVURLAssetHTTPHeaderFieldsKey"
|
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
|
@main
|
||||||
@objc class AppDelegate: FlutterAppDelegate, FlutterImplicitEngineDelegate {
|
@objc class AppDelegate: FlutterAppDelegate, FlutterImplicitEngineDelegate {
|
||||||
private let wirelessDataPrompt = WirelessDataPrompt()
|
private let wirelessDataPrompt = WirelessDataPrompt()
|
||||||
@@ -63,6 +376,8 @@ final class RunnerFlutterViewController: FlutterViewController {
|
|||||||
func didInitializeImplicitFlutterEngine(_ engineBridge: FlutterImplicitEngineBridge) {
|
func didInitializeImplicitFlutterEngine(_ engineBridge: FlutterImplicitEngineBridge) {
|
||||||
GeneratedPluginRegistrant.register(with: engineBridge.pluginRegistry)
|
GeneratedPluginRegistrant.register(with: engineBridge.pluginRegistry)
|
||||||
registerWirelessDataChannel(engineBridge)
|
registerWirelessDataChannel(engineBridge)
|
||||||
|
registerDeviceIdChannel(engineBridge)
|
||||||
|
registerPipChannel(engineBridge)
|
||||||
let channel = FlutterMethodChannel(
|
let channel = FlutterMethodChannel(
|
||||||
name: "com.stormg.lumadrama/share",
|
name: "com.stormg.lumadrama/share",
|
||||||
binaryMessenger: engineBridge.applicationRegistrar.messenger()
|
binaryMessenger: engineBridge.applicationRegistrar.messenger()
|
||||||
@@ -144,6 +459,114 @@ 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) {
|
||||||
|
let channel = FlutterMethodChannel(
|
||||||
|
name: "com.stormg.lumadrama/device",
|
||||||
|
binaryMessenger: engineBridge.applicationRegistrar.messenger()
|
||||||
|
)
|
||||||
|
channel.setMethodCallHandler { call, result in
|
||||||
|
switch call.method {
|
||||||
|
case "idfv":
|
||||||
|
result(UIDevice.current.identifierForVendor?.uuidString)
|
||||||
|
case "region":
|
||||||
|
if #available(iOS 16.0, *) {
|
||||||
|
result(Locale.current.region?.identifier)
|
||||||
|
} else {
|
||||||
|
result(Locale.current.regionCode)
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
result(FlutterMethodNotImplemented)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private func registerWirelessDataChannel(_ engineBridge: FlutterImplicitEngineBridge) {
|
private func registerWirelessDataChannel(_ engineBridge: FlutterImplicitEngineBridge) {
|
||||||
let channel = FlutterMethodChannel(
|
let channel = FlutterMethodChannel(
|
||||||
name: WirelessDataPrompt.channelName,
|
name: WirelessDataPrompt.channelName,
|
||||||
|
|||||||
@@ -48,7 +48,7 @@
|
|||||||
<key>NSIncludesSubdomains</key>
|
<key>NSIncludesSubdomains</key>
|
||||||
<true/>
|
<true/>
|
||||||
</dict>
|
</dict>
|
||||||
<key>10.43.47.1</key>
|
<key>192.168.31.243</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>NSExceptionAllowsInsecureHTTPLoads</key>
|
<key>NSExceptionAllowsInsecureHTTPLoads</key>
|
||||||
<true/>
|
<true/>
|
||||||
@@ -87,6 +87,10 @@
|
|||||||
</array>
|
</array>
|
||||||
</dict>
|
</dict>
|
||||||
</dict>
|
</dict>
|
||||||
|
<key>UIBackgroundModes</key>
|
||||||
|
<array>
|
||||||
|
<string>audio</string>
|
||||||
|
</array>
|
||||||
<key>UIApplicationSupportsIndirectInputEvents</key>
|
<key>UIApplicationSupportsIndirectInputEvents</key>
|
||||||
<true/>
|
<true/>
|
||||||
<key>UILaunchStoryboardName</key>
|
<key>UILaunchStoryboardName</key>
|
||||||
|
|||||||
+8
-13
@@ -14,6 +14,7 @@ import 'core/data/remote/catalog_api.dart';
|
|||||||
import 'core/data/remote/category_api.dart';
|
import 'core/data/remote/category_api.dart';
|
||||||
import 'core/data/remote/comment_api.dart';
|
import 'core/data/remote/comment_api.dart';
|
||||||
import 'core/data/remote/commerce_api.dart';
|
import 'core/data/remote/commerce_api.dart';
|
||||||
|
import 'core/data/remote/device_profile.dart';
|
||||||
import 'core/data/remote/download_api.dart';
|
import 'core/data/remote/download_api.dart';
|
||||||
import 'core/data/remote/interaction_api.dart';
|
import 'core/data/remote/interaction_api.dart';
|
||||||
import 'core/data/remote/library_api.dart';
|
import 'core/data/remote/library_api.dart';
|
||||||
@@ -117,12 +118,13 @@ class _LumaDramaAppState extends State<LumaDramaApp> {
|
|||||||
late final AuthSessionStore _sessionStore = AuthSessionStore();
|
late final AuthSessionStore _sessionStore = AuthSessionStore();
|
||||||
|
|
||||||
/// 全 App 共用一个 ApiClient:这样目录、账号、后续的互动/进度请求
|
/// 全 App 共用一个 ApiClient:这样目录、账号、后续的互动/进度请求
|
||||||
/// 都自动带 `Authorization` 与 `X-Device-Id`,401 的刷新重试也只有一处实现。
|
/// 都自动带 `Authorization`、`X-Device-Id` 与平台头,401 的刷新重试也只有一处实现。
|
||||||
late final ApiClient _apiClient = ApiClient(
|
late final ApiClient _apiClient = ApiClient(
|
||||||
accessTokenReader: () => _auth.accessToken,
|
accessTokenReader: () => _auth.accessToken,
|
||||||
tokenRefresher: () => _auth.refresh(),
|
tokenRefresher: () => _auth.refresh(),
|
||||||
onUnauthorized: () => _auth.clear(),
|
onUnauthorized: () => _auth.clear(),
|
||||||
deviceIdReader: _sessionStore.deviceId,
|
deviceIdReader: _sessionStore.deviceId,
|
||||||
|
platformReader: clientPlatform,
|
||||||
);
|
);
|
||||||
|
|
||||||
late final AuthController _auth = AuthController(
|
late final AuthController _auth = AuthController(
|
||||||
@@ -141,17 +143,11 @@ class _LumaDramaAppState extends State<LumaDramaApp> {
|
|||||||
|
|
||||||
late final WatchHistoryRepository _watchHistory =
|
late final WatchHistoryRepository _watchHistory =
|
||||||
widget.watchHistoryRepository ??
|
widget.watchHistoryRepository ??
|
||||||
HttpWatchHistoryRepository(
|
HttpWatchHistoryRepository(WatchApi(_apiClient));
|
||||||
WatchApi(_apiClient),
|
|
||||||
isSignedIn: () => _auth.isSignedIn,
|
|
||||||
);
|
|
||||||
|
|
||||||
late final FavoriteRepository _favorites =
|
late final FavoriteRepository _favorites =
|
||||||
widget.favoriteRepository ??
|
widget.favoriteRepository ??
|
||||||
HttpFavoriteRepository(
|
HttpFavoriteRepository(LibraryApi(_apiClient));
|
||||||
LibraryApi(_apiClient),
|
|
||||||
isSignedIn: () => _auth.isSignedIn,
|
|
||||||
);
|
|
||||||
|
|
||||||
late final PlaybackRepository _playback =
|
late final PlaybackRepository _playback =
|
||||||
widget.playbackRepository ??
|
widget.playbackRepository ??
|
||||||
@@ -219,7 +215,7 @@ class _LumaDramaAppState extends State<LumaDramaApp> {
|
|||||||
unawaited(_localeController.load());
|
unawaited(_localeController.load());
|
||||||
// 登录/登出时同步收藏状态:收藏属于账号,不能跨账号串联
|
// 登录/登出时同步收藏状态:收藏属于账号,不能跨账号串联
|
||||||
_auth.addListener(_onAuthChanged);
|
_auth.addListener(_onAuthChanged);
|
||||||
if (_auth.isSignedIn) unawaited(_favoriteController.load());
|
unawaited(_favoriteController.load());
|
||||||
if (_auth.isSignedIn) unawaited(_walletController.load());
|
if (_auth.isSignedIn) unawaited(_walletController.load());
|
||||||
unawaited(_downloadController.restore());
|
unawaited(_downloadController.restore());
|
||||||
}
|
}
|
||||||
@@ -235,6 +231,7 @@ class _LumaDramaAppState extends State<LumaDramaApp> {
|
|||||||
unawaited(_walletController.load());
|
unawaited(_walletController.load());
|
||||||
} else {
|
} else {
|
||||||
_favoriteController.clear();
|
_favoriteController.clear();
|
||||||
|
unawaited(_favoriteController.load());
|
||||||
_downloadController.reset();
|
_downloadController.reset();
|
||||||
_walletController.reset();
|
_walletController.reset();
|
||||||
}
|
}
|
||||||
@@ -293,9 +290,7 @@ class _LumaDramaAppState extends State<LumaDramaApp> {
|
|||||||
),
|
),
|
||||||
ChangeNotifierProvider(create: (_) => _createCategories()),
|
ChangeNotifierProvider(create: (_) => _createCategories()),
|
||||||
if (playlists != null)
|
if (playlists != null)
|
||||||
ChangeNotifierProvider(
|
ChangeNotifierProvider(create: (_) => PlaylistController(playlists)),
|
||||||
create: (_) => PlaylistController(playlists),
|
|
||||||
),
|
|
||||||
ChangeNotifierProvider.value(value: _favoriteController),
|
ChangeNotifierProvider.value(value: _favoriteController),
|
||||||
ChangeNotifierProvider.value(value: _downloadController),
|
ChangeNotifierProvider.value(value: _downloadController),
|
||||||
ChangeNotifierProvider.value(value: _walletController),
|
ChangeNotifierProvider.value(value: _walletController),
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ class AppConfig {
|
|||||||
/// 开发调试默认服务地址,当前指向本机局域网 IP。
|
/// 开发调试默认服务地址,当前指向本机局域网 IP。
|
||||||
///
|
///
|
||||||
/// 换网络时只改这一行,地址不要带结尾斜杠。
|
/// 换网络时只改这一行,地址不要带结尾斜杠。
|
||||||
static const String devHostBaseUrl = 'http://10.43.47.1:8081';
|
static const String devHostBaseUrl = 'http://192.168.31.243:8081';
|
||||||
|
|
||||||
/// 本机后端地址:通过 `adb reverse tcp:8081 tcp:8081` 映射到开发机,
|
/// 本机后端地址:通过 `adb reverse tcp:8081 tcp:8081` 映射到开发机,
|
||||||
/// 探测可达时 App 直连本机服务;不可达时回落到公网地址。
|
/// 探测可达时 App 直连本机服务;不可达时回落到公网地址。
|
||||||
@@ -51,9 +51,12 @@ class AppConfig {
|
|||||||
? _runtimeBaseUrl
|
? _runtimeBaseUrl
|
||||||
: (compiledBaseUrl.isNotEmpty ? compiledBaseUrl : defaultBaseUrl);
|
: (compiledBaseUrl.isNotEmpty ? compiledBaseUrl : defaultBaseUrl);
|
||||||
|
|
||||||
static final String _defaultBaseUrl = _runsOnDevMachine
|
/// 生产包固定走公网地址;仅 debug 才按平台默认到环回/开发机。
|
||||||
? lanBaseUrl
|
static final String _defaultBaseUrl = kReleaseMode
|
||||||
: devHostBaseUrl;
|
? publicBaseUrl
|
||||||
|
: (_runsOnDevMachine
|
||||||
|
? lanBaseUrl
|
||||||
|
: devHostBaseUrl);
|
||||||
|
|
||||||
/// 模拟器、桌面端与开发机同机,环回地址可用;iOS 真机不满足。
|
/// 模拟器、桌面端与开发机同机,环回地址可用;iOS 真机不满足。
|
||||||
/// Android 没有等价的探测方式,统一按真机处理(模拟器用
|
/// Android 没有等价的探测方式,统一按真机处理(模拟器用
|
||||||
@@ -93,6 +96,11 @@ class AppConfig {
|
|||||||
if (_runtimeBaseUrl.isEmpty) applyRuntimeBaseUrl(compiled);
|
if (_runtimeBaseUrl.isEmpty) applyRuntimeBaseUrl(compiled);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// 生产包固定公网地址,不再探测环回/开发机局域网地址,避免请求到开发机。
|
||||||
|
if (kReleaseMode) {
|
||||||
|
if (_runtimeBaseUrl.isEmpty) applyRuntimeBaseUrl(publicBaseUrl);
|
||||||
|
return;
|
||||||
|
}
|
||||||
final candidates = <String>[
|
final candidates = <String>[
|
||||||
if (_runtimeBaseUrl.isNotEmpty) _runtimeBaseUrl,
|
if (_runtimeBaseUrl.isNotEmpty) _runtimeBaseUrl,
|
||||||
for (final candidate in _probeCandidates)
|
for (final candidate in _probeCandidates)
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ class Episode {
|
|||||||
this.likeCount,
|
this.likeCount,
|
||||||
this.commentCount,
|
this.commentCount,
|
||||||
this.thumbnailsUrl,
|
this.thumbnailsUrl,
|
||||||
|
this.posterUrl,
|
||||||
});
|
});
|
||||||
|
|
||||||
final String id;
|
final String id;
|
||||||
@@ -37,12 +38,14 @@ class Episode {
|
|||||||
final int? likeCount;
|
final int? likeCount;
|
||||||
final int? commentCount;
|
final int? commentCount;
|
||||||
final String? thumbnailsUrl;
|
final String? thumbnailsUrl;
|
||||||
|
final String? posterUrl;
|
||||||
|
|
||||||
Episode withVideoUrl(
|
Episode withVideoUrl(
|
||||||
String url, {
|
String url, {
|
||||||
int? likeCount,
|
int? likeCount,
|
||||||
int? commentCount,
|
int? commentCount,
|
||||||
String? thumbnailsUrl,
|
String? thumbnailsUrl,
|
||||||
|
String? posterUrl,
|
||||||
}) => Episode(
|
}) => Episode(
|
||||||
id: id,
|
id: id,
|
||||||
number: number,
|
number: number,
|
||||||
@@ -54,6 +57,21 @@ class Episode {
|
|||||||
likeCount: likeCount ?? this.likeCount,
|
likeCount: likeCount ?? this.likeCount,
|
||||||
commentCount: commentCount ?? this.commentCount,
|
commentCount: commentCount ?? this.commentCount,
|
||||||
thumbnailsUrl: thumbnailsUrl ?? this.thumbnailsUrl,
|
thumbnailsUrl: thumbnailsUrl ?? this.thumbnailsUrl,
|
||||||
|
posterUrl: posterUrl ?? this.posterUrl,
|
||||||
|
);
|
||||||
|
|
||||||
|
Episode withStats({int? likeCount, int? commentCount}) => Episode(
|
||||||
|
id: id,
|
||||||
|
number: number,
|
||||||
|
title: title,
|
||||||
|
isFree: isFree,
|
||||||
|
videoUrl: videoUrl,
|
||||||
|
durationSec: durationSec,
|
||||||
|
locked: locked,
|
||||||
|
likeCount: likeCount ?? this.likeCount,
|
||||||
|
commentCount: commentCount ?? this.commentCount,
|
||||||
|
thumbnailsUrl: thumbnailsUrl,
|
||||||
|
posterUrl: posterUrl,
|
||||||
);
|
);
|
||||||
|
|
||||||
factory Episode.fromJson(Map<String, dynamic> json) {
|
factory Episode.fromJson(Map<String, dynamic> json) {
|
||||||
@@ -68,6 +86,7 @@ class Episode {
|
|||||||
likeCount: _optionalInt(json['likeCount']),
|
likeCount: _optionalInt(json['likeCount']),
|
||||||
commentCount: _optionalInt(json['commentCount']),
|
commentCount: _optionalInt(json['commentCount']),
|
||||||
thumbnailsUrl: _optionalString(json['thumbnailsUrl']),
|
thumbnailsUrl: _optionalString(json['thumbnailsUrl']),
|
||||||
|
posterUrl: _optionalString(json['posterUrl']),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -324,4 +343,4 @@ String _genreText(List<Map<String, String>> types, Object? fallback) {
|
|||||||
final joined = names.join(' / ');
|
final joined = names.join(' / ');
|
||||||
if (joined.isNotEmpty) return joined;
|
if (joined.isNotEmpty) return joined;
|
||||||
return fallback is String ? fallback : '';
|
return fallback is String ? fallback : '';
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
// Author: fruit.com.cn
|
||||||
|
|
||||||
|
import 'json_numbers.dart';
|
||||||
|
|
||||||
|
/// 播放页轻量互动计数快照,不包含播放地址或票据信息。
|
||||||
|
class EpisodeStats {
|
||||||
|
const EpisodeStats({
|
||||||
|
required this.episodeId,
|
||||||
|
required this.dramaId,
|
||||||
|
required this.likeCount,
|
||||||
|
required this.commentCount,
|
||||||
|
required this.favoriteCount,
|
||||||
|
required this.liked,
|
||||||
|
required this.favorited,
|
||||||
|
});
|
||||||
|
|
||||||
|
final String episodeId;
|
||||||
|
final String dramaId;
|
||||||
|
final int likeCount;
|
||||||
|
final int commentCount;
|
||||||
|
final int favoriteCount;
|
||||||
|
final bool liked;
|
||||||
|
final bool favorited;
|
||||||
|
|
||||||
|
EpisodeStats copyWith({
|
||||||
|
String? dramaId,
|
||||||
|
int? likeCount,
|
||||||
|
int? commentCount,
|
||||||
|
int? favoriteCount,
|
||||||
|
bool? liked,
|
||||||
|
bool? favorited,
|
||||||
|
}) {
|
||||||
|
return EpisodeStats(
|
||||||
|
episodeId: episodeId,
|
||||||
|
dramaId: dramaId ?? this.dramaId,
|
||||||
|
likeCount: likeCount ?? this.likeCount,
|
||||||
|
commentCount: commentCount ?? this.commentCount,
|
||||||
|
favoriteCount: favoriteCount ?? this.favoriteCount,
|
||||||
|
liked: liked ?? this.liked,
|
||||||
|
favorited: favorited ?? this.favorited,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
factory EpisodeStats.fromJson(Map<String, dynamic> json) {
|
||||||
|
return EpisodeStats(
|
||||||
|
episodeId: jsonToId(json['episodeId']),
|
||||||
|
dramaId: jsonToId(json['dramaId']),
|
||||||
|
likeCount: jsonToInt(json['likeCount']),
|
||||||
|
commentCount: jsonToInt(json['commentCount']),
|
||||||
|
favoriteCount: jsonToInt(json['favoriteCount']),
|
||||||
|
liked: json['liked'] == true,
|
||||||
|
favorited: json['favorited'] == true,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -58,14 +58,16 @@ class LikeToggleResult {
|
|||||||
|
|
||||||
/// 控制器统一返回结果;失败消息可直接展示后端 `message`。
|
/// 控制器统一返回结果;失败消息可直接展示后端 `message`。
|
||||||
class OperationResult<T> {
|
class OperationResult<T> {
|
||||||
const OperationResult._(this.data, this.errorMessage);
|
const OperationResult._(this.data, this.errorMessage, this.errorCode);
|
||||||
|
|
||||||
const OperationResult.success([T? data]) : this._(data, null);
|
const OperationResult.success([T? data]) : this._(data, null, null);
|
||||||
|
|
||||||
const OperationResult.failure(this.errorMessage) : data = null;
|
const OperationResult.failure(this.errorMessage, {this.errorCode})
|
||||||
|
: data = null;
|
||||||
|
|
||||||
final T? data;
|
final T? data;
|
||||||
final String? errorMessage;
|
final String? errorMessage;
|
||||||
|
final int? errorCode;
|
||||||
|
|
||||||
bool get isSuccess => errorMessage == null;
|
bool get isSuccess => errorMessage == null;
|
||||||
}
|
}
|
||||||
@@ -16,6 +16,7 @@ class PlayTicket {
|
|||||||
this.qualities = const [],
|
this.qualities = const [],
|
||||||
this.tracks = const [],
|
this.tracks = const [],
|
||||||
this.thumbnailsUrl,
|
this.thumbnailsUrl,
|
||||||
|
this.posterUrl,
|
||||||
this.likeCount,
|
this.likeCount,
|
||||||
this.commentCount,
|
this.commentCount,
|
||||||
});
|
});
|
||||||
@@ -46,6 +47,7 @@ class PlayTicket {
|
|||||||
/// 各档签名地址。AUTO 是主列表,点选其它档位时换成对应地址。
|
/// 各档签名地址。AUTO 是主列表,点选其它档位时换成对应地址。
|
||||||
final List<PlayQualityTrack> tracks;
|
final List<PlayQualityTrack> tracks;
|
||||||
final String? thumbnailsUrl;
|
final String? thumbnailsUrl;
|
||||||
|
final String? posterUrl;
|
||||||
final int? likeCount;
|
final int? likeCount;
|
||||||
final int? commentCount;
|
final int? commentCount;
|
||||||
|
|
||||||
@@ -70,6 +72,7 @@ class PlayTicket {
|
|||||||
.toList(),
|
.toList(),
|
||||||
tracks: _tracks(json['tracks'], json['playUrl'] as String? ?? ''),
|
tracks: _tracks(json['tracks'], json['playUrl'] as String? ?? ''),
|
||||||
thumbnailsUrl: _optionalString(json['thumbnailsUrl']),
|
thumbnailsUrl: _optionalString(json['thumbnailsUrl']),
|
||||||
|
posterUrl: _optionalString(json['posterUrl']),
|
||||||
likeCount: json['likeCount'] == null
|
likeCount: json['likeCount'] == null
|
||||||
? null
|
? null
|
||||||
: jsonToInt(json['likeCount']),
|
: jsonToInt(json['likeCount']),
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ class ApiClient {
|
|||||||
this.tokenRefresher,
|
this.tokenRefresher,
|
||||||
this.onUnauthorized,
|
this.onUnauthorized,
|
||||||
this.deviceIdReader,
|
this.deviceIdReader,
|
||||||
|
this.platformReader,
|
||||||
}) : _fixedBaseUrl = baseUrl {
|
}) : _fixedBaseUrl = baseUrl {
|
||||||
_dio = Dio(
|
_dio = Dio(
|
||||||
BaseOptions(
|
BaseOptions(
|
||||||
@@ -40,6 +41,7 @@ class ApiClient {
|
|||||||
AuthHeaderInterceptor(
|
AuthHeaderInterceptor(
|
||||||
accessTokenReader: accessTokenReader,
|
accessTokenReader: accessTokenReader,
|
||||||
deviceIdReader: deviceIdReader,
|
deviceIdReader: deviceIdReader,
|
||||||
|
platformReader: platformReader,
|
||||||
),
|
),
|
||||||
const EnvelopeInterceptor(),
|
const EnvelopeInterceptor(),
|
||||||
NetworkLogInterceptor(),
|
NetworkLogInterceptor(),
|
||||||
@@ -67,6 +69,9 @@ class ApiClient {
|
|||||||
/// 设备号(`X-Device-Id`):注册风控、后续下载绑定都要用
|
/// 设备号(`X-Device-Id`):注册风控、后续下载绑定都要用
|
||||||
final Future<String> Function()? deviceIdReader;
|
final Future<String> Function()? deviceIdReader;
|
||||||
|
|
||||||
|
/// 客户端平台(`X-Client-Platform`):后台区分 iOS / Android
|
||||||
|
final String Function()? platformReader;
|
||||||
|
|
||||||
Future<Object?> get(String path, {Map<String, String>? query}) {
|
Future<Object?> get(String path, {Map<String, String>? query}) {
|
||||||
return _request('GET', path, query: query);
|
return _request('GET', path, query: query);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,7 +32,11 @@ class TokenExpiredException implements Exception {
|
|||||||
///
|
///
|
||||||
/// 每个请求都重新取一次令牌,所以刷新成功后重发的那次会自动带上新令牌。
|
/// 每个请求都重新取一次令牌,所以刷新成功后重发的那次会自动带上新令牌。
|
||||||
class AuthHeaderInterceptor extends Interceptor {
|
class AuthHeaderInterceptor extends Interceptor {
|
||||||
AuthHeaderInterceptor({this.accessTokenReader, this.deviceIdReader});
|
AuthHeaderInterceptor({
|
||||||
|
this.accessTokenReader,
|
||||||
|
this.deviceIdReader,
|
||||||
|
this.platformReader,
|
||||||
|
});
|
||||||
|
|
||||||
/// 当前 access token;未登录返回 null 或空串。
|
/// 当前 access token;未登录返回 null 或空串。
|
||||||
final String? Function()? accessTokenReader;
|
final String? Function()? accessTokenReader;
|
||||||
@@ -40,6 +44,9 @@ class AuthHeaderInterceptor extends Interceptor {
|
|||||||
/// 设备号(`X-Device-Id`):注册风控、下载绑定都用它。
|
/// 设备号(`X-Device-Id`):注册风控、下载绑定都用它。
|
||||||
final Future<String> Function()? deviceIdReader;
|
final Future<String> Function()? deviceIdReader;
|
||||||
|
|
||||||
|
/// 客户端平台(`X-Client-Platform`):后台区分 iOS / Android,匿名请求同样要带。
|
||||||
|
final String Function()? platformReader;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> onRequest(
|
Future<void> onRequest(
|
||||||
RequestOptions options,
|
RequestOptions options,
|
||||||
@@ -54,6 +61,10 @@ class AuthHeaderInterceptor extends Interceptor {
|
|||||||
if (deviceId != null && deviceId.isNotEmpty) {
|
if (deviceId != null && deviceId.isNotEmpty) {
|
||||||
options.headers['X-Device-Id'] = deviceId;
|
options.headers['X-Device-Id'] = deviceId;
|
||||||
}
|
}
|
||||||
|
final platform = platformReader?.call() ?? '';
|
||||||
|
if (platform.isNotEmpty) {
|
||||||
|
options.headers['X-Client-Platform'] = platform;
|
||||||
|
}
|
||||||
handler.next(options);
|
handler.next(options);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ class AuthApi {
|
|||||||
required String target,
|
required String target,
|
||||||
required String code,
|
required String code,
|
||||||
required String deviceId,
|
required String deviceId,
|
||||||
|
String countryCode = '',
|
||||||
String platform = '',
|
String platform = '',
|
||||||
String osVersion = '',
|
String osVersion = '',
|
||||||
String appVersion = '',
|
String appVersion = '',
|
||||||
@@ -66,6 +67,7 @@ class AuthApi {
|
|||||||
'targetType': 'PHONE',
|
'targetType': 'PHONE',
|
||||||
'target': target,
|
'target': target,
|
||||||
'code': code,
|
'code': code,
|
||||||
|
'countryCode': countryCode,
|
||||||
'deviceId': deviceId,
|
'deviceId': deviceId,
|
||||||
'platform': platform,
|
'platform': platform,
|
||||||
'osVersion': osVersion,
|
'osVersion': osVersion,
|
||||||
@@ -79,6 +81,7 @@ class AuthApi {
|
|||||||
required String email,
|
required String email,
|
||||||
required String password,
|
required String password,
|
||||||
required String deviceId,
|
required String deviceId,
|
||||||
|
String countryCode = '',
|
||||||
String platform = '',
|
String platform = '',
|
||||||
String osVersion = '',
|
String osVersion = '',
|
||||||
String appVersion = '',
|
String appVersion = '',
|
||||||
@@ -89,7 +92,7 @@ class AuthApi {
|
|||||||
'targetType': 'EMAIL',
|
'targetType': 'EMAIL',
|
||||||
'target': email,
|
'target': email,
|
||||||
'password': password,
|
'password': password,
|
||||||
'countryCode': 'ID',
|
'countryCode': countryCode,
|
||||||
'deviceId': deviceId,
|
'deviceId': deviceId,
|
||||||
'platform': platform,
|
'platform': platform,
|
||||||
'osVersion': osVersion,
|
'osVersion': osVersion,
|
||||||
@@ -134,6 +137,7 @@ class AuthApi {
|
|||||||
'platform': platform,
|
'platform': platform,
|
||||||
'osVersion': osVersion,
|
'osVersion': osVersion,
|
||||||
},
|
},
|
||||||
|
skipAuthRetry: true,
|
||||||
);
|
);
|
||||||
return AuthSession.fromJson((data as Map).cast<String, dynamic>());
|
return AuthSession.fromJson((data as Map).cast<String, dynamic>());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
// Author: fruit.com.cn
|
||||||
|
|
||||||
|
import 'dart:io' show Platform;
|
||||||
|
|
||||||
|
import 'package:flutter/foundation.dart';
|
||||||
|
|
||||||
|
/// 客户端平台,后台只用来区分 iOS / Android。
|
||||||
|
///
|
||||||
|
/// 系统版本、机型一律不上报:后台列表需要的只是「这台设备是安卓还是苹果」。
|
||||||
|
String clientPlatform() {
|
||||||
|
if (kIsWeb) return 'WEB';
|
||||||
|
if (Platform.isAndroid) return 'ANDROID';
|
||||||
|
if (Platform.isIOS) return 'IOS';
|
||||||
|
return '';
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
// Author: fruit.com.cn
|
// Author: fruit.com.cn
|
||||||
|
|
||||||
|
import '../models/episode_stats.dart';
|
||||||
import '../models/play_ticket.dart';
|
import '../models/play_ticket.dart';
|
||||||
import 'api_client.dart';
|
import 'api_client.dart';
|
||||||
|
|
||||||
@@ -17,4 +18,11 @@ class PlaybackApi {
|
|||||||
if (data is Map<String, dynamic>) return PlayTicket.fromJson(data);
|
if (data is Map<String, dynamic>) return PlayTicket.fromJson(data);
|
||||||
throw const ApiException(-1, '返回数据格式异常');
|
throw const ApiException(-1, '返回数据格式异常');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// 轻量刷新互动计数:不签发地址,也不占用播放票据缓存。
|
||||||
|
Future<EpisodeStats> episodeStats(String episodeId) async {
|
||||||
|
final data = await _client.get('/app/episodes/$episodeId/stats');
|
||||||
|
if (data is Map<String, dynamic>) return EpisodeStats.fromJson(data);
|
||||||
|
throw const ApiException(-1, '返回数据格式异常');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -4,7 +4,7 @@ import '../models/page_result.dart';
|
|||||||
import '../models/watch_progress.dart';
|
import '../models/watch_progress.dart';
|
||||||
import 'api_client.dart';
|
import 'api_client.dart';
|
||||||
|
|
||||||
/// 观看进度接口:`/app/watch/*`(契约 §1.5)。全部需要登录态。
|
/// 观看进度接口:`/app/watch/*`(契约 §1.5)。支持账号或设备身份。
|
||||||
class WatchApi {
|
class WatchApi {
|
||||||
const WatchApi(this._client);
|
const WatchApi(this._client);
|
||||||
|
|
||||||
|
|||||||
@@ -19,21 +19,15 @@ abstract interface class FavoriteRepository {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class HttpFavoriteRepository implements FavoriteRepository {
|
class HttpFavoriteRepository implements FavoriteRepository {
|
||||||
const HttpFavoriteRepository(this._api, {this.isSignedIn});
|
const HttpFavoriteRepository(this._api);
|
||||||
|
|
||||||
final LibraryApi _api;
|
final LibraryApi _api;
|
||||||
|
|
||||||
/// 未登录时不请求:收藏属于账号,匿名浏览时列表按空处理(点收藏按钮会先引导登录)。
|
|
||||||
final bool Function()? isSignedIn;
|
|
||||||
|
|
||||||
bool get _signedIn => isSignedIn?.call() ?? true;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<bool> toggle(String dramaId) => _api.toggleFavorite(dramaId);
|
Future<bool> toggle(String dramaId) => _api.toggleFavorite(dramaId);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<PageResult<Drama>> page({int pageIndex = 1, int pageSize = 20}) async {
|
Future<PageResult<Drama>> page({int pageIndex = 1, int pageSize = 20}) async {
|
||||||
if (!_signedIn) return const PageResult();
|
|
||||||
return _api.favorites(pageIndex: pageIndex, pageSize: pageSize);
|
return _api.favorites(pageIndex: pageIndex, pageSize: pageSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
// Author: fruit.com.cn
|
// Author: fruit.com.cn
|
||||||
|
|
||||||
|
import '../models/episode_stats.dart';
|
||||||
import '../models/play_ticket.dart';
|
import '../models/play_ticket.dart';
|
||||||
import '../remote/playback_api.dart';
|
import '../remote/playback_api.dart';
|
||||||
|
|
||||||
@@ -10,6 +11,9 @@ import '../remote/playback_api.dart';
|
|||||||
abstract interface class PlaybackRepository {
|
abstract interface class PlaybackRepository {
|
||||||
Future<PlayTicket> ticketFor(String episodeId, {bool forceRefresh = false});
|
Future<PlayTicket> ticketFor(String episodeId, {bool forceRefresh = false});
|
||||||
|
|
||||||
|
/// 读取互动计数快照;与 [ticketFor] 分离,避免为了刷新计数重新签发地址。
|
||||||
|
Future<EpisodeStats> episodeStats(String episodeId);
|
||||||
|
|
||||||
/// 当前缓存的票据是否还在有效期内(用于"回前台发现过期就重新取")。
|
/// 当前缓存的票据是否还在有效期内(用于"回前台发现过期就重新取")。
|
||||||
bool isFresh(String episodeId);
|
bool isFresh(String episodeId);
|
||||||
}
|
}
|
||||||
@@ -42,6 +46,10 @@ class HttpPlaybackRepository implements PlaybackRepository {
|
|||||||
return ticket;
|
return ticket;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<EpisodeStats> episodeStats(String episodeId) =>
|
||||||
|
_api.episodeStats(episodeId);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool isFresh(String episodeId) {
|
bool isFresh(String episodeId) {
|
||||||
final cached = _cache[episodeId];
|
final cached = _cache[episodeId];
|
||||||
@@ -65,11 +73,22 @@ class _CachedTicket {
|
|||||||
|
|
||||||
/// 测试与离线场景用:按集返回固定票据,并记录被请求过几次。
|
/// 测试与离线场景用:按集返回固定票据,并记录被请求过几次。
|
||||||
class FakePlaybackRepository implements PlaybackRepository {
|
class FakePlaybackRepository implements PlaybackRepository {
|
||||||
FakePlaybackRepository({this.ticket, this.error, this.fresh = true});
|
FakePlaybackRepository({
|
||||||
|
this.ticket,
|
||||||
|
this.error,
|
||||||
|
this.fresh = true,
|
||||||
|
this.stats,
|
||||||
|
this.statsError,
|
||||||
|
Map<String, EpisodeStats>? statsByEpisode,
|
||||||
|
}) : statsByEpisode = statsByEpisode ?? {};
|
||||||
|
|
||||||
PlayTicket? ticket;
|
PlayTicket? ticket;
|
||||||
Object? error;
|
Object? error;
|
||||||
|
EpisodeStats? stats;
|
||||||
|
Object? statsError;
|
||||||
|
final Map<String, EpisodeStats> statsByEpisode;
|
||||||
final List<String> requests = [];
|
final List<String> requests = [];
|
||||||
|
final List<String> statsRequests = [];
|
||||||
final List<bool> forced = [];
|
final List<bool> forced = [];
|
||||||
|
|
||||||
/// 模拟"票据是否还有效":置 false 可验证回前台会重新取。
|
/// 模拟"票据是否还有效":置 false 可验证回前台会重新取。
|
||||||
@@ -95,4 +114,13 @@ class FakePlaybackRepository implements PlaybackRepository {
|
|||||||
qualities: const ['AUTO', '720P', '1080P'],
|
qualities: const ['AUTO', '720P', '1080P'],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<EpisodeStats> episodeStats(String episodeId) async {
|
||||||
|
statsRequests.add(episodeId);
|
||||||
|
if (statsError != null) throw statsError!;
|
||||||
|
final value = statsByEpisode[episodeId] ?? stats;
|
||||||
|
if (value != null) return value;
|
||||||
|
throw StateError('episode stats not configured for $episodeId');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -35,18 +35,12 @@ abstract interface class WatchHistoryRepository {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class HttpWatchHistoryRepository implements WatchHistoryRepository {
|
class HttpWatchHistoryRepository implements WatchHistoryRepository {
|
||||||
const HttpWatchHistoryRepository(this._api, {this.isSignedIn});
|
const HttpWatchHistoryRepository(this._api);
|
||||||
|
|
||||||
final WatchApi _api;
|
final WatchApi _api;
|
||||||
|
|
||||||
/// 未登录时这些接口必然 401:直接短路成"没有记录",让浏览/试看保持匿名可用。
|
|
||||||
final bool Function()? isSignedIn;
|
|
||||||
|
|
||||||
bool get _signedIn => isSignedIn?.call() ?? true;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<WatchProgress?> progressFor(String dramaId) async {
|
Future<WatchProgress?> progressFor(String dramaId) async {
|
||||||
if (!_signedIn) return null;
|
|
||||||
return _api.progressOfDrama(dramaId);
|
return _api.progressOfDrama(dramaId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,7 +51,6 @@ class HttpWatchHistoryRepository implements WatchHistoryRepository {
|
|||||||
Duration? duration,
|
Duration? duration,
|
||||||
bool finished = false,
|
bool finished = false,
|
||||||
}) async {
|
}) async {
|
||||||
if (!_signedIn) return null;
|
|
||||||
return _api.saveProgress(
|
return _api.saveProgress(
|
||||||
episodeId: episodeId,
|
episodeId: episodeId,
|
||||||
position: position,
|
position: position,
|
||||||
@@ -71,19 +64,16 @@ class HttpWatchHistoryRepository implements WatchHistoryRepository {
|
|||||||
int pageIndex = 1,
|
int pageIndex = 1,
|
||||||
int pageSize = 20,
|
int pageSize = 20,
|
||||||
}) async {
|
}) async {
|
||||||
if (!_signedIn) return const PageResult();
|
|
||||||
return _api.recent(pageIndex: pageIndex, pageSize: pageSize);
|
return _api.recent(pageIndex: pageIndex, pageSize: pageSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> remove(String dramaId) async {
|
Future<void> remove(String dramaId) async {
|
||||||
if (!_signedIn) return;
|
|
||||||
await _api.removeProgress(dramaId);
|
await _api.removeProgress(dramaId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> clear() async {
|
Future<void> clear() async {
|
||||||
if (!_signedIn) return;
|
|
||||||
await _api.clearProgress();
|
await _api.clearProgress();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ class AllDramasController {
|
|||||||
this.categories = const [],
|
this.categories = const [],
|
||||||
this.tags = const [],
|
this.tags = const [],
|
||||||
this.dramas = const [],
|
this.dramas = const [],
|
||||||
}) : _api = api;
|
}) : _api = api; // ignore: prefer_initializing_formals
|
||||||
|
|
||||||
final AllDramasRemote? _api;
|
final AllDramasRemote? _api;
|
||||||
List<ContentCategory> classifications;
|
List<ContentCategory> classifications;
|
||||||
|
|||||||
@@ -3,7 +3,8 @@
|
|||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/services.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 {
|
class AndroidPictureInPicture {
|
||||||
AndroidPictureInPicture({MethodChannel? channel})
|
AndroidPictureInPicture({MethodChannel? channel})
|
||||||
: _channel = channel ?? const MethodChannel('com.stormg.lumadrama/pip');
|
: _channel = channel ?? const MethodChannel('com.stormg.lumadrama/pip');
|
||||||
@@ -11,22 +12,147 @@ class AndroidPictureInPicture {
|
|||||||
final MethodChannel _channel;
|
final MethodChannel _channel;
|
||||||
|
|
||||||
bool get isPlatformSupported =>
|
bool get isPlatformSupported =>
|
||||||
!kIsWeb && defaultTargetPlatform == TargetPlatform.android;
|
!kIsWeb &&
|
||||||
|
(defaultTargetPlatform == TargetPlatform.android ||
|
||||||
|
defaultTargetPlatform == TargetPlatform.iOS);
|
||||||
|
|
||||||
void setStateListener(ValueChanged<bool>? listener) {
|
void Function(bool active, int finalPositionMs)? _pipChangedListener;
|
||||||
_channel.setMethodCallHandler(
|
VoidCallback? _playbackEndedListener;
|
||||||
listener == null
|
|
||||||
? null
|
/// PiP 状态回调:iOS 停止时 [finalPositionMs] 为影子最终进度(毫秒)。
|
||||||
: (call) async {
|
void setStateListener(void Function(bool active, int finalPositionMs)? listener) {
|
||||||
if (call.method == 'onPipChanged') {
|
_pipChangedListener = listener;
|
||||||
listener(call.arguments == true);
|
_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;
|
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 (_) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -48,6 +48,7 @@ class AuthController extends ChangeNotifier {
|
|||||||
email: email,
|
email: email,
|
||||||
password: password,
|
password: password,
|
||||||
deviceId: await _store.deviceId(),
|
deviceId: await _store.deviceId(),
|
||||||
|
countryCode: await _store.deviceRegion(),
|
||||||
platform: _platform,
|
platform: _platform,
|
||||||
osVersion: _osVersion,
|
osVersion: _osVersion,
|
||||||
);
|
);
|
||||||
@@ -95,6 +96,7 @@ class AuthController extends ChangeNotifier {
|
|||||||
target: target,
|
target: target,
|
||||||
code: code,
|
code: code,
|
||||||
deviceId: await _store.deviceId(),
|
deviceId: await _store.deviceId(),
|
||||||
|
countryCode: await _store.deviceRegion(),
|
||||||
platform: _platform,
|
platform: _platform,
|
||||||
osVersion: _osVersion,
|
osVersion: _osVersion,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import 'dart:math';
|
|||||||
import 'package:shared_preferences/shared_preferences.dart';
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
|
|
||||||
import '../models/auth_session.dart';
|
import '../models/auth_session.dart';
|
||||||
|
import 'device_id_provider.dart';
|
||||||
|
|
||||||
/// 令牌与设备号的本地持久化。
|
/// 令牌与设备号的本地持久化。
|
||||||
///
|
///
|
||||||
@@ -11,13 +12,17 @@ import '../models/auth_session.dart';
|
|||||||
/// `SharedPreferences.getInstance()` 在新版本里已标注弃用,两套混用还会让
|
/// `SharedPreferences.getInstance()` 在新版本里已标注弃用,两套混用还会让
|
||||||
/// widget 测试只 mock 到其中一套。
|
/// widget 测试只 mock 到其中一套。
|
||||||
///
|
///
|
||||||
/// 设备号是后端注册风控与后续"下载设备绑定"的依据,所以**首次生成后就固定下来**;
|
/// 设备号优先取系统标识(Android SSAID / iOS IDFV),这样卸载重装后还是同一台设备;
|
||||||
/// 不引 UUID 库(保持极简依赖),用「时间戳 + 随机数」拼一个够用的 id。
|
/// 系统标识不可用时才回退到本地生成并持久化的 UUID,保证任何环境都能跑。
|
||||||
class AuthSessionStore {
|
class AuthSessionStore {
|
||||||
AuthSessionStore({SharedPreferencesAsync? preferences})
|
AuthSessionStore({
|
||||||
: _preferences = preferences ?? SharedPreferencesAsync();
|
SharedPreferencesAsync? preferences,
|
||||||
|
DeviceIdProvider? deviceIdProvider,
|
||||||
|
}) : _preferences = preferences ?? SharedPreferencesAsync(),
|
||||||
|
_deviceIdProvider = deviceIdProvider ?? DeviceIdProvider();
|
||||||
|
|
||||||
final SharedPreferencesAsync _preferences;
|
final SharedPreferencesAsync _preferences;
|
||||||
|
final DeviceIdProvider _deviceIdProvider;
|
||||||
|
|
||||||
static const _kAccessToken = 'auth.accessToken';
|
static const _kAccessToken = 'auth.accessToken';
|
||||||
static const _kRefreshToken = 'auth.refreshToken';
|
static const _kRefreshToken = 'auth.refreshToken';
|
||||||
@@ -25,21 +30,46 @@ class AuthSessionStore {
|
|||||||
static const _kDeviceId = 'device.id';
|
static const _kDeviceId = 'device.id';
|
||||||
|
|
||||||
String? _cachedDeviceId;
|
String? _cachedDeviceId;
|
||||||
|
String? _cachedRegion;
|
||||||
|
|
||||||
Future<String> deviceId() async {
|
Future<String> deviceId() async {
|
||||||
if (_cachedDeviceId != null) return _cachedDeviceId!;
|
if (_cachedDeviceId != null) return _cachedDeviceId!;
|
||||||
var value = await _preferences.getString(_kDeviceId) ?? '';
|
final systemId = await _deviceIdProvider.systemDeviceId();
|
||||||
if (value.isEmpty) {
|
final value = systemId ?? await _localDeviceId();
|
||||||
final random = Random();
|
|
||||||
value =
|
|
||||||
'd-${DateTime.now().millisecondsSinceEpoch.toRadixString(36)}-'
|
|
||||||
'${random.nextInt(1 << 32).toRadixString(36)}';
|
|
||||||
await _preferences.setString(_kDeviceId, value);
|
|
||||||
}
|
|
||||||
_cachedDeviceId = value;
|
_cachedDeviceId = value;
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// 设备区域(ISO-2),取不到返回空串;只在注册时作为服务端 IP 解析失败后的兜底。
|
||||||
|
Future<String> deviceRegion() async {
|
||||||
|
if (_cachedRegion != null) return _cachedRegion!;
|
||||||
|
final value = await _deviceIdProvider.deviceRegion() ?? '';
|
||||||
|
_cachedRegion = value;
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 系统标识取不到时的兜底:本地 UUIDv4,生成一次后固定下来。
|
||||||
|
Future<String> _localDeviceId() async {
|
||||||
|
final stored = await _preferences.getString(_kDeviceId) ?? '';
|
||||||
|
if (stored.isNotEmpty) return stored;
|
||||||
|
final generated = 'd-${_uuidV4()}';
|
||||||
|
await _preferences.setString(_kDeviceId, generated);
|
||||||
|
return generated;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// UUIDv4:122 位随机,碰撞概率可忽略,不引第三方依赖。
|
||||||
|
String _uuidV4() {
|
||||||
|
final random = Random.secure();
|
||||||
|
final bytes = List<int>.generate(16, (_) => random.nextInt(256));
|
||||||
|
bytes[6] = (bytes[6] & 0x0f) | 0x40;
|
||||||
|
bytes[8] = (bytes[8] & 0x3f) | 0x80;
|
||||||
|
String hex(int start, int end) => bytes
|
||||||
|
.sublist(start, end)
|
||||||
|
.map((byte) => byte.toRadixString(16).padLeft(2, '0'))
|
||||||
|
.join();
|
||||||
|
return '${hex(0, 4)}-${hex(4, 6)}-${hex(6, 8)}-${hex(8, 10)}-${hex(10, 16)}';
|
||||||
|
}
|
||||||
|
|
||||||
Future<AuthSession?> read() async {
|
Future<AuthSession?> read() async {
|
||||||
final accessToken = await _preferences.getString(_kAccessToken) ?? '';
|
final accessToken = await _preferences.getString(_kAccessToken) ?? '';
|
||||||
final refreshToken = await _preferences.getString(_kRefreshToken) ?? '';
|
final refreshToken = await _preferences.getString(_kRefreshToken) ?? '';
|
||||||
|
|||||||
@@ -197,7 +197,10 @@ class CommentController extends ChangeNotifier {
|
|||||||
_insertPublished(comment, replyTo);
|
_insertPublished(comment, replyTo);
|
||||||
return OperationResult.success(comment);
|
return OperationResult.success(comment);
|
||||||
} catch (failure) {
|
} catch (failure) {
|
||||||
return OperationResult.failure(_errorMessage(failure));
|
return OperationResult.failure(
|
||||||
|
_errorMessage(failure),
|
||||||
|
errorCode: failure is ApiException ? failure.code : null,
|
||||||
|
);
|
||||||
} finally {
|
} finally {
|
||||||
submitting = false;
|
submitting = false;
|
||||||
_notify();
|
_notify();
|
||||||
@@ -217,7 +220,10 @@ class CommentController extends ChangeNotifier {
|
|||||||
return const OperationResult.success();
|
return const OperationResult.success();
|
||||||
} catch (failure) {
|
} catch (failure) {
|
||||||
_restoreComment(comment, location);
|
_restoreComment(comment, location);
|
||||||
return OperationResult.failure(_errorMessage(failure));
|
return OperationResult.failure(
|
||||||
|
_errorMessage(failure),
|
||||||
|
errorCode: failure is ApiException ? failure.code : null,
|
||||||
|
);
|
||||||
} finally {
|
} finally {
|
||||||
_deletingCommentIds.remove(comment.id);
|
_deletingCommentIds.remove(comment.id);
|
||||||
_notify();
|
_notify();
|
||||||
@@ -253,7 +259,10 @@ class CommentController extends ChangeNotifier {
|
|||||||
return OperationResult.success(result);
|
return OperationResult.success(result);
|
||||||
} catch (failure) {
|
} catch (failure) {
|
||||||
_replaceComment(current);
|
_replaceComment(current);
|
||||||
return OperationResult.failure(_errorMessage(failure));
|
return OperationResult.failure(
|
||||||
|
_errorMessage(failure),
|
||||||
|
errorCode: failure is ApiException ? failure.code : null,
|
||||||
|
);
|
||||||
} finally {
|
} finally {
|
||||||
_likingCommentIds.remove(comment.id);
|
_likingCommentIds.remove(comment.id);
|
||||||
_notify();
|
_notify();
|
||||||
@@ -277,7 +286,10 @@ class CommentController extends ChangeNotifier {
|
|||||||
);
|
);
|
||||||
return OperationResult.success(reportId);
|
return OperationResult.success(reportId);
|
||||||
} catch (failure) {
|
} catch (failure) {
|
||||||
return OperationResult.failure(_errorMessage(failure));
|
return OperationResult.failure(
|
||||||
|
_errorMessage(failure),
|
||||||
|
errorCode: failure is ApiException ? failure.code : null,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,50 @@
|
|||||||
|
// Author: fruit.com.cn
|
||||||
|
|
||||||
|
import 'dart:io' show Platform;
|
||||||
|
|
||||||
|
import 'package:flutter/foundation.dart';
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
|
|
||||||
|
/// 读取系统级设备标识,两端都不需要任何权限。
|
||||||
|
///
|
||||||
|
/// - Android:SSAID(`Settings.Secure.ANDROID_ID`),卸载重装不变;
|
||||||
|
/// - iOS:IDFV(`identifierForVendor`),卸载本 App 不变,同厂商应用全删才会变。
|
||||||
|
///
|
||||||
|
/// 两端都由原生侧提供,不引插件:项目 iOS 走 SPM,避免混入 CocoaPods。
|
||||||
|
/// 取不到(Web、测试环境、通道异常)时返回 null,由调用方回退到本地生成的 id。
|
||||||
|
class DeviceIdProvider {
|
||||||
|
static const MethodChannel _channel = MethodChannel(
|
||||||
|
'com.stormg.lumadrama/device',
|
||||||
|
);
|
||||||
|
|
||||||
|
Future<String?> systemDeviceId() async {
|
||||||
|
if (kIsWeb) return null;
|
||||||
|
try {
|
||||||
|
if (Platform.isAndroid) {
|
||||||
|
final ssaid = await _channel.invokeMethod<String>('ssaid');
|
||||||
|
if (ssaid != null && ssaid.isNotEmpty) return 'a-$ssaid';
|
||||||
|
}
|
||||||
|
if (Platform.isIOS) {
|
||||||
|
final idfv = await _channel.invokeMethod<String>('idfv');
|
||||||
|
if (idfv != null && idfv.isNotEmpty) return 'i-$idfv';
|
||||||
|
}
|
||||||
|
} catch (_) {
|
||||||
|
// 原生通道不可用(widget 测试)时走本地兜底
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 设备所在区域(ISO-2),仅用于服务端 IP 解析失败时兜底注册国家。
|
||||||
|
/// Android 依次取网络运营商 / SIM 卡 / 系统语言的国家,iOS 取系统 region。
|
||||||
|
Future<String?> deviceRegion() async {
|
||||||
|
if (kIsWeb) return null;
|
||||||
|
try {
|
||||||
|
final region = await _channel.invokeMethod<String>('region');
|
||||||
|
final value = region?.trim().toUpperCase() ?? '';
|
||||||
|
if (value.length == 2) return value;
|
||||||
|
} catch (_) {
|
||||||
|
// 原生通道不可用(widget 测试)时返回 null,由服务端兜底
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,6 +3,7 @@
|
|||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
|
|
||||||
import '../models/drama.dart';
|
import '../models/drama.dart';
|
||||||
|
import '../remote/api_client.dart';
|
||||||
import '../repositories/favorite_repository.dart';
|
import '../repositories/favorite_repository.dart';
|
||||||
|
|
||||||
/// 收藏状态:**以服务端为准**。
|
/// 收藏状态:**以服务端为准**。
|
||||||
@@ -17,6 +18,7 @@ class FavoriteController extends ChangeNotifier {
|
|||||||
final FavoriteRepository _repository;
|
final FavoriteRepository _repository;
|
||||||
final int pageSize;
|
final int pageSize;
|
||||||
final Set<String> _saved = {};
|
final Set<String> _saved = {};
|
||||||
|
final Map<String, int> _favoriteCounts = {};
|
||||||
List<Drama> cards = const [];
|
List<Drama> cards = const [];
|
||||||
int total = 0;
|
int total = 0;
|
||||||
bool loading = false;
|
bool loading = false;
|
||||||
@@ -24,6 +26,7 @@ class FavoriteController extends ChangeNotifier {
|
|||||||
bool hasMore = false;
|
bool hasMore = false;
|
||||||
String? error;
|
String? error;
|
||||||
String? loadMoreError;
|
String? loadMoreError;
|
||||||
|
int? lastErrorCode;
|
||||||
int _pageIndex = 0;
|
int _pageIndex = 0;
|
||||||
int _requestSeq = 0;
|
int _requestSeq = 0;
|
||||||
bool _disposed = false;
|
bool _disposed = false;
|
||||||
@@ -32,6 +35,53 @@ class FavoriteController extends ChangeNotifier {
|
|||||||
|
|
||||||
bool isSaved(String dramaId) => _saved.contains(dramaId);
|
bool isSaved(String dramaId) => _saved.contains(dramaId);
|
||||||
|
|
||||||
|
/// 当前剧收藏数;包含本地 toggle 增量。
|
||||||
|
int? favoriteCount(String dramaId) => _favoriteCounts[dramaId];
|
||||||
|
|
||||||
|
/// 首次展示时缓存卡片基数;之后统一由本控制器维护,避免页面各存一份。
|
||||||
|
int? favoriteCountFor(Drama drama) {
|
||||||
|
final current = _favoriteCounts[drama.id];
|
||||||
|
if (current != null) return current;
|
||||||
|
final fallback = drama.favoriteCount;
|
||||||
|
if (fallback == null) return null;
|
||||||
|
final normalized = fallback < 0 ? 0 : fallback;
|
||||||
|
_favoriteCounts[drama.id] = normalized;
|
||||||
|
return normalized;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 用 stats/detail 的服务端快照校准唯一状态和计数。
|
||||||
|
void applyServerState(
|
||||||
|
String dramaId, {
|
||||||
|
required bool saved,
|
||||||
|
int? favoriteCount,
|
||||||
|
}) {
|
||||||
|
var changed = _saved.contains(dramaId) != saved;
|
||||||
|
if (saved) {
|
||||||
|
_saved.add(dramaId);
|
||||||
|
} else {
|
||||||
|
_saved.remove(dramaId);
|
||||||
|
}
|
||||||
|
if (favoriteCount != null) {
|
||||||
|
final normalized = favoriteCount < 0 ? 0 : favoriteCount;
|
||||||
|
changed = changed || _favoriteCounts[dramaId] != normalized;
|
||||||
|
_favoriteCounts[dramaId] = normalized;
|
||||||
|
}
|
||||||
|
if (changed) notify();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 详情等只有计数、没有当前收藏状态的接口使用。
|
||||||
|
void applyServerCount(
|
||||||
|
String dramaId,
|
||||||
|
int? favoriteCount, {
|
||||||
|
bool notify = true,
|
||||||
|
}) {
|
||||||
|
if (favoriteCount == null) return;
|
||||||
|
final normalized = favoriteCount < 0 ? 0 : favoriteCount;
|
||||||
|
if (_favoriteCounts[dramaId] == normalized) return;
|
||||||
|
_favoriteCounts[dramaId] = normalized;
|
||||||
|
if (notify) this.notify();
|
||||||
|
}
|
||||||
|
|
||||||
void notify() {
|
void notify() {
|
||||||
if (!_disposed) notifyListeners();
|
if (!_disposed) notifyListeners();
|
||||||
}
|
}
|
||||||
@@ -43,6 +93,7 @@ class FavoriteController extends ChangeNotifier {
|
|||||||
loadingMore = false;
|
loadingMore = false;
|
||||||
error = null;
|
error = null;
|
||||||
loadMoreError = null;
|
loadMoreError = null;
|
||||||
|
lastErrorCode = null;
|
||||||
notify();
|
notify();
|
||||||
try {
|
try {
|
||||||
final page = await _repository.page(pageIndex: 1, pageSize: pageSize);
|
final page = await _repository.page(pageIndex: 1, pageSize: pageSize);
|
||||||
@@ -52,12 +103,14 @@ class FavoriteController extends ChangeNotifier {
|
|||||||
_saved
|
_saved
|
||||||
..clear()
|
..clear()
|
||||||
..addAll(list.map((drama) => drama.id));
|
..addAll(list.map((drama) => drama.id));
|
||||||
|
_rememberCardCounts(list);
|
||||||
total = page.total;
|
total = page.total;
|
||||||
_pageIndex = 1;
|
_pageIndex = 1;
|
||||||
hasMore = page.list.isNotEmpty && cards.length < total;
|
hasMore = page.list.isNotEmpty && cards.length < total;
|
||||||
} catch (_) {
|
} catch (failure) {
|
||||||
if (!_disposed && request == _requestSeq) {
|
if (!_disposed && request == _requestSeq) {
|
||||||
error = 'favoritesError';
|
error = 'favoritesError';
|
||||||
|
if (failure is ApiException) lastErrorCode = failure.code;
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
if (!_disposed && request == _requestSeq) {
|
if (!_disposed && request == _requestSeq) {
|
||||||
@@ -73,6 +126,7 @@ class FavoriteController extends ChangeNotifier {
|
|||||||
final request = ++_requestSeq;
|
final request = ++_requestSeq;
|
||||||
loadingMore = true;
|
loadingMore = true;
|
||||||
loadMoreError = null;
|
loadMoreError = null;
|
||||||
|
lastErrorCode = null;
|
||||||
notify();
|
notify();
|
||||||
try {
|
try {
|
||||||
final page = await _repository.page(
|
final page = await _repository.page(
|
||||||
@@ -86,12 +140,14 @@ class FavoriteController extends ChangeNotifier {
|
|||||||
).where((drama) => known.add(drama.id)).toList(growable: false);
|
).where((drama) => known.add(drama.id)).toList(growable: false);
|
||||||
cards = [...cards, ...appended];
|
cards = [...cards, ...appended];
|
||||||
_saved.addAll(appended.map((drama) => drama.id));
|
_saved.addAll(appended.map((drama) => drama.id));
|
||||||
|
_rememberCardCounts(appended);
|
||||||
total = page.total;
|
total = page.total;
|
||||||
_pageIndex += 1;
|
_pageIndex += 1;
|
||||||
hasMore = page.list.isNotEmpty && cards.length < total;
|
hasMore = page.list.isNotEmpty && cards.length < total;
|
||||||
} catch (_) {
|
} catch (failure) {
|
||||||
if (!_disposed && request == _requestSeq) {
|
if (!_disposed && request == _requestSeq) {
|
||||||
loadMoreError = 'favoritesError';
|
loadMoreError = 'favoritesError';
|
||||||
|
if (failure is ApiException) lastErrorCode = failure.code;
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
if (!_disposed && request == _requestSeq) {
|
if (!_disposed && request == _requestSeq) {
|
||||||
@@ -101,18 +157,23 @@ class FavoriteController extends ChangeNotifier {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 未登录时不要调用(服务端要求登录态)。
|
/// 每次切换都以接口状态为准;匿名请求由设备号归属。
|
||||||
///
|
///
|
||||||
/// [card] 是当前剧的卡片(播放页/详情页手上就有):收藏成功时直接放进列表,
|
/// [card] 是当前剧的卡片(播放页/详情页手上就有):收藏成功时直接放进列表,
|
||||||
/// 这样"收藏完打开我的收藏"能立刻看到,不必等下一次整表刷新。
|
/// 这样"收藏完打开我的收藏"能立刻看到,不必等下一次整表刷新。
|
||||||
Future<bool> toggle(String dramaId, {Drama? card}) async {
|
Future<bool> toggle(String dramaId, {Drama? card}) async {
|
||||||
|
lastErrorCode = null;
|
||||||
final wasSaved = _saved.contains(dramaId);
|
final wasSaved = _saved.contains(dramaId);
|
||||||
|
final previousCount = card == null
|
||||||
|
? favoriteCount(dramaId)
|
||||||
|
: favoriteCountFor(card);
|
||||||
final previousCards = cards;
|
final previousCards = cards;
|
||||||
final previousTotal = total;
|
final previousTotal = total;
|
||||||
final previousHasMore = hasMore;
|
final previousHasMore = hasMore;
|
||||||
// 乐观更新
|
// 乐观更新
|
||||||
if (wasSaved) {
|
if (wasSaved) {
|
||||||
_saved.remove(dramaId);
|
_saved.remove(dramaId);
|
||||||
|
_stepCount(dramaId, -1);
|
||||||
if (cards.any((drama) => drama.id == dramaId)) {
|
if (cards.any((drama) => drama.id == dramaId)) {
|
||||||
cards = cards.where((drama) => drama.id != dramaId).toList();
|
cards = cards.where((drama) => drama.id != dramaId).toList();
|
||||||
total = total > 0 ? total - 1 : 0;
|
total = total > 0 ? total - 1 : 0;
|
||||||
@@ -120,6 +181,7 @@ class FavoriteController extends ChangeNotifier {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
_saved.add(dramaId);
|
_saved.add(dramaId);
|
||||||
|
_stepCount(dramaId, 1);
|
||||||
}
|
}
|
||||||
notify();
|
notify();
|
||||||
try {
|
try {
|
||||||
@@ -128,6 +190,7 @@ class FavoriteController extends ChangeNotifier {
|
|||||||
if (saved) {
|
if (saved) {
|
||||||
_saved.add(dramaId);
|
_saved.add(dramaId);
|
||||||
if (wasSaved) {
|
if (wasSaved) {
|
||||||
|
_restoreCount(dramaId, previousCount);
|
||||||
cards = previousCards;
|
cards = previousCards;
|
||||||
total = previousTotal;
|
total = previousTotal;
|
||||||
hasMore = previousHasMore;
|
hasMore = previousHasMore;
|
||||||
@@ -138,6 +201,9 @@ class FavoriteController extends ChangeNotifier {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
_saved.remove(dramaId);
|
_saved.remove(dramaId);
|
||||||
|
if (!wasSaved) {
|
||||||
|
_restoreCount(dramaId, previousCount);
|
||||||
|
}
|
||||||
if (cards.any((drama) => drama.id == dramaId)) {
|
if (cards.any((drama) => drama.id == dramaId)) {
|
||||||
cards = cards.where((drama) => drama.id != dramaId).toList();
|
cards = cards.where((drama) => drama.id != dramaId).toList();
|
||||||
total = total > 0 ? total - 1 : 0;
|
total = total > 0 ? total - 1 : 0;
|
||||||
@@ -146,7 +212,7 @@ class FavoriteController extends ChangeNotifier {
|
|||||||
}
|
}
|
||||||
notify();
|
notify();
|
||||||
return true;
|
return true;
|
||||||
} catch (_) {
|
} catch (failure) {
|
||||||
// 回滚
|
// 回滚
|
||||||
cards = previousCards;
|
cards = previousCards;
|
||||||
total = previousTotal;
|
total = previousTotal;
|
||||||
@@ -156,7 +222,9 @@ class FavoriteController extends ChangeNotifier {
|
|||||||
} else {
|
} else {
|
||||||
_saved.remove(dramaId);
|
_saved.remove(dramaId);
|
||||||
}
|
}
|
||||||
|
_restoreCount(dramaId, previousCount);
|
||||||
notify();
|
notify();
|
||||||
|
if (failure is ApiException) lastErrorCode = failure.code;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -170,9 +238,13 @@ class FavoriteController extends ChangeNotifier {
|
|||||||
final previousHasMore = hasMore;
|
final previousHasMore = hasMore;
|
||||||
final removed = cards.where((drama) => ids.contains(drama.id)).toList();
|
final removed = cards.where((drama) => ids.contains(drama.id)).toList();
|
||||||
if (removed.isEmpty) return true;
|
if (removed.isEmpty) return true;
|
||||||
|
final previousCounts = {
|
||||||
|
for (final drama in removed) drama.id: _favoriteCounts[drama.id],
|
||||||
|
};
|
||||||
cards = cards.where((drama) => !ids.contains(drama.id)).toList();
|
cards = cards.where((drama) => !ids.contains(drama.id)).toList();
|
||||||
for (final id in ids) {
|
for (final id in ids) {
|
||||||
_saved.remove(id);
|
_saved.remove(id);
|
||||||
|
_stepCount(id, -1);
|
||||||
}
|
}
|
||||||
total = total > removed.length ? total - removed.length : 0;
|
total = total > removed.length ? total - removed.length : 0;
|
||||||
hasMore = cards.length < total;
|
hasMore = cards.length < total;
|
||||||
@@ -187,6 +259,9 @@ class FavoriteController extends ChangeNotifier {
|
|||||||
for (final drama in removed) {
|
for (final drama in removed) {
|
||||||
_saved.add(drama.id);
|
_saved.add(drama.id);
|
||||||
}
|
}
|
||||||
|
for (final entry in previousCounts.entries) {
|
||||||
|
_restoreCount(entry.key, entry.value);
|
||||||
|
}
|
||||||
notify();
|
notify();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -197,7 +272,9 @@ class FavoriteController extends ChangeNotifier {
|
|||||||
final index = cards.indexWhere((drama) => drama.id == dramaId);
|
final index = cards.indexWhere((drama) => drama.id == dramaId);
|
||||||
if (index < 0) return true;
|
if (index < 0) return true;
|
||||||
final removed = cards[index];
|
final removed = cards[index];
|
||||||
|
final previousCount = _favoriteCounts[dramaId];
|
||||||
_saved.remove(dramaId);
|
_saved.remove(dramaId);
|
||||||
|
_stepCount(dramaId, -1);
|
||||||
final next = [...cards]..removeAt(index);
|
final next = [...cards]..removeAt(index);
|
||||||
cards = next;
|
cards = next;
|
||||||
total = total > 0 ? total - 1 : 0;
|
total = total > 0 ? total - 1 : 0;
|
||||||
@@ -214,6 +291,7 @@ class FavoriteController extends ChangeNotifier {
|
|||||||
);
|
);
|
||||||
cards = restored;
|
cards = restored;
|
||||||
_saved.add(dramaId);
|
_saved.add(dramaId);
|
||||||
|
_restoreCount(dramaId, previousCount);
|
||||||
total += 1;
|
total += 1;
|
||||||
hasMore = cards.length < total;
|
hasMore = cards.length < total;
|
||||||
notify();
|
notify();
|
||||||
@@ -244,6 +322,30 @@ class FavoriteController extends ChangeNotifier {
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _rememberCardCounts(List<Drama> dramas) {
|
||||||
|
for (final drama in dramas) {
|
||||||
|
final count = drama.favoriteCount;
|
||||||
|
if (count != null && !_favoriteCounts.containsKey(drama.id)) {
|
||||||
|
_favoriteCounts[drama.id] = count < 0 ? 0 : count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void _stepCount(String dramaId, int delta) {
|
||||||
|
final current = _favoriteCounts[dramaId];
|
||||||
|
if (current == null) return;
|
||||||
|
final next = current + delta;
|
||||||
|
_favoriteCounts[dramaId] = next < 0 ? 0 : next;
|
||||||
|
}
|
||||||
|
|
||||||
|
void _restoreCount(String dramaId, int? count) {
|
||||||
|
if (count == null) {
|
||||||
|
_favoriteCounts.remove(dramaId);
|
||||||
|
} else {
|
||||||
|
_favoriteCounts[dramaId] = count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
_disposed = true;
|
_disposed = true;
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ class HomeFeedController extends ChangeNotifier {
|
|||||||
String? get cursor => _state(_channel).cursor;
|
String? get cursor => _state(_channel).cursor;
|
||||||
bool get hasMore => _state(_channel).hasMore;
|
bool get hasMore => _state(_channel).hasMore;
|
||||||
bool get loaded => _state(_channel).loaded;
|
bool get loaded => _state(_channel).loaded;
|
||||||
|
bool get isLoading => _state(_channel).loading;
|
||||||
bool get loadingMore => _state(_channel).loadingMore;
|
bool get loadingMore => _state(_channel).loadingMore;
|
||||||
bool get loadingFirstPage => !loaded && _state(_channel).loading;
|
bool get loadingFirstPage => !loaded && _state(_channel).loading;
|
||||||
|
|
||||||
|
|||||||
@@ -40,6 +40,24 @@ class InteractionController extends ChangeNotifier {
|
|||||||
/// 该集服务端最新点赞数。
|
/// 该集服务端最新点赞数。
|
||||||
int? episodeLikeCount(String episodeId) => _episodeLikeCounts[episodeId];
|
int? episodeLikeCount(String episodeId) => _episodeLikeCounts[episodeId];
|
||||||
|
|
||||||
|
/// 用轻量统计快照校准当前用户的分集点赞状态与计数。
|
||||||
|
void applyEpisodeStats(
|
||||||
|
String episodeId, {
|
||||||
|
required bool liked,
|
||||||
|
required int likeCount,
|
||||||
|
}) {
|
||||||
|
final changed =
|
||||||
|
_likedEpisodeIds.contains(episodeId) != liked ||
|
||||||
|
_episodeLikeCounts[episodeId] != likeCount;
|
||||||
|
if (liked) {
|
||||||
|
_likedEpisodeIds.add(episodeId);
|
||||||
|
} else {
|
||||||
|
_likedEpisodeIds.remove(episodeId);
|
||||||
|
}
|
||||||
|
_episodeLikeCounts[episodeId] = likeCount;
|
||||||
|
if (changed) _notify();
|
||||||
|
}
|
||||||
|
|
||||||
/// 乐观切换剧集点赞,失败时回滚并以服务端返回状态校准。
|
/// 乐观切换剧集点赞,失败时回滚并以服务端返回状态校准。
|
||||||
Future<OperationResult<LikeToggleResult>> toggleDramaLike(String dramaId) =>
|
Future<OperationResult<LikeToggleResult>> toggleDramaLike(String dramaId) =>
|
||||||
_toggleLike(
|
_toggleLike(
|
||||||
@@ -97,7 +115,10 @@ class InteractionController extends ChangeNotifier {
|
|||||||
} else {
|
} else {
|
||||||
likedIds.remove(id);
|
likedIds.remove(id);
|
||||||
}
|
}
|
||||||
return OperationResult.failure(_errorMessage(failure));
|
return OperationResult.failure(
|
||||||
|
_errorMessage(failure),
|
||||||
|
errorCode: failure is ApiException ? failure.code : null,
|
||||||
|
);
|
||||||
} finally {
|
} finally {
|
||||||
busyIds.remove(id);
|
busyIds.remove(id);
|
||||||
_notify();
|
_notify();
|
||||||
@@ -121,7 +142,10 @@ class InteractionController extends ChangeNotifier {
|
|||||||
);
|
);
|
||||||
return OperationResult.success(reportId);
|
return OperationResult.success(reportId);
|
||||||
} catch (failure) {
|
} catch (failure) {
|
||||||
return OperationResult.failure(_errorMessage(failure));
|
return OperationResult.failure(
|
||||||
|
_errorMessage(failure),
|
||||||
|
errorCode: failure is ApiException ? failure.code : null,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,14 +13,40 @@ class PlaybackCoordinator {
|
|||||||
Future<bool> _acquire(PlaybackSession session, bool Function() valid) {
|
Future<bool> _acquire(PlaybackSession session, bool Function() valid) {
|
||||||
final result = _handoff.then((_) async {
|
final result = _handoff.then((_) async {
|
||||||
if (!valid()) return false;
|
if (!valid()) return false;
|
||||||
|
final previous = _owner;
|
||||||
|
if (kDebugMode) {
|
||||||
|
debugPrint(
|
||||||
|
'[player-coordinator] phase=acquire '
|
||||||
|
'session=${identityHashCode(session)} owner=${session.owner.name} '
|
||||||
|
'previous=${previous == null ? '-' : identityHashCode(previous)} '
|
||||||
|
'previousOwner=${previous?.owner.name ?? '-'} '
|
||||||
|
'previousLive=${previous?.livePlayerCount ?? 0} '
|
||||||
|
'same=${identical(previous, session)}',
|
||||||
|
);
|
||||||
|
}
|
||||||
if (_owner != session) {
|
if (_owner != session) {
|
||||||
final previous = _owner;
|
if (previous != null && previous.owner != session.owner) {
|
||||||
|
if (kDebugMode) {
|
||||||
|
debugPrint(
|
||||||
|
'[player-owner] phase=reject-coordinator-handoff '
|
||||||
|
'owner=${session.owner.name} '
|
||||||
|
'activeOwner=${previous.owner.name}',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
await previous?._releasePlayers();
|
await previous?._releasePlayers();
|
||||||
if (previous != null && previous.livePlayerCount != 0) return false;
|
if (previous != null && previous.livePlayerCount != 0) return false;
|
||||||
_owner = null;
|
_owner = null;
|
||||||
if (!valid()) return false;
|
if (!valid()) return false;
|
||||||
_owner = session;
|
_owner = session;
|
||||||
}
|
}
|
||||||
|
if (kDebugMode) {
|
||||||
|
debugPrint(
|
||||||
|
'[player-coordinator] phase=acquired '
|
||||||
|
'session=${identityHashCode(session)} live=${session.livePlayerCount}',
|
||||||
|
);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
_handoff = result.then<void>((_) {});
|
_handoff = result.then<void>((_) {});
|
||||||
@@ -49,13 +75,21 @@ Future<void> _parkNeighbors(
|
|||||||
_PlayerSlot? warmNext,
|
_PlayerSlot? warmNext,
|
||||||
_PlayerSlot? warmPrevious,
|
_PlayerSlot? warmPrevious,
|
||||||
) async {
|
) async {
|
||||||
await _placeNeighbor(session, old);
|
await _placeNeighbor(session, old, roleHint: 'old-current');
|
||||||
await _placeNeighbor(session, warmNext);
|
await _placeNeighbor(session, warmNext, roleHint: 'next');
|
||||||
await _placeNeighbor(session, warmPrevious);
|
await _placeNeighbor(session, warmPrevious, roleHint: 'previous');
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _placeNeighbor(PlaybackSession session, _PlayerSlot? slot) async {
|
Future<void> _placeNeighbor(
|
||||||
|
PlaybackSession session,
|
||||||
|
_PlayerSlot? slot, {
|
||||||
|
required String roleHint,
|
||||||
|
}) async {
|
||||||
if (slot == null || slot == session._active || slot.retiring) return;
|
if (slot == null || slot == session._active || slot.retiring) return;
|
||||||
|
if (slot.owner != session.owner) {
|
||||||
|
session._logOwnerRejection('park', slot);
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (session._next == null && slot.index == session._nextIndex) {
|
if (session._next == null && slot.index == session._nextIndex) {
|
||||||
session._next = slot;
|
session._next = slot;
|
||||||
return;
|
return;
|
||||||
@@ -64,18 +98,22 @@ Future<void> _placeNeighbor(PlaybackSession session, _PlayerSlot? slot) async {
|
|||||||
session._previous = slot;
|
session._previous = slot;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await session._retire(slot);
|
await session._retire(slot, trigger: 'park-neighbor', roleHint: roleHint);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 当前集已经出画后,静默准备上一集和下一集。
|
/// 当前集已经出画后,按手势方向静默准备上一集和下一集。
|
||||||
void _warmNeighbors(PlaybackSession session) {
|
void _warmNeighbors(PlaybackSession session, {bool preferredNext = true}) {
|
||||||
final request = session._generation;
|
final request = session._generation;
|
||||||
session._preloadTask = () async {
|
final nextTask = _warmOne(session, request, session._nextIndex, next: true);
|
||||||
await Future.wait([
|
final previousTask = _warmOne(
|
||||||
_warmOne(session, request, session._nextIndex, next: true),
|
session,
|
||||||
_warmOne(session, request, session._previousIndex, next: false),
|
request,
|
||||||
]);
|
session._previousIndex,
|
||||||
}();
|
next: false,
|
||||||
|
);
|
||||||
|
session._preloadTask = Future.wait(
|
||||||
|
preferredNext ? [nextTask, previousTask] : [previousTask, nextTask],
|
||||||
|
).then<void>((_) {});
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _warmOne(
|
Future<void> _warmOne(
|
||||||
@@ -100,7 +138,11 @@ Future<void> _warmOne(
|
|||||||
await session._enqueue(() async {
|
await session._enqueue(() async {
|
||||||
if (!_stillHeld(session, candidate, next: next)) return;
|
if (!_stillHeld(session, candidate, next: next)) return;
|
||||||
_clearNeighbor(session, next: next);
|
_clearNeighbor(session, next: next);
|
||||||
await session._retire(candidate);
|
await session._retire(
|
||||||
|
candidate,
|
||||||
|
trigger: 'warm-failure',
|
||||||
|
roleHint: next ? 'next' : 'previous',
|
||||||
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -117,7 +159,11 @@ Future<_PlayerSlot?> _allocateNeighbor(
|
|||||||
final current = next ? session._next : session._previous;
|
final current = next ? session._next : session._previous;
|
||||||
if (!allowed || current?.index != index) {
|
if (!allowed || current?.index != index) {
|
||||||
_clearNeighbor(session, next: next);
|
_clearNeighbor(session, next: next);
|
||||||
await session._retire(current);
|
await session._retire(
|
||||||
|
current,
|
||||||
|
trigger: 'warm-slot-invalid',
|
||||||
|
roleHint: next ? 'next' : 'previous',
|
||||||
|
);
|
||||||
}
|
}
|
||||||
if (!_canAllocate(session, request, allowed: allowed, next: next)) {
|
if (!_canAllocate(session, request, allowed: allowed, next: next)) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -8,14 +8,17 @@ import '../models/player_port.dart';
|
|||||||
import 'video_player_port.dart';
|
import 'video_player_port.dart';
|
||||||
|
|
||||||
part 'playback_neighbors.dart';
|
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 PlayerFactory = PlayerPort Function(Episode episode);
|
||||||
typedef PlayerPreparation =
|
typedef PlayerPreparation =
|
||||||
Future<void> Function(Episode episode, PlayerPort player);
|
Future<void> Function(Episode episode, PlayerPort player);
|
||||||
|
|
||||||
|
enum PlaybackSessionOwner { home, player }
|
||||||
|
|
||||||
/// Owns current plus previous/next frames; allocation stays serialized.
|
/// Owns current plus previous/next frames; allocation stays serialized.
|
||||||
class PlaybackSession extends ChangeNotifier {
|
class PlaybackSession extends ChangeNotifier {
|
||||||
PlaybackSession({
|
PlaybackSession({
|
||||||
@@ -26,6 +29,8 @@ class PlaybackSession extends ChangeNotifier {
|
|||||||
this.activate,
|
this.activate,
|
||||||
PlaybackCoordinator? coordinator,
|
PlaybackCoordinator? coordinator,
|
||||||
this.waitForFrame,
|
this.waitForFrame,
|
||||||
|
this.owner = PlaybackSessionOwner.player,
|
||||||
|
this.dramaIdAt,
|
||||||
}) : _coordinator = coordinator ?? PlaybackCoordinator();
|
}) : _coordinator = coordinator ?? PlaybackCoordinator();
|
||||||
|
|
||||||
final List<Episode> episodes;
|
final List<Episode> episodes;
|
||||||
@@ -38,6 +43,8 @@ class PlaybackSession extends ChangeNotifier {
|
|||||||
/// Runs only when a slot becomes current (e.g. progress listeners).
|
/// Runs only when a slot becomes current (e.g. progress listeners).
|
||||||
final PlayerPreparation? activate;
|
final PlayerPreparation? activate;
|
||||||
final Future<void> Function()? waitForFrame;
|
final Future<void> Function()? waitForFrame;
|
||||||
|
final PlaybackSessionOwner owner;
|
||||||
|
final String? Function(int index)? dramaIdAt;
|
||||||
final PlaybackCoordinator _coordinator;
|
final PlaybackCoordinator _coordinator;
|
||||||
final Set<_PlayerSlot> _live = {};
|
final Set<_PlayerSlot> _live = {};
|
||||||
_PlayerSlot? _active;
|
_PlayerSlot? _active;
|
||||||
@@ -77,9 +84,18 @@ class PlaybackSession extends ChangeNotifier {
|
|||||||
bool get canAutoAdvance => _mayPlay && !_loading && active != null;
|
bool get canAutoAdvance => _mayPlay && !_loading && active != null;
|
||||||
bool get isLocked => !canPlay(currentEpisode);
|
bool get isLocked => !canPlay(currentEpisode);
|
||||||
String? get error => _error;
|
String? get error => _error;
|
||||||
|
bool get debugAppResumed => _appResumed;
|
||||||
|
bool get debugRouteVisible => _routeVisible;
|
||||||
|
bool get debugOverlayOpen => _overlayOpen;
|
||||||
|
bool get debugVisible => _visible;
|
||||||
|
bool get debugMayPlay => _mayPlay;
|
||||||
// Includes initialization and asynchronous disposal, until native release ends.
|
// Includes initialization and asynchronous disposal, until native release ends.
|
||||||
int get livePlayerCount => _live.length;
|
int get livePlayerCount => _live.length;
|
||||||
|
bool get activeSlotActivated => _active?.activated ?? false;
|
||||||
|
bool get activeSlotPlaying => _active?.playing ?? false;
|
||||||
int? get preloadedIndex => _next?.prepared == true ? _next?.index : null;
|
int? get preloadedIndex => _next?.prepared == true ? _next?.index : null;
|
||||||
|
int? get previousPreloadedIndex =>
|
||||||
|
_previous?.prepared == true ? _previous?.index : null;
|
||||||
Future<void> get playbackSettled => _operations;
|
Future<void> get playbackSettled => _operations;
|
||||||
Future<void> get preloadSettled => _preloadTask;
|
Future<void> get preloadSettled => _preloadTask;
|
||||||
|
|
||||||
@@ -106,15 +122,6 @@ class PlaybackSession extends ChangeNotifier {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 清晰度切换时盖住黑帧的旧播放器。只在仍由会话持有时交给界面。
|
|
||||||
PlayerPort? handoffAt(int index) {
|
|
||||||
final slot = _handoff;
|
|
||||||
if (_closed || slot == null || slot.retiring || slot.index != index) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return slot.player;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 队列重排后把当前仍在播放的 slot 映射到新索引,不重新创建播放器。
|
/// 队列重排后把当前仍在播放的 slot 映射到新索引,不重新创建播放器。
|
||||||
void remapCurrentIndex(int index, {int? preloadIndex, int? previousIndex}) {
|
void remapCurrentIndex(int index, {int? preloadIndex, int? previousIndex}) {
|
||||||
if (_closed || index < 0 || index >= episodes.length) return;
|
if (_closed || index < 0 || index >= episodes.length) return;
|
||||||
@@ -136,8 +143,12 @@ class PlaybackSession extends ChangeNotifier {
|
|||||||
_notify();
|
_notify();
|
||||||
unawaited(
|
unawaited(
|
||||||
_enqueue(() async {
|
_enqueue(() async {
|
||||||
await _retire(staleNext);
|
await _retire(staleNext, trigger: 'remap-stale-next', roleHint: 'next');
|
||||||
await _retire(stalePrevious);
|
await _retire(
|
||||||
|
stalePrevious,
|
||||||
|
trigger: 'remap-stale-previous',
|
||||||
|
roleHint: 'previous',
|
||||||
|
);
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
if (_visible && !_overlayOpen) _warmNeighbors(this);
|
if (_visible && !_overlayOpen) _warmNeighbors(this);
|
||||||
@@ -165,7 +176,12 @@ class PlaybackSession extends ChangeNotifier {
|
|||||||
if (_live.length >= maxLivePlayers) {
|
if (_live.length >= maxLivePlayers) {
|
||||||
throw StateError('Playback resource limit reached');
|
throw StateError('Playback resource limit reached');
|
||||||
}
|
}
|
||||||
final slot = _PlayerSlot(index, factory(episodes[index]));
|
final slot = _PlayerSlot(
|
||||||
|
index,
|
||||||
|
factory(episodes[index]),
|
||||||
|
owner: owner,
|
||||||
|
dramaId: dramaIdAt?.call(index),
|
||||||
|
);
|
||||||
_live.add(slot);
|
_live.add(slot);
|
||||||
slot.ready = () async {
|
slot.ready = () async {
|
||||||
try {
|
try {
|
||||||
@@ -183,8 +199,23 @@ class PlaybackSession extends ChangeNotifier {
|
|||||||
return slot;
|
return slot;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _retire(_PlayerSlot? slot) async {
|
Future<void> _retire(
|
||||||
if (slot == null || !_live.contains(slot)) return;
|
_PlayerSlot? slot, {
|
||||||
|
required String trigger,
|
||||||
|
String? roleHint,
|
||||||
|
}) async {
|
||||||
|
if (slot == null) return;
|
||||||
|
if (slot.owner != owner) {
|
||||||
|
_logOwnerRejection('retire', slot);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!_live.contains(slot)) return;
|
||||||
|
final role = _slotRole(slot, roleHint: roleHint);
|
||||||
|
final video = slot.player is VideoPlayerPort
|
||||||
|
? slot.player as VideoPlayerPort
|
||||||
|
: null;
|
||||||
|
final value = video?.controller.value;
|
||||||
|
final slotPlaying = slot.playing;
|
||||||
slot.retiring = true;
|
slot.retiring = true;
|
||||||
final cleared =
|
final cleared =
|
||||||
_active == slot ||
|
_active == slot ||
|
||||||
@@ -203,6 +234,19 @@ class PlaybackSession extends ChangeNotifier {
|
|||||||
} finally {
|
} finally {
|
||||||
await slot.player.dispose();
|
await slot.player.dispose();
|
||||||
_live.remove(slot);
|
_live.remove(slot);
|
||||||
|
if (kDebugMode) {
|
||||||
|
debugPrint(
|
||||||
|
'[player-slot] slot_released role=$role owner=${slot.owner.name} '
|
||||||
|
'selectOwner=$owner drama=${slot.dramaId ?? '-'} '
|
||||||
|
'episodeIndex=${slot.index} '
|
||||||
|
'controller=${_playerIdentity(slot.player)} '
|
||||||
|
'slotPlaying=${slotPlaying ? 1 : 0} '
|
||||||
|
'isPlaying=${value?.isPlaying == true ? 1 : 0} '
|
||||||
|
'position=${value?.position.inMilliseconds ?? '-'} '
|
||||||
|
'currentIndex=$_currentIndex generation=$_generation '
|
||||||
|
'trigger=$trigger',
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -212,11 +256,23 @@ class PlaybackSession extends ChangeNotifier {
|
|||||||
int index, {
|
int index, {
|
||||||
int? preloadIndex,
|
int? preloadIndex,
|
||||||
int? previousIndex,
|
int? previousIndex,
|
||||||
|
bool? userWantsPlay,
|
||||||
}) async {
|
}) async {
|
||||||
if (_closed || index < 0 || index >= episodes.length) return;
|
if (_closed || index < 0 || index >= episodes.length) return;
|
||||||
// 切到另一集时,上一集按下的暂停不跟着走:滑过去就应该自动播放。
|
if (kDebugMode) {
|
||||||
// 重复选中同一集(例如页面重新可见)不在这里恢复,尊重用户按下的暂停。
|
debugPrint(
|
||||||
if (!_selected || index != _currentIndex) {
|
'[player-session] phase=select-enter session=${identityHashCode(this)} '
|
||||||
|
'owner=${owner.name} index=$index user=$_userWantsPlay '
|
||||||
|
'selected=$_selected current=$_currentIndex '
|
||||||
|
'appResumed=$_appResumed routeVisible=$_routeVisible '
|
||||||
|
'overlayOpen=$_overlayOpen visible=$_visible mayPlay=$_mayPlay '
|
||||||
|
'live=${_live.length}',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
// 切换到不同剧集时恢复播放;仍停留在同一集时保留用户暂停。
|
||||||
|
if (userWantsPlay != null) {
|
||||||
|
_userWantsPlay = userWantsPlay;
|
||||||
|
} else if (!_selected || index != _currentIndex) {
|
||||||
_userWantsPlay = true;
|
_userWantsPlay = true;
|
||||||
}
|
}
|
||||||
final request = ++_generation;
|
final request = ++_generation;
|
||||||
@@ -247,7 +303,7 @@ class PlaybackSession extends ChangeNotifier {
|
|||||||
_PlayerSlot? target;
|
_PlayerSlot? target;
|
||||||
await _enqueue(() async {
|
await _enqueue(() async {
|
||||||
if (_closed || request != _generation) return;
|
if (_closed || request != _generation) return;
|
||||||
await _retire(_handoff);
|
await _retire(_handoff, trigger: 'select-handoff');
|
||||||
final old = _active;
|
final old = _active;
|
||||||
if (old != null &&
|
if (old != null &&
|
||||||
old.index == index &&
|
old.index == index &&
|
||||||
@@ -256,7 +312,10 @@ class PlaybackSession extends ChangeNotifier {
|
|||||||
target = old;
|
target = old;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (old != null) await old.player.pause();
|
if (old != null) {
|
||||||
|
await old.player.pause();
|
||||||
|
old.playing = false;
|
||||||
|
}
|
||||||
final warmNext = _next;
|
final warmNext = _next;
|
||||||
final warmPrevious = _previous;
|
final warmPrevious = _previous;
|
||||||
_active = null;
|
_active = null;
|
||||||
@@ -266,6 +325,7 @@ class PlaybackSession extends ChangeNotifier {
|
|||||||
_usableWarm(this, warmNext, index) ??
|
_usableWarm(this, warmNext, index) ??
|
||||||
_usableWarm(this, warmPrevious, index);
|
_usableWarm(this, warmPrevious, index);
|
||||||
if (warm != null) {
|
if (warm != null) {
|
||||||
|
warm.reusedWarm = true;
|
||||||
target = _active = warm;
|
target = _active = warm;
|
||||||
_loading = !warm.prepared;
|
_loading = !warm.prepared;
|
||||||
_notify();
|
_notify();
|
||||||
@@ -314,7 +374,9 @@ class PlaybackSession extends ChangeNotifier {
|
|||||||
await _enqueue(() => _start(slot, request));
|
await _enqueue(() => _start(slot, request));
|
||||||
await Future<void>.delayed(_qualityHandoffHold);
|
await Future<void>.delayed(_qualityHandoffHold);
|
||||||
if (previous != null && _handoff == previous && _active == slot) {
|
if (previous != null && _handoff == previous && _active == slot) {
|
||||||
await _enqueue(() => _retire(previous));
|
await _enqueue(
|
||||||
|
() => _retire(previous, trigger: 'quality-handoff-complete'),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
if (!_closed && request == _generation) _warmNeighbors(this);
|
if (!_closed && request == _generation) _warmNeighbors(this);
|
||||||
return _active == slot && slot.failure == null;
|
return _active == slot && slot.failure == null;
|
||||||
@@ -326,8 +388,8 @@ class PlaybackSession extends ChangeNotifier {
|
|||||||
if (_closed || request != _generation || _active == null) return;
|
if (_closed || request != _generation || _active == null) return;
|
||||||
final warm = _next;
|
final warm = _next;
|
||||||
_next = null;
|
_next = null;
|
||||||
await _retire(_handoff);
|
await _retire(_handoff, trigger: 'replacement-handoff');
|
||||||
await _retire(warm);
|
await _retire(warm, trigger: 'replacement-next');
|
||||||
if (_closed || request != _generation || _active == null) return;
|
if (_closed || request != _generation || _active == null) return;
|
||||||
try {
|
try {
|
||||||
created = _create(index);
|
created = _create(index);
|
||||||
@@ -354,7 +416,9 @@ class PlaybackSession extends ChangeNotifier {
|
|||||||
|
|
||||||
Future<void> _dropReplacement(_PlayerSlot slot) {
|
Future<void> _dropReplacement(_PlayerSlot slot) {
|
||||||
return _enqueue(() async {
|
return _enqueue(() async {
|
||||||
if (_live.contains(slot)) await _retire(slot);
|
if (_live.contains(slot)) {
|
||||||
|
await _retire(slot, trigger: 'replacement-drop');
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -369,7 +433,10 @@ class PlaybackSession extends ChangeNotifier {
|
|||||||
_handoff = previous;
|
_handoff = previous;
|
||||||
_active = slot;
|
_active = slot;
|
||||||
shown = true;
|
shown = true;
|
||||||
if (previous != null) await previous!.player.pause();
|
if (previous != null) {
|
||||||
|
await previous!.player.pause();
|
||||||
|
previous!.playing = false;
|
||||||
|
}
|
||||||
_notify();
|
_notify();
|
||||||
});
|
});
|
||||||
if (!shown || _active != slot) return null;
|
if (!shown || _active != slot) return null;
|
||||||
@@ -413,6 +480,22 @@ class PlaybackSession extends ChangeNotifier {
|
|||||||
Future<void> _applyPlayback(_PlayerSlot slot) async {
|
Future<void> _applyPlayback(_PlayerSlot slot) async {
|
||||||
if (_closed || _active != slot || !slot.activated) return;
|
if (_closed || _active != slot || !slot.activated) return;
|
||||||
final shouldPlay = _mayPlay && slot.index == _currentIndex && !isLocked;
|
final shouldPlay = _mayPlay && slot.index == _currentIndex && !isLocked;
|
||||||
|
final video = slot.player is VideoPlayerPort
|
||||||
|
? slot.player as VideoPlayerPort
|
||||||
|
: null;
|
||||||
|
if (kDebugMode) {
|
||||||
|
debugPrint(
|
||||||
|
'[player-session] phase=apply-playback '
|
||||||
|
'session=${identityHashCode(this)} owner=${owner.name} '
|
||||||
|
'index=${slot.index} shouldPlay=$shouldPlay user=$_userWantsPlay '
|
||||||
|
'appResumed=$_appResumed routeVisible=$_routeVisible '
|
||||||
|
'overlayOpen=$_overlayOpen locked=$isLocked '
|
||||||
|
'player=${identityHashCode(slot.player)} '
|
||||||
|
'controller=${video == null ? '-' : identityHashCode(video.controller)} '
|
||||||
|
'isPlaying=${video?.controller.value.isPlaying ?? '-'} '
|
||||||
|
'slotPlaying=${slot.playing}',
|
||||||
|
);
|
||||||
|
}
|
||||||
if (shouldPlay == slot.playing) return;
|
if (shouldPlay == slot.playing) return;
|
||||||
if (shouldPlay) {
|
if (shouldPlay) {
|
||||||
await slot.player.play();
|
await slot.player.play();
|
||||||
@@ -420,27 +503,15 @@ class PlaybackSession extends ChangeNotifier {
|
|||||||
await slot.player.pause();
|
await slot.player.pause();
|
||||||
}
|
}
|
||||||
slot.playing = shouldPlay;
|
slot.playing = shouldPlay;
|
||||||
}
|
if (kDebugMode) {
|
||||||
|
debugPrint(
|
||||||
void setAppResumed(bool value) {
|
'[player-session] phase=apply-playback-result '
|
||||||
_appResumed = value;
|
'session=${identityHashCode(this)} index=${slot.index} '
|
||||||
_syncPlayback();
|
'shouldPlay=$shouldPlay '
|
||||||
}
|
'isPlaying=${video?.controller.value.isPlaying ?? '-'} '
|
||||||
|
'slotPlaying=${slot.playing}',
|
||||||
void setRouteVisible(bool value) {
|
);
|
||||||
_routeVisible = value;
|
}
|
||||||
_syncPlayback();
|
|
||||||
}
|
|
||||||
|
|
||||||
void setOverlayOpen(bool value) {
|
|
||||||
_overlayOpen = value;
|
|
||||||
_syncPlayback();
|
|
||||||
}
|
|
||||||
|
|
||||||
void setUserWantsPlay(bool value) {
|
|
||||||
_userWantsPlay = value;
|
|
||||||
_syncPlayback();
|
|
||||||
_notify();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void _syncPlayback() {
|
void _syncPlayback() {
|
||||||
@@ -467,7 +538,7 @@ class PlaybackSession extends ChangeNotifier {
|
|||||||
_loading = false;
|
_loading = false;
|
||||||
_notify();
|
_notify();
|
||||||
for (final slot in _live.toList()) {
|
for (final slot in _live.toList()) {
|
||||||
await _retire(slot);
|
await _retire(slot, trigger: 'session-release-all');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -476,6 +547,23 @@ class PlaybackSession extends ChangeNotifier {
|
|||||||
if (!_closed) notifyListeners();
|
if (!_closed) notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String _slotRole(_PlayerSlot slot, {String? roleHint}) {
|
||||||
|
if (identical(slot, _active)) return 'current';
|
||||||
|
if (identical(slot, _previous)) return 'previous';
|
||||||
|
if (identical(slot, _next)) return 'next';
|
||||||
|
if (identical(slot, _handoff)) return 'handoff';
|
||||||
|
return roleHint ?? 'unassigned';
|
||||||
|
}
|
||||||
|
|
||||||
|
void _logOwnerRejection(String phase, _PlayerSlot slot) {
|
||||||
|
if (!kDebugMode) return;
|
||||||
|
debugPrint(
|
||||||
|
'[player-owner] phase=reject-$phase expected=${owner.name} '
|
||||||
|
'actual=${slot.owner.name} drama=${slot.dramaId ?? '-'} '
|
||||||
|
'episodeIndex=${slot.index} controller=${_playerIdentity(slot.player)}',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
Future<void> close() async {
|
Future<void> close() async {
|
||||||
if (_closed) return;
|
if (_closed) return;
|
||||||
_closed = true;
|
_closed = true;
|
||||||
@@ -486,13 +574,27 @@ class PlaybackSession extends ChangeNotifier {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _PlayerSlot {
|
class _PlayerSlot {
|
||||||
_PlayerSlot(this.index, this.player);
|
_PlayerSlot(
|
||||||
|
this.index,
|
||||||
|
this.player, {
|
||||||
|
required this.owner,
|
||||||
|
required this.dramaId,
|
||||||
|
});
|
||||||
int index;
|
int index;
|
||||||
final PlayerPort player;
|
final PlayerPort player;
|
||||||
|
final PlaybackSessionOwner owner;
|
||||||
|
final String? dramaId;
|
||||||
late final Future<void> ready;
|
late final Future<void> ready;
|
||||||
bool prepared = false;
|
bool prepared = false;
|
||||||
bool activated = false;
|
bool activated = false;
|
||||||
bool playing = false;
|
bool playing = false;
|
||||||
bool retiring = false;
|
bool retiring = false;
|
||||||
|
bool reusedWarm = false;
|
||||||
Object? failure;
|
Object? failure;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String _playerIdentity(PlayerPort player) {
|
||||||
|
return player is VideoPlayerPort
|
||||||
|
? '${identityHashCode(player.controller)}'
|
||||||
|
: '${identityHashCode(player)}';
|
||||||
|
}
|
||||||
@@ -0,0 +1,133 @@
|
|||||||
|
// Author: fruit.com.cn
|
||||||
|
|
||||||
|
part of 'playback_session.dart';
|
||||||
|
|
||||||
|
/// 播放会话的可见性、用户意图与相邻集预热控制。
|
||||||
|
extension PlaybackSessionControls on PlaybackSession {
|
||||||
|
/// 滑动手势开始时按方向优先准备相邻集,不改变当前集播放状态。
|
||||||
|
void prewarmNeighbors({required bool forward}) {
|
||||||
|
if (!_visible || _overlayOpen || _active?.prepared != true) return;
|
||||||
|
_warmNeighbors(this, preferredNext: forward);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 路由交接时同步暂停当前原生播放器,controller 仍由 session 持有。
|
||||||
|
Future<void> pauseForRouteHandoff() {
|
||||||
|
if (_closed) return Future<void>.value();
|
||||||
|
_routeVisible = false;
|
||||||
|
return _enqueue(() async {
|
||||||
|
final slot = _active;
|
||||||
|
if (slot == null) return;
|
||||||
|
await slot.player.pause();
|
||||||
|
slot.playing = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 路由恢复可见后立即同步当前 controller,并等待原生播放状态落地。
|
||||||
|
Future<void> resumeForRouteHandoff() {
|
||||||
|
if (_closed) return Future<void>.value();
|
||||||
|
_routeVisible = true;
|
||||||
|
return _enqueue(() async {
|
||||||
|
final slot = _active;
|
||||||
|
if (kDebugMode) {
|
||||||
|
debugPrint(
|
||||||
|
'[feed-handoff] phase=resume slot=${slot?.index} '
|
||||||
|
'activated=${slot?.activated} playing=${slot?.playing} '
|
||||||
|
'retiring=${slot?.retiring} current=$_currentIndex '
|
||||||
|
'visible=$_visible user=$_userWantsPlay loading=$_loading',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (slot == null || slot.retiring) return;
|
||||||
|
if (!slot.activated) {
|
||||||
|
try {
|
||||||
|
await activate?.call(episodes[slot.index], slot.player);
|
||||||
|
} catch (error) {
|
||||||
|
if (kDebugMode) {
|
||||||
|
debugPrint('[feed-handoff] phase=activation-failed error=$error');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (_closed || _active != slot || slot.retiring) {
|
||||||
|
if (kDebugMode) {
|
||||||
|
debugPrint(
|
||||||
|
'[feed-handoff] phase=activation-aborted closed=$_closed '
|
||||||
|
'activeSame=${identical(_active, slot)} retiring=${slot.retiring}',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
slot.activated = true;
|
||||||
|
}
|
||||||
|
await _applyPlayback(slot);
|
||||||
|
if (_visible && !_overlayOpen && !_loading) _warmNeighbors(this);
|
||||||
|
if (kDebugMode) {
|
||||||
|
debugPrint(
|
||||||
|
'[feed-handoff] phase=resumed activated=${slot.activated} '
|
||||||
|
'playing=${slot.playing}',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 选中锁定集时立即停播并释放所有原生播放器,不创建新片源。
|
||||||
|
Future<void> selectLocked(
|
||||||
|
int index, {
|
||||||
|
int? preloadIndex,
|
||||||
|
int? previousIndex,
|
||||||
|
}) {
|
||||||
|
if (_closed || index < 0 || index >= episodes.length) {
|
||||||
|
return Future<void>.value();
|
||||||
|
}
|
||||||
|
_generation++;
|
||||||
|
_selected = false;
|
||||||
|
_currentIndex = index;
|
||||||
|
_rememberNeighbors(preloadIndex, previousIndex);
|
||||||
|
_loading = false;
|
||||||
|
_error = null;
|
||||||
|
_userWantsPlay = false;
|
||||||
|
_notify();
|
||||||
|
return _releasePlayers();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 清晰度切换时盖住黑帧的旧播放器。只在仍由会话持有时交给界面。
|
||||||
|
PlayerPort? handoffAt(int index) {
|
||||||
|
final slot = _handoff;
|
||||||
|
if (_closed || slot == null || slot.retiring || slot.index != index) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return slot.player;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 当前索引是否复用了已预热的播放器槽。
|
||||||
|
bool reusedWarmAt(int index) {
|
||||||
|
for (final slot in [_active, _next, _previous]) {
|
||||||
|
if (slot != null && !slot.retiring && slot.index == index) {
|
||||||
|
return slot.reusedWarm;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 同步应用前台状态并恢复或暂停当前集。
|
||||||
|
void setAppResumed(bool value) {
|
||||||
|
_appResumed = value;
|
||||||
|
_syncPlayback();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 同步播放器路由是否可见。
|
||||||
|
void setRouteVisible(bool value) {
|
||||||
|
_routeVisible = value;
|
||||||
|
_syncPlayback();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 同步浮层是否遮挡播放器。
|
||||||
|
void setOverlayOpen(bool value) {
|
||||||
|
_overlayOpen = value;
|
||||||
|
_syncPlayback();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 记录用户播放意图;切换剧集时会在 [PlaybackSession.select] 中恢复播放。
|
||||||
|
void setUserWantsPlay(bool value) {
|
||||||
|
_userWantsPlay = value;
|
||||||
|
_syncPlayback();
|
||||||
|
_notify();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -9,7 +9,7 @@ import '../../config/app_config.dart';
|
|||||||
import 'sprite_thumbnail_asset_loader.dart';
|
import 'sprite_thumbnail_asset_loader.dart';
|
||||||
|
|
||||||
const Duration spriteVttCacheTtl = Duration(minutes: 10);
|
const Duration spriteVttCacheTtl = Duration(minutes: 10);
|
||||||
const int spriteImageCacheCapacity = 2;
|
const int spriteImageCacheCapacity = 1;
|
||||||
|
|
||||||
/// 单个 VTT cue 对应的 sprite 裁剪区域。
|
/// 单个 VTT cue 对应的 sprite 裁剪区域。
|
||||||
class SpriteThumbnailCue {
|
class SpriteThumbnailCue {
|
||||||
@@ -132,36 +132,36 @@ class SpriteThumbnailAxisService extends ChangeNotifier
|
|||||||
SpriteThumbnailAxisService({
|
SpriteThumbnailAxisService({
|
||||||
SpriteThumbnailAssetLoader? loader,
|
SpriteThumbnailAssetLoader? loader,
|
||||||
this.cacheTtl = spriteVttCacheTtl,
|
this.cacheTtl = spriteVttCacheTtl,
|
||||||
|
this.spriteCacheCapacity = spriteImageCacheCapacity,
|
||||||
DateTime Function()? now,
|
DateTime Function()? now,
|
||||||
}) : _loader = loader ?? DioSpriteThumbnailAssetLoader(),
|
}) : _loader = loader ?? DioSpriteThumbnailAssetLoader(),
|
||||||
_now = now ?? DateTime.now;
|
_now = now ?? DateTime.now;
|
||||||
|
|
||||||
final SpriteThumbnailAssetLoader _loader;
|
final SpriteThumbnailAssetLoader _loader;
|
||||||
final Duration cacheTtl;
|
final Duration cacheTtl;
|
||||||
|
final int spriteCacheCapacity;
|
||||||
final DateTime Function() _now;
|
final DateTime Function() _now;
|
||||||
final Map<String, _CachedAxis> _axisCache = {};
|
final Map<String, _CachedAxis> _axisCache = {};
|
||||||
final Map<String, Future<SpriteThumbnailAxis>> _axisRequests = {};
|
final Map<String, Future<SpriteThumbnailAxis>> _axisRequests = {};
|
||||||
final LinkedHashMap<String, _CachedSprite> _spriteCache = LinkedHashMap();
|
final LinkedHashMap<String, _CachedSprite> _spriteCache = LinkedHashMap();
|
||||||
final Map<String, Future<_CachedSprite?>> _spriteRequests = {};
|
final Map<String, Future<_CachedSprite?>> _spriteRequests = {};
|
||||||
final Set<String> _failedSprites = {};
|
final Set<String> _failedSprites = {};
|
||||||
String? _activeAxisUrl;
|
|
||||||
int _axisGeneration = 0;
|
|
||||||
bool _disposed = false;
|
bool _disposed = false;
|
||||||
|
|
||||||
@visibleForTesting
|
|
||||||
int get spriteCacheSize => _spriteCache.length;
|
int get spriteCacheSize => _spriteCache.length;
|
||||||
|
|
||||||
@visibleForTesting
|
@visibleForTesting
|
||||||
List<String> get spriteCacheKeys => _spriteCache.keys.toList();
|
List<String> get spriteCacheKeys => _spriteCache.keys
|
||||||
|
.map((url) => Uri.tryParse(url)?.pathSegments.lastOrNull ?? url)
|
||||||
|
.toList();
|
||||||
|
|
||||||
/// 播放器就绪时预取当前 cue 与相邻 sprite,拖动帧不触发网络或解码。
|
/// 播放器就绪时预取当前 cue;容量大于 1 时顺带预取相邻 sprite。
|
||||||
@override
|
@override
|
||||||
Future<void> prepareAt(String? thumbnailsUrl, Duration position) async {
|
Future<void> prepareAt(String? thumbnailsUrl, Duration position) async {
|
||||||
final url = _normalizeUrl(thumbnailsUrl);
|
final url = _normalizeUrl(thumbnailsUrl);
|
||||||
if (_disposed || url == null) return;
|
if (_disposed || url == null) return;
|
||||||
_activateAxis(url);
|
|
||||||
final axis = await _loadAxis(url);
|
final axis = await _loadAxis(url);
|
||||||
if (_disposed || _activeAxisUrl != url) return;
|
if (_disposed) return;
|
||||||
for (final cue in _prefetchCues(axis, position)) {
|
for (final cue in _prefetchCues(axis, position)) {
|
||||||
await _ensureSprite(axis, cue);
|
await _ensureSprite(axis, cue);
|
||||||
}
|
}
|
||||||
@@ -170,7 +170,7 @@ class SpriteThumbnailAxisService extends ChangeNotifier
|
|||||||
@override
|
@override
|
||||||
bool hasAxis(String? thumbnailsUrl) {
|
bool hasAxis(String? thumbnailsUrl) {
|
||||||
final url = _normalizeUrl(thumbnailsUrl);
|
final url = _normalizeUrl(thumbnailsUrl);
|
||||||
if (url == null || url != _activeAxisUrl) return false;
|
if (url == null) return false;
|
||||||
return _readAxis(url) != null;
|
return _readAxis(url) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -180,12 +180,14 @@ class SpriteThumbnailAxisService extends ChangeNotifier
|
|||||||
Duration position,
|
Duration position,
|
||||||
) {
|
) {
|
||||||
final url = _normalizeUrl(thumbnailsUrl);
|
final url = _normalizeUrl(thumbnailsUrl);
|
||||||
if (url == null || url != _activeAxisUrl) return null;
|
if (url == null) return null;
|
||||||
final axis = _readAxis(url);
|
final axis = _readAxis(url);
|
||||||
if (axis == null) return null;
|
if (axis == null) return null;
|
||||||
final cue = selectSpriteThumbnailCue(axis.cues, position);
|
final cue = selectSpriteThumbnailCue(axis.cues, position);
|
||||||
if (cue == null) return null;
|
if (cue == null) return null;
|
||||||
final cached = _readSprite(cue.spriteFile);
|
final cached = _readSprite(
|
||||||
|
axis.resolveSpriteUri(cue.spriteFile).toString(),
|
||||||
|
);
|
||||||
if (cached == null) return null;
|
if (cached == null) return null;
|
||||||
final sourceRect = _scaledSourceRect(cached, cue.sourceRect);
|
final sourceRect = _scaledSourceRect(cached, cue.sourceRect);
|
||||||
if (sourceRect == null) return null;
|
if (sourceRect == null) return null;
|
||||||
@@ -206,13 +208,6 @@ class SpriteThumbnailAxisService extends ChangeNotifier
|
|||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
void _activateAxis(String url) {
|
|
||||||
if (_activeAxisUrl == url) return;
|
|
||||||
_activeAxisUrl = url;
|
|
||||||
_axisGeneration++;
|
|
||||||
_clearSprites();
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<SpriteThumbnailAxis> _loadAxis(String url) {
|
Future<SpriteThumbnailAxis> _loadAxis(String url) {
|
||||||
final cached = _readAxis(url);
|
final cached = _readAxis(url);
|
||||||
if (cached != null) return Future.value(cached);
|
if (cached != null) return Future.value(cached);
|
||||||
@@ -239,7 +234,6 @@ class SpriteThumbnailAxisService extends ChangeNotifier
|
|||||||
} on SpriteThumbnailForbiddenException {
|
} on SpriteThumbnailForbiddenException {
|
||||||
if (_disposed) return SpriteThumbnailAxis.empty(url);
|
if (_disposed) return SpriteThumbnailAxis.empty(url);
|
||||||
_axisCache.remove(url);
|
_axisCache.remove(url);
|
||||||
if (_activeAxisUrl == url) _clearSprites();
|
|
||||||
} catch (_) {
|
} catch (_) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -274,6 +268,7 @@ class SpriteThumbnailAxisService extends ChangeNotifier
|
|||||||
if (current == null) return const [];
|
if (current == null) return const [];
|
||||||
final index = axis.cues.indexOf(current);
|
final index = axis.cues.indexOf(current);
|
||||||
final candidates = <SpriteThumbnailCue>[current];
|
final candidates = <SpriteThumbnailCue>[current];
|
||||||
|
if (spriteCacheCapacity <= 1) return candidates;
|
||||||
for (final direction in const [1, -1]) {
|
for (final direction in const [1, -1]) {
|
||||||
for (var step = 1; step < axis.cues.length; step++) {
|
for (var step = 1; step < axis.cues.length; step++) {
|
||||||
final neighborIndex = index + direction * step;
|
final neighborIndex = index + direction * step;
|
||||||
@@ -293,23 +288,23 @@ class SpriteThumbnailAxisService extends ChangeNotifier
|
|||||||
SpriteThumbnailAxis axis,
|
SpriteThumbnailAxis axis,
|
||||||
SpriteThumbnailCue cue,
|
SpriteThumbnailCue cue,
|
||||||
) {
|
) {
|
||||||
final cached = _readSprite(cue.spriteFile);
|
final spriteUrl = axis.resolveSpriteUri(cue.spriteFile).toString();
|
||||||
|
final cached = _readSprite(spriteUrl);
|
||||||
if (cached != null) return Future.value(cached);
|
if (cached != null) return Future.value(cached);
|
||||||
if (_failedSprites.contains(cue.spriteFile)) return Future.value();
|
if (_failedSprites.contains(spriteUrl)) return Future.value();
|
||||||
final existing = _spriteRequests[cue.spriteFile];
|
final existing = _spriteRequests[spriteUrl];
|
||||||
if (existing != null) return existing;
|
if (existing != null) return existing;
|
||||||
final generation = _axisGeneration;
|
final request = _loadSprite(axis, cue, spriteUrl);
|
||||||
final request = _loadSprite(axis, cue, generation);
|
_spriteRequests[spriteUrl] = request;
|
||||||
_spriteRequests[cue.spriteFile] = request;
|
|
||||||
return request.whenComplete(() {
|
return request.whenComplete(() {
|
||||||
_spriteRequests.remove(cue.spriteFile);
|
_spriteRequests.remove(spriteUrl);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<_CachedSprite?> _loadSprite(
|
Future<_CachedSprite?> _loadSprite(
|
||||||
SpriteThumbnailAxis axis,
|
SpriteThumbnailAxis axis,
|
||||||
SpriteThumbnailCue cue,
|
SpriteThumbnailCue cue,
|
||||||
int generation,
|
String spriteUrl,
|
||||||
) async {
|
) async {
|
||||||
SpriteThumbnailDecodedImage? decoded;
|
SpriteThumbnailDecodedImage? decoded;
|
||||||
try {
|
try {
|
||||||
@@ -318,16 +313,16 @@ class SpriteThumbnailAxisService extends ChangeNotifier
|
|||||||
decoded = null;
|
decoded = null;
|
||||||
}
|
}
|
||||||
if (decoded == null) {
|
if (decoded == null) {
|
||||||
_failedSprites.add(cue.spriteFile);
|
_failedSprites.add(spriteUrl);
|
||||||
if (!_disposed) notifyListeners();
|
if (!_disposed) notifyListeners();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (_disposed || generation != _axisGeneration) {
|
if (_disposed) {
|
||||||
decoded.image.dispose();
|
decoded.image.dispose();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
final cached = _CachedSprite(decoded);
|
final cached = _CachedSprite(decoded);
|
||||||
_putSprite(cue.spriteFile, cached);
|
_putSprite(spriteUrl, cached);
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
return cached;
|
return cached;
|
||||||
}
|
}
|
||||||
@@ -342,7 +337,7 @@ class SpriteThumbnailAxisService extends ChangeNotifier
|
|||||||
void _putSprite(String key, _CachedSprite value) {
|
void _putSprite(String key, _CachedSprite value) {
|
||||||
_spriteCache.remove(key)?.decoded.image.dispose();
|
_spriteCache.remove(key)?.decoded.image.dispose();
|
||||||
_spriteCache[key] = value;
|
_spriteCache[key] = value;
|
||||||
while (_spriteCache.length > spriteImageCacheCapacity) {
|
while (_spriteCache.length > spriteCacheCapacity) {
|
||||||
final oldest = _spriteCache.remove(_spriteCache.keys.first);
|
final oldest = _spriteCache.remove(_spriteCache.keys.first);
|
||||||
oldest?.decoded.image.dispose();
|
oldest?.decoded.image.dispose();
|
||||||
}
|
}
|
||||||
@@ -378,8 +373,6 @@ class SpriteThumbnailAxisService extends ChangeNotifier
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _clearAll() {
|
void _clearAll() {
|
||||||
_axisGeneration++;
|
|
||||||
_activeAxisUrl = null;
|
|
||||||
_axisCache.clear();
|
_axisCache.clear();
|
||||||
_axisRequests.clear();
|
_axisRequests.clear();
|
||||||
_clearSprites();
|
_clearSprites();
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ class WatchRecordsController extends ChangeNotifier {
|
|||||||
String? error;
|
String? error;
|
||||||
String? loadMoreError;
|
String? loadMoreError;
|
||||||
String? actionError;
|
String? actionError;
|
||||||
|
int? lastErrorCode;
|
||||||
int _pageIndex = 0;
|
int _pageIndex = 0;
|
||||||
int _requestSeq = 0;
|
int _requestSeq = 0;
|
||||||
bool _disposed = false;
|
bool _disposed = false;
|
||||||
@@ -50,6 +51,7 @@ class WatchRecordsController extends ChangeNotifier {
|
|||||||
error = null;
|
error = null;
|
||||||
loadMoreError = null;
|
loadMoreError = null;
|
||||||
actionError = null;
|
actionError = null;
|
||||||
|
lastErrorCode = null;
|
||||||
_notify();
|
_notify();
|
||||||
try {
|
try {
|
||||||
final page = await _history.recent(pageIndex: 1, pageSize: pageSize);
|
final page = await _history.recent(pageIndex: 1, pageSize: pageSize);
|
||||||
@@ -71,6 +73,7 @@ class WatchRecordsController extends ChangeNotifier {
|
|||||||
);
|
);
|
||||||
if (!_disposed && request == _requestSeq) {
|
if (!_disposed && request == _requestSeq) {
|
||||||
error = failure is ApiException ? failure.message : 'progressError';
|
error = failure is ApiException ? failure.message : 'progressError';
|
||||||
|
if (failure is ApiException) lastErrorCode = failure.code;
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
if (!_disposed && request == _requestSeq) {
|
if (!_disposed && request == _requestSeq) {
|
||||||
@@ -86,6 +89,7 @@ class WatchRecordsController extends ChangeNotifier {
|
|||||||
final request = ++_requestSeq;
|
final request = ++_requestSeq;
|
||||||
loadingMore = true;
|
loadingMore = true;
|
||||||
loadMoreError = null;
|
loadMoreError = null;
|
||||||
|
lastErrorCode = null;
|
||||||
_notify();
|
_notify();
|
||||||
try {
|
try {
|
||||||
final page = await _history.recent(
|
final page = await _history.recent(
|
||||||
@@ -108,6 +112,7 @@ class WatchRecordsController extends ChangeNotifier {
|
|||||||
loadMoreError = failure is ApiException
|
loadMoreError = failure is ApiException
|
||||||
? failure.message
|
? failure.message
|
||||||
: 'progressError';
|
: 'progressError';
|
||||||
|
if (failure is ApiException) lastErrorCode = failure.code;
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
if (!_disposed && request == _requestSeq) {
|
if (!_disposed && request == _requestSeq) {
|
||||||
@@ -139,6 +144,14 @@ class WatchRecordsController extends ChangeNotifier {
|
|||||||
return _detailCache[dramaId];
|
return _detailCache[dramaId];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// 按剧集 id 找最近观看记录,供收藏网格显示「看到第n集」与继续观看横幅。
|
||||||
|
WatchRecord? recordForDrama(String dramaId) {
|
||||||
|
for (final record in records) {
|
||||||
|
if (record.dramaId == dramaId) return record;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/// 删除单条记录,先更新 UI,失败按原位置回滚。
|
/// 删除单条记录,先更新 UI,失败按原位置回滚。
|
||||||
Future<bool> remove(String dramaId) async {
|
Future<bool> remove(String dramaId) async {
|
||||||
final index = _recordIndex(dramaId);
|
final index = _recordIndex(dramaId);
|
||||||
@@ -148,17 +161,19 @@ class WatchRecordsController extends ChangeNotifier {
|
|||||||
total = total > 0 ? total - 1 : 0;
|
total = total > 0 ? total - 1 : 0;
|
||||||
hasMore = records.length < total;
|
hasMore = records.length < total;
|
||||||
actionError = null;
|
actionError = null;
|
||||||
|
lastErrorCode = null;
|
||||||
_notify();
|
_notify();
|
||||||
try {
|
try {
|
||||||
await _history.remove(dramaId);
|
await _history.remove(dramaId);
|
||||||
return true;
|
return true;
|
||||||
} catch (_) {
|
} catch (failure) {
|
||||||
final next = [...records];
|
final next = [...records];
|
||||||
next.insert(index > next.length ? next.length : index, removed);
|
next.insert(index > next.length ? next.length : index, removed);
|
||||||
records = next;
|
records = next;
|
||||||
total += 1;
|
total += 1;
|
||||||
hasMore = records.length < total;
|
hasMore = records.length < total;
|
||||||
actionError = 'recordDeleteFailed';
|
actionError = 'recordDeleteFailed';
|
||||||
|
if (failure is ApiException) lastErrorCode = failure.code;
|
||||||
return false;
|
return false;
|
||||||
} finally {
|
} finally {
|
||||||
_notify();
|
_notify();
|
||||||
@@ -179,16 +194,18 @@ class WatchRecordsController extends ChangeNotifier {
|
|||||||
loadingMore = false;
|
loadingMore = false;
|
||||||
clearing = true;
|
clearing = true;
|
||||||
actionError = null;
|
actionError = null;
|
||||||
|
lastErrorCode = null;
|
||||||
_notify();
|
_notify();
|
||||||
try {
|
try {
|
||||||
await _history.clear();
|
await _history.clear();
|
||||||
return true;
|
return true;
|
||||||
} catch (_) {
|
} catch (failure) {
|
||||||
records = previous;
|
records = previous;
|
||||||
total = previousTotal;
|
total = previousTotal;
|
||||||
_pageIndex = previousPageIndex;
|
_pageIndex = previousPageIndex;
|
||||||
hasMore = records.length < total;
|
hasMore = records.length < total;
|
||||||
actionError = 'recordClearFailed';
|
actionError = 'recordClearFailed';
|
||||||
|
if (failure is ApiException) lastErrorCode = failure.code;
|
||||||
return false;
|
return false;
|
||||||
} finally {
|
} finally {
|
||||||
clearing = false;
|
clearing = false;
|
||||||
@@ -305,6 +322,23 @@ class WatchRecordsController extends ChangeNotifier {
|
|||||||
if (!_disposed) notifyListeners();
|
if (!_disposed) notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// 切换账号/设备身份时清除内存数据,不删除服务端记录。
|
||||||
|
void reset() {
|
||||||
|
_requestSeq += 1;
|
||||||
|
records = const [];
|
||||||
|
total = 0;
|
||||||
|
loading = false;
|
||||||
|
loadingMore = false;
|
||||||
|
hasMore = false;
|
||||||
|
clearing = false;
|
||||||
|
error = null;
|
||||||
|
loadMoreError = null;
|
||||||
|
actionError = null;
|
||||||
|
lastErrorCode = null;
|
||||||
|
_pageIndex = 0;
|
||||||
|
_notify();
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
_disposed = true;
|
_disposed = true;
|
||||||
|
|||||||
@@ -0,0 +1,239 @@
|
|||||||
|
// Author: fruit.com.cn
|
||||||
|
|
||||||
|
/// 账号资料页只读字段的展示格式化。
|
||||||
|
///
|
||||||
|
/// 后端存的是 ISO 国家码、BCP-47 语言标签和 IANA 时区(`ID` / `id-ID` / `Asia/Jakarta`),
|
||||||
|
/// 直接展示对用户没有意义,这里统一转成当前界面语言的名称。
|
||||||
|
/// 国家与城市名只维护中文与英文两套:界面语言为印尼语时回退英文名,
|
||||||
|
/// 语言名与账号状态则三种界面语言都有。
|
||||||
|
library;
|
||||||
|
|
||||||
|
const _countryNamesZh = {
|
||||||
|
'ID': '印度尼西亚',
|
||||||
|
'MY': '马来西亚',
|
||||||
|
'SG': '新加坡',
|
||||||
|
'TH': '泰国',
|
||||||
|
'VN': '越南',
|
||||||
|
'PH': '菲律宾',
|
||||||
|
'KH': '柬埔寨',
|
||||||
|
'MM': '缅甸',
|
||||||
|
'LA': '老挝',
|
||||||
|
'BN': '文莱',
|
||||||
|
'CN': '中国',
|
||||||
|
'TW': '中国台湾',
|
||||||
|
'HK': '中国香港',
|
||||||
|
'MO': '中国澳门',
|
||||||
|
'JP': '日本',
|
||||||
|
'KR': '韩国',
|
||||||
|
'IN': '印度',
|
||||||
|
'PK': '巴基斯坦',
|
||||||
|
'BD': '孟加拉国',
|
||||||
|
'LK': '斯里兰卡',
|
||||||
|
'NP': '尼泊尔',
|
||||||
|
'US': '美国',
|
||||||
|
'CA': '加拿大',
|
||||||
|
'MX': '墨西哥',
|
||||||
|
'BR': '巴西',
|
||||||
|
'AR': '阿根廷',
|
||||||
|
'CL': '智利',
|
||||||
|
'CO': '哥伦比亚',
|
||||||
|
'PE': '秘鲁',
|
||||||
|
'VE': '委内瑞拉',
|
||||||
|
'EC': '厄瓜多尔',
|
||||||
|
'GT': '危地马拉',
|
||||||
|
'DO': '多米尼加',
|
||||||
|
'GB': '英国',
|
||||||
|
'DE': '德国',
|
||||||
|
'FR': '法国',
|
||||||
|
'ES': '西班牙',
|
||||||
|
'IT': '意大利',
|
||||||
|
'NL': '荷兰',
|
||||||
|
'PL': '波兰',
|
||||||
|
'RU': '俄罗斯',
|
||||||
|
'UA': '乌克兰',
|
||||||
|
'TR': '土耳其',
|
||||||
|
'SA': '沙特阿拉伯',
|
||||||
|
'AE': '阿联酋',
|
||||||
|
'IL': '以色列',
|
||||||
|
'EG': '埃及',
|
||||||
|
'NG': '尼日利亚',
|
||||||
|
'ZA': '南非',
|
||||||
|
'KE': '肯尼亚',
|
||||||
|
'MA': '摩洛哥',
|
||||||
|
'AU': '澳大利亚',
|
||||||
|
'NZ': '新西兰',
|
||||||
|
};
|
||||||
|
|
||||||
|
const _countryNamesEn = {
|
||||||
|
'ID': 'Indonesia',
|
||||||
|
'MY': 'Malaysia',
|
||||||
|
'SG': 'Singapore',
|
||||||
|
'TH': 'Thailand',
|
||||||
|
'VN': 'Vietnam',
|
||||||
|
'PH': 'Philippines',
|
||||||
|
'KH': 'Cambodia',
|
||||||
|
'MM': 'Myanmar',
|
||||||
|
'LA': 'Laos',
|
||||||
|
'BN': 'Brunei',
|
||||||
|
'CN': 'China',
|
||||||
|
'TW': 'Taiwan',
|
||||||
|
'HK': 'Hong Kong',
|
||||||
|
'MO': 'Macau',
|
||||||
|
'JP': 'Japan',
|
||||||
|
'KR': 'South Korea',
|
||||||
|
'IN': 'India',
|
||||||
|
'PK': 'Pakistan',
|
||||||
|
'BD': 'Bangladesh',
|
||||||
|
'LK': 'Sri Lanka',
|
||||||
|
'NP': 'Nepal',
|
||||||
|
'US': 'United States',
|
||||||
|
'CA': 'Canada',
|
||||||
|
'MX': 'Mexico',
|
||||||
|
'BR': 'Brazil',
|
||||||
|
'AR': 'Argentina',
|
||||||
|
'CL': 'Chile',
|
||||||
|
'CO': 'Colombia',
|
||||||
|
'PE': 'Peru',
|
||||||
|
'VE': 'Venezuela',
|
||||||
|
'EC': 'Ecuador',
|
||||||
|
'GT': 'Guatemala',
|
||||||
|
'DO': 'Dominican Republic',
|
||||||
|
'GB': 'United Kingdom',
|
||||||
|
'DE': 'Germany',
|
||||||
|
'FR': 'France',
|
||||||
|
'ES': 'Spain',
|
||||||
|
'IT': 'Italy',
|
||||||
|
'NL': 'Netherlands',
|
||||||
|
'PL': 'Poland',
|
||||||
|
'RU': 'Russia',
|
||||||
|
'UA': 'Ukraine',
|
||||||
|
'TR': 'Turkey',
|
||||||
|
'SA': 'Saudi Arabia',
|
||||||
|
'AE': 'United Arab Emirates',
|
||||||
|
'IL': 'Israel',
|
||||||
|
'EG': 'Egypt',
|
||||||
|
'NG': 'Nigeria',
|
||||||
|
'ZA': 'South Africa',
|
||||||
|
'KE': 'Kenya',
|
||||||
|
'MA': 'Morocco',
|
||||||
|
'AU': 'Australia',
|
||||||
|
'NZ': 'New Zealand',
|
||||||
|
};
|
||||||
|
|
||||||
|
const _timezoneNamesZh = {
|
||||||
|
'Asia/Jakarta': '雅加达',
|
||||||
|
'Asia/Kuala_Lumpur': '吉隆坡',
|
||||||
|
'Asia/Singapore': '新加坡',
|
||||||
|
'Asia/Bangkok': '曼谷',
|
||||||
|
'Asia/Ho_Chi_Minh': '胡志明市',
|
||||||
|
'Asia/Manila': '马尼拉',
|
||||||
|
'Asia/Phnom_Penh': '金边',
|
||||||
|
'Asia/Yangon': '仰光',
|
||||||
|
'Asia/Vientiane': '万象',
|
||||||
|
'Asia/Brunei': '斯里巴加湾市',
|
||||||
|
'Asia/Shanghai': '上海',
|
||||||
|
'Asia/Taipei': '台北',
|
||||||
|
'Asia/Hong_Kong': '香港',
|
||||||
|
'Asia/Macau': '澳门',
|
||||||
|
'Asia/Tokyo': '东京',
|
||||||
|
'Asia/Seoul': '首尔',
|
||||||
|
'Asia/Kolkata': '加尔各答',
|
||||||
|
'Asia/Karachi': '卡拉奇',
|
||||||
|
'Asia/Dhaka': '达卡',
|
||||||
|
'Asia/Colombo': '科伦坡',
|
||||||
|
'Asia/Kathmandu': '加德满都',
|
||||||
|
'America/New_York': '纽约',
|
||||||
|
'America/Toronto': '多伦多',
|
||||||
|
'America/Mexico_City': '墨西哥城',
|
||||||
|
'America/Sao_Paulo': '圣保罗',
|
||||||
|
'America/Argentina/Buenos_Aires': '布宜诺斯艾利斯',
|
||||||
|
'America/Santiago': '圣地亚哥',
|
||||||
|
'America/Bogota': '波哥大',
|
||||||
|
'America/Lima': '利马',
|
||||||
|
'America/Caracas': '加拉加斯',
|
||||||
|
'America/Guayaquil': '瓜亚基尔',
|
||||||
|
'America/Guatemala': '危地马拉城',
|
||||||
|
'America/Santo_Domingo': '圣多明各',
|
||||||
|
'Europe/London': '伦敦',
|
||||||
|
'Europe/Berlin': '柏林',
|
||||||
|
'Europe/Paris': '巴黎',
|
||||||
|
'Europe/Madrid': '马德里',
|
||||||
|
'Europe/Rome': '罗马',
|
||||||
|
'Europe/Amsterdam': '阿姆斯特丹',
|
||||||
|
'Europe/Warsaw': '华沙',
|
||||||
|
'Europe/Moscow': '莫斯科',
|
||||||
|
'Europe/Kyiv': '基辅',
|
||||||
|
'Europe/Istanbul': '伊斯坦布尔',
|
||||||
|
'Asia/Riyadh': '利雅得',
|
||||||
|
'Asia/Dubai': '迪拜',
|
||||||
|
'Asia/Jerusalem': '耶路撒冷',
|
||||||
|
'Africa/Cairo': '开罗',
|
||||||
|
'Africa/Lagos': '拉各斯',
|
||||||
|
'Africa/Johannesburg': '约翰内斯堡',
|
||||||
|
'Africa/Nairobi': '内罗毕',
|
||||||
|
'Africa/Casablanca': '卡萨布兰卡',
|
||||||
|
'Australia/Sydney': '悉尼',
|
||||||
|
'Pacific/Auckland': '奥克兰',
|
||||||
|
};
|
||||||
|
|
||||||
|
const _languageNames = {
|
||||||
|
'id': {'zh': '印度尼西亚语', 'en': 'Indonesian', 'id': 'Bahasa Indonesia'},
|
||||||
|
'en': {'zh': '英语', 'en': 'English', 'id': 'Inggris'},
|
||||||
|
'zh': {'zh': '中文', 'en': 'Chinese', 'id': 'Mandarin'},
|
||||||
|
};
|
||||||
|
|
||||||
|
const _statusNames = {
|
||||||
|
'normal': {'zh': '正常', 'en': 'Active', 'id': 'Aktif'},
|
||||||
|
'limited': {'zh': '受限', 'en': 'Limited', 'id': 'Dibatasi'},
|
||||||
|
'banned': {'zh': '已封禁', 'en': 'Banned', 'id': 'Diblokir'},
|
||||||
|
'deactivated': {'zh': '已注销', 'en': 'Deactivated', 'id': 'Dinonaktifkan'},
|
||||||
|
};
|
||||||
|
|
||||||
|
String _pick(Map<String, String> names, String localeName) =>
|
||||||
|
names[localeName] ?? names['en']!;
|
||||||
|
|
||||||
|
/// 国家码 → 国家名;未收录的码原样返回。
|
||||||
|
String countryName(String code, String localeName) {
|
||||||
|
final key = code.trim().toUpperCase();
|
||||||
|
if (key.isEmpty) return '';
|
||||||
|
final names = localeName == 'zh' ? _countryNamesZh : _countryNamesEn;
|
||||||
|
return names[key] ?? key;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// IANA 时区 → 城市名;中文界面查表,其余语言取时区里的城市段。
|
||||||
|
String timezoneName(String timezone, String localeName) {
|
||||||
|
final value = timezone.trim();
|
||||||
|
if (value.isEmpty) return '';
|
||||||
|
if (localeName == 'zh') {
|
||||||
|
final name = _timezoneNamesZh[value];
|
||||||
|
if (name != null) return name;
|
||||||
|
}
|
||||||
|
final city = value.split('/').last.replaceAll('_', ' ');
|
||||||
|
return city.isEmpty ? value : city;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// BCP-47 语言标签 → 语言名,按主语言归类(`zh-TW` 也算中文)。
|
||||||
|
String languageName(String language, String localeName) {
|
||||||
|
final value = language.trim();
|
||||||
|
if (value.isEmpty) return '';
|
||||||
|
final primary = value.split(RegExp('[-_]')).first.toLowerCase();
|
||||||
|
final names = _languageNames[primary];
|
||||||
|
return names == null ? value : _pick(names, localeName);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 账号状态 → 展示文案;未知状态原样返回。
|
||||||
|
String accountStatusText(String status, String localeName) {
|
||||||
|
final value = status.trim().toLowerCase();
|
||||||
|
final names = _statusNames[value];
|
||||||
|
return names == null ? status : _pick(names, localeName);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// VIP 等级:0 表示未开通,避免用户看到一个孤零零的 0。
|
||||||
|
String vipLevelText(int level, String localeName) {
|
||||||
|
if (level > 0) return 'VIP $level';
|
||||||
|
return switch (localeName) {
|
||||||
|
'zh' => '未开通',
|
||||||
|
'id' => 'Belum aktif',
|
||||||
|
_ => 'Not subscribed',
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -4,14 +4,16 @@ import 'package:flutter/widgets.dart';
|
|||||||
|
|
||||||
/// 无位移的短促淡入转场。
|
/// 无位移的短促淡入转场。
|
||||||
class FadePageRoute<T> extends PageRouteBuilder<T> {
|
class FadePageRoute<T> extends PageRouteBuilder<T> {
|
||||||
FadePageRoute({required WidgetBuilder builder, super.settings})
|
FadePageRoute({
|
||||||
: super(
|
required WidgetBuilder builder,
|
||||||
transitionDuration: const Duration(milliseconds: 220),
|
super.settings,
|
||||||
reverseTransitionDuration: const Duration(milliseconds: 180),
|
super.transitionDuration = const Duration(milliseconds: 220),
|
||||||
pageBuilder: (context, _, _) => builder(context),
|
super.reverseTransitionDuration = const Duration(milliseconds: 180),
|
||||||
transitionsBuilder: (context, animation, _, child) => FadeTransition(
|
}) : super(
|
||||||
opacity: CurvedAnimation(parent: animation, curve: Curves.easeOut),
|
pageBuilder: (context, _, _) => builder(context),
|
||||||
child: child,
|
transitionsBuilder: (context, animation, _, child) => FadeTransition(
|
||||||
),
|
opacity: CurvedAnimation(parent: animation, curve: Curves.easeOut),
|
||||||
);
|
child: child,
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
@@ -27,13 +27,13 @@ abstract final class AppColors {
|
|||||||
static const overlaySecondary = Color(0xFFC7C7CC);
|
static const overlaySecondary = Color(0xFFC7C7CC);
|
||||||
static const overlayLabel = Color(0xFFE6E6EB);
|
static const overlayLabel = Color(0xFFE6E6EB);
|
||||||
|
|
||||||
/// 主操作、选中态、播放进度(品牌橙)。
|
/// 主操作、选中态、播放进度。旧品牌橙已全量映射为品牌红(2026-10 改版)。
|
||||||
static const blue = Color(0xFFFF6B2C);
|
static const blue = Color(0xFFF04E4E);
|
||||||
static const primary = blue;
|
static const primary = blue;
|
||||||
static const actionRed = Color(0xFFFF3B30);
|
static const actionRed = Color(0xFFFF3B30);
|
||||||
|
|
||||||
/// 主操作按下态。
|
/// 主操作按下态。
|
||||||
static const bluePressed = Color(0xFFE55A1F);
|
static const bluePressed = Color(0xFFD64040);
|
||||||
|
|
||||||
/// 链接与次要高亮:统一改用中性浅灰,避免旧青色残留。
|
/// 链接与次要高亮:统一改用中性浅灰,避免旧青色残留。
|
||||||
static const blueSoft = Color(0xFFB0B0B0);
|
static const blueSoft = Color(0xFFB0B0B0);
|
||||||
@@ -47,6 +47,10 @@ abstract final class AppColors {
|
|||||||
static const homeGiftPink = Color(0xFFFF4D8D);
|
static const homeGiftPink = Color(0xFFFF4D8D);
|
||||||
static const vipGoldStart = Color(0xFFF5D9A0);
|
static const vipGoldStart = Color(0xFFF5D9A0);
|
||||||
static const vipGoldEnd = Color(0xFFE8B65A);
|
static const vipGoldEnd = Color(0xFFE8B65A);
|
||||||
|
|
||||||
|
/// 「我的」页 VIP 卡的浅香槟金(见设计稿,接近纯色)。
|
||||||
|
static const vipCardStart = Color(0xFFF6E8C6);
|
||||||
|
static const vipCardEnd = Color(0xFFEDD9A8);
|
||||||
static const vipBadgeSurface = Color(0x1F3D2408);
|
static const vipBadgeSurface = Color(0x1F3D2408);
|
||||||
static const bronze = Color(0xFFCD7F32);
|
static const bronze = Color(0xFFCD7F32);
|
||||||
static const bronzeDeep = Color(0xFFA9713A);
|
static const bronzeDeep = Color(0xFFA9713A);
|
||||||
@@ -75,10 +79,24 @@ abstract final class AppColors {
|
|||||||
/// 首页/追剧/我的统一的纯黑内容背景。
|
/// 首页/追剧/我的统一的纯黑内容背景。
|
||||||
static const appBackground = Color(0xFF000000);
|
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 contentCard = Color(0xFF16161A);
|
||||||
static const contentSurface = Color(0xFF1C1C1E);
|
static const contentSurface = Color(0xFF1C1C1E);
|
||||||
static const skeletonSurface = Color(0xFF141414);
|
|
||||||
|
/// 首页、分类与搜索网格骨架的极暗底色。
|
||||||
|
static const skeletonSurface = Color(0xFF0E0E0E);
|
||||||
|
|
||||||
|
/// 播放器、推荐与详情页大面积媒体占位的深灰底色。
|
||||||
|
static const skeletonMedia = Color(0xFF1C1C1E);
|
||||||
static const contentChip = Color(0xFF2C2C2E);
|
static const contentChip = Color(0xFF2C2C2E);
|
||||||
static const contentBorder = Color(0x1AFFFFFF);
|
static const contentBorder = Color(0x1AFFFFFF);
|
||||||
static const filterChipSelected = Color(0xFF21090E);
|
static const filterChipSelected = Color(0xFF21090E);
|
||||||
@@ -91,7 +109,7 @@ abstract final class AppColors {
|
|||||||
static const mineGradientTop = Color(0xFF3A1B0E);
|
static const mineGradientTop = Color(0xFF3A1B0E);
|
||||||
static const mineGradientMiddle = Color(0xFF1A0C07);
|
static const mineGradientMiddle = Color(0xFF1A0C07);
|
||||||
static const mineGradientBottom = Color(0xFF000000);
|
static const mineGradientBottom = Color(0xFF000000);
|
||||||
static const mineGradientGlow = Color(0x33FF6B2C);
|
static const mineGradientGlow = Color(0x33F04E4E);
|
||||||
static const mineGridSurface = Color(0x99101010);
|
static const mineGridSurface = Color(0x99101010);
|
||||||
static const minePanelSurface = Color(0xFF101010);
|
static const minePanelSurface = Color(0xFF101010);
|
||||||
static const mineMoreDivider = Color(0xFF1C1C1E);
|
static const mineMoreDivider = Color(0xFF1C1C1E);
|
||||||
@@ -106,7 +124,7 @@ abstract final class AppColors {
|
|||||||
static const mineIconLanguage = Color(0xFF22D3EE);
|
static const mineIconLanguage = Color(0xFF22D3EE);
|
||||||
static const mineIconSettings = Color(0xFFA1A1AA);
|
static const mineIconSettings = Color(0xFFA1A1AA);
|
||||||
static const mineIconNotices = Color(0xFFFF8A4C);
|
static const mineIconNotices = Color(0xFFFF8A4C);
|
||||||
static const recommendPlaylistGlow = Color(0x26FF6B2C);
|
static const recommendPlaylistGlow = Color(0x26F04E4E);
|
||||||
|
|
||||||
/// 次级文字与列表 chevron。
|
/// 次级文字与列表 chevron。
|
||||||
static const textPrimary = Color(0xFFFFFFFF);
|
static const textPrimary = Color(0xFFFFFFFF);
|
||||||
@@ -128,9 +146,11 @@ abstract final class AppColors {
|
|||||||
/// 底部导航底色。
|
/// 底部导航底色。
|
||||||
static const bar = ink;
|
static const bar = ink;
|
||||||
|
|
||||||
/// 底部导航专用:纯黑背景、选中白与未选中灰。
|
/// 底部导航专用:纯黑背景、选中品牌红与未选中白。
|
||||||
static const navBackground = Color(0xFF000000);
|
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);
|
static const cardShadow = Color(0x00000000);
|
||||||
@@ -183,8 +203,8 @@ abstract final class AppColors {
|
|||||||
/// 封面集数胶囊。
|
/// 封面集数胶囊。
|
||||||
static const badgeBeige = raised;
|
static const badgeBeige = raised;
|
||||||
|
|
||||||
/// 导航未选中。
|
/// 导航未选中(设计稿为白色线框 + 白色文字)。
|
||||||
static const navUnselected = textSecondary;
|
static const navUnselected = Color(0xFFFFFFFF);
|
||||||
|
|
||||||
/// 首页内容角标。
|
/// 首页内容角标。
|
||||||
static const badgeHot = Color(0xFFE5484D);
|
static const badgeHot = Color(0xFFE5484D);
|
||||||
@@ -208,7 +228,7 @@ abstract final class AppColors {
|
|||||||
static const bannerScrimEnd = Color(0xE6000000);
|
static const bannerScrimEnd = Color(0xE6000000);
|
||||||
|
|
||||||
/// 票券虚线等主色描边。
|
/// 票券虚线等主色描边。
|
||||||
static const primaryBorder = Color(0x66FF6B2C);
|
static const primaryBorder = Color(0x66F04E4E);
|
||||||
|
|
||||||
static const outlineDark = border;
|
static const outlineDark = border;
|
||||||
static const outlineVariantDark = border;
|
static const outlineVariantDark = border;
|
||||||
|
|||||||
@@ -146,10 +146,12 @@ abstract final class AppDimens {
|
|||||||
static const double homeActionGap = 6;
|
static const double homeActionGap = 6;
|
||||||
|
|
||||||
/// 推荐分区。
|
/// 推荐分区。
|
||||||
|
static const double recommendSectionGap = 12;
|
||||||
static const double recommendSectionTitle = 17;
|
static const double recommendSectionTitle = 17;
|
||||||
static const double recommendSectionSubtitle = 11;
|
static const double recommendSectionSubtitle = 11;
|
||||||
static const double recommendSectionMore = 12;
|
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;
|
static const double recommendCardWidth = 122;
|
||||||
|
|
||||||
/// 首页热播榜。
|
/// 首页热播榜。
|
||||||
@@ -169,25 +171,26 @@ abstract final class AppDimens {
|
|||||||
|
|
||||||
/// 全部短剧筛选与追剧双列。
|
/// 全部短剧筛选与追剧双列。
|
||||||
static const double filterChipFont = 16;
|
static const double filterChipFont = 16;
|
||||||
static const double filterChipHeight = 32;
|
static const double filterChipHeight = 28;
|
||||||
static const double filterChipRadius = 16;
|
static const double filterChipRadius = 14;
|
||||||
static const double filterChipHorizontalPadding = 12;
|
static const double filterChipHorizontalPadding = 12;
|
||||||
static const double filterRowGap = 6;
|
static const double filterRowGap = 6;
|
||||||
static const double filterItemGap = 10;
|
static const double filterItemGap = 10;
|
||||||
static const double allDramasHorizontal = 12;
|
static const double allDramasHorizontal = 12;
|
||||||
static const double allDramasGridGap = 6;
|
static const double allDramasGridGap = 6;
|
||||||
static const double allDramasGridRowGap = 12;
|
static const double allDramasGridRowGap = 6;
|
||||||
static const double allDramasFilterToGridGap = 12;
|
static const double allDramasFilterToGridGap = 12;
|
||||||
static const double followingHeaderHeight = 52;
|
static const double followingHeaderHeight = 52;
|
||||||
static const double followingTabFont = 18;
|
static const double followingTabFont = 18;
|
||||||
static const double followingTabGap = 24;
|
static const double followingTabGap = 24;
|
||||||
static const double followingEditIconSize = 20;
|
static const double followingEditIconSize = 20;
|
||||||
static const double followingEditHitSize = 40;
|
static const double followingEditHitSize = 40;
|
||||||
static const double followingAddIconSize = 28;
|
static const double followingAddIconSize = 20;
|
||||||
static const double followingAddIconStroke = 1.5;
|
static const double followingAddIconStroke = 1.5;
|
||||||
static const double followingGridGap = 6;
|
static const double followingGridGap = 6;
|
||||||
static const double followingGridRowGap = 12;
|
static const double followingGridRowGap = 12;
|
||||||
static const double followingCardTextExtent = 70;
|
// 单行标题 16*1.3 + 间距 6+4 + 副标题约 16 ≈ 47。
|
||||||
|
static const double followingCardTextExtent = 48;
|
||||||
static const double followingSubtitleFont = 12;
|
static const double followingSubtitleFont = 12;
|
||||||
static const double followingSubtitleGap = 4;
|
static const double followingSubtitleGap = 4;
|
||||||
static const double followingProgressHeight = 2;
|
static const double followingProgressHeight = 2;
|
||||||
@@ -201,6 +204,47 @@ abstract final class AppDimens {
|
|||||||
static const double followingHistoryProgressGap = 8;
|
static const double followingHistoryProgressGap = 8;
|
||||||
static const double followingHistoryLabelGap = 4;
|
static const double followingHistoryLabelGap = 4;
|
||||||
static const double followingHistoryActionHeight = 28;
|
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(
|
static const Duration followingTabAnimationDuration = Duration(
|
||||||
milliseconds: 180,
|
milliseconds: 180,
|
||||||
);
|
);
|
||||||
@@ -211,8 +255,8 @@ abstract final class AppDimens {
|
|||||||
/// 「我的」页中性视觉。
|
/// 「我的」页中性视觉。
|
||||||
static const double mineCardRadius = 16;
|
static const double mineCardRadius = 16;
|
||||||
static const double mineSectionTitle = 15;
|
static const double mineSectionTitle = 15;
|
||||||
static const double mineAvatar = 56;
|
static const double mineAvatar = 64;
|
||||||
static const double mineUserName = 20;
|
static const double mineUserName = 24;
|
||||||
static const double mineUserNameLineHeight = 1.15;
|
static const double mineUserNameLineHeight = 1.15;
|
||||||
static const double mineUserNameUidGap = 2;
|
static const double mineUserNameUidGap = 2;
|
||||||
static const double mineUid = 12;
|
static const double mineUid = 12;
|
||||||
@@ -227,9 +271,25 @@ abstract final class AppDimens {
|
|||||||
static const double mineGridDividerWidth = 1;
|
static const double mineGridDividerWidth = 1;
|
||||||
static const double mineSectionTitleFont = 16;
|
static const double mineSectionTitleFont = 16;
|
||||||
static const double mineSectionLinkFont = 12;
|
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 mineContinueCardWidth = 96;
|
||||||
static const double mineContinueRowHeight = 168;
|
static const double mineContinueRowHeight = 172;
|
||||||
static const double mineContinueTitleFont = 13;
|
static const double mineContinueTitleFont = 13;
|
||||||
static const double mineContinueMetaFont = 11;
|
static const double mineContinueMetaFont = 11;
|
||||||
static const double mineStatsValueFont = 18;
|
static const double mineStatsValueFont = 18;
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ abstract final class AppTheme {
|
|||||||
/// 全局深色主题。
|
/// 全局深色主题。
|
||||||
static ThemeData dark() {
|
static ThemeData dark() {
|
||||||
const scheme = ColorScheme.dark(
|
const scheme = ColorScheme.dark(
|
||||||
primary: AppColors.blue,
|
primary: AppColors.brandRed,
|
||||||
onPrimary: AppColors.onPrimary,
|
onPrimary: AppColors.onPrimary,
|
||||||
secondary: AppColors.secondary,
|
secondary: AppColors.secondary,
|
||||||
onSecondary: AppColors.ink,
|
onSecondary: AppColors.ink,
|
||||||
@@ -54,7 +54,7 @@ abstract final class AppTheme {
|
|||||||
outline: AppColors.border,
|
outline: AppColors.border,
|
||||||
outlineVariant: AppColors.border,
|
outlineVariant: AppColors.border,
|
||||||
surfaceTint: AppColors.transparent,
|
surfaceTint: AppColors.transparent,
|
||||||
inversePrimary: AppColors.bluePressed,
|
inversePrimary: AppColors.brandRedPressed,
|
||||||
error: AppColors.error,
|
error: AppColors.error,
|
||||||
onError: AppColors.onPrimary,
|
onError: AppColors.onPrimary,
|
||||||
);
|
);
|
||||||
@@ -66,16 +66,16 @@ abstract final class AppTheme {
|
|||||||
canvasColor: AppColors.ink,
|
canvasColor: AppColors.ink,
|
||||||
fontFamily: 'PlusJakartaSans',
|
fontFamily: 'PlusJakartaSans',
|
||||||
progressIndicatorTheme: const ProgressIndicatorThemeData(
|
progressIndicatorTheme: const ProgressIndicatorThemeData(
|
||||||
color: AppColors.blue,
|
color: AppColors.brandRed,
|
||||||
),
|
),
|
||||||
sliderTheme: const SliderThemeData(
|
sliderTheme: const SliderThemeData(
|
||||||
activeTrackColor: AppColors.blue,
|
activeTrackColor: AppColors.brandRed,
|
||||||
inactiveTrackColor: AppColors.border,
|
inactiveTrackColor: AppColors.border,
|
||||||
thumbColor: AppColors.onPrimary,
|
thumbColor: AppColors.onPrimary,
|
||||||
),
|
),
|
||||||
tabBarTheme: const TabBarThemeData(
|
tabBarTheme: const TabBarThemeData(
|
||||||
labelColor: AppColors.blue,
|
labelColor: AppColors.brandRed,
|
||||||
indicatorColor: AppColors.blue,
|
indicatorColor: AppColors.brandRed,
|
||||||
unselectedLabelColor: AppColors.muted,
|
unselectedLabelColor: AppColors.muted,
|
||||||
),
|
),
|
||||||
textButtonTheme: TextButtonThemeData(
|
textButtonTheme: TextButtonThemeData(
|
||||||
@@ -138,12 +138,12 @@ abstract final class AppTheme {
|
|||||||
),
|
),
|
||||||
focusedBorder: OutlineInputBorder(
|
focusedBorder: OutlineInputBorder(
|
||||||
borderRadius: _inputRadius,
|
borderRadius: _inputRadius,
|
||||||
borderSide: const BorderSide(color: AppColors.blue),
|
borderSide: const BorderSide(color: AppColors.brandRed),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
chipTheme: ChipThemeData(
|
chipTheme: ChipThemeData(
|
||||||
backgroundColor: AppColors.raised,
|
backgroundColor: AppColors.raised,
|
||||||
selectedColor: AppColors.blue.withValues(alpha: 0.22),
|
selectedColor: AppColors.brandRed.withValues(alpha: 0.22),
|
||||||
labelStyle: const TextStyle(color: AppColors.onSurface),
|
labelStyle: const TextStyle(color: AppColors.onSurface),
|
||||||
secondaryLabelStyle: const TextStyle(color: AppColors.muted),
|
secondaryLabelStyle: const TextStyle(color: AppColors.muted),
|
||||||
side: const BorderSide(color: AppColors.border),
|
side: const BorderSide(color: AppColors.border),
|
||||||
@@ -216,7 +216,7 @@ abstract final class AppTheme {
|
|||||||
),
|
),
|
||||||
trackColor: WidgetStateProperty.resolveWith(
|
trackColor: WidgetStateProperty.resolveWith(
|
||||||
(states) =>
|
(states) =>
|
||||||
states.contains(WidgetState.selected) ? AppColors.blue : null,
|
states.contains(WidgetState.selected) ? AppColors.brandRed : null,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
snackBarTheme: const SnackBarThemeData(
|
snackBarTheme: const SnackBarThemeData(
|
||||||
@@ -273,8 +273,8 @@ abstract final class AppTheme {
|
|||||||
if (states.contains(WidgetState.pressed) ||
|
if (states.contains(WidgetState.pressed) ||
|
||||||
states.contains(WidgetState.hovered) ||
|
states.contains(WidgetState.hovered) ||
|
||||||
states.contains(WidgetState.focused)) {
|
states.contains(WidgetState.focused)) {
|
||||||
return AppColors.bluePressed;
|
return AppColors.brandRedPressed;
|
||||||
}
|
}
|
||||||
return AppColors.blue;
|
return AppColors.brandRed;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,119 @@
|
|||||||
|
// 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
|
||||||
|
?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],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,18 +7,12 @@ import 'app_bottom_nav.dart';
|
|||||||
|
|
||||||
/// 客户端根导航的固定顺序。
|
/// 客户端根导航的固定顺序。
|
||||||
enum AppRootTab {
|
enum AppRootTab {
|
||||||
home(
|
home(),
|
||||||
assetPath: 'assets/icon/film_reel.png',
|
|
||||||
selectedAssetPath: 'assets/icon/film_reel_filled.png',
|
|
||||||
),
|
|
||||||
recommend(),
|
recommend(),
|
||||||
following(),
|
following(),
|
||||||
mine();
|
mine();
|
||||||
|
|
||||||
const AppRootTab({this.assetPath, this.selectedAssetPath});
|
const AppRootTab();
|
||||||
|
|
||||||
final String? assetPath;
|
|
||||||
final String? selectedAssetPath;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
extension AppRootTabUi on AppRootTab {
|
extension AppRootTabUi on AppRootTab {
|
||||||
@@ -30,15 +24,15 @@ extension AppRootTabUi on AppRootTab {
|
|||||||
};
|
};
|
||||||
|
|
||||||
IconData get icon => switch (this) {
|
IconData get icon => switch (this) {
|
||||||
AppRootTab.home => Icons.theaters_outlined,
|
AppRootTab.home => Icons.home_outlined,
|
||||||
AppRootTab.recommend => Icons.smart_display_outlined,
|
AppRootTab.recommend => Icons.celebration_outlined,
|
||||||
AppRootTab.following => Icons.bookmark_border_rounded,
|
AppRootTab.following => Icons.bookmark_border_rounded,
|
||||||
AppRootTab.mine => Icons.person_outline_rounded,
|
AppRootTab.mine => Icons.person_outline_rounded,
|
||||||
};
|
};
|
||||||
|
|
||||||
IconData get selectedIcon => switch (this) {
|
IconData get selectedIcon => switch (this) {
|
||||||
AppRootTab.home => Icons.theaters,
|
AppRootTab.home => Icons.home_rounded,
|
||||||
AppRootTab.recommend => Icons.smart_display_rounded,
|
AppRootTab.recommend => Icons.celebration_rounded,
|
||||||
AppRootTab.following => Icons.bookmark_rounded,
|
AppRootTab.following => Icons.bookmark_rounded,
|
||||||
AppRootTab.mine => Icons.person_rounded,
|
AppRootTab.mine => Icons.person_rounded,
|
||||||
};
|
};
|
||||||
@@ -75,8 +69,6 @@ class AppRootBottomNav extends StatelessWidget {
|
|||||||
tabKey: tab.tabKey,
|
tabKey: tab.tabKey,
|
||||||
icon: tab.icon,
|
icon: tab.icon,
|
||||||
selectedIcon: tab.selectedIcon,
|
selectedIcon: tab.selectedIcon,
|
||||||
assetPath: tab.assetPath,
|
|
||||||
selectedAssetPath: tab.selectedAssetPath,
|
|
||||||
label: tab.label(l10n),
|
label: tab.label(l10n),
|
||||||
selected: tab == selected,
|
selected: tab == selected,
|
||||||
onTap: () => onSelected(tab),
|
onTap: () => onSelected(tab),
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import '../../l10n/app_localizations.dart';
|
|||||||
import '../../pages/auth/auth_view.dart';
|
import '../../pages/auth/auth_view.dart';
|
||||||
import '../data/services/auth_controller.dart';
|
import '../data/services/auth_controller.dart';
|
||||||
import '../theme/app_colors.dart';
|
import '../theme/app_colors.dart';
|
||||||
|
import 'app_glow_panel.dart';
|
||||||
|
|
||||||
/// 打开登录 / 注册页(沿用现有 Navigator 风格,不引路由库)
|
/// 打开登录 / 注册页(沿用现有 Navigator 风格,不引路由库)
|
||||||
Future<void> openAuthPage(BuildContext context, {bool signUpMode = false}) {
|
Future<void> openAuthPage(BuildContext context, {bool signUpMode = false}) {
|
||||||
@@ -15,7 +16,7 @@ Future<void> openAuthPage(BuildContext context, {bool signUpMode = false}) {
|
|||||||
|
|
||||||
/// 受限动作的登录闸:已登录返回 true;未登录弹底部提示并引导登录,返回 false。
|
/// 受限动作的登录闸:已登录返回 true;未登录弹底部提示并引导登录,返回 false。
|
||||||
///
|
///
|
||||||
/// 首页/发现/详情保持匿名可看,只有收藏、点赞、评论这类"要对到具体账号"的动作才走这里。
|
/// 首页/发现/详情与非付费互动保持匿名可用;解锁、权益与消耗类动作走这里。
|
||||||
Future<bool> ensureSignedIn(BuildContext context) async {
|
Future<bool> ensureSignedIn(BuildContext context) async {
|
||||||
final auth = context.read<AuthController>();
|
final auth = context.read<AuthController>();
|
||||||
if (auth.isSignedIn) return true;
|
if (auth.isSignedIn) return true;
|
||||||
@@ -23,11 +24,11 @@ Future<bool> ensureSignedIn(BuildContext context) async {
|
|||||||
final l10n = AppLocalizations.of(context)!;
|
final l10n = AppLocalizations.of(context)!;
|
||||||
final go = await showModalBottomSheet<bool>(
|
final go = await showModalBottomSheet<bool>(
|
||||||
context: context,
|
context: context,
|
||||||
backgroundColor: AppColors.card,
|
backgroundColor: AppColors.transparent,
|
||||||
shape: const RoundedRectangleBorder(
|
builder: (sheetContext) => AppGlowPanel(
|
||||||
borderRadius: BorderRadius.vertical(top: Radius.circular(18)),
|
borderRadius: const BorderRadius.vertical(top: Radius.circular(18)),
|
||||||
),
|
border: false,
|
||||||
builder: (sheetContext) => SafeArea(
|
child: SafeArea(
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.fromLTRB(20, 18, 20, 20),
|
padding: const EdgeInsets.fromLTRB(20, 18, 20, 20),
|
||||||
child: Column(
|
child: Column(
|
||||||
@@ -71,11 +72,13 @@ Future<bool> ensureSignedIn(BuildContext context) async {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
if (go == true && context.mounted) {
|
if (go == true && context.mounted) {
|
||||||
await openAuthPage(context);
|
await openAuthPage(context);
|
||||||
|
if (context.mounted) return context.read<AuthController>().isSignedIn;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import 'package:flutter/material.dart';
|
|||||||
import '../config/app_config.dart';
|
import '../config/app_config.dart';
|
||||||
import '../config/server_endpoint.dart';
|
import '../config/server_endpoint.dart';
|
||||||
import '../theme/app_colors.dart';
|
import '../theme/app_colors.dart';
|
||||||
|
import 'app_glow_panel.dart';
|
||||||
|
|
||||||
const String _title = '设置服务地址';
|
const String _title = '设置服务地址';
|
||||||
const String _save = '保存';
|
const String _save = '保存';
|
||||||
@@ -72,9 +73,9 @@ class _CatalogEndpointDialogState extends State<_CatalogEndpointDialog> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return AlertDialog(
|
return AppGlowDialog(
|
||||||
title: const Text(_title),
|
title: _title,
|
||||||
content: SingleChildScrollView(
|
contentChild: SingleChildScrollView(
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
|||||||
@@ -11,7 +11,8 @@ const Duration _shimmerPeriod = Duration(milliseconds: 1400);
|
|||||||
const double _shimmerTravel = 2.4;
|
const double _shimmerTravel = 2.4;
|
||||||
const double _shimmerStart = -1.2;
|
const double _shimmerStart = -1.2;
|
||||||
const double _subtitleWidthFactor = 0.62;
|
const double _subtitleWidthFactor = 0.62;
|
||||||
const Color _shimmerHighlight = Color(0x38FFFFFF);
|
const double _shimmerPhaseStep = 0.13;
|
||||||
|
const Color _shimmerHighlight = Color(0x0DFFFFFF);
|
||||||
|
|
||||||
/// 首页短剧网格的占位。行数至少铺满可视高度,并带一道扫光。
|
/// 首页短剧网格的占位。行数至少铺满可视高度,并带一道扫光。
|
||||||
class DramaGridSkeleton extends StatefulWidget {
|
class DramaGridSkeleton extends StatefulWidget {
|
||||||
@@ -53,21 +54,19 @@ class _DramaGridSkeletonState extends State<DramaGridSkeleton>
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return LayoutBuilder(
|
return LayoutBuilder(
|
||||||
builder: (context, constraints) {
|
builder: (context, constraints) {
|
||||||
final grid = _grid(constraints.maxWidth, constraints.maxHeight);
|
|
||||||
return AnimatedBuilder(
|
return AnimatedBuilder(
|
||||||
animation: _shimmer,
|
animation: _shimmer,
|
||||||
builder: (context, child) => ShaderMask(
|
builder: (context, _) => _grid(
|
||||||
blendMode: BlendMode.srcATop,
|
constraints.maxWidth,
|
||||||
shaderCallback: (bounds) => _shader(bounds),
|
constraints.maxHeight,
|
||||||
child: child,
|
_shimmer.value,
|
||||||
),
|
),
|
||||||
child: grid,
|
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _grid(double width, double height) {
|
Widget _grid(double width, double height, double shimmerValue) {
|
||||||
final itemWidth = _itemWidth(width);
|
final itemWidth = _itemWidth(width);
|
||||||
final itemExtent = _itemExtent(itemWidth);
|
final itemExtent = _itemExtent(itemWidth);
|
||||||
return GridView.builder(
|
return GridView.builder(
|
||||||
@@ -85,7 +84,8 @@ class _DramaGridSkeletonState extends State<DramaGridSkeleton>
|
|||||||
mainAxisExtent: itemExtent,
|
mainAxisExtent: itemExtent,
|
||||||
),
|
),
|
||||||
itemCount: _fillCount(height, itemExtent),
|
itemCount: _fillCount(height, itemExtent),
|
||||||
itemBuilder: (context, index) => _SkeletonCard(index: index),
|
itemBuilder: (context, index) =>
|
||||||
|
_SkeletonCard(index: index, shimmerValue: shimmerValue),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -105,48 +105,61 @@ class _DramaGridSkeletonState extends State<DramaGridSkeleton>
|
|||||||
final rows = (height / rowHeight).ceil() + 1;
|
final rows = (height / rowHeight).ceil() + 1;
|
||||||
return math.max(widget.itemCount, rows * widget.columns);
|
return math.max(widget.itemCount, rows * widget.columns);
|
||||||
}
|
}
|
||||||
|
|
||||||
Shader _shader(Rect bounds) {
|
|
||||||
final shift = _shimmerStart + _shimmerTravel * _shimmer.value;
|
|
||||||
return LinearGradient(
|
|
||||||
begin: Alignment(shift, -0.3),
|
|
||||||
end: Alignment(shift + 1, 0.3),
|
|
||||||
colors: const [
|
|
||||||
AppColors.skeletonSurface,
|
|
||||||
_shimmerHighlight,
|
|
||||||
AppColors.skeletonSurface,
|
|
||||||
],
|
|
||||||
).createShader(bounds);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class _SkeletonCard extends StatelessWidget {
|
class _SkeletonCard extends StatelessWidget {
|
||||||
const _SkeletonCard({required this.index});
|
const _SkeletonCard({required this.index, required this.shimmerValue});
|
||||||
|
|
||||||
final int index;
|
final int index;
|
||||||
|
final double shimmerValue;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Column(
|
final phase = (shimmerValue + index * _shimmerPhaseStep) % 1.0;
|
||||||
|
return Stack(
|
||||||
key: Key('drama-grid-skeleton-$index'),
|
key: Key('drama-grid-skeleton-$index'),
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
children: [
|
||||||
AspectRatio(
|
Column(
|
||||||
aspectRatio: AppDimens.cardCoverAspectRatio,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
child: const _SkeletonBlock(),
|
children: [
|
||||||
|
AspectRatio(
|
||||||
|
aspectRatio: AppDimens.cardCoverAspectRatio,
|
||||||
|
child: const _SkeletonBlock(),
|
||||||
|
),
|
||||||
|
const SizedBox(height: AppDimens.cardCoverTitleGap),
|
||||||
|
const _SkeletonBar(),
|
||||||
|
const SizedBox(height: AppDimens.skeletonTitleBarGap),
|
||||||
|
const FractionallySizedBox(
|
||||||
|
widthFactor: _subtitleWidthFactor,
|
||||||
|
child: _SkeletonBar(),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(height: AppDimens.cardCoverTitleGap),
|
Positioned.fill(
|
||||||
const _SkeletonBar(),
|
child: IgnorePointer(
|
||||||
const SizedBox(height: AppDimens.skeletonTitleBarGap),
|
child: ClipRRect(
|
||||||
const FractionallySizedBox(
|
borderRadius: BorderRadius.circular(AppDimens.homeCardRadius),
|
||||||
widthFactor: _subtitleWidthFactor,
|
child: DecoratedBox(
|
||||||
child: _SkeletonBar(),
|
decoration: BoxDecoration(gradient: _cardHighlight(phase)),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LinearGradient _cardHighlight(double shimmerValue) {
|
||||||
|
final shift = _shimmerStart + _shimmerTravel * shimmerValue;
|
||||||
|
return LinearGradient(
|
||||||
|
begin: Alignment(shift, -0.3),
|
||||||
|
end: Alignment(shift + 1, 0.3),
|
||||||
|
colors: const [Colors.transparent, _shimmerHighlight, Colors.transparent],
|
||||||
|
stops: const [0.42, 0.5, 0.58],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
class _SkeletonBlock extends StatelessWidget {
|
class _SkeletonBlock extends StatelessWidget {
|
||||||
const _SkeletonBlock();
|
const _SkeletonBlock();
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import '../theme/app_colors.dart';
|
import '../theme/app_colors.dart';
|
||||||
import '../theme/app_theme.dart';
|
|
||||||
import 'subpage_header.dart';
|
import 'subpage_header.dart';
|
||||||
|
|
||||||
/// 二级页面通用骨架:返回栏 + 标题/副标题 + 可滚动内容,无底部导航。
|
/// 二级页面通用骨架:返回栏 + 标题/副标题 + 可滚动内容,无底部导航。
|
||||||
@@ -29,7 +28,19 @@ class PlainPageScaffold extends StatelessWidget {
|
|||||||
key: pageKey,
|
key: pageKey,
|
||||||
backgroundColor: AppColors.ink,
|
backgroundColor: AppColors.ink,
|
||||||
body: DecoratedBox(
|
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: SafeArea(
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
|||||||
@@ -5,6 +5,24 @@ import 'package:flutter/material.dart';
|
|||||||
import '../config/app_config.dart';
|
import '../config/app_config.dart';
|
||||||
import '../theme/app_colors.dart';
|
import '../theme/app_colors.dart';
|
||||||
|
|
||||||
|
const int _minImageDecodePixels = 96;
|
||||||
|
const int _maxImageDecodePixels = 2048;
|
||||||
|
|
||||||
|
/// 将布局逻辑尺寸换算成有限像素尺寸,兼顾小头像和全屏首帧。
|
||||||
|
int resolveImageDecodePixels(double? logicalExtent, double devicePixelRatio) {
|
||||||
|
final ratio = devicePixelRatio.isFinite && devicePixelRatio > 0
|
||||||
|
? devicePixelRatio
|
||||||
|
: 1.0;
|
||||||
|
final extent =
|
||||||
|
logicalExtent != null && logicalExtent.isFinite && logicalExtent > 0
|
||||||
|
? logicalExtent
|
||||||
|
: 120.0;
|
||||||
|
return (extent * ratio)
|
||||||
|
.ceil()
|
||||||
|
.clamp(_minImageDecodePixels, _maxImageDecodePixels)
|
||||||
|
.toInt();
|
||||||
|
}
|
||||||
|
|
||||||
/// 封面图统一入口:后端给的是相对路径,这里补服务地址并处理加载失败。
|
/// 封面图统一入口:后端给的是相对路径,这里补服务地址并处理加载失败。
|
||||||
class RemoteImage extends StatelessWidget {
|
class RemoteImage extends StatelessWidget {
|
||||||
const RemoteImage(
|
const RemoteImage(
|
||||||
@@ -17,6 +35,8 @@ class RemoteImage extends StatelessWidget {
|
|||||||
this.fallbackIconKey,
|
this.fallbackIconKey,
|
||||||
this.fallbackAspectRatio,
|
this.fallbackAspectRatio,
|
||||||
this.fallbackColor = AppColors.raised,
|
this.fallbackColor = AppColors.raised,
|
||||||
|
this.decodeWidth,
|
||||||
|
this.decodeHeight,
|
||||||
});
|
});
|
||||||
|
|
||||||
final String path;
|
final String path;
|
||||||
@@ -27,21 +47,60 @@ class RemoteImage extends StatelessWidget {
|
|||||||
final Key? fallbackIconKey;
|
final Key? fallbackIconKey;
|
||||||
final double? fallbackAspectRatio;
|
final double? fallbackAspectRatio;
|
||||||
final Color fallbackColor;
|
final Color fallbackColor;
|
||||||
|
final int? decodeWidth;
|
||||||
|
final int? decodeHeight;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final url = AppConfig.mediaUrl(path);
|
final url = AppConfig.mediaUrl(path);
|
||||||
if (url.isEmpty) return _fallback(brand: showFallbackIcon);
|
if (url.isEmpty) return _fallback(brand: showFallbackIcon);
|
||||||
return Image.network(
|
return LayoutBuilder(
|
||||||
url,
|
builder: (context, constraints) {
|
||||||
width: width,
|
final pixelRatio = MediaQuery.devicePixelRatioOf(context);
|
||||||
height: height,
|
final layoutWidth = constraints.hasBoundedWidth
|
||||||
fit: fit,
|
? constraints.maxWidth
|
||||||
gaplessPlayback: true,
|
: width;
|
||||||
errorBuilder: (_, _, _) => _fallback(brand: showFallbackIcon),
|
final aspectRatio =
|
||||||
frameBuilder: (context, child, frame, wasSynchronouslyLoaded) {
|
fallbackAspectRatio != null &&
|
||||||
if (wasSynchronouslyLoaded || frame != null) return child;
|
fallbackAspectRatio!.isFinite &&
|
||||||
return _fallback(brand: showFallbackIcon);
|
fallbackAspectRatio! > 0
|
||||||
|
? fallbackAspectRatio
|
||||||
|
: null;
|
||||||
|
final inferredHeight = constraints.hasBoundedHeight
|
||||||
|
? constraints.maxHeight
|
||||||
|
: height ??
|
||||||
|
(layoutWidth != null && aspectRatio != null
|
||||||
|
? layoutWidth / aspectRatio
|
||||||
|
: null);
|
||||||
|
final cacheWidth =
|
||||||
|
decodeWidth ?? resolveImageDecodePixels(layoutWidth, pixelRatio);
|
||||||
|
// 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(
|
||||||
|
url,
|
||||||
|
width: width,
|
||||||
|
height: height,
|
||||||
|
fit: fit,
|
||||||
|
cacheWidth: cacheWidth
|
||||||
|
.clamp(_minImageDecodePixels, _maxImageDecodePixels)
|
||||||
|
.toInt(),
|
||||||
|
cacheHeight: cacheHeight
|
||||||
|
?.clamp(_minImageDecodePixels, _maxImageDecodePixels)
|
||||||
|
.toInt(),
|
||||||
|
gaplessPlayback: true,
|
||||||
|
errorBuilder: (_, _, _) => _fallback(brand: showFallbackIcon),
|
||||||
|
frameBuilder: (context, child, frame, wasSynchronouslyLoaded) {
|
||||||
|
if (wasSynchronouslyLoaded || frame != null) return child;
|
||||||
|
return _fallback(brand: showFallbackIcon);
|
||||||
|
},
|
||||||
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ const double _height = 52;
|
|||||||
const double _heightWithSubtitle = 64;
|
const double _heightWithSubtitle = 64;
|
||||||
const double _horizontal = 14;
|
const double _horizontal = 14;
|
||||||
const double _backSize = 40;
|
const double _backSize = 40;
|
||||||
const double _backGap = 12;
|
const double _backGap = 6;
|
||||||
const double _titleFontSize = 18;
|
const double _titleFontSize = 18;
|
||||||
const double _subtitleFontSize = 12;
|
const double _subtitleFontSize = 12;
|
||||||
const double _actionGap = 8;
|
const double _actionGap = 8;
|
||||||
@@ -163,7 +163,7 @@ class AppSubpageHeader extends StatelessWidget {
|
|||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: foreground,
|
color: foreground,
|
||||||
fontSize: _titleFontSize,
|
fontSize: _titleFontSize,
|
||||||
fontWeight: FontWeight.w800,
|
fontWeight: FontWeight.w400,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (subtitle != null) ...[
|
if (subtitle != null) ...[
|
||||||
|
|||||||
+73
-4
@@ -20,7 +20,6 @@
|
|||||||
"featured": "Featured",
|
"featured": "Featured",
|
||||||
"recommended": "Recommended",
|
"recommended": "Recommended",
|
||||||
"fruitShortsBrand": "FruitShorts",
|
"fruitShortsBrand": "FruitShorts",
|
||||||
"authLandingSubtitle": "Sign in to sync progress, favorites and coins",
|
|
||||||
"comingSoon": "Coming soon",
|
"comingSoon": "Coming soon",
|
||||||
"authLegal": "By continuing, you agree to the Terms of Service and Privacy Policy.",
|
"authLegal": "By continuing, you agree to the Terms of Service and Privacy Policy.",
|
||||||
"authLegalLead": "By continuing, you agree to the",
|
"authLegalLead": "By continuing, you agree to the",
|
||||||
@@ -55,12 +54,24 @@
|
|||||||
"viewers": {"type": "String"}
|
"viewers": {"type": "String"}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"watchFullSeries": "Watch full series · {episodes} eps",
|
"watchFullSeries": "Watch full series {episodes} eps",
|
||||||
"@watchFullSeries": {
|
"@watchFullSeries": {
|
||||||
"placeholders": {
|
"placeholders": {
|
||||||
"episodes": {"type": "String"}
|
"episodes": {"type": "String"}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"feedEpisodePrefix": "EP{episode}",
|
||||||
|
"@feedEpisodePrefix": {
|
||||||
|
"placeholders": {
|
||||||
|
"episode": {"type": "int"}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"feedWatchingCount": "{count} watching",
|
||||||
|
"@feedWatchingCount": {
|
||||||
|
"placeholders": {
|
||||||
|
"count": {"type": "String"}
|
||||||
|
}
|
||||||
|
},
|
||||||
"feedTabAnime": "Anime",
|
"feedTabAnime": "Anime",
|
||||||
"feedTabReal": "Live-action",
|
"feedTabReal": "Live-action",
|
||||||
"feedTabForYou": "For you",
|
"feedTabForYou": "For you",
|
||||||
@@ -263,8 +274,21 @@
|
|||||||
"shareFailed": "Could not open the share sheet.",
|
"shareFailed": "Could not open the share sheet.",
|
||||||
"nowPlaying": "Playing now",
|
"nowPlaying": "Playing now",
|
||||||
"pictureInPicture": "Picture in picture",
|
"pictureInPicture": "Picture in picture",
|
||||||
|
"autoEnterPip": "Auto mini player on exit",
|
||||||
"pipUnavailable": "Picture in picture is unavailable on this device",
|
"pipUnavailable": "Picture in picture is unavailable on this device",
|
||||||
"originalTag": "Original",
|
"originalTag": "Original",
|
||||||
|
"originalProduction": "Original",
|
||||||
|
"watchNowAction": "Watch Now",
|
||||||
|
"newArrivalBadge": "NEW",
|
||||||
|
"editorPick": "Editor's Pick",
|
||||||
|
"totalEpisodesShort": "{count} eps",
|
||||||
|
"@totalEpisodesShort": {
|
||||||
|
"placeholders": {
|
||||||
|
"count": {
|
||||||
|
"type": "int"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"dramaTag": "Short drama",
|
"dramaTag": "Short drama",
|
||||||
"episodeLabel": "Episode {number}",
|
"episodeLabel": "Episode {number}",
|
||||||
"@episodeLabel": {
|
"@episodeLabel": {
|
||||||
@@ -418,6 +442,7 @@
|
|||||||
"restoreDefault": "Restore default",
|
"restoreDefault": "Restore default",
|
||||||
"invalidServerAddress": "Enter a valid http(s) server address.",
|
"invalidServerAddress": "Enter a valid http(s) server address.",
|
||||||
"signOut": "Sign Out",
|
"signOut": "Sign Out",
|
||||||
|
"signOutConfirm": "Sign out of your current account?",
|
||||||
"mockUserName": "Vicky sheng",
|
"mockUserName": "Vicky sheng",
|
||||||
"mockUserId": "ID: M1CZWVYE",
|
"mockUserId": "ID: M1CZWVYE",
|
||||||
"mockNotice": "Sample data only.",
|
"mockNotice": "Sample data only.",
|
||||||
@@ -763,8 +788,14 @@
|
|||||||
"offlineDownloads": "Offline downloads",
|
"offlineDownloads": "Offline downloads",
|
||||||
"watchPreferences": "Watch preferences",
|
"watchPreferences": "Watch preferences",
|
||||||
"contactSupport": "Contact support",
|
"contactSupport": "Contact support",
|
||||||
"vipBrandName": "Netshort VIP",
|
"vipBrandName": "FruitShorts VIP",
|
||||||
"mineVipSubtitle": "Enjoy exclusive benefits",
|
"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": "Episode {episode} / {total} total",
|
||||||
"@favoriteEpisodeProgress": {
|
"@favoriteEpisodeProgress": {
|
||||||
"placeholders": {
|
"placeholders": {
|
||||||
@@ -772,6 +803,44 @@
|
|||||||
"total": { "type": "int" }
|
"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": "Watched to Episode {episode}",
|
||||||
"@watchedToEpisode": { "placeholders": { "episode": { "type": "int" } } },
|
"@watchedToEpisode": { "placeholders": { "episode": { "type": "int" } } },
|
||||||
"homeWatchAll": "Watch all",
|
"homeWatchAll": "Watch all",
|
||||||
|
|||||||
+78
-4
@@ -20,7 +20,6 @@
|
|||||||
"featured": "Unggulan",
|
"featured": "Unggulan",
|
||||||
"recommended": "Rekomendasi",
|
"recommended": "Rekomendasi",
|
||||||
"fruitShortsBrand": "FruitShorts",
|
"fruitShortsBrand": "FruitShorts",
|
||||||
"authLandingSubtitle": "Masuk untuk menyinkronkan progres, favorit, dan koin",
|
|
||||||
"comingSoon": "Segera hadir",
|
"comingSoon": "Segera hadir",
|
||||||
"authLegal": "Dengan melanjutkan, Anda menyetujui Ketentuan Layanan dan Kebijakan Privasi.",
|
"authLegal": "Dengan melanjutkan, Anda menyetujui Ketentuan Layanan dan Kebijakan Privasi.",
|
||||||
"authLegalLead": "Dengan melanjutkan, Anda menyetujui",
|
"authLegalLead": "Dengan melanjutkan, Anda menyetujui",
|
||||||
@@ -49,7 +48,24 @@
|
|||||||
"hotBadge": "Hits",
|
"hotBadge": "Hits",
|
||||||
"filterAll": "Semua",
|
"filterAll": "Semua",
|
||||||
"seriesMeta": "Serial · {episodes} eps | {viewers} menonton",
|
"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",
|
"feedTabAnime": "Anime",
|
||||||
"feedTabReal": "Live-action",
|
"feedTabReal": "Live-action",
|
||||||
"feedTabForYou": "Untukmu",
|
"feedTabForYou": "Untukmu",
|
||||||
@@ -237,8 +253,21 @@
|
|||||||
"shareFailed": "Tidak bisa membuka menu berbagi.",
|
"shareFailed": "Tidak bisa membuka menu berbagi.",
|
||||||
"nowPlaying": "Sedang diputar",
|
"nowPlaying": "Sedang diputar",
|
||||||
"pictureInPicture": "Gambar dalam gambar",
|
"pictureInPicture": "Gambar dalam gambar",
|
||||||
|
"autoEnterPip": "Mini player otomatis saat keluar",
|
||||||
"pipUnavailable": "Gambar dalam gambar tidak tersedia di perangkat ini",
|
"pipUnavailable": "Gambar dalam gambar tidak tersedia di perangkat ini",
|
||||||
"originalTag": "Original",
|
"originalTag": "Original",
|
||||||
|
"originalProduction": "Original",
|
||||||
|
"watchNowAction": "Tonton Sekarang",
|
||||||
|
"newArrivalBadge": "BARU",
|
||||||
|
"editorPick": "Pilihan Editor",
|
||||||
|
"totalEpisodesShort": "{count} eps",
|
||||||
|
"@totalEpisodesShort": {
|
||||||
|
"placeholders": {
|
||||||
|
"count": {
|
||||||
|
"type": "int"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"dramaTag": "Drama pendek",
|
"dramaTag": "Drama pendek",
|
||||||
"episodeLabel": "Episode {number}",
|
"episodeLabel": "Episode {number}",
|
||||||
"@episodeLabel": {
|
"@episodeLabel": {
|
||||||
@@ -392,6 +421,7 @@
|
|||||||
"restoreDefault": "Pulihkan default",
|
"restoreDefault": "Pulihkan default",
|
||||||
"invalidServerAddress": "Masukkan alamat server http(s) yang valid.",
|
"invalidServerAddress": "Masukkan alamat server http(s) yang valid.",
|
||||||
"signOut": "Keluar",
|
"signOut": "Keluar",
|
||||||
|
"signOutConfirm": "Keluar dari akun saat ini?",
|
||||||
"mockUserName": "Vicky sheng",
|
"mockUserName": "Vicky sheng",
|
||||||
"mockUserId": "ID: M1CZWVYE",
|
"mockUserId": "ID: M1CZWVYE",
|
||||||
"mockNotice": "Hanya data contoh.",
|
"mockNotice": "Hanya data contoh.",
|
||||||
@@ -720,8 +750,14 @@
|
|||||||
"offlineDownloads": "Unduhan offline",
|
"offlineDownloads": "Unduhan offline",
|
||||||
"watchPreferences": "Preferensi tontonan",
|
"watchPreferences": "Preferensi tontonan",
|
||||||
"contactSupport": "Hubungi dukungan",
|
"contactSupport": "Hubungi dukungan",
|
||||||
"vipBrandName": "Netshort VIP",
|
"vipBrandName": "FruitShorts VIP",
|
||||||
"mineVipSubtitle": "Nikmati manfaat eksklusif",
|
"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": "Episode {episode} / total {total}",
|
||||||
"@favoriteEpisodeProgress": {
|
"@favoriteEpisodeProgress": {
|
||||||
"placeholders": {
|
"placeholders": {
|
||||||
@@ -729,6 +765,44 @@
|
|||||||
"total": { "type": "int" }
|
"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": "Ditonton hingga Episode {episode}",
|
||||||
"@watchedToEpisode": { "placeholders": { "episode": { "type": "int" } } },
|
"@watchedToEpisode": { "placeholders": { "episode": { "type": "int" } } },
|
||||||
"homeWatchAll": "Tonton semua",
|
"homeWatchAll": "Tonton semua",
|
||||||
|
|||||||
+148
-10
@@ -220,12 +220,6 @@ abstract class AppLocalizations {
|
|||||||
/// **'FruitShorts'**
|
/// **'FruitShorts'**
|
||||||
String get fruitShortsBrand;
|
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.
|
/// No description provided for @comingSoon.
|
||||||
///
|
///
|
||||||
/// In en, this message translates to:
|
/// In en, this message translates to:
|
||||||
@@ -397,9 +391,21 @@ abstract class AppLocalizations {
|
|||||||
/// No description provided for @watchFullSeries.
|
/// No description provided for @watchFullSeries.
|
||||||
///
|
///
|
||||||
/// In en, this message translates to:
|
/// In en, this message translates to:
|
||||||
/// **'Watch full series · {episodes} eps'**
|
/// **'Watch full series {episodes} eps'**
|
||||||
String watchFullSeries(String episodes);
|
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.
|
/// No description provided for @feedTabAnime.
|
||||||
///
|
///
|
||||||
/// In en, this message translates to:
|
/// In en, this message translates to:
|
||||||
@@ -1186,6 +1192,12 @@ abstract class AppLocalizations {
|
|||||||
/// **'Picture in picture'**
|
/// **'Picture in picture'**
|
||||||
String get pictureInPicture;
|
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.
|
/// No description provided for @pipUnavailable.
|
||||||
///
|
///
|
||||||
/// In en, this message translates to:
|
/// In en, this message translates to:
|
||||||
@@ -1198,6 +1210,36 @@ abstract class AppLocalizations {
|
|||||||
/// **'Original'**
|
/// **'Original'**
|
||||||
String get originalTag;
|
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.
|
/// No description provided for @dramaTag.
|
||||||
///
|
///
|
||||||
/// In en, this message translates to:
|
/// In en, this message translates to:
|
||||||
@@ -1786,6 +1828,12 @@ abstract class AppLocalizations {
|
|||||||
/// **'Sign Out'**
|
/// **'Sign Out'**
|
||||||
String get signOut;
|
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.
|
/// No description provided for @mockUserName.
|
||||||
///
|
///
|
||||||
/// In en, this message translates to:
|
/// In en, this message translates to:
|
||||||
@@ -2083,7 +2131,7 @@ abstract class AppLocalizations {
|
|||||||
/// No description provided for @myFavorites.
|
/// No description provided for @myFavorites.
|
||||||
///
|
///
|
||||||
/// In en, this message translates to:
|
/// In en, this message translates to:
|
||||||
/// **'My favorites'**
|
/// **'My Favorites'**
|
||||||
String get myFavorites;
|
String get myFavorites;
|
||||||
|
|
||||||
/// No description provided for @noFavorites.
|
/// No description provided for @noFavorites.
|
||||||
@@ -3385,13 +3433,49 @@ abstract class AppLocalizations {
|
|||||||
/// No description provided for @vipBrandName.
|
/// No description provided for @vipBrandName.
|
||||||
///
|
///
|
||||||
/// In en, this message translates to:
|
/// In en, this message translates to:
|
||||||
/// **'Netshort VIP'**
|
/// **'FruitShorts VIP'**
|
||||||
String get vipBrandName;
|
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.
|
/// No description provided for @mineVipSubtitle.
|
||||||
///
|
///
|
||||||
/// In en, this message translates to:
|
/// In en, this message translates to:
|
||||||
/// **'Enjoy exclusive benefits'**
|
/// **'Unlock excitement, binge freely'**
|
||||||
String get mineVipSubtitle;
|
String get mineVipSubtitle;
|
||||||
|
|
||||||
/// No description provided for @favoriteEpisodeProgress.
|
/// No description provided for @favoriteEpisodeProgress.
|
||||||
@@ -3400,6 +3484,60 @@ abstract class AppLocalizations {
|
|||||||
/// **'Episode {episode} / {total} total'**
|
/// **'Episode {episode} / {total} total'**
|
||||||
String favoriteEpisodeProgress(int episode, int 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.
|
/// No description provided for @watchedToEpisode.
|
||||||
///
|
///
|
||||||
/// In en, this message translates to:
|
/// In en, this message translates to:
|
||||||
|
|||||||
@@ -69,10 +69,6 @@ class AppLocalizationsEn extends AppLocalizations {
|
|||||||
@override
|
@override
|
||||||
String get fruitShortsBrand => 'FruitShorts';
|
String get fruitShortsBrand => 'FruitShorts';
|
||||||
|
|
||||||
@override
|
|
||||||
String get authLandingSubtitle =>
|
|
||||||
'Sign in to sync progress, favorites and coins';
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get comingSoon => 'Coming soon';
|
String get comingSoon => 'Coming soon';
|
||||||
|
|
||||||
@@ -162,7 +158,17 @@ class AppLocalizationsEn extends AppLocalizations {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
String watchFullSeries(String episodes) {
|
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
|
@override
|
||||||
@@ -587,6 +593,9 @@ class AppLocalizationsEn extends AppLocalizations {
|
|||||||
@override
|
@override
|
||||||
String get pictureInPicture => 'Picture in picture';
|
String get pictureInPicture => 'Picture in picture';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get autoEnterPip => 'Auto mini player on exit';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get pipUnavailable =>
|
String get pipUnavailable =>
|
||||||
'Picture in picture is unavailable on this device';
|
'Picture in picture is unavailable on this device';
|
||||||
@@ -594,6 +603,23 @@ class AppLocalizationsEn extends AppLocalizations {
|
|||||||
@override
|
@override
|
||||||
String get originalTag => 'Original';
|
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
|
@override
|
||||||
String get dramaTag => 'Short drama';
|
String get dramaTag => 'Short drama';
|
||||||
|
|
||||||
@@ -906,6 +932,9 @@ class AppLocalizationsEn extends AppLocalizations {
|
|||||||
@override
|
@override
|
||||||
String get signOut => 'Sign Out';
|
String get signOut => 'Sign Out';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get signOutConfirm => 'Sign out of your current account?';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get mockUserName => 'Vicky sheng';
|
String get mockUserName => 'Vicky sheng';
|
||||||
|
|
||||||
@@ -1060,7 +1089,7 @@ class AppLocalizationsEn extends AppLocalizations {
|
|||||||
'Could not update favorites. Please retry.';
|
'Could not update favorites. Please retry.';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get myFavorites => 'My favorites';
|
String get myFavorites => 'My Favorites';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get noFavorites => 'No favorites yet.';
|
String get noFavorites => 'No favorites yet.';
|
||||||
@@ -1763,16 +1792,71 @@ class AppLocalizationsEn extends AppLocalizations {
|
|||||||
String get contactSupport => 'Contact support';
|
String get contactSupport => 'Contact support';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get vipBrandName => 'Netshort VIP';
|
String get vipBrandName => 'FruitShorts VIP';
|
||||||
|
|
||||||
@override
|
@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
|
@override
|
||||||
String favoriteEpisodeProgress(int episode, int total) {
|
String favoriteEpisodeProgress(int episode, int total) {
|
||||||
return 'Episode $episode / $total 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
|
@override
|
||||||
String watchedToEpisode(int episode) {
|
String watchedToEpisode(int episode) {
|
||||||
return 'Watched to Episode $episode';
|
return 'Watched to Episode $episode';
|
||||||
|
|||||||
@@ -69,10 +69,6 @@ class AppLocalizationsId extends AppLocalizations {
|
|||||||
@override
|
@override
|
||||||
String get fruitShortsBrand => 'FruitShorts';
|
String get fruitShortsBrand => 'FruitShorts';
|
||||||
|
|
||||||
@override
|
|
||||||
String get authLandingSubtitle =>
|
|
||||||
'Masuk untuk menyinkronkan progres, favorit, dan koin';
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get comingSoon => 'Segera hadir';
|
String get comingSoon => 'Segera hadir';
|
||||||
|
|
||||||
@@ -162,7 +158,17 @@ class AppLocalizationsId extends AppLocalizations {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
String watchFullSeries(String episodes) {
|
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
|
@override
|
||||||
@@ -289,7 +295,7 @@ class AppLocalizationsId extends AppLocalizations {
|
|||||||
String get localDemoProfile => 'Profil demo lokal';
|
String get localDemoProfile => 'Profil demo lokal';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get continueWatching => 'Lanjut Tonton';
|
String get continueWatching => 'Lanjutkan';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String episodeRemaining(int episode, int minutes) {
|
String episodeRemaining(int episode, int minutes) {
|
||||||
@@ -588,6 +594,9 @@ class AppLocalizationsId extends AppLocalizations {
|
|||||||
@override
|
@override
|
||||||
String get pictureInPicture => 'Gambar dalam gambar';
|
String get pictureInPicture => 'Gambar dalam gambar';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get autoEnterPip => 'Mini player otomatis saat keluar';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get pipUnavailable =>
|
String get pipUnavailable =>
|
||||||
'Gambar dalam gambar tidak tersedia di perangkat ini';
|
'Gambar dalam gambar tidak tersedia di perangkat ini';
|
||||||
@@ -595,6 +604,23 @@ class AppLocalizationsId extends AppLocalizations {
|
|||||||
@override
|
@override
|
||||||
String get originalTag => 'Original';
|
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
|
@override
|
||||||
String get dramaTag => 'Drama pendek';
|
String get dramaTag => 'Drama pendek';
|
||||||
|
|
||||||
@@ -910,6 +936,9 @@ class AppLocalizationsId extends AppLocalizations {
|
|||||||
@override
|
@override
|
||||||
String get signOut => 'Keluar';
|
String get signOut => 'Keluar';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get signOutConfirm => 'Keluar dari akun saat ini?';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get mockUserName => 'Vicky sheng';
|
String get mockUserName => 'Vicky sheng';
|
||||||
|
|
||||||
@@ -1062,7 +1091,7 @@ class AppLocalizationsId extends AppLocalizations {
|
|||||||
String get favoriteToggleFailed => 'Gagal memperbarui favorit. Coba lagi.';
|
String get favoriteToggleFailed => 'Gagal memperbarui favorit. Coba lagi.';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get myFavorites => 'Favorit saya';
|
String get myFavorites => 'Favorit Saya';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get noFavorites => 'Belum ada favorit.';
|
String get noFavorites => 'Belum ada favorit.';
|
||||||
@@ -1765,16 +1794,71 @@ class AppLocalizationsId extends AppLocalizations {
|
|||||||
String get contactSupport => 'Hubungi dukungan';
|
String get contactSupport => 'Hubungi dukungan';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get vipBrandName => 'Netshort VIP';
|
String get vipBrandName => 'FruitShorts VIP';
|
||||||
|
|
||||||
@override
|
@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
|
@override
|
||||||
String favoriteEpisodeProgress(int episode, int total) {
|
String favoriteEpisodeProgress(int episode, int total) {
|
||||||
return 'Episode $episode / total $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
|
@override
|
||||||
String watchedToEpisode(int episode) {
|
String watchedToEpisode(int episode) {
|
||||||
return 'Ditonton hingga Episode $episode';
|
return 'Ditonton hingga Episode $episode';
|
||||||
|
|||||||
@@ -66,10 +66,7 @@ class AppLocalizationsZh extends AppLocalizations {
|
|||||||
String get recommended => '推荐';
|
String get recommended => '推荐';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get fruitShortsBrand => '水果短剧';
|
String get fruitShortsBrand => 'FruitShorts';
|
||||||
|
|
||||||
@override
|
|
||||||
String get authLandingSubtitle => '登录后同步进度、收藏与金币权益';
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get comingSoon => '即将上线';
|
String get comingSoon => '即将上线';
|
||||||
@@ -159,7 +156,17 @@ class AppLocalizationsZh extends AppLocalizations {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
String watchFullSeries(String episodes) {
|
String watchFullSeries(String episodes) {
|
||||||
return '观看完整剧集 · 全$episodes集';
|
return '观看完整剧集 全$episodes集';
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
String feedEpisodePrefix(int episode) {
|
||||||
|
return '第$episode集';
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
String feedWatchingCount(String count) {
|
||||||
|
return '共$count人在看';
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -581,12 +588,32 @@ class AppLocalizationsZh extends AppLocalizations {
|
|||||||
@override
|
@override
|
||||||
String get pictureInPicture => '画中画';
|
String get pictureInPicture => '画中画';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get autoEnterPip => '退出后自动小窗';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get pipUnavailable => '此设备无法使用画中画';
|
String get pipUnavailable => '此设备无法使用画中画';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get originalTag => '原创';
|
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
|
@override
|
||||||
String get dramaTag => '短剧';
|
String get dramaTag => '短剧';
|
||||||
|
|
||||||
@@ -895,6 +922,9 @@ class AppLocalizationsZh extends AppLocalizations {
|
|||||||
@override
|
@override
|
||||||
String get signOut => '退出登录';
|
String get signOut => '退出登录';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get signOutConfirm => '确定要退出当前账号吗?';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get mockUserName => 'Vicky sheng';
|
String get mockUserName => 'Vicky sheng';
|
||||||
|
|
||||||
@@ -1737,16 +1767,71 @@ class AppLocalizationsZh extends AppLocalizations {
|
|||||||
String get contactSupport => '联系客服';
|
String get contactSupport => '联系客服';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get vipBrandName => 'Netshort VIP';
|
String get vipBrandName => 'FruitShorts VIP';
|
||||||
|
|
||||||
@override
|
@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
|
@override
|
||||||
String favoriteEpisodeProgress(int episode, int total) {
|
String favoriteEpisodeProgress(int episode, int total) {
|
||||||
return '第 $episode 集 / 共 $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
|
@override
|
||||||
String watchedToEpisode(int episode) {
|
String watchedToEpisode(int episode) {
|
||||||
return '已看至 第 $episode 集';
|
return '已看至 第 $episode 集';
|
||||||
|
|||||||
+79
-5
@@ -19,8 +19,7 @@
|
|||||||
"searchCancel": "取消",
|
"searchCancel": "取消",
|
||||||
"featured": "精选",
|
"featured": "精选",
|
||||||
"recommended": "推荐",
|
"recommended": "推荐",
|
||||||
"fruitShortsBrand": "水果短剧",
|
"fruitShortsBrand": "FruitShorts",
|
||||||
"authLandingSubtitle": "登录后同步进度、收藏与金币权益",
|
|
||||||
"comingSoon": "即将上线",
|
"comingSoon": "即将上线",
|
||||||
"authLegal": "继续即代表同意《用户协议》与《隐私政策》",
|
"authLegal": "继续即代表同意《用户协议》与《隐私政策》",
|
||||||
"authLegalLead": "继续即代表同意",
|
"authLegalLead": "继续即代表同意",
|
||||||
@@ -49,7 +48,24 @@
|
|||||||
"hotBadge": "爆剧",
|
"hotBadge": "爆剧",
|
||||||
"filterAll": "全部",
|
"filterAll": "全部",
|
||||||
"seriesMeta": "系列剧 · 共{episodes}集 | 共{viewers}人在追",
|
"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": "漫剧",
|
"feedTabAnime": "漫剧",
|
||||||
"feedTabReal": "真人剧",
|
"feedTabReal": "真人剧",
|
||||||
"feedTabForYou": "推荐",
|
"feedTabForYou": "推荐",
|
||||||
@@ -237,8 +253,21 @@
|
|||||||
"shareFailed": "无法打开系统分享面板。",
|
"shareFailed": "无法打开系统分享面板。",
|
||||||
"nowPlaying": "正在播放",
|
"nowPlaying": "正在播放",
|
||||||
"pictureInPicture": "画中画",
|
"pictureInPicture": "画中画",
|
||||||
|
"autoEnterPip": "退出后自动小窗",
|
||||||
"pipUnavailable": "此设备无法使用画中画",
|
"pipUnavailable": "此设备无法使用画中画",
|
||||||
"originalTag": "原创",
|
"originalTag": "原创",
|
||||||
|
"originalProduction": "原创出品",
|
||||||
|
"watchNowAction": "立即观看",
|
||||||
|
"newArrivalBadge": "上新",
|
||||||
|
"editorPick": "编辑精选",
|
||||||
|
"totalEpisodesShort": "全{count}集",
|
||||||
|
"@totalEpisodesShort": {
|
||||||
|
"placeholders": {
|
||||||
|
"count": {
|
||||||
|
"type": "int"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"dramaTag": "短剧",
|
"dramaTag": "短剧",
|
||||||
"episodeLabel": "第 {number} 集",
|
"episodeLabel": "第 {number} 集",
|
||||||
"@episodeLabel": {
|
"@episodeLabel": {
|
||||||
@@ -354,6 +383,7 @@
|
|||||||
"restoreDefault": "恢复默认",
|
"restoreDefault": "恢复默认",
|
||||||
"invalidServerAddress": "请输入有效的 http(s) 服务器地址。",
|
"invalidServerAddress": "请输入有效的 http(s) 服务器地址。",
|
||||||
"signOut": "退出登录",
|
"signOut": "退出登录",
|
||||||
|
"signOutConfirm": "确定要退出当前账号吗?",
|
||||||
"mockUserName": "Vicky sheng",
|
"mockUserName": "Vicky sheng",
|
||||||
"mockUserId": "ID: M1CZWVYE",
|
"mockUserId": "ID: M1CZWVYE",
|
||||||
"mockNotice": "当前是示例数据。",
|
"mockNotice": "当前是示例数据。",
|
||||||
@@ -682,8 +712,14 @@
|
|||||||
"offlineDownloads": "离线缓存",
|
"offlineDownloads": "离线缓存",
|
||||||
"watchPreferences": "观看偏好",
|
"watchPreferences": "观看偏好",
|
||||||
"contactSupport": "联系客服",
|
"contactSupport": "联系客服",
|
||||||
"vipBrandName": "Netshort VIP",
|
"vipBrandName": "FruitShorts VIP",
|
||||||
"mineVipSubtitle": "享受专属权益",
|
"vipOpenNow": "立即开通",
|
||||||
|
"vipBenefitFree": "全剧免费看",
|
||||||
|
"vipBenefitNoAds": "免广告打扰",
|
||||||
|
"vipBenefitHd": "1080P高清",
|
||||||
|
"vipBenefitFastCache": "极速缓存",
|
||||||
|
"moreServices": "更多服务",
|
||||||
|
"mineVipSubtitle": "解锁精彩,畅看好剧",
|
||||||
"favoriteEpisodeProgress": "第 {episode} 集 / 共 {total} 集",
|
"favoriteEpisodeProgress": "第 {episode} 集 / 共 {total} 集",
|
||||||
"@favoriteEpisodeProgress": {
|
"@favoriteEpisodeProgress": {
|
||||||
"placeholders": {
|
"placeholders": {
|
||||||
@@ -691,6 +727,44 @@
|
|||||||
"total": { "type": "int" }
|
"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": "已看至 第 {episode} 集",
|
||||||
"@watchedToEpisode": { "placeholders": { "episode": { "type": "int" } } },
|
"@watchedToEpisode": { "placeholders": { "episode": { "type": "int" } } },
|
||||||
"homeWatchAll": "观看全集",
|
"homeWatchAll": "观看全集",
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import '../../core/formatting/localized_date_time.dart';
|
|||||||
import '../../core/theme/app_colors.dart';
|
import '../../core/theme/app_colors.dart';
|
||||||
import '../../core/theme/app_dimens.dart';
|
import '../../core/theme/app_dimens.dart';
|
||||||
import '../../core/theme/app_theme.dart';
|
import '../../core/theme/app_theme.dart';
|
||||||
|
import '../../core/widgets/app_glow_panel.dart';
|
||||||
import '../../core/widgets/auth_gate.dart';
|
import '../../core/widgets/auth_gate.dart';
|
||||||
import '../../core/widgets/plain_page_scaffold.dart';
|
import '../../core/widgets/plain_page_scaffold.dart';
|
||||||
import '../../l10n/app_localizations.dart';
|
import '../../l10n/app_localizations.dart';
|
||||||
@@ -172,15 +173,15 @@ class _AccountDeactivatePageState extends State<AccountDeactivatePage> {
|
|||||||
final l10n = AppLocalizations.of(context)!;
|
final l10n = AppLocalizations.of(context)!;
|
||||||
final confirmed = await showDialog<bool>(
|
final confirmed = await showDialog<bool>(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (dialogContext) => AlertDialog(
|
builder: (dialogContext) => AppGlowDialog(
|
||||||
title: Text(l10n.accountConfirmDeactivateTitle),
|
title: l10n.accountConfirmDeactivateTitle,
|
||||||
content: Text(l10n.accountConfirmDeactivateMessage),
|
content: l10n.accountConfirmDeactivateMessage,
|
||||||
actions: [
|
actions: [
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () => Navigator.of(dialogContext).pop(false),
|
onPressed: () => Navigator.of(dialogContext).pop(false),
|
||||||
child: Text(l10n.cancel),
|
child: Text(l10n.cancel),
|
||||||
),
|
),
|
||||||
FilledButton(
|
TextButton(
|
||||||
key: const Key('account-deactivate-confirm'),
|
key: const Key('account-deactivate-confirm'),
|
||||||
onPressed: () => Navigator.of(dialogContext).pop(true),
|
onPressed: () => Navigator.of(dialogContext).pop(true),
|
||||||
child: Text(l10n.accountConfirmDeactivate),
|
child: Text(l10n.accountConfirmDeactivate),
|
||||||
|
|||||||
@@ -45,8 +45,7 @@ class AccountEntryCard extends StatelessWidget {
|
|||||||
];
|
];
|
||||||
return Material(
|
return Material(
|
||||||
key: const Key('mine-account-card'),
|
key: const Key('mine-account-card'),
|
||||||
color: AppColors.card,
|
color: AppColors.contentSurface,
|
||||||
borderRadius: BorderRadius.circular(AppDimens.cardRadius),
|
|
||||||
clipBehavior: Clip.antiAlias,
|
clipBehavior: Clip.antiAlias,
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
@@ -55,7 +54,7 @@ class AccountEntryCard extends StatelessWidget {
|
|||||||
const Divider(
|
const Divider(
|
||||||
height: AppDimens.mineGridDividerWidth,
|
height: AppDimens.mineGridDividerWidth,
|
||||||
thickness: AppDimens.mineGridDividerWidth,
|
thickness: AppDimens.mineGridDividerWidth,
|
||||||
color: AppColors.outlineVariantDark,
|
color: AppColors.contentBorder,
|
||||||
),
|
),
|
||||||
_AccountListTile(row: rows[index]),
|
_AccountListTile(row: rows[index]),
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import 'package:provider/provider.dart';
|
|||||||
import '../../core/data/models/account_profile.dart';
|
import '../../core/data/models/account_profile.dart';
|
||||||
import '../../core/data/repositories/account_repository.dart';
|
import '../../core/data/repositories/account_repository.dart';
|
||||||
import '../../core/data/services/auth_controller.dart';
|
import '../../core/data/services/auth_controller.dart';
|
||||||
|
import '../../core/formatting/account_display.dart';
|
||||||
import '../../core/formatting/error_text.dart';
|
import '../../core/formatting/error_text.dart';
|
||||||
import '../../core/formatting/localized_date_time.dart';
|
import '../../core/formatting/localized_date_time.dart';
|
||||||
import '../../core/theme/app_colors.dart';
|
import '../../core/theme/app_colors.dart';
|
||||||
@@ -225,6 +226,7 @@ class _AccountProfilePageState extends State<AccountProfilePage> {
|
|||||||
);
|
);
|
||||||
|
|
||||||
Widget _readOnlyCard(AccountProfile profile, AppLocalizations l10n) {
|
Widget _readOnlyCard(AccountProfile profile, AppLocalizations l10n) {
|
||||||
|
final localeName = Localizations.localeOf(context).languageCode;
|
||||||
return _AccountCard(
|
return _AccountCard(
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
@@ -238,13 +240,34 @@ class _AccountProfilePageState extends State<AccountProfilePage> {
|
|||||||
),
|
),
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
_info(l10n.accountMaskedAccount, profile.maskedTarget),
|
_info(l10n.accountMaskedAccount, profile.maskedTarget),
|
||||||
_info(l10n.accountCountry, profile.countryCode),
|
_info(
|
||||||
|
l10n.accountCountry,
|
||||||
|
countryName(profile.countryCode, localeName),
|
||||||
|
),
|
||||||
_info(l10n.accountCurrency, profile.currency),
|
_info(l10n.accountCurrency, profile.currency),
|
||||||
_info(l10n.accountStatus, profile.status),
|
_info(
|
||||||
_info(l10n.accountLanguage, profile.language),
|
l10n.accountStatus,
|
||||||
_info(l10n.accountTimezone, profile.timezone),
|
accountStatusText(profile.status, localeName),
|
||||||
_info(l10n.accountRegion, profile.regionCode),
|
),
|
||||||
_info(l10n.accountVipLevel, '${profile.vipLevel}'),
|
_info(
|
||||||
|
l10n.accountLanguage,
|
||||||
|
languageName(profile.language, localeName),
|
||||||
|
),
|
||||||
|
_info(
|
||||||
|
l10n.accountTimezone,
|
||||||
|
timezoneName(profile.timezone, localeName),
|
||||||
|
),
|
||||||
|
// region 与 country 后端写的是同一个值,重复时不再单列一行
|
||||||
|
if (profile.regionCode.isNotEmpty &&
|
||||||
|
profile.regionCode != profile.countryCode)
|
||||||
|
_info(
|
||||||
|
l10n.accountRegion,
|
||||||
|
countryName(profile.regionCode, localeName),
|
||||||
|
),
|
||||||
|
_info(
|
||||||
|
l10n.accountVipLevel,
|
||||||
|
vipLevelText(profile.vipLevel, localeName),
|
||||||
|
),
|
||||||
if (profile.createdAt != null)
|
if (profile.createdAt != null)
|
||||||
_info(
|
_info(
|
||||||
l10n.accountCreatedAt,
|
l10n.accountCreatedAt,
|
||||||
@@ -275,7 +298,7 @@ class _AccountProfilePageState extends State<AccountProfilePage> {
|
|||||||
),
|
),
|
||||||
Flexible(
|
Flexible(
|
||||||
child: Text(
|
child: Text(
|
||||||
value.isEmpty ? '-' : value,
|
value.isEmpty ? '—' : value,
|
||||||
textAlign: TextAlign.right,
|
textAlign: TextAlign.right,
|
||||||
style: const TextStyle(fontSize: AppDimens.body),
|
style: const TextStyle(fontSize: AppDimens.body),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ class _AuthFields extends StatelessWidget {
|
|||||||
onChanged: callbacks.onEmailChanged,
|
onChanged: callbacks.onEmailChanged,
|
||||||
onSubmitted: (_) => state.fields.passwordFocus.requestFocus(),
|
onSubmitted: (_) => state.fields.passwordFocus.requestFocus(),
|
||||||
style: const TextStyle(color: AppColors.onSurface, fontSize: 15),
|
style: const TextStyle(color: AppColors.onSurface, fontSize: 15),
|
||||||
cursorColor: AppColors.blue,
|
cursorColor: AppColors.brandRed,
|
||||||
decoration: _decoration(
|
decoration: _decoration(
|
||||||
context: context,
|
context: context,
|
||||||
hint: 'name@example.com',
|
hint: 'name@example.com',
|
||||||
@@ -93,7 +93,7 @@ class _AuthFields extends StatelessWidget {
|
|||||||
onChanged: callbacks.onPasswordChanged,
|
onChanged: callbacks.onPasswordChanged,
|
||||||
onSubmitted: (_) => callbacks.onSubmit(),
|
onSubmitted: (_) => callbacks.onSubmit(),
|
||||||
style: const TextStyle(color: AppColors.onSurface, fontSize: 15),
|
style: const TextStyle(color: AppColors.onSurface, fontSize: 15),
|
||||||
cursorColor: AppColors.blue,
|
cursorColor: AppColors.brandRed,
|
||||||
decoration: _decoration(
|
decoration: _decoration(
|
||||||
context: context,
|
context: context,
|
||||||
hint: l10n.authPasswordHint,
|
hint: l10n.authPasswordHint,
|
||||||
@@ -128,7 +128,7 @@ class _AuthFields extends StatelessWidget {
|
|||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
color: AppColors.muted,
|
color: AppColors.muted,
|
||||||
fontSize: 12,
|
fontSize: 12,
|
||||||
fontWeight: FontWeight.w700,
|
fontWeight: FontWeight.w400,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -142,10 +142,7 @@ class _AuthFields extends StatelessWidget {
|
|||||||
}) {
|
}) {
|
||||||
final border = OutlineInputBorder(
|
final border = OutlineInputBorder(
|
||||||
borderRadius: BorderRadius.circular(_fieldRadius),
|
borderRadius: BorderRadius.circular(_fieldRadius),
|
||||||
borderSide: const BorderSide(
|
borderSide: BorderSide.none,
|
||||||
color: AppColors.border,
|
|
||||||
width: _fieldBorderWidth,
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
final errorColor = Theme.of(context).colorScheme.error;
|
final errorColor = Theme.of(context).colorScheme.error;
|
||||||
final errorBorder = OutlineInputBorder(
|
final errorBorder = OutlineInputBorder(
|
||||||
@@ -158,7 +155,7 @@ class _AuthFields extends StatelessWidget {
|
|||||||
prefixIcon: Icon(
|
prefixIcon: Icon(
|
||||||
icon,
|
icon,
|
||||||
size: 21,
|
size: 21,
|
||||||
color: focused ? AppColors.blue : AppColors.muted,
|
color: focused ? AppColors.brandRed : AppColors.muted,
|
||||||
),
|
),
|
||||||
prefixIconConstraints: const BoxConstraints(
|
prefixIconConstraints: const BoxConstraints(
|
||||||
minWidth: _minTapTarget,
|
minWidth: _minTapTarget,
|
||||||
@@ -166,7 +163,7 @@ class _AuthFields extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
suffixIcon: suffix,
|
suffixIcon: suffix,
|
||||||
filled: true,
|
filled: true,
|
||||||
fillColor: AppColors.card,
|
fillColor: Colors.white.withValues(alpha: 0.05),
|
||||||
isDense: true,
|
isDense: true,
|
||||||
contentPadding: const EdgeInsets.only(right: 16),
|
contentPadding: const EdgeInsets.only(right: 16),
|
||||||
border: border,
|
border: border,
|
||||||
@@ -175,7 +172,7 @@ class _AuthFields extends StatelessWidget {
|
|||||||
focusedBorder: OutlineInputBorder(
|
focusedBorder: OutlineInputBorder(
|
||||||
borderRadius: BorderRadius.circular(_fieldRadius),
|
borderRadius: BorderRadius.circular(_fieldRadius),
|
||||||
borderSide: const BorderSide(
|
borderSide: const BorderSide(
|
||||||
color: AppColors.blue,
|
color: AppColors.brandRed,
|
||||||
width: _fieldBorderWidth,
|
width: _fieldBorderWidth,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -204,17 +201,17 @@ class _AuthSubmitButton extends StatelessWidget {
|
|||||||
style: ButtonStyle(
|
style: ButtonStyle(
|
||||||
backgroundColor: WidgetStateProperty.resolveWith((states) {
|
backgroundColor: WidgetStateProperty.resolveWith((states) {
|
||||||
if (states.contains(WidgetState.disabled)) {
|
if (states.contains(WidgetState.disabled)) {
|
||||||
return AppColors.blue.withValues(alpha: 0.5);
|
return AppColors.brandRed.withValues(alpha: 0.5);
|
||||||
}
|
}
|
||||||
if (states.contains(WidgetState.pressed)) {
|
if (states.contains(WidgetState.pressed)) {
|
||||||
return AppColors.bluePressed;
|
return AppColors.brandRedPressed;
|
||||||
}
|
}
|
||||||
return AppColors.blue;
|
return AppColors.brandRed;
|
||||||
}),
|
}),
|
||||||
foregroundColor: const WidgetStatePropertyAll(AppColors.onPrimary),
|
foregroundColor: const WidgetStatePropertyAll(AppColors.onPrimary),
|
||||||
elevation: const WidgetStatePropertyAll(2),
|
elevation: const WidgetStatePropertyAll(2),
|
||||||
shadowColor: WidgetStatePropertyAll(
|
shadowColor: WidgetStatePropertyAll(
|
||||||
AppColors.blue.withValues(alpha: 0.22),
|
AppColors.brandRed.withValues(alpha: 0.22),
|
||||||
),
|
),
|
||||||
padding: const WidgetStatePropertyAll(EdgeInsets.zero),
|
padding: const WidgetStatePropertyAll(EdgeInsets.zero),
|
||||||
shape: WidgetStatePropertyAll(
|
shape: WidgetStatePropertyAll(
|
||||||
@@ -235,7 +232,7 @@ class _AuthSubmitButton extends StatelessWidget {
|
|||||||
status.signUpMode ? l10n.signUp : l10n.signIn,
|
status.signUpMode ? l10n.signUp : l10n.signIn,
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
fontSize: 15,
|
fontSize: 15,
|
||||||
fontWeight: FontWeight.w800,
|
fontWeight: FontWeight.w600,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -243,18 +240,16 @@ class _AuthSubmitButton extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class _ModeSegment extends StatelessWidget {
|
class _ModeTab extends StatelessWidget {
|
||||||
const _ModeSegment({
|
const _ModeTab({
|
||||||
required this.segmentKey,
|
required this.segmentKey,
|
||||||
required this.label,
|
required this.label,
|
||||||
required this.hiddenLabel,
|
|
||||||
required this.selected,
|
required this.selected,
|
||||||
required this.onTap,
|
required this.onTap,
|
||||||
});
|
});
|
||||||
|
|
||||||
final Key segmentKey;
|
final Key segmentKey;
|
||||||
final String label;
|
final String label;
|
||||||
final String hiddenLabel;
|
|
||||||
final bool selected;
|
final bool selected;
|
||||||
final VoidCallback? onTap;
|
final VoidCallback? onTap;
|
||||||
|
|
||||||
@@ -264,43 +259,30 @@ class _ModeSegment extends StatelessWidget {
|
|||||||
key: segmentKey,
|
key: segmentKey,
|
||||||
behavior: HitTestBehavior.opaque,
|
behavior: HitTestBehavior.opaque,
|
||||||
onTap: onTap,
|
onTap: onTap,
|
||||||
child: AnimatedContainer(
|
child: Column(
|
||||||
duration: _segmentDuration,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
alignment: Alignment.center,
|
mainAxisSize: MainAxisSize.min,
|
||||||
decoration: BoxDecoration(
|
children: [
|
||||||
color: selected ? AppColors.blue : AppColors.transparent,
|
Text(
|
||||||
borderRadius: BorderRadius.circular(18),
|
label,
|
||||||
),
|
style: TextStyle(
|
||||||
child: Stack(
|
color: selected ? AppColors.textPrimary : AppColors.muted,
|
||||||
fit: StackFit.expand,
|
fontSize: AppDimens.followingSegmentFont,
|
||||||
children: [
|
fontWeight: FontWeight.w400,
|
||||||
Center(
|
),
|
||||||
child: Text(
|
),
|
||||||
label,
|
const SizedBox(height: AppDimens.followingSegmentIndicatorTopGap),
|
||||||
style: TextStyle(
|
Container(
|
||||||
color: selected ? AppColors.onPrimary : AppColors.onSurface,
|
width: AppDimens.followingSegmentIndicatorWidth,
|
||||||
fontSize: 14,
|
height: AppDimens.followingSegmentIndicatorHeight,
|
||||||
fontWeight: FontWeight.w700,
|
decoration: BoxDecoration(
|
||||||
),
|
color: selected ? AppColors.brandRed : AppColors.transparent,
|
||||||
|
borderRadius: BorderRadius.circular(
|
||||||
|
AppDimens.followingSegmentIndicatorRadius,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Positioned.fill(
|
),
|
||||||
child: ExcludeSemantics(
|
],
|
||||||
child: Opacity(
|
|
||||||
opacity: 0,
|
|
||||||
child: Center(
|
|
||||||
child: Text(
|
|
||||||
hiddenLabel,
|
|
||||||
maxLines: 1,
|
|
||||||
softWrap: false,
|
|
||||||
style: const TextStyle(fontSize: 14),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -349,7 +331,7 @@ class _AuthBrand extends StatelessWidget {
|
|||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
color: AppColors.onSurface,
|
color: AppColors.onSurface,
|
||||||
fontSize: 24,
|
fontSize: 24,
|
||||||
fontWeight: FontWeight.w900,
|
fontWeight: FontWeight.w700,
|
||||||
height: 1.1,
|
height: 1.1,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ class _AuthLegalLinksState extends State<AuthLegalLinks> {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final l10n = AppLocalizations.of(context)!;
|
final l10n = AppLocalizations.of(context)!;
|
||||||
final muted = TextStyle(color: AppColors.muted, fontSize: _legalFontSize, height: 1.6);
|
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(
|
return Text.rich(
|
||||||
TextSpan(
|
TextSpan(
|
||||||
style: muted,
|
style: muted,
|
||||||
|
|||||||
@@ -24,18 +24,14 @@ part 'auth_widgets.dart';
|
|||||||
part 'auth_form_widgets.dart';
|
part 'auth_form_widgets.dart';
|
||||||
|
|
||||||
const double _minTapTarget = 44;
|
const double _minTapTarget = 44;
|
||||||
const double _brandMarkSize = 72;
|
const double _brandMarkSize = 88;
|
||||||
const double _compactBrandMarkSize = 48;
|
const double _compactBrandMarkSize = 48;
|
||||||
const double _brandMarkRadius = 20;
|
const double _brandMarkRadius = 26;
|
||||||
const double _compactBrandMarkRadius = 14;
|
const double _compactBrandMarkRadius = 14;
|
||||||
const double _landingLogoTopGap = 28;
|
|
||||||
const String _appLogoAsset = 'assets/icon/fruitshorts.png';
|
const String _appLogoAsset = 'assets/icon/fruitshorts.png';
|
||||||
const double _contentMaxWidth = 440;
|
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 _fieldHeight = 52;
|
||||||
const double _fieldRadius = 14;
|
const double _fieldRadius = 12;
|
||||||
const double _fieldBorderWidth = 1;
|
const double _fieldBorderWidth = 1;
|
||||||
const double _buttonHeight = 50;
|
const double _buttonHeight = 50;
|
||||||
const double _buttonRadius = 25;
|
const double _buttonRadius = 25;
|
||||||
@@ -47,14 +43,11 @@ const double _bottomContentPadding = 28;
|
|||||||
const double _compactTopContentPadding = 40;
|
const double _compactTopContentPadding = 40;
|
||||||
const double _compactHeightBreakpoint = 720;
|
const double _compactHeightBreakpoint = 720;
|
||||||
const double _compactBrandGap = 16;
|
const double _compactBrandGap = 16;
|
||||||
const double _glowSize = 280;
|
const double _entryButtonHeight = 52;
|
||||||
const double _warmGlowOpacity = 0.18;
|
const double _entryButtonRadius = 26;
|
||||||
const double _entryButtonHeight = 50;
|
|
||||||
const double _entryButtonRadius = 25;
|
|
||||||
const double _entryButtonFontSize = 15;
|
const double _entryButtonFontSize = 15;
|
||||||
const double _entryIconSize = 20;
|
const double _entryIconSize = 20;
|
||||||
const Duration _enterDuration = Duration(milliseconds: 220);
|
const Duration _enterDuration = Duration(milliseconds: 220);
|
||||||
const Duration _segmentDuration = Duration(milliseconds: 160);
|
|
||||||
|
|
||||||
Widget _brandMarkWidget({
|
Widget _brandMarkWidget({
|
||||||
Key? key,
|
Key? key,
|
||||||
@@ -267,45 +260,53 @@ class _AuthPageState extends State<AuthPage> {
|
|||||||
child: IgnorePointer(
|
child: IgnorePointer(
|
||||||
child: DecoratedBox(
|
child: DecoratedBox(
|
||||||
key: Key('auth-page-background'),
|
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(
|
decoration: BoxDecoration(
|
||||||
shape: BoxShape.circle,
|
gradient: LinearGradient(
|
||||||
gradient: RadialGradient(
|
begin: Alignment.topCenter,
|
||||||
|
end: Alignment.bottomCenter,
|
||||||
colors: [
|
colors: [
|
||||||
AppColors.surfaceTop,
|
AppColors.followingGlow,
|
||||||
AppColors.surfaceTop.withValues(alpha: 0),
|
AppColors.followingGlowMid,
|
||||||
|
AppColors.appBackground,
|
||||||
],
|
],
|
||||||
|
stops: [0, 0.14, 0.3],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Positioned(
|
// 全屏海报背景:压暗保证文字可读,顶部再叠品牌红光。
|
||||||
left: -110,
|
Positioned.fill(
|
||||||
bottom: -90,
|
child: IgnorePointer(child: _AuthPosterBackdrop()),
|
||||||
width: _glowSize,
|
),
|
||||||
height: _glowSize,
|
const Positioned.fill(
|
||||||
child: IgnorePointer(
|
child: IgnorePointer(
|
||||||
child: Container(
|
child: DecoratedBox(
|
||||||
key: const Key('auth-background-warm-glow'),
|
key: Key('auth-poster-scrim'),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
shape: BoxShape.circle,
|
gradient: LinearGradient(
|
||||||
gradient: RadialGradient(
|
begin: Alignment.topCenter,
|
||||||
|
end: Alignment.bottomCenter,
|
||||||
colors: [
|
colors: [
|
||||||
AppColors.gold.withValues(alpha: _warmGlowOpacity),
|
Color(0x66000000),
|
||||||
AppColors.gold.withValues(alpha: 0),
|
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(
|
constraints: const BoxConstraints(
|
||||||
maxWidth: _contentMaxWidth,
|
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>(
|
TweenAnimationBuilder<double>(
|
||||||
key: const Key('auth-enter-animation'),
|
key: const Key('auth-enter-animation'),
|
||||||
tween: Tween(begin: 0, end: 1),
|
tween: Tween(begin: 0, end: 1),
|
||||||
@@ -409,15 +418,18 @@ class _AuthPageState extends State<AuthPage> {
|
|||||||
_authCard(l10n),
|
_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'),
|
key: const Key('auth-landing'),
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
children: [
|
children: [
|
||||||
const SizedBox(height: _landingLogoTopGap),
|
const Spacer(flex: 5),
|
||||||
Center(
|
Center(
|
||||||
child: _brandMarkWidget(
|
child: _brandMarkWidget(
|
||||||
key: const Key('auth-brand-logo'),
|
key: const Key('auth-brand-logo'),
|
||||||
@@ -425,24 +437,19 @@ class _AuthPageState extends State<AuthPage> {
|
|||||||
radius: _brandMarkRadius,
|
radius: _brandMarkRadius,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 10),
|
||||||
Text(
|
Text(
|
||||||
l10n.fruitShortsBrand,
|
l10n.fruitShortsBrand,
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
fontFamily: 'Outfit',
|
fontFamily: 'Outfit',
|
||||||
color: AppColors.onSurface,
|
color: AppColors.onSurface,
|
||||||
fontSize: 24,
|
fontSize: 26,
|
||||||
fontWeight: FontWeight.w900,
|
fontWeight: FontWeight.w700,
|
||||||
|
letterSpacing: 2,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 6),
|
const Spacer(flex: 3),
|
||||||
Text(
|
|
||||||
l10n.authLandingSubtitle,
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
style: const TextStyle(color: AppColors.muted, fontSize: 13),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 28),
|
|
||||||
_AuthEntryButton(
|
_AuthEntryButton(
|
||||||
key: const Key('auth-entry-phone'),
|
key: const Key('auth-entry-phone'),
|
||||||
label: l10n.authPhoneSignIn,
|
label: l10n.authPhoneSignIn,
|
||||||
@@ -458,10 +465,12 @@ class _AuthPageState extends State<AuthPage> {
|
|||||||
primary: false,
|
primary: false,
|
||||||
onTap: () => setState(() => _emailEntryOpen = true),
|
onTap: () => setState(() => _emailEntryOpen = true),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 18),
|
const SizedBox(height: 14),
|
||||||
const AuthLegalLinks(),
|
const Opacity(opacity: 0.75, child: AuthLegalLinks()),
|
||||||
],
|
const Spacer(flex: 6),
|
||||||
);
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
Future<void> _openPhoneSheet() async {
|
Future<void> _openPhoneSheet() async {
|
||||||
final signedIn = await showPhoneAuthSheet(
|
final signedIn = await showPhoneAuthSheet(
|
||||||
@@ -526,15 +535,15 @@ class _AuthEntryButton extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
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;
|
final foreground = primary ? AppColors.onPrimary : AppColors.onSurface;
|
||||||
return Material(
|
return Material(
|
||||||
color: background,
|
color: background,
|
||||||
shape: RoundedRectangleBorder(
|
shape: RoundedRectangleBorder(
|
||||||
borderRadius: BorderRadius.circular(_entryButtonRadius),
|
borderRadius: BorderRadius.circular(_entryButtonRadius),
|
||||||
side: primary
|
|
||||||
? BorderSide.none
|
|
||||||
: const BorderSide(color: AppColors.border),
|
|
||||||
),
|
),
|
||||||
clipBehavior: Clip.antiAlias,
|
clipBehavior: Clip.antiAlias,
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
@@ -556,7 +565,7 @@ class _AuthEntryButton extends StatelessWidget {
|
|||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: foreground,
|
color: foreground,
|
||||||
fontSize: _entryButtonFontSize,
|
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,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -70,52 +70,45 @@ class _AuthCard extends StatelessWidget {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final l10n = state.l10n;
|
final l10n = state.l10n;
|
||||||
final status = state.status;
|
final status = state.status;
|
||||||
return Container(
|
// 不再做卡片盒子,表单直接排在红光晕背景上。
|
||||||
|
return Column(
|
||||||
key: const Key('auth-card'),
|
key: const Key('auth-card'),
|
||||||
padding: const EdgeInsets.all(_cardPadding),
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
decoration: BoxDecoration(
|
children: [
|
||||||
color: AppColors.card,
|
_AuthModeSwitch(
|
||||||
borderRadius: BorderRadius.circular(_cardRadius),
|
l10n: l10n,
|
||||||
border: Border.all(color: AppColors.border),
|
signUpMode: status.signUpMode,
|
||||||
),
|
busy: status.busy,
|
||||||
child: Column(
|
onSelected: callbacks.onModeSelected,
|
||||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
),
|
||||||
children: [
|
const SizedBox(height: 24),
|
||||||
_AuthModeSwitch(
|
Text(
|
||||||
l10n: l10n,
|
status.signUpMode ? l10n.authSignUpTitle : l10n.authSignInTitle,
|
||||||
signUpMode: status.signUpMode,
|
style: const TextStyle(
|
||||||
busy: status.busy,
|
color: AppColors.onSurface,
|
||||||
onSelected: callbacks.onModeSelected,
|
fontSize: 24,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
height: 1.2,
|
||||||
),
|
),
|
||||||
const SizedBox(height: 22),
|
),
|
||||||
Text(
|
const SizedBox(height: 6),
|
||||||
status.signUpMode ? l10n.authSignUpTitle : l10n.authSignInTitle,
|
Text(
|
||||||
style: const TextStyle(
|
status.signUpMode ? l10n.authSignUpSubtitle : l10n.authSubtitle,
|
||||||
color: AppColors.onSurface,
|
style: const TextStyle(
|
||||||
fontSize: 25,
|
color: AppColors.muted,
|
||||||
fontWeight: FontWeight.w800,
|
fontSize: AppDimens.body,
|
||||||
height: 1.2,
|
height: 1.45,
|
||||||
),
|
|
||||||
),
|
),
|
||||||
const SizedBox(height: 6),
|
),
|
||||||
Text(
|
const SizedBox(height: 20),
|
||||||
status.signUpMode ? l10n.authSignUpSubtitle : l10n.authSubtitle,
|
_AuthFields(state: state, callbacks: callbacks),
|
||||||
style: const TextStyle(
|
if (status.errorMessage != null) ...[
|
||||||
color: AppColors.muted,
|
const SizedBox(height: 14),
|
||||||
fontSize: AppDimens.body,
|
_AuthError(message: status.errorMessage!),
|
||||||
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: 22),
|
||||||
|
_AuthSubmitButton(state: state, onSubmit: callbacks.onSubmit),
|
||||||
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -135,47 +128,23 @@ class _AuthModeSwitch extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return TextButton(
|
return Row(
|
||||||
key: const Key('auth-switch-mode'),
|
key: const Key('auth-switch-mode'),
|
||||||
onPressed: busy ? null : () => onSelected(!signUpMode),
|
children: [
|
||||||
style: TextButton.styleFrom(
|
_ModeTab(
|
||||||
minimumSize: const Size(0, _minTapTarget),
|
segmentKey: const Key('auth-mode-sign-in'),
|
||||||
padding: EdgeInsets.zero,
|
label: l10n.signIn,
|
||||||
overlayColor: AppColors.transparent,
|
selected: !signUpMode,
|
||||||
splashFactory: NoSplash.splashFactory,
|
onTap: busy ? null : () => onSelected(false),
|
||||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(22)),
|
|
||||||
),
|
|
||||||
child: Container(
|
|
||||||
height: 36,
|
|
||||||
padding: const EdgeInsets.all(2),
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: AppColors.raised,
|
|
||||||
borderRadius: BorderRadius.circular(18),
|
|
||||||
),
|
),
|
||||||
child: Row(
|
const SizedBox(width: AppDimens.followingSegmentGap),
|
||||||
children: [
|
_ModeTab(
|
||||||
Expanded(
|
segmentKey: const Key('auth-mode-sign-up'),
|
||||||
child: _ModeSegment(
|
label: l10n.signUp,
|
||||||
segmentKey: const Key('auth-mode-sign-in'),
|
selected: signUpMode,
|
||||||
label: l10n.signIn,
|
onTap: busy ? null : () => onSelected(true),
|
||||||
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),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -8,10 +8,10 @@ import 'package:provider/provider.dart';
|
|||||||
|
|
||||||
import '../../core/data/remote/api_client.dart';
|
import '../../core/data/remote/api_client.dart';
|
||||||
import '../../core/data/services/auth_controller.dart';
|
import '../../core/data/services/auth_controller.dart';
|
||||||
import '../../core/formatting/error_text.dart';
|
|
||||||
import '../../core/platform/haptics.dart';
|
import '../../core/platform/haptics.dart';
|
||||||
import '../../core/platform/keyboard_inset.dart';
|
import '../../core/platform/keyboard_inset.dart';
|
||||||
import '../../core/theme/app_colors.dart';
|
import '../../core/theme/app_colors.dart';
|
||||||
|
import '../../core/widgets/app_glow_panel.dart';
|
||||||
import '../../core/widgets/centered_toast.dart';
|
import '../../core/widgets/centered_toast.dart';
|
||||||
import '../../l10n/app_localizations.dart';
|
import '../../l10n/app_localizations.dart';
|
||||||
|
|
||||||
@@ -253,15 +253,15 @@ class _PhoneAuthSheetState extends State<PhoneAuthSheet> {
|
|||||||
final bottom = effectiveKeyboardInset(context, _keyboardInset);
|
final bottom = effectiveKeyboardInset(context, _keyboardInset);
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: EdgeInsets.only(bottom: bottom),
|
padding: EdgeInsets.only(bottom: bottom),
|
||||||
child: Container(
|
child: AppGlowPanel(
|
||||||
key: const Key('phone-auth-sheet'),
|
borderRadius: const BorderRadius.vertical(
|
||||||
decoration: const BoxDecoration(
|
top: Radius.circular(_sheetRadius),
|
||||||
color: AppColors.card,
|
|
||||||
borderRadius: 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,
|
controller: _scrollController,
|
||||||
padding: const EdgeInsets.fromLTRB(22, 10, 22, 26),
|
padding: const EdgeInsets.fromLTRB(22, 10, 22, 26),
|
||||||
child: Column(
|
child: Column(
|
||||||
@@ -314,6 +314,7 @@ class _PhoneAuthSheetState extends State<PhoneAuthSheet> {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -404,7 +405,7 @@ class _PhoneAuthSheetState extends State<PhoneAuthSheet> {
|
|||||||
key: const Key('auth-phone-submit'),
|
key: const Key('auth-phone-submit'),
|
||||||
onPressed: _submitting ? null : _submit,
|
onPressed: _submitting ? null : _submit,
|
||||||
style: FilledButton.styleFrom(
|
style: FilledButton.styleFrom(
|
||||||
backgroundColor: AppColors.blue,
|
backgroundColor: AppColors.brandRed,
|
||||||
foregroundColor: AppColors.onPrimary,
|
foregroundColor: AppColors.onPrimary,
|
||||||
shape: RoundedRectangleBorder(
|
shape: RoundedRectangleBorder(
|
||||||
borderRadius: BorderRadius.circular(_buttonHeight / 2),
|
borderRadius: BorderRadius.circular(_buttonHeight / 2),
|
||||||
@@ -440,7 +441,7 @@ class _PhoneAuthSheetState extends State<PhoneAuthSheet> {
|
|||||||
),
|
),
|
||||||
focusedBorder: OutlineInputBorder(
|
focusedBorder: OutlineInputBorder(
|
||||||
borderRadius: BorderRadius.circular(_fieldRadius),
|
borderRadius: BorderRadius.circular(_fieldRadius),
|
||||||
borderSide: const BorderSide(color: AppColors.blue, width: 1.5),
|
borderSide: const BorderSide(color: AppColors.brandRed, width: 1.5),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -139,7 +139,7 @@ class _SearchPageState extends State<SearchPage> {
|
|||||||
color: AppColors.textSecondary,
|
color: AppColors.textSecondary,
|
||||||
size: 18,
|
size: 18,
|
||||||
),
|
),
|
||||||
const SizedBox(width: AppDimens.spaceSm),
|
const SizedBox(width: 2),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: TextField(
|
child: TextField(
|
||||||
key: const Key('discover-search'),
|
key: const Key('discover-search'),
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import '../../core/platform/haptics.dart';
|
|||||||
import '../../core/theme/app_colors.dart';
|
import '../../core/theme/app_colors.dart';
|
||||||
import '../../core/theme/app_dimens.dart';
|
import '../../core/theme/app_dimens.dart';
|
||||||
import '../../core/theme/app_theme.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/app_pull_to_refresh.dart';
|
||||||
import '../../core/widgets/auth_gate.dart';
|
import '../../core/widgets/auth_gate.dart';
|
||||||
import '../../core/widgets/empty_state.dart';
|
import '../../core/widgets/empty_state.dart';
|
||||||
@@ -181,15 +182,15 @@ class _DownloadsBody extends StatelessWidget {
|
|||||||
final l10n = AppLocalizations.of(context)!;
|
final l10n = AppLocalizations.of(context)!;
|
||||||
final confirmed = await showDialog<bool>(
|
final confirmed = await showDialog<bool>(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (dialogContext) => AlertDialog(
|
builder: (dialogContext) => AppGlowDialog(
|
||||||
title: Text(l10n.clearDownloadsTitle),
|
title: l10n.clearDownloadsTitle,
|
||||||
content: Text(l10n.clearDownloadsMessage),
|
content: l10n.clearDownloadsMessage,
|
||||||
actions: [
|
actions: [
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () => Navigator.of(dialogContext).pop(false),
|
onPressed: () => Navigator.of(dialogContext).pop(false),
|
||||||
child: Text(l10n.cancel),
|
child: Text(l10n.cancel),
|
||||||
),
|
),
|
||||||
FilledButton(
|
TextButton(
|
||||||
onPressed: () => Navigator.of(dialogContext).pop(true),
|
onPressed: () => Navigator.of(dialogContext).pop(true),
|
||||||
child: Text(l10n.confirmClear),
|
child: Text(l10n.confirmClear),
|
||||||
),
|
),
|
||||||
@@ -435,7 +436,7 @@ class _LicenseTile extends StatelessWidget {
|
|||||||
minHeight: AppDimens.progressHeight,
|
minHeight: AppDimens.progressHeight,
|
||||||
value: progress.clamp(0.0, 1.0),
|
value: progress.clamp(0.0, 1.0),
|
||||||
backgroundColor: AppColors.border,
|
backgroundColor: AppColors.border,
|
||||||
valueColor: const AlwaysStoppedAnimation(AppColors.blueSoft),
|
valueColor: const AlwaysStoppedAnimation(AppColors.brandRed),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (license.expireAt != null) ...[
|
if (license.expireAt != null) ...[
|
||||||
|
|||||||
@@ -38,7 +38,6 @@ class DramaDetailLogic extends ChangeNotifier {
|
|||||||
int? continueIndex;
|
int? continueIndex;
|
||||||
WatchProgress? progress;
|
WatchProgress? progress;
|
||||||
String? progressError;
|
String? progressError;
|
||||||
int _favoriteCountDelta = 0;
|
|
||||||
bool _disposed = false;
|
bool _disposed = false;
|
||||||
|
|
||||||
void notify() {
|
void notify() {
|
||||||
@@ -47,6 +46,7 @@ class DramaDetailLogic extends ChangeNotifier {
|
|||||||
|
|
||||||
/// 列表卡片只带一集可播预览,进详情时补一次完整剧集列表。
|
/// 列表卡片只带一集可播预览,进详情时补一次完整剧集列表。
|
||||||
Future<void> load(Future<Drama> Function() fetch) async {
|
Future<void> load(Future<Drama> Function() fetch) async {
|
||||||
|
favorites.applyServerCount(drama.id, drama.favoriteCount, notify: false);
|
||||||
if (drama.detailLoaded) {
|
if (drama.detailLoaded) {
|
||||||
await loadContinue();
|
await loadContinue();
|
||||||
return;
|
return;
|
||||||
@@ -57,6 +57,7 @@ class DramaDetailLogic extends ChangeNotifier {
|
|||||||
notify();
|
notify();
|
||||||
try {
|
try {
|
||||||
drama = await fetch();
|
drama = await fetch();
|
||||||
|
favorites.applyServerCount(drama.id, drama.favoriteCount);
|
||||||
await loadContinue();
|
await loadContinue();
|
||||||
} on ApiException catch (exception) {
|
} on ApiException catch (exception) {
|
||||||
failed = true;
|
failed = true;
|
||||||
@@ -139,25 +140,12 @@ class DramaDetailLogic extends ChangeNotifier {
|
|||||||
await loadContinue();
|
await loadContinue();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 详情页展示用的收藏数;没有服务端计数时继续保持缺省展示。
|
/// 详情页展示用的收藏数,统一从全局 FavoriteController 读取。
|
||||||
int? get adjustedFavoriteCount {
|
int? get adjustedFavoriteCount => favorites.favoriteCountFor(drama);
|
||||||
final base = drama.favoriteCount;
|
|
||||||
if (base == null) return null;
|
|
||||||
final adjusted = base + _favoriteCountDelta;
|
|
||||||
return adjusted < 0 ? 0 : adjusted;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 收藏切换:乐观状态由控制器负责回滚,这里只在成功后同步计数。
|
/// 收藏切换:状态与计数均由全局控制器维护。
|
||||||
Future<bool> toggleFavorite() async {
|
Future<bool> toggleFavorite() async {
|
||||||
final wasSaved = favorites.isSaved(drama.id);
|
return favorites.toggle(drama.id, card: drama);
|
||||||
final ok = await favorites.toggle(drama.id, card: drama);
|
|
||||||
if (!ok) return false;
|
|
||||||
final nowSaved = favorites.isSaved(drama.id);
|
|
||||||
if (nowSaved != wasSaved) {
|
|
||||||
_favoriteCountDelta += nowSaved ? 1 : -1;
|
|
||||||
notify();
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|||||||
@@ -164,7 +164,9 @@ class _DramaDetailPageState extends State<DramaDetailPage> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (_tagValues(context, drama).isNotEmpty)
|
if (_tagValues(context, drama).isNotEmpty)
|
||||||
SliverToBoxAdapter(child: DramaTags(tags: _tagValues(context, drama))),
|
SliverToBoxAdapter(
|
||||||
|
child: DramaTags(tags: _tagValues(context, drama)),
|
||||||
|
),
|
||||||
SliverToBoxAdapter(child: _episodes(l10n, drama, continueIndex)),
|
SliverToBoxAdapter(child: _episodes(l10n, drama, continueIndex)),
|
||||||
const SliverToBoxAdapter(child: SizedBox(height: 24)),
|
const SliverToBoxAdapter(child: SizedBox(height: 24)),
|
||||||
],
|
],
|
||||||
@@ -396,11 +398,14 @@ class _DramaDetailPageState extends State<DramaDetailPage> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _toggleFavorite(AppLocalizations l10n) async {
|
Future<void> _toggleFavorite(AppLocalizations l10n) async {
|
||||||
if (!await ensureSignedIn(context)) return;
|
|
||||||
if (!mounted) return;
|
if (!mounted) return;
|
||||||
unawaited(context.read<Haptics>().lightImpact());
|
unawaited(context.read<Haptics>().lightImpact());
|
||||||
final ok = await logic.toggleFavorite();
|
final ok = await logic.toggleFavorite();
|
||||||
if (ok || !mounted) return;
|
if (ok || !mounted) return;
|
||||||
|
if (logic.favorites.lastErrorCode == 200007) {
|
||||||
|
await ensureSignedIn(context);
|
||||||
|
return;
|
||||||
|
}
|
||||||
ScaffoldMessenger.of(
|
ScaffoldMessenger.of(
|
||||||
context,
|
context,
|
||||||
).showSnackBar(SnackBar(content: Text(l10n.favoriteToggleFailed)));
|
).showSnackBar(SnackBar(content: Text(l10n.favoriteToggleFailed)));
|
||||||
@@ -443,7 +448,9 @@ class _DramaDetailPageState extends State<DramaDetailPage> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
List<String> _tagValues(BuildContext context, Drama drama) {
|
List<String> _tagValues(BuildContext context, Drama drama) {
|
||||||
final localized = drama.localizedTypeLabels(Localizations.localeOf(context).languageCode);
|
final localized = drama.localizedTypeLabels(
|
||||||
|
Localizations.localeOf(context).languageCode,
|
||||||
|
);
|
||||||
final result = <String>[];
|
final result = <String>[];
|
||||||
if (localized.isNotEmpty) {
|
if (localized.isNotEmpty) {
|
||||||
result.addAll(localized.take(_maxTags));
|
result.addAll(localized.take(_maxTags));
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ class DramaResumeBar extends StatelessWidget {
|
|||||||
value: fraction,
|
value: fraction,
|
||||||
minHeight: 3,
|
minHeight: 3,
|
||||||
backgroundColor: AppColors.border,
|
backgroundColor: AppColors.border,
|
||||||
valueColor: const AlwaysStoppedAnimation(AppColors.blue),
|
valueColor: const AlwaysStoppedAnimation(AppColors.brandRed),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (label != null) ...[
|
if (label != null) ...[
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import 'package:flutter/material.dart';
|
|||||||
import '../../../core/data/models/drama.dart';
|
import '../../../core/data/models/drama.dart';
|
||||||
import '../../../core/formatting/localized_content.dart';
|
import '../../../core/formatting/localized_content.dart';
|
||||||
import '../../../core/theme/app_colors.dart';
|
import '../../../core/theme/app_colors.dart';
|
||||||
import '../../../core/theme/app_theme.dart';
|
|
||||||
import '../../../core/widgets/remote_image.dart';
|
import '../../../core/widgets/remote_image.dart';
|
||||||
import '../../../core/widgets/subpage_header.dart';
|
import '../../../core/widgets/subpage_header.dart';
|
||||||
import '../../../l10n/app_localizations.dart';
|
import '../../../l10n/app_localizations.dart';
|
||||||
@@ -54,7 +53,18 @@ class DramaDetailHeader extends StatelessWidget {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Container(
|
return Container(
|
||||||
key: const Key('detail-hero'),
|
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(
|
child: SafeArea(
|
||||||
bottom: false,
|
bottom: false,
|
||||||
child: Padding(
|
child: Padding(
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ class _DramaEpisodesLoadingState extends State<DramaEpisodesLoading>
|
|||||||
opacity: _opacity,
|
opacity: _opacity,
|
||||||
child: Container(
|
child: Container(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: AppColors.raised,
|
color: AppColors.skeletonMedia,
|
||||||
borderRadius: BorderRadius.circular(_radius),
|
borderRadius: BorderRadius.circular(_radius),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
import '../../core/data/models/drama.dart';
|
import '../../core/data/models/drama.dart';
|
||||||
import '../../core/data/services/auth_controller.dart';
|
|
||||||
import '../../core/data/services/favorite_controller.dart';
|
import '../../core/data/services/favorite_controller.dart';
|
||||||
import '../../core/formatting/count_format.dart';
|
import '../../core/formatting/count_format.dart';
|
||||||
import '../../core/formatting/error_text.dart';
|
import '../../core/formatting/error_text.dart';
|
||||||
@@ -77,11 +76,6 @@ class _FavoritesContentState extends State<FavoritesContent> {
|
|||||||
@override
|
@override
|
||||||
void didChangeDependencies() {
|
void didChangeDependencies() {
|
||||||
super.didChangeDependencies();
|
super.didChangeDependencies();
|
||||||
final signedIn = context.watch<AuthController>().isSignedIn;
|
|
||||||
if (!signedIn) {
|
|
||||||
_requested = false;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (_requested) return;
|
if (_requested) return;
|
||||||
_requested = true;
|
_requested = true;
|
||||||
final favorites = context.read<FavoriteController>();
|
final favorites = context.read<FavoriteController>();
|
||||||
@@ -93,7 +87,6 @@ class _FavoritesContentState extends State<FavoritesContent> {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final l10n = AppLocalizations.of(context)!;
|
final l10n = AppLocalizations.of(context)!;
|
||||||
final signedIn = context.watch<AuthController>().isSignedIn;
|
|
||||||
return SafeArea(
|
return SafeArea(
|
||||||
bottom: false,
|
bottom: false,
|
||||||
child: Column(
|
child: Column(
|
||||||
@@ -104,9 +97,9 @@ class _FavoritesContentState extends State<FavoritesContent> {
|
|||||||
showBack: widget.showBack,
|
showBack: widget.showBack,
|
||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: signedIn
|
child: _FavoritesBody(
|
||||||
? _FavoritesBody(favorites: context.watch<FavoriteController>())
|
favorites: context.watch<FavoriteController>(),
|
||||||
: const AuthGatePanel(),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@@ -122,6 +115,9 @@ class _FavoritesBody extends StatelessWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final l10n = AppLocalizations.of(context)!;
|
final l10n = AppLocalizations.of(context)!;
|
||||||
|
if (favorites.lastErrorCode == 200007) {
|
||||||
|
return const AuthGatePanel();
|
||||||
|
}
|
||||||
if (favorites.loading && favorites.cards.isEmpty) {
|
if (favorites.loading && favorites.cards.isEmpty) {
|
||||||
return const Center(
|
return const Center(
|
||||||
child: CircularProgressIndicator(key: Key('favorites-loading')),
|
child: CircularProgressIndicator(key: Key('favorites-loading')),
|
||||||
|
|||||||
@@ -25,67 +25,6 @@ const double _barHorizontal = 16;
|
|||||||
const double _barFontSize = 13;
|
const double _barFontSize = 13;
|
||||||
const double _barButtonHeight = 30;
|
const double _barButtonHeight = 30;
|
||||||
const double _removeDialogButtonHeight = 32;
|
const double _removeDialogButtonHeight = 32;
|
||||||
const double _removeDialogRadius = 6;
|
|
||||||
const double _removeDialogBottomInset = 8;
|
|
||||||
|
|
||||||
/// 播放历史移除确认。只把移除按钮压矮。
|
|
||||||
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(
|
|
||||||
content: Text(l10n.confirmCancelFollowing),
|
|
||||||
actions: [
|
|
||||||
TextButton(
|
|
||||||
onPressed: () => Navigator.pop(dialogContext, false),
|
|
||||||
child: Text(l10n.cancel),
|
|
||||||
),
|
|
||||||
FilledButton(
|
|
||||||
onPressed: () => Navigator.pop(dialogContext, true),
|
|
||||||
child: Text(l10n.cancelFollowing),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
) ??
|
|
||||||
false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 只在追剧编辑中显示底栏。
|
/// 只在追剧编辑中显示底栏。
|
||||||
class FollowingEditSlot extends StatelessWidget {
|
class FollowingEditSlot extends StatelessWidget {
|
||||||
@@ -175,6 +114,7 @@ class FollowingEditBar extends StatelessWidget {
|
|||||||
TextButton(
|
TextButton(
|
||||||
key: const Key('following-select-all'),
|
key: const Key('following-select-all'),
|
||||||
style: TextButton.styleFrom(
|
style: TextButton.styleFrom(
|
||||||
|
foregroundColor: AppColors.brandRed,
|
||||||
visualDensity: VisualDensity.compact,
|
visualDensity: VisualDensity.compact,
|
||||||
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||||
minimumSize: const Size(0, _barButtonHeight),
|
minimumSize: const Size(0, _barButtonHeight),
|
||||||
@@ -194,16 +134,14 @@ class FollowingEditBar extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
const Spacer(),
|
const Spacer(),
|
||||||
FilledButton(
|
TextButton(
|
||||||
key: const Key('following-cancel-follow'),
|
key: const Key('following-cancel-follow'),
|
||||||
style: FilledButton.styleFrom(
|
style: TextButton.styleFrom(
|
||||||
|
foregroundColor: AppColors.brandRed,
|
||||||
visualDensity: VisualDensity.compact,
|
visualDensity: VisualDensity.compact,
|
||||||
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||||
minimumSize: const Size(0, _removeDialogButtonHeight),
|
minimumSize: const Size(0, _removeDialogButtonHeight),
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 12),
|
padding: const EdgeInsets.symmetric(horizontal: 12),
|
||||||
shape: RoundedRectangleBorder(
|
|
||||||
borderRadius: BorderRadius.circular(_removeDialogRadius),
|
|
||||||
),
|
|
||||||
textStyle: const TextStyle(
|
textStyle: const TextStyle(
|
||||||
fontSize: _barFontSize,
|
fontSize: _barFontSize,
|
||||||
fontWeight: FontWeight.w600,
|
fontWeight: FontWeight.w600,
|
||||||
|
|||||||
@@ -5,12 +5,18 @@ import 'dart:async';
|
|||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import '../../core/data/models/watch_record.dart';
|
||||||
import '../../core/data/services/favorite_controller.dart';
|
import '../../core/data/services/favorite_controller.dart';
|
||||||
|
import '../../core/data/services/watch_records_controller.dart';
|
||||||
import '../../core/formatting/error_text.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 '../../l10n/app_localizations.dart';
|
||||||
import '../player/open_player.dart';
|
import '../player/open_player.dart';
|
||||||
import 'following_grid_card.dart';
|
import 'following_grid_card.dart';
|
||||||
import 'following_paged_grid.dart';
|
import 'following_paged_grid.dart';
|
||||||
|
import 'widgets/continue_watching_banner.dart';
|
||||||
|
|
||||||
/// 追剧编辑中的选中状态。
|
/// 追剧编辑中的选中状态。
|
||||||
class FollowingFavoriteSelection {
|
class FollowingFavoriteSelection {
|
||||||
@@ -30,15 +36,19 @@ class FollowingFavoritesGrid extends StatelessWidget {
|
|||||||
const FollowingFavoritesGrid({
|
const FollowingFavoritesGrid({
|
||||||
super.key,
|
super.key,
|
||||||
required this.controller,
|
required this.controller,
|
||||||
|
required this.history,
|
||||||
required this.selection,
|
required this.selection,
|
||||||
required this.scrollController,
|
required this.scrollController,
|
||||||
required this.onGoHome,
|
required this.onGoHome,
|
||||||
|
required this.onContinueRecord,
|
||||||
});
|
});
|
||||||
|
|
||||||
final FavoriteController controller;
|
final FavoriteController controller;
|
||||||
|
final WatchRecordsController history;
|
||||||
final FollowingFavoriteSelection selection;
|
final FollowingFavoriteSelection selection;
|
||||||
final ScrollController scrollController;
|
final ScrollController scrollController;
|
||||||
final VoidCallback onGoHome;
|
final VoidCallback onGoHome;
|
||||||
|
final ValueChanged<WatchRecord> onContinueRecord;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@@ -49,7 +59,7 @@ class FollowingFavoritesGrid extends StatelessWidget {
|
|||||||
valueListenable: selection.selected,
|
valueListenable: selection.selected,
|
||||||
builder: (context, picked, _) {
|
builder: (context, picked, _) {
|
||||||
return ListenableBuilder(
|
return ListenableBuilder(
|
||||||
listenable: controller,
|
listenable: Listenable.merge([controller, history]),
|
||||||
builder: (context, _) => _grid(context, isEditing, picked),
|
builder: (context, _) => _grid(context, isEditing, picked),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
@@ -60,14 +70,15 @@ class FollowingFavoritesGrid extends StatelessWidget {
|
|||||||
|
|
||||||
Widget _grid(BuildContext context, bool isEditing, Set<String> picked) {
|
Widget _grid(BuildContext context, bool isEditing, Set<String> picked) {
|
||||||
final l10n = AppLocalizations.of(context)!;
|
final l10n = AppLocalizations.of(context)!;
|
||||||
final extra = isEditing ? 0 : 1;
|
final hasFavorites = controller.cards.isNotEmpty;
|
||||||
|
final extra = !isEditing && hasFavorites ? 1 : 0;
|
||||||
return FollowingPagedGrid(
|
return FollowingPagedGrid(
|
||||||
key: const Key('following-favorites-grid'),
|
key: const Key('following-favorites-grid'),
|
||||||
scrollController: scrollController,
|
scrollController: scrollController,
|
||||||
loading: controller.loading,
|
loading: controller.loading,
|
||||||
loadingMore: controller.loadingMore,
|
loadingMore: controller.loadingMore,
|
||||||
hasMore: controller.hasMore,
|
hasMore: controller.hasMore,
|
||||||
hasItems: controller.cards.isNotEmpty,
|
hasItems: hasFavorites,
|
||||||
showInitialLoading: false,
|
showInitialLoading: false,
|
||||||
errorMessage: controller.error == null
|
errorMessage: controller.error == null
|
||||||
? null
|
? null
|
||||||
@@ -78,23 +89,96 @@ class FollowingFavoritesGrid extends StatelessWidget {
|
|||||||
onRefresh: controller.load,
|
onRefresh: controller.load,
|
||||||
onLoadMore: controller.loadMore,
|
onLoadMore: controller.loadMore,
|
||||||
itemCount: controller.cards.length + extra,
|
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),
|
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(
|
Widget _item(
|
||||||
BuildContext context,
|
BuildContext context,
|
||||||
int index,
|
int index,
|
||||||
bool isEditing,
|
bool isEditing,
|
||||||
Set<String> picked,
|
Set<String> picked,
|
||||||
) {
|
) {
|
||||||
|
final l10n = AppLocalizations.of(context)!;
|
||||||
if (index == controller.cards.length) {
|
if (index == controller.cards.length) {
|
||||||
return FollowingAddCard(onTap: onGoHome);
|
return FollowingAddCard(onTap: onGoHome);
|
||||||
}
|
}
|
||||||
final l10n = AppLocalizations.of(context)!;
|
|
||||||
final drama = controller.cards[index];
|
final drama = controller.cards[index];
|
||||||
|
final record = history.recordForDrama(drama.id);
|
||||||
final episode = drama.episodes.isEmpty ? 1 : drama.episodes.first.number;
|
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(
|
return FollowingGridCard(
|
||||||
dramaId: drama.id,
|
dramaId: drama.id,
|
||||||
title: drama.localizedTitle(Localizations.localeOf(context).languageCode),
|
title: drama.localizedTitle(Localizations.localeOf(context).languageCode),
|
||||||
@@ -102,7 +186,10 @@ class FollowingFavoritesGrid extends StatelessWidget {
|
|||||||
viewCount: drama.viewCount,
|
viewCount: drama.viewCount,
|
||||||
editing: isEditing,
|
editing: isEditing,
|
||||||
selected: isEditing ? picked.contains(drama.id) : null,
|
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),
|
onTap: () => _openOrToggle(context, drama.id, isEditing),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,6 +25,8 @@ class FollowingGridCard extends StatelessWidget {
|
|||||||
this.editing = false,
|
this.editing = false,
|
||||||
this.selected,
|
this.selected,
|
||||||
this.onRemove,
|
this.onRemove,
|
||||||
|
this.updateBadge,
|
||||||
|
this.subtitleColor,
|
||||||
});
|
});
|
||||||
|
|
||||||
final String dramaId;
|
final String dramaId;
|
||||||
@@ -38,6 +40,13 @@ class FollowingGridCard extends StatelessWidget {
|
|||||||
final bool? selected;
|
final bool? selected;
|
||||||
final VoidCallback? onRemove;
|
final VoidCallback? onRemove;
|
||||||
|
|
||||||
|
/// 左上角「有更新」角标文案;null 不显示。
|
||||||
|
/// 待后端在 Drama 增加更新状态字段后由收藏网格传入。
|
||||||
|
final String? updateBadge;
|
||||||
|
|
||||||
|
/// 副标题颜色;更新中用强调红,完结用默认灰。
|
||||||
|
final Color? subtitleColor;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return InkWell(
|
return InkWell(
|
||||||
@@ -109,6 +118,32 @@ class FollowingGridCard extends StatelessWidget {
|
|||||||
count: viewCount,
|
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)
|
if (progress != null)
|
||||||
Positioned(
|
Positioned(
|
||||||
left: 0,
|
left: 0,
|
||||||
@@ -120,7 +155,7 @@ class FollowingGridCard extends StatelessWidget {
|
|||||||
minHeight: AppDimens.followingProgressHeight,
|
minHeight: AppDimens.followingProgressHeight,
|
||||||
backgroundColor: AppColors.inactiveTrack,
|
backgroundColor: AppColors.inactiveTrack,
|
||||||
valueColor: const AlwaysStoppedAnimation<Color>(
|
valueColor: const AlwaysStoppedAnimation<Color>(
|
||||||
AppColors.primary,
|
AppColors.brandRed,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -130,13 +165,13 @@ class FollowingGridCard extends StatelessWidget {
|
|||||||
const SizedBox(height: AppDimens.cardCoverTitleGap),
|
const SizedBox(height: AppDimens.cardCoverTitleGap),
|
||||||
Text(
|
Text(
|
||||||
title,
|
title,
|
||||||
maxLines: 2,
|
maxLines: 1,
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
textAlign: TextAlign.left,
|
textAlign: TextAlign.left,
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
color: AppColors.textPrimary,
|
color: AppColors.textPrimary,
|
||||||
fontSize: AppDimens.cardTitleFont,
|
fontSize: AppDimens.followingCardTitleFontNew,
|
||||||
fontWeight: FontWeight.w500,
|
fontWeight: FontWeight.w400,
|
||||||
height: AppDimens.cardTitleLineHeight,
|
height: AppDimens.cardTitleLineHeight,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -146,9 +181,9 @@ class FollowingGridCard extends StatelessWidget {
|
|||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
textAlign: TextAlign.left,
|
textAlign: TextAlign.left,
|
||||||
style: const TextStyle(
|
style: TextStyle(
|
||||||
color: AppColors.textTertiary,
|
color: subtitleColor ?? AppColors.textTertiary,
|
||||||
fontSize: AppDimens.followingSubtitleFont,
|
fontSize: AppDimens.followingCardSubtitleFontNew,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@@ -169,9 +204,9 @@ class _SelectMark extends StatelessWidget {
|
|||||||
height: _selectMarkSize,
|
height: _selectMarkSize,
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
shape: BoxShape.circle,
|
shape: BoxShape.circle,
|
||||||
color: selected ? AppColors.blue : AppColors.transparent,
|
color: selected ? AppColors.brandRed : AppColors.transparent,
|
||||||
border: Border.all(
|
border: Border.all(
|
||||||
color: selected ? AppColors.blue : AppColors.textPrimary,
|
color: selected ? AppColors.brandRed : AppColors.textPrimary,
|
||||||
width: _selectBorderWidth,
|
width: _selectBorderWidth,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -158,7 +158,7 @@ class FollowingHistoryCard extends StatelessWidget {
|
|||||||
minHeight: AppDimens.followingHistoryProgressHeight,
|
minHeight: AppDimens.followingHistoryProgressHeight,
|
||||||
backgroundColor: AppColors.inactiveTrack,
|
backgroundColor: AppColors.inactiveTrack,
|
||||||
valueColor: const AlwaysStoppedAnimation<Color>(
|
valueColor: const AlwaysStoppedAnimation<Color>(
|
||||||
AppColors.primary,
|
AppColors.brandRed,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -15,31 +15,33 @@ import '../../core/data/services/watch_records_controller.dart';
|
|||||||
import '../../core/formatting/error_text.dart';
|
import '../../core/formatting/error_text.dart';
|
||||||
import '../../core/theme/app_colors.dart';
|
import '../../core/theme/app_colors.dart';
|
||||||
import '../../core/theme/app_dimens.dart';
|
import '../../core/theme/app_dimens.dart';
|
||||||
import '../../core/widgets/auth_gate.dart';
|
|
||||||
import '../../core/widgets/empty_state.dart';
|
import '../../core/widgets/empty_state.dart';
|
||||||
import '../../l10n/app_localizations.dart';
|
import '../../l10n/app_localizations.dart';
|
||||||
|
import '../discover/search_page.dart';
|
||||||
import '../player/open_player.dart';
|
import '../player/open_player.dart';
|
||||||
|
import '../recommend/widgets/search_gift_glyphs.dart';
|
||||||
import 'following_edit_bar.dart';
|
import 'following_edit_bar.dart';
|
||||||
import 'following_favorites_grid.dart';
|
import 'following_favorites_grid.dart';
|
||||||
import 'following_history_card.dart';
|
import 'following_history_card.dart';
|
||||||
import 'following_keep_alive_tab.dart';
|
import 'following_keep_alive_tab.dart';
|
||||||
import 'following_paged_grid.dart';
|
import 'following_paged_grid.dart';
|
||||||
|
|
||||||
const double _doneFontSize = 14;
|
|
||||||
const double _doneTextGap = 12;
|
|
||||||
|
|
||||||
class FollowingPage extends StatefulWidget {
|
class FollowingPage extends StatefulWidget {
|
||||||
const FollowingPage({
|
const FollowingPage({
|
||||||
super.key,
|
super.key,
|
||||||
required this.onGoHome,
|
required this.onGoHome,
|
||||||
required this.favoriteController,
|
required this.favoriteController,
|
||||||
this.historyRequest = 0,
|
this.historyRequest = 0,
|
||||||
|
this.visible = true,
|
||||||
});
|
});
|
||||||
|
|
||||||
final VoidCallback onGoHome;
|
final VoidCallback onGoHome;
|
||||||
final FavoriteController favoriteController;
|
final FavoriteController favoriteController;
|
||||||
final int historyRequest;
|
final int historyRequest;
|
||||||
|
|
||||||
|
/// 当前是否为首页选中的 tab;重新可见时刷新观看历史,保证横幅是最新进度。
|
||||||
|
final bool visible;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<FollowingPage> createState() => _FollowingPageState();
|
State<FollowingPage> createState() => _FollowingPageState();
|
||||||
}
|
}
|
||||||
@@ -67,7 +69,7 @@ class _FollowingPageState extends State<FollowingPage> {
|
|||||||
history: context.read<WatchHistoryRepository>(),
|
history: context.read<WatchHistoryRepository>(),
|
||||||
catalog: context.read<CatalogRepository>(),
|
catalog: context.read<CatalogRepository>(),
|
||||||
);
|
);
|
||||||
if (_wasSignedIn) unawaited(_history.load());
|
unawaited(_history.load());
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
if (mounted) unawaited(widget.favoriteController.load());
|
if (mounted) unawaited(widget.favoriteController.load());
|
||||||
});
|
});
|
||||||
@@ -75,8 +77,16 @@ class _FollowingPageState extends State<FollowingPage> {
|
|||||||
|
|
||||||
void _onAuthChanged() {
|
void _onAuthChanged() {
|
||||||
final signedIn = _auth.isSignedIn;
|
final signedIn = _auth.isSignedIn;
|
||||||
if (signedIn && !_wasSignedIn) unawaited(_history.load());
|
if (signedIn == _wasSignedIn) return;
|
||||||
_wasSignedIn = signedIn;
|
_wasSignedIn = signedIn;
|
||||||
|
_leaveEditing();
|
||||||
|
_history.reset();
|
||||||
|
widget.favoriteController.clear();
|
||||||
|
unawaited(_reloadForIdentity());
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _reloadForIdentity() async {
|
||||||
|
await Future.wait([_history.load(), widget.favoriteController.load()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -95,6 +105,9 @@ class _FollowingPageState extends State<FollowingPage> {
|
|||||||
@override
|
@override
|
||||||
void didUpdateWidget(covariant FollowingPage oldWidget) {
|
void didUpdateWidget(covariant FollowingPage oldWidget) {
|
||||||
super.didUpdateWidget(oldWidget);
|
super.didUpdateWidget(oldWidget);
|
||||||
|
if (!oldWidget.visible && widget.visible) {
|
||||||
|
unawaited(_history.load());
|
||||||
|
}
|
||||||
if (oldWidget.historyRequest == widget.historyRequest) return;
|
if (oldWidget.historyRequest == widget.historyRequest) return;
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
if (mounted) _selectTab(FollowingTab.history);
|
if (mounted) _selectTab(FollowingTab.history);
|
||||||
@@ -104,57 +117,69 @@ class _FollowingPageState extends State<FollowingPage> {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final l10n = AppLocalizations.of(context)!;
|
final l10n = AppLocalizations.of(context)!;
|
||||||
final signedIn = context.watch<AuthController>().isSignedIn;
|
return DecoratedBox(
|
||||||
return ColoredBox(
|
|
||||||
key: const Key('following-page'),
|
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(
|
child: SafeArea(
|
||||||
bottom: false,
|
bottom: false,
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
_header(l10n),
|
_header(l10n),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: !signedIn
|
child: PageView(
|
||||||
? const AuthGatePanel()
|
key: const Key('following-tab-pages'),
|
||||||
: PageView(
|
controller: _pageController,
|
||||||
key: const Key('following-tab-pages'),
|
onPageChanged: _onPageChanged,
|
||||||
controller: _pageController,
|
children: [
|
||||||
onPageChanged: _onPageChanged,
|
FollowingKeepAliveTab(
|
||||||
children: [
|
child: FollowingFavoritesGrid(
|
||||||
FollowingKeepAliveTab(
|
controller: widget.favoriteController,
|
||||||
child: FollowingFavoritesGrid(
|
history: _history,
|
||||||
controller: widget.favoriteController,
|
selection: FollowingFavoriteSelection(
|
||||||
selection: FollowingFavoriteSelection(
|
editing: _editing,
|
||||||
editing: _editing,
|
selected: _selected,
|
||||||
selected: _selected,
|
onToggle: _toggleDrama,
|
||||||
onToggle: _toggleDrama,
|
),
|
||||||
),
|
scrollController: _favoriteScroll,
|
||||||
scrollController: _favoriteScroll,
|
onGoHome: widget.onGoHome,
|
||||||
onGoHome: widget.onGoHome,
|
onContinueRecord: (record) => unawaited(
|
||||||
),
|
_openHistory(context, _history, record),
|
||||||
),
|
),
|
||||||
FollowingKeepAliveTab(
|
|
||||||
child: _HistoryList(
|
|
||||||
controller: _history,
|
|
||||||
editing: _editing,
|
|
||||||
scrollController: _historyScroll,
|
|
||||||
onListEmptied: _exitEditingIfEmpty,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (signedIn)
|
FollowingKeepAliveTab(
|
||||||
FollowingEditSlot(
|
child: _HistoryList(
|
||||||
tab: _tab,
|
controller: _history,
|
||||||
editing: _editing,
|
editing: _editing,
|
||||||
favorites: widget.favoriteController,
|
scrollController: _historyScroll,
|
||||||
selected: _selected,
|
onListEmptied: _exitEditingIfEmpty,
|
||||||
actions: FollowingEditActions(
|
),
|
||||||
onToggleAll: _toggleAll,
|
),
|
||||||
onRemove: () => unawaited(_cancelSelected()),
|
],
|
||||||
),
|
|
||||||
),
|
),
|
||||||
|
),
|
||||||
|
FollowingEditSlot(
|
||||||
|
tab: _tab,
|
||||||
|
editing: _editing,
|
||||||
|
favorites: widget.favoriteController,
|
||||||
|
selected: _selected,
|
||||||
|
actions: FollowingEditActions(
|
||||||
|
onToggleAll: _toggleAll,
|
||||||
|
onRemove: () => unawaited(_cancelSelected()),
|
||||||
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -162,119 +187,165 @@ class _FollowingPageState extends State<FollowingPage> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget _header(AppLocalizations l10n) {
|
Widget _header(AppLocalizations l10n) {
|
||||||
return SizedBox(
|
return Padding(
|
||||||
key: const Key('following-header'),
|
key: const Key('following-header'),
|
||||||
height: AppDimens.followingHeaderHeight,
|
padding: const EdgeInsets.fromLTRB(
|
||||||
child: Padding(
|
AppDimens.feedPageHorizontal,
|
||||||
padding: const EdgeInsets.symmetric(
|
AppDimens.followingTitleTopGap,
|
||||||
horizontal: AppDimens.feedPageHorizontal,
|
AppDimens.feedPageHorizontal,
|
||||||
),
|
0,
|
||||||
child: ValueListenableBuilder<FollowingTab>(
|
),
|
||||||
valueListenable: _tab,
|
child: Column(
|
||||||
builder: (context, selectedTab, _) {
|
children: [
|
||||||
return ValueListenableBuilder<bool>(
|
SizedBox(
|
||||||
valueListenable: _editing,
|
height: AppDimens.followingTitleRowHeight,
|
||||||
builder: (context, editing, _) {
|
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(
|
return Row(
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
ListenableBuilder(
|
||||||
child: Row(
|
listenable: widget.favoriteController,
|
||||||
children: [
|
builder: (context, _) {
|
||||||
Flexible(
|
return _segment(
|
||||||
fit: FlexFit.loose,
|
FollowingTab.favorites,
|
||||||
child: _tabButton(
|
Text(
|
||||||
FollowingTab.favorites,
|
'${l10n.myFavorites} ${widget.favoriteController.total}',
|
||||||
l10n.followingTab,
|
maxLines: 1,
|
||||||
'favorites',
|
|
||||||
selectedTab == FollowingTab.favorites,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
const SizedBox(width: AppDimens.followingTabGap),
|
'favorites',
|
||||||
Flexible(
|
selectedTab == FollowingTab.favorites,
|
||||||
fit: FlexFit.loose,
|
);
|
||||||
child: _tabButton(
|
},
|
||||||
FollowingTab.history,
|
),
|
||||||
l10n.watchHistory,
|
const SizedBox(width: AppDimens.followingSegmentGap),
|
||||||
'history',
|
_segment(
|
||||||
selectedTab == FollowingTab.history,
|
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,
|
FollowingTab tab,
|
||||||
String label,
|
Widget label,
|
||||||
String keyName,
|
String keyName,
|
||||||
bool selected,
|
bool selected,
|
||||||
) {
|
) {
|
||||||
return InkWell(
|
return InkWell(
|
||||||
key: Key('following-tab-$keyName'),
|
key: Key('following-tab-$keyName'),
|
||||||
onTap: () => _selectTab(tab),
|
onTap: () => _selectTab(tab),
|
||||||
child: SizedBox(
|
borderRadius: BorderRadius.circular(8),
|
||||||
height: AppDimens.followingHeaderHeight,
|
child: Column(
|
||||||
child: Align(
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
alignment: Alignment.centerLeft,
|
children: [
|
||||||
widthFactor: 1,
|
AnimatedDefaultTextStyle(
|
||||||
child: AnimatedDefaultTextStyle(
|
|
||||||
duration: AppDimens.followingTabAnimationDuration,
|
duration: AppDimens.followingTabAnimationDuration,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: selected
|
color: selected
|
||||||
? AppColors.textPrimary
|
? AppColors.textPrimary
|
||||||
: AppColors.textTabInactive,
|
: AppColors.textTabInactive,
|
||||||
fontSize: AppDimens.followingTabFont,
|
fontSize: AppDimens.followingSegmentFont,
|
||||||
fontWeight: selected ? FontWeight.w600 : FontWeight.w400,
|
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,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -297,7 +368,7 @@ class _FollowingPageState extends State<FollowingPage> {
|
|||||||
final tab = FollowingTab.values[index];
|
final tab = FollowingTab.values[index];
|
||||||
_leaveEditing();
|
_leaveEditing();
|
||||||
_tab.value = tab;
|
_tab.value = tab;
|
||||||
if (tab == FollowingTab.history && _auth.isSignedIn) {
|
if (tab == FollowingTab.history) {
|
||||||
unawaited(_history.load());
|
unawaited(_history.load());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -326,10 +397,7 @@ class _FollowingPageState extends State<FollowingPage> {
|
|||||||
|
|
||||||
Future<void> _cancelSelected() async {
|
Future<void> _cancelSelected() async {
|
||||||
final ids = _selected.value.toList();
|
final ids = _selected.value.toList();
|
||||||
if (ids.isEmpty || !mounted || !await confirmCancelFollowing(context)) {
|
if (ids.isEmpty || !mounted) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!mounted) return;
|
|
||||||
final removed = await widget.favoriteController.removeMany(ids);
|
final removed = await widget.favoriteController.removeMany(ids);
|
||||||
if (!removed || !mounted) return;
|
if (!removed || !mounted) return;
|
||||||
_selected.value = {};
|
_selected.value = {};
|
||||||
@@ -421,8 +489,7 @@ class _HistoryList extends StatelessWidget {
|
|||||||
onTap: openRecord,
|
onTap: openRecord,
|
||||||
onContinue: openRecord,
|
onContinue: openRecord,
|
||||||
onRemove: () async {
|
onRemove: () async {
|
||||||
if (await confirmHistoryRemove(context) &&
|
if (await controller.remove(record.dramaId) &&
|
||||||
await controller.remove(record.dramaId) &&
|
|
||||||
controller.records.isEmpty) {
|
controller.records.isEmpty) {
|
||||||
onListEmptied();
|
onListEmptied();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ class FollowingPagedGrid extends StatelessWidget {
|
|||||||
this.singleColumn = false,
|
this.singleColumn = false,
|
||||||
this.errorMessage,
|
this.errorMessage,
|
||||||
this.loadMoreError,
|
this.loadMoreError,
|
||||||
|
this.topSlivers = const [],
|
||||||
});
|
});
|
||||||
|
|
||||||
static const double _loadMoreThreshold = 240;
|
static const double _loadMoreThreshold = 240;
|
||||||
@@ -44,6 +45,10 @@ class FollowingPagedGrid extends StatelessWidget {
|
|||||||
final String? loadMoreError;
|
final String? loadMoreError;
|
||||||
final bool showInitialLoading;
|
final bool showInitialLoading;
|
||||||
final bool singleColumn;
|
final bool singleColumn;
|
||||||
|
|
||||||
|
/// 列表顶部的非分页内容(继续观看横幅、区块标题等)。
|
||||||
|
/// 必须是 sliver;空列表时也会保留,因此可携带空态上方的固定区块。
|
||||||
|
final List<Widget> topSlivers;
|
||||||
final Future<void> Function() onRefresh;
|
final Future<void> Function() onRefresh;
|
||||||
final Future<void> Function() onLoadMore;
|
final Future<void> Function() onLoadMore;
|
||||||
|
|
||||||
@@ -81,6 +86,7 @@ class FollowingPagedGrid extends StatelessWidget {
|
|||||||
controller: scrollController,
|
controller: scrollController,
|
||||||
physics: AppPullToRefresh.physics,
|
physics: AppPullToRefresh.physics,
|
||||||
slivers: [
|
slivers: [
|
||||||
|
...topSlivers,
|
||||||
if (itemCount == 0)
|
if (itemCount == 0)
|
||||||
SliverFillRemaining(
|
SliverFillRemaining(
|
||||||
hasScrollBody: false,
|
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),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,7 +12,6 @@ import '../../core/data/services/home_feed_controller.dart';
|
|||||||
import '../../core/data/services/catalog_controller.dart';
|
import '../../core/data/services/catalog_controller.dart';
|
||||||
import '../../core/data/services/category_controller.dart';
|
import '../../core/data/services/category_controller.dart';
|
||||||
import '../../core/data/services/favorite_controller.dart';
|
import '../../core/data/services/favorite_controller.dart';
|
||||||
import '../../core/data/services/wallet_controller.dart';
|
|
||||||
import '../../core/platform/haptics.dart';
|
import '../../core/platform/haptics.dart';
|
||||||
import '../../core/theme/app_colors.dart';
|
import '../../core/theme/app_colors.dart';
|
||||||
import '../../core/theme/app_theme.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 '../../core/widgets/app_root_tab.dart';
|
||||||
import '../discover/search_page.dart';
|
import '../discover/search_page.dart';
|
||||||
import '../following/following_page.dart';
|
import '../following/following_page.dart';
|
||||||
import '../filter/filter_page.dart';
|
|
||||||
import '../mine/mine_types.dart';
|
import '../mine/mine_types.dart';
|
||||||
import '../recommend/recommend_page.dart';
|
import '../recommend/recommend_page.dart';
|
||||||
|
import '../recommend/recommend_discover_page.dart';
|
||||||
import '../mine/mine_view.dart';
|
import '../mine/mine_view.dart';
|
||||||
import '../store/vip_page.dart';
|
|
||||||
import '../wallet/wallet_page.dart';
|
import '../wallet/wallet_page.dart';
|
||||||
import 'home_binding.dart';
|
import 'home_binding.dart';
|
||||||
import 'home_logic.dart';
|
import 'home_logic.dart';
|
||||||
import 'widgets/home_feed_grid.dart';
|
|
||||||
import 'widgets/home_grid_header.dart';
|
|
||||||
|
|
||||||
class HomePage extends StatefulWidget {
|
class HomePage extends StatefulWidget {
|
||||||
const HomePage({super.key});
|
const HomePage({super.key});
|
||||||
@@ -147,7 +143,7 @@ class _HomeTabsState extends State<_HomeTabs> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget _scaffold(BuildContext context) {
|
Widget _scaffold(BuildContext context) {
|
||||||
final mediaTab = logic.tab == 0 || logic.tab == 1;
|
// 各 tab 均自绘背景(媒体 tab 纯黑,追剧/我的带顶部红光晕),无需外层渐变。
|
||||||
final content = PopScope(
|
final content = PopScope(
|
||||||
canPop: false,
|
canPop: false,
|
||||||
onPopInvokedWithResult: (didPop, _) {
|
onPopInvokedWithResult: (didPop, _) {
|
||||||
@@ -164,24 +160,19 @@ class _HomeTabsState extends State<_HomeTabs> {
|
|||||||
);
|
);
|
||||||
return AnnotatedRegion<SystemUiOverlayStyle>(
|
return AnnotatedRegion<SystemUiOverlayStyle>(
|
||||||
value: SystemUiOverlayStyle.light,
|
value: SystemUiOverlayStyle.light,
|
||||||
child: mediaTab
|
child: content,
|
||||||
? content
|
|
||||||
: DecoratedBox(
|
|
||||||
key: const Key('home-page-gradient'),
|
|
||||||
decoration: const BoxDecoration(gradient: AppTheme.pageGradient),
|
|
||||||
child: content,
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _body(BuildContext context) {
|
Widget _body(BuildContext context) {
|
||||||
final pages = <Widget>[
|
final pages = <Widget>[
|
||||||
_homeGrid(context),
|
|
||||||
_recommend(context),
|
_recommend(context),
|
||||||
|
_recommendDiscover(context),
|
||||||
FollowingPage(
|
FollowingPage(
|
||||||
onGoHome: () => logic.select(0),
|
onGoHome: () => logic.select(0),
|
||||||
favoriteController: context.read<FavoriteController>(),
|
favoriteController: context.read<FavoriteController>(),
|
||||||
historyRequest: logic.followingHistoryRequest,
|
historyRequest: logic.followingHistoryRequest,
|
||||||
|
visible: logic.tab == 2,
|
||||||
),
|
),
|
||||||
_my(context),
|
_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) {
|
Widget _recommend(BuildContext context) {
|
||||||
return RecommendPage(
|
return RecommendPage(
|
||||||
feedController: widget.feedController,
|
feedController: widget.feedController,
|
||||||
catalogApi: _catalogApi(context),
|
catalogApi: _catalogApi(context),
|
||||||
active: logic.tab == 1,
|
active: logic.tab == 0,
|
||||||
videoOnly: logic.videoImmersive,
|
videoOnly: logic.videoImmersive,
|
||||||
onImmersiveChanged: logic.onImmersiveChanged,
|
onImmersiveChanged: logic.onImmersiveChanged,
|
||||||
onSearch: () => _openSearch(context),
|
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()));
|
).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 {
|
Future<void> _openWallet(BuildContext context) async {
|
||||||
if (!await ensureSignedIn(context) || !context.mounted) return;
|
if (!await ensureSignedIn(context) || !context.mounted) return;
|
||||||
await Navigator.of(
|
await Navigator.of(
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ class HomeFeedCard extends StatelessWidget {
|
|||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
textAlign: TextAlign.left,
|
textAlign: TextAlign.left,
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
color: AppColors.navSelected,
|
color: AppColors.textPrimary,
|
||||||
fontSize: AppDimens.cardTitleFont,
|
fontSize: AppDimens.cardTitleFont,
|
||||||
fontWeight: FontWeight.w500,
|
fontWeight: FontWeight.w500,
|
||||||
height: AppDimens.cardTitleLineHeight,
|
height: AppDimens.cardTitleLineHeight,
|
||||||
|
|||||||
@@ -104,6 +104,7 @@ class _HomeFeedGridState extends State<HomeFeedGrid> {
|
|||||||
return _categoryPlaceholder(
|
return _categoryPlaceholder(
|
||||||
l10n,
|
l10n,
|
||||||
context.watch<CategoryController>(),
|
context.watch<CategoryController>(),
|
||||||
|
catalog,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
final category = shortcuts[index];
|
final category = shortcuts[index];
|
||||||
@@ -146,7 +147,11 @@ class _HomeFeedGridState extends State<HomeFeedGrid> {
|
|||||||
Widget _categoryPlaceholder(
|
Widget _categoryPlaceholder(
|
||||||
AppLocalizations l10n,
|
AppLocalizations l10n,
|
||||||
CategoryController controller,
|
CategoryController controller,
|
||||||
|
CatalogController catalog,
|
||||||
) {
|
) {
|
||||||
|
if (catalog.error != null) {
|
||||||
|
return _catalogErrorState(l10n, catalog);
|
||||||
|
}
|
||||||
if (controller.loading) {
|
if (controller.loading) {
|
||||||
return const DramaGridSkeleton(
|
return const DramaGridSkeleton(
|
||||||
key: Key('home-grid-skeleton'),
|
key: Key('home-grid-skeleton'),
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import '../../../core/data/models/interaction.dart';
|
import '../../../core/data/models/interaction.dart';
|
||||||
|
import '../../../core/widgets/app_glow_panel.dart';
|
||||||
import '../../../l10n/app_localizations.dart';
|
import '../../../l10n/app_localizations.dart';
|
||||||
|
|
||||||
const int _maxDescriptionLength = 300;
|
const int _maxDescriptionLength = 300;
|
||||||
@@ -67,9 +68,9 @@ class _ReportDialogState extends State<_ReportDialog> {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final l10n = AppLocalizations.of(context)!;
|
final l10n = AppLocalizations.of(context)!;
|
||||||
return AlertDialog(
|
return AppGlowDialog(
|
||||||
title: Text(widget.title),
|
title: widget.title,
|
||||||
content: SingleChildScrollView(
|
contentChild: SingleChildScrollView(
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ class MineLogic extends ChangeNotifier {
|
|||||||
bool recentLoading = false;
|
bool recentLoading = false;
|
||||||
String? recentError;
|
String? recentError;
|
||||||
bool _disposed = false;
|
bool _disposed = false;
|
||||||
|
int _requestSeq = 0;
|
||||||
|
|
||||||
void notify() {
|
void notify() {
|
||||||
if (!_disposed) notifyListeners();
|
if (!_disposed) notifyListeners();
|
||||||
@@ -25,21 +26,37 @@ class MineLogic extends ChangeNotifier {
|
|||||||
|
|
||||||
/// 最近观看:取分页首屏,剧名封面仍由目录卡片按 id 映射。
|
/// 最近观看:取分页首屏,剧名封面仍由目录卡片按 id 映射。
|
||||||
Future<void> refreshRecent() async {
|
Future<void> refreshRecent() async {
|
||||||
|
final request = ++_requestSeq;
|
||||||
recentLoading = true;
|
recentLoading = true;
|
||||||
recentError = null;
|
recentError = null;
|
||||||
notify();
|
notify();
|
||||||
try {
|
try {
|
||||||
final page = await history.recent(pageIndex: 1, pageSize: 10);
|
final page = await history.recent(pageIndex: 1, pageSize: 10);
|
||||||
|
if (_disposed || request != _requestSeq) return;
|
||||||
recent = page.list;
|
recent = page.list;
|
||||||
watchRecordTotal = page.total;
|
watchRecordTotal = page.total;
|
||||||
} catch (_) {
|
} catch (_) {
|
||||||
recentError = 'progressError';
|
if (!_disposed && request == _requestSeq) {
|
||||||
|
recentError = 'progressError';
|
||||||
|
}
|
||||||
} finally {
|
} finally {
|
||||||
recentLoading = false;
|
if (!_disposed && request == _requestSeq) {
|
||||||
notify();
|
recentLoading = false;
|
||||||
|
notify();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// 切换账号/设备身份时先清空,避免旧身份数据回写或短暂混显。
|
||||||
|
void resetRecent() {
|
||||||
|
_requestSeq += 1;
|
||||||
|
recent = const [];
|
||||||
|
watchRecordTotal = null;
|
||||||
|
recentLoading = false;
|
||||||
|
recentError = null;
|
||||||
|
notify();
|
||||||
|
}
|
||||||
|
|
||||||
/// 页面重新可见时刷新最近观看,避免停留在旧进度。
|
/// 页面重新可见时刷新最近观看,避免停留在旧进度。
|
||||||
void syncPage({required bool active, required bool wasActive}) {
|
void syncPage({required bool active, required bool wasActive}) {
|
||||||
if (active && !wasActive) refreshRecent();
|
if (active && !wasActive) refreshRecent();
|
||||||
|
|||||||
+139
-112
@@ -14,27 +14,25 @@ import '../../core/data/services/wallet_controller.dart';
|
|||||||
import '../../core/theme/app_colors.dart';
|
import '../../core/theme/app_colors.dart';
|
||||||
import '../../core/theme/app_dimens.dart';
|
import '../../core/theme/app_dimens.dart';
|
||||||
import '../../core/theme/app_theme.dart';
|
import '../../core/theme/app_theme.dart';
|
||||||
|
import '../../core/widgets/app_glow_panel.dart';
|
||||||
import '../../core/widgets/app_root_tab.dart';
|
import '../../core/widgets/app_root_tab.dart';
|
||||||
import '../../core/widgets/auth_gate.dart';
|
import '../../core/widgets/auth_gate.dart';
|
||||||
import '../../core/widgets/plain_page_scaffold.dart';
|
import '../../core/widgets/plain_page_scaffold.dart';
|
||||||
import '../../l10n/app_localizations.dart';
|
import '../../l10n/app_localizations.dart';
|
||||||
import '../downloads/downloads_page.dart';
|
import '../downloads/downloads_page.dart';
|
||||||
import '../account/account_profile_page.dart';
|
import '../account/account_profile_page.dart';
|
||||||
|
import '../favorites/favorites_page.dart';
|
||||||
import '../filter/filter_page.dart';
|
import '../filter/filter_page.dart';
|
||||||
import '../notices/notices_page.dart';
|
import '../notices/notices_page.dart';
|
||||||
import '../settings/settings_page.dart';
|
import '../settings/settings_page.dart';
|
||||||
import '../store/vip_page.dart';
|
import '../store/vip_page.dart';
|
||||||
import '../wallet/wallet_page.dart';
|
import '../wallet/wallet_page.dart';
|
||||||
import '../watch_records/watch_records_page.dart';
|
import '../watch_records/watch_records_page.dart';
|
||||||
import 'about_page.dart';
|
|
||||||
import 'mine_binding.dart';
|
import 'mine_binding.dart';
|
||||||
import 'mine_logic.dart';
|
import 'mine_logic.dart';
|
||||||
import 'mine_types.dart';
|
import 'mine_types.dart';
|
||||||
import 'widgets/mine_continue_watching.dart';
|
|
||||||
import 'widgets/mine_header.dart';
|
import 'widgets/mine_header.dart';
|
||||||
import 'widgets/mine_menu.dart';
|
import 'widgets/mine_menu.dart';
|
||||||
import 'widgets/mine_more_services.dart';
|
|
||||||
import 'widgets/mine_stats_panel.dart';
|
|
||||||
|
|
||||||
/// K28-B 我的页。
|
/// K28-B 我的页。
|
||||||
class MyPage extends StatefulWidget {
|
class MyPage extends StatefulWidget {
|
||||||
@@ -53,25 +51,70 @@ class MyPage extends StatefulWidget {
|
|||||||
|
|
||||||
class _MyPageState extends State<MyPage> {
|
class _MyPageState extends State<MyPage> {
|
||||||
late final MineLogic logic;
|
late final MineLogic logic;
|
||||||
|
late final AuthController _auth;
|
||||||
|
late final FavoriteController _favorites;
|
||||||
|
late bool _wasSignedIn;
|
||||||
|
bool _activationRefreshScheduled = false;
|
||||||
|
|
||||||
bool get embedded => widget.callbacks.embedded;
|
bool get embedded => widget.callbacks.embedded;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
|
_auth = context.read<AuthController>();
|
||||||
|
_favorites = context.read<FavoriteController>();
|
||||||
|
_wasSignedIn = _auth.isSignedIn;
|
||||||
|
_auth.addListener(_onAuthChanged);
|
||||||
logic = MineBinding().create(
|
logic = MineBinding().create(
|
||||||
history: context.read<WatchHistoryRepository>(),
|
history: context.read<WatchHistoryRepository>(),
|
||||||
);
|
);
|
||||||
|
if (widget.active) _scheduleFavoriteLoad();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void didUpdateWidget(covariant MyPage oldWidget) {
|
void didUpdateWidget(covariant MyPage oldWidget) {
|
||||||
super.didUpdateWidget(oldWidget);
|
super.didUpdateWidget(oldWidget);
|
||||||
logic.syncPage(active: widget.active, wasActive: oldWidget.active);
|
if (widget.active && !oldWidget.active) {
|
||||||
|
_scheduleActivationRefresh();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void _scheduleFavoriteLoad() {
|
||||||
|
if (_activationRefreshScheduled) return;
|
||||||
|
_activationRefreshScheduled = true;
|
||||||
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
|
_activationRefreshScheduled = false;
|
||||||
|
if (mounted) unawaited(_favorites.load());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void _scheduleActivationRefresh() {
|
||||||
|
if (_activationRefreshScheduled) return;
|
||||||
|
_activationRefreshScheduled = true;
|
||||||
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
|
_activationRefreshScheduled = false;
|
||||||
|
if (!mounted || !widget.active) return;
|
||||||
|
logic.syncPage(active: true, wasActive: false);
|
||||||
|
unawaited(_favorites.load());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void _onAuthChanged() {
|
||||||
|
final signedIn = _auth.isSignedIn;
|
||||||
|
if (signedIn == _wasSignedIn) return;
|
||||||
|
_wasSignedIn = signedIn;
|
||||||
|
logic.resetRecent();
|
||||||
|
_favorites.clear();
|
||||||
|
unawaited(_reloadForIdentity());
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _reloadForIdentity() async {
|
||||||
|
await Future.wait([logic.refreshRecent(), _favorites.load()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
|
_auth.removeListener(_onAuthChanged);
|
||||||
logic.dispose();
|
logic.dispose();
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
@@ -87,41 +130,27 @@ class _MyPageState extends State<MyPage> {
|
|||||||
Widget _page(BuildContext context) {
|
Widget _page(BuildContext context) {
|
||||||
final content = DecoratedBox(
|
final content = DecoratedBox(
|
||||||
key: const Key('mine-page-surface'),
|
key: const Key('mine-page-surface'),
|
||||||
|
// 与追剧页同款:纯黑底 + 顶部暗红光晕。
|
||||||
decoration: const BoxDecoration(
|
decoration: const BoxDecoration(
|
||||||
gradient: LinearGradient(
|
gradient: LinearGradient(
|
||||||
begin: Alignment.topCenter,
|
begin: Alignment.topCenter,
|
||||||
end: Alignment.bottomCenter,
|
end: Alignment.bottomCenter,
|
||||||
colors: [
|
colors: [
|
||||||
AppColors.mineGradientTop,
|
AppColors.followingGlow,
|
||||||
AppColors.mineGradientMiddle,
|
AppColors.followingGlowMid,
|
||||||
AppColors.mineGradientBottom,
|
AppColors.appBackground,
|
||||||
],
|
],
|
||||||
stops: [0, 0.4, 0.75],
|
stops: [0, 0.14, 0.3],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
child: Stack(
|
child: SafeArea(
|
||||||
fit: StackFit.expand,
|
bottom: false,
|
||||||
children: [
|
child: Column(
|
||||||
const DecoratedBox(
|
children: [
|
||||||
key: Key('mine-page-glow'),
|
Expanded(child: _body(context)),
|
||||||
decoration: BoxDecoration(
|
if (!embedded) _bottomNav(),
|
||||||
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(),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
return AnnotatedRegion<SystemUiOverlayStyle>(
|
return AnnotatedRegion<SystemUiOverlayStyle>(
|
||||||
@@ -136,20 +165,7 @@ class _MyPageState extends State<MyPage> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget _body(BuildContext context) {
|
Widget _body(BuildContext context) {
|
||||||
final auth = context.watch<AuthController>();
|
final l10n = AppLocalizations.of(context)!;
|
||||||
final favorites = context.watch<FavoriteController>();
|
|
||||||
final wallet = context.watch<WalletController>();
|
|
||||||
final continueWatching = logic.recent.take(10).toList(growable: false);
|
|
||||||
final followingCount =
|
|
||||||
auth.isSignedIn &&
|
|
||||||
favorites.error == null &&
|
|
||||||
!(favorites.loading && favorites.total == 0)
|
|
||||||
? favorites.total
|
|
||||||
: null;
|
|
||||||
final watchRecordCount = auth.isSignedIn ? logic.watchRecordTotal : null;
|
|
||||||
final coinBalance = auth.isSignedIn && wallet.snapshot != null
|
|
||||||
? wallet.balance
|
|
||||||
: null;
|
|
||||||
return ListView(
|
return ListView(
|
||||||
key: const Key('mine-page-scroll'),
|
key: const Key('mine-page-scroll'),
|
||||||
padding: const EdgeInsets.only(bottom: AppDimens.spaceXl),
|
padding: const EdgeInsets.only(bottom: AppDimens.spaceXl),
|
||||||
@@ -163,6 +179,7 @@ class _MyPageState extends State<MyPage> {
|
|||||||
onEdit: () => _push(const AccountProfilePage()),
|
onEdit: () => _push(const AccountProfilePage()),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
const SizedBox(height: AppDimens.spaceMd),
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.symmetric(
|
padding: const EdgeInsets.symmetric(
|
||||||
horizontal: AppDimens.pageHorizontal,
|
horizontal: AppDimens.pageHorizontal,
|
||||||
@@ -171,22 +188,16 @@ class _MyPageState extends State<MyPage> {
|
|||||||
onOpen: () => _openDestination(MineDestination.vip),
|
onOpen: () => _openDestination(MineDestination.vip),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (continueWatching.isNotEmpty) ...[
|
|
||||||
const SizedBox(height: AppDimens.mineSectionGap),
|
|
||||||
MineContinueWatching(
|
|
||||||
records: continueWatching,
|
|
||||||
onOpenAll: _openHistoryTab,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
const SizedBox(height: AppDimens.mineSectionGap),
|
const SizedBox(height: AppDimens.mineSectionGap),
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.symmetric(
|
padding: const EdgeInsets.symmetric(
|
||||||
horizontal: AppDimens.mineGridHorizontal,
|
horizontal: AppDimens.pageHorizontal,
|
||||||
),
|
),
|
||||||
child: MineStatsPanel(
|
child: MineQuickActions(
|
||||||
followingCount: followingCount,
|
onWallet: () => _openDestination(MineDestination.wallet),
|
||||||
watchRecordCount: watchRecordCount,
|
onFavorites: () => _push(const FavoritesPage()),
|
||||||
coinBalance: coinBalance,
|
onDownloads: () => _openDestination(MineDestination.downloads),
|
||||||
|
onHistory: () => _openDestination(MineDestination.history),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: AppDimens.mineSectionGap),
|
const SizedBox(height: AppDimens.mineSectionGap),
|
||||||
@@ -194,29 +205,44 @@ class _MyPageState extends State<MyPage> {
|
|||||||
padding: const EdgeInsets.symmetric(
|
padding: const EdgeInsets.symmetric(
|
||||||
horizontal: AppDimens.mineGridHorizontal,
|
horizontal: AppDimens.mineGridHorizontal,
|
||||||
),
|
),
|
||||||
child: MineMenuList(
|
child: Column(
|
||||||
onOpen: _openDestination,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
onLanguage: _openLanguage,
|
children: [
|
||||||
),
|
Text(
|
||||||
),
|
l10n.moreServices,
|
||||||
const SizedBox(height: AppDimens.mineSectionGap),
|
style: const TextStyle(
|
||||||
Padding(
|
color: AppColors.textTertiary,
|
||||||
padding: const EdgeInsets.symmetric(
|
fontSize: AppDimens.mineSectionTitle,
|
||||||
horizontal: AppDimens.mineGridHorizontal,
|
),
|
||||||
),
|
),
|
||||||
child: MineMoreServices(
|
const SizedBox(height: AppDimens.spaceSm),
|
||||||
onCommonQuestions: _pushPlaceholder,
|
MineServiceList(
|
||||||
onAbout: () => _push(const MineAboutPage()),
|
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) {
|
void _openDestination(MineDestination destination) {
|
||||||
switch (destination) {
|
switch (destination) {
|
||||||
case MineDestination.history:
|
case MineDestination.history:
|
||||||
_push(const WatchRecordsPage());
|
unawaited(_openHistoryPage());
|
||||||
case MineDestination.downloads:
|
case MineDestination.downloads:
|
||||||
_push(const DownloadsPage());
|
_push(const DownloadsPage());
|
||||||
case MineDestination.wallet:
|
case MineDestination.wallet:
|
||||||
@@ -238,21 +264,37 @@ class _MyPageState extends State<MyPage> {
|
|||||||
unawaited(openAuthPage(context));
|
unawaited(openAuthPage(context));
|
||||||
}
|
}
|
||||||
|
|
||||||
void _openHistoryTab() {
|
Future<void> _openHistoryPage() async {
|
||||||
final callback = widget.callbacks.onOpenHistoryTab;
|
await _push(const WatchRecordsPage());
|
||||||
if (callback != null) {
|
if (mounted) unawaited(logic.refreshRecent());
|
||||||
callback();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_push(const WatchRecordsPage());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void _push(Widget page) {
|
Future<void> _push(Widget page) {
|
||||||
Navigator.of(context).push<void>(MaterialPageRoute(builder: (_) => page));
|
return Navigator.of(
|
||||||
|
context,
|
||||||
|
).push<void>(MaterialPageRoute(builder: (_) => page));
|
||||||
}
|
}
|
||||||
|
|
||||||
void _pushPlaceholder() {
|
void _pushPlaceholder() {
|
||||||
_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 {
|
Future<void> _openProtected(Widget page) async {
|
||||||
@@ -260,7 +302,7 @@ class _MyPageState extends State<MyPage> {
|
|||||||
await ensureSignedIn(context);
|
await ensureSignedIn(context);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (mounted) _push(page);
|
if (mounted) await _push(page);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _openVip() {
|
void _openVip() {
|
||||||
@@ -321,14 +363,16 @@ class _LanguageSheet extends StatelessWidget {
|
|||||||
(const Locale('en'), const Key('mine-language-en'), l10n.english),
|
(const Locale('en'), const Key('mine-language-en'), l10n.english),
|
||||||
(const Locale('id'), const Key('mine-language-id'), l10n.bahasaIndonesia),
|
(const Locale('id'), const Key('mine-language-id'), l10n.bahasaIndonesia),
|
||||||
];
|
];
|
||||||
return Material(
|
return AppGlowPanel(
|
||||||
key: const Key('mine-language-sheet'),
|
|
||||||
color: AppColors.contentCard,
|
|
||||||
borderRadius: const BorderRadius.vertical(
|
borderRadius: const BorderRadius.vertical(
|
||||||
top: Radius.circular(AppDimens.mineCardRadius),
|
top: Radius.circular(AppDimens.mineCardRadius),
|
||||||
),
|
),
|
||||||
clipBehavior: Clip.antiAlias,
|
border: false,
|
||||||
child: SafeArea(
|
child: Material(
|
||||||
|
key: const Key('mine-language-sheet'),
|
||||||
|
type: MaterialType.transparency,
|
||||||
|
clipBehavior: Clip.antiAlias,
|
||||||
|
child: SafeArea(
|
||||||
top: false,
|
top: false,
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.fromLTRB(20, 14, 20, 20),
|
padding: const EdgeInsets.fromLTRB(20, 14, 20, 20),
|
||||||
@@ -351,7 +395,13 @@ class _LanguageSheet extends StatelessWidget {
|
|||||||
IconButton(
|
IconButton(
|
||||||
tooltip: l10n.close,
|
tooltip: l10n.close,
|
||||||
onPressed: () => Navigator.pop(context),
|
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),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@@ -372,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,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,10 +12,14 @@ class MineContinueWatching extends StatelessWidget {
|
|||||||
const MineContinueWatching({
|
const MineContinueWatching({
|
||||||
super.key,
|
super.key,
|
||||||
required this.records,
|
required this.records,
|
||||||
|
required this.onOpenRecord,
|
||||||
required this.onOpenAll,
|
required this.onOpenAll,
|
||||||
});
|
});
|
||||||
|
|
||||||
final List<WatchProgress> records;
|
final List<WatchProgress> records;
|
||||||
|
|
||||||
|
/// 单张卡片:直接进入该剧的播放页,并定位到记录的集。
|
||||||
|
final ValueChanged<WatchProgress> onOpenRecord;
|
||||||
final VoidCallback onOpenAll;
|
final VoidCallback onOpenAll;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -94,7 +98,11 @@ class MineContinueWatching extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _card(AppLocalizations l10n, WatchProgress record, String languageCode) {
|
Widget _card(
|
||||||
|
AppLocalizations l10n,
|
||||||
|
WatchProgress record,
|
||||||
|
String languageCode,
|
||||||
|
) {
|
||||||
final title = record.localizedTitle(languageCode).trim();
|
final title = record.localizedTitle(languageCode).trim();
|
||||||
final episode = record.episodeNumber;
|
final episode = record.episodeNumber;
|
||||||
final hasProgress = record.duration > Duration.zero;
|
final hasProgress = record.duration > Duration.zero;
|
||||||
@@ -103,7 +111,7 @@ class MineContinueWatching extends StatelessWidget {
|
|||||||
child: InkWell(
|
child: InkWell(
|
||||||
key: Key('mine-continue-${record.dramaId}'),
|
key: Key('mine-continue-${record.dramaId}'),
|
||||||
borderRadius: BorderRadius.circular(AppDimens.homeCardRadius),
|
borderRadius: BorderRadius.circular(AppDimens.homeCardRadius),
|
||||||
onTap: onOpenAll,
|
onTap: () => onOpenRecord(record),
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
// Author: fruit.com.cn
|
// Author: fruit.com.cn
|
||||||
|
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
import 'dart:ui' as ui;
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
@@ -13,8 +14,7 @@ import '../../../core/widgets/centered_toast.dart';
|
|||||||
import '../../../core/widgets/remote_image.dart';
|
import '../../../core/widgets/remote_image.dart';
|
||||||
import '../../../l10n/app_localizations.dart';
|
import '../../../l10n/app_localizations.dart';
|
||||||
|
|
||||||
const double _buttonHeight = 34;
|
const double _buttonHeight = 40;
|
||||||
const double _buttonRadius = 6;
|
|
||||||
|
|
||||||
/// 「我的」页用户区。
|
/// 「我的」页用户区。
|
||||||
class MineHeader extends StatelessWidget {
|
class MineHeader extends StatelessWidget {
|
||||||
@@ -35,7 +35,7 @@ class MineHeader extends StatelessWidget {
|
|||||||
final uid = signedIn ? user?.uid.trim() ?? '' : '';
|
final uid = signedIn ? user?.uid.trim() ?? '' : '';
|
||||||
return Padding(
|
return Padding(
|
||||||
key: const Key('mine-user-row'),
|
key: const Key('mine-user-row'),
|
||||||
padding: const EdgeInsets.symmetric(vertical: AppDimens.spaceMd),
|
padding: const EdgeInsets.symmetric(vertical: AppDimens.spaceSm),
|
||||||
child: Row(
|
child: Row(
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
@@ -55,7 +55,7 @@ class MineHeader extends StatelessWidget {
|
|||||||
fontFamily: 'Outfit',
|
fontFamily: 'Outfit',
|
||||||
color: AppColors.textPrimary,
|
color: AppColors.textPrimary,
|
||||||
fontSize: AppDimens.mineUserName,
|
fontSize: AppDimens.mineUserName,
|
||||||
fontWeight: FontWeight.w700,
|
fontWeight: FontWeight.w400,
|
||||||
height: AppDimens.mineUserNameLineHeight,
|
height: AppDimens.mineUserNameLineHeight,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -121,18 +121,29 @@ class MineHeader extends StatelessWidget {
|
|||||||
key: const Key('mine-avatar'),
|
key: const Key('mine-avatar'),
|
||||||
width: AppDimens.mineAvatar,
|
width: AppDimens.mineAvatar,
|
||||||
height: AppDimens.mineAvatar,
|
height: AppDimens.mineAvatar,
|
||||||
decoration: const BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: AppColors.contentSurface,
|
|
||||||
shape: BoxShape.circle,
|
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 String label,
|
||||||
required VoidCallback onTap,
|
required VoidCallback onTap,
|
||||||
}) {
|
}) {
|
||||||
return OutlinedButton(
|
return TextButton(
|
||||||
key: key,
|
key: key,
|
||||||
onPressed: onTap,
|
onPressed: onTap,
|
||||||
style: OutlinedButton.styleFrom(
|
style: TextButton.styleFrom(
|
||||||
minimumSize: const Size(0, _buttonHeight),
|
minimumSize: const Size(0, _buttonHeight),
|
||||||
padding: const EdgeInsets.symmetric(horizontal: AppDimens.spaceMd),
|
padding: const EdgeInsets.symmetric(horizontal: AppDimens.spaceMd),
|
||||||
foregroundColor: AppColors.textPrimary,
|
backgroundColor: AppColors.brandRed,
|
||||||
side: const BorderSide(color: AppColors.mineOutline),
|
foregroundColor: AppColors.onPrimary,
|
||||||
shape: RoundedRectangleBorder(
|
shape: RoundedRectangleBorder(
|
||||||
borderRadius: BorderRadius.circular(_buttonRadius),
|
borderRadius: BorderRadius.circular(_buttonHeight / 2),
|
||||||
),
|
),
|
||||||
textStyle: const TextStyle(
|
textStyle: const TextStyle(
|
||||||
fontSize: AppDimens.body,
|
fontSize: AppDimens.body,
|
||||||
fontWeight: FontWeight.w500,
|
fontWeight: FontWeight.w400,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
child: Row(
|
child: Row(
|
||||||
|
|||||||
@@ -7,11 +7,9 @@ import '../../../core/theme/app_dimens.dart';
|
|||||||
import '../../../l10n/app_localizations.dart';
|
import '../../../l10n/app_localizations.dart';
|
||||||
import '../mine_types.dart';
|
import '../mine_types.dart';
|
||||||
|
|
||||||
const double _vipRadius = 12;
|
const double _vipRadius = 14;
|
||||||
const double _vipBadgeSize = 36;
|
|
||||||
const double _vipButtonHeight = 34;
|
|
||||||
|
|
||||||
/// 金色会员横幅。
|
/// 「我的」页金色 VIP 卡:品牌行 + 立即开通 + 2×2 权益宫格。
|
||||||
class MineVipBanner extends StatelessWidget {
|
class MineVipBanner extends StatelessWidget {
|
||||||
const MineVipBanner({super.key, required this.onOpen});
|
const MineVipBanner({super.key, required this.onOpen});
|
||||||
|
|
||||||
@@ -24,7 +22,9 @@ class MineVipBanner extends StatelessWidget {
|
|||||||
key: const Key('mine-vip'),
|
key: const Key('mine-vip'),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
gradient: const LinearGradient(
|
gradient: const LinearGradient(
|
||||||
colors: [AppColors.vipGoldStart, AppColors.vipGoldEnd],
|
begin: Alignment.topLeft,
|
||||||
|
end: Alignment.bottomRight,
|
||||||
|
colors: [AppColors.vipCardStart, AppColors.vipCardEnd],
|
||||||
),
|
),
|
||||||
borderRadius: BorderRadius.circular(_vipRadius),
|
borderRadius: BorderRadius.circular(_vipRadius),
|
||||||
),
|
),
|
||||||
@@ -35,69 +35,89 @@ class MineVipBanner extends StatelessWidget {
|
|||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: onOpen,
|
onTap: onOpen,
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.symmetric(
|
padding: const EdgeInsets.fromLTRB(
|
||||||
horizontal: AppDimens.cardPadding,
|
AppDimens.cardPadding,
|
||||||
vertical: AppDimens.spaceMd,
|
AppDimens.spaceSm + 2,
|
||||||
|
AppDimens.cardPadding,
|
||||||
|
AppDimens.spaceSm + 2,
|
||||||
),
|
),
|
||||||
child: Row(
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Container(
|
Row(
|
||||||
width: _vipBadgeSize,
|
children: [
|
||||||
height: _vipBadgeSize,
|
const Icon(
|
||||||
decoration: const BoxDecoration(
|
Icons.diamond_outlined,
|
||||||
color: AppColors.vipBadgeSurface,
|
color: AppColors.onGold,
|
||||||
shape: BoxShape.circle,
|
size: 24,
|
||||||
),
|
),
|
||||||
child: const Icon(
|
const SizedBox(width: AppDimens.spaceSm),
|
||||||
Icons.workspace_premium_rounded,
|
Expanded(
|
||||||
color: AppColors.onGold,
|
child: Text(
|
||||||
size: 22,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(width: AppDimens.spaceMd),
|
|
||||||
Expanded(
|
|
||||||
child: Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
l10n.vipBrandName,
|
l10n.vipBrandName,
|
||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
color: AppColors.onGold,
|
color: AppColors.onGold,
|
||||||
fontSize: AppDimens.sectionTitle,
|
fontSize: 18,
|
||||||
fontWeight: FontWeight.w700,
|
fontWeight: FontWeight.w400,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 2),
|
),
|
||||||
Text(
|
const SizedBox(width: AppDimens.spaceSm),
|
||||||
l10n.mineVipSubtitle,
|
_openButton(l10n),
|
||||||
maxLines: 1,
|
],
|
||||||
overflow: TextOverflow.ellipsis,
|
),
|
||||||
style: const TextStyle(
|
Transform.translate(
|
||||||
color: AppColors.onGold,
|
offset: const Offset(0, -7),
|
||||||
fontSize: AppDimens.caption,
|
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),
|
const SizedBox(height: AppDimens.mineVipBenefitRowGap),
|
||||||
TextButton(
|
Container(
|
||||||
key: const Key('mine-vip-open'),
|
height: 1,
|
||||||
onPressed: onOpen,
|
color: AppColors.onGold.withValues(alpha: 0.15),
|
||||||
style: TextButton.styleFrom(
|
),
|
||||||
minimumSize: const Size(0, _vipButtonHeight),
|
const SizedBox(height: AppDimens.mineVipBenefitRowGap),
|
||||||
padding: const EdgeInsets.symmetric(
|
Table(
|
||||||
horizontal: AppDimens.spaceMd,
|
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,
|
TableRow(
|
||||||
foregroundColor: AppColors.textPrimary,
|
children: [
|
||||||
shape: RoundedRectangleBorder(
|
_benefit(
|
||||||
borderRadius: BorderRadius.circular(_vipButtonHeight),
|
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 {
|
class MineQuickActions extends StatelessWidget {
|
||||||
const MineMenuList({
|
const MineQuickActions({
|
||||||
super.key,
|
super.key,
|
||||||
required this.onOpen,
|
required this.onWallet,
|
||||||
required this.onLanguage,
|
required this.onFavorites,
|
||||||
|
required this.onDownloads,
|
||||||
|
required this.onHistory,
|
||||||
});
|
});
|
||||||
|
|
||||||
final ValueChanged<MineDestination> onOpen;
|
final VoidCallback onWallet;
|
||||||
final VoidCallback onLanguage;
|
final VoidCallback onFavorites;
|
||||||
|
final VoidCallback onDownloads;
|
||||||
|
final VoidCallback onHistory;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final l10n = AppLocalizations.of(context)!;
|
final l10n = AppLocalizations.of(context)!;
|
||||||
return Container(
|
return Row(
|
||||||
key: const Key('mine-menu'),
|
children: [
|
||||||
decoration: BoxDecoration(
|
_action(
|
||||||
color: AppColors.mineGridSurface,
|
key: const Key('mine-wallet'),
|
||||||
borderRadius: BorderRadius.circular(AppDimens.mineGridRadius),
|
icon: Icons.wallet_outlined,
|
||||||
),
|
label: l10n.wallet,
|
||||||
child: Material(
|
onTap: onWallet,
|
||||||
color: AppColors.transparent,
|
),
|
||||||
borderRadius: BorderRadius.circular(AppDimens.mineGridRadius),
|
_action(
|
||||||
clipBehavior: Clip.antiAlias,
|
key: const Key('mine-favorites'),
|
||||||
child: Table(
|
icon: Icons.star_border_rounded,
|
||||||
key: const Key('mine-menu-grid'),
|
label: l10n.myFavorites,
|
||||||
defaultColumnWidth: const FlexColumnWidth(),
|
onTap: onFavorites,
|
||||||
defaultVerticalAlignment: TableCellVerticalAlignment.middle,
|
),
|
||||||
border: const TableBorder(
|
_action(
|
||||||
horizontalInside: BorderSide(
|
key: const Key('mine-downloads'),
|
||||||
color: AppColors.mineGridDivider,
|
icon: Icons.download_outlined,
|
||||||
width: AppDimens.mineGridDividerWidth,
|
label: l10n.offlineDownloads,
|
||||||
),
|
onTap: onDownloads,
|
||||||
verticalInside: BorderSide(
|
),
|
||||||
color: AppColors.mineGridDivider,
|
_action(
|
||||||
width: AppDimens.mineGridDividerWidth,
|
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: [
|
children: [
|
||||||
TableRow(
|
Icon(icon, color: AppColors.textPrimary, size: AppDimens.mineServiceIcon),
|
||||||
children: [
|
const SizedBox(width: AppDimens.spaceMd),
|
||||||
_cell(
|
Expanded(
|
||||||
index: 0,
|
child: Text(
|
||||||
actionKey: const Key('mine-wallet'),
|
label,
|
||||||
icon: Icons.account_balance_wallet_outlined,
|
maxLines: 1,
|
||||||
iconColor: AppColors.mineIconWallet,
|
overflow: TextOverflow.ellipsis,
|
||||||
label: l10n.wallet,
|
style: const TextStyle(
|
||||||
onTap: () => onOpen(MineDestination.wallet),
|
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(
|
if (value != null && value.isNotEmpty) ...[
|
||||||
children: [
|
const SizedBox(width: AppDimens.spaceSm),
|
||||||
_cell(
|
Text(
|
||||||
index: 4,
|
value,
|
||||||
actionKey: const Key('mine-help'),
|
style: const TextStyle(
|
||||||
icon: Icons.support_agent_rounded,
|
color: AppColors.textTertiary,
|
||||||
iconColor: AppColors.mineIconSupport,
|
fontSize: AppDimens.mineServiceValueFont,
|
||||||
label: l10n.contactSupport,
|
|
||||||
onTap: () => onOpen(MineDestination.help),
|
|
||||||
),
|
),
|
||||||
_cell(
|
),
|
||||||
index: 5,
|
],
|
||||||
actionKey: const Key('mine-language'),
|
const SizedBox(width: AppDimens.spaceXs),
|
||||||
icon: Icons.language_rounded,
|
const Icon(
|
||||||
iconColor: AppColors.mineIconLanguage,
|
Icons.chevron_right_rounded,
|
||||||
label: l10n.language,
|
color: AppColors.textSecondary,
|
||||||
onTap: onLanguage,
|
size: 22,
|
||||||
),
|
|
||||||
_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),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
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,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -10,7 +10,6 @@ import '../../core/data/models/drama.dart';
|
|||||||
import '../../core/data/services/catalog_controller.dart';
|
import '../../core/data/services/catalog_controller.dart';
|
||||||
import '../../core/formatting/count_format.dart';
|
import '../../core/formatting/count_format.dart';
|
||||||
import '../../core/theme/app_colors.dart';
|
import '../../core/theme/app_colors.dart';
|
||||||
import '../../core/theme/app_theme.dart';
|
|
||||||
import '../../core/widgets/app_pull_to_refresh.dart';
|
import '../../core/widgets/app_pull_to_refresh.dart';
|
||||||
import '../../core/widgets/paged_local_list.dart';
|
import '../../core/widgets/paged_local_list.dart';
|
||||||
import '../../core/widgets/remote_image.dart';
|
import '../../core/widgets/remote_image.dart';
|
||||||
@@ -108,7 +107,18 @@ class _NewReleasesPageState extends State<NewReleasesPage> {
|
|||||||
key: const Key('new-releases-page'),
|
key: const Key('new-releases-page'),
|
||||||
backgroundColor: AppColors.ink,
|
backgroundColor: AppColors.ink,
|
||||||
body: DecoratedBox(
|
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: SafeArea(
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
@@ -432,7 +442,7 @@ class _NewReleasesPageState extends State<NewReleasesPage> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 6),
|
const SizedBox(height: 4),
|
||||||
Text(
|
Text(
|
||||||
drama.title,
|
drama.title,
|
||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import '../../core/formatting/localized_date_time.dart';
|
|||||||
import '../../core/theme/app_colors.dart';
|
import '../../core/theme/app_colors.dart';
|
||||||
import '../../core/theme/app_dimens.dart';
|
import '../../core/theme/app_dimens.dart';
|
||||||
import '../../core/theme/app_theme.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/app_pull_to_refresh.dart';
|
||||||
import '../../core/widgets/empty_state.dart';
|
import '../../core/widgets/empty_state.dart';
|
||||||
import '../../core/widgets/plain_page_scaffold.dart';
|
import '../../core/widgets/plain_page_scaffold.dart';
|
||||||
@@ -191,9 +192,9 @@ class _NoticesPageState extends State<NoticesPage> {
|
|||||||
: formatLocalizedDateTime(context, notice.publishAt!);
|
: formatLocalizedDateTime(context, notice.publishAt!);
|
||||||
return showDialog<void>(
|
return showDialog<void>(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (dialogContext) => AlertDialog(
|
builder: (dialogContext) => AppGlowDialog(
|
||||||
title: Text(notice.title),
|
title: notice.title,
|
||||||
content: SizedBox(
|
contentChild: SizedBox(
|
||||||
width: double.maxFinite,
|
width: double.maxFinite,
|
||||||
child: SingleChildScrollView(
|
child: SingleChildScrollView(
|
||||||
child: Column(
|
child: Column(
|
||||||
|
|||||||
@@ -1,24 +1,14 @@
|
|||||||
// Author: fruit.com.cn
|
// Author: fruit.com.cn
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:provider/provider.dart';
|
|
||||||
|
|
||||||
import '../../core/data/models/drama.dart';
|
import '../../core/data/models/drama.dart';
|
||||||
import '../../core/data/services/auth_controller.dart';
|
|
||||||
import '../../core/widgets/auth_gate.dart';
|
|
||||||
|
|
||||||
/// 评论入口统一登录闸:登录成功且页面仍存在时再打开评论面板。
|
/// 评论列表与非付费互动均支持设备身份,不再把登录作为入口前置条件。
|
||||||
Future<void> openCommentsWithAuth(
|
Future<void> openComments(
|
||||||
BuildContext context,
|
BuildContext context,
|
||||||
Drama drama, {
|
Drama drama, {
|
||||||
required Future<void> Function(BuildContext context, Drama drama) show,
|
required Future<void> Function(BuildContext context, Drama drama) show,
|
||||||
}) async {
|
}) async {
|
||||||
final auth = context.read<AuthController>();
|
|
||||||
if (auth.isSignedIn) {
|
|
||||||
await show(context, drama);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
await ensureSignedIn(context);
|
|
||||||
if (!context.mounted || !auth.isSignedIn) return;
|
|
||||||
await show(context, drama);
|
await show(context, drama);
|
||||||
}
|
}
|
||||||
@@ -15,6 +15,7 @@ class PlayerBinding {
|
|||||||
required PlaybackPositionCache positionCache,
|
required PlaybackPositionCache positionCache,
|
||||||
WalletController? wallet,
|
WalletController? wallet,
|
||||||
DownloadController? downloads,
|
DownloadController? downloads,
|
||||||
|
bool Function()? isSignedIn,
|
||||||
}) => PlayerLogic(
|
}) => PlayerLogic(
|
||||||
history: history,
|
history: history,
|
||||||
playback: playback,
|
playback: playback,
|
||||||
@@ -22,5 +23,6 @@ class PlayerBinding {
|
|||||||
pictureInPicture: AndroidPictureInPicture(),
|
pictureInPicture: AndroidPictureInPicture(),
|
||||||
wallet: wallet,
|
wallet: wallet,
|
||||||
downloads: downloads,
|
downloads: downloads,
|
||||||
|
isSignedIn: isSignedIn,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -1,13 +1,19 @@
|
|||||||
// Author: fruit.com.cn
|
// Author: fruit.com.cn
|
||||||
|
|
||||||
import 'dart:async';
|
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:flutter/material.dart';
|
||||||
import 'package:video_player/video_player.dart';
|
import 'package:video_player/video_player.dart';
|
||||||
import 'package:flutter/scheduler.dart';
|
import 'package:flutter/scheduler.dart';
|
||||||
import 'package:provider/provider.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/drama.dart';
|
||||||
|
import '../../core/data/models/episode_stats.dart';
|
||||||
import '../../core/data/models/play_ticket.dart';
|
import '../../core/data/models/play_ticket.dart';
|
||||||
import '../../core/data/models/watch_progress.dart';
|
import '../../core/data/models/watch_progress.dart';
|
||||||
import '../../core/data/models/player_port.dart';
|
import '../../core/data/models/player_port.dart';
|
||||||
@@ -42,6 +48,16 @@ typedef _PlaybackSnapshot = ({
|
|||||||
});
|
});
|
||||||
|
|
||||||
class PlayerLogic extends ChangeNotifier {
|
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({
|
PlayerLogic({
|
||||||
required this.history,
|
required this.history,
|
||||||
required this.playback,
|
required this.playback,
|
||||||
@@ -50,9 +66,13 @@ class PlayerLogic extends ChangeNotifier {
|
|||||||
this.downloads,
|
this.downloads,
|
||||||
PlaybackPositionCache? positionCache,
|
PlaybackPositionCache? positionCache,
|
||||||
Future<void> Function()? waitForFrame,
|
Future<void> Function()? waitForFrame,
|
||||||
|
DateTime Function()? clock,
|
||||||
|
bool Function()? isSignedIn,
|
||||||
}) : positionCache = positionCache ?? PlaybackPositionCache(),
|
}) : positionCache = positionCache ?? PlaybackPositionCache(),
|
||||||
_waitForFrame =
|
_waitForFrame =
|
||||||
waitForFrame ?? (() => WidgetsBinding.instance.endOfFrame);
|
waitForFrame ?? (() => WidgetsBinding.instance.endOfFrame),
|
||||||
|
_clock = clock ?? DateTime.now,
|
||||||
|
_isSignedIn = isSignedIn ?? (() => true);
|
||||||
|
|
||||||
final WatchHistoryRepository history;
|
final WatchHistoryRepository history;
|
||||||
final PlaybackRepository playback;
|
final PlaybackRepository playback;
|
||||||
@@ -61,6 +81,8 @@ class PlayerLogic extends ChangeNotifier {
|
|||||||
final DownloadController? downloads;
|
final DownloadController? downloads;
|
||||||
final PlaybackPositionCache positionCache;
|
final PlaybackPositionCache positionCache;
|
||||||
final Future<void> Function() _waitForFrame;
|
final Future<void> Function() _waitForFrame;
|
||||||
|
final DateTime Function() _clock;
|
||||||
|
final bool Function() _isSignedIn;
|
||||||
|
|
||||||
late PageController pages;
|
late PageController pages;
|
||||||
late PlaybackQueue queue;
|
late PlaybackQueue queue;
|
||||||
@@ -93,13 +115,71 @@ class PlayerLogic extends ChangeNotifier {
|
|||||||
String selectedQuality = 'AUTO';
|
String selectedQuality = 'AUTO';
|
||||||
Duration? _qualitySeek;
|
Duration? _qualitySeek;
|
||||||
int pageRequest = 0;
|
int pageRequest = 0;
|
||||||
|
int? _pendingSelectionIndex;
|
||||||
|
int? _pendingSelectionRevision;
|
||||||
|
Future<void>? _selectionDrain;
|
||||||
bool muted = false;
|
bool muted = false;
|
||||||
double playbackSpeed = 1.0;
|
double playbackSpeed = 1.0;
|
||||||
bool stoppedAtFeedEnd = false;
|
bool stoppedAtFeedEnd = false;
|
||||||
|
Duration episodeStatsTtl = const Duration(seconds: 60);
|
||||||
|
ValueChanged<EpisodeStats>? onEpisodeStatsUpdated;
|
||||||
VideoPlayerPort? scrubbingPlayer;
|
VideoPlayerPort? scrubbingPlayer;
|
||||||
bool pip = false;
|
bool pip = false;
|
||||||
bool pipPreparing = 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>{};
|
||||||
|
static final Map<String, int> pickedEpisode = {};
|
||||||
|
final Set<String> _unlockedEpisodeIds = {};
|
||||||
|
final Map<String, EpisodeStats> _episodeStats = {};
|
||||||
|
final Map<String, DateTime> _episodeStatsFetchedAt = {};
|
||||||
|
final Map<String, Future<void>> _episodeStatsInFlight = {};
|
||||||
|
final Map<String, int> _episodeStatsRevision = {};
|
||||||
|
final Map<String, int> _dramaStatsRevision = {};
|
||||||
|
|
||||||
/// 解锁中的集 id 与失败文案;空表示没有进行中的解锁。
|
/// 解锁中的集 id 与失败文案;空表示没有进行中的解锁。
|
||||||
String? unlockingEpisodeId;
|
String? unlockingEpisodeId;
|
||||||
@@ -163,6 +243,8 @@ class PlayerLogic extends ChangeNotifier {
|
|||||||
return fallback;
|
return fallback;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EpisodeStats? episodeStats(String episodeId) => _episodeStats[episodeId];
|
||||||
|
|
||||||
void notify() {
|
void notify() {
|
||||||
if (!_disposed) notifyListeners();
|
if (!_disposed) notifyListeners();
|
||||||
}
|
}
|
||||||
@@ -188,11 +270,15 @@ class PlayerLogic extends ChangeNotifier {
|
|||||||
void start({
|
void start({
|
||||||
required PlayerFactory factory,
|
required PlayerFactory factory,
|
||||||
required PlaybackCoordinator coordinator,
|
required PlaybackCoordinator coordinator,
|
||||||
|
bool initialUserWantsPlay = true,
|
||||||
}) {
|
}) {
|
||||||
_started = true;
|
_started = true;
|
||||||
_sessionFactory = factory;
|
_sessionFactory = factory;
|
||||||
_sessionCoordinator = coordinator;
|
_sessionCoordinator = coordinator;
|
||||||
pictureInPicture.setStateListener(onPipChanged);
|
_pipSubscribers.add(this);
|
||||||
|
pictureInPicture.setStateListener(_dispatchPipChanged);
|
||||||
|
pictureInPicture.setPlaybackEndedListener(_dispatchPipPlaybackEnded);
|
||||||
|
unawaited(_loadIosAutoPipPref());
|
||||||
queue = feedDramas == null
|
queue = feedDramas == null
|
||||||
? PlaybackQueue.series(pageDrama)
|
? PlaybackQueue.series(pageDrama)
|
||||||
: PlaybackQueue.home(feedDramas!);
|
: PlaybackQueue.home(feedDramas!);
|
||||||
@@ -205,7 +291,48 @@ class PlayerLogic extends ChangeNotifier {
|
|||||||
session.setRouteVisible(false);
|
session.setRouteVisible(false);
|
||||||
}
|
}
|
||||||
unawaited(loadResumePoint());
|
unawaited(loadResumePoint());
|
||||||
unawaited(selectEpisode(initialIndex));
|
unawaited(
|
||||||
|
selectEpisode(
|
||||||
|
initialIndex,
|
||||||
|
userWantsPlay: initialUserWantsPlay ? null : false,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 独立播放页覆盖首页时只暂停并保存进度,首页 session 与 controller 保持存活。
|
||||||
|
Future<void> pauseForFullPlayer() async {
|
||||||
|
if (!_started) return;
|
||||||
|
_logFeedHandoff('pause');
|
||||||
|
cancelScrub();
|
||||||
|
await session.pauseForRouteHandoff();
|
||||||
|
_logFeedHandoff('paused');
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 独立播放页关闭并恢复首页路由后,等原生播放器实际恢复再结束交接。
|
||||||
|
Future<void> resumeAfterFullPlayer() async {
|
||||||
|
if (!_started) return;
|
||||||
|
_logFeedHandoff('resume');
|
||||||
|
if (visibleIndices.isNotEmpty) {
|
||||||
|
await session.resumeForRouteHandoff();
|
||||||
|
} else {
|
||||||
|
session.setRouteVisible(false);
|
||||||
|
await session.playbackSettled;
|
||||||
|
}
|
||||||
|
_logFeedHandoff('resumed');
|
||||||
|
}
|
||||||
|
|
||||||
|
void _logFeedHandoff(String phase) {
|
||||||
|
if (!kDebugMode) return;
|
||||||
|
final player = session.active;
|
||||||
|
final video = player is VideoPlayerPort ? player : null;
|
||||||
|
debugPrint(
|
||||||
|
'[feed-session] phase=$phase session=${identityHashCode(session)} '
|
||||||
|
'index=${session.currentIndex} episode=${session.currentEpisode.id} '
|
||||||
|
'controller=${video == null ? '-' : identityHashCode(video.controller)} '
|
||||||
|
'user=${session.userWantsPlay} routeVisible=${session.debugRouteVisible} '
|
||||||
|
'appResumed=${session.debugAppResumed} overlayOpen=${session.debugOverlayOpen} '
|
||||||
|
'live=${session.livePlayerCount}',
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 串行替换首页 feed 队列;频道变化时重置到第 1 个,刷新时尽量保留当前剧。
|
/// 串行替换首页 feed 队列;频道变化时重置到第 1 个,刷新时尽量保留当前剧。
|
||||||
@@ -238,11 +365,16 @@ class PlayerLogic extends ChangeNotifier {
|
|||||||
episodes: sessionEpisodes,
|
episodes: sessionEpisodes,
|
||||||
factory: factory,
|
factory: factory,
|
||||||
// 地址只由后端下发(票据或详情里的免费集签名地址),拿不到地址即视为锁定
|
// 地址只由后端下发(票据或详情里的免费集签名地址),拿不到地址即视为锁定
|
||||||
canPlay: (episode) => episode.videoUrl.isNotEmpty,
|
canPlay: (episode) =>
|
||||||
|
episode.videoUrl.isNotEmpty && !isEpisodeLocked(episode),
|
||||||
prepare: preparePlayer,
|
prepare: preparePlayer,
|
||||||
activate: activatePlayer,
|
activate: activatePlayer,
|
||||||
coordinator: coordinator,
|
coordinator: coordinator,
|
||||||
waitForFrame: _waitForFrame,
|
waitForFrame: _waitForFrame,
|
||||||
|
owner: homeMode ? PlaybackSessionOwner.home : PlaybackSessionOwner.player,
|
||||||
|
dramaIdAt: (index) => index >= 0 && index < queue.length
|
||||||
|
? queue.entryAt(index).drama.id
|
||||||
|
: null,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -428,6 +560,7 @@ class PlayerLogic extends ChangeNotifier {
|
|||||||
final localPath = await downloads?.findLocalPath(episode.id);
|
final localPath = await downloads?.findLocalPath(episode.id);
|
||||||
if (request != pageRequest) return false;
|
if (request != pageRequest) return false;
|
||||||
if (localPath != null) {
|
if (localPath != null) {
|
||||||
|
_unlockedEpisodeIds.add(episode.id);
|
||||||
blockedTicket = null;
|
blockedTicket = null;
|
||||||
blockedEpisodeId = null;
|
blockedEpisodeId = null;
|
||||||
qualities = const [];
|
qualities = const [];
|
||||||
@@ -452,12 +585,14 @@ class PlayerLogic extends ChangeNotifier {
|
|||||||
final playUrl = preferred ?? ticket.playUrl;
|
final playUrl = preferred ?? ticket.playUrl;
|
||||||
if (preferred == null) selectedQuality = 'AUTO';
|
if (preferred == null) selectedQuality = 'AUTO';
|
||||||
if (ticket.accessible && playUrl.isNotEmpty) {
|
if (ticket.accessible && playUrl.isNotEmpty) {
|
||||||
|
_unlockedEpisodeIds.add(episode.id);
|
||||||
// 签名地址原样写回,不做任何拼接/改写(AppConfig.mediaUrl 只补 host)
|
// 签名地址原样写回,不做任何拼接/改写(AppConfig.mediaUrl 只补 host)
|
||||||
sessionEpisodes[index] = episode.withVideoUrl(
|
sessionEpisodes[index] = episode.withVideoUrl(
|
||||||
playUrl,
|
playUrl,
|
||||||
likeCount: ticket.likeCount,
|
likeCount: ticket.likeCount,
|
||||||
commentCount: ticket.commentCount,
|
commentCount: ticket.commentCount,
|
||||||
thumbnailsUrl: ticket.thumbnailsUrl,
|
thumbnailsUrl: ticket.thumbnailsUrl,
|
||||||
|
posterUrl: ticket.posterUrl,
|
||||||
);
|
);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -467,7 +602,7 @@ class PlayerLogic extends ChangeNotifier {
|
|||||||
} catch (exception) {
|
} catch (exception) {
|
||||||
if (request != pageRequest) return false;
|
if (request != pageRequest) return false;
|
||||||
// 详情里已有可用地址(免费集)时降级继续,避免票据服务抖动就完全看不了
|
// 详情里已有可用地址(免费集)时降级继续,避免票据服务抖动就完全看不了
|
||||||
if (episode.videoUrl.isNotEmpty) {
|
if (episode.videoUrl.isNotEmpty && !isEpisodeLocked(episode)) {
|
||||||
ticketError = null;
|
ticketError = null;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -481,6 +616,160 @@ class PlayerLogic extends ChangeNotifier {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// 当前集激活后刷新轻量互动计数;同集命中 TTL 或已有请求时不重复发请求。
|
||||||
|
Future<void> refreshEpisodeStats(int index) {
|
||||||
|
if (_disposed || index < 0 || index >= sessionEpisodes.length) {
|
||||||
|
return Future<void>.value();
|
||||||
|
}
|
||||||
|
final episodeId = sessionEpisodes[index].id;
|
||||||
|
final cached = _episodeStats[episodeId];
|
||||||
|
final fetchedAt = _episodeStatsFetchedAt[episodeId];
|
||||||
|
if (cached != null &&
|
||||||
|
fetchedAt != null &&
|
||||||
|
_clock().difference(fetchedAt) < episodeStatsTtl) {
|
||||||
|
_logEpisodeStatsRefresh(episodeId, cached: true);
|
||||||
|
onEpisodeStatsUpdated?.call(cached);
|
||||||
|
return Future<void>.value();
|
||||||
|
}
|
||||||
|
final inFlight = _episodeStatsInFlight[episodeId];
|
||||||
|
if (inFlight != null) {
|
||||||
|
_logEpisodeStatsRefresh(episodeId, cached: true, inFlight: true);
|
||||||
|
return inFlight;
|
||||||
|
}
|
||||||
|
_logEpisodeStatsRefresh(episodeId, cached: false);
|
||||||
|
final expectedDramaId = index < queue.length
|
||||||
|
? queue.entryAt(index).drama.id
|
||||||
|
: '';
|
||||||
|
final episodeRevision = _episodeStatsRevision[episodeId] ?? 0;
|
||||||
|
final dramaRevision = _dramaStatsRevision[expectedDramaId] ?? 0;
|
||||||
|
late final Future<void> request;
|
||||||
|
request =
|
||||||
|
_fetchEpisodeStats(
|
||||||
|
episodeId,
|
||||||
|
expectedDramaId: expectedDramaId,
|
||||||
|
episodeRevision: episodeRevision,
|
||||||
|
dramaRevision: dramaRevision,
|
||||||
|
).whenComplete(() {
|
||||||
|
if (identical(_episodeStatsInFlight[episodeId], request)) {
|
||||||
|
_episodeStatsInFlight.remove(episodeId);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
_episodeStatsInFlight[episodeId] = request;
|
||||||
|
return request;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _fetchEpisodeStats(
|
||||||
|
String episodeId, {
|
||||||
|
required String expectedDramaId,
|
||||||
|
required int episodeRevision,
|
||||||
|
required int dramaRevision,
|
||||||
|
}) async {
|
||||||
|
try {
|
||||||
|
final fetched = await playback.episodeStats(episodeId);
|
||||||
|
if (_disposed) return;
|
||||||
|
if ((_episodeStatsRevision[episodeId] ?? 0) != episodeRevision ||
|
||||||
|
(_dramaStatsRevision[expectedDramaId] ?? 0) != dramaRevision) {
|
||||||
|
if (kDebugMode) {
|
||||||
|
debugPrint(
|
||||||
|
'[player] phase=episode-stats-discarded episodeId=$episodeId '
|
||||||
|
'reason=local-state-newer',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final stats = fetched.copyWith(
|
||||||
|
dramaId: fetched.dramaId.isEmpty ? expectedDramaId : fetched.dramaId,
|
||||||
|
);
|
||||||
|
_episodeStats[episodeId] = stats;
|
||||||
|
_episodeStatsFetchedAt[episodeId] = _clock();
|
||||||
|
final episodeIndex = sessionEpisodes.indexWhere(
|
||||||
|
(episode) => episode.id == episodeId,
|
||||||
|
);
|
||||||
|
if (episodeIndex >= 0) {
|
||||||
|
sessionEpisodes[episodeIndex] = sessionEpisodes[episodeIndex].withStats(
|
||||||
|
likeCount: stats.likeCount,
|
||||||
|
commentCount: stats.commentCount,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
onEpisodeStatsUpdated?.call(stats);
|
||||||
|
notify();
|
||||||
|
} catch (_) {
|
||||||
|
// 统计接口只负责校准计数,失败时保留播放与旧值。
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void _logEpisodeStatsRefresh(
|
||||||
|
String episodeId, {
|
||||||
|
required bool cached,
|
||||||
|
bool inFlight = false,
|
||||||
|
}) {
|
||||||
|
if (!kDebugMode) return;
|
||||||
|
debugPrint(
|
||||||
|
'[player] phase=episode-stats-refresh episodeId=$episodeId '
|
||||||
|
'cached=${cached ? 1 : 0}${inFlight ? ' inFlight=1' : ''}',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 点赞成功后同步本地统计快照,避免切回时被旧缓存覆盖。
|
||||||
|
void applyEpisodeLikeState(
|
||||||
|
String episodeId, {
|
||||||
|
required bool liked,
|
||||||
|
required int likeCount,
|
||||||
|
}) {
|
||||||
|
_episodeStatsRevision.update(
|
||||||
|
episodeId,
|
||||||
|
(value) => value + 1,
|
||||||
|
ifAbsent: () => 1,
|
||||||
|
);
|
||||||
|
final stats = _episodeStats[episodeId];
|
||||||
|
if (stats != null) {
|
||||||
|
_episodeStats[episodeId] = stats.copyWith(
|
||||||
|
liked: liked,
|
||||||
|
likeCount: likeCount,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
final index = sessionEpisodes.indexWhere(
|
||||||
|
(episode) => episode.id == episodeId,
|
||||||
|
);
|
||||||
|
if (index >= 0) {
|
||||||
|
sessionEpisodes[index] = sessionEpisodes[index].withStats(
|
||||||
|
likeCount: likeCount,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
notify();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 评论面板关闭后同步评论数。
|
||||||
|
void applyEpisodeCommentCount(String episodeId, int commentCount) {
|
||||||
|
_episodeStatsRevision.update(
|
||||||
|
episodeId,
|
||||||
|
(value) => value + 1,
|
||||||
|
ifAbsent: () => 1,
|
||||||
|
);
|
||||||
|
final stats = _episodeStats[episodeId];
|
||||||
|
if (stats != null) {
|
||||||
|
_episodeStats[episodeId] = stats.copyWith(commentCount: commentCount);
|
||||||
|
}
|
||||||
|
final index = sessionEpisodes.indexWhere(
|
||||||
|
(episode) => episode.id == episodeId,
|
||||||
|
);
|
||||||
|
if (index >= 0) {
|
||||||
|
sessionEpisodes[index] = sessionEpisodes[index].withStats(
|
||||||
|
commentCount: commentCount,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
notify();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 收藏成功后让旧 stats 请求失效,计数本身只写 FavoriteController。
|
||||||
|
void markDramaFavoriteChanged(String dramaId) {
|
||||||
|
_dramaStatsRevision.update(
|
||||||
|
dramaId,
|
||||||
|
(value) => value + 1,
|
||||||
|
ifAbsent: () => 1,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
String _fileUrl(String path) =>
|
String _fileUrl(String path) =>
|
||||||
path.startsWith('file:') ? path : Uri.file(path).toString();
|
path.startsWith('file:') ? path : Uri.file(path).toString();
|
||||||
|
|
||||||
@@ -553,7 +842,10 @@ class PlayerLogic extends ChangeNotifier {
|
|||||||
/// 金币解锁当前集;成功后强制刷新票据并直接起播。
|
/// 金币解锁当前集;成功后强制刷新票据并直接起播。
|
||||||
Future<bool> unlockEpisode(int index) async {
|
Future<bool> unlockEpisode(int index) async {
|
||||||
final service = wallet;
|
final service = wallet;
|
||||||
if (service == null || index < 0 || index >= sessionEpisodes.length) {
|
if (service == null ||
|
||||||
|
!_isSignedIn() ||
|
||||||
|
index < 0 ||
|
||||||
|
index >= sessionEpisodes.length) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final episode = sessionEpisodes[index];
|
final episode = sessionEpisodes[index];
|
||||||
@@ -566,6 +858,7 @@ class PlayerLogic extends ChangeNotifier {
|
|||||||
unlockError = service.unlockError;
|
unlockError = service.unlockError;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
_unlockedEpisodeIds.add(episode.id);
|
||||||
final ready = await ensureTicket(index, forceRefresh: true);
|
final ready = await ensureTicket(index, forceRefresh: true);
|
||||||
if (ready) {
|
if (ready) {
|
||||||
await _selectVisible(index);
|
await _selectVisible(index);
|
||||||
@@ -621,6 +914,11 @@ class PlayerLogic extends ChangeNotifier {
|
|||||||
if (pip || pipPreparing) {
|
if (pip || pipPreparing) {
|
||||||
pip = false;
|
pip = false;
|
||||||
pipPreparing = false;
|
pipPreparing = false;
|
||||||
|
if (iosDevice) {
|
||||||
|
// 部分回前台路径不回调 didStop:销毁影子、seek 刷纹理并恢复播放,
|
||||||
|
// 否则停在 PiP 期间的暂停态表现为黑屏;自动小窗开着则重建待命。
|
||||||
|
unawaited(_recoverFromIosPipFallback());
|
||||||
|
}
|
||||||
notify();
|
notify();
|
||||||
notifyImmersive();
|
notifyImmersive();
|
||||||
}
|
}
|
||||||
@@ -644,6 +942,33 @@ class PlayerLogic extends ChangeNotifier {
|
|||||||
state == AppLifecycleState.resumed || pip || pipPreparing,
|
state == AppLifecycleState.resumed || pip || pipPreparing,
|
||||||
);
|
);
|
||||||
if (state != AppLifecycleState.resumed) cancelScrub();
|
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(
|
Future<void> _refreshTicketThenResume(
|
||||||
@@ -675,7 +1000,13 @@ class PlayerLogic extends ChangeNotifier {
|
|||||||
void dispose() {
|
void dispose() {
|
||||||
if (_disposed) return;
|
if (_disposed) return;
|
||||||
_disposed = true;
|
_disposed = true;
|
||||||
pictureInPicture.setStateListener(null);
|
_pipSubscribers.remove(this);
|
||||||
|
_pipStartTimer?.cancel();
|
||||||
|
if (_pipSubscribers.isEmpty) {
|
||||||
|
pictureInPicture.setStateListener(null);
|
||||||
|
pictureInPicture.setPlaybackEndedListener(null);
|
||||||
|
}
|
||||||
|
unawaited(syncPipAutoArm(false));
|
||||||
unawaited(saveCurrentProgress());
|
unawaited(saveCurrentProgress());
|
||||||
_detachTrackedPlayerListener();
|
_detachTrackedPlayerListener();
|
||||||
if (_started) {
|
if (_started) {
|
||||||
@@ -689,31 +1020,117 @@ class PlayerLogic extends ChangeNotifier {
|
|||||||
|
|
||||||
void notifyImmersive() => onImmersiveChanged?.call(chromeHidden);
|
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 {
|
Future<void> enterPip(BuildContext context) async {
|
||||||
if (pip || pipPreparing) return;
|
if (pip || pipPreparing) {
|
||||||
if (session.active is! VideoPlayerPort) {
|
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(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
SnackBar(content: Text(AppLocalizations.of(context)!.pipUnavailable)),
|
SnackBar(content: Text(AppLocalizations.of(context)!.pipUnavailable)),
|
||||||
);
|
);
|
||||||
return;
|
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;
|
pipPreparing = true;
|
||||||
notify();
|
notify();
|
||||||
notifyImmersive();
|
notifyImmersive();
|
||||||
await WidgetsBinding.instance.endOfFrame;
|
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;
|
bool entered = false;
|
||||||
try {
|
try {
|
||||||
entered = await pictureInPicture.enter();
|
entered = await pictureInPicture.enter(url: url, positionMs: positionMs);
|
||||||
} catch (_) {
|
} catch (e) {
|
||||||
|
debugPrint('pip: enter threw $e');
|
||||||
// Android reports unavailable for devices without PiP support.
|
// Android reports unavailable for devices without PiP support.
|
||||||
}
|
}
|
||||||
|
debugPrint('pip: entered=$entered');
|
||||||
if (!context.mounted) return;
|
if (!context.mounted) return;
|
||||||
if (entered) {
|
if (entered) {
|
||||||
pip = true;
|
if (isIos) {
|
||||||
pipPreparing = false;
|
// iOS 等影子流就绪后自动进入小窗(原生 pendingStart 兜底不会过期);
|
||||||
notify();
|
// 超时仅复位按钮状态,避免长时间卡在「准备中」。
|
||||||
notifyImmersive();
|
_pipStartTimer?.cancel();
|
||||||
session.setAppResumed(true);
|
_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 {
|
} else {
|
||||||
pipPreparing = false;
|
pipPreparing = false;
|
||||||
notify();
|
notify();
|
||||||
@@ -724,10 +1141,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 (!isMounted()) return;
|
||||||
|
if (!kIsWeb && Platform.isIOS) {
|
||||||
|
_onIosPipChanged(enabled, finalPositionMs);
|
||||||
|
return;
|
||||||
|
}
|
||||||
pip = enabled;
|
pip = enabled;
|
||||||
pipPreparing = false;
|
pipPreparing = false;
|
||||||
|
_pipStartTimer?.cancel();
|
||||||
|
_pipStartTimer = null;
|
||||||
notify();
|
notify();
|
||||||
notifyImmersive();
|
notifyImmersive();
|
||||||
session.setAppResumed(
|
session.setAppResumed(
|
||||||
@@ -736,6 +1171,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 {
|
Future<void> preparePlayer(Episode episode, PlayerPort player) async {
|
||||||
if (player is! VideoPlayerPort) return;
|
if (player is! VideoPlayerPort) return;
|
||||||
try {
|
try {
|
||||||
@@ -791,6 +1314,121 @@ class PlayerLogic extends ChangeNotifier {
|
|||||||
_completionProgressSaved = false;
|
_completionProgressSaved = false;
|
||||||
lastProgressWrite = DateTime.now();
|
lastProgressWrite = DateTime.now();
|
||||||
player.controller.addListener(_handleTrackedPlayerChanged);
|
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() {
|
void _detachTrackedPlayerListener() {
|
||||||
@@ -951,7 +1589,43 @@ class PlayerLogic extends ChangeNotifier {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> selectEpisode(int index, {int? revision}) async {
|
/// 翻页入口使用 single-flight:执行中的切集不被重复排队,只保留最新目标。
|
||||||
|
Future<void> requestEpisodeSelection(int index, {int? revision}) {
|
||||||
|
if (_disposed || index < 0 || index >= sessionEpisodes.length) {
|
||||||
|
return Future<void>.value();
|
||||||
|
}
|
||||||
|
_pendingSelectionIndex = index;
|
||||||
|
_pendingSelectionRevision = revision;
|
||||||
|
return _selectionDrain ??= _drainEpisodeSelections();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _drainEpisodeSelections() async {
|
||||||
|
try {
|
||||||
|
while (!_disposed) {
|
||||||
|
final index = _pendingSelectionIndex;
|
||||||
|
if (index == null) break;
|
||||||
|
final revision = _pendingSelectionRevision;
|
||||||
|
_pendingSelectionIndex = null;
|
||||||
|
_pendingSelectionRevision = null;
|
||||||
|
await selectEpisode(index, revision: revision);
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
_selectionDrain = null;
|
||||||
|
final index = _pendingSelectionIndex;
|
||||||
|
if (!_disposed && index != null) {
|
||||||
|
unawaited(
|
||||||
|
requestEpisodeSelection(index, revision: _pendingSelectionRevision),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> selectEpisode(
|
||||||
|
int index, {
|
||||||
|
int? revision,
|
||||||
|
bool? userWantsPlay,
|
||||||
|
}) async {
|
||||||
|
if (index < 0 || index >= sessionEpisodes.length) return;
|
||||||
final feedRevisionAtStart = revision ?? feedRevision;
|
final feedRevisionAtStart = revision ?? feedRevision;
|
||||||
final request = ++pageRequest;
|
final request = ++pageRequest;
|
||||||
cancelScrub();
|
cancelScrub();
|
||||||
@@ -962,6 +1636,26 @@ class PlayerLogic extends ChangeNotifier {
|
|||||||
!isMounted()) {
|
!isMounted()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
final episode = sessionEpisodes[index];
|
||||||
|
if (isEpisodeLocked(episode)) {
|
||||||
|
blockedTicket = null;
|
||||||
|
blockedEpisodeId = episode.id;
|
||||||
|
ticketError = null;
|
||||||
|
await session.selectLocked(
|
||||||
|
index,
|
||||||
|
preloadIndex: nextVisibleIndex(index),
|
||||||
|
previousIndex: previousVisibleIndex(index),
|
||||||
|
);
|
||||||
|
if (request != pageRequest ||
|
||||||
|
feedRevisionAtStart != feedRevision ||
|
||||||
|
!isMounted()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!_isSignedIn()) {
|
||||||
|
unawaited(refreshEpisodeStats(index));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
// 起播前先要票据:拿不到就不起播,交给三态 UI 提示(失败可重试)
|
// 起播前先要票据:拿不到就不起播,交给三态 UI 提示(失败可重试)
|
||||||
final ready = await ensureTicket(index);
|
final ready = await ensureTicket(index);
|
||||||
if (request != pageRequest ||
|
if (request != pageRequest ||
|
||||||
@@ -969,17 +1663,30 @@ class PlayerLogic extends ChangeNotifier {
|
|||||||
!isMounted()) {
|
!isMounted()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!ready && ticketError != null) return;
|
if (!ready) {
|
||||||
await _selectVisible(index);
|
unawaited(refreshEpisodeStats(index));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
await _selectVisible(index, userWantsPlay: userWantsPlay);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 收费集只有在本会话确认可播或解锁成功后才解除门禁。
|
||||||
|
bool isEpisodeLocked(Episode episode) {
|
||||||
|
return (episode.locked || !episode.isFree) &&
|
||||||
|
!_unlockedEpisodeIds.contains(episode.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 按可见队列选择一集,并预热上一集与下一集。
|
/// 按可见队列选择一集,并预热上一集与下一集。
|
||||||
Future<void> _selectVisible(int index) {
|
Future<void> _selectVisible(int index, {bool? userWantsPlay}) async {
|
||||||
return session.select(
|
await session.select(
|
||||||
index,
|
index,
|
||||||
preloadIndex: nextVisibleIndex(index),
|
preloadIndex: nextVisibleIndex(index),
|
||||||
previousIndex: previousVisibleIndex(index),
|
previousIndex: previousVisibleIndex(index),
|
||||||
|
userWantsPlay: userWantsPlay,
|
||||||
);
|
);
|
||||||
|
if (!_disposed && session.currentIndex == index) {
|
||||||
|
unawaited(refreshEpisodeStats(index));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int? nextVisibleIndex(int index) {
|
int? nextVisibleIndex(int index) {
|
||||||
@@ -1113,12 +1820,10 @@ class PlayerLogic extends ChangeNotifier {
|
|||||||
Drama drama,
|
Drama drama,
|
||||||
int index,
|
int index,
|
||||||
) async {
|
) async {
|
||||||
session.setRouteVisible(false);
|
final route = Navigator.of(context).push(
|
||||||
await session.playbackSettled;
|
|
||||||
await saveCurrentProgress();
|
|
||||||
if (!context.mounted) return;
|
|
||||||
await Navigator.of(context).push(
|
|
||||||
FadePageRoute<void>(
|
FadePageRoute<void>(
|
||||||
|
transitionDuration: Duration.zero,
|
||||||
|
reverseTransitionDuration: Duration.zero,
|
||||||
builder: (_) => PlayerPage(
|
builder: (_) => PlayerPage(
|
||||||
drama: drama,
|
drama: drama,
|
||||||
initialIndex: index,
|
initialIndex: index,
|
||||||
@@ -1127,7 +1832,14 @@ class PlayerLogic extends ChangeNotifier {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
if (isMounted()) session.setRouteVisible(active);
|
if (kDebugMode) {
|
||||||
|
debugPrint('[player-entry] phase=route-pushed source=watch-all ms=0');
|
||||||
|
}
|
||||||
|
unawaited(pauseForFullPlayer());
|
||||||
|
unawaited(saveCurrentProgress());
|
||||||
|
await route;
|
||||||
|
if (!isMounted()) return;
|
||||||
|
await resumeAfterFullPlayer();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> showEpisodes(BuildContext context) async {
|
Future<void> showEpisodes(BuildContext context) async {
|
||||||
|
|||||||
+822
-153
File diff suppressed because it is too large.
Load diff
@@ -37,9 +37,14 @@ extension _PlayerViewActions on _PlayerPageState {
|
|||||||
onQualityChanged: (quality) => _switchQuality(context, l10n, quality),
|
onQualityChanged: (quality) => _switchQuality(context, l10n, quality),
|
||||||
onClear: _hideChrome,
|
onClear: _hideChrome,
|
||||||
onDownload: () => requestEpisodeDownload(context, episode.id),
|
onDownload: () => requestEpisodeDownload(context, episode.id),
|
||||||
onPip: logic.pictureInPicture.isPlatformSupported
|
// iOS 不显示手动「画中画」入口(走下方「退出后自动小窗」开关)。
|
||||||
|
onPip: logic.pictureInPicture.isPlatformSupported && !logic.iosDevice
|
||||||
? () => unawaited(logic.enterPip(context))
|
? () => unawaited(logic.enterPip(context))
|
||||||
: null,
|
: null,
|
||||||
|
autoPipEnabled: logic.iosAutoPipEnabled,
|
||||||
|
onAutoPipChanged: logic.iosDevice
|
||||||
|
? (value) => unawaited(logic.setIosAutoPip(value))
|
||||||
|
: null,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -65,6 +70,11 @@ extension _PlayerViewActions on _PlayerPageState {
|
|||||||
) async {
|
) async {
|
||||||
final wallet = logic.wallet;
|
final wallet = logic.wallet;
|
||||||
if (wallet == null) return;
|
if (wallet == null) return;
|
||||||
|
if (!context.read<AuthController>().isSignedIn &&
|
||||||
|
!await ensureSignedIn(context)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!context.mounted) return;
|
||||||
await showModalBottomSheet<bool>(
|
await showModalBottomSheet<bool>(
|
||||||
context: context,
|
context: context,
|
||||||
backgroundColor: AppColors.transparent,
|
backgroundColor: AppColors.transparent,
|
||||||
@@ -81,7 +91,7 @@ extension _PlayerViewActions on _PlayerPageState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<bool> _unlockEpisode(BuildContext context, int index) async {
|
Future<bool> _unlockEpisode(BuildContext context, int index) async {
|
||||||
if (!await ensureSignedIn(context) || !context.mounted) return false;
|
if (!context.read<AuthController>().isSignedIn) return false;
|
||||||
final ok = await logic.unlockEpisode(index);
|
final ok = await logic.unlockEpisode(index);
|
||||||
if (ok || !context.mounted) return ok;
|
if (ok || !context.mounted) return ok;
|
||||||
final l10n = AppLocalizations.of(context)!;
|
final l10n = AppLocalizations.of(context)!;
|
||||||
@@ -99,18 +109,53 @@ extension _PlayerViewActions on _PlayerPageState {
|
|||||||
Episode episode, {
|
Episode episode, {
|
||||||
bool likeOnly = false,
|
bool likeOnly = false,
|
||||||
}) async {
|
}) async {
|
||||||
unawaited(context.read<Haptics>().lightImpact());
|
final busyBefore = interactions.isEpisodeBusy(episode.id);
|
||||||
if (interactions.isEpisodeBusy(episode.id) ||
|
final likedBefore = interactions.isEpisodeLiked(episode.id);
|
||||||
(likeOnly && interactions.isEpisodeLiked(episode.id))) {
|
if (kDebugMode) {
|
||||||
return;
|
debugPrint(
|
||||||
|
'[player-like] phase=toggle-start '
|
||||||
|
'episodeId=${episode.id} likeOnly=$likeOnly '
|
||||||
|
'busy=$busyBefore liked=$likedBefore',
|
||||||
|
);
|
||||||
}
|
}
|
||||||
if (!await ensureSignedIn(context) || !context.mounted) return;
|
unawaited(context.read<Haptics>().lightImpact());
|
||||||
if (interactions.isEpisodeBusy(episode.id) ||
|
if (busyBefore || (likeOnly && likedBefore)) {
|
||||||
(likeOnly && interactions.isEpisodeLiked(episode.id))) {
|
if (kDebugMode) {
|
||||||
|
debugPrint(
|
||||||
|
'[player-like] phase=toggle-skipped '
|
||||||
|
'episodeId=${episode.id} '
|
||||||
|
'reason=${busyBefore ? 'busy' : 'already-liked'}',
|
||||||
|
);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final result = await interactions.toggleEpisodeLike(episode.id);
|
final result = await interactions.toggleEpisodeLike(episode.id);
|
||||||
if (result.isSuccess || !context.mounted) return;
|
if (kDebugMode) {
|
||||||
|
debugPrint(
|
||||||
|
'[player-like] phase=toggle-result '
|
||||||
|
'episodeId=${episode.id} success=${result.isSuccess} '
|
||||||
|
'liked=${interactions.isEpisodeLiked(episode.id)} '
|
||||||
|
'count=${interactions.episodeLikeCount(episode.id)} '
|
||||||
|
'error=${result.errorMessage ?? '-'}',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (result.isSuccess) {
|
||||||
|
final likeCount = interactions.episodeLikeCount(episode.id);
|
||||||
|
if (likeCount != null) {
|
||||||
|
logic.applyEpisodeLikeState(
|
||||||
|
episode.id,
|
||||||
|
liked: interactions.isEpisodeLiked(episode.id),
|
||||||
|
likeCount: likeCount,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
_refreshLikeState();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!context.mounted) return;
|
||||||
|
if (result.errorCode == 200007) {
|
||||||
|
await ensureSignedIn(context);
|
||||||
|
return;
|
||||||
|
}
|
||||||
showCenteredToast(
|
showCenteredToast(
|
||||||
context,
|
context,
|
||||||
result.errorMessage ?? AppLocalizations.of(context)!.likeFailed,
|
result.errorMessage ?? AppLocalizations.of(context)!.likeFailed,
|
||||||
@@ -119,7 +164,6 @@ extension _PlayerViewActions on _PlayerPageState {
|
|||||||
|
|
||||||
Future<void> _toggleSave(BuildContext context, Drama drama) async {
|
Future<void> _toggleSave(BuildContext context, Drama drama) async {
|
||||||
final favorites = context.read<FavoriteController>();
|
final favorites = context.read<FavoriteController>();
|
||||||
if (!await ensureSignedIn(context) || !context.mounted) return;
|
|
||||||
unawaited(context.read<Haptics>().lightImpact());
|
unawaited(context.read<Haptics>().lightImpact());
|
||||||
final wasSaved = favorites.isSaved(drama.id);
|
final wasSaved = favorites.isSaved(drama.id);
|
||||||
final ok = await favorites.toggle(drama.id, card: drama);
|
final ok = await favorites.toggle(drama.id, card: drama);
|
||||||
@@ -127,10 +171,14 @@ extension _PlayerViewActions on _PlayerPageState {
|
|||||||
if (ok) {
|
if (ok) {
|
||||||
final nowSaved = favorites.isSaved(drama.id);
|
final nowSaved = favorites.isSaved(drama.id);
|
||||||
if (nowSaved != wasSaved) {
|
if (nowSaved != wasSaved) {
|
||||||
_applyFavoriteDelta(drama.id, nowSaved: nowSaved);
|
logic.markDramaFavoriteChanged(drama.id);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (favorites.lastErrorCode == 200007) {
|
||||||
|
await ensureSignedIn(context);
|
||||||
|
return;
|
||||||
|
}
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
SnackBar(
|
SnackBar(
|
||||||
content: Text(AppLocalizations.of(context)!.favoriteToggleFailed),
|
content: Text(AppLocalizations.of(context)!.favoriteToggleFailed),
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import 'package:flutter/services.dart';
|
|||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
import '../../../core/data/models/comment.dart';
|
import '../../../core/data/models/comment.dart';
|
||||||
import '../../../core/data/services/auth_controller.dart';
|
|
||||||
import '../../../core/data/services/comment_controller.dart';
|
import '../../../core/data/services/comment_controller.dart';
|
||||||
import '../../../core/platform/haptics.dart';
|
import '../../../core/platform/haptics.dart';
|
||||||
import '../../../core/platform/keyboard_inset.dart';
|
import '../../../core/platform/keyboard_inset.dart';
|
||||||
@@ -196,23 +195,20 @@ class _CommentComposerSheetState extends State<CommentComposerSheet> {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final l10n = AppLocalizations.of(context)!;
|
final l10n = AppLocalizations.of(context)!;
|
||||||
|
if (result.errorCode == 200007) {
|
||||||
|
await ensureSignedIn(context);
|
||||||
|
return;
|
||||||
|
}
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
SnackBar(content: Text(result.errorMessage ?? l10n.commentPostFailed)),
|
SnackBar(content: Text(result.errorMessage ?? l10n.commentPostFailed)),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _authenticate() async {
|
|
||||||
await ensureSignedIn(context);
|
|
||||||
if (!mounted || !context.read<AuthController>().isSignedIn) return;
|
|
||||||
_inputFocus.requestFocus();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final l10n = AppLocalizations.of(context)!;
|
final l10n = AppLocalizations.of(context)!;
|
||||||
final signedIn = context.watch<AuthController>().isSignedIn;
|
|
||||||
final hasContent = _input.text.trim().isNotEmpty;
|
final hasContent = _input.text.trim().isNotEmpty;
|
||||||
final canPost = signedIn && hasContent && !widget.controller.submitting;
|
final canPost = hasContent && !widget.controller.submitting;
|
||||||
final multiline = _input.text.contains('\n');
|
final multiline = _input.text.contains('\n');
|
||||||
final bottomInset = _isAndroid
|
final bottomInset = _isAndroid
|
||||||
? _pinnedKeyboardInset
|
? _pinnedKeyboardInset
|
||||||
@@ -247,8 +243,8 @@ class _CommentComposerSheetState extends State<CommentComposerSheet> {
|
|||||||
key: const Key('comment-composer-input'),
|
key: const Key('comment-composer-input'),
|
||||||
controller: _input,
|
controller: _input,
|
||||||
focusNode: _inputFocus,
|
focusNode: _inputFocus,
|
||||||
readOnly: !signedIn,
|
readOnly: false,
|
||||||
canRequestFocus: signedIn,
|
canRequestFocus: true,
|
||||||
minLines: 1,
|
minLines: 1,
|
||||||
maxLines: 4,
|
maxLines: 4,
|
||||||
maxLength: _maxCommentLength,
|
maxLength: _maxCommentLength,
|
||||||
@@ -262,9 +258,7 @@ class _CommentComposerSheetState extends State<CommentComposerSheet> {
|
|||||||
),
|
),
|
||||||
cursorColor: AppColors.blue,
|
cursorColor: AppColors.blue,
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
hintText: signedIn
|
hintText: l10n.writeComment,
|
||||||
? l10n.writeComment
|
|
||||||
: l10n.commentLoginHint,
|
|
||||||
hintStyle: const TextStyle(
|
hintStyle: const TextStyle(
|
||||||
color: AppColors.muted,
|
color: AppColors.muted,
|
||||||
fontSize: 14,
|
fontSize: 14,
|
||||||
@@ -278,7 +272,7 @@ class _CommentComposerSheetState extends State<CommentComposerSheet> {
|
|||||||
enabledBorder: InputBorder.none,
|
enabledBorder: InputBorder.none,
|
||||||
focusedBorder: InputBorder.none,
|
focusedBorder: InputBorder.none,
|
||||||
),
|
),
|
||||||
onTap: signedIn ? null : _authenticate,
|
onTap: null,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 12),
|
const SizedBox(height: 12),
|
||||||
|
|||||||
@@ -11,11 +11,10 @@ import '../../../core/data/models/comment.dart';
|
|||||||
import '../../../core/data/models/drama.dart';
|
import '../../../core/data/models/drama.dart';
|
||||||
import '../../../core/data/repositories/comment_repository.dart';
|
import '../../../core/data/repositories/comment_repository.dart';
|
||||||
import '../../../core/data/repositories/interaction_repository.dart';
|
import '../../../core/data/repositories/interaction_repository.dart';
|
||||||
import '../../../core/data/services/auth_controller.dart';
|
|
||||||
import '../../../core/data/services/comment_controller.dart';
|
import '../../../core/data/services/comment_controller.dart';
|
||||||
import '../../../core/formatting/error_text.dart';
|
import '../../../core/formatting/error_text.dart';
|
||||||
import '../../../core/theme/app_colors.dart';
|
import '../../../core/theme/app_colors.dart';
|
||||||
import '../../../core/widgets/auth_gate.dart';
|
import '../../../core/widgets/app_glow_panel.dart';
|
||||||
import '../../../core/widgets/empty_state.dart';
|
import '../../../core/widgets/empty_state.dart';
|
||||||
import '../../../l10n/app_localizations.dart';
|
import '../../../l10n/app_localizations.dart';
|
||||||
import 'comment_composer_sheet.dart';
|
import 'comment_composer_sheet.dart';
|
||||||
@@ -29,7 +28,7 @@ const double _sheetRadius = 20;
|
|||||||
const double _headerHeight = 44;
|
const double _headerHeight = 44;
|
||||||
const double _composerTopGap = 8;
|
const double _composerTopGap = 8;
|
||||||
|
|
||||||
/// 服务端评论底部弹窗:匿名列表、游标翻页、回复与登录发布。
|
/// 服务端评论底部弹窗:匿名列表、游标翻页、回复与设备身份发布。
|
||||||
class DramaCommentsSheet extends StatefulWidget {
|
class DramaCommentsSheet extends StatefulWidget {
|
||||||
const DramaCommentsSheet({super.key, required this.drama, this.episodeId});
|
const DramaCommentsSheet({super.key, required this.drama, this.episodeId});
|
||||||
|
|
||||||
@@ -92,8 +91,7 @@ class _DramaCommentsSheetState extends State<DramaCommentsSheet> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _openComposer({DramaComment? replyTo}) async {
|
Future<void> _openComposer({DramaComment? replyTo}) async {
|
||||||
await ensureSignedIn(context);
|
if (!mounted) return;
|
||||||
if (!mounted || !context.read<AuthController>().isSignedIn) return;
|
|
||||||
_removeComposerOverlay();
|
_removeComposerOverlay();
|
||||||
final entry = OverlayEntry(
|
final entry = OverlayEntry(
|
||||||
builder: (_) => CommentComposerSheet(
|
builder: (_) => CommentComposerSheet(
|
||||||
@@ -179,14 +177,14 @@ class _DramaCommentsSheetState extends State<DramaCommentsSheet> {
|
|||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
key: const Key('comment-sheet-constraints'),
|
key: const Key('comment-sheet-constraints'),
|
||||||
height: sheetHeight,
|
height: sheetHeight,
|
||||||
child: Container(
|
child: AppGlowPanel(
|
||||||
decoration: const BoxDecoration(
|
borderRadius: const BorderRadius.vertical(
|
||||||
color: AppColors.card,
|
top: Radius.circular(_sheetRadius),
|
||||||
borderRadius: BorderRadius.vertical(
|
|
||||||
top: Radius.circular(_sheetRadius),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
child: SafeArea(
|
border: false,
|
||||||
|
child: Container(
|
||||||
|
decoration: const BoxDecoration(color: AppColors.transparent),
|
||||||
|
child: SafeArea(
|
||||||
top: false,
|
top: false,
|
||||||
child: ListenableBuilder(
|
child: ListenableBuilder(
|
||||||
listenable: _controller,
|
listenable: _controller,
|
||||||
@@ -196,6 +194,7 @@ class _DramaCommentsSheetState extends State<DramaCommentsSheet> {
|
|||||||
child: _content(context),
|
child: _content(context),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -222,7 +221,6 @@ class _DramaCommentsSheetState extends State<DramaCommentsSheet> {
|
|||||||
Widget _content(BuildContext context) {
|
Widget _content(BuildContext context) {
|
||||||
final l10n = AppLocalizations.of(context)!;
|
final l10n = AppLocalizations.of(context)!;
|
||||||
final count = _serverCount ?? _controller.exactCount;
|
final count = _serverCount ?? _controller.exactCount;
|
||||||
final signedIn = context.watch<AuthController>().isSignedIn;
|
|
||||||
final composerReserve = _composerHeight + _composerTopGap;
|
final composerReserve = _composerHeight + _composerTopGap;
|
||||||
return Column(
|
return Column(
|
||||||
key: const Key('comment-sheet-content'),
|
key: const Key('comment-sheet-content'),
|
||||||
@@ -242,7 +240,7 @@ class _DramaCommentsSheetState extends State<DramaCommentsSheet> {
|
|||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
color: AppColors.onSurface,
|
color: AppColors.onSurface,
|
||||||
fontSize: 16,
|
fontSize: 16,
|
||||||
fontWeight: FontWeight.w600,
|
fontWeight: FontWeight.w400,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Positioned(
|
Positioned(
|
||||||
@@ -269,7 +267,7 @@ class _DramaCommentsSheetState extends State<DramaCommentsSheet> {
|
|||||||
Padding(
|
Padding(
|
||||||
key: const Key('comment-composer-area'),
|
key: const Key('comment-composer-area'),
|
||||||
padding: const EdgeInsets.only(top: _composerTopGap),
|
padding: const EdgeInsets.only(top: _composerTopGap),
|
||||||
child: _fakeComposer(l10n, signedIn: signedIn),
|
child: _fakeComposer(l10n),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
@@ -352,7 +350,7 @@ class _DramaCommentsSheetState extends State<DramaCommentsSheet> {
|
|||||||
return const SizedBox(height: 8);
|
return const SizedBox(height: 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _fakeComposer(AppLocalizations l10n, {required bool signedIn}) {
|
Widget _fakeComposer(AppLocalizations l10n) {
|
||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
behavior: HitTestBehavior.opaque,
|
behavior: HitTestBehavior.opaque,
|
||||||
onTap: _openComposer,
|
onTap: _openComposer,
|
||||||
@@ -372,7 +370,7 @@ class _DramaCommentsSheetState extends State<DramaCommentsSheet> {
|
|||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.only(left: 16),
|
padding: const EdgeInsets.only(left: 16),
|
||||||
child: Text(
|
child: Text(
|
||||||
signedIn ? l10n.writeComment : l10n.commentLoginHint,
|
l10n.writeComment,
|
||||||
key: const Key('comment-input-placeholder-label'),
|
key: const Key('comment-input-placeholder-label'),
|
||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import '../../../core/data/models/drama.dart';
|
|||||||
import '../../../core/formatting/localized_content.dart';
|
import '../../../core/formatting/localized_content.dart';
|
||||||
import '../../../core/theme/app_colors.dart';
|
import '../../../core/theme/app_colors.dart';
|
||||||
import '../../../core/theme/app_dimens.dart';
|
import '../../../core/theme/app_dimens.dart';
|
||||||
|
import '../../../core/widgets/app_glow_panel.dart';
|
||||||
import '../../../l10n/app_localizations.dart';
|
import '../../../l10n/app_localizations.dart';
|
||||||
import 'episode_picker_cell.dart';
|
import 'episode_picker_cell.dart';
|
||||||
|
|
||||||
@@ -47,16 +48,16 @@ class EpisodePickerSheet extends StatelessWidget {
|
|||||||
systemNavigationBarIconBrightness: Brightness.light,
|
systemNavigationBarIconBrightness: Brightness.light,
|
||||||
systemNavigationBarContrastEnforced: false,
|
systemNavigationBarContrastEnforced: false,
|
||||||
),
|
),
|
||||||
child: Container(
|
child: AppGlowPanel(
|
||||||
key: const Key('player-episodes-sheet'),
|
borderRadius: const BorderRadius.vertical(
|
||||||
height: MediaQuery.sizeOf(context).height * _sheetHeightFactor,
|
top: Radius.circular(_sheetRadius),
|
||||||
decoration: const BoxDecoration(
|
|
||||||
color: AppColors.card,
|
|
||||||
borderRadius: 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,
|
top: false,
|
||||||
bottom: true,
|
bottom: true,
|
||||||
child: Column(
|
child: Column(
|
||||||
@@ -139,6 +140,7 @@ class EpisodePickerSheet extends StatelessWidget {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import '../../../core/theme/app_colors.dart';
|
|||||||
import '../../../l10n/app_localizations.dart';
|
import '../../../l10n/app_localizations.dart';
|
||||||
import 'home_feed_recommend_panel.dart';
|
import 'home_feed_recommend_panel.dart';
|
||||||
import 'loading_progress_track.dart';
|
import 'loading_progress_track.dart';
|
||||||
import 'player_double_tap_hearts.dart';
|
import 'player_tap_gesture_region.dart';
|
||||||
import 'seek_progress_bar.dart';
|
import 'seek_progress_bar.dart';
|
||||||
import 'scrub_preview_card.dart';
|
import 'scrub_preview_card.dart';
|
||||||
|
|
||||||
@@ -22,11 +22,13 @@ part 'home_feed_overlay_parts.dart';
|
|||||||
|
|
||||||
const double _progressHeight = 2;
|
const double _progressHeight = 2;
|
||||||
const double _progressHitHeight = 32;
|
const double _progressHitHeight = 32;
|
||||||
const double _pageHorizontal = 14;
|
const double _pageHorizontal = 20;
|
||||||
const double _railRight = 8;
|
const double _railRight = 14;
|
||||||
const double _railGap = 12;
|
const double _railGap = 12;
|
||||||
const double _bottomInfoInset = 32;
|
// 观看条高 44;2pt 进度线视觉上沿距观看条顶约 7pt(线中心距进度条盒底 8)。
|
||||||
const double _railBottomOffset = 60;
|
// 信息面板底边取 44+16=60,使简介↔进度线、进度线↔观看条两侧间距均为 7pt。
|
||||||
|
const double _bottomInfoInset = homeFeedWatchAllHeight + 16;
|
||||||
|
const double _railBottomOffset = 40;
|
||||||
const Duration _overlayFadeDuration = Duration(milliseconds: 120);
|
const Duration _overlayFadeDuration = Duration(milliseconds: 120);
|
||||||
const List<Shadow> _boostTextShadows = [
|
const List<Shadow> _boostTextShadows = [
|
||||||
Shadow(color: AppColors.shadow, blurRadius: 5, offset: Offset(0, 1)),
|
Shadow(color: AppColors.shadow, blurRadius: 5, offset: Offset(0, 1)),
|
||||||
@@ -52,6 +54,7 @@ class HomeFeedOverlay extends StatefulWidget {
|
|||||||
required this.onDetail,
|
required this.onDetail,
|
||||||
required this.onOpenFullPlayer,
|
required this.onOpenFullPlayer,
|
||||||
this.onEpisodes,
|
this.onEpisodes,
|
||||||
|
this.onOpenSearch,
|
||||||
required this.onTogglePlay,
|
required this.onTogglePlay,
|
||||||
required this.onBoostStart,
|
required this.onBoostStart,
|
||||||
required this.onBoostEnd,
|
required this.onBoostEnd,
|
||||||
@@ -69,6 +72,7 @@ class HomeFeedOverlay extends StatefulWidget {
|
|||||||
this.cancelScrubRequest = 0,
|
this.cancelScrubRequest = 0,
|
||||||
this.thumbnailService,
|
this.thumbnailService,
|
||||||
this.spriteAxisService,
|
this.spriteAxisService,
|
||||||
|
this.suppressBufferLoading = false,
|
||||||
});
|
});
|
||||||
|
|
||||||
final AppLocalizations l10n;
|
final AppLocalizations l10n;
|
||||||
@@ -91,6 +95,9 @@ class HomeFeedOverlay extends StatefulWidget {
|
|||||||
final VoidCallback onDetail;
|
final VoidCallback onDetail;
|
||||||
final VoidCallback onOpenFullPlayer;
|
final VoidCallback onOpenFullPlayer;
|
||||||
final VoidCallback? onEpisodes;
|
final VoidCallback? onEpisodes;
|
||||||
|
|
||||||
|
/// 底部热搜胶囊点击(降级版:跳搜索页)。
|
||||||
|
final VoidCallback? onOpenSearch;
|
||||||
final VoidCallback onTogglePlay;
|
final VoidCallback onTogglePlay;
|
||||||
final VoidCallback onBoostStart;
|
final VoidCallback onBoostStart;
|
||||||
final VoidCallback onBoostEnd;
|
final VoidCallback onBoostEnd;
|
||||||
@@ -104,25 +111,15 @@ class HomeFeedOverlay extends StatefulWidget {
|
|||||||
final int cancelScrubRequest;
|
final int cancelScrubRequest;
|
||||||
final PlaybackThumbnailService? thumbnailService;
|
final PlaybackThumbnailService? thumbnailService;
|
||||||
final SpriteThumbnailAxisService? spriteAxisService;
|
final SpriteThumbnailAxisService? spriteAxisService;
|
||||||
|
final bool suppressBufferLoading;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<HomeFeedOverlay> createState() => _HomeFeedOverlayState();
|
State<HomeFeedOverlay> createState() => _HomeFeedOverlayState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _HomeFeedOverlayState extends State<HomeFeedOverlay> {
|
class _HomeFeedOverlayState extends State<HomeFeedOverlay> {
|
||||||
static const Duration _singleTapDelay = Duration(milliseconds: 400);
|
|
||||||
|
|
||||||
bool _scrubbing = false;
|
bool _scrubbing = false;
|
||||||
bool _wasVisibleBeforeScrub = true;
|
bool _wasVisibleBeforeScrub = true;
|
||||||
Timer? _singleTapTimer;
|
|
||||||
DateTime? _lastDownAt;
|
|
||||||
DateTime? _blockSingleTapUntil;
|
|
||||||
bool _doubleTapDown = false;
|
|
||||||
bool _likedThisPair = false;
|
|
||||||
int _downSerial = 0;
|
|
||||||
int _tapSeq = 0;
|
|
||||||
int _nextHeartBurstId = 0;
|
|
||||||
final List<({int id, Offset position})> _heartBursts = [];
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void didUpdateWidget(covariant HomeFeedOverlay oldWidget) {
|
void didUpdateWidget(covariant HomeFeedOverlay oldWidget) {
|
||||||
@@ -132,37 +129,80 @@ class _HomeFeedOverlayState extends State<HomeFeedOverlay> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
|
||||||
void dispose() {
|
|
||||||
_tapSeq++;
|
|
||||||
_singleTapTimer?.cancel();
|
|
||||||
super.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return SafeArea(
|
return SafeArea(
|
||||||
bottom: false,
|
bottom: false,
|
||||||
child: Stack(
|
child: Stack(
|
||||||
|
clipBehavior: Clip.none,
|
||||||
children: [
|
children: [
|
||||||
Positioned.fill(
|
Positioned.fill(
|
||||||
child: LayoutBuilder(
|
child: PlayerTapGestureRegion(
|
||||||
builder: (context, constraints) => Listener(
|
key: const ValueKey('home-feed-tap-gesture-region'),
|
||||||
onPointerUp: (_) => widget.onBoostEnd(),
|
gestureKey: const Key('home-feed-gesture'),
|
||||||
onPointerCancel: (_) => widget.onBoostEnd(),
|
enabled: !_scrubbing,
|
||||||
onPointerDown: _handlePointerDown,
|
doubleTapEnabled: !widget.locked,
|
||||||
child: GestureDetector(
|
now: widget.now,
|
||||||
key: const Key('home-feed-gesture'),
|
onSingleTap: widget.onTogglePlay,
|
||||||
behavior: HitTestBehavior.opaque,
|
onDoubleTapLike: widget.onDoubleTapLike,
|
||||||
onTapUp: _handleTapUp,
|
onLongPressStart: _handleLongPressStart,
|
||||||
onLongPressStart: (details) =>
|
onInteractionEnd: widget.onBoostEnd,
|
||||||
_handleLongPressStart(details, constraints.maxWidth),
|
),
|
||||||
onLongPressEnd: (_) => widget.onBoostEnd(),
|
),
|
||||||
onLongPressCancel: 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(
|
Positioned(
|
||||||
left: _pageHorizontal,
|
left: _pageHorizontal,
|
||||||
right: _railRight,
|
right: _railRight,
|
||||||
@@ -190,58 +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,
|
|
||||||
posterUrl: widget.drama.posterUrl,
|
|
||||||
onScrubStart: _startScrub,
|
|
||||||
onScrubEnd: _endScrub,
|
|
||||||
onSeek: widget.onSeek,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
if (_heartBursts.isNotEmpty)
|
|
||||||
Positioned.fill(
|
|
||||||
child: IgnorePointer(
|
|
||||||
child: Stack(
|
|
||||||
clipBehavior: Clip.none,
|
|
||||||
children: [
|
|
||||||
for (final burst in _heartBursts)
|
|
||||||
Positioned(
|
|
||||||
left: burst.position.dx,
|
|
||||||
top: burst.position.dy - 10,
|
|
||||||
child: PlayerDoubleTapHeartBurst(
|
|
||||||
key: ValueKey(burst.id),
|
|
||||||
onCompleted: () => _removeHeartBurst(burst.id),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -263,83 +251,8 @@ class _HomeFeedOverlayState extends State<HomeFeedOverlay> {
|
|||||||
widget.onScrubEnd?.call(wasVisible);
|
widget.onScrubEnd?.call(wasVisible);
|
||||||
}
|
}
|
||||||
|
|
||||||
DateTime _now() => widget.now?.call() ?? DateTime.now();
|
|
||||||
|
|
||||||
void _handlePointerDown(PointerDownEvent event) {
|
|
||||||
final now = _now();
|
|
||||||
final previous = _lastDownAt;
|
|
||||||
_downSerial++;
|
|
||||||
_lastDownAt = now;
|
|
||||||
final repeated =
|
|
||||||
previous != null && now.difference(previous) <= _singleTapDelay;
|
|
||||||
if (!repeated) {
|
|
||||||
if (_singleTapBlocked(now)) return;
|
|
||||||
_doubleTapDown = false;
|
|
||||||
_likedThisPair = false;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_doubleTapDown = true;
|
|
||||||
_blockSingleTapUntil = now.add(_singleTapDelay);
|
|
||||||
_cancelPendingSingleTap();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool _singleTapBlocked(DateTime now) {
|
|
||||||
final blockedUntil = _blockSingleTapUntil;
|
|
||||||
return blockedUntil != null && now.isBefore(blockedUntil);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _cancelPendingSingleTap() {
|
|
||||||
_tapSeq++;
|
|
||||||
_singleTapTimer?.cancel();
|
|
||||||
_singleTapTimer = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
void _handleTapUp(TapUpDetails details) {
|
|
||||||
final now = _now();
|
|
||||||
if (_doubleTapDown || _singleTapBlocked(now)) {
|
|
||||||
_showDoubleTapLike(details.localPosition);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
final serial = _downSerial;
|
|
||||||
final tapSeq = ++_tapSeq;
|
|
||||||
_singleTapTimer?.cancel();
|
|
||||||
late final Timer pending;
|
|
||||||
pending = Timer(_singleTapDelay, () {
|
|
||||||
if (!identical(_singleTapTimer, pending)) return;
|
|
||||||
_singleTapTimer = null;
|
|
||||||
if (!mounted || tapSeq != _tapSeq || serial != _downSerial) return;
|
|
||||||
if (_doubleTapDown || _singleTapBlocked(_now())) return;
|
|
||||||
_lastDownAt = null;
|
|
||||||
widget.onTogglePlay();
|
|
||||||
});
|
|
||||||
_singleTapTimer = pending;
|
|
||||||
}
|
|
||||||
|
|
||||||
void _showDoubleTapLike(Offset position) {
|
|
||||||
if (_likedThisPair) return;
|
|
||||||
_likedThisPair = true;
|
|
||||||
_blockSingleTapUntil = _now().add(_singleTapDelay);
|
|
||||||
_cancelPendingSingleTap();
|
|
||||||
_showHearts(position);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _showHearts(Offset position) {
|
|
||||||
final id = _nextHeartBurstId++;
|
|
||||||
setState(() => _heartBursts.add((id: id, position: position)));
|
|
||||||
widget.onDoubleTapLike?.call(position);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _removeHeartBurst(int id) {
|
|
||||||
if (!mounted) return;
|
|
||||||
setState(() => _heartBursts.removeWhere((burst) => burst.id == id));
|
|
||||||
}
|
|
||||||
|
|
||||||
void _handleLongPressStart(LongPressStartDetails details, double width) {
|
void _handleLongPressStart(LongPressStartDetails details, double width) {
|
||||||
final third = width / 3;
|
final third = width / 3;
|
||||||
_tapSeq++;
|
|
||||||
_cancelPendingSingleTap();
|
|
||||||
_doubleTapDown = false;
|
|
||||||
_lastDownAt = null;
|
|
||||||
final dx = details.localPosition.dx;
|
final dx = details.localPosition.dx;
|
||||||
if (dx < third || dx > width - third) {
|
if (dx < third || dx > width - third) {
|
||||||
widget.onBoostStart();
|
widget.onBoostStart();
|
||||||
@@ -383,9 +296,11 @@ class _HomeFeedOverlayState extends State<HomeFeedOverlay> {
|
|||||||
liked: widget.liked,
|
liked: widget.liked,
|
||||||
favoriteCount: widget.favoriteCount,
|
favoriteCount: widget.favoriteCount,
|
||||||
likeCount: widget.likeCount,
|
likeCount: widget.likeCount,
|
||||||
|
commentCount: widget.commentCount,
|
||||||
onSave: widget.onSave,
|
onSave: widget.onSave,
|
||||||
onLike: widget.onLike,
|
onLike: widget.onLike,
|
||||||
onEpisodes: widget.onEpisodes ?? widget.onOpenFullPlayer,
|
onComments: widget.onComments,
|
||||||
|
onShare: widget.onShare,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -395,6 +310,7 @@ class _HomeFeedOverlayState extends State<HomeFeedOverlay> {
|
|||||||
episode: widget.episode,
|
episode: widget.episode,
|
||||||
onDetail: widget.onDetail,
|
onDetail: widget.onDetail,
|
||||||
onOpenFullPlayer: widget.onOpenFullPlayer,
|
onOpenFullPlayer: widget.onOpenFullPlayer,
|
||||||
|
onOpenSearch: widget.onOpenSearch,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -6,7 +6,6 @@ const double _thumbSize = 6;
|
|||||||
const double _thumbActiveSize = 14;
|
const double _thumbActiveSize = 14;
|
||||||
const double _trackActiveHeight = 6;
|
const double _trackActiveHeight = 6;
|
||||||
const double _lineCenterFromBottom = 8;
|
const double _lineCenterFromBottom = 8;
|
||||||
const Duration _trackResizeDuration = Duration(milliseconds: 120);
|
|
||||||
const double _timeBubbleWidth = 96;
|
const double _timeBubbleWidth = 96;
|
||||||
const double _timeBubbleMargin = 12;
|
const double _timeBubbleMargin = 12;
|
||||||
const Key _inactiveTrackKey = Key('home-feed-progress-inactive');
|
const Key _inactiveTrackKey = Key('home-feed-progress-inactive');
|
||||||
@@ -23,7 +22,7 @@ class _FeedProgressBar extends StatefulWidget {
|
|||||||
this.spriteAxisService,
|
this.spriteAxisService,
|
||||||
this.thumbnailsUrl,
|
this.thumbnailsUrl,
|
||||||
this.episodeId,
|
this.episodeId,
|
||||||
this.posterUrl = '',
|
this.suppressBufferLoading = false,
|
||||||
this.onScrubStart,
|
this.onScrubStart,
|
||||||
this.onScrubEnd,
|
this.onScrubEnd,
|
||||||
this.onSeek,
|
this.onSeek,
|
||||||
@@ -38,7 +37,7 @@ class _FeedProgressBar extends StatefulWidget {
|
|||||||
final SpriteThumbnailAxisSource? spriteAxisService;
|
final SpriteThumbnailAxisSource? spriteAxisService;
|
||||||
final String? thumbnailsUrl;
|
final String? thumbnailsUrl;
|
||||||
final String? episodeId;
|
final String? episodeId;
|
||||||
final String posterUrl;
|
final bool suppressBufferLoading;
|
||||||
final VoidCallback? onScrubStart;
|
final VoidCallback? onScrubStart;
|
||||||
final VoidCallback? onScrubEnd;
|
final VoidCallback? onScrubEnd;
|
||||||
final ValueChanged<Duration>? onSeek;
|
final ValueChanged<Duration>? onSeek;
|
||||||
@@ -54,6 +53,7 @@ class _FeedProgressBarState extends State<_FeedProgressBar> {
|
|||||||
Timer? _bufferTimer;
|
Timer? _bufferTimer;
|
||||||
bool _buffering = false;
|
bool _buffering = false;
|
||||||
bool _dragging = false;
|
bool _dragging = false;
|
||||||
|
Duration? _lastPosition;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@@ -69,6 +69,7 @@ class _FeedProgressBarState extends State<_FeedProgressBar> {
|
|||||||
_bufferTimer?.cancel();
|
_bufferTimer?.cancel();
|
||||||
_bufferTimer = null;
|
_bufferTimer = null;
|
||||||
_buffering = false;
|
_buffering = false;
|
||||||
|
_lastPosition = null;
|
||||||
_attachSource();
|
_attachSource();
|
||||||
}
|
}
|
||||||
if (oldWidget.cancelScrubRequest != widget.cancelScrubRequest) {
|
if (oldWidget.cancelScrubRequest != widget.cancelScrubRequest) {
|
||||||
@@ -79,6 +80,7 @@ class _FeedProgressBarState extends State<_FeedProgressBar> {
|
|||||||
_bufferTimer?.cancel();
|
_bufferTimer?.cancel();
|
||||||
_bufferTimer = null;
|
_bufferTimer = null;
|
||||||
_buffering = false;
|
_buffering = false;
|
||||||
|
_lastPosition = null;
|
||||||
if (widget.locked) {
|
if (widget.locked) {
|
||||||
_dragging = false;
|
_dragging = false;
|
||||||
_preview = null;
|
_preview = null;
|
||||||
@@ -86,6 +88,13 @@ class _FeedProgressBarState extends State<_FeedProgressBar> {
|
|||||||
_syncBufferState(notify: false);
|
_syncBufferState(notify: false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (oldWidget.suppressBufferLoading != widget.suppressBufferLoading) {
|
||||||
|
_bufferTimer?.cancel();
|
||||||
|
_bufferTimer = null;
|
||||||
|
_buffering = false;
|
||||||
|
_lastPosition = null;
|
||||||
|
_syncBufferState(notify: false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -102,7 +111,11 @@ class _FeedProgressBarState extends State<_FeedProgressBar> {
|
|||||||
final width = constraints.maxWidth;
|
final width = constraints.maxWidth;
|
||||||
final source = widget.controller;
|
final source = widget.controller;
|
||||||
final scrubbing = _dragging;
|
final scrubbing = _dragging;
|
||||||
final loading = !widget.locked && !scrubbing && _buffering;
|
final loading =
|
||||||
|
!widget.locked &&
|
||||||
|
!widget.suppressBufferLoading &&
|
||||||
|
!scrubbing &&
|
||||||
|
_buffering;
|
||||||
final track = widget.locked
|
final track = widget.locked
|
||||||
? _inactiveTrack()
|
? _inactiveTrack()
|
||||||
: source == null
|
: source == null
|
||||||
@@ -166,7 +179,6 @@ class _FeedProgressBarState extends State<_FeedProgressBar> {
|
|||||||
spriteAxisService: widget.spriteAxisService,
|
spriteAxisService: widget.spriteAxisService,
|
||||||
thumbnailsUrl: widget.thumbnailsUrl,
|
thumbnailsUrl: widget.thumbnailsUrl,
|
||||||
episodeId: widget.episodeId!,
|
episodeId: widget.episodeId!,
|
||||||
posterUrl: widget.posterUrl,
|
|
||||||
position: previewPosition,
|
position: previewPosition,
|
||||||
duration: video!.duration,
|
duration: video!.duration,
|
||||||
),
|
),
|
||||||
@@ -202,14 +214,24 @@ class _FeedProgressBarState extends State<_FeedProgressBar> {
|
|||||||
|
|
||||||
void _syncBufferState({bool notify = true}) {
|
void _syncBufferState({bool notify = true}) {
|
||||||
final source = widget.controller;
|
final source = widget.controller;
|
||||||
if (widget.locked || source == null) {
|
if (widget.locked || widget.suppressBufferLoading || source == null) {
|
||||||
_bufferTimer?.cancel();
|
_bufferTimer?.cancel();
|
||||||
_bufferTimer = null;
|
_bufferTimer = null;
|
||||||
|
_lastPosition = null;
|
||||||
_setBuffering(false, notify: notify);
|
_setBuffering(false, notify: notify);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final value = source.value;
|
final value = source.value;
|
||||||
if (!value.isInitialized) {
|
if (!value.isInitialized) {
|
||||||
|
_bufferTimer?.cancel();
|
||||||
|
_bufferTimer = null;
|
||||||
|
_lastPosition = null;
|
||||||
|
_setBuffering(false, notify: notify);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final previousPosition = _lastPosition;
|
||||||
|
_lastPosition = value.position;
|
||||||
|
if (previousPosition != null && value.position > previousPosition) {
|
||||||
_bufferTimer?.cancel();
|
_bufferTimer?.cancel();
|
||||||
_bufferTimer = null;
|
_bufferTimer = null;
|
||||||
_setBuffering(false, notify: notify);
|
_setBuffering(false, notify: notify);
|
||||||
@@ -221,14 +243,22 @@ class _FeedProgressBarState extends State<_FeedProgressBar> {
|
|||||||
_setBuffering(false, notify: notify);
|
_setBuffering(false, notify: notify);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (previousPosition == null &&
|
||||||
|
value.isPlaying &&
|
||||||
|
value.position > Duration.zero) {
|
||||||
|
_setBuffering(false, notify: notify);
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (_buffering || _bufferTimer != null) return;
|
if (_buffering || _bufferTimer != null) return;
|
||||||
|
final bufferingPosition = value.position;
|
||||||
_bufferTimer = Timer(_bufferDebounce, () {
|
_bufferTimer = Timer(_bufferDebounce, () {
|
||||||
_bufferTimer = null;
|
_bufferTimer = null;
|
||||||
final current = widget.controller;
|
final current = widget.controller;
|
||||||
if (!mounted ||
|
if (!mounted ||
|
||||||
current != source ||
|
current != source ||
|
||||||
!current!.value.isInitialized ||
|
!current!.value.isInitialized ||
|
||||||
!current.value.isBuffering) {
|
!current.value.isBuffering ||
|
||||||
|
current.value.position != bufferingPosition) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_setBuffering(true);
|
_setBuffering(true);
|
||||||
@@ -340,10 +370,8 @@ class _FeedProgressBarState extends State<_FeedProgressBar> {
|
|||||||
children: [
|
children: [
|
||||||
Align(
|
Align(
|
||||||
alignment: Alignment.centerLeft,
|
alignment: Alignment.centerLeft,
|
||||||
child: AnimatedContainer(
|
child: Container(
|
||||||
key: const Key('home-feed-progress-track'),
|
key: const Key('home-feed-progress-track'),
|
||||||
duration: _trackResizeDuration,
|
|
||||||
curve: Curves.easeOut,
|
|
||||||
width: width,
|
width: width,
|
||||||
height: trackHeight,
|
height: trackHeight,
|
||||||
color: AppColors.border,
|
color: AppColors.border,
|
||||||
@@ -351,10 +379,8 @@ class _FeedProgressBarState extends State<_FeedProgressBar> {
|
|||||||
),
|
),
|
||||||
Align(
|
Align(
|
||||||
alignment: Alignment.centerLeft,
|
alignment: Alignment.centerLeft,
|
||||||
child: AnimatedContainer(
|
child: Container(
|
||||||
key: const Key('home-feed-progress-played'),
|
key: const Key('home-feed-progress-played'),
|
||||||
duration: dragging ? Duration.zero : _trackResizeDuration,
|
|
||||||
curve: Curves.easeOut,
|
|
||||||
width: playedWidth,
|
width: playedWidth,
|
||||||
height: trackHeight,
|
height: trackHeight,
|
||||||
color: AppColors.blue,
|
color: AppColors.blue,
|
||||||
@@ -370,10 +396,8 @@ class _FeedProgressBarState extends State<_FeedProgressBar> {
|
|||||||
child: SizedBox.square(
|
child: SizedBox.square(
|
||||||
dimension: _thumbActiveSize,
|
dimension: _thumbActiveSize,
|
||||||
child: Center(
|
child: Center(
|
||||||
child: AnimatedContainer(
|
child: Container(
|
||||||
key: const Key('home-feed-progress-thumb'),
|
key: const Key('home-feed-progress-thumb'),
|
||||||
duration: _trackResizeDuration,
|
|
||||||
curve: Curves.easeOut,
|
|
||||||
width: size,
|
width: size,
|
||||||
height: size,
|
height: size,
|
||||||
decoration: const BoxDecoration(
|
decoration: const BoxDecoration(
|
||||||
|
|||||||
@@ -1,28 +1,31 @@
|
|||||||
// Author: fruit.com.cn
|
// Author: fruit.com.cn
|
||||||
|
|
||||||
import 'dart:math' as math;
|
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:intl/intl.dart';
|
||||||
|
|
||||||
import '../../../core/data/models/drama.dart';
|
import '../../../core/data/models/drama.dart';
|
||||||
import '../../../core/formatting/count_format.dart';
|
|
||||||
import '../../../core/formatting/localized_content.dart';
|
import '../../../core/formatting/localized_content.dart';
|
||||||
import '../../../core/theme/app_colors.dart';
|
import '../../../core/theme/app_colors.dart';
|
||||||
import '../../../l10n/app_localizations.dart';
|
import '../../../l10n/app_localizations.dart';
|
||||||
import '../../home/widgets/home_drama_classification.dart';
|
import '../../home/widgets/home_drama_classification.dart';
|
||||||
|
import 'interaction_rail.dart';
|
||||||
|
|
||||||
const double _seriesFont = 19;
|
const double _seriesFont = 17;
|
||||||
const double _tagFont = 13;
|
const double _tagFont = 12;
|
||||||
const double _synopsisFont = 13;
|
const double _synopsisFont = 14;
|
||||||
const double _watchAllHeight = 44;
|
const double _watchAllHeight = 44;
|
||||||
const double _actionGap = 28;
|
|
||||||
const double _actionIcon = 32;
|
|
||||||
const double _actionWidth = 64;
|
|
||||||
const List<Shadow> _textShadows = [
|
const List<Shadow> _textShadows = [
|
||||||
Shadow(color: AppColors.shadow, blurRadius: 6, offset: Offset(0, 1)),
|
Shadow(color: AppColors.shadow, blurRadius: 6, offset: Offset(0, 1)),
|
||||||
];
|
];
|
||||||
final RegExp _tagSplitter = RegExp(r'[,/、·]');
|
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 {
|
class HomeFeedInfoPanel extends StatefulWidget {
|
||||||
const HomeFeedInfoPanel({
|
const HomeFeedInfoPanel({
|
||||||
super.key,
|
super.key,
|
||||||
@@ -30,6 +33,7 @@ class HomeFeedInfoPanel extends StatefulWidget {
|
|||||||
required this.episode,
|
required this.episode,
|
||||||
required this.onDetail,
|
required this.onDetail,
|
||||||
required this.onOpenFullPlayer,
|
required this.onOpenFullPlayer,
|
||||||
|
this.onOpenSearch,
|
||||||
});
|
});
|
||||||
|
|
||||||
final Drama drama;
|
final Drama drama;
|
||||||
@@ -37,6 +41,9 @@ class HomeFeedInfoPanel extends StatefulWidget {
|
|||||||
final VoidCallback onDetail;
|
final VoidCallback onDetail;
|
||||||
final VoidCallback onOpenFullPlayer;
|
final VoidCallback onOpenFullPlayer;
|
||||||
|
|
||||||
|
/// 热搜胶囊点击;为空或播放量为 0 时不显示胶囊。
|
||||||
|
final VoidCallback? onOpenSearch;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<HomeFeedInfoPanel> createState() => _HomeFeedInfoPanelState();
|
State<HomeFeedInfoPanel> createState() => _HomeFeedInfoPanelState();
|
||||||
}
|
}
|
||||||
@@ -51,9 +58,22 @@ class _HomeFeedInfoPanelState extends State<HomeFeedInfoPanel> {
|
|||||||
final synopsis = localizedDramaSynopsis(l10n, widget.drama).trim();
|
final synopsis = localizedDramaSynopsis(l10n, widget.drama).trim();
|
||||||
final genres = _genreValues(Localizations.localeOf(context).languageCode);
|
final genres = _genreValues(Localizations.localeOf(context).languageCode);
|
||||||
return Column(
|
return Column(
|
||||||
|
key: const Key('home-feed-info-panel'),
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
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(
|
GestureDetector(
|
||||||
key: const Key('home-feed-series-name'),
|
key: const Key('home-feed-series-name'),
|
||||||
behavior: HitTestBehavior.opaque,
|
behavior: HitTestBehavior.opaque,
|
||||||
@@ -70,221 +90,186 @@ class _HomeFeedInfoPanelState extends State<HomeFeedInfoPanel> {
|
|||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
color: AppColors.textPrimary,
|
color: AppColors.textPrimary,
|
||||||
fontSize: _seriesFont,
|
fontSize: _seriesFont,
|
||||||
fontWeight: FontWeight.w600,
|
fontWeight: FontWeight.w400,
|
||||||
shadows: _textShadows,
|
shadows: _textShadows,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(width: 4),
|
const SizedBox(width: 2),
|
||||||
const Icon(
|
const Icon(
|
||||||
Icons.chevron_right_rounded,
|
Icons.chevron_right_rounded,
|
||||||
size: 20,
|
size: 18,
|
||||||
color: AppColors.textPrimary,
|
color: AppColors.textPrimary,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 8),
|
const SizedBox(height: 6),
|
||||||
_tagMetaRow(l10n, genres),
|
_tagMetaRow(l10n, genres),
|
||||||
if (synopsis.isNotEmpty) ...[
|
if (synopsis.isNotEmpty) ...[
|
||||||
const SizedBox(height: 8),
|
const SizedBox(height: 8),
|
||||||
_synopsis(l10n, synopsis),
|
_synopsis(l10n, synopsis),
|
||||||
],
|
],
|
||||||
const SizedBox(height: 12),
|
|
||||||
_watchAll(context, l10n),
|
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _tagMetaRow(AppLocalizations l10n, List<String> genres) {
|
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'),
|
key: const Key('home-feed-tags'),
|
||||||
children: [
|
height: 22,
|
||||||
if (isHotDrama(widget.drama)) ...[
|
child: ListView.separated(
|
||||||
Container(
|
scrollDirection: Axis.horizontal,
|
||||||
key: const Key('home-feed-hot-badge'),
|
physics: const BouncingScrollPhysics(),
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 2),
|
shrinkWrap: true,
|
||||||
decoration: BoxDecoration(
|
itemCount: chips.length,
|
||||||
color: AppColors.error,
|
separatorBuilder: (_, _) => const SizedBox(width: 6),
|
||||||
borderRadius: BorderRadius.circular(3),
|
itemBuilder: (_, index) => chips[index],
|
||||||
),
|
),
|
||||||
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,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _synopsis(AppLocalizations l10n, String synopsis) {
|
Widget _synopsis(AppLocalizations l10n, String synopsis) {
|
||||||
const style = TextStyle(
|
final prefix = l10n.feedEpisodePrefix(widget.episode.number);
|
||||||
color: AppColors.overlaySecondary,
|
final baseStyle = const TextStyle(
|
||||||
|
color: AppColors.textPrimary,
|
||||||
fontSize: _synopsisFont,
|
fontSize: _synopsisFont,
|
||||||
height: 1.35,
|
height: 1.3,
|
||||||
shadows: _textShadows,
|
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(
|
return LayoutBuilder(
|
||||||
builder: (context, constraints) {
|
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(
|
final painter = TextPainter(
|
||||||
text: TextSpan(text: synopsis, style: style),
|
text: span,
|
||||||
maxLines: 2,
|
maxLines: 1,
|
||||||
textDirection: Directionality.of(context),
|
textDirection: Directionality.of(context),
|
||||||
textScaler: MediaQuery.textScalerOf(context),
|
textScaler: MediaQuery.textScalerOf(context),
|
||||||
)..layout(maxWidth: constraints.maxWidth);
|
)..layout(maxWidth: constraints.maxWidth);
|
||||||
final overflows = painter.didExceedMaxLines;
|
if (!painter.didExceedMaxLines) {
|
||||||
if (!overflows) {
|
return Text.rich(
|
||||||
return Text(
|
span,
|
||||||
synopsis,
|
|
||||||
key: const Key('home-feed-synopsis'),
|
key: const Key('home-feed-synopsis'),
|
||||||
style: style,
|
maxLines: 1,
|
||||||
|
style: baseStyle,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (_synopsisExpanded) {
|
// 设计稿:单行省略号 + 行内固定「展开」。
|
||||||
return _expandedSynopsis(constraints.maxWidth, synopsis, style, l10n);
|
// 整行可点:真机上不必精确命中两个小字,点简介任意位置都能展开。
|
||||||
}
|
return GestureDetector(
|
||||||
return Stack(
|
behavior: HitTestBehavior.opaque,
|
||||||
children: [
|
onTap: () => setState(() => _synopsisExpanded = true),
|
||||||
Padding(
|
child: Row(
|
||||||
padding: const EdgeInsets.only(right: 40),
|
key: const Key('home-feed-synopsis-collapsed'),
|
||||||
child: Text(
|
// 顶对齐:文字位置不变,toggle 的 bottom 留白把触控区向下扩到空白处。
|
||||||
synopsis,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
key: const Key('home-feed-synopsis'),
|
children: [
|
||||||
maxLines: 2,
|
Expanded(
|
||||||
overflow: TextOverflow.ellipsis,
|
child: Text.rich(
|
||||||
style: style,
|
span,
|
||||||
|
key: const Key('home-feed-synopsis'),
|
||||||
|
maxLines: 1,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
style: baseStyle,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
const SizedBox(width: 2),
|
||||||
Positioned(
|
toggle,
|
||||||
right: 0,
|
],
|
||||||
bottom: 0,
|
),
|
||||||
child: _synopsisToggle(
|
|
||||||
key: const Key('home-feed-synopsis-more'),
|
|
||||||
label: l10n.expandSynopsis,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _expandedSynopsis(
|
Widget _expandedSynopsis(
|
||||||
double maxWidth,
|
InlineSpan span,
|
||||||
String synopsis,
|
|
||||||
TextStyle style,
|
TextStyle style,
|
||||||
AppLocalizations l10n,
|
AppLocalizations l10n,
|
||||||
) {
|
) {
|
||||||
return SizedBox(
|
// 「收起」内联在简介最后一行末尾,避免独占一行导致多行简介与进度条间
|
||||||
width: maxWidth,
|
// 出现大片空白;垂直方向只留少量触控留白(仅撑高最后一行)。
|
||||||
child: Column(
|
final expandedSpan = TextSpan(
|
||||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
style: style,
|
||||||
children: [
|
children: [
|
||||||
Text(synopsis, key: const Key('home-feed-synopsis'), style: style),
|
span,
|
||||||
Align(
|
WidgetSpan(
|
||||||
alignment: Alignment.centerRight,
|
alignment: PlaceholderAlignment.baseline,
|
||||||
child: _synopsisToggle(
|
baseline: TextBaseline.alphabetic,
|
||||||
key: const Key('home-feed-synopsis-more'),
|
child: _synopsisToggle(
|
||||||
label: l10n.showLess,
|
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(
|
return GestureDetector(
|
||||||
key: key,
|
key: key,
|
||||||
|
// opaque + 留白扩大命中区;留白方向由调用方决定,
|
||||||
|
// 展开态不能加 top padding,否则「收起」距简介正文过远。
|
||||||
|
behavior: HitTestBehavior.opaque,
|
||||||
onTap: () => setState(() => _synopsisExpanded = !_synopsisExpanded),
|
onTap: () => setState(() => _synopsisExpanded = !_synopsisExpanded),
|
||||||
child: Text(
|
child: Padding(
|
||||||
label,
|
padding: padding,
|
||||||
style: const TextStyle(
|
child: Text(
|
||||||
color: AppColors.textPrimary,
|
label,
|
||||||
fontSize: _synopsisFont,
|
style: const TextStyle(
|
||||||
fontWeight: FontWeight.w600,
|
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) {
|
List<String> _genreValues(String languageCode) {
|
||||||
final localized = widget.drama.localizedTypeLabels(languageCode);
|
final localized = widget.drama.localizedTypeLabels(languageCode);
|
||||||
if (localized.isNotEmpty) return localized.take(3).toList(growable: false);
|
if (localized.isNotEmpty) return localized.take(3).toList(growable: false);
|
||||||
@@ -300,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 {
|
class HomeFeedActionRail extends StatelessWidget {
|
||||||
const HomeFeedActionRail({
|
const HomeFeedActionRail({
|
||||||
super.key,
|
super.key,
|
||||||
@@ -307,112 +433,69 @@ class HomeFeedActionRail extends StatelessWidget {
|
|||||||
required this.liked,
|
required this.liked,
|
||||||
required this.onSave,
|
required this.onSave,
|
||||||
required this.onLike,
|
required this.onLike,
|
||||||
required this.onEpisodes,
|
required this.onComments,
|
||||||
|
required this.onShare,
|
||||||
this.favoriteCount,
|
this.favoriteCount,
|
||||||
this.likeCount,
|
this.likeCount,
|
||||||
|
this.commentCount,
|
||||||
});
|
});
|
||||||
|
|
||||||
final bool saved;
|
final bool saved;
|
||||||
final bool liked;
|
final bool liked;
|
||||||
final int? favoriteCount;
|
final int? favoriteCount;
|
||||||
final int? likeCount;
|
final int? likeCount;
|
||||||
|
final int? commentCount;
|
||||||
final VoidCallback onSave;
|
final VoidCallback onSave;
|
||||||
final VoidCallback onLike;
|
final VoidCallback onLike;
|
||||||
final VoidCallback onEpisodes;
|
final VoidCallback onComments;
|
||||||
|
final VoidCallback onShare;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final l10n = AppLocalizations.of(context)!;
|
final l10n = AppLocalizations.of(context)!;
|
||||||
return SizedBox(
|
return InteractionRail(
|
||||||
width: _actionWidth,
|
itemGap: 12,
|
||||||
child: Column(
|
buttonSize: 48,
|
||||||
mainAxisSize: MainAxisSize.min,
|
iconSize: 36,
|
||||||
children: [
|
countFontSize: 15,
|
||||||
_action(
|
iconCountGap: 2,
|
||||||
key: const Key('rail-save'),
|
items: [
|
||||||
icon: saved
|
InteractionRailItem(
|
||||||
? Icons.bookmark_rounded
|
key: const Key('rail-save'),
|
||||||
: Icons.bookmark_border_rounded,
|
asset: 'assets/icon/rail/rail_save.png',
|
||||||
label: favoriteCount == null
|
label: l10n.favorite,
|
||||||
? l10n.favorite
|
count: favoriteCount,
|
||||||
: formatInteractionCount(favoriteCount!),
|
countKey: const Key('rail-save-count'),
|
||||||
labelKey: const Key('rail-save-count'),
|
selected: saved,
|
||||||
onTap: onSave,
|
selectedColor: AppColors.brandRed,
|
||||||
),
|
onTap: onSave,
|
||||||
const SizedBox(height: _actionGap),
|
),
|
||||||
_action(
|
InteractionRailItem(
|
||||||
key: const Key('rail-like'),
|
key: const Key('rail-comments'),
|
||||||
icon: liked
|
asset: 'assets/icon/rail/rail_comment.png',
|
||||||
? Icons.favorite_rounded
|
label: l10n.comments,
|
||||||
: Icons.favorite_border_rounded,
|
count: commentCount,
|
||||||
iconColor: liked
|
countKey: const Key('rail-comments-count'),
|
||||||
? AppColors.doubleTapHeartRed
|
onTap: onComments,
|
||||||
: AppColors.textPrimary,
|
),
|
||||||
label: likeCount == null
|
InteractionRailItem(
|
||||||
? l10n.like
|
key: const Key('rail-like'),
|
||||||
: formatInteractionCount(likeCount!),
|
asset: 'assets/icon/rail/rail_like.png',
|
||||||
labelKey: const Key('rail-like-count'),
|
label: l10n.like,
|
||||||
onTap: onLike,
|
count: likeCount,
|
||||||
),
|
countKey: const Key('rail-like-count'),
|
||||||
const SizedBox(height: _actionGap),
|
selected: liked,
|
||||||
_action(
|
selectedColor: AppColors.brandRed,
|
||||||
key: const Key('rail-episodes'),
|
onTap: onLike,
|
||||||
icon: Icons.layers_rounded,
|
),
|
||||||
label: l10n.episodes,
|
InteractionRailItem(
|
||||||
labelKey: const Key('rail-episodes-label'),
|
key: const Key('rail-share'),
|
||||||
labelFontSize: 11,
|
asset: 'assets/icon/rail/rail_share.png',
|
||||||
onTap: onEpisodes,
|
label: l10n.share,
|
||||||
),
|
countKey: const Key('rail-share-label'),
|
||||||
],
|
onTap: onShare,
|
||||||
),
|
),
|
||||||
);
|
],
|
||||||
}
|
|
||||||
|
|
||||||
Widget _action({
|
|
||||||
required Key key,
|
|
||||||
required IconData icon,
|
|
||||||
required String label,
|
|
||||||
required Key labelKey,
|
|
||||||
required VoidCallback onTap,
|
|
||||||
Color iconColor = AppColors.textPrimary,
|
|
||||||
double labelFontSize = 12,
|
|
||||||
}) {
|
|
||||||
return GestureDetector(
|
|
||||||
key: key,
|
|
||||||
behavior: HitTestBehavior.opaque,
|
|
||||||
onTap: onTap,
|
|
||||||
child: Column(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: [
|
|
||||||
Icon(
|
|
||||||
icon,
|
|
||||||
size: _actionIcon,
|
|
||||||
color: iconColor,
|
|
||||||
shadows: const [
|
|
||||||
Shadow(
|
|
||||||
color: AppColors.shadowSoft,
|
|
||||||
blurRadius: 4,
|
|
||||||
offset: Offset(0, 1),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
const SizedBox(height: 2),
|
|
||||||
Text(
|
|
||||||
label,
|
|
||||||
key: labelKey,
|
|
||||||
maxLines: 1,
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
style: TextStyle(
|
|
||||||
color: AppColors.textPrimary,
|
|
||||||
fontSize: labelFontSize,
|
|
||||||
fontWeight: FontWeight.w500,
|
|
||||||
height: 1,
|
|
||||||
shadows: _textShadows,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loaded 100 of 182 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user