feat(home): 顶部导航随翻页联动并把推荐更名为精选
This commit is contained in:
1 parent
2f4593a46e
commit
335e5dc286
27 files changed
+1095
-214
No files matched your search
@@ -0,0 +1,73 @@
|
||||
// Author: fruit.com.cn
|
||||
// 职责:验证推荐页封面标签使用常规字重,保留原有样式与点击。
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:fruitshorts/core/data/models/drama.dart';
|
||||
import 'package:fruitshorts/core/theme/app_colors.dart';
|
||||
import 'package:fruitshorts/l10n/app_localizations.dart';
|
||||
import 'package:fruitshorts/pages/recommend/widgets/home_recommend_content.dart';
|
||||
|
||||
const _tag = '热播';
|
||||
const _fallback = '上新';
|
||||
const _posterWidth = 110.0;
|
||||
const _posterHeight = 230.0;
|
||||
|
||||
void main() {
|
||||
for (final tag in [_tag, '']) {
|
||||
testWidgets(
|
||||
'should_keep_badge_regular_when_using_${tag.isEmpty ? 'fallback' : 'tag'}',
|
||||
(tester) async {
|
||||
var taps = 0;
|
||||
await tester.pumpWidget(_host(tag, () => taps++));
|
||||
await tester.pumpAndSettle();
|
||||
final label = find.text(tag.isEmpty ? _fallback : tag);
|
||||
final text = tester.widget<Text>(label);
|
||||
expect(text.style?.fontWeight, FontWeight.w400);
|
||||
expect(text.style?.fontSize, 11);
|
||||
expect(text.style?.color, AppColors.textPrimary);
|
||||
final badge = tester.widget<Container>(
|
||||
find.ancestor(of: label, matching: find.byType(Container)).first,
|
||||
);
|
||||
final decoration = badge.decoration! as BoxDecoration;
|
||||
expect(decoration.color, AppColors.brandRed);
|
||||
expect(decoration.borderRadius, BorderRadius.circular(6));
|
||||
expect(decoration.boxShadow, isNull);
|
||||
expect(
|
||||
badge.padding,
|
||||
const EdgeInsets.symmetric(horizontal: 8, vertical: 3),
|
||||
);
|
||||
final position = tester.widget<Positioned>(
|
||||
find.ancestor(of: label, matching: find.byType(Positioned)).first,
|
||||
);
|
||||
expect(position.left, 8);
|
||||
expect(position.top, 8);
|
||||
await tester.tap(label);
|
||||
expect(taps, 1);
|
||||
expect(tester.takeException(), isNull);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Widget _host(String tag, VoidCallback onTap) => MaterialApp(
|
||||
locale: const Locale('zh'),
|
||||
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
||||
supportedLocales: AppLocalizations.supportedLocales,
|
||||
home: Scaffold(
|
||||
body: SizedBox(
|
||||
width: _posterWidth,
|
||||
height: _posterHeight,
|
||||
child: HomePosterCard(
|
||||
drama: Drama(
|
||||
id: 'poster',
|
||||
title: '测试短剧',
|
||||
synopsis: '',
|
||||
posterUrl: '',
|
||||
tag: tag,
|
||||
),
|
||||
badge: _fallback,
|
||||
onTap: onTap,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
Reference in new issue
Block a user