WT 1.1.11+4 bug fixes
This commit is contained in:
@@ -9,6 +9,14 @@ part 'exercise_control_event.dart';
|
||||
|
||||
part 'exercise_control_state.dart';
|
||||
|
||||
enum ExerciseTypeLocal { oneRepMax, endurance }
|
||||
|
||||
extension ExerciseTypeLocalExt on ExerciseTypeLocal {
|
||||
String toStr() => this.toString().split(".").last;
|
||||
bool equalsTo(ExerciseTypeLocal type) => this.toString() == type.toString();
|
||||
bool equalsStringTo(String type) => this.toStr() == type;
|
||||
}
|
||||
|
||||
class ExerciseControlBloc extends Bloc<ExerciseControlEvent, ExerciseControlState> {
|
||||
final TimerBloc timerBloc;
|
||||
final ExerciseRepository exerciseRepository;
|
||||
@@ -26,16 +34,25 @@ class ExerciseControlBloc extends Bloc<ExerciseControlEvent, ExerciseControlStat
|
||||
double? firstUnitQuantity; // unit quantity of the first test
|
||||
|
||||
double scrollOffset = 0;
|
||||
late ExerciseTypeLocal exerciseTypeLocal;
|
||||
|
||||
@override
|
||||
ExerciseControlBloc({required this.exerciseRepository, required this.readonly, required this.timerBloc})
|
||||
: super(ExerciseControlInitial()) {
|
||||
print("Exercise ${exerciseRepository.exercise!.toJson()}");
|
||||
|
||||
exerciseTypeLocal = ExerciseTypeLocal.oneRepMax;
|
||||
oneRepQuantity = exerciseRepository.exercise!.quantity!;
|
||||
if (oneRepQuantity > 25) {
|
||||
exerciseTypeLocal = ExerciseTypeLocal.endurance;
|
||||
}
|
||||
oneRepUnitQuantity = exerciseRepository.exercise!.unitQuantity!;
|
||||
initialRM = this.calculate1RM(percent75: false);
|
||||
unitQuantity = this.calculate1RM(percent75: true).roundToDouble();
|
||||
quantity = 12;
|
||||
if (oneRepQuantity > 25) {
|
||||
quantity = 35;
|
||||
}
|
||||
origQuantity = quantity;
|
||||
|
||||
exerciseRepository.setUnitQuantity(unitQuantity);
|
||||
@@ -47,11 +64,12 @@ class ExerciseControlBloc extends Bloc<ExerciseControlEvent, ExerciseControlStat
|
||||
@override
|
||||
Stream<ExerciseControlState> mapEventToState(ExerciseControlEvent event) async* {
|
||||
try {
|
||||
if (event is ExerciseControlLoad) {
|
||||
/* if (event is ExerciseControlLoad) {
|
||||
yield ExerciseControlLoading();
|
||||
step = 1;
|
||||
yield ExerciseControlReady();
|
||||
} else if (event is ExerciseControlQuantityChange) {
|
||||
} else */
|
||||
if (event is ExerciseControlQuantityChange) {
|
||||
//yield ExerciseControlLoading();
|
||||
if (event.step == step) {
|
||||
exerciseRepository.setQuantity(event.quantity);
|
||||
@@ -60,7 +78,7 @@ class ExerciseControlBloc extends Bloc<ExerciseControlEvent, ExerciseControlStat
|
||||
//yield ExerciseControlReady();
|
||||
} else if (event is ExerciseControlUnitQuantityChange) {
|
||||
yield ExerciseControlLoading();
|
||||
|
||||
print("event step ${event.step} quantity ${event.quantity}");
|
||||
if (event.step == step) {
|
||||
this.unitQuantity = event.quantity;
|
||||
exerciseRepository.setUnitQuantity(event.quantity);
|
||||
@@ -108,7 +126,12 @@ class ExerciseControlBloc extends Bloc<ExerciseControlEvent, ExerciseControlStat
|
||||
print("Weight: $weight repeat: $repeat, $rmWendler, Oconner: $rmOconner");
|
||||
double average = (rmWendler + rmOconner) / 2;
|
||||
|
||||
return percent75 ? average * 0.75 : average;
|
||||
double serieQuantity = 0.75;
|
||||
if (exerciseTypeLocal.equalsTo(ExerciseTypeLocal.endurance)) {
|
||||
serieQuantity = 0.5;
|
||||
}
|
||||
|
||||
return percent75 ? average * serieQuantity : average;
|
||||
}
|
||||
|
||||
int calculateQuantityByUnitQuantity() {
|
||||
|
||||
+1
-1
@@ -21,7 +21,7 @@ class Track with Logging {
|
||||
Flurry.logEvent(event.toString());
|
||||
Smartlook.setGlobalEventProperty(event.toString(), eventValue, false);
|
||||
model.Tracking tracking = model.Tracking();
|
||||
tracking.customerId = Cache().userLoggedIn!.customerId!;
|
||||
tracking.customerId = Cache().userLoggedIn == null ? 0 : Cache().userLoggedIn!.customerId!;
|
||||
tracking.event = event.enumToString();
|
||||
if (eventValue.isNotEmpty) {
|
||||
tracking.eventValue = eventValue;
|
||||
|
||||
@@ -598,7 +598,9 @@ class _AnimatedLiquidCustomProgressIndicatorState extends State<_AnimatedLiquidC
|
||||
vsync: this,
|
||||
duration: Duration(seconds: 3),
|
||||
)..addListener(() {
|
||||
setState(() {});
|
||||
setState(() {
|
||||
print("build animation state change");
|
||||
});
|
||||
});
|
||||
|
||||
_animationController.forward();
|
||||
|
||||
@@ -41,8 +41,8 @@ class _ExerciseControlPage extends State<ExerciseControlPage> with Trans {
|
||||
TimerBloc timerBloc = BlocProvider.of<TimerBloc>(context);
|
||||
|
||||
return BlocProvider(
|
||||
create: (context) => ExerciseControlBloc(exerciseRepository: exerciseRepository, readonly: readonly, timerBloc: timerBloc)
|
||||
..add(ExerciseControlLoad()),
|
||||
create: (context) => ExerciseControlBloc(exerciseRepository: exerciseRepository, readonly: readonly, timerBloc: timerBloc),
|
||||
//..add(ExerciseControlLoad()),
|
||||
child: BlocConsumer<ExerciseControlBloc, ExerciseControlState>(listener: (context, state) {
|
||||
if (state is ExerciseControlError) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
@@ -260,6 +260,7 @@ class _ExerciseControlPage extends State<ExerciseControlPage> with Trans {
|
||||
|
||||
Widget numberPickForm(ExerciseControlBloc exerciseBloc, int step) {
|
||||
final String strTimes = step == 2 ? exerciseBloc.origQuantity.toStringAsFixed(0) : "max.";
|
||||
//print("step $step, quantity ${exerciseBloc.origQuantity}");
|
||||
|
||||
String title = (step + 1).toString() + "/4 " + t("Control Exercise:");
|
||||
LinkedHashMap args = LinkedHashMap();
|
||||
@@ -301,8 +302,8 @@ class _ExerciseControlPage extends State<ExerciseControlPage> with Trans {
|
||||
TextSpan(text: t("hu_with") + " "),
|
||||
TextSpan(
|
||||
text: strTimes + " ",
|
||||
style: GoogleFonts.inter(
|
||||
fontSize: 16,
|
||||
style: GoogleFonts.archivoBlack(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.yellow[100],
|
||||
)),
|
||||
@@ -318,7 +319,7 @@ class _ExerciseControlPage extends State<ExerciseControlPage> with Trans {
|
||||
NumberPickerWidget(
|
||||
minValue: 0,
|
||||
maxValue: 200,
|
||||
initalValue: exerciseBloc.quantity.round(),
|
||||
initalValue: exerciseBloc.origQuantity.round(),
|
||||
unit: t("reps"),
|
||||
color: Colors.yellow[50]!,
|
||||
onChange: (value) => {exerciseBloc.add(ExerciseControlQuantityChange(quantity: value.toDouble(), step: step))}),
|
||||
@@ -372,10 +373,9 @@ class UnitQuantityControl extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _UnitQuantityControlState extends State<UnitQuantityControl> with Trans {
|
||||
late double changedValue;
|
||||
double? changedValue;
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
changedValue = widget.exerciseBloc.unitQuantity;
|
||||
setContext(context);
|
||||
return Dialog(
|
||||
shape: RoundedRectangleBorder(
|
||||
@@ -431,12 +431,21 @@ class _UnitQuantityControlState extends State<UnitQuantityControl> with Trans {
|
||||
initalValue: widget.exerciseBloc.unitQuantity.round(),
|
||||
unit: t("kg"),
|
||||
color: Colors.yellow[50]!,
|
||||
onChange: (value) => {changedValue = value}),
|
||||
onChange: (value) => {
|
||||
setState(() {
|
||||
changedValue = value;
|
||||
})
|
||||
}),
|
||||
Align(
|
||||
alignment: Alignment.center,
|
||||
child: GestureDetector(
|
||||
onTap: () => {
|
||||
widget.exerciseBloc.add(ExerciseControlUnitQuantityChange(quantity: changedValue.toDouble(), step: widget.step)),
|
||||
if (changedValue == null)
|
||||
{
|
||||
changedValue = widget.exerciseBloc.unitQuantity,
|
||||
},
|
||||
//print("Changed new value $changedValue"),
|
||||
widget.exerciseBloc.add(ExerciseControlUnitQuantityChange(quantity: changedValue!.toDouble(), step: widget.step)),
|
||||
Navigator.of(context).pop(),
|
||||
},
|
||||
child: Stack(
|
||||
|
||||
@@ -240,7 +240,9 @@ class _ExercisePlanDetailAddPage extends State<ExercisePlanDetailAddPage> with T
|
||||
initialValue: bloc.quantityUnit.toStringAsFixed(0),
|
||||
keyboardType: TextInputType.numberWithOptions(decimal: true),
|
||||
style: GoogleFonts.archivoBlack(fontSize: 60, color: Colors.yellow[200]),
|
||||
onChanged: (value) => {bloc.add(ExercisePlanCustomAddChangeQuantityUnit(quantity: double.parse(value)))})
|
||||
onChanged: (value) => {
|
||||
if (value.isNotEmpty) {bloc.add(ExercisePlanCustomAddChangeQuantityUnit(quantity: double.parse(value)))}
|
||||
})
|
||||
: Offstage(),
|
||||
|
||||
Divider(),
|
||||
|
||||
@@ -350,7 +350,9 @@ class _ExerciseTileState extends State<ExerciseTile> with Trans {
|
||||
animation.start();
|
||||
animation.addStatusListener((status) {
|
||||
if (status == AnimationStatus.completed) {
|
||||
setState(() {});
|
||||
setState(() {
|
||||
print("animation state completed");
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -151,7 +151,7 @@ class Search extends StatelessWidget with Trans {
|
||||
searchBoxDecoration: InputDecoration(
|
||||
contentPadding: EdgeInsets.only(left: 15, top: 5, bottom: 5),
|
||||
labelText: t("Search Exercises..."),
|
||||
labelStyle: GoogleFonts.inter(fontSize: 14, color: Colors.grey[400]),
|
||||
labelStyle: GoogleFonts.inter(fontSize: 12, color: Colors.grey[400]),
|
||||
fillColor: Colors.white24,
|
||||
filled: true,
|
||||
border: OutlineInputBorder(
|
||||
|
||||
@@ -30,6 +30,7 @@ class NumberPickerWidget extends StatefulWidget {
|
||||
|
||||
class _NumberPickerWidgetState extends State<NumberPickerWidget> with Trans {
|
||||
late FixedExtentScrollController _scrollController;
|
||||
double value = 0;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -38,13 +39,22 @@ class _NumberPickerWidgetState extends State<NumberPickerWidget> with Trans {
|
||||
_scrollController.animateToItem(widget.initalValue, duration: Duration(milliseconds: 100), curve: Curves.easeIn);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_scrollController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
void didUpdateWidget(NumberPickerWidget oldWidget) {
|
||||
//print("value $value initial ${widget.initalValue}");
|
||||
if (value == 0) {
|
||||
_scrollController.animateToItem(widget.initalValue, duration: Duration(milliseconds: 100), curve: Curves.easeIn);
|
||||
}
|
||||
super.didUpdateWidget(oldWidget);
|
||||
}
|
||||
|
||||
Widget durationPicker({bool inSeconds = false, bool inHundredths = false}) {
|
||||
double value = 0;
|
||||
return CupertinoPicker(
|
||||
scrollController: _scrollController,
|
||||
useMagnifier: true,
|
||||
@@ -54,9 +64,11 @@ class _NumberPickerWidgetState extends State<NumberPickerWidget> with Trans {
|
||||
selectionOverlay: Container(),
|
||||
onSelectedItemChanged: (x) {
|
||||
currentData = x.toDouble();
|
||||
value = x.toDouble();
|
||||
|
||||
//print("sec" + seconds.toStringAsFixed(2));
|
||||
setState(() {});
|
||||
setState(() {
|
||||
value = x.toDouble();
|
||||
});
|
||||
widget.onChange(value);
|
||||
},
|
||||
children: List.generate(
|
||||
@@ -69,6 +81,7 @@ class _NumberPickerWidgetState extends State<NumberPickerWidget> with Trans {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
setContext(context);
|
||||
value = 0;
|
||||
return Container(
|
||||
color: Colors.transparent,
|
||||
width: MediaQuery.of(context).size.width * .40,
|
||||
|
||||
Reference in New Issue
Block a user