Some refactors
This commit is contained in:
@@ -7,7 +7,7 @@ part 'analysis_controller.g.dart';
|
||||
|
||||
@riverpod
|
||||
class AnalysisController extends _$AnalysisController {
|
||||
late final AnalysisRepository _repo;
|
||||
late AnalysisRepository _repo;
|
||||
|
||||
@override
|
||||
Future<AnalysisState> build() async {
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:trainhub_flutter/core/theme/app_colors.dart';
|
||||
import 'package:trainhub_flutter/core/constants/ui_constants.dart';
|
||||
import 'package:trainhub_flutter/domain/entities/analysis_session.dart';
|
||||
|
||||
class AnalysisSessionList extends StatelessWidget {
|
||||
@@ -15,26 +17,148 @@ class AnalysisSessionList extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (sessions.isEmpty) {
|
||||
return const Center(
|
||||
child: Text('No analysis sessions yet. Tap + to create one.'),
|
||||
);
|
||||
}
|
||||
return ListView.builder(
|
||||
padding: const EdgeInsets.all(UIConstants.spacing24),
|
||||
itemCount: sessions.length,
|
||||
itemBuilder: (context, index) {
|
||||
final session = sessions[index];
|
||||
return ListTile(
|
||||
leading: const CircleAvatar(child: Icon(Icons.video_library)),
|
||||
title: Text(session.name),
|
||||
subtitle: Text(session.date),
|
||||
trailing: IconButton(
|
||||
icon: const Icon(Icons.delete_outline),
|
||||
onPressed: () => onDeleteSession(session),
|
||||
),
|
||||
return _SessionCard(
|
||||
session: session,
|
||||
onTap: () => onSessionSelected(session),
|
||||
onDelete: () => onDeleteSession(session),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _SessionCard extends StatefulWidget {
|
||||
final AnalysisSessionEntity session;
|
||||
final VoidCallback onTap;
|
||||
final VoidCallback onDelete;
|
||||
|
||||
const _SessionCard({
|
||||
required this.session,
|
||||
required this.onTap,
|
||||
required this.onDelete,
|
||||
});
|
||||
|
||||
@override
|
||||
State<_SessionCard> createState() => _SessionCardState();
|
||||
}
|
||||
|
||||
class _SessionCardState extends State<_SessionCard> {
|
||||
bool _isHovered = false;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MouseRegion(
|
||||
onEnter: (_) => setState(() => _isHovered = true),
|
||||
onExit: (_) => setState(() => _isHovered = false),
|
||||
child: AnimatedContainer(
|
||||
duration: UIConstants.animationDuration,
|
||||
margin: const EdgeInsets.only(bottom: UIConstants.spacing12),
|
||||
decoration: BoxDecoration(
|
||||
color: _isHovered ? AppColors.surfaceContainerHigh : AppColors.surfaceContainer,
|
||||
borderRadius: UIConstants.cardBorderRadius,
|
||||
border: Border.all(
|
||||
color: _isHovered ? AppColors.zinc600 : AppColors.border,
|
||||
),
|
||||
),
|
||||
child: Material(
|
||||
color: Colors.transparent,
|
||||
child: InkWell(
|
||||
onTap: widget.onTap,
|
||||
borderRadius: UIConstants.cardBorderRadius,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(UIConstants.cardPadding),
|
||||
child: Row(
|
||||
children: [
|
||||
Container(
|
||||
width: 44,
|
||||
height: 44,
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.purpleMuted,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
child: const Icon(
|
||||
Icons.play_circle_outline,
|
||||
color: AppColors.purple,
|
||||
size: 24,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: UIConstants.spacing16),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
widget.session.name,
|
||||
style: const TextStyle(
|
||||
color: AppColors.textPrimary,
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Row(
|
||||
children: [
|
||||
const Icon(
|
||||
Icons.calendar_today_outlined,
|
||||
size: 12,
|
||||
color: AppColors.textMuted,
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
Text(
|
||||
widget.session.date,
|
||||
style: const TextStyle(
|
||||
color: AppColors.textMuted,
|
||||
fontSize: 12,
|
||||
),
|
||||
),
|
||||
if (widget.session.videoPath != null) ...[
|
||||
const SizedBox(width: UIConstants.spacing12),
|
||||
const Icon(
|
||||
Icons.videocam_outlined,
|
||||
size: 12,
|
||||
color: AppColors.info,
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
const Text(
|
||||
'Video',
|
||||
style: TextStyle(
|
||||
color: AppColors.info,
|
||||
fontSize: 12,
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
if (_isHovered)
|
||||
IconButton(
|
||||
icon: const Icon(
|
||||
Icons.delete_outline,
|
||||
size: 18,
|
||||
color: AppColors.destructive,
|
||||
),
|
||||
onPressed: widget.onDelete,
|
||||
tooltip: 'Delete',
|
||||
)
|
||||
else
|
||||
const Icon(
|
||||
Icons.chevron_right,
|
||||
size: 20,
|
||||
color: AppColors.textMuted,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,9 +10,9 @@ part 'calendar_controller.g.dart';
|
||||
|
||||
@riverpod
|
||||
class CalendarController extends _$CalendarController {
|
||||
late final ProgramRepository _programRepo;
|
||||
late final TrainingPlanRepository _planRepo;
|
||||
late final ExerciseRepository _exerciseRepo;
|
||||
late ProgramRepository _programRepo;
|
||||
late TrainingPlanRepository _planRepo;
|
||||
late ExerciseRepository _exerciseRepo;
|
||||
|
||||
@override
|
||||
Future<CalendarState> build() async {
|
||||
|
||||
@@ -1,9 +1,14 @@
|
||||
import 'package:auto_route/auto_route.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:trainhub_flutter/core/theme/app_colors.dart';
|
||||
import 'package:trainhub_flutter/core/constants/ui_constants.dart';
|
||||
import 'package:trainhub_flutter/presentation/calendar/calendar_controller.dart';
|
||||
import 'package:trainhub_flutter/presentation/calendar/widgets/program_selector.dart';
|
||||
import 'package:trainhub_flutter/presentation/calendar/widgets/program_week_view.dart';
|
||||
import 'package:trainhub_flutter/presentation/common/widgets/app_empty_state.dart';
|
||||
import 'package:trainhub_flutter/presentation/common/dialogs/text_input_dialog.dart';
|
||||
import 'package:trainhub_flutter/presentation/common/dialogs/confirm_dialog.dart';
|
||||
|
||||
@RoutePage()
|
||||
class CalendarPage extends ConsumerWidget {
|
||||
@@ -14,103 +19,111 @@ class CalendarPage extends ConsumerWidget {
|
||||
final state = ref.watch(calendarControllerProvider);
|
||||
final controller = ref.read(calendarControllerProvider.notifier);
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: const Text('Program & Schedule')),
|
||||
body: state.when(
|
||||
data: (data) {
|
||||
if (data.programs.isEmpty) {
|
||||
return Center(
|
||||
child: ElevatedButton(
|
||||
onPressed: () => _showCreateProgramDialog(context, controller),
|
||||
child: const Text('Create First Program'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return Column(
|
||||
children: [
|
||||
ProgramSelector(
|
||||
programs: data.programs,
|
||||
activeProgram: data.activeProgram,
|
||||
onProgramSelected: (p) => controller.loadProgram(p.id),
|
||||
onCreateProgram: () =>
|
||||
_showCreateProgramDialog(context, controller),
|
||||
),
|
||||
Expanded(
|
||||
child: data.activeProgram == null
|
||||
? const Center(child: Text("Select a program"))
|
||||
: ListView.builder(
|
||||
padding: const EdgeInsets.all(16),
|
||||
itemCount: data.weeks.length + 1,
|
||||
itemBuilder: (context, index) {
|
||||
if (index == data.weeks.length) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 24.0,
|
||||
),
|
||||
child: Center(
|
||||
child: OutlinedButton.icon(
|
||||
onPressed: controller.addWeek,
|
||||
icon: const Icon(Icons.add),
|
||||
label: const Text("Add Week"),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
final week = data.weeks[index];
|
||||
final weekWorkouts = data.workouts
|
||||
.where((w) => w.weekId == week.id)
|
||||
.toList();
|
||||
return ProgramWeekView(
|
||||
week: week,
|
||||
workouts: weekWorkouts,
|
||||
availablePlans: data.plans,
|
||||
onAddWorkout: (workout) => controller.addWorkout(
|
||||
workout,
|
||||
), // logic needs refined params
|
||||
onDeleteWorkout: controller.deleteWorkout,
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
return state.when(
|
||||
data: (data) {
|
||||
if (data.programs.isEmpty) {
|
||||
return AppEmptyState(
|
||||
icon: Icons.calendar_month_outlined,
|
||||
title: 'No programs yet',
|
||||
subtitle: 'Create your first training program to start scheduling workouts',
|
||||
actionLabel: 'Create Program',
|
||||
onAction: () => _showCreateProgramDialog(context, controller),
|
||||
);
|
||||
},
|
||||
error: (e, s) => Center(child: Text('Error: $e')),
|
||||
loading: () => const Center(child: CircularProgressIndicator()),
|
||||
}
|
||||
|
||||
return Column(
|
||||
children: [
|
||||
ProgramSelector(
|
||||
programs: data.programs,
|
||||
activeProgram: data.activeProgram,
|
||||
onProgramSelected: (p) => controller.loadProgram(p.id),
|
||||
onCreateProgram: () =>
|
||||
_showCreateProgramDialog(context, controller),
|
||||
onDuplicateProgram: () {
|
||||
if (data.activeProgram != null) {
|
||||
controller.duplicateProgram(data.activeProgram!.id);
|
||||
}
|
||||
},
|
||||
onDeleteProgram: () async {
|
||||
if (data.activeProgram != null) {
|
||||
final confirmed = await ConfirmDialog.show(
|
||||
context,
|
||||
title: 'Delete Program?',
|
||||
message:
|
||||
'Are you sure you want to delete "${data.activeProgram!.name}"? This cannot be undone.',
|
||||
);
|
||||
if (confirmed == true) {
|
||||
controller.deleteProgram(data.activeProgram!.id);
|
||||
}
|
||||
}
|
||||
},
|
||||
),
|
||||
Expanded(
|
||||
child: data.activeProgram == null
|
||||
? const Center(
|
||||
child: Text(
|
||||
'Select a program to view its schedule',
|
||||
style: TextStyle(
|
||||
color: AppColors.textMuted,
|
||||
fontSize: 14,
|
||||
),
|
||||
),
|
||||
)
|
||||
: ListView.builder(
|
||||
padding: const EdgeInsets.all(UIConstants.spacing24),
|
||||
itemCount: data.weeks.length + 1,
|
||||
itemBuilder: (context, index) {
|
||||
if (index == data.weeks.length) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: UIConstants.spacing24),
|
||||
child: Center(
|
||||
child: OutlinedButton.icon(
|
||||
onPressed: controller.addWeek,
|
||||
icon: const Icon(Icons.add, size: 18),
|
||||
label: const Text('Add Week'),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
final week = data.weeks[index];
|
||||
final weekWorkouts = data.workouts
|
||||
.where((w) => w.weekId == week.id)
|
||||
.toList();
|
||||
return ProgramWeekView(
|
||||
week: week,
|
||||
workouts: weekWorkouts,
|
||||
availablePlans: data.plans,
|
||||
onAddWorkout: (workout) =>
|
||||
controller.addWorkout(workout),
|
||||
onDeleteWorkout: controller.deleteWorkout,
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
error: (e, s) => Center(
|
||||
child: Text(
|
||||
'Error: $e',
|
||||
style: const TextStyle(color: AppColors.destructive),
|
||||
),
|
||||
),
|
||||
loading: () => const Center(child: CircularProgressIndicator()),
|
||||
);
|
||||
}
|
||||
|
||||
void _showCreateProgramDialog(
|
||||
Future<void> _showCreateProgramDialog(
|
||||
BuildContext context,
|
||||
CalendarController controller,
|
||||
) {
|
||||
final textController = TextEditingController();
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
title: const Text('New Program'),
|
||||
content: TextField(
|
||||
controller: textController,
|
||||
decoration: const InputDecoration(labelText: 'Program Name'),
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context),
|
||||
child: const Text('Cancel'),
|
||||
),
|
||||
FilledButton(
|
||||
onPressed: () {
|
||||
if (textController.text.isNotEmpty) {
|
||||
controller.createProgram(textController.text);
|
||||
Navigator.pop(context);
|
||||
}
|
||||
},
|
||||
child: const Text('Create'),
|
||||
),
|
||||
],
|
||||
),
|
||||
) async {
|
||||
final name = await TextInputDialog.show(
|
||||
context,
|
||||
title: 'New Program',
|
||||
hintText: 'e.g. 12 Week Strength',
|
||||
);
|
||||
if (name != null && name.isNotEmpty) {
|
||||
controller.createProgram(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ part 'chat_controller.g.dart';
|
||||
|
||||
@riverpod
|
||||
class ChatController extends _$ChatController {
|
||||
late final ChatRepository _repo;
|
||||
late ChatRepository _repo;
|
||||
|
||||
@override
|
||||
Future<ChatState> build() async {
|
||||
|
||||
@@ -13,7 +13,7 @@ part 'plan_editor_controller.g.dart';
|
||||
|
||||
@riverpod
|
||||
class PlanEditorController extends _$PlanEditorController {
|
||||
late final TrainingPlanRepository _planRepo;
|
||||
late TrainingPlanRepository _planRepo;
|
||||
|
||||
@override
|
||||
Future<PlanEditorState> build(String planId) async {
|
||||
|
||||
@@ -10,8 +10,8 @@ part 'trainings_controller.g.dart';
|
||||
|
||||
@riverpod
|
||||
class TrainingsController extends _$TrainingsController {
|
||||
late final TrainingPlanRepository _planRepo;
|
||||
late final ExerciseRepository _exerciseRepo;
|
||||
late TrainingPlanRepository _planRepo;
|
||||
late ExerciseRepository _exerciseRepo;
|
||||
|
||||
@override
|
||||
Future<TrainingsState> build() async {
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:trainhub_flutter/core/theme/app_colors.dart';
|
||||
import 'package:trainhub_flutter/core/constants/ui_constants.dart';
|
||||
import 'package:trainhub_flutter/domain/entities/workout_activity.dart';
|
||||
|
||||
class ActivityCard extends StatelessWidget {
|
||||
@@ -8,65 +10,127 @@ class ActivityCard extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final isRest = activity.type == 'rest';
|
||||
final isRest = activity.isRest;
|
||||
final accentColor = isRest ? AppColors.info : AppColors.accent;
|
||||
|
||||
return Card(
|
||||
elevation: 4,
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(24.0),
|
||||
child: Column(
|
||||
children: [
|
||||
Text(
|
||||
activity.name,
|
||||
style: Theme.of(context).textTheme.headlineMedium,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
if (!isRest) ...[
|
||||
Text(
|
||||
"${activity.sectionName} • Set ${activity.setIndex}/${activity.totalSets}",
|
||||
style: Theme.of(context).textTheme.titleMedium?.copyWith(
|
||||
color: Theme.of(context).colorScheme.secondary,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
if (activity.originalExercise != null)
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
_buildInfo(
|
||||
context,
|
||||
"Sets",
|
||||
"${activity.originalExercise!.sets}",
|
||||
),
|
||||
const SizedBox(width: 24),
|
||||
_buildInfo(
|
||||
context,
|
||||
activity.originalExercise!.isTime ? "Secs" : "Reps",
|
||||
"${activity.originalExercise!.value}",
|
||||
),
|
||||
],
|
||||
),
|
||||
] else
|
||||
Text(
|
||||
"Resting...",
|
||||
style: Theme.of(context).textTheme.titleMedium?.copyWith(
|
||||
color: Theme.of(context).colorScheme.secondary,
|
||||
),
|
||||
),
|
||||
],
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: UIConstants.spacing24,
|
||||
vertical: UIConstants.spacing16,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.surfaceContainer.withValues(alpha: 0.6),
|
||||
borderRadius: UIConstants.cardBorderRadius,
|
||||
border: Border.all(
|
||||
color: accentColor.withValues(alpha: 0.2),
|
||||
),
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
// Activity type badge
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 4),
|
||||
decoration: BoxDecoration(
|
||||
color: accentColor.withValues(alpha: 0.12),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: Text(
|
||||
isRest ? 'REST' : 'WORK',
|
||||
style: TextStyle(
|
||||
color: accentColor,
|
||||
fontSize: 10,
|
||||
fontWeight: FontWeight.w700,
|
||||
letterSpacing: 1.5,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: UIConstants.spacing12),
|
||||
// Activity name
|
||||
Text(
|
||||
activity.name,
|
||||
style: const TextStyle(
|
||||
color: AppColors.textPrimary,
|
||||
fontSize: 22,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
if (!isRest) ...[
|
||||
const SizedBox(height: UIConstants.spacing8),
|
||||
Text(
|
||||
'${activity.sectionName ?? ''} \u00B7 Set ${activity.setIndex}/${activity.totalSets}',
|
||||
style: const TextStyle(
|
||||
color: AppColors.textMuted,
|
||||
fontSize: 13,
|
||||
),
|
||||
),
|
||||
if (activity.originalExercise != null) ...[
|
||||
const SizedBox(height: UIConstants.spacing16),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
_InfoChip(
|
||||
label: 'Sets',
|
||||
value: '${activity.originalExercise!.sets}',
|
||||
),
|
||||
const SizedBox(width: UIConstants.spacing16),
|
||||
_InfoChip(
|
||||
label: activity.originalExercise!.isTime ? 'Secs' : 'Reps',
|
||||
value: '${activity.originalExercise!.value}',
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
] else
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: UIConstants.spacing8),
|
||||
child: Text(
|
||||
'Take a break',
|
||||
style: TextStyle(
|
||||
color: AppColors.textMuted,
|
||||
fontSize: 14,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Widget _buildInfo(BuildContext context, String label, String value) {
|
||||
return Column(
|
||||
children: [
|
||||
Text(value, style: Theme.of(context).textTheme.headlineSmall),
|
||||
Text(label, style: Theme.of(context).textTheme.labelMedium),
|
||||
],
|
||||
class _InfoChip extends StatelessWidget {
|
||||
final String label;
|
||||
final String value;
|
||||
|
||||
const _InfoChip({required this.label, required this.value});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.zinc800.withValues(alpha: 0.5),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
Text(
|
||||
value,
|
||||
style: const TextStyle(
|
||||
color: AppColors.textPrimary,
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
label,
|
||||
style: const TextStyle(
|
||||
color: AppColors.textMuted,
|
||||
fontSize: 11,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
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;
|
||||
@@ -20,35 +22,109 @@ class SessionControls extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (isFinished) {
|
||||
return ElevatedButton(
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
child: const Text('Finish Workout'),
|
||||
);
|
||||
}
|
||||
if (isFinished) return const SizedBox.shrink();
|
||||
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
IconButton.filledTonal(
|
||||
onPressed: onPrevious,
|
||||
icon: const Icon(Icons.skip_previous),
|
||||
iconSize: 32,
|
||||
),
|
||||
const SizedBox(width: 24),
|
||||
IconButton.filled(
|
||||
onPressed: isRunning ? onPause : onPlay,
|
||||
icon: Icon(isRunning ? Icons.pause : Icons.play_arrow),
|
||||
iconSize: 48,
|
||||
style: IconButton.styleFrom(padding: const EdgeInsets.all(16)),
|
||||
),
|
||||
const SizedBox(width: 24),
|
||||
IconButton.filledTonal(
|
||||
onPressed: onNext,
|
||||
icon: const Icon(Icons.skip_next),
|
||||
iconSize: 32,
|
||||
),
|
||||
],
|
||||
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: [
|
||||
_ControlButton(
|
||||
icon: Icons.skip_previous_rounded,
|
||||
onTap: onPrevious,
|
||||
size: 28,
|
||||
),
|
||||
const SizedBox(width: UIConstants.spacing24),
|
||||
// Play/Pause - larger main button
|
||||
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,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
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,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:trainhub_flutter/core/theme/app_colors.dart';
|
||||
|
||||
class SessionProgressBar extends StatelessWidget {
|
||||
final double progress;
|
||||
@@ -7,10 +8,23 @@ class SessionProgressBar extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return LinearProgressIndicator(
|
||||
value: progress,
|
||||
minHeight: 8,
|
||||
backgroundColor: Theme.of(context).colorScheme.surfaceContainerHighest,
|
||||
return Container(
|
||||
height: 4,
|
||||
color: AppColors.zinc800,
|
||||
child: FractionallySizedBox(
|
||||
alignment: Alignment.centerLeft,
|
||||
widthFactor: progress.clamp(0.0, 1.0),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
colors: [
|
||||
AppColors.accent,
|
||||
AppColors.accent.withValues(alpha: 0.7),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user