feat(flutter): 首页顶栏改为通知铃铛入口

This commit is contained in:
Zhou Weidong committed 2026-10-20 13:11:46 +08:00
1 parent e32fa58979
commit 524b7f5b35
2 files changed
+56 -24

No files matched your search

+26 -23
View File
@@ -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,
),
),
),
);
}