feat(flutter): 统一二级页头并恢复新剧暖色
This commit is contained in:
1 parent
7b2970d5c5
commit
1c6c92170d
26 files changed
+492
-427
No files matched your search
@@ -0,0 +1,86 @@
|
||||
// Author: fruit.com.cn
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:fruitshorts/core/theme/app_colors.dart';
|
||||
import 'package:fruitshorts/core/theme/app_theme.dart';
|
||||
import 'package:fruitshorts/core/widgets/subpage_header.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('should_render_unified_light_header_dimensions', (tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
theme: AppTheme.light(),
|
||||
home: Scaffold(
|
||||
body: AppSubpageHeader(
|
||||
title: 'Title',
|
||||
backKey: const Key('sample-back'),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
expect(tester.getSize(find.byKey(const Key('subpage-header'))).height, 52);
|
||||
expect(
|
||||
tester.getSize(find.byKey(const Key('sample-back'))),
|
||||
const Size(36, 36),
|
||||
);
|
||||
final title = tester.widget<Text>(find.byKey(const Key('subpage-title')));
|
||||
expect(title.style?.fontSize, 18);
|
||||
expect(title.style?.fontWeight, FontWeight.w800);
|
||||
expect(title.style?.color, AppColors.onSurface);
|
||||
final back = tester.getRect(find.byKey(const Key('sample-back')));
|
||||
final titleRect = tester.getRect(find.byKey(const Key('subpage-title')));
|
||||
expect(titleRect.left - back.right, closeTo(12, 0.5));
|
||||
});
|
||||
|
||||
testWidgets('should_use_64_height_when_subtitle_exists', (tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
theme: AppTheme.light(),
|
||||
home: Scaffold(
|
||||
body: AppSubpageHeader(
|
||||
title: 'Title',
|
||||
subtitle: 'Subtitle',
|
||||
backKey: const Key('sample-back'),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
expect(tester.getSize(find.byKey(const Key('subpage-header'))).height, 64);
|
||||
expect(find.byKey(const Key('subpage-subtitle')), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('should_use_transparent_dark_back_button', (tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
theme: AppTheme.light(),
|
||||
home: const Scaffold(
|
||||
backgroundColor: Colors.black,
|
||||
body: AppSubpageHeader(
|
||||
title: 'Title',
|
||||
backKey: Key('sample-back'),
|
||||
dark: true,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
final material = tester.widget<Material>(
|
||||
find.descendant(
|
||||
of: find.byKey(const Key('sample-back')),
|
||||
matching: find.byType(Material),
|
||||
),
|
||||
);
|
||||
final icon = tester.widget<Icon>(
|
||||
find.descendant(
|
||||
of: find.byKey(const Key('sample-back')),
|
||||
matching: find.byIcon(Icons.chevron_left_rounded),
|
||||
),
|
||||
);
|
||||
expect(material.color, Colors.transparent);
|
||||
expect(icon.color, Colors.white);
|
||||
expect(icon.size, 20);
|
||||
});
|
||||
}
|
||||
@@ -29,6 +29,7 @@ void main() {
|
||||
await _pumpFilterPage(tester);
|
||||
|
||||
expect(find.byKey(const Key('filter-page')), findsOneWidget);
|
||||
_expectUnifiedHeader(tester, const Key('filter-back'));
|
||||
expect(
|
||||
find.byKey(const Key('filter-group-label-category')),
|
||||
findsOneWidget,
|
||||
@@ -184,6 +185,13 @@ final List<Drama> _filterDramas = [
|
||||
),
|
||||
];
|
||||
|
||||
void _expectUnifiedHeader(WidgetTester tester, Key backKey) {
|
||||
expect(tester.getSize(find.byKey(backKey)), const Size(36, 36));
|
||||
final title = tester.widget<Text>(find.byKey(const Key('subpage-title')));
|
||||
expect(title.style?.fontSize, 18);
|
||||
expect(title.style?.fontWeight, FontWeight.w800);
|
||||
}
|
||||
|
||||
Drama _drama({
|
||||
required String id,
|
||||
required String title,
|
||||
|
||||
@@ -29,6 +29,7 @@ void main() {
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byKey(const Key('ranking-page')), findsOneWidget);
|
||||
_expectUnifiedHeader(tester, const Key('ranking-back'));
|
||||
expect(find.text('TOP 1'), findsOneWidget);
|
||||
expect(
|
||||
tester.widget<Text>(find.byKey(const Key('ranking-title-1'))).data,
|
||||
@@ -46,6 +47,15 @@ void main() {
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byKey(const Key('new-releases-page')), findsOneWidget);
|
||||
_expectUnifiedHeader(tester, const Key('new-releases-back'));
|
||||
final newPage = tester.widget<Scaffold>(
|
||||
find.byKey(const Key('new-releases-page')),
|
||||
);
|
||||
expect(newPage.backgroundColor, AppColors.ink);
|
||||
final badge = tester.widget<Container>(
|
||||
find.byKey(const Key('new-releases-hero-badge')),
|
||||
);
|
||||
expect((badge.decoration! as BoxDecoration).color, AppColors.blue);
|
||||
expect(find.byKey(const Key('new-releases-hero')), findsOneWidget);
|
||||
expect(find.text('Vengeance Rising'), findsWidgets);
|
||||
expect(
|
||||
@@ -68,6 +78,7 @@ void main() {
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byKey(const Key('reserve-page')), findsOneWidget);
|
||||
_expectUnifiedHeader(tester, const Key('reserve-back'));
|
||||
expect(find.byKey(const Key('reserve-week-strip')), findsOneWidget);
|
||||
for (var index = 0; index < 7; index++) {
|
||||
expect(find.byKey(Key('reserve-day-$index')), findsOneWidget);
|
||||
@@ -207,3 +218,10 @@ List<Drama> _rankDramas(int count) => [
|
||||
],
|
||||
),
|
||||
];
|
||||
|
||||
void _expectUnifiedHeader(WidgetTester tester, Key backKey) {
|
||||
expect(tester.getSize(find.byKey(backKey)), const Size(36, 36));
|
||||
final title = tester.widget<Text>(find.byKey(const Key('subpage-title')));
|
||||
expect(title.style?.fontSize, 18);
|
||||
expect(title.style?.fontWeight, FontWeight.w800);
|
||||
}
|
||||
@@ -52,6 +52,13 @@ void main() {
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byKey(const Key('settings-page')), findsOneWidget);
|
||||
expect(
|
||||
tester.getSize(find.byKey(const Key('settings-back'))),
|
||||
const Size(36, 36),
|
||||
);
|
||||
final title = tester.widget<Text>(find.byKey(const Key('subpage-title')));
|
||||
expect(title.style?.fontSize, 18);
|
||||
expect(title.style?.fontWeight, FontWeight.w800);
|
||||
expect(find.byKey(const Key('settings-notices')), findsOneWidget);
|
||||
expect(find.byKey(const Key('server-endpoint-setting')), findsNothing);
|
||||
expect(find.text('Server address'), findsNothing);
|
||||
|
||||
@@ -52,6 +52,13 @@ void main() {
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byKey(const Key('notices-page')), findsOneWidget);
|
||||
expect(
|
||||
tester.getSize(find.byKey(const Key('notices-back'))),
|
||||
const Size(36, 36),
|
||||
);
|
||||
final title = tester.widget<Text>(find.byKey(const Key('subpage-title')));
|
||||
expect(title.style?.fontSize, 18);
|
||||
expect(title.style?.fontWeight, FontWeight.w800);
|
||||
expect(find.byKey(const Key('auth-gate-panel')), findsNothing);
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user