WT 1.1.8+1 TrainingPlan
This commit is contained in:
@@ -90,7 +90,7 @@ class _NawDrawerWidget extends State<BottomNavigator> with Trans, Logging {
|
||||
case 2:
|
||||
Navigator.of(context).pop();
|
||||
Track().track(TrackingEvent.my_exerciseplan);
|
||||
Navigator.of(context).pushNamed('myExercisePlan');
|
||||
Navigator.of(context).pushNamed('myTrainingPlans');
|
||||
|
||||
break;
|
||||
case 3:
|
||||
|
||||
@@ -12,8 +12,8 @@ import 'dialog_html.dart';
|
||||
|
||||
// ignore: must_be_immutable
|
||||
class ExerciseSave extends StatefulWidget {
|
||||
final ValueChanged<dynamic> onQuantityChanged;
|
||||
final ValueChanged<dynamic>? onUnitQuantityChanged;
|
||||
final ValueChanged<double> onQuantityChanged;
|
||||
final ValueChanged<double>? onUnitQuantityChanged;
|
||||
final VoidCallback? onSubmit;
|
||||
final bool hasUnitQuantity;
|
||||
final String? unitQuantityUnit;
|
||||
@@ -22,18 +22,23 @@ class ExerciseSave extends StatefulWidget {
|
||||
final String exerciseDescription;
|
||||
final String exerciseTask;
|
||||
final int exerciseTypeId;
|
||||
final double? weight;
|
||||
final int? repeats;
|
||||
|
||||
ExerciseSave(
|
||||
{required this.onQuantityChanged,
|
||||
this.onUnitQuantityChanged,
|
||||
this.onSubmit,
|
||||
required this.hasUnitQuantity,
|
||||
this.unitQuantityUnit,
|
||||
required this.unit,
|
||||
required this.exerciseName,
|
||||
required this.exerciseDescription,
|
||||
required this.exerciseTask,
|
||||
required this.exerciseTypeId});
|
||||
ExerciseSave({
|
||||
required this.onQuantityChanged,
|
||||
this.onUnitQuantityChanged,
|
||||
this.onSubmit,
|
||||
required this.hasUnitQuantity,
|
||||
this.unitQuantityUnit,
|
||||
required this.unit,
|
||||
required this.exerciseName,
|
||||
required this.exerciseDescription,
|
||||
required this.exerciseTask,
|
||||
required this.exerciseTypeId,
|
||||
this.weight,
|
||||
this.repeats,
|
||||
});
|
||||
@override
|
||||
_ExerciseSaveState createState() => _ExerciseSaveState();
|
||||
}
|
||||
@@ -53,11 +58,15 @@ class _ExerciseSaveState extends State<ExerciseSave> with Trans {
|
||||
return getExerciseWidget();
|
||||
}
|
||||
|
||||
//@override
|
||||
@override
|
||||
initState() {
|
||||
super.initState();
|
||||
_controller1.text = "30";
|
||||
_controller2.text = "12";
|
||||
_controller1.text = widget.weight == null
|
||||
? "30"
|
||||
: widget.weight! % widget.weight!.round() == 0
|
||||
? widget.weight!.toStringAsFixed(0)
|
||||
: widget.weight!.toStringAsFixed(1);
|
||||
_controller2.text = widget.repeats == null ? "12" : widget.repeats!.toStringAsFixed(0);
|
||||
_nodeText1.addListener(() {
|
||||
if (_nodeText1.hasFocus) {
|
||||
_controller1.selection = TextSelection(baseOffset: 0, extentOffset: _controller1.text.length);
|
||||
@@ -69,7 +78,7 @@ class _ExerciseSaveState extends State<ExerciseSave> with Trans {
|
||||
}
|
||||
});
|
||||
if (widget.unit == "second") {
|
||||
stopWatchTimer.rawTime.listen((value) => widget.onQuantityChanged((value / 1000).toString()));
|
||||
stopWatchTimer.rawTime.listen((value) => widget.onQuantityChanged((value / 1000)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -190,6 +199,18 @@ class _ExerciseSaveState extends State<ExerciseSave> with Trans {
|
||||
fontSize: 14,
|
||||
color: Colors.orange,
|
||||
fontWeight: FontWeight.bold,
|
||||
shadows: <Shadow>[
|
||||
Shadow(
|
||||
offset: Offset(2.0, 2.0),
|
||||
blurRadius: 6.0,
|
||||
color: Colors.black54,
|
||||
),
|
||||
Shadow(
|
||||
offset: Offset(-3.0, 3.0),
|
||||
blurRadius: 12.0,
|
||||
color: Colors.black54,
|
||||
),
|
||||
],
|
||||
),
|
||||
maxLines: 3,
|
||||
textAlign: TextAlign.center,
|
||||
@@ -258,7 +279,7 @@ class _ExerciseSaveState extends State<ExerciseSave> with Trans {
|
||||
onChanged: (value) => {
|
||||
value = value.replaceFirst(",", "."),
|
||||
value = value.replaceAll(RegExp(r'[^0-9.]'), ""),
|
||||
widget.onUnitQuantityChanged!(value),
|
||||
widget.onUnitQuantityChanged!(double.parse(value)),
|
||||
}),
|
||||
]));
|
||||
}
|
||||
@@ -273,7 +294,7 @@ class _ExerciseSaveState extends State<ExerciseSave> with Trans {
|
||||
//padding: const EdgeInsets.only(bottom: 0),
|
||||
child: StreamBuilder<int>(
|
||||
stream: stopWatchTimer.rawTime,
|
||||
initialData: stopWatchTimer.rawTime.valueWrapper?.value,
|
||||
initialData: stopWatchTimer.rawTime.value,
|
||||
builder: (context, snap) {
|
||||
final value = snap.data;
|
||||
final displayTime = StopWatchTimer.getDisplayTime(value!, hours: false);
|
||||
@@ -344,7 +365,7 @@ class _ExerciseSaveState extends State<ExerciseSave> with Trans {
|
||||
Divider(),
|
||||
Divider(),
|
||||
Text(t("Or type the time manually:"), style: GoogleFonts.inter(color: Colors.white)),
|
||||
TimePickerWidget(onChange: (value) => widget.onQuantityChanged((value).toString()))
|
||||
TimePickerWidget(onChange: (value) => widget.onQuantityChanged((value)))
|
||||
]);
|
||||
}
|
||||
Widget row = Container(
|
||||
@@ -369,7 +390,9 @@ class _ExerciseSaveState extends State<ExerciseSave> with Trans {
|
||||
textInputAction: TextInputAction.next,
|
||||
style: GoogleFonts.archivoBlack(fontSize: 80, color: Colors.orange[200]),
|
||||
onChanged: (value) {
|
||||
widget.onQuantityChanged(value);
|
||||
value = value.replaceFirst(",", ".");
|
||||
value = value.replaceAll(RegExp(r'[^0-9.]'), "");
|
||||
widget.onQuantityChanged(double.parse(value));
|
||||
},
|
||||
),
|
||||
]));
|
||||
|
||||
@@ -22,6 +22,7 @@ class ImageButton extends StatelessWidget {
|
||||
final bool? isLocked;
|
||||
bool? isMarked;
|
||||
int? buttonIndex;
|
||||
Color? textColor;
|
||||
|
||||
ImageButton(
|
||||
{required this.text,
|
||||
@@ -37,11 +38,13 @@ class ImageButton extends StatelessWidget {
|
||||
this.onTap,
|
||||
this.buttonIndex,
|
||||
this.isMarked,
|
||||
required this.isLocked}) {
|
||||
required this.isLocked,
|
||||
this.textColor}) {
|
||||
width = width ?? 180;
|
||||
height = height ?? 180;
|
||||
isMarked = isMarked ?? false;
|
||||
isShape = isShape ?? false;
|
||||
textColor = textColor ?? Colors.white;
|
||||
style = style ??
|
||||
GoogleFonts.archivoBlack(
|
||||
fontSize: 14,
|
||||
@@ -54,10 +57,9 @@ class ImageButton extends StatelessWidget {
|
||||
top = height! - (style!.fontSize! - 5) * text.length - 2 * left < 0
|
||||
? height! - 2 * style!.fontSize! - 22
|
||||
: height! - style!.fontSize! - 37;
|
||||
//print("Top: " + top.toStringAsFixed(0) + " length: " + ((style.fontSize - 5) * text.length).toString());
|
||||
}
|
||||
final double width = MediaQuery.of(context).size.width;
|
||||
//print("Mediawidth: " + width.toStringAsFixed(0));
|
||||
|
||||
return Stack(alignment: AlignmentDirectional.bottomStart, children: [
|
||||
TextButton(
|
||||
style: TextButton.styleFrom(
|
||||
@@ -93,7 +95,7 @@ class ImageButton extends StatelessWidget {
|
||||
maxLines: 2,
|
||||
style: GoogleFonts.archivoBlack(
|
||||
fontSize: 16,
|
||||
color: Colors.white,
|
||||
color: textColor,
|
||||
shadows: <Shadow>[
|
||||
Shadow(
|
||||
offset: Offset(2.0, 2.0),
|
||||
|
||||
@@ -7,7 +7,12 @@ import 'package:aitrainer_app/library/transparent_image.dart';
|
||||
class MenuImage extends StatelessWidget {
|
||||
final int? workoutTreeId;
|
||||
final String imageName;
|
||||
const MenuImage({required this.workoutTreeId, required this.imageName});
|
||||
double radius;
|
||||
MenuImage({
|
||||
required this.workoutTreeId,
|
||||
required this.imageName,
|
||||
this.radius = 24,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -31,7 +36,7 @@ class MenuImage extends StatelessWidget {
|
||||
if (imageName.contains("https")) {
|
||||
if (!wt.ImageCache().existsImageInMap(workoutTreeId!, imageName)) {
|
||||
widget = ClipRRect(
|
||||
borderRadius: BorderRadius.circular(24.0),
|
||||
borderRadius: BorderRadius.circular(radius),
|
||||
child: Container(
|
||||
color: Colors.transparent,
|
||||
child: FadeInImage(
|
||||
@@ -43,7 +48,7 @@ class MenuImage extends StatelessWidget {
|
||||
}
|
||||
} else {
|
||||
widget = ClipRRect(
|
||||
borderRadius: BorderRadius.circular(24.0),
|
||||
borderRadius: BorderRadius.circular(radius),
|
||||
child: Container(
|
||||
color: Colors.transparent,
|
||||
child: Image.asset(imageName),
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'dart:collection';
|
||||
import 'dart:ui';
|
||||
import 'package:aitrainer_app/bloc/training_plan/training_plan_bloc.dart';
|
||||
import 'package:aitrainer_app/bloc/tutorial/tutorial_bloc.dart';
|
||||
import 'package:aitrainer_app/model/exercise_ability.dart';
|
||||
import 'package:aitrainer_app/bloc/menu/menu_bloc.dart';
|
||||
@@ -47,7 +48,7 @@ class _MenuPageWidgetState extends State<MenuPageWidget> with Trans, Logging {
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
if (activeExercisePlan) {
|
||||
if (activeExercisePlan || Cache().myTrainingPlan != null) {
|
||||
animation.start();
|
||||
animation.addStatusListener((status) {
|
||||
if (status == AnimationStatus.completed || status == AnimationStatus.dismissed) {
|
||||
@@ -313,6 +314,46 @@ class _MenuPageWidgetState extends State<MenuPageWidget> with Trans, Logging {
|
||||
}
|
||||
},
|
||||
),
|
||||
Cache().myTrainingPlan != null
|
||||
? GestureDetector(
|
||||
onTap: () => showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return DialogCommon(
|
||||
title: t("You have an active Training Plan"),
|
||||
descriptions: Cache().myTrainingPlan!.name != null ? Cache().myTrainingPlan!.name! : "",
|
||||
description2: t("Press OK to continue"),
|
||||
text: "OK",
|
||||
onTap: () {
|
||||
Navigator.of(context).pop();
|
||||
if (Cache().myTrainingPlan != null) {
|
||||
final TrainingPlanBloc bloc = BlocProvider.of<TrainingPlanBloc>(context);
|
||||
bloc.myPlan = Cache().myTrainingPlan;
|
||||
Navigator.of(context).pushNamed("myTrainingPlanExecute");
|
||||
}
|
||||
},
|
||||
onCancel: () => {
|
||||
Navigator.of(context).pop(),
|
||||
},
|
||||
);
|
||||
}),
|
||||
child: AnimatedBuilder(
|
||||
animation: animation,
|
||||
builder: (context, snapshot) {
|
||||
return Center(
|
||||
child: Container(
|
||||
width: animation.value,
|
||||
height: animation.value,
|
||||
child: Image.asset("asset/image/pict_hypertrophy.png"),
|
||||
),
|
||||
);
|
||||
}))
|
||||
: Offstage(),
|
||||
activeExercisePlan
|
||||
? SizedBox(
|
||||
width: 10,
|
||||
)
|
||||
: Offstage(),
|
||||
Cache().activeExercisePlan != null
|
||||
? GestureDetector(
|
||||
onTap: () => showDialog(
|
||||
|
||||
Reference in New Issue
Block a user