1.1.22+3 corrections

This commit is contained in:
bossanyit
2021-09-05 07:47:15 +02:00
parent cebd83648b
commit e34add8185
57 changed files with 1577 additions and 1490 deletions
+1 -2
View File
@@ -286,7 +286,7 @@ class _BMRState extends State<BMR> with Trans {
),
),
mode: Mode.MENU,
compareFn: (FitnessState i, FitnessState s) => i.isEqual(s),
compareFn: (FitnessState? i, FitnessState? s) => i!.isEqual(s),
showSelectedItem: true,
selectedItem: FitnessItem().getItem(fitnessLevel),
itemAsString: (data) => t(data!.stateText),
@@ -301,7 +301,6 @@ class _BMRState extends State<BMR> with Trans {
color: Colors.yellow[200],
),
));
//items: FitnessItem().toList()));
}
Widget _customMenuBuilder(BuildContext context, FitnessState? item, bool isSelected) {
+3 -7
View File
@@ -88,7 +88,7 @@ class _DialogPremiumState extends State<DialogPremium> with Trans {
alignment: AlignmentDirectional.topEnd,
children: [
Text(
widget.unlocked ? t("Keep testing") : t("Go Premium") + " ",
widget.unlocked ? t("Keep training") : t("Go Premium") + " ",
style: GoogleFonts.archivoBlack(
fontSize: widget.unlocked ? 20 : 24,
color: Colors.yellow[400],
@@ -257,11 +257,7 @@ class _DialogPremiumState extends State<DialogPremium> with Trans {
list.add(TextSpan(text: t(" ")));
list.add(
TextSpan(
text: widget.unlockRound == 1
? t("the first")
: widget.unlockRound == 2
? t("the second")
: t("the third"),
text: widget.unlockRound.toString() + " " + t("week"),
style: GoogleFonts.inter(
fontSize: 14,
fontWeight: FontWeight.bold,
@@ -282,7 +278,7 @@ class _DialogPremiumState extends State<DialogPremium> with Trans {
),
);
list.add(TextSpan(text: t(" ")));
list.add(TextSpan(text: t("100% test circles")));
list.add(TextSpan(text: t("100% completed training")));
return list;
}
+2 -2
View File
@@ -120,7 +120,7 @@ class _DialogTrialWidgetState extends State<DialogTrialWidget> with Trans {
children: [
Image.asset('asset/icon/gomb_lila_b.png', width: 100, height: 45),
Text(
t("Nem"),
t("No"),
style: TextStyle(fontSize: 16, color: Colors.white),
),
],
@@ -132,7 +132,7 @@ class _DialogTrialWidgetState extends State<DialogTrialWidget> with Trans {
children: [
Image.asset('asset/icon/gomb_orange_c.png', width: 100, height: 45),
Text(
t("Igen"),
t("Yes"),
style: TextStyle(fontSize: 16, color: Colors.white),
),
],
+461 -112
View File
@@ -1,21 +1,113 @@
import 'dart:async';
import 'package:aitrainer_app/bloc/tutorial/tutorial_bloc.dart';
import 'package:aitrainer_app/library/custom_icon_icons.dart';
import 'package:aitrainer_app/model/cache.dart';
import 'package:aitrainer_app/util/trans.dart';
import 'package:aitrainer_app/widgets/menu_image.dart';
import 'package:aitrainer_app/widgets/time_picker.dart';
import 'package:aitrainer_app/widgets/tutorial_widget.dart';
import 'package:badges/badges.dart';
import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:keyboard_actions/keyboard_actions.dart';
import 'package:keyboard_actions/keyboard_actions_config.dart';
import 'package:stop_watch_timer/stop_watch_timer.dart';
import 'package:wakelock/wakelock.dart';
import 'dialog_common.dart';
import 'dialog_html.dart';
enum Explanations { intro, introBold, explanationWeight, explanationRepeats, explanationButton, explanationButtonExt }
extension ExplanationsExt on Explanations {
String toStr() => this.toString().split(".").last;
bool equalsTo(Explanations type) => this.toString() == type.toString();
bool equalsStringTo(String type) => this.toStr() == type;
}
class ExplanationExt {
final ActivityDone tip;
final String? unitQuantityUnit;
final double? weight;
final int? repeats;
ExplanationExt({
required this.tip,
this.unitQuantityUnit,
required this.weight,
required this.repeats,
});
String getExplanation(Explanations explanation) {
String expl = "";
if (this.tip.equalsTo(ActivityDone.exerciseSaveTestTip)) {
if (explanation.equalsTo(Explanations.intro)) {
expl = "Please take a middle weight which you are able to do 8-20 times with.";
} else if (explanation.equalsTo(Explanations.introBold)) {
expl = "Execute your MAXIMUM repeats with it!";
} else if (explanation.equalsTo(Explanations.explanationWeight)) {
expl = "Type here your selected weight,";
} else if (explanation.equalsTo(Explanations.explanationRepeats)) {
expl = "then here, how many times could you repeat it!";
} else if (explanation.equalsTo(Explanations.explanationButton)) {
expl = "After you done, click to the OK button!";
} else if (explanation.equalsTo(Explanations.explanationButtonExt)) {
expl = "";
}
} else if (this.tip.equalsTo(ActivityDone.exerciseSaveTrainingTip)) {
if (unitQuantityUnit != null) {
if (weight == -1) {
if (explanation.equalsTo(Explanations.intro)) {
expl = "Please take a middle weight which you are able to do 8-20 times with.";
} else if (explanation.equalsTo(Explanations.introBold)) {
expl = "Execute your MAXIMUM repeats with it!";
}
} else if (repeats == 99) {
if (explanation.equalsTo(Explanations.intro)) {
expl = "It is time to exhaust your muscles";
}
} else {
if (explanation.equalsTo(Explanations.intro)) {
expl = "For your optimal development we calculated a suitable weight and repeats";
} else if (explanation.equalsTo(Explanations.introBold)) {
expl = "You can change the weight, if you could not set it in the training room";
}
}
if (explanation.equalsTo(Explanations.explanationButtonExt)) {
if (repeats != 99) {
expl = "If you could do less, then modify and click to OK";
}
} else if (explanation.equalsTo(Explanations.explanationWeight)) {
if (weight == -1 || weight == -2) {
expl = "Type here your selected weight,";
} else {
expl = "Here is your tailored weight,";
}
} else if (explanation.equalsTo(Explanations.explanationRepeats)) {
if (repeats == 99) {
expl = "and execute it with maximum repeats!";
} else {
expl = "and executed with this number of repeats!";
}
}
} else {
if (repeats == 99) {
if (explanation.equalsTo(Explanations.intro)) {
expl = "Please repeat as much times as you can! MAXIMIZE it!";
}
} else {
if (explanation.equalsTo(Explanations.intro)) {
expl = "Please try to execute this exercise with exact repeats what is suggested";
}
}
}
if (explanation.equalsTo(Explanations.explanationButton)) {
expl = "After you done, click to the OK button!";
}
} else if (this.tip.equalsTo(ActivityDone.exerciseSaveTestsetTip)) {}
return expl;
}
}
// ignore: must_be_immutable
class ExerciseSave extends StatefulWidget {
final ValueChanged<double> onQuantityChanged;
@@ -33,6 +125,8 @@ class ExerciseSave extends StatefulWidget {
final int? set;
final int? exerciseNr;
final int? originalQuantity;
final MenuImage menuImage;
final ActivityDone? tip;
ExerciseSave(
{required this.onQuantityChanged,
@@ -49,7 +143,9 @@ class ExerciseSave extends StatefulWidget {
this.repeats,
this.set,
this.exerciseNr,
this.originalQuantity});
this.originalQuantity,
required this.menuImage,
this.tip});
@override
_ExerciseSaveState createState() => _ExerciseSaveState();
}
@@ -72,12 +168,6 @@ class _ExerciseSaveState extends State<ExerciseSave> with Trans {
@override
initState() {
super.initState();
_controller1.text = widget.weight == null
? "0"
: 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);
@@ -98,25 +188,31 @@ class _ExerciseSaveState extends State<ExerciseSave> with Trans {
}
SchedulerBinding.instance!.addPostFrameCallback((_) {
/* //final TutorialBloc bloc = BlocProvider.of<TutorialBloc>(context);
if (bloc.actualCheck == "directTest") {
_controller1.text = widget.weight == null || widget.weight == -1
? "--"
: widget.weight! % widget.weight!.round() == 0
? widget.weight!.toStringAsFixed(0)
: widget.weight!.toStringAsFixed(1);
_controller2.text = widget.repeats == null
? "--"
: widget.repeats! == 99
? "MAX"
: widget.repeats!.toStringAsFixed(0);
if (widget.unitQuantityUnit != null && widget.tip != null && Cache().isActivityDone(widget.tip!) == false) {
Timer(
Duration(milliseconds: 2000),
() => {
showDialog(
context: context,
barrierDismissible: false,
builder: (BuildContext context) {
return DialogCommon(
title: t("Attention"),
descriptions: t(widget.exerciseTask),
text: "OK",
onTap: () => Navigator.of(context).pop(),
onCancel: () => Navigator.of(context).pop(),
);
})
TutorialWidget().explanation(
context,
ExplanationWidget(
unitQuantityUnit: widget.unitQuantityUnit,
unit: widget.unit,
tip: widget.tip,
weight: widget.weight,
repeats: widget.repeats,
)),
});
} */
}
});
}
@@ -189,82 +285,139 @@ class _ExerciseSaveState extends State<ExerciseSave> with Trans {
}
Widget getExerciseWidget() {
ExplanationExt expl = ExplanationExt(
tip: widget.tip!,
weight: widget.weight,
repeats: widget.repeats,
unitQuantityUnit: widget.unitQuantityUnit,
);
return KeyboardActions(
config: _buildConfig(context),
child: Container(
child: SingleChildScrollView(
scrollDirection: Axis.vertical,
child: Column(mainAxisAlignment: MainAxisAlignment.spaceEvenly, crossAxisAlignment: CrossAxisAlignment.center, children: <Widget>[
Text(
widget.exerciseName,
style: GoogleFonts.archivoBlack(
fontWeight: FontWeight.bold,
fontSize: 24,
color: Colors.white,
shadows: <Shadow>[
Shadow(
offset: Offset(5.0, 5.0),
blurRadius: 12.0,
color: Colors.black54,
),
Shadow(
offset: Offset(-3.0, 3.0),
blurRadius: 12.0,
color: Colors.black54,
),
],
Stack(alignment: Alignment.bottomLeft, children: [
Badge(
elevation: 0,
padding: EdgeInsets.all(0),
position: BadgePosition.topEnd(top: 5, end: 5),
animationDuration: Duration(milliseconds: 1500),
animationType: BadgeAnimationType.fade,
badgeColor: Colors.transparent,
showBadge: true,
badgeContent: IconButton(
iconSize: 30,
onPressed: () => showDialog(
context: context,
builder: (BuildContext context) {
return DialogHTML(title: widget.exerciseName, htmlData: '<p>' + widget.exerciseDescription + '</p>');
}),
icon: Icon(
CustomIcon.info_circle,
color: Colors.white,
)),
child: widget.menuImage,
),
overflow: TextOverflow.fade,
maxLines: 4,
softWrap: true,
textAlign: TextAlign.center,
),
SizedBox(
height: 15,
),
InkWell(
child: Text(
t("Exercise descripton") + " »",
style: GoogleFonts.inter(fontSize: 12, color: Colors.blue[200]),
Container(
padding: EdgeInsets.only(left: 10, bottom: 10, right: 10),
child: Text(
widget.exerciseName,
style: GoogleFonts.archivoBlack(
fontWeight: FontWeight.bold,
fontSize: 24,
color: Colors.white,
shadows: <Shadow>[
Shadow(
offset: Offset(5.0, 5.0),
blurRadius: 12.0,
color: Colors.black54,
),
Shadow(
offset: Offset(-3.0, 3.0),
blurRadius: 12.0,
color: Colors.black54,
),
],
),
overflow: TextOverflow.fade,
maxLines: 4,
softWrap: true,
))
]),
ListTile(
leading: IconButton(
iconSize: 30,
onPressed: () => {
if (widget.unitQuantityUnit != null)
{
TutorialWidget().explanation(
context,
ExplanationWidget(
unitQuantityUnit: widget.unitQuantityUnit,
unit: widget.unit,
tip: widget.tip,
weight: widget.weight,
repeats: widget.repeats,
))
}
},
icon: Icon(
CustomIcon.info_circle,
color: Colors.orange[100],
)),
subtitle: Text(
t(expl.getExplanation(Explanations.intro)),
style: GoogleFonts.inter(
fontSize: 14,
color: Colors.white,
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.left,
overflow: TextOverflow.fade,
softWrap: true,
),
onTap: () => {
showDialog(
context: context,
builder: (BuildContext context) {
return DialogHTML(title: widget.exerciseName, htmlData: '<p>' + widget.exerciseDescription + '</p>');
})
},
),
Divider(
color: Colors.transparent,
),
Text(
t(widget.exerciseTask),
style: GoogleFonts.inter(
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,
overflow: TextOverflow.fade,
softWrap: true,
),
Divider(
color: Colors.transparent,
),
expl.getExplanation(Explanations.introBold).length > 0
? Text(
t(expl.getExplanation(Explanations.introBold)),
style: GoogleFonts.inter(
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,
overflow: TextOverflow.fade,
softWrap: true,
)
: Offstage(),
widget.unit == "second"
? Text(
getTimeGoal(widget.originalQuantity),
@@ -289,29 +442,60 @@ class _ExerciseSaveState extends State<ExerciseSave> with Trans {
)
: Offstage(),
columnQuantityUnit(),
Divider(
color: Colors.transparent,
),
columnQuantity(),
Divider(
color: Colors.transparent,
),
widget.hasUnitQuantity
? Text(
widget.set == null || widget.exerciseNr == null
? t("Step") + ": " + "1/4"
: t("Step") + ": " + "${widget.exerciseNr}/${widget.set}",
style: GoogleFonts.inter(
fontSize: 22,
color: Colors.white,
fontWeight: FontWeight.bold,
),
maxLines: 3,
textAlign: TextAlign.center,
overflow: TextOverflow.fade,
softWrap: true,
)
: Offstage(),
Text(
t(expl.getExplanation(Explanations.explanationButton)),
style: GoogleFonts.inter(
fontSize: 14,
color: Colors.white,
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,
overflow: TextOverflow.fade,
softWrap: true,
),
Padding(
padding: const EdgeInsets.only(left: 35, right: 35),
child: Text(
t(expl.getExplanation(Explanations.explanationButtonExt)),
style: GoogleFonts.inter(
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,
overflow: TextOverflow.fade,
softWrap: true,
)),
Divider(
color: Colors.transparent,
),
@@ -476,3 +660,168 @@ class _ExerciseSaveState extends State<ExerciseSave> with Trans {
return row;
}
}
class ExplanationWidget extends StatefulWidget {
final String? unitQuantityUnit;
final String unit;
final ActivityDone? tip;
final double? weight;
final int? repeats;
const ExplanationWidget({
Key? key,
this.unitQuantityUnit,
required this.unit,
this.tip,
this.weight,
this.repeats,
}) : super(key: key);
@override
_ExplanationWidgetState createState() => _ExplanationWidgetState();
}
class _ExplanationWidgetState extends State<ExplanationWidget> with Trans {
bool _selected = false;
@override
Widget build(BuildContext context) {
ExplanationExt expl = ExplanationExt(
tip: widget.tip!,
weight: widget.weight,
repeats: widget.repeats,
unitQuantityUnit: widget.unitQuantityUnit,
);
setContext(context);
return Material(
color: Colors.transparent,
child: Column(
children: [
Padding(
padding: const EdgeInsets.only(top: 10, left: 10, right: 10),
child: Text(t(expl.getExplanation(Explanations.intro)),
maxLines: 5,
textAlign: TextAlign.center,
style: GoogleFonts.inter(
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: 16,
))),
Padding(
padding: const EdgeInsets.only(top: 10, left: 10, right: 10),
child: Text(t(expl.getExplanation(Explanations.introBold)),
maxLines: 5,
textAlign: TextAlign.center,
style: GoogleFonts.inter(
color: Colors.orange,
fontWeight: FontWeight.bold,
fontSize: 16,
))),
Stack(children: [
Padding(
padding: const EdgeInsets.only(top: 13, left: 18, right: 18),
child: Column(mainAxisAlignment: MainAxisAlignment.spaceAround, children: [
TextFormField(
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),
),
),
initialValue: ".",
keyboardType: TextInputType.numberWithOptions(decimal: true),
textInputAction: TextInputAction.done,
style: GoogleFonts.archivoBlack(fontSize: 80, color: Colors.transparent),
onChanged: (value) {}),
])),
Container(
padding: EdgeInsets.only(top: 35, left: 35, right: 35),
child: Text(
t(expl.getExplanation(Explanations.explanationWeight)),
style: GoogleFonts.archivoBlack(fontSize: 23, color: Colors.yellow[300]),
)),
]),
Stack(children: [
Padding(
padding: const EdgeInsets.only(top: 10, left: 15, right: 15),
child: Column(mainAxisAlignment: MainAxisAlignment.spaceAround, children: [
TextFormField(
decoration: InputDecoration(
contentPadding: EdgeInsets.only(left: 25, top: 5, bottom: 5),
labelText: t(widget.unit),
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),
),
),
initialValue: ".",
keyboardType: TextInputType.numberWithOptions(decimal: true),
textInputAction: TextInputAction.done,
style: GoogleFonts.archivoBlack(fontSize: 80, color: Colors.transparent),
onChanged: (value) {}),
])),
Container(
padding: EdgeInsets.only(top: 25, left: 35, right: 35),
child: Text(
t(expl.getExplanation(Explanations.explanationRepeats)),
style: GoogleFonts.archivoBlack(fontSize: 23, color: Colors.yellow[300]),
)),
]),
Padding(
padding: const EdgeInsets.only(top: 10, left: 5, right: 5),
child: Text(
t("Don't forget, the app can give you only the right values, if you execute the task regurarly and after the exact instructions."),
maxLines: 5,
textAlign: TextAlign.center,
style: GoogleFonts.inter(
color: Colors.white,
fontSize: 14,
))),
Divider(),
GestureDetector(
onTap: () => {
TutorialWidget().close(),
if (_selected && widget.tip != null)
{
Cache().setActivityDonePrefs(widget.tip!),
}
},
child: Stack(
alignment: Alignment.center,
children: [
Image.asset('asset/icon/gomb_orange_c.png', width: 100, height: 45),
Text(
t("Got It"),
style: TextStyle(fontSize: 20, color: Colors.white),
),
],
)),
Theme(
data: ThemeData(unselectedWidgetColor: Colors.white38),
child: CheckboxListTile(
value: _selected,
onChanged: (bool? checked) {
setState(() {
_selected = checked!;
});
},
checkColor: Colors.white,
activeColor: Colors.orange[600],
controlAffinity: ListTileControlAffinity.leading,
title: Text(
t("Show this tip no more"),
style: GoogleFonts.inter(color: Colors.grey),
)))
],
));
}
}
+4 -4
View File
@@ -83,16 +83,16 @@ class _MenuPageWidgetState extends State<MenuPageWidget> with Trans, Logging {
context: context,
builder: (BuildContext context) {
return DialogTrialWidget(
title: "10 days Premium for free",
description: "Would you like to try all premium functions for 10 days, without any subscription or bank card data?",
title: t("10 days Premium for free"),
description: t("Would you like to try all premium functions for 10 days, without any subscription or bank card data?"),
widget: Column(children: [
Text(
"If you click to 'Yes', all premium functions will be available right now.",
t("If you click to 'Yes', all premium functions will be available right now."),
style: GoogleFonts.inter(color: Colors.white),
),
Divider(),
Text(
"If you click to 'No', you can use all basic functions, and you will loose the oppurtunity to try the premium functions for free.",
t("If you click to 'No', you can use all basic functions, and you will loose the oppurtunity to try the premium functions for free."),
style: GoogleFonts.inter(color: Colors.white),
),
]),
+40
View File
@@ -25,6 +25,46 @@ class TutorialWidget with Trans, Logging {
}
}
Widget explanationFrame(Widget widget) {
return Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(24),
boxShadow: [BoxShadow(color: Colors.black, offset: Offset(0, 10), blurRadius: 10)],
image: DecorationImage(
image: AssetImage('asset/image/WT_plainblack_background.jpg'),
fit: BoxFit.cover,
alignment: Alignment.center,
),
),
child: widget,
);
}
void explanation(BuildContext context, Widget widget) {
tooltip = SuperTooltip(
top: 120,
left: 20,
right: 20,
backgroundColor: Colors.black87,
popupDirection: TooltipDirection.up,
maxWidth: 330,
borderColor: Colors.transparent,
borderWidth: 1.0,
minimumOutSidePadding: 20,
//snapsFarAwayVertically: false,
showCloseButton: ShowCloseButton.outside,
closeButtonColor: Colors.grey,
dismissOnTapOutside: true,
outsideBackgroundColor: Colors.black.withOpacity(0.6),
hasShadow: true,
touchThrougArea: null,
//onClose: () => bloc.add(TutorialFinished()),
custom: true,
content: explanationFrame(widget));
tooltip!.showBox(context);
}
void tip(BuildContext context) {
final TutorialBloc bloc = BlocProvider.of<TutorialBloc>(context);
if (bloc.action == null) {