Initial commit
This commit is contained in:
29
lib/presentation/workout_session/workout_session_state.dart
Normal file
29
lib/presentation/workout_session/workout_session_state.dart
Normal file
@@ -0,0 +1,29 @@
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:trainhub_flutter/domain/entities/workout_activity.dart';
|
||||
|
||||
part 'workout_session_state.freezed.dart';
|
||||
|
||||
@freezed
|
||||
class WorkoutSessionState with _$WorkoutSessionState {
|
||||
const factory WorkoutSessionState({
|
||||
required List<WorkoutActivityEntity> activities,
|
||||
@Default(0) int currentIndex,
|
||||
@Default(0) int timeRemaining,
|
||||
@Default(0) int totalTimeElapsed,
|
||||
@Default(false) bool isRunning,
|
||||
@Default(false) bool isFinished,
|
||||
}) = _WorkoutSessionState;
|
||||
|
||||
const WorkoutSessionState._();
|
||||
|
||||
WorkoutActivityEntity? get currentActivity =>
|
||||
currentIndex < activities.length ? activities[currentIndex] : null;
|
||||
|
||||
WorkoutActivityEntity? get nextActivity =>
|
||||
currentIndex + 1 < activities.length
|
||||
? activities[currentIndex + 1]
|
||||
: null;
|
||||
|
||||
double get progress =>
|
||||
activities.isEmpty ? 0.0 : currentIndex / activities.length;
|
||||
}
|
||||
Reference in New Issue
Block a user