7 Commits
27 changed files with 399 additions and 245 deletions

No files matched your search

+30 -3
View File
@@ -1,11 +1,24 @@
// Author: fruit.com.cn
import java.io.FileInputStream
import java.util.Properties
plugins {
id("com.android.application")
// The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins.
id("dev.flutter.flutter-gradle-plugin")
}
// 正式包签名信息从 android/key.properties 读取;该文件与 keystore 都已忽略入库。
// 文件缺失时回落到 debug 签名,保证本地 `flutter run --release` 仍可调试。
val keystorePropertiesFile = rootProject.file("key.properties")
val keystoreProperties = Properties()
if (keystorePropertiesFile.exists()) {
FileInputStream(keystorePropertiesFile).use { keystoreProperties.load(it) }
}
val hasReleaseKeystore = keystorePropertiesFile.exists() &&
keystoreProperties.getProperty("storeFile").orEmpty().isNotEmpty()
android {
namespace = "com.stormg.lumadrama"
// permission_handler_android 14 的 AAR 元数据要求依赖方 compileSdk >= 37,
@@ -29,6 +42,21 @@ android {
versionName = flutter.versionName
}
signingConfigs {
if (hasReleaseKeystore) {
create("release") {
storeFile = file(keystoreProperties.getProperty("storeFile"))
storePassword = keystoreProperties.getProperty("storePassword")
keyAlias = keystoreProperties.getProperty("keyAlias")
keyPassword = keystoreProperties.getProperty("keyPassword")
// Google Play 要求上传包必须使用固定密钥签名,且开启 Play 应用签名后该密钥成为上传密钥。
enableV1Signing = true
enableV2Signing = true
enableV3Signing = true
}
}
}
buildTypes {
release {
// 生产包只保留 arm64-v8a 与 armeabi-v7a,避免插件带入 x86_64 原生库
@@ -42,9 +70,8 @@ android {
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro",
)
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig = signingConfigs.getByName("debug")
// 有 upload keystore 时用正式签名,否则回落到 debug 便于本地调试。
signingConfig = signingConfigs.getByName(if (hasReleaseKeystore) "release" else "debug")
}
}
}
+1 -1
View File
@@ -6,7 +6,7 @@
<uses-permission
android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<application
android:label="ymb"
android:label="YMB"
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher"
android:usesCleartextTraffic="true">
@@ -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
}
+1 -1
View File
@@ -7,7 +7,7 @@
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleDisplayName</key>
<string>ymb</string>
<string>YMB</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
+5 -5
View File
@@ -1,5 +1,7 @@
// Author: fruit.com.cn
import 'package:flutter/foundation.dart';
import 'dev_config.dart';
import 'prod_config.dart';
@@ -9,12 +11,10 @@ import 'prod_config.dart';
/// - `dev_config.dart`:[DevConfig](本机联调)
/// - `prod_config.dart`:[ProdConfig](生产)
///
/// 切换环境只改下面这一个布尔值,不用传任何构建参数、也不做网络探测。
/// Debug 使用开发环境,Release 自动使用生产环境,不做网络探测。
abstract final class AppConfig {
/// **环境开关**:true 用开发环境,false 用生产环境。
///
/// 打生产包前必须改成 false;release 构建若仍为 true 会在启动时直接报错。
static const bool useDevConfig = true;
/// **环境开关**:Debug 使用开发环境,Release 使用生产环境。
static const bool useDevConfig = !kReleaseMode;
/// 当前选中的环境地址。
static String get baseUrl =>
+1 -1
View File
@@ -5,5 +5,5 @@
/// 发版前确认这里的 [baseUrl],地址不要带结尾斜杠。
abstract final class ProdConfig {
/// 生产后端地址。
static const String baseUrl = 'http://39.162.50.99:8081';
static const String baseUrl = 'https://drama-api.frostgiant.vip';
}
+2
View File
@@ -61,6 +61,8 @@ abstract final class AppColors {
static const vipCardStart = Color(0xFF21191C);
static const vipCardMiddle = Color(0xFF181719);
static const vipCardEnd = Color(0xFF141416);
static const mineVipSurfaceStart = Color(0xFF2D1519);
static const mineVipSurfaceEnd = Color(0xFF171416);
static const vipCardBorder = Color(0x2EFFFFFF);
static const vipCardRedGlow = Color(0x2EF04E4E);
static const vipCardGoldGlow = Color(0x16F5D9A0);
+9 -16
View File
@@ -274,23 +274,16 @@ abstract final class AppDimens {
static const double mineSectionGap = 12;
/// 「我的」页紧凑会员横幅尺寸。
static const double mineVipRadius = 18;
static const double mineVipPadding = 10;
static const double mineVipTitleFont = 21;
static const double mineVipSubtitleFont = 11;
static const double mineVipEmblem = 48;
static const double mineVipEmblemIcon = 28;
static const double mineVipArtWidth = 84;
static const double mineVipArtHeight = 84;
static const double mineVipArtGlow = 56;
static const double mineVipArtSurface = 44;
static const double mineVipArtIcon = 22;
static const double mineVipActionWidth = 86;
static const double mineVipBenefitFont = 10.5;
static const double mineVipBenefitSurface = 28;
static const double mineVipRadius = 14;
static const double mineVipPadding = 9;
static const double mineVipBrandFont = 20;
static const double mineVipLeadFont = 22;
static const double mineVipCrownSize = 52;
static const double mineVipActionWidth = 92;
static const double mineVipArrowSize = 16;
static const double mineVipBenefitFont = 11;
static const double mineVipBenefitGlyph = 16;
static const double mineVipBenefitRowGap = 2;
static const double mineVipButtonHeight = 26;
static const double mineVipButtonHeight = 28;
static const double mineContinueCardWidth = 96;
static const double mineContinueRowHeight = 172;
static const double mineContinueTitleFont = 13;
+3 -3
View File
@@ -1,6 +1,6 @@
{
"@@locale": "en",
"appName": "ymb",
"appName": "YMB",
"demo": "DEMO",
"homeHeadline": "Watch now",
"homeSubtitle": "Free short drama preview.",
@@ -19,7 +19,7 @@
"searchCancel": "Cancel",
"featured": "Featured",
"recommended": "Recommended",
"fruitShortsBrand": "ymb",
"fruitShortsBrand": "YMB",
"comingSoon": "Coming soon",
"authLegal": "By continuing, you agree to the Terms of Service and Privacy Policy.",
"authLegalLead": "By continuing, you agree to the",
@@ -416,7 +416,7 @@
"continueWatchingHeading": "CONTINUE WATCHING",
"preferencesHeading": "PREFERENCES",
"brandMark": "YMB",
"shareFooter": "ymb",
"shareFooter": "YMB",
"shortsTab": "Shorts",
"myListTab": "My List",
"watchFull": "Watch Full",
+3 -3
View File
@@ -1,6 +1,6 @@
{
"@@locale": "id",
"appName": "ymb",
"appName": "YMB",
"demo": "Demo",
"homeHeadline": "Tonton sekarang",
"homeSubtitle": "Pratinjau drama pendek gratis.",
@@ -19,7 +19,7 @@
"searchCancel": "Batal",
"featured": "Unggulan",
"recommended": "Rekomendasi",
"fruitShortsBrand": "ymb",
"fruitShortsBrand": "YMB",
"comingSoon": "Segera hadir",
"authLegal": "Dengan melanjutkan, Anda menyetujui Ketentuan Layanan dan Kebijakan Privasi.",
"authLegalLead": "Dengan melanjutkan, Anda menyetujui",
@@ -390,7 +390,7 @@
"continueWatchingHeading": "LANJUT TONTON",
"preferencesHeading": "PREFERENSI",
"brandMark": "YMB",
"shareFooter": "ymb",
"shareFooter": "YMB",
"shortsTab": "Drama Pendek",
"myListTab": "Daftar Saya",
"watchFull": "Tonton Penuh",
+3 -3
View File
@@ -103,7 +103,7 @@ abstract class AppLocalizations {
/// No description provided for @appName.
///
/// In en, this message translates to:
/// **'ymb'**
/// **'YMB'**
String get appName;
/// No description provided for @demo.
@@ -217,7 +217,7 @@ abstract class AppLocalizations {
/// No description provided for @fruitShortsBrand.
///
/// In en, this message translates to:
/// **'ymb'**
/// **'YMB'**
String get fruitShortsBrand;
/// No description provided for @comingSoon.
@@ -1645,7 +1645,7 @@ abstract class AppLocalizations {
/// No description provided for @shareFooter.
///
/// In en, this message translates to:
/// **'ymb'**
/// **'YMB'**
String get shareFooter;
/// No description provided for @shortsTab.
+3 -3
View File
@@ -9,7 +9,7 @@ class AppLocalizationsEn extends AppLocalizations {
AppLocalizationsEn([String locale = 'en']) : super(locale);
@override
String get appName => 'ymb';
String get appName => 'YMB';
@override
String get demo => 'DEMO';
@@ -67,7 +67,7 @@ class AppLocalizationsEn extends AppLocalizations {
String get recommended => 'Recommended';
@override
String get fruitShortsBrand => 'ymb';
String get fruitShortsBrand => 'YMB';
@override
String get comingSoon => 'Coming soon';
@@ -842,7 +842,7 @@ class AppLocalizationsEn extends AppLocalizations {
String get brandMark => 'YMB';
@override
String get shareFooter => 'ymb';
String get shareFooter => 'YMB';
@override
String get shortsTab => 'Shorts';
+3 -3
View File
@@ -9,7 +9,7 @@ class AppLocalizationsId extends AppLocalizations {
AppLocalizationsId([String locale = 'id']) : super(locale);
@override
String get appName => 'ymb';
String get appName => 'YMB';
@override
String get demo => 'Demo';
@@ -67,7 +67,7 @@ class AppLocalizationsId extends AppLocalizations {
String get recommended => 'Rekomendasi';
@override
String get fruitShortsBrand => 'ymb';
String get fruitShortsBrand => 'YMB';
@override
String get comingSoon => 'Segera hadir';
@@ -845,7 +845,7 @@ class AppLocalizationsId extends AppLocalizations {
String get brandMark => 'YMB';
@override
String get shareFooter => 'ymb';
String get shareFooter => 'YMB';
@override
String get shortsTab => 'Drama Pendek';
+3 -3
View File
@@ -9,7 +9,7 @@ class AppLocalizationsZh extends AppLocalizations {
AppLocalizationsZh([String locale = 'zh']) : super(locale);
@override
String get appName => 'ymb';
String get appName => 'YMB';
@override
String get demo => '演示';
@@ -66,7 +66,7 @@ class AppLocalizationsZh extends AppLocalizations {
String get recommended => '推荐';
@override
String get fruitShortsBrand => 'ymb';
String get fruitShortsBrand => 'YMB';
@override
String get comingSoon => '即将上线';
@@ -832,7 +832,7 @@ class AppLocalizationsZh extends AppLocalizations {
String get brandMark => 'YMB';
@override
String get shareFooter => 'ymb';
String get shareFooter => 'YMB';
@override
String get shortsTab => '短剧';
+3 -3
View File
@@ -1,6 +1,6 @@
{
"@@locale": "zh",
"appName": "ymb",
"appName": "YMB",
"demo": "演示",
"homeHeadline": "即刻观看",
"homeSubtitle": "免费短剧预览。",
@@ -19,7 +19,7 @@
"searchCancel": "取消",
"featured": "精选",
"recommended": "推荐",
"fruitShortsBrand": "ymb",
"fruitShortsBrand": "YMB",
"comingSoon": "即将上线",
"authLegal": "继续即代表同意《用户协议》与《隐私政策》",
"authLegalLead": "继续即代表同意",
@@ -352,7 +352,7 @@
"continueWatchingHeading": "继续观看",
"preferencesHeading": "偏好设置",
"brandMark": "YMB",
"shareFooter": "ymb",
"shareFooter": "YMB",
"shortsTab": "短剧",
"myListTab": "片单",
"watchFull": "看全集",
+70 -143
View File
@@ -6,11 +6,12 @@ import '../../../core/theme/app_colors.dart';
import '../../../core/theme/app_dimens.dart';
import '../../../core/widgets/app_press_scale.dart';
import '../../../l10n/app_localizations.dart';
import 'mine_stat_icon.dart';
const double _vipMaxTextScale = 1.15;
const double _vipGradientMiddleStop = 0.62;
const double _vipGlowRadius = 0.9;
const double _vipButtonLetterSpacing = 0.2;
const double _vipLabelLetterSpacing = 1.2;
const double _vipGlowRadius = 0.85;
/// 「我的」页 VIP 会员卡:主视觉、权益横排与开通入口。
class MineVipBanner extends StatelessWidget {
@@ -38,7 +39,7 @@ class MineVipBanner extends StatelessWidget {
const Positioned.fill(child: _VipAmbientGlow()),
Padding(
padding: const EdgeInsets.all(AppDimens.mineVipPadding),
child: _VipContent(l10n: l10n, onOpen: onOpen),
child: _VipContent(l10n: l10n),
),
],
),
@@ -54,30 +55,17 @@ class MineVipBanner extends StatelessWidget {
gradient: const LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: [
AppColors.vipCardStart,
AppColors.vipCardMiddle,
AppColors.vipCardEnd,
],
stops: [0, _vipGradientMiddleStop, 1],
colors: [AppColors.mineVipSurfaceStart, AppColors.mineVipSurfaceEnd],
),
borderRadius: BorderRadius.circular(AppDimens.mineVipRadius),
boxShadow: const [
BoxShadow(
color: AppColors.shadowSoft,
blurRadius: AppDimens.spaceLg,
offset: Offset(0, AppDimens.spaceSm),
),
],
);
}
}
class _VipContent extends StatelessWidget {
const _VipContent({required this.l10n, required this.onOpen});
const _VipContent({required this.l10n});
final AppLocalizations l10n;
final VoidCallback onOpen;
@override
Widget build(BuildContext context) {
@@ -87,11 +75,17 @@ class _VipContent extends StatelessWidget {
Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Expanded(
child: _VipCopy(l10n: l10n, onOpen: onOpen),
),
Expanded(child: _VipCopy(l10n: l10n)),
const SizedBox(width: AppDimens.spaceSm),
const _VipArt(),
Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
const _VipCrown(),
const SizedBox(height: AppDimens.spaceXs),
_VipOpenButton(label: l10n.vipOpenNow),
],
),
],
),
const SizedBox(height: AppDimens.spaceXs),
@@ -102,10 +96,9 @@ class _VipContent extends StatelessWidget {
}
class _VipCopy extends StatelessWidget {
const _VipCopy({required this.l10n, required this.onOpen});
const _VipCopy({required this.l10n});
final AppLocalizations l10n;
final VoidCallback onOpen;
@override
Widget build(BuildContext context) {
@@ -115,70 +108,65 @@ class _VipCopy extends StatelessWidget {
children: [
Text(
l10n.vipBrandName,
key: const Key('mine-vip-brand'),
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: const TextStyle(
color: AppColors.vipCardText,
fontSize: AppDimens.mineVipTitleFont,
color: AppColors.primary,
fontSize: AppDimens.mineVipBrandFont,
fontWeight: FontWeight.w800,
letterSpacing: 1.0,
letterSpacing: _vipLabelLetterSpacing,
),
),
const SizedBox(height: AppDimens.spaceXs),
Text(
l10n.mineVipSubtitle,
maxLines: 1,
l10n.vipBenefitFree,
key: const Key('mine-vip-benefit-0'),
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: const TextStyle(
color: AppColors.vipCardMuted,
fontSize: AppDimens.mineVipSubtitleFont,
height: 1.3,
color: AppColors.vipCardText,
fontSize: AppDimens.mineVipLeadFont,
fontWeight: FontWeight.w800,
height: 1.15,
),
),
const SizedBox(height: AppDimens.spaceXs),
_VipOpenButton(label: l10n.vipOpenNow, onOpen: onOpen),
],
);
}
}
class _VipArt extends StatelessWidget {
const _VipArt();
class _VipCrown extends StatelessWidget {
const _VipCrown();
@override
Widget build(BuildContext context) {
return SizedBox(
key: const Key('mine-vip-art'),
width: AppDimens.mineVipArtWidth,
height: AppDimens.mineVipArtHeight,
child: Image.asset(
'assets/icon/vip_membership_badge.png',
return SizedBox.square(
key: const Key('mine-vip-emblem'),
width: AppDimens.mineVipArtWidth,
height: AppDimens.mineVipArtHeight,
fit: BoxFit.contain,
),
dimension: AppDimens.mineVipCrownSize,
child: const MineVipEmblem(),
);
}
}
class _VipOpenButton extends StatelessWidget {
const _VipOpenButton({required this.label, required this.onOpen});
const _VipOpenButton({required this.label});
final String label;
final VoidCallback onOpen;
@override
Widget build(BuildContext context) {
return SizedBox(
return Container(
key: const Key('mine-vip-open'),
width: AppDimens.mineVipActionWidth,
height: AppDimens.mineVipButtonHeight,
child: InkWell(
onTap: onOpen,
decoration: BoxDecoration(
gradient: const LinearGradient(
colors: [AppColors.vipButtonStart, AppColors.vipButtonEnd],
),
borderRadius: BorderRadius.circular(AppDimens.pillRadius),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Flexible(
child: Text(
@@ -186,8 +174,8 @@ class _VipOpenButton extends StatelessWidget {
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: const TextStyle(
color: AppColors.vipGoldStart,
fontSize: AppDimens.body,
color: AppColors.onPrimary,
fontSize: AppDimens.chipFont,
fontWeight: FontWeight.w700,
letterSpacing: _vipButtonLetterSpacing,
),
@@ -196,11 +184,27 @@ class _VipOpenButton extends StatelessWidget {
const SizedBox(width: AppDimens.spaceXs),
const Icon(
Icons.arrow_forward_rounded,
color: AppColors.vipGoldStart,
size: AppDimens.mineVipBenefitGlyph,
color: AppColors.onPrimary,
size: AppDimens.mineVipArrowSize,
),
],
),
);
}
}
class _VipAmbientGlow extends StatelessWidget {
const _VipAmbientGlow();
@override
Widget build(BuildContext context) {
return const DecoratedBox(
decoration: BoxDecoration(
gradient: RadialGradient(
center: Alignment(0.9, -0.75),
radius: _vipGlowRadius,
colors: [AppColors.vipCardRedGlow, AppColors.transparent],
),
),
);
}
@@ -213,32 +217,14 @@ class _VipBenefits extends StatelessWidget {
@override
Widget build(BuildContext context) {
final items = [
(Icons.all_inclusive_rounded, l10n.vipBenefitFree),
(Icons.block_rounded, l10n.vipBenefitNoAds),
(Icons.hd_outlined, l10n.vipBenefitHd),
(Icons.download_for_offline_outlined, l10n.vipBenefitFastCache),
];
return Column(
final items = [l10n.vipBenefitNoAds, l10n.vipBenefitHd];
return Row(
key: const Key('mine-vip-benefits'),
children: [
_row(items, 0),
const SizedBox(height: AppDimens.spaceXs),
_row(items, 2),
],
);
}
Widget _row(List<(IconData, String)> items, int start) {
return Row(
children: [
for (var index = start; index < start + 2; index++)
Expanded(
child: _VipBenefit(
itemKey: Key('mine-vip-benefit-$index'),
icon: items[index].$1,
label: items[index].$2,
),
for (var index = 0; index < items.length; index++)
_VipBenefit(
itemKey: Key('mine-vip-benefit-${index + 1}'),
label: items[index],
),
],
);
@@ -246,24 +232,16 @@ class _VipBenefits extends StatelessWidget {
}
class _VipBenefit extends StatelessWidget {
const _VipBenefit({
required this.itemKey,
required this.icon,
required this.label,
});
const _VipBenefit({required this.itemKey, required this.label});
final Key itemKey;
final IconData icon;
final String label;
@override
Widget build(BuildContext context) {
return Row(
return Padding(
key: itemKey,
children: [
_VipBenefitGlyph(icon: icon),
const SizedBox(width: AppDimens.spaceXs),
Expanded(
padding: const EdgeInsets.only(right: AppDimens.spaceMd),
child: Text(
label,
maxLines: 1,
@@ -275,57 +253,6 @@ class _VipBenefit extends StatelessWidget {
height: 1.15,
),
),
),
],
);
}
}
class _VipBenefitGlyph extends StatelessWidget {
const _VipBenefitGlyph({required this.icon});
final IconData icon;
@override
Widget build(BuildContext context) {
return Icon(
icon,
color: AppColors.vipGoldStart,
size: AppDimens.mineVipBenefitGlyph,
);
}
}
class _VipAmbientGlow extends StatelessWidget {
const _VipAmbientGlow();
@override
Widget build(BuildContext context) {
return Stack(
children: const [
Positioned.fill(
child: DecoratedBox(
decoration: BoxDecoration(
gradient: RadialGradient(
center: Alignment(0.85, -0.8),
radius: _vipGlowRadius,
colors: [AppColors.vipCardGoldGlow, AppColors.transparent],
),
),
),
),
Positioned.fill(
child: DecoratedBox(
decoration: BoxDecoration(
gradient: RadialGradient(
center: Alignment(-0.9, 1),
radius: _vipGlowRadius,
colors: [AppColors.vipCardRedGlow, AppColors.transparent],
),
),
),
),
],
);
}
}
+55 -1
View File
@@ -1,6 +1,8 @@
// Author: fruit.com.cn
// 绘制个人数据区统一的红色叠层质感图标。
import 'dart:math' as math;
import 'package:flutter/material.dart';
import '../../../core/theme/app_colors.dart';
@@ -57,10 +59,31 @@ class MineStatIcon extends StatelessWidget {
}
}
/// VIP 专用徽记,与个人数据图标共享红色叠层绘制语言。
class MineVipEmblem extends StatelessWidget {
/// 绘制会员主视觉。
const MineVipEmblem({super.key});
@override
Widget build(BuildContext context) {
return SizedBox.square(
dimension: AppDimens.mineVipCrownSize,
child: DecoratedBox(
decoration: const BoxDecoration(
gradient: RadialGradient(
colors: [AppColors.mineStatGlow, AppColors.transparent],
),
),
child: const CustomPaint(painter: _MineStatPainter(null)),
),
);
}
}
class _MineStatPainter extends CustomPainter {
const _MineStatPainter(this.type);
final MineStatIconType type;
final MineStatIconType? type;
@override
void paint(Canvas canvas, Size size) {
@@ -81,6 +104,8 @@ class _MineStatPainter extends CustomPainter {
case MineStatIconType.favorites:
_tilt(canvas, _bookmarkTilt);
_bookmark(canvas);
case null:
_vip(canvas);
}
canvas.restore();
}
@@ -159,6 +184,35 @@ class _MineStatPainter extends CustomPainter {
_reflection(canvas, reflectionStart, reflectionEnd);
}
void _vip(Canvas canvas) {
const backBounds = Rect.fromLTWH(12, 5, 32, 32);
const frontBounds = Rect.fromLTWH(4, 9, 36, 36);
const center = Offset(22, 27);
const double innerRadius = 14;
const double starOuter = 9;
const double starInner = 4;
const int points = 5;
final turn = 2 * math.pi;
final startAngle = -math.pi / 2;
_surface(canvas, Path()..addOval(backBounds), backBounds, _backGradient);
_surface(canvas, Path()..addOval(frontBounds), frontBounds, _faceGradient);
canvas.drawCircle(
center,
innerRadius,
Paint()
..color = AppColors.mineStatEdge
..style = PaintingStyle.stroke
..strokeWidth = _ringWidth,
);
final star = <Offset>[];
for (var index = 0; index < points * 2; index++) {
final angle = startAngle + turn * index / (points * 2);
final radius = index.isEven ? starOuter : starInner;
star.add(center + Offset(math.cos(angle), math.sin(angle)) * radius);
}
canvas.drawPath(_polygon(star), Paint()..color = AppColors.mineStatGlint);
}
void _surface(Canvas canvas, Path path, Rect bounds, Gradient gradient) {
canvas.save();
canvas.translate(0, _depth);
+3 -3
View File
@@ -22,7 +22,7 @@ void main() {
test('should_use_ymb_when_resolving_each_app_locale', () async {
for (final locale in AppLocalizations.supportedLocales) {
final l10n = await AppLocalizations.delegate.load(locale);
expect(l10n.appName, 'ymb');
expect(l10n.appName, 'YMB');
}
});
@@ -118,11 +118,11 @@ void main() {
final manifest = File(
'android/app/src/main/AndroidManifest.xml',
).readAsStringSync();
expect(manifest, contains('android:label="ymb"'));
expect(manifest, contains('android:label="YMB"'));
final plist = File('ios/Runner/Info.plist').readAsStringSync();
expect(
RegExp(
r'<key>CFBundleDisplayName</key>\s*<string>ymb</string>',
r'<key>CFBundleDisplayName</key>\s*<string>YMB</string>',
).hasMatch(plist),
isTrue,
);
+2 -2
View File
@@ -29,9 +29,9 @@ void main() {
for (final locale in const [Locale('en'), Locale('zh'), Locale('id')]) {
final l10n = await AppLocalizations.delegate.load(locale);
expect(l10n.appName, 'ymb', reason: '$locale appName');
expect(l10n.appName, 'YMB', reason: '$locale appName');
expect(l10n.brandMark, 'YMB', reason: '$locale brandMark');
expect(l10n.shareFooter, 'ymb', reason: '$locale shareFooter');
expect(l10n.shareFooter, 'YMB', reason: '$locale shareFooter');
expect(l10n.brandMark.toLowerCase(), isNot(contains('demo')));
expect(l10n.shareFooter.toLowerCase(), isNot(contains('demo')));
}
@@ -0,0 +1,18 @@
// Author: fruit.com.cn
// 应用环境选择测试。
import 'package:flutter/foundation.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:fruitshorts/core/config/app_config.dart';
import 'package:fruitshorts/core/config/dev_config.dart';
import 'package:fruitshorts/core/config/prod_config.dart';
void main() {
test('should_use_environment_matching_build_mode', () {
expect(AppConfig.useDevConfig, !kReleaseMode);
expect(
AppConfig.baseUrl,
kReleaseMode ? ProdConfig.baseUrl : DevConfig.baseUrl,
);
});
}
@@ -0,0 +1,37 @@
// Author: fruit.com.cn
import 'package:flutter_test/flutter_test.dart';
import 'package:fruitshorts/core/data/models/drama.dart';
import 'package:fruitshorts/core/data/models/play_ticket.dart';
const String _posterUrl = '/files/transcoded/1/poster.jpg?e=1&s=sig';
void main() {
test('should_parse_poster_url_when_home_preview_contains_it', () {
final drama = Drama.fromCardJson({
'id': '1',
'cover': '/files/drama/1.jpg',
'preview': {
'id': '11',
'number': 1,
'isFree': true,
'posterUrl': _posterUrl,
'thumbnailsUrl': '/files/transcoded/1/thumbnails/thumbnails.vtt',
},
});
expect(drama.episodes.single.posterUrl, _posterUrl);
});
test('should_parse_poster_url_when_play_ticket_contains_it', () {
final ticket = PlayTicket.fromJson({
'episodeId': '11',
'accessible': true,
'accessType': 'FREE',
'playUrl': '/files/transcoded/1/master.m3u8?e=1&s=sig',
'posterUrl': _posterUrl,
});
expect(ticket.posterUrl, _posterUrl);
});
}
+4 -1
View File
@@ -1,3 +1,6 @@
// Author: fruit.com.cn
// 验证短剧本地化文案与分享内容。
import 'package:flutter_test/flutter_test.dart';
import 'package:fruitshorts/core/data/models/drama.dart';
import 'package:fruitshorts/core/formatting/localized_content.dart';
@@ -127,7 +130,7 @@ void main() {
expect(copies, hasLength(3));
for (final copy in copies) {
expect(copy, contains('ymb'));
expect(copy, contains('YMB'));
expect(copy.split('\n'), hasLength(3));
expect(copy.split('\n').every((line) => line.isNotEmpty), isTrue);
}
+57 -12
View File
@@ -11,30 +11,42 @@ import 'package:fruitshorts/l10n/app_localizations.dart';
import 'package:fruitshorts/pages/mine/mine_types.dart';
import 'package:fruitshorts/pages/mine/widgets/mine_action_grid.dart';
import 'package:fruitshorts/pages/mine/widgets/mine_menu.dart';
import 'package:fruitshorts/pages/mine/widgets/mine_stat_icon.dart';
const _layoutTolerance = 0.1;
const _minimumVipHeight = 110.0;
const _premiumVipHeightLimit = 150.0;
const _minimumVipHeight = 95.0;
const _premiumVipHeightLimit = 120.0;
void main() {
testWidgets('should_keep_equal_visible_vip_padding_and_reduce_height', (
for (final localeTag in ['en', 'id', 'zh']) {
testWidgets('should_keep_vip_compact_when_locale_is_$localeTag', (
tester,
) async {
await _pumpLocalized(
tester,
const SizedBox(width: 342, child: MineVipBanner(onOpen: _noop)),
locale: Locale(localeTag),
);
final cardRect = tester.getRect(find.byKey(const Key('mine-vip')));
final emblemRect = tester.getRect(find.byKey(const Key('mine-vip-emblem')));
final emblem = tester.widget<Image>(
final emblemRect = tester.getRect(
find.byKey(const Key('mine-vip-emblem')),
);
expect(emblemRect.width, greaterThanOrEqualTo(52));
expect(
(emblem.image as AssetImage).assetName,
'assets/icon/vip_membership_badge.png',
find.descendant(
of: find.byKey(const Key('mine-vip-emblem')),
matching: find.byType(MineVipEmblem),
),
findsOneWidget,
);
final titleRect = tester.getRect(find.text('VIP'));
final titleRect = tester.getRect(
find.byKey(const Key('mine-vip-benefit-0')),
);
final brand = tester.widget<Text>(
find.byKey(const Key('mine-vip-brand')),
);
expect(brand.style?.fontSize, greaterThanOrEqualTo(20));
final benefitsRect = tester.getRect(
find.byKey(const Key('mine-vip-benefits')),
);
@@ -46,11 +58,44 @@ void main() {
);
expect(benefitsRect.bottom, lessThan(cardRect.bottom));
expect(emblemRect.left, greaterThan(titleRect.right));
final first = tester.getRect(find.byKey(const Key('mine-vip-benefit-0')));
final second = tester.getRect(find.byKey(const Key('mine-vip-benefit-1')));
final second = tester.getRect(
find.byKey(const Key('mine-vip-benefit-1')),
);
final third = tester.getRect(find.byKey(const Key('mine-vip-benefit-2')));
expect(first.top, second.top);
expect(third.top, greaterThan(first.top));
final open = tester.getRect(find.byKey(const Key('mine-vip-open')));
expect(titleRect.top, lessThan(second.top));
expect(second.top, third.top);
expect(find.byKey(const Key('mine-vip-benefit-3')), findsNothing);
expect(open.top, greaterThan(titleRect.top));
expect(open.height, greaterThanOrEqualTo(28));
expect(open.right, lessThanOrEqualTo(cardRect.right));
expect(
find.descendant(
of: find.byKey(const Key('mine-vip-benefits')),
matching: find.byType(Icon),
),
findsNothing,
);
expect(tester.takeException(), isNull);
});
}
testWidgets('should_keep_indonesian_vip_readable_when_width_is_narrow', (
tester,
) async {
await _pumpLocalized(
tester,
const SizedBox(width: 292, child: MineVipBanner(onOpen: _noop)),
locale: const Locale('id'),
);
final title = tester.widget<Text>(
find.byKey(const Key('mine-vip-benefit-0')),
);
final cardRect = tester.getRect(find.byKey(const Key('mine-vip')));
expect(title.maxLines, 2);
expect(cardRect.height, lessThan(125));
expect(tester.takeException(), isNull);
});
for (final localeTag in ['en', 'id']) {
+13 -26
View File
@@ -169,14 +169,13 @@ void main() {
final vip = tester.widget<Container>(find.byKey(const Key('mine-vip')));
final vipDecoration = vip.decoration! as BoxDecoration;
expect((vipDecoration.gradient! as LinearGradient).colors, const [
AppColors.vipCardStart,
AppColors.vipCardMiddle,
AppColors.vipCardEnd,
AppColors.mineVipSurfaceStart,
AppColors.mineVipSurfaceEnd,
]);
expect(vipDecoration.border, isNull);
expect(vipDecoration.boxShadow, isNotEmpty);
expect(vipDecoration.boxShadow, isNull);
// 卡片高度由内容撑开,身份头部与底部 CTA 都保留安全内边距。
// 核心权益在主行,辅助权益保留为轻量文字。
final vipRect = tester.getRect(find.byKey(const Key('mine-vip')));
final emblemRect = tester.getRect(find.byKey(const Key('mine-vip-emblem')));
final benefitsRect = tester.getRect(
@@ -191,28 +190,16 @@ void main() {
tester.getSize(find.byKey(const Key('mine-vip-open'))).height,
greaterThanOrEqualTo(AppDimens.mineVipButtonHeight),
);
const benefitKeys = [
Key('mine-vip-benefit-0'),
Key('mine-vip-benefit-1'),
Key('mine-vip-benefit-2'),
Key('mine-vip-benefit-3'),
];
final benefitTops = benefitKeys
.map((key) => tester.getTopLeft(find.byKey(key)))
final leadBenefit = tester.getRect(
find.byKey(const Key('mine-vip-benefit-0')),
);
final detailBenefits = [1, 2]
.map(
(index) => tester.getRect(find.byKey(Key('mine-vip-benefit-$index'))),
)
.toList();
expect(
benefitTops.take(2).map((position) => position.dy).toSet(),
hasLength(1),
);
expect(
benefitTops.skip(2).map((position) => position.dy).toSet(),
hasLength(1),
);
expect(benefitTops[2].dy, greaterThan(benefitTops[0].dy));
expect(
benefitTops.take(2).map((position) => position.dx).toSet(),
hasLength(2),
);
expect(detailBenefits.every((rect) => rect.top > leadBenefit.top), isTrue);
expect(find.byKey(const Key('mine-vip-benefit-3')), findsNothing);
final order = [
tester.getTopLeft(find.byKey(const Key('mine-user-row'))).dy,
-7
View File
@@ -69,13 +69,6 @@ void main() {
expect(tops.toSet(), hasLength(1));
expect(tester.takeException(), isNull);
if (_captureEnabled) {
final context = tester.element(find.byKey(const Key('mine-vip-emblem')));
await tester.runAsync(() async {
await precacheImage(
const AssetImage('assets/icon/vip_membership_badge.png'),
context,
);
});
await tester.pumpAndSettle();
await saveWidgetCapture(tester, _captureKey, _capturePath);
}
+1 -1
View File
@@ -1170,7 +1170,7 @@ void main() {
tester
.widget<Material>(find.byKey(const Key('player-episodes-pill')))
.color,
AppColors.textPrimary.withValues(alpha: 0.14),
AppColors.glassSurface,
);
expect(
tester
+1 -1
View File
@@ -265,7 +265,7 @@ void main() {
await tester.tap(find.byKey(const Key('player-rail-share')));
await tester.pumpAndSettle();
expect(sharedText, contains('City Lights & Velvet Nights'));
expect(sharedText, contains('ymb'));
expect(sharedText, contains('YMB'));
expect(tester.takeException(), isNull);
});