interact_route_arguments.dart 1.24 KB
/// Typed context passed from a health-data entry to the interaction page.
///
/// Keep values atomic: a sleep or fitness card is represented by several
/// [InteractDisplayValue]s instead of flattening them into one localized
/// string. The interaction page and the request payload can therefore format
/// the same data independently.
class InteractRouteArguments {
  const InteractRouteArguments({
    required this.friendUserId,
    required this.page,
    required this.title,
    required this.date,
    required this.values,
  });

  final int friendUserId;
  final InteractPageSource page;
  final String title;
  final DateTime date;
  final List<InteractDisplayValue> values;
}

enum InteractPageSource { home }

enum InteractValueType {
  averageHrv,
  restingHeartRate,
  sleepDuration,
  sleepQualityScore,
  sleepQualityState,
  averageSleepHeartRate,
  activeCalories,
  exerciseDuration,
  standDuration,
}

enum InteractValueUnit {
  milliseconds,
  beatsPerMinute,
  seconds,
  kilocalories,
  hours,
  score,
  state,
}

class InteractDisplayValue {
  const InteractDisplayValue({
    required this.type,
    required this.value,
    required this.unit,
  });

  final InteractValueType type;
  final num value;
  final InteractValueUnit unit;
}