petsHero-AI/lib/shared/widgets/top_nav_bar.dart
2026-03-09 16:39:54 +08:00

86 lines
2.3 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter_lucide/flutter_lucide.dart';
import '../../core/theme/app_colors.dart';
import '../../core/theme/app_spacing.dart';
import '../../core/theme/app_typography.dart';
import 'credits_badge.dart';
/// Top navigation bar - matches Pencil topNav
class TopNavBar extends StatelessWidget implements PreferredSizeWidget {
const TopNavBar({
super.key,
required this.title,
this.credits,
this.showBackButton = false,
this.onBack,
this.onCreditsTap,
});
final String title;
final String? credits;
final bool showBackButton;
final VoidCallback? onBack;
final VoidCallback? onCreditsTap;
@override
Size get preferredSize => const Size.fromHeight(56);
@override
Widget build(BuildContext context) {
return Container(
height: 56,
padding: const EdgeInsets.symmetric(horizontal: AppSpacing.screenPadding),
decoration: BoxDecoration(
color: AppColors.surface,
boxShadow: [
BoxShadow(
color: AppColors.shadowLight,
blurRadius: 8,
offset: const Offset(0, 2),
),
],
),
child: Row(
children: [
if (showBackButton)
GestureDetector(
onTap: onBack ?? () => Navigator.of(context).pop(),
behavior: HitTestBehavior.opaque,
child: SizedBox(
width: 40,
height: 40,
child: Center(
child: Icon(
LucideIcons.arrow_left,
size: 24,
color: AppColors.textPrimary,
),
),
),
),
Expanded(
child: showBackButton
? Center(
child: Text(
title,
style: AppTypography.navTitle,
),
)
: Align(
alignment: Alignment.centerLeft,
child: Text(
title,
style: AppTypography.navTitle,
),
),
),
if (credits != null)
CreditsBadge(credits: credits!, onTap: onCreditsTap)
else
const SizedBox(width: 40),
],
),
);
}
}