WT1.1.23 fix changes
This commit is contained in:
@@ -16,6 +16,24 @@ import 'package:stop_watch_timer/stop_watch_timer.dart';
|
||||
import 'package:wakelock/wakelock.dart';
|
||||
import 'dialog_html.dart';
|
||||
|
||||
class ExerciseSaveStream {
|
||||
static final ExerciseSaveStream _singleton = ExerciseSaveStream._internal();
|
||||
final StreamController<bool> streamController = StreamController<bool>.broadcast();
|
||||
int repeats = 0;
|
||||
double weight = 0;
|
||||
|
||||
Stream get stream => streamController.stream;
|
||||
StreamController getStreamController() => streamController;
|
||||
|
||||
factory ExerciseSaveStream() => _singleton;
|
||||
|
||||
ExerciseSaveStream._internal();
|
||||
|
||||
void dispose() {
|
||||
streamController.close();
|
||||
}
|
||||
}
|
||||
|
||||
enum Explanations { intro, introBold, explanationWeight, explanationRepeats, explanationButton, explanationButtonExt }
|
||||
|
||||
extension ExplanationsExt on Explanations {
|
||||
@@ -112,6 +130,8 @@ class ExplanationExt {
|
||||
class ExerciseSave extends StatefulWidget {
|
||||
final ValueChanged<double> onQuantityChanged;
|
||||
final ValueChanged<double>? onUnitQuantityChanged;
|
||||
final VoidCallback? onUnitQuantityChangeUp;
|
||||
final VoidCallback? onUnitQuantityChangeDown;
|
||||
final VoidCallback? onSubmit;
|
||||
final bool hasUnitQuantity;
|
||||
final String? unitQuantityUnit;
|
||||
@@ -131,6 +151,8 @@ class ExerciseSave extends StatefulWidget {
|
||||
ExerciseSave(
|
||||
{required this.onQuantityChanged,
|
||||
this.onUnitQuantityChanged,
|
||||
this.onUnitQuantityChangeUp,
|
||||
this.onUnitQuantityChangeDown,
|
||||
this.onSubmit,
|
||||
required this.hasUnitQuantity,
|
||||
this.unitQuantityUnit,
|
||||
@@ -158,6 +180,9 @@ class _ExerciseSaveState extends State<ExerciseSave> with Trans {
|
||||
final StopWatchTimer stopWatchTimer = StopWatchTimer(
|
||||
isLapHours: false,
|
||||
);
|
||||
final Stream stream = ExerciseSaveStream().stream;
|
||||
late StreamSubscription<dynamic> subscription;
|
||||
bool changable = false;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -188,16 +213,24 @@ class _ExerciseSaveState extends State<ExerciseSave> with Trans {
|
||||
}
|
||||
|
||||
SchedulerBinding.instance!.addPostFrameCallback((_) {
|
||||
subscription = stream.listen((event) {
|
||||
_controller1.text = ExerciseSaveStream().weight.toStringAsFixed(0);
|
||||
_controller2.text = ExerciseSaveStream().repeats.toStringAsFixed(0);
|
||||
});
|
||||
print("ExerciseSave weight ${widget.weight}");
|
||||
_controller1.text = widget.weight == null || widget.weight == -1
|
||||
? "--"
|
||||
? "TEST"
|
||||
: widget.weight! % widget.weight!.round() == 0
|
||||
? widget.weight!.toStringAsFixed(0)
|
||||
: widget.weight!.toStringAsFixed(1);
|
||||
_controller2.text = widget.repeats == null
|
||||
? "--"
|
||||
? "TEST"
|
||||
: widget.repeats! == 99
|
||||
? "MAX"
|
||||
: widget.repeats!.toStringAsFixed(0);
|
||||
: widget.weight == -1 || widget.weight == -2
|
||||
? "TEST"
|
||||
: widget.repeats!.toStringAsFixed(0);
|
||||
changable = (_controller2.text != "TEST" && _controller1.text != "TEST");
|
||||
if (widget.unitQuantityUnit != null && widget.tip != null && Cache().isActivityDone(widget.tip!) == false) {
|
||||
Timer(
|
||||
Duration(milliseconds: 2000),
|
||||
@@ -220,9 +253,16 @@ class _ExerciseSaveState extends State<ExerciseSave> with Trans {
|
||||
dispose() {
|
||||
_controller1.dispose();
|
||||
stopWatchTimer.dispose();
|
||||
|
||||
subscription.cancel();
|
||||
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
void isChangable() {
|
||||
changable = !(widget.weight == -1 || widget.weight == -2 || widget.weight == null);
|
||||
}
|
||||
|
||||
KeyboardActionsConfig _buildConfig(BuildContext context) {
|
||||
return KeyboardActionsConfig(
|
||||
keyboardActionsPlatform: KeyboardActionsPlatform.ALL,
|
||||
@@ -507,36 +547,54 @@ class _ExerciseSaveState extends State<ExerciseSave> with Trans {
|
||||
}
|
||||
|
||||
Widget columnQuantityUnit() {
|
||||
//changable = (_controller2.text != "TEST" && _controller1.text != "TEST");
|
||||
isChangable();
|
||||
changable = false;
|
||||
//print("PlusMinus: $changable - con2: ${_controller2.text} con1: ${_controller1.text}");
|
||||
Widget row = Padding(padding: const EdgeInsets.only(top: 10, left: 55, right: 55), child: Column());
|
||||
if (widget.hasUnitQuantity) {
|
||||
row = Padding(
|
||||
padding: const EdgeInsets.only(top: 10, left: 55, right: 55),
|
||||
child: Column(mainAxisAlignment: MainAxisAlignment.spaceAround, children: [
|
||||
TextFormField(
|
||||
focusNode: _nodeText1,
|
||||
controller: _controller1,
|
||||
decoration: InputDecoration(
|
||||
contentPadding: EdgeInsets.only(left: 25, top: 5, bottom: 5),
|
||||
labelText: t(widget.unitQuantityUnit!),
|
||||
labelStyle: GoogleFonts.inter(fontSize: 20, color: Colors.yellow[50]),
|
||||
fillColor: Colors.black38,
|
||||
filled: true,
|
||||
border: OutlineInputBorder(
|
||||
gapPadding: 8.0,
|
||||
borderRadius: BorderRadius.circular(12.0),
|
||||
borderSide: BorderSide(color: Colors.white12, width: 0.4),
|
||||
),
|
||||
),
|
||||
keyboardType: TextInputType.numberWithOptions(decimal: true),
|
||||
textInputAction: TextInputAction.done,
|
||||
style: GoogleFonts.archivoBlack(fontSize: 80, color: Colors.yellow[300]),
|
||||
onChanged: (value) {
|
||||
if (value.isNotEmpty) {
|
||||
value = value.replaceFirst(",", ".");
|
||||
value = value.replaceAll(RegExp(r'[^0-9.]'), "");
|
||||
widget.onUnitQuantityChanged!(double.parse(value));
|
||||
}
|
||||
}),
|
||||
child: Row(mainAxisAlignment: MainAxisAlignment.spaceAround, children: [
|
||||
Flexible(
|
||||
child: TextFormField(
|
||||
focusNode: _nodeText1,
|
||||
controller: _controller1,
|
||||
maxLength: 5,
|
||||
decoration: InputDecoration(
|
||||
contentPadding: EdgeInsets.only(left: 25, top: 5, bottom: 5),
|
||||
labelText: t(widget.unitQuantityUnit!),
|
||||
labelStyle: GoogleFonts.inter(fontSize: 20, color: Colors.yellow[50]),
|
||||
fillColor: Colors.black38,
|
||||
filled: true,
|
||||
border: OutlineInputBorder(
|
||||
gapPadding: 8.0,
|
||||
borderRadius: BorderRadius.circular(12.0),
|
||||
borderSide: BorderSide(color: Colors.white12, width: 0.4),
|
||||
),
|
||||
),
|
||||
keyboardType: TextInputType.numberWithOptions(decimal: true),
|
||||
textInputAction: TextInputAction.done,
|
||||
style: GoogleFonts.archivoBlack(fontSize: 75, color: Colors.yellow[300]),
|
||||
onChanged: (value) {
|
||||
if (value.isNotEmpty) {
|
||||
value = value.replaceFirst(",", ".");
|
||||
value = value.replaceAll(RegExp(r'[^0-9.]'), "");
|
||||
widget.onUnitQuantityChanged!(double.parse(value));
|
||||
}
|
||||
})),
|
||||
changable
|
||||
? Column(children: [
|
||||
IconButton(
|
||||
onPressed: () => widget.onUnitQuantityChangeUp!(),
|
||||
icon: Icon(CustomIcon.plus_circle, color: Colors.orange, size: 20),
|
||||
),
|
||||
IconButton(
|
||||
onPressed: () => widget.onUnitQuantityChangeDown!(),
|
||||
icon: Icon(CustomIcon.minus_circle, color: Colors.orange, size: 20),
|
||||
),
|
||||
])
|
||||
: Offstage()
|
||||
]));
|
||||
}
|
||||
return row;
|
||||
@@ -646,7 +704,7 @@ class _ExerciseSaveState extends State<ExerciseSave> with Trans {
|
||||
),
|
||||
keyboardType: TextInputType.number,
|
||||
textInputAction: TextInputAction.next,
|
||||
style: GoogleFonts.archivoBlack(fontSize: 80, color: Colors.orange[200]),
|
||||
style: GoogleFonts.archivoBlack(fontSize: 75, color: Colors.orange[200]),
|
||||
onChanged: (value) {
|
||||
if (value.isNotEmpty) {
|
||||
value = value.replaceFirst(",", ".");
|
||||
|
||||
Reference in New Issue
Block a user