Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fe0e77775e | ||
|
|
6ef5429a52 | ||
|
|
9ef78ad670 | ||
|
|
bea08110c9 | ||
|
|
67670d46b1 | ||
|
|
7b90bd59b9 | ||
|
|
938435dfb9 | ||
|
|
b61bfe625c | ||
|
|
a7b4277536 | ||
|
|
dabff48f7c | ||
|
|
6acc00394b | ||
|
|
f3cfd0d0ec | ||
|
|
35cbdd2bd3 | ||
|
|
3ad371aa9d | ||
|
|
7463d3ee26 | ||
|
|
59fbd33059 | ||
|
|
8c1662475a | ||
|
|
7f65fe4d48 | ||
|
|
613147c20c | ||
|
|
731638b31b | ||
|
|
a833d62c50 | ||
|
|
bc01716449 | ||
|
|
12b1a11bd3 | ||
|
|
8ec6df2be5 | ||
|
|
5ec4db151a | ||
|
|
a47af8c3ad | ||
|
|
2ddf9ee1c6 | ||
|
|
3bc79ad8e2 | ||
|
|
c307903c42 | ||
|
|
c5b94633f1 | ||
|
|
fd2ba0bf43 | ||
|
|
aed9ee2b01 | ||
|
|
335e5dc286 | ||
|
|
2f4593a46e | ||
|
|
7509cf2ecd | ||
|
|
501bc66282 | ||
|
|
19196ceb8e | ||
|
|
9ef8eb15b0 | ||
|
|
53e8c924a6 | ||
|
|
e7399fa3fd | ||
|
|
22cc669bbe | ||
|
|
26321e3348 | ||
|
|
3590cd0c55 | ||
|
|
c311985601 | ||
|
|
4dd37b2588 | ||
|
|
543d0aadd5 | ||
|
|
d5bcda54d3 | ||
|
|
79463e65c2 | ||
|
|
ad7aba3daf | ||
|
|
47fdd4a29d | ||
|
|
fe49527dd8 | ||
|
|
4aaa5bbd60 | ||
|
|
5649e4c3d4 | ||
|
|
9f7301305e | ||
|
|
63191b4692 | ||
|
|
0f777b19f2 | ||
|
|
fb9001a02d | ||
|
|
1b80f841be |
No files matched your search
@@ -0,0 +1,25 @@
|
|||||||
|
# Author: fruit.com.cn
|
||||||
|
# ReelShort 客户端 CI:静态分析 + 测试门禁
|
||||||
|
name: flutter-ci
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [develop, main]
|
||||||
|
pull_request:
|
||||||
|
branches: [develop, main]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: subosito/flutter-action@v2
|
||||||
|
with:
|
||||||
|
channel: stable
|
||||||
|
cache: true
|
||||||
|
- name: 依赖
|
||||||
|
run: flutter pub get
|
||||||
|
- name: 静态分析(零告警门禁)
|
||||||
|
run: dart analyze --fatal-infos
|
||||||
|
- name: 单元测试(全绿门禁)
|
||||||
|
run: flutter test -r expanded
|
||||||
@@ -65,3 +65,6 @@ app.*.map.json
|
|||||||
.env
|
.env
|
||||||
.env.*
|
.env.*
|
||||||
!.env.example
|
!.env.example
|
||||||
|
|
||||||
|
# IDE 的 Flutter Widget Preview 生成目录。
|
||||||
|
.widget_preview/
|
||||||
@@ -81,12 +81,15 @@ Android 模拟器访问宿主机时,同样在调试条里填 `http://10.0.2.2:
|
|||||||
|
|
||||||
### iOS
|
### iOS
|
||||||
|
|
||||||
手机与 Mac 需在同一网络,首次启动允许“本地网络”权限:
|
iOS 模拟器直接访问 Mac 本机服务,默认地址为 `http://127.0.0.1:8081`:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
flutter run -d <udid>
|
flutter run -d <simulator-udid>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
iPhone 真机不能用 `127.0.0.1` 访问 Mac;真机联调时需让手机与 Mac 位于同一网络,
|
||||||
|
并通过调试入口临时填写 Mac 的局域网地址。
|
||||||
|
|
||||||
### 服务地址配置
|
### 服务地址配置
|
||||||
|
|
||||||
地址是代码里的一个开关,**不做任何网络探测**,也不用传构建参数。两套环境各占
|
地址是代码里的一个开关,**不做任何网络探测**,也不用传构建参数。两套环境各占
|
||||||
@@ -94,7 +97,7 @@ flutter run -d <udid>
|
|||||||
|
|
||||||
| 文件 | 用途 | 默认值 |
|
| 文件 | 用途 | 默认值 |
|
||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| `lib/core/config/dev_config.dart` | 开发 / 联调 | `http://192.168.31.243:8081` |
|
| `lib/core/config/dev_config.dart` | 开发 / 联调 | `http://127.0.0.1:8081` |
|
||||||
| `lib/core/config/prod_config.dart` | 生产 | `http://39.162.50.99:8081` |
|
| `lib/core/config/prod_config.dart` | 生产 | `http://39.162.50.99:8081` |
|
||||||
|
|
||||||
切换环境只改 `lib/core/config/app_config.dart` 里的一个布尔值:
|
切换环境只改 `lib/core/config/app_config.dart` 里的一个布尔值:
|
||||||
@@ -103,7 +106,7 @@ flutter run -d <udid>
|
|||||||
static const bool useDevConfig = true; // false 即用生产地址
|
static const bool useDevConfig = true; // false 即用生产地址
|
||||||
```
|
```
|
||||||
|
|
||||||
换 Wi-Fi 或换网段时只改 `dev_config.dart` 的 `baseUrl`。打生产包前把
|
真机或 Android 模拟器联调时,通过调试入口覆盖地址,不修改默认开发配置。打生产包前把
|
||||||
`useDevConfig` 改成 `false`;release 构建若仍为 `true` 会在启动时直接报错,
|
`useDevConfig` 改成 `false`;release 构建若仍为 `true` 会在启动时直接报错,
|
||||||
避免线上包连到开发机。
|
避免线上包连到开发机。
|
||||||
|
|
||||||
@@ -197,7 +200,7 @@ flutter test
|
|||||||
flutter build apk --debug
|
flutter build apk --debug
|
||||||
```
|
```
|
||||||
|
|
||||||
当前基线:`dart analyze` 仅 1 条既存 info(`intl` 未在 `pubspec.yaml` 声明);
|
当前基线:`dart analyze` 仅 1 条既存 info(`intl` 未在 `pubspec.yaml` 声明);
|
||||||
`flutter test` 全量 775 例通过。测试文件按模块放在 `test/` 下,用例名使用
|
`flutter test` 全量 775 例通过。测试文件按模块放在 `test/` 下,用例名使用
|
||||||
`should_<期望>_when_<条件>`。真实后端联调测试在服务未启动时会跳过。
|
`should_<期望>_when_<条件>`。真实后端联调测试在服务未启动时会跳过。
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<uses-permission
|
<uses-permission
|
||||||
android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
|
android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
|
||||||
<application
|
<application
|
||||||
android:label="FruitShorts"
|
android:label="ymb"
|
||||||
android:name="${applicationName}"
|
android:name="${applicationName}"
|
||||||
android:icon="@mipmap/ic_launcher"
|
android:icon="@mipmap/ic_launcher"
|
||||||
android:usesCleartextTraffic="true">
|
android:usesCleartextTraffic="true">
|
||||||
|
|||||||
|
After Width: | Height: | Size: 5.2 KiB |
|
Before Width: | Height: | Size: 7.0 KiB After Width: | Height: | Size: 3.6 KiB |
|
After Width: | Height: | Size: 3.9 KiB |
|
After Width: | Height: | Size: 3.2 KiB |
|
Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 1.9 KiB |
|
After Width: | Height: | Size: 2.4 KiB |
|
Before Width: | Height: | Size: 21 KiB |
|
Before Width: | Height: | Size: 20 KiB |
|
After Width: | Height: | Size: 7.4 KiB |
|
Before Width: | Height: | Size: 7.2 KiB After Width: | Height: | Size: 3.8 KiB |
|
After Width: | Height: | Size: 5.3 KiB |
|
After Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 5.8 KiB |
|
After Width: | Height: | Size: 8.6 KiB |
|
After Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 8.0 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 6.5 KiB After Width: | Height: | Size: 156 B |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.0 KiB |
|
Before Width: | Height: | Size: 3.6 KiB After Width: | Height: | Size: 113 B |
|
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 2.2 KiB |
|
Before Width: | Height: | Size: 9.7 KiB After Width: | Height: | Size: 216 B |
|
Before Width: | Height: | Size: 5.8 KiB After Width: | Height: | Size: 3.5 KiB |
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 384 B |
|
Before Width: | Height: | Size: 6.3 KiB After Width: | Height: | Size: 4.5 KiB |
|
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 623 B |
@@ -8,7 +8,7 @@
|
|||||||
<item name="android:windowDrawsSystemBarBackgrounds">false</item>
|
<item name="android:windowDrawsSystemBarBackgrounds">false</item>
|
||||||
<item name="android:windowLayoutInDisplayCutoutMode">shortEdges</item>
|
<item name="android:windowLayoutInDisplayCutoutMode">shortEdges</item>
|
||||||
<item name="android:windowSplashScreenBackground">#000000</item>
|
<item name="android:windowSplashScreenBackground">#000000</item>
|
||||||
<item name="android:windowSplashScreenAnimatedIcon">@drawable/splash_brand</item>
|
<item name="android:windowSplashScreenAnimatedIcon">@drawable/android12splash</item>
|
||||||
<item name="android:windowSplashScreenAnimationDuration">0</item>
|
<item name="android:windowSplashScreenAnimationDuration">0</item>
|
||||||
</style>
|
</style>
|
||||||
<style name="NormalTheme" parent="@android:style/Theme.Black.NoTitleBar">
|
<style name="NormalTheme" parent="@android:style/Theme.Black.NoTitleBar">
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
<item name="android:windowDrawsSystemBarBackgrounds">false</item>
|
<item name="android:windowDrawsSystemBarBackgrounds">false</item>
|
||||||
<item name="android:windowLayoutInDisplayCutoutMode">shortEdges</item>
|
<item name="android:windowLayoutInDisplayCutoutMode">shortEdges</item>
|
||||||
<item name="android:windowSplashScreenBackground">#000000</item>
|
<item name="android:windowSplashScreenBackground">#000000</item>
|
||||||
<item name="android:windowSplashScreenAnimatedIcon">@drawable/splash_brand</item>
|
<item name="android:windowSplashScreenAnimatedIcon">@drawable/android12splash</item>
|
||||||
<item name="android:windowSplashScreenAnimationDuration">0</item>
|
<item name="android:windowSplashScreenAnimationDuration">0</item>
|
||||||
</style>
|
</style>
|
||||||
<style name="NormalTheme" parent="@android:style/Theme.Light.NoTitleBar">
|
<style name="NormalTheme" parent="@android:style/Theme.Light.NoTitleBar">
|
||||||
|
|||||||
@@ -3,5 +3,5 @@
|
|||||||
|
|
||||||
<resources>
|
<resources>
|
||||||
<color name="splash_background">#000000</color>
|
<color name="splash_background">#000000</color>
|
||||||
<color name="ic_launcher_background">#FF6B2C</color>
|
<color name="ic_launcher_background">#000000</color>
|
||||||
</resources>
|
</resources>
|
||||||
|
Before Width: | Height: | Size: 41 KiB |
|
After Width: | Height: | Size: 9.6 KiB |
|
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 28 KiB |
|
Before Width: | Height: | Size: 42 KiB |
|
After Width: | Height: | Size: 50 KiB |
|
After Width: | Height: | Size: 18 KiB |
|
After Width: | Height: | Size: 18 KiB |
|
After Width: | Height: | Size: 16 KiB |
@@ -387,7 +387,7 @@
|
|||||||
"$(inherited)",
|
"$(inherited)",
|
||||||
"@executable_path/Frameworks",
|
"@executable_path/Frameworks",
|
||||||
);
|
);
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = com.stormg.lumadramv;
|
PRODUCT_BUNDLE_IDENTIFIER = com.stormg.lumadrama;
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
|
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
|
||||||
SWIFT_VERSION = 5.0;
|
SWIFT_VERSION = 5.0;
|
||||||
@@ -567,7 +567,7 @@
|
|||||||
"$(inherited)",
|
"$(inherited)",
|
||||||
"@executable_path/Frameworks",
|
"@executable_path/Frameworks",
|
||||||
);
|
);
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = com.stormg.lumadramv;
|
PRODUCT_BUNDLE_IDENTIFIER = com.stormg.lumadrama;
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
|
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
|
||||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||||
@@ -590,7 +590,7 @@
|
|||||||
"$(inherited)",
|
"$(inherited)",
|
||||||
"@executable_path/Frameworks",
|
"@executable_path/Frameworks",
|
||||||
);
|
);
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = com.stormg.lumadramv;
|
PRODUCT_BUNDLE_IDENTIFIER = com.stormg.lumadrama;
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
|
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
|
||||||
SWIFT_VERSION = 5.0;
|
SWIFT_VERSION = 5.0;
|
||||||
|
|||||||
@@ -0,0 +1,68 @@
|
|||||||
|
{
|
||||||
|
"pins" : [
|
||||||
|
{
|
||||||
|
"identity" : "app-check",
|
||||||
|
"kind" : "remoteSourceControl",
|
||||||
|
"location" : "https://github.com/google/app-check.git",
|
||||||
|
"state" : {
|
||||||
|
"revision" : "b7c71458b70284cc0f5a87103f66f0b1d98b1873",
|
||||||
|
"version" : "12.1.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"identity" : "appauth-ios",
|
||||||
|
"kind" : "remoteSourceControl",
|
||||||
|
"location" : "https://github.com/openid/AppAuth-iOS.git",
|
||||||
|
"state" : {
|
||||||
|
"revision" : "a972daac82d449d58ab119e91c68153e29ddac33",
|
||||||
|
"version" : "3.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"identity" : "googlesignin-ios",
|
||||||
|
"kind" : "remoteSourceControl",
|
||||||
|
"location" : "https://github.com/google/GoogleSignIn-iOS.git",
|
||||||
|
"state" : {
|
||||||
|
"revision" : "bfaebbc04a4d13ed7a89b0fc1fb8ad66b362cc1c",
|
||||||
|
"version" : "10.1.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"identity" : "googleutilities",
|
||||||
|
"kind" : "remoteSourceControl",
|
||||||
|
"location" : "https://github.com/google/GoogleUtilities.git",
|
||||||
|
"state" : {
|
||||||
|
"revision" : "5459ee5603def3db0fe14ca522185f42c48d978e",
|
||||||
|
"version" : "8.1.5"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"identity" : "gtm-session-fetcher",
|
||||||
|
"kind" : "remoteSourceControl",
|
||||||
|
"location" : "https://github.com/google/gtm-session-fetcher.git",
|
||||||
|
"state" : {
|
||||||
|
"revision" : "724a52eea6329b7e12d3ad8300d76ca9f3895fcc",
|
||||||
|
"version" : "5.3.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"identity" : "gtmappauth",
|
||||||
|
"kind" : "remoteSourceControl",
|
||||||
|
"location" : "https://github.com/google/GTMAppAuth.git",
|
||||||
|
"state" : {
|
||||||
|
"revision" : "57094cd46bc8700d3a887e2a429f42b6e8ea3f0b",
|
||||||
|
"version" : "6.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"identity" : "interop-ios-for-google-sdks",
|
||||||
|
"kind" : "remoteSourceControl",
|
||||||
|
"location" : "https://github.com/google/interop-ios-for-google-sdks.git",
|
||||||
|
"state" : {
|
||||||
|
"revision" : "040d087ac2267d2ddd4cca36c757d1c6a05fdbfe",
|
||||||
|
"version" : "101.0.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"version" : 2
|
||||||
|
}
|
||||||
@@ -386,15 +386,29 @@ final class PipShadowCoordinator: NSObject, AVPictureInPictureControllerDelegate
|
|||||||
guard call.method == "shareText",
|
guard call.method == "shareText",
|
||||||
let arguments = call.arguments as? [String: Any],
|
let arguments = call.arguments as? [String: Any],
|
||||||
let text = arguments["text"] as? String,
|
let text = arguments["text"] as? String,
|
||||||
!text.isEmpty,
|
!text.isEmpty else {
|
||||||
let controller = self?.window?.rootViewController else {
|
|
||||||
result(FlutterError(code: "share_unavailable", message: "Share sheet is unavailable", details: nil))
|
result(FlutterError(code: "share_unavailable", message: "Share sheet is unavailable", details: nil))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
let activity = UIActivityViewController(activityItems: [text], applicationActivities: nil)
|
DispatchQueue.main.async {
|
||||||
activity.popoverPresentationController?.sourceView = controller.view
|
guard let controller = self?.sharePresenter() else {
|
||||||
activity.completionWithItemsHandler = { _, _, _, _ in result(nil) }
|
result(FlutterError(code: "share_unavailable", message: "Share sheet is unavailable", details: nil))
|
||||||
controller.present(activity, animated: true)
|
return
|
||||||
|
}
|
||||||
|
let activity = UIActivityViewController(activityItems: [text], applicationActivities: nil)
|
||||||
|
if let popover = activity.popoverPresentationController {
|
||||||
|
popover.sourceView = controller.view
|
||||||
|
popover.sourceRect = CGRect(
|
||||||
|
x: controller.view.bounds.midX,
|
||||||
|
y: controller.view.bounds.midY,
|
||||||
|
width: 0,
|
||||||
|
height: 0
|
||||||
|
)
|
||||||
|
popover.permittedArrowDirections = []
|
||||||
|
}
|
||||||
|
activity.completionWithItemsHandler = { _, _, _, _ in result(nil) }
|
||||||
|
controller.present(activity, animated: true)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let thumbnailChannel = FlutterMethodChannel(
|
let thumbnailChannel = FlutterMethodChannel(
|
||||||
@@ -459,6 +473,34 @@ final class PipShadowCoordinator: NSObject, AVPictureInPictureControllerDelegate
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// 当前前台 Scene 的根控制器之上,最适合展示系统分享面板的控制器。
|
||||||
|
private func sharePresenter() -> UIViewController? {
|
||||||
|
let keyWindow = UIApplication.shared.connectedScenes
|
||||||
|
.compactMap { $0 as? UIWindowScene }
|
||||||
|
.first { $0.activationState == .foregroundActive }?
|
||||||
|
.windows.first { $0.isKeyWindow }
|
||||||
|
guard let rootController = keyWindow?.rootViewController else { return nil }
|
||||||
|
let presenter = topPresentedController(from: rootController)
|
||||||
|
guard presenter.viewIfLoaded?.window != nil else { return nil }
|
||||||
|
return presenter
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 解析已展示页面、导航栈和标签页中的当前可见控制器。
|
||||||
|
private func topPresentedController(from controller: UIViewController) -> UIViewController {
|
||||||
|
if let presented = controller.presentedViewController {
|
||||||
|
return topPresentedController(from: presented)
|
||||||
|
}
|
||||||
|
if let navigation = controller as? UINavigationController,
|
||||||
|
let visible = navigation.visibleViewController {
|
||||||
|
return topPresentedController(from: visible)
|
||||||
|
}
|
||||||
|
if let tabs = controller as? UITabBarController,
|
||||||
|
let selected = tabs.selectedViewController {
|
||||||
|
return topPresentedController(from: selected)
|
||||||
|
}
|
||||||
|
return controller
|
||||||
|
}
|
||||||
|
|
||||||
/// iOS 画中画:影子播放器通道,与 Android 共用同一 channel 名。
|
/// iOS 画中画:影子播放器通道,与 Android 共用同一 channel 名。
|
||||||
private func registerPipChannel(_ engineBridge: FlutterImplicitEngineBridge) {
|
private func registerPipChannel(_ engineBridge: FlutterImplicitEngineBridge) {
|
||||||
let channel = FlutterMethodChannel(
|
let channel = FlutterMethodChannel(
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 43 KiB After Width: | Height: | Size: 24 KiB |
|
Before Width: | Height: | Size: 412 B After Width: | Height: | Size: 361 B |
|
Before Width: | Height: | Size: 907 B After Width: | Height: | Size: 799 B |
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 593 B After Width: | Height: | Size: 587 B |
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 907 B After Width: | Height: | Size: 799 B |
|
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 3.6 KiB After Width: | Height: | Size: 2.8 KiB |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.0 KiB |
|
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 2.3 KiB |
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 2.6 KiB |
|
Before Width: | Height: | Size: 3.6 KiB After Width: | Height: | Size: 2.8 KiB |
|
Before Width: | Height: | Size: 6.0 KiB After Width: | Height: | Size: 4.2 KiB |
|
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 5.8 KiB After Width: | Height: | Size: 3.5 KiB |
|
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 7.1 KiB After Width: | Height: | Size: 3.8 KiB |
|
Before Width: | Height: | Size: 6.3 KiB After Width: | Height: | Size: 4.0 KiB |
|
Before Width: | Height: | Size: 6.0 KiB After Width: | Height: | Size: 3.7 KiB |
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 9.9 KiB |
|
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 20 KiB |
@@ -1,115 +1,128 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?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">
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
<plist version="1.0">
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>CADisableMinimumFrameDurationOnPhone</key>
|
||||||
|
<true/>
|
||||||
|
<key>CFBundleDevelopmentRegion</key>
|
||||||
|
<string>$(DEVELOPMENT_LANGUAGE)</string>
|
||||||
|
<key>CFBundleDisplayName</key>
|
||||||
|
<string>ymb</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>ymb</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>CFBundleURLTypes</key>
|
||||||
|
<array>
|
||||||
|
<dict>
|
||||||
|
<key>CFBundleTypeRole</key>
|
||||||
|
<string>Editor</string>
|
||||||
|
<key>CFBundleURLSchemes</key>
|
||||||
|
<array>
|
||||||
|
<string>com.googleusercontent.apps.11115008580-51gv4sj2c78rud6n127g3shu4d2n96un</string>
|
||||||
|
</array>
|
||||||
|
</dict>
|
||||||
|
</array>
|
||||||
|
<key>GIDClientID</key>
|
||||||
|
<string>11115008580-51gv4sj2c78rud6n127g3shu4d2n96un.apps.googleusercontent.com</string>
|
||||||
|
<key>LSRequiresIPhoneOS</key>
|
||||||
|
<true/>
|
||||||
|
<key>NSAppTransportSecurity</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>CADisableMinimumFrameDurationOnPhone</key>
|
<key>NSAllowsArbitraryLoads</key>
|
||||||
<true/>
|
<true/>
|
||||||
<key>CFBundleDevelopmentRegion</key>
|
<key>NSAllowsLocalNetworking</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/>
|
<true/>
|
||||||
<key>NSAppTransportSecurity</key>
|
<key>NSExceptionDomains</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>NSAllowsArbitraryLoads</key>
|
<key>127.0.0.1</key>
|
||||||
<true/>
|
|
||||||
<key>NSAllowsLocalNetworking</key>
|
|
||||||
<true/>
|
|
||||||
<key>NSExceptionDomains</key>
|
|
||||||
<dict>
|
<dict>
|
||||||
<key>127.0.0.1</key>
|
<key>NSExceptionAllowsInsecureHTTPLoads</key>
|
||||||
<dict>
|
<true/>
|
||||||
<key>NSExceptionAllowsInsecureHTTPLoads</key>
|
<key>NSIncludesSubdomains</key>
|
||||||
<true/>
|
<true/>
|
||||||
<key>NSIncludesSubdomains</key>
|
</dict>
|
||||||
<true/>
|
<key>192.168.31.243</key>
|
||||||
</dict>
|
<dict>
|
||||||
<key>localhost</key>
|
<key>NSExceptionAllowsInsecureHTTPLoads</key>
|
||||||
<dict>
|
<true/>
|
||||||
<key>NSExceptionAllowsInsecureHTTPLoads</key>
|
<key>NSIncludesSubdomains</key>
|
||||||
<true/>
|
<true/>
|
||||||
<key>NSIncludesSubdomains</key>
|
</dict>
|
||||||
<true/>
|
<key>39.162.50.99</key>
|
||||||
</dict>
|
<dict>
|
||||||
<key>192.168.31.243</key>
|
<key>NSExceptionAllowsInsecureHTTPLoads</key>
|
||||||
<dict>
|
<true/>
|
||||||
<key>NSExceptionAllowsInsecureHTTPLoads</key>
|
<key>NSIncludesSubdomains</key>
|
||||||
<true/>
|
<true/>
|
||||||
<key>NSIncludesSubdomains</key>
|
</dict>
|
||||||
<true/>
|
<key>localhost</key>
|
||||||
</dict>
|
<dict>
|
||||||
<key>39.162.50.99</key>
|
<key>NSExceptionAllowsInsecureHTTPLoads</key>
|
||||||
<dict>
|
<true/>
|
||||||
<key>NSExceptionAllowsInsecureHTTPLoads</key>
|
<key>NSIncludesSubdomains</key>
|
||||||
<true/>
|
<true/>
|
||||||
<key>NSIncludesSubdomains</key>
|
|
||||||
<true/>
|
|
||||||
</dict>
|
|
||||||
</dict>
|
</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>UIBackgroundModes</key>
|
|
||||||
<array>
|
|
||||||
<string>audio</string>
|
|
||||||
</array>
|
|
||||||
<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>
|
</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>UIBackgroundModes</key>
|
||||||
|
<array>
|
||||||
|
<string>audio</string>
|
||||||
|
</array>
|
||||||
|
<key>UILaunchStoryboardName</key>
|
||||||
|
<string>LaunchScreen</string>
|
||||||
|
<key>UIMainStoryboardFile</key>
|
||||||
|
<string>Main</string>
|
||||||
|
<key>UIStatusBarHidden</key>
|
||||||
|
<false/>
|
||||||
|
<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>
|
</plist>
|
||||||
@@ -14,12 +14,14 @@ import 'core/data/remote/catalog_api.dart';
|
|||||||
import 'core/data/remote/category_api.dart';
|
import 'core/data/remote/category_api.dart';
|
||||||
import 'core/data/remote/comment_api.dart';
|
import 'core/data/remote/comment_api.dart';
|
||||||
import 'core/data/remote/commerce_api.dart';
|
import 'core/data/remote/commerce_api.dart';
|
||||||
|
import 'core/data/remote/config_api.dart';
|
||||||
import 'core/data/remote/device_profile.dart';
|
import 'core/data/remote/device_profile.dart';
|
||||||
import 'core/data/remote/download_api.dart';
|
import 'core/data/remote/download_api.dart';
|
||||||
import 'core/data/remote/interaction_api.dart';
|
import 'core/data/remote/interaction_api.dart';
|
||||||
import 'core/data/remote/library_api.dart';
|
import 'core/data/remote/library_api.dart';
|
||||||
import 'core/data/remote/notice_api.dart';
|
import 'core/data/remote/notice_api.dart';
|
||||||
import 'core/data/remote/playback_api.dart';
|
import 'core/data/remote/playback_api.dart';
|
||||||
|
import 'core/data/remote/reward_api.dart';
|
||||||
import 'core/data/remote/watch_api.dart';
|
import 'core/data/remote/watch_api.dart';
|
||||||
import 'core/data/repositories/catalog_repository.dart';
|
import 'core/data/repositories/catalog_repository.dart';
|
||||||
import 'core/data/repositories/account_repository.dart';
|
import 'core/data/repositories/account_repository.dart';
|
||||||
@@ -32,9 +34,11 @@ import 'core/data/repositories/interaction_repository.dart';
|
|||||||
import 'core/data/repositories/notice_repository.dart';
|
import 'core/data/repositories/notice_repository.dart';
|
||||||
import 'core/data/repositories/playback_repository.dart';
|
import 'core/data/repositories/playback_repository.dart';
|
||||||
import 'core/data/repositories/playlist_repository.dart';
|
import 'core/data/repositories/playlist_repository.dart';
|
||||||
|
import 'core/data/repositories/reward_repository.dart';
|
||||||
import 'core/data/repositories/search_repository.dart';
|
import 'core/data/repositories/search_repository.dart';
|
||||||
import 'core/data/repositories/store_repository.dart';
|
import 'core/data/repositories/store_repository.dart';
|
||||||
import 'core/data/repositories/watch_history_repository.dart';
|
import 'core/data/repositories/watch_history_repository.dart';
|
||||||
|
import 'core/data/services/app_config_controller.dart';
|
||||||
import 'core/data/services/auth_controller.dart';
|
import 'core/data/services/auth_controller.dart';
|
||||||
import 'core/data/services/auth_session_store.dart';
|
import 'core/data/services/auth_session_store.dart';
|
||||||
import 'core/data/services/catalog_controller.dart';
|
import 'core/data/services/catalog_controller.dart';
|
||||||
@@ -47,6 +51,7 @@ import 'core/data/services/playlist_controller.dart';
|
|||||||
import 'core/data/services/event_tracker.dart';
|
import 'core/data/services/event_tracker.dart';
|
||||||
import 'core/data/services/playback_position_cache.dart';
|
import 'core/data/services/playback_position_cache.dart';
|
||||||
import 'core/data/services/playback_session.dart';
|
import 'core/data/services/playback_session.dart';
|
||||||
|
import 'core/data/services/reward_controller.dart';
|
||||||
import 'core/data/services/unlocked_episode_registry.dart';
|
import 'core/data/services/unlocked_episode_registry.dart';
|
||||||
import 'core/data/services/video_player_port.dart';
|
import 'core/data/services/video_player_port.dart';
|
||||||
import 'core/data/services/wallet_controller.dart';
|
import 'core/data/services/wallet_controller.dart';
|
||||||
@@ -88,6 +93,7 @@ class LumaDramaApp extends StatefulWidget {
|
|||||||
this.storeRepository,
|
this.storeRepository,
|
||||||
this.searchRepository,
|
this.searchRepository,
|
||||||
this.playlistRepository,
|
this.playlistRepository,
|
||||||
|
this.rewardRepository,
|
||||||
this.haptics = const FlutterHaptics(),
|
this.haptics = const FlutterHaptics(),
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -109,6 +115,7 @@ class LumaDramaApp extends StatefulWidget {
|
|||||||
final StoreRepository? storeRepository;
|
final StoreRepository? storeRepository;
|
||||||
final SearchRepository? searchRepository;
|
final SearchRepository? searchRepository;
|
||||||
final PlaylistRepository? playlistRepository;
|
final PlaylistRepository? playlistRepository;
|
||||||
|
final RewardRepository? rewardRepository;
|
||||||
final Haptics haptics;
|
final Haptics haptics;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -177,6 +184,13 @@ class _LumaDramaAppState extends State<LumaDramaApp> {
|
|||||||
_commerceRepository,
|
_commerceRepository,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
late final RewardRepository _rewardRepository =
|
||||||
|
widget.rewardRepository ?? HttpRewardRepository(RewardApi(_apiClient));
|
||||||
|
|
||||||
|
late final RewardController _rewardController = RewardController(
|
||||||
|
_rewardRepository,
|
||||||
|
);
|
||||||
|
|
||||||
late final SearchRepository _searchRepository =
|
late final SearchRepository _searchRepository =
|
||||||
widget.searchRepository ?? HttpSearchRepository(CatalogApi(_apiClient));
|
widget.searchRepository ?? HttpSearchRepository(CatalogApi(_apiClient));
|
||||||
|
|
||||||
@@ -208,6 +222,11 @@ class _LumaDramaAppState extends State<LumaDramaApp> {
|
|||||||
|
|
||||||
late final LocaleController _localeController = LocaleController();
|
late final LocaleController _localeController = LocaleController();
|
||||||
|
|
||||||
|
/// 后台下发的启动配置(登录页背景等);拉不到就用本地默认。
|
||||||
|
late final AppConfigController _appConfigController = AppConfigController(
|
||||||
|
ConfigApi(_apiClient),
|
||||||
|
);
|
||||||
|
|
||||||
/// 登录期内共享的「已解锁收费集」:播放页进出、feed 与全屏切换都要沿用。
|
/// 登录期内共享的「已解锁收费集」:播放页进出、feed 与全屏切换都要沿用。
|
||||||
late final UnlockedEpisodeRegistry _unlockedEpisodes =
|
late final UnlockedEpisodeRegistry _unlockedEpisodes =
|
||||||
UnlockedEpisodeRegistry();
|
UnlockedEpisodeRegistry();
|
||||||
@@ -218,6 +237,7 @@ class _LumaDramaAppState extends State<LumaDramaApp> {
|
|||||||
// 恢复本地令牌与设备号;未登录也能正常浏览,不阻塞首屏
|
// 恢复本地令牌与设备号;未登录也能正常浏览,不阻塞首屏
|
||||||
_auth.load();
|
_auth.load();
|
||||||
unawaited(_localeController.load());
|
unawaited(_localeController.load());
|
||||||
|
unawaited(_appConfigController.load());
|
||||||
// 登录/登出时同步收藏状态:收藏属于账号,不能跨账号串联
|
// 登录/登出时同步收藏状态:收藏属于账号,不能跨账号串联
|
||||||
_auth.addListener(_onAuthChanged);
|
_auth.addListener(_onAuthChanged);
|
||||||
unawaited(_favoriteController.load());
|
unawaited(_favoriteController.load());
|
||||||
@@ -241,6 +261,7 @@ class _LumaDramaAppState extends State<LumaDramaApp> {
|
|||||||
unawaited(_favoriteController.load());
|
unawaited(_favoriteController.load());
|
||||||
_downloadController.reset();
|
_downloadController.reset();
|
||||||
_walletController.reset();
|
_walletController.reset();
|
||||||
|
_rewardController.reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -250,8 +271,10 @@ class _LumaDramaAppState extends State<LumaDramaApp> {
|
|||||||
_favoriteController.dispose();
|
_favoriteController.dispose();
|
||||||
_downloadController.dispose();
|
_downloadController.dispose();
|
||||||
_walletController.dispose();
|
_walletController.dispose();
|
||||||
|
_rewardController.dispose();
|
||||||
_interactionController.dispose();
|
_interactionController.dispose();
|
||||||
_localeController.dispose();
|
_localeController.dispose();
|
||||||
|
_appConfigController.dispose();
|
||||||
_apiClient.close();
|
_apiClient.close();
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
@@ -259,7 +282,9 @@ class _LumaDramaAppState extends State<LumaDramaApp> {
|
|||||||
CategoryController _createCategories() {
|
CategoryController _createCategories() {
|
||||||
final controller = CategoryController(_categoryRepository);
|
final controller = CategoryController(_categoryRepository);
|
||||||
if (widget.catalogRepository == null) {
|
if (widget.catalogRepository == null) {
|
||||||
controller.dramaPageLoader = CategoryApi(_apiClient).dramas;
|
final api = CategoryApi(_apiClient);
|
||||||
|
controller.dramaPageLoader = api.dramas;
|
||||||
|
controller.rankingLoader = api.ranking;
|
||||||
}
|
}
|
||||||
controller.load();
|
controller.load();
|
||||||
return controller;
|
return controller;
|
||||||
@@ -302,8 +327,10 @@ class _LumaDramaAppState extends State<LumaDramaApp> {
|
|||||||
ChangeNotifierProvider.value(value: _favoriteController),
|
ChangeNotifierProvider.value(value: _favoriteController),
|
||||||
ChangeNotifierProvider.value(value: _downloadController),
|
ChangeNotifierProvider.value(value: _downloadController),
|
||||||
ChangeNotifierProvider.value(value: _walletController),
|
ChangeNotifierProvider.value(value: _walletController),
|
||||||
|
ChangeNotifierProvider.value(value: _rewardController),
|
||||||
ChangeNotifierProvider.value(value: _interactionController),
|
ChangeNotifierProvider.value(value: _interactionController),
|
||||||
ChangeNotifierProvider.value(value: _localeController),
|
ChangeNotifierProvider.value(value: _localeController),
|
||||||
|
ChangeNotifierProvider.value(value: _appConfigController),
|
||||||
ChangeNotifierProvider.value(value: _auth),
|
ChangeNotifierProvider.value(value: _auth),
|
||||||
],
|
],
|
||||||
child: Consumer<LocaleController>(
|
child: Consumer<LocaleController>(
|
||||||
|
|||||||
@@ -2,8 +2,9 @@
|
|||||||
|
|
||||||
/// 开发环境配置。
|
/// 开发环境配置。
|
||||||
///
|
///
|
||||||
/// 本机联调用:换 Wi-Fi、换网段后只改这里的 [baseUrl],地址不要带结尾斜杠。
|
/// 本机联调用:模拟器与桌面端可直接用回环地址,但 iOS/Android 真机必须用
|
||||||
|
/// 开发机的局域网 IP(真机上的 127.0.0.1 指向手机自己)。地址不要带结尾斜杠。
|
||||||
abstract final class DevConfig {
|
abstract final class DevConfig {
|
||||||
/// 开发机后端地址。
|
/// 开发机后端地址(Mac 当前 Wi-Fi 地址,换网络后需要同步修改)。
|
||||||
static const String baseUrl = 'http://192.168.31.243:8081';
|
static const String baseUrl = 'http://192.168.31.120:8081';
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,67 @@
|
|||||||
|
// Author: fruit.com.cn
|
||||||
|
|
||||||
|
import 'drama.dart';
|
||||||
|
import 'locale_text.dart';
|
||||||
|
|
||||||
|
/// 服务端推荐榜快照;顺序和排名均不可在客户端重算。
|
||||||
|
class CategoryRanking {
|
||||||
|
const CategoryRanking({
|
||||||
|
required this.id,
|
||||||
|
required this.code,
|
||||||
|
required this.revision,
|
||||||
|
required this.entries,
|
||||||
|
this.locales = const {},
|
||||||
|
this.generatedAt,
|
||||||
|
});
|
||||||
|
|
||||||
|
final String id;
|
||||||
|
final String code;
|
||||||
|
final String revision;
|
||||||
|
final Map<String, String> locales;
|
||||||
|
final DateTime? generatedAt;
|
||||||
|
final List<CategoryRankingEntry> entries;
|
||||||
|
|
||||||
|
/// 解析 `GET /app/categories/{id}/ranking`。
|
||||||
|
factory CategoryRanking.fromJson(Map<String, dynamic> json) {
|
||||||
|
final rawList = json['list'];
|
||||||
|
final entries = rawList is List
|
||||||
|
? rawList
|
||||||
|
.whereType<Map>()
|
||||||
|
.map(
|
||||||
|
(item) =>
|
||||||
|
CategoryRankingEntry.fromJson(item.cast<String, dynamic>()),
|
||||||
|
)
|
||||||
|
.toList(growable: false)
|
||||||
|
: const <CategoryRankingEntry>[];
|
||||||
|
return CategoryRanking(
|
||||||
|
id: (json['id'] ?? '').toString(),
|
||||||
|
code: json['code'] as String? ?? '',
|
||||||
|
revision: (json['revision'] ?? '1').toString(),
|
||||||
|
locales: localeMap(json['locales']),
|
||||||
|
generatedAt: DateTime.tryParse(json['generatedAt'] as String? ?? ''),
|
||||||
|
entries: entries,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 推荐榜中的一部短剧及其服务端排名。
|
||||||
|
class CategoryRankingEntry {
|
||||||
|
const CategoryRankingEntry({required this.rank, required this.drama});
|
||||||
|
|
||||||
|
final int rank;
|
||||||
|
final Drama drama;
|
||||||
|
|
||||||
|
factory CategoryRankingEntry.fromJson(Map<String, dynamic> json) {
|
||||||
|
final rawDrama = json['drama'];
|
||||||
|
return CategoryRankingEntry(
|
||||||
|
rank: (json['rank'] as num?)?.toInt() ?? 0,
|
||||||
|
drama: Drama.fromCardJson(
|
||||||
|
rawDrama is Map<String, dynamic>
|
||||||
|
? rawDrama
|
||||||
|
: rawDrama is Map
|
||||||
|
? rawDrama.cast<String, dynamic>()
|
||||||
|
: const <String, dynamic>{},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,10 +7,19 @@ class ContentCategory {
|
|||||||
const ContentCategory({
|
const ContentCategory({
|
||||||
required this.id,
|
required this.id,
|
||||||
required this.name,
|
required this.name,
|
||||||
|
this.code = '',
|
||||||
|
this.layoutType = gridLayout,
|
||||||
|
this.revision = '1',
|
||||||
this.locales = const {},
|
this.locales = const {},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
static const String gridLayout = 'GRID';
|
||||||
|
static const String rankingLayout = 'RANKING';
|
||||||
|
|
||||||
final String id;
|
final String id;
|
||||||
|
final String code;
|
||||||
|
final String layoutType;
|
||||||
|
final String revision;
|
||||||
|
|
||||||
/// 中文名称,与 locales 里的 zh 相同。
|
/// 中文名称,与 locales 里的 zh 相同。
|
||||||
final String name;
|
final String name;
|
||||||
@@ -20,9 +29,18 @@ class ContentCategory {
|
|||||||
factory ContentCategory.fromJson(Map<String, dynamic> json) {
|
factory ContentCategory.fromJson(Map<String, dynamic> json) {
|
||||||
final locales = localeMap(json['locales']);
|
final locales = localeMap(json['locales']);
|
||||||
final name = json['name'] as String? ?? locales['zh'] ?? '';
|
final name = json['name'] as String? ?? locales['zh'] ?? '';
|
||||||
return ContentCategory(id: (json['id'] ?? '').toString(), name: name, locales: locales);
|
return ContentCategory(
|
||||||
|
id: (json['id'] ?? '').toString(),
|
||||||
|
name: name,
|
||||||
|
code: json['code'] as String? ?? '',
|
||||||
|
layoutType: json['layoutType'] as String? ?? gridLayout,
|
||||||
|
revision: (json['revision'] ?? '1').toString(),
|
||||||
|
locales: locales,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool get isRanking => layoutType == rankingLayout;
|
||||||
|
|
||||||
/// 按界面语言取名称。缺对应语言时回落到中文。
|
/// 按界面语言取名称。缺对应语言时回落到中文。
|
||||||
String localizedName(String languageCode) {
|
String localizedName(String languageCode) {
|
||||||
return localizedText(languageCode, name, locales);
|
return localizedText(languageCode, name, locales);
|
||||||
|
|||||||
@@ -97,11 +97,13 @@ class Drama {
|
|||||||
required this.title,
|
required this.title,
|
||||||
required this.synopsis,
|
required this.synopsis,
|
||||||
required this.posterUrl,
|
required this.posterUrl,
|
||||||
|
this.coverLandscape = '',
|
||||||
this.episodes = const [],
|
this.episodes = const [],
|
||||||
this.titleLocales = const {},
|
this.titleLocales = const {},
|
||||||
this.synopsisLocales = const {},
|
this.synopsisLocales = const {},
|
||||||
this.tag = '',
|
this.tag = '',
|
||||||
this.tagLocales = const {},
|
this.tagLocales = const {},
|
||||||
|
this.tagCode = '',
|
||||||
this.tagColor = '',
|
this.tagColor = '',
|
||||||
this.category = '',
|
this.category = '',
|
||||||
this.categoryLocales = const {},
|
this.categoryLocales = const {},
|
||||||
@@ -127,8 +129,14 @@ class Drama {
|
|||||||
final Map<String, String> synopsisLocales;
|
final Map<String, String> synopsisLocales;
|
||||||
final String tag;
|
final String tag;
|
||||||
final Map<String, String> tagLocales;
|
final Map<String, String> tagLocales;
|
||||||
|
|
||||||
|
/// 标签语义码(如 `NEW_ARRIVAL`)。文案会随语言变,语义判断只认这个码。
|
||||||
|
final String tagCode;
|
||||||
final String tagColor;
|
final String tagColor;
|
||||||
final String posterUrl;
|
final String posterUrl;
|
||||||
|
|
||||||
|
/// 横版封面,用于继续观看横幅等横向展示位;为空时回退竖版 `posterUrl`。
|
||||||
|
final String coverLandscape;
|
||||||
final List<Episode> episodes;
|
final List<Episode> episodes;
|
||||||
final String category;
|
final String category;
|
||||||
final Map<String, String> categoryLocales;
|
final Map<String, String> categoryLocales;
|
||||||
@@ -172,8 +180,10 @@ class Drama {
|
|||||||
synopsisLocales: text.synopsisLocales,
|
synopsisLocales: text.synopsisLocales,
|
||||||
tag: text.tag,
|
tag: text.tag,
|
||||||
tagLocales: text.tagLocales,
|
tagLocales: text.tagLocales,
|
||||||
|
tagCode: (json['tagCode'] as String? ?? '').trim(),
|
||||||
tagColor: json['tagColor'] as String? ?? '',
|
tagColor: json['tagColor'] as String? ?? '',
|
||||||
posterUrl: json['cover'] as String? ?? '',
|
posterUrl: json['cover'] as String? ?? '',
|
||||||
|
coverLandscape: json['coverLandscape'] as String? ?? '',
|
||||||
episodes: preview is Map<String, dynamic>
|
episodes: preview is Map<String, dynamic>
|
||||||
? [Episode.fromJson(preview)]
|
? [Episode.fromJson(preview)]
|
||||||
: const [],
|
: const [],
|
||||||
@@ -204,8 +214,10 @@ class Drama {
|
|||||||
synopsisLocales: text.synopsisLocales,
|
synopsisLocales: text.synopsisLocales,
|
||||||
tag: text.tag,
|
tag: text.tag,
|
||||||
tagLocales: text.tagLocales,
|
tagLocales: text.tagLocales,
|
||||||
|
tagCode: (json['tagCode'] as String? ?? '').trim(),
|
||||||
tagColor: json['tagColor'] as String? ?? '',
|
tagColor: json['tagColor'] as String? ?? '',
|
||||||
posterUrl: json['cover'] as String? ?? '',
|
posterUrl: json['cover'] as String? ?? '',
|
||||||
|
coverLandscape: json['coverLandscape'] as String? ?? '',
|
||||||
category: text.category,
|
category: text.category,
|
||||||
categoryLocales: text.categoryLocales,
|
categoryLocales: text.categoryLocales,
|
||||||
types: text.types,
|
types: text.types,
|
||||||
@@ -315,7 +327,10 @@ class _DramaText {
|
|||||||
final category = _firstText(categoryLocales, json['category'], types);
|
final category = _firstText(categoryLocales, json['category'], types);
|
||||||
return _DramaText(
|
return _DramaText(
|
||||||
title: _firstText(titleLocales, json['title']),
|
title: _firstText(titleLocales, json['title']),
|
||||||
synopsis: _firstText(synopsisLocales, json['synopsis'] ?? json['description']),
|
synopsis: _firstText(
|
||||||
|
synopsisLocales,
|
||||||
|
json['synopsis'] ?? json['description'],
|
||||||
|
),
|
||||||
titleLocales: titleLocales,
|
titleLocales: titleLocales,
|
||||||
synopsisLocales: synopsisLocales,
|
synopsisLocales: synopsisLocales,
|
||||||
tag: _firstText(tagLocales, json['tag']),
|
tag: _firstText(tagLocales, json['tag']),
|
||||||
@@ -328,7 +343,11 @@ class _DramaText {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String _firstText(Map<String, String> locales, Object? fallback, [List<Map<String, String>>? types]) {
|
String _firstText(
|
||||||
|
Map<String, String> locales,
|
||||||
|
Object? fallback, [
|
||||||
|
List<Map<String, String>>? types,
|
||||||
|
]) {
|
||||||
final chinese = locales['zh'] ?? '';
|
final chinese = locales['zh'] ?? '';
|
||||||
if (chinese.isNotEmpty) return chinese;
|
if (chinese.isNotEmpty) return chinese;
|
||||||
if (types != null && types.isNotEmpty) {
|
if (types != null && types.isNotEmpty) {
|
||||||
@@ -339,7 +358,9 @@ String _firstText(Map<String, String> locales, Object? fallback, [List<Map<Strin
|
|||||||
}
|
}
|
||||||
|
|
||||||
String _genreText(List<Map<String, String>> types, Object? fallback) {
|
String _genreText(List<Map<String, String>> types, Object? fallback) {
|
||||||
final names = types.map((item) => item['zh'] ?? '').where((value) => value.isNotEmpty);
|
final names = types
|
||||||
|
.map((item) => item['zh'] ?? '')
|
||||||
|
.where((value) => value.isNotEmpty);
|
||||||
final joined = names.join(' / ');
|
final joined = names.join(' / ');
|
||||||
if (joined.isNotEmpty) return joined;
|
if (joined.isNotEmpty) return joined;
|
||||||
return fallback is String ? fallback : '';
|
return fallback is String ? fallback : '';
|
||||||
|
|||||||
@@ -7,7 +7,11 @@ Map<String, String> localeMap(Object? raw) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// 按当前语言取文案。没有对应语言时用中文,中文也没有时用 fallback。
|
/// 按当前语言取文案。没有对应语言时用中文,中文也没有时用 fallback。
|
||||||
String localizedText(String languageCode, String fallback, Map<String, String> locales) {
|
String localizedText(
|
||||||
|
String languageCode,
|
||||||
|
String fallback,
|
||||||
|
Map<String, String> locales,
|
||||||
|
) {
|
||||||
final selected = locales[languageCode] ?? '';
|
final selected = locales[languageCode] ?? '';
|
||||||
if (selected.isNotEmpty) return selected;
|
if (selected.isNotEmpty) return selected;
|
||||||
final chinese = locales['zh'] ?? '';
|
final chinese = locales['zh'] ?? '';
|
||||||
|
|||||||
@@ -0,0 +1,242 @@
|
|||||||
|
// Author: fruit.com.cn
|
||||||
|
|
||||||
|
import 'json_numbers.dart';
|
||||||
|
|
||||||
|
/// 奖励中心首屏数据。
|
||||||
|
class RewardOverview {
|
||||||
|
const RewardOverview({
|
||||||
|
required this.serverDate,
|
||||||
|
required this.timezone,
|
||||||
|
required this.coinBalance,
|
||||||
|
required this.checkin,
|
||||||
|
this.sections = const [],
|
||||||
|
this.activities = const [],
|
||||||
|
});
|
||||||
|
|
||||||
|
final String serverDate;
|
||||||
|
final String timezone;
|
||||||
|
final int coinBalance;
|
||||||
|
final RewardCheckinState checkin;
|
||||||
|
final List<RewardSection> sections;
|
||||||
|
final List<RewardActivity> activities;
|
||||||
|
|
||||||
|
factory RewardOverview.fromJson(Map<String, dynamic> json) {
|
||||||
|
return RewardOverview(
|
||||||
|
serverDate: json['serverDate'] as String? ?? '',
|
||||||
|
timezone: json['timezone'] as String? ?? '',
|
||||||
|
coinBalance: jsonToInt(json['coinBalance']),
|
||||||
|
checkin: RewardCheckinState.fromJson(_map(json['checkin'])),
|
||||||
|
sections: _maps(json['sections']).map(RewardSection.fromJson).toList(),
|
||||||
|
activities: _maps(
|
||||||
|
json['activities'],
|
||||||
|
).map(RewardActivity.fromJson).toList(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 七日签到状态。
|
||||||
|
class RewardCheckinState {
|
||||||
|
const RewardCheckinState({
|
||||||
|
required this.taskId,
|
||||||
|
required this.checkedInToday,
|
||||||
|
required this.streak,
|
||||||
|
required this.currentDay,
|
||||||
|
this.days = const [],
|
||||||
|
});
|
||||||
|
|
||||||
|
final String taskId;
|
||||||
|
final bool checkedInToday;
|
||||||
|
final int streak;
|
||||||
|
final int currentDay;
|
||||||
|
final List<RewardCheckinDay> days;
|
||||||
|
|
||||||
|
factory RewardCheckinState.fromJson(Map<String, dynamic> json) {
|
||||||
|
return RewardCheckinState(
|
||||||
|
taskId: (json['taskId'] ?? '').toString(),
|
||||||
|
checkedInToday: json['checkedInToday'] == true,
|
||||||
|
streak: jsonToInt(json['streak']),
|
||||||
|
currentDay: jsonToInt(json['currentDay']),
|
||||||
|
days: _maps(json['days']).map(RewardCheckinDay.fromJson).toList(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 签到周期中的一天。
|
||||||
|
class RewardCheckinDay {
|
||||||
|
const RewardCheckinDay({
|
||||||
|
required this.dayIndex,
|
||||||
|
required this.rewardCoin,
|
||||||
|
required this.checked,
|
||||||
|
required this.current,
|
||||||
|
});
|
||||||
|
|
||||||
|
final int dayIndex;
|
||||||
|
final int rewardCoin;
|
||||||
|
final bool checked;
|
||||||
|
final bool current;
|
||||||
|
|
||||||
|
factory RewardCheckinDay.fromJson(Map<String, dynamic> json) {
|
||||||
|
return RewardCheckinDay(
|
||||||
|
dayIndex: jsonToInt(json['dayIndex']),
|
||||||
|
rewardCoin: jsonToInt(json['rewardCoin']),
|
||||||
|
checked: json['checked'] == true,
|
||||||
|
current: json['current'] == true,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 一组奖励任务。
|
||||||
|
class RewardSection {
|
||||||
|
const RewardSection({
|
||||||
|
required this.code,
|
||||||
|
required this.title,
|
||||||
|
this.tasks = const [],
|
||||||
|
});
|
||||||
|
|
||||||
|
final String code;
|
||||||
|
final String title;
|
||||||
|
final List<RewardTask> tasks;
|
||||||
|
|
||||||
|
factory RewardSection.fromJson(Map<String, dynamic> json) {
|
||||||
|
return RewardSection(
|
||||||
|
code: json['code'] as String? ?? '',
|
||||||
|
title: json['title'] as String? ?? '',
|
||||||
|
tasks: _maps(json['tasks']).map(RewardTask.fromJson).toList(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 奖励任务卡片。
|
||||||
|
class RewardTask {
|
||||||
|
const RewardTask({
|
||||||
|
required this.id,
|
||||||
|
required this.code,
|
||||||
|
required this.type,
|
||||||
|
required this.title,
|
||||||
|
required this.subtitle,
|
||||||
|
required this.ctaText,
|
||||||
|
required this.actionType,
|
||||||
|
required this.actionUrl,
|
||||||
|
required this.progressValue,
|
||||||
|
required this.targetValue,
|
||||||
|
required this.rewardCoin,
|
||||||
|
required this.status,
|
||||||
|
this.iconUrl = '',
|
||||||
|
});
|
||||||
|
|
||||||
|
final String id;
|
||||||
|
final String code;
|
||||||
|
final String type;
|
||||||
|
final String title;
|
||||||
|
final String subtitle;
|
||||||
|
final String ctaText;
|
||||||
|
final String actionType;
|
||||||
|
final String actionUrl;
|
||||||
|
final String iconUrl;
|
||||||
|
final int progressValue;
|
||||||
|
final int targetValue;
|
||||||
|
final int rewardCoin;
|
||||||
|
final String status;
|
||||||
|
|
||||||
|
bool get claimable => status == 'COMPLETED';
|
||||||
|
bool get claimed => status == 'CLAIMED';
|
||||||
|
double get progress =>
|
||||||
|
targetValue <= 0 ? 0 : (progressValue / targetValue).clamp(0.0, 1.0);
|
||||||
|
|
||||||
|
factory RewardTask.fromJson(Map<String, dynamic> json) {
|
||||||
|
return RewardTask(
|
||||||
|
id: (json['id'] ?? '').toString(),
|
||||||
|
code: json['code'] as String? ?? '',
|
||||||
|
type: json['type'] as String? ?? '',
|
||||||
|
title: json['title'] as String? ?? '',
|
||||||
|
subtitle: json['subtitle'] as String? ?? '',
|
||||||
|
ctaText: json['ctaText'] as String? ?? '',
|
||||||
|
actionType: json['actionType'] as String? ?? '',
|
||||||
|
actionUrl: json['actionUrl'] as String? ?? '',
|
||||||
|
iconUrl: json['iconUrl'] as String? ?? '',
|
||||||
|
progressValue: jsonToInt(json['progressValue']),
|
||||||
|
targetValue: jsonToInt(json['targetValue']),
|
||||||
|
rewardCoin: jsonToInt(json['rewardCoin']),
|
||||||
|
status: json['status'] as String? ?? 'IN_PROGRESS',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 奖励活动展示卡片。
|
||||||
|
class RewardActivity {
|
||||||
|
const RewardActivity({
|
||||||
|
required this.id,
|
||||||
|
required this.code,
|
||||||
|
required this.title,
|
||||||
|
required this.summary,
|
||||||
|
required this.ctaText,
|
||||||
|
required this.actionType,
|
||||||
|
required this.actionUrl,
|
||||||
|
this.coverUrl = '',
|
||||||
|
});
|
||||||
|
|
||||||
|
final String id;
|
||||||
|
final String code;
|
||||||
|
final String title;
|
||||||
|
final String summary;
|
||||||
|
final String ctaText;
|
||||||
|
final String actionType;
|
||||||
|
final String actionUrl;
|
||||||
|
final String coverUrl;
|
||||||
|
|
||||||
|
factory RewardActivity.fromJson(Map<String, dynamic> json) {
|
||||||
|
return RewardActivity(
|
||||||
|
id: (json['id'] ?? '').toString(),
|
||||||
|
code: json['code'] as String? ?? '',
|
||||||
|
title: json['title'] as String? ?? '',
|
||||||
|
summary: json['summary'] as String? ?? '',
|
||||||
|
ctaText: json['ctaText'] as String? ?? '',
|
||||||
|
actionType: json['actionType'] as String? ?? '',
|
||||||
|
actionUrl: json['actionUrl'] as String? ?? '',
|
||||||
|
coverUrl: json['coverUrl'] as String? ?? '',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 签到或任务领取后的余额变化结果。
|
||||||
|
class RewardActionResult {
|
||||||
|
const RewardActionResult({
|
||||||
|
required this.rewardCoin,
|
||||||
|
required this.coinBalance,
|
||||||
|
required this.alreadyCompleted,
|
||||||
|
});
|
||||||
|
|
||||||
|
final int rewardCoin;
|
||||||
|
final int coinBalance;
|
||||||
|
final bool alreadyCompleted;
|
||||||
|
|
||||||
|
factory RewardActionResult.fromCheckin(Map<String, dynamic> json) {
|
||||||
|
return RewardActionResult(
|
||||||
|
rewardCoin: jsonToInt(json['rewardCoin']),
|
||||||
|
coinBalance: jsonToInt(json['coinBalance']),
|
||||||
|
alreadyCompleted: json['alreadyCheckedIn'] == true,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
factory RewardActionResult.fromClaim(Map<String, dynamic> json) {
|
||||||
|
return RewardActionResult(
|
||||||
|
rewardCoin: jsonToInt(json['rewardCoin']),
|
||||||
|
coinBalance: jsonToInt(json['coinBalance']),
|
||||||
|
alreadyCompleted: json['alreadyGranted'] == true,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> _map(Object? value) {
|
||||||
|
if (value is Map<String, dynamic>) return value;
|
||||||
|
if (value is Map) return value.cast<String, dynamic>();
|
||||||
|
return const {};
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Map<String, dynamic>> _maps(Object? value) {
|
||||||
|
if (value is! List) return const [];
|
||||||
|
return value
|
||||||
|
.whereType<Map>()
|
||||||
|
.map((item) => item.cast<String, dynamic>())
|
||||||
|
.toList();
|
||||||
|
}
|
||||||
@@ -16,6 +16,7 @@ class WatchProgress {
|
|||||||
this.dramaTitle,
|
this.dramaTitle,
|
||||||
this.titleLocales = const {},
|
this.titleLocales = const {},
|
||||||
this.dramaCover,
|
this.dramaCover,
|
||||||
|
this.dramaCoverLandscape,
|
||||||
this.episodeNumber,
|
this.episodeNumber,
|
||||||
this.totalEpisodes,
|
this.totalEpisodes,
|
||||||
this.finished = false,
|
this.finished = false,
|
||||||
@@ -29,6 +30,9 @@ class WatchProgress {
|
|||||||
final String? dramaTitle;
|
final String? dramaTitle;
|
||||||
final Map<String, String> titleLocales;
|
final Map<String, String> titleLocales;
|
||||||
final String? dramaCover;
|
final String? dramaCover;
|
||||||
|
|
||||||
|
/// 横版封面,用于继续观看横幅等横向位;为空时回退 [dramaCover]。
|
||||||
|
final String? dramaCoverLandscape;
|
||||||
final int? episodeNumber;
|
final int? episodeNumber;
|
||||||
final int? totalEpisodes;
|
final int? totalEpisodes;
|
||||||
final Duration position;
|
final Duration position;
|
||||||
@@ -60,6 +64,7 @@ class WatchProgress {
|
|||||||
dramaTitle: json['dramaTitle']?.toString(),
|
dramaTitle: json['dramaTitle']?.toString(),
|
||||||
titleLocales: localeMap(json['titleLocales']),
|
titleLocales: localeMap(json['titleLocales']),
|
||||||
dramaCover: json['dramaCover']?.toString(),
|
dramaCover: json['dramaCover']?.toString(),
|
||||||
|
dramaCoverLandscape: json['dramaCoverLandscape']?.toString(),
|
||||||
episodeNumber: json['episodeNumber'] == null
|
episodeNumber: json['episodeNumber'] == null
|
||||||
? null
|
? null
|
||||||
: jsonToInt(json['episodeNumber']),
|
: jsonToInt(json['episodeNumber']),
|
||||||
@@ -83,6 +88,7 @@ class WatchProgress {
|
|||||||
if (dramaTitle != null) 'dramaTitle': dramaTitle,
|
if (dramaTitle != null) 'dramaTitle': dramaTitle,
|
||||||
if (titleLocales.isNotEmpty) 'titleLocales': titleLocales,
|
if (titleLocales.isNotEmpty) 'titleLocales': titleLocales,
|
||||||
if (dramaCover != null) 'dramaCover': dramaCover,
|
if (dramaCover != null) 'dramaCover': dramaCover,
|
||||||
|
if (dramaCoverLandscape != null) 'dramaCoverLandscape': dramaCoverLandscape,
|
||||||
if (episodeNumber != null) 'episodeNumber': episodeNumber,
|
if (episodeNumber != null) 'episodeNumber': episodeNumber,
|
||||||
if (totalEpisodes != null) 'totalEpisodes': totalEpisodes,
|
if (totalEpisodes != null) 'totalEpisodes': totalEpisodes,
|
||||||
'positionMs': position.inMilliseconds,
|
'positionMs': position.inMilliseconds,
|
||||||
|
|||||||
@@ -46,6 +46,14 @@ class WatchRecord {
|
|||||||
return pageCover.isNotEmpty ? pageCover : drama?.posterUrl ?? '';
|
return pageCover.isNotEmpty ? pageCover : drama?.posterUrl ?? '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// 横向展示位(继续观看横幅)优先用横版封面,缺省回退竖版。
|
||||||
|
String get displayLandscapeCover {
|
||||||
|
final pageLandscape = progress.dramaCoverLandscape?.trim() ?? '';
|
||||||
|
if (pageLandscape.isNotEmpty) return pageLandscape;
|
||||||
|
final landscape = drama?.coverLandscape.trim() ?? '';
|
||||||
|
return landscape.isNotEmpty ? landscape : displayCover;
|
||||||
|
}
|
||||||
|
|
||||||
/// 分页接口已带展示字段时无需等待详情加载。
|
/// 分页接口已带展示字段时无需等待详情加载。
|
||||||
bool get hasDisplayMetadata =>
|
bool get hasDisplayMetadata =>
|
||||||
displayTitle.isNotEmpty ||
|
displayTitle.isNotEmpty ||
|
||||||
|
|||||||
@@ -125,6 +125,29 @@ class AuthApi {
|
|||||||
return AuthSession.fromJson((data as Map).cast<String, dynamic>());
|
return AuthSession.fromJson((data as Map).cast<String, dynamic>());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Google 登录:把客户端拿到的 idToken 交给后端校验并换发令牌。
|
||||||
|
///
|
||||||
|
/// 账号按 Google 返回的邮箱归并:邮箱已存在则直接登入,不存在则自动建号。
|
||||||
|
Future<AuthSession> googleLogin({
|
||||||
|
required String idToken,
|
||||||
|
required String deviceId,
|
||||||
|
String platform = '',
|
||||||
|
String osVersion = '',
|
||||||
|
String appVersion = '',
|
||||||
|
}) async {
|
||||||
|
final data = await _client.post(
|
||||||
|
'/app/auth/google',
|
||||||
|
body: {
|
||||||
|
'idToken': idToken,
|
||||||
|
'deviceId': deviceId,
|
||||||
|
'platform': platform,
|
||||||
|
'osVersion': osVersion,
|
||||||
|
'appVersion': appVersion,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
return AuthSession.fromJson((data as Map).cast<String, dynamic>());
|
||||||
|
}
|
||||||
|
|
||||||
Future<AuthSession> refresh(
|
Future<AuthSession> refresh(
|
||||||
String refreshToken, {
|
String refreshToken, {
|
||||||
String platform = '',
|
String platform = '',
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
// Author: fruit.com.cn
|
// Author: fruit.com.cn
|
||||||
|
|
||||||
import '../models/content_category.dart';
|
import '../models/content_category.dart';
|
||||||
|
import '../models/category_ranking.dart';
|
||||||
import '../models/drama.dart';
|
import '../models/drama.dart';
|
||||||
import '../models/page_result.dart';
|
import '../models/page_result.dart';
|
||||||
import 'api_client.dart';
|
import 'api_client.dart';
|
||||||
@@ -30,11 +31,14 @@ class CategoryApi {
|
|||||||
}) async {
|
}) async {
|
||||||
final data = await _client.get(
|
final data = await _client.get(
|
||||||
'/app/categories/$categoryId/dramas',
|
'/app/categories/$categoryId/dramas',
|
||||||
query: {
|
query: {'pageIndex': '$pageIndex', 'pageSize': '$pageSize'},
|
||||||
'pageIndex': '$pageIndex',
|
|
||||||
'pageSize': '$pageSize',
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
return PageResult.parse(data, Drama.fromCardJson);
|
return PageResult.parse(data, Drama.fromCardJson);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// 推荐榜快照,服务端已确定内容顺序和连续排名。
|
||||||
|
Future<CategoryRanking> ranking(String categoryId) async {
|
||||||
|
final data = await _client.get('/app/categories/$categoryId/ranking');
|
||||||
|
return CategoryRanking.fromJson(ResponseDecoders.asMap(data));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
// Author: fruit.com.cn
|
||||||
|
|
||||||
|
import 'api_client.dart';
|
||||||
|
|
||||||
|
/// 启动配置:`GET /app/config`(匿名,后台只下发白名单键)。
|
||||||
|
class ConfigApi {
|
||||||
|
const ConfigApi(this._client);
|
||||||
|
|
||||||
|
final ApiClient _client;
|
||||||
|
|
||||||
|
/// 白名单配置表;结构异常时返回空表,调用方按本地默认处理。
|
||||||
|
Future<Map<String, dynamic>> appConfig() async {
|
||||||
|
final data = await _client.get('/app/config');
|
||||||
|
return data is Map<String, dynamic> ? data : const <String, dynamic>{};
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
// Author: fruit.com.cn
|
||||||
|
|
||||||
|
import '../models/reward.dart';
|
||||||
|
import 'api_client.dart';
|
||||||
|
import 'response_decoders.dart';
|
||||||
|
|
||||||
|
/// 奖励中心接口,对应契约 §1.8.1。
|
||||||
|
class RewardApi {
|
||||||
|
const RewardApi(this._client);
|
||||||
|
|
||||||
|
final ApiClient _client;
|
||||||
|
|
||||||
|
Future<RewardOverview> overview(String locale) async {
|
||||||
|
final data = await _client.get(
|
||||||
|
'/app/rewards/overview',
|
||||||
|
query: {'locale': locale},
|
||||||
|
);
|
||||||
|
return RewardOverview.fromJson(ResponseDecoders.asMap(data));
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<RewardActionResult> checkIn() async {
|
||||||
|
final data = await _client.post('/app/rewards/check-in');
|
||||||
|
return RewardActionResult.fromCheckin(ResponseDecoders.asMap(data));
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<RewardActionResult> claim(String taskId) async {
|
||||||
|
final data = await _client.post('/app/rewards/tasks/$taskId/claim');
|
||||||
|
return RewardActionResult.fromClaim(ResponseDecoders.asMap(data));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
// Author: fruit.com.cn
|
||||||
|
|
||||||
|
import '../models/reward.dart';
|
||||||
|
import '../remote/reward_api.dart';
|
||||||
|
|
||||||
|
/// 奖励中心数据来源。
|
||||||
|
abstract interface class RewardRepository {
|
||||||
|
Future<RewardOverview> fetchOverview(String locale);
|
||||||
|
|
||||||
|
Future<RewardActionResult> checkIn();
|
||||||
|
|
||||||
|
Future<RewardActionResult> claim(String taskId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 奖励中心 HTTP 仓库。
|
||||||
|
class HttpRewardRepository implements RewardRepository {
|
||||||
|
const HttpRewardRepository(this._api);
|
||||||
|
|
||||||
|
final RewardApi _api;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<RewardOverview> fetchOverview(String locale) => _api.overview(locale);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<RewardActionResult> checkIn() => _api.checkIn();
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<RewardActionResult> claim(String taskId) => _api.claim(taskId);
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
// Author: fruit.com.cn
|
||||||
|
|
||||||
|
import 'package:flutter/foundation.dart';
|
||||||
|
|
||||||
|
import '../remote/config_api.dart';
|
||||||
|
|
||||||
|
/// 后台下发的启动配置。
|
||||||
|
///
|
||||||
|
/// 失败一律静默:拿不到就用 App 内置默认,不阻塞启动、不弹错。
|
||||||
|
class AppConfigController extends ChangeNotifier {
|
||||||
|
AppConfigController(this._api);
|
||||||
|
|
||||||
|
final ConfigApi _api;
|
||||||
|
|
||||||
|
String _loginBackgroundUrl = '';
|
||||||
|
|
||||||
|
/// 登录页整屏背景图;空串表示用本地默认图。
|
||||||
|
String get loginBackgroundUrl => _loginBackgroundUrl;
|
||||||
|
|
||||||
|
Future<void> load() async {
|
||||||
|
try {
|
||||||
|
final config = await _api.appConfig();
|
||||||
|
final url = (config['loginBackgroundUrl'] as String? ?? '').trim();
|
||||||
|
if (url == _loginBackgroundUrl) return;
|
||||||
|
_loginBackgroundUrl = url;
|
||||||
|
notifyListeners();
|
||||||
|
} catch (error) {
|
||||||
|
debugPrint('[config] load failed: $error');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -103,6 +103,17 @@ class AuthController extends ChangeNotifier {
|
|||||||
await _apply(session);
|
await _apply(session);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Google 登录:把 Google 返回的 idToken 交给后端校验并落登录态。
|
||||||
|
Future<void> signInWithGoogle(String idToken) async {
|
||||||
|
final session = await _api.googleLogin(
|
||||||
|
idToken: idToken,
|
||||||
|
deviceId: await _store.deviceId(),
|
||||||
|
platform: _platform,
|
||||||
|
osVersion: _osVersion,
|
||||||
|
);
|
||||||
|
await _apply(session);
|
||||||
|
}
|
||||||
|
|
||||||
Future<void> clear() async {
|
Future<void> clear() async {
|
||||||
_session = null;
|
_session = null;
|
||||||
await _store.clear();
|
await _store.clear();
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import 'package:flutter/foundation.dart';
|
|||||||
|
|
||||||
import '../../config/app_config.dart';
|
import '../../config/app_config.dart';
|
||||||
import '../models/content_category.dart';
|
import '../models/content_category.dart';
|
||||||
|
import '../models/category_ranking.dart';
|
||||||
import '../models/drama.dart';
|
import '../models/drama.dart';
|
||||||
import '../models/home_feed.dart';
|
import '../models/home_feed.dart';
|
||||||
import '../models/page_result.dart';
|
import '../models/page_result.dart';
|
||||||
@@ -21,10 +22,15 @@ class CategoryController extends ChangeNotifier {
|
|||||||
String categoryId, {
|
String categoryId, {
|
||||||
int pageIndex,
|
int pageIndex,
|
||||||
int pageSize,
|
int pageSize,
|
||||||
})? dramaPageLoader;
|
})?
|
||||||
|
dramaPageLoader;
|
||||||
|
|
||||||
|
/// 生产环境推荐榜加载器,测试与本地数据模式可不注入。
|
||||||
|
Future<CategoryRanking> Function(String categoryId)? rankingLoader;
|
||||||
|
|
||||||
List<ContentCategory> categories = const [];
|
List<ContentCategory> categories = const [];
|
||||||
final Map<String, CategoryDramaSlot> _slots = {};
|
final Map<String, CategoryDramaSlot> _slots = {};
|
||||||
|
final Map<String, CategoryRankingSlot> _rankingSlots = {};
|
||||||
HomeFeed feed = const HomeFeed();
|
HomeFeed feed = const HomeFeed();
|
||||||
bool loading = false;
|
bool loading = false;
|
||||||
String? error;
|
String? error;
|
||||||
@@ -36,6 +42,29 @@ class CategoryController extends ChangeNotifier {
|
|||||||
return _slots.putIfAbsent(categoryId, CategoryDramaSlot.new);
|
return _slots.putIfAbsent(categoryId, CategoryDramaSlot.new);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CategoryRankingSlot rankingSlotOf(String categoryId) {
|
||||||
|
return _rankingSlots.putIfAbsent(categoryId, CategoryRankingSlot.new);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 打开推荐榜并获取当前服务端快照。
|
||||||
|
Future<void> openRanking(String categoryId) async {
|
||||||
|
final loader = rankingLoader;
|
||||||
|
if (loader == null) return;
|
||||||
|
final slot = rankingSlotOf(categoryId);
|
||||||
|
slot.loading = true;
|
||||||
|
slot.error = null;
|
||||||
|
_notify();
|
||||||
|
try {
|
||||||
|
slot.ranking = await loader(categoryId);
|
||||||
|
} catch (exception) {
|
||||||
|
slot.error = exception;
|
||||||
|
if (kDebugMode) debugPrint('[category-ranking] $exception');
|
||||||
|
} finally {
|
||||||
|
slot.loading = false;
|
||||||
|
_notify();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// 打开分类并加载第一页短剧。
|
/// 打开分类并加载第一页短剧。
|
||||||
Future<void> openCategory(String categoryId) async {
|
Future<void> openCategory(String categoryId) async {
|
||||||
final loader = dramaPageLoader;
|
final loader = dramaPageLoader;
|
||||||
@@ -126,8 +155,14 @@ class CategoryController extends ChangeNotifier {
|
|||||||
loading = false;
|
loading = false;
|
||||||
_notify();
|
_notify();
|
||||||
}
|
}
|
||||||
if (error == null && dramaPageLoader != null && categories.isNotEmpty) {
|
final hasRemoteLoader = dramaPageLoader != null || rankingLoader != null;
|
||||||
await openCategory(categories.first.id);
|
if (error == null && hasRemoteLoader && categories.isNotEmpty) {
|
||||||
|
final first = categories.first;
|
||||||
|
if (first.isRanking) {
|
||||||
|
await openRanking(first.id);
|
||||||
|
} else {
|
||||||
|
await openCategory(first.id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -152,3 +187,10 @@ class CategoryDramaSlot {
|
|||||||
|
|
||||||
bool get hasMore => dramas.length < total;
|
bool get hasMore => dramas.length < total;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// 单个推荐榜的快照状态。
|
||||||
|
class CategoryRankingSlot {
|
||||||
|
CategoryRanking? ranking;
|
||||||
|
Object? error;
|
||||||
|
bool loading = false;
|
||||||
|
}
|
||||||
@@ -120,7 +120,9 @@ class DownloadController extends ChangeNotifier {
|
|||||||
String episodeId, {
|
String episodeId, {
|
||||||
DownloadLicense? license,
|
DownloadLicense? license,
|
||||||
}) async {
|
}) async {
|
||||||
if (_downloading.contains(episodeId)) return const DownloadActionResult(ok: true);
|
if (_downloading.contains(episodeId)) {
|
||||||
|
return const DownloadActionResult(ok: true);
|
||||||
|
}
|
||||||
final source = license ?? _licenseFor(episodeId);
|
final source = license ?? _licenseFor(episodeId);
|
||||||
if (source == null) return const DownloadActionResult(ok: false);
|
if (source == null) return const DownloadActionResult(ok: false);
|
||||||
_beginDownload(episodeId);
|
_beginDownload(episodeId);
|
||||||
@@ -129,7 +131,8 @@ class DownloadController extends ChangeNotifier {
|
|||||||
final media = await _storage.download(
|
final media = await _storage.download(
|
||||||
episodeId: episodeId,
|
episodeId: episodeId,
|
||||||
url: resolved,
|
url: resolved,
|
||||||
onProgress: (received, total) => _onProgress(episodeId, received, total),
|
onProgress: (received, total) =>
|
||||||
|
_onProgress(episodeId, received, total),
|
||||||
);
|
);
|
||||||
_localPaths[episodeId] = media.filePath;
|
_localPaths[episodeId] = media.filePath;
|
||||||
_progress[episodeId] = 1;
|
_progress[episodeId] = 1;
|
||||||
|
|||||||
@@ -0,0 +1,121 @@
|
|||||||
|
// Author: fruit.com.cn
|
||||||
|
|
||||||
|
import 'dart:async';
|
||||||
|
import 'dart:io' show Platform;
|
||||||
|
|
||||||
|
import 'package:flutter/foundation.dart';
|
||||||
|
import 'package:google_sign_in/google_sign_in.dart';
|
||||||
|
|
||||||
|
/// Google 授权结局。
|
||||||
|
///
|
||||||
|
/// 插件调用与 IO 一样用结果对象返回,不把异常抛到页面:
|
||||||
|
/// 页面只需要区分"成功 / 用户取消 / 不可用 / 失败"四种情况。
|
||||||
|
class GoogleSignInOutcome {
|
||||||
|
const GoogleSignInOutcome._({
|
||||||
|
this.idToken,
|
||||||
|
this.canceled = false,
|
||||||
|
this.unavailable = false,
|
||||||
|
this.failed = false,
|
||||||
|
});
|
||||||
|
|
||||||
|
/// 成功拿到可交给后端校验的 idToken。
|
||||||
|
const GoogleSignInOutcome.success(String idToken) : this._(idToken: idToken);
|
||||||
|
|
||||||
|
/// 用户主动取消授权,页面不应提示错误。
|
||||||
|
const GoogleSignInOutcome.canceled() : this._(canceled: true);
|
||||||
|
|
||||||
|
/// 当前平台或构建不支持交互式登录。
|
||||||
|
const GoogleSignInOutcome.unavailable() : this._(unavailable: true);
|
||||||
|
|
||||||
|
/// 授权过程失败(网络、配置缺失、Google 拒绝等)。
|
||||||
|
const GoogleSignInOutcome.failed() : this._(failed: true);
|
||||||
|
|
||||||
|
/// Google 返回的 idToken;未成功时为 null。
|
||||||
|
final String? idToken;
|
||||||
|
|
||||||
|
/// 用户是否主动取消。
|
||||||
|
final bool canceled;
|
||||||
|
|
||||||
|
/// 平台是否不支持。
|
||||||
|
final bool unavailable;
|
||||||
|
|
||||||
|
/// 是否失败。
|
||||||
|
final bool failed;
|
||||||
|
|
||||||
|
/// 是否拿到了可用的 idToken。
|
||||||
|
bool get isSuccess => idToken != null && idToken!.isNotEmpty;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Google 登录客户端封装。
|
||||||
|
///
|
||||||
|
/// 只负责拉起 Google 授权并取出 idToken;换发本应用令牌由 AuthController 完成,
|
||||||
|
/// 插件调用与网络层各自独立,页面通过 [GoogleSignInOutcome] 判断结局。
|
||||||
|
class GoogleAuthService {
|
||||||
|
GoogleAuthService({GoogleSignIn? signIn})
|
||||||
|
: _signIn = signIn ?? GoogleSignIn.instance;
|
||||||
|
|
||||||
|
/// Android 必须显式传 serverClientId 才会返回 idToken,且要传 Web 客户端 id;
|
||||||
|
/// iOS 由 Info.plist 的 GIDClientID 决定,无需再传。
|
||||||
|
static const String _serverClientId =
|
||||||
|
'11115008580-dbqe47fhp5560nhrocrppiq7hcnlvl1s.apps.googleusercontent.com';
|
||||||
|
|
||||||
|
/// 授权等待上限:插件在账号被撤销后可能永不返回,必须有超时兜底,
|
||||||
|
/// 否则页面 loading 状态会一直卡住、按钮再也点不动。
|
||||||
|
static const Duration _authTimeout = Duration(seconds: 60);
|
||||||
|
|
||||||
|
final GoogleSignIn _signIn;
|
||||||
|
bool _initialized = false;
|
||||||
|
|
||||||
|
/// 拉起授权并返回结局;不会抛异常。
|
||||||
|
Future<GoogleSignInOutcome> signIn() async {
|
||||||
|
try {
|
||||||
|
await _ensureInitialized();
|
||||||
|
if (!_signIn.supportsAuthenticate()) {
|
||||||
|
return const GoogleSignInOutcome.unavailable();
|
||||||
|
}
|
||||||
|
// 先清掉插件缓存的旧账号:用户可能在 Google 侧撤销过授权或切换过账号,
|
||||||
|
// 残留状态会让 authenticate 直接返回失效账号或干脆不弹授权页。
|
||||||
|
await _clearStaleAccount();
|
||||||
|
final account = await _signIn.authenticate().timeout(_authTimeout);
|
||||||
|
final idToken = account.authentication.idToken;
|
||||||
|
if (idToken == null || idToken.isEmpty) {
|
||||||
|
return const GoogleSignInOutcome.failed();
|
||||||
|
}
|
||||||
|
return GoogleSignInOutcome.success(idToken);
|
||||||
|
} on TimeoutException {
|
||||||
|
await _clearStaleAccount();
|
||||||
|
return const GoogleSignInOutcome.failed();
|
||||||
|
} on GoogleSignInException catch (error) {
|
||||||
|
if (error.code == GoogleSignInExceptionCode.canceled) {
|
||||||
|
return const GoogleSignInOutcome.canceled();
|
||||||
|
}
|
||||||
|
// 失败多半是插件缓存了已失效的账号(用户手动撤销授权、换账号),
|
||||||
|
// 清掉本地状态,下次点击才能重新拉起授权页。
|
||||||
|
await _clearStaleAccount();
|
||||||
|
return const GoogleSignInOutcome.failed();
|
||||||
|
} catch (_) {
|
||||||
|
await _clearStaleAccount();
|
||||||
|
return const GoogleSignInOutcome.failed();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 清掉插件缓存的 Google 账号;失败不影响登录结果,异常直接吞掉。
|
||||||
|
Future<void> _clearStaleAccount() async {
|
||||||
|
try {
|
||||||
|
await _signIn.signOut();
|
||||||
|
} catch (_) {
|
||||||
|
// 忽略:清缓存失败不应阻断页面恢复
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 插件要求先 initialize 才能 authenticate;只做一次。
|
||||||
|
Future<void> _ensureInitialized() async {
|
||||||
|
if (_initialized) return;
|
||||||
|
await _signIn.initialize(
|
||||||
|
serverClientId: _isAndroid ? _serverClientId : null,
|
||||||
|
);
|
||||||
|
_initialized = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool get _isAndroid => !kIsWeb && Platform.isAndroid;
|
||||||
|
}
|
||||||
@@ -33,10 +33,15 @@ class PlaybackPositionCache {
|
|||||||
PlaybackPositionCache({
|
PlaybackPositionCache({
|
||||||
DateTime Function()? now,
|
DateTime Function()? now,
|
||||||
this.maxAge = _defaultMaxAge,
|
this.maxAge = _defaultMaxAge,
|
||||||
|
this.maxEntries = defaultMaxEntries,
|
||||||
}) : _now = now ?? DateTime.now;
|
}) : _now = now ?? DateTime.now;
|
||||||
|
|
||||||
|
/// 最多保留的集数:长会话连看几十部剧也不至于让 Map 无限增长。
|
||||||
|
static const int defaultMaxEntries = 100;
|
||||||
|
|
||||||
final DateTime Function() _now;
|
final DateTime Function() _now;
|
||||||
final Duration maxAge;
|
final Duration maxAge;
|
||||||
|
final int maxEntries;
|
||||||
final Map<String, CachedPlaybackPosition> _positions = {};
|
final Map<String, CachedPlaybackPosition> _positions = {};
|
||||||
|
|
||||||
/// 保存最近有效播放位置;零位置不会覆盖已有记录。
|
/// 保存最近有效播放位置;零位置不会覆盖已有记录。
|
||||||
@@ -57,6 +62,24 @@ class PlaybackPositionCache {
|
|||||||
duration: duration,
|
duration: duration,
|
||||||
updatedAt: _now(),
|
updatedAt: _now(),
|
||||||
);
|
);
|
||||||
|
_evictOverflow();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 超出上限时按写入时间淘汰最旧的一条,避免长会话内存只增不减。
|
||||||
|
void _evictOverflow() {
|
||||||
|
while (maxEntries > 0 && _positions.length > maxEntries) {
|
||||||
|
String? oldestKey;
|
||||||
|
DateTime? oldestAt;
|
||||||
|
for (final entry in _positions.entries) {
|
||||||
|
final at = entry.value.updatedAt;
|
||||||
|
if (oldestAt == null || at.isBefore(oldestAt)) {
|
||||||
|
oldestAt = at;
|
||||||
|
oldestKey = entry.key;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (oldestKey == null) return;
|
||||||
|
_positions.remove(oldestKey);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 读取同剧同集且未过期的最近位置。
|
/// 读取同剧同集且未过期的最近位置。
|
||||||
|
|||||||
@@ -0,0 +1,108 @@
|
|||||||
|
// Author: fruit.com.cn
|
||||||
|
|
||||||
|
import 'package:flutter/foundation.dart';
|
||||||
|
|
||||||
|
import '../models/reward.dart';
|
||||||
|
import '../remote/api_exception.dart';
|
||||||
|
import '../repositories/reward_repository.dart';
|
||||||
|
|
||||||
|
/// 奖励中心状态与签到、领取动作。
|
||||||
|
class RewardController extends ChangeNotifier {
|
||||||
|
RewardController(this._repository);
|
||||||
|
|
||||||
|
final RewardRepository _repository;
|
||||||
|
RewardOverview? overview;
|
||||||
|
bool loading = false;
|
||||||
|
bool checkingIn = false;
|
||||||
|
String? claimingTaskId;
|
||||||
|
String? error;
|
||||||
|
String? actionError;
|
||||||
|
bool _disposed = false;
|
||||||
|
String _locale = 'id';
|
||||||
|
|
||||||
|
Future<void> load(String locale) async {
|
||||||
|
if (_disposed || loading) return;
|
||||||
|
_locale = locale;
|
||||||
|
loading = true;
|
||||||
|
error = null;
|
||||||
|
_notify();
|
||||||
|
try {
|
||||||
|
overview = await _repository.fetchOverview(locale);
|
||||||
|
} on ApiException catch (exception) {
|
||||||
|
error = exception.message;
|
||||||
|
} catch (_) {
|
||||||
|
error = 'rewardLoadFailed';
|
||||||
|
} finally {
|
||||||
|
loading = false;
|
||||||
|
_notify();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 签到成功后刷新总览,确保签到格和余额来自服务端事实。
|
||||||
|
Future<RewardActionResult?> checkIn() async {
|
||||||
|
if (_disposed || checkingIn) return null;
|
||||||
|
checkingIn = true;
|
||||||
|
actionError = null;
|
||||||
|
_notify();
|
||||||
|
try {
|
||||||
|
final result = await _repository.checkIn();
|
||||||
|
await _reload();
|
||||||
|
return result;
|
||||||
|
} on ApiException catch (exception) {
|
||||||
|
actionError = exception.message;
|
||||||
|
return null;
|
||||||
|
} catch (_) {
|
||||||
|
actionError = 'rewardActionFailed';
|
||||||
|
return null;
|
||||||
|
} finally {
|
||||||
|
checkingIn = false;
|
||||||
|
_notify();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 领取任务奖励;同一时刻只允许一个领取动作。
|
||||||
|
Future<RewardActionResult?> claim(String taskId) async {
|
||||||
|
if (_disposed || claimingTaskId != null) return null;
|
||||||
|
claimingTaskId = taskId;
|
||||||
|
actionError = null;
|
||||||
|
_notify();
|
||||||
|
try {
|
||||||
|
final result = await _repository.claim(taskId);
|
||||||
|
await _reload();
|
||||||
|
return result;
|
||||||
|
} on ApiException catch (exception) {
|
||||||
|
actionError = exception.message;
|
||||||
|
return null;
|
||||||
|
} catch (_) {
|
||||||
|
actionError = 'rewardActionFailed';
|
||||||
|
return null;
|
||||||
|
} finally {
|
||||||
|
claimingTaskId = null;
|
||||||
|
_notify();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void reset() {
|
||||||
|
overview = null;
|
||||||
|
loading = false;
|
||||||
|
checkingIn = false;
|
||||||
|
claimingTaskId = null;
|
||||||
|
error = null;
|
||||||
|
actionError = null;
|
||||||
|
_notify();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _reload() async {
|
||||||
|
overview = await _repository.fetchOverview(_locale);
|
||||||
|
}
|
||||||
|
|
||||||
|
void _notify() {
|
||||||
|
if (!_disposed) notifyListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_disposed = true;
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -8,7 +8,8 @@ import 'package:dio/dio.dart';
|
|||||||
|
|
||||||
import '../../config/app_config.dart';
|
import '../../config/app_config.dart';
|
||||||
|
|
||||||
const int spriteThumbnailDecodeMaxDimension = 2048;
|
/// 雪碧图解码上限:擦洗预览只占很小一块区域,2048 会让单张位图膨胀到 16MB。
|
||||||
|
const int spriteThumbnailDecodeMaxDimension = 1024;
|
||||||
|
|
||||||
/// VTT 资源拒绝访问,服务层据此清缓存并重试一次。
|
/// VTT 资源拒绝访问,服务层据此清缓存并重试一次。
|
||||||
class SpriteThumbnailForbiddenException implements Exception {
|
class SpriteThumbnailForbiddenException implements Exception {
|
||||||
|
|||||||
@@ -21,23 +21,29 @@ class WalletController extends ChangeNotifier {
|
|||||||
String? unlockError;
|
String? unlockError;
|
||||||
String? unlockingEpisodeId;
|
String? unlockingEpisodeId;
|
||||||
bool _disposed = false;
|
bool _disposed = false;
|
||||||
|
int _requestSeq = 0;
|
||||||
|
|
||||||
int get balance => snapshot?.wallet.coinBalance ?? 0;
|
int get balance => snapshot?.wallet.coinBalance ?? 0;
|
||||||
List<CoinLedgerEntry> get ledger => snapshot?.ledger ?? const [];
|
List<CoinLedgerEntry> get ledger => snapshot?.ledger ?? const [];
|
||||||
|
|
||||||
Future<void> load() async {
|
Future<void> load() async {
|
||||||
|
if (_disposed) return;
|
||||||
|
final request = ++_requestSeq;
|
||||||
loading = true;
|
loading = true;
|
||||||
error = null;
|
error = null;
|
||||||
_notify();
|
_notify();
|
||||||
try {
|
try {
|
||||||
snapshot = await _repository.fetchWallet();
|
final result = await _repository.fetchWallet();
|
||||||
|
if (_isCurrent(request)) snapshot = result;
|
||||||
} on ApiException catch (exception) {
|
} on ApiException catch (exception) {
|
||||||
error = exception.message;
|
if (_isCurrent(request)) error = exception.message;
|
||||||
} catch (_) {
|
} catch (_) {
|
||||||
error = 'walletLoadFailed';
|
if (_isCurrent(request)) error = 'walletLoadFailed';
|
||||||
} finally {
|
} finally {
|
||||||
loading = false;
|
if (_isCurrent(request)) {
|
||||||
_notify();
|
loading = false;
|
||||||
|
_notify();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,6 +81,7 @@ class WalletController extends ChangeNotifier {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void reset() {
|
void reset() {
|
||||||
|
_requestSeq += 1;
|
||||||
snapshot = null;
|
snapshot = null;
|
||||||
loading = false;
|
loading = false;
|
||||||
unlocking = false;
|
unlocking = false;
|
||||||
@@ -88,6 +95,8 @@ class WalletController extends ChangeNotifier {
|
|||||||
if (!_disposed) notifyListeners();
|
if (!_disposed) notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool _isCurrent(int request) => !_disposed && request == _requestSeq;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
_disposed = true;
|
_disposed = true;
|
||||||
|
|||||||
@@ -227,14 +227,17 @@ class WatchRecordsController extends PagedListController<WatchRecord> {
|
|||||||
);
|
);
|
||||||
return detail;
|
return detail;
|
||||||
} catch (failure, stackTrace) {
|
} catch (failure, stackTrace) {
|
||||||
debugPrint(
|
// 弱网时详情会成批失败,release 下不需要逐条打堆栈。
|
||||||
'[WatchRecordsController] detail failed dramaId=$dramaId '
|
if (kDebugMode) {
|
||||||
'${failure.runtimeType}: $failure',
|
debugPrint(
|
||||||
);
|
'[WatchRecordsController] detail failed dramaId=$dramaId '
|
||||||
debugPrintStack(
|
'${failure.runtimeType}: $failure',
|
||||||
stackTrace: stackTrace,
|
);
|
||||||
label: '[WatchRecordsController] detail failed dramaId=$dramaId',
|
debugPrintStack(
|
||||||
);
|
stackTrace: stackTrace,
|
||||||
|
label: '[WatchRecordsController] detail failed dramaId=$dramaId',
|
||||||
|
);
|
||||||
|
}
|
||||||
if (isDisposed) return null;
|
if (isDisposed) return null;
|
||||||
final current = _recordIndex(dramaId);
|
final current = _recordIndex(dramaId);
|
||||||
if (current < 0) return null;
|
if (current < 0) return null;
|
||||||
|
|||||||
@@ -27,6 +27,15 @@ abstract final class AppColors {
|
|||||||
static const overlaySecondary = Color(0xFFC7C7CC);
|
static const overlaySecondary = Color(0xFFC7C7CC);
|
||||||
static const overlayLabel = Color(0xFFE6E6EB);
|
static const overlayLabel = Color(0xFFE6E6EB);
|
||||||
|
|
||||||
|
/// 首页及剧集播放页视频信息文案:参考设计图的 65% 半透明白。
|
||||||
|
static const homeFeedVideoCopy = Color(0xA6FFFFFF);
|
||||||
|
|
||||||
|
/// 首页观看全集按钮:与浮层玻璃语言一致的半透明白表面。
|
||||||
|
static const watchAllSurface = Color(0x26FFFFFF);
|
||||||
|
|
||||||
|
/// 观看全集按钮的极淡白色轮廓。
|
||||||
|
static const watchAllBorder = Color(0x0FFFFFFF);
|
||||||
|
|
||||||
/// 主操作、选中态、播放进度。旧品牌橙已全量映射为品牌红(2026-10 改版)。
|
/// 主操作、选中态、播放进度。旧品牌橙已全量映射为品牌红(2026-10 改版)。
|
||||||
static const blue = Color(0xFFF04E4E);
|
static const blue = Color(0xFFF04E4E);
|
||||||
static const primary = blue;
|
static const primary = blue;
|
||||||
@@ -48,10 +57,23 @@ abstract final class AppColors {
|
|||||||
static const vipGoldStart = Color(0xFFF5D9A0);
|
static const vipGoldStart = Color(0xFFF5D9A0);
|
||||||
static const vipGoldEnd = Color(0xFFE8B65A);
|
static const vipGoldEnd = Color(0xFFE8B65A);
|
||||||
|
|
||||||
/// 「我的」页 VIP 卡的浅香槟金(见设计稿,接近纯色)。
|
/// 「我的」页 VIP 卡:品牌红、暖黑与中性灰形成统一层级。
|
||||||
static const vipCardStart = Color(0xFFF6E8C6);
|
static const vipCardStart = Color(0xFF21191C);
|
||||||
static const vipCardEnd = Color(0xFFEDD9A8);
|
static const vipCardMiddle = Color(0xFF181719);
|
||||||
static const vipBadgeSurface = Color(0x1F3D2408);
|
static const vipCardEnd = Color(0xFF141416);
|
||||||
|
static const vipCardBorder = Color(0x2EFFFFFF);
|
||||||
|
static const vipCardRedGlow = Color(0x2EF04E4E);
|
||||||
|
static const vipCardGoldGlow = Color(0x16F5D9A0);
|
||||||
|
static const vipArtGlow = Color(0x55F04E4E);
|
||||||
|
static const vipArtStart = Color(0xFFE45757);
|
||||||
|
static const vipArtEnd = Color(0xFF6E1F2D);
|
||||||
|
static const vipCardText = Color(0xFFF5F5F7);
|
||||||
|
static const vipCardMuted = Color(0xB3B0B0B0);
|
||||||
|
static const vipBadgeSurface = Color(0x24F04E4E);
|
||||||
|
static const vipBenefitSurface = Color(0x12FFFFFF);
|
||||||
|
static const vipBenefitBorder = Color(0x14FFFFFF);
|
||||||
|
static const vipButtonStart = Color(0xFFF04E4E);
|
||||||
|
static const vipButtonEnd = Color(0xFFC93648);
|
||||||
static const bronze = Color(0xFFCD7F32);
|
static const bronze = Color(0xFFCD7F32);
|
||||||
static const bronzeDeep = Color(0xFFA9713A);
|
static const bronzeDeep = Color(0xFFA9713A);
|
||||||
static const rankSilver = Color(0xFFC0C0C0);
|
static const rankSilver = Color(0xFFC0C0C0);
|
||||||
@@ -113,9 +135,18 @@ abstract final class AppColors {
|
|||||||
static const mineGridSurface = Color(0x99101010);
|
static const mineGridSurface = Color(0x99101010);
|
||||||
static const minePanelSurface = Color(0xFF101010);
|
static const minePanelSurface = Color(0xFF101010);
|
||||||
static const mineMoreDivider = Color(0xFF1C1C1E);
|
static const mineMoreDivider = Color(0xFF1C1C1E);
|
||||||
static const mineGridDivider = Color(0xFF2A2A2A);
|
static const mineGridDivider = Color(0x10FFFFFF);
|
||||||
static const mineGridIconSurface = Color(0xFF1C1C1E);
|
static const mineGridIconSurface = Color(0xFF1C1C1E);
|
||||||
static const mineGridLabel = Color(0xFFE6E6EB);
|
static const mineGridLabel = Color(0xFFE6E6EB);
|
||||||
|
static const mineGridIconAccent = brandRed;
|
||||||
|
|
||||||
|
/// 个人数据图标:品牌红的亮面、暗部与暖白反光。
|
||||||
|
static const mineStatHighlight = Color(0xFFFFAAA3);
|
||||||
|
static const mineStatShade = Color(0xFFAF263C);
|
||||||
|
static const mineStatDepth = Color(0xFF681D2B);
|
||||||
|
static const mineStatGlint = Color(0xFFFFE8E2);
|
||||||
|
static const mineStatEdge = Color(0x80FFD1CB);
|
||||||
|
static const mineStatGlow = Color(0x24F04E4E);
|
||||||
static const mineIconWallet = Color(0xFFF5C451);
|
static const mineIconWallet = Color(0xFFF5C451);
|
||||||
static const mineIconDownloads = Color(0xFF4DA3FF);
|
static const mineIconDownloads = Color(0xFF4DA3FF);
|
||||||
static const mineIconHistory = Color(0xFF4ADE80);
|
static const mineIconHistory = Color(0xFF4ADE80);
|
||||||
@@ -134,6 +165,10 @@ abstract final class AppColors {
|
|||||||
/// 列表底部「没有更多了」这类弱提示。
|
/// 列表底部「没有更多了」这类弱提示。
|
||||||
static const textHint = Color(0xFF5C5C60);
|
static const textHint = Color(0xFF5C5C60);
|
||||||
static const textTabInactive = Color(0xFFB0B0B0);
|
static const textTabInactive = Color(0xFFB0B0B0);
|
||||||
|
|
||||||
|
/// 首页顶部三项导航未选中文字,略暗于选中白色但保持清晰。
|
||||||
|
static const homeTabInactive = Color(0xFFC7C7CC);
|
||||||
|
|
||||||
static const textFilterIcon = Color(0xFF7A7A7E);
|
static const textFilterIcon = Color(0xFF7A7A7E);
|
||||||
static const searchResultMeta = Color(0xFF9E9E9E);
|
static const searchResultMeta = Color(0xFF9E9E9E);
|
||||||
|
|
||||||
@@ -150,6 +185,7 @@ abstract final class AppColors {
|
|||||||
static const navBackground = Color(0xFF000000);
|
static const navBackground = Color(0xFF000000);
|
||||||
static const brandRed = Color(0xFFF04E4E);
|
static const brandRed = Color(0xFFF04E4E);
|
||||||
static const brandRedPressed = Color(0xFFD64040);
|
static const brandRedPressed = Color(0xFFD64040);
|
||||||
|
static const navSelectedGlow = Color(0x33F04E4E);
|
||||||
static const navSelected = brandRed;
|
static const navSelected = brandRed;
|
||||||
|
|
||||||
/// 卡片阴影(深色几乎不用阴影)。
|
/// 卡片阴影(深色几乎不用阴影)。
|
||||||
@@ -190,6 +226,12 @@ abstract final class AppColors {
|
|||||||
|
|
||||||
/// 玻璃面板描边。
|
/// 玻璃面板描边。
|
||||||
static const glassBorder = Color(0x33FFFFFF);
|
static const glassBorder = Color(0x33FFFFFF);
|
||||||
|
|
||||||
|
/// 玻璃控件使用的发丝级轮廓,避免边缘抢过内容。
|
||||||
|
static const glassHairline = Color(0x12FFFFFF);
|
||||||
|
|
||||||
|
/// 轻量玻璃控件的白色表面。
|
||||||
|
static const glassSurface = Color(0x24FFFFFF);
|
||||||
static const glassSurfaceStart = Color(0xEB16161A);
|
static const glassSurfaceStart = Color(0xEB16161A);
|
||||||
static const glassSurfaceEnd = Color(0xD1101010);
|
static const glassSurfaceEnd = Color(0xD1101010);
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ abstract final class AppDimens {
|
|||||||
static const double buttonRadius = 10;
|
static const double buttonRadius = 10;
|
||||||
static const double inputRadius = 10;
|
static const double inputRadius = 10;
|
||||||
static const double chipRadius = 6;
|
static const double chipRadius = 6;
|
||||||
static const double coverRadius = 12;
|
static const double coverRadius = 8;
|
||||||
static const double sheetRadius = 12;
|
static const double sheetRadius = 12;
|
||||||
|
|
||||||
static const double caption = 12;
|
static const double caption = 12;
|
||||||
@@ -37,7 +37,7 @@ abstract final class AppDimens {
|
|||||||
static const double previewSectionTitle = 14;
|
static const double previewSectionTitle = 14;
|
||||||
static const double chipFont = 10;
|
static const double chipFont = 10;
|
||||||
static const double navLabel = 13;
|
static const double navLabel = 13;
|
||||||
static const double navLabelGap = 5;
|
static const double navLabelGap = 1;
|
||||||
|
|
||||||
static const double buttonHeight = 48;
|
static const double buttonHeight = 48;
|
||||||
static const double primaryButtonHeight = 52;
|
static const double primaryButtonHeight = 52;
|
||||||
@@ -92,7 +92,7 @@ abstract final class AppDimens {
|
|||||||
static const double homeGridGap = 6;
|
static const double homeGridGap = 6;
|
||||||
static const double homeGridRowGap = 10;
|
static const double homeGridRowGap = 10;
|
||||||
static const double homeCardRadius = 6;
|
static const double homeCardRadius = 6;
|
||||||
static const double cardCoverRadius = 8;
|
static const double cardCoverRadius = coverRadius;
|
||||||
static const double homeCardPadding = 8;
|
static const double homeCardPadding = 8;
|
||||||
static const double cardTitleFont = 15;
|
static const double cardTitleFont = 15;
|
||||||
static const double cardTitleLineHeight = 1.3;
|
static const double cardTitleLineHeight = 1.3;
|
||||||
@@ -141,7 +141,7 @@ abstract final class AppDimens {
|
|||||||
static const double homePrimarySecondaryGap = 8;
|
static const double homePrimarySecondaryGap = 8;
|
||||||
static const double homeSecondaryGridGap = 10;
|
static const double homeSecondaryGridGap = 10;
|
||||||
static const double homeHeaderIcon = 22;
|
static const double homeHeaderIcon = 22;
|
||||||
static const double homeActionSlot = 40;
|
static const double homeActionSlot = tapTarget;
|
||||||
static const double homeActionIcon = 30;
|
static const double homeActionIcon = 30;
|
||||||
static const double homeActionGap = 6;
|
static const double homeActionGap = 6;
|
||||||
|
|
||||||
@@ -150,24 +150,16 @@ abstract final class AppDimens {
|
|||||||
static const double recommendSectionTitle = 17;
|
static const double recommendSectionTitle = 17;
|
||||||
static const double recommendSectionSubtitle = 11;
|
static const double recommendSectionSubtitle = 11;
|
||||||
static const double recommendSectionMore = 12;
|
static const double recommendSectionMore = 12;
|
||||||
// 封面 122*(4/3)≈163 + 间距6 + 两行标题39 + 间距6 + 标签13 ≈ 227。
|
// 封面 122*(4/3)≈163 + 间距6 + 两行标题≈42 + 间距6 + 标签≈13 ≈ 230,留 6 余量。
|
||||||
static const double recommendRowHeight = 228;
|
static const double recommendRowHeight = 236;
|
||||||
static const double recommendCardWidth = 122;
|
static const double recommendCardWidth = 122;
|
||||||
|
|
||||||
/// 首页热播榜。
|
/// 首页热播榜。
|
||||||
static const double rankingHeroTitle = 22;
|
static const double rankingHeroTitle = 22;
|
||||||
static const double rankingHeroSubtitle = 11;
|
static const double rankingHeroSubtitle = 11;
|
||||||
static const double rankingPodiumChampionWidth = 110;
|
static const double rankingCoverRadius = coverRadius;
|
||||||
static const double rankingPodiumChampionHeight = 146;
|
static const double rankingCardCoverWidth = 96;
|
||||||
static const double rankingPodiumWidth = 92;
|
static const double rankingCardCoverHeight = 128;
|
||||||
static const double rankingPodiumHeight = 122;
|
|
||||||
static const double rankingPodiumRadius = 10;
|
|
||||||
static const double rankingRowHeight = 96;
|
|
||||||
static const double rankingNumberWidth = 56;
|
|
||||||
static const double rankingNumberFont = 48;
|
|
||||||
static const double rankingCoverWidth = 60;
|
|
||||||
static const double rankingCoverHeight = 80;
|
|
||||||
static const double rankingCoverRadius = 6;
|
|
||||||
|
|
||||||
/// 全部短剧筛选与追剧双列。
|
/// 全部短剧筛选与追剧双列。
|
||||||
static const double filterChipFont = 16;
|
static const double filterChipFont = 16;
|
||||||
@@ -184,20 +176,20 @@ abstract final class AppDimens {
|
|||||||
static const double followingTabFont = 18;
|
static const double followingTabFont = 18;
|
||||||
static const double followingTabGap = 24;
|
static const double followingTabGap = 24;
|
||||||
static const double followingEditIconSize = 20;
|
static const double followingEditIconSize = 20;
|
||||||
static const double followingEditHitSize = 40;
|
static const double followingEditHitSize = tapTarget;
|
||||||
static const double followingAddIconSize = 20;
|
static const double followingAddIconSize = 20;
|
||||||
static const double followingAddIconStroke = 1.5;
|
static const double followingAddIconStroke = 1.5;
|
||||||
static const double followingGridGap = 6;
|
static const double followingGridGap = 6;
|
||||||
static const double followingGridRowGap = 12;
|
static const double followingGridRowGap = 12;
|
||||||
// 单行标题 16*1.3=20.8 + 间距 6+4 + 副标题行高约 18.6 ≈ 49.4,留 0.6 余量;
|
|
||||||
// 按 48 估算在副标题行高偏高的字体下会溢出 1~2px。
|
/// 追剧网格卡文字区:间距 6 + 两行剧名 16*1.3*2=41.6 ≈ 48,留 4 余量。
|
||||||
static const double followingCardTextExtent = 50;
|
static const double followingCardTextExtent = 52;
|
||||||
static const double followingSubtitleFont = 12;
|
static const double followingSubtitleFont = 12;
|
||||||
static const double followingSubtitleGap = 4;
|
static const double followingSubtitleGap = 4;
|
||||||
static const double followingProgressHeight = 2;
|
static const double followingProgressHeight = 2;
|
||||||
static const double followingHistoryCoverWidth = 96;
|
static const double followingHistoryCoverWidth = 96;
|
||||||
static const double followingHistoryCoverHeight = 128;
|
static const double followingHistoryCoverHeight = 128;
|
||||||
static const double followingHistoryCoverRadius = 6;
|
static const double followingHistoryCoverRadius = coverRadius;
|
||||||
static const double followingHistoryContentGap = 12;
|
static const double followingHistoryContentGap = 12;
|
||||||
static const double followingHistoryRowGap = 16;
|
static const double followingHistoryRowGap = 16;
|
||||||
static const double followingHistoryProgressHeight = 3;
|
static const double followingHistoryProgressHeight = 3;
|
||||||
@@ -269,32 +261,48 @@ abstract final class AppDimens {
|
|||||||
static const double mineGridIconSurface = 44;
|
static const double mineGridIconSurface = 44;
|
||||||
static const double mineGridIcon = 22;
|
static const double mineGridIcon = 22;
|
||||||
static const double mineGridLabel = 12;
|
static const double mineGridLabel = 12;
|
||||||
|
static const double mineGridLabelLineHeight = 1.15;
|
||||||
static const double mineGridDividerWidth = 1;
|
static const double mineGridDividerWidth = 1;
|
||||||
|
|
||||||
|
/// 宫格内部分隔线:0.5pt 发丝线,深色底上比 1pt 更轻。
|
||||||
|
static const double mineGridHairline = 0.5;
|
||||||
|
static const int mineGridRows = 2;
|
||||||
|
static const double mineGridHeight =
|
||||||
|
mineGridCellHeight * mineGridRows + mineGridHairline;
|
||||||
static const double mineSectionTitleFont = 16;
|
static const double mineSectionTitleFont = 16;
|
||||||
static const double mineSectionLinkFont = 12;
|
static const double mineSectionLinkFont = 12;
|
||||||
static const double mineSectionGap = 12;
|
static const double mineSectionGap = 12;
|
||||||
|
|
||||||
/// 「我的」页新版:快捷图标行与服务列表。
|
/// 「我的」页紧凑会员横幅尺寸。
|
||||||
static const double mineQuickActionIcon = 28;
|
static const double mineVipRadius = 18;
|
||||||
static const double mineQuickActionLabelFont = 14;
|
static const double mineVipPadding = 10;
|
||||||
static const double mineQuickActionGap = 8;
|
static const double mineVipTitleFont = 21;
|
||||||
static const double mineServiceRowHeight = 56;
|
static const double mineVipSubtitleFont = 11;
|
||||||
static const double mineServiceIcon = 24;
|
static const double mineVipEmblem = 48;
|
||||||
static const double mineServiceTitleFont = 16;
|
static const double mineVipEmblemIcon = 28;
|
||||||
static const double mineServiceValueFont = 14;
|
static const double mineVipArtWidth = 84;
|
||||||
static const double mineVipBenefitFont = 14;
|
static const double mineVipArtHeight = 84;
|
||||||
static const double mineVipBenefitIcon = 20;
|
static const double mineVipArtGlow = 56;
|
||||||
static const double mineVipBenefitBox = 30;
|
static const double mineVipArtSurface = 44;
|
||||||
static const double mineVipBenefitBoxRadius = 7;
|
static const double mineVipArtIcon = 22;
|
||||||
static const double mineVipBenefitGlyph = 17;
|
static const double mineVipActionWidth = 86;
|
||||||
static const double mineVipBenefitRowGap = 4;
|
static const double mineVipBenefitFont = 10.5;
|
||||||
static const double mineVipButtonHeight = 36;
|
static const double mineVipBenefitSurface = 28;
|
||||||
|
static const double mineVipBenefitGlyph = 16;
|
||||||
|
static const double mineVipBenefitRowGap = 2;
|
||||||
|
static const double mineVipButtonHeight = 26;
|
||||||
static const double mineContinueCardWidth = 96;
|
static const double mineContinueCardWidth = 96;
|
||||||
static const double mineContinueRowHeight = 172;
|
static const double mineContinueRowHeight = 172;
|
||||||
static const double mineContinueTitleFont = 13;
|
static const double mineContinueTitleFont = 13;
|
||||||
static const double mineContinueMetaFont = 11;
|
static const double mineContinueMetaFont = 11;
|
||||||
static const double mineStatsValueFont = 18;
|
static const double mineStatsValueFont = 24;
|
||||||
static const double mineStatsLabelFont = 11;
|
static const double mineStatsLabelFont = 12;
|
||||||
|
static const double mineStatsIcon = 42;
|
||||||
|
static const double mineStatsMinHeight = 104;
|
||||||
|
static const double mineStatsDividerHeight = 32;
|
||||||
|
static const double mineStatsDividerWidth = 0.5;
|
||||||
|
static const double mineStatsValueLineHeight = 1.1;
|
||||||
|
static const double mineStatsLabelLineHeight = 1.25;
|
||||||
static const double minePanelPadding = 12;
|
static const double minePanelPadding = 12;
|
||||||
static const double mineMoreRowHeight = 52;
|
static const double mineMoreRowHeight = 52;
|
||||||
static const double mineMoreFont = 15;
|
static const double mineMoreFont = 15;
|
||||||
|
|||||||
@@ -0,0 +1,71 @@
|
|||||||
|
// Author: fruit.com.cn
|
||||||
|
// 职责:固定顶部导航文字排版,以绘制缩放和颜色插值实现选中切换。
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import '../theme/app_colors.dart';
|
||||||
|
import '../theme/app_dimens.dart';
|
||||||
|
|
||||||
|
const double _inactiveScale = 0.9;
|
||||||
|
|
||||||
|
/// 保留最大字号、固定字重与占位,避免选中动画触发相邻标签重新布局。
|
||||||
|
class AnimatedNavLabel extends StatelessWidget {
|
||||||
|
/// [style] 指定选中态字号与颜色;字重固定,未指定时默认加粗。
|
||||||
|
const AnimatedNavLabel({
|
||||||
|
super.key,
|
||||||
|
required this.label,
|
||||||
|
required this.selected,
|
||||||
|
required this.style,
|
||||||
|
this.alignment = Alignment.bottomCenter,
|
||||||
|
this.selectionProgress,
|
||||||
|
this.inactiveColor = AppColors.textTabInactive,
|
||||||
|
});
|
||||||
|
|
||||||
|
final String label;
|
||||||
|
final bool selected;
|
||||||
|
final TextStyle style;
|
||||||
|
final Alignment alignment;
|
||||||
|
|
||||||
|
/// 未选中文字颜色;默认保持通用导航原有灰色。
|
||||||
|
final Color inactiveColor;
|
||||||
|
|
||||||
|
/// 页面拖动时直接使用连续进度,避免再叠加一层延迟动画。
|
||||||
|
final double? selectionProgress;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final target = selected ? 1.0 : 0.0;
|
||||||
|
final reduceMotion = MediaQuery.disableAnimationsOf(context);
|
||||||
|
return Semantics(
|
||||||
|
selected: selected,
|
||||||
|
child: selectionProgress != null
|
||||||
|
? _label(selectionProgress!.clamp(0.0, 1.0))
|
||||||
|
: TweenAnimationBuilder<double>(
|
||||||
|
tween: Tween(begin: target, end: target),
|
||||||
|
duration: reduceMotion
|
||||||
|
? Duration.zero
|
||||||
|
: AppDimens.homePrimaryTabAnimationDuration,
|
||||||
|
curve: Curves.easeOut,
|
||||||
|
builder: (context, progress, _) => _label(progress),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _label(double progress) => Transform.scale(
|
||||||
|
scale: _inactiveScale + (1 - _inactiveScale) * progress,
|
||||||
|
alignment: alignment,
|
||||||
|
child: Text(
|
||||||
|
label,
|
||||||
|
maxLines: 1,
|
||||||
|
textAlign: TextAlign.left,
|
||||||
|
style: style.copyWith(
|
||||||
|
fontWeight: style.fontWeight ?? FontWeight.w700,
|
||||||
|
letterSpacing: 0,
|
||||||
|
color: Color.lerp(
|
||||||
|
inactiveColor,
|
||||||
|
style.color ?? AppColors.textPrimary,
|
||||||
|
progress,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -4,6 +4,9 @@ import 'package:flutter/material.dart';
|
|||||||
|
|
||||||
import '../theme/app_colors.dart';
|
import '../theme/app_colors.dart';
|
||||||
import '../theme/app_dimens.dart';
|
import '../theme/app_dimens.dart';
|
||||||
|
import 'app_press_scale.dart';
|
||||||
|
|
||||||
|
const double _maxNavigationTextScale = 1.3;
|
||||||
|
|
||||||
/// 底部导航普通目的地。
|
/// 底部导航普通目的地。
|
||||||
class AppBottomNavItem {
|
class AppBottomNavItem {
|
||||||
@@ -16,6 +19,7 @@ class AppBottomNavItem {
|
|||||||
this.selected = false,
|
this.selected = false,
|
||||||
this.assetPath,
|
this.assetPath,
|
||||||
this.selectedAssetPath,
|
this.selectedAssetPath,
|
||||||
|
this.customIcon,
|
||||||
});
|
});
|
||||||
|
|
||||||
final Key tabKey;
|
final Key tabKey;
|
||||||
@@ -23,12 +27,13 @@ class AppBottomNavItem {
|
|||||||
final IconData selectedIcon;
|
final IconData selectedIcon;
|
||||||
final String? assetPath;
|
final String? assetPath;
|
||||||
final String? selectedAssetPath;
|
final String? selectedAssetPath;
|
||||||
|
final Widget? customIcon;
|
||||||
final String label;
|
final String label;
|
||||||
final VoidCallback onTap;
|
final VoidCallback onTap;
|
||||||
final bool selected;
|
final bool selected;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 四槽底部导航:纯黑背景,白色选中态,灰色未选中态。
|
/// 均分底部导航:纯黑背景,品牌红选中态,白色未选中态。
|
||||||
class AppBottomNav extends StatelessWidget {
|
class AppBottomNav extends StatelessWidget {
|
||||||
const AppBottomNav({super.key, required this.items, this.barKey});
|
const AppBottomNav({super.key, required this.items, this.barKey});
|
||||||
|
|
||||||
@@ -41,14 +46,17 @@ class AppBottomNav extends StatelessWidget {
|
|||||||
key: barKey,
|
key: barKey,
|
||||||
height: AppDimens.navHeight,
|
height: AppDimens.navHeight,
|
||||||
color: AppColors.navBackground,
|
color: AppColors.navBackground,
|
||||||
child: Row(
|
child: MediaQuery.withClampedTextScaling(
|
||||||
children: [
|
maxScaleFactor: _maxNavigationTextScale,
|
||||||
for (final item in items)
|
child: Row(
|
||||||
_NavDestination(
|
children: [
|
||||||
item: item,
|
for (final item in items)
|
||||||
unselectedColor: AppColors.navUnselected,
|
_NavDestination(
|
||||||
),
|
item: item,
|
||||||
],
|
unselectedColor: AppColors.navUnselected,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
return ColoredBox(
|
return ColoredBox(
|
||||||
@@ -84,30 +92,46 @@ class _NavDestination extends StatelessWidget {
|
|||||||
child: Column(
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
AnimatedScale(
|
AppPressScale(
|
||||||
duration: const Duration(milliseconds: 160),
|
child: DecoratedBox(
|
||||||
curve: Curves.easeOut,
|
decoration: BoxDecoration(
|
||||||
scale: item.selected ? 1 : 0.96,
|
borderRadius: BorderRadius.circular(AppDimens.navIcon),
|
||||||
child: assetPath == null
|
boxShadow: item.selected
|
||||||
? Icon(
|
? const [
|
||||||
fallbackIcon,
|
BoxShadow(
|
||||||
size: AppDimens.navIcon,
|
color: AppColors.navSelectedGlow,
|
||||||
color: color,
|
blurRadius: 12,
|
||||||
)
|
spreadRadius: 1,
|
||||||
: ColorFiltered(
|
),
|
||||||
colorFilter: ColorFilter.mode(color, BlendMode.srcIn),
|
]
|
||||||
child: Image.asset(
|
: const [],
|
||||||
assetPath,
|
),
|
||||||
width: AppDimens.navIcon,
|
child:
|
||||||
height: AppDimens.navIcon,
|
item.customIcon ??
|
||||||
fit: BoxFit.contain,
|
(assetPath == null
|
||||||
errorBuilder: (_, _, _) => Icon(
|
? Icon(
|
||||||
fallbackIcon,
|
fallbackIcon,
|
||||||
size: AppDimens.navIcon,
|
size: AppDimens.navIcon,
|
||||||
color: color,
|
color: color,
|
||||||
),
|
)
|
||||||
),
|
: ColorFiltered(
|
||||||
),
|
colorFilter: ColorFilter.mode(
|
||||||
|
color,
|
||||||
|
BlendMode.srcIn,
|
||||||
|
),
|
||||||
|
child: Image.asset(
|
||||||
|
assetPath,
|
||||||
|
width: AppDimens.navIcon,
|
||||||
|
height: AppDimens.navIcon,
|
||||||
|
fit: BoxFit.contain,
|
||||||
|
errorBuilder: (_, _, _) => Icon(
|
||||||
|
fallbackIcon,
|
||||||
|
size: AppDimens.navIcon,
|
||||||
|
color: color,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: AppDimens.navLabelGap),
|
const SizedBox(height: AppDimens.navLabelGap),
|
||||||
Text(
|
Text(
|
||||||
|
|||||||
@@ -0,0 +1,53 @@
|
|||||||
|
// Author: fruit.com.cn
|
||||||
|
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
const double _pressedScale = 0.97;
|
||||||
|
|
||||||
|
/// 为可点击内容提供轻量、短促的按压缩放反馈。
|
||||||
|
class AppPressScale extends StatefulWidget {
|
||||||
|
const AppPressScale({
|
||||||
|
super.key,
|
||||||
|
required this.child,
|
||||||
|
this.onTap,
|
||||||
|
this.scale = _pressedScale,
|
||||||
|
});
|
||||||
|
|
||||||
|
final Widget child;
|
||||||
|
final VoidCallback? onTap;
|
||||||
|
final double scale;
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<AppPressScale> createState() => _AppPressScaleState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _AppPressScaleState extends State<AppPressScale> {
|
||||||
|
bool _pressed = false;
|
||||||
|
|
||||||
|
void _setPressed(bool pressed) {
|
||||||
|
if (_pressed == pressed) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
setState(() => _pressed = pressed);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final scale = _pressed ? widget.scale : 1.0;
|
||||||
|
final feedback = Listener(
|
||||||
|
behavior: HitTestBehavior.translucent,
|
||||||
|
onPointerDown: (_) => _setPressed(true),
|
||||||
|
onPointerUp: (_) => _setPressed(false),
|
||||||
|
onPointerCancel: (_) => _setPressed(false),
|
||||||
|
child: Transform.scale(scale: scale, child: widget.child),
|
||||||
|
);
|
||||||
|
if (widget.onTap == null) {
|
||||||
|
return feedback;
|
||||||
|
}
|
||||||
|
return GestureDetector(
|
||||||
|
behavior: HitTestBehavior.translucent,
|
||||||
|
onTap: widget.onTap,
|
||||||
|
child: feedback,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -11,6 +11,7 @@ const double _maxPullDistance = 96;
|
|||||||
const double _refreshThreshold = 56;
|
const double _refreshThreshold = 56;
|
||||||
const double _indicatorHeight = 56;
|
const double _indicatorHeight = 56;
|
||||||
const double _indicatorDisplacement = 40;
|
const double _indicatorDisplacement = 40;
|
||||||
|
const double _indicatorTopPadding = 8;
|
||||||
const Duration _settleDuration = Duration(milliseconds: 200);
|
const Duration _settleDuration = Duration(milliseconds: 200);
|
||||||
|
|
||||||
enum _PullState { idle, pull, armed, refreshing }
|
enum _PullState { idle, pull, armed, refreshing }
|
||||||
@@ -27,6 +28,10 @@ class AppPullToRefresh extends StatefulWidget {
|
|||||||
static const AlwaysScrollableScrollPhysics physics =
|
static const AlwaysScrollableScrollPhysics physics =
|
||||||
AlwaysScrollableScrollPhysics(parent: BouncingScrollPhysics());
|
AlwaysScrollableScrollPhysics(parent: BouncingScrollPhysics());
|
||||||
|
|
||||||
|
/// 达到刷新阈值时,指示器顶部相对容器顶部的下移距离。
|
||||||
|
static const double indicatorRevealOffset =
|
||||||
|
_indicatorDisplacement + _indicatorTopPadding;
|
||||||
|
|
||||||
final Widget child;
|
final Widget child;
|
||||||
final Future<void> Function() onRefresh;
|
final Future<void> Function() onRefresh;
|
||||||
final double edgeOffset;
|
final double edgeOffset;
|
||||||
@@ -191,7 +196,7 @@ class _AppPullToRefreshState extends State<AppPullToRefresh>
|
|||||||
child: Align(
|
child: Align(
|
||||||
alignment: Alignment.topCenter,
|
alignment: Alignment.topCenter,
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.only(top: 8),
|
padding: const EdgeInsets.only(top: _indicatorTopPadding),
|
||||||
child: _indicator(),
|
child: _indicator(),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||