Skip to content

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

Say the exercise names thing in the changelogs

InlitX95a026ab7047
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index d51b47f..739fcae 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -26,7 +26,7 @@ Anything that keeps working on a phone in flight mode is fair game.
```bash
flutter pub get
-flutter test # 220+ tests, all of them should pass
+flutter test # 350+ tests, all of them should pass
flutter run
```
@@ -47,14 +47,18 @@ lib/
└── widgets/ shared UI pieces
```
+The exercise catalogue is `catalog/exercise_catalog.dart`, and
+`catalog/exercise_aliases.dart` is the plain list that lets people search an
+exercise by the name another app gives it — one line per exercise, add yours there.
+
`FitState` is the single source of truth. It lives in `state/fit_state.dart` and
is split across `part` files by area, so you can work on statistics without
scrolling past the rest of the app. `fit` is its one global instance.
## House style
-- **Almost no comments.** Names and structure carry the meaning; a short comment
- is only for the rare line that genuinely fought back.
+- **No comments.** Names and structure carry the meaning; the reason for a
+ change goes in the commit message, not in the file.
- Text the user can read **always** goes through `t.<key>` and an ARB entry —
never a literal in a widget. A test enforces this.
- Prefer small widgets and pure functions. Statistics must be computed from real
diff --git a/android/app/src/main/kotlin/com/gymmane/app/BodyWidgetProvider.kt b/android/app/src/main/kotlin/com/gymmane/app/BodyWidgetProvider.kt
index fe36f41..e180b95 100644
--- a/android/app/src/main/kotlin/com/gymmane/app/BodyWidgetProvider.kt
+++ b/android/app/src/main/kotlin/com/gymmane/app/BodyWidgetProvider.kt
@@ -9,8 +9,6 @@ import android.graphics.BitmapFactory
import android.widget.RemoteViews
import es.antonborri.home_widget.HomeWidgetProvider
-/// Widget del mapa muscular: solo muestra el PNG que renderiza Flutter
-/// (WidgetBridge -> home_widget). Al tocarlo abre la app.
class BodyWidgetProvider : HomeWidgetProvider() {
override fun onUpdate(
context: Context,
diff --git a/android/app/src/main/kotlin/com/gymmane/app/HeatmapWidgetProvider.kt b/android/app/src/main/kotlin/com/gymmane/app/HeatmapWidgetProvider.kt
index 8eab4ff..d454418 100644
--- a/android/app/src/main/kotlin/com/gymmane/app/HeatmapWidgetProvider.kt
+++ b/android/app/src/main/kotlin/com/gymmane/app/HeatmapWidgetProvider.kt
@@ -9,8 +9,6 @@ import android.graphics.BitmapFactory
import android.widget.RemoteViews
import es.antonborri.home_widget.HomeWidgetProvider
-/// Widget de heatmap: solo muestra el PNG que renderiza Flutter
-/// (WidgetBridge -> home_widget). Al tocarlo abre la app.
class HeatmapWidgetProvider : HomeWidgetProvider() {
override fun onUpdate(
context: Context,
diff --git a/android/app/src/main/kotlin/com/gymmane/app/StatsWidgetProvider.kt b/android/app/src/main/kotlin/com/gymmane/app/StatsWidgetProvider.kt
index 4c83aef..07c1450 100644
--- a/android/app/src/main/kotlin/com/gymmane/app/StatsWidgetProvider.kt
+++ b/android/app/src/main/kotlin/com/gymmane/app/StatsWidgetProvider.kt
@@ -9,8 +9,6 @@ import android.graphics.BitmapFactory
import android.widget.RemoteViews
import es.antonborri.home_widget.HomeWidgetProvider
-/// Widget cuadrado de estadísticas (racha + semana + objetivo). Muestra el PNG
-/// que renderiza Flutter. Al tocarlo abre la app.
class StatsWidgetProvider : HomeWidgetProvider() {
override fun onUpdate(
context: Context,
diff --git a/fastlane/metadata/android/en-US/changelogs/21.txt b/fastlane/metadata/android/en-US/changelogs/21.txt
index 867a6e5..f8b68c3 100644
--- a/fastlane/metadata/android/en-US/changelogs/21.txt
+++ b/fastlane/metadata/android/en-US/changelogs/21.txt
@@ -2,6 +2,7 @@
📝 Training journal on a calendar — a dot on every day you wrote on, notes with photos and video
📍 Places — say what kit you have and the library only offers what you can do there
🏋️ 15 kettlebell exercises and a "no kit" filter
+🔎 Coming from Hevy or Strong? Search with the exercise names you already know
📸 Progress photo timeline with before/after and a reminder — or the same timeline drawn on the muscle map
📊 Week rhythm, all-time totals and a clearer volume chart with its own axis
📐 Ten body measurements, each with its own history and curve
diff --git a/fastlane/metadata/android/en-US/changelogs/22.txt b/fastlane/metadata/android/en-US/changelogs/22.txt
index 867a6e5..f8b68c3 100644
--- a/fastlane/metadata/android/en-US/changelogs/22.txt
+++ b/fastlane/metadata/android/en-US/changelogs/22.txt
@@ -2,6 +2,7 @@
📝 Training journal on a calendar — a dot on every day you wrote on, notes with photos and video
📍 Places — say what kit you have and the library only offers what you can do there
🏋️ 15 kettlebell exercises and a "no kit" filter
+🔎 Coming from Hevy or Strong? Search with the exercise names you already know
📸 Progress photo timeline with before/after and a reminder — or the same timeline drawn on the muscle map
📊 Week rhythm, all-time totals and a clearer volume chart with its own axis
📐 Ten body measurements, each with its own history and curve
diff --git a/fastlane/metadata/android/en-US/changelogs/23.txt b/fastlane/metadata/android/en-US/changelogs/23.txt
index 867a6e5..f8b68c3 100644
--- a/fastlane/metadata/android/en-US/changelogs/23.txt
+++ b/fastlane/metadata/android/en-US/changelogs/23.txt
@@ -2,6 +2,7 @@
📝 Training journal on a calendar — a dot on every day you wrote on, notes with photos and video
📍 Places — say what kit you have and the library only offers what you can do there
🏋️ 15 kettlebell exercises and a "no kit" filter
+🔎 Coming from Hevy or Strong? Search with the exercise names you already know
📸 Progress photo timeline with before/after and a reminder — or the same timeline drawn on the muscle map
📊 Week rhythm, all-time totals and a clearer volume chart with its own axis
📐 Ten body measurements, each with its own history and curve
diff --git a/fastlane/metadata/android/es-ES/changelogs/21.txt b/fastlane/metadata/android/es-ES/changelogs/21.txt
index 0e86cbd..ccef895 100644
--- a/fastlane/metadata/android/es-ES/changelogs/21.txt
+++ b/fastlane/metadata/android/es-ES/changelogs/21.txt
@@ -2,6 +2,7 @@
📝 Diario en calendario — un punto en cada día que escribiste, con fotos y vídeo
📍 Sitios — di qué material tienes y la biblioteca solo te ofrece lo que puedes hacer ahí
🏋️ 15 ejercicios de kettlebell y filtro de "sin material"
+🔎 ¿Vienes de Hevy o Strong? Busca con los nombres de ejercicio que ya te sabes
📸 Evolución en fotos con antes/después y aviso — o la misma evolución dibujada en el muñeco
📊 Ritmo semanal, totales de siempre y una gráfica de volumen con sus números
📐 Diez medidas del cuerpo, cada una con su historial y su curva
diff --git a/fastlane/metadata/android/es-ES/changelogs/22.txt b/fastlane/metadata/android/es-ES/changelogs/22.txt
index 0e86cbd..ccef895 100644
--- a/fastlane/metadata/android/es-ES/changelogs/22.txt
+++ b/fastlane/metadata/android/es-ES/changelogs/22.txt
@@ -2,6 +2,7 @@
📝 Diario en calendario — un punto en cada día que escribiste, con fotos y vídeo
📍 Sitios — di qué material tienes y la biblioteca solo te ofrece lo que puedes hacer ahí
🏋️ 15 ejercicios de kettlebell y filtro de "sin material"
+🔎 ¿Vienes de Hevy o Strong? Busca con los nombres de ejercicio que ya te sabes
📸 Evolución en fotos con antes/después y aviso — o la misma evolución dibujada en el muñeco
📊 Ritmo semanal, totales de siempre y una gráfica de volumen con sus números
📐 Diez medidas del cuerpo, cada una con su historial y su curva
diff --git a/fastlane/metadata/android/es-ES/changelogs/23.txt b/fastlane/metadata/android/es-ES/changelogs/23.txt
index 0e86cbd..ccef895 100644
--- a/fastlane/metadata/android/es-ES/changelogs/23.txt
+++ b/fastlane/metadata/android/es-ES/changelogs/23.txt
@@ -2,6 +2,7 @@
📝 Diario en calendario — un punto en cada día que escribiste, con fotos y vídeo
📍 Sitios — di qué material tienes y la biblioteca solo te ofrece lo que puedes hacer ahí
🏋️ 15 ejercicios de kettlebell y filtro de "sin material"
+🔎 ¿Vienes de Hevy o Strong? Busca con los nombres de ejercicio que ya te sabes
📸 Evolución en fotos con antes/después y aviso — o la misma evolución dibujada en el muñeco
📊 Ritmo semanal, totales de siempre y una gráfica de volumen con sus números
📐 Diez medidas del cuerpo, cada una con su historial y su curva
diff --git a/lib/app/app_shell.dart b/lib/app/app_shell.dart
index 188d97a..55d0c3c 100644
--- a/lib/app/app_shell.dart
+++ b/lib/app/app_shell.dart
@@ -18,14 +18,15 @@ import '../screens/routine_edit_screen.dart';
import '../screens/routines_screen.dart';
import '../screens/session_screen.dart';
import '../screens/settings_screen.dart';
-import '../screens/tool_detail_screen.dart';
import '../screens/timeline_screen.dart';
+import '../screens/tool_detail_screen.dart';
import '../screens/tools_screen.dart';
import '../screens/train_screen.dart';
import '../state/fit_state.dart';
import '../theme/app_colors.dart';
import '../theme/app_theme.dart';
import '../widgets/app_background.dart';
+import '../widgets/dialogs.dart';
class AppShell extends StatefulWidget {
const AppShell({super.key});
@@ -55,7 +56,6 @@ class _AppShellState extends State<AppShell> with WidgetsBindingObserver {
state == AppLifecycleState.detached) {
fit.persistNow();
}
- // al volver de los ajustes del sistema el permiso puede haber cambiado
if (state == AppLifecycleState.resumed) fit.refreshAlarmPermission();
}
@@ -96,30 +96,13 @@ class _AppShellState extends State<AppShell> with WidgetsBindingObserver {
);
}
- Future<bool> _confirmDiscard(BuildContext context) async {
- final gc = context.gc;
- final ok = await showDialog<bool>(
- context: context,
- builder: (dctx) => AlertDialog(
- backgroundColor: gc.bgRaised,
- shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)),
- title: Text(t.discardTitle, style: AppTheme.d(18, weight: FontWeight.w700, color: gc.text)),
- content: Text(t.discardBody,
- style: AppTheme.s(13, color: gc.textSecondary)),
- actions: [
- TextButton(
- onPressed: () => Navigator.of(dctx).pop(false),
- child: Text(t.keepTraining, style: AppTheme.s(14, color: gc.textSecondary)),
- ),
- TextButton(
- onPressed: () => Navigator.of(dctx).pop(true),
- child: Text(t.discard, style: AppTheme.s(14, weight: FontWeight.w700, color: gc.accent)),
- ),
- ],
- ),
- );
- return ok ?? false;
- }
+ Future<bool> _confirmDiscard(BuildContext context) => askConfirm(
+ context,
+ title: t.discardTitle,
+ body: t.discardBody,
+ cancelLabel: t.keepTraining,
+ confirmLabel: t.discard,
+ );
Widget _animatedScreen() {
return AnimatedSwitcher(
diff --git a/lib/catalog/exercise_aliases.dart b/lib/catalog/exercise_aliases.dart
new file mode 100644
index 0000000..c3078f4
--- /dev/null
+++ b/lib/catalog/exercise_aliases.dart
@@ -0,0 +1,150 @@
+const Map<String, List<String>> kExerciseAliases = {
+ 'Alternate Lateral Pulldown': ['Lat Pulldown Single Arm (Cable)'],
+ 'Assisted Chest Dip (Kneeling)': ['Chest Dip (Assisted)'],
+ 'Assisted Pull-up': ['Pull Up (Assisted)', 'Assisted Pull Up (Machine)'],
+ 'Band Pull-Apart': ['Band Pullaparts'],
+ 'Barbell Bench Press': ['Bench Press (Barbell)', 'Flat Bench Press'],
+ 'Barbell Bent Over Row': ['Bent Over Row (Barbell)', 'Barbell Row'],
+ 'Barbell Clean and Press': ['Clean and Press (Barbell)'],
+ 'Barbell Close-grip Bench Press': ['Close Grip Bench Press (Barbell)'],
+ 'Barbell Curl': ['Bicep Curl (Barbell)', 'Barbell Bicep Curl'],
+ 'Barbell Deadlift': ['Deadlift (Barbell)', 'Conventional Deadlift'],
+ 'Barbell Decline Bench Press': ['Decline Bench Press (Barbell)'],
+ 'Barbell Front Squat': ['Front Squat (Barbell)'],
+ 'Barbell Full Squat': [
+ 'Squat (Barbell)',
+ 'Back Squat',
+ 'Back Squat (Barbell)',
+ 'Barbell Squat',
+ 'High Bar Squat',
+ ],
+ 'Barbell Glute Bridge': ['Glute Bridge (Barbell)'],
+ 'Barbell Good Morning': ['Good Morning (Barbell)'],
+ 'Barbell Hack Squat': ['Hack Squat (Barbell)'],
+ 'Barbell Incline Bench Press': ['Incline Bench Press (Barbell)'],
+ 'Barbell Lying Triceps Extension': ['Skullcrusher (Barbell)', 'Lying Triceps Extension (Barbell)'],
+ 'Barbell Overhead Squat': ['Overhead Squat (Barbell)'],
+ 'Barbell Pendlay Row': ['Pendlay Row (Barbell)'],
+ 'Barbell Preacher Curl': ['Preacher Curl (Barbell)'],
+ 'Barbell Reverse Curl': ['Reverse Curl (Barbell)'],
+ 'Barbell Reverse Wrist Curl': ['Reverse Wrist Curl (Barbell)'],
+ 'Barbell Rollerout': ['Ab Wheel', 'Ab Wheel Rollout'],
+ 'Barbell Romanian Deadlift': ['Romanian Deadlift (Barbell)'],
+ 'Barbell Seated Calf Raise': ['Seated Calf Raise (Barbell)'],
+ 'Barbell Shrug': ['Shrug (Barbell)'],
+ 'Barbell Single Leg Split Squat': ['Bulgarian Split Squat (Barbell)'],
+ 'Barbell Standing Calf Raise': ['Standing Calf Raise (Barbell)'],
+ 'Barbell Standing Wide Military Press': [
+ 'Overhead Press (Barbell)',
+ 'Shoulder Press (Barbell)',
+ 'Military Press (Barbell)',
+ 'Standing Military Press',
+ ],
+ 'Barbell Straight Leg Deadlift': ['Stiff Leg Deadlift (Barbell)'],
+ 'Barbell Sumo Deadlift': ['Sumo Deadlift (Barbell)'],
+ 'Barbell Wrist Curl': ['Wrist Curl (Barbell)'],
+ 'Belt Squat': ['Belt Squat (Machine)'],
+ 'Bench Dip (Knees Bent)': ['Bench Dip'],
+ 'Bicycle Crunch': ['Bicycle Crunch (Bodyweight)'],
+ 'Bodyweight Squat': ['Squat', 'Squat (Bodyweight)', 'Air Squat'],
+ 'Cable Cross-over Variation': ['Cable Fly Crossovers', 'Chest Fly (Cable)'],
+ 'Cable Curl': ['Bicep Curl (Cable)'],
+ 'Cable Front Raise': ['Front Raise (Cable)'],
+ 'Cable Hammer Curl (With Rope)': ['Hammer Curl (Cable)'],
+ 'Cable Kickback': ['Triceps Kickback (Cable)'],
+ 'Cable Kneeling Crunch': ['Cable Crunch', 'Kneeling Crunch (Cable)'],
+ 'Cable Lateral Raise': ['Lateral Raise (Cable)'],
+ 'Cable Overhead Triceps Extension (Rope Attachment)': [
+ 'Triceps Extension (Cable)',
+ 'Overhead Tricep Extension (Cable)',
+ ],
+ 'Cable Pulldown': ['Lat Pulldown (Cable)', 'Lat Pulldown (Machine)', 'Lat Pulldown'],
+ 'Cable Pushdown': ['Triceps Pushdown (Cable)', 'Tricep Pushdown'],
+ 'Cable Seated Row': ['Seated Cable Row', 'Seated Row (Cable)', 'Seated Cable Row - Bar Grip'],
+ 'Cable Shrug': ['Shrug (Cable)'],
+ 'Chin-up': ['Chin Up'],
+ 'Close-Grip Lat Pulldown': ['Lat Pulldown - Close Grip (Cable)'],
+ 'Crunch Floor': ['Crunch', 'Crunch (Bodyweight)'],
+ 'Dumbbell Alternate Preacher Curl': ['Preacher Curl (Dumbbell)'],
+ 'Dumbbell Arnold Press': ['Arnold Press (Dumbbell)'],
+ 'Dumbbell Bench Press': ['Bench Press (Dumbbell)'],
+ 'Dumbbell Bent Over Row': ['Bent Over Row (Dumbbell)'],
+ 'Dumbbell Biceps Curl': ['Bicep Curl (Dumbbell)', 'Dumbbell Bicep Curl'],
+ 'Dumbbell Concentration Curl': ['Concentration Curl (Dumbbell)'],
+ 'Dumbbell Deadlift': ['Deadlift (Dumbbell)'],
+ 'Dumbbell Decline Bench Press': ['Decline Bench Press (Dumbbell)'],
+ 'Dumbbell Fly': ['Chest Fly (Dumbbell)', 'Dumbbell Flyes'],
+ 'Dumbbell Front Raise': ['Front Raise (Dumbbell)'],
+ 'Dumbbell Goblet Squat': ['Goblet Squat (Dumbbell)'],
+ 'Dumbbell Hammer Curl': ['Hammer Curl (Dumbbell)'],
+ 'Dumbbell Hip Thrust': ['Hip Thrust (Dumbbell)'],
+ 'Dumbbell Incline Bench Press': ['Incline Bench Press (Dumbbell)'],
+ 'Dumbbell Lateral Raise': ['Lateral Raise (Dumbbell)', 'Side Lateral Raise'],
+ 'Dumbbell Lunge': ['Lunge (Dumbbell)', 'Walking Lunge (Dumbbell)'],
+ 'Dumbbell Pullover': ['Pullover (Dumbbell)'],
+ 'Dumbbell Reverse Fly': ['Reverse Fly (Dumbbell)', 'Rear Delt Fly (Dumbbell)'],
+ 'Dumbbell Seated Calf Raise': ['Seated Calf Raise (Dumbbell)'],
+ 'Dumbbell Shrug': ['Shrug (Dumbbell)'],
+ 'Dumbbell Single Leg Split Squat': ['Bulgarian Split Squat (Dumbbell)'],
+ 'Dumbbell Standing Calf Raise': ['Standing Calf Raise (Dumbbell)'],
+ 'Dumbbell Standing Overhead Press': ['Shoulder Press (Dumbbell)', 'Overhead Press (Dumbbell)'],
+ 'Dumbbell Standing Triceps Extension': [
+ 'Triceps Extension (Dumbbell)',
+ 'Overhead Tricep Extension (Dumbbell)',
+ ],
+ 'Elliptical Trainer': ['Elliptical Machine', 'Elliptical'],
+ 'Face Pull': ['Face Pull (Cable)'],
+ 'Hip Abduction Machine': ['Hip Abduction (Machine)'],
+ 'Hip Adduction Machine': ['Hip Adduction (Machine)'],
+ 'Hip Thrust': ['Hip Thrust (Bodyweight)'],
+ 'Incline Dumbbell Curl': ['Incline Curl (Dumbbell)'],
+ 'Jump Rope': ['Skipping Rope'],
+ 'Kettlebell Farmer Carry': ['Farmers Walk', 'Farmers Carry'],
+ 'Kettlebell Goblet Squat': ['Goblet Squat (Kettlebell)'],
+ 'Kettlebell Overhead Press': ['Overhead Press (Kettlebell)'],
+ 'Kettlebell Romanian Deadlift': ['Romanian Deadlift (Kettlebell)'],
+ 'Knee Push-up': ['Knee Push Up (Bodyweight)'],
+ 'Landmine Press': ['Landmine Press (Barbell)'],
+ 'Lever Seated Reverse Fly': ['Rear Delt Reverse Fly (Machine)', 'Reverse Fly (Machine)'],
+ 'Lever Seated Row': ['Seated Row (Machine)', 'Iso-Lateral Row (Machine)'],
+ 'Lever Shoulder Press': ['Shoulder Press (Machine)', 'Seated Shoulder Press (Machine)'],
+ 'Lever Shrug': ['Shrug (Machine)'],
+ 'Lever Standing Calf Raise': ['Standing Calf Raise (Machine)', 'Calf Raise (Machine)'],
+ 'Lever Standing Chest Press': ['Chest Press (Machine)', 'Seated Chest Press (Machine)'],
+ 'Lever T Bar Row': ['T Bar Row', 'T Bar Row (Machine)'],
+ 'Lever Triceps Extension': ['Triceps Extension (Machine)'],
+ 'Lying Leg Raise': ['Leg Raise (Bodyweight)'],
+ 'Machine Glute Kickback': ['Glute Kickback (Machine)'],
+ 'Machine Lateral Raise': ['Lateral Raise (Machine)'],
+ 'Meadows Row': ['Meadows Row (Barbell)'],
+ 'One-Arm Dumbbell Row': ['Single Arm Dumbbell Row', 'Dumbbell Row'],
+ 'Pec Deck': ['Chest Fly (Machine)', 'Pec Deck (Machine)', 'Butterfly (Machine)'],
+ 'Power Clean': ['Power Clean (Barbell)'],
+ 'Pull-up': ['Pull Up'],
+ 'Push-up': ['Push Up (Bodyweight)', 'Press Up'],
+ 'Reverse Lunge': ['Reverse Lunge (Bodyweight)'],
+ 'Rope Tricep Pushdown': ['Triceps Rope Pushdown (Cable)'],
+ 'Rowing Machine': ['Rowing (Machine)', 'Rowing'],
+ 'Russian Twist': ['Russian Twist (Bodyweight)'],
+ 'Seated Leg Curl': ['Leg Curl (Machine)', 'Seated Leg Curl (Machine)'],
+ 'Single Dumbbell Skullcrusher': ['Skullcrusher (Dumbbell)'],
+ 'Single-Arm Cable Row': ['Seated Row Single Arm (Cable)'],
+ 'Ski Erg': ['Ski Machine'],
+ 'Smith Bench Press': ['Bench Press (Smith Machine)'],
+ 'Smith Hack Squat': ['Hack Squat (Machine)'],
+ 'Smith Machine Bicep Curl': ['Bicep Curl (Smith Machine)'],
+ 'Smith Machine Bulgarian Split Squat': ['Bulgarian Split Squat (Smith Machine)'],
+ 'Smith Seated Shoulder Press': ['Shoulder Press (Smith Machine)'],
+ 'Stair Climber': ['Stair Machine', 'Stairmaster'],
+ 'Stationary Bike': ['Cycling (Indoor)', 'Cycling'],
+ 'Trap Bar Deadlift': ['Deadlift (Trap Bar)', 'Hex Bar Deadlift'],
+ 'Treadmill Run': ['Running (Treadmill)', 'Running'],
+ 'Treadmill Walk': ['Walking (Treadmill)', 'Walking'],
+ 'Triceps Dip': ['Triceps Dip (Bodyweight)', 'Tricep Dip'],
+ 'Upright Row': ['Upright Row (Barbell)', 'Upright Row (Cable)'],
+ 'Weighted Front Plank': ['Plank', 'Front Plank'],
+ 'Weighted Hanging Leg-hip Raise': ['Hanging Leg Raise'],
+ 'Weighted Pull-up': ['Pull Up (Weighted)'],
+ 'Weighted Russian Twist': ['Russian Twist (Weighted)'],
+ 'Wide-Grip Lat Pulldown': ['Lat Pulldown - Wide Grip (Cable)'],
+};
diff --git a/lib/screens/about_screen.dart b/lib/screens/about_screen.dart
index 43185c4..02752ce 100644
--- a/lib/screens/about_screen.dart
+++ b/lib/screens/about_screen.dart
@@ -7,7 +7,6 @@ import '../l10n/l10n.dart';
import '../state/fit_state.dart';
import '../theme/app_colors.dart';
import '../theme/app_theme.dart';
-import '../widgets/svg_icon.dart';
import '../widgets/ui_kit.dart';
const _kVersion = '1.1.0';
@@ -29,11 +28,12 @@ class AboutScreen extends StatelessWidget {
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
- Row(children: [
- RoundBtn(icon: Ic.chevronLeft, onTap: fit.backFromAbout),
- const SizedBox(width: 12),
- Text(t.about, style: AppTheme.d(18, weight: FontWeight.w700, color: gc.text, letterSpacing: 1)),
- ]),
+ ScreenHeader(
+ title: t.about,
+ onBack: fit.backFromAbout,
+ titleSize: 18,
+ titleSpacing: 1,
+ ),
const SizedBox(height: 20),
_hero(gc),
const SizedBox(height: 24),
diff --git a/lib/screens/compare_screen.dart b/lib/screens/compare_screen.dart
index ae54e3a..2d96fad 100644
--- a/lib/screens/compare_screen.dart
+++ b/lib/screens/compare_screen.dart
@@ -10,7 +10,6 @@ import '../state/fit_state.dart';
import '../theme/app_colors.dart';
import '../theme/app_theme.dart';
import '../widgets/share_cards.dart';
-import '../widgets/svg_icon.dart';
import '../widgets/ui_kit.dart';
import 'share_sheet.dart';
@@ -34,27 +33,14 @@ class CompareScreen extends StatelessWidget {
children: [
Padding(
padding: const EdgeInsets.fromLTRB(20, 12, 20, 8),
- child: Row(
- children: [
- RoundBtn(icon: Ic.chevronLeft, onTap: fit.backFromCompare),
- const SizedBox(width: 12),
- Expanded(child: ScreenTitle(t.compare, size: 20)),
- Semantics(
- button: true,
+ child: ScreenHeader(
+ title: t.compare,
+ onBack: fit.backFromCompare,
+ actions: [
+ RoundAction(
label: t.share,
- child: GestureDetector(
- onTap: () => showShareSheet(context, initial: ShareKind.compare),
- child: Container(
- width: 36,
- height: 36,
- decoration: BoxDecoration(
- color: gc.bgRaised,
- shape: BoxShape.circle,
- border: Border.all(color: gc.border),
- ),
- child: Icon(PhosphorIconsRegular.shareNetwork, size: 16, color: gc.text),
- ),
- ),
+ onTap: () => showShareSheet(context, initial: ShareKind.compare),
+ child: Icon(PhosphorIconsRegular.shareNetwork, size: 16, color: gc.text),
),
],
),
diff --git a/lib/screens/exercise_detail_screen.dart b/lib/screens/exercise_detail_screen.dart
index f7ef133..be36978 100644
--- a/lib/screens/exercise_detail_screen.dart
+++ b/lib/screens/exercise_detail_screen.dart
@@ -63,36 +63,18 @@ class _ExerciseDetailScreenState extends State<ExerciseDetailScreen> {
RoundBtn(icon: Ic.chevronLeft, onTap: fit.closeExerciseDetail),
Row(children: [
if (fit.isCustom(ex.id)) ...[
- GestureDetector(
+ RoundAction(
onTap: () {
fit.closeExerciseDetail();
fit.deleteCustomExercise(ex.id);
},
- child: Container(
- width: 36,
- height: 36,
- decoration: BoxDecoration(
- color: gc.bgRaised,
- shape: BoxShape.circle,
- border: Border.all(color: gc.border),
- ),
- child: Icon(PhosphorIconsRegular.trash, size: 16, color: gc.textSecondary),
- ),
+ child: Icon(PhosphorIconsRegular.trash, size: 16, color: gc.textSecondary),
),
const SizedBox(width: 10),
],
- GestureDetector(
+ RoundAction(
onTap: () => fit.toggleFavorite(ex.id),
- child: Container(
- width: 36,
- height: 36,
- decoration: BoxDecoration(
- color: gc.bgRaised,
- shape: BoxShape.circle,
- border: Border.all(color: gc.border),
- ),
- child: Center(child: _star(gc, fav)),
- ),
+ child: _star(gc, fav),
),
]),
],
diff --git a/lib/screens/exercises_screen.dart b/lib/screens/exercises_screen.dart
index 705517d..790e812 100644
--- a/lib/screens/exercises_screen.dart
+++ b/lib/screens/exercises_screen.dart
@@ -60,33 +60,7 @@ class _ExercisesScreenState extends State<ExercisesScreen> {
const SizedBox(height: 4),
Text(t.libraryCount(count), style: AppTheme.s(13, color: gc.textSecondary)),
const SizedBox(height: 14),
- Container(
- height: 48,
- padding: const EdgeInsets.symmetric(horizontal: 16),
- decoration: BoxDecoration(
- color: gc.bgRaised,
- border: Border.all(color: gc.border),
- borderRadius: BorderRadius.circular(100),
- ),
- child: Row(children: [
- SvgPathIcon(Ic.search, size: 16, color: gc.textSecondary),
- const SizedBox(width: 10),
- Expanded(
- child: TextField(
- controller: _c,
- onChanged: fit.setExSearch,
- style: AppTheme.s(14, color: gc.text),
- cursorColor: gc.accent,
- decoration: InputDecoration(
- isCollapsed: true,
- border: InputBorder.none,
- hintText: t.searchExercises,
- hintStyle: AppTheme.s(14, color: gc.textSecondary),
- ),
- ),
- ),
- ]),
- ),
+ SearchField(controller: _c, hint: t.searchExercises, onChanged: fit.setExSearch),
const SizedBox(height: 14),
GestureDetector(
behavior: HitTestBehavior.opaque,
@@ -156,25 +130,10 @@ class _ExercisesScreenState extends State<ExercisesScreen> {
_FilterChipData(t.difficulty(d), fit.exDifficultyFilter == d, () => fit.setDifficultyFilter(d)),
], gc, hPad: 12, vPad: 6, fontSize: 12),
const SizedBox(height: 14),
- GestureDetector(
+ GhostButton(
+ label: t.newExercise,
+ icon: PhosphorIconsRegular.plus,
onTap: () => showCreateExerciseSheet(context),
- child: Container(
- height: 46,
- alignment: Alignment.center,
- decoration: BoxDecoration(
- border: Border.all(color: gc.border),
- borderRadius: BorderRadius.circular(14),
- ),
- child: Row(
- mainAxisSize: MainAxisSize.min,
- children: [
- Icon(PhosphorIconsRegular.plus, size: 16, color: gc.ember),
- const SizedBox(width: 8),
- Text(t.newExercise,
- style: AppTheme.d(13, weight: FontWeight.w600, color: gc.text, letterSpacing: 1)),
- ],
- ),
- ),
),
const SizedBox(height: 14),
],
diff --git a/lib/screens/measures_screen.dart b/lib/screens/measures_screen.dart
index 2b5150b..8fd61b6 100644
--- a/lib/screens/measures_screen.dart
+++ b/lib/screens/measures_screen.dart
@@ -25,22 +25,10 @@ class MeasuresScreen extends StatelessWidget {
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
- Row(
- children: [
- RoundBtn(icon: Ic.chevronLeft, onTap: fit.backFromMeasures),
- const SizedBox(width: 12),
- Expanded(
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- ScreenTitle(t.measures, size: 20),
- const SizedBox(height: 2),
- Text(t.measureCount(fit.measures.length),
- style: AppTheme.s(12.5, color: gc.textSecondary)),
- ],
- ),
- ),
- ],
+ ScreenHeader(
+ title: t.measures,
+ subtitle: t.measureCount(fit.measures.length),
+ onBack: fit.backFromMeasures,
),
const SizedBox(height: 14),
Text(t.measuresHint, style: AppTheme.s(13, color: gc.textSecondary, height: 1.5)),
@@ -186,12 +174,7 @@ class _MeasureSheetState extends State<_MeasureSheet> {
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
- Container(
- width: 40,
- height: 4,
- margin: const EdgeInsets.symmetric(vertical: 12),
- decoration: BoxDecoration(color: gc.border, borderRadius: BorderRadius.circular(2)),
- ),
+ SheetHandle(color: gc.border, margin: const EdgeInsets.symmetric(vertical: 12)),
Padding(
padding: const EdgeInsets.fromLTRB(20, 4, 20, 20),
child: Column(
diff --git a/lib/screens/note_edit_screen.dart b/lib/screens/note_edit_screen.dart
index 9105495..d98ae12 100644
--- a/lib/screens/note_edit_screen.dart
+++ b/lib/screens/note_edit_screen.dart
@@ -5,12 +5,13 @@ import 'package:phosphor_flutter/phosphor_flutter.dart';
import '../l10n/l10n.dart';
import '../models/exercise.dart';
import '../models/note.dart';
+import '../services/exercise_match.dart';
import '../services/media_store.dart';
import '../state/fit_state.dart';
import '../theme/app_colors.dart';
import '../theme/app_theme.dart';
+import '../widgets/dialogs.dart';
import '../widgets/note_kit.dart';
-import '../widgets/svg_icon.dart';
import '../widgets/ui_kit.dart';
const int _kNoteMaxLength = 1000;
@@ -84,27 +85,14 @@ class _NoteEditScreenState extends State<NoteEditScreen> {
Future<void> _confirmDelete() async {
final note = _note;
if (note == null) return;
- final gc = context.gc;
- final ok = await showDialog<bool>(
- context: context,
- builder: (dctx) => AlertDialog(
- backgroundColor: gc.bgRaised,
- shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)),
- title: Text(t.deleteNoteTitle, style: AppTheme.d(18, weight: FontWeight.w700, color: gc.text)),
- content: Text(t.deleteNoteBody, style: AppTheme.s(13, color: gc.textSecondary)),
- actions: [
- TextButton(
- onPressed: () => Navigator.of(dctx).pop(false),
- child: Text(t.cancel, style: AppTheme.s(14, color: gc.textSecondary)),
- ),
- TextButton(
- onPressed: () => Navigator.of(dctx).pop(true),
- child: Text(t.delete, style: AppTheme.s(14, weight: FontWeight.w700, color: gc.danger)),
- ),
- ],
- ),
+ final ok = await askConfirm(
+ context,
+ title: t.deleteNoteTitle,
+ body: t.deleteNoteBody,
+ confirmLabel: t.delete,
+ danger: true,
);
- if (ok != true) return;
+ if (!ok) return;
fit.deleteNote(note.id);
fit.closeNoteEditor();
}
@@ -123,28 +111,15 @@ class _NoteEditScreenState extends State<NoteEditScreen> {
children: [
Padding(
padding: const EdgeInsets.fromLTRB(20, 12, 20, 8),
- child: Row(
- children: [
- RoundBtn(icon: Ic.chevronLeft, onTap: fit.closeNoteEditor),
- const SizedBox(width: 12),
- Expanded(child: ScreenTitle(_note == null ? t.newNote : t.editNote, size: 20)),
+ child: ScreenHeader(
+ title: _note == null ? t.newNote : t.editNote,
+ onBack: fit.closeNoteEditor,
+ actions: [
if (_note != null)
- Semantics(
- button: true,
+ RoundAction(
label: t.delete,
- child: GestureDetector(
- onTap: _confirmDelete,
- child: Container(
- width: 36,
- height: 36,
- decoration: BoxDecoration(
- color: gc.bgRaised,
- shape: BoxShape.circle,
- border: Border.all(color: gc.border),
- ),
- child: Icon(PhosphorIconsRegular.trash, size: 16, color: gc.danger),
- ),
- ),
+ onTap: _confirmDelete,
+ child: Icon(PhosphorIconsRegular.trash, size: 16, color: gc.danger),
),
],
),
@@ -339,14 +314,9 @@ class _ExercisePickerSheetState extends State<_ExercisePickerSheet> {
}
List<Exercise> get _results {
- final q = _q.text.trim().toLowerCase();
final all = fit.allExercises;
- if (q.isEmpty) return all.take(40).toList();
- return all
- .where((e) =>
- e.name.toLowerCase().contains(q) || exerciseName(e).toLowerCase().contains(q))
- .take(60)
- .toList();
+ if (_q.text.trim().isEmpty) return all.take(40).toList();
+ return all.where(exerciseSearch(_q.text)).take(60).toList();
}
@override
@@ -366,12 +336,7 @@ class _ExercisePickerSheetState extends State<_ExercisePickerSheet> {
clipBehavior: Clip.antiAlias,
child: Column(
children: [
- Container(
- width: 40,
- height: 4,
- margin: const EdgeInsets.symmetric(vertical: 12),
- decoration: BoxDecoration(color: gc.border, borderRadius: BorderRadius.circular(2)),
- ),
+ SheetHandle(color: gc.border, margin: const EdgeInsets.symmetric(vertical: 12)),
Padding(
padding: const EdgeInsets.fromLTRB(20, 0, 20, 12),
child: TextField(
diff --git a/lib/screens/notes_screen.dart b/lib/screens/notes_screen.dart
index 142cd58..01833e1 100644
--- a/lib/screens/notes_screen.dart
+++ b/lib/screens/notes_screen.dart
@@ -8,7 +8,6 @@ import '../state/fit_state.dart';
import '../theme/app_colors.dart';
import '../theme/app_theme.dart';
import '../widgets/note_kit.dart';
-import '../widgets/svg_icon.dart';
import '../widgets/ui_kit.dart';
class NotesScreen extends StatelessWidget {
@@ -26,27 +25,11 @@ class NotesScreen extends StatelessWidget {
children: [
Padding(
padding: const EdgeInsets.fromLTRB(20, 12, 20, 0),
- child: Row(
- children: [
- RoundBtn(icon: Ic.chevronLeft, onTap: fit.backFromNotes),
- const SizedBox(width: 12),
- Expanded(
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- ScreenTitle(
- scoped == null ? t.journal : exerciseName(scoped).toUpperCase(),
- size: 20,
- ),
- const SizedBox(height: 2),
- Text(
- all
- ? t.noteCount(fit.notesInScope.length)
- : t.noteMonthCount(fit.notesInMonth),
- style: AppTheme.s(12.5, color: gc.textSecondary)),
- ],
- ),
- ),
+ child: ScreenHeader(
+ title: scoped == null ? t.journal : exerciseName(scoped).toUpperCase(),
+ subtitle: all ? t.noteCount(fit.notesInScope.length) : t.noteMonthCount(fit.notesInMonth),
+ onBack: fit.backFromNotes,
+ actions: [
_action(
gc,
icon: PhosphorIconsBold.plus,
@@ -84,23 +67,12 @@ class NotesScreen extends StatelessWidget {
required VoidCallback onTap,
bool filled = false,
}) =>
- Semantics(
- button: true,
+ RoundAction(
label: label,
- child: GestureDetector(
- behavior: HitTestBehavior.opaque,
- onTap: onTap,
- child: Container(
- width: 38,
- height: 38,
- decoration: BoxDecoration(
- color: filled ? gc.ember : gc.bgRaised,
- shape: BoxShape.circle,
- border: Border.all(color: filled ? gc.ember : gc.border),
- ),
- child: Icon(icon, size: 16, color: filled ? gc.onEmber : gc.text),
- ),
- ),
+ onTap: onTap,
+ size: 38,
+ filled: filled,
+ child: Icon(icon, size: 16, color: filled ? gc.onEmber : gc.text),
);
Widget _calendar(BuildContext context, GymColors gc, bool showExercise) {
diff --git a/lib/screens/places_screen.dart b/lib/screens/places_screen.dart
index f674a8c..b526aa2 100644
--- a/lib/screens/places_screen.dart
+++ b/lib/screens/places_screen.dart
@@ -7,7 +7,7 @@ import '../models/place.dart';
import '../state/fit_state.dart';
import '../theme/app_colors.dart';
import '../theme/app_theme.dart';
-import '../widgets/svg_icon.dart';
+import '../widgets/dialogs.dart';
import '../widgets/ui_kit.dart';
class PlacesScreen extends StatelessWidget {
@@ -24,25 +24,10 @@ class PlacesScreen extends StatelessWidget {
children: [
Padding(
padding: const EdgeInsets.fromLTRB(20, 12, 20, 0),
- child: Row(
- children: [
- RoundBtn(icon: Ic.chevronLeft, onTap: fit.backFromPlaces),
- const SizedBox(width: 12),
- Expanded(
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- ScreenTitle(t.places, size: 20),
- const SizedBox(height: 2),
- Text(
- fit.activePlace == null
- ? t.placeAll
- : t.placeActive(fit.activePlace!.name),
- style: AppTheme.s(12.5, color: gc.textSecondary)),
- ],
- ),
- ),
- ],
+ child: ScreenHeader(
+ title: t.places,
+ subtitle: fit.activePlace == null ? t.placeAll : t.placeActive(fit.activePlace!.name),
+ onBack: fit.backFromPlaces,
),
),
Expanded(
@@ -284,9 +269,8 @@ class PlacesScreen extends StatelessWidget {
final controller = TextEditingController(text: place?.name ?? '');
final name = await showDialog<String>(
context: context,
- builder: (dctx) => AlertDialog(
- backgroundColor: gc.bgRaised,
- shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)),
+ builder: (dctx) => appDialog(
+ gc,
title: Text(place == null ? t.placeNew : t.editEntry,
style: AppTheme.d(18, weight: FontWeight.w700, color: gc.text)),
content: TextField(
@@ -304,14 +288,8 @@ class PlacesScreen extends StatelessWidget {
onSubmitted: (v) => Navigator.of(dctx).pop(v),
),
actions: [
- TextButton(
- onPressed: () => Navigator.of(dctx).pop(),
- child: Text(t.cancel, style: AppTheme.s(14, color: gc.textSecondary)),
- ),
- TextButton(
- onPressed: () => Navigator.of(dctx).pop(controller.text),
- child: Text(t.save, style: AppTheme.s(14, weight: FontWeight.w700, color: gc.accent)),
- ),
+ dialogAction(t.cancel, gc.textSecondary, () => Navigator.of(dctx).pop(), strong: false),
+ dialogAction(t.save, gc.accent, () => Navigator.of(dctx).pop(controller.text)),
],
),
);
@@ -325,27 +303,13 @@ class PlacesScreen extends StatelessWidget {
}
Future<void> _confirmDelete(BuildContext context, GymPlace place) async {
- final gc = context.gc;
- final ok = await showDialog<bool>(
- context: context,
- builder: (dctx) => AlertDialog(
- backgroundColor: gc.bgRaised,
- shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)),
- title: Text(t.placeDeleteTitle,
- style: AppTheme.d(18, weight: FontWeight.w700, color: gc.text)),
- content: Text(t.placeDeleteBody, style: AppTheme.s(13, color: gc.textSecondary)),
- actions: [
- TextButton(
- onPressed: () => Navigator.of(dctx).pop(false),
- child: Text(t.cancel, style: AppTheme.s(14, color: gc.textSecondary)),
- ),
- TextButton(
- onPressed: () => Navigator.of(dctx).pop(true),
- child: Text(t.delete, style: AppTheme.s(14, weight: FontWeight.w700, color: gc.danger)),
- ),
- ],
- ),
+ final ok = await askConfirm(
+ context,
+ title: t.placeDeleteTitle,
+ body: t.placeDeleteBody,
+ confirmLabel: t.delete,
+ danger: true,
);
- if (ok == true) fit.deletePlace(place.id);
+ if (ok) fit.deletePlace(place.id);
}
}
diff --git a/lib/screens/progress_screen.dart b/lib/screens/progress_screen.dart
index a1f97c8..c88c50a 100644
--- a/lib/screens/progress_screen.dart
+++ b/lib/screens/progress_screen.dart
@@ -12,6 +12,7 @@ import '../theme/app_colors.dart';
import '../theme/app_theme.dart';
import '../widgets/body_map.dart';
import '../widgets/charts.dart';
+import '../widgets/dialogs.dart';
import '../widgets/svg_icon.dart';
import '../widgets/ui_kit.dart';
import 'share_sheet.dart';
@@ -809,13 +810,7 @@ class _DaySheet extends StatelessWidget {
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
- Center(
- child: Container(
- width: 40,
- height: 4,
- decoration: BoxDecoration(color: gc.bgRaised2, borderRadius: BorderRadius.circular(2)),
- ),
- ),
+ const SheetHandle(),
const SizedBox(height: 18),
Text(t.longDate(date),
style: AppTheme.d(20, weight: FontWeight.w700, color: gc.text)),
@@ -884,28 +879,13 @@ class _DaySheet extends StatelessWidget {
}
Future<void> _confirmResume(BuildContext context, LoggedSession s) async {
- final gc = context.gc;
- final ok = await showDialog<bool>(
- context: context,
- builder: (dctx) => AlertDialog(
- backgroundColor: gc.bgRaised,
- shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)),
- title: Text(t.continueWorkout, style: AppTheme.d(18, weight: FontWeight.w700, color: gc.text)),
- content: Text(t.continueWorkoutBody, style: AppTheme.s(13, color: gc.textSecondary)),
- actions: [
- TextButton(
- onPressed: () => Navigator.of(dctx).pop(false),
- child: Text(t.cancel, style: AppTheme.s(14, color: gc.textSecondary)),
- ),
- TextButton(
- onPressed: () => Navigator.of(dctx).pop(true),
- child: Text(t.continueWorkout,
- style: AppTheme.s(14, weight: FontWeight.w700, color: gc.accent)),
- ),
- ],
- ),
+ final ok = await askConfirm(
+ context,
+ title: t.continueWorkout,
+ body: t.continueWorkoutBody,
+ confirmLabel: t.continueWorkout,
);
- if (ok != true || !context.mounted) return;
+ if (!ok || !context.mounted) return;
Navigator.of(context).pop();
fit.resumeLoggedSession(s);
}
@@ -968,27 +948,13 @@ class _DaySheet extends StatelessWidget {
}
Future<void> _confirmDelete(BuildContext context, LoggedSession s, LoggedExercise e) async {
- final gc = context.gc;
- final ok = await showDialog<bool>(
- context: context,
- builder: (dctx) => AlertDialog(
- backgroundColor: gc.bgRaised,
- shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)),
- title: Text(t.deleteEntry, style: AppTheme.d(18, weight: FontWeight.w700, color: gc.text)),
- content: Text(t.deleteEntryBody(t.catalogName(e.id, e.name)), style: AppTheme.s(13, color: gc.textSecondary)),
- actions: [
- TextButton(
- onPressed: () => Navigator.of(dctx).pop(false),
- child: Text(t.cancel, style: AppTheme.s(14, color: gc.textSecondary)),
- ),
- TextButton(
- onPressed: () => Navigator.of(dctx).pop(true),
- child: Text(t.delete, style: AppTheme.s(14, weight: FontWeight.w700, color: gc.accent)),
- ),
- ],
- ),
+ final ok = await askConfirm(
+ context,
+ title: t.deleteEntry,
+ body: t.deleteEntryBody(t.catalogName(e.id, e.name)),
+ confirmLabel: t.delete,
);
- if (ok == true) fit.deleteLoggedExercise(s, e);
+ if (ok) fit.deleteLoggedExercise(s, e);
}
Widget _stat(GymColors gc, String label, String value) {
@@ -1038,11 +1004,7 @@ class _LogBodyweightSheetState extends State<_LogBodyweightSheet> {
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
- Container(
- width: 40,
- height: 4,
- decoration: BoxDecoration(color: gc.bgRaised2, borderRadius: BorderRadius.circular(2)),
- ),
+ const SheetHandle(),
const SizedBox(height: 18),
Text(t.logBodyweight,
style: AppTheme.d(14, weight: FontWeight.w600, color: gc.text, letterSpacing: 2)),
@@ -1120,14 +1082,7 @@ void showEditLoggedSheet(BuildContext context, LoggedSession s, LoggedExercise e
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
- Center(
- child: Container(
- width: 40,
- height: 4,
- decoration:
- BoxDecoration(color: gc.bgRaised2, borderRadius: BorderRadius.circular(2)),
- ),
- ),
+ const SheetHandle(),
const SizedBox(height: 18),
Text(t.catalogName(e.id, e.name), style: AppTheme.d(20, weight: FontWeight.w700, color: gc.text)),
const SizedBox(height: 4),
diff --git a/lib/screens/routine_edit_screen.dart b/lib/screens/routine_edit_screen.dart
index 1901faf..a4b025a 100644
--- a/lib/screens/routine_edit_screen.dart
+++ b/lib/screens/routine_edit_screen.dart
@@ -4,6 +4,7 @@ import 'package:phosphor_flutter/phosphor_flutter.dart';
import '../catalog/exercise_catalog.dart';
import '../l10n/l10n.dart';
import '../models/exercise.dart';
+import '../services/exercise_match.dart';
import '../state/fit_state.dart';
import '../theme/app_colors.dart';
import '../theme/app_theme.dart';
@@ -33,12 +34,8 @@ class _RoutineEditScreenState extends State<RoutineEditScreen> {
}
List<Exercise> get _filtered {
- final q = _q.trim().toLowerCase();
- if (q.isEmpty) return kExercises;
- return kExercises
- .where((e) =>
- e.name.toLowerCase().contains(q) || exerciseName(e).toLowerCase().contains(q))
- .toList();
+ if (_q.trim().isEmpty) return kExercises;
+ return kExercises.where(exerciseSearch(_q)).toList();
}
@override
@@ -141,32 +138,10 @@ class _RoutineEditScreenState extends State<RoutineEditScreen> {
),
],
const SizedBox(height: 20),
- Container(
- height: 48,
- padding: const EdgeInsets.symmetric(horizontal: 16),
- decoration: BoxDecoration(
- color: gc.bgRaised,
- border: Border.all(color: gc.border),
- borderRadius: BorderRadius.circular(100),
- ),
- child: Row(children: [
- SvgPathIcon(Ic.search, size: 16, color: gc.textSecondary),
- const SizedBox(width: 10),
- Expanded(
- child: TextField(
- controller: _search,
- onChanged: (v) => setState(() => _q = v),
- style: AppTheme.s(14, color: gc.text),
- cursorColor: gc.accent,
- decoration: InputDecoration(
- isCollapsed: true,
- border: InputBorder.none,
- hintText: t.addExercises,
- hintStyle: AppTheme.s(14, color: gc.textSecondary),
- ),
- ),
- ),
- ]),
+ SearchField(
+ controller: _search,
+ hint: t.addExercises,
+ onChanged: (v) => setState(() => _q = v),
),
const SizedBox(height: 12),
],
diff --git a/lib/screens/routines_screen.dart b/lib/screens/routines_screen.dart
index 3a1248a..e48f49c 100644
--- a/lib/screens/routines_screen.dart
+++ b/lib/screens/routines_screen.dart
@@ -22,11 +22,7 @@ class RoutinesScreen extends StatelessWidget {
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
- Row(children: [
- RoundBtn(icon: Ic.chevronLeft, onTap: fit.backFromRoutines),
- const SizedBox(width: 12),
- ScreenTitle(t.routines),
- ]),
+ ScreenHeader(title: t.routines, onBack: fit.backFromRoutines, titleSize: 22),
const SizedBox(height: 22),
Text(t.weeklyPlan, style: AppTheme.d(12, weight: FontWeight.w600, color: gc.textSecondary, letterSpacing: 3)),
const SizedBox(height: 10),
diff --git a/lib/screens/session_screen.dart b/lib/screens/session_screen.dart
index a30e48b..6fdcbfb 100644
--- a/lib/screens/session_screen.dart
+++ b/lib/screens/session_screen.dart
@@ -9,10 +9,11 @@ import '../models/workout.dart';
import '../state/fit_state.dart';
import '../theme/app_colors.dart';
import '../theme/app_theme.dart';
+import '../widgets/dialogs.dart';
import '../widgets/exercise_media.dart';
+import '../widgets/share_cards.dart';
import '../widgets/svg_icon.dart';
import '../widgets/ui_kit.dart';
-import '../widgets/share_cards.dart';
import 'exercises_screen.dart';
import 'share_sheet.dart';
@@ -199,26 +200,10 @@ class SessionScreen extends StatelessWidget {
Row(
children: [
Expanded(
- child: GestureDetector(
- behavior: HitTestBehavior.opaque,
+ child: GhostButton(
+ label: t.addExercise,
+ icon: PhosphorIconsRegular.plus,
onTap: () => showAddToSessionSheet(context),
- child: Container(
- height: 46,
- alignment: Alignment.center,
- decoration: BoxDecoration(
- border: Border.all(color: gc.border),
- borderRadius: BorderRadius.circular(14),
- ),
- child: Row(
- mainAxisSize: MainAxisSize.min,
- children: [
- Icon(PhosphorIconsRegular.plus, size: 16, color: gc.ember),
- const SizedBox(width: 8),
- Text(t.addExercise,
- style: AppTheme.d(13, weight: FontWeight.w600, color: gc.text, letterSpacing: 1)),
- ],
- ),
- ),
),
),
const SizedBox(width: 10),
@@ -293,27 +278,13 @@ class SessionScreen extends StatelessWidget {
}
Future<void> _confirmDrop(BuildContext context, int exIdx, String name) async {
- final gc = context.gc;
- final ok = await showDialog<bool>(
- context: context,
- builder: (dctx) => AlertDialog(
- backgroundColor: gc.bgRaised,
- shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)),
- title: Text(t.dropExercise, style: AppTheme.d(18, weight: FontWeight.w700, color: gc.text)),
- content: Text(t.dropExerciseBody(name), style: AppTheme.s(13, color: gc.textSecondary)),
- actions: [
- TextButton(
- onPressed: () => Navigator.of(dctx).pop(false),
- child: Text(t.cancel, style: AppTheme.s(14, color: gc.textSecondary)),
- ),
- TextButton(
- onPressed: () => Navigator.of(dctx).pop(true),
- child: Text(t.drop, style: AppTheme.s(14, weight: FontWeight.w700, color: gc.accent)),
- ),
- ],
- ),
+ final ok = await askConfirm(
+ context,
+ title: t.dropExercise,
+ body: t.dropExerciseBody(name),
+ confirmLabel: t.drop,
);
- if (ok == true) fit.removeSessionExercise(exIdx);
+ if (ok) fit.removeSessionExercise(exIdx);
}
static const _numCol = 24.0;
@@ -530,14 +501,7 @@ class SessionScreen extends StatelessWidget {
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
- Center(
- child: Container(
- width: 40,
- height: 4,
- decoration:
- BoxDecoration(color: gc.bgRaised2, borderRadius: BorderRadius.circular(2)),
- ),
- ),
+ const SheetHandle(),
const SizedBox(height: 18),
Text(t.setType,
style: AppTheme.d(12,
@@ -643,44 +607,7 @@ class SessionScreen extends StatelessWidget {
required bool decimal,
required void Function(double) onSave,
}) async {
- final gc = context.gc;
- final controller = TextEditingController(text: initial)
- ..selection = TextSelection(baseOffset: 0, extentOffset: initial.length);
-
- final raw = await showDialog<String>(
- context: context,
- builder: (dctx) => AlertDialog(
- backgroundColor: gc.bgRaised,
- shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)),
- title: Text(title, style: AppTheme.d(14, weight: FontWeight.w700, color: gc.text, letterSpacing: 2)),
- content: TextField(
- controller: controller,
- autofocus: true,
- keyboardType: TextInputType.numberWithOptions(decimal: decimal),
- textAlign: TextAlign.center,
- style: AppTheme.d(32, weight: FontWeight.w700, color: gc.text),
- cursorColor: gc.accent,
- onSubmitted: (v) => Navigator.of(dctx).pop(v),
- decoration: InputDecoration(
- filled: true,
- fillColor: gc.bgRaised2,
- border: OutlineInputBorder(borderRadius: BorderRadius.circular(14), borderSide: BorderSide.none),
- ),
- ),
- actions: [
- TextButton(
- onPressed: () => Navigator.of(dctx).pop(),
- child: Text(t.cancel, style: AppTheme.s(14, color: gc.textSecondary)),
- ),
- TextButton(
- onPressed: () => Navigator.of(dctx).pop(controller.text),
- child: Text(t.set, style: AppTheme.s(14, weight: FontWeight.w700, color: gc.accent)),
- ),
- ],
- ),
- );
-
- final parsed = double.tryParse((raw ?? '').trim().replaceAll(',', '.'));
+ final parsed = await askNumber(context, title: title, initial: initial, decimal: decimal);
if (parsed != null) onSave(parsed);
}
@@ -896,33 +823,11 @@ void showAddToSessionSheet(BuildContext context) {
Text(t.addExercise,
style: AppTheme.d(15, weight: FontWeight.w700, color: gc.text, letterSpacing: 2)),
const SizedBox(height: 14),
- Container(
- height: 48,
- padding: const EdgeInsets.symmetric(horizontal: 16),
- decoration: BoxDecoration(
- color: gc.bgRaised2,
- border: Border.all(color: gc.border),
- borderRadius: BorderRadius.circular(100),
- ),
- child: Row(children: [
- SvgPathIcon(Ic.search, size: 16, color: gc.textSecondary),
- const SizedBox(width: 10),
- Expanded(
- child: TextField(
- controller: search,
- autofocus: false,
- onChanged: (_) => setSheet(() {}),
- style: AppTheme.s(14, color: gc.text),
- cursorColor: gc.accent,
- decoration: InputDecoration(
- isCollapsed: true,
- border: InputBorder.none,
- hintText: t.searchExercises,
- hintStyle: AppTheme.s(14, color: gc.textSecondary),
- ),
- ),
- ),
- ]),
+ SearchField(
+ controller: search,
+ hint: t.searchExercises,
+ color: gc.bgRaised2,
+ onChanged: (_) => setSheet(() {}),
),
const SizedBox(height: 12),
Text(q.isEmpty ? t.suggested.toUpperCase() : t.results.toUpperCase(),
@@ -947,30 +852,13 @@ void showAddToSessionSheet(BuildContext context) {
),
Padding(
padding: const EdgeInsets.fromLTRB(20, 4, 20, 18),
- child: GestureDetector(
- behavior: HitTestBehavior.opaque,
+ child: GhostButton(
+ label: t.newExercise,
+ icon: PhosphorIconsRegular.plus,
onTap: () {
Navigator.pop(sheetCtx);
showCreateExerciseSheet(context, onCreated: fit.addExerciseToSession);
},
- child: Container(
- height: 46,
- alignment: Alignment.center,
- decoration: BoxDecoration(
- border: Border.all(color: gc.border),
- borderRadius: BorderRadius.circular(14),
- ),
- child: Row(
- mainAxisSize: MainAxisSize.min,
- children: [
- Icon(PhosphorIconsRegular.plus, size: 16, color: gc.ember),
- const SizedBox(width: 8),
- Text(t.newExercise,
- style: AppTheme.d(13,
- weight: FontWeight.w600, color: gc.text, letterSpacing: 1)),
- ],
- ),
- ),
),
),
],
diff --git a/lib/screens/settings_screen.dart b/lib/screens/settings_screen.dart
index 55d9477..4313723 100644
--- a/lib/screens/settings_screen.dart
+++ b/lib/screens/settings_screen.dart
@@ -22,6 +22,8 @@ import '../services/workout_import.dart';
import '../state/fit_state.dart';
import '../theme/app_colors.dart';
import '../theme/app_theme.dart';
+import '../widgets/dialogs.dart';
+import '../widgets/photo_source_sheet.dart';
import '../widgets/profile_avatar.dart';
import '../widgets/ui_kit.dart';
@@ -274,27 +276,13 @@ class SettingsScreen extends StatelessWidget {
}
Future<void> _resetAll(BuildContext context) async {
- final gc = context.gc;
- final ok = await showDialog<bool>(
- context: context,
- builder: (dctx) => AlertDialog(
- backgroundColor: gc.bgRaised,
- shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)),
- title: Text(t.resetTitle, style: AppTheme.d(18, weight: FontWeight.w700, color: gc.text)),
- content: Text(t.resetBody, style: AppTheme.s(13, color: gc.textSecondary)),
- actions: [
- TextButton(
- onPressed: () => Navigator.of(dctx).pop(false),
- child: Text(t.cancel, style: AppTheme.s(14, color: gc.textSecondary)),
- ),
- TextButton(
- onPressed: () => Navigator.of(dctx).pop(true),
- child: Text(t.resetConfirm, style: AppTheme.s(14, weight: FontWeight.w700, color: gc.accent)),
- ),
- ],
- ),
+ final ok = await askConfirm(
+ context,
+ title: t.resetTitle,
+ body: t.resetBody,
+ confirmLabel: t.resetConfirm,
);
- if (ok != true) return;
+ if (!ok) return;
fit.resetAllData();
if (context.mounted) _snack(context, t.resetDone);
}
@@ -311,27 +299,13 @@ class SettingsScreen extends StatelessWidget {
}
Future<void> _importBackup(BuildContext context) async {
- final gc = context.gc;
- final ok = await showDialog<bool>(
- context: context,
- builder: (dctx) => AlertDialog(
- backgroundColor: gc.bgRaised,
- shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)),
- title: Text(t.importBackup, style: AppTheme.d(18, weight: FontWeight.w700, color: gc.text)),
- content: Text(t.importHint, style: AppTheme.s(13, color: gc.textSecondary)),
- actions: [
- TextButton(
- onPressed: () => Navigator.of(dctx).pop(false),
- child: Text(t.cancel, style: AppTheme.s(14, color: gc.textSecondary)),
- ),
- TextButton(
- onPressed: () => Navigator.of(dctx).pop(true),
- child: Text(t.chooseFile, style: AppTheme.s(14, weight: FontWeight.w700, color: gc.accent)),
- ),
- ],
- ),
+ final ok = await askConfirm(
+ context,
+ title: t.importBackup,
+ body: t.importHint,
+ confirmLabel: t.chooseFile,
);
- if (ok != true) return;
+ if (!ok) return;
Uint8List? bytes;
try {
@@ -394,8 +368,6 @@ class SettingsScreen extends StatelessWidget {
}
Future<void> _importFromApp(BuildContext context) async {
- // Se aceptan todos los ficheros y se mira el contenido: la copia de
- // FitNotes lleva una extensión rara y el selector de Android la escondería.
Uint8List? bytes;
try {
final result = await FilePicker.platform.pickFiles(withData: true);
@@ -411,7 +383,6 @@ class SettingsScreen extends StatelessWidget {
return;
}
- // FitNotes: base de datos SQLite entera.
if (SqliteDb.looksLikeSqlite(bytes)) {
final parsed = parseFitNotes(bytes);
if (parsed == null) {
@@ -425,7 +396,6 @@ class SettingsScreen extends StatelessWidget {
String? raw;
try {
if (bytes.length > 2 && bytes[0] == 0x50 && bytes[1] == 0x4B) {
- // Strong exporta las medidas en un zip con un csv por medida.
raw = weightCsvFromZip(bytes);
if (raw == null) {
_snack(context, t.importZipNoWeights);
@@ -475,20 +445,13 @@ class SettingsScreen extends StatelessWidget {
final gc = context.gc;
return showDialog<bool>(
context: context,
- builder: (dctx) => AlertDialog(
- backgroundColor: gc.bgRaised,
- shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)),
+ builder: (dctx) => appDialog(
+ gc,
title: Text(t.importUnitTitle, style: AppTheme.d(18, weight: FontWeight.w700, color: gc.text)),
content: Text(t.importUnitBody, style: AppTheme.s(13, color: gc.textSecondary)),
actions: [
- TextButton(
- onPressed: () => Navigator.of(dctx).pop(false),
- child: Text('kg', style: AppTheme.s(14, weight: FontWeight.w700, color: gc.accent)),
- ),
- TextButton(
- onPressed: () => Navigator.of(dctx).pop(true),
- child: Text('lb', style: AppTheme.s(14, weight: FontWeight.w700, color: gc.accent)),
- ),
+ dialogAction('kg', gc.accent, () => Navigator.of(dctx).pop(false)),
+ dialogAction('lb', gc.accent, () => Navigator.of(dctx).pop(true)),
],
),
);
@@ -620,52 +583,6 @@ class SettingsScreen extends StatelessWidget {
}
}
-class _SourceSheet extends StatelessWidget {
- @override
- Widget build(BuildContext context) {
- final gc = context.gc;
- return Container(
- padding: const EdgeInsets.fromLTRB(20, 12, 20, 28),
- decoration: BoxDecoration(
- color: gc.bgRaised,
- border: Border.all(color: gc.border),
- borderRadius: const BorderRadius.vertical(top: Radius.circular(28)),
- ),
- child: Column(
- mainAxisSize: MainAxisSize.min,
- children: [
- Container(
- width: 40,
- height: 4,
- decoration: BoxDecoration(color: gc.bgRaised2, borderRadius: BorderRadius.circular(2)),
- ),
- const SizedBox(height: 18),
- _option(context, PhosphorIconsRegular.camera, t.takePhoto, ImageSource.camera),
- const SizedBox(height: 10),
- _option(context, PhosphorIconsRegular.image, t.chooseGallery, ImageSource.gallery),
- ],
- ),
- );
- }
-
- Widget _option(BuildContext context, IconData icon, String label, ImageSource source) {
- final gc = context.gc;
- return GestureDetector(
- behavior: HitTestBehavior.opaque,
- onTap: () => Navigator.of(context).pop(source),
- child: SoftCard(
- radius: 16,
- padding: const EdgeInsets.all(16),
- child: Row(children: [
- Icon(icon, size: 20, color: gc.textSecondary),
- const SizedBox(width: 14),
- Expanded(child: Text(label, style: AppTheme.s(14, weight: FontWeight.w600, color: gc.text))),
- ]),
- ),
- );
- }
-}
-
class _LanguageSheet extends StatelessWidget {
@override
Widget build(BuildContext context) {
@@ -681,13 +598,7 @@ class _LanguageSheet extends StatelessWidget {
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
- Center(
- child: Container(
- width: 40,
- height: 4,
- decoration: BoxDecoration(color: gc.bgRaised2, borderRadius: BorderRadius.circular(2)),
- ),
- ),
+ const SheetHandle(),
const SizedBox(height: 18),
Text(t.languageLabel,
textAlign: TextAlign.center,
@@ -749,13 +660,7 @@ class _AlarmSoundSheet extends StatelessWidget {
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
- Center(
- child: Container(
- width: 40,
- height: 4,
- decoration: BoxDecoration(color: gc.bgRaised2, borderRadius: BorderRadius.circular(2)),
- ),
- ),
+ const SheetHandle(),
const SizedBox(height: 18),
Text(t.alarmSound,
textAlign: TextAlign.center,
@@ -825,13 +730,7 @@ class _ProfileSheetState extends State<_ProfileSheet> {
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
- Center(
- child: Container(
- width: 40,
- height: 4,
- decoration: BoxDecoration(color: gc.bgRaised2, borderRadius: BorderRadius.circular(2)),
- ),
- ),
+ const SheetHandle(),
const SizedBox(height: 18),
Text(t.yourProfile,
textAlign: TextAlign.center,
@@ -928,11 +827,7 @@ class _ProfileSheetState extends State<_ProfileSheet> {
}
Future<void> _pickPhoto() async {
- final source = await showModalBottomSheet<ImageSource>(
- context: context,
- backgroundColor: Colors.transparent,
- builder: (sheetCtx) => _SourceSheet(),
- );
+ final source = await pickPhotoSource(context);
if (source == null) return;
final shot = await ImagePicker().pickImage(
diff --git a/lib/screens/share_sheet.dart b/lib/screens/share_sheet.dart
index c050463..8132f24 100644
--- a/lib/screens/share_sheet.dart
+++ b/lib/screens/share_sheet.dart
@@ -91,12 +91,7 @@ class _ShareSheetState extends State<_ShareSheet> {
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
- Container(
- width: 40,
- height: 4,
- margin: const EdgeInsets.symmetric(vertical: 12),
- decoration: BoxDecoration(color: gc.border, borderRadius: BorderRadius.circular(2)),
- ),
+ SheetHandle(color: gc.border, margin: const EdgeInsets.symmetric(vertical: 12)),
Padding(
padding: const EdgeInsets.fromLTRB(20, 4, 20, 12),
child: Row(
diff --git a/lib/screens/timeline_screen.dart b/lib/screens/timeline_screen.dart
index 72d164c..e8cbb7b 100644
--- a/lib/screens/timeline_screen.dart
+++ b/lib/screens/timeline_screen.dart
@@ -12,6 +12,7 @@ import '../state/fit_state.dart';
import '../theme/app_colors.dart';
import '../theme/app_theme.dart';
import '../widgets/body_map.dart';
+import '../widgets/dialogs.dart';
import '../widgets/note_kit.dart';
import '../widgets/photo_source_sheet.dart';
import '../widgets/svg_icon.dart';
@@ -49,52 +50,25 @@ class _TimelineScreenState extends State<TimelineScreen> {
}
Future<void> _confirmDelete(ProgressEntry entry) async {
- final gc = context.gc;
- final ok = await showDialog<bool>(
- context: context,
- builder: (dctx) => AlertDialog(
- backgroundColor: gc.bgRaised,
- shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)),
- title: Text(t.deleteEntryTitle, style: AppTheme.d(18, weight: FontWeight.w700, color: gc.text)),
- content: Text(t.deleteDayBody, style: AppTheme.s(13, color: gc.textSecondary)),
- actions: [
- TextButton(
- onPressed: () => Navigator.of(dctx).pop(false),
- child: Text(t.cancel, style: AppTheme.s(14, color: gc.textSecondary)),
- ),
- TextButton(
- onPressed: () => Navigator.of(dctx).pop(true),
- child: Text(t.delete, style: AppTheme.s(14, weight: FontWeight.w700, color: gc.danger)),
- ),
- ],
- ),
+ final ok = await askConfirm(
+ context,
+ title: t.deleteEntryTitle,
+ body: t.deleteDayBody,
+ confirmLabel: t.delete,
+ danger: true,
);
- if (ok == true) fit.deleteEntry(entry.id);
+ if (ok) fit.deleteEntry(entry.id);
}
Future<void> _confirmRemove(ProgressEntry entry, String pose) async {
- final gc = context.gc;
- final ok = await showDialog<bool>(
- context: context,
- builder: (dctx) => AlertDialog(
- backgroundColor: gc.bgRaised,
- shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)),
- title: Text(t.delete, style: AppTheme.d(18, weight: FontWeight.w700, color: gc.text)),
- content: Text(t.posePhoto(t.poseName(pose).toLowerCase()),
- style: AppTheme.s(13, color: gc.textSecondary)),
- actions: [
- TextButton(
- onPressed: () => Navigator.of(dctx).pop(false),
- child: Text(t.cancel, style: AppTheme.s(14, color: gc.textSecondary)),
- ),
- TextButton(
- onPressed: () => Navigator.of(dctx).pop(true),
- child: Text(t.delete, style: AppTheme.s(14, weight: FontWeight.w700, color: gc.danger)),
- ),
- ],
- ),
+ final ok = await askConfirm(
+ context,
+ title: t.delete,
+ body: t.posePhoto(t.poseName(pose).toLowerCase()),
+ confirmLabel: t.delete,
+ danger: true,
);
- if (ok == true) fit.removeShot(entry.id, pose);
+ if (ok) fit.removeShot(entry.id, pose);
}
@override
@@ -111,25 +85,10 @@ class _TimelineScreenState extends State<TimelineScreen> {
children: [
Padding(
padding: const EdgeInsets.fromLTRB(20, 12, 20, 0),
- child: Row(
- children: [
- RoundBtn(icon: Ic.chevronLeft, onTap: fit.backFromTimeline),
- const SizedBox(width: 12),
- Expanded(
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- ScreenTitle(t.timeline, size: 20),
- const SizedBox(height: 2),
- Text(
- body
- ? t.sessionsLogged(fit.totalSessions)
- : t.photoCount(fit.shotCount),
- style: AppTheme.s(12.5, color: gc.textSecondary)),
- ],
- ),
- ),
- ],
+ child: ScreenHeader(
+ title: t.timeline,
+ subtitle: body ? t.sessionsLogged(fit.totalSessions) : t.photoCount(fit.shotCount),
+ onBack: fit.backFromTimeline,
),
),
const SizedBox(height: 16),
@@ -702,11 +661,7 @@ class _TimelineScreenState extends State<TimelineScreen> {
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
- Container(
- width: 40,
- height: 4,
- decoration: BoxDecoration(color: gc.bgRaised2, borderRadius: BorderRadius.circular(2)),
- ),
+ const SheetHandle(),
const SizedBox(height: 18),
for (final p in kPoses) ...[
if (p != kPoses.first) const SizedBox(height: 10),
diff --git a/lib/screens/tool_detail_screen.dart b/lib/screens/tool_detail_screen.dart
index 3fbed5e..c762563 100644
--- a/lib/screens/tool_detail_screen.dart
+++ b/lib/screens/tool_detail_screen.dart
@@ -4,6 +4,7 @@ import '../l10n/l10n.dart';
import '../state/fit_state.dart';
import '../theme/app_colors.dart';
import '../theme/app_theme.dart';
+import '../widgets/dialogs.dart';
import '../widgets/svg_icon.dart';
import '../widgets/ui_kit.dart';
@@ -142,45 +143,7 @@ class ToolDetailScreen extends StatelessWidget {
required bool decimal,
required void Function(double) apply,
}) async {
- final gc = context.gc;
- final initial = fmt(current);
- final controller = TextEditingController(text: initial)
- ..selection = TextSelection(baseOffset: 0, extentOffset: initial.length);
-
- final raw = await showDialog<String>(
- context: context,
- builder: (dctx) => AlertDialog(
- backgroundColor: gc.bgRaised,
- shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)),
- title: Text(title, style: AppTheme.d(14, weight: FontWeight.w700, color: gc.text, letterSpacing: 2)),
- content: TextField(
- controller: controller,
- autofocus: true,
- keyboardType: TextInputType.numberWithOptions(decimal: decimal),
- textAlign: TextAlign.center,
- style: AppTheme.d(32, weight: FontWeight.w700, color: gc.text),
- cursorColor: gc.accent,
- onSubmitted: (v) => Navigator.of(dctx).pop(v),
- decoration: InputDecoration(
- filled: true,
- fillColor: gc.bgRaised2,
- border: OutlineInputBorder(borderRadius: BorderRadius.circular(14), borderSide: BorderSide.none),
- ),
- ),
- actions: [
- TextButton(
- onPressed: () => Navigator.of(dctx).pop(),
- child: Text(t.cancel, style: AppTheme.s(14, color: gc.textSecondary)),
- ),
- TextButton(
- onPressed: () => Navigator.of(dctx).pop(controller.text),
- child: Text(t.set, style: AppTheme.s(14, weight: FontWeight.w700, color: gc.accent)),
- ),
- ],
- ),
- );
-
- final parsed = double.tryParse((raw ?? '').trim().replaceAll(',', '.'));
+ final parsed = await askNumber(context, title: title, initial: fmt(current), decimal: decimal);
if (parsed != null) apply(parsed);
}
diff --git a/lib/screens/tools_screen.dart b/lib/screens/tools_screen.dart
index a0659cb..02b2cd1 100644
--- a/lib/screens/tools_screen.dart
+++ b/lib/screens/tools_screen.dart
@@ -7,7 +7,6 @@ import '../models/exercise.dart';
import '../state/fit_state.dart';
import '../theme/app_colors.dart';
import '../theme/app_theme.dart';
-import '../widgets/svg_icon.dart';
import '../widgets/ui_kit.dart';
IconData _toolIcon(String id) => switch (id) {
@@ -32,13 +31,7 @@ class ToolsScreen extends StatelessWidget {
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
- Row(
- children: [
- RoundBtn(icon: Ic.chevronLeft, onTap: fit.backFromTools),
- const SizedBox(width: 12),
- ScreenTitle(t.tools),
- ],
- ),
+ ScreenHeader(title: t.tools, onBack: fit.backFromTools, titleSize: 22),
const SizedBox(height: 6),
Padding(
padding: const EdgeInsets.only(left: 48),
diff --git a/lib/services/backup_zip.dart b/lib/services/backup_zip.dart
index fa69a70..04e337e 100644
--- a/lib/services/backup_zip.dart
+++ b/lib/services/backup_zip.dart
@@ -21,8 +21,6 @@ const String _alarmDir = 'alarm';
bool looksLikeZip(Uint8List b) =>
b.length > 4 && b[0] == 0x50 && b[1] == 0x4B && (b[2] == 0x03 || b[2] == 0x05 || b[2] == 0x07);
-/// Copia completa: el JSON de datos más el media propio del usuario,
-/// repartido en carpetas y renombrado con el ejercicio al que pertenece.
Future<Uint8List> buildBackupZip() async {
final data = fit.toJson();
final archive = Archive();
@@ -82,8 +80,6 @@ Future<Uint8List> buildBackupZip() async {
return ZipEncoder().encodeBytes(archive);
}
-/// Restaura una copia en zip: vuelca el media a disco con nombres internos y
-/// deja el JSON apuntando a los ficheros ya restaurados.
Future<bool> restoreBackupZip(Uint8List zipBytes) async {
final Archive archive;
try {
diff --git a/lib/services/exercise_match.dart b/lib/services/exercise_match.dart
index 725e749..220fae4 100644
--- a/lib/services/exercise_match.dart
+++ b/lib/services/exercise_match.dart
@@ -1,8 +1,6 @@
+import '../catalog/exercise_aliases.dart';
import '../models/exercise.dart';
-/// Hevy y Strong nombran «Movimiento (Material)» y el catálogo «Material Movimiento».
-/// Comparar cadenas enteras no encuentra nada: hay que comparar palabras.
-
const _stop = {'the', 'a', 'an', 'with', 'on', 'to', 'and', 'or', 'in', 'for', 'v', 'var'};
const _syn = {
@@ -20,7 +18,6 @@ const _syn = {
'flyes': 'fly', 'flies': 'fly', 'flys': 'fly',
'deadlifts': 'deadlift', 'lunges': 'lunge', 'dips': 'dip', 'pulldowns': 'pulldown',
'legs': 'leg', 'arms': 'arm', 'abs': 'abdominal', 'delts': 'deltoid',
- // el catálogo llama «Lever» a lo que las otras apps llaman «Machine»
'lever': 'machine', 'smith': 'machine', 'skullcrusher': 'lying triceps extension',
'skullcrushers': 'lying triceps extension',
'rdl': 'romanian deadlift', 'sldl': 'stiff leg deadlift',
@@ -31,28 +28,6 @@ const _equipment = {
'bodyweight', 'lever', 'sled', 'weighted', 'assisted', 'ez',
};
-/// Nombres de otras apps que a palabras sueltas quedarían ambiguos.
-const _aliases = {
- 'squat barbell': 'Barbell Full Squat',
- 'barbell squat': 'Barbell Full Squat',
- 'back squat barbell': 'Barbell Full Squat',
- 'squat': 'Bodyweight Squat',
- 'bench press barbell': 'Barbell Bench Press',
- 'deadlift barbell': 'Barbell Deadlift',
- 'overhead press barbell': 'Barbell Standing Wide Military Press',
- 'military press barbell': 'Barbell Standing Wide Military Press',
- 'shoulder press dumbbell': 'Dumbbell Standing Overhead Press',
- 'bicep curl barbell': 'Barbell Curl',
- 'bicep curl dumbbell': 'Dumbbell Biceps Curl',
- 'hammer curl dumbbell': 'Dumbbell Hammer Curl',
- 'lat pulldown cable': 'Cable Pulldown',
- 'seated row cable': 'Cable Seated Row',
- 'bent over row barbell': 'Barbell Bent Over Row',
- 'romanian deadlift barbell': 'Barbell Romanian Deadlift',
- 'incline bench press barbell': 'Barbell Incline Bench Press',
- 'incline bench press dumbbell': 'Dumbbell Incline Bench Press',
-};
-
List<String> nameTokens(String raw) {
final flat = raw
.toLowerCase()
@@ -71,9 +46,33 @@ List<String> nameTokens(String raw) {
return out;
}
-String _aliasKey(String raw) => nameTokens(raw).join(' ');
+String searchKey(String raw) => nameTokens(raw).join(' ');
+
+final Map<String, String> _keyCache = {};
+
+String _keyOf(String name) => _keyCache.putIfAbsent(name, () => searchKey(name));
+
+final Map<String, String> _aliasIndex = {
+ for (final entry in kExerciseAliases.entries)
+ for (final alias in entry.value) searchKey(alias): entry.key,
+};
+
+typedef ExerciseFilter = bool Function(Exercise);
+
+ExerciseFilter exerciseSearch(String query) {
+ final plain = query.trim().toLowerCase();
+ if (plain.isEmpty) return (_) => true;
+ final key = searchKey(query);
+
+ return (e) {
+ final label = exerciseName(e);
+ if (e.name.toLowerCase().contains(plain) || label.toLowerCase().contains(plain)) return true;
+ if (key.isEmpty) return false;
+ if (_keyOf(e.name).contains(key) || _keyOf(label).contains(key)) return true;
+ return kExerciseAliases[e.name]?.any((a) => _keyOf(a).contains(key)) ?? false;
+ };
+}
-// Un press de barra no es el mismo ejercicio que uno de mancuerna.
bool _sameEquipment(Set<String> q, Set<String> c) {
final qe = q.intersection(_equipment);
final ce = c.intersection(_equipment);
@@ -87,12 +86,6 @@ int _score(Set<String> q, Set<String> c) {
return shared.length * 3 - c.difference(q).length - q.difference(c).length;
}
-final Map<String, String> _aliasIndex = {
- for (final e in _aliases.entries) _aliasKey(e.key): e.value,
-};
-
-/// Si el ejercicio importado no está en el catálogo, al menos sabemos a qué
-/// músculo va: así sigue contando en el mapa muscular y en el reparto.
const _muscleHints = <List<String>, String>{
['calf', 'calves', 'soleus']: 'calves',
['hamstring', 'leg curl', 'good morning', 'nordic']: 'hamstrings',
@@ -121,14 +114,14 @@ String? guessMuscle(String name) {
}
Exercise? matchExercise(String name, Iterable<Exercise> pool) {
- final key = _aliasKey(name);
+ final key = searchKey(name);
if (key.isEmpty) return null;
final alias = _aliasIndex[key];
if (alias != null) {
- final wanted = _aliasKey(alias);
+ final wanted = searchKey(alias);
for (final e in pool) {
- if (_aliasKey(e.name) == wanted) return e;
+ if (searchKey(e.name) == wanted) return e;
}
}
diff --git a/lib/services/fitnotes_backup.dart b/lib/services/fitnotes_backup.dart
index b6f1acc..fb1c4d1 100644
--- a/lib/services/fitnotes_backup.dart
+++ b/lib/services/fitnotes_backup.dart
@@ -1,9 +1,6 @@
import 'sqlite_reader.dart';
import 'workout_import.dart';
-/// La copia de seguridad de FitNotes (.fitnotes) es una base SQLite.
-/// De ella salen las series (training_log) y el peso corporal
-/// (MeasurementRecord), que es lo único que esta app guarda.
const _categoryMuscle = {
'shoulders': 'shoulders',
'chest': 'chest',
@@ -43,7 +40,7 @@ ImportResult? parseFitNotes(List<int> bytes) {
for (final log in db.rows('training_log')) {
final reps = _int(log['reps']);
- if (reps <= 0) continue; // planchas y demás: sin repeticiones no hay serie
+ if (reps <= 0) continue;
final date = _date(_text(log['date']));
if (date == null) continue;
final exercise = exercises[_int(log['exercise_id'])];
diff --git a/lib/services/rest_alarm.dart b/lib/services/rest_alarm.dart
index 3a7e629..f0e1d14 100644
--- a/lib/services/rest_alarm.dart
+++ b/lib/services/rest_alarm.dart
@@ -91,7 +91,6 @@ class RestAlarm {
AndroidFlutterLocalNotificationsPlugin? get _androidPlugin =>
_plugin.resolvePlatformSpecificImplementation<AndroidFlutterLocalNotificationsPlugin>();
- /// Sin este permiso la alarma no suena con la pantalla apagada.
Future<bool> notificationsAllowed() async {
if (!_ready) return true;
try {
@@ -101,8 +100,6 @@ class RestAlarm {
}
}
- /// Devuelve si quedó concedido. Android solo enseña el diálogo un par de
- /// veces; a partir de ahí hay que mandar al usuario a los ajustes.
Future<bool> requestPermission() async {
if (!_ready) return true;
try {
diff --git a/lib/services/sqlite_reader.dart b/lib/services/sqlite_reader.dart
index 45c55fb..441c605 100644
--- a/lib/services/sqlite_reader.dart
+++ b/lib/services/sqlite_reader.dart
@@ -1,11 +1,6 @@
import 'dart:convert';
import 'dart:typed_data';
-/// Lector de SQLite de solo lectura, en Dart puro.
-///
-/// FitNotes no exporta un CSV: su copia de seguridad es una base de datos
-/// SQLite entera. Con esto se lee sin plugins nativos, así que sigue
-/// funcionando en los tests y en la web.
class SqliteDb {
SqliteDb._(this._bytes, this._pageSize, this._usable, this._tables);
@@ -53,7 +48,6 @@ class SqliteDb {
}
}
- /// Filas de una tabla, ya con el nombre de cada columna.
List<Map<String, Object?>> rows(String table) {
final t = _tables[table.toLowerCase()];
if (t == null) return const [];
@@ -62,7 +56,6 @@ class SqliteDb {
final row = <String, Object?>{};
for (var i = 0; i < t.columns.length; i++) {
final value = i < rec.values.length ? rec.values[i] : null;
- // Una columna INTEGER PRIMARY KEY no se guarda: es el rowid.
row[t.columns[i].name] = value == null && t.columns[i].isRowId ? rec.rowId : value;
}
out.add(row);
@@ -70,7 +63,6 @@ class SqliteDb {
return out;
}
- // ── árbol B ──────────────────────────────────────────────────
List<_Record> _readTree(int page) {
final out = <_Record>[];
_walk(page, out, 0);
@@ -110,7 +102,6 @@ class SqliteDb {
}
}
- /// Cuando la fila no cabe en la página, el resto va en páginas de desbordamiento.
Uint8List? _payload(int at, int total) {
final maxLocal = _usable - 35;
if (total <= maxLocal) {
diff --git a/lib/services/workout_import.dart b/lib/services/workout_import.dart
index b82aa17..044b384 100644
--- a/lib/services/workout_import.dart
+++ b/lib/services/workout_import.dart
@@ -133,7 +133,6 @@ ImportFormat detectFormat(String csv) {
if (cols.contains('exercise') && cols.contains('category') && _pick(cols, _anyWeight) != null) {
return ImportFormat.fitnotes;
}
- // Medidas corporales: llevan fecha y peso, pero ningún ejercicio.
final hasExercise = cols.any((c) => c.contains('exercise') || c.contains('ejercicio'));
final dateCol = _pick(cols, _dateCols);
final weightCol = _pick(cols, [..._weightKgCols, ..._weightLbCols, 'weight', 'peso']);
@@ -160,8 +159,6 @@ bool needsUnitChoice(String csv) {
return _pick(cols, fmt.weightPlain ?? const []) != null;
}
-/// El export de medidas de Strong es un zip con un csv por medida.
-/// De todos ellos solo nos sirve el peso.
String? weightCsvFromZip(List<int> bytes) {
Archive archive;
try {
@@ -422,7 +419,6 @@ List<List<String>> _rows(String text, String delim) {
while (i < n) {
final c = text[i];
- // Dentro de comillas un campo puede llevar saltos de línea: no cortar la fila aquí.
if (quoted) {
if (c == '"') {
if (i + 1 < n && text[i + 1] == '"') {
diff --git a/lib/state/fit_core.dart b/lib/state/fit_core.dart
index 65ffa81..ba08086 100644
--- a/lib/state/fit_core.dart
+++ b/lib/state/fit_core.dart
@@ -10,10 +10,8 @@ double _round3(double n) => (n * 1000).round() / 1000;
double _roundTo(double n, double step) => (n / step).round() * step;
DateTime _dayKey(DateTime d) => DateTime(d.year, d.month, d.day);
-/// Sumar días con Duration se queda corto en el cambio de hora; el calendario no.
DateTime shiftDays(DateTime d, int n) => DateTime(d.year, d.month, d.day + n);
-/// Con horario de verano por medio, restar dos DateTime locales se queda corto.
int daysBetween(DateTime from, DateTime to) =>
DateTime.utc(to.year, to.month, to.day)
.difference(DateTime.utc(from.year, from.month, from.day))
@@ -23,7 +21,6 @@ const int kHeatmapDays = 84;
const int heatLevels = 4;
-/// 0 = untouched, 4 = at or over the target for the period.
int heatLevel(double v) {
if (v <= 0) return 0;
if (v < 0.25) return 1;
@@ -52,15 +49,12 @@ abstract class FitCore extends ChangeNotifier {
final List<Exercise> customExercises = [];
final List<GymPlace> places = [];
- /// Media propio del usuario por ejercicio: id -> fichero en MediaStore.
final Map<String, String> exerciseMedia = {};
- /// Ejercicios que el usuario marca como "solo repeticiones", sin peso.
final Map<String, int> exerciseRest = {};
final Set<String> repsOnly = {};
- /// Los que ha desmarcado a mano, para no volver a deducirlo por el material.
final Set<String> repsOnlyOff = {};
VoidCallback? onWidgetsShouldUpdate;
diff --git a/lib/state/fit_state.dart b/lib/state/fit_state.dart
index b22e5ce..3fdf969 100644
--- a/lib/state/fit_state.dart
+++ b/lib/state/fit_state.dart
@@ -14,15 +14,15 @@ import '../models/live_session.dart';
import '../models/measure.dart';
import '../models/note.dart';
import '../models/place.dart';
-import '../models/progress_shot.dart';
import '../models/profile.dart';
+import '../models/progress_shot.dart';
import '../models/workout.dart';
import '../services/alarm_store.dart';
+import '../services/exercise_match.dart';
import '../services/local_store.dart';
import '../services/media_store.dart';
import '../services/progress_reminder.dart';
import '../services/rest_alarm.dart';
-import '../services/exercise_match.dart';
import '../services/workout_import.dart';
part 'fit_core.dart';
@@ -321,8 +321,6 @@ class FitState extends FitCore
return true;
}
- /// [restoredMedia] llega de una copia en zip: los ficheros ya están en
- /// MediaStore con nombres nuevos y sustituyen al mapa del JSON.
void applyBackup(Map<String, dynamic> map,
{Map<String, String>? restoredMedia,
Map<String, String>? restoredNoteMedia,
diff --git a/lib/state/library_state.dart b/lib/state/library_state.dart
index 1979a77..1751611 100644
--- a/lib/state/library_state.dart
+++ b/lib/state/library_state.dart
@@ -67,15 +67,10 @@ mixin LibraryState on FitCore {
int get favouriteCount => favorites.values.where((v) => v).length;
List<Exercise> get exercisesFiltered {
- final q = exSearch.trim().toLowerCase();
+ final matchesSearch = exerciseSearch(exSearch);
return allExercises.where((ex) {
if (exFavouritesOnly && favorites[ex.id] != true) return false;
-
- if (q.isNotEmpty &&
- !ex.name.toLowerCase().contains(q) &&
- !exerciseName(ex).toLowerCase().contains(q)) {
- return false;
- }
+ if (!matchesSearch(ex)) return false;
if (exMuscleFilter != null &&
ex.primary != exMuscleFilter &&
!ex.secondary.contains(exMuscleFilter)) {
@@ -151,8 +146,6 @@ mixin LibraryState on FitCore {
notifyListeners();
}
- /// Sin peso: o lo ha marcado el usuario, o es de peso corporal y nunca lo
- /// ha cargado con lastre.
bool isRepsOnly(String id) {
if (repsOnly.contains(id)) return true;
if (repsOnlyOff.contains(id)) return false;
diff --git a/lib/state/places_state.dart b/lib/state/places_state.dart
index 4cad9e7..3b0bc69 100644
--- a/lib/state/places_state.dart
+++ b/lib/state/places_state.dart
@@ -19,7 +19,6 @@ mixin PlacesState on FitCore, LibraryState {
return null;
}
- /// Sin sitio elegido cabe todo; el peso corporal nunca necesita material.
Set<String> get gearHere {
final place = activePlace;
return place == null ? kEquipment.toSet() : {...place.equipment, 'Bodyweight'};
diff --git a/lib/state/settings_state.dart b/lib/state/settings_state.dart
index 05ce0ea..84acf5f 100644
--- a/lib/state/settings_state.dart
+++ b/lib/state/settings_state.dart
@@ -153,8 +153,6 @@ mixin SettingsState on FitCore, ToolsState {
notifyListeners();
}
- /// Si dice que no, no se insiste en el momento: se vuelve a preguntar en
- /// otra sesión, pasados unos días. Mientras tanto se avisa en Ajustes.
static const _askAgainAfter = Duration(days: 3);
Future<void> refreshAlarmPermission() async {
diff --git a/lib/state/stats_state.dart b/lib/state/stats_state.dart
index 5e3e9d5..4331e96 100644
--- a/lib/state/stats_state.dart
+++ b/lib/state/stats_state.dart
@@ -3,16 +3,9 @@ part of 'fit_state.dart';
mixin StatsState on FitCore, ToolsState, LibraryState, TimelineState {
List<Exercise> recommendedExercises(int n) {
final muscles = suggestedFocus.muscles;
- final picks = <Exercise>[];
- final usedMuscle = <String>{};
-
- for (final m in muscles) {
- final ex = kExercises.firstWhere(
- (e) => e.primary == m && !picks.contains(e),
- orElse: () => kExercises.first,
- );
- if (ex.primary == m && usedMuscle.add(m)) picks.add(ex);
- }
+ final picks = [
+ for (final m in muscles) ...kExercises.where((e) => e.primary == m).take(1),
+ ];
for (final e in kExercises) {
if (picks.length >= n) break;
@@ -85,7 +78,6 @@ mixin StatsState on FitCore, ToolsState, LibraryState, TimelineState {
? Duration.zero
: Duration(seconds: totalTime.inSeconds ~/ sessions.length);
- /// Sesiones por día de la semana (1 = lunes … 7 = domingo).
Map<int, int> get sessionsByWeekday {
final out = {for (int w = 1; w <= 7; w++) w: 0};
for (final s in sessions) {
@@ -94,7 +86,6 @@ mixin StatsState on FitCore, ToolsState, LibraryState, TimelineState {
return out;
}
- /// 0 si no hay entrenos o si hay empate: entonces no hay "tu día".
int get busiestWeekday {
final by = sessionsByWeekday;
final top = by.values.fold(0, (m, v) => v > m ? v : m);
diff --git a/lib/state/tools_state.dart b/lib/state/tools_state.dart
index 136ecad..9bd797c 100644
--- a/lib/state/tools_state.dart
+++ b/lib/state/tools_state.dart
@@ -111,7 +111,6 @@ mixin ToolsState on FitCore {
double get defaultBar => isLb ? 45 : 20;
- /// Discos por lado para una barra, en las unidades que se estén enseñando.
List<({double weight, int count})> platesPerSide(double displayTarget, double displayBar) {
double perSide = math.max(0, (displayTarget - displayBar) / 2);
final out = <({double weight, int count})>[];
diff --git a/lib/state/workout_state.dart b/lib/state/workout_state.dart
index 2eae835..6b8711a 100644
--- a/lib/state/workout_state.dart
+++ b/lib/state/workout_state.dart
@@ -50,12 +50,8 @@ mixin WorkoutState on FitCore, SettingsState, LibraryState, PlacesState, StatsSt
}
List<Exercise> trainSearchResults(String query) {
- final q = query.trim().toLowerCase();
- if (q.isEmpty) return const [];
- return allExercises
- .where((e) => exerciseName(e).toLowerCase().contains(q) || e.name.toLowerCase().contains(q))
- .take(40)
- .toList();
+ if (query.trim().isEmpty) return const [];
+ return allExercises.where(exerciseSearch(query)).take(40).toList();
}
static const _pickTarget = 6;
@@ -331,7 +327,6 @@ mixin WorkoutState on FitCore, SettingsState, LibraryState, PlacesState, StatsSt
notifyListeners();
}
- /// Para añadir sobre la marcha: favoritos y usados hace poco, sin repetir.
List<Exercise> sessionSuggestions() {
final inSession = session?.exercises.map((e) => e.id).toSet() ?? <String>{};
final ids = <String>[];
@@ -441,7 +436,6 @@ mixin WorkoutState on FitCore, SettingsState, LibraryState, PlacesState, StatsSt
summaryVsLast = previous?.volume;
}
- /// Reabre un entreno ya guardado para seguir donde se dejó.
void resumeLoggedSession(LoggedSession ls) {
if (session != null && !session!.complete) return;
sessions.remove(ls);
diff --git a/lib/widgets/body_map.dart b/lib/widgets/body_map.dart
index a9e9ebe..fb72763 100644
--- a/lib/widgets/body_map.dart
+++ b/lib/widgets/body_map.dart
@@ -92,7 +92,6 @@ class BodyHeatMap extends StatelessWidget {
}
}
-/// El mismo dibujo sin gestos ni Theme, para el widget de la pantalla de inicio.
class BodyHeatArt extends StatelessWidget {
const BodyHeatArt({super.key, required this.gc, required this.intensity, required this.width});
diff --git a/lib/widgets/dialogs.dart b/lib/widgets/dialogs.dart
new file mode 100644
index 0000000..8d41228
--- /dev/null
+++ b/lib/widgets/dialogs.dart
@@ -0,0 +1,91 @@
+import 'package:flutter/material.dart';
+
+import '../l10n/l10n.dart';
+import '../theme/app_colors.dart';
+import '../theme/app_theme.dart';
+
+AlertDialog appDialog(
+ GymColors gc, {
+ required Widget title,
+ required Widget content,
+ required List<Widget> actions,
+}) =>
+ AlertDialog(
+ backgroundColor: gc.bgRaised,
+ shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)),
+ title: title,
+ content: content,
+ actions: actions,
+ );
+
+Widget dialogAction(String label, Color color, VoidCallback onPressed, {bool strong = true}) =>
+ TextButton(
+ onPressed: onPressed,
+ child: Text(label,
+ style: AppTheme.s(14, weight: strong ? FontWeight.w700 : FontWeight.w400, color: color)),
+ );
+
+Future<bool> askConfirm(
+ BuildContext context, {
+ required String title,
+ required String body,
+ required String confirmLabel,
+ String? cancelLabel,
+ bool danger = false,
+}) async {
+ final gc = context.gc;
+ final ok = await showDialog<bool>(
+ context: context,
+ builder: (dctx) => appDialog(
+ gc,
+ title: Text(title, style: AppTheme.d(18, weight: FontWeight.w700, color: gc.text)),
+ content: Text(body, style: AppTheme.s(13, color: gc.textSecondary)),
+ actions: [
+ dialogAction(cancelLabel ?? t.cancel, gc.textSecondary, () => Navigator.of(dctx).pop(false),
+ strong: false),
+ dialogAction(confirmLabel, danger ? gc.danger : gc.accent, () => Navigator.of(dctx).pop(true)),
+ ],
+ ),
+ );
+ return ok ?? false;
+}
+
+Future<double?> askNumber(
+ BuildContext context, {
+ required String title,
+ required String initial,
+ required bool decimal,
+}) async {
+ final gc = context.gc;
+ final controller = TextEditingController(text: initial)
+ ..selection = TextSelection(baseOffset: 0, extentOffset: initial.length);
+
+ final raw = await showDialog<String>(
+ context: context,
+ builder: (dctx) => appDialog(
+ gc,
+ title: Text(title, style: AppTheme.d(14, weight: FontWeight.w700, color: gc.text, letterSpacing: 2)),
+ content: TextField(
+ controller: controller,
+ autofocus: true,
+ keyboardType: TextInputType.numberWithOptions(decimal: decimal),
+ textAlign: TextAlign.center,
+ style: AppTheme.d(32, weight: FontWeight.w700, color: gc.text),
+ cursorColor: gc.accent,
+ onSubmitted: (v) => Navigator.of(dctx).pop(v),
+ decoration: InputDecoration(
+ filled: true,
+ fillColor: gc.bgRaised2,
+ border: OutlineInputBorder(borderRadius: BorderRadius.circular(14), borderSide: BorderSide.none),
+ ),
+ ),
+ actions: [
+ dialogAction(t.cancel, gc.textSecondary, () => Navigator.of(dctx).pop(), strong: false),
+ dialogAction(t.set, gc.accent, () => Navigator.of(dctx).pop(controller.text)),
+ ],
+ ),
+ );
+ controller.dispose();
+
+ return double.tryParse((raw ?? '').trim().replaceAll(',', '.'));
+}
diff --git a/lib/widgets/exercise_art.dart b/lib/widgets/exercise_art.dart
index ab69e15..8abcde8 100644
--- a/lib/widgets/exercise_art.dart
+++ b/lib/widgets/exercise_art.dart
@@ -178,7 +178,6 @@ class _ArtPainter extends CustomPainter {
canvas.translate(-b.center.dx, -b.center.dy);
final n = art.frames.length;
- // Un ciclo va 1-2-3-2 y vuelve: cada tramo aguanta la pose y funde al final.
final steps = (n - 1) * 2;
final pos = t * steps;
final step = pos.floor() % steps;
diff --git a/lib/widgets/note_kit.dart b/lib/widgets/note_kit.dart
index 99fb14c..25cf873 100644
--- a/lib/widgets/note_kit.dart
+++ b/lib/widgets/note_kit.dart
@@ -10,6 +10,7 @@ import '../services/media_store.dart';
import '../state/fit_state.dart';
import '../theme/app_colors.dart';
import '../theme/app_theme.dart';
+import 'ui_kit.dart';
Color noteKindColor(GymColors gc, NoteKind k) => switch (k) {
NoteKind.note => gc.info,
@@ -200,14 +201,7 @@ Future<void> showNoteDaySheet(BuildContext context, DateTime day) async {
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
- Center(
- child: Container(
- width: 40,
- height: 4,
- decoration:
- BoxDecoration(color: gc.bgRaised2, borderRadius: BorderRadius.circular(2)),
- ),
- ),
+ const SheetHandle(),
const SizedBox(height: 18),
Text(noteDayLabel(day).toUpperCase(),
style: AppTheme.d(13, weight: FontWeight.w700, color: gc.text, letterSpacing: 2)),
diff --git a/lib/widgets/photo_source_sheet.dart b/lib/widgets/photo_source_sheet.dart
index 405e226..ddec939 100644
--- a/lib/widgets/photo_source_sheet.dart
+++ b/lib/widgets/photo_source_sheet.dart
@@ -29,11 +29,7 @@ class PhotoSourceSheet extends StatelessWidget {
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
- Container(
- width: 40,
- height: 4,
- decoration: BoxDecoration(color: gc.bgRaised2, borderRadius: BorderRadius.circular(2)),
- ),
+ const SheetHandle(),
const SizedBox(height: 18),
_option(context, PhosphorIconsRegular.camera, t.takePhoto, ImageSource.camera),
const SizedBox(height: 10),
diff --git a/lib/widgets/ui_kit.dart b/lib/widgets/ui_kit.dart
index 0ab8678..2a4849d 100644
--- a/lib/widgets/ui_kit.dart
+++ b/lib/widgets/ui_kit.dart
@@ -40,31 +40,199 @@ class SoftCard extends StatelessWidget {
}
}
-class RoundBtn extends StatelessWidget {
- const RoundBtn({super.key, required this.icon, required this.onTap, this.iconColor});
- final List<IconPath> icon;
+class SearchField extends StatelessWidget {
+ const SearchField({
+ super.key,
+ required this.controller,
+ required this.hint,
+ required this.onChanged,
+ this.color,
+ });
+
+ final TextEditingController controller;
+ final String hint;
+ final ValueChanged<String> onChanged;
+ final Color? color;
+
+ @override
+ Widget build(BuildContext context) {
+ final gc = context.gc;
+ return Container(
+ height: 48,
+ padding: const EdgeInsets.symmetric(horizontal: 16),
+ decoration: BoxDecoration(
+ color: color ?? gc.bgRaised,
+ border: Border.all(color: gc.border),
+ borderRadius: BorderRadius.circular(100),
+ ),
+ child: Row(children: [
+ SvgPathIcon(Ic.search, size: 16, color: gc.textSecondary),
+ const SizedBox(width: 10),
+ Expanded(
+ child: TextField(
+ controller: controller,
+ onChanged: onChanged,
+ style: AppTheme.s(14, color: gc.text),
+ cursorColor: gc.accent,
+ decoration: InputDecoration(
+ isCollapsed: true,
+ border: InputBorder.none,
+ hintText: hint,
+ hintStyle: AppTheme.s(14, color: gc.textSecondary),
+ ),
+ ),
+ ),
+ ]),
+ );
+ }
+}
+
+class GhostButton extends StatelessWidget {
+ const GhostButton({super.key, required this.label, required this.icon, required this.onTap});
+
+ final String label;
+ final IconData icon;
final VoidCallback onTap;
- final Color? iconColor;
@override
Widget build(BuildContext context) {
final gc = context.gc;
return GestureDetector(
+ behavior: HitTestBehavior.opaque,
onTap: onTap,
child: Container(
- width: 36,
- height: 36,
+ height: 46,
+ alignment: Alignment.center,
decoration: BoxDecoration(
- color: gc.bgRaised,
- shape: BoxShape.circle,
border: Border.all(color: gc.border),
+ borderRadius: BorderRadius.circular(14),
+ ),
+ child: Row(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ Icon(icon, size: 16, color: gc.ember),
+ const SizedBox(width: 8),
+ Text(label, style: AppTheme.d(13, weight: FontWeight.w600, color: gc.text, letterSpacing: 1)),
+ ],
),
- child: Center(child: SvgPathIcon(icon, size: 16, color: iconColor ?? gc.text)),
),
);
}
}
+class SheetHandle extends StatelessWidget {
+ const SheetHandle({super.key, this.color, this.margin});
+
+ final Color? color;
+ final EdgeInsets? margin;
+
+ @override
+ Widget build(BuildContext context) => Center(
+ child: Container(
+ width: 40,
+ height: 4,
+ margin: margin,
+ decoration: BoxDecoration(
+ color: color ?? context.gc.bgRaised2,
+ borderRadius: BorderRadius.circular(2),
+ ),
+ ),
+ );
+}
+
+class RoundAction extends StatelessWidget {
+ const RoundAction({
+ super.key,
+ required this.child,
+ required this.onTap,
+ this.label,
+ this.size = 36,
+ this.filled = false,
+ });
+
+ final Widget child;
+ final VoidCallback onTap;
+ final String? label;
+ final double size;
+ final bool filled;
+
+ @override
+ Widget build(BuildContext context) {
+ final gc = context.gc;
+ final button = GestureDetector(
+ behavior: HitTestBehavior.opaque,
+ onTap: onTap,
+ child: Container(
+ width: size,
+ height: size,
+ decoration: BoxDecoration(
+ color: filled ? gc.ember : gc.bgRaised,
+ shape: BoxShape.circle,
+ border: Border.all(color: filled ? gc.ember : gc.border),
+ ),
+ child: Center(child: child),
+ ),
+ );
+ return label == null ? button : Semantics(button: true, label: label, child: button);
+ }
+}
+
+class RoundBtn extends StatelessWidget {
+ const RoundBtn({super.key, required this.icon, required this.onTap, this.iconColor});
+ final List<IconPath> icon;
+ final VoidCallback onTap;
+ final Color? iconColor;
+
+ @override
+ Widget build(BuildContext context) => RoundAction(
+ onTap: onTap,
+ child: SvgPathIcon(icon, size: 16, color: iconColor ?? context.gc.text),
+ );
+}
+
+class ScreenHeader extends StatelessWidget {
+ const ScreenHeader({
+ super.key,
+ required this.title,
+ required this.onBack,
+ this.subtitle,
+ this.titleSize = 20,
+ this.titleSpacing = 2,
+ this.actions = const [],
+ });
+
+ final String title;
+ final VoidCallback onBack;
+ final String? subtitle;
+ final double titleSize;
+ final double titleSpacing;
+ final List<Widget> actions;
+
+ @override
+ Widget build(BuildContext context) {
+ final gc = context.gc;
+ return Row(
+ children: [
+ RoundBtn(icon: Ic.chevronLeft, onTap: onBack),
+ const SizedBox(width: 12),
+ Expanded(
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ ScreenTitle(title, size: titleSize, spacing: titleSpacing),
+ if (subtitle != null) ...[
+ const SizedBox(height: 2),
+ Text(subtitle!, style: AppTheme.s(12.5, color: gc.textSecondary)),
+ ],
+ ],
+ ),
+ ),
+ ...actions,
+ ],
+ );
+ }
+}
+
class ScreenTitle extends StatelessWidget {
const ScreenTitle(this.text, {super.key, this.size = 22, this.spacing = 2});
final String text;
diff --git a/test/backup_zip_test.dart b/test/backup_zip_test.dart
index 921f6ba..abd1ba0 100644
--- a/test/backup_zip_test.dart
+++ b/test/backup_zip_test.dart
@@ -7,10 +7,10 @@ import 'package:flutter_test/flutter_test.dart';
import 'package:gymmane/catalog/exercise_catalog.dart';
import 'package:gymmane/models/exercise.dart';
import 'package:gymmane/models/note.dart';
-import 'package:gymmane/services/progress_reminder.dart';
import 'package:gymmane/services/backup_zip.dart';
import 'package:gymmane/services/local_store.dart';
import 'package:gymmane/services/media_store.dart';
+import 'package:gymmane/services/progress_reminder.dart';
import 'package:gymmane/state/fit_state.dart';
import 'package:shared_preferences/shared_preferences.dart';
diff --git a/test/body_hit_test.dart b/test/body_hit_test.dart
index 95018b1..ed7ca5a 100644
--- a/test/body_hit_test.dart
+++ b/test/body_hit_test.dart
@@ -4,23 +4,20 @@ import 'package:path_drawing/path_drawing.dart';
void main() {
test('body muscles are hit-testable across the figure', () {
- var hits = 0;
+ final areas = {
+ for (final e in muscleFills.entries)
+ e.key: [
+ for (final d in muscleHits[e.key]?.isNotEmpty ?? false ? muscleHits[e.key]! : e.value)
+ parseSvgPathData(d),
+ ],
+ };
+
final found = <String>{};
for (double y = 0; y < bodyViewH; y += 5) {
for (double x = 0; x < bodyViewW; x += 5) {
final p = Offset(x, y);
- for (final e in muscleFills.entries) {
- final probes =
- (muscleHits[e.key]?.isNotEmpty ?? false) ? muscleHits[e.key]! : e.value;
- var hit = false;
- for (final d in probes) {
- if (parseSvgPathData(d).contains(p)) {
- hit = true;
- break;
- }
- }
- if (hit) {
- hits++;
+ for (final e in areas.entries) {
+ if (e.value.any((path) => path.contains(p))) {
found.add(e.key);
break;
}
@@ -28,8 +25,6 @@ void main() {
}
}
- // ignore: avoid_print
- print('GRID HITS=$hits muscles found=${found.length}/13: ${found.toList()..sort()}');
expect(found.length, greaterThan(6), reason: 'too few muscles are tappable');
});
}
diff --git a/test/exercise_alias_test.dart b/test/exercise_alias_test.dart
new file mode 100644
index 0000000..634a61f
--- /dev/null
+++ b/test/exercise_alias_test.dart
@@ -0,0 +1,79 @@
+import 'package:flutter_test/flutter_test.dart';
+import 'package:gymmane/catalog/exercise_aliases.dart';
+import 'package:gymmane/catalog/exercise_catalog.dart';
+import 'package:gymmane/models/exercise.dart';
+import 'package:gymmane/services/exercise_match.dart';
+
+const _hevyNames = {
+ 'Bench Press (Barbell)': 'Barbell Bench Press',
+ 'Squat (Barbell)': 'Barbell Full Squat',
+ 'Deadlift (Barbell)': 'Barbell Deadlift',
+ 'Lat Pulldown (Cable)': 'Cable Pulldown',
+ 'Seated Row (Cable)': 'Cable Seated Row',
+ 'Overhead Press (Barbell)': 'Barbell Standing Wide Military Press',
+ 'Shoulder Press (Dumbbell)': 'Dumbbell Standing Overhead Press',
+ 'Lateral Raise (Dumbbell)': 'Dumbbell Lateral Raise',
+ 'Bicep Curl (Dumbbell)': 'Dumbbell Biceps Curl',
+ 'Hammer Curl (Dumbbell)': 'Dumbbell Hammer Curl',
+ 'Triceps Pushdown (Cable)': 'Cable Pushdown',
+ 'Skullcrusher (Barbell)': 'Barbell Lying Triceps Extension',
+ 'Romanian Deadlift (Barbell)': 'Barbell Romanian Deadlift',
+ 'Bulgarian Split Squat (Dumbbell)': 'Dumbbell Single Leg Split Squat',
+ 'Chest Fly (Machine)': 'Pec Deck',
+ 'Chest Press (Machine)': 'Lever Standing Chest Press',
+ 'T Bar Row': 'Lever T Bar Row',
+ 'Hip Abduction (Machine)': 'Hip Abduction Machine',
+ 'Leg Curl (Machine)': 'Seated Leg Curl',
+ 'Farmers Walk': 'Kettlebell Farmer Carry',
+};
+
+List<Exercise> _search(String query) => kExercises.where(exerciseSearch(query)).toList();
+
+void main() {
+ final byName = {for (final e in kExercises) e.name: e};
+
+ test('every alias belongs to an exercise in the catalog', () {
+ final orphans = kExerciseAliases.keys.where((name) => !byName.containsKey(name));
+ expect(orphans, isEmpty);
+ });
+
+ test('no two exercises claim the same alias', () {
+ final owners = <String, String>{};
+ final clashes = <String>[];
+ for (final entry in kExerciseAliases.entries) {
+ for (final alias in entry.value) {
+ final owner = owners.putIfAbsent(searchKey(alias), () => entry.key);
+ if (owner != entry.key) clashes.add('$alias: $owner / ${entry.key}');
+ }
+ }
+ expect(clashes, isEmpty);
+ });
+
+ test('searching a name from another app finds the exercise', () {
+ for (final entry in _hevyNames.entries) {
+ expect(_search(entry.key).map((e) => e.name), contains(entry.value),
+ reason: 'searching "${entry.key}" should find ${entry.value}');
+ }
+ });
+
+ test('importing a name from another app maps to the same exercise', () {
+ for (final entry in _hevyNames.entries) {
+ expect(matchExercise(entry.key, kExercises)?.name, entry.value);
+ }
+ });
+
+ test('a half-typed name still narrows down to the exercise', () {
+ expect(_search('lat pulld').map((e) => e.name), contains('Cable Pulldown'));
+ expect(_search('db bench').map((e) => e.name), contains('Dumbbell Bench Press'));
+ expect(_search('bulgarian split').map((e) => e.name), contains('Dumbbell Single Leg Split Squat'));
+ });
+
+ test('the plain catalog name still wins on its own', () {
+ expect(_search('Barbell Bench Press').map((e) => e.name), contains('Barbell Bench Press'));
+ expect(_search('pec deck').single.name, 'Pec Deck');
+ });
+
+ test('an empty search keeps the whole catalog', () {
+ expect(_search(' ').length, kExercises.length);
+ });
+}
diff --git a/test/import_real_files_test.dart b/test/import_real_files_test.dart
index 86e35c0..0a32e07 100644
--- a/test/import_real_files_test.dart
+++ b/test/import_real_files_test.dart
@@ -36,7 +36,6 @@ void main() {
final sets = s.exercises.single.sets;
expect(sets.map((x) => x.reps), [5, 8, 6]);
- // 15 lb = 6.8 kg
expect(sets.first.weightKg, closeTo(6.804, 0.001));
});
@@ -84,7 +83,6 @@ void main() {
expect(csv, isNotNull, reason: 'weight.csv está dentro del zip');
expect(csv!.contains('Weight (lb)'), true);
expect(detectFormat(csv), ImportFormat.strongWeights);
- // este export venía sin pesajes anotados: no debe reventar
expect(parseImport(csv).weights, isEmpty);
});
diff --git a/test/muscle_map_test.dart b/test/muscle_map_test.dart
index a19cb43..6e51f3c 100644
--- a/test/muscle_map_test.dart
+++ b/test/muscle_map_test.dart
@@ -13,7 +13,6 @@ void main() {
tearDown(() => fit.sessions.clear());
test('sets land on the primary muscle and half on the secondary ones', () {
- // barbell-bench-press: chest primary, triceps secondary.
final ex = fit.allExercises.firstWhere((e) => e.primary == 'chest' && e.secondary.contains('triceps'));
fit.sessions.add(session(1, ex.id, 'chest', 4));
diff --git a/test/routine_session_edit_test.dart b/test/routine_session_edit_test.dart
index ad188c9..86f799d 100644
--- a/test/routine_session_edit_test.dart
+++ b/test/routine_session_edit_test.dart
@@ -1,6 +1,6 @@
import 'package:flutter_test/flutter_test.dart';
-import 'package:gymmane/services/local_store.dart';
import 'package:gymmane/models/note.dart';
+import 'package:gymmane/services/local_store.dart';
import 'package:gymmane/state/fit_state.dart';
import 'package:shared_preferences/shared_preferences.dart';
diff --git a/test/stats_realdata_test.dart b/test/stats_realdata_test.dart
index 3f0afad..5d9e713 100644
--- a/test/stats_realdata_test.dart
+++ b/test/stats_realdata_test.dart
@@ -7,8 +7,6 @@ import 'package:gymmane/services/local_store.dart';
import 'package:gymmane/state/fit_state.dart';
import 'package:shared_preferences/shared_preferences.dart';
-/// El fixture tiene fechas fijas; se desplaza entero para que el último
-/// entreno caiga ayer y las ventanas de 30 días sigan teniendo sentido.
String _slideToToday(String text) {
final data = jsonDecode(text) as Map<String, dynamic>;
final sessions = (data['sessions'] as List).cast<Map<String, dynamic>>();