WT 1.1.7+2 SearchBar, Timer for ExerciseControl
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import 'dart:async';
|
||||
import 'dart:collection';
|
||||
|
||||
import 'package:aitrainer_app/localization/app_language.dart';
|
||||
import 'package:aitrainer_app/util/app_language.dart';
|
||||
import 'package:aitrainer_app/model/exercise.dart';
|
||||
import 'package:aitrainer_app/model/workout_menu_tree.dart';
|
||||
import 'package:aitrainer_app/repository/exercise_repository.dart';
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:aitrainer_app/model/cache.dart';
|
||||
import 'package:aitrainer_app/repository/customer_repository.dart';
|
||||
import 'package:bloc/bloc.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
part 'development_sizes_event.dart';
|
||||
part 'development_sizes_state.dart';
|
||||
|
||||
class DevelopmentSizesBloc extends Bloc<DevelopmentSizesEvent, DevelopmentSizesState> {
|
||||
final CustomerRepository customerRepository;
|
||||
DevelopmentSizesBloc({this.customerRepository}) : super(DevelopmentSizesInitial()) {
|
||||
isMan = Cache().userLoggedIn.sex == "m";
|
||||
}
|
||||
|
||||
bool isMan;
|
||||
|
||||
@override
|
||||
Stream<DevelopmentSizesState> mapEventToState(
|
||||
DevelopmentSizesEvent event,
|
||||
) async* {
|
||||
try {
|
||||
if (state is DevelopmentSizesLoad) {
|
||||
yield DevelopmentSizesLoading();
|
||||
yield DevelopmentSizesReady();
|
||||
}
|
||||
} on Exception catch (e) {
|
||||
yield DevelopmentSizesError(message: e.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
part of 'development_sizes_bloc.dart';
|
||||
|
||||
abstract class DevelopmentSizesEvent extends Equatable {
|
||||
const DevelopmentSizesEvent();
|
||||
|
||||
@override
|
||||
List<Object> get props => [];
|
||||
}
|
||||
|
||||
class DevelopmentSizesLoad extends DevelopmentSizesEvent {
|
||||
const DevelopmentSizesLoad();
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
part of 'development_sizes_bloc.dart';
|
||||
|
||||
abstract class DevelopmentSizesState extends Equatable {
|
||||
const DevelopmentSizesState();
|
||||
|
||||
@override
|
||||
List<Object> get props => [];
|
||||
}
|
||||
|
||||
class DevelopmentSizesInitial extends DevelopmentSizesState {
|
||||
const DevelopmentSizesInitial();
|
||||
}
|
||||
|
||||
class DevelopmentSizesLoading extends DevelopmentSizesState {
|
||||
const DevelopmentSizesLoading();
|
||||
}
|
||||
|
||||
class DevelopmentSizesReady extends DevelopmentSizesState {
|
||||
const DevelopmentSizesReady();
|
||||
}
|
||||
|
||||
class DevelopmentSizesError extends DevelopmentSizesState {
|
||||
final String message;
|
||||
const DevelopmentSizesError({this.message});
|
||||
|
||||
@override
|
||||
List<Object> get props => [this.message];
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'dart:async';
|
||||
import 'package:aitrainer_app/bloc/timer/timer_bloc.dart';
|
||||
import 'package:aitrainer_app/repository/exercise_repository.dart';
|
||||
import 'package:bloc/bloc.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
@@ -9,6 +10,7 @@ part 'exercise_control_event.dart';
|
||||
part 'exercise_control_state.dart';
|
||||
|
||||
class ExerciseControlBloc extends Bloc<ExerciseControlEvent, ExerciseControlState> {
|
||||
final TimerBloc timerBloc;
|
||||
final ExerciseRepository exerciseRepository;
|
||||
final bool readonly;
|
||||
final double percentToCalculate;
|
||||
@@ -25,7 +27,8 @@ class ExerciseControlBloc extends Bloc<ExerciseControlEvent, ExerciseControlStat
|
||||
double scrollOffset = 0;
|
||||
|
||||
@override
|
||||
ExerciseControlBloc({this.exerciseRepository, this.readonly, this.percentToCalculate}) : super(ExerciseControlInitial()) {
|
||||
ExerciseControlBloc({this.exerciseRepository, this.readonly, this.percentToCalculate, @required this.timerBloc})
|
||||
: super(ExerciseControlInitial()) {
|
||||
initialRM = this.calculate1RM(percent75: false);
|
||||
unitQuantity = this.calculate1RM(percent75: true).roundToDouble();
|
||||
quantity = percentToCalculate == 0.75 ? 12 : 30;
|
||||
@@ -34,6 +37,7 @@ class ExerciseControlBloc extends Bloc<ExerciseControlEvent, ExerciseControlStat
|
||||
exerciseRepository.setUnitQuantity(unitQuantity);
|
||||
exerciseRepository.setQuantity(quantity);
|
||||
print("init quantity: " + quantity.toString());
|
||||
timerBloc.add(TimerStart(duration: 300));
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -78,6 +82,7 @@ class ExerciseControlBloc extends Bloc<ExerciseControlEvent, ExerciseControlStat
|
||||
|
||||
exerciseRepository.setQuantity(quantity);
|
||||
exerciseRepository.exercise.exerciseId = null;
|
||||
step <= 3 ? timerBloc.add(TimerStart(duration: 300)) : timerBloc.add(TimerEnd());
|
||||
}
|
||||
yield ExerciseControlReady();
|
||||
}
|
||||
@@ -109,12 +114,7 @@ class ExerciseControlBloc extends Bloc<ExerciseControlEvent, ExerciseControlStat
|
||||
final double weight = exerciseRepository.exercise.unitQuantity;
|
||||
final double repeatWendler = (rmWendler - weight) / 0.0333 / weight;
|
||||
final double repeatOconner = (rmOconner / weight - 1) * 40;
|
||||
print("Weight: " +
|
||||
weight.toString() +
|
||||
" repeatWendler: " +
|
||||
repeatWendler.toStringAsFixed(0) +
|
||||
" repeat Oconner: " +
|
||||
repeatOconner.toStringAsFixed(0));
|
||||
return repeatWendler;
|
||||
print("Weight: $weight repeatWendler: $repeatWendler repeat Oconner: $repeatOconner");
|
||||
return unitQuantity > 100 ? (repeatOconner + repeatWendler) / 2 : repeatWendler;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,14 +44,12 @@ class ExerciseNewBloc extends Bloc<ExerciseNewEvent, ExerciseNewState> with Logg
|
||||
String fitnessLevel;
|
||||
bool changedWeight = false;
|
||||
bool changedSizes = false;
|
||||
final List<Property> womanSizes = List();
|
||||
final List<Property> manSizes = List();
|
||||
|
||||
final double baseWidth = 312;
|
||||
final double baseHeight = 675.2;
|
||||
double mediaWidth = 0;
|
||||
double mediaHeight = 0;
|
||||
bool isMan = true;
|
||||
|
||||
String exerciseTask = "";
|
||||
|
||||
final StopWatchTimer stopWatchTimer = StopWatchTimer(
|
||||
@@ -73,7 +71,7 @@ class ExerciseNewBloc extends Bloc<ExerciseNewEvent, ExerciseNewState> with Logg
|
||||
height = customerRepository.customer.getProperty("Height");
|
||||
birthYear = customerRepository.customer.birthYear;
|
||||
fitnessLevel = customerRepository.customer.fitnessLevel;
|
||||
this.isMan = (customerRepository.customer.sex == "m");
|
||||
|
||||
}
|
||||
if (exerciseType.unit == "second") {
|
||||
stopWatchTimer.rawTime.listen((value) => {timerValue = value, this.setQuantity((value / 1000).toDouble())});
|
||||
@@ -109,196 +107,6 @@ class ExerciseNewBloc extends Bloc<ExerciseNewEvent, ExerciseNewState> with Logg
|
||||
exerciseRepository.setQuantity(quantity);
|
||||
}
|
||||
|
||||
void setMediaDimensions(double width, double height) {
|
||||
this.mediaHeight = height;
|
||||
this.mediaWidth = width;
|
||||
this.addSizes(customerRepository.sex);
|
||||
}
|
||||
|
||||
void addSizes(String sex) {
|
||||
List<Property> properties = Cache().getProperties();
|
||||
if (properties == null) {
|
||||
return;
|
||||
}
|
||||
final double distortionWidth = mediaWidth / baseWidth;
|
||||
final double distortionHeight = mediaHeight / baseHeight;
|
||||
if (isMan) {
|
||||
properties.forEach((element) {
|
||||
if (element.propertyName == "Shoulder") {
|
||||
element.top = (122 * distortionHeight).toInt();
|
||||
element.left = (130 * distortionWidth).toInt();
|
||||
element.value = customerRepository.customer.getProperty("Shoulder");
|
||||
manSizes.add(element);
|
||||
} else if (element.propertyName == "Neck") {
|
||||
element.top = (68 * distortionHeight).toInt();
|
||||
element.left = (130 * distortionWidth).toInt();
|
||||
element.value = customerRepository.customer.getProperty("Neck");
|
||||
manSizes.add(element);
|
||||
} else if (element.propertyName == "Biceps") {
|
||||
element.top = (178 * distortionHeight).toInt();
|
||||
element.left = (208 * distortionWidth).toInt();
|
||||
element.value = customerRepository.customer.getProperty("Biceps");
|
||||
manSizes.add(element);
|
||||
} else if (element.propertyName == "Chest") {
|
||||
element.top = (154 * distortionHeight).toInt();
|
||||
element.left = (130 * distortionWidth).toInt();
|
||||
element.value = customerRepository.customer.getProperty("Chest");
|
||||
manSizes.add(element);
|
||||
} else if (element.propertyName == "Belly") {
|
||||
element.top = (244 * distortionHeight).toInt();
|
||||
element.left = (130 * distortionWidth).toInt();
|
||||
element.value = customerRepository.customer.getProperty("Belly");
|
||||
manSizes.add(element);
|
||||
} else if (element.propertyName == "Hip") {
|
||||
element.top = (308 * distortionHeight).toInt();
|
||||
element.left = (130 * distortionWidth).toInt();
|
||||
element.value = customerRepository.customer.getProperty("Hip");
|
||||
manSizes.add(element);
|
||||
} else if (element.propertyName == "Thigh Top") {
|
||||
element.top = (332 * distortionHeight).toInt();
|
||||
element.left = (165 * distortionWidth).toInt();
|
||||
element.value = customerRepository.customer.getProperty("Thigh Top");
|
||||
manSizes.add(element);
|
||||
} else if (element.propertyName == "Thigh Middle") {
|
||||
element.top = (382 * distortionHeight).toInt();
|
||||
element.left = (100 * distortionWidth).toInt();
|
||||
element.value = customerRepository.customer.getProperty("Thigh Middle");
|
||||
manSizes.add(element);
|
||||
} else if (element.propertyName == "Knee") {
|
||||
element.top = (464 * distortionHeight).toInt();
|
||||
element.left = (97 * distortionWidth).toInt();
|
||||
element.value = customerRepository.customer.getProperty("Knee");
|
||||
manSizes.add(element);
|
||||
} else if (element.propertyName == "Calf") {
|
||||
element.top = (520 * distortionHeight).toInt();
|
||||
element.left = (97 * distortionWidth).toInt();
|
||||
element.value = customerRepository.customer.getProperty("Calf");
|
||||
manSizes.add(element);
|
||||
} else if (element.propertyName == "Ankle") {
|
||||
element.top = (620 * distortionHeight).toInt();
|
||||
element.left = (150 * distortionWidth).toInt();
|
||||
element.value = customerRepository.customer.getProperty("Ankle");
|
||||
manSizes.add(element);
|
||||
} else if (element.propertyName == "Weight") {
|
||||
element.top = (402 * distortionHeight).toInt();
|
||||
element.left = (240 * distortionWidth).toInt();
|
||||
element.value = customerRepository.customer.getProperty("Weight");
|
||||
manSizes.add(element);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
properties.forEach((element) {
|
||||
if (element.propertyName == "Shoulder") {
|
||||
element.top = (122 * distortionHeight).toInt();
|
||||
element.left = (151 * distortionWidth).toInt();
|
||||
element.value = customerRepository.customer.getProperty("Shoulder");
|
||||
manSizes.add(element);
|
||||
} else if (element.propertyName == "Neck") {
|
||||
element.top = (78 * distortionHeight).toInt();
|
||||
element.left = (151 * distortionWidth).toInt();
|
||||
element.value = customerRepository.customer.getProperty("Neck");
|
||||
manSizes.add(element);
|
||||
} else if (element.propertyName == "Biceps") {
|
||||
element.top = (178 * distortionHeight).toInt();
|
||||
element.left = (212 * distortionWidth).toInt();
|
||||
element.value = customerRepository.customer.getProperty("Biceps");
|
||||
manSizes.add(element);
|
||||
} else if (element.propertyName == "Chest") {
|
||||
element.top = (154 * distortionHeight).toInt();
|
||||
element.left = (151 * distortionWidth).toInt();
|
||||
element.value = customerRepository.customer.getProperty("Chest");
|
||||
manSizes.add(element);
|
||||
} else if (element.propertyName == "Belly") {
|
||||
element.top = (230 * distortionHeight).toInt();
|
||||
element.left = (151 * distortionWidth).toInt();
|
||||
element.value = customerRepository.customer.getProperty("Belly");
|
||||
manSizes.add(element);
|
||||
} else if (element.propertyName == "Hip") {
|
||||
element.top = (294 * distortionHeight).toInt();
|
||||
element.left = (151 * distortionWidth).toInt();
|
||||
element.value = customerRepository.customer.getProperty("Hip");
|
||||
manSizes.add(element);
|
||||
} else if (element.propertyName == "Thigh Top") {
|
||||
element.top = (335 * distortionHeight).toInt();
|
||||
element.left = (185 * distortionWidth).toInt();
|
||||
element.value = customerRepository.customer.getProperty("Thigh Top");
|
||||
manSizes.add(element);
|
||||
} else if (element.propertyName == "Thigh Middle") {
|
||||
element.top = (377 * distortionHeight).toInt();
|
||||
element.left = (125 * distortionWidth).toInt();
|
||||
element.value = customerRepository.customer.getProperty("Thigh Middle");
|
||||
manSizes.add(element);
|
||||
} else if (element.propertyName == "Knee") {
|
||||
element.top = (468 * distortionHeight).toInt();
|
||||
element.left = (129 * distortionWidth).toInt();
|
||||
element.value = customerRepository.customer.getProperty("Knee");
|
||||
manSizes.add(element);
|
||||
} else if (element.propertyName == "Calf") {
|
||||
element.top = (525 * distortionHeight).toInt();
|
||||
element.left = (129 * distortionWidth).toInt();
|
||||
element.value = customerRepository.customer.getProperty("Calf");
|
||||
manSizes.add(element);
|
||||
} else if (element.propertyName == "Ankle") {
|
||||
element.top = (620 * distortionHeight).toInt();
|
||||
element.left = (162 * distortionWidth).toInt();
|
||||
element.value = customerRepository.customer.getProperty("Ankle");
|
||||
manSizes.add(element);
|
||||
} else if (element.propertyName == "Weight") {
|
||||
element.top = (402 * distortionHeight).toInt();
|
||||
element.left = (240 * distortionWidth).toInt();
|
||||
element.value = customerRepository.customer.getProperty("Weight");
|
||||
manSizes.add(element);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
int getWeightCoordinate(isMan, {isTop = false, isLeft = false}) {
|
||||
int value = 0;
|
||||
this.manSizes.forEach((element) {
|
||||
if (element.propertyName == "Weight") {
|
||||
if (isTop == true) {
|
||||
value = element.top;
|
||||
} else if (isLeft == true) {
|
||||
value = element.left;
|
||||
}
|
||||
}
|
||||
});
|
||||
return value;
|
||||
}
|
||||
|
||||
Property getPropertyByName(String propertyName) {
|
||||
Property property;
|
||||
List<Property> sizes;
|
||||
if (customerRepository.sex == "Man") {
|
||||
sizes = this.manSizes;
|
||||
} else {
|
||||
sizes = this.womanSizes;
|
||||
}
|
||||
|
||||
sizes.forEach((element) {
|
||||
if (element.propertyName == propertyName) {
|
||||
property = element;
|
||||
}
|
||||
});
|
||||
return property;
|
||||
}
|
||||
|
||||
void updateSizes(String propertyName, double value) {
|
||||
List<Property> sizes;
|
||||
if (customerRepository.sex == "Man") {
|
||||
sizes = this.manSizes;
|
||||
} else {
|
||||
sizes = this.womanSizes;
|
||||
}
|
||||
|
||||
sizes.forEach((element) {
|
||||
if (element.propertyName == propertyName) {
|
||||
element.value = value;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Stream<ExerciseNewState> mapEventToState(ExerciseNewEvent event) async* {
|
||||
try {
|
||||
@@ -358,7 +166,7 @@ class ExerciseNewBloc extends Bloc<ExerciseNewEvent, ExerciseNewState> with Logg
|
||||
} else if (event is ExerciseNewSizeChange) {
|
||||
yield ExerciseNewLoading();
|
||||
this.changedSizes = true;
|
||||
this.updateSizes(event.propertyName, event.value);
|
||||
this.customerRepository.updateSizes(event.propertyName, event.value);
|
||||
customerRepository.setCustomerProperty(event.propertyName, event.value);
|
||||
yield ExerciseNewReady();
|
||||
} else if (event is ExerciseNewSubmit) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:aitrainer_app/bloc/settings/settings_bloc.dart';
|
||||
import 'package:aitrainer_app/localization/app_language.dart';
|
||||
import 'package:aitrainer_app/util/app_language.dart';
|
||||
import 'package:aitrainer_app/service/logging.dart';
|
||||
import 'package:aitrainer_app/util/session.dart';
|
||||
import 'package:bloc/bloc.dart';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:aitrainer_app/localization/app_language.dart';
|
||||
import 'package:aitrainer_app/localization/app_localization.dart';
|
||||
import 'package:aitrainer_app/util/app_language.dart';
|
||||
import 'package:aitrainer_app/util/app_localization.dart';
|
||||
import 'package:aitrainer_app/model/cache.dart';
|
||||
import 'package:aitrainer_app/service/logging.dart';
|
||||
import 'package:aitrainer_app/util/enums.dart';
|
||||
|
||||
@@ -0,0 +1,106 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:audioplayer/audioplayer.dart';
|
||||
import 'package:bloc/bloc.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
part 'timer_event.dart';
|
||||
part 'timer_state.dart';
|
||||
|
||||
class Ticker {
|
||||
Stream<int> tick({int ticks}) {
|
||||
return Stream.periodic(Duration(seconds: 1), (x) => compute(ticks, x)).take(ticks);
|
||||
}
|
||||
|
||||
int compute(int ticks, int x) {
|
||||
//print("tcik: " + (ticks - x - 1).toString());
|
||||
return ticks - x - 1;
|
||||
}
|
||||
}
|
||||
|
||||
class TimerBloc extends Bloc<TimerEvent, TimerState> {
|
||||
final Ticker _ticker = Ticker();
|
||||
int _duration = 0;
|
||||
|
||||
final AudioPlayer audioPlayer = AudioPlayer();
|
||||
int minutes = 0;
|
||||
int seconds = 0;
|
||||
|
||||
StreamSubscription<int> _tickerSubscription;
|
||||
|
||||
TimerBloc() : super(TimerReady(300));
|
||||
|
||||
@override
|
||||
void onTransition(Transition<TimerEvent, TimerState> transition) {
|
||||
super.onTransition(transition);
|
||||
//print(transition);
|
||||
}
|
||||
|
||||
@override
|
||||
Stream<TimerState> mapEventToState(
|
||||
TimerEvent event,
|
||||
) async* {
|
||||
if (event is TimerStart) {
|
||||
yield* _mapStartToState(event);
|
||||
} else if (event is TimerPause) {
|
||||
yield* _mapPauseToState(event);
|
||||
} else if (event is TimerResume) {
|
||||
yield* _mapResumeToState(event);
|
||||
} else if (event is TimerReset) {
|
||||
yield* _mapResetToState(event);
|
||||
} else if (event is TimerTick) {
|
||||
yield* _mapTickToState(event);
|
||||
} else if (event is TimerEnd) {
|
||||
print("$event");
|
||||
_tickerSubscription?.cancel();
|
||||
yield TimerFinished(state.duration);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> close() {
|
||||
_tickerSubscription?.cancel();
|
||||
return super.close();
|
||||
}
|
||||
|
||||
Stream<TimerState> _mapStartToState(TimerStart start) async* {
|
||||
//print("$start");
|
||||
yield TimerRunning(start.duration);
|
||||
_tickerSubscription?.cancel();
|
||||
_tickerSubscription = _ticker.tick(ticks: start.duration).listen(
|
||||
(localDuration) {
|
||||
//print("local: $localDuration");
|
||||
add(TimerTick(duration: localDuration));
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Stream<TimerState> _mapPauseToState(TimerPause pause) async* {
|
||||
if (state is TimerRunning) {
|
||||
_tickerSubscription?.pause();
|
||||
yield TimerPaused(state.duration);
|
||||
}
|
||||
}
|
||||
|
||||
Stream<TimerState> _mapResumeToState(TimerResume pause) async* {
|
||||
if (state is TimerPaused) {
|
||||
_tickerSubscription?.resume();
|
||||
yield TimerRunning(state.duration);
|
||||
}
|
||||
}
|
||||
|
||||
Stream<TimerState> _mapResetToState(TimerReset reset) async* {
|
||||
this._duration = 0;
|
||||
yield TimerReady(_duration);
|
||||
}
|
||||
|
||||
Stream<TimerState> _mapTickToState(TimerTick tick) async* {
|
||||
//print("tick $tick");
|
||||
yield TickStart(tick.duration);
|
||||
yield tick.duration >= 0 ? TimerRunning(tick.duration) : TimerFinished(tick.duration);
|
||||
}
|
||||
|
||||
Future _play() async {
|
||||
await audioPlayer.play('asset/wine-glass.mp3', isLocal: true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
part of 'timer_bloc.dart';
|
||||
|
||||
abstract class TimerEvent extends Equatable {
|
||||
const TimerEvent();
|
||||
|
||||
@override
|
||||
List<Object> get props => [];
|
||||
}
|
||||
|
||||
class TimerStart extends TimerEvent {
|
||||
final int duration;
|
||||
const TimerStart({this.duration});
|
||||
|
||||
@override
|
||||
String toString() => "TimerStart { duration: $duration }";
|
||||
}
|
||||
|
||||
class TimerEnd extends TimerEvent {
|
||||
final int duration;
|
||||
const TimerEnd({this.duration});
|
||||
}
|
||||
|
||||
class TimerTick extends TimerEvent {
|
||||
final int duration;
|
||||
const TimerTick({this.duration});
|
||||
|
||||
@override
|
||||
String toString() => "Tick { duration: $duration }";
|
||||
}
|
||||
|
||||
class TimerPause extends TimerEvent {
|
||||
const TimerPause();
|
||||
}
|
||||
|
||||
class TimerResume extends TimerEvent {
|
||||
const TimerResume();
|
||||
}
|
||||
|
||||
class TimerReset extends TimerEvent {
|
||||
const TimerReset();
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
part of 'timer_bloc.dart';
|
||||
|
||||
abstract class TimerState extends Equatable {
|
||||
final int duration;
|
||||
|
||||
TimerState(this.duration, [List props = const []]);
|
||||
|
||||
@override
|
||||
List<Object> get props => [];
|
||||
}
|
||||
|
||||
class TickStart extends TimerState {
|
||||
TickStart(int duration) : super(duration);
|
||||
@override
|
||||
String toString() => 'Start { duration: $duration }';
|
||||
}
|
||||
|
||||
class TimerRunning extends TimerState {
|
||||
TimerRunning(int duration) : super(duration);
|
||||
|
||||
@override
|
||||
String toString() => 'Running { duration: $duration }';
|
||||
}
|
||||
|
||||
class TimerReady extends TimerState {
|
||||
TimerReady(int duration) : super(duration);
|
||||
|
||||
@override
|
||||
String toString() => 'Ready { duration: $duration }';
|
||||
}
|
||||
|
||||
class TimerPaused extends TimerState {
|
||||
TimerPaused(int duration) : super(duration);
|
||||
|
||||
@override
|
||||
String toString() => 'Paused { duration: $duration }';
|
||||
}
|
||||
|
||||
class TimerFinished extends TimerState {
|
||||
TimerFinished(int duration) : super(duration);
|
||||
|
||||
@override
|
||||
String toString() => 'Finished { duration: $duration }';
|
||||
}
|
||||
|
||||
class TimerError extends TimerState {
|
||||
final String message;
|
||||
TimerError(int duration, {this.message}) : super(duration);
|
||||
}
|
||||
Reference in New Issue
Block a user