Files
ReelShort/lib/pages/home/widgets/home_browse_header.dart
T

138 lines
3.8 KiB
Dart

// Author: fruit.com.cn
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,
required this.onSearch,
required this.onProfile,
});
final VoidCallback onSearch;
final VoidCallback onProfile;
@override
Widget build(BuildContext context) {
final l10n = AppLocalizations.of(context)!;
return SizedBox(
height: AppDimens.contentHeaderHeight,
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: AppDimens.pageHorizontal,
),
child: Row(
children: [
Expanded(child: _search(l10n, onSearch)),
const SizedBox(width: AppDimens.spaceSm),
_notifications(context, l10n),
const SizedBox(width: AppDimens.spaceSm),
_profile(l10n),
],
),
),
);
}
Widget _search(AppLocalizations l10n, VoidCallback onTap) {
return Semantics(
button: true,
label: l10n.search,
child: InkWell(
key: const Key('home-search'),
onTap: onTap,
borderRadius: BorderRadius.circular(AppDimens.pillRadius),
child: Container(
height: _searchHeight,
padding: const EdgeInsets.symmetric(horizontal: AppDimens.spaceMd),
decoration: BoxDecoration(
color: AppColors.input,
borderRadius: BorderRadius.circular(AppDimens.pillRadius),
),
child: Row(
children: [
const Icon(
Icons.search_rounded,
color: AppColors.subtle,
size: 17,
),
const SizedBox(width: AppDimens.spaceSm),
Expanded(
child: Text(
l10n.searchDiscover,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: const TextStyle(
color: AppColors.subtle,
fontSize: AppDimens.caption,
),
),
),
],
),
),
),
);
}
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,
),
),
),
);
}
Widget _profile(AppLocalizations l10n) {
return Semantics(
button: true,
label: l10n.myTab,
child: InkWell(
key: const Key('home-profile'),
customBorder: const CircleBorder(),
onTap: onProfile,
child: Container(
width: AppDimens.tapTarget,
height: AppDimens.tapTarget,
decoration: const BoxDecoration(
color: AppColors.card,
shape: BoxShape.circle,
),
child: const Icon(
Icons.person_rounded,
color: AppColors.onSurface,
size: AppDimens.accountIcon,
),
),
),
);
}
}