wt1.1.2e NumberPicker

This commit is contained in:
Bossanyi Tibor
2020-10-21 15:08:15 +02:00
parent c83d224768
commit 7354611881
69 changed files with 2741 additions and 1271 deletions
+31 -1
View File
@@ -129,11 +129,12 @@ class AccountPage extends StatelessWidget with Trans {
color: Colors.white,
onPressed: () => {
if ( accountBloc.loggedIn ) {
accountBloc.add(AccountLogout())
confirmationDialog( accountBloc ),
} else {
accountBloc.add(AccountLogin()),
Navigator.of(context).pushNamed('login'),
}
},
),
);
@@ -209,4 +210,33 @@ class AccountPage extends StatelessWidget with Trans {
);
}
void confirmationDialog(AccountBloc accountBloc) {
showCupertinoDialog(
useRootNavigator: true,
context: context,
//barrierDismissible: false,
builder:(_) => CupertinoAlertDialog(
title: Text(t("Are you sure to logout?")),
content: Column(
children: [
Divider(),
]),
actions: [
FlatButton(
child: Text(t("No")),
onPressed: () => Navigator.pop(context),
),
FlatButton(
child: Text(t("Yes")),
onPressed: () => {
accountBloc.add(AccountLogout()),
Navigator.pop(context),
},
)
],
)
);
}
}
+1 -37
View File
@@ -18,16 +18,7 @@ class CustomerModifyPage extends StatelessWidget with Trans {
setContext(context);
// ignore: close_sinks
final accountBloc = BlocProvider.of<AccountBloc>(context);
// we cannot initialize the translations in the initState
/* genders.forEach((GenderItem element) {
if (element.dbValue == "m") {
element.name = AppLocalizations.of(context).translate("Man");
}
if (element.dbValue == "w") {
element.name = AppLocalizations.of(context).translate("Woman");
}
});
*/
return BlocProvider(
create: (context) => CustomerChangeFormBloc(customerRepository: accountBloc.customerRepository),
child: Builder(builder: (context) {
@@ -82,20 +73,6 @@ class CustomerModifyPage extends StatelessWidget with Trans {
labelText: t('Email'),
),
),
/* TextFormField(
style: TextStyle(fontSize: 12),
decoration: InputDecoration(
fillColor: Colors.white24,
filled: true,
labelText: AppLocalizations.of(context)
.translate('Email'),
), */
// initialValue: customerChangingViewModel.customer
// .customer.email,
// onFieldSubmitted: (input) =>
// customerChangingViewModel.customer.setEmail(
// input)
)
],
),
@@ -113,19 +90,6 @@ class CustomerModifyPage extends StatelessWidget with Trans {
labelText: t('Password (Leave empty if no change)'),
),
),
/*TextFormField(
style: TextStyle(fontSize: 12),
obscureText: true,
decoration: InputDecoration(
fillColor: Colors.white24,
filled: true,
labelText: AppLocalizations.of(context)
.translate(
'Password (Leave empty if you don\'t want to change)'),
),
//initialValue: customerChangingViewModel.customer.customer.password,
// onFieldSubmitted: (input) => customerChangingViewModel.customer.setPassword(input)
)*/
)
],
),
+171 -202
View File
@@ -1,47 +1,63 @@
import 'dart:collection';
import 'package:aitrainer_app/bloc/exercise_control_form_bloc.dart';
import 'package:aitrainer_app/bloc/exercise_control/exercise_control_bloc.dart';
import 'package:aitrainer_app/localization/app_language.dart';
import 'package:aitrainer_app/localization/app_localization.dart';
import 'package:aitrainer_app/repository/exercise_repository.dart';
import 'package:aitrainer_app/util/trans.dart';
import 'package:aitrainer_app/widgets/app_bar.dart';
import 'package:aitrainer_app/widgets/bottom_nav.dart';
import 'package:aitrainer_app/widgets/splash.dart';
import 'package:flutter/services.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_form_bloc/flutter_form_bloc.dart';
import 'package:aitrainer_app/library/numberpicker.dart';
class ExerciseControlPage extends StatefulWidget {
_ExerciseControlPage createState() => _ExerciseControlPage();
}
class _ExerciseControlPage extends State<ExerciseControlPage> {
class _ExerciseControlPage extends State<ExerciseControlPage> with Trans {
@override
Widget build(BuildContext context) {
LinkedHashMap arguments = ModalRoute.of(context).settings.arguments;
final ExerciseRepository exerciseRepository = arguments['exerciseRepository'];
final double percent = arguments['percent'];
final bool readonly = arguments['readonly'];
setContext(context);
return BlocProvider(
create: (context) => ExerciseControlFormBloc(
exerciseRepository: exerciseRepository, percentToCalculate: percent, readonly: readonly),
child: BlocBuilder<ExerciseControlFormBloc, FormBlocState>(builder: (context, state) {
// ignore: close_sinks
final exerciseBloc = BlocProvider.of<ExerciseControlFormBloc>(context);
if (state is FormBlocLoading) {
create: (context) => ExerciseControlBloc(
exerciseRepository: exerciseRepository, percentToCalculate: percent, readonly: readonly)..
add(ExerciseControlLoad()),
child:
BlocConsumer<ExerciseControlBloc, ExerciseControlState>(
listener: (context, state) {
if (state is ExerciseControlError) {
Scaffold.of(context).showSnackBar(SnackBar(
backgroundColor: Colors.orange,
content:
Text(state.message, style: TextStyle(color: Colors.white))));
} else if (state is ExerciseControlLoading) {
return LoadingDialog();
} else if (state is FormBlocSuccess) {
}
},
builder: (context, state) {
final exerciseBloc = BlocProvider.of<ExerciseControlBloc>(context);
if (state is ExerciseControlReady) {
return getControlForm(exerciseBloc);
} else {
return getControlForm(exerciseBloc);
}
}));
})
);
}
Form getControlForm(ExerciseControlFormBloc exerciseBloc) {
Form getControlForm(ExerciseControlBloc exerciseBloc) {
String exerciseName = AppLanguage().appLocal == Locale("en")
? exerciseBloc.exerciseRepository.exerciseType.name
: exerciseBloc.exerciseRepository.exerciseType.nameTranslation;
@@ -65,209 +81,162 @@ class _ExerciseControlPage extends State<ExerciseControlPage> {
padding: const EdgeInsets.only(top: 25, left: 25, right: 25),
child: SingleChildScrollView(
scrollDirection: Axis.vertical,
child: Column(mainAxisAlignment: MainAxisAlignment.spaceAround, children: <Widget>[
Text(
exerciseName,
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 18, color: Colors.deepOrange),
overflow: TextOverflow.fade,
maxLines: 1,
softWrap: true,
),
FlatButton(
child: Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
Icon(Icons.question_answer),
Text(AppLocalizations.of(context).translate("Why do you need Exercise Control?"),
style: TextStyle(color: Colors.blueAccent, fontWeight: FontWeight.normal, fontSize: 14)),
Icon(Icons.arrow_forward_ios),
]),
textColor: Colors.blueAccent,
color: Colors.transparent,
onPressed: () => {
//Navigator.of(context).pushNamed('exerciseTypeDescription', arguments: exerciseBloc.exerciseRepository),
},
),
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
AppLocalizations.of(context).translate("Your 1RM:"),
exerciseName,
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 18, color: Colors.deepOrange),
overflow: TextOverflow.fade,
maxLines: 1,
softWrap: true,
),
Text(
" " +
exerciseBloc.initialRMField.value +
FlatButton(
child: Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
Icon(Icons.info),
Flexible(
child: Text(t("Why do you need Exercise Control?"),
style:
TextStyle(color: Colors.blueAccent, fontWeight: FontWeight.normal, fontSize: 14)),
),
Icon(Icons.arrow_forward_ios),
]),
textColor: Colors.blueAccent,
color: Colors.transparent,
onPressed: () => {
//Navigator.of(context).pushNamed('exerciseTypeDescription', arguments: exerciseBloc.exerciseRepository),
},
),
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Text(
t("Your 1RM:"),
),
Text(
" " +
exerciseBloc.exerciseRepository.exerciseType.unitQuantityUnit,
style: TextStyle(fontWeight: FontWeight.bold),
exerciseBloc.initialRM.toStringAsFixed(0) +
" " +
exerciseBloc.exerciseRepository.exerciseType.unitQuantityUnit,
style: TextStyle(fontWeight: FontWeight.bold),
),
],
),
],
),
Divider(),
Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
AppLocalizations.of(context).translate("1st Control Exercise:"),
style: TextStyle(),
),
TextFieldBlocBuilder(
readOnly: exerciseBloc.step != 1,
textFieldBloc: exerciseBloc.quantity1Field,
textAlign: TextAlign.center,
style: TextStyle(fontSize: 14, color: Colors.deepOrange, fontWeight: FontWeight.bold),
inputFormatters: [FilteringTextInputFormatter.allow(RegExp(r"[\d.]"))],
decoration: InputDecoration(
fillColor: Colors.white,
filled: false,
hintStyle: TextStyle(fontSize: 12, color: Colors.black54, fontWeight: FontWeight.w100),
hintText: AppLocalizations.of(context).translate("The number of the exercise"),
labelStyle:
TextStyle(fontSize: 12, color: Colors.deepOrange, fontWeight: FontWeight.normal),
labelText: "Please repeat with " +
exerciseBloc.unitQuantity1Field.value +
" " +
exerciseBloc.exerciseRepository.exerciseType.unitQuantityUnit +
" " +
exerciseBloc.times +
" times!",
),
),
RaisedButton(
padding: EdgeInsets.all(0),
textColor: Colors.white,
color: exerciseBloc.step == 1 ? Colors.blue : Colors.black26,
focusColor: Colors.blueAccent,
onPressed: () => {exerciseBloc.submit()},
child: Text(
AppLocalizations.of(context).translate("Check"),
style: TextStyle(fontSize: 12),
)),
],
),
Divider(),
Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
AppLocalizations.of(context).translate("2nd Control Exercise:"),
style: TextStyle(),
),
TextFieldBlocBuilder(
readOnly: exerciseBloc.step != 2,
textFieldBloc: exerciseBloc.quantity2Field,
textAlign: TextAlign.center,
style: TextStyle(fontSize: 14, color: Colors.deepOrange, fontWeight: FontWeight.bold),
inputFormatters: [FilteringTextInputFormatter.allow(RegExp(r"[\d.]"))],
onChanged: (input) => {
print("Quantity 2 value $input"),
//exerciseBloc.exerciseRepository.setQuantity(double.parse(input)),
//exerciseBloc.exerciseRepository
// .setUnit(exerciseBloc.exerciseRepository.exerciseType.unit)
},
decoration: InputDecoration(
fillColor: Colors.white,
filled: false,
hintStyle: TextStyle(fontSize: 12, color: Colors.black54, fontWeight: FontWeight.w100),
hintText: AppLocalizations.of(context).translate("The number of the exercise"),
labelStyle:
TextStyle(fontSize: 12, color: Colors.deepOrange, fontWeight: FontWeight.normal),
labelText: "Please repeat with " +
exerciseBloc.unitQuantity2Field.value +
" " +
exerciseBloc.exerciseRepository.exerciseType.unitQuantityUnit +
" 12 times!",
),
),
RaisedButton(
padding: EdgeInsets.all(0),
textColor: Colors.white,
color: exerciseBloc.step == 2 ? Colors.blue : Colors.black26,
focusColor: Colors.blueAccent,
onPressed: () => {exerciseBloc.submit()},
child: Text(
AppLocalizations.of(context).translate("Check"),
style: TextStyle(fontSize: 12),
)),
],
),
Divider(),
Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
AppLocalizations.of(context).translate("3rd Control Exercise:"),
style: TextStyle(),
),
TextFieldBlocBuilder(
readOnly: exerciseBloc.step != 3,
textFieldBloc: exerciseBloc.quantity3Field,
textAlign: TextAlign.center,
style: TextStyle(fontSize: 14, color: Colors.deepOrange, fontWeight: FontWeight.bold),
inputFormatters: [FilteringTextInputFormatter.allow(RegExp(r"[\d.]"))],
onChanged: (input) => {
print("Quantity 3 value $input"),
//exerciseBloc.exerciseRepository.setQuantity(double.parse(input)),
//exerciseBloc.exerciseRepository
// .setUnit(exerciseBloc.exerciseRepository.exerciseType.unit)
},
decoration: InputDecoration(
fillColor: Colors.white,
filled: false,
hintStyle: TextStyle(fontSize: 12, color: Colors.black54, fontWeight: FontWeight.w100),
hintText: AppLocalizations.of(context).translate("The number of the exercise"),
labelStyle:
TextStyle(fontSize: 12, color: Colors.deepOrange, fontWeight: FontWeight.normal),
labelText: "Please repeat with " +
exerciseBloc.unitQuantity3Field.value +
" " +
exerciseBloc.exerciseRepository.exerciseType.unitQuantityUnit +
" 12 times!",
),
),
RaisedButton(
padding: EdgeInsets.all(0),
textColor: Colors.white,
color: exerciseBloc.step == 3 ? Colors.blue : Colors.black26,
focusColor: Colors.blueAccent,
onPressed: () => {exerciseBloc.submit()},
child: Text(
AppLocalizations.of(context).translate("Check"),
style: TextStyle(fontSize: 12),
)),
],
),
]),
Divider(),
numberPickForm(exerciseBloc, 1),
Divider(),
numberPickForm(exerciseBloc, 2),
Divider(),
numberPickForm(exerciseBloc, 3),
]),
))),
bottomNavigationBar: BottomNavigator(bottomNavIndex: 1),
),
);
}
Widget numberPickForm(ExerciseControlBloc exerciseBloc, int step) {
String strTimes = step == 2 ? exerciseBloc.origQuantity.toString() : "max.";
String textInstruction = "";
textInstruction = t("Please repeat with ") +
exerciseBloc.unitQuantity.toStringAsFixed(0) +
" " +
exerciseBloc.exerciseRepository.exerciseType.unitQuantityUnit +
t("hu_with") + " " +
strTimes + " " + t("times!");
String title = step.toString() + ". " + t("Control Exercise:");
List<Widget> listWidgets = [
Text(
title,
style: TextStyle(fontWeight: FontWeight.bold),
),
Text(
textInstruction,
style: TextStyle(fontSize: 12),
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
NumberPicker.horizontal(
highlightSelectedValue: step == exerciseBloc.step,
initialValue: exerciseBloc.quantity.toInt(),
minValue: 0,
maxValue: 200,
step: 1,
onChanged: (value) => {
exerciseBloc.add(ExerciseControlQuantityChange(quantity: value.toDouble(), step: step))
},
listViewHeight: 80,
//decoration: _decoration,
),
RaisedButton(
padding: EdgeInsets.all(0),
textColor: Colors.white,
color: step == exerciseBloc.step ? Colors.blue : Colors.black26,
focusColor: Colors.blueAccent,
onPressed: () => {
exerciseBloc.add(ExerciseControlSubmit(step: step)),
if ( step == 3 ) {
confirmationDialog(exerciseBloc)
}
},
child: Text(
t("Save"),
style: TextStyle(fontSize: 12),
)),
],
),
];
return
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: listWidgets,
);
}
String validateNumberInput(input) {
String error = AppLocalizations.of(context).translate("Please type the right quantity 0-10000");
dynamic rc = (input != null && input.length > 0);
if (!rc) {
return null;
}
void confirmationDialog( ExerciseControlBloc bloc ) {
Pattern pattern = r'^\d+(?:\.\d+)?$';
RegExp regex = new RegExp(pattern);
if (!regex.hasMatch(input)) {
return error;
}
rc = double.tryParse(input);
if (rc == null) {
return error;
}
String unit = t(bloc.exerciseRepository.exerciseType.unit);
if (!(double.parse(input) < 10000 && double.parse(input) > 0)) {
return error;
}
showCupertinoDialog(
useRootNavigator: true,
context: context,
//barrierDismissible: false,
builder:(_) => CupertinoAlertDialog(
title: Text(t("Summary of your test")),
content: Column(
return null;
children: [
Text(t("Test") + ": " + bloc.repeats[1].toStringAsFixed(0) + "x" + bloc.repeats[0].toStringAsFixed(0) + " " + unit ,
style: (TextStyle(color: Colors.blue)),),
Divider(),
Text(t("1st Control") + ": " + bloc.repeats[2].toStringAsFixed(0) + "x" + bloc.unitQuantity.toStringAsFixed(0) + " " + unit ,
style: (TextStyle(color: Colors.blue)),),
Text(t("2nd Control") + ": " + bloc.repeats[3].toStringAsFixed(0) + "x" + bloc.unitQuantity.toStringAsFixed(0) + " " + unit ,
style: (TextStyle(color: Colors.blue)),),
Text(t("3rd Control") + ": " + bloc.repeats [4].toStringAsFixed(0) + "x" + bloc.unitQuantity.toStringAsFixed(0) + " " + unit ,
style: (TextStyle(color: Colors.blue)),),
]),
actions: [
FlatButton(
child: Text(t("OK")),
onPressed: () => {
Navigator.of(context).pop(),
Navigator.of(context).pop()
},
)
],
)
);
}
}
@@ -1,5 +1,5 @@
import 'dart:collection';
import 'package:aitrainer_app/bloc/exercise_by_plan/exercise_by_plan_bloc.dart';
import 'package:aitrainer_app/bloc/exercise_execute_plan/exercise_execute_plan_bloc.dart';
import 'package:aitrainer_app/model/cache.dart';
import 'package:aitrainer_app/model/workout_menu_tree.dart';
import 'package:aitrainer_app/library/tree_view.dart';
@@ -13,15 +13,15 @@ import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
class ExerciseByPlanPage extends StatefulWidget {
class ExerciseExecutePage extends StatefulWidget {
@override
_ExerciseByPlanPage createState() => _ExerciseByPlanPage();
_ExerciseExecutePage createState() => _ExerciseExecutePage();
}
class _ExerciseByPlanPage extends State<ExerciseByPlanPage> with Trans {
class _ExerciseExecutePage extends State<ExerciseExecutePage> with Trans {
final GlobalKey<ScaffoldState> _scaffoldKey = new GlobalKey<ScaffoldState>();
// ignore: close_sinks
ExerciseByPlanBloc bloc;
ExerciseExecutePlanBloc bloc;
@override
void initState() {
@@ -29,7 +29,7 @@ class _ExerciseByPlanPage extends State<ExerciseByPlanPage> with Trans {
/// We require the initializers to run after the loading screen is rendered
SchedulerBinding.instance.addPostFrameCallback((_) {
BlocProvider.of<ExerciseByPlanBloc>(context).add(ExerciseByPlanLoad());
BlocProvider.of<ExerciseExecutePlanBloc>(context).add(ExerciseByPlanLoad());
});
}
@@ -37,7 +37,7 @@ class _ExerciseByPlanPage extends State<ExerciseByPlanPage> with Trans {
Widget build(BuildContext context) {
LinkedHashMap arguments = ModalRoute.of(context).settings.arguments;
final int customerId = arguments['customerId'];
bloc = BlocProvider.of<ExerciseByPlanBloc>(context);
bloc = BlocProvider.of<ExerciseExecutePlanBloc>(context);
bloc.customerId = customerId;
setContext(context);
@@ -49,13 +49,13 @@ class _ExerciseByPlanPage extends State<ExerciseByPlanPage> with Trans {
decoration: BoxDecoration(
image: DecorationImage(
image: customerId == Cache().userLoggedIn.customerId
? AssetImage('asset/image/WT_light_background.png')
? AssetImage('asset/image/WT_menu_dark.png')
: AssetImage('asset/image/WT_menu_dark.png'),
fit: BoxFit.cover,
alignment: Alignment.center,
),
),
child: BlocConsumer<ExerciseByPlanBloc, ExerciseByPlanState>(
child: BlocConsumer<ExerciseExecutePlanBloc, ExerciseExecutePlanState>(
listener: (context, state) {
if (state is ExerciseByPlanError) {
Scaffold.of(context).showSnackBar(SnackBar(
@@ -82,14 +82,14 @@ class _ExerciseByPlanPage extends State<ExerciseByPlanPage> with Trans {
);
}
Widget exerciseWidget(ExerciseByPlanBloc bloc) {
Widget exerciseWidget(ExerciseExecutePlanBloc bloc) {
return TreeView(
startExpanded: false,
children: nodeExercisePlan(bloc),
);
}
List<Widget> nodeExercisePlan(ExerciseByPlanBloc bloc) {
List<Widget> nodeExercisePlan(ExerciseExecutePlanBloc bloc) {
List<Widget> exerciseTypes = List();
Card explanation = Card(
color: Colors.white38,
@@ -141,7 +141,7 @@ class _ExerciseByPlanPage extends State<ExerciseByPlanPage> with Trans {
return exerciseTypes;
}
List<Widget> _getChildList(List<WorkoutMenuTree> listWorkoutTree, ExerciseByPlanBloc bloc) {
List<Widget> _getChildList(List<WorkoutMenuTree> listWorkoutTree, ExerciseExecutePlanBloc bloc) {
List<Widget> list = List();
listWorkoutTree.forEach((element) {
@@ -184,7 +184,7 @@ class _ExerciseByPlanPage extends State<ExerciseByPlanPage> with Trans {
IconButton(
padding: EdgeInsets.all(0),
icon: Icon(Icons.description, color: Colors.black12,),
icon: Icon(Icons.info, color: Colors.black12,),
onPressed: () {
},
@@ -202,11 +202,11 @@ class _ExerciseByPlanPage extends State<ExerciseByPlanPage> with Trans {
return list;
}
void addExerciseByPlanEvent(ExerciseByPlanBloc bloc, WorkoutMenuTree workoutTree) {
void addExerciseByPlanEvent(ExerciseExecutePlanBloc bloc, WorkoutMenuTree workoutTree) {
LinkedHashMap args = LinkedHashMap();
args['blocExerciseByPlan'] = bloc;
args['customerId'] = bloc.customerId;
args['workoutTree'] = workoutTree;
Navigator.of(context).pushNamed("exerciseAddByPlanPage", arguments: args);
Navigator.of(context).pushNamed("exerciseExecuteAddPage", arguments: args);
}
}
@@ -1,29 +1,29 @@
import 'dart:collection';
import 'package:aitrainer_app/bloc/exercise_add_by_plan_bloc.dart';
import 'package:aitrainer_app/bloc/exercise_by_plan/exercise_by_plan_bloc.dart';
import 'package:aitrainer_app/bloc/exercise_execute_plan/exercise_execute_plan_bloc.dart';
import 'package:aitrainer_app/bloc/exercise_execute_plan_add/exercise_execute_plan_add_bloc.dart';
import 'package:aitrainer_app/localization/app_language.dart';
import 'package:aitrainer_app/model/workout_menu_tree.dart';
import 'package:aitrainer_app/repository/exercise_repository.dart';
import 'package:aitrainer_app/util/trans.dart';
import 'package:aitrainer_app/widgets/splash.dart';
import 'package:flutter/services.dart';
import 'package:aitrainer_app/library/numberpicker.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_form_bloc/flutter_form_bloc.dart';
class ExerciseAddByPlanPage extends StatefulWidget{
_ExerciseAddByPlanPage createState() => _ExerciseAddByPlanPage();
class ExerciseExecutePlanAddPage extends StatefulWidget{
_ExerciseExecuteAddPage createState() => _ExerciseExecuteAddPage();
}
class _ExerciseAddByPlanPage extends State<ExerciseAddByPlanPage> with Trans {
class _ExerciseExecuteAddPage extends State<ExerciseExecutePlanAddPage> with Trans {
@override
Widget build(BuildContext context) {
LinkedHashMap arguments = ModalRoute.of(context).settings.arguments;
// ignore: close_sinks
final ExerciseByPlanBloc bloc = arguments['blocExerciseByPlan'];
final ExerciseExecutePlanBloc planBloc = arguments['blocExerciseByPlan'];
final int customerId = arguments['customerId'];
final WorkoutMenuTree workoutTree = arguments['workoutTree'];
final ExerciseRepository exerciseRepository = ExerciseRepository();
@@ -31,18 +31,29 @@ class _ExerciseAddByPlanPage extends State<ExerciseAddByPlanPage> with Trans {
return BlocProvider(
create: (context) =>
ExerciseAddByPlanFormBloc(
ExerciseExecutePlanAddBloc(
exerciseRepository: exerciseRepository,
exercisePlanRepository: bloc.exercisePlanRepository,
exercisePlanRepository: planBloc.exercisePlanRepository,
customerId: customerId,
workoutTree: workoutTree),
child: BlocBuilder<ExerciseAddByPlanFormBloc, FormBlocState>(
workoutTree: workoutTree,
planBloc: planBloc),
child: BlocConsumer<ExerciseExecutePlanAddBloc, ExerciseExecutePlanAddState>(
listener: (context, state) {
if (state is ExerciseExecutePlanAddError) {
Scaffold.of(context).showSnackBar(SnackBar(
backgroundColor: Colors.orange,
content:
Text(state.message, style: TextStyle(color: Colors.white))));
} else if (state is ExerciseExecutePlanAddLoading) {
return LoadingDialog();
}
},
builder: (context, state) {
// ignore: close_sinks
final exerciseBloc = BlocProvider.of<ExerciseAddByPlanFormBloc>(context);
if ( state is FormBlocLoading ) {
final exerciseBloc = BlocProvider.of<ExerciseExecutePlanAddBloc>(context);
if ( state is ExerciseExecutePlanAddLoading ) {
return LoadingDialog();
} else if ( state is FormBlocSuccess) {
} else if ( state is ExerciseExecutePlanAddReady) {
return getControlForm(exerciseBloc);
} else {
return getControlForm(exerciseBloc);
@@ -51,7 +62,7 @@ class _ExerciseAddByPlanPage extends State<ExerciseAddByPlanPage> with Trans {
));
}
Form getControlForm( ExerciseAddByPlanFormBloc exerciseBloc) {
Form getControlForm( ExerciseExecutePlanAddBloc exerciseBloc) {
String exerciseName = AppLanguage().appLocal == Locale("en") ?
exerciseBloc.exerciseRepository.exerciseType.name :
exerciseBloc.exerciseRepository.exerciseType.nameTranslation;
@@ -65,7 +76,7 @@ class _ExerciseAddByPlanPage extends State<ExerciseAddByPlanPage> with Trans {
title: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Text("Add Exercise"),
Text(t("Save Exercise"), style: TextStyle(fontSize: 18),),
Image.asset(
'asset/image/WT_long_logo.png',
fit: BoxFit.cover,
@@ -98,6 +109,9 @@ class _ExerciseAddByPlanPage extends State<ExerciseAddByPlanPage> with Trans {
padding: const EdgeInsets.only (top: 25, left: 25, right: 25),
child: SingleChildScrollView(
scrollDirection: Axis.vertical,
controller: ScrollController(
initialScrollOffset: exerciseBloc.scrollOffset,
),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
@@ -128,7 +142,7 @@ class _ExerciseAddByPlanPage extends State<ExerciseAddByPlanPage> with Trans {
);
}
List<Column> repeatExercises(ExerciseAddByPlanFormBloc exerciseBloc) {
List<Column> repeatExercises(ExerciseExecutePlanAddBloc exerciseBloc) {
List<Column> listColumns = List<Column>();
for ( int i = 0; i < exerciseBloc.countSteps; i++) {
Column col = Column(
@@ -138,8 +152,54 @@ class _ExerciseAddByPlanPage extends State<ExerciseAddByPlanPage> with Trans {
Divider(color: Colors.transparent,),
Text(t("Execute the") + " " + (i+1).toString() + t(". set!"),
style: TextStyle(),),
Divider(color: Colors.transparent,),
Text(t("Please repeat with") + " "+ exerciseBloc.unitQuantity.toStringAsFixed(0) + " " +
exerciseBloc.exerciseRepository.exerciseType.unitQuantityUnit + " " +
exerciseBloc.exercisePlanRepository.getActualPlanDetail().repeats.toString() + " " + t("times!")),
Row(
children: [
NumberPicker.horizontal(
highlightSelectedValue: (i + 1) == exerciseBloc.step,
initialValue: exerciseBloc.unitQuantity.toInt(),
minValue: 0,
maxValue: 200,
step: 1,
textStyle: TextStyle(fontWeight: FontWeight.bold),
textStyleHighlighted: TextStyle(fontSize: 24, color: Colors.indigo, fontWeight: FontWeight.bold),
onChanged: (value) => {
exerciseBloc.add(ExerciseExecutePlanAddChangeUnitQuantity(quantity: value.toDouble()))
},
listViewHeight: 80,
//decoration: _decoration,
),
Text(exerciseBloc.exerciseRepository.exerciseType.unitQuantityUnit),
]
),
TextFieldBlocBuilder(
Row(
children: [
NumberPicker.horizontal(
highlightSelectedValue: (i+1) == exerciseBloc.step,
initialValue: exerciseBloc.quantity.toInt(),
minValue: 0,
maxValue: 200,
step: 1,
textStyle: TextStyle(fontWeight: FontWeight.bold),
textStyleHighlighted: TextStyle(fontSize: 24, color: Colors.deepOrange, fontWeight: FontWeight.bold),
onChanged: (value) => {
exerciseBloc.add(ExerciseExecutePlanAddChangeQuantity(quantity: value.toDouble()))
},
listViewHeight: 80,
//decoration: _decoration,
),
Text(t("repeat")),
]
),
/*TextFieldBlocBuilder(
readOnly: exerciseBloc.step != i+1,
textFieldBloc: exerciseBloc.unitQuantity1Field,
textAlign: TextAlign.center,
@@ -159,8 +219,8 @@ class _ExerciseAddByPlanPage extends State<ExerciseAddByPlanPage> with Trans {
labelStyle: TextStyle(fontSize: 14, color: Colors.deepOrange, fontWeight: FontWeight.normal),
labelText: exerciseBloc.exerciseRepository.exerciseType.unitQuantityUnit,
),
),
TextFieldBlocBuilder(
),*/
/*TextFieldBlocBuilder(
readOnly: exerciseBloc.step != i+1,
textFieldBloc: exerciseBloc.quantity1Field,
textAlign: TextAlign.center,
@@ -183,7 +243,7 @@ class _ExerciseAddByPlanPage extends State<ExerciseAddByPlanPage> with Trans {
exerciseBloc.exerciseRepository.exerciseType.unitQuantityUnit + " " +
exerciseBloc.exercisePlanRepository.getActualPlanDetail().repeats.toString() + " " + t("times!"),
),
),
),*/
RaisedButton(
padding: EdgeInsets.all(0),
@@ -194,47 +254,21 @@ class _ExerciseAddByPlanPage extends State<ExerciseAddByPlanPage> with Trans {
{
print ("Submit step " + exerciseBloc.step.toString() + " (i) " + i.toString()),
if ( exerciseBloc.step == i+1 ) {
exerciseBloc.submit()
exerciseBloc.add(ExerciseExecutePlanAddSubmit())
},
if ( i+1 == exerciseBloc.countSteps) {
Navigator.of(context).pop()
}
},
child: Text(
t("Check"),
t("Save"),
style: TextStyle(fontSize: 12),)
),
Divider(color: Colors.transparent,),
Divider(),
],
);
listColumns.add(col);
}
return listColumns;
}
String validateNumberInput(input) {
String error = t("Please type the right quantity 0-10000");
dynamic rc = (input != null && input.length > 0);
if (!rc) {
return null;
}
Pattern pattern = r'^\d+(?:\.\d+)?$';
RegExp regex = new RegExp(pattern);
if (!regex.hasMatch(input)) {
return error;
}
rc = double.tryParse(input);
if (rc == null) {
return error;
}
if (!(double.parse(input) < 10000 && double.parse(input) > 0)) {
return error;
}
return null;
}
}
+125 -28
View File
@@ -1,6 +1,10 @@
import 'dart:collection';
import 'package:aitrainer_app/bloc/exercise_log/exercise_log_bloc.dart';
import 'package:aitrainer_app/widgets/app_bar.dart';
import 'package:aitrainer_app/widgets/bottom_nav.dart';
import 'package:aitrainer_app/widgets/splash.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:intl/intl.dart';
import 'package:aitrainer_app/localization/app_language.dart';
import 'package:aitrainer_app/model/cache.dart';
@@ -22,36 +26,68 @@ class _ExerciseLogPage extends State<ExerciseLogPage> with Trans, Common {
@override
Widget build(BuildContext context) {
LinkedHashMap arguments = ModalRoute.of(context).settings.arguments;
final ExerciseRepository exerciseRepository = arguments['exerciseRepository'];
//final ExerciseRepository exerciseRepository = arguments['exerciseRepository'];
final int customerId = arguments['customerId'];
setContext(context);
return BlocProvider(
create: (context) => ExerciseLogBloc(exerciseRepository: ExerciseRepository())..
add(ExerciseLogLoad()),
child: BlocConsumer<ExerciseLogBloc, ExerciseLogState>(
listener: (context, state) {
if ( state is ExerciseLogLoading ) {
return LoadingDialog();
} else if ( state is ExerciseLogError ) {
Scaffold.of(context).showSnackBar(SnackBar(
backgroundColor: Colors.orange,
content:
Text(state.message, style: TextStyle(color: Colors.white))));
}
},
builder: (context, state) {
final exerciseBloc = BlocProvider.of<ExerciseLogBloc>(context);
if ( state is ExerciseLogReady ) {
return getExerciseLog(customerId, exerciseBloc);
} else {
return getExerciseLog(customerId, exerciseBloc);
}
}
)
);
}
Widget getExerciseLog(int customerId, ExerciseLogBloc exerciseLogBloc) {
return Scaffold(
appBar: AppBarNav(depth: 1),
body: Container(
padding: EdgeInsets.all(20),
decoration: BoxDecoration(
image: DecorationImage(
image: customerId == Cache().userLoggedIn.customerId ? AssetImage('asset/image/WT_light_background.png'):
AssetImage('asset/image/WT_menu_dark.png'),
fit: BoxFit.cover,
alignment: Alignment.center,
),
appBar: AppBarNav(depth: 1),
body: Container(
padding: EdgeInsets.all(20),
decoration: BoxDecoration(
image: DecorationImage(
image: customerId == Cache().userLoggedIn.customerId ? AssetImage('asset/image/WT_light_background.png'):
AssetImage('asset/image/WT_menu_dark.png'),
fit: BoxFit.cover,
alignment: Alignment.center,
),
child: exerciseWidget(exerciseRepository, customerId),
),
bottomNavigationBar: BottomNavigator(bottomNavIndex: 1),
child: exerciseWidget(exerciseLogBloc, customerId),
),
bottomNavigationBar: BottomNavigator(bottomNavIndex: 1),
);
}
Widget exerciseWidget(ExerciseRepository exerciseRepository, int customerId) {
Widget exerciseWidget(ExerciseLogBloc exerciseLogBloc, int customerId) {
return TreeView(
startExpanded: false,
children: _getTreeChildren(exerciseRepository, customerId),
children: _getTreeChildren(exerciseLogBloc, customerId),
);
}
List<Widget> _getTreeChildren(ExerciseRepository exerciseRepository, int customerId) {
List<Widget> _getTreeChildren(ExerciseLogBloc exerciseLogBloc, int customerId) {
final ExerciseRepository exerciseRepository = exerciseLogBloc.exerciseRepository;
if ( customerId == Cache().userLoggedIn.customerId ) {
exerciseRepository.exerciseList = exerciseRepository.getExerciseList();
} else if ( Cache().getTrainee() != null && customerId == Cache().getTrainee().customerId ) {
@@ -109,9 +145,9 @@ class _ExerciseLogPage extends State<ExerciseLogPage> with Trans, Common {
Container(
margin: const EdgeInsets.only(left: 4.0),
child: TreeViewChild(
startExpanded: true,
startExpanded: false,
parent: TreeviewParentWidget(text: origDate),
children: _getChildList(listExercises, exerciseRepository),
children: _getChildList(listExercises, exerciseRepository, exerciseLogBloc),
)
)
);
@@ -134,7 +170,7 @@ class _ExerciseLogPage extends State<ExerciseLogPage> with Trans, Common {
child: TreeViewChild(
startExpanded: true,
parent: TreeviewParentWidget(text: origDate),
children: _getChildList(listExercises, exerciseRepository),
children: _getChildList(listExercises, exerciseRepository, exerciseLogBloc),
)
)
);
@@ -143,7 +179,7 @@ class _ExerciseLogPage extends State<ExerciseLogPage> with Trans, Common {
return listWidget;
}
List<Widget> _getChildList(List<Exercise> listExercises, ExerciseRepository exerciseRepository) {
List<Widget> _getChildList(List<Exercise> listExercises, ExerciseRepository exerciseRepository, ExerciseLogBloc exerciseLogBloc) {
List<Widget> list = List();
bool isEnglish = AppLanguage().appLocal == Locale('en');
@@ -173,18 +209,28 @@ class _ExerciseLogPage extends State<ExerciseLogPage> with Trans, Common {
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Icon(Icons.accessibility, color: Colors.black12),
SizedBox(width: 20),
SizedBox(width: 10,),
Flexible(
child:
Text(
exerciseName,
textAlign: TextAlign.start,
style: TextStyle(fontSize: 12, color: Colors.black),
),
fit: FlexFit.tight,
flex: 8,
child: Text(
exerciseName,
style: TextStyle(fontSize: 12, color: Colors.black),
),
),
SizedBox(width: 20),
Flexible(fit: FlexFit.tight, child: SizedBox(width: 10,)),
Text(labelExercise , style: TextStyle(fontSize: 9, color: Colors.blueAccent.shade700),) ,
Flexible(fit: FlexFit.tight, child: SizedBox(width: 10,)),
IconButton(
icon: Icon(Icons.delete, color: Colors.black12),
onPressed: () {
confirmationDialog(exerciseLogBloc, exercise);
},
),
]),
)
),
@@ -195,4 +241,55 @@ class _ExerciseLogPage extends State<ExerciseLogPage> with Trans, Common {
return list;
}
void confirmationDialog( ExerciseLogBloc bloc, Exercise exercise ) {
ExerciseType exerciseType = bloc.exerciseRepository.getExerciseTypeById(exercise.exerciseTypeId);
String exerciseName = AppLanguage().appLocal == Locale("en")
? exerciseType.name
: exerciseType.nameTranslation;
String strDate = AppLanguage().appLocal == Locale("en")
? "on the " + DateFormat(DateFormat.YEAR_MONTH_DAY, AppLanguage().appLocal.toString()).format(exercise.dateAdd.toUtc())
: DateFormat(DateFormat.YEAR_MONTH_DAY, AppLanguage().appLocal.toString()).format(exercise.dateAdd.toUtc()) + "-n";
showCupertinoDialog(
useRootNavigator: true,
context: context,
//barrierDismissible: false,
builder:(_) => CupertinoAlertDialog(
title: Text(t("Are you sure to delete this exercise?")),
content: Column(
children: [
Divider(),
Text(t("Exercise") + ": " + exerciseName,
style: (TextStyle(color: Colors.blue)),),
Text(
exercise.quantity.toStringAsFixed(0) + "x" + exercise.unitQuantity.toStringAsFixed(0) + " " + exerciseType.unitQuantityUnit,
style: (TextStyle(color: Colors.deepOrange)),
),
Text(
strDate,
style: (TextStyle(color: Colors.deepOrange)),
),
]),
actions: [
FlatButton(
child: Text(t("No")),
onPressed: () => Navigator.pop(context),
),
FlatButton(
child: Text(t("Yes")),
onPressed: () => {
print("delete exercise: " + exercise.toJson().toString()),
bloc.add(ExerciseLogDelete(exercise: exercise)),
Navigator.pop(context)
},
)
],
)
);
}
}
+172 -190
View File
@@ -1,232 +1,214 @@
import 'dart:collection';
import 'package:aitrainer_app/bloc/exercise_form_bloc.dart';
import 'package:aitrainer_app/bloc/exercise_new/exercise_new_bloc.dart';
import 'package:aitrainer_app/bloc/menu/menu_bloc.dart';
import 'package:aitrainer_app/localization/app_language.dart';
import 'package:aitrainer_app/localization/app_localization.dart';
import 'package:aitrainer_app/model/cache.dart';
import 'package:aitrainer_app/model/exercise_type.dart';
import 'package:aitrainer_app/repository/exercise_repository.dart';
import 'package:aitrainer_app/util/trans.dart';
import 'package:aitrainer_app/widgets/app_bar.dart';
import 'package:flutter/services.dart';
import 'package:aitrainer_app/widgets/splash.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_form_bloc/flutter_form_bloc.dart';
import 'package:aitrainer_app/library/numberpicker.dart';
class ExerciseNewPage extends StatefulWidget{
_ExerciseNewPageState createState() => _ExerciseNewPageState();
}
class _ExerciseNewPageState extends State<ExerciseNewPage> {
class _ExerciseNewPageState extends State<ExerciseNewPage> with Trans{
@override
Widget build(BuildContext context) {
final ExerciseType exerciseType = ModalRoute.of(context).settings.arguments;
// ignore: close_sinks
final menuBloc = BlocProvider.of<MenuBloc>(context);
setContext(context);
return BlocProvider(
create: (context) => ExerciseFormBloc(exerciseRepository: ExerciseRepository(), menuBloc: menuBloc),
child: Builder(builder: (context) {
// ignore: close_sinks
final exerciseBloc = BlocProvider.of<ExerciseFormBloc>(context);
exerciseBloc.exerciseRepository.setExerciseType(exerciseType);
String exerciseName = AppLanguage().appLocal == Locale("en") ?
exerciseBloc.exerciseRepository.exerciseType.name :
exerciseBloc.exerciseRepository.exerciseType.nameTranslation;
return Form(
autovalidate: true,
child: Scaffold(
resizeToAvoidBottomInset: true,
appBar: AppBarNav(depth: 1),
body: Container(
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage('asset/image/WT_light_background.png'),
fit: BoxFit.fill,
alignment: Alignment.center,
),
),
child: Container(
padding: const EdgeInsets.only (top: 25, left:25, right: 25),
child: SingleChildScrollView(
scrollDirection: Axis.vertical,
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
Divider(color: Colors.transparent,),
Divider(color: Colors.transparent,),
Text(AppLocalizations.of(context).translate('Save Exercise'),
style: TextStyle(fontSize: 14, color: Colors.blueAccent)),
Text(exerciseName,
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 18, color: Colors.deepOrange),
overflow: TextOverflow.fade,
maxLines: 1,
softWrap: true,
),
Divider(color: Colors.transparent,),
FlatButton(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Icon(Icons.description),
Text(AppLocalizations.of(context).translate("Description"),
style: TextStyle(
color: Colors.blueAccent, fontWeight: FontWeight.normal, fontSize: 14 )),
Icon(Icons.arrow_forward_ios),
]),
textColor: Colors.blueAccent,
color: Colors.transparent,
onPressed: () => {
Navigator.of(context).pushNamed('exerciseTypeDescription', arguments: exerciseBloc.exerciseRepository),
},
),
Divider(color: Colors.transparent,),
columnQuantityUnit(exerciseBloc),
Divider(color: Colors.transparent,),
Divider(color: Colors.transparent,),
Divider(color: Colors.transparent,),
columnQuantity(exerciseBloc),
Divider(),
RaisedButton(
textColor: Colors.white,
color: Colors.deepOrange,
focusColor: Colors.white,
onPressed: () =>
{
confirmationDialog( exerciseBloc ),
},
child: Text(AppLocalizations.of(context).translate("Save"), style: TextStyle(fontSize: 16),)
),
Divider(color: Colors.transparent,),
Divider(color: Colors.transparent,),
Divider(color: Colors.transparent,),
]),
)
)
),
),
);
})
create: (context) => ExerciseNewBloc(exerciseRepository: ExerciseRepository(), menuBloc: menuBloc, exerciseType: exerciseType)..
add(ExerciseNewLoad()),
child: BlocConsumer<ExerciseNewBloc, ExerciseNewState>(
listener: (context, state) {
if ( state is ExerciseNewLoading ) {
return LoadingDialog();
} else if ( state is ExerciseNewError ) {
Scaffold.of(context).showSnackBar(SnackBar(
backgroundColor: Colors.orange,
content:
Text(state.message, style: TextStyle(color: Colors.white))));
}
},
builder: (context, state) {
final exerciseBloc = BlocProvider.of<ExerciseNewBloc>(context);
if ( state is ExerciseNewReady ) {
return getExerciseWidget(exerciseBloc, exerciseType);
} else {
return getExerciseWidget(exerciseBloc, exerciseType);
}
},
)
);
}
Column columnQuantityUnit( ExerciseFormBloc bloc ) {
Column column = Column();
if ( bloc.exerciseRepository.exerciseType != null &&
bloc.exerciseRepository.exerciseType.unitQuantity == "1") {
column = Column(
children: [
TextFieldBlocBuilder(
textFieldBloc: bloc.unitQuantityField,
textAlign: TextAlign.center,
style: TextStyle(fontSize: 30,
color: Colors.lightBlue,
fontWeight: FontWeight.bold),
inputFormatters: [
FilteringTextInputFormatter.allow(RegExp(r"[\d.]"))
],
onChanged: (input) =>
{
print("UnitQuantity value $input"),
bloc.exerciseRepository.setUnitQuantity(
double.parse(input))
},
decoration: InputDecoration(
fillColor: Colors.white,
filled: false,
hintStyle: TextStyle(fontSize: 16, color: Colors.black54, fontWeight: FontWeight.w100),
hintText: AppLocalizations.of(context).translate("The number of the exercise done with"),
labelStyle: TextStyle(fontSize: 16, color: Colors.lightBlue),
labelText: AppLocalizations.of(context).translate(
bloc.exerciseRepository.exerciseType.unitQuantityUnit),
Widget getExerciseWidget(ExerciseNewBloc exerciseBloc, ExerciseType exerciseType) {
exerciseBloc.exerciseRepository.setExerciseType(exerciseType);
String exerciseName = AppLanguage().appLocal == Locale("en") ?
exerciseBloc.exerciseRepository.exerciseType.name :
exerciseBloc.exerciseRepository.exerciseType.nameTranslation;
return Form(
autovalidate: true,
child: Scaffold(
resizeToAvoidBottomInset: true,
appBar: AppBarNav(depth: 1),
body: Container(
width: MediaQuery
.of(context)
.size
.width,
height: MediaQuery
.of(context)
.size
.height,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage('asset/image/WT_light_background.png'),
fit: BoxFit.fill,
alignment: Alignment.center,
),
),
child: Container(
padding: const EdgeInsets.only (top: 25, left: 25, right: 25),
child: SingleChildScrollView(
scrollDirection: Axis.vertical,
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
/*Divider(color: Colors.transparent,),
Divider(color: Colors.transparent,),*/
Text(t('Save Exercise'),
style: TextStyle(fontSize: 14, color: Colors.blueAccent)),
Text(exerciseName,
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 18, color: Colors.deepOrange),
overflow: TextOverflow.fade,
maxLines: 1,
softWrap: true,
),
//Divider(color: Colors.transparent,),
FlatButton(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Icon(Icons.description),
Text(t("Description"),
style: TextStyle(
color: Colors.blueAccent, fontWeight: FontWeight.normal, fontSize: 14)),
Icon(Icons.arrow_forward_ios),
]),
textColor: Colors.blueAccent,
color: Colors.transparent,
onPressed: () =>
{
Navigator.of(context).pushNamed(
'exerciseTypeDescription', arguments: exerciseBloc.exerciseRepository),
},
),
//Divider(color: Colors.transparent,),
columnQuantityUnit(exerciseBloc),
Divider(color: Colors.transparent,),
columnQuantity(exerciseBloc),
Divider(),
Divider(color: Colors.transparent,),
Divider(color: Colors.transparent,),
Divider(color: Colors.transparent,),
RaisedButton(
textColor: Colors.white,
color: Colors.deepOrange,
focusColor: Colors.white,
onPressed: () =>
{
confirmationDialog(exerciseBloc),
},
child: Text(t("Save"), style: TextStyle(fontSize: 16),)
),
]),
)
)
),
),
);
}
Row columnQuantityUnit( ExerciseNewBloc bloc ) {
Row row = Row();
if ( bloc.exerciseRepository.exerciseType != null &&
bloc.exerciseRepository.exerciseType.unitQuantity == "1") {
row = Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
NumberPicker.horizontal(
highlightSelectedValue: true,
initialValue: bloc.unitQuantity.toInt(),
minValue: 0,
maxValue: 200,
step: 1,
onChanged: (value) => {
bloc.add(ExerciseNewQuantityUnitChange(quantity: value.toDouble()))
},
listViewHeight: 80,
textStyle: TextStyle(fontSize: 24),
textStyleHighlighted: TextStyle(fontSize: 40, color: Colors.orange, fontWeight: FontWeight.bold),
//decoration: _decoration,
),
new InkWell(
child: new Text(AppLocalizations.of(context).translate(
bloc.exerciseRepository.exerciseType.unitQuantityUnit),
child: new Text(t(bloc.exerciseRepository.exerciseType.unitQuantityUnit),
style: TextStyle(fontSize: 16)),
),
]);
}
return column;
return row;
}
Column columnQuantity( ExerciseFormBloc bloc ) {
Column column = Column(
Row columnQuantity( ExerciseNewBloc bloc ) {
Row row = Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
TextFieldBlocBuilder(
textFieldBloc: bloc.quantityField,
textAlign: TextAlign.center,
style: TextStyle(fontSize: 50,
color: Colors.deepOrange,
fontWeight: FontWeight.bold),
inputFormatters: [
FilteringTextInputFormatter.allow (RegExp(r"[\d.]"))
],
onChanged: (input) =>
{
print ("Quantity value $input"),
bloc.exerciseRepository.setQuantity(double.parse(input)),
bloc.exerciseRepository.setUnit(bloc.exerciseRepository.exerciseType.unit)
NumberPicker.horizontal(
highlightSelectedValue: true,
initialValue: bloc.quantity.toInt(),
minValue: 0,
maxValue: 200,
step: 1,
onChanged: (value) => {
bloc.add(ExerciseNewQuantityChange(quantity: value.toDouble()))
},
decoration: InputDecoration(
fillColor: Colors.white,
filled: false,
hintStyle: TextStyle(fontSize: 16, color: Colors.black54, fontWeight: FontWeight.w100),
hintText: AppLocalizations.of(context).translate("The number of the exercise"),
labelStyle: TextStyle(fontSize: 16, color: Colors.deepOrange),
labelText: AppLocalizations.of(context).translate(
bloc.exerciseRepository.exerciseType.unit),
),
listViewHeight: 80,
textStyle: TextStyle(fontSize: 24),
textStyleHighlighted: TextStyle(fontSize: 40, color: Colors.orange, fontWeight: FontWeight.bold),
//decoration: _decoration,
),
Text(t(bloc.exerciseRepository.exerciseType.unit),
style: TextStyle(fontSize: 16)),
]);
return column;
return row;
}
String validateNumberInput( input ) {
String error = AppLocalizations.of(context).translate("Please type the right quantity 0-10000");
dynamic rc = ( input != null && input.length > 0);
if ( ! rc ) {
return null;
}
Pattern pattern = r'^\d+(?:\.\d+)?$';
RegExp regex = new RegExp(pattern);
if (!regex.hasMatch(input)) {
return error;
}
rc = double.tryParse(input);
if ( rc == null ) {
return error;
}
if ( ! ( double.parse(input) < 10000 && double.parse(input) > 0) ) {
return error;
}
return null;
}
void confirmationDialog( ExerciseFormBloc bloc ) {
void confirmationDialog( ExerciseNewBloc bloc ) {
LinkedHashMap args = LinkedHashMap();
print("exercise validated " + bloc.exerciseRepository.exercise.quantity.toString());
if ( bloc.exerciseRepository.exercise.quantity == null) {
@@ -250,21 +232,21 @@ class _ExerciseNewPageState extends State<ExerciseNewPage> {
context: context,
//barrierDismissible: false,
builder:(_) => CupertinoAlertDialog(
title: Text(AppLocalizations.of(context).translate("Do you save this exercise with these parameters?")),
title: Text(t("Do you save this exercise with these parameters?")),
content: Column(
children: [
Divider(),
Text(AppLocalizations.of(context).translate("Exercise") + ": " +
Text(t("Exercise") + ": " +
bloc.exerciseRepository.exerciseType.name,
style: (TextStyle(color: Colors.blue)),),
Text(quantity + " " +
AppLocalizations.of(context).translate(bloc.exerciseRepository.exerciseType.unit),
t(bloc.exerciseRepository.exerciseType.unit),
style: (TextStyle(color: Colors.deepOrange)),),
Text(bloc.exerciseRepository.exerciseType.unitQuantity == "1" ?
AppLocalizations.of(context).translate("with") + " "
t("with") + " "
+ unitQuantity + " "
+ AppLocalizations.of(context).translate(bloc.exerciseRepository.exerciseType.unitQuantityUnit) :
+ t(bloc.exerciseRepository.exerciseType.unitQuantityUnit) :
"",
style: (TextStyle(color: Colors.deepOrange)),
),
@@ -272,11 +254,11 @@ class _ExerciseNewPageState extends State<ExerciseNewPage> {
]),
actions: [
FlatButton(
child: Text(AppLocalizations.of(context).translate("No")),
child: Text(t("No")),
onPressed: () => Navigator.pop(context),
),
FlatButton(
child: Text(AppLocalizations.of(context).translate("Yes")),
child: Text(t("Yes")),
onPressed: () => {
bloc.exerciseRepository.setCustomer(Cache().userLoggedIn),
bloc.exerciseRepository.addExercise(),
+222 -121
View File
@@ -1,12 +1,14 @@
import 'dart:collection';
import 'package:aitrainer_app/bloc/exercise_plan/exercise_plan_bloc.dart';
import 'package:aitrainer_app/bloc/exercise_plan_custom_form.dart';
import 'package:aitrainer_app/bloc/exercise_plan_custom_add/exercise_plan_custom_add_bloc.dart';
import 'package:aitrainer_app/library/numberpicker.dart';
import 'package:aitrainer_app/localization/app_language.dart';
import 'package:aitrainer_app/localization/app_localization.dart';
import 'package:aitrainer_app/model/exercise_plan_detail.dart';
import 'package:aitrainer_app/model/workout_menu_tree.dart';
import 'package:aitrainer_app/repository/exercise_plan_repository.dart';
import 'package:aitrainer_app/util/trans.dart';
import 'package:aitrainer_app/widgets/app_bar.dart';
import 'package:flutter/services.dart';
import 'package:aitrainer_app/widgets/splash.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
@@ -20,130 +22,229 @@ class ExercisePlanDetailAddPage extends StatefulWidget {
class _ExercisePlanDetailAddPage extends State<ExercisePlanDetailAddPage> with Trans {
@override
Widget build(BuildContext context) {
LinkedHashMap args = ModalRoute.of(context).settings.arguments;
// ignore: close_sinks
final ExercisePlanBloc planBloc = ModalRoute.of(context).settings.arguments;
final ExercisePlanBloc planBloc = args['bloc'];
final WorkoutMenuTree workoutMenuTree = args['workoutTreeItem'];
final ExercisePlanRepository exercisePlanRepository = planBloc.exercisePlanRepository;
setContext(context);
return BlocProvider(
create: (context) =>
ExercisePlanCustomerFormBloc(exercisePlanRepository: exercisePlanRepository, planBloc: planBloc),
child: Builder(builder: (context) {
// ignore: close_sinks
final bloc = BlocProvider.of<ExercisePlanCustomerFormBloc>(context);
ExercisePlanCustomAddBloc(exercisePlanRepository: exercisePlanRepository, planBloc: planBloc, workoutMenuTree: workoutMenuTree)
..add(ExercisePlanCustomAddLoad()),
child: BlocConsumer<ExercisePlanCustomAddBloc, ExercisePlanCustomAddState>(
listener: (context, state) {
if (state is ExercisePlanCustomAddLoading) {
return LoadingDialog();
} else if (state is ExercisePlanCustomAddError) {
Scaffold.of(context).showSnackBar(SnackBar(
backgroundColor: Colors.orange, content: Text(state.message, style: TextStyle(color: Colors.white))));
}
},
builder: (context, state) {
// ignore: close_sinks
final bloc = BlocProvider.of<ExercisePlanCustomAddBloc>(context);
return getForm(bloc, workoutMenuTree);
},
));
}
String exerciseName = "";
if (bloc != null) {
exerciseName = AppLanguage().appLocal == Locale("en")
? bloc.exercisePlanRepository.getActualPlanDetail().exerciseType.name
: bloc.exercisePlanRepository.getActualPlanDetail().exerciseType.nameTranslation;
}
return Form(
autovalidate: true,
child: Scaffold(
resizeToAvoidBottomInset: true,
appBar: AppBarNav(depth: 1),
body: Container(
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage('asset/image/WT_light_background.png'),
fit: BoxFit.fill,
alignment: Alignment.center,
),
),
child: Container(
padding: const EdgeInsets.only(top: 25, left: 25, right: 25),
child: SingleChildScrollView(
scrollDirection: Axis.vertical,
child: Column(mainAxisAlignment: MainAxisAlignment.spaceAround, children: <Widget>[
Text(AppLocalizations.of(context).translate('Save The Exercise To The Exercise Plan'),
style: TextStyle(fontSize: 14, color: Colors.blueAccent)),
Text(
exerciseName,
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 18, color: Colors.deepOrange),
overflow: TextOverflow.fade,
maxLines: 1,
softWrap: true,
),
TextFieldBlocBuilder(
textFieldBloc: bloc.serieField,
textAlign: TextAlign.center,
style: TextStyle(fontSize: 30, color: Colors.lightBlue, fontWeight: FontWeight.bold),
inputFormatters: [FilteringTextInputFormatter.allow(RegExp(r"[\d.]"))],
decoration: InputDecoration(
fillColor: Colors.white,
filled: false,
hintStyle: TextStyle(fontSize: 16, color: Colors.black54, fontWeight: FontWeight.w100),
hintText: AppLocalizations.of(context).translate("The number of the serie done with"),
labelStyle: TextStyle(fontSize: 16, color: Colors.lightBlue),
labelText: AppLocalizations.of(context).translate("Serie"),
),
),
TextFieldBlocBuilder(
textFieldBloc: bloc.quantityField,
textAlign: TextAlign.center,
style: TextStyle(fontSize: 30, color: Colors.lightBlue, fontWeight: FontWeight.bold),
inputFormatters: [FilteringTextInputFormatter.allow(RegExp(r"[\d.]"))],
decoration: InputDecoration(
fillColor: Colors.white,
filled: false,
hintStyle: TextStyle(fontSize: 16, color: Colors.black54, fontWeight: FontWeight.w100),
hintText:
AppLocalizations.of(context).translate("The number of the repeats of one serie"),
labelStyle: TextStyle(fontSize: 16, color: Colors.lightBlue),
labelText: AppLocalizations.of(context).translate("Repeats"),
),
),
TextFieldBlocBuilder(
textFieldBloc: bloc.weightField,
textAlign: TextAlign.center,
style: TextStyle(fontSize: 30, color: Colors.lightBlue, fontWeight: FontWeight.bold),
inputFormatters: [FilteringTextInputFormatter.allow(RegExp(r"[\d.]"))],
decoration: InputDecoration(
fillColor: Colors.white,
filled: false,
hintStyle: TextStyle(fontSize: 16, color: Colors.black54, fontWeight: FontWeight.w100),
hintText: AppLocalizations.of(context).translate("The weight"),
labelStyle: TextStyle(fontSize: 16, color: Colors.lightBlue),
labelText: AppLocalizations.of(context).translate("Weight"),
),
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
RaisedButton(
textColor: Colors.white,
color: Colors.red.shade300,
focusColor: Colors.white,
onPressed: () => {
print("Remove " + bloc.exercisePlanRepository.getActualPlanDetail().exerciseType.name),
bloc.exercisePlanRepository.getActualPlanDetail().change = ExercisePlanDetailChange.delete,
planBloc.add(ExercisePlanRemoveExercise(
exercisePlanDetail: bloc.exercisePlanRepository.getActualPlanDetail() )),
Navigator.of(context).pop(),
},
child: Text(t(
"Delete")), //Text(AppLocalizations.of(context).translate("Delete"), style: TextStyle(fontSize: 16),)
),
RaisedButton(
textColor: Colors.white,
color: Colors.blueAccent,
focusColor: Colors.white,
onPressed: () => {
bloc.submit(),
Navigator.of(context).pop(),
},
child: Text(t("Save"), style: TextStyle(fontSize: 16),
)),
],
),
]),
))),
Widget getForm(ExercisePlanCustomAddBloc bloc, WorkoutMenuTree workoutMenuTree) {
String exerciseName = "";
if (bloc != null) {
exerciseName = AppLanguage().appLocal == Locale("en")
? bloc.exercisePlanRepository.getActualPlanDetail().exerciseType.name
: bloc.exercisePlanRepository.getActualPlanDetail().exerciseType.nameTranslation;
}
return Form(
autovalidate: true,
child: Scaffold(
resizeToAvoidBottomInset: true,
appBar: AppBarNav(depth: 1),
body: Container(
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage('asset/image/WT_light_background.png'),
fit: BoxFit.fill,
alignment: Alignment.center,
),
),
);
}));
child: Container(
padding: const EdgeInsets.only(top: 25, left: 25, right: 25),
child: SingleChildScrollView(
scrollDirection: Axis.vertical,
child: Column(mainAxisAlignment: MainAxisAlignment.spaceAround, children: <Widget>[
Text(t('Save The Exercise To The Exercise Plan'),
style: TextStyle(fontSize: 14, color: Colors.blueAccent)),
Text(
exerciseName,
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 18, color: Colors.deepOrange),
overflow: TextOverflow.fade,
maxLines: 1,
softWrap: true,
),
Divider(color: Colors.transparent,height: 30,),
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Flexible(
fit: FlexFit.tight,
flex: 8,
child:
Text(t("Serie")),
),
NumberPicker.horizontal(
highlightSelectedValue: true,
initialValue: bloc.serie.toInt(),
minValue: 0,
maxValue: 200,
step: 1,
onChanged: (value) => {
bloc.add(ExercisePlanCustomAddChangeSerie(quantity: value.toDouble()))
},
listViewHeight: 80,
textStyle: TextStyle(fontSize: 24),
textStyleHighlighted: TextStyle(fontSize: 40, color: Colors.orange, fontWeight: FontWeight.bold),
//decoration: _decoration,
),
]
),
Divider(),
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Flexible(
fit: FlexFit.tight,
flex: 8,
child:
Text(t("Weight") + " (" + bloc.exercisePlanRepository.getActualPlanDetail().exerciseType.unitQuantityUnit + ")"),
),
NumberPicker.horizontal(
highlightSelectedValue: true,
initialValue: bloc.quantityUnit.toInt(),
minValue: 0,
maxValue: 200,
step: 1,
onChanged: (value) => {
bloc.add(ExercisePlanCustomAddChangeQuantityUnit(quantity: value.toDouble()))
},
listViewHeight: 80,
textStyle: TextStyle(fontSize: 24),
textStyleHighlighted: TextStyle(fontSize: 40, color: Colors.orange, fontWeight: FontWeight.bold),
//decoration: _decoration,
),
]),
Divider(),
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Flexible(
fit: FlexFit.tight,
flex: 8,
child:
Text(t("Repeats")),
),
NumberPicker.horizontal(
highlightSelectedValue: true,
initialValue: bloc.quantity.toInt(),
minValue: 0,
maxValue: 200,
step: 1,
onChanged: (value) => {
bloc.add(ExercisePlanCustomAddChangeQuantity(quantity: value.toDouble()))
},
listViewHeight: 80,
textStyle: TextStyle(fontSize: 24),
textStyleHighlighted: TextStyle(fontSize: 40, color: Colors.orange, fontWeight: FontWeight.bold),
//decoration: _decoration,
),
]),
Divider(),
/*TextFieldBlocBuilder(
textFieldBloc: bloc.serieField,
textAlign: TextAlign.center,
style: TextStyle(fontSize: 30, color: Colors.lightBlue, fontWeight: FontWeight.bold),
inputFormatters: [FilteringTextInputFormatter.allow(RegExp(r"[\d.]"))],
decoration: InputDecoration(
fillColor: Colors.white,
filled: false,
hintStyle: TextStyle(fontSize: 16, color: Colors.black54, fontWeight: FontWeight.w100),
hintText: AppLocalizations.of(context).translate("The number of the serie done with"),
labelStyle: TextStyle(fontSize: 16, color: Colors.lightBlue),
labelText: AppLocalizations.of(context).translate("Serie"),
),
),*/
/*TextFieldBlocBuilder(
textFieldBloc: bloc.quantityField,
textAlign: TextAlign.center,
style: TextStyle(fontSize: 30, color: Colors.lightBlue, fontWeight: FontWeight.bold),
inputFormatters: [FilteringTextInputFormatter.allow(RegExp(r"[\d.]"))],
decoration: InputDecoration(
fillColor: Colors.white,
filled: false,
hintStyle: TextStyle(fontSize: 16, color: Colors.black54, fontWeight: FontWeight.w100),
hintText:
AppLocalizations.of(context).translate("The number of the repeats of one serie"),
labelStyle: TextStyle(fontSize: 16, color: Colors.lightBlue),
labelText: AppLocalizations.of(context).translate("Repeats"),
),
),*/
/*TextFieldBlocBuilder(
textFieldBloc: bloc.weightField,
textAlign: TextAlign.center,
style: TextStyle(fontSize: 30, color: Colors.lightBlue, fontWeight: FontWeight.bold),
inputFormatters: [FilteringTextInputFormatter.allow(RegExp(r"[\d.]"))],
decoration: InputDecoration(
fillColor: Colors.white,
filled: false,
hintStyle: TextStyle(fontSize: 16, color: Colors.black54, fontWeight: FontWeight.w100),
hintText: AppLocalizations.of(context).translate("The weight"),
labelStyle: TextStyle(fontSize: 16, color: Colors.lightBlue),
labelText: AppLocalizations.of(context).translate("Weight"),
),
),*/
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
RaisedButton(
textColor: Colors.white,
color: Colors.red.shade300,
focusColor: Colors.white,
onPressed: () => {
bloc.add(ExercisePlanCustomAddRemove()),
Navigator.of(context).pop(),
/*print("Remove " + bloc.exercisePlanRepository.getActualPlanDetail().exerciseType.name),
bloc.exercisePlanRepository.getActualPlanDetail().change = ExercisePlanDetailChange.delete,
planBloc.add(ExercisePlanRemoveExercise(
exercisePlanDetail: bloc.exercisePlanRepository.getActualPlanDetail() )),
Navigator.of(context).pop(),*/
},
child: Text(t(
"Delete")), //Text(AppLocalizations.of(context).translate("Delete"), style: TextStyle(fontSize: 16),)
),
RaisedButton(
textColor: Colors.white,
color: Colors.blueAccent,
focusColor: Colors.white,
onPressed: () => {
bloc.add(ExercisePlanCustomAddSubmit()),
Navigator.of(context).pop(),
/* bloc.submit(),
Navigator.of(context).pop(),*/
},
child: Text(
t("Save"),
style: TextStyle(fontSize: 16),
)),
],
),
]),
))),
),
);
}
}
+17 -16
View File
@@ -50,7 +50,7 @@ class _ExercisePlanCustomPage extends State<ExercisePlanCustomPage> with Trans {
padding: EdgeInsets.all(20),
decoration: BoxDecoration(
image: DecorationImage(
image: customerId == Cache().userLoggedIn.customerId ? AssetImage('asset/image/WT_light_background.png'):
image: customerId == Cache().userLoggedIn.customerId ? AssetImage('asset/image/WT_menu_dark.png'):
AssetImage('asset/image/WT_menu_dark.png'),
fit: BoxFit.cover,
alignment: Alignment.center,
@@ -157,14 +157,14 @@ class _ExercisePlanCustomPage extends State<ExercisePlanCustomPage> with Trans {
mainAxisAlignment: MainAxisAlignment.start,
children: [
IconButton(
icon: element.selected ? Icon(Icons.check, color: Colors.greenAccent.shade700,) : Icon(Icons.add, color: Colors.blue.shade400,),
onPressed: () => {
bloc.add(ExercisePlanUpdateUI(workoutTree: element)),
Navigator.of(context).pushNamed("exercisePlanDetailAdd", arguments: bloc),
},
icon: element.selected ? Icon(Icons.check, color: Colors.greenAccent.shade700,)
: Icon(Icons.add, color: Colors.blue.shade400,),
onPressed: () => clickAddDetail(bloc, element),
),
SizedBox(width: 20),
SizedBox(width: 10),
Flexible(
fit: FlexFit.tight,
flex: 8,
child:
InkWell(
child:
@@ -173,10 +173,7 @@ class _ExercisePlanCustomPage extends State<ExercisePlanCustomPage> with Trans {
textAlign: TextAlign.start,
style: TextStyle(fontSize: 12, color: Colors.black),
),
onTap: () => {
bloc.add(ExercisePlanUpdateUI(workoutTree: element)),
Navigator.of(context).pushNamed("exercisePlanDetailAdd", arguments: bloc),
},
onTap: () => clickAddDetail(bloc, element),
),
),
InkWell(
@@ -186,15 +183,12 @@ class _ExercisePlanCustomPage extends State<ExercisePlanCustomPage> with Trans {
Text(bloc.exercisePlanRepository.exercisePlanDetails[element.exerciseTypeId].repeats.toString() +
" x " + bloc.exercisePlanRepository.exercisePlanDetails[element.exerciseTypeId].weightEquation +
" " + element.exerciseType.unitQuantityUnit, style: TextStyle(fontSize: 9, color: Colors.green),),
onTap: () => {
bloc.add(ExercisePlanUpdateUI(workoutTree: element)),
Navigator.of(context).pushNamed("exercisePlanDetailAdd", arguments: bloc),
},
onTap: () => clickAddDetail(bloc, element),
),
IconButton(
padding: EdgeInsets.all(0),
icon: Icon(Icons.description, color: Colors.black12,),
icon: Icon(Icons.info, color: Colors.black12,),
onPressed: () {
},
@@ -211,4 +205,11 @@ class _ExercisePlanCustomPage extends State<ExercisePlanCustomPage> with Trans {
});
return list;
}
void clickAddDetail(ExercisePlanBloc bloc, WorkoutMenuTree workoutMenuTree) {
final LinkedHashMap args = LinkedHashMap();
args['bloc'] = bloc;
args['workoutTreeItem'] = workoutMenuTree;
Navigator.of(context).pushNamed("exercisePlanDetailAdd", arguments: args);
}
}
+1
View File
@@ -27,6 +27,7 @@ class _MenuPage extends State<MenuPage> {
@override
Widget build(BuildContext context) {
menuBloc = BlocProvider.of<MenuBloc>(context);
menuBloc.parent = widget.parent;
return Scaffold(
appBar: AppBarNav(isMenu: true,),
body: Container(
+2 -2
View File
@@ -268,7 +268,7 @@ class _MyDevelopmentMuscleState extends State<MyDevelopmentMusclePage> with Comm
show: true,
bottomTitles: SideTitles(
showTitles: true,
textStyle: TextStyle(fontSize: 8, color: Colors.blueGrey),
getTextStyles: (_) => TextStyle(fontSize: 8, color: Colors.blueGrey),
getTitles: (double value) {
var date = new DateTime.fromMillisecondsSinceEpoch(value.toInt());
//String strDate = DateFormat('MM.dd.', AppLanguage().appLocal.toString()).format(date);
@@ -278,7 +278,7 @@ class _MyDevelopmentMuscleState extends State<MyDevelopmentMusclePage> with Comm
),
leftTitles: SideTitles(
showTitles: true,
textStyle: TextStyle(fontSize: 8, color: Colors.blueGrey),
getTextStyles: (_) => TextStyle(fontSize: 8, color: Colors.blueGrey),
interval: bloc.listChartData[element.exerciseTypeId] == null
? 100
: bloc.listChartData[element.exerciseTypeId].interval,
+19 -101
View File
@@ -26,10 +26,10 @@ class _MyDevelopmentPage extends State<MyDevelopmentPage> with Trans {
return Scaffold(
appBar: AppBarNav(depth: 0),
body: Container(
padding: EdgeInsets.all(20),
padding: EdgeInsets.all(10),
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage('asset/image/WT_light_background.png'),
image: AssetImage('asset/image/WT_menu_dark.png'),
fit: BoxFit.cover,
alignment: Alignment.center,
),
@@ -44,61 +44,22 @@ class _MyDevelopmentPage extends State<MyDevelopmentPage> with Trans {
ImageButton(
textAlignment: Alignment.topCenter,
text: t("My Exercise Logs"),
style: TextStyle(fontSize: 20, color: Colors.orange, fontWeight: FontWeight.bold, backgroundColor: Colors.black54.withOpacity(0.4)),
image: "asset/image/exercise_log.jpg",
top: 40,
style: TextStyle(fontSize: 16, color: Colors.orange, fontWeight: FontWeight.bold, backgroundColor: Colors.black54.withOpacity(0.4)),
image: "asset/image/edzesnaplom400400.jpg",
top: 150,
left: 15,
onTap:() => this.callBackExerciseLog(exerciseRepository, customerRepository),
isLocked: false,
),
/*FlatButton(
padding: EdgeInsets.all(0),
textColor: Colors.white,
color: Colors.black12,
focusColor: Colors.blueAccent,
onPressed: () =>
{
args['exerciseRepository'] = exerciseRepository,
args['customerRepository'] = customerRepository,
args['customerId'] = Cache().userLoggedIn.customerId,
Navigator.of(context).pushNamed('exerciseLogPage',
arguments: args)
},
child: Text(t("My Exercise Logs"),
style: TextStyle(fontSize: 18),)
),*/
/*Stack(
fit: StackFit.passthrough,
overflow: Overflow.clip,
alignment: Alignment.topLeft,
children: [
Image.asset('asset/image/lock.png',
height: 40,
width: 40,
),
FlatButton(
padding: EdgeInsets.all(20),
textColor: Colors.white,
color: Colors.black12,
focusColor: Colors.blueAccent,
onPressed: () =>
{
args['customerId'] = Cache().userLoggedIn.customerId,
Navigator.of(context).pushNamed('mydevelopmentBodyPage',
arguments: args)
},
child: Text(t("My Whole Body Development"),
style: TextStyle(fontSize: 18),)
),
],
),*/
ImageButton(
textAlignment: Alignment.topLeft,
text: t("My Whole Body Development"),
style: TextStyle(fontSize: 20, color: Colors.orange, fontWeight: FontWeight.bold,
style: TextStyle(fontSize: 16, color: Colors.orange, fontWeight: FontWeight.bold,
backgroundColor: Colors.black54.withOpacity(0.4)),
image: "asset/menu/3.1.BMI.png",
top: 50,
image: "asset/image/testemfejl400x400.jpg",
top: 150,
left: 15,
onTap:() => {
args['customerId'] = Cache().userLoggedIn.customerId,
Navigator.of(context).pushNamed('mydevelopmentBodyPage',
@@ -109,82 +70,39 @@ class _MyDevelopmentPage extends State<MyDevelopmentPage> with Trans {
ImageButton(
textAlignment: Alignment.topLeft,
text: t("Development Of Muscles"),
style: TextStyle(fontSize: 20, color: Colors.orange, fontWeight: FontWeight.bold,
style: TextStyle(fontSize: 16, color: Colors.orange, fontWeight: FontWeight.bold,
backgroundColor: Colors.black54.withOpacity(0.4)),
image: "asset/image/development_muscles.jpg",
top: 50,
image: "asset/image/izomcsop400400.jpg",
top: 120,
left: 10,
onTap:() => {
Navigator.of(context).pushNamed('mydevelopmentMusclePage',
arguments: args)
},
isLocked: true,
),
/*Stack(
fit: StackFit.passthrough,
overflow: Overflow.clip,
children: [
*//*Image.asset('asset/image/lock.png',
height: 40,
width: 40,
),*//*
FlatButton(
padding: EdgeInsets.all(20),
textColor: Colors.white,
color: Colors.black12,
focusColor: Colors.blueAccent,
onPressed: () =>
{
Navigator.of(context).pushNamed('mydevelopmentMusclePage',
arguments: args)
},
child: Text(t("Development Of Muscles"),
style: TextStyle(fontSize: 18),)
),
]
),*/
ImageButton(
textAlignment: Alignment.topLeft,
text: t("Predictions"),
style: TextStyle(fontSize: 20, color: Colors.orange, fontWeight: FontWeight.bold,
style: TextStyle(fontSize: 16, color: Colors.orange, fontWeight: FontWeight.bold,
backgroundColor: Colors.black54.withOpacity(0.4)),
image: "asset/menu/2.2.1.1RM.png",
top: 50,
top: 150,
onTap:() => {
},
isLocked: true,
),
/*Stack(
fit: StackFit.passthrough,
overflow: Overflow.clip,
children: [
Image.asset('asset/image/lock.png',
height: 40,
width: 40,
),
FlatButton(
padding: EdgeInsets.all(20),
textColor: Colors.white,
color: Colors.black12,
focusColor: Colors.blueAccent,
onPressed: () =>
{
},
child: Text(t("Predictions"),
style: TextStyle(fontSize: 18),)
),
]
),*/
hiddenWidget(customerRepository, exerciseRepository),
]
),
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
mainAxisSpacing: 20.0,
crossAxisSpacing: 20.0,
childAspectRatio: 1.2,
mainAxisSpacing: 15.0,
crossAxisSpacing: 15.0,
childAspectRatio: 1.0,
),
)
]
+64 -78
View File
@@ -4,6 +4,7 @@ import 'package:aitrainer_app/repository/exercise_repository.dart';
import 'package:aitrainer_app/util/trans.dart';
import 'package:aitrainer_app/widgets/app_bar.dart';
import 'package:aitrainer_app/widgets/bottom_nav.dart';
import 'package:aitrainer_app/widgets/image_button.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
@@ -25,7 +26,7 @@ class _MyExercisePlanPage extends State<MyExercisePlanPage> with Trans {
padding: EdgeInsets.all(20),
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage('asset/image/WT_light_background.png'),
image: AssetImage('asset/image/WT_menu_dark.png'),
fit: BoxFit.cover,
alignment: Alignment.center,
),
@@ -37,97 +38,82 @@ class _MyExercisePlanPage extends State<MyExercisePlanPage> with Trans {
SliverGrid(
delegate: SliverChildListDelegate(
[
FlatButton(
padding: EdgeInsets.all(10),
textColor: Colors.white,
color: Colors.black12,
focusColor: Colors.blueAccent,
onPressed: () =>
{
ImageButton(
textAlignment: Alignment.topLeft,
text: t("Execute My Selected Training Plan"),
style: TextStyle(fontSize: 14, color: Colors.orange, fontWeight: FontWeight.bold,
backgroundColor: Colors.black54.withOpacity(0.4)),
image: "asset/image/exercise_plan_execute.jpg",
top: 150,
left: 15,
onTap:() => {
args['customerId'] = Cache().userLoggedIn.customerId,
Navigator.of(context).pushNamed('exerciseByPlanPage',
Navigator.of(context).pushNamed('exerciseExecutePlanPage',
arguments: args)
},
child: Text(t("Execute My Selected Training Plan"),
style: TextStyle(fontSize: 18),)
isLocked: false,
),
FlatButton(
padding: EdgeInsets.all(0),
textColor: Colors.white,
color: Colors.black12,
focusColor: Colors.blueAccent,
onPressed: () =>
{
ImageButton(
textAlignment: Alignment.topLeft,
text: t("Edit My Custom Plan"),
style: TextStyle(fontSize: 14, color: Colors.orange, fontWeight: FontWeight.bold,
backgroundColor: Colors.black54.withOpacity(0.4)),
image: "asset/image/exercise_plan_custom.jpg",
top: 150,
left: 15,
onTap:() => {
args['exerciseRepository'] = exerciseRepository,
args['customerId'] = Cache().userLoggedIn.customerId,
Navigator.of(context).pushNamed('exercisePlanCustomPage',
arguments: args)
},
child: Text(t("Edit My Custom Plan"),
style: TextStyle(fontSize: 18),)
isLocked: false,
),
FlatButton(
padding: EdgeInsets.all(20),
textColor: Colors.white,
color: Colors.black12,
focusColor: Colors.blueAccent,
onPressed: () =>
{
ImageButton(
textAlignment: Alignment.topLeft,
text: t("Suggested Training Plan"),
style: TextStyle(fontSize: 14, color: Colors.orange, fontWeight: FontWeight.bold,
backgroundColor: Colors.black54.withOpacity(0.4)),
image: "asset/image/exercise_plan_suggested.jpg",
top: 150,
left: 10,
onTap:() => {
},
child: Text(t("Suggested Training Plan"),
style: TextStyle(fontSize: 18),)
),
Stack(
fit: StackFit.passthrough,
overflow: Overflow.clip,
alignment: Alignment.topLeft,
children: [
Image.asset('asset/image/lock.png',
height: 40,
width: 40,
),
FlatButton(
padding: EdgeInsets.all(20),
textColor: Colors.white,
color: Colors.black12,
focusColor: Colors.blueAccent,
onPressed: () =>
{
},
child: Text(t("My Special Plan"),
style: TextStyle(fontSize: 18),)
),
],
isLocked: true,
),
Stack(
fit: StackFit.passthrough,
overflow: Overflow.clip,
children: [
Image.asset('asset/image/lock.png',
height: 40,
width: 40,
),
FlatButton(
padding: EdgeInsets.all(20),
textColor: Colors.white,
color: Colors.black12,
focusColor: Colors.blueAccent,
onPressed: () =>
{
ImageButton(
textAlignment: Alignment.topLeft,
text: t("My Special Plan"),
style: TextStyle(fontSize: 16, color: Colors.orange, fontWeight: FontWeight.bold,
backgroundColor: Colors.black54.withOpacity(0.4)),
image: "asset/image/exercise_plan_special.jpg",
top: 150,
left: 10,
onTap:() => {
},
child: Text(t("My Arnold's Plan"),
style: TextStyle(fontSize: 18),)
),
]
},
isLocked: true,
),
ImageButton(
textAlignment: Alignment.topLeft,
text: t("My Arnold's Plan"),
style: TextStyle(fontSize: 14, color: Colors.orange, fontWeight: FontWeight.bold,
backgroundColor: Colors.black54.withOpacity(0.4)),
image: "asset/image/exercise_plan_stars.jpg",
top: 120,
left: 10,
onTap:() => {
},
isLocked: true,
),
hiddenPlanWidget(exerciseRepository),
hiddenTrainingWidget(),
@@ -136,9 +122,9 @@ class _MyExercisePlanPage extends State<MyExercisePlanPage> with Trans {
),
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
mainAxisSpacing: 20.0,
crossAxisSpacing: 20.0,
childAspectRatio: 1.2,
mainAxisSpacing: 15.0,
crossAxisSpacing: 15.0,
childAspectRatio: 1.0,
),
)
]
@@ -182,7 +168,7 @@ class _MyExercisePlanPage extends State<MyExercisePlanPage> with Trans {
onPressed: () =>
{
args['customerId'] = Cache().getTrainee().customerId,
Navigator.of(context).pushNamed('exerciseByPlanPage',
Navigator.of(context).pushNamed('exerciseExecutePlanPage',
arguments: args)
},
child: Text(t("Execute My Trainee's Training Plan"),
-7
View File
@@ -108,13 +108,6 @@ class SettingsPage extends StatelessWidget{
)
),
ListTile(
leading: Icon(Icons.get_app),
title: RaisedButton(
child: Text("Check lang", style: TextStyle(fontSize: 12),),
onPressed: () => settingsBloc.add(SettingsGetLanguage()),
)
)
]
);
}