feat: 改造我的页渐变与图标网格

This commit is contained in:
Zhou Weidong committed 2026-10-22 21:35:14 +08:00
1 parent e70ca03c03
commit 9785a1baf3
6 files changed
+244 -179

No files matched your search

+52 -20
View File
@@ -25,7 +25,7 @@ import '../support/fake_notice_repository.dart';
import '../support/widget_player.dart';
void main() {
testWidgets('should_render_visitor_user_vip_and_seven_menu_rows', (
testWidgets('should_render_visitor_user_vip_and_seven_grid_entries', (
tester,
) async {
await _pumpApp(tester, signedIn: false);
@@ -50,6 +50,18 @@ void main() {
expect(title.style?.fontSize, AppDimens.minePageTitle);
expect(title.style?.fontWeight, FontWeight.w700);
expect(find.byKey(const Key('mine-mini-player')), findsNothing);
final surface = tester.widget<DecoratedBox>(
find.byKey(const Key('mine-page-surface')),
);
final surfaceDecoration = surface.decoration as BoxDecoration;
final background = surfaceDecoration.gradient! as LinearGradient;
expect(background.begin, Alignment.topCenter);
expect(background.end, Alignment.bottomCenter);
expect(background.colors, const [
AppColors.mineGradientTop,
AppColors.mineGradientMiddle,
AppColors.mineGradientBottom,
]);
for (final oldShortcut in const [
Key('mine-watchlist'),
Key('mine-history-shortcut'),
@@ -58,13 +70,7 @@ void main() {
expect(find.byKey(oldShortcut), findsNothing);
}
final menuRows = tester.widgetList<ListTile>(
find.descendant(
of: find.byKey(const Key('mine-menu')),
matching: find.byType(ListTile),
),
);
expect(menuRows.map((row) => row.key), const [
const entryKeys = [
Key('mine-wallet'),
Key('mine-downloads'),
Key('mine-history'),
@@ -72,32 +78,59 @@ void main() {
Key('mine-help'),
Key('mine-language'),
Key('mine-settings'),
]);
expect(menuRows, hasLength(7));
];
expect(entryKeys, hasLength(7));
for (final entryKey in entryKeys) {
expect(find.byKey(entryKey), findsOneWidget);
}
for (var index = 0; index < 8; index++) {
expect(find.byKey(Key('mine-menu-cell-$index')), findsOneWidget);
}
expect(
menuRows.every((row) => row.minTileHeight == AppDimens.mineRowHeight),
isTrue,
find.descendant(
of: find.byKey(const Key('mine-menu-cell-7')),
matching: find.byType(Icon),
),
findsNothing,
);
final dividers = tester.widgetList<Divider>(
expect(
find.descendant(
of: find.byKey(const Key('mine-menu')),
matching: find.byType(Divider),
matching: find.byType(ListTile),
),
findsNothing,
);
expect(dividers, hasLength(6));
final positions = [
for (final entryKey in entryKeys) tester.getTopLeft(find.byKey(entryKey)),
];
expect(
dividers.every((divider) => divider.color == AppColors.contentSurface),
isTrue,
positions.take(4).map((position) => position.dy).toSet(),
hasLength(1),
);
expect(
positions.skip(4).map((position) => position.dy).toSet(),
hasLength(1),
);
expect(positions[1].dx, greaterThan(positions[0].dx));
expect(positions[2].dx, greaterThan(positions[1].dx));
expect(positions[3].dx, greaterThan(positions[2].dx));
expect(positions[5].dx, greaterThan(positions[4].dx));
expect(positions[6].dx, greaterThan(positions[5].dx));
expect(tester.getTopLeft(find.byKey(const Key('mine-menu'))).dx, 14);
final menu = tester.widget<Container>(find.byKey(const Key('mine-menu')));
final menuDecoration = menu.decoration! as BoxDecoration;
expect(menuDecoration.color, AppColors.mineCard);
expect(menuDecoration.color, AppColors.mineGridSurface);
expect(
menuDecoration.borderRadius,
BorderRadius.circular(AppDimens.mineCardRadius),
BorderRadius.circular(AppDimens.mineGridRadius),
);
expect(menuDecoration.border, isNull);
expect(menuDecoration.boxShadow, isNull);
final table = tester.widget<Table>(find.byKey(const Key('mine-menu-grid')));
final border = table.border!;
expect(border.horizontalInside.color, AppColors.mineGridDivider);
expect(border.verticalInside.color, AppColors.mineGridDivider);
final vip = tester.widget<Container>(find.byKey(const Key('mine-vip')));
final vipDecoration = vip.decoration! as BoxDecoration;
expect((vipDecoration.gradient! as LinearGradient).colors, const [
@@ -179,7 +212,6 @@ void main() {
child: MineMenuList(
onOpen: opened.add,
onLanguage: () => languageOpened++,
languageLabel: 'English',
),
),
),