style(mine): 收紧 VIP 入口并统一徽记视觉

This commit is contained in:
Zhou Weidong committed 2026-11-17 09:56:36 +08:00
1 parent fe0e77775e
commit 52e1883862
8 files changed
+251 -250

No files matched your search

+74 -29
View File
@@ -11,46 +11,91 @@ 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')),
);
expect(emblemRect.width, greaterThanOrEqualTo(52));
expect(
find.descendant(
of: find.byKey(const Key('mine-vip-emblem')),
matching: find.byType(MineVipEmblem),
),
findsOneWidget,
);
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')),
);
expect(cardRect.height, lessThan(_premiumVipHeightLimit));
expect(cardRect.height, greaterThanOrEqualTo(_minimumVipHeight));
expect(
emblemRect.top - cardRect.top,
greaterThanOrEqualTo(AppDimens.mineVipPadding),
);
expect(benefitsRect.bottom, lessThan(cardRect.bottom));
expect(emblemRect.left, greaterThan(titleRect.right));
final second = tester.getRect(
find.byKey(const Key('mine-vip-benefit-1')),
);
final third = tester.getRect(find.byKey(const Key('mine-vip-benefit-2')));
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: 342, child: MineVipBanner(onOpen: _noop)),
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')));
final emblemRect = tester.getRect(find.byKey(const Key('mine-vip-emblem')));
final emblem = tester.widget<Image>(
find.byKey(const Key('mine-vip-emblem')),
);
expect(
(emblem.image as AssetImage).assetName,
'assets/icon/vip_membership_badge.png',
);
final titleRect = tester.getRect(find.text('VIP'));
final benefitsRect = tester.getRect(
find.byKey(const Key('mine-vip-benefits')),
);
expect(cardRect.height, lessThan(_premiumVipHeightLimit));
expect(cardRect.height, greaterThanOrEqualTo(_minimumVipHeight));
expect(
emblemRect.top - cardRect.top,
greaterThanOrEqualTo(AppDimens.mineVipPadding),
);
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 third = tester.getRect(find.byKey(const Key('mine-vip-benefit-2')));
expect(first.top, second.top);
expect(third.top, greaterThan(first.top));
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