Files
swiftcontrol/lib/utils/host_platform.dart
Jonas Acker f44f55041c feat(rides): ride details and export, Health Connect on Android
- Details page (pushed, centred column): date, clock range and moving time;
  a stat grid with moving and total time, distance (only with a speed
  source), work in kJ with ≈ kcal, Ø/max power, cadence and heart rate,
  gear changes — values a ride never had are left out; power and heart
  rate on one time axis with the pause hatched, the dashed average and a
  hover / press-and-drag scrub; Export; delete in the ⋯ menu with a
  confirm that says what stays in the Health store.
- Export, no Pro: Apple Health / Health Connect (a status once written, no
  second write; the install when Health Connect is missing), share the .fit
  under a readable name, save the .fit (Files, the system picker, a save
  panel), and the rides folder on desktop. A phone gets a sheet, desktop a
  menu.
- Android: a small Health Connect writer over a method channel (session
  with pause segments; power, cadence, speed, heart rate, distance, active
  energy; client record ids from the ride's sync id). Write-only
  permissions, the permission-rationale activity and alias, the provider
  package query; minSdk stays 24 (the writer reports unsupported below 26).
- macOS may write user-selected files (save the .fit).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-05 21:43:41 +02:00

32 lines
1.3 KiB
Dart

import 'dart:io' show Platform;
import 'package:flutter/foundation.dart';
/// Stands another operating system in for the one the app runs on, for the
/// gates that go through [HostPlatform]. For the feature-video capture, which
/// films the Android build's options on a desktop test host. Off everywhere
/// else: while null, [HostPlatform] is dart:io's [Platform].
@visibleForTesting
TargetPlatform? debugHostPlatformOverride;
/// The operating system BikeControl runs on, as the feature gates that read it
/// see it — dart:io's [Platform] (false on the web), unless a test stages
/// another one with [debugHostPlatformOverride].
abstract final class HostPlatform {
static bool get isAndroid => _is(TargetPlatform.android, () => Platform.isAndroid);
static bool get isIOS => _is(TargetPlatform.iOS, () => Platform.isIOS);
static bool get isMacOS => _is(TargetPlatform.macOS, () => Platform.isMacOS);
static bool get isWindows => _is(TargetPlatform.windows, () => Platform.isWindows);
static bool get isLinux => _is(TargetPlatform.linux, () => Platform.isLinux);
static bool _is(TargetPlatform platform, bool Function() host) {
final override = debugHostPlatformOverride;
if (override != null) return override == platform;
return !kIsWeb && host();
}
}