WT 1.1.14 Tutorial, Sports, New goals

This commit is contained in:
bossanyit
2021-05-02 17:12:42 +02:00
parent 5fe8f76f48
commit c901b07bf8
65 changed files with 2472 additions and 620 deletions
+1 -1
View File
@@ -107,7 +107,7 @@ class AccountPage extends StatelessWidget with Trans {
),
ListTile(
leading: Common.badgedIcon(Colors.grey, Icons.perm_contact_cal, "FitnessLevel"), //Icon(Icons.perm_contact_cal),
subtitle: Text(t("Activity")),
subtitle: Text(t("Activity") + " " + t("and") + " " + t("Sport")),
title: TextButton(
child: Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
Text(fitnessLevel, style: TextStyle(color: Colors.blue)),
+27 -13
View File
@@ -1,6 +1,8 @@
import 'dart:collection';
import 'package:aitrainer_app/bloc/customer_change/customer_change_bloc.dart';
import 'package:aitrainer_app/model/cache.dart';
import 'package:aitrainer_app/model/sport.dart';
import 'package:aitrainer_app/util/app_localization.dart';
import 'package:aitrainer_app/repository/customer_repository.dart';
import 'package:aitrainer_app/model/fitness_state.dart';
@@ -82,10 +84,9 @@ class _CustomerFitnessPageState extends State<CustomerFitnessPage> with Trans {
Text(
t("Your Fitness State"),
textAlign: TextAlign.center,
style: TextStyle(
style: GoogleFonts.archivoBlack(
color: Colors.orange,
fontSize: 42,
fontFamily: 'Arial',
fontSize: 30,
fontWeight: FontWeight.w900,
),
)
@@ -218,7 +219,15 @@ class _CustomerFitnessPageState extends State<CustomerFitnessPage> with Trans {
}),
}),
Divider(),
selected == FitnessState.professional ? getSport(changeBloc) : Offstage(),
Text(
t("Your Primary Sport") + ":",
textAlign: TextAlign.center,
style: GoogleFonts.archivoBlack(
color: Colors.orange,
fontSize: 20,
),
),
getSport(changeBloc),
Divider(),
ElevatedButton(
style: ElevatedButton.styleFrom(
@@ -253,7 +262,7 @@ class _CustomerFitnessPageState extends State<CustomerFitnessPage> with Trans {
}
Widget getSport(CustomerChangeBloc bloc) {
Sport? selected = bloc.getSelectedSport;
Sport? selected = bloc.selectedSport;
return Container(
padding: EdgeInsets.only(left: 65, right: 65),
child: DropdownSearch<Sport>(
@@ -270,10 +279,16 @@ class _CustomerFitnessPageState extends State<CustomerFitnessPage> with Trans {
),
),
mode: Mode.MENU,
compareFn: (Sport i, Sport s) => i.equalsTo(s),
compareFn: (Sport? i, Sport? s) {
if (i == null || s == null) {
return false;
} else {
return i.sportId == s.sportId;
}
},
showSelectedItem: true,
selectedItem: selected,
itemAsString: (data) => t(data.toStr()),
itemAsString: (data) => t(data.sportNameTranslation),
onChanged: (data) {
bloc.add(CustomerSportChange(sport: data));
},
@@ -281,7 +296,7 @@ class _CustomerFitnessPageState extends State<CustomerFitnessPage> with Trans {
popupItemBuilder: _customMenuBuilder,
popupBarrierColor: Colors.white10,
//popupBackgroundColor: Colors.yellow,
items: Sport.values,
items: Cache().getSports(),
dropDownButton: Icon(
Icons.arrow_drop_down,
color: Colors.indigo,
@@ -291,7 +306,6 @@ class _CustomerFitnessPageState extends State<CustomerFitnessPage> with Trans {
}
Widget _customMenuBuilder(BuildContext context, Sport sport, bool isSelected) {
//bool selected = bloc.getSelectedSport;
return Container(
decoration: !isSelected
? BoxDecoration(color: Colors.grey[300])
@@ -303,11 +317,11 @@ class _CustomerFitnessPageState extends State<CustomerFitnessPage> with Trans {
child: ListTile(
selected: isSelected,
title: Text(
t(sport.toStr()),
t(sport.sportNameTranslation),
style: GoogleFonts.archivoBlack(fontSize: 20, color: Colors.blue[600]),
),
subtitle: Text(
t(sport.description(sport)),
t(sport.name),
style: GoogleFonts.inter(fontSize: 12, color: Colors.blue[600]),
),
),
@@ -327,11 +341,11 @@ class _CustomerFitnessPageState extends State<CustomerFitnessPage> with Trans {
: ListTile(
contentPadding: EdgeInsets.all(0),
title: Text(
t(item.toStr()),
t(item.sportNameTranslation),
style: GoogleFonts.archivoBlack(fontSize: 20, color: Colors.blue[600]),
),
subtitle: Text(
t(item.description(item)),
t(item.name),
style: GoogleFonts.inter(fontSize: 12, color: Colors.blue[600]),
),
),
+166 -101
View File
@@ -1,7 +1,7 @@
import 'dart:collection';
import 'package:aitrainer_app/bloc/customer_change/customer_change_bloc.dart';
import 'package:aitrainer_app/util/app_localization.dart';
import 'package:aitrainer_app/library/custom_icon_icons.dart';
import 'package:aitrainer_app/repository/customer_repository.dart';
import 'package:aitrainer_app/util/trans.dart';
import 'package:aitrainer_app/widgets/app_bar_min.dart';
@@ -11,9 +11,45 @@ import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:google_fonts/google_fonts.dart';
class GoalsItem {
static String muscle = "gain_muscle";
static String weight = "weight_loss";
enum Goals { gain_muscle, weight_loss, endurance, muscle_endurance, flexibility, gain_strength, explosiveness, shape_forming }
extension GoalsExt on Goals {
String toStr() => this.toString().split(".").last;
bool equalsTo(Goals goal) => this.toString() == goal.toString();
bool equalsStringTo(String goal) => this.toStr() == goal;
String description(Goals goal) {
switch (goal) {
case Goals.endurance:
return "Endurance";
case Goals.weight_loss:
return "Loss Weight";
case Goals.gain_muscle:
return "Gain Muscle";
case Goals.gain_strength:
return "Gain Strength";
case Goals.muscle_endurance:
return "Muscle Endurance";
case Goals.flexibility:
return "Flexibility";
case Goals.explosiveness:
return "Explosiveness";
case Goals.shape_forming:
return "Shape Forming";
default:
return "Gain Muscle";
}
}
Goals getGoal(Goals goal) {
Goals selected = Goals.gain_muscle;
Goals.values.forEach((element) {
if (goal.equalsTo(element)) {
selected = element;
}
});
return selected;
}
}
// ignore: must_be_immutable
@@ -25,6 +61,7 @@ class CustomerGoalPage extends StatefulWidget {
class _CustomerGoalPage extends State<CustomerGoalPage> with Trans {
String? selected;
bool fulldata = false;
late CustomerChangeBloc changeBloc;
@override
Widget build(BuildContext context) {
@@ -47,107 +84,135 @@ class _CustomerGoalPage extends State<CustomerGoalPage> with Trans {
}
return Scaffold(
appBar: _bar,
body: Container(
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage('asset/image/WT_light_background.jpg'),
fit: BoxFit.cover,
alignment: Alignment.center,
),
appBar: _bar,
body: Container(
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage('asset/image/WT_light_background.jpg'),
fit: BoxFit.cover,
alignment: Alignment.center,
),
height: double.infinity,
width: double.infinity,
child: BlocProvider(
create: (context) => CustomerChangeBloc(customerRepository: customerRepository),
child: Builder(builder: (context) {
CustomerChangeBloc changeBloc = BlocProvider.of<CustomerChangeBloc>(context);
),
height: double.infinity,
width: double.infinity,
child: BlocProvider(
create: (context) => CustomerChangeBloc(customerRepository: customerRepository),
child: Builder(builder: (context) {
changeBloc = BlocProvider.of<CustomerChangeBloc>(context);
return SingleChildScrollView(
child: Center(
child: Column(
children: [
Divider(),
Wrap(alignment: WrapAlignment.center, children: [
Text(
AppLocalizations.of(context)!.translate("Set Your Goals"),
style: GoogleFonts.archivoBlack(
color: Colors.orange,
fontSize: 42,
fontWeight: FontWeight.w900,
),
return SingleChildScrollView(
child: Center(
child: Column(
children: [
Divider(),
Wrap(alignment: WrapAlignment.center, children: [
Text(
t("Set Your Primary Goal"),
maxLines: 2,
style: GoogleFonts.archivoBlack(
color: Colors.orange,
fontSize: 30,
shadows: <Shadow>[
Shadow(
offset: Offset(2.0, 2.0),
blurRadius: 3.0,
color: Colors.black87,
),
],
),
]),
Divider(),
Stack(alignment: Alignment.bottomLeft, children: [
TextButton(
style: TextButton.styleFrom(
padding: EdgeInsets.all(0.0),
shape: getShape(changeBloc, GoalsItem.muscle),
),
child: Image.asset(
"asset/image/Gain_muscle.jpg",
height: 180,
),
onPressed: () => {
setState(() {
selected = GoalsItem.muscle;
changeBloc.add(CustomerGoalChange(goal: GoalsItem.muscle));
}),
}),
InkWell(
child: Text(
AppLocalizations.of(context)!.translate("Gain Muscle"),
style: TextStyle(color: Colors.white, fontSize: 32, fontFamily: 'Arial', fontWeight: FontWeight.w900),
),
highlightColor: Colors.white,
)
]),
Divider(),
Stack(alignment: Alignment.bottomLeft, children: [
TextButton(
style: TextButton.styleFrom(
padding: EdgeInsets.all(0.0),
shape: getShape(changeBloc, GoalsItem.weight),
),
child: Image.asset(
"asset/image/WT_weight_loss.jpg",
height: 180,
),
onPressed: () => {
setState(() {
selected = GoalsItem.muscle;
changeBloc.add(CustomerGoalChange(goal: GoalsItem.weight));
}),
}),
InkWell(
child: Text(
AppLocalizations.of(context)!.translate("Loose Weight"),
style: TextStyle(color: Colors.white, fontSize: 32, fontFamily: 'Arial', fontWeight: FontWeight.w900),
),
highlightColor: Colors.white,
)
]),
Divider(),
ElevatedButton(
style: ElevatedButton.styleFrom(
onPrimary: Colors.white,
primary: Colors.orange,
),
child: Text(fulldata ? t("Save") : t("Next")),
onPressed: () => {
//changingViewModel.saveCustomer(),
changeBloc.add(CustomerSave()),
Navigator.of(context).pop(),
if (!fulldata) {Navigator.of(context).pushNamed("customerFitnessPage", arguments: changeBloc.customerRepository)}
},
)
],
),
));
}),
),
]),
Divider(),
getItem(changeBloc, Goals.gain_muscle),
Divider(),
getItem(changeBloc, Goals.weight_loss),
Divider(),
getItem(changeBloc, Goals.shape_forming),
Divider(),
getItem(changeBloc, Goals.endurance),
Divider(),
getItem(changeBloc, Goals.gain_strength),
Divider(),
getItem(changeBloc, Goals.muscle_endurance),
Divider(),
getItem(changeBloc, Goals.flexibility),
Divider(),
getItem(changeBloc, Goals.explosiveness),
Divider(),
/* ElevatedButton(
style: ElevatedButton.styleFrom(
onPrimary: Colors.white,
primary: Colors.orange,
),
child: Text(fulldata ? t("Save") : t("Next")),
onPressed: () => {
//changingViewModel.saveCustomer(),
changeBloc.add(CustomerSave()),
Navigator.of(context).pop(),
if (!fulldata) {Navigator.of(context).pushNamed("customerFitnessPage", arguments: changeBloc.customerRepository)}
},
) */
],
),
));
}),
),
),
floatingActionButton: FloatingActionButton.extended(
onPressed: () => {
//changingViewModel.saveCustomer(),
changeBloc.add(CustomerSave()),
Navigator.of(context).pop(),
if (!fulldata) {Navigator.of(context).pushNamed("customerFitnessPage", arguments: changeBloc.customerRepository)}
},
backgroundColor: Colors.orange[800],
icon: Icon(
CustomIcon.save,
size: 20,
),
label: Text(
fulldata ? t("Save") : t("Next"),
style: GoogleFonts.inter(fontWeight: FontWeight.bold, fontSize: 12),
),
),
);
}
Widget getItem(CustomerChangeBloc changeBloc, Goals goal) {
return Stack(alignment: Alignment.bottomLeft, children: [
TextButton(
style: TextButton.styleFrom(
padding: EdgeInsets.all(0.0),
shape: getShape(changeBloc, goal.toStr()),
),
));
child: Image.asset(
"asset/image/" + goal.toStr() + ".jpg",
height: 180,
),
onPressed: () => {
setState(() {
selected = goal.toStr();
changeBloc.add(CustomerGoalChange(goal: goal.toStr()));
}),
}),
Container(
padding: EdgeInsets.only(bottom: 5, left: 10),
child: Text(
t(goal.description(goal)),
style: GoogleFonts.archivoBlack(
color: Colors.yellow[300],
fontSize: 28,
shadows: <Shadow>[
Shadow(
offset: Offset(2.0, 2.0),
blurRadius: 5.0,
color: Colors.black87,
),
],
),
),
)
]);
}
dynamic getShape(CustomerChangeBloc customerBloc, String goal) {
-31
View File
@@ -126,37 +126,6 @@ class CustomerModifyPage extends StatelessWidget with Trans {
Divider(
color: Colors.transparent,
),
/* Cache().getLoginType() == LoginType.email
? TextFormField(
key: LibraryKeys.loginPasswordField,
obscureText: true,
decoration: InputDecoration(
labelStyle: TextStyle(fontSize: 14),
contentPadding: EdgeInsets.only(left: 15, top: 15, bottom: 15),
suffixIcon: IconButton(
onPressed: () => {customerBloc.add(CustomerChangePasswordObscure())},
icon: Icon(Icons.remove_red_eye),
),
labelText: t('Password (Leave empty if no change)'),
fillColor: Colors.white24,
filled: true,
border: OutlineInputBorder(
gapPadding: 1.0,
borderRadius: BorderRadius.circular(12.0),
borderSide: BorderSide(color: Colors.green[50]!, width: 0.4),
),
),
initialValue: customerBloc.customerRepository.customer!.password,
autovalidateMode: AutovalidateMode.onUserInteraction,
validator: (val) {
String? validator = customerBloc.passwordValidation(val);
return validator == null ? null : t(validator);
},
keyboardType: TextInputType.visiblePassword,
style: new TextStyle(fontSize: 16, color: Colors.indigo),
onChanged: (value) => {customerBloc.add(CustomerPasswordChange(password: value))})
)
: Offstage(), */
Divider(
color: Colors.transparent,
),
+8
View File
@@ -1,6 +1,8 @@
import 'dart:collection';
import 'dart:ui';
import 'package:aitrainer_app/bloc/tutorial/tutorial_bloc.dart';
import 'package:aitrainer_app/util/enums.dart';
import 'package:aitrainer_app/widgets/tutorial_widget.dart';
import 'package:intl/intl.dart';
import 'package:aitrainer_app/bloc/result/result_bloc.dart';
import 'package:aitrainer_app/util/app_language.dart';
@@ -56,6 +58,12 @@ class EvaluationPage extends StatelessWidget with Trans {
imageUrl = 'asset/image/WT_Results_for_runners.jpg';
}
final TutorialBloc tutorialBloc = BlocProvider.of<TutorialBloc>(context);
print("Evaluation page tutorial isActive? ${tutorialBloc.isActive}");
if (tutorialBloc.isActive == false) {
TutorialWidget().close();
}
setContext(context);
return Scaffold(
appBar: AppBarMin(
+3
View File
@@ -229,6 +229,9 @@ class _ExerciseControlPage extends State<ExerciseControlPage> with Trans {
numberPickForm(exerciseBloc, 2),
Divider(),
numberPickForm(exerciseBloc, 3),
SizedBox(
height: 80,
)
]),
)),
TimerWidget(
+57 -12
View File
@@ -3,6 +3,7 @@ import 'dart:collection';
import 'package:aitrainer_app/bloc/exercise_new/exercise_new_bloc.dart';
import 'package:aitrainer_app/bloc/menu/menu_bloc.dart';
import 'package:aitrainer_app/bloc/test_set_execute/test_set_execute_bloc.dart';
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/model/exercise_ability.dart';
@@ -15,6 +16,7 @@ import 'package:aitrainer_app/widgets/app_bar.dart';
import 'package:aitrainer_app/widgets/bmi_widget.dart';
import 'package:aitrainer_app/widgets/bmr_widget.dart';
import 'package:aitrainer_app/widgets/bottom_bar_multiple_exercises.dart';
import 'package:aitrainer_app/widgets/dialog_common.dart';
import 'package:aitrainer_app/widgets/exercise_save.dart';
import 'package:aitrainer_app/widgets/size_widget.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
@@ -45,8 +47,20 @@ class _ExerciseNewPageState extends State<ExerciseNewPage> with Trans, Logging {
child: BlocConsumer<ExerciseNewBloc, ExerciseNewState>(
listener: (context, state) {
if (state is ExerciseNewError) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(backgroundColor: Colors.orange, content: Text(state.message, style: TextStyle(color: Colors.white))));
showDialog(
context: context,
builder: (BuildContext context) {
return DialogCommon(
warning: true,
title: t("Warning"),
descriptions: t(state.message),
text: "OK",
onTap: () => Navigator.of(context).pushNamed("login"),
onCancel: () => {
Navigator.of(context).pop(),
},
);
});
} else if (state is ExerciseNewSaved) {
final LinkedHashMap args = LinkedHashMap();
// ignore: close_sinks
@@ -84,13 +98,25 @@ class _ExerciseNewPageState extends State<ExerciseNewPage> with Trans, Logging {
Widget getExerciseSaveWidget(ExerciseNewBloc exerciseBloc, ExerciseType exerciseType, MenuBloc menuBloc) {
if (exerciseBloc.exerciseRepository.exerciseType!.name == "BMR") {
return BMR(exerciseBloc: exerciseBloc);
if (Cache().userLoggedIn == null) {
exerciseBloc.add(ExerciseNewAddError(message: "Please log in"));
} else {
return BMR(exerciseBloc: exerciseBloc);
}
}
if (exerciseBloc.exerciseRepository.exerciseType!.name == "BMI") {
return BMI(exerciseBloc: exerciseBloc);
if (Cache().userLoggedIn == null) {
exerciseBloc.add(ExerciseNewAddError(message: "Please log in"));
} else {
return BMI(exerciseBloc: exerciseBloc);
}
}
if (exerciseBloc.exerciseRepository.exerciseType!.name == "Sizes") {
return SizeWidget(exerciseBloc: exerciseBloc);
if (Cache().userLoggedIn == null) {
exerciseBloc.add(ExerciseNewAddError(message: "Please log in"));
} else {
return SizeWidget(exerciseBloc: exerciseBloc);
}
}
return Scaffold(
@@ -143,6 +169,20 @@ class _ExerciseNewPageState extends State<ExerciseNewPage> with Trans, Logging {
// ignore: close_sinks
final TestSetExecuteBloc? executeBloc = BlocProvider.of<TestSetExecuteBloc>(context);
final TutorialBloc tutorialBloc = BlocProvider.of<TutorialBloc>(context);
if (tutorialBloc.isActive) {
final String checkText = "Save";
if (!tutorialBloc.checkAction(checkText)) {
return;
}
if (Cache().userLoggedIn != null) {
saveAll(bloc);
return;
} else {
Navigator.of(context).pushNamed("registration");
}
}
if (executeBloc != null && executeBloc.existsActivePlan() == true) {
confirmationOverride(bloc);
} else {
@@ -203,14 +243,19 @@ class _ExerciseNewPageState extends State<ExerciseNewPage> with Trans, Logging {
TextButton(
child: Text(t("Yes")),
onPressed: () {
saveAll(bloc);
if (executeBloc.existsActivePlan() == true) {
executeBloc.add(TestSetExecuteExerciseFinished(
exerciseTypeId: bloc.exerciseRepository.exerciseType!.exerciseTypeId,
quantity: bloc.exerciseRepository.exercise!.quantity!,
unitQuantity: bloc.exerciseRepository.exercise!.unitQuantity!));
if (Cache().userLoggedIn == null) {
Navigator.pop(context);
bloc.add(ExerciseNewAddError(message: "Please log in"));
} else {
saveAll(bloc);
if (executeBloc.existsActivePlan() == true) {
executeBloc.add(TestSetExecuteExerciseFinished(
exerciseTypeId: bloc.exerciseRepository.exerciseType!.exerciseTypeId,
quantity: bloc.exerciseRepository.exercise!.quantity!,
unitQuantity: bloc.exerciseRepository.exercise!.unitQuantity!));
}
Navigator.pop(context);
}
Navigator.pop(context);
},
)
],
+44 -9
View File
@@ -5,6 +5,7 @@ import 'package:aitrainer_app/bloc/login/login_bloc.dart';
import 'package:aitrainer_app/repository/user_repository.dart';
import 'package:aitrainer_app/util/trans.dart';
import 'package:aitrainer_app/widgets/app_bar_min.dart';
import 'package:aitrainer_app/widgets/dialog_common.dart';
import 'package:aitrainer_app/widgets/dialog_long.dart';
import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
@@ -33,6 +34,21 @@ class LoginPage extends StatelessWidget with Trans {
SnackBar(backgroundColor: Colors.orange, content: Text(t(state.message), style: TextStyle(color: Colors.white))));
} else if (state is LoginSuccess) {
Navigator.of(context).pushNamed('home');
} else if (state is LoginSkipped) {
showDialog(
context: context,
builder: (BuildContext context) {
return DialogCommon(
title: t("No Login"),
descriptions: t("You will skip the login."),
description2: t("The app functionalitity will be restricted, but please take a tour!"),
text: "OK",
onTap: () => {Navigator.of(context).pushNamed('home')},
onCancel: () => {
Navigator.of(context).pop(),
},
);
});
}
}, builder: (context, state) {
final loginBloc = BlocProvider.of<LoginBloc>(context);
@@ -69,8 +85,17 @@ class LoginPage extends StatelessWidget with Trans {
key: _scaffoldKey,
child: Container(
padding: const EdgeInsets.only(left: 20, right: 20),
child: ListView(shrinkWrap: false, padding: EdgeInsets.only(top: 150.0), children: <Widget>[
ListTile(title: Text(t("Login"), style: GoogleFonts.inter(fontSize: 24))),
child: ListView(shrinkWrap: false, padding: EdgeInsets.only(top: 10.0), children: <Widget>[
GestureDetector(
onTap: () => loginBloc.add(LoginSkip()),
child: Text(
t("Skip"),
textAlign: TextAlign.right,
style: GoogleFonts.inter(color: Colors.black, decoration: TextDecoration.underline),
)),
SizedBox(
height: 140,
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
@@ -102,8 +127,9 @@ class LoginPage extends StatelessWidget with Trans {
],
),
Divider(),
ListTile(title: Text(t("OR"), style: GoogleFonts.inter())),
Divider(),
SizedBox(
height: 50,
),
TextFormField(
key: LibraryKeys.loginEmailField,
decoration: InputDecoration(
@@ -178,22 +204,31 @@ class LoginPage extends StatelessWidget with Trans {
//Image.asset('asset/icon/gomb_zold_b-1.png', width: 100, height: 100),
onPressed: () => {loginBloc.add(LoginSubmit())}),
]),
Divider(
color: Colors.transparent,
SizedBox(
height: 50,
),
Row(mainAxisAlignment: MainAxisAlignment.spaceAround, children: <Widget>[
InkWell(
child: Text(t('SignUpLink')),
child: Text(
t('SignUpLink'),
style: GoogleFonts.inter(color: Colors.black, decoration: TextDecoration.underline),
),
onTap: () => Navigator.of(context).pushNamed('registration'),
),
Spacer(flex: 2),
InkWell(
child: Text(t('I forgot the password')),
child: Text(
t('I forgot the password'),
style: GoogleFonts.inter(color: Colors.black, decoration: TextDecoration.underline),
),
onTap: () => Navigator.of(context).pushNamed('resetPassword'),
),
Spacer(flex: 2),
InkWell(
child: Text(t('Privacy')),
child: Text(
t('Privacy'),
style: GoogleFonts.inter(color: Colors.black, decoration: TextDecoration.underline),
),
onTap: () => {
showDialog(
context: context,
+53 -5
View File
@@ -33,7 +33,6 @@ class RegistrationPage extends StatelessWidget with Trans {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(backgroundColor: Colors.orange, content: Text(t(state.message), style: TextStyle(color: Colors.white))));
} else if (state is LoginSuccess) {
//Navigator.of(context).pushNamed('customerModifyPage');
showDialog(
context: context,
builder: (BuildContext context) {
@@ -48,6 +47,21 @@ class RegistrationPage extends StatelessWidget with Trans {
},
);
});
} else if (state is LoginSkipped) {
showDialog(
context: context,
builder: (BuildContext context) {
return DialogCommon(
title: t("No Registration"),
descriptions: t("You will skip the registration process."),
description2: t("Please take a short tour in the app"),
text: "OK",
onTap: () => {Navigator.of(context).pushNamed('home')},
onCancel: () => {
Navigator.of(context).pop(),
},
);
});
}
}, builder: (context, state) {
final loginBloc = BlocProvider.of<LoginBloc>(context);
@@ -84,7 +98,17 @@ class RegistrationPage extends StatelessWidget with Trans {
key: _scaffoldKey,
child: Container(
padding: const EdgeInsets.only(left: 20, right: 20),
child: ListView(shrinkWrap: false, padding: EdgeInsets.only(top: 150.0), children: <Widget>[
child: ListView(shrinkWrap: false, padding: EdgeInsets.only(top: 10.0), children: <Widget>[
GestureDetector(
onTap: () => loginBloc.add(LoginSkip()),
child: Text(
t("Skip"),
textAlign: TextAlign.right,
style: GoogleFonts.inter(color: Colors.black, decoration: TextDecoration.underline),
)),
SizedBox(
height: 120,
),
ListTile(title: Text(t("SignUp"), style: GoogleFonts.inter())),
Row(
mainAxisAlignment: MainAxisAlignment.center,
@@ -116,7 +140,10 @@ class RegistrationPage extends StatelessWidget with Trans {
: Offstage(),
],
),
ListTile(title: Text(t("OR"), style: GoogleFonts.inter())),
//ListTile(title: Text(t("OR"), style: GoogleFonts.inter())),
Divider(
color: Colors.transparent,
),
TextFormField(
key: LibraryKeys.loginEmailField,
decoration: InputDecoration(
@@ -176,6 +203,7 @@ class RegistrationPage extends StatelessWidget with Trans {
color: Colors.transparent,
),
getDataProtection(loginBloc),
getEmailSubscription(loginBloc),
Divider(
color: Colors.transparent,
),
@@ -203,12 +231,18 @@ class RegistrationPage extends StatelessWidget with Trans {
),
Row(mainAxisAlignment: MainAxisAlignment.spaceAround, children: <Widget>[
InkWell(
child: Text(t('Login')),
child: Text(
t('Login'),
style: GoogleFonts.inter(decoration: TextDecoration.underline),
),
onTap: () => Navigator.of(context).pushNamed('login'),
),
Spacer(flex: 2),
InkWell(
child: Text(t('Privacy')),
child: Text(
t('Privacy'),
style: GoogleFonts.inter(decoration: TextDecoration.underline),
),
onTap: () => {
showDialog(
context: context,
@@ -234,4 +268,18 @@ class RegistrationPage extends StatelessWidget with Trans {
controlAffinity: ListTileControlAffinity.leading, // <-- leading Checkbox
);
}
Widget getEmailSubscription(LoginBloc loginBloc) {
return CheckboxListTile(
title: Text(t("Email notifications")),
subtitle: Text(t("We may ask you about your opinion, send events in email")),
dense: true,
value: loginBloc.emailSubscription,
activeColor: Colors.indigo,
onChanged: (value) {
loginBloc.add(DataProtectionClicked(marked: value!));
},
controlAffinity: ListTileControlAffinity.leading, // <-- leading Checkbox
);
}
}
+26
View File
@@ -1,5 +1,6 @@
import 'package:aitrainer_app/bloc/menu/menu_bloc.dart';
import 'package:aitrainer_app/bloc/settings/settings_bloc.dart';
import 'package:aitrainer_app/bloc/tutorial/tutorial_bloc.dart';
import 'package:aitrainer_app/library/custom_icon_icons.dart';
import 'package:aitrainer_app/util/app_language.dart';
import 'package:aitrainer_app/model/cache.dart';
@@ -43,6 +44,7 @@ class SettingsPage extends StatelessWidget with Trans {
SnackBar(backgroundColor: Colors.orange, content: Text(state.message, style: TextStyle(color: Colors.white))));
} else if (state is SettingsReady) {
menuBloc.add(MenuRecreateTree());
Navigator.of(context).pushNamed("home");
}
}, builder: (context, state) {
return ModalProgressHUD(
@@ -76,6 +78,7 @@ class SettingsPage extends StatelessWidget with Trans {
Track().track(TrackingEvent.settings_lang, eventValue: lang)
})),
getServer(settingsBloc),
getTuturialBasic(settingsBloc),
//getDevice(settingsBloc),
]);
}
@@ -131,4 +134,27 @@ class SettingsPage extends StatelessWidget with Trans {
),
);
}
ListTile getTuturialBasic(SettingsBloc settingsBloc) {
final TutorialBloc tutorialBloc = BlocProvider.of<TutorialBloc>(context);
return ListTile(
leading: Icon(CustomIcon.question_circle),
subtitle: Text("Activating the basic tutorial"),
title: ToggleSwitch(
minWidth: 120.0,
minHeight: 30.0,
fontSize: 14.0,
initialLabelIndex: 0,
activeBgColor: Colors.indigo,
activeFgColor: Colors.white,
inactiveBgColor: Colors.white60,
inactiveFgColor: Colors.grey[900],
labels: [t('Basic Tutorial'), t('Activate')],
onToggle: (index) {
settingsBloc.add(SettingsActivateTutorial(activity: ActivityDone.tutorialBasic));
tutorialBloc.add(TutorialStart());
},
),
);
}
}
+52 -34
View File
@@ -26,7 +26,7 @@ class TestSetEdit extends StatelessWidget with Trans {
final String templateNameTranslation = args['templateNameTranslation'];
// ignore: close_sinks
final MenuBloc menuBloc = BlocProvider.of<MenuBloc>(context);
late TestSetEditBloc? bloc;
late TestSetEditBloc bloc;
final bool activeExercisePlan = Cache().activeExercisePlan != null;
setContext(context);
@@ -51,8 +51,20 @@ class TestSetEdit extends StatelessWidget with Trans {
menuBloc: menuBloc),
child: BlocConsumer<TestSetEditBloc, TestSetEditState>(listener: (context, state) {
if (state is TestSetEditError) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(backgroundColor: Colors.orange, content: Text(state.message, style: TextStyle(color: Colors.white))));
showDialog(
context: context,
builder: (BuildContext context) {
return DialogCommon(
warning: true,
title: t("Warning"),
descriptions: t(state.message),
text: "OK",
onTap: () => Navigator.of(context).pushNamed("login"),
onCancel: () => {
Navigator.of(context).pop(),
},
);
});
} else if (state is TestSetEditSaved) {
Navigator.of(context).pop();
Navigator.of(context).pushNamed("testSetExecute");
@@ -60,7 +72,7 @@ class TestSetEdit extends StatelessWidget with Trans {
}, builder: (context, state) {
bloc = BlocProvider.of<TestSetEditBloc>(context);
return ModalProgressHUD(
child: getTestSetWidget(bloc!, templateNameTranslation),
child: getTestSetWidget(bloc, templateNameTranslation),
inAsyncCall: state is TestSetEditLoading,
opacity: 0.5,
color: Colors.black54,
@@ -69,36 +81,40 @@ class TestSetEdit extends StatelessWidget with Trans {
}))),
floatingActionButton: FloatingActionButton.extended(
onPressed: () {
if (activeExercisePlan) {
showCupertinoDialog(
useRootNavigator: true,
context: context,
builder: (_) => CupertinoAlertDialog(
title: Text(t("You have an active Test Set!") + "\n" + Cache().activeExercisePlan!.name),
content: Column(children: [
Divider(),
Text(t("Do you want to override it?"), style: GoogleFonts.inter(color: Colors.black, fontSize: 16)),
]),
actions: [
TextButton(
child: Text(t("No, bring me there"), textAlign: TextAlign.center),
onPressed: () => {
Navigator.pop(context),
Navigator.pop(context),
Navigator.of(context).pushNamed("testSetExecute"),
},
),
TextButton(
child: Text(t("Yes")),
onPressed: () {
Navigator.pop(context);
startTrainingDialog(bloc);
},
)
],
));
if (Cache().userLoggedIn == null) {
bloc.add(TestSetEditAddError(message: "Please log in"));
} else {
startTrainingDialog(bloc);
if (activeExercisePlan) {
showCupertinoDialog(
useRootNavigator: true,
context: context,
builder: (_) => CupertinoAlertDialog(
title: Text(t("You have an active Test Set!") + "\n" + Cache().activeExercisePlan!.name),
content: Column(children: [
Divider(),
Text(t("Do you want to override it?"), style: GoogleFonts.inter(color: Colors.black, fontSize: 16)),
]),
actions: [
TextButton(
child: Text(t("No, bring me there"), textAlign: TextAlign.center),
onPressed: () => {
Navigator.pop(context),
Navigator.pop(context),
Navigator.of(context).pushNamed("testSetExecute"),
},
),
TextButton(
child: Text(t("Yes")),
onPressed: () {
Navigator.pop(context);
startTrainingDialog(bloc);
},
)
],
));
} else {
startTrainingDialog(bloc);
}
}
},
backgroundColor: Colors.orange[800],
@@ -249,7 +265,9 @@ class TestSetEdit extends StatelessWidget with Trans {
child: ClipRRect(
borderRadius: BorderRadius.circular(24.0),
child: GestureDetector(
onTap: () => bloc.add(TestSetEditAddExerciseType(indexKey: index)),
onTap: () {
bloc.add(TestSetEditAddExerciseType(indexKey: index));
},
child: Container(
color: Colors.yellow[700],
child: Center(