152 lines
4.3 KiB
Dart
152 lines
4.3 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:trainhub_flutter/core/theme/app_colors.dart';
|
|
import 'package:trainhub_flutter/core/constants/ui_constants.dart';
|
|
|
|
class SessionControls extends StatelessWidget {
|
|
final bool isRunning;
|
|
final bool isFinished;
|
|
final bool isTimeBased;
|
|
final VoidCallback onPause;
|
|
final VoidCallback onPlay;
|
|
final VoidCallback onNext;
|
|
final VoidCallback onPrevious;
|
|
final VoidCallback onRewind;
|
|
final VoidCallback onFastForward;
|
|
|
|
const SessionControls({
|
|
super.key,
|
|
required this.isRunning,
|
|
required this.isFinished,
|
|
required this.isTimeBased,
|
|
required this.onPause,
|
|
required this.onPlay,
|
|
required this.onNext,
|
|
required this.onPrevious,
|
|
required this.onRewind,
|
|
required this.onFastForward,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
if (isFinished) return const SizedBox.shrink();
|
|
|
|
return Container(
|
|
margin: const EdgeInsets.symmetric(horizontal: UIConstants.spacing24),
|
|
padding: const EdgeInsets.symmetric(
|
|
horizontal: UIConstants.spacing24,
|
|
vertical: UIConstants.spacing12,
|
|
),
|
|
decoration: BoxDecoration(
|
|
color: AppColors.surfaceContainer.withValues(alpha: 0.7),
|
|
borderRadius: BorderRadius.circular(40),
|
|
border: Border.all(color: AppColors.border.withValues(alpha: 0.5)),
|
|
),
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
if (isTimeBased) ...[
|
|
_ControlButton(
|
|
icon: Icons.replay_10,
|
|
onTap: onRewind,
|
|
size: 24,
|
|
),
|
|
const SizedBox(width: UIConstants.spacing8),
|
|
],
|
|
_ControlButton(
|
|
icon: Icons.skip_previous_rounded,
|
|
onTap: onPrevious,
|
|
size: 28,
|
|
),
|
|
const SizedBox(width: UIConstants.spacing24),
|
|
Container(
|
|
width: 56,
|
|
height: 56,
|
|
decoration: BoxDecoration(
|
|
color: AppColors.zinc50,
|
|
shape: BoxShape.circle,
|
|
boxShadow: [
|
|
BoxShadow(
|
|
color: AppColors.zinc50.withValues(alpha: 0.15),
|
|
blurRadius: 16,
|
|
spreadRadius: 2,
|
|
),
|
|
],
|
|
),
|
|
child: Material(
|
|
color: Colors.transparent,
|
|
child: InkWell(
|
|
onTap: isRunning ? onPause : onPlay,
|
|
borderRadius: BorderRadius.circular(28),
|
|
child: Icon(
|
|
isRunning ? Icons.pause_rounded : Icons.play_arrow_rounded,
|
|
color: AppColors.zinc950,
|
|
size: 32,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
const SizedBox(width: UIConstants.spacing24),
|
|
_ControlButton(
|
|
icon: Icons.skip_next_rounded,
|
|
onTap: onNext,
|
|
size: 28,
|
|
),
|
|
if (isTimeBased) ...[
|
|
const SizedBox(width: UIConstants.spacing8),
|
|
_ControlButton(
|
|
icon: Icons.forward_10,
|
|
onTap: onFastForward,
|
|
size: 24,
|
|
),
|
|
],
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
class _ControlButton extends StatefulWidget {
|
|
final IconData icon;
|
|
final VoidCallback onTap;
|
|
final double size;
|
|
|
|
const _ControlButton({
|
|
required this.icon,
|
|
required this.onTap,
|
|
this.size = 24,
|
|
});
|
|
|
|
@override
|
|
State<_ControlButton> createState() => _ControlButtonState();
|
|
}
|
|
|
|
class _ControlButtonState extends State<_ControlButton> {
|
|
bool _isHovered = false;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return MouseRegion(
|
|
onEnter: (_) => setState(() => _isHovered = true),
|
|
onExit: (_) => setState(() => _isHovered = false),
|
|
child: GestureDetector(
|
|
onTap: widget.onTap,
|
|
child: AnimatedContainer(
|
|
duration: UIConstants.animationDuration,
|
|
width: 44,
|
|
height: 44,
|
|
decoration: BoxDecoration(
|
|
color: _isHovered ? AppColors.zinc700 : Colors.transparent,
|
|
shape: BoxShape.circle,
|
|
),
|
|
child: Icon(
|
|
widget.icon,
|
|
color: _isHovered ? AppColors.textPrimary : AppColors.textSecondary,
|
|
size: widget.size,
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|