wt1.1b exercise description, bug fixing + custom exercise fix
This commit is contained in:
parent
4d9f2e5152
commit
e938f1be8c
@ -50,7 +50,7 @@
|
||||
"BMI": "BMI",
|
||||
"BMR": "BMR",
|
||||
"Sizes": "Sizes",
|
||||
"Save Exercise": "save Exercise",
|
||||
"Save Exercise": "Save Exercise of:",
|
||||
"Save": "Save",
|
||||
|
||||
"Name": "Name",
|
||||
@ -103,5 +103,7 @@
|
||||
"Your Body Type": "Your Body Type",
|
||||
"Ectomorph": "Ectomorph",
|
||||
"Endomorph": "Endomorph",
|
||||
"Mesomorph": "Mesomorph"
|
||||
"Mesomorph": "Mesomorph",
|
||||
|
||||
"Description": "Description"
|
||||
}
|
@ -50,7 +50,7 @@
|
||||
"BMI": "Testtömegindex",
|
||||
"BMR": "Alapanyagcsere",
|
||||
"Sizes": "Méretek",
|
||||
"Save Exercise": "gyakorlat mentése",
|
||||
"Save Exercise": "Gyakorlat mentése:",
|
||||
"Save": "Mentés",
|
||||
"The number of the exercise": "Írd be a gyakorlat számát",
|
||||
"The number of the exercise done with": "Írd be, mennyivel csináltad a gyakorlatot",
|
||||
@ -103,6 +103,8 @@
|
||||
"Your Body Type": "Milyen a testtípusod?",
|
||||
"Ectomorph": "Ectomorf",
|
||||
"Endomorph":"Endomorf",
|
||||
"Mesomorph":"Mezomorf"
|
||||
"Mesomorph":"Mezomorf",
|
||||
|
||||
"Description": "Leírás"
|
||||
|
||||
}
|
@ -39,5 +39,25 @@
|
||||
</array>
|
||||
<key>UIViewControllerBasedStatusBarAppearance</key>
|
||||
<false/>
|
||||
<key>CFBundleURLTypes</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>CFBundleURLSchemes</key>
|
||||
<array>
|
||||
<string>fb584181112271127</string>
|
||||
</array>
|
||||
</dict>
|
||||
</array>
|
||||
<key>FacebookAppID</key>
|
||||
<string>584181112271127</string>
|
||||
<key>FacebookDisplayName</key>
|
||||
<string>Mobile Login</string>
|
||||
<key>LSApplicationQueriesSchemes</key>
|
||||
<array>
|
||||
<string>fbapi</string>
|
||||
<string>fb-messenger-share-api</string>
|
||||
<string>fbauth2</string>
|
||||
<string>fbshareextension</string>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
||||
|
@ -19,14 +19,15 @@ class CustomExerciseFormBloc extends FormBloc<String, String> {
|
||||
|
||||
//1RM calculated Fields
|
||||
final rmWendlerField = TextFieldBloc( initialValue: "0",);
|
||||
final rmMcGothlinField = TextFieldBloc( initialValue: "0");
|
||||
final rmLombardiField = TextFieldBloc( initialValue: "0");
|
||||
final rmMayhewField = TextFieldBloc( initialValue: "0");
|
||||
final rmOconnerField = TextFieldBloc( initialValue: "0");
|
||||
final rmWathenField = TextFieldBloc( initialValue: "0");
|
||||
final rmAverageField = TextFieldBloc( initialValue: "0");
|
||||
final rm90Field = TextFieldBloc( initialValue: "0");
|
||||
final rm80Field = TextFieldBloc( initialValue: "0");
|
||||
final rm75Field = TextFieldBloc( initialValue: "0");
|
||||
final rm75WendlerField = TextFieldBloc( initialValue: "0");
|
||||
final rm75OconnorField = TextFieldBloc( initialValue: "0");
|
||||
final rm70Field = TextFieldBloc( initialValue: "0");
|
||||
final rm60Field = TextFieldBloc( initialValue: "0");
|
||||
final rm50Field = TextFieldBloc( initialValue: "0");
|
||||
@ -36,8 +37,6 @@ class CustomExerciseFormBloc extends FormBloc<String, String> {
|
||||
quantityField,
|
||||
unitQuantityField,
|
||||
rmWendlerField,
|
||||
rmMcGothlinField,
|
||||
rmLombardiField,
|
||||
rmMayhewField,
|
||||
rmOconnerField,
|
||||
rmWathenField,
|
||||
@ -45,6 +44,9 @@ class CustomExerciseFormBloc extends FormBloc<String, String> {
|
||||
rm90Field,
|
||||
rm80Field,
|
||||
rm70Field,
|
||||
rm75Field,
|
||||
rm75WendlerField,
|
||||
rm75OconnorField,
|
||||
rm60Field,
|
||||
rm50Field
|
||||
]);
|
||||
@ -81,28 +83,27 @@ class CustomExerciseFormBloc extends FormBloc<String, String> {
|
||||
}
|
||||
print("Calculating 1RM");
|
||||
exerciseRepository.rmWendler = weight * repeat * 0.0333 + weight;
|
||||
rmWendlerField.updateValue(exerciseRepository.rmWendler.toString());
|
||||
exerciseRepository.rmMcglothlin = 100 * weight / (101.3 - 2.67123 * repeat);
|
||||
rmMcGothlinField.updateValue(exerciseRepository.rmMcglothlin.toString());
|
||||
exerciseRepository.rmLombardi = pow(weight * repeat, 0.1);
|
||||
rmLombardiField.updateValue(exerciseRepository.rmLombardi.toString());
|
||||
rmWendlerField.updateValue(exerciseRepository.rmWendler.toStringAsFixed(1));
|
||||
exerciseRepository.rmOconner = weight * (1 + repeat / 40);
|
||||
rmOconnerField.updateValue(exerciseRepository.rmOconner.toString());
|
||||
rmOconnerField.updateValue(exerciseRepository.rmOconner.toStringAsFixed(1));
|
||||
exerciseRepository.rmMayhew =
|
||||
100 * weight / (52.2 + 41.9 * pow(e, -0.055 * repeat));
|
||||
rmMayhewField.updateValue(exerciseRepository.rmMayhew.toString());
|
||||
rmMayhewField.updateValue(exerciseRepository.rmMayhew.toStringAsFixed(1));
|
||||
exerciseRepository.rmWathen =
|
||||
100 * weight / (48.8 + 53.8 * pow(e, -0.075 * repeat));
|
||||
rmWathenField.updateValue(exerciseRepository.rmWathen.toString());
|
||||
rmWathenField.updateValue(exerciseRepository.rmWathen.toStringAsFixed(1));
|
||||
double average = (exerciseRepository.rmWendler + exerciseRepository.rmWathen +
|
||||
exerciseRepository.rmMayhew + exerciseRepository.rmOconner +
|
||||
exerciseRepository.rmMcglothlin)/5;
|
||||
rmAverageField.updateValue(average.toString());
|
||||
rm90Field.updateValue((average*0.9).toString());
|
||||
rm80Field.updateValue((average*0.8).toString());
|
||||
rm70Field.updateValue((average*0.7).toString());
|
||||
rm60Field.updateValue((average*0.6).toString());
|
||||
rm50Field.updateValue((average*0.5).toString());
|
||||
exerciseRepository.rmMcglothlin)/4;
|
||||
rmAverageField.updateValue(average.toStringAsFixed(1));
|
||||
rm90Field.updateValue((average*0.9).toStringAsFixed(1));
|
||||
rm80Field.updateValue((average*0.8).toStringAsFixed(1));
|
||||
rm75Field.updateValue((average*0.75).toStringAsFixed(1));
|
||||
rm75OconnorField.updateValue((exerciseRepository.rmOconner*0.75).toStringAsFixed(1));
|
||||
rm75WendlerField.updateValue((exerciseRepository.rmWendler*0.75).toStringAsFixed(1));
|
||||
rm70Field.updateValue((average*0.7).toStringAsFixed(1));
|
||||
rm60Field.updateValue((average*0.6).toStringAsFixed(1));
|
||||
rm50Field.updateValue((average*0.5).toStringAsFixed(1));
|
||||
}
|
||||
|
||||
//@override
|
||||
@ -111,14 +112,15 @@ class CustomExerciseFormBloc extends FormBloc<String, String> {
|
||||
unitQuantityField.close();
|
||||
|
||||
rmWendlerField.close();
|
||||
rmMcGothlinField.close();
|
||||
rmLombardiField.close();
|
||||
rmMayhewField.close();
|
||||
rmOconnerField.close();
|
||||
rmWathenField.close();
|
||||
rmAverageField.close();
|
||||
rm90Field.close();
|
||||
rm80Field.close();
|
||||
rm75WendlerField.close();
|
||||
rm75OconnorField.close();
|
||||
rm75Field.close();
|
||||
rm70Field.close();
|
||||
rm60Field.close();
|
||||
rm50Field.close();
|
||||
|
@ -26,6 +26,10 @@ class MenuBloc extends Bloc<MenuEvent, MenuState> {
|
||||
yield MenuLoading();
|
||||
await menuTreeRepository.createTree();
|
||||
yield MenuReady();
|
||||
} else if (event is MenuRecreateTree) {
|
||||
// ie. at language changes
|
||||
await menuTreeRepository.createTree();
|
||||
yield MenuReady();
|
||||
} else if (event is MenuTreeDown) {
|
||||
// get child menus or exercises
|
||||
yield MenuLoading();
|
||||
|
@ -39,3 +39,7 @@ class MenuClickExercise extends MenuEvent {
|
||||
List<Object> get props => [exerciseTypeId];
|
||||
}
|
||||
|
||||
class MenuRecreateTree extends MenuEvent {
|
||||
const MenuRecreateTree();
|
||||
}
|
||||
|
||||
|
@ -17,6 +17,14 @@ class SettingsBloc extends Bloc<SettingsEvent, SettingsState> {
|
||||
|
||||
SettingsBloc({this.context}) : super(SettingsInitial());
|
||||
|
||||
void setLocale(Locale locale) {
|
||||
_locale = locale;
|
||||
}
|
||||
|
||||
Locale getLocale() {
|
||||
return _locale;
|
||||
}
|
||||
|
||||
@override
|
||||
Stream<SettingsState> mapEventToState(
|
||||
SettingsEvent event,
|
||||
|
@ -18,7 +18,7 @@ class AppLanguage extends ChangeNotifier {
|
||||
|
||||
Locale get appLocal => _appLocale ?? Locale("en");
|
||||
|
||||
fetchLocale() async {
|
||||
Future<void> fetchLocale() async {
|
||||
var prefs = await SharedPreferences.getInstance();
|
||||
if (prefs.getString('language_code') == null) {
|
||||
_appLocale = Locale('en');
|
||||
|
@ -10,6 +10,7 @@ import 'package:aitrainer_app/view/customer_fitness_page.dart';
|
||||
import 'package:aitrainer_app/view/customer_goal_page.dart';
|
||||
import 'package:aitrainer_app/view/customer_modify_page.dart';
|
||||
import 'package:aitrainer_app/view/customer_welcome_page.dart';
|
||||
import 'package:aitrainer_app/view/exercise_type_description.dart';
|
||||
import 'package:aitrainer_app/view/gdpr.dart';
|
||||
import 'package:aitrainer_app/view/login.dart';
|
||||
import 'package:aitrainer_app/view/exercise_new_page.dart';
|
||||
@ -168,6 +169,7 @@ class AitrainerApp extends StatelessWidget {
|
||||
'menu_page': (context) => MenuPage(),
|
||||
'account': (context) => AccountPage(),
|
||||
'settings': (context) => SettingsPage(),
|
||||
'exerciseTypeDescription': (context) => ExerciseTypeDescription(),
|
||||
},
|
||||
initialRoute: 'home',
|
||||
title: 'Aitrainer',
|
||||
|
@ -10,6 +10,7 @@ class ExerciseType {
|
||||
String unitQuantity;
|
||||
String unitQuantityUnit;
|
||||
bool active;
|
||||
bool base;
|
||||
String imageUrl;
|
||||
String nameTranslation;
|
||||
String descriptionTranslation;
|
||||
@ -25,6 +26,7 @@ class ExerciseType {
|
||||
this.unitQuantity = json['unitQuantity'];
|
||||
this.unitQuantityUnit = json['unitQuantityUnit'];
|
||||
this.active = json['active'];
|
||||
this.base = json['base'];
|
||||
this.imageUrl = json['images'][0]['url'];
|
||||
this.nameTranslation = json['translations'][0]['name'];
|
||||
this.descriptionTranslation = json['translations'][0]['description'];
|
||||
|
@ -12,7 +12,8 @@ class WorkoutTree {
|
||||
bool child;
|
||||
int exerciseTypeId;
|
||||
ExerciseType exerciseType;
|
||||
bool base;
|
||||
|
||||
WorkoutTree(this.id, this.parent, this.name, this.imageName, this.color, this.fontSize, this.child, this.exerciseTypeId, this.exerciseType);
|
||||
WorkoutTree(this.id, this.parent, this.name, this.imageName, this.color, this.fontSize, this.child, this.exerciseTypeId, this.exerciseType, this.base);
|
||||
|
||||
}
|
||||
|
@ -32,7 +32,8 @@ class MenuTreeRepository {
|
||||
32,
|
||||
false,
|
||||
0,
|
||||
null
|
||||
null,
|
||||
false
|
||||
);
|
||||
});
|
||||
|
||||
@ -54,7 +55,8 @@ class MenuTreeRepository {
|
||||
16,
|
||||
true,
|
||||
exerciseType.exerciseTypeId,
|
||||
exerciseType
|
||||
exerciseType,
|
||||
exerciseType.base
|
||||
);
|
||||
});
|
||||
}
|
||||
|
@ -191,10 +191,10 @@ class _CustomExerciseNewPageState extends State<CustomExercisePage> {
|
||||
SliverGrid gridCalculation(CustomExerciseFormBloc bloc) {
|
||||
return SliverGrid(
|
||||
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: 2,
|
||||
crossAxisCount: 3,
|
||||
mainAxisSpacing: 10.0,
|
||||
crossAxisSpacing: 10.0,
|
||||
childAspectRatio: 4.0,
|
||||
childAspectRatio: 2.0,
|
||||
),
|
||||
delegate: SliverChildListDelegate(
|
||||
[
|
||||
@ -209,29 +209,6 @@ class _CustomExerciseNewPageState extends State<CustomExercisePage> {
|
||||
filled: false,
|
||||
labelText: "1RM by Wendler: ",
|
||||
)),
|
||||
TextFieldBlocBuilder(
|
||||
readOnly: true,
|
||||
padding: EdgeInsets.only(left:30),
|
||||
textFieldBloc: bloc.rmMcGothlinField,
|
||||
style: TextStyle(color: Colors.deepOrange, fontSize: 12),
|
||||
decoration: InputDecoration(
|
||||
border: InputBorder.none,
|
||||
fillColor: Colors.white,
|
||||
filled: false,
|
||||
labelText: "1RM by McGlothin: ",
|
||||
)),
|
||||
TextFieldBlocBuilder(
|
||||
readOnly: true,
|
||||
padding: EdgeInsets.only(left:30),
|
||||
maxLines: 1,
|
||||
textFieldBloc: bloc.rmLombardiField,
|
||||
style: TextStyle(color: Colors.deepOrange, fontSize: 12),
|
||||
decoration: InputDecoration(
|
||||
border: InputBorder.none,
|
||||
fillColor: Colors.white,
|
||||
filled: false,
|
||||
labelText: "1RM by Lambordini: ",
|
||||
)),
|
||||
TextFieldBlocBuilder(
|
||||
readOnly: true,
|
||||
padding: EdgeInsets.only(left:30),
|
||||
@ -292,6 +269,43 @@ class _CustomExerciseNewPageState extends State<CustomExercisePage> {
|
||||
filled: false,
|
||||
labelText: "1RM 90%: ",
|
||||
)),
|
||||
|
||||
TextFieldBlocBuilder(
|
||||
readOnly: true,
|
||||
padding: EdgeInsets.only(left:30),
|
||||
maxLines: 1,
|
||||
textFieldBloc: bloc.rm75Field,
|
||||
style: TextStyle(color: Colors.deepOrange, fontSize: 12, fontWeight: FontWeight.bold),
|
||||
decoration: InputDecoration(
|
||||
border: InputBorder.none,
|
||||
fillColor: Colors.white,
|
||||
filled: false,
|
||||
labelText: "1RM 75%: ",
|
||||
)),
|
||||
TextFieldBlocBuilder(
|
||||
readOnly: true,
|
||||
padding: EdgeInsets.only(left:30),
|
||||
maxLines: 1,
|
||||
textFieldBloc: bloc.rm75OconnorField,
|
||||
style: TextStyle(color: Colors.deepOrange, fontSize: 12, fontWeight: FontWeight.bold),
|
||||
decoration: InputDecoration(
|
||||
border: InputBorder.none,
|
||||
fillColor: Colors.white,
|
||||
filled: false,
|
||||
labelText: "1RM 75%: by O'Connor",
|
||||
)),
|
||||
TextFieldBlocBuilder(
|
||||
readOnly: true,
|
||||
padding: EdgeInsets.only(left:30),
|
||||
maxLines: 1,
|
||||
textFieldBloc: bloc.rm75WendlerField,
|
||||
style: TextStyle(color: Colors.deepOrange, fontSize: 12, fontWeight: FontWeight.bold),
|
||||
decoration: InputDecoration(
|
||||
border: InputBorder.none,
|
||||
fillColor: Colors.white,
|
||||
filled: false,
|
||||
labelText: "1RM 75% by Wendler: ",
|
||||
)),
|
||||
TextFieldBlocBuilder(
|
||||
readOnly: true,
|
||||
padding: EdgeInsets.only(left:30),
|
||||
|
@ -1,4 +1,5 @@
|
||||
import 'package:aitrainer_app/bloc/exercise_form_bloc.dart';
|
||||
import 'package:aitrainer_app/localization/app_language.dart';
|
||||
import 'package:aitrainer_app/localization/app_localization.dart';
|
||||
import 'package:aitrainer_app/model/auth.dart';
|
||||
import 'package:aitrainer_app/model/exercise_type.dart';
|
||||
@ -26,7 +27,9 @@ class _ExerciseNewPageState extends State<ExerciseNewPage> {
|
||||
final exerciseBloc = BlocProvider.of<ExerciseFormBloc>(context);
|
||||
|
||||
exerciseBloc.exerciseRepository.setExerciseType(exerciseType);
|
||||
String exerciseName = exerciseBloc.exerciseRepository.exerciseType.name;
|
||||
String exerciseName = AppLanguage().appLocal == Locale("en") ?
|
||||
exerciseBloc.exerciseRepository.exerciseType.name :
|
||||
exerciseBloc.exerciseRepository.exerciseType.nameTranslation;
|
||||
|
||||
return Form(
|
||||
autovalidate: true,
|
||||
@ -68,13 +71,34 @@ class _ExerciseNewPageState extends State<ExerciseNewPage> {
|
||||
children: <Widget>[
|
||||
Divider(color: Colors.transparent,),
|
||||
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,
|
||||
),
|
||||
|
||||
|
||||
Text(AppLocalizations.of(context).translate(exerciseName) + " " +
|
||||
AppLocalizations.of(context).translate('Save Exercise'),
|
||||
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 18, color: Colors.deepOrange)),
|
||||
Divider(color: Colors.transparent,),
|
||||
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,),
|
||||
@ -138,36 +162,6 @@ class _ExerciseNewPageState extends State<ExerciseNewPage> {
|
||||
bloc.exerciseRepository.exerciseType.unitQuantityUnit),
|
||||
),
|
||||
),
|
||||
/*TextFormField(
|
||||
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),
|
||||
),
|
||||
autovalidate: true,
|
||||
textAlign: TextAlign.center,
|
||||
initialValue: "",
|
||||
style: TextStyle(fontSize: 30,
|
||||
color: Colors.lightBlue,
|
||||
fontWeight: FontWeight.bold),
|
||||
validator: (input) {
|
||||
return validateNumberInput(input);
|
||||
},
|
||||
inputFormatters: [
|
||||
FilteringTextInputFormatter(RegExp(r"[\d.]"))
|
||||
//WhitelistingTextInputFormatter(RegExp(r"[\d.]"))
|
||||
],
|
||||
onChanged: (input) => {
|
||||
print ("UnitQuantity value $input"),
|
||||
bloc.exerciseRepository.setUnitQuantity(
|
||||
double.parse(input))
|
||||
},
|
||||
|
||||
), */
|
||||
new InkWell(
|
||||
child: new Text(AppLocalizations.of(context).translate(
|
||||
bloc.exerciseRepository.exerciseType.unitQuantityUnit),
|
||||
@ -207,36 +201,6 @@ class _ExerciseNewPageState extends State<ExerciseNewPage> {
|
||||
bloc.exerciseRepository.exerciseType.unit),
|
||||
),
|
||||
),
|
||||
/* TextFormField(
|
||||
decoration: InputDecoration(
|
||||
fillColor: Colors.white,
|
||||
filled: false,
|
||||
hintText: AppLocalizations.of(context).translate("The number of the exercise"),
|
||||
hintStyle: TextStyle(fontSize: 16, color: Colors.black54, fontWeight: FontWeight.w100),
|
||||
labelStyle: TextStyle(fontSize: 16, color: Colors.deepOrange),
|
||||
labelText: AppLocalizations.of(context).translate(
|
||||
bloc.exerciseRepository.exerciseType.unit),
|
||||
),
|
||||
autovalidate: true,
|
||||
textAlign: TextAlign.center,
|
||||
initialValue: "",
|
||||
style: TextStyle(fontSize: 50,
|
||||
color: Colors.deepOrange,
|
||||
fontWeight: FontWeight.bold),
|
||||
validator: (input) {
|
||||
return validateNumberInput(input);
|
||||
},
|
||||
inputFormatters: [
|
||||
WhitelistingTextInputFormatter(RegExp(r"[\d.]"))
|
||||
],
|
||||
onChanged: (input) =>
|
||||
{
|
||||
print ("Quantity value $input"),
|
||||
bloc.exerciseRepository.setQuantity(double.parse(input)),
|
||||
bloc.exerciseRepository.setUnit(bloc.exerciseRepository.exerciseType.unit)
|
||||
|
||||
}
|
||||
),*/
|
||||
|
||||
]);
|
||||
|
||||
|
67
lib/view/exercise_type_description.dart
Normal file
67
lib/view/exercise_type_description.dart
Normal file
@ -0,0 +1,67 @@
|
||||
import 'package:aitrainer_app/localization/app_language.dart';
|
||||
import 'package:aitrainer_app/repository/exercise_repository.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class ExerciseTypeDescription extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final ExerciseRepository exerciseRepository =
|
||||
ModalRoute.of(context).settings.arguments;
|
||||
String exerciseDescription = AppLanguage().appLocal == Locale("en")
|
||||
? exerciseRepository.exerciseType.description
|
||||
: exerciseRepository.exerciseType.descriptionTranslation;
|
||||
|
||||
|
||||
String exerciseName = AppLanguage().appLocal == Locale("en") ?
|
||||
exerciseRepository.exerciseType.name :
|
||||
exerciseRepository.exerciseType.nameTranslation;
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
backgroundColor: Colors.transparent,
|
||||
title: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: <Widget>[
|
||||
Image.asset(
|
||||
'asset/image/WT_long_logo.png',
|
||||
fit: BoxFit.cover,
|
||||
height: 65.0,
|
||||
),
|
||||
],
|
||||
),
|
||||
leading: IconButton(
|
||||
icon: Icon(Icons.arrow_back, color: Colors.white),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
),
|
||||
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,
|
||||
),
|
||||
),
|
||||
padding: EdgeInsets.only(left: 20, top: 20, right: 15),
|
||||
child: ListView(
|
||||
|
||||
children: [
|
||||
Text(exerciseName,
|
||||
style: TextStyle(color: Colors.blueGrey,
|
||||
fontSize: 20, fontWeight: FontWeight.bold),
|
||||
),
|
||||
Divider(color: Colors.transparent,),
|
||||
InkWell(
|
||||
child: Text(exerciseDescription,
|
||||
style: TextStyle(color: Colors.blueGrey,
|
||||
fontSize: 18, fontWeight: FontWeight.normal),),
|
||||
),
|
||||
]
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
@ -7,7 +7,7 @@ import 'package:aitrainer_app/widgets/splash.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
//import 'package:flutter_facebook_login/flutter_facebook_login.dart';
|
||||
import 'package:flutter_facebook_login/flutter_facebook_login.dart';
|
||||
import 'package:flutter_form_bloc/flutter_form_bloc.dart';
|
||||
|
||||
import '../library_keys.dart';
|
||||
@ -87,7 +87,7 @@ class _LoginWidget extends State<LoginWidget> {
|
||||
width: cWidth * .85,
|
||||
),
|
||||
onPressed: () => {
|
||||
//_fbLogin(),
|
||||
_fbLogin(),
|
||||
print("Login with FB"),
|
||||
},
|
||||
),
|
||||
@ -172,7 +172,7 @@ class _LoginWidget extends State<LoginWidget> {
|
||||
content: Text(error, style: TextStyle(color: Colors.white))));
|
||||
}
|
||||
|
||||
/* Future<Null> _fbLogin() async {
|
||||
Future<Null> _fbLogin() async {
|
||||
final FacebookLogin facebookSignIn = new FacebookLogin();
|
||||
final FacebookLoginResult result = await facebookSignIn.logIn(['email']);
|
||||
|
||||
@ -197,5 +197,5 @@ class _LoginWidget extends State<LoginWidget> {
|
||||
'Here\'s the error Facebook gave us: ${result.errorMessage}');
|
||||
break;
|
||||
}
|
||||
} */
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
import 'package:aitrainer_app/bloc/menu/menu_bloc.dart';
|
||||
import 'package:aitrainer_app/bloc/settings/settings_bloc.dart';
|
||||
import 'package:aitrainer_app/localization/app_language.dart';
|
||||
import 'package:aitrainer_app/localization/app_localization.dart';
|
||||
import 'package:aitrainer_app/model/auth.dart';
|
||||
import 'package:aitrainer_app/widgets/bottom_nav.dart';
|
||||
import 'package:aitrainer_app/widgets/splash.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@ -15,7 +17,10 @@ class SettingsPage extends StatelessWidget{
|
||||
Widget build(BuildContext context) {
|
||||
// ignore: close_sinks
|
||||
SettingsBloc settingsBloc = BlocProvider.of<SettingsBloc>(context);
|
||||
settingsBloc.setLocale(AppLanguage().appLocal);
|
||||
settingsBloc.context = context;
|
||||
|
||||
MenuBloc menuBloc = BlocProvider.of<MenuBloc>(context);
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Row(
|
||||
@ -45,47 +50,18 @@ class SettingsPage extends StatelessWidget{
|
||||
listener: (context, state) {
|
||||
if ( state is SettingsError ) {
|
||||
|
||||
} else if ( state is SettingsReady ) {
|
||||
menuBloc.add(MenuRecreateTree());
|
||||
}
|
||||
},
|
||||
// ignore: missing_return
|
||||
builder: (context, state) {
|
||||
if ( state is SettingsLoading ) {
|
||||
return LoadingDialog();
|
||||
} else if ( state is SettingsReady || state is SettingsInitial) {
|
||||
return ListView(
|
||||
padding: EdgeInsets.only(top: 150),
|
||||
children: <Widget>[
|
||||
ListTile(
|
||||
leading: Icon(Icons.language),
|
||||
subtitle: Text(
|
||||
AppLocalizations.of(context).translate(
|
||||
"Change App Language")),
|
||||
title: DropdownButton(
|
||||
|
||||
value: state.props[0] == Locale('en')
|
||||
? AppLocalizations.of(context).translate(
|
||||
"English")
|
||||
: AppLocalizations.of(context).translate(
|
||||
"Hungarian"),
|
||||
items: [AppLocalizations.of(context).translate(
|
||||
"English"), AppLocalizations.of(context)
|
||||
.translate("Hungarian")
|
||||
]
|
||||
.map<DropdownMenuItem<String>>((String value) {
|
||||
return DropdownMenuItem<String>(
|
||||
value: value,
|
||||
child: Text(value),
|
||||
);
|
||||
}).toList(),
|
||||
onChanged: (String lang) =>
|
||||
settingsBloc.add(
|
||||
SettingsChangeLanguage(language: lang)
|
||||
),
|
||||
)
|
||||
|
||||
),
|
||||
]
|
||||
);
|
||||
} else if ( state is SettingsInitial) {
|
||||
return settingsUI(context, settingsBloc, menuBloc);
|
||||
} else if ( state is SettingsReady ) {
|
||||
return settingsUI(context, settingsBloc, menuBloc);
|
||||
} else {
|
||||
return Container();
|
||||
}
|
||||
@ -97,4 +73,43 @@ class SettingsPage extends StatelessWidget{
|
||||
|
||||
);
|
||||
}
|
||||
|
||||
ListView settingsUI(BuildContext context, SettingsBloc settingsBloc, MenuBloc menuBloc) {
|
||||
return ListView(
|
||||
padding: EdgeInsets.only(top: 150),
|
||||
children: <Widget>[
|
||||
ListTile(
|
||||
leading: Icon(Icons.language),
|
||||
subtitle: Text(
|
||||
AppLocalizations.of(context).translate(
|
||||
"Change App Language")),
|
||||
title: DropdownButton(
|
||||
|
||||
value: settingsBloc.getLocale() == Locale('en')
|
||||
? AppLocalizations.of(context).translate(
|
||||
"English")
|
||||
: AppLocalizations.of(context).translate(
|
||||
"Hungarian"),
|
||||
items: [AppLocalizations.of(context).translate(
|
||||
"English"), AppLocalizations.of(context)
|
||||
.translate("Hungarian")
|
||||
]
|
||||
.map<DropdownMenuItem<String>>((String value) {
|
||||
return DropdownMenuItem<String>(
|
||||
value: value,
|
||||
child: Text(value),
|
||||
);
|
||||
}).toList(),
|
||||
onChanged: (String lang) =>
|
||||
{
|
||||
settingsBloc.add(
|
||||
SettingsChangeLanguage(language: lang)
|
||||
),
|
||||
}
|
||||
)
|
||||
|
||||
),
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
@ -6,95 +6,104 @@ import 'package:aitrainer_app/model/auth.dart';
|
||||
import 'package:aitrainer_app/model/workout_tree.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/painting.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
||||
|
||||
// ignore: must_be_immutable
|
||||
class MenuPageWidget extends StatelessWidget {
|
||||
int parent;
|
||||
|
||||
MenuPageWidget({this.parent});
|
||||
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
MenuBloc menuBloc = BlocProvider.of<MenuBloc>(context);
|
||||
|
||||
return CustomScrollView(
|
||||
scrollDirection: Axis.vertical,
|
||||
slivers: <Widget>[
|
||||
buildMenuColumn(parent, context, menuBloc)
|
||||
]
|
||||
);
|
||||
slivers: <Widget>[buildMenuColumn(parent, context, menuBloc)]);
|
||||
}
|
||||
|
||||
SliverList buildMenuColumn(int parent, BuildContext context, MenuBloc menuBloc) {
|
||||
SliverList buildMenuColumn(
|
||||
int parent, BuildContext context, MenuBloc menuBloc) {
|
||||
final List<Widget> _columnChildren = List();
|
||||
|
||||
menuBloc.menuTreeRepository.getBranch(menuBloc.parent).forEach((treeName, value) {
|
||||
menuBloc.menuTreeRepository
|
||||
.getBranch(menuBloc.parent)
|
||||
.forEach((treeName, value) {
|
||||
WorkoutTree workoutTree = value as WorkoutTree;
|
||||
_columnChildren.add(
|
||||
Container(
|
||||
padding: EdgeInsets.only(top: 16.0),
|
||||
child: Center(
|
||||
child: Stack(
|
||||
alignment: Alignment.bottomLeft,
|
||||
overflow: Overflow.visible,
|
||||
children: [
|
||||
FlatButton(
|
||||
child: _getButtonImage(workoutTree),
|
||||
padding: EdgeInsets.all(0.0),
|
||||
onPressed:() =>
|
||||
{
|
||||
print("Hi!, Menu clicked " + workoutTree.id.toString()),
|
||||
if ( workoutTree.child == false ) {
|
||||
menuBloc.add(MenuTreeDown(parent: workoutTree.id)),
|
||||
_columnChildren.add(Container(
|
||||
padding: EdgeInsets.only(top: 16.0),
|
||||
child: Center(
|
||||
child: Stack(
|
||||
alignment: Alignment.bottomLeft,
|
||||
clipBehavior: Clip.hardEdge,
|
||||
fit: StackFit.loose,
|
||||
children: [
|
||||
FlatButton(
|
||||
child: _getButtonImage(workoutTree),
|
||||
padding: EdgeInsets.only(left: 0.0, bottom: 0),
|
||||
shape: getShape(workoutTree),
|
||||
onPressed: () => menuClick(workoutTree, menuBloc, context),
|
||||
),
|
||||
InkWell(
|
||||
onTap:() => menuClick(workoutTree, menuBloc, context),
|
||||
child: Text(
|
||||
" " + workoutTree.name,
|
||||
maxLines: 2,
|
||||
style: TextStyle(
|
||||
color: workoutTree.color,
|
||||
fontSize: workoutTree.fontSize,
|
||||
fontFamily: 'Arial',
|
||||
fontWeight: FontWeight.w900),
|
||||
),
|
||||
highlightColor: workoutTree.color,
|
||||
),
|
||||
|
||||
} else {
|
||||
menuBloc.add(MenuClickExercise(exerciseTypeId: workoutTree.id)),
|
||||
if ( Auth().userLoggedIn == null ) {
|
||||
Scaffold.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
backgroundColor: Colors.orange,
|
||||
content: Text(
|
||||
AppLocalizations.of(context).translate('Please log in'),
|
||||
style: TextStyle(color: Colors.white))
|
||||
))
|
||||
} else {
|
||||
if ( workoutTree.exerciseType.name == "Custom") {
|
||||
Navigator.of(context).pushNamed(
|
||||
'exerciseCustomPage',
|
||||
arguments: workoutTree.exerciseType),
|
||||
} else {
|
||||
Navigator.of(context).pushNamed(
|
||||
'exerciseNewPage',
|
||||
arguments: workoutTree.exerciseType),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
),
|
||||
InkWell(
|
||||
child: Text(workoutTree.name, style: TextStyle(color: workoutTree.color, fontSize: workoutTree.fontSize, fontFamily: 'Arial', fontWeight: FontWeight.w900 ),),
|
||||
highlightColor: workoutTree.color,
|
||||
)]
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
]))));
|
||||
});
|
||||
//_columnChildren.add(Spacer(flex: 3));
|
||||
|
||||
SliverList sliverList =
|
||||
SliverList(
|
||||
delegate: SliverChildListDelegate(
|
||||
_columnChildren
|
||||
)
|
||||
);
|
||||
SliverList(delegate: SliverChildListDelegate(_columnChildren));
|
||||
|
||||
return sliverList;
|
||||
}
|
||||
|
||||
void menuClick(
|
||||
WorkoutTree workoutTree, MenuBloc menuBloc, BuildContext context) {
|
||||
print("Hi!, Menu clicked " + workoutTree.id.toString());
|
||||
if (workoutTree.child == false) {
|
||||
menuBloc.add(MenuTreeDown(parent: workoutTree.id));
|
||||
} else {
|
||||
menuBloc.add(MenuClickExercise(exerciseTypeId: workoutTree.id));
|
||||
if (Auth().userLoggedIn == null) {
|
||||
Scaffold.of(context).showSnackBar(SnackBar(
|
||||
backgroundColor: Colors.orange,
|
||||
content: Text(
|
||||
AppLocalizations.of(context).translate('Please log in'),
|
||||
style: TextStyle(color: Colors.white))));
|
||||
} else {
|
||||
if (workoutTree.exerciseType.name == "Custom") {
|
||||
Navigator.of(context).pushNamed('exerciseCustomPage',
|
||||
arguments: workoutTree.exerciseType);
|
||||
} else {
|
||||
Navigator.of(context).pushNamed('exerciseNewPage',
|
||||
arguments: workoutTree.exerciseType);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dynamic getShape(WorkoutTree workoutTree) {
|
||||
bool base = workoutTree.base;
|
||||
dynamic returnCode = (base == true)
|
||||
? RoundedRectangleBorder(
|
||||
side: BorderSide(width: 4, color: Colors.orangeAccent),
|
||||
)
|
||||
: null;
|
||||
return returnCode;
|
||||
}
|
||||
|
||||
dynamic _getButtonImage(WorkoutTree workoutTree) {
|
||||
dynamic image;
|
||||
/*String url = workoutTree.imageName;
|
||||
@ -112,17 +121,18 @@ class MenuPageWidget extends StatelessWidget {
|
||||
image = Image.asset(
|
||||
workoutTree.imageName,
|
||||
height: 180,
|
||||
errorBuilder: (context, error, stackTrace) {
|
||||
String url = Auth.mediaUrl + 'images/' + workoutTree.imageName.substring(11);
|
||||
Widget image = FadeInImage.assetNetwork(
|
||||
errorBuilder: (context, error, stackTrace) {
|
||||
String url =
|
||||
Auth.mediaUrl + 'images/' + workoutTree.imageName.substring(11);
|
||||
Widget image = FadeInImage.assetNetwork(
|
||||
placeholder: 'asset/image/dots.gif',
|
||||
image: url,
|
||||
height: 180,
|
||||
);
|
||||
return image;
|
||||
return image;
|
||||
},
|
||||
);
|
||||
} on Exception catch(_) {
|
||||
} on Exception catch (_) {
|
||||
String url = Auth.mediaUrl + '/images/' + workoutTree.imageName;
|
||||
image = FadeInImage.assetNetwork(
|
||||
placeholder: 'asset/image/dots.gif',
|
||||
@ -133,4 +143,4 @@ class MenuPageWidget extends StatelessWidget {
|
||||
|
||||
return image;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -172,6 +172,13 @@ packages:
|
||||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.0"
|
||||
flutter_facebook_login:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: flutter_facebook_login
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "3.0.0"
|
||||
flutter_form_bloc:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
@ -31,7 +31,7 @@ dependencies:
|
||||
sentry: ^3.0.1
|
||||
# firebase_messaging: ^6.0.16
|
||||
flutter_local_notifications: 1.1.1
|
||||
#flutter_facebook_login: ^3.0.0
|
||||
flutter_facebook_login: ^3.0.0
|
||||
flutter_bloc: ^6.0.1
|
||||
equatable: ^1.2.3
|
||||
flutter_form_bloc: ^0.19.0
|
||||
|
Loading…
Reference in New Issue
Block a user