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']) {