feat(flutter): 首页顶栏改为通知铃铛入口
This commit is contained in:
1 parent
e32fa58979
commit
524b7f5b35
2 files changed
+56
-24
No files matched your search
@@ -5,10 +5,11 @@ import 'package:flutter/material.dart';
|
||||
import '../../../core/theme/app_colors.dart';
|
||||
import '../../../core/theme/app_dimens.dart';
|
||||
import '../../../l10n/app_localizations.dart';
|
||||
import '../../notices/notices_page.dart';
|
||||
|
||||
const double _searchHeight = 36;
|
||||
|
||||
/// 首页固定顶栏:搜索、星期与头像入口。
|
||||
/// 首页固定顶栏:搜索、通知与头像入口。
|
||||
class HomeBrowseHeader extends StatelessWidget {
|
||||
const HomeBrowseHeader({
|
||||
super.key,
|
||||
@@ -22,7 +23,6 @@ class HomeBrowseHeader extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final l10n = AppLocalizations.of(context)!;
|
||||
final weekday = _weekday(l10n);
|
||||
return SizedBox(
|
||||
height: AppDimens.contentHeaderHeight,
|
||||
child: Padding(
|
||||
@@ -33,7 +33,7 @@ class HomeBrowseHeader extends StatelessWidget {
|
||||
children: [
|
||||
Expanded(child: _search(l10n, onSearch)),
|
||||
const SizedBox(width: AppDimens.spaceSm),
|
||||
_weekdayText(weekday),
|
||||
_notifications(context, l10n),
|
||||
const SizedBox(width: AppDimens.spaceSm),
|
||||
_profile(l10n),
|
||||
],
|
||||
@@ -42,18 +42,6 @@ class HomeBrowseHeader extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
String _weekday(AppLocalizations l10n) {
|
||||
return switch (DateTime.now().weekday) {
|
||||
DateTime.monday => l10n.weekdayMon,
|
||||
DateTime.tuesday => l10n.weekdayTue,
|
||||
DateTime.wednesday => l10n.weekdayWed,
|
||||
DateTime.thursday => l10n.weekdayThu,
|
||||
DateTime.friday => l10n.weekdayFri,
|
||||
DateTime.saturday => l10n.weekdaySat,
|
||||
_ => l10n.weekdaySun,
|
||||
};
|
||||
}
|
||||
|
||||
Widget _search(AppLocalizations l10n, VoidCallback onTap) {
|
||||
return Semantics(
|
||||
button: true,
|
||||
@@ -95,14 +83,29 @@ class HomeBrowseHeader extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _weekdayText(String value) {
|
||||
return Text(
|
||||
value,
|
||||
key: const Key('home-weekday'),
|
||||
style: const TextStyle(
|
||||
color: AppColors.muted,
|
||||
fontSize: AppDimens.caption,
|
||||
fontWeight: FontWeight.w600,
|
||||
Widget _notifications(BuildContext context, AppLocalizations l10n) {
|
||||
return Semantics(
|
||||
button: true,
|
||||
label: l10n.notices,
|
||||
child: InkWell(
|
||||
key: const Key('home-notifications'),
|
||||
customBorder: const CircleBorder(),
|
||||
onTap: () => Navigator.of(
|
||||
context,
|
||||
).push(MaterialPageRoute<void>(builder: (_) => const NoticesPage())),
|
||||
child: Container(
|
||||
width: AppDimens.tapTarget,
|
||||
height: AppDimens.tapTarget,
|
||||
decoration: const BoxDecoration(
|
||||
color: AppColors.card,
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
child: const Icon(
|
||||
Icons.notifications_none_rounded,
|
||||
color: AppColors.onSurface,
|
||||
size: AppDimens.accountIcon,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ void main() {
|
||||
|
||||
expect(find.byKey(const Key('home-search')), findsOneWidget);
|
||||
expect(find.byKey(const Key('home-profile')), findsOneWidget);
|
||||
expect(find.byKey(const Key('home-weekday')), findsOneWidget);
|
||||
expect(find.byKey(const Key('home-notifications')), findsOneWidget);
|
||||
for (final channel in ['hot', 'free', 'newReleases', 'ranking']) {
|
||||
expect(find.byKey(Key('home-channel-$channel')), findsOneWidget);
|
||||
}
|
||||
@@ -76,6 +76,35 @@ void main() {
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
|
||||
testWidgets('should_open_notices_when_bell_is_tapped', (tester) async {
|
||||
SharedPreferencesAsyncPlatform.instance =
|
||||
InMemorySharedPreferencesAsync.empty();
|
||||
tester.view.physicalSize = const Size(390, 844);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.resetPhysicalSize);
|
||||
addTearDown(tester.view.resetDevicePixelRatio);
|
||||
final catalog = FakeCatalogRepository();
|
||||
await tester.pumpWidget(
|
||||
LumaDramaApp(
|
||||
playerFactory: createWidgetPlayer,
|
||||
catalogRepository: catalog,
|
||||
categoryRepository: FakeCategoryRepository(catalog: catalog),
|
||||
watchHistoryRepository: InMemoryWatchHistoryRepository(),
|
||||
favoriteRepository: InMemoryFavoriteRepository(cards: catalog.dramas),
|
||||
playbackRepository: FakePlaybackRepository(),
|
||||
commentRepository: FakeCommentRepository(),
|
||||
interactionRepository: FakeInteractionRepository(),
|
||||
noticeRepository: FakeNoticeRepository(),
|
||||
haptics: FakeHaptics(),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
await tester.tap(find.byKey(const Key('home-notifications')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(const Key('notices-page')), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('should_use_episode_title_then_drama_title_as_fallback', (
|
||||
tester,
|
||||
) async {
|
||||
|
||||
Reference in new issue
Block a user