Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
222bacdeeb | ||
|
|
b83b5799e3 | ||
|
|
d4ae8f427f | ||
|
|
98d7debfb5 | ||
|
|
b5e9deb4bd | ||
|
|
47df002d8e | ||
|
|
4f1feeadbd | ||
|
|
8b50b5bd06 | ||
|
|
8481611372 | ||
|
|
b1e95b370c | ||
|
|
0ef0d46919 | ||
|
|
b4d38f8e10 | ||
|
|
c034627fdb | ||
|
|
ef29fc5f15 | ||
|
|
671e0ce143 | ||
|
|
0f1f64a09f | ||
|
|
d29ae20491 | ||
|
|
12e08a89a4 | ||
|
|
e0ba54f23b | ||
|
|
5043d6c25b | ||
|
|
ab6800aba2 | ||
|
|
f8500bbaca | ||
|
|
9b1afbdb36 | ||
|
|
f4cf7bc2dd | ||
|
|
60489d6dca | ||
|
|
44d3bcba18 | ||
|
|
f206977ad8 | ||
|
|
f3d64f6fb5 | ||
|
|
6318ca24ec | ||
|
|
b513ac0a9c | ||
|
|
25d90e1383 | ||
|
|
7804809d83 | ||
|
|
5f278a3510 | ||
|
|
56d7abc6b1 | ||
|
|
345cc2ad28 | ||
|
|
41bd4683c3 | ||
|
|
d868ce9336 | ||
|
|
928ac1de19 | ||
|
|
6b3d870c93 | ||
|
|
281f13a810 | ||
|
|
8637f5da21 | ||
|
|
0319f8a6a8 | ||
|
|
9aa797504b | ||
|
|
933333b0fe | ||
|
|
bbc759473c | ||
|
|
9ddd7fc833 | ||
|
|
5794dd4e4d | ||
|
|
76c4b528d3 | ||
|
|
68ccfa21c0 | ||
|
|
78d0166eb7 | ||
|
|
4140c4eb50 | ||
|
|
e2cc409e5a | ||
|
|
9b83283689 | ||
|
|
db8433ace3 | ||
|
|
6f1da5aa39 | ||
|
|
397483d339 | ||
|
|
37e35f4b47 | ||
|
|
86aa7e0f4f | ||
|
|
604ab60b63 | ||
|
|
0b3f362093 | ||
|
|
19acbb2278 | ||
|
|
ce3ecc4d21 | ||
|
|
c604cc1333 | ||
|
|
e7367e99be | ||
|
|
9953c955e3 | ||
|
|
7971ac18fc | ||
|
|
a81bec4d47 | ||
|
|
647f6afd77 | ||
|
|
9785a1baf3 | ||
|
|
e70ca03c03 | ||
|
|
95fb2ff882 | ||
|
|
b6e5f808d6 | ||
|
|
3f3dc9263c | ||
|
|
f67b8bd514 | ||
|
|
4d304cb549 | ||
|
|
201d58e8f4 | ||
|
|
091ea358bd | ||
|
|
af828d2c46 | ||
|
|
c14d89ffce | ||
|
|
b185200e8c | ||
|
|
2fac46f248 | ||
|
|
cffb68809c | ||
|
|
13d70fcef2 | ||
|
|
bf20e44b85 | ||
|
|
9cf1efc316 | ||
|
|
3655d94869 | ||
|
|
196ce69a12 | ||
|
|
c7a0e277f2 | ||
|
|
57c9e6b477 | ||
|
|
64bc1997ba | ||
|
|
21bb716af4 | ||
|
|
a40adbb99a | ||
|
|
d79e200650 | ||
|
|
3b9ff8a306 | ||
|
|
af4d918938 | ||
|
|
3289012f64 | ||
|
|
e147002e00 | ||
|
|
099d05064e | ||
|
|
4eb411ef28 | ||
|
|
14885d9efa | ||
|
|
17faa749b2 | ||
|
|
5fce65ac57 | ||
|
|
357492acb2 | ||
|
|
23799353b5 | ||
|
|
cf6d12b7c8 | ||
|
|
5af6caea6e | ||
|
|
d66ff13d0f | ||
|
|
7599da1d40 | ||
|
|
04f1f5a73f | ||
|
|
f5721592f7 | ||
|
|
5abee5f69a | ||
|
|
3690fb1bc4 | ||
|
|
2765343340 | ||
|
|
afe7a49ef0 | ||
|
|
b6666290ba | ||
|
|
c478eebb0e | ||
|
|
d731b36c1f | ||
|
|
ac4a800b78 | ||
|
|
30b55afdd4 | ||
|
|
76c4f1d411 | ||
|
|
d66ac8327e | ||
|
|
ccda41b15b | ||
|
|
0c06a6dccd | ||
|
|
8737937875 | ||
|
|
5dd3492aea | ||
|
|
77689a3eaa | ||
|
|
b22ac6ab04 | ||
|
|
2fdff34ed0 | ||
|
|
f9e9334934 | ||
|
|
856a825a74 | ||
|
|
df960f84ea | ||
|
|
bfe1a2f9e8 | ||
|
|
fd2b0dbf23 | ||
|
|
5860302ce7 | ||
|
|
4592b5dfba | ||
|
|
6a10992812 | ||
|
|
8ae2ed4d93 | ||
|
|
b1963a718e | ||
|
|
f47e4dd298 | ||
|
|
c24518c1a4 | ||
|
|
97e2db1b7b | ||
|
|
bd4bdf8aea | ||
|
|
38643e7fde | ||
|
|
2cfa655750 | ||
|
|
8936c3d6eb | ||
|
|
4291031ace | ||
|
|
7945f3ffed | ||
|
|
a1c0af3f00 | ||
|
|
b5bfc1d7b2 | ||
|
|
1d2ba93e48 | ||
|
|
c08df9af40 | ||
|
|
be166f5856 | ||
|
|
e531c78997 | ||
|
|
8ed6cd9fd6 | ||
|
|
c1d55b91a2 | ||
|
|
3dcfa02372 | ||
|
|
b6826f7483 | ||
|
|
cd3d84cf9a | ||
|
|
010ce326ea | ||
|
|
2577797772 | ||
|
|
05e2952815 | ||
|
|
6ae9e8e043 | ||
|
|
182b7e3ac2 | ||
|
|
8bb365db2a | ||
|
|
0cb57d084d | ||
|
|
5c174b007c | ||
|
|
35364c949a | ||
|
|
814b2c0b7b | ||
|
|
3d0e0804ca |
No files matched your search
@@ -1,7 +1,7 @@
|
||||
<!-- Author: fruit.com.cn -->
|
||||
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<uses-permission android:name="android.permission.INTERNET"/>
|
||||
<uses-permission
|
||||
android:name="android.permission.INTERNET"/>
|
||||
<application
|
||||
android:label="FruitShorts"
|
||||
android:name="${applicationName}"
|
||||
@@ -23,9 +23,8 @@
|
||||
while the Flutter UI initializes. After that, this theme continues
|
||||
to determine the Window background behind the Flutter UI. -->
|
||||
<meta-data
|
||||
android:name="io.flutter.embedding.android.NormalTheme"
|
||||
android:resource="@style/NormalTheme"
|
||||
/>
|
||||
android:name="io.flutter.embedding.android.NormalTheme"
|
||||
android:resource="@style/NormalTheme"/>
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN"/>
|
||||
<category android:name="android.intent.category.LAUNCHER"/>
|
||||
@@ -35,7 +34,7 @@
|
||||
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
|
||||
<meta-data
|
||||
android:name="flutterEmbedding"
|
||||
android:value="2" />
|
||||
android:value="2"/>
|
||||
</application>
|
||||
<!-- Required to query activities that can process text, see:
|
||||
https://developer.android.com/training/package-visibility and
|
||||
@@ -44,8 +43,10 @@
|
||||
In particular, this is used by the Flutter engine in io.flutter.plugin.text.ProcessTextPlugin. -->
|
||||
<queries>
|
||||
<intent>
|
||||
<action android:name="android.intent.action.PROCESS_TEXT"/>
|
||||
<data android:mimeType="text/plain"/>
|
||||
<action
|
||||
android:name="android.intent.action.PROCESS_TEXT"/>
|
||||
<data
|
||||
android:mimeType="text/plain"/>
|
||||
</intent>
|
||||
</queries>
|
||||
</manifest>
|
||||
@@ -36,6 +36,9 @@ class MainActivity : FlutterActivity() {
|
||||
private var imeInset = 0
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
||||
splashScreen.setOnExitAnimationListener { screen -> screen.remove() }
|
||||
}
|
||||
super.onCreate(savedInstanceState)
|
||||
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
||||
}
|
||||
|
||||
|
Before Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 7.0 KiB |
|
Before Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 9.1 KiB |
|
Before Width: | Height: | Size: 6.8 KiB After Width: | Height: | Size: 3.1 KiB |
|
Before Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 9.1 KiB |
@@ -1,4 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Author: fruit.com.cn -->
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:drawable="@color/splash_background" />
|
||||
<item>
|
||||
<bitmap
|
||||
android:gravity="center"
|
||||
android:src="@drawable/splash_screen" />
|
||||
</item>
|
||||
</layer-list>
|
||||
|
Before Width: | Height: | Size: 19 KiB |
|
Before Width: | Height: | Size: 31 KiB |
|
Before Width: | Height: | Size: 43 KiB |
@@ -1,4 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Author: fruit.com.cn -->
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:drawable="@color/splash_background" />
|
||||
<item>
|
||||
<bitmap
|
||||
android:gravity="center"
|
||||
android:src="@drawable/splash_screen" />
|
||||
</item>
|
||||
</layer-list>
|
||||
|
After Width: | Height: | Size: 21 KiB |
|
After Width: | Height: | Size: 20 KiB |
|
Before Width: | Height: | Size: 69 B After Width: | Height: | Size: 69 B |
@@ -1,9 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Author: fruit.com.cn -->
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:drawable="@color/splash_background" />
|
||||
<item>
|
||||
<bitmap android:gravity="fill" android:src="@drawable/background"/>
|
||||
</item>
|
||||
<item>
|
||||
<bitmap android:gravity="center" android:src="@drawable/splash"/>
|
||||
<bitmap
|
||||
android:gravity="center"
|
||||
android:src="@drawable/splash_screen" />
|
||||
</item>
|
||||
</layer-list>
|
||||
@@ -1,6 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Author: fruit.com.cn -->
|
||||
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:drawable="@color/splash_background" />
|
||||
<item>
|
||||
<bitmap
|
||||
android:gravity="center"
|
||||
android:src="@drawable/splash_screen" />
|
||||
</item>
|
||||
</layer-list>
|
||||
|
Before Width: | Height: | Size: 19 KiB |
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 7.2 KiB |
|
Before Width: | Height: | Size: 23 KiB |
|
Before Width: | Height: | Size: 31 KiB |
|
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 37 KiB |
|
Before Width: | Height: | Size: 43 KiB |
|
Before Width: | Height: | Size: 31 KiB After Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 51 KiB |
|
Before Width: | Height: | Size: 69 B After Width: | Height: | Size: 69 B |
@@ -1,9 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Author: fruit.com.cn -->
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:drawable="@color/splash_background" />
|
||||
<item>
|
||||
<bitmap android:gravity="fill" android:src="@drawable/background"/>
|
||||
</item>
|
||||
<item>
|
||||
<bitmap android:gravity="center" android:src="@drawable/splash"/>
|
||||
<bitmap
|
||||
android:gravity="center"
|
||||
android:src="@drawable/splash_screen" />
|
||||
</item>
|
||||
</layer-list>
|
||||
@@ -1,5 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@mipmap/ic_launcher_background"/>
|
||||
<foreground android:drawable="@drawable/ic_launcher_foreground"/>
|
||||
<background android:drawable="@color/ic_launcher_background"/>
|
||||
<foreground>
|
||||
<inset
|
||||
android:drawable="@drawable/ic_launcher_foreground"
|
||||
android:inset="16%" />
|
||||
</foreground>
|
||||
</adaptive-icon>
|
||||
|
Before Width: | Height: | Size: 4.3 KiB After Width: | Height: | Size: 2.3 KiB |
|
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 6.1 KiB After Width: | Height: | Size: 2.7 KiB |
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 5.8 KiB |
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 6.3 KiB |
@@ -1,11 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Author: fruit.com.cn -->
|
||||
|
||||
<resources>
|
||||
<style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar">
|
||||
<item name="android:windowBackground">@drawable/launch_background</item>
|
||||
<item name="android:windowSplashScreenBackground">@color/splash_background</item>
|
||||
<item name="android:windowSplashScreenAnimatedIcon">@drawable/android12splash</item>
|
||||
<item name="android:forceDarkAllowed">false</item>
|
||||
<item name="android:windowFullscreen">false</item>
|
||||
<item name="android:windowDrawsSystemBarBackgrounds">false</item>
|
||||
<item name="android:windowLayoutInDisplayCutoutMode">shortEdges</item>
|
||||
<item name="android:windowSplashScreenBackground">#000000</item>
|
||||
<item name="android:windowSplashScreenAnimatedIcon">@drawable/splash_brand</item>
|
||||
<item name="android:windowSplashScreenAnimationDuration">0</item>
|
||||
</style>
|
||||
<style name="NormalTheme" parent="@android:style/Theme.Black.NoTitleBar">
|
||||
<item name="android:windowBackground">@color/splash_background</item>
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Author: fruit.com.cn -->
|
||||
|
||||
<resources>
|
||||
<style name="LaunchTheme" parent="@android:style/Theme.Light.NoTitleBar">
|
||||
<item name="android:windowBackground">@drawable/launch_background</item>
|
||||
<item name="android:windowSplashScreenBackground">@color/splash_background</item>
|
||||
<item name="android:windowSplashScreenAnimatedIcon">@drawable/android12splash</item>
|
||||
<item name="android:forceDarkAllowed">false</item>
|
||||
<item name="android:windowFullscreen">false</item>
|
||||
<item name="android:windowDrawsSystemBarBackgrounds">false</item>
|
||||
<item name="android:windowLayoutInDisplayCutoutMode">shortEdges</item>
|
||||
<item name="android:windowSplashScreenBackground">#000000</item>
|
||||
<item name="android:windowSplashScreenAnimatedIcon">@drawable/splash_brand</item>
|
||||
<item name="android:windowSplashScreenAnimationDuration">0</item>
|
||||
</style>
|
||||
<style name="NormalTheme" parent="@android:style/Theme.Light.NoTitleBar">
|
||||
<item name="android:windowBackground">@color/splash_background</item>
|
||||
|
||||
@@ -2,5 +2,6 @@
|
||||
<!-- Author: fruit.com.cn -->
|
||||
|
||||
<resources>
|
||||
<color name="splash_background">#1F1B16</color>
|
||||
</resources>
|
||||
<color name="splash_background">#000000</color>
|
||||
<color name="ic_launcher_background">#FF6B2C</color>
|
||||
</resources>
|
||||
|
After Width: | Height: | Size: 1.9 KiB |
|
After Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 48 KiB After Width: | Height: | Size: 41 KiB |
|
Before Width: | Height: | Size: 47 KiB After Width: | Height: | Size: 24 KiB |
|
Before Width: | Height: | Size: 39 KiB After Width: | Height: | Size: 42 KiB |
@@ -1124,3 +1124,198 @@ $ flutter test
|
||||
- 播放量贴封面右下角(底 2、右 6),火焰图标 11 + 12/w400 纯文字,间距 4,并保留极淡底部渐变。
|
||||
- 修复二级 chip 运行时颜色误用 `const TextStyle` 的编译错误,并校正相关测试 Finder 类型。
|
||||
- 全部短剧的地区、字幕、配音筛选 UI 已占位;以下接口待补:地区、字幕/配音筛选数据。
|
||||
|
||||
## 2026-10-22 短剧列表刷新体验优化
|
||||
|
||||
- 公共下拉刷新统一为白指示器、40 displacement、Bouncing + AlwaysScrollable,并在下拉期间屏蔽内容点击与滚动条。
|
||||
- 首页移除父级 feed 监听,网格、剧单和全部短剧改为局部监听,刷新时保留旧数据及原滚动位置。
|
||||
- 剧单、全部短剧、追剧沿用相同刷新策略;首帧加载与刷新指示器分离。
|
||||
- 按当前流程未执行 analyze/test。
|
||||
|
||||
## 2026-10-22 ChangeNotifier 监听生命周期排查
|
||||
|
||||
- 全仓核对手动 add/remove;首页、推荐和追剧改为内容区单实例 ListenableBuilder,避免重复订阅。
|
||||
- 播放器进度监听改为具名回调,在切换、重建会话和 dispose 时解绑;评论输入弹窗补 controller 更换迁移。
|
||||
- `_onFeedChanged` 已无源码调用链,报错来源为热重载前注册的旧 tear-off;需完全关闭 App 后冷启动。
|
||||
- 按当前流程未执行 analyze/test。
|
||||
|
||||
## 2026-10-22 二级标签筛选按钮右对齐
|
||||
|
||||
- 三横线热区由 44 宽改为 26×26,消除 44 宽居中盒造成的视觉右边距偏移。
|
||||
- 标签滚动区与按钮间距改为 6,按钮右边缘固定对齐页面 14 边距。
|
||||
- 补充按钮尺寸与屏幕右边距断言;按当前流程未执行 analyze/test。
|
||||
|
||||
## 2026-10-22 首页导航图标调整
|
||||
|
||||
- `AppRootTab.home` 未选中改为 `theaters_outlined`,选中改为 `theaters`。
|
||||
- 其余三个根导航图标、26 尺寸及白/灰颜色规则保持不变;测试断言同步。
|
||||
- 按当前流程未执行 analyze/test。
|
||||
|
||||
## 2026-10-22 首页圆形胶片盘图标
|
||||
|
||||
- `AppRootTab` 新增可选 `assetPath`,首页使用 `assets/icon/film_reel.png`。
|
||||
- 共享导航通过 `ColorFiltered + Image.asset` 按选中态着色,尺寸保持 26,缺图回退胶片 Material 图标。
|
||||
- 推荐、追剧、我的图标不变;素材与测试断言同步,按当前流程未执行 analyze/test。
|
||||
|
||||
## 2026-10-22 首页选中态实心摄影机
|
||||
|
||||
- `AppRootTab` 新增 `selectedAssetPath`,首页选中使用 `film_reel_filled.png`,未选中使用描边版。
|
||||
- 共享导航保持 `ColorFiltered(srcIn)` 与 26×26,缺图按选中态回退实心/描边胶片图标。
|
||||
- 推荐、追剧、我的不变;测试断言同步,按当前流程未执行 analyze/test。
|
||||
|
||||
## 2026-10-22 底部导航图标与文字加大
|
||||
|
||||
- 公共 token 调整为图标 30、文字 13、图标文字间距 5、内容高度 62。
|
||||
- 图片首页图标同步使用 30×30;SafeArea 仍在内容区外独立追加,四等分布局不变。
|
||||
- 尺寸测试断言同步,按当前流程未执行 analyze/test。
|
||||
|
||||
## 2026-10-22 推荐页沉浸式布局对齐
|
||||
|
||||
- 推荐/剧单/全部短剧顶部改为视频内居中浮层,17 字号、无下划线,搜索固定右侧 14。
|
||||
- 右侧保留收藏/点赞/选集,白色 32 图标、28 间距;评论、分享入口已从该浮层移除。
|
||||
- 底部信息重构为标题、真实热度、剧名、题材/集数、可展开简介与渐变观看全集按钮。
|
||||
- 新增三语“观看全集”文案;按当前流程未执行 analyze/test。
|
||||
- 榜单行支持可选排名:有名次显示 `TOPn·热播榜`,无名次回退“热播榜”;热度值改用 `w` 格式。
|
||||
- 题材改为空格分隔,集数固定右侧单行;右侧操作栏改为距屏幕边缘 8,底部位置不变。
|
||||
|
||||
## 2026-10-22 推荐页底部信息二次修正
|
||||
|
||||
- 按最新反馈移除整行榜单与热度胶囊,信息顺序收敛为标题、剧名、标签、简介、观看全集。
|
||||
- 剧名 19/w600,箭头 20 白色并紧邻剧名;标签行改为 13/w600 亮灰内联布局。
|
||||
- 简介「展开/收起」沿用现有三语文案;进度条热区恢复 24 并接入拖动自动清屏与预览卡片。
|
||||
- 拖动仅控制视频浮层内容,顶部导航与根底栏保持常驻。
|
||||
- 进度条固定中心并动画到 6 高,命中高度 32,时间气泡限制在左右 12;end/cancel/pointer 兜底均恢复拖动前状态。
|
||||
- 修复 `scrubCancelRequest` 误置于 `initState` 的编译错误,并清理推荐页未使用变量;`flutter analyze` 无问题。
|
||||
- 观看全集按钮相对进度条上移 8,间距调整为 20;按钮改为屏幕宽度 70% 左对齐,`flutter analyze` 无问题。
|
||||
|
||||
## 2026-10-22 进度条按下与拖动彻底修复
|
||||
|
||||
- Slider 不再在 `onChangeStart` 清屏;首次真实移动后才进入 scrub,轨道 2/6、thumb 6/8。
|
||||
- 推荐流拖动使用独立 opaque 手势与 pointer 兜底,end/cancel 同时恢复浮层和轨道。
|
||||
- 推荐浮层改为 AnimatedOpacity + IgnorePointer,进度条节点始终留在树中;scrub setState 均加 mounted 守卫。
|
||||
- `flutter test test/player/seek_scrub_visibility_test.dart`:6 项测试全部通过。
|
||||
|
||||
## 2026-10-22 推荐页播放跳转修正
|
||||
|
||||
- 标题、剧名行和观看全集统一通过 `playDramaFromCatalog` 打开非 `homeMode` 逐集播放页。
|
||||
- 仅含集数的剧集标题不再显示在标题上方,集数只保留下方进度文案。
|
||||
- `flutter analyze`:No issues found。
|
||||
|
||||
## 2026-10-22 推荐页横向切换
|
||||
|
||||
- 推荐、剧单、全部短剧改为共享 PageController 的横向 PageView,点击与滑动均驱动同一选中态。
|
||||
- 三页使用 AutomaticKeepAliveClientMixin 保留视频、滚动位置和筛选状态;顶部导航固定在外层。
|
||||
- `flutter analyze`:No issues found。
|
||||
|
||||
## 2026-10-22 全部短剧布局重排
|
||||
|
||||
- 四行筛选统一 28 高、8 行距、24 项目间距;选中 chip 改为 `#4A1E1E`、白字 13/w600、圆角 14。
|
||||
- 最热/最新改为纯文字选中态,三横线筛选固定在右端;网格改为左右 12、列距 6、行距 12。
|
||||
- 第三行筛选完整展示,卡片继续复用首页组件;`flutter analyze`:No issues found。
|
||||
- 筛选项字号提升到 15、圆角 15;筛选区移出滚动容器并固定吸顶,下拉刷新仅作用于网格。
|
||||
- 四行首项文字统一到同一 x;行高 30、行距 6、项目距 12,第 4 行保持弹性空白后固定筛选图标。
|
||||
- 按最新截图改为 16sp、32 高、10 行距、16 项距;选中态为 `#21090E` 底配 `#FF4D6A` 粉字。
|
||||
- 第 4 行复用选中胶囊样式,右侧改为 44×44 圆形深灰按钮和 22 三横线图标;`flutter analyze` 无问题。
|
||||
- 筛选行距收紧到 6、项距 10,chip 左右 padding 12;四行均可横向回弹滑动。
|
||||
- 第 4 行仅最热/最新在滚动区内,44 圆形筛选按钮固定在滚动区外;`flutter analyze` 无问题。
|
||||
- 四行统一复用 `_filterRow` 构建,筛选区仅保留一层左右 12 padding。
|
||||
- 新增量化测试断言四行首项 x 均为 12、相邻 chip 间距均为 10;`flutter analyze` 无问题。
|
||||
- 修复横向 viewport 对短内容居中:滚动内容最小宽度撑满视口后由 Row.start 排列。
|
||||
- `flutter test test/recommend/all_dramas_filter_alignment_test.dart`:1 项测试通过。
|
||||
|
||||
## 2026-10-22 首页二级标签移除筛选按钮
|
||||
|
||||
- 首页二级标签行改为纯横向滑动,右侧三横线按钮不渲染也不占位。
|
||||
- 删除不再使用的筛选回调、尺寸 token、颜色和 CustomPainter;全部短剧页筛选按钮保持不变。
|
||||
- `flutter analyze`:No issues found。
|
||||
- 按后续更正恢复首页透明三横线按钮(26、无背景、`#7A7A7E`),删除全部短剧第 4 行圆形按钮及回调链路。
|
||||
|
||||
## 2026-10-22 追剧页三列改造
|
||||
|
||||
- 追剧页移除预约 tab,改为追剧/播放历史双页横向切换,并保留各自滚动位置。
|
||||
- 追剧与历史统一三列卡片,新增固定加号卡片,历史进度与编辑删除能力保留。
|
||||
- 按最新口径调整列距 6、行距 12、封面圆角 6;`flutter analyze`:No issues found。
|
||||
|
||||
## 2026-10-22 播放历史单列列表
|
||||
|
||||
- 追剧保持三列网格,播放历史改为左封面右信息的单列列表,行距 16。
|
||||
- 历史卡片补充 96×128 封面、观看进度、已看百分比、继续观看和编辑删除。
|
||||
- 追剧加号卡片移到全部追剧卡片之后,空列表时仍在左上角。
|
||||
- 加号改为 `#8E8E93`、28 尺寸、1.5 描边,卡片底色与圆角不变。
|
||||
- 刷新、分页与各页独立滚动位置保持;`flutter analyze`:No issues found。
|
||||
|
||||
## 2026-10-22 追剧页切换与编辑按钮修正
|
||||
|
||||
- 追剧与历史页增加 keep-alive,tab 与编辑态改用局部 ValueNotifier 更新,切换不再重建整个页面。
|
||||
- 编辑图标调整为 20、`#B0B0B0`,热区 40×40,保持右侧 14 边距和垂直居中。
|
||||
- 列表刷新期间保留已有数据与各页滚动位置;`flutter analyze`:No issues found。
|
||||
|
||||
## 2026-10-22 播放历史继续观看按钮微调
|
||||
|
||||
- 继续观看改为无边框、无底色的纯文字按钮,默认 `#B0B0B0`、12/w500,按压态使用品牌色。
|
||||
- 保持 28 高点击热区和右侧零间距;未执行测试或 analyze。
|
||||
|
||||
## 2026-10-22 我的页渐变与图标网格
|
||||
|
||||
- 页面背景改为暖黑三段纵向渐变,用户区与 VIP 卡布局保持不变。
|
||||
- 行式入口替换为 4 列图标网格,7 个原入口按顺序保留,第 8 格为空占位。
|
||||
- 网格使用 14 边距、半透明深灰底、圆角 12 和仅内部 1px 分隔线;`flutter analyze`:No issues found。
|
||||
- 渐变增强为 `#3A1B0E`/`#1A0C07`/黑色并叠加顶部品牌橙径向光晕,同时移除页面级「我的」标题栏。
|
||||
- 7 个宫格图标分别使用金币金、天蓝、薄荷绿、粉红、紫色、青色和冷灰;`flutter analyze`:No issues found。
|
||||
|
||||
## 2026-10-22 我的页补充内容
|
||||
|
||||
- VIP 与宫格之间新增继续观看横向列表、追剧/观看记录/金币统计面板,继续观看最多 10 条。
|
||||
- 宫格后新增常见问题与关于我们入口;关于页版本暂用与 pubspec 同步的常量占位。
|
||||
- 继续观看全部入口可切到追剧页播放历史 tab;`flutter analyze`:No issues found。
|
||||
- 用户区昵称与 UID 收紧为 4 间距,昵称列相对头像垂直居中;UID 12、复制图标 14。
|
||||
- UID 行改用 GestureDetector 并锁定 16 高,昵称与 UID 间距 2、昵称行高 1.15,避免 Material 热区撑高;`flutter analyze`:No issues found。
|
||||
|
||||
## 2026-10-22 推荐剧单渐变背景
|
||||
|
||||
- 仅为推荐页「剧单」子页增加暖黑三段渐变和品牌橙径向光晕,推荐视频与全部短剧背景不变。
|
||||
- 渐变复用「我的」页色值,光晕使用 `#26FF6B2C`;分区与卡片样式保持原样;`flutter analyze`:No issues found。
|
||||
|
||||
## 2026-10-22 全站深色视觉统一
|
||||
|
||||
- 全局 token 改为纯黑页面、`#16161A` 卡片、`#1C1C1E` 描边/分割线与 B0/8E 文本层级,旧深蓝页面渐变替换为暖黑渐变。
|
||||
- 普通二级页标题栏改为透明、白色标题与返回图标;统一卡片 12 圆角、1px 描边和无阴影策略。
|
||||
- 覆盖新剧、筛选、榜单、预约、收藏、观看历史、下载、设置、钱包、VIP、通知、详情、登录、关于;播放器沉浸区保持纯黑。
|
||||
- `flutter analyze`:No issues found。
|
||||
|
||||
## 2026-10-22 统一下拉与加载指示器
|
||||
|
||||
- 下拉刷新统一为 40×40、60% 黑底圆角指示器内嵌 20 白色加载圈,不再显示任何状态文字。
|
||||
- 网络分页与本地分页 footer 统一仅显示白色加载圈,无更多状态完全隐藏;通知页补触底自动加载。
|
||||
- 移除不再使用的刷新提示与无更多文案;`flutter analyze`:No issues found。
|
||||
|
||||
## 2026-10-22 首页热播榜重做
|
||||
|
||||
- 首页榜单 tab 改为独立领奖台 + 单列排行布局,不再复用三列网格。
|
||||
- 前三名按 2/1/3 排列,冠军放大并上移;第 4 名起使用大号描边名次与横向信息行。
|
||||
- 榜单沿用现有播放热度排序、分页和播放逻辑;`flutter analyze`:No issues found。
|
||||
|
||||
## 2026-10-22 播放器双击点赞与飘心
|
||||
|
||||
- 沉浸式播放器改用 onTapUp + 280ms Timer 判定双击,双击取消单击,长按左右倍速与中间更多保持不变。
|
||||
- 双击和右侧心形共用点赞方法,成功后控制器通知并点亮红色实心心形,失败由 controller 回滚并使用 Toast。
|
||||
- 飘心层使用独立 IgnorePointer Stack,动画完成后自动移除;`flutter analyze`:No issues found。
|
||||
- `flutter test test/player/double_tap_like_test.dart`:2 项测试全部通过。
|
||||
- 移除视频表面点击识别器,双击后增加 300ms 暂停防护;飘心收敛为 3~4 颗、20~26、±18、90~120dp、600~700ms。
|
||||
- 双击窗口延长至 320ms,单击 Timer 使用点击序号校验,双击后保留 350ms 播放切换保护。
|
||||
- `double_tap_like_test.dart` 覆盖 120/250/300ms 双击与 500ms 单击恢复:2 项测试全部通过。
|
||||
|
||||
## 2026-10-22 统一二级搜索页
|
||||
|
||||
- 首页与推荐/剧单/全部短剧搜索入口统一 push SearchPage,不再切换推荐 tab 聚焦。
|
||||
- 搜索页提供返回、自动聚焦输入框与取消,复用 `/app/search` 逻辑和首页三列卡片。
|
||||
- 清理旧的 searchRequest/focusSearch/syncSearch 参数;`flutter analyze`:No issues found。
|
||||
- 搜索页结果改为独立两列卡片,左右 14、列距 12、行距 16,并移除 HomeFeedCard 复用。
|
||||
- 搜索结果支持下拉刷新:保留旧结果按当前关键词重取第一页,空关键词直接回弹且不改变焦点。
|
||||
|
||||
## 2026-10-22 App 图标与开屏更新
|
||||
|
||||
- Launcher/Android 12 启动背景统一纯黑,自适应图标背景改为品牌橙。
|
||||
- Android/iOS 图标与启动资源已重新生成;应用内开屏固定 splash_logo,宽 200 等比居中。
|
||||
- `flutter analyze`:No issues found。
|
||||
- 移除 Flutter 内 `_startupSplash` 与 `startup-splash`,只保留系统原生开屏;最新斜体字标素材已重新生成。
|
||||
@@ -11,6 +11,7 @@
|
||||
331C808B294A63AB00263BE5 /* RunnerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 331C807B294A618700263BE5 /* RunnerTests.swift */; };
|
||||
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
|
||||
74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; };
|
||||
8C4E1A022F9A4B1000C636F3 /* WirelessDataPrompt.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8C4E1A012F9A4B1000C636F3 /* WirelessDataPrompt.swift */; };
|
||||
7884E8682EC3CC0700C636F2 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7884E8672EC3CC0400C636F2 /* SceneDelegate.swift */; };
|
||||
78A318202AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage in Frameworks */ = {isa = PBXBuildFile; productRef = 78A3181F2AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage */; };
|
||||
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; };
|
||||
@@ -49,6 +50,7 @@
|
||||
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
|
||||
74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = "<group>"; };
|
||||
74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
|
||||
8C4E1A012F9A4B1000C636F3 /* WirelessDataPrompt.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WirelessDataPrompt.swift; sourceTree = "<group>"; };
|
||||
7884E8672EC3CC0400C636F2 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = "<group>"; };
|
||||
78E0A7A72DC9AD7400C4905E /* FlutterGeneratedPluginSwiftPackage */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = FlutterGeneratedPluginSwiftPackage; path = Flutter/ephemeral/Packages/FlutterGeneratedPluginSwiftPackage; sourceTree = "<group>"; };
|
||||
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = "<group>"; };
|
||||
@@ -122,6 +124,7 @@
|
||||
1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */,
|
||||
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */,
|
||||
74858FAE1ED2DC5600515810 /* AppDelegate.swift */,
|
||||
8C4E1A012F9A4B1000C636F3 /* WirelessDataPrompt.swift */,
|
||||
7884E8672EC3CC0400C636F2 /* SceneDelegate.swift */,
|
||||
74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */,
|
||||
);
|
||||
@@ -282,6 +285,7 @@
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */,
|
||||
8C4E1A022F9A4B1000C636F3 /* WirelessDataPrompt.swift in Sources */,
|
||||
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */,
|
||||
7884E8682EC3CC0700C636F2 /* SceneDelegate.swift in Sources */,
|
||||
);
|
||||
|
||||
@@ -2,6 +2,8 @@ import Flutter
|
||||
import UIKit
|
||||
import AVFoundation
|
||||
|
||||
private let thumbnailHTTPHeaderFieldsKey = "AVURLAssetHTTPHeaderFieldsKey"
|
||||
|
||||
private final class ThumbnailResponseGate {
|
||||
private let lock = NSLock()
|
||||
private var completed = false
|
||||
@@ -29,12 +31,13 @@ final class RunnerFlutterViewController: FlutterViewController {
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
view.backgroundColor = UIColor(red: 16.0 / 255.0, green: 12.0 / 255.0, blue: 10.0 / 255.0, alpha: 1)
|
||||
view.backgroundColor = .black
|
||||
}
|
||||
}
|
||||
|
||||
@main
|
||||
@objc class AppDelegate: FlutterAppDelegate, FlutterImplicitEngineDelegate {
|
||||
private let wirelessDataPrompt = WirelessDataPrompt()
|
||||
private let thumbnailQueue = DispatchQueue(
|
||||
label: "com.stormg.lumadrama.thumbnail",
|
||||
qos: .userInitiated
|
||||
@@ -48,8 +51,18 @@ final class RunnerFlutterViewController: FlutterViewController {
|
||||
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
|
||||
}
|
||||
|
||||
override func applicationDidBecomeActive(_ application: UIApplication) {
|
||||
super.applicationDidBecomeActive(application)
|
||||
requestWirelessDataPrompt()
|
||||
}
|
||||
|
||||
func requestWirelessDataPrompt() {
|
||||
wirelessDataPrompt.requestSystemPrompt()
|
||||
}
|
||||
|
||||
func didInitializeImplicitFlutterEngine(_ engineBridge: FlutterImplicitEngineBridge) {
|
||||
GeneratedPluginRegistrant.register(with: engineBridge.pluginRegistry)
|
||||
registerWirelessDataChannel(engineBridge)
|
||||
let channel = FlutterMethodChannel(
|
||||
name: "com.stormg.lumadrama/share",
|
||||
binaryMessenger: engineBridge.applicationRegistrar.messenger()
|
||||
@@ -104,7 +117,7 @@ final class RunnerFlutterViewController: FlutterViewController {
|
||||
|
||||
let options: [String: Any]? = headers.isEmpty
|
||||
? nil
|
||||
: [AVURLAssetHTTPHeaderFieldsKey: headers]
|
||||
: [thumbnailHTTPHeaderFieldsKey: headers]
|
||||
let asset = AVURLAsset(url: assetUrl, options: options)
|
||||
let generator = AVAssetImageGenerator(asset: asset)
|
||||
generator.appliesPreferredTrackTransform = true
|
||||
@@ -130,4 +143,22 @@ final class RunnerFlutterViewController: FlutterViewController {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func registerWirelessDataChannel(_ engineBridge: FlutterImplicitEngineBridge) {
|
||||
let channel = FlutterMethodChannel(
|
||||
name: WirelessDataPrompt.channelName,
|
||||
binaryMessenger: engineBridge.applicationRegistrar.messenger()
|
||||
)
|
||||
channel.setMethodCallHandler { [weak self] call, result in
|
||||
guard call.method == WirelessDataPrompt.awaitDecisionMethod else {
|
||||
result(FlutterMethodNotImplemented)
|
||||
return
|
||||
}
|
||||
guard let self else {
|
||||
result(nil)
|
||||
return
|
||||
}
|
||||
self.wirelessDataPrompt.awaitDecision(result)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Before Width: | Height: | Size: 48 KiB After Width: | Height: | Size: 43 KiB |
|
Before Width: | Height: | Size: 866 B After Width: | Height: | Size: 412 B |
|
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 907 B |
|
Before Width: | Height: | Size: 3.9 KiB After Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 593 B |
|
Before Width: | Height: | Size: 3.7 KiB After Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 6.1 KiB After Width: | Height: | Size: 2.3 KiB |
|
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 907 B |
|
Before Width: | Height: | Size: 5.4 KiB After Width: | Height: | Size: 2.1 KiB |
|
Before Width: | Height: | Size: 8.9 KiB After Width: | Height: | Size: 3.6 KiB |
|
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 7.3 KiB After Width: | Height: | Size: 2.8 KiB |
|
Before Width: | Height: | Size: 3.6 KiB After Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 8.7 KiB After Width: | Height: | Size: 3.3 KiB |
|
Before Width: | Height: | Size: 8.9 KiB After Width: | Height: | Size: 3.6 KiB |
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 6.0 KiB |
|
Before Width: | Height: | Size: 4.7 KiB After Width: | Height: | Size: 2.3 KiB |
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 5.8 KiB |
|
Before Width: | Height: | Size: 5.2 KiB After Width: | Height: | Size: 2.5 KiB |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 7.1 KiB |
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 6.3 KiB |
|
Before Width: | Height: | Size: 69 B After Width: | Height: | Size: 69 B |
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 6.0 KiB |
|
Before Width: | Height: | Size: 23 KiB After Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 37 KiB After Width: | Height: | Size: 24 KiB |
@@ -16,18 +16,13 @@
|
||||
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleToFill" image="LaunchBackground" translatesAutoresizingMaskIntoConstraints="NO" id="tWc-Dq-wcI"/>
|
||||
<imageView opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" image="LaunchImage" translatesAutoresizingMaskIntoConstraints="NO" id="YRO-k0-Ey4"></imageView>
|
||||
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" image="LaunchImage" translatesAutoresizingMaskIntoConstraints="NO" id="YRO-k0-Ey4"/>
|
||||
</subviews>
|
||||
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<color key="backgroundColor" red="0" green="0" blue="0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<constraints>
|
||||
<constraint firstItem="YRO-k0-Ey4" firstAttribute="leading" secondItem="Ze5-6b-2t3" secondAttribute="leading" id="3T2-ad-Qdv"/>
|
||||
<constraint firstItem="tWc-Dq-wcI" firstAttribute="bottom" secondItem="Ze5-6b-2t3" secondAttribute="bottom" id="RPx-PI-7Xg"/>
|
||||
<constraint firstItem="tWc-Dq-wcI" firstAttribute="top" secondItem="Ze5-6b-2t3" secondAttribute="top" id="SdS-ul-q2q"/>
|
||||
<constraint firstAttribute="trailing" secondItem="tWc-Dq-wcI" secondAttribute="trailing" id="Swv-Gf-Rwn"/>
|
||||
<constraint firstAttribute="trailing" secondItem="YRO-k0-Ey4" secondAttribute="trailing" id="TQA-XW-tRk"/>
|
||||
<constraint firstItem="YRO-k0-Ey4" firstAttribute="bottom" secondItem="Ze5-6b-2t3" secondAttribute="bottom" id="duK-uY-Gun"/>
|
||||
<constraint firstItem="tWc-Dq-wcI" firstAttribute="leading" secondItem="Ze5-6b-2t3" secondAttribute="leading" id="kV7-tw-vXt"/>
|
||||
<constraint firstItem="YRO-k0-Ey4" firstAttribute="top" secondItem="Ze5-6b-2t3" secondAttribute="top" id="xPn-NY-SIU"/>
|
||||
</constraints>
|
||||
</view>
|
||||
@@ -38,7 +33,6 @@
|
||||
</scene>
|
||||
</scenes>
|
||||
<resources>
|
||||
<image name="LaunchImage" width="1152" height="1152"/>
|
||||
<image name="LaunchBackground" width="1" height="1"/>
|
||||
<image name="LaunchImage" width="390" height="844"/>
|
||||
</resources>
|
||||
</document>
|
||||
@@ -1,109 +1,111 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CADisableMinimumFrameDurationOnPhone</key>
|
||||
<true/>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>$(DEVELOPMENT_LANGUAGE)</string>
|
||||
<key>CFBundleDisplayName</key>
|
||||
<string>FruitShorts</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>$(EXECUTABLE_NAME)</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>FruitShorts</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>$(FLUTTER_BUILD_NAME)</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>$(FLUTTER_BUILD_NUMBER)</string>
|
||||
<key>LSRequiresIPhoneOS</key>
|
||||
<true/>
|
||||
<key>NSAppTransportSecurity</key>
|
||||
<dict>
|
||||
<key>NSAllowsArbitraryLoads</key>
|
||||
<key>CADisableMinimumFrameDurationOnPhone</key>
|
||||
<true/>
|
||||
<key>NSAllowsLocalNetworking</key>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>$(DEVELOPMENT_LANGUAGE)</string>
|
||||
<key>CFBundleDisplayName</key>
|
||||
<string>FruitShorts</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>$(EXECUTABLE_NAME)</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>FruitShorts</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>$(FLUTTER_BUILD_NAME)</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>$(FLUTTER_BUILD_NUMBER)</string>
|
||||
<key>LSRequiresIPhoneOS</key>
|
||||
<true/>
|
||||
<key>NSExceptionDomains</key>
|
||||
<key>NSAppTransportSecurity</key>
|
||||
<dict>
|
||||
<key>127.0.0.1</key>
|
||||
<key>NSAllowsArbitraryLoads</key>
|
||||
<true/>
|
||||
<key>NSAllowsLocalNetworking</key>
|
||||
<true/>
|
||||
<key>NSExceptionDomains</key>
|
||||
<dict>
|
||||
<key>NSExceptionAllowsInsecureHTTPLoads</key>
|
||||
<true/>
|
||||
<key>NSIncludesSubdomains</key>
|
||||
<true/>
|
||||
</dict>
|
||||
<key>localhost</key>
|
||||
<dict>
|
||||
<key>NSExceptionAllowsInsecureHTTPLoads</key>
|
||||
<true/>
|
||||
<key>NSIncludesSubdomains</key>
|
||||
<true/>
|
||||
</dict>
|
||||
<key>192.168.31.187</key>
|
||||
<dict>
|
||||
<key>NSExceptionAllowsInsecureHTTPLoads</key>
|
||||
<true/>
|
||||
<key>NSIncludesSubdomains</key>
|
||||
<true/>
|
||||
</dict>
|
||||
<key>39.162.50.99</key>
|
||||
<dict>
|
||||
<key>NSExceptionAllowsInsecureHTTPLoads</key>
|
||||
<true/>
|
||||
<key>NSIncludesSubdomains</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>NSLocalNetworkUsageDescription</key>
|
||||
<string>开发阶段需要访问同一局域网内的短剧内容服务。</string>
|
||||
<key>UIApplicationSceneManifest</key>
|
||||
<dict>
|
||||
<key>UIApplicationSupportsMultipleScenes</key>
|
||||
<false/>
|
||||
<key>UISceneConfigurations</key>
|
||||
<dict>
|
||||
<key>UIWindowSceneSessionRoleApplication</key>
|
||||
<array>
|
||||
<key>127.0.0.1</key>
|
||||
<dict>
|
||||
<key>UISceneClassName</key>
|
||||
<string>UIWindowScene</string>
|
||||
<key>UISceneConfigurationName</key>
|
||||
<string>flutter</string>
|
||||
<key>UISceneDelegateClassName</key>
|
||||
<string>$(PRODUCT_MODULE_NAME).SceneDelegate</string>
|
||||
<key>UISceneStoryboardFile</key>
|
||||
<string>Main</string>
|
||||
<key>NSExceptionAllowsInsecureHTTPLoads</key>
|
||||
<true/>
|
||||
<key>NSIncludesSubdomains</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</array>
|
||||
<key>localhost</key>
|
||||
<dict>
|
||||
<key>NSExceptionAllowsInsecureHTTPLoads</key>
|
||||
<true/>
|
||||
<key>NSIncludesSubdomains</key>
|
||||
<true/>
|
||||
</dict>
|
||||
<key>10.43.47.1</key>
|
||||
<dict>
|
||||
<key>NSExceptionAllowsInsecureHTTPLoads</key>
|
||||
<true/>
|
||||
<key>NSIncludesSubdomains</key>
|
||||
<true/>
|
||||
</dict>
|
||||
<key>39.162.50.99</key>
|
||||
<dict>
|
||||
<key>NSExceptionAllowsInsecureHTTPLoads</key>
|
||||
<true/>
|
||||
<key>NSIncludesSubdomains</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>NSLocalNetworkUsageDescription</key>
|
||||
<string>开发阶段需要访问同一局域网内的短剧内容服务。</string>
|
||||
<key>UIApplicationSceneManifest</key>
|
||||
<dict>
|
||||
<key>UIApplicationSupportsMultipleScenes</key>
|
||||
<false/>
|
||||
<key>UISceneConfigurations</key>
|
||||
<dict>
|
||||
<key>UIWindowSceneSessionRoleApplication</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>UISceneClassName</key>
|
||||
<string>UIWindowScene</string>
|
||||
<key>UISceneConfigurationName</key>
|
||||
<string>flutter</string>
|
||||
<key>UISceneDelegateClassName</key>
|
||||
<string>$(PRODUCT_MODULE_NAME).SceneDelegate</string>
|
||||
<key>UISceneStoryboardFile</key>
|
||||
<string>Main</string>
|
||||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>UIApplicationSupportsIndirectInputEvents</key>
|
||||
<true/>
|
||||
<key>UILaunchStoryboardName</key>
|
||||
<string>LaunchScreen</string>
|
||||
<key>UIMainStoryboardFile</key>
|
||||
<string>Main</string>
|
||||
<key>UISupportedInterfaceOrientations</key>
|
||||
<array>
|
||||
<string>UIInterfaceOrientationPortrait</string>
|
||||
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||
</array>
|
||||
<key>UISupportedInterfaceOrientations~ipad</key>
|
||||
<array>
|
||||
<string>UIInterfaceOrientationPortrait</string>
|
||||
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||
</array>
|
||||
<key>UIStatusBarHidden</key>
|
||||
<false/>
|
||||
</dict>
|
||||
<key>UIApplicationSupportsIndirectInputEvents</key>
|
||||
<true/>
|
||||
<key>UILaunchStoryboardName</key>
|
||||
<string>LaunchScreen</string>
|
||||
<key>UIMainStoryboardFile</key>
|
||||
<string>Main</string>
|
||||
<key>UISupportedInterfaceOrientations</key>
|
||||
<array>
|
||||
<string>UIInterfaceOrientationPortrait</string>
|
||||
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||
</array>
|
||||
<key>UISupportedInterfaceOrientations~ipad</key>
|
||||
<array>
|
||||
<string>UIInterfaceOrientationPortrait</string>
|
||||
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -1,6 +1,11 @@
|
||||
// Author: fruit.com.cn
|
||||
|
||||
import Flutter
|
||||
import UIKit
|
||||
|
||||
class SceneDelegate: FlutterSceneDelegate {
|
||||
|
||||
override func sceneDidBecomeActive(_ scene: UIScene) {
|
||||
super.sceneDidBecomeActive(scene)
|
||||
(UIApplication.shared.delegate as? AppDelegate)?.requestWirelessDataPrompt()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
// Author: fruit.com.cn
|
||||
|
||||
import CoreTelephony
|
||||
import Flutter
|
||||
import Foundation
|
||||
|
||||
/// 监听系统无线数据选择,并用 URLSession 唤起系统选择框。
|
||||
final class WirelessDataPrompt {
|
||||
static let channelName = "com.stormg.lumadrama/wireless-data"
|
||||
static let awaitDecisionMethod = "awaitDecision"
|
||||
|
||||
/// 系统选择框由 URLSession 触发,Dart 的 Socket 请求不会弹出。
|
||||
private static let promptURL = URL(string: "https://captive.apple.com/hotspot-detect.html")
|
||||
|
||||
private let cellularData = CTCellularData()
|
||||
private let lock = NSLock()
|
||||
private var pending: [FlutterResult] = []
|
||||
private var decided = false
|
||||
private var didRequestPrompt = false
|
||||
|
||||
init() {
|
||||
cellularData.cellularDataRestrictionDidUpdateNotifier = { [weak self] state in
|
||||
DispatchQueue.main.async {
|
||||
self?.completeIfDecided(state)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// 应用进入前台后请求一次,促使系统弹出无线数据选择。
|
||||
func requestSystemPrompt() {
|
||||
guard !didRequestPrompt, let promptURL = Self.promptURL else {
|
||||
return
|
||||
}
|
||||
didRequestPrompt = true
|
||||
_ = cellularData.restrictedState
|
||||
URLSession.shared.dataTask(with: promptURL) { _, _, _ in }.resume()
|
||||
}
|
||||
|
||||
/// 未允许前先挂起;用户允许无线数据后再放行。
|
||||
func awaitDecision(_ result: @escaping FlutterResult) {
|
||||
lock.lock()
|
||||
if decided {
|
||||
lock.unlock()
|
||||
DispatchQueue.main.async {
|
||||
result(nil)
|
||||
}
|
||||
return
|
||||
}
|
||||
pending.append(result)
|
||||
lock.unlock()
|
||||
}
|
||||
|
||||
private func completeIfDecided(_ state: CTCellularDataRestrictedState) {
|
||||
if state != .notRestricted {
|
||||
return
|
||||
}
|
||||
lock.lock()
|
||||
if decided {
|
||||
lock.unlock()
|
||||
return
|
||||
}
|
||||
decided = true
|
||||
let waiters = pending
|
||||
pending.removeAll()
|
||||
lock.unlock()
|
||||
waiters.forEach { $0(nil) }
|
||||
}
|
||||
}
|
||||
@@ -30,6 +30,7 @@ import 'core/data/repositories/favorite_repository.dart';
|
||||
import 'core/data/repositories/interaction_repository.dart';
|
||||
import 'core/data/repositories/notice_repository.dart';
|
||||
import 'core/data/repositories/playback_repository.dart';
|
||||
import 'core/data/repositories/playlist_repository.dart';
|
||||
import 'core/data/repositories/search_repository.dart';
|
||||
import 'core/data/repositories/store_repository.dart';
|
||||
import 'core/data/repositories/watch_history_repository.dart';
|
||||
@@ -41,6 +42,7 @@ import 'core/data/services/download_controller.dart';
|
||||
import 'core/data/services/favorite_controller.dart';
|
||||
import 'core/data/services/interaction_controller.dart';
|
||||
import 'core/data/services/locale_controller.dart';
|
||||
import 'core/data/services/playlist_controller.dart';
|
||||
import 'core/data/services/event_tracker.dart';
|
||||
import 'core/data/services/playback_position_cache.dart';
|
||||
import 'core/data/services/playback_session.dart';
|
||||
@@ -83,6 +85,7 @@ class LumaDramaApp extends StatefulWidget {
|
||||
this.commerceRepository,
|
||||
this.storeRepository,
|
||||
this.searchRepository,
|
||||
this.playlistRepository,
|
||||
this.haptics = const FlutterHaptics(),
|
||||
});
|
||||
|
||||
@@ -103,6 +106,7 @@ class LumaDramaApp extends StatefulWidget {
|
||||
final CommerceRepository? commerceRepository;
|
||||
final StoreRepository? storeRepository;
|
||||
final SearchRepository? searchRepository;
|
||||
final PlaylistRepository? playlistRepository;
|
||||
final Haptics haptics;
|
||||
|
||||
@override
|
||||
@@ -126,8 +130,10 @@ class _LumaDramaAppState extends State<LumaDramaApp> {
|
||||
_sessionStore,
|
||||
);
|
||||
|
||||
late final CatalogApi _catalogApi = CatalogApi(_apiClient);
|
||||
|
||||
late final CatalogRepository _catalogRepository =
|
||||
widget.catalogRepository ?? HttpCatalogRepository(CatalogApi(_apiClient));
|
||||
widget.catalogRepository ?? HttpCatalogRepository(_catalogApi);
|
||||
|
||||
late final CategoryRepository _categoryRepository =
|
||||
widget.categoryRepository ??
|
||||
@@ -177,6 +183,13 @@ class _LumaDramaAppState extends State<LumaDramaApp> {
|
||||
late final SearchRepository _searchRepository =
|
||||
widget.searchRepository ?? HttpSearchRepository(CatalogApi(_apiClient));
|
||||
|
||||
/// 测试注入了目录仓库时不打剧单接口,剧单页继续用本地分区。
|
||||
late final PlaylistRepository? _playlistRepository =
|
||||
widget.playlistRepository ??
|
||||
(widget.catalogRepository == null
|
||||
? HttpPlaylistRepository(CatalogApi(_apiClient))
|
||||
: null);
|
||||
|
||||
late final StoreRepository _storeRepository =
|
||||
widget.storeRepository ?? HttpStoreRepository(CommerceApi(_apiClient));
|
||||
|
||||
@@ -239,14 +252,26 @@ class _LumaDramaAppState extends State<LumaDramaApp> {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
CategoryController _createCategories() {
|
||||
final controller = CategoryController(_categoryRepository);
|
||||
if (widget.catalogRepository == null) {
|
||||
controller.dramaPageLoader = CategoryApi(_apiClient).dramas;
|
||||
}
|
||||
controller.load();
|
||||
return controller;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final playlists = _playlistRepository;
|
||||
return MultiProvider(
|
||||
providers: [
|
||||
Provider(create: (_) => PlaybackCoordinator()),
|
||||
Provider<EventTracker>(create: (_) => EventTracker(_apiClient)),
|
||||
Provider<PlayerFactory>(create: (_) => widget.playerFactory),
|
||||
Provider<CatalogRepository>.value(value: _catalogRepository),
|
||||
if (widget.catalogRepository == null)
|
||||
Provider<CatalogApi>.value(value: _catalogApi),
|
||||
Provider<PlaybackRepository>.value(value: _playback),
|
||||
Provider<PlaybackPositionCache>.value(value: _playbackPositionCache),
|
||||
Provider<WatchHistoryRepository>.value(value: _watchHistory),
|
||||
@@ -260,11 +285,17 @@ class _LumaDramaAppState extends State<LumaDramaApp> {
|
||||
Provider<SearchRepository>.value(value: _searchRepository),
|
||||
Provider<Haptics>.value(value: widget.haptics),
|
||||
ChangeNotifierProvider(
|
||||
create: (_) => CatalogController(_catalogRepository)..load(),
|
||||
),
|
||||
ChangeNotifierProvider(
|
||||
create: (_) => CategoryController(_categoryRepository)..load(),
|
||||
create: (_) {
|
||||
final catalog = CatalogController(_catalogRepository);
|
||||
if (widget.catalogRepository != null) catalog.load();
|
||||
return catalog;
|
||||
},
|
||||
),
|
||||
ChangeNotifierProvider(create: (_) => _createCategories()),
|
||||
if (playlists != null)
|
||||
ChangeNotifierProvider(
|
||||
create: (_) => PlaylistController(playlists),
|
||||
),
|
||||
ChangeNotifierProvider.value(value: _favoriteController),
|
||||
ChangeNotifierProvider.value(value: _downloadController),
|
||||
ChangeNotifierProvider.value(value: _walletController),
|
||||
|
||||
@@ -14,7 +14,7 @@ class AppConfig {
|
||||
/// 开发调试默认服务地址,当前指向本机局域网 IP。
|
||||
///
|
||||
/// 换网络时只改这一行,地址不要带结尾斜杠。
|
||||
static const String devHostBaseUrl = 'http://192.168.31.187:8081';
|
||||
static const String devHostBaseUrl = 'http://10.43.47.1:8081';
|
||||
|
||||
/// 本机后端地址:通过 `adb reverse tcp:8081 tcp:8081` 映射到开发机,
|
||||
/// 探测可达时 App 直连本机服务;不可达时回落到公网地址。
|
||||
|
||||
@@ -1,17 +1,30 @@
|
||||
// Author: fruit.com.cn
|
||||
|
||||
import 'locale_text.dart';
|
||||
|
||||
/// 服务端内容分类。id 按契约保持字符串,避免雪花 ID 精度丢失。
|
||||
class ContentCategory {
|
||||
const ContentCategory({required this.id, required this.name});
|
||||
const ContentCategory({
|
||||
required this.id,
|
||||
required this.name,
|
||||
this.locales = const {},
|
||||
});
|
||||
|
||||
final String id;
|
||||
|
||||
/// 中文名称,与 locales 里的 zh 相同。
|
||||
final String name;
|
||||
final Map<String, String> locales;
|
||||
|
||||
/// 解析 `GET /app/categories` 的单项。
|
||||
factory ContentCategory.fromJson(Map<String, dynamic> json) {
|
||||
return ContentCategory(
|
||||
id: (json['id'] ?? '').toString(),
|
||||
name: json['name'] as String? ?? '',
|
||||
);
|
||||
final locales = localeMap(json['locales']);
|
||||
final name = json['name'] as String? ?? locales['zh'] ?? '';
|
||||
return ContentCategory(id: (json['id'] ?? '').toString(), name: name, locales: locales);
|
||||
}
|
||||
|
||||
/// 按界面语言取名称。缺对应语言时回落到中文。
|
||||
String localizedName(String languageCode) {
|
||||
return localizedText(languageCode, name, locales);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,9 @@
|
||||
// Author: fruit.com.cn
|
||||
|
||||
import 'dart:ui';
|
||||
|
||||
import 'json_numbers.dart';
|
||||
import 'locale_text.dart';
|
||||
|
||||
/// 短剧与剧集,字段与后端 `/app/**` 的下发结构对应。
|
||||
///
|
||||
@@ -76,7 +79,14 @@ class Drama {
|
||||
required this.synopsis,
|
||||
required this.posterUrl,
|
||||
this.episodes = const [],
|
||||
this.titleLocales = const {},
|
||||
this.synopsisLocales = const {},
|
||||
this.tag = '',
|
||||
this.tagLocales = const {},
|
||||
this.tagColor = '',
|
||||
this.category = '',
|
||||
this.categoryLocales = const {},
|
||||
this.types = const [],
|
||||
this.genre = '',
|
||||
this.totalEpisodes = 0,
|
||||
this.freeEpisodes = 0,
|
||||
@@ -94,9 +104,16 @@ class Drama {
|
||||
final String id;
|
||||
final String title;
|
||||
final String synopsis;
|
||||
final Map<String, String> titleLocales;
|
||||
final Map<String, String> synopsisLocales;
|
||||
final String tag;
|
||||
final Map<String, String> tagLocales;
|
||||
final String tagColor;
|
||||
final String posterUrl;
|
||||
final List<Episode> episodes;
|
||||
final String category;
|
||||
final Map<String, String> categoryLocales;
|
||||
final List<Map<String, String>> types;
|
||||
final String genre;
|
||||
final int totalEpisodes;
|
||||
final int freeEpisodes;
|
||||
@@ -127,19 +144,26 @@ class Drama {
|
||||
/// 列表卡片:带一集可播预览(首页直接起播),完整剧集进详情再取。
|
||||
factory Drama.fromCardJson(Map<String, dynamic> json) {
|
||||
final preview = json['preview'];
|
||||
final text = _DramaText.fromJson(json);
|
||||
return Drama(
|
||||
id: (json['id'] ?? '').toString(),
|
||||
title: json['title'] as String? ?? '',
|
||||
synopsis: json['synopsis'] as String? ?? '',
|
||||
title: text.title,
|
||||
synopsis: text.synopsis,
|
||||
titleLocales: text.titleLocales,
|
||||
synopsisLocales: text.synopsisLocales,
|
||||
tag: text.tag,
|
||||
tagLocales: text.tagLocales,
|
||||
tagColor: json['tagColor'] as String? ?? '',
|
||||
posterUrl: json['cover'] as String? ?? '',
|
||||
episodes: preview is Map<String, dynamic>
|
||||
? [Episode.fromJson(preview)]
|
||||
: const [],
|
||||
category: json['category'] as String? ?? '',
|
||||
genre: json['genre'] as String? ?? '',
|
||||
category: text.category,
|
||||
categoryLocales: text.categoryLocales,
|
||||
types: text.types,
|
||||
genre: text.genre,
|
||||
totalEpisodes: (json['totalEpisodes'] as num?)?.toInt() ?? 0,
|
||||
isHot: json['isHot'] == true,
|
||||
// viewCount 后端是 Long,按字符串下发(见 json_numbers.dart)
|
||||
viewCount: jsonToInt(json['viewCount']),
|
||||
likeCount: _optionalInt(json['likeCount']),
|
||||
favoriteCount: _optionalInt(json['favoriteCount']),
|
||||
@@ -152,13 +176,21 @@ class Drama {
|
||||
|
||||
/// 详情:带剧集列表。
|
||||
factory Drama.fromDetailJson(Map<String, dynamic> json) {
|
||||
final text = _DramaText.fromJson(json);
|
||||
return Drama(
|
||||
id: (json['id'] ?? '').toString(),
|
||||
title: json['title'] as String? ?? '',
|
||||
synopsis: json['synopsis'] as String? ?? '',
|
||||
title: text.title,
|
||||
synopsis: text.synopsis,
|
||||
titleLocales: text.titleLocales,
|
||||
synopsisLocales: text.synopsisLocales,
|
||||
tag: text.tag,
|
||||
tagLocales: text.tagLocales,
|
||||
tagColor: json['tagColor'] as String? ?? '',
|
||||
posterUrl: json['cover'] as String? ?? '',
|
||||
category: json['category'] as String? ?? '',
|
||||
genre: json['genre'] as String? ?? '',
|
||||
category: text.category,
|
||||
categoryLocales: text.categoryLocales,
|
||||
types: text.types,
|
||||
genre: text.genre,
|
||||
totalEpisodes: (json['totalEpisodes'] as num?)?.toInt() ?? 0,
|
||||
freeEpisodes: (json['freeEpisodes'] as num?)?.toInt() ?? 0,
|
||||
isHot: json['isHot'] == true,
|
||||
@@ -176,6 +208,37 @@ class Drama {
|
||||
.toList(),
|
||||
);
|
||||
}
|
||||
|
||||
String localizedTitle(String languageCode) {
|
||||
return localizedText(languageCode, title, titleLocales);
|
||||
}
|
||||
|
||||
String localizedSynopsis(String languageCode) {
|
||||
return localizedText(languageCode, synopsis, synopsisLocales);
|
||||
}
|
||||
|
||||
String localizedTag(String languageCode) {
|
||||
return localizedText(languageCode, tag, tagLocales);
|
||||
}
|
||||
|
||||
/// 标签角标背景色。接口没给合法色值时用 fallback。
|
||||
Color tagRibbonColor(Color fallback) {
|
||||
final parsed = _colorFromHex(tagColor);
|
||||
return parsed ?? fallback;
|
||||
}
|
||||
|
||||
/// 按当前语言取类型名称。接口没带语言表时返回空,调用方继续用中文 genre。
|
||||
List<String> localizedTypeLabels(String languageCode) {
|
||||
final labels = <String>[];
|
||||
for (final item in types) {
|
||||
final label = localizedText(languageCode, item['zh'] ?? '', item);
|
||||
if (label.isNotEmpty && !labels.contains(label)) labels.add(label);
|
||||
}
|
||||
if (labels.isNotEmpty) return labels;
|
||||
final primary = localizedText(languageCode, '', categoryLocales);
|
||||
if (primary.isNotEmpty) return [primary];
|
||||
return const [];
|
||||
}
|
||||
}
|
||||
|
||||
int? _optionalInt(dynamic value) => value == null ? null : jsonToInt(value);
|
||||
@@ -184,3 +247,81 @@ String? _optionalString(dynamic value) {
|
||||
final text = value is String ? value.trim() : '';
|
||||
return text.isEmpty ? null : text;
|
||||
}
|
||||
|
||||
Color? _colorFromHex(String raw) {
|
||||
final text = raw.trim();
|
||||
if (text.length != 7 || !text.startsWith('#')) return null;
|
||||
final value = int.tryParse(text.substring(1), radix: 16);
|
||||
if (value == null) return null;
|
||||
return Color(0xFF000000 | value);
|
||||
}
|
||||
|
||||
List<Map<String, String>> _typeLocales(Object? raw) {
|
||||
if (raw is! List) return const [];
|
||||
return raw.whereType<Map>().map(localeMap).toList(growable: false);
|
||||
}
|
||||
|
||||
/// 从语言表还原中文展示字段。列表接口不再单独下发 title / synopsis / tag。
|
||||
class _DramaText {
|
||||
const _DramaText({
|
||||
required this.title,
|
||||
required this.synopsis,
|
||||
required this.titleLocales,
|
||||
required this.synopsisLocales,
|
||||
required this.tag,
|
||||
required this.tagLocales,
|
||||
required this.category,
|
||||
required this.categoryLocales,
|
||||
required this.types,
|
||||
required this.genre,
|
||||
});
|
||||
|
||||
final String title;
|
||||
final String synopsis;
|
||||
final Map<String, String> titleLocales;
|
||||
final Map<String, String> synopsisLocales;
|
||||
final String tag;
|
||||
final Map<String, String> tagLocales;
|
||||
final String category;
|
||||
final Map<String, String> categoryLocales;
|
||||
final List<Map<String, String>> types;
|
||||
final String genre;
|
||||
|
||||
factory _DramaText.fromJson(Map<String, dynamic> json) {
|
||||
final titleLocales = localeMap(json['titleLocales']);
|
||||
final synopsisLocales = localeMap(json['synopsisLocales']);
|
||||
final tagLocales = localeMap(json['tagLocales']);
|
||||
final categoryLocales = localeMap(json['categoryLocales']);
|
||||
final types = _typeLocales(json['types']);
|
||||
final category = _firstText(categoryLocales, json['category'], types);
|
||||
return _DramaText(
|
||||
title: _firstText(titleLocales, json['title']),
|
||||
synopsis: _firstText(synopsisLocales, json['synopsis'] ?? json['description']),
|
||||
titleLocales: titleLocales,
|
||||
synopsisLocales: synopsisLocales,
|
||||
tag: _firstText(tagLocales, json['tag']),
|
||||
tagLocales: tagLocales,
|
||||
category: category,
|
||||
categoryLocales: categoryLocales,
|
||||
types: types,
|
||||
genre: _genreText(types, json['genre']),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
String _firstText(Map<String, String> locales, Object? fallback, [List<Map<String, String>>? types]) {
|
||||
final chinese = locales['zh'] ?? '';
|
||||
if (chinese.isNotEmpty) return chinese;
|
||||
if (types != null && types.isNotEmpty) {
|
||||
final label = types.first['zh'] ?? '';
|
||||
if (label.isNotEmpty) return label;
|
||||
}
|
||||
return fallback is String ? fallback : '';
|
||||
}
|
||||
|
||||
String _genreText(List<Map<String, String>> types, Object? fallback) {
|
||||
final names = types.map((item) => item['zh'] ?? '').where((value) => value.isNotEmpty);
|
||||
final joined = names.join(' / ');
|
||||
if (joined.isNotEmpty) return joined;
|
||||
return fallback is String ? fallback : '';
|
||||
}
|
||||
@@ -48,7 +48,7 @@ class FeedSection {
|
||||
factory FeedSection.fromJson(Map<String, dynamic> json) {
|
||||
return FeedSection(
|
||||
code: json['code'] as String? ?? '',
|
||||
title: json['title'] as String? ?? '',
|
||||
title: _sectionTitle(json),
|
||||
dramas: (json['dramas'] as List? ?? const [])
|
||||
.whereType<Map<String, dynamic>>()
|
||||
.map(Drama.fromCardJson)
|
||||
@@ -84,3 +84,12 @@ class FeedBanner {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
String _sectionTitle(Map<String, dynamic> json) {
|
||||
final locales = json['titleLocales'];
|
||||
if (locales is Map) {
|
||||
final chinese = locales['zh']?.toString() ?? '';
|
||||
if (chinese.isNotEmpty) return chinese;
|
||||
}
|
||||
return json['title'] as String? ?? '';
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
// Author: fruit.com.cn
|
||||
|
||||
/// 把接口里的语言表解析成字符串映射。
|
||||
Map<String, String> localeMap(Object? raw) {
|
||||
if (raw is! Map) return const {};
|
||||
return raw.map((key, value) => MapEntry('$key', value?.toString() ?? ''));
|
||||
}
|
||||
|
||||
/// 按当前语言取文案。没有对应语言时用中文,中文也没有时用 fallback。
|
||||
String localizedText(String languageCode, String fallback, Map<String, String> locales) {
|
||||
final selected = locales[languageCode] ?? '';
|
||||
if (selected.isNotEmpty) return selected;
|
||||
final chinese = locales['zh'] ?? '';
|
||||
if (chinese.isNotEmpty) return chinese;
|
||||
return fallback;
|
||||
}
|
||||
@@ -14,6 +14,7 @@ class PlayTicket {
|
||||
this.unlockCoin = 0,
|
||||
this.previewSeconds = 0,
|
||||
this.qualities = const [],
|
||||
this.tracks = const [],
|
||||
this.thumbnailsUrl,
|
||||
this.likeCount,
|
||||
this.commentCount,
|
||||
@@ -39,8 +40,11 @@ class PlayTicket {
|
||||
/// 试看秒数:仅 `COIN_REQUIRED` 时有意义(付费解锁在 B2 做)。
|
||||
final int previewSeconds;
|
||||
|
||||
/// 后端下发的清晰度档位(如 AUTO / 720P / 1080P),HLS 由播放器自动切换。
|
||||
/// 后端下发的清晰度档位(如 AUTO / 720p / 1080p)。
|
||||
final List<String> qualities;
|
||||
|
||||
/// 各档签名地址。AUTO 是主列表,点选其它档位时换成对应地址。
|
||||
final List<PlayQualityTrack> tracks;
|
||||
final String? thumbnailsUrl;
|
||||
final int? likeCount;
|
||||
final int? commentCount;
|
||||
@@ -64,6 +68,7 @@ class PlayTicket {
|
||||
.whereType<String>()
|
||||
.where((quality) => quality.isNotEmpty)
|
||||
.toList(),
|
||||
tracks: _tracks(json['tracks'], json['playUrl'] as String? ?? ''),
|
||||
thumbnailsUrl: _optionalString(json['thumbnailsUrl']),
|
||||
likeCount: json['likeCount'] == null
|
||||
? null
|
||||
@@ -75,6 +80,67 @@ class PlayTicket {
|
||||
}
|
||||
}
|
||||
|
||||
List<PlayQualityTrack> _tracks(dynamic raw, String playUrl) {
|
||||
final tracks = <PlayQualityTrack>[];
|
||||
if (raw is List) {
|
||||
for (final item in raw) {
|
||||
if (item is! Map) continue;
|
||||
final quality = item['quality'] as String? ?? '';
|
||||
final url = item['playUrl'] as String? ?? '';
|
||||
if (quality.isEmpty || url.isEmpty) continue;
|
||||
tracks.add(PlayQualityTrack(quality: quality, playUrl: url));
|
||||
}
|
||||
}
|
||||
if (tracks.isEmpty && playUrl.isNotEmpty) {
|
||||
tracks.add(PlayQualityTrack(quality: 'AUTO', playUrl: playUrl));
|
||||
}
|
||||
return tracks;
|
||||
}
|
||||
|
||||
/// 按票据里的分轨地址取播放地址;没有分轨时,从主列表路径推出同目录的单档地址。
|
||||
String? qualityPlayUrl({
|
||||
required String quality,
|
||||
required List<PlayQualityTrack> tracks,
|
||||
required String currentUrl,
|
||||
}) {
|
||||
final wanted = quality.toUpperCase();
|
||||
for (final track in tracks) {
|
||||
if (track.quality.toUpperCase() == wanted && track.playUrl.isNotEmpty) {
|
||||
return track.playUrl;
|
||||
}
|
||||
}
|
||||
return siblingRenditionUrl(currentUrl, wanted);
|
||||
}
|
||||
|
||||
/// `.../master.m3u8` 与 `.../720p/index.m3u8` 互相换算,查询参数原样保留。
|
||||
String? siblingRenditionUrl(String currentUrl, String quality) {
|
||||
final uri = Uri.tryParse(currentUrl);
|
||||
if (uri == null || uri.path.isEmpty) return null;
|
||||
final path = uri.path;
|
||||
const masterSuffix = '/master.m3u8';
|
||||
String? root;
|
||||
if (path.endsWith(masterSuffix)) {
|
||||
root = path.substring(0, path.length - masterSuffix.length);
|
||||
} else {
|
||||
final match = RegExp(r'/(\d+p)/index\.m3u8$').firstMatch(path);
|
||||
if (match == null) return null;
|
||||
root = path.substring(0, match.start);
|
||||
}
|
||||
final next = quality.toUpperCase() == 'AUTO'
|
||||
? '$root$masterSuffix'
|
||||
: '$root/${quality.toLowerCase()}/index.m3u8';
|
||||
if (next == path) return currentUrl;
|
||||
return uri.replace(path: next).toString();
|
||||
}
|
||||
|
||||
/// 一档清晰度的签名播放地址。
|
||||
class PlayQualityTrack {
|
||||
const PlayQualityTrack({required this.quality, required this.playUrl});
|
||||
|
||||
final String quality;
|
||||
final String playUrl;
|
||||
}
|
||||
|
||||
String? _optionalString(dynamic value) {
|
||||
final text = value is String ? value.trim() : '';
|
||||
return text.isEmpty ? null : text;
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
// Author: fruit.com.cn
|
||||
|
||||
import 'drama.dart';
|
||||
import 'locale_text.dart';
|
||||
|
||||
/// C 端剧单:`GET /app/playlists` 与 `GET /app/playlists/{id}` 的同一结构。
|
||||
class PlaylistDetail {
|
||||
const PlaylistDetail({
|
||||
required this.id,
|
||||
required this.name,
|
||||
required this.description,
|
||||
this.locales = const {},
|
||||
this.descriptionLocales = const {},
|
||||
required this.dramaCount,
|
||||
required this.dramas,
|
||||
this.pageIndex = 1,
|
||||
this.pageSize = 0,
|
||||
});
|
||||
|
||||
final String id;
|
||||
|
||||
/// 中文名称,与 locales 里的 zh 相同。
|
||||
final String name;
|
||||
final Map<String, String> locales;
|
||||
|
||||
/// 中文描述,与 descriptionLocales 里的 zh 相同。
|
||||
final String description;
|
||||
final Map<String, String> descriptionLocales;
|
||||
final int dramaCount;
|
||||
final int pageIndex;
|
||||
final int pageSize;
|
||||
final List<Drama> dramas;
|
||||
|
||||
factory PlaylistDetail.fromJson(Map<String, dynamic> json) {
|
||||
final dramas = _dramasOf(json['list']);
|
||||
final locales = localeMap(json['locales']);
|
||||
final descriptions = localeMap(json['descriptionLocales']);
|
||||
return PlaylistDetail(
|
||||
id: (json['id'] ?? '').toString(),
|
||||
name: json['name'] as String? ?? locales['zh'] ?? '',
|
||||
locales: locales,
|
||||
description: json['description'] as String? ?? descriptions['zh'] ?? '',
|
||||
descriptionLocales: descriptions,
|
||||
dramaCount: (json['dramaCount'] as num?)?.toInt() ?? dramas.length,
|
||||
pageIndex: (json['pageIndex'] as num?)?.toInt() ?? 1,
|
||||
pageSize: (json['pageSize'] as num?)?.toInt() ?? dramas.length,
|
||||
dramas: dramas,
|
||||
);
|
||||
}
|
||||
|
||||
/// 按界面语言取名称。缺对应语言时回落到中文。
|
||||
String localizedName(String languageCode) {
|
||||
return localizedText(languageCode, name, locales);
|
||||
}
|
||||
|
||||
/// 按界面语言取描述。缺对应语言时回落到中文。
|
||||
String localizedDescription(String languageCode) {
|
||||
return localizedText(languageCode, description, descriptionLocales);
|
||||
}
|
||||
}
|
||||
|
||||
List<Drama> _dramasOf(Object? rows) {
|
||||
if (rows is! List) return const [];
|
||||
return rows
|
||||
.whereType<Map>()
|
||||
.map((item) => Drama.fromCardJson(Map<String, dynamic>.from(item)))
|
||||
.toList(growable: false);
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
// Author: fruit.com.cn
|
||||
|
||||
import 'json_numbers.dart';
|
||||
import 'locale_text.dart';
|
||||
|
||||
/// 服务端续看记录:`GET /app/watch/progress?dramaId=` 与 `/app/watch/recent` 的下发结构。
|
||||
///
|
||||
@@ -13,17 +14,20 @@ class WatchProgress {
|
||||
required this.position,
|
||||
required this.duration,
|
||||
this.dramaTitle,
|
||||
this.titleLocales = const {},
|
||||
this.dramaCover,
|
||||
this.episodeNumber,
|
||||
this.totalEpisodes,
|
||||
this.finished = false,
|
||||
this.playCount = 0,
|
||||
this.viewCount,
|
||||
this.updatedAt,
|
||||
});
|
||||
|
||||
final String dramaId;
|
||||
final String episodeId;
|
||||
final String? dramaTitle;
|
||||
final Map<String, String> titleLocales;
|
||||
final String? dramaCover;
|
||||
final int? episodeNumber;
|
||||
final int? totalEpisodes;
|
||||
@@ -31,6 +35,9 @@ class WatchProgress {
|
||||
final Duration duration;
|
||||
final bool finished;
|
||||
final int playCount;
|
||||
|
||||
/// 短剧热度。历史列表没下发时为空,不能拿用户自己的 playCount 冒充。
|
||||
final int? viewCount;
|
||||
final DateTime? updatedAt;
|
||||
|
||||
bool get hasPosition => position > Duration.zero;
|
||||
@@ -41,11 +48,17 @@ class WatchProgress {
|
||||
return (position.inMilliseconds / duration.inMilliseconds).clamp(0.0, 1.0);
|
||||
}
|
||||
|
||||
/// 按当前语言取剧名。没有对应语言时回退中文,再回退 dramaTitle。
|
||||
String localizedTitle(String languageCode) {
|
||||
return localizedText(languageCode, dramaTitle ?? '', titleLocales);
|
||||
}
|
||||
|
||||
factory WatchProgress.fromJson(Map<String, dynamic> json) {
|
||||
return WatchProgress(
|
||||
dramaId: (json['dramaId'] ?? '').toString(),
|
||||
episodeId: (json['episodeId'] ?? '').toString(),
|
||||
dramaTitle: json['dramaTitle']?.toString(),
|
||||
titleLocales: localeMap(json['titleLocales']),
|
||||
dramaCover: json['dramaCover']?.toString(),
|
||||
episodeNumber: json['episodeNumber'] == null
|
||||
? null
|
||||
@@ -57,6 +70,9 @@ class WatchProgress {
|
||||
duration: Duration(milliseconds: jsonToInt(json['durationMs'])),
|
||||
finished: json['finished'] == true,
|
||||
playCount: jsonToInt(json['playCount']),
|
||||
viewCount: json['viewCount'] == null
|
||||
? null
|
||||
: jsonToInt(json['viewCount']),
|
||||
updatedAt: DateTime.tryParse(json['updatedAt'] as String? ?? ''),
|
||||
);
|
||||
}
|
||||
@@ -65,6 +81,7 @@ class WatchProgress {
|
||||
'dramaId': dramaId,
|
||||
'episodeId': episodeId,
|
||||
if (dramaTitle != null) 'dramaTitle': dramaTitle,
|
||||
if (titleLocales.isNotEmpty) 'titleLocales': titleLocales,
|
||||
if (dramaCover != null) 'dramaCover': dramaCover,
|
||||
if (episodeNumber != null) 'episodeNumber': episodeNumber,
|
||||
if (totalEpisodes != null) 'totalEpisodes': totalEpisodes,
|
||||
@@ -72,6 +89,7 @@ class WatchProgress {
|
||||
'durationMs': duration.inMilliseconds,
|
||||
'finished': finished,
|
||||
'playCount': playCount,
|
||||
if (viewCount != null) 'viewCount': viewCount,
|
||||
if (updatedAt != null) 'updatedAt': updatedAt!.toIso8601String(),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -31,9 +31,13 @@ class WatchRecord {
|
||||
}
|
||||
|
||||
/// 服务端分页标题优先,详情标题作为回退。
|
||||
String get displayTitle {
|
||||
final pageTitle = progress.dramaTitle?.trim() ?? '';
|
||||
return pageTitle.isNotEmpty ? pageTitle : drama?.title.trim() ?? '';
|
||||
String get displayTitle => localizedDisplayTitle('zh');
|
||||
|
||||
/// 按当前语言取标题。分页语言表优先,详情语言表作为回退。
|
||||
String localizedDisplayTitle(String languageCode) {
|
||||
final pageTitle = progress.localizedTitle(languageCode).trim();
|
||||
if (pageTitle.isNotEmpty) return pageTitle;
|
||||
return drama?.localizedTitle(languageCode).trim() ?? '';
|
||||
}
|
||||
|
||||
/// 服务端分页封面优先,详情封面作为回退。
|
||||
|
||||
@@ -148,7 +148,8 @@ class ApiClient {
|
||||
skipAuthRetry: skipAuthRetry,
|
||||
);
|
||||
}
|
||||
onUnauthorized?.call();
|
||||
final token = accessTokenReader?.call();
|
||||
if (token == null || token.isEmpty) onUnauthorized?.call();
|
||||
throw ApiException(401, cause.message ?? '登录已过期');
|
||||
}
|
||||
if (cause is ApiException) {
|
||||
|
||||
@@ -33,6 +33,7 @@ class AuthApi {
|
||||
required String code,
|
||||
required String deviceId,
|
||||
String platform = '',
|
||||
String osVersion = '',
|
||||
String appVersion = '',
|
||||
}) async {
|
||||
final data = await _client.post(
|
||||
@@ -43,6 +44,7 @@ class AuthApi {
|
||||
'code': code,
|
||||
'deviceId': deviceId,
|
||||
'platform': platform,
|
||||
'osVersion': osVersion,
|
||||
'appVersion': appVersion,
|
||||
},
|
||||
);
|
||||
@@ -55,6 +57,7 @@ class AuthApi {
|
||||
required String code,
|
||||
required String deviceId,
|
||||
String platform = '',
|
||||
String osVersion = '',
|
||||
String appVersion = '',
|
||||
}) async {
|
||||
final data = await _client.post(
|
||||
@@ -65,6 +68,7 @@ class AuthApi {
|
||||
'code': code,
|
||||
'deviceId': deviceId,
|
||||
'platform': platform,
|
||||
'osVersion': osVersion,
|
||||
'appVersion': appVersion,
|
||||
},
|
||||
);
|
||||
@@ -76,6 +80,7 @@ class AuthApi {
|
||||
required String password,
|
||||
required String deviceId,
|
||||
String platform = '',
|
||||
String osVersion = '',
|
||||
String appVersion = '',
|
||||
}) async {
|
||||
final data = await _client.post(
|
||||
@@ -87,6 +92,7 @@ class AuthApi {
|
||||
'countryCode': 'ID',
|
||||
'deviceId': deviceId,
|
||||
'platform': platform,
|
||||
'osVersion': osVersion,
|
||||
'appVersion': appVersion,
|
||||
},
|
||||
);
|
||||
@@ -98,6 +104,7 @@ class AuthApi {
|
||||
required String password,
|
||||
required String deviceId,
|
||||
String platform = '',
|
||||
String osVersion = '',
|
||||
String appVersion = '',
|
||||
}) async {
|
||||
final data = await _client.post(
|
||||
@@ -108,18 +115,25 @@ class AuthApi {
|
||||
'password': password,
|
||||
'deviceId': deviceId,
|
||||
'platform': platform,
|
||||
'osVersion': osVersion,
|
||||
'appVersion': appVersion,
|
||||
},
|
||||
);
|
||||
return AuthSession.fromJson((data as Map).cast<String, dynamic>());
|
||||
}
|
||||
|
||||
Future<AuthSession> refresh(String refreshToken) async {
|
||||
Future<AuthSession> refresh(
|
||||
String refreshToken, {
|
||||
String platform = '',
|
||||
String osVersion = '',
|
||||
}) async {
|
||||
final data = await _client.post(
|
||||
'/app/auth/refresh',
|
||||
body: {'refreshToken': refreshToken},
|
||||
// 刷新请求本身不带旧令牌重试,失败就是失败
|
||||
skipAuthRetry: true,
|
||||
body: {
|
||||
'refreshToken': refreshToken,
|
||||
'platform': platform,
|
||||
'osVersion': osVersion,
|
||||
},
|
||||
);
|
||||
return AuthSession.fromJson((data as Map).cast<String, dynamic>());
|
||||
}
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
import '../models/content_category.dart';
|
||||
import '../models/drama.dart';
|
||||
import '../models/feed_page.dart';
|
||||
import '../models/home_feed.dart';
|
||||
import '../models/page_result.dart';
|
||||
import '../models/playlist_detail.dart';
|
||||
import '../models/search_result.dart';
|
||||
import 'api_client.dart';
|
||||
|
||||
@@ -58,12 +61,95 @@ class CatalogApi {
|
||||
return SearchResult.fromJson(_asMap(data));
|
||||
}
|
||||
|
||||
static const int playlistPageSize = 10;
|
||||
static const int playlistDramaPageSize = 20;
|
||||
|
||||
/// 已启用剧单,分页返回,每条带已上线短剧卡片。
|
||||
Future<PageResult<PlaylistDetail>> playlists({
|
||||
int pageIndex = 1,
|
||||
int pageSize = playlistPageSize,
|
||||
}) async {
|
||||
final data = await _client.get(
|
||||
'/app/playlists',
|
||||
query: {
|
||||
'pageIndex': '$pageIndex',
|
||||
'pageSize': '$pageSize',
|
||||
},
|
||||
);
|
||||
return PageResult.parse(data, PlaylistDetail.fromJson);
|
||||
}
|
||||
|
||||
/// 单个剧单详情。短剧按 pageIndex、pageSize 翻页。
|
||||
Future<PlaylistDetail> playlist(
|
||||
String id, {
|
||||
int pageIndex = 1,
|
||||
int pageSize = playlistDramaPageSize,
|
||||
}) async {
|
||||
return PlaylistDetail.fromJson(
|
||||
_asMap(
|
||||
await _client.get(
|
||||
'/app/playlists/$id',
|
||||
query: {
|
||||
'pageIndex': '$pageIndex',
|
||||
'pageSize': '$pageSize',
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// 已启用首页分类,名称在 locales。
|
||||
Future<List<ContentCategory>> classifications() async {
|
||||
return _categories(await _client.get('/app/categories'));
|
||||
}
|
||||
|
||||
/// 已启用类型,名称在 locales。
|
||||
Future<List<ContentCategory>> dramaCategories() async {
|
||||
return _categories(await _client.get('/app/drama-categories'));
|
||||
}
|
||||
|
||||
/// 已启用标签,名称在 locales。
|
||||
Future<List<ContentCategory>> tags() async {
|
||||
return _categories(await _client.get('/app/tags'));
|
||||
}
|
||||
|
||||
static const int libraryPageSize = 20;
|
||||
|
||||
/// 全部短剧。同一组 id 多选为或,组与组之间为且。
|
||||
Future<PageResult<Drama>> libraryDramas({
|
||||
List<String> categoryIds = const [],
|
||||
List<String> classificationIds = const [],
|
||||
List<String> tagIds = const [],
|
||||
int pageIndex = 1,
|
||||
int pageSize = libraryPageSize,
|
||||
}) async {
|
||||
final data = await _client.post(
|
||||
'/app/dramas/page',
|
||||
body: {
|
||||
'pageIndex': pageIndex,
|
||||
'pageSize': pageSize,
|
||||
'categoryIds': categoryIds,
|
||||
'classificationIds': classificationIds,
|
||||
'tagIds': tagIds,
|
||||
},
|
||||
);
|
||||
return PageResult.parse(data, Drama.fromCardJson);
|
||||
}
|
||||
|
||||
Future<Drama> dramaDetail(String dramaId) async {
|
||||
return Drama.fromDetailJson(
|
||||
_asMap(await _client.get('/app/dramas/$dramaId')),
|
||||
);
|
||||
}
|
||||
|
||||
List<ContentCategory> _categories(Object? data) {
|
||||
if (data is! List) return const [];
|
||||
return [
|
||||
for (final item in data)
|
||||
if (item is Map<String, dynamic>) ContentCategory.fromJson(item),
|
||||
];
|
||||
}
|
||||
|
||||
Map<String, dynamic> _asMap(Object? data) {
|
||||
if (data is Map<String, dynamic>) return data;
|
||||
throw const ApiException(-1, '返回数据格式异常');
|
||||
|
||||
@@ -1,12 +1,16 @@
|
||||
// Author: fruit.com.cn
|
||||
|
||||
import '../models/content_category.dart';
|
||||
import '../models/drama.dart';
|
||||
import '../models/page_result.dart';
|
||||
import 'api_client.dart';
|
||||
|
||||
/// 内容分类接口,对应契约 `GET /app/categories`。
|
||||
class CategoryApi {
|
||||
const CategoryApi(this._client);
|
||||
|
||||
static const int dramaPageSize = 20;
|
||||
|
||||
final ApiClient _client;
|
||||
|
||||
/// 拉取已启用分类,id 全程按字符串解析。
|
||||
@@ -18,4 +22,20 @@ class CategoryApi {
|
||||
if (item is Map<String, dynamic>) ContentCategory.fromJson(item),
|
||||
];
|
||||
}
|
||||
|
||||
/// 分类下已上线短剧,pageIndex 从 1 开始。
|
||||
Future<PageResult<Drama>> dramas(
|
||||
String categoryId, {
|
||||
int pageIndex = 1,
|
||||
int pageSize = dramaPageSize,
|
||||
}) async {
|
||||
final data = await _client.get(
|
||||
'/app/categories/$categoryId/dramas',
|
||||
query: {
|
||||
'pageIndex': '$pageIndex',
|
||||
'pageSize': '$pageSize',
|
||||
},
|
||||
);
|
||||
return PageResult.parse(data, Drama.fromCardJson);
|
||||
}
|
||||
}
|
||||
@@ -36,4 +36,9 @@ class LibraryApi {
|
||||
Future<void> removeFavorite(String dramaId) async {
|
||||
await _client.delete('/app/favorites/$dramaId');
|
||||
}
|
||||
|
||||
/// 一次取消多部短剧,请求体为 dramaIds 数组。
|
||||
Future<void> removeFavorites(List<String> dramaIds) async {
|
||||
await _client.post('/app/favorites/remove', body: {'dramaIds': dramaIds});
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,9 @@ abstract interface class FavoriteRepository {
|
||||
Future<PageResult<Drama>> page({int pageIndex = 1, int pageSize = 20});
|
||||
|
||||
Future<void> remove(String dramaId);
|
||||
|
||||
/// 一次取消多部短剧。
|
||||
Future<void> removeMany(List<String> dramaIds);
|
||||
}
|
||||
|
||||
class HttpFavoriteRepository implements FavoriteRepository {
|
||||
@@ -36,6 +39,10 @@ class HttpFavoriteRepository implements FavoriteRepository {
|
||||
|
||||
@override
|
||||
Future<void> remove(String dramaId) => _api.removeFavorite(dramaId);
|
||||
|
||||
@override
|
||||
Future<void> removeMany(List<String> dramaIds) =>
|
||||
_api.removeFavorites(dramaIds);
|
||||
}
|
||||
|
||||
/// 内存实现:单测与 widget 测试注入用。
|
||||
@@ -51,6 +58,7 @@ class InMemoryFavoriteRepository implements FavoriteRepository {
|
||||
bool failRemove = false;
|
||||
int toggleCalls = 0;
|
||||
int pageCalls = 0;
|
||||
int removeManyCalls = 0;
|
||||
|
||||
@override
|
||||
Future<bool> toggle(String dramaId) async {
|
||||
@@ -80,4 +88,11 @@ class InMemoryFavoriteRepository implements FavoriteRepository {
|
||||
if (failRemove) throw StateError('favorite unavailable');
|
||||
_saved.remove(dramaId);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> removeMany(List<String> dramaIds) async {
|
||||
removeManyCalls += 1;
|
||||
if (failRemove) throw StateError('favorite unavailable');
|
||||
_saved.removeAll(dramaIds);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
// Author: fruit.com.cn
|
||||
|
||||
import '../models/page_result.dart';
|
||||
import '../models/playlist_detail.dart';
|
||||
import '../remote/catalog_api.dart';
|
||||
|
||||
/// 剧单来源:列表分页拉取,详情用于打开单条时刷新。
|
||||
abstract interface class PlaylistRepository {
|
||||
Future<PageResult<PlaylistDetail>> fetchPlaylists({
|
||||
int pageIndex = 1,
|
||||
int pageSize = CatalogApi.playlistPageSize,
|
||||
});
|
||||
|
||||
Future<PlaylistDetail> fetchPlaylist(
|
||||
String id, {
|
||||
int pageIndex = 1,
|
||||
int pageSize = CatalogApi.playlistDramaPageSize,
|
||||
});
|
||||
}
|
||||
|
||||
class HttpPlaylistRepository implements PlaylistRepository {
|
||||
HttpPlaylistRepository(this._api);
|
||||
|
||||
final CatalogApi _api;
|
||||
|
||||
@override
|
||||
Future<PageResult<PlaylistDetail>> fetchPlaylists({
|
||||
int pageIndex = 1,
|
||||
int pageSize = CatalogApi.playlistPageSize,
|
||||
}) => _api.playlists(pageIndex: pageIndex, pageSize: pageSize);
|
||||
|
||||
@override
|
||||
Future<PlaylistDetail> fetchPlaylist(
|
||||
String id, {
|
||||
int pageIndex = 1,
|
||||
int pageSize = CatalogApi.playlistDramaPageSize,
|
||||
}) => _api.playlist(id, pageIndex: pageIndex, pageSize: pageSize);
|
||||
}
|
||||
@@ -0,0 +1,173 @@
|
||||
// Author: fruit.com.cn
|
||||
// 全部短剧筛选与分页:拉取分类、类型、标签,并按页加载短剧。
|
||||
|
||||
import '../models/content_category.dart';
|
||||
import '../models/drama.dart';
|
||||
import '../models/page_result.dart';
|
||||
import '../remote/catalog_api.dart';
|
||||
|
||||
/// 全部短剧筛选与分页所需的远端能力。
|
||||
abstract interface class AllDramasRemote {
|
||||
/// 已启用分类。
|
||||
Future<List<ContentCategory>> classifications();
|
||||
|
||||
/// 已启用类型。
|
||||
Future<List<ContentCategory>> categories();
|
||||
|
||||
/// 已启用标签。
|
||||
Future<List<ContentCategory>> tags();
|
||||
|
||||
/// 按当前筛选取一页短剧。
|
||||
Future<PageResult<Drama>> dramas({
|
||||
required List<String> categoryIds,
|
||||
required List<String> classificationIds,
|
||||
required List<String> tagIds,
|
||||
required int pageIndex,
|
||||
});
|
||||
}
|
||||
|
||||
/// 用现有目录接口实现全部短剧远端能力。
|
||||
class CatalogAllDramasRemote implements AllDramasRemote {
|
||||
/// 绑定目录接口。
|
||||
const CatalogAllDramasRemote(this._api);
|
||||
|
||||
final CatalogApi _api;
|
||||
|
||||
@override
|
||||
Future<List<ContentCategory>> classifications() => _api.classifications();
|
||||
|
||||
@override
|
||||
Future<List<ContentCategory>> categories() => _api.dramaCategories();
|
||||
|
||||
@override
|
||||
Future<List<ContentCategory>> tags() => _api.tags();
|
||||
|
||||
@override
|
||||
Future<PageResult<Drama>> dramas({
|
||||
required List<String> categoryIds,
|
||||
required List<String> classificationIds,
|
||||
required List<String> tagIds,
|
||||
required int pageIndex,
|
||||
}) {
|
||||
return _api.libraryDramas(
|
||||
categoryIds: categoryIds,
|
||||
classificationIds: classificationIds,
|
||||
tagIds: tagIds,
|
||||
pageIndex: pageIndex,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// 全部短剧:筛选项来自类型、分类、标签,列表按页加载。
|
||||
class AllDramasController {
|
||||
AllDramasController({
|
||||
AllDramasRemote? api,
|
||||
this.classifications = const [],
|
||||
this.categories = const [],
|
||||
this.tags = const [],
|
||||
this.dramas = const [],
|
||||
}) : _api = api;
|
||||
|
||||
final AllDramasRemote? _api;
|
||||
List<ContentCategory> classifications;
|
||||
List<ContentCategory> categories;
|
||||
List<ContentCategory> tags;
|
||||
final Set<String> selectedClassifications = {};
|
||||
final Set<String> selectedCategories = {};
|
||||
final Set<String> selectedTags = {};
|
||||
List<Drama> dramas;
|
||||
bool loading = false;
|
||||
bool loadingMore = false;
|
||||
bool hasMore = false;
|
||||
String? error;
|
||||
int _page = 1;
|
||||
int _total = 0;
|
||||
|
||||
bool get usesRemote => _api != null;
|
||||
|
||||
/// 预览用:筛选项和列表都已在本地,不请求接口。
|
||||
factory AllDramasController.preview({
|
||||
List<ContentCategory> classifications = const [],
|
||||
List<ContentCategory> categories = const [],
|
||||
List<ContentCategory> tags = const [],
|
||||
List<Drama> dramas = const [],
|
||||
}) {
|
||||
return AllDramasController(
|
||||
classifications: classifications,
|
||||
categories: categories,
|
||||
tags: tags,
|
||||
dramas: dramas,
|
||||
);
|
||||
}
|
||||
|
||||
/// 从第一页重新拉取筛选项和短剧。没有接口时直接返回。
|
||||
Future<void> refresh() async {
|
||||
if (_api == null) return;
|
||||
loading = true;
|
||||
error = null;
|
||||
_page = 1;
|
||||
try {
|
||||
final filters = await Future.wait([
|
||||
_api.classifications(),
|
||||
_api.categories(),
|
||||
_api.tags(),
|
||||
]);
|
||||
classifications = filters[0];
|
||||
categories = filters[1];
|
||||
tags = filters[2];
|
||||
final page = await _loadPage(1);
|
||||
dramas = page;
|
||||
hasMore = dramas.length < _total;
|
||||
} catch (caught) {
|
||||
error = '$caught';
|
||||
} finally {
|
||||
loading = false;
|
||||
}
|
||||
}
|
||||
|
||||
/// 追加下一页。没有更多、正在加载或没有接口时直接返回。
|
||||
Future<void> loadMore() async {
|
||||
if (_api == null || loading || loadingMore || !hasMore) return;
|
||||
loadingMore = true;
|
||||
error = null;
|
||||
try {
|
||||
final next = await _loadPage(_page + 1);
|
||||
_page += 1;
|
||||
dramas = [...dramas, ...next];
|
||||
hasMore = dramas.length < _total;
|
||||
} catch (caught) {
|
||||
error = '$caught';
|
||||
} finally {
|
||||
loadingMore = false;
|
||||
}
|
||||
}
|
||||
|
||||
/// 切换一个分类。传入空字符串表示清空这一组。
|
||||
void toggleClassification(String id) =>
|
||||
_toggle(selectedClassifications, id);
|
||||
|
||||
/// 切换一个类型。传入空字符串表示清空这一组。
|
||||
void toggleCategory(String id) => _toggle(selectedCategories, id);
|
||||
|
||||
/// 切换一个标签。传入空字符串表示清空这一组。
|
||||
void toggleTag(String id) => _toggle(selectedTags, id);
|
||||
|
||||
void _toggle(Set<String> selected, String id) {
|
||||
if (id.isEmpty) {
|
||||
selected.clear();
|
||||
return;
|
||||
}
|
||||
if (!selected.add(id)) selected.remove(id);
|
||||
}
|
||||
|
||||
Future<List<Drama>> _loadPage(int pageIndex) async {
|
||||
final page = await _api!.dramas(
|
||||
categoryIds: selectedCategories.toList(growable: false),
|
||||
classificationIds: selectedClassifications.toList(growable: false),
|
||||
tagIds: selectedTags.toList(growable: false),
|
||||
pageIndex: pageIndex,
|
||||
);
|
||||
_total = page.total;
|
||||
return page.list;
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,5 @@
|
||||
import 'dart:io' show Platform;
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
|
||||
import '../models/auth_session.dart';
|
||||
@@ -9,7 +11,7 @@ import 'auth_session_store.dart';
|
||||
///
|
||||
/// 职责:本地会话的读写([AuthSessionStore])、注册/登录/登出、令牌刷新;
|
||||
/// 也是 [ApiClient] 的 `accessTokenReader` / `tokenRefresher` / `onUnauthorized` 实现方 ——
|
||||
/// 401 → 刷新 → 重试失败就清会话,UI 通过 [isSignedIn] 自动回到未登录态。
|
||||
/// 401 → 刷新 → 重试。令牌被拒绝才清会话,服务中断时保持登录。
|
||||
class AuthController extends ChangeNotifier {
|
||||
AuthController(this._api, this._store);
|
||||
|
||||
@@ -19,6 +21,10 @@ class AuthController extends ChangeNotifier {
|
||||
AuthSession? _session;
|
||||
String _deviceId = '';
|
||||
bool _loaded = false;
|
||||
Future<bool>? _refreshing;
|
||||
|
||||
/// 登录已过期、账号停用才清本地会话。服务不可达不能当成退出登录。
|
||||
static const Set<int> _rejectedSessionCodes = {401, 100001};
|
||||
|
||||
bool get isLoaded => _loaded;
|
||||
bool get isSignedIn => _session != null;
|
||||
@@ -43,6 +49,7 @@ class AuthController extends ChangeNotifier {
|
||||
password: password,
|
||||
deviceId: await _store.deviceId(),
|
||||
platform: _platform,
|
||||
osVersion: _osVersion,
|
||||
);
|
||||
await _apply(session);
|
||||
}
|
||||
@@ -53,14 +60,12 @@ class AuthController extends ChangeNotifier {
|
||||
password: password,
|
||||
deviceId: await _store.deviceId(),
|
||||
platform: _platform,
|
||||
osVersion: _osVersion,
|
||||
);
|
||||
await _apply(session);
|
||||
}
|
||||
|
||||
Future<void> sendOtp({
|
||||
required String target,
|
||||
String scene = 'LOGIN',
|
||||
}) async {
|
||||
Future<void> sendOtp({required String target, String scene = 'LOGIN'}) async {
|
||||
await _api.sendOtp(
|
||||
target: target,
|
||||
scene: scene,
|
||||
@@ -77,6 +82,7 @@ class AuthController extends ChangeNotifier {
|
||||
code: code,
|
||||
deviceId: await _store.deviceId(),
|
||||
platform: _platform,
|
||||
osVersion: _osVersion,
|
||||
);
|
||||
await _apply(session);
|
||||
}
|
||||
@@ -90,10 +96,17 @@ class AuthController extends ChangeNotifier {
|
||||
code: code,
|
||||
deviceId: await _store.deviceId(),
|
||||
platform: _platform,
|
||||
osVersion: _osVersion,
|
||||
);
|
||||
await _apply(session);
|
||||
}
|
||||
|
||||
Future<void> clear() async {
|
||||
_session = null;
|
||||
await _store.clear();
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
Future<void> signOut() async {
|
||||
final refreshToken = _session?.refreshToken ?? '';
|
||||
_session = null;
|
||||
@@ -107,29 +120,43 @@ class AuthController extends ChangeNotifier {
|
||||
}
|
||||
}
|
||||
|
||||
/// 供 [ApiClient] 调用:刷新令牌并落盘。失败时清本地会话。
|
||||
Future<bool> refresh() async {
|
||||
/// 供 [ApiClient] 调用:刷新令牌并落盘。
|
||||
///
|
||||
/// 同一时刻只刷新一次,避免重启期间并发 401 把新令牌轮换掉。
|
||||
/// 网络失败或 5xx 保留本地会话;只有令牌被拒绝才退出登录。
|
||||
Future<bool> refresh() {
|
||||
final current = _refreshing;
|
||||
if (current != null) return current;
|
||||
final run = _refreshSingle();
|
||||
_refreshing = run;
|
||||
return run.whenComplete(() {
|
||||
if (identical(_refreshing, run)) _refreshing = null;
|
||||
});
|
||||
}
|
||||
|
||||
Future<bool> _refreshSingle() async {
|
||||
final refreshToken = _session?.refreshToken ?? '';
|
||||
if (refreshToken.isEmpty) {
|
||||
await clear();
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
await _apply(await _api.refresh(refreshToken));
|
||||
await _apply(
|
||||
await _api.refresh(
|
||||
refreshToken,
|
||||
platform: _platform,
|
||||
osVersion: _osVersion,
|
||||
),
|
||||
);
|
||||
return true;
|
||||
} on ApiException catch (error) {
|
||||
if (_rejectedSessionCodes.contains(error.code)) await clear();
|
||||
return false;
|
||||
} catch (_) {
|
||||
await clear();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> clear() async {
|
||||
if (_session == null) return;
|
||||
_session = null;
|
||||
await _store.clear();
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
/// 资料保存成功后同步登录态摘要,保留当前令牌。
|
||||
Future<void> applyProfile(AuthUser user) async {
|
||||
final current = _session;
|
||||
@@ -154,4 +181,9 @@ class AuthController extends ChangeNotifier {
|
||||
if (kIsWeb) return 'WEB';
|
||||
return defaultTargetPlatform == TargetPlatform.iOS ? 'IOS' : 'ANDROID';
|
||||
}
|
||||
|
||||
String get _osVersion {
|
||||
if (kIsWeb) return '';
|
||||
return Platform.operatingSystemVersion;
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,8 @@ import '../../config/app_config.dart';
|
||||
import '../models/content_category.dart';
|
||||
import '../models/drama.dart';
|
||||
import '../models/home_feed.dart';
|
||||
import '../models/page_result.dart';
|
||||
import '../remote/category_api.dart';
|
||||
import '../repositories/category_repository.dart';
|
||||
|
||||
/// 剧场页数据:服务端分类清单与发现 feed。
|
||||
@@ -14,13 +16,80 @@ class CategoryController extends ChangeNotifier {
|
||||
|
||||
final CategoryRepository _repository;
|
||||
|
||||
/// 生产环境注入。未注入时首页分类继续用本地筛选。
|
||||
Future<PageResult<Drama>> Function(
|
||||
String categoryId, {
|
||||
int pageIndex,
|
||||
int pageSize,
|
||||
})? dramaPageLoader;
|
||||
|
||||
List<ContentCategory> categories = const [];
|
||||
final Map<String, CategoryDramaSlot> _slots = {};
|
||||
HomeFeed feed = const HomeFeed();
|
||||
bool loading = false;
|
||||
String? error;
|
||||
String? debugError;
|
||||
bool _disposed = false;
|
||||
|
||||
/// 某个分类自己的短剧分页,不和别的分类共用。
|
||||
CategoryDramaSlot slotOf(String categoryId) {
|
||||
return _slots.putIfAbsent(categoryId, CategoryDramaSlot.new);
|
||||
}
|
||||
|
||||
/// 打开分类并加载第一页短剧。
|
||||
Future<void> openCategory(String categoryId) async {
|
||||
final loader = dramaPageLoader;
|
||||
if (loader == null) return;
|
||||
final slot = slotOf(categoryId);
|
||||
slot.loading = true;
|
||||
slot.loadingMore = false;
|
||||
_notify();
|
||||
try {
|
||||
final page = await loader(
|
||||
categoryId,
|
||||
pageIndex: 1,
|
||||
pageSize: CategoryApi.dramaPageSize,
|
||||
);
|
||||
slot.dramas = page.list;
|
||||
slot.total = page.total;
|
||||
slot.pageIndex = 1;
|
||||
} catch (exception) {
|
||||
if (kDebugMode) debugPrint('[category] $exception');
|
||||
} finally {
|
||||
slot.loading = false;
|
||||
_notify();
|
||||
}
|
||||
}
|
||||
|
||||
/// 上拉加载这个分类的下一页。
|
||||
Future<void> loadMore(String categoryId) async {
|
||||
final loader = dramaPageLoader;
|
||||
final slot = _slots[categoryId];
|
||||
if (loader == null || slot == null) return;
|
||||
if (slot.loading || slot.loadingMore || !slot.hasMore) return;
|
||||
slot.loadingMore = true;
|
||||
_notify();
|
||||
try {
|
||||
final page = await loader(
|
||||
categoryId,
|
||||
pageIndex: slot.pageIndex + 1,
|
||||
pageSize: CategoryApi.dramaPageSize,
|
||||
);
|
||||
if (page.list.isEmpty) {
|
||||
slot.total = slot.dramas.length;
|
||||
} else {
|
||||
slot.dramas = [...slot.dramas, ...page.list];
|
||||
slot.total = page.total;
|
||||
slot.pageIndex += 1;
|
||||
}
|
||||
} catch (exception) {
|
||||
if (kDebugMode) debugPrint('[category] more $exception');
|
||||
} finally {
|
||||
slot.loadingMore = false;
|
||||
_notify();
|
||||
}
|
||||
}
|
||||
|
||||
/// 分类九宫格点击后读取该分类的剧目;缺失分区返回空列表。
|
||||
List<Drama> dramasOf(String categoryId) {
|
||||
final code = 'category-$categoryId';
|
||||
@@ -30,19 +99,23 @@ class CategoryController extends ChangeNotifier {
|
||||
return const [];
|
||||
}
|
||||
|
||||
/// 加载分类与发现 feed;失败保留可重试错误态。
|
||||
/// 首页只拉分类,再拉第一个分类的短剧。发现页聚合留到没有短剧分页时再取。
|
||||
Future<void> load() async {
|
||||
loading = true;
|
||||
error = null;
|
||||
debugError = null;
|
||||
_notify();
|
||||
try {
|
||||
final results = await Future.wait<Object>([
|
||||
_repository.fetchCategories(),
|
||||
_repository.fetchDiscoverFeed(),
|
||||
]);
|
||||
categories = results[0] as List<ContentCategory>;
|
||||
feed = results[1] as HomeFeed;
|
||||
if (dramaPageLoader != null) {
|
||||
categories = await _repository.fetchCategories();
|
||||
} else {
|
||||
final results = await Future.wait<Object>([
|
||||
_repository.fetchCategories(),
|
||||
_repository.fetchDiscoverFeed(),
|
||||
]);
|
||||
categories = results[0] as List<ContentCategory>;
|
||||
feed = results[1] as HomeFeed;
|
||||
}
|
||||
} catch (exception) {
|
||||
error = 'categoriesError';
|
||||
debugError = exception.toString();
|
||||
@@ -53,6 +126,9 @@ class CategoryController extends ChangeNotifier {
|
||||
loading = false;
|
||||
_notify();
|
||||
}
|
||||
if (error == null && dramaPageLoader != null && categories.isNotEmpty) {
|
||||
await openCategory(categories.first.id);
|
||||
}
|
||||
}
|
||||
|
||||
void _notify() {
|
||||
@@ -65,3 +141,14 @@ class CategoryController extends ChangeNotifier {
|
||||
super.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
/// 单个分类的短剧分页状态。
|
||||
class CategoryDramaSlot {
|
||||
List<Drama> dramas = const [];
|
||||
int total = 0;
|
||||
int pageIndex = 0;
|
||||
bool loading = false;
|
||||
bool loadingMore = false;
|
||||
|
||||
bool get hasMore => dramas.length < total;
|
||||
}
|
||||
@@ -161,6 +161,37 @@ class FavoriteController extends ChangeNotifier {
|
||||
}
|
||||
}
|
||||
|
||||
/// 一次取消多部收藏。失败时整批回滚。
|
||||
Future<bool> removeMany(List<String> dramaIds) async {
|
||||
final ids = dramaIds.toSet();
|
||||
if (ids.isEmpty) return true;
|
||||
final previousCards = cards;
|
||||
final previousTotal = total;
|
||||
final previousHasMore = hasMore;
|
||||
final removed = cards.where((drama) => ids.contains(drama.id)).toList();
|
||||
if (removed.isEmpty) return true;
|
||||
cards = cards.where((drama) => !ids.contains(drama.id)).toList();
|
||||
for (final id in ids) {
|
||||
_saved.remove(id);
|
||||
}
|
||||
total = total > removed.length ? total - removed.length : 0;
|
||||
hasMore = cards.length < total;
|
||||
notify();
|
||||
try {
|
||||
await _repository.removeMany(dramaIds);
|
||||
return true;
|
||||
} catch (_) {
|
||||
cards = previousCards;
|
||||
total = previousTotal;
|
||||
hasMore = previousHasMore;
|
||||
for (final drama in removed) {
|
||||
_saved.add(drama.id);
|
||||
}
|
||||
notify();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// 取消收藏("我的"页列表里删除某条)。
|
||||
Future<bool> remove(String dramaId) async {
|
||||
final index = cards.indexWhere((drama) => drama.id == dramaId);
|
||||
|
||||
@@ -0,0 +1,177 @@
|
||||
// Author: fruit.com.cn
|
||||
|
||||
part of 'playback_session.dart';
|
||||
|
||||
/// 当前集加上一集、下一集,切集时最多三个解码器。
|
||||
const int maxLivePlayers = 3;
|
||||
|
||||
/// 另一条播放路由必须等当前路由释放完全部原生播放器。
|
||||
class PlaybackCoordinator {
|
||||
PlaybackSession? _owner;
|
||||
Future<void> _handoff = Future<void>.value();
|
||||
|
||||
Future<bool> _acquire(PlaybackSession session, bool Function() valid) {
|
||||
final result = _handoff.then((_) async {
|
||||
if (!valid()) return false;
|
||||
if (_owner != session) {
|
||||
final previous = _owner;
|
||||
await previous?._releasePlayers();
|
||||
if (previous != null && previous.livePlayerCount != 0) return false;
|
||||
_owner = null;
|
||||
if (!valid()) return false;
|
||||
_owner = session;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
_handoff = result.then<void>((_) {});
|
||||
return result;
|
||||
}
|
||||
|
||||
void _forget(PlaybackSession session) {
|
||||
if (_owner == session && session.livePlayerCount == 0) _owner = null;
|
||||
}
|
||||
}
|
||||
|
||||
_PlayerSlot? _usableWarm(
|
||||
PlaybackSession session,
|
||||
_PlayerSlot? slot,
|
||||
int index,
|
||||
) {
|
||||
if (slot == null || slot.index != index || slot.failure != null) return null;
|
||||
if (session.isLocked) return null;
|
||||
return slot;
|
||||
}
|
||||
|
||||
/// 滑走的一集若仍是相邻集,就留着最后一帧,其余槽位释放。
|
||||
Future<void> _parkNeighbors(
|
||||
PlaybackSession session,
|
||||
_PlayerSlot? old,
|
||||
_PlayerSlot? warmNext,
|
||||
_PlayerSlot? warmPrevious,
|
||||
) async {
|
||||
await _placeNeighbor(session, old);
|
||||
await _placeNeighbor(session, warmNext);
|
||||
await _placeNeighbor(session, warmPrevious);
|
||||
}
|
||||
|
||||
Future<void> _placeNeighbor(PlaybackSession session, _PlayerSlot? slot) async {
|
||||
if (slot == null || slot == session._active || slot.retiring) return;
|
||||
if (session._next == null && slot.index == session._nextIndex) {
|
||||
session._next = slot;
|
||||
return;
|
||||
}
|
||||
if (session._previous == null && slot.index == session._previousIndex) {
|
||||
session._previous = slot;
|
||||
return;
|
||||
}
|
||||
await session._retire(slot);
|
||||
}
|
||||
|
||||
/// 当前集已经出画后,静默准备上一集和下一集。
|
||||
void _warmNeighbors(PlaybackSession session) {
|
||||
final request = session._generation;
|
||||
session._preloadTask = () async {
|
||||
await Future.wait([
|
||||
_warmOne(session, request, session._nextIndex, next: true),
|
||||
_warmOne(session, request, session._previousIndex, next: false),
|
||||
]);
|
||||
}();
|
||||
}
|
||||
|
||||
Future<void> _warmOne(
|
||||
PlaybackSession session,
|
||||
int request,
|
||||
int? index, {
|
||||
required bool next,
|
||||
}) async {
|
||||
final candidate = await _allocateNeighbor(
|
||||
session,
|
||||
request,
|
||||
index,
|
||||
next: next,
|
||||
);
|
||||
if (candidate == null) return;
|
||||
await candidate.ready;
|
||||
if (session._closed || !_stillHeld(session, candidate, next: next)) return;
|
||||
if (candidate.failure == null) {
|
||||
session._notify();
|
||||
return;
|
||||
}
|
||||
await session._enqueue(() async {
|
||||
if (!_stillHeld(session, candidate, next: next)) return;
|
||||
_clearNeighbor(session, next: next);
|
||||
await session._retire(candidate);
|
||||
});
|
||||
}
|
||||
|
||||
Future<_PlayerSlot?> _allocateNeighbor(
|
||||
PlaybackSession session,
|
||||
int request,
|
||||
int? index, {
|
||||
required bool next,
|
||||
}) async {
|
||||
_PlayerSlot? created;
|
||||
await session._enqueue(() async {
|
||||
if (session._closed || request != session._generation) return;
|
||||
final allowed = _neighborAllowed(session, index);
|
||||
final current = next ? session._next : session._previous;
|
||||
if (!allowed || current?.index != index) {
|
||||
_clearNeighbor(session, next: next);
|
||||
await session._retire(current);
|
||||
}
|
||||
if (!_canAllocate(session, request, allowed: allowed, next: next)) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
created = session._create(index!);
|
||||
} on StateError catch (error) {
|
||||
if (kDebugMode) debugPrint('相邻集预热跳过: $error');
|
||||
return;
|
||||
}
|
||||
if (next) {
|
||||
session._next = created;
|
||||
} else {
|
||||
session._previous = created;
|
||||
}
|
||||
});
|
||||
return created;
|
||||
}
|
||||
|
||||
bool _neighborAllowed(PlaybackSession session, int? index) {
|
||||
return index != null &&
|
||||
index >= 0 &&
|
||||
index < session.episodes.length &&
|
||||
index != session._currentIndex &&
|
||||
session.canPlay(session.episodes[index]);
|
||||
}
|
||||
|
||||
bool _canAllocate(
|
||||
PlaybackSession session,
|
||||
int request, {
|
||||
required bool allowed,
|
||||
required bool next,
|
||||
}) {
|
||||
final held = next ? session._next : session._previous;
|
||||
return session._visible &&
|
||||
!session._overlayOpen &&
|
||||
request == session._generation &&
|
||||
session._active?.prepared == true &&
|
||||
allowed &&
|
||||
held == null;
|
||||
}
|
||||
|
||||
bool _stillHeld(
|
||||
PlaybackSession session,
|
||||
_PlayerSlot slot, {
|
||||
required bool next,
|
||||
}) {
|
||||
return (next ? session._next : session._previous) == slot;
|
||||
}
|
||||
|
||||
void _clearNeighbor(PlaybackSession session, {required bool next}) {
|
||||
if (next) {
|
||||
session._next = null;
|
||||
return;
|
||||
}
|
||||
session._previous = null;
|
||||
}
|
||||
@@ -5,42 +5,18 @@ import 'dart:async';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import '../models/drama.dart';
|
||||
import '../models/player_port.dart';
|
||||
import 'video_player_port.dart';
|
||||
|
||||
part 'playback_neighbors.dart';
|
||||
|
||||
/// 新纹理第一帧常是黑的,旧画面只盖住这一小段。
|
||||
const Duration _qualityHandoffHold = Duration(milliseconds: 200);
|
||||
|
||||
typedef PlayerFactory = PlayerPort Function(Episode episode);
|
||||
typedef PlayerPreparation =
|
||||
Future<void> Function(Episode episode, PlayerPort player);
|
||||
|
||||
/// Shared by routes: the previous session releases all native players before
|
||||
/// another session allocates. The app therefore has at most two, not two per page.
|
||||
class PlaybackCoordinator {
|
||||
PlaybackSession? _owner;
|
||||
Future<void> _handoff = Future<void>.value();
|
||||
|
||||
Future<bool> _acquire(PlaybackSession session, bool Function() valid) {
|
||||
final result = _handoff.then((_) async {
|
||||
if (!valid()) return false;
|
||||
if (_owner != session) {
|
||||
final previous = _owner;
|
||||
await previous?._releasePlayers();
|
||||
// A failed native disposal cannot be treated as a free decoder slot.
|
||||
if (previous != null && previous.livePlayerCount != 0) return false;
|
||||
_owner = null;
|
||||
if (!valid()) return false;
|
||||
_owner = session;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
_handoff = result.then<void>((_) {});
|
||||
return result;
|
||||
}
|
||||
|
||||
void _forget(PlaybackSession session) {
|
||||
if (_owner == session && session.livePlayerCount == 0) _owner = null;
|
||||
}
|
||||
}
|
||||
|
||||
/// Owns current + one prepared successor. All allocation, playback and disposal
|
||||
/// operations are serialized; initialization can run while current plays.
|
||||
/// Owns current plus previous/next frames; allocation stays serialized.
|
||||
class PlaybackSession extends ChangeNotifier {
|
||||
PlaybackSession({
|
||||
required this.episodes,
|
||||
@@ -66,11 +42,14 @@ class PlaybackSession extends ChangeNotifier {
|
||||
final Set<_PlayerSlot> _live = {};
|
||||
_PlayerSlot? _active;
|
||||
_PlayerSlot? _next;
|
||||
_PlayerSlot? _previous;
|
||||
_PlayerSlot? _handoff;
|
||||
Future<void> _operations = Future<void>.value();
|
||||
Future<void> _preloadTask = Future<void>.value();
|
||||
int _generation = 0;
|
||||
int _currentIndex = 0;
|
||||
int? _nextIndex;
|
||||
int? _previousIndex;
|
||||
bool _selected = false;
|
||||
bool _loading = false;
|
||||
bool _closed = false;
|
||||
@@ -115,7 +94,7 @@ class PlaybackSession extends ChangeNotifier {
|
||||
/// during a swipe without starting audio or registering history listeners.
|
||||
PlayerPort? preparedPlayerAt(int index) {
|
||||
if (_closed) return null;
|
||||
for (final slot in [_active, _next]) {
|
||||
for (final slot in [_active, _next, _previous]) {
|
||||
if (slot == null ||
|
||||
slot.retiring ||
|
||||
slot.index != index ||
|
||||
@@ -127,25 +106,46 @@ class PlaybackSession extends ChangeNotifier {
|
||||
return null;
|
||||
}
|
||||
|
||||
/// 清晰度切换时盖住黑帧的旧播放器。只在仍由会话持有时交给界面。
|
||||
PlayerPort? handoffAt(int index) {
|
||||
final slot = _handoff;
|
||||
if (_closed || slot == null || slot.retiring || slot.index != index) {
|
||||
return null;
|
||||
}
|
||||
return slot.player;
|
||||
}
|
||||
|
||||
/// 队列重排后把当前仍在播放的 slot 映射到新索引,不重新创建播放器。
|
||||
void remapCurrentIndex(int index, {int? preloadIndex}) {
|
||||
void remapCurrentIndex(int index, {int? preloadIndex, int? previousIndex}) {
|
||||
if (_closed || index < 0 || index >= episodes.length) return;
|
||||
final activeSlot = _active;
|
||||
if (activeSlot == null || activeSlot.index != _currentIndex) {
|
||||
_currentIndex = index;
|
||||
_nextIndex = preloadIndex;
|
||||
_rememberNeighbors(preloadIndex, previousIndex);
|
||||
_notify();
|
||||
return;
|
||||
}
|
||||
_generation++;
|
||||
activeSlot.index = index;
|
||||
_currentIndex = index;
|
||||
_nextIndex = preloadIndex;
|
||||
_rememberNeighbors(preloadIndex, previousIndex);
|
||||
final staleNext = _next;
|
||||
final stalePrevious = _previous;
|
||||
_next = null;
|
||||
_previous = null;
|
||||
_notify();
|
||||
unawaited(_enqueue(() async => _retire(staleNext)));
|
||||
if (_visible && !_overlayOpen) _schedulePreload();
|
||||
unawaited(
|
||||
_enqueue(() async {
|
||||
await _retire(staleNext);
|
||||
await _retire(stalePrevious);
|
||||
}),
|
||||
);
|
||||
if (_visible && !_overlayOpen) _warmNeighbors(this);
|
||||
}
|
||||
|
||||
void _rememberNeighbors(int? preloadIndex, int? previousIndex) {
|
||||
_nextIndex = preloadIndex;
|
||||
_previousIndex = previousIndex;
|
||||
}
|
||||
|
||||
Future<void> _enqueue(Future<void> Function() operation) {
|
||||
@@ -162,7 +162,9 @@ class PlaybackSession extends ChangeNotifier {
|
||||
}
|
||||
|
||||
_PlayerSlot _create(int index) {
|
||||
if (_live.length >= 2) throw StateError('Playback resource limit reached');
|
||||
if (_live.length >= maxLivePlayers) {
|
||||
throw StateError('Playback resource limit reached');
|
||||
}
|
||||
final slot = _PlayerSlot(index, factory(episodes[index]));
|
||||
_live.add(slot);
|
||||
slot.ready = () async {
|
||||
@@ -184,9 +186,15 @@ class PlaybackSession extends ChangeNotifier {
|
||||
Future<void> _retire(_PlayerSlot? slot) async {
|
||||
if (slot == null || !_live.contains(slot)) return;
|
||||
slot.retiring = true;
|
||||
final cleared = _active == slot || _next == slot;
|
||||
final cleared =
|
||||
_active == slot ||
|
||||
_next == slot ||
|
||||
_previous == slot ||
|
||||
_handoff == slot;
|
||||
if (_active == slot) _active = null;
|
||||
if (_next == slot) _next = null;
|
||||
if (_previous == slot) _previous = null;
|
||||
if (_handoff == slot) _handoff = null;
|
||||
if (cleared) _notify();
|
||||
await waitForFrame?.call();
|
||||
await slot.ready;
|
||||
@@ -200,7 +208,11 @@ class PlaybackSession extends ChangeNotifier {
|
||||
|
||||
/// preloadIndex comes from the visible queue, so filtered categories and series
|
||||
/// use exactly the same mechanism without warming an unrelated episode.
|
||||
Future<void> select(int index, {int? preloadIndex}) async {
|
||||
Future<void> select(
|
||||
int index, {
|
||||
int? preloadIndex,
|
||||
int? previousIndex,
|
||||
}) async {
|
||||
if (_closed || index < 0 || index >= episodes.length) return;
|
||||
// 切到另一集时,上一集按下的暂停不跟着走:滑过去就应该自动播放。
|
||||
// 重复选中同一集(例如页面重新可见)不在这里恢复,尊重用户按下的暂停。
|
||||
@@ -210,7 +222,7 @@ class PlaybackSession extends ChangeNotifier {
|
||||
final request = ++_generation;
|
||||
_selected = true;
|
||||
_currentIndex = index;
|
||||
_nextIndex = preloadIndex;
|
||||
_rememberNeighbors(preloadIndex, previousIndex);
|
||||
_error = null;
|
||||
if (!_visible) {
|
||||
_loading = false;
|
||||
@@ -235,6 +247,7 @@ class PlaybackSession extends ChangeNotifier {
|
||||
_PlayerSlot? target;
|
||||
await _enqueue(() async {
|
||||
if (_closed || request != _generation) return;
|
||||
await _retire(_handoff);
|
||||
final old = _active;
|
||||
if (old != null &&
|
||||
old.index == index &&
|
||||
@@ -244,19 +257,22 @@ class PlaybackSession extends ChangeNotifier {
|
||||
return;
|
||||
}
|
||||
if (old != null) await old.player.pause();
|
||||
final warm = _next;
|
||||
final warmNext = _next;
|
||||
final warmPrevious = _previous;
|
||||
_active = null;
|
||||
_next = null;
|
||||
final hit = warm?.index == index && warm?.failure == null && !isLocked;
|
||||
if (hit) {
|
||||
_previous = null;
|
||||
final warm =
|
||||
_usableWarm(this, warmNext, index) ??
|
||||
_usableWarm(this, warmPrevious, index);
|
||||
if (warm != null) {
|
||||
target = _active = warm;
|
||||
_loading = !warm!.prepared;
|
||||
_loading = !warm.prepared;
|
||||
_notify();
|
||||
// Start a ready successor before awaiting slow disposal of the old one.
|
||||
if (warm.prepared) await _start(warm, request);
|
||||
}
|
||||
await _retire(old);
|
||||
if (!hit) await _retire(warm);
|
||||
await _parkNeighbors(this, old, warmNext, warmPrevious);
|
||||
if (_closed || request != _generation || isLocked) return;
|
||||
if (target == null) {
|
||||
target = _active = _create(index);
|
||||
@@ -269,7 +285,109 @@ class PlaybackSession extends ChangeNotifier {
|
||||
await slot.ready;
|
||||
if (_closed || request != _generation || _active != slot) return;
|
||||
await _enqueue(() => _start(slot, request));
|
||||
if (!_closed && request == _generation) _schedulePreload();
|
||||
if (!_closed && request == _generation) _warmNeighbors(this);
|
||||
}
|
||||
|
||||
/// 后台准备新片源,成功后再替换当前播放器。失败时原播放器保持不动。
|
||||
Future<bool> replaceCurrent() async {
|
||||
if (_closed || !_selected) return false;
|
||||
final index = _currentIndex;
|
||||
if (index < 0 || index >= episodes.length || isLocked) return false;
|
||||
if (!canPlay(episodes[index])) return false;
|
||||
final request = _generation;
|
||||
final slot = await _prepareReplacement(index, request);
|
||||
if (slot == null) {
|
||||
await _resumeActive();
|
||||
return false;
|
||||
}
|
||||
await slot.ready;
|
||||
if (!_replacementReady(slot, request)) {
|
||||
await _dropReplacement(slot);
|
||||
await _resumeActive();
|
||||
return false;
|
||||
}
|
||||
final previous = await _showReplacement(slot, request);
|
||||
if (_active != slot) {
|
||||
await _dropReplacement(slot);
|
||||
return false;
|
||||
}
|
||||
await _enqueue(() => _start(slot, request));
|
||||
await Future<void>.delayed(_qualityHandoffHold);
|
||||
if (previous != null && _handoff == previous && _active == slot) {
|
||||
await _enqueue(() => _retire(previous));
|
||||
}
|
||||
if (!_closed && request == _generation) _warmNeighbors(this);
|
||||
return _active == slot && slot.failure == null;
|
||||
}
|
||||
|
||||
Future<_PlayerSlot?> _prepareReplacement(int index, int request) async {
|
||||
_PlayerSlot? created;
|
||||
await _enqueue(() async {
|
||||
if (_closed || request != _generation || _active == null) return;
|
||||
final warm = _next;
|
||||
_next = null;
|
||||
await _retire(_handoff);
|
||||
await _retire(warm);
|
||||
if (_closed || request != _generation || _active == null) return;
|
||||
try {
|
||||
created = _create(index);
|
||||
} catch (_) {
|
||||
created = null;
|
||||
}
|
||||
});
|
||||
return created;
|
||||
}
|
||||
|
||||
bool _replacementReady(_PlayerSlot slot, int request) {
|
||||
return !_closed &&
|
||||
request == _generation &&
|
||||
_active != null &&
|
||||
slot.failure == null &&
|
||||
slot.prepared;
|
||||
}
|
||||
|
||||
Future<void> _resumeActive() async {
|
||||
final slot = _active;
|
||||
if (slot == null || !_userWantsPlay || _closed) return;
|
||||
await _enqueue(() => _applyPlayback(slot));
|
||||
}
|
||||
|
||||
Future<void> _dropReplacement(_PlayerSlot slot) {
|
||||
return _enqueue(() async {
|
||||
if (_live.contains(slot)) await _retire(slot);
|
||||
});
|
||||
}
|
||||
|
||||
/// 先把已出画的新播放器交到界面上,旧播放器留给调用方稍后释放。
|
||||
Future<_PlayerSlot?> _showReplacement(_PlayerSlot slot, int request) async {
|
||||
_PlayerSlot? previous;
|
||||
var shown = false;
|
||||
await _enqueue(() async {
|
||||
if (!_replacementReady(slot, request)) return;
|
||||
previous = _active;
|
||||
await _catchUp(slot, previous);
|
||||
_handoff = previous;
|
||||
_active = slot;
|
||||
shown = true;
|
||||
if (previous != null) await previous!.player.pause();
|
||||
_notify();
|
||||
});
|
||||
if (!shown || _active != slot) return null;
|
||||
return previous;
|
||||
}
|
||||
|
||||
/// 旧片仍在播,把新片对齐到当前进度,盖住时画面才接得上。
|
||||
Future<void> _catchUp(_PlayerSlot slot, _PlayerSlot? previous) async {
|
||||
final next = slot.player;
|
||||
final current = previous?.player;
|
||||
if (next is! VideoPlayerPort || current is! VideoPlayerPort) return;
|
||||
final position = current.controller.value.position;
|
||||
if (position <= Duration.zero) return;
|
||||
try {
|
||||
await next.seekTo(position);
|
||||
} catch (_) {
|
||||
// 对齐失败仍用准备阶段的进度,不因此放弃切换。
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _start(_PlayerSlot slot, int request) async {
|
||||
@@ -304,54 +422,6 @@ class PlaybackSession extends ChangeNotifier {
|
||||
slot.playing = shouldPlay;
|
||||
}
|
||||
|
||||
void _schedulePreload() {
|
||||
final request = _generation;
|
||||
final index = _nextIndex;
|
||||
_preloadTask = () async {
|
||||
_PlayerSlot? candidate;
|
||||
await _enqueue(() async {
|
||||
if (_closed || request != _generation) return;
|
||||
final allowed =
|
||||
index != null &&
|
||||
index >= 0 &&
|
||||
index < episodes.length &&
|
||||
index != _currentIndex &&
|
||||
canPlay(episodes[index]);
|
||||
if (!allowed || _next?.index != index) {
|
||||
final stale = _next;
|
||||
_next = null;
|
||||
await _retire(stale);
|
||||
}
|
||||
if (!_visible ||
|
||||
_overlayOpen ||
|
||||
request != _generation ||
|
||||
_active?.prepared != true ||
|
||||
!allowed) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
candidate = _next ??= _create(index);
|
||||
} catch (_) {
|
||||
// Optional allocation failure must not interrupt the playing item.
|
||||
}
|
||||
});
|
||||
final slot = candidate;
|
||||
if (slot == null) return;
|
||||
await slot.ready;
|
||||
if (_closed || _next != slot) return;
|
||||
if (slot.failure != null) {
|
||||
// Optional work fails silently. A later explicit selection retries.
|
||||
await _enqueue(() async {
|
||||
if (_next != slot) return;
|
||||
_next = null;
|
||||
await _retire(slot);
|
||||
});
|
||||
} else {
|
||||
_notify();
|
||||
}
|
||||
}();
|
||||
}
|
||||
|
||||
void setAppResumed(bool value) {
|
||||
_appResumed = value;
|
||||
_syncPlayback();
|
||||
@@ -376,18 +446,24 @@ class PlaybackSession extends ChangeNotifier {
|
||||
void _syncPlayback() {
|
||||
if (_closed) return;
|
||||
if (_visible && _selected && active == null) {
|
||||
unawaited(select(_currentIndex, preloadIndex: _nextIndex));
|
||||
unawaited(
|
||||
select(
|
||||
_currentIndex,
|
||||
preloadIndex: _nextIndex,
|
||||
previousIndex: _previousIndex,
|
||||
),
|
||||
);
|
||||
return;
|
||||
}
|
||||
final slot = _active;
|
||||
if (slot != null) unawaited(_enqueue(() => _applyPlayback(slot)));
|
||||
if (_visible && !_overlayOpen && !_loading) _schedulePreload();
|
||||
if (_visible && !_overlayOpen && !_loading) _warmNeighbors(this);
|
||||
}
|
||||
|
||||
Future<void> _releasePlayers() {
|
||||
_generation++;
|
||||
return _enqueue(() async {
|
||||
_active = _next = null;
|
||||
_active = _next = _previous = _handoff = null;
|
||||
_loading = false;
|
||||
_notify();
|
||||
for (final slot in _live.toList()) {
|
||||
|
||||