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,66 @@
|
||||
// Author: fruit.com.cn
|
||||
// 职责:首页顶部精选与底部推荐使用不同文案,覆盖支持的三种语言。
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:fruitshorts/core/widgets/app_root_tab.dart';
|
||||
import 'package:fruitshorts/l10n/app_localizations.dart';
|
||||
import 'package:fruitshorts/pages/recommend/recommend_types.dart';
|
||||
import 'package:fruitshorts/pages/recommend/widgets/recommend_top_nav.dart';
|
||||
|
||||
const _labels = [
|
||||
('zh', '精选', '推荐', '剧单', '全部短剧'),
|
||||
('en', 'Featured', 'Recommend', 'Playlists', 'All Dramas'),
|
||||
('id', 'Unggulan', 'Rekomendasi', 'Daftar Putar', 'Semua'),
|
||||
];
|
||||
|
||||
void main() {
|
||||
for (final (language, featured, recommend, playlists, all) in _labels) {
|
||||
testWidgets(
|
||||
'should_distinguish_featured_from_recommend_when_locale_is_$language',
|
||||
(tester) async {
|
||||
await tester.pumpWidget(_host(language));
|
||||
await tester.pumpAndSettle();
|
||||
final top = find.byKey(const Key('recommend-top-nav'));
|
||||
final bottom = find.byKey(const Key('tab-recommend'));
|
||||
expect(
|
||||
find.descendant(of: top, matching: find.text(featured)),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(
|
||||
find.descendant(of: top, matching: find.text(recommend)),
|
||||
findsNothing,
|
||||
);
|
||||
expect(
|
||||
find.descendant(of: bottom, matching: find.text(recommend)),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(
|
||||
find.descendant(of: top, matching: find.text(playlists)),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(
|
||||
find.descendant(of: top, matching: find.text(all)),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(tester.takeException(), isNull);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Widget _host(String language) => MaterialApp(
|
||||
locale: Locale(language),
|
||||
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
||||
supportedLocales: AppLocalizations.supportedLocales,
|
||||
home: Scaffold(
|
||||
body: RecommendTopNav(
|
||||
selected: RecommendInnerTab.feed,
|
||||
onSelected: (_) {},
|
||||
onSearch: () {},
|
||||
),
|
||||
bottomNavigationBar: AppRootBottomNav(
|
||||
selected: AppRootTab.home,
|
||||
onSelected: (_) {},
|
||||
),
|
||||
),
|
||||
);
|
||||
Reference in new issue
Block a user