style(mine): 收紧 VIP 入口并统一徽记视觉
This commit is contained in:
1 parent
fe0e77775e
commit
52e1883862
8 files changed
+207
-206
No files matched your search
@@ -61,6 +61,8 @@ abstract final class AppColors {
|
|||||||
static const vipCardStart = Color(0xFF21191C);
|
static const vipCardStart = Color(0xFF21191C);
|
||||||
static const vipCardMiddle = Color(0xFF181719);
|
static const vipCardMiddle = Color(0xFF181719);
|
||||||
static const vipCardEnd = Color(0xFF141416);
|
static const vipCardEnd = Color(0xFF141416);
|
||||||
|
static const mineVipSurfaceStart = Color(0xFF2D1519);
|
||||||
|
static const mineVipSurfaceEnd = Color(0xFF171416);
|
||||||
static const vipCardBorder = Color(0x2EFFFFFF);
|
static const vipCardBorder = Color(0x2EFFFFFF);
|
||||||
static const vipCardRedGlow = Color(0x2EF04E4E);
|
static const vipCardRedGlow = Color(0x2EF04E4E);
|
||||||
static const vipCardGoldGlow = Color(0x16F5D9A0);
|
static const vipCardGoldGlow = Color(0x16F5D9A0);
|
||||||
|
|||||||
@@ -274,23 +274,16 @@ abstract final class AppDimens {
|
|||||||
static const double mineSectionGap = 12;
|
static const double mineSectionGap = 12;
|
||||||
|
|
||||||
/// 「我的」页紧凑会员横幅尺寸。
|
/// 「我的」页紧凑会员横幅尺寸。
|
||||||
static const double mineVipRadius = 18;
|
static const double mineVipRadius = 14;
|
||||||
static const double mineVipPadding = 10;
|
static const double mineVipPadding = 9;
|
||||||
static const double mineVipTitleFont = 21;
|
static const double mineVipBrandFont = 20;
|
||||||
static const double mineVipSubtitleFont = 11;
|
static const double mineVipLeadFont = 22;
|
||||||
static const double mineVipEmblem = 48;
|
static const double mineVipCrownSize = 52;
|
||||||
static const double mineVipEmblemIcon = 28;
|
static const double mineVipActionWidth = 92;
|
||||||
static const double mineVipArtWidth = 84;
|
static const double mineVipArrowSize = 16;
|
||||||
static const double mineVipArtHeight = 84;
|
static const double mineVipBenefitFont = 11;
|
||||||
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 mineVipBenefitGlyph = 16;
|
static const double mineVipBenefitGlyph = 16;
|
||||||
static const double mineVipBenefitRowGap = 2;
|
static const double mineVipButtonHeight = 28;
|
||||||
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;
|
||||||
|
|||||||
@@ -6,11 +6,12 @@ import '../../../core/theme/app_colors.dart';
|
|||||||
import '../../../core/theme/app_dimens.dart';
|
import '../../../core/theme/app_dimens.dart';
|
||||||
import '../../../core/widgets/app_press_scale.dart';
|
import '../../../core/widgets/app_press_scale.dart';
|
||||||
import '../../../l10n/app_localizations.dart';
|
import '../../../l10n/app_localizations.dart';
|
||||||
|
import 'mine_stat_icon.dart';
|
||||||
|
|
||||||
const double _vipMaxTextScale = 1.15;
|
const double _vipMaxTextScale = 1.15;
|
||||||
const double _vipGradientMiddleStop = 0.62;
|
|
||||||
const double _vipGlowRadius = 0.9;
|
|
||||||
const double _vipButtonLetterSpacing = 0.2;
|
const double _vipButtonLetterSpacing = 0.2;
|
||||||
|
const double _vipLabelLetterSpacing = 1.2;
|
||||||
|
const double _vipGlowRadius = 0.85;
|
||||||
|
|
||||||
/// 「我的」页 VIP 会员卡:主视觉、权益横排与开通入口。
|
/// 「我的」页 VIP 会员卡:主视觉、权益横排与开通入口。
|
||||||
class MineVipBanner extends StatelessWidget {
|
class MineVipBanner extends StatelessWidget {
|
||||||
@@ -38,7 +39,7 @@ class MineVipBanner extends StatelessWidget {
|
|||||||
const Positioned.fill(child: _VipAmbientGlow()),
|
const Positioned.fill(child: _VipAmbientGlow()),
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.all(AppDimens.mineVipPadding),
|
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(
|
gradient: const LinearGradient(
|
||||||
begin: Alignment.topLeft,
|
begin: Alignment.topLeft,
|
||||||
end: Alignment.bottomRight,
|
end: Alignment.bottomRight,
|
||||||
colors: [
|
colors: [AppColors.mineVipSurfaceStart, AppColors.mineVipSurfaceEnd],
|
||||||
AppColors.vipCardStart,
|
|
||||||
AppColors.vipCardMiddle,
|
|
||||||
AppColors.vipCardEnd,
|
|
||||||
],
|
|
||||||
stops: [0, _vipGradientMiddleStop, 1],
|
|
||||||
),
|
),
|
||||||
borderRadius: BorderRadius.circular(AppDimens.mineVipRadius),
|
borderRadius: BorderRadius.circular(AppDimens.mineVipRadius),
|
||||||
boxShadow: const [
|
|
||||||
BoxShadow(
|
|
||||||
color: AppColors.shadowSoft,
|
|
||||||
blurRadius: AppDimens.spaceLg,
|
|
||||||
offset: Offset(0, AppDimens.spaceSm),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class _VipContent extends StatelessWidget {
|
class _VipContent extends StatelessWidget {
|
||||||
const _VipContent({required this.l10n, required this.onOpen});
|
const _VipContent({required this.l10n});
|
||||||
|
|
||||||
final AppLocalizations l10n;
|
final AppLocalizations l10n;
|
||||||
final VoidCallback onOpen;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@@ -87,11 +75,17 @@ class _VipContent extends StatelessWidget {
|
|||||||
Row(
|
Row(
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(child: _VipCopy(l10n: l10n)),
|
||||||
child: _VipCopy(l10n: l10n, onOpen: onOpen),
|
|
||||||
),
|
|
||||||
const SizedBox(width: AppDimens.spaceSm),
|
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),
|
const SizedBox(height: AppDimens.spaceXs),
|
||||||
@@ -102,10 +96,9 @@ class _VipContent extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _VipCopy extends StatelessWidget {
|
class _VipCopy extends StatelessWidget {
|
||||||
const _VipCopy({required this.l10n, required this.onOpen});
|
const _VipCopy({required this.l10n});
|
||||||
|
|
||||||
final AppLocalizations l10n;
|
final AppLocalizations l10n;
|
||||||
final VoidCallback onOpen;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@@ -115,70 +108,65 @@ class _VipCopy extends StatelessWidget {
|
|||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
l10n.vipBrandName,
|
l10n.vipBrandName,
|
||||||
|
key: const Key('mine-vip-brand'),
|
||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
color: AppColors.vipCardText,
|
color: AppColors.primary,
|
||||||
fontSize: AppDimens.mineVipTitleFont,
|
fontSize: AppDimens.mineVipBrandFont,
|
||||||
fontWeight: FontWeight.w800,
|
fontWeight: FontWeight.w800,
|
||||||
letterSpacing: 1.0,
|
letterSpacing: _vipLabelLetterSpacing,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: AppDimens.spaceXs),
|
const SizedBox(height: AppDimens.spaceXs),
|
||||||
Text(
|
Text(
|
||||||
l10n.mineVipSubtitle,
|
l10n.vipBenefitFree,
|
||||||
maxLines: 1,
|
key: const Key('mine-vip-benefit-0'),
|
||||||
|
maxLines: 2,
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
color: AppColors.vipCardMuted,
|
color: AppColors.vipCardText,
|
||||||
fontSize: AppDimens.mineVipSubtitleFont,
|
fontSize: AppDimens.mineVipLeadFont,
|
||||||
height: 1.3,
|
fontWeight: FontWeight.w800,
|
||||||
|
height: 1.15,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: AppDimens.spaceXs),
|
|
||||||
_VipOpenButton(label: l10n.vipOpenNow, onOpen: onOpen),
|
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class _VipArt extends StatelessWidget {
|
class _VipCrown extends StatelessWidget {
|
||||||
const _VipArt();
|
const _VipCrown();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return SizedBox(
|
return SizedBox.square(
|
||||||
key: const Key('mine-vip-art'),
|
|
||||||
width: AppDimens.mineVipArtWidth,
|
|
||||||
height: AppDimens.mineVipArtHeight,
|
|
||||||
child: Image.asset(
|
|
||||||
'assets/icon/vip_membership_badge.png',
|
|
||||||
key: const Key('mine-vip-emblem'),
|
key: const Key('mine-vip-emblem'),
|
||||||
width: AppDimens.mineVipArtWidth,
|
dimension: AppDimens.mineVipCrownSize,
|
||||||
height: AppDimens.mineVipArtHeight,
|
child: const MineVipEmblem(),
|
||||||
fit: BoxFit.contain,
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class _VipOpenButton extends StatelessWidget {
|
class _VipOpenButton extends StatelessWidget {
|
||||||
const _VipOpenButton({required this.label, required this.onOpen});
|
const _VipOpenButton({required this.label});
|
||||||
|
|
||||||
final String label;
|
final String label;
|
||||||
final VoidCallback onOpen;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return SizedBox(
|
return Container(
|
||||||
key: const Key('mine-vip-open'),
|
key: const Key('mine-vip-open'),
|
||||||
width: AppDimens.mineVipActionWidth,
|
width: AppDimens.mineVipActionWidth,
|
||||||
height: AppDimens.mineVipButtonHeight,
|
height: AppDimens.mineVipButtonHeight,
|
||||||
child: InkWell(
|
decoration: BoxDecoration(
|
||||||
onTap: onOpen,
|
gradient: const LinearGradient(
|
||||||
|
colors: [AppColors.vipButtonStart, AppColors.vipButtonEnd],
|
||||||
|
),
|
||||||
borderRadius: BorderRadius.circular(AppDimens.pillRadius),
|
borderRadius: BorderRadius.circular(AppDimens.pillRadius),
|
||||||
|
),
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
Flexible(
|
Flexible(
|
||||||
child: Text(
|
child: Text(
|
||||||
@@ -186,8 +174,8 @@ class _VipOpenButton extends StatelessWidget {
|
|||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
color: AppColors.vipGoldStart,
|
color: AppColors.onPrimary,
|
||||||
fontSize: AppDimens.body,
|
fontSize: AppDimens.chipFont,
|
||||||
fontWeight: FontWeight.w700,
|
fontWeight: FontWeight.w700,
|
||||||
letterSpacing: _vipButtonLetterSpacing,
|
letterSpacing: _vipButtonLetterSpacing,
|
||||||
),
|
),
|
||||||
@@ -196,11 +184,27 @@ class _VipOpenButton extends StatelessWidget {
|
|||||||
const SizedBox(width: AppDimens.spaceXs),
|
const SizedBox(width: AppDimens.spaceXs),
|
||||||
const Icon(
|
const Icon(
|
||||||
Icons.arrow_forward_rounded,
|
Icons.arrow_forward_rounded,
|
||||||
color: AppColors.vipGoldStart,
|
color: AppColors.onPrimary,
|
||||||
size: AppDimens.mineVipBenefitGlyph,
|
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
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final items = [
|
final items = [l10n.vipBenefitNoAds, l10n.vipBenefitHd];
|
||||||
(Icons.all_inclusive_rounded, l10n.vipBenefitFree),
|
return Row(
|
||||||
(Icons.block_rounded, l10n.vipBenefitNoAds),
|
|
||||||
(Icons.hd_outlined, l10n.vipBenefitHd),
|
|
||||||
(Icons.download_for_offline_outlined, l10n.vipBenefitFastCache),
|
|
||||||
];
|
|
||||||
return Column(
|
|
||||||
key: const Key('mine-vip-benefits'),
|
key: const Key('mine-vip-benefits'),
|
||||||
children: [
|
children: [
|
||||||
_row(items, 0),
|
for (var index = 0; index < items.length; index++)
|
||||||
const SizedBox(height: AppDimens.spaceXs),
|
_VipBenefit(
|
||||||
_row(items, 2),
|
itemKey: Key('mine-vip-benefit-${index + 1}'),
|
||||||
],
|
label: items[index],
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
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,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
@@ -246,24 +232,16 @@ class _VipBenefits extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _VipBenefit extends StatelessWidget {
|
class _VipBenefit extends StatelessWidget {
|
||||||
const _VipBenefit({
|
const _VipBenefit({required this.itemKey, required this.label});
|
||||||
required this.itemKey,
|
|
||||||
required this.icon,
|
|
||||||
required this.label,
|
|
||||||
});
|
|
||||||
|
|
||||||
final Key itemKey;
|
final Key itemKey;
|
||||||
final IconData icon;
|
|
||||||
final String label;
|
final String label;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Row(
|
return Padding(
|
||||||
key: itemKey,
|
key: itemKey,
|
||||||
children: [
|
padding: const EdgeInsets.only(right: AppDimens.spaceMd),
|
||||||
_VipBenefitGlyph(icon: icon),
|
|
||||||
const SizedBox(width: AppDimens.spaceXs),
|
|
||||||
Expanded(
|
|
||||||
child: Text(
|
child: Text(
|
||||||
label,
|
label,
|
||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
@@ -275,57 +253,6 @@ class _VipBenefit extends StatelessWidget {
|
|||||||
height: 1.15,
|
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],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
// Author: fruit.com.cn
|
// Author: fruit.com.cn
|
||||||
// 绘制个人数据区统一的红色叠层质感图标。
|
// 绘制个人数据区统一的红色叠层质感图标。
|
||||||
|
|
||||||
|
import 'dart:math' as math;
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import '../../../core/theme/app_colors.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 {
|
class _MineStatPainter extends CustomPainter {
|
||||||
const _MineStatPainter(this.type);
|
const _MineStatPainter(this.type);
|
||||||
|
|
||||||
final MineStatIconType type;
|
final MineStatIconType? type;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void paint(Canvas canvas, Size size) {
|
void paint(Canvas canvas, Size size) {
|
||||||
@@ -81,6 +104,8 @@ class _MineStatPainter extends CustomPainter {
|
|||||||
case MineStatIconType.favorites:
|
case MineStatIconType.favorites:
|
||||||
_tilt(canvas, _bookmarkTilt);
|
_tilt(canvas, _bookmarkTilt);
|
||||||
_bookmark(canvas);
|
_bookmark(canvas);
|
||||||
|
case null:
|
||||||
|
_vip(canvas);
|
||||||
}
|
}
|
||||||
canvas.restore();
|
canvas.restore();
|
||||||
}
|
}
|
||||||
@@ -159,6 +184,35 @@ class _MineStatPainter extends CustomPainter {
|
|||||||
_reflection(canvas, reflectionStart, reflectionEnd);
|
_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) {
|
void _surface(Canvas canvas, Path path, Rect bounds, Gradient gradient) {
|
||||||
canvas.save();
|
canvas.save();
|
||||||
canvas.translate(0, _depth);
|
canvas.translate(0, _depth);
|
||||||
|
|||||||
@@ -11,30 +11,42 @@ import 'package:fruitshorts/l10n/app_localizations.dart';
|
|||||||
import 'package:fruitshorts/pages/mine/mine_types.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_action_grid.dart';
|
||||||
import 'package:fruitshorts/pages/mine/widgets/mine_menu.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 _layoutTolerance = 0.1;
|
||||||
const _minimumVipHeight = 110.0;
|
const _minimumVipHeight = 95.0;
|
||||||
const _premiumVipHeightLimit = 150.0;
|
const _premiumVipHeightLimit = 120.0;
|
||||||
|
|
||||||
void main() {
|
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,
|
tester,
|
||||||
) async {
|
) async {
|
||||||
await _pumpLocalized(
|
await _pumpLocalized(
|
||||||
tester,
|
tester,
|
||||||
const SizedBox(width: 342, child: MineVipBanner(onOpen: _noop)),
|
const SizedBox(width: 342, child: MineVipBanner(onOpen: _noop)),
|
||||||
|
locale: Locale(localeTag),
|
||||||
);
|
);
|
||||||
|
|
||||||
final cardRect = tester.getRect(find.byKey(const Key('mine-vip')));
|
final cardRect = tester.getRect(find.byKey(const Key('mine-vip')));
|
||||||
final emblemRect = tester.getRect(find.byKey(const Key('mine-vip-emblem')));
|
final emblemRect = tester.getRect(
|
||||||
final emblem = tester.widget<Image>(
|
|
||||||
find.byKey(const Key('mine-vip-emblem')),
|
find.byKey(const Key('mine-vip-emblem')),
|
||||||
);
|
);
|
||||||
|
expect(emblemRect.width, greaterThanOrEqualTo(52));
|
||||||
expect(
|
expect(
|
||||||
(emblem.image as AssetImage).assetName,
|
find.descendant(
|
||||||
'assets/icon/vip_membership_badge.png',
|
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(
|
final benefitsRect = tester.getRect(
|
||||||
find.byKey(const Key('mine-vip-benefits')),
|
find.byKey(const Key('mine-vip-benefits')),
|
||||||
);
|
);
|
||||||
@@ -46,11 +58,44 @@ void main() {
|
|||||||
);
|
);
|
||||||
expect(benefitsRect.bottom, lessThan(cardRect.bottom));
|
expect(benefitsRect.bottom, lessThan(cardRect.bottom));
|
||||||
expect(emblemRect.left, greaterThan(titleRect.right));
|
expect(emblemRect.left, greaterThan(titleRect.right));
|
||||||
final first = tester.getRect(find.byKey(const Key('mine-vip-benefit-0')));
|
final second = tester.getRect(
|
||||||
final second = tester.getRect(find.byKey(const Key('mine-vip-benefit-1')));
|
find.byKey(const Key('mine-vip-benefit-1')),
|
||||||
|
);
|
||||||
final third = tester.getRect(find.byKey(const Key('mine-vip-benefit-2')));
|
final third = tester.getRect(find.byKey(const Key('mine-vip-benefit-2')));
|
||||||
expect(first.top, second.top);
|
final open = tester.getRect(find.byKey(const Key('mine-vip-open')));
|
||||||
expect(third.top, greaterThan(first.top));
|
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']) {
|
for (final localeTag in ['en', 'id']) {
|
||||||
|
|||||||
@@ -169,14 +169,13 @@ void main() {
|
|||||||
final vip = tester.widget<Container>(find.byKey(const Key('mine-vip')));
|
final vip = tester.widget<Container>(find.byKey(const Key('mine-vip')));
|
||||||
final vipDecoration = vip.decoration! as BoxDecoration;
|
final vipDecoration = vip.decoration! as BoxDecoration;
|
||||||
expect((vipDecoration.gradient! as LinearGradient).colors, const [
|
expect((vipDecoration.gradient! as LinearGradient).colors, const [
|
||||||
AppColors.vipCardStart,
|
AppColors.mineVipSurfaceStart,
|
||||||
AppColors.vipCardMiddle,
|
AppColors.mineVipSurfaceEnd,
|
||||||
AppColors.vipCardEnd,
|
|
||||||
]);
|
]);
|
||||||
expect(vipDecoration.border, isNull);
|
expect(vipDecoration.border, isNull);
|
||||||
expect(vipDecoration.boxShadow, isNotEmpty);
|
expect(vipDecoration.boxShadow, isNull);
|
||||||
|
|
||||||
// 卡片高度由内容撑开,身份头部与底部 CTA 都保留安全内边距。
|
// 核心权益在主行,辅助权益保留为轻量文字。
|
||||||
final vipRect = tester.getRect(find.byKey(const Key('mine-vip')));
|
final vipRect = tester.getRect(find.byKey(const Key('mine-vip')));
|
||||||
final emblemRect = tester.getRect(find.byKey(const Key('mine-vip-emblem')));
|
final emblemRect = tester.getRect(find.byKey(const Key('mine-vip-emblem')));
|
||||||
final benefitsRect = tester.getRect(
|
final benefitsRect = tester.getRect(
|
||||||
@@ -191,28 +190,16 @@ void main() {
|
|||||||
tester.getSize(find.byKey(const Key('mine-vip-open'))).height,
|
tester.getSize(find.byKey(const Key('mine-vip-open'))).height,
|
||||||
greaterThanOrEqualTo(AppDimens.mineVipButtonHeight),
|
greaterThanOrEqualTo(AppDimens.mineVipButtonHeight),
|
||||||
);
|
);
|
||||||
const benefitKeys = [
|
final leadBenefit = tester.getRect(
|
||||||
Key('mine-vip-benefit-0'),
|
find.byKey(const Key('mine-vip-benefit-0')),
|
||||||
Key('mine-vip-benefit-1'),
|
);
|
||||||
Key('mine-vip-benefit-2'),
|
final detailBenefits = [1, 2]
|
||||||
Key('mine-vip-benefit-3'),
|
.map(
|
||||||
];
|
(index) => tester.getRect(find.byKey(Key('mine-vip-benefit-$index'))),
|
||||||
final benefitTops = benefitKeys
|
)
|
||||||
.map((key) => tester.getTopLeft(find.byKey(key)))
|
|
||||||
.toList();
|
.toList();
|
||||||
expect(
|
expect(detailBenefits.every((rect) => rect.top > leadBenefit.top), isTrue);
|
||||||
benefitTops.take(2).map((position) => position.dy).toSet(),
|
expect(find.byKey(const Key('mine-vip-benefit-3')), findsNothing);
|
||||||
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),
|
|
||||||
);
|
|
||||||
|
|
||||||
final order = [
|
final order = [
|
||||||
tester.getTopLeft(find.byKey(const Key('mine-user-row'))).dy,
|
tester.getTopLeft(find.byKey(const Key('mine-user-row'))).dy,
|
||||||
|
|||||||
@@ -69,13 +69,6 @@ void main() {
|
|||||||
expect(tops.toSet(), hasLength(1));
|
expect(tops.toSet(), hasLength(1));
|
||||||
expect(tester.takeException(), isNull);
|
expect(tester.takeException(), isNull);
|
||||||
if (_captureEnabled) {
|
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 tester.pumpAndSettle();
|
||||||
await saveWidgetCapture(tester, _captureKey, _capturePath);
|
await saveWidgetCapture(tester, _captureKey, _capturePath);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1170,7 +1170,7 @@ void main() {
|
|||||||
tester
|
tester
|
||||||
.widget<Material>(find.byKey(const Key('player-episodes-pill')))
|
.widget<Material>(find.byKey(const Key('player-episodes-pill')))
|
||||||
.color,
|
.color,
|
||||||
AppColors.textPrimary.withValues(alpha: 0.14),
|
AppColors.glassSurface,
|
||||||
);
|
);
|
||||||
expect(
|
expect(
|
||||||
tester
|
tester
|
||||||
|
|||||||
Reference in new issue
Block a user