2026-02-25 10:52:18 +08:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
2026-03-12 16:41:45 +08:00
|
|
|
import '../../core/theme/design_tokens.dart';
|
|
|
|
|
|
2026-02-25 10:52:18 +08:00
|
|
|
class PageHeader extends StatelessWidget {
|
|
|
|
|
final Widget? leading;
|
|
|
|
|
final Widget? trailing;
|
|
|
|
|
final double height;
|
|
|
|
|
|
|
|
|
|
const PageHeader({super.key, this.leading, this.trailing, this.height = 64});
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
return SizedBox(
|
|
|
|
|
height: height,
|
|
|
|
|
child: Padding(
|
|
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 20),
|
|
|
|
|
child: Row(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
2026-03-16 16:11:16 +08:00
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
2026-02-25 10:52:18 +08:00
|
|
|
children: [
|
|
|
|
|
leading ?? const SizedBox.shrink(),
|
|
|
|
|
trailing ?? const SizedBox.shrink(),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-16 16:11:16 +08:00
|
|
|
class BackButton extends StatefulWidget {
|
2026-02-25 10:52:18 +08:00
|
|
|
final VoidCallback? onPressed;
|
|
|
|
|
|
|
|
|
|
const BackButton({super.key, this.onPressed});
|
|
|
|
|
|
2026-03-16 16:11:16 +08:00
|
|
|
@override
|
|
|
|
|
State<BackButton> createState() => _BackButtonState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _BackButtonState extends State<BackButton> {
|
|
|
|
|
bool _isPressed = false;
|
|
|
|
|
|
2026-02-25 10:52:18 +08:00
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
2026-03-27 19:07:39 +08:00
|
|
|
final colorScheme = Theme.of(context).colorScheme;
|
|
|
|
|
final background = _isPressed
|
|
|
|
|
? colorScheme.secondaryContainer
|
|
|
|
|
: colorScheme.surface;
|
2026-03-16 16:11:16 +08:00
|
|
|
final borderColor = _isPressed
|
2026-03-27 19:07:39 +08:00
|
|
|
? colorScheme.outlineVariant
|
|
|
|
|
: colorScheme.outline;
|
2026-03-16 16:11:16 +08:00
|
|
|
|
|
|
|
|
return AnimatedScale(
|
|
|
|
|
scale: _isPressed ? 0.96 : 1,
|
|
|
|
|
duration: const Duration(milliseconds: 110),
|
|
|
|
|
curve: Curves.easeOut,
|
|
|
|
|
child: AnimatedContainer(
|
|
|
|
|
duration: const Duration(milliseconds: 110),
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
color: background,
|
|
|
|
|
borderRadius: BorderRadius.circular(AppRadius.full),
|
|
|
|
|
border: Border.all(color: borderColor),
|
|
|
|
|
boxShadow: _isPressed
|
|
|
|
|
? const []
|
|
|
|
|
: [
|
2026-03-27 19:07:39 +08:00
|
|
|
BoxShadow(
|
|
|
|
|
color: colorScheme.surface,
|
2026-03-16 16:11:16 +08:00
|
|
|
blurRadius: AppRadius.sm,
|
2026-03-27 19:07:39 +08:00
|
|
|
offset: const Offset(0, -1),
|
2026-03-16 16:11:16 +08:00
|
|
|
),
|
|
|
|
|
BoxShadow(
|
2026-03-27 19:07:39 +08:00
|
|
|
color: colorScheme.shadow.withValues(alpha: 0.42),
|
2026-03-16 16:11:16 +08:00
|
|
|
blurRadius: AppRadius.md,
|
|
|
|
|
offset: const Offset(0, AppSpacing.xs),
|
|
|
|
|
),
|
|
|
|
|
],
|
2026-02-25 10:52:18 +08:00
|
|
|
),
|
2026-03-16 16:11:16 +08:00
|
|
|
child: SizedBox(
|
|
|
|
|
width: AppSpacing.xl * 2,
|
|
|
|
|
height: AppSpacing.xl * 2,
|
|
|
|
|
child: Material(
|
2026-03-27 19:07:39 +08:00
|
|
|
color: colorScheme.surface.withValues(alpha: 0),
|
2026-03-16 16:11:16 +08:00
|
|
|
child: InkWell(
|
|
|
|
|
borderRadius: BorderRadius.circular(AppRadius.full),
|
|
|
|
|
onTap: widget.onPressed ?? () => Navigator.of(context).pop(),
|
|
|
|
|
onTapDown: (_) {
|
2026-03-27 19:07:39 +08:00
|
|
|
if (_isPressed) return;
|
|
|
|
|
setState(() => _isPressed = true);
|
2026-03-16 16:11:16 +08:00
|
|
|
},
|
|
|
|
|
onTapCancel: () {
|
2026-03-27 19:07:39 +08:00
|
|
|
if (!_isPressed) return;
|
|
|
|
|
setState(() => _isPressed = false);
|
2026-03-16 16:11:16 +08:00
|
|
|
},
|
|
|
|
|
onTapUp: (_) {
|
2026-03-27 19:07:39 +08:00
|
|
|
if (!_isPressed) return;
|
|
|
|
|
setState(() => _isPressed = false);
|
2026-03-16 16:11:16 +08:00
|
|
|
},
|
|
|
|
|
child: Center(
|
|
|
|
|
child: Icon(
|
|
|
|
|
Icons.chevron_left,
|
|
|
|
|
size: AppSpacing.lg + AppSpacing.xs,
|
2026-03-27 19:07:39 +08:00
|
|
|
color: _isPressed
|
|
|
|
|
? colorScheme.primary
|
|
|
|
|
: colorScheme.onSurfaceVariant,
|
2026-03-16 16:11:16 +08:00
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
2026-02-25 10:52:18 +08:00
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|