Offline gym log for Android. No account, no ads, no internet.
Dart androidbodybuildingdartexercisesf-droidfitnessfluttergymgym-apphealthprivacyself-hostedworkoutworkout-appworkout-tracker
Tidy health cards and step metrics
InlitXfd451e1a5daf
diff --git a/lib/services/health_metrics.dart b/lib/services/health_metrics.dartindex 0e29e20..0b4d7be 100644--- a/lib/services/health_metrics.dart+++ b/lib/services/health_metrics.dart@@ -39,7 +39,7 @@ class HealthMetrics {static const _channel = MethodChannel('gymmane/health');static Future<Set<HealthMetric>> granted() async {- if (!Platform.isAndroid) return {};+ if (!(Platform.isAndroid || Platform.isIOS)) return {};try {final keys = await _channel.invokeListMethod<String>('metricsGranted') ?? const [];final byName = HealthMetric.values.asNameMap();@@ -52,7 +52,7 @@ class HealthMetrics {}static Future<bool> request(Iterable<HealthMetric> metrics) async {- if (!Platform.isAndroid) return false;+ if (!(Platform.isAndroid || Platform.isIOS)) return false;try {return await _channel.invokeMethod<bool>('requestMetrics', {'metrics': [for (final m in metrics) m.name],@@ -66,7 +66,7 @@ class HealthMetrics {}static Future<Set<String>> grantedKeys() async {- if (!Platform.isAndroid) return {};+ if (!(Platform.isAndroid || Platform.isIOS)) return {};try {return {...?await _channel.invokeListMethod<String>('metricsGranted')};} on PlatformException {@@ -77,7 +77,7 @@ class HealthMetrics {}static Future<bool> requestKeys(List<String> keys) async {- if (!Platform.isAndroid) return false;+ if (!(Platform.isAndroid || Platform.isIOS)) return false;try {return await _channel.invokeMethod<bool>('requestMetrics', {'metrics': keys}) ?? false;} on PlatformException {@@ -96,7 +96,7 @@ class HealthMetrics {String notes = '',bool manual = false,}) async {- if (!Platform.isAndroid) return false;+ if (!(Platform.isAndroid || Platform.isIOS)) return false;try {return await _channel.invokeMethod<bool>('writeWorkout', {'id': id,@@ -116,7 +116,7 @@ class HealthMetrics {}static Future<bool> deleteWorkout(String id) async {- if (!Platform.isAndroid) return false;+ if (!(Platform.isAndroid || Platform.isIOS)) return false;try {return await _channel.invokeMethod<bool>('deleteWorkout', {'id': id}) ?? false;} on PlatformException {@@ -130,7 +130,7 @@ class HealthMetrics {readKey(metric.name, from, to);static Future<List<List<double>>?> readKey(String key, DateTime from, DateTime to) async {- if (!Platform.isAndroid) return null;+ if (!(Platform.isAndroid || Platform.isIOS)) return null;try {final rows = await _channel.invokeListMethod<Object?>('readMetric', {'metric': key,diff --git a/lib/services/health_steps.dart b/lib/services/health_steps.dartindex 6b59cf7..e42f5f1 100644--- a/lib/services/health_steps.dart+++ b/lib/services/health_steps.dart@@ -28,7 +28,7 @@ class HealthSteps {}static Future<HealthAccess> access() async {- if (!Platform.isAndroid) return HealthAccess.unsupported;+ if (!(Platform.isAndroid || Platform.isIOS)) return HealthAccess.unsupported;try {final status = await _channel.invokeMethod<String>('status');return HealthAccess.values.asNameMap()[status] ?? HealthAccess.unsupported;@@ -40,7 +40,7 @@ class HealthSteps {}static Future<bool> request() async {- if (!Platform.isAndroid) return false;+ if (!(Platform.isAndroid || Platform.isIOS)) return false;try {return await _channel.invokeMethod<bool>('request') ?? false;} on PlatformException {@@ -51,7 +51,7 @@ class HealthSteps {}static Future<bool> openSettings() async {- if (!Platform.isAndroid) return false;+ if (!(Platform.isAndroid || Platform.isIOS)) return false;try {return await _channel.invokeMethod<bool>('openSettings') ?? false;} on PlatformException {@@ -62,7 +62,7 @@ class HealthSteps {}static Future<Map<DateTime, int>?> read(List<DateTime> days) async {- if (days.isEmpty || !Platform.isAndroid) return null;+ if (days.isEmpty || !(Platform.isAndroid || Platform.isIOS)) return null;final now = DateTime.now().millisecondsSinceEpoch;final ranges = [for (final day in days)diff --git a/lib/widgets/health_cards.dart b/lib/widgets/health_cards.dartindex 0633e18..ba890f1 100644--- a/lib/widgets/health_cards.dart+++ b/lib/widgets/health_cards.dart@@ -161,7 +161,7 @@ class HealthCard extends StatelessWidget {const SizedBox(height: 12),Row(children: [Expanded(- child: Text(t.healthFrom,+ child: Text(health(t.healthFrom),maxLines: 1,overflow: TextOverflow.ellipsis,style: AppTheme.f(11.5, weight: FontWeight.w500, color: gc.textTertiary)),@@ -258,7 +258,7 @@ class HealthScreen extends StatelessWidget {Text(t.healthTitle,style: AppTheme.f(32, weight: FontWeight.w800, color: gc.text, letterSpacing: -0.9, height: 1.05)),const SizedBox(height: 4),- Text(t.healthFrom, style: AppTheme.f(13, weight: FontWeight.w500, color: gc.textSecondary)),+ Text(health(t.healthFrom), style: AppTheme.f(13, weight: FontWeight.w500, color: gc.textSecondary)),for (final g in HealthGroup.values)if (shown.any((m) => m.group == g) || (g == HealthGroup.activity && fit.stepsOn))Column(@@ -525,7 +525,7 @@ void showHealthPicker(BuildContext context) {const SizedBox(height: 20),Text(t.healthPickTitle, textAlign: TextAlign.center, style: AppTheme.f(19, color: gc.text)),const SizedBox(height: 6),- Text(t.healthPickHint,+ Text(health(t.healthPickHint),textAlign: TextAlign.center,style: AppTheme.f(12.5, weight: FontWeight.w500, color: gc.textSecondary, height: 1.4)),const SizedBox(height: 16),@@ -724,6 +724,12 @@ void showHealthDetail(BuildContext context, HealthMetric metric) {if (fit.healthOnDay(metric, d)?.first case final v?) healthShown(metric, v) else null,],labels: [for (final d in week) t.weekdayInitial(d.weekday)],+ tags: pressure+ ? [+ for (final d in week)+ if (fit.healthOnDay(metric, d) case final v? when v.length > 1) healthValue(metric, v) else null,+ ]+ : null,format: (v) => switch (metric) {HealthMetric.sleep => healthNumber(metric, v * 60),HealthMetric.spo2 ||@@ -762,7 +768,7 @@ void showHealthDetail(BuildContext context, HealthMetric metric) {],]),const SizedBox(height: 10),- Text(t.healthFrom,+ Text(health(t.healthFrom),textAlign: TextAlign.center,style: AppTheme.f(11.5, weight: FontWeight.w500, color: gc.textTertiary)),const SizedBox(height: 16),@@ -797,7 +803,7 @@ class _HealthLinksState extends State<_HealthLinks> {final ok = await set(!saved);if (mounted) setState(() => _asking.remove(title));if (!ok && context.mounted) {- showNotchToast(context, t.healthLinkDenied,+ showNotchToast(context, health(t.healthLinkDenied),icon: PhosphorIconsFill.warningCircle, accent: gc.warn, action: t.healthOpenSettings,onTap: () => HealthSteps.openSettings());}@@ -833,7 +839,7 @@ class _HealthLinksState extends State<_HealthLinks> {Divider(height: 1, thickness: 1, color: gc.border, indent: 14, endIndent: 14),row(PhosphorIconsRegular.scales, t.healthLinkWeight, t.healthLinkWeightHint, fit.hcWeights, fit.setHcWeights),Divider(height: 1, thickness: 1, color: gc.border, indent: 14, endIndent: 14),- row(PhosphorIconsRegular.barbell, t.healthLinkWrite, t.healthLinkWriteHint, fit.hcWrite, fit.setHcWrite),+ row(PhosphorIconsRegular.barbell, t.healthLinkWrite, health(t.healthLinkWriteHint), fit.hcWrite, fit.setHcWrite),]),),]);diff --git a/lib/widgets/steps_card.dart b/lib/widgets/steps_card.dartindex 3e381b8..aab2e27 100644--- a/lib/widgets/steps_card.dart+++ b/lib/widgets/steps_card.dart@@ -41,7 +41,7 @@ class StepsCard extends StatelessWidget {children: [Text(t.stepsNoAccess, style: AppTheme.f(14.5, color: gc.text)),const SizedBox(height: 2),- Text(t.stepsGrant,+ Text(health(t.stepsGrant),style: AppTheme.f(12, weight: FontWeight.w500, color: gc.textSecondary)),],),@@ -147,9 +147,9 @@ class StepsCard extends StatelessWidget {void showStepsSheet(BuildContext context) {final gc = context.gc;final points = [- (PhosphorIconsRegular.footprints, t.stepsInfoRead),+ (PhosphorIconsRegular.footprints, health(t.stepsInfoRead)),(PhosphorIconsRegular.deviceMobile, t.stepsInfoLocal),- (PhosphorIconsRegular.toggleLeft, t.stepsInfoOff),+ (PhosphorIconsRegular.toggleLeft, health(t.stepsInfoOff)),];showAppSheet<void>(context: context,