Some refactors

This commit is contained in:
Kazimierz Ciołek
2026-02-19 14:16:03 +01:00
parent 782986a632
commit f943e89430
21 changed files with 490 additions and 7378 deletions

View File

@@ -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,
),
),
],
),
);
}
}