164 lines
4.9 KiB
Dart
164 lines
4.9 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:lucide_icons/lucide_icons.dart';
|
|
|
|
import '../../../../core/theme/design_tokens.dart';
|
|
|
|
const homeFloatingHeaderKey = ValueKey('home_floating_header');
|
|
const homeFloatingHeaderTitleKey = ValueKey('home_floating_header_title');
|
|
|
|
class HomeFloatingHeader extends StatelessWidget {
|
|
const HomeFloatingHeader({
|
|
super.key,
|
|
required this.unreadCount,
|
|
required this.onTapSettings,
|
|
required this.onTapCalendar,
|
|
required this.onTapMessages,
|
|
});
|
|
|
|
final int unreadCount;
|
|
final VoidCallback onTapSettings;
|
|
final VoidCallback onTapCalendar;
|
|
final VoidCallback onTapMessages;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Container(
|
|
key: homeFloatingHeaderKey,
|
|
padding: const EdgeInsets.fromLTRB(
|
|
AppSpacing.lg,
|
|
AppSpacing.xs,
|
|
AppSpacing.lg,
|
|
AppSpacing.xs,
|
|
),
|
|
decoration: const BoxDecoration(
|
|
color: AppColors.homeToolbarSurface,
|
|
border: Border(bottom: BorderSide(color: AppColors.homeToolbarBorder)),
|
|
),
|
|
child: Stack(
|
|
alignment: Alignment.center,
|
|
children: [
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
children: [
|
|
_HeaderIconButton(
|
|
icon: LucideIcons.settings,
|
|
onPressed: onTapSettings,
|
|
),
|
|
Row(
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
children: [
|
|
_HeaderIconButton(
|
|
icon: LucideIcons.calendar,
|
|
onPressed: onTapCalendar,
|
|
),
|
|
const SizedBox(width: AppSpacing.sm),
|
|
_MessagesButton(
|
|
unreadCount: unreadCount,
|
|
onPressed: onTapMessages,
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
const IgnorePointer(
|
|
child: Padding(
|
|
padding: EdgeInsets.symmetric(horizontal: AppSpacing.xl * 3),
|
|
child: Text(
|
|
'Linksy',
|
|
key: homeFloatingHeaderTitleKey,
|
|
maxLines: 1,
|
|
overflow: TextOverflow.ellipsis,
|
|
style: TextStyle(
|
|
fontSize: AppSpacing.lg + (AppSpacing.xs / 2),
|
|
fontWeight: FontWeight.w600,
|
|
color: AppColors.slate800,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
class _HeaderIconButton extends StatelessWidget {
|
|
const _HeaderIconButton({required this.icon, required this.onPressed});
|
|
|
|
final IconData icon;
|
|
final VoidCallback onPressed;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return IconButton(
|
|
visualDensity: VisualDensity.compact,
|
|
padding: const EdgeInsets.all(AppSpacing.xs),
|
|
constraints: const BoxConstraints(
|
|
minWidth: AppSpacing.xxl + AppSpacing.lg,
|
|
minHeight: AppSpacing.xxl + AppSpacing.lg,
|
|
),
|
|
onPressed: onPressed,
|
|
icon: Icon(icon, size: AppSpacing.xxl, color: AppColors.slate900),
|
|
);
|
|
}
|
|
}
|
|
|
|
class _MessagesButton extends StatelessWidget {
|
|
const _MessagesButton({required this.unreadCount, required this.onPressed});
|
|
|
|
final int unreadCount;
|
|
final VoidCallback onPressed;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return IconButton(
|
|
visualDensity: VisualDensity.compact,
|
|
padding: const EdgeInsets.all(AppSpacing.xs),
|
|
constraints: const BoxConstraints(
|
|
minWidth: AppSpacing.xxl + AppSpacing.lg,
|
|
minHeight: AppSpacing.xxl + AppSpacing.lg,
|
|
),
|
|
onPressed: onPressed,
|
|
icon: Stack(
|
|
clipBehavior: Clip.none,
|
|
children: [
|
|
const Icon(
|
|
LucideIcons.messageSquare,
|
|
size: AppSpacing.xxl,
|
|
color: AppColors.slate900,
|
|
),
|
|
if (unreadCount > 0)
|
|
Positioned(
|
|
right: -AppSpacing.xs,
|
|
top: -AppSpacing.xs,
|
|
child: Container(
|
|
padding: const EdgeInsets.symmetric(
|
|
horizontal: AppSpacing.xs,
|
|
vertical: AppSpacing.xs / 2,
|
|
),
|
|
decoration: BoxDecoration(
|
|
color: AppColors.red500,
|
|
borderRadius: BorderRadius.circular(AppSpacing.sm),
|
|
),
|
|
constraints: const BoxConstraints(
|
|
minWidth: AppSpacing.lg,
|
|
minHeight: AppSpacing.lg,
|
|
),
|
|
child: Text(
|
|
unreadCount > 99 ? '99+' : unreadCount.toString(),
|
|
textAlign: TextAlign.center,
|
|
style: const TextStyle(
|
|
fontSize: AppSpacing.sm + (AppSpacing.xs / 2),
|
|
fontWeight: FontWeight.w600,
|
|
color: AppColors.white,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|