Skip to content

Offline gym log for Android. No account, no ads, no internet.

Group the library by muscle and pin the search and the filters (#22, #23)

InlitXc0a230400c2e
diff --git a/lib/screens/exercise_detail_screen.dart b/lib/screens/exercise_detail_screen.dart
index be36978..062cabc 100644
--- a/lib/screens/exercise_detail_screen.dart
+++ b/lib/screens/exercise_detail_screen.dart
@@ -1,6 +1,6 @@
import 'package:file_picker/file_picker.dart';
import 'package:flutter/material.dart';
-import 'package:phosphor_flutter/phosphor_flutter.dart';
+import 'package:phosphoricons_flutter/phosphoricons_flutter.dart';
import '../l10n/l10n.dart';
import '../models/exercise.dart';
@@ -86,7 +86,8 @@ class _ExerciseDetailScreenState extends State<ExerciseDetailScreen> {
children: [
SizedBox(
width: double.infinity,
- child: ExerciseMedia(ex: ex, height: 210, live: true),
+ child: ExerciseMedia(
+ ex: ex, height: 220, radius: 22, live: true, bordered: false),
),
Positioned(
bottom: 10,
@@ -115,56 +116,70 @@ class _ExerciseDetailScreenState extends State<ExerciseDetailScreen> {
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
- Text(exerciseName(ex), style: AppTheme.d(24, weight: FontWeight.w700, color: gc.text)),
- const SizedBox(height: 20),
+ Text(exerciseName(ex),
+ style: AppTheme.f(26, weight: FontWeight.w800, color: gc.text, height: 1.1)),
+ const SizedBox(height: 18),
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
- _meta(gc, t.primaryLabel, muscleLabel(ex.primary), gc.ember),
+ _meta(gc, t.primaryLabel, muscleLabel(ex.primary)),
const SizedBox(width: 20),
- _meta(gc, t.secondaryLabel, secondary, gc.text),
+ _meta(gc, t.secondaryLabel, secondary),
const SizedBox(width: 20),
- _meta(gc, t.equipmentLabel, t.equipment(ex.equipment), gc.text),
+ _meta(gc, t.equipmentLabel, t.equipment(ex.equipment)),
],
),
- const SizedBox(height: 16),
- _repsOnlyRow(gc, ex.id, repsOnly),
- const SizedBox(height: 10),
- _restRow(gc, ex.id),
+ const SizedBox(height: 18),
+ _group(gc, [
+ _repsOnlyRow(gc, ex.id, repsOnly),
+ _restRow(gc, ex.id),
+ if (!repsOnly) ...[
+ _progressRow(gc, ex.id),
+ _switchRow(
+ gc,
+ PhosphorIconsRegular.fire,
+ t.autoWarmup,
+ t.autoWarmupHint,
+ fit.warmsUp(ex.id),
+ () => fit.toggleAutoWarmup(ex.id),
+ ),
+ ],
+ ]),
const SizedBox(height: 20),
const StopwatchCard(),
const SizedBox(height: 20),
if (pr != null) ...[
Container(
- padding: const EdgeInsets.all(16),
+ padding: const EdgeInsets.all(18),
decoration: BoxDecoration(
color: gc.bgRaised,
- border: Border.all(color: gc.border),
- borderRadius: BorderRadius.circular(16),
+ borderRadius: BorderRadius.circular(20),
),
child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
+ crossAxisAlignment: CrossAxisAlignment.end,
children: [
- SvgPathIcon(Ic.trendUp, size: 18, color: gc.accent),
- const SizedBox(width: 12),
Expanded(
- child: Text(t.personalRecord,
- style: AppTheme.d(13, weight: FontWeight.w600, color: gc.text, letterSpacing: 1)),
- ),
- Column(
- crossAxisAlignment: CrossAxisAlignment.end,
- children: [
- Text(fit.weightLabel(pr.topWeight),
- style: AppTheme.d(18, weight: FontWeight.w700, color: gc.text)),
- Text(t.oneRmEst(fit.weightLabel(pr.oneRm)),
- style: AppTheme.s(11, color: gc.textSecondary)),
- ],
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ _cardLabel(gc, t.personalRecord),
+ const SizedBox(height: 8),
+ Text(fit.weightLabel(pr.topWeight),
+ style: AppTheme.f(30,
+ weight: FontWeight.w800, color: gc.text, height: 1)),
+ ],
+ ),
),
+ Text(t.oneRmEst(fit.weightLabel(pr.oneRm)),
+ style: AppTheme.f(12,
+ weight: FontWeight.w500, color: gc.textSecondary)),
],
),
if (oneRm.length > 2) ...[
- const SizedBox(height: 14),
+ const SizedBox(height: 16),
Sparkline(values: oneRm, height: 52, color: gc.accent),
],
],
@@ -172,11 +187,15 @@ class _ExerciseDetailScreenState extends State<ExerciseDetailScreen> {
),
const SizedBox(height: 20),
],
- Text(t.history, style: AppTheme.d(14, weight: FontWeight.w600, color: gc.text, letterSpacing: 1)),
- const SizedBox(height: 12),
+ if (fit.nextTargetLabel(ex.id) != null) ...[
+ _nextCard(gc, ex.id),
+ const SizedBox(height: 20),
+ ],
+ _section(gc, t.history),
+ const SizedBox(height: 6),
if (history.isEmpty)
Text(t.noHistory,
- style: AppTheme.s(13, color: gc.textSecondary))
+ style: AppTheme.f(13, weight: FontWeight.w500, color: gc.textSecondary))
else
for (int i = 0; i < history.length && i < 8; i++)
_historyRow(gc, history[i], i < history.length - 1 && i < 7),
@@ -184,8 +203,8 @@ class _ExerciseDetailScreenState extends State<ExerciseDetailScreen> {
_notesRow(gc, ex.id),
const SizedBox(height: 24),
if (steps.isNotEmpty) ...[
- Text(t.howTo, style: AppTheme.d(14, weight: FontWeight.w600, color: gc.text, letterSpacing: 1)),
- const SizedBox(height: 12),
+ _section(gc, t.howTo),
+ const SizedBox(height: 14),
for (int i = 0; i < steps.length; i++) ...[
_step(gc, i + 1, steps[i]),
if (i < steps.length - 1) const SizedBox(height: 14),
@@ -197,8 +216,8 @@ class _ExerciseDetailScreenState extends State<ExerciseDetailScreen> {
],
if (fit.similarExercises(ex, 4).isNotEmpty) ...[
const SizedBox(height: 24),
- Text(t.similar, style: AppTheme.d(14, weight: FontWeight.w600, color: gc.text, letterSpacing: 1)),
- const SizedBox(height: 12),
+ _section(gc, t.similar),
+ const SizedBox(height: 10),
for (final s in fit.similarExercises(ex, 4)) _similarRow(gc, s),
],
],
@@ -217,7 +236,7 @@ class _ExerciseDetailScreenState extends State<ExerciseDetailScreen> {
decoration: BoxDecoration(
color: gc.bgRaised,
border: Border.all(color: gc.warn.withValues(alpha: 0.5)),
- borderRadius: BorderRadius.circular(18),
+ borderRadius: BorderRadius.circular(20),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
@@ -228,18 +247,18 @@ class _ExerciseDetailScreenState extends State<ExerciseDetailScreen> {
const SizedBox(width: 10),
Expanded(
child: Text(t.notHere(t.equipment(ex.equipment).toLowerCase(), place.name),
- style: AppTheme.s(13.5, weight: FontWeight.w600, color: gc.text)),
+ style: AppTheme.f(14, weight: FontWeight.w600, color: gc.text)),
),
],
),
const SizedBox(height: 4),
Padding(
padding: const EdgeInsets.only(left: 26),
- child: Text(t.notHereWhy, style: AppTheme.s(12.5, color: gc.textSecondary, height: 1.4)),
+ child: Text(t.notHereWhy, style: AppTheme.f(12.5, weight: FontWeight.w500, color: gc.textSecondary, height: 1.4)),
),
const SizedBox(height: 14),
Text(t.altHere,
- style: AppTheme.s(10,
+ style: AppTheme.f(10.5,
weight: FontWeight.w700, color: gc.textTertiary, letterSpacing: 1.5)),
const SizedBox(height: 6),
for (final alt in fit.alternativesHere(ex, 3)) _similarRow(gc, alt),
@@ -248,12 +267,21 @@ class _ExerciseDetailScreenState extends State<ExerciseDetailScreen> {
);
}
+ String _setsLine(LoggedExercise e) {
+ final rpe = e.sets.map((s) => s.rpe).whereType<double>().toList();
+ final sets = t.setCount(e.sets.length);
+ if (rpe.isEmpty) return sets;
+ return '$sets · RPE ${fmt(rpe.reduce((a, b) => a > b ? a : b))}';
+ }
+
Widget _historyRow(GymColors gc, ({DateTime date, LoggedExercise ex}) h, bool border) {
final e = h.ex;
return Container(
- padding: const EdgeInsets.symmetric(vertical: 12),
+ padding: const EdgeInsets.symmetric(vertical: 13),
decoration: BoxDecoration(
- border: border ? Border(bottom: BorderSide(color: gc.border)) : null,
+ border: border
+ ? Border(bottom: BorderSide(color: gc.border.withValues(alpha: 0.55)))
+ : null,
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
@@ -261,17 +289,21 @@ class _ExerciseDetailScreenState extends State<ExerciseDetailScreen> {
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
- Text(_fmtDate(h.date), style: AppTheme.s(14, weight: FontWeight.w600, color: gc.text)),
- const SizedBox(height: 2),
- Text(t.setCount(e.sets.length), style: AppTheme.s(12, color: gc.textSecondary)),
+ Text(_fmtDate(h.date),
+ style: AppTheme.f(14.5, weight: FontWeight.w600, color: gc.text)),
+ const SizedBox(height: 3),
+ Text(_setsLine(e),
+ style: AppTheme.f(12, weight: FontWeight.w500, color: gc.textSecondary)),
],
),
Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Text(fit.weightLabel(e.topWeight),
- style: AppTheme.d(16, weight: FontWeight.w700, color: gc.text)),
- Text(t.volumeSuffix(fit.volumeLabel(e.volume)), style: AppTheme.s(11, color: gc.textSecondary)),
+ style: AppTheme.f(17, weight: FontWeight.w700, color: gc.text)),
+ const SizedBox(height: 3),
+ Text(t.volumeSuffix(fit.volumeLabel(e.volume)),
+ style: AppTheme.f(11.5, weight: FontWeight.w500, color: gc.textSecondary)),
],
),
],
@@ -287,31 +319,28 @@ class _ExerciseDetailScreenState extends State<ExerciseDetailScreen> {
behavior: HitTestBehavior.opaque,
onTap: () => fit.goNotes(exerciseId: exId),
child: Container(
- padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 12),
+ padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 13),
decoration: BoxDecoration(
color: gc.bgRaised,
- border: Border.all(color: n > 0 ? gc.ember : gc.border),
- borderRadius: BorderRadius.circular(16),
+ borderRadius: BorderRadius.circular(20),
),
child: Row(
children: [
- Icon(PhosphorIconsRegular.notebook,
- size: 18, color: n > 0 ? gc.ember : gc.textSecondary),
- const SizedBox(width: 12),
+ _rowIcon(gc, PhosphorIconsRegular.notebook, n > 0),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
- Text(t.notes,
- style: AppTheme.s(12,
- weight: FontWeight.w600, color: gc.text, letterSpacing: 0.5)),
- const SizedBox(height: 2),
+ Text(titleCase(t.notes),
+ style: AppTheme.f(14.5, weight: FontWeight.w500, color: gc.text)),
+ const SizedBox(height: 3),
Text(n == 0 ? t.noteNoneForExercise : t.noteCount(n),
- style: AppTheme.s(11, color: gc.textSecondary)),
+ style: AppTheme.f(11.5,
+ weight: FontWeight.w500, color: gc.textSecondary)),
],
),
),
- Icon(PhosphorIconsRegular.caretRight, size: 16, color: gc.textSecondary),
+ Icon(PhosphorIconsRegular.caretRight, size: 15, color: gc.textTertiary),
],
),
),
@@ -325,41 +354,76 @@ class _ExerciseDetailScreenState extends State<ExerciseDetailScreen> {
behavior: HitTestBehavior.opaque,
child: Container(
margin: const EdgeInsets.only(bottom: 8),
- padding: const EdgeInsets.all(10),
+ padding: const EdgeInsets.fromLTRB(12, 9, 14, 9),
decoration: BoxDecoration(
color: gc.bgRaised,
- border: Border.all(color: gc.border),
- borderRadius: BorderRadius.circular(14),
+ borderRadius: BorderRadius.circular(18),
),
child: Row(
children: [
- SizedBox(width: 48, child: ExerciseMedia(ex: s, height: 48, radius: 10)),
- const SizedBox(width: 12),
+ SizedBox(
+ width: 48,
+ child: ExerciseMedia(ex: s, height: 48, radius: 14, bordered: false),
+ ),
+ const SizedBox(width: 13),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
- Text(exerciseName(s), style: AppTheme.s(14, weight: FontWeight.w600, color: gc.text)),
- const SizedBox(height: 2),
- Text(t.equipment(s.equipment), style: AppTheme.s(12, color: gc.textSecondary)),
+ Text(exerciseName(s),
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ style: AppTheme.f(14.5, weight: FontWeight.w600, color: gc.text)),
+ const SizedBox(height: 4),
+ Text(t.equipment(s.equipment),
+ style: AppTheme.f(12, weight: FontWeight.w500, color: gc.textSecondary)),
],
),
),
- SvgPathIcon(Ic.chevronRight, size: 16, color: gc.textTertiary),
+ SvgPathIcon(Ic.chevronRight, size: 15, color: gc.textTertiary),
],
),
),
);
}
- Widget _meta(GymColors gc, String label, String value, Color valueColor) {
+ Widget _meta(GymColors gc, String label, String value) {
return Flexible(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
- Text(label, style: AppTheme.s(11, weight: FontWeight.w600, color: gc.textSecondary, letterSpacing: 1)),
- const SizedBox(height: 4),
- Text(value, style: AppTheme.s(14, weight: FontWeight.w600, color: valueColor)),
+ _cardLabel(gc, label),
+ const SizedBox(height: 5),
+ Text(value,
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ style: AppTheme.f(14.5, weight: FontWeight.w600, color: gc.text)),
+ ],
+ ),
+ );
+ }
+
+ Widget _cardLabel(GymColors gc, String label) => Text(label.toUpperCase(),
+ style: AppTheme.f(10.5, weight: FontWeight.w700, color: gc.textTertiary, letterSpacing: 1.3));
+
+ Widget _section(GymColors gc, String label) => Text(titleCase(label),
+ style: AppTheme.f(18, weight: FontWeight.w700, color: gc.text));
+
+ Widget _group(GymColors gc, List<Widget> rows) {
+ return Container(
+ decoration: BoxDecoration(color: gc.bgRaised, borderRadius: BorderRadius.circular(20)),
+ clipBehavior: Clip.antiAlias,
+ child: Column(
+ children: [
+ for (int i = 0; i < rows.length; i++) ...[
+ rows[i],
+ if (i < rows.length - 1)
+ Container(
+ height: 1,
+ margin: const EdgeInsets.only(left: 16),
+ color: gc.border.withValues(alpha: 0.55),
+ ),
+ ],
],
),
);
@@ -374,10 +438,13 @@ class _ExerciseDetailScreenState extends State<ExerciseDetailScreen> {
height: 24,
decoration: BoxDecoration(color: gc.emberSoft, shape: BoxShape.circle),
alignment: Alignment.center,
- child: Text('$n', style: AppTheme.s(12, weight: FontWeight.w700, color: gc.ember)),
+ child: Text('$n', style: AppTheme.f(12, weight: FontWeight.w700, color: gc.ember)),
),
const SizedBox(width: 12),
- Expanded(child: Text(text, style: AppTheme.s(14, color: gc.textSecondary, height: 1.5))),
+ Expanded(
+ child: Text(text,
+ style: AppTheme.f(14, weight: FontWeight.w500, color: gc.textSecondary, height: 1.5)),
+ ),
],
);
}
@@ -397,36 +464,32 @@ class _ExerciseDetailScreenState extends State<ExerciseDetailScreen> {
Widget _restRow(GymColors gc, String id) {
final custom = fit.hasCustomRest(id);
final seconds = fit.restFor(id);
- return Container(
- padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 12),
- decoration: BoxDecoration(
- color: gc.bgRaised,
- border: Border.all(color: custom ? gc.ember : gc.border),
- borderRadius: BorderRadius.circular(16),
- ),
+ return Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
child: Row(
children: [
- Icon(PhosphorIconsRegular.timer, size: 18, color: custom ? gc.ember : gc.textSecondary),
- const SizedBox(width: 12),
+ _rowIcon(gc, PhosphorIconsRegular.timer, custom),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
- Text(t.restForExercise,
- style: AppTheme.s(12, weight: FontWeight.w600, color: gc.text, letterSpacing: 0.5)),
- const SizedBox(height: 2),
+ Text(titleCase(t.restForExercise),
+ style: AppTheme.f(14.5, weight: FontWeight.w500, color: gc.text)),
+ const SizedBox(height: 3),
GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: custom ? () => fit.setExerciseRest(id, null) : null,
child: Text(custom ? t.restCustom : t.restUsingDefault,
- style: AppTheme.s(11, color: custom ? gc.accent : gc.textSecondary)),
+ style: AppTheme.f(11.5,
+ weight: FontWeight.w500,
+ color: custom ? gc.accent : gc.textSecondary)),
),
],
),
),
const SizedBox(width: 12),
StepperControl(
- value: '${seconds}s',
+ value: seconds == 0 ? t.restOff : '${seconds}s',
minWidth: 44,
btnSize: 30,
gap: 3,
@@ -440,55 +503,179 @@ class _ExerciseDetailScreenState extends State<ExerciseDetailScreen> {
);
}
- Widget _repsOnlyRow(GymColors gc, String id, bool on) {
+ Widget _rowIcon(GymColors gc, IconData icon, bool on) => Padding(
+ padding: const EdgeInsets.only(right: 14),
+ child: SizedBox(
+ width: 22,
+ child: Icon(icon, size: 19, color: on ? gc.text : gc.textSecondary),
+ ),
+ );
+
+ Widget _nextCard(GymColors gc, String id) {
+ final target = fit.nextTarget(id)!;
+ return Container(
+ padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 14),
+ decoration: BoxDecoration(
+ color: gc.bgRaised,
+ border: Border.all(color: target.up ? gc.ember : gc.border),
+ borderRadius: BorderRadius.circular(16),
+ ),
+ child: Row(
+ children: [
+ SvgPathIcon(Ic.trendUp, size: 18, color: target.up ? gc.ember : gc.textSecondary),
+ const SizedBox(width: 12),
+ Expanded(
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Text(t.nextTime,
+ style: AppTheme.f(10.5, weight: FontWeight.w700, color: gc.textTertiary, letterSpacing: 1.3)),
+ if (!target.up) ...[
+ const SizedBox(height: 2),
+ Text(t.nextHold, style: AppTheme.f(11.5, weight: FontWeight.w500, color: gc.textTertiary)),
+ ],
+ ],
+ ),
+ ),
+ const SizedBox(width: 10),
+ Text(fit.nextTargetLabel(id)!,
+ style: AppTheme.f(20, weight: FontWeight.w800, color: target.up ? gc.ember : gc.text)),
+ ],
+ ),
+ );
+ }
+
+ Widget _switchRow(GymColors gc, IconData icon, String title, String hint, bool on,
+ VoidCallback onTap) {
return Semantics(
button: true,
toggled: on,
child: GestureDetector(
behavior: HitTestBehavior.opaque,
- onTap: () => fit.toggleRepsOnly(id),
- child: Container(
- padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 12),
- decoration: BoxDecoration(
- color: gc.bgRaised,
- border: Border.all(color: on ? gc.ember : gc.border),
- borderRadius: BorderRadius.circular(16),
- ),
+ onTap: onTap,
+ child: Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
child: Row(
children: [
- Icon(PhosphorIconsRegular.scales, size: 18, color: on ? gc.ember : gc.textSecondary),
- const SizedBox(width: 12),
+ _rowIcon(gc, icon, on),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
- Text(t.repsOnly, style: AppTheme.s(13.5, weight: FontWeight.w600, color: gc.text)),
- const SizedBox(height: 2),
- Text(t.repsOnlyHint, style: AppTheme.s(11, color: gc.textSecondary)),
+ Text(title, style: AppTheme.f(14.5, weight: FontWeight.w500, color: gc.text)),
+ const SizedBox(height: 3),
+ Text(hint,
+ style: AppTheme.f(11.5,
+ weight: FontWeight.w500, color: gc.textSecondary, height: 1.3)),
],
),
),
- const SizedBox(width: 10),
- AnimatedContainer(
- duration: const Duration(milliseconds: 140),
- width: 44,
- height: 26,
- padding: const EdgeInsets.all(3),
- alignment: on ? Alignment.centerRight : Alignment.centerLeft,
- decoration: BoxDecoration(
- color: on ? gc.ember : gc.bgRaised2,
- borderRadius: BorderRadius.circular(100),
- border: Border.all(color: on ? gc.ember : gc.border),
- ),
- child: Container(
- width: 20,
- height: 20,
- decoration: BoxDecoration(
- color: on ? gc.onEmber : gc.textTertiary,
- shape: BoxShape.circle,
+ const SizedBox(width: 12),
+ TinySwitch(on: on),
+ ],
+ ),
+ ),
+ ),
+ );
+ }
+
+ Widget _progressRow(GymColors gc, String id) {
+ final on = fit.hasProgress(id);
+ final step = fit.weightLabel(fit.progressFor(id) ?? 0);
+ return Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
+ child: Column(
+ children: [
+ Semantics(
+ button: true,
+ toggled: on,
+ child: GestureDetector(
+ behavior: HitTestBehavior.opaque,
+ onTap: () => fit.toggleProgress(id),
+ child: Row(
+ children: [
+ Padding(
+ padding: const EdgeInsets.only(right: 14),
+ child: SizedBox(
+ width: 22,
+ child: SvgPathIcon(Ic.trendUp,
+ size: 19, color: on ? gc.text : gc.textSecondary),
+ ),
),
+ Expanded(
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Text(t.autoProgress,
+ style: AppTheme.f(14.5, weight: FontWeight.w500, color: gc.text)),
+ const SizedBox(height: 3),
+ Text(
+ on
+ ? t.autoProgressHint(step)
+ : t.autoProgressHint(
+ fit.weightLabel(fit.fromDisplayWeight(fit.weightStep))),
+ style: AppTheme.f(11.5,
+ weight: FontWeight.w500, color: gc.textSecondary, height: 1.3)),
+ ],
+ ),
+ ),
+ const SizedBox(width: 12),
+ TinySwitch(on: on),
+ ],
+ ),
+ ),
+ ),
+ if (on) ...[
+ const SizedBox(height: 12),
+ Row(
+ mainAxisAlignment: MainAxisAlignment.spaceBetween,
+ children: [
+ _cardLabel(gc, t.weightLabel),
+ StepperControl(
+ value: step,
+ minWidth: 62,
+ btnSize: 30,
+ gap: 6,
+ fontSize: 14,
+ btnRadius: 10,
+ onDec: () => fit.bumpProgressStep(id, -1),
+ onInc: () => fit.bumpProgressStep(id, 1),
+ ),
+ ],
+ ),
+ ],
+ ],
+ ),
+ );
+ }
+
+ Widget _repsOnlyRow(GymColors gc, String id, bool on) {
+ return Semantics(
+ button: true,
+ toggled: on,
+ child: GestureDetector(
+ behavior: HitTestBehavior.opaque,
+ onTap: () => fit.toggleRepsOnly(id),
+ child: Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
+ child: Row(
+ children: [
+ _rowIcon(gc, PhosphorIconsRegular.scales, on),
+ Expanded(
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Text(t.repsOnly,
+ style: AppTheme.f(14.5, weight: FontWeight.w500, color: gc.text)),
+ const SizedBox(height: 3),
+ Text(t.repsOnlyHint,
+ style: AppTheme.f(11.5,
+ weight: FontWeight.w500, color: gc.textSecondary, height: 1.3)),
+ ],
),
),
+ const SizedBox(width: 12),
+ TinySwitch(on: on),
],
),
),
diff --git a/lib/screens/exercises_screen.dart b/lib/screens/exercises_screen.dart
index 4d11cd9..6eb537e 100644
--- a/lib/screens/exercises_screen.dart
+++ b/lib/screens/exercises_screen.dart
@@ -2,7 +2,7 @@ import 'dart:io';
import 'package:file_picker/file_picker.dart';
import 'package:flutter/material.dart';
-import 'package:phosphor_flutter/phosphor_flutter.dart';
+import 'package:phosphoricons_flutter/phosphoricons_flutter.dart';
import '../catalog/exercise_catalog.dart';
import '../l10n/l10n.dart';
@@ -50,9 +50,25 @@ class _ExercisesScreenState extends State<ExercisesScreen> {
itemCount: list.isEmpty ? 1 : list.length,
itemBuilder: (context, i) {
if (list.isEmpty) return _empty(gc);
- return Padding(
- padding: const EdgeInsets.only(bottom: 10),
- child: _card(gc, list[i]),
+ final ex = list[i];
+ final first = i == 0 || list[i - 1].primary != ex.primary;
+ final last = i == list.length - 1 || list[i + 1].primary != ex.primary;
+ return Column(
+ crossAxisAlignment: CrossAxisAlignment.stretch,
+ children: [
+ if (first) ...[
+ SizedBox(height: i == 0 ? 2 : 22),
+ Padding(
+ padding: const EdgeInsets.fromLTRB(4, 0, 0, 8),
+ child: Text(muscleLabel(ex.primary).toUpperCase(),
+ style: AppTheme.f(10.5,
+ weight: FontWeight.w700,
+ color: gc.textTertiary,
+ letterSpacing: 1.3)),
+ ),
+ ],
+ _row(gc, ex, first: first, last: last),
+ ],
);
},
),
@@ -85,7 +101,8 @@ class _ExercisesScreenState extends State<ExercisesScreen> {
children: [
ScreenTitle(t.exercises),
const SizedBox(height: 4),
- Text(t.libraryCount(count), style: AppTheme.s(13, color: gc.textSecondary)),
+ Text(t.libraryCount(count),
+ style: AppTheme.f(13, weight: FontWeight.w500, color: gc.textSecondary)),
],
),
),
@@ -115,7 +132,7 @@ class _ExercisesScreenState extends State<ExercisesScreen> {
label: active > 0 ? '${t.filters} · $active' : t.filters,
bg: active > 0 ? gc.ember : gc.bgRaised2,
fg: active > 0 ? gc.onEmber : gc.textSecondary,
- onTap: () => _openFilters(context),
+ onTap: () => showExerciseFilters(context, onClear: _c.clear),
hPad: 14,
vPad: 7,
fontSize: 12.5,
@@ -158,118 +175,6 @@ class _ExercisesScreenState extends State<ExercisesScreen> {
);
}
- void _openFilters(BuildContext context) {
- final gc = context.gc;
- showModalBottomSheet<void>(
- context: context,
- backgroundColor: Colors.transparent,
- isScrollControlled: true,
- builder: (sheet) => StatefulBuilder(
- builder: (sheet, setSheet) => Container(
- padding: sheetPad(sheet),
- constraints: BoxConstraints(maxHeight: MediaQuery.sizeOf(sheet).height * 0.85),
- decoration: BoxDecoration(
- color: gc.bgRaised,
- border: Border.all(color: gc.border),
- borderRadius: const BorderRadius.vertical(top: Radius.circular(28)),
- ),
- child: SingleChildScrollView(
- child: Column(
- mainAxisSize: MainAxisSize.min,
- crossAxisAlignment: CrossAxisAlignment.stretch,
- children: [
- const SheetHandle(),
- const SizedBox(height: 18),
- Text(t.filters,
- textAlign: TextAlign.center,
- style: AppTheme.d(14, weight: FontWeight.w700, color: gc.text, letterSpacing: 2)),
- const SizedBox(height: 18),
- _filterLabel(gc, t.placeFilterLabel),
- const SizedBox(height: 8),
- _chipRow([
- _FilterChipData(t.placeAll, fit.activePlaceId.isEmpty,
- () => setSheet(() => fit.setActivePlace(''))),
- for (final place in fit.places)
- _FilterChipData(place.name, fit.activePlaceId == place.id,
- () => setSheet(() => fit.setActivePlace(place.id))),
- _FilterChipData(fit.places.isEmpty ? t.placeNew : '+', false, () {
- Navigator.pop(sheet);
- fit.goPlaces();
- }),
- ], gc, hPad: 14, vPad: 8, fontSize: 13),
- const SizedBox(height: 16),
- _filterLabel(gc, t.muscleFilter),
- const SizedBox(height: 8),
- _chipRow([
- for (final id in kFilterMuscles)
- _FilterChipData(muscleLabel(id), fit.exMuscleFilter == id,
- () => setSheet(() => fit.setMuscleFilter(id))),
- ], gc, hPad: 14, vPad: 8, fontSize: 13),
- const SizedBox(height: 16),
- _filterLabel(gc, t.equipmentLabel),
- const SizedBox(height: 8),
- _chipRow([
- _FilterChipData(
- t.noGearOnly, fit.exNoGearOnly, () => setSheet(fit.toggleNoGearFilter)),
- for (final e in kFilterEquipment)
- _FilterChipData(t.equipment(e), fit.exEquipmentFilter == e,
- () => setSheet(() => fit.setEquipmentFilter(e))),
- ], gc, hPad: 12, vPad: 6, fontSize: 12),
- const SizedBox(height: 16),
- _filterLabel(gc, t.levelFilter),
- const SizedBox(height: 8),
- _chipRow([
- for (final d in kDifficulties)
- _FilterChipData(t.difficulty(d), fit.exDifficultyFilter == d,
- () => setSheet(() => fit.setDifficultyFilter(d))),
- ], gc, hPad: 12, vPad: 6, fontSize: 12),
- const SizedBox(height: 22),
- PrimaryButton(
- label: t.libraryCount(fit.exercisesFiltered.length),
- onTap: () => Navigator.pop(sheet)),
- const SizedBox(height: 6),
- GestureDetector(
- behavior: HitTestBehavior.opaque,
- onTap: () => setSheet(_clearAll),
- child: Container(
- height: 44,
- alignment: Alignment.center,
- child: Text(t.clearFilters,
- style: AppTheme.s(13, weight: FontWeight.w600, color: gc.accent)),
- ),
- ),
- ],
- ),
- ),
- ),
- ),
- );
- }
-
- Widget _filterLabel(GymColors gc, String t) =>
- Text(t, style: AppTheme.s(10, weight: FontWeight.w700, color: gc.textTertiary, letterSpacing: 1.5));
-
- Widget _chipRow(List<_FilterChipData> chips, GymColors gc,
- {required double hPad, required double vPad, required double fontSize}) {
- return SingleChildScrollView(
- scrollDirection: Axis.horizontal,
- child: Row(children: [
- for (int i = 0; i < chips.length; i++) ...[
- Pill(
- label: chips[i].label,
- bg: chips[i].active ? gc.ember : gc.bgRaised2,
- fg: chips[i].active ? gc.onEmber : gc.textSecondary,
- onTap: chips[i].onTap,
- hPad: hPad,
- vPad: vPad,
- fontSize: fontSize,
- ),
- if (i < chips.length - 1) const SizedBox(width: 8),
- ],
- ]),
- );
- }
-
Widget _empty(GymColors gc) {
final noFavs = fit.exFavouritesOnly && fit.favouriteCount == 0;
return Padding(
@@ -282,10 +187,11 @@ class _ExercisesScreenState extends State<ExercisesScreen> {
SvgPathIcon(const [IconPath('M11 11m-7 0a7 7 0 1 0 14 0a7 7 0 1 0 -14 0', strokeWidth: 1.5), IconPath('M21 21l-4.35-4.35', strokeWidth: 1.5)], size: 40, color: gc.textTertiary),
const SizedBox(height: 10),
Text(noFavs ? t.noFavouritesYet : t.noExercisesFound,
- style: AppTheme.s(15, weight: FontWeight.w600, color: gc.text)),
+ style: AppTheme.f(15.5, weight: FontWeight.w700, color: gc.text)),
const SizedBox(height: 4),
Text(noFavs ? t.noFavouritesHint : t.noExercisesHint,
- textAlign: TextAlign.center, style: AppTheme.s(13, color: gc.textSecondary)),
+ textAlign: TextAlign.center,
+ style: AppTheme.f(13, weight: FontWeight.w500, color: gc.textSecondary)),
const SizedBox(height: 16),
GestureDetector(
behavior: HitTestBehavior.opaque,
@@ -293,7 +199,7 @@ class _ExercisesScreenState extends State<ExercisesScreen> {
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10),
child: Text(t.clearFilters,
- style: AppTheme.s(13, weight: FontWeight.w600, color: gc.accent)),
+ style: AppTheme.f(13, weight: FontWeight.w600, color: gc.accent)),
),
),
],
@@ -301,75 +207,65 @@ class _ExercisesScreenState extends State<ExercisesScreen> {
);
}
- Widget _card(GymColors gc, Exercise ex) {
+ Widget _row(GymColors gc, Exercise ex, {required bool first, required bool last}) {
final fav = fit.favorites[ex.id] ?? false;
- final diffColor = ex.difficulty == 'Beginner'
- ? gc.sage
- : ex.difficulty == 'Advanced'
- ? gc.accent
- : gc.textSecondary;
return Container(
- padding: const EdgeInsets.all(12),
decoration: BoxDecoration(
color: gc.bgRaised,
- border: Border.all(color: gc.border),
- borderRadius: BorderRadius.circular(18),
+ borderRadius: BorderRadius.vertical(
+ top: Radius.circular(first ? 20 : 0),
+ bottom: Radius.circular(last ? 20 : 0),
+ ),
),
- child: Stack(
+ child: Column(
children: [
- Row(
- crossAxisAlignment: CrossAxisAlignment.center,
- children: [
- GestureDetector(
- onTap: () => fit.openExercise(ex.id),
- child: SizedBox(width: 64, child: ExerciseMedia(ex: ex, height: 64, radius: 14)),
- ),
- const SizedBox(width: 14),
- Expanded(
- child: GestureDetector(
- onTap: () => fit.openExercise(ex.id),
- behavior: HitTestBehavior.opaque,
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Padding(
- padding: const EdgeInsets.only(right: 24),
- child: Text(exerciseName(ex), style: AppTheme.s(14, weight: FontWeight.w600, color: gc.text)),
- ),
- const SizedBox(height: 6),
- Row(children: [
- Container(
- padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 3),
- decoration: BoxDecoration(color: gc.accentSoft, borderRadius: BorderRadius.circular(100)),
- child: Text(muscleLabel(ex.primary),
- style: AppTheme.s(11, weight: FontWeight.w600, color: gc.accent)),
- ),
- const SizedBox(width: 6),
- Text(t.equipment(ex.equipment), style: AppTheme.s(12, color: gc.textSecondary)),
- ]),
- const SizedBox(height: 6),
- Row(children: [
- Container(width: 6, height: 6, decoration: BoxDecoration(color: diffColor, shape: BoxShape.circle)),
- const SizedBox(width: 5),
- Text(t.difficulty(ex.difficulty), style: AppTheme.s(11, color: gc.textTertiary)),
- ]),
- ],
+ GestureDetector(
+ behavior: HitTestBehavior.opaque,
+ onTap: () => fit.openExercise(ex.id),
+ child: Padding(
+ padding: const EdgeInsets.fromLTRB(12, 9, 6, 9),
+ child: Row(
+ children: [
+ SizedBox(
+ width: 52,
+ child: ExerciseMedia(ex: ex, height: 52, radius: 15, bordered: false),
),
- ),
- ),
- ],
- ),
- Positioned(
- top: 0,
- right: 0,
- child: GestureDetector(
- onTap: () => fit.toggleFavorite(ex.id),
- child: Padding(
- padding: const EdgeInsets.all(6),
- child: _star(gc, fav),
+ const SizedBox(width: 13),
+ Expanded(
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Text(exerciseName(ex),
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ style: AppTheme.f(14.5, weight: FontWeight.w600, color: gc.text)),
+ const SizedBox(height: 4),
+ Text('${t.equipment(ex.equipment)} · ${t.difficulty(ex.difficulty)}',
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ style: AppTheme.f(12,
+ weight: FontWeight.w500, color: gc.textSecondary)),
+ ],
+ ),
+ ),
+ GestureDetector(
+ behavior: HitTestBehavior.opaque,
+ onTap: () => fit.toggleFavorite(ex.id),
+ child: Padding(
+ padding: const EdgeInsets.all(10),
+ child: _star(gc, fav),
+ ),
+ ),
+ ],
),
),
),
+ if (!last)
+ Container(
+ margin: const EdgeInsets.only(left: 77),
+ height: 1,
+ color: gc.border.withValues(alpha: 0.55),
+ ),
],
),
);
@@ -428,18 +324,18 @@ void showCreateExerciseSheet(BuildContext context, {void Function(String id)? on
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
- Text(t.newExercise,
- style: AppTheme.d(15, weight: FontWeight.w700, color: gc.text, letterSpacing: 2)),
+ Text(titleCase(t.newExercise),
+ style: AppTheme.f(19, weight: FontWeight.w800, color: gc.text)),
const SizedBox(height: 16),
TextField(
controller: nameCtrl,
autofocus: true,
- style: AppTheme.s(15, color: gc.text),
+ style: AppTheme.f(15, weight: FontWeight.w500, color: gc.text),
cursorColor: gc.accent,
textCapitalization: TextCapitalization.words,
decoration: InputDecoration(
hintText: t.exerciseName,
- hintStyle: AppTheme.s(15, color: gc.textTertiary),
+ hintStyle: AppTheme.f(15, weight: FontWeight.w500, color: gc.textTertiary),
filled: true,
fillColor: gc.bgRaised2,
contentPadding: const EdgeInsets.all(14),
@@ -450,7 +346,7 @@ void showCreateExerciseSheet(BuildContext context, {void Function(String id)? on
),
),
const SizedBox(height: 16),
- Text(t.muscleFilter, style: AppTheme.s(11, weight: FontWeight.w700, color: gc.textTertiary, letterSpacing: 1.5)),
+ _filterLabel(gc, t.muscleFilter),
const SizedBox(height: 8),
Wrap(spacing: 8, runSpacing: 8, children: [
for (final m in kMuscles)
@@ -464,7 +360,7 @@ void showCreateExerciseSheet(BuildContext context, {void Function(String id)? on
),
]),
const SizedBox(height: 16),
- Text(t.equipmentLabel, style: AppTheme.s(11, weight: FontWeight.w700, color: gc.textTertiary, letterSpacing: 1.5)),
+ _filterLabel(gc, t.equipmentLabel),
const SizedBox(height: 8),
Wrap(spacing: 8, runSpacing: 8, children: [
for (final e in kEquipment)
@@ -478,7 +374,7 @@ void showCreateExerciseSheet(BuildContext context, {void Function(String id)? on
),
]),
const SizedBox(height: 16),
- Text(t.levelFilter, style: AppTheme.s(11, weight: FontWeight.w700, color: gc.textTertiary, letterSpacing: 1.5)),
+ _filterLabel(gc, t.levelFilter),
const SizedBox(height: 8),
Wrap(spacing: 8, runSpacing: 8, children: [
for (final d in kDifficulties)
@@ -501,13 +397,13 @@ void showCreateExerciseSheet(BuildContext context, {void Function(String id)? on
size: 16, color: gc.textSecondary),
const SizedBox(width: 8),
Text(t.advanced,
- style: AppTheme.s(11, weight: FontWeight.w700, color: gc.textSecondary, letterSpacing: 1.5)),
+ style: AppTheme.f(11, weight: FontWeight.w700, color: gc.textSecondary, letterSpacing: 1.3)),
],
),
),
if (advanced) ...[
const SizedBox(height: 12),
- Text(t.demoMedia, style: AppTheme.s(11, weight: FontWeight.w600, color: gc.textTertiary, letterSpacing: 1.5)),
+ _filterLabel(gc, t.demoMedia),
const SizedBox(height: 8),
if (mediaPath == null)
GestureDetector(
@@ -525,9 +421,9 @@ void showCreateExerciseSheet(BuildContext context, {void Function(String id)? on
children: [
Icon(PhosphorIconsRegular.uploadSimple, size: 26, color: gc.textSecondary),
const SizedBox(height: 8),
- Text(t.addMedia, style: AppTheme.s(13, weight: FontWeight.w600, color: gc.textSecondary)),
+ Text(t.addMedia, style: AppTheme.f(13.5, weight: FontWeight.w600, color: gc.textSecondary)),
const SizedBox(height: 2),
- Text(t.mediaHint, style: AppTheme.s(11, color: gc.textTertiary)),
+ Text(t.mediaHint, style: AppTheme.f(11.5, weight: FontWeight.w500, color: gc.textTertiary)),
],
),
),
@@ -548,7 +444,8 @@ void showCreateExerciseSheet(BuildContext context, {void Function(String id)? on
child: Column(mainAxisSize: MainAxisSize.min, children: [
Icon(PhosphorIconsFill.playCircle, size: 40, color: gc.textSecondary),
const SizedBox(height: 6),
- Text(t.videoSelected, style: AppTheme.s(12, color: gc.textSecondary)),
+ Text(t.videoSelected,
+ style: AppTheme.f(12, weight: FontWeight.w500, color: gc.textSecondary)),
]),
)
: Center(child: Image.file(File(mediaPath!), fit: BoxFit.contain, alignment: Alignment.center)),
@@ -573,7 +470,7 @@ void showCreateExerciseSheet(BuildContext context, {void Function(String id)? on
child: Container(
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
decoration: BoxDecoration(color: gc.bg.withValues(alpha: 0.8), borderRadius: BorderRadius.circular(100)),
- child: Text(t.changeMedia, style: AppTheme.s(11, weight: FontWeight.w600, color: gc.text)),
+ child: Text(t.changeMedia, style: AppTheme.f(11.5, weight: FontWeight.w600, color: gc.text)),
),
),
),
@@ -609,3 +506,121 @@ void showCreateExerciseSheet(BuildContext context, {void Function(String id)? on
),
);
}
+
+
+void _clearFilters(VoidCallback? onClear) {
+ fit.clearExFilters();
+ onClear?.call();
+}
+
+void showExerciseFilters(BuildContext context, {VoidCallback? onClear}) {
+ final gc = context.gc;
+ showModalBottomSheet<void>(
+ context: context,
+ backgroundColor: Colors.transparent,
+ isScrollControlled: true,
+ builder: (sheet) => StatefulBuilder(
+ builder: (sheet, setSheet) => Container(
+ padding: sheetPad(sheet),
+ constraints: BoxConstraints(maxHeight: MediaQuery.sizeOf(sheet).height * 0.85),
+ decoration: BoxDecoration(
+ color: gc.bgRaised,
+ border: Border.all(color: gc.border),
+ borderRadius: const BorderRadius.vertical(top: Radius.circular(28)),
+ ),
+ child: SingleChildScrollView(
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ crossAxisAlignment: CrossAxisAlignment.stretch,
+ children: [
+ const SheetHandle(),
+ const SizedBox(height: 18),
+ Text(titleCase(t.filters),
+ textAlign: TextAlign.center,
+ style: AppTheme.f(19, weight: FontWeight.w800, color: gc.text)),
+ const SizedBox(height: 18),
+ _filterLabel(gc, t.placeFilterLabel),
+ const SizedBox(height: 8),
+ _chipRow([
+ _FilterChipData(t.placeAll, fit.activePlaceId.isEmpty,
+ () => setSheet(() => fit.setActivePlace(''))),
+ for (final place in fit.places)
+ _FilterChipData(place.name, fit.activePlaceId == place.id,
+ () => setSheet(() => fit.setActivePlace(place.id))),
+ _FilterChipData(fit.places.isEmpty ? t.placeNew : '+', false, () {
+ Navigator.pop(sheet);
+ fit.goPlaces();
+ }),
+ ], gc, hPad: 14, vPad: 8, fontSize: 13),
+ const SizedBox(height: 16),
+ _filterLabel(gc, t.muscleFilter),
+ const SizedBox(height: 8),
+ _chipRow([
+ for (final id in kFilterMuscles)
+ _FilterChipData(muscleLabel(id), fit.exMuscleFilter == id,
+ () => setSheet(() => fit.setMuscleFilter(id))),
+ ], gc, hPad: 14, vPad: 8, fontSize: 13),
+ const SizedBox(height: 16),
+ _filterLabel(gc, t.equipmentLabel),
+ const SizedBox(height: 8),
+ _chipRow([
+ _FilterChipData(
+ t.noGearOnly, fit.exNoGearOnly, () => setSheet(fit.toggleNoGearFilter)),
+ for (final e in kFilterEquipment)
+ _FilterChipData(t.equipment(e), fit.exEquipmentFilter == e,
+ () => setSheet(() => fit.setEquipmentFilter(e))),
+ ], gc, hPad: 12, vPad: 6, fontSize: 12),
+ const SizedBox(height: 16),
+ _filterLabel(gc, t.levelFilter),
+ const SizedBox(height: 8),
+ _chipRow([
+ for (final d in kDifficulties)
+ _FilterChipData(t.difficulty(d), fit.exDifficultyFilter == d,
+ () => setSheet(() => fit.setDifficultyFilter(d))),
+ ], gc, hPad: 12, vPad: 6, fontSize: 12),
+ const SizedBox(height: 22),
+ PrimaryButton(
+ label: t.libraryCount(fit.exercisesFiltered.length),
+ onTap: () => Navigator.pop(sheet)),
+ const SizedBox(height: 6),
+ GestureDetector(
+ behavior: HitTestBehavior.opaque,
+ onTap: () => setSheet(() => _clearFilters(onClear)),
+ child: Container(
+ height: 44,
+ alignment: Alignment.center,
+ child: Text(t.clearFilters,
+ style: AppTheme.f(13, weight: FontWeight.w600, color: gc.accent)),
+ ),
+ ),
+ ],
+ ),
+ ),
+ ),
+ ),
+ );
+}
+
+Widget _filterLabel(GymColors gc, String label) => Text(label.toUpperCase(),
+ style: AppTheme.f(10.5, weight: FontWeight.w700, color: gc.textTertiary, letterSpacing: 1.3));
+
+Widget _chipRow(List<_FilterChipData> chips, GymColors gc,
+ {required double hPad, required double vPad, required double fontSize}) {
+ return SingleChildScrollView(
+ scrollDirection: Axis.horizontal,
+ child: Row(children: [
+ for (int i = 0; i < chips.length; i++) ...[
+ Pill(
+ label: chips[i].label,
+ bg: chips[i].active ? gc.ember : gc.bgRaised2,
+ fg: chips[i].active ? gc.onEmber : gc.textSecondary,
+ onTap: chips[i].onTap,
+ hPad: hPad,
+ vPad: vPad,
+ fontSize: fontSize,
+ ),
+ if (i < chips.length - 1) const SizedBox(width: 8),
+ ],
+ ]),
+ );
+}
diff --git a/lib/state/library_state.dart b/lib/state/library_state.dart
index 1751611..3d57ea4 100644
--- a/lib/state/library_state.dart
+++ b/lib/state/library_state.dart
@@ -6,6 +6,7 @@ mixin LibraryState on FitCore {
String? exDifficultyFilter;
String? exEquipmentFilter;
String? activeExerciseId;
+ int _customSeq = 0;
List<Exercise> get allExercises => [...kExercises, ...customExercises];
Exercise? exerciseById(String id) {
@@ -66,9 +67,11 @@ mixin LibraryState on FitCore {
int get favouriteCount => favorites.values.where((v) => v).length;
- List<Exercise> get exercisesFiltered {
- final matchesSearch = exerciseSearch(exSearch);
- return allExercises.where((ex) {
+ List<Exercise> get exercisesFiltered => exercisesMatching(exSearch);
+
+ List<Exercise> exercisesMatching(String query) {
+ final matchesSearch = exerciseSearch(query);
+ final list = allExercises.where((ex) {
if (exFavouritesOnly && favorites[ex.id] != true) return false;
if (!matchesSearch(ex)) return false;
if (exMuscleFilter != null &&
@@ -80,6 +83,21 @@ mixin LibraryState on FitCore {
if (exEquipmentFilter != null && ex.equipment != exEquipmentFilter) return false;
return true;
}).toList();
+ final muscle = exMuscleFilter;
+ if (muscle == null) return _groupedByMuscle(list);
+ final primary = list.where((ex) => ex.primary == muscle);
+ final secondary = _groupedByMuscle(list.where((ex) => ex.primary != muscle).toList());
+ return [...primary, ...secondary];
+ }
+
+ List<Exercise> _groupedByMuscle(List<Exercise> list) {
+ final order = {for (var i = 0; i < kMuscles.length; i++) kMuscles[i].id: i};
+ final seats = [
+ for (var i = 0; i < list.length; i++)
+ (ex: list[i], muscle: order[list[i].primary] ?? kMuscles.length, seat: i),
+ ]..sort((a, b) =>
+ a.muscle == b.muscle ? a.seat.compareTo(b.seat) : a.muscle.compareTo(b.muscle));
+ return [for (final s in seats) s.ex];
}
Exercise get activeExercise =>
@@ -98,7 +116,7 @@ mixin LibraryState on FitCore {
required String equipment,
String difficulty = 'Beginner',
}) {
- final id = 'c${DateTime.now().microsecondsSinceEpoch}';
+ final id = 'c${DateTime.now().microsecondsSinceEpoch}-${_customSeq++}';
customExercises.add(Exercise(
id: id,
name: name.trim(),
diff --git a/lib/widgets/exercise_art.dart b/lib/widgets/exercise_art.dart
index 8abcde8..bc6659b 100644
--- a/lib/widgets/exercise_art.dart
+++ b/lib/widgets/exercise_art.dart
@@ -4,7 +4,7 @@ import 'package:flutter/foundation.dart' show SynchronousFuture;
import 'package:flutter/material.dart';
import 'package:flutter/services.dart' show rootBundle;
import 'package:path_drawing/path_drawing.dart';
-import 'package:phosphor_flutter/phosphor_flutter.dart';
+import 'package:phosphoricons_flutter/phosphoricons_flutter.dart';
import '../theme/app_colors.dart';
@@ -53,12 +53,14 @@ class ExerciseArt extends StatefulWidget {
this.height = 210,
this.radius = 20,
this.live = false,
+ this.bordered = true,
});
final String slug;
final double height;
final double radius;
final bool live;
+ final bool bordered;
@override
State<ExerciseArt> createState() => _ExerciseArtState();
@@ -145,7 +147,7 @@ class _ExerciseArtState extends State<ExerciseArt> with SingleTickerProviderStat
decoration: BoxDecoration(
color: gc.bgRaised2,
borderRadius: BorderRadius.circular(widget.radius),
- border: Border.all(color: gc.border),
+ border: widget.bordered ? Border.all(color: gc.border) : null,
),
clipBehavior: Clip.antiAlias,
child: child,
diff --git a/lib/widgets/exercise_media.dart b/lib/widgets/exercise_media.dart
index ea33150..79fd173 100644
--- a/lib/widgets/exercise_media.dart
+++ b/lib/widgets/exercise_media.dart
@@ -1,7 +1,7 @@
import 'dart:io';
import 'package:flutter/material.dart';
-import 'package:phosphor_flutter/phosphor_flutter.dart';
+import 'package:phosphoricons_flutter/phosphoricons_flutter.dart';
import 'package:video_player/video_player.dart';
import '../models/exercise.dart';
@@ -17,19 +17,22 @@ class ExerciseMedia extends StatelessWidget {
this.height = 210,
this.radius = 20,
this.live = false,
+ this.bordered = true,
});
final Exercise ex;
final double height;
final double radius;
final bool live;
+ final bool bordered;
@override
Widget build(BuildContext context) {
final media = fit.mediaFor(ex.id);
final path = media.isEmpty ? null : MediaStore.pathFor(media);
if (path == null) {
- return ExerciseArt(slug: ex.art, height: height, radius: radius, live: live);
+ return ExerciseArt(
+ slug: ex.art, height: height, radius: radius, live: live, bordered: bordered);
}
final isVideo = MediaStore.isVideo(media);
if (isVideo && live) {
@@ -38,6 +41,7 @@ class ExerciseMedia extends StatelessWidget {
return _MediaFrame(
height: height,
radius: radius,
+ bordered: bordered,
child: isVideo
? _VideoPoster(height: height)
: Center(
@@ -60,10 +64,15 @@ Widget _fallbackIcon(BuildContext context, double height) => Center(
);
class _MediaFrame extends StatelessWidget {
- const _MediaFrame({required this.child, required this.height, required this.radius});
+ const _MediaFrame(
+ {required this.child,
+ required this.height,
+ required this.radius,
+ this.bordered = true});
final Widget child;
final double height;
final double radius;
+ final bool bordered;
@override
Widget build(BuildContext context) {
@@ -73,7 +82,7 @@ class _MediaFrame extends StatelessWidget {
decoration: BoxDecoration(
color: gc.bgRaised2,
borderRadius: BorderRadius.circular(radius),
- border: Border.all(color: gc.border),
+ border: bordered ? Border.all(color: gc.border) : null,
),
clipBehavior: Clip.antiAlias,
child: child,