style(mine): 重构紧凑 VIP 会员入口

This commit is contained in:
Zhou Weidong committed 2026-11-13 17:41:47 +08:00
1 parent 9ef78ad670
commit 6ef5429a52
7 files changed
+155 -178

No files matched your search

+19 -4
View File
@@ -13,8 +13,8 @@ import 'package:fruitshorts/pages/mine/widgets/mine_action_grid.dart';
import 'package:fruitshorts/pages/mine/widgets/mine_menu.dart';
const _layoutTolerance = 0.1;
const _minimumVipHeight = 190.0;
const _previousVipPlaceholderHeight = 220.0;
const _minimumVipHeight = 110.0;
const _premiumVipHeightLimit = 150.0;
void main() {
testWidgets('should_keep_equal_visible_vip_padding_and_reduce_height', (
@@ -27,15 +27,30 @@ void main() {
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(_previousVipPlaceholderHeight));
expect(cardRect.height, lessThan(_premiumVipHeightLimit));
expect(cardRect.height, greaterThanOrEqualTo(_minimumVipHeight));
expect(
emblemRect.top - cardRect.top,
closeTo(cardRect.bottom - benefitsRect.bottom, _layoutTolerance),
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));
});
for (final localeTag in ['en', 'id']) {
+15 -7
View File
@@ -173,10 +173,10 @@ void main() {
AppColors.vipCardMiddle,
AppColors.vipCardEnd,
]);
expect(vipDecoration.border, isNotNull);
expect(vipDecoration.border, isNull);
expect(vipDecoration.boxShadow, isNotEmpty);
// 卡片高度由内容撑开,上下内边距必须一致(边框各占 1pt)。
// 卡片高度由内容撑开,身份头部与底部 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(
@@ -184,12 +184,12 @@ void main() {
);
final topInset = emblemRect.top - vipRect.top;
final bottomInset = vipRect.bottom - benefitsRect.bottom;
expect(topInset, closeTo(bottomInset, 0.01));
expect(topInset, greaterThanOrEqualTo(AppDimens.mineVipPadding));
expect(bottomInset, greaterThanOrEqualTo(AppDimens.mineVipPadding));
expect(find.byKey(const Key('mine-vip-emblem')), findsOneWidget);
expect(
tester.getSize(find.byKey(const Key('mine-vip-open'))).height,
greaterThanOrEqualTo(AppDimens.tapTarget),
greaterThanOrEqualTo(AppDimens.mineVipButtonHeight),
);
const benefitKeys = [
Key('mine-vip-benefit-0'),
@@ -200,10 +200,18 @@ void main() {
final benefitTops = benefitKeys
.map((key) => tester.getTopLeft(find.byKey(key)))
.toList();
expect(benefitTops.map((position) => position.dy).toSet(), hasLength(1));
expect(
benefitTops.map((position) => position.dx).toSet(),
hasLength(benefitKeys.length),
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),
);
final order = [
+8
View File
@@ -69,6 +69,14 @@ 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);
}
});