wt1.1d custom exercise, mydevelopment exercise list, environment for different databases
This commit is contained in:
parent
6b0892ec09
commit
f0ba820385
@ -114,5 +114,8 @@
|
||||
"Check":"Check",
|
||||
"1st Control Exercise:": "1st Control Exercise:",
|
||||
"2nd Control Exercise:": "2nd Control Exercise:",
|
||||
"3rd Control Exercise:": "3rd Control Exercise:"
|
||||
"3rd Control Exercise:": "3rd Control Exercise:",
|
||||
|
||||
"My Development":"My Development",
|
||||
"My Training Plan":"My Training Plan"
|
||||
}
|
@ -113,5 +113,8 @@
|
||||
"Check":"Ellenőrzés",
|
||||
"1st Control Exercise:": "1. kontrollgyakorlat:",
|
||||
"2nd Control Exercise:": "2. kontrollgyakorlat:",
|
||||
"3rd Control Exercise:": "3. kontrollgyakorlat:"
|
||||
"3rd Control Exercise:": "3. kontrollgyakorlat:",
|
||||
|
||||
"My Development":"Fejlődésem",
|
||||
"My Training Plan":"Edzéstervem"
|
||||
}
|
@ -1,4 +1,3 @@
|
||||
import 'package:aitrainer_app/localization/app_localization.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
|
@ -6,6 +6,7 @@ class ExerciseControlFormBloc extends FormBloc<String, String> {
|
||||
final ExerciseRepository exerciseRepository;
|
||||
int step = 1;
|
||||
final double percentToCalculate;
|
||||
final bool readonly;
|
||||
|
||||
final initialRMField = TextFieldBloc(
|
||||
);
|
||||
@ -30,7 +31,7 @@ class ExerciseControlFormBloc extends FormBloc<String, String> {
|
||||
|
||||
|
||||
|
||||
ExerciseControlFormBloc({this.exerciseRepository, this.percentToCalculate}) {
|
||||
ExerciseControlFormBloc({this.exerciseRepository, this.percentToCalculate, this.readonly}) {
|
||||
addFieldBlocs(fieldBlocs: [
|
||||
initialRMField,
|
||||
quantity1Field,
|
||||
@ -49,25 +50,19 @@ class ExerciseControlFormBloc extends FormBloc<String, String> {
|
||||
|
||||
quantity1Field.onValueChanges(onData: (previous, current) async* {
|
||||
exerciseRepository.setQuantity(current.valueToDouble);
|
||||
exerciseRepository.setUnitQuantity(unitQuantity1Field.valueToDouble);
|
||||
});
|
||||
|
||||
unitQuantity1Field.onValueChanges(onData: (previous, current) async* {
|
||||
exerciseRepository.setUnitQuantity(current.valueToDouble);
|
||||
});
|
||||
quantity2Field.onValueChanges(onData: (previous, current) async* {
|
||||
exerciseRepository.setQuantity(current.valueToDouble);
|
||||
exerciseRepository.setUnitQuantity(unitQuantity2Field.valueToDouble);
|
||||
});
|
||||
|
||||
unitQuantity2Field.onValueChanges(onData: (previous, current) async* {
|
||||
exerciseRepository.setUnitQuantity(current.valueToDouble);
|
||||
});
|
||||
quantity3Field.onValueChanges(onData: (previous, current) async* {
|
||||
exerciseRepository.setQuantity(current.valueToDouble);
|
||||
exerciseRepository.setUnitQuantity(unitQuantity3Field.valueToDouble);
|
||||
});
|
||||
|
||||
unitQuantity3Field.onValueChanges(onData: (previous, current) async* {
|
||||
exerciseRepository.setUnitQuantity(current.valueToDouble);
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
@ -93,7 +88,9 @@ class ExerciseControlFormBloc extends FormBloc<String, String> {
|
||||
//updatedRMField.updateInitialValue(calculate1RM(percent75: false).toStringAsFixed(0));
|
||||
}
|
||||
|
||||
//await exerciseRepository.addExercise();
|
||||
if ( ! readonly ) {
|
||||
await exerciseRepository.addExercise();
|
||||
}
|
||||
|
||||
emitSuccess(canSubmitAgain: true);
|
||||
} on Exception catch (ex) {
|
||||
|
@ -2,6 +2,7 @@ import 'dart:async';
|
||||
|
||||
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:bloc/bloc.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
|
@ -1,7 +1,7 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
class AppLanguage extends ChangeNotifier {
|
||||
class AppLanguage{
|
||||
static final AppLanguage _singleton = AppLanguage._internal();
|
||||
|
||||
Locale _appLocale = Locale('en');
|
||||
@ -51,6 +51,5 @@ class AppLanguage extends ChangeNotifier {
|
||||
await prefs.setString('countryCode', 'US');
|
||||
}
|
||||
print(" ---- Stored lang: " + _appLocale.toString());
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ import 'package:aitrainer_app/view/gdpr.dart';
|
||||
import 'package:aitrainer_app/view/login.dart';
|
||||
import 'package:aitrainer_app/view/exercise_new_page.dart';
|
||||
import 'package:aitrainer_app/view/menu_page.dart';
|
||||
import 'package:aitrainer_app/view/mydevelopment_page.dart';
|
||||
import 'package:aitrainer_app/view/registration.dart';
|
||||
import 'package:aitrainer_app/view/settings.dart';
|
||||
import 'package:aitrainer_app/widgets/home.dart';
|
||||
@ -171,6 +172,7 @@ class AitrainerApp extends StatelessWidget {
|
||||
'account': (context) => AccountPage(),
|
||||
'settings': (context) => SettingsPage(),
|
||||
'exerciseTypeDescription': (context) => ExerciseTypeDescription(),
|
||||
'mydevelopment': (context) => MyDevelopmentPage(),
|
||||
},
|
||||
initialRoute: 'home',
|
||||
title: 'Aitrainer',
|
||||
|
@ -7,6 +7,7 @@ import 'package:aitrainer_app/model/workout_tree.dart';
|
||||
import 'package:aitrainer_app/repository/exercise_repository.dart';
|
||||
import 'package:aitrainer_app/service/exercise_tree_service.dart';
|
||||
import 'package:aitrainer_app/service/exercisetype_service.dart';
|
||||
import 'package:aitrainer_app/util/env.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:aitrainer_app/model/exercise_type.dart';
|
||||
|
||||
@ -41,8 +42,9 @@ class Cache {
|
||||
static final String lastStoreDateKey = 'last_date';
|
||||
static final String isRegisteredKey = 'is_registered';
|
||||
static final String isLoggedInKey = 'is_logged_in';
|
||||
static final String langKey = 'lang';
|
||||
|
||||
static final String baseUrl = 'http://aitrainer.info:8888/api/';
|
||||
static String baseUrl = 'http://aitrainer.info:8888/api/';
|
||||
static final String mediaUrl = 'https://aitrainer.info:4343/media/';
|
||||
static final String username = 'bosi';
|
||||
static final String password = 'andio2009';
|
||||
@ -55,6 +57,7 @@ class Cache {
|
||||
List<ExerciseTree> _exerciseTree;
|
||||
List<Exercise> _exercises;
|
||||
LinkedHashMap _tree = LinkedHashMap<String, WorkoutTree>();
|
||||
double _percentExercises = -1;
|
||||
|
||||
List deviceLanguages;
|
||||
String startPage;
|
||||
@ -63,7 +66,12 @@ class Cache {
|
||||
return _singleton;
|
||||
}
|
||||
|
||||
Cache._internal();
|
||||
Cache._internal() {
|
||||
String testEnv = EnvironmentConfig.test_env;
|
||||
if ( testEnv == "1") {
|
||||
baseUrl = 'http://aitrainer.app:8899/api/';
|
||||
}
|
||||
}
|
||||
|
||||
String getAuthToken() {
|
||||
return this.authToken;
|
||||
@ -166,4 +174,16 @@ class Cache {
|
||||
return this._tree;
|
||||
}
|
||||
|
||||
void setPercentExercises(double percent) {
|
||||
this._percentExercises = percent;
|
||||
}
|
||||
|
||||
double getPercentExercises() {
|
||||
return this._percentExercises;
|
||||
}
|
||||
|
||||
void addExercise(Exercise exercise) {
|
||||
_exercises.add(exercise);
|
||||
}
|
||||
|
||||
}
|
@ -1,7 +1,10 @@
|
||||
import 'dart:collection';
|
||||
|
||||
import 'package:aitrainer_app/model/cache.dart';
|
||||
import 'package:aitrainer_app/model/customer.dart';
|
||||
import 'package:aitrainer_app/model/exercise.dart';
|
||||
import 'package:aitrainer_app/model/exercise_type.dart';
|
||||
import 'package:aitrainer_app/model/workout_tree.dart';
|
||||
import 'package:aitrainer_app/service/exercise_service.dart';
|
||||
|
||||
class ExerciseRepository {
|
||||
@ -70,6 +73,7 @@ class ExerciseRepository {
|
||||
modelExercise.customerId = this.customer.customerId;
|
||||
modelExercise.exerciseTypeId = this.exerciseType.exerciseTypeId;
|
||||
await ExerciseApi().addExercise(modelExercise);
|
||||
Cache().addExercise(exercise);
|
||||
}
|
||||
|
||||
|
||||
@ -96,8 +100,57 @@ class ExerciseRepository {
|
||||
return this.exerciseList;
|
||||
}
|
||||
|
||||
double getBaseExerciseFinishedPercent() {
|
||||
return 0;
|
||||
void getBaseExerciseFinishedPercent() {
|
||||
List<int> checkedExerciseTypeId = List();
|
||||
List<int> baseTreeItem = List();
|
||||
List<int> checkedBaseTreeItem = List();
|
||||
int count1RMExercises = 0;
|
||||
LinkedHashMap<String, WorkoutTree> tree = Cache().getWorkoutTree();
|
||||
|
||||
if ( tree == null ) {
|
||||
return;
|
||||
}
|
||||
|
||||
tree.forEach((key, value) {
|
||||
WorkoutTree treeItem = value;
|
||||
if (treeItem.exerciseType != null &&
|
||||
treeItem.exerciseType.base == true &&
|
||||
!baseTreeItem.contains(treeItem.parent)) {
|
||||
baseTreeItem.add(treeItem.parent);
|
||||
}
|
||||
});
|
||||
|
||||
if ( exerciseList == null ) {
|
||||
exerciseList = Cache().getExercises();
|
||||
}
|
||||
|
||||
if ( exerciseList == null ) {
|
||||
return;
|
||||
}
|
||||
|
||||
exerciseList.forEach((element) {
|
||||
Exercise exercise = element;
|
||||
if ( !checkedExerciseTypeId.contains(exercise.exerciseTypeId )) {
|
||||
checkedExerciseTypeId.add(exercise.exerciseTypeId);
|
||||
tree.forEach((key, value) {
|
||||
WorkoutTree treeItem = value;
|
||||
if (treeItem.exerciseType != null
|
||||
&& treeItem.exerciseType.base == true
|
||||
&& exercise.exerciseTypeId == treeItem.exerciseType.exerciseTypeId
|
||||
&& !checkedBaseTreeItem.contains(treeItem.parent)) {
|
||||
print ("id: " + exercise.exerciseTypeId.toString());
|
||||
checkedBaseTreeItem.add(treeItem.parent);
|
||||
count1RMExercises++;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
print ("checkedExerciseTypeid: " + checkedExerciseTypeId.toString());
|
||||
print ("baseTreeItem: " + baseTreeItem.toString());
|
||||
print ("count1RMExercises: " + count1RMExercises.toString());
|
||||
final double percent = count1RMExercises / baseTreeItem.length;
|
||||
Cache().setPercentExercises(percent);
|
||||
}
|
||||
|
||||
void getLastExercise() {
|
||||
@ -128,4 +181,5 @@ class ExerciseRepository {
|
||||
}
|
||||
return actualExerciseType;
|
||||
}
|
||||
|
||||
}
|
@ -4,6 +4,7 @@ import 'package:aitrainer_app/model/cache.dart';
|
||||
import 'package:aitrainer_app/model/exercise_tree.dart';
|
||||
import 'package:aitrainer_app/model/exercise_type.dart';
|
||||
import 'package:aitrainer_app/model/workout_tree.dart';
|
||||
import 'package:aitrainer_app/repository/exercise_repository.dart';
|
||||
import 'package:aitrainer_app/service/exercise_tree_service.dart';
|
||||
import 'package:aitrainer_app/service/exercisetype_service.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@ -12,9 +13,9 @@ class MenuTreeRepository {
|
||||
final LinkedHashMap tree = LinkedHashMap<String, WorkoutTree>();
|
||||
|
||||
Future<void> createTree() async {
|
||||
|
||||
final AppLanguage appLanguage = AppLanguage();
|
||||
bool isEnglish = appLanguage.appLocal == Locale('en');
|
||||
print("** Start creating tree on lang: " + appLanguage.appLocal.toString());
|
||||
|
||||
List<ExerciseTree> exerciseTree = Cache().getExerciseTree();
|
||||
if ( exerciseTree == null || exerciseTree.length == 0) {
|
||||
@ -25,8 +26,8 @@ class MenuTreeRepository {
|
||||
String treeName = isEnglish ? treeItem.name : treeItem.nameTranslation;
|
||||
String assetImage = 'asset/menu/' + treeItem.imageUrl.substring(7);
|
||||
bool is1RM = treeItem.name == '1RM' ? true : false;
|
||||
if ( is1RM == false) {
|
||||
is1RM = false; //isParent1RM(treeItem.treeId);
|
||||
if ( is1RM == false && treeItem.parentId != 0) {
|
||||
is1RM = isParent1RM(treeItem.parentId);
|
||||
}
|
||||
this.tree[treeItem.name] = WorkoutTree(
|
||||
treeItem.treeId,
|
||||
@ -51,7 +52,8 @@ class MenuTreeRepository {
|
||||
String exerciseTypeName = isEnglish ?
|
||||
exerciseType.name : exerciseType.nameTranslation;
|
||||
String assetImage = 'asset/menu/' + exerciseType.imageUrl.substring(7);
|
||||
bool is1RM = false; //this.isParent1RM(exerciseType.treeId);
|
||||
bool is1RM = this.isParent1RM(exerciseType.treeId);
|
||||
exerciseType.is1RM = is1RM;
|
||||
this.tree[exerciseType.name] = WorkoutTree(
|
||||
exerciseType.exerciseTypeId,
|
||||
exerciseType.treeId,
|
||||
@ -66,18 +68,24 @@ class MenuTreeRepository {
|
||||
is1RM
|
||||
);
|
||||
});
|
||||
|
||||
Cache().setWorkoutTree(tree);
|
||||
ExerciseRepository exerciseRepository = ExerciseRepository();
|
||||
exerciseRepository.getBaseExerciseFinishedPercent();
|
||||
}
|
||||
|
||||
bool isParent1RM(int treeId) {
|
||||
bool isTreeItem1RM = false;
|
||||
|
||||
for (int i = 0; i < this.tree.length; i++ ) {
|
||||
WorkoutTree treeItem = this.tree[i];
|
||||
this.tree.forEach((key, value) {
|
||||
WorkoutTree treeItem = value as WorkoutTree;
|
||||
if ( treeItem.id == treeId ) {
|
||||
isTreeItem1RM = treeItem.is1RM;
|
||||
break;
|
||||
//print (treeItem.name + " 1RM " + treeItem.is1RM.toString() );
|
||||
}
|
||||
};
|
||||
|
||||
});
|
||||
|
||||
return isTreeItem1RM;
|
||||
}
|
||||
|
||||
|
3
lib/util/env.dart
Normal file
3
lib/util/env.dart
Normal file
@ -0,0 +1,3 @@
|
||||
class EnvironmentConfig {
|
||||
static const test_env = String.fromEnvironment('test_env');
|
||||
}
|
@ -65,7 +65,7 @@ class AccountPage extends StatelessWidget {
|
||||
}
|
||||
),
|
||||
),
|
||||
bottomNavigationBar: BottomNavigator(bottomNavIndex: 2));
|
||||
bottomNavigationBar: BottomNavigator(bottomNavIndex: 3));
|
||||
}
|
||||
|
||||
ListView accountWidget(BuildContext context, String customerName, AccountBloc accountBloc) {
|
||||
|
@ -277,7 +277,7 @@ class _CustomExerciseNewPageState extends State<CustomExercisePage> {
|
||||
padding: EdgeInsets.only(left:10),
|
||||
maxLines: 1,
|
||||
textFieldBloc: bloc.rm75Field,
|
||||
style: TextStyle(color: Colors.deepOrange, fontSize: 12, fontWeight: FontWeight.bold),
|
||||
style: TextStyle(color: Colors.deepOrange, fontSize: 12, fontWeight: FontWeight.normal),
|
||||
decoration: InputDecoration(
|
||||
border: InputBorder.none,
|
||||
fillColor: Colors.white,
|
||||
@ -289,7 +289,7 @@ class _CustomExerciseNewPageState extends State<CustomExercisePage> {
|
||||
padding: EdgeInsets.only(left:10),
|
||||
maxLines: 1,
|
||||
textFieldBloc: bloc.rm75OconnorField,
|
||||
style: TextStyle(color: Colors.deepOrange, fontSize: 12, fontWeight: FontWeight.bold),
|
||||
style: TextStyle(color: Colors.deepOrange, fontSize: 12, fontWeight: FontWeight.normal),
|
||||
decoration: InputDecoration(
|
||||
border: InputBorder.none,
|
||||
fillColor: Colors.white,
|
||||
@ -301,7 +301,7 @@ class _CustomExerciseNewPageState extends State<CustomExercisePage> {
|
||||
padding: EdgeInsets.only(left:10),
|
||||
maxLines: 1,
|
||||
textFieldBloc: bloc.rm75WendlerField,
|
||||
style: TextStyle(color: Colors.deepOrange, fontSize: 12, fontWeight: FontWeight.bold),
|
||||
style: TextStyle(color: Colors.deepOrange, fontSize: 12, fontWeight: FontWeight.normal),
|
||||
decoration: InputDecoration(
|
||||
border: InputBorder.none,
|
||||
fillColor: Colors.white,
|
||||
@ -366,6 +366,7 @@ class _CustomExerciseNewPageState extends State<CustomExercisePage> {
|
||||
{
|
||||
args['exerciseRepository'] = bloc.exerciseRepository,
|
||||
args['percent'] = 0.75,
|
||||
args['readonly'] = true,
|
||||
Navigator.of(context).pushNamed('exerciseControlPage',
|
||||
arguments: args)
|
||||
},
|
||||
@ -381,6 +382,7 @@ class _CustomExerciseNewPageState extends State<CustomExercisePage> {
|
||||
{
|
||||
args['exerciseRepository'] = bloc.exerciseRepository,
|
||||
args['percent'] = 0.5,
|
||||
args['readonly'] = true,
|
||||
Navigator.of(context).pushNamed('exerciseControlPage',
|
||||
arguments: args )
|
||||
},
|
||||
|
@ -22,10 +22,11 @@ class _ExerciseControlPage extends State<ExerciseControlPage> {
|
||||
LinkedHashMap arguments = ModalRoute.of(context).settings.arguments;
|
||||
final ExerciseRepository exerciseRepository = arguments['exerciseRepository'];
|
||||
final double percent = arguments['percent'];
|
||||
final bool readonly = arguments['readonly'];
|
||||
|
||||
return BlocProvider(
|
||||
create: (context) =>
|
||||
ExerciseControlFormBloc(exerciseRepository: exerciseRepository, percentToCalculate: percent),
|
||||
ExerciseControlFormBloc(exerciseRepository: exerciseRepository, percentToCalculate: percent, readonly: readonly),
|
||||
child: BlocBuilder<ExerciseControlFormBloc, FormBlocState>(
|
||||
builder: (context, state) {
|
||||
// ignore: close_sinks
|
||||
@ -148,12 +149,7 @@ class _ExerciseControlPage extends State<ExerciseControlPage> {
|
||||
inputFormatters: [
|
||||
WhitelistingTextInputFormatter (RegExp(r"[\d.]"))
|
||||
],
|
||||
onChanged: (input) => {
|
||||
print("Quantity 1 value $input"),
|
||||
//exerciseBloc.exerciseRepository.setQuantity(double.parse(input)),
|
||||
//exerciseBloc.exerciseRepository
|
||||
// .setUnit(exerciseBloc.exerciseRepository.exerciseType.unit)
|
||||
},
|
||||
|
||||
decoration: InputDecoration(
|
||||
fillColor: Colors.white,
|
||||
filled: false,
|
||||
|
@ -1,3 +1,5 @@
|
||||
import 'dart:collection';
|
||||
|
||||
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';
|
||||
@ -235,7 +237,7 @@ class _ExerciseNewPageState extends State<ExerciseNewPage> {
|
||||
}
|
||||
|
||||
void confirmationDialog( ExerciseFormBloc bloc ) {
|
||||
|
||||
LinkedHashMap args = LinkedHashMap();
|
||||
print("exercise validated " + bloc.exerciseRepository.exercise.quantity.toString());
|
||||
if ( bloc.exerciseRepository.exercise.quantity == null) {
|
||||
return;
|
||||
@ -245,9 +247,12 @@ class _ExerciseNewPageState extends State<ExerciseNewPage> {
|
||||
bloc.exerciseRepository.exercise.quantity.round().toString() :
|
||||
bloc.exerciseRepository.exercise.quantity.toString();
|
||||
|
||||
String unitQuantity = bloc.exerciseRepository.exercise.unitQuantity % 1 == 0?
|
||||
bloc.exerciseRepository.exercise.unitQuantity.round().toString() :
|
||||
bloc.exerciseRepository.exercise.unitQuantity.toString();
|
||||
String unitQuantity = "";
|
||||
if ( bloc.exerciseRepository.exercise.unitQuantity != null ) {
|
||||
unitQuantity = bloc.exerciseRepository.exercise.unitQuantity % 1 == 0 ?
|
||||
bloc.exerciseRepository.exercise.unitQuantity.round().toString() :
|
||||
bloc.exerciseRepository.exercise.unitQuantity.toString();
|
||||
}
|
||||
|
||||
|
||||
showCupertinoDialog(
|
||||
@ -261,7 +266,7 @@ class _ExerciseNewPageState extends State<ExerciseNewPage> {
|
||||
children: [
|
||||
Divider(),
|
||||
Text(AppLocalizations.of(context).translate("Exercise") + ": " +
|
||||
AppLocalizations.of(context).translate(bloc.exerciseRepository.exerciseType.name),
|
||||
bloc.exerciseRepository.exerciseType.name,
|
||||
style: (TextStyle(color: Colors.blue)),),
|
||||
Text(quantity + " " +
|
||||
AppLocalizations.of(context).translate(bloc.exerciseRepository.exerciseType.unit),
|
||||
@ -285,10 +290,16 @@ class _ExerciseNewPageState extends State<ExerciseNewPage> {
|
||||
onPressed: () => {
|
||||
bloc.exerciseRepository.setCustomer(Cache().userLoggedIn),
|
||||
bloc.exerciseRepository.addExercise(),
|
||||
|
||||
Navigator.pop(context),
|
||||
Navigator.pop(context),
|
||||
},
|
||||
if ( bloc.exerciseRepository.exerciseType.is1RM ) {
|
||||
args['exerciseRepository'] = bloc.exerciseRepository,
|
||||
args['percent'] = 0.75,
|
||||
args['readonly'] = false,
|
||||
Navigator.of(context).pushNamed('exerciseControlPage',
|
||||
arguments: args )
|
||||
}
|
||||
},
|
||||
)
|
||||
],
|
||||
)
|
||||
|
147
lib/view/mydevelopment_page.dart
Normal file
147
lib/view/mydevelopment_page.dart
Normal file
@ -0,0 +1,147 @@
|
||||
import 'package:aitrainer_app/localization/app_language.dart';
|
||||
import 'package:aitrainer_app/localization/app_localization.dart';
|
||||
import 'package:aitrainer_app/model/exercise.dart';
|
||||
import 'package:aitrainer_app/model/exercise_type.dart';
|
||||
import 'package:aitrainer_app/repository/exercise_repository.dart';
|
||||
import 'package:aitrainer_app/widgets/app_bar.dart';
|
||||
import 'package:aitrainer_app/widgets/bottom_nav.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_treeview/tree_view.dart';
|
||||
|
||||
class MyDevelopmentPage extends StatefulWidget {
|
||||
@override
|
||||
_MyDevelopmentPage createState() => _MyDevelopmentPage();
|
||||
}
|
||||
|
||||
class _MyDevelopmentPage extends State<MyDevelopmentPage> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final ExerciseRepository exerciseRepository = ExerciseRepository();
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBarNav(),
|
||||
body: Container(
|
||||
decoration: BoxDecoration(
|
||||
image: DecorationImage(
|
||||
image: AssetImage('asset/image/WT_light_background.png'),
|
||||
fit: BoxFit.cover,
|
||||
alignment: Alignment.center,
|
||||
),
|
||||
),
|
||||
child: Container(
|
||||
padding: EdgeInsets.all(10),
|
||||
child:
|
||||
exerciseWidget(exerciseRepository),
|
||||
|
||||
)
|
||||
),
|
||||
bottomNavigationBar: BottomNavigator(bottomNavIndex: 1));
|
||||
}
|
||||
|
||||
Widget exerciseWidget(ExerciseRepository exerciseRepository) {
|
||||
TreeViewController _treeViewController = TreeViewController(children: nodeExercises(exerciseRepository) );
|
||||
|
||||
TreeViewTheme _treeViewTheme = TreeViewTheme(
|
||||
expanderTheme: ExpanderThemeData(
|
||||
type: ExpanderType.caret,
|
||||
modifier: ExpanderModifier.none,
|
||||
position: ExpanderPosition.start,
|
||||
color: Colors.red.shade800,
|
||||
size: 20,
|
||||
),
|
||||
labelStyle: TextStyle(
|
||||
fontSize: 12,
|
||||
letterSpacing: 0.1,
|
||||
),
|
||||
parentLabelStyle: TextStyle(
|
||||
fontSize: 16,
|
||||
letterSpacing: 0.1,
|
||||
fontWeight: FontWeight.w800,
|
||||
color: Colors.orange.shade600,
|
||||
),
|
||||
iconTheme: IconThemeData(
|
||||
size: 18,
|
||||
color: Colors.grey.shade800,
|
||||
),
|
||||
colorScheme: ColorScheme.light(
|
||||
background: Colors.transparent
|
||||
),
|
||||
);
|
||||
|
||||
return TreeView(
|
||||
controller: _treeViewController,
|
||||
allowParentSelect: false,
|
||||
supportParentDoubleTap: false,
|
||||
//onExpansionChanged: _expandNodeHandler,
|
||||
onNodeTap: (key) {
|
||||
setState(() {
|
||||
_treeViewController = _treeViewController.copyWith(selectedKey: key);
|
||||
});
|
||||
},
|
||||
theme: _treeViewTheme,
|
||||
);
|
||||
}
|
||||
|
||||
List<Node> nodeExercises(ExerciseRepository exerciseRepository) {
|
||||
List<Node> nodes = List<Node>();
|
||||
List<Exercise> exercises = exerciseRepository.getExerciseList();
|
||||
|
||||
String prevDay = "";
|
||||
Node actualNode;
|
||||
List<Node> listExercisesPerDay;
|
||||
exercises.forEach((element) {
|
||||
Exercise exercise = element;
|
||||
ExerciseType exerciseType =
|
||||
exerciseRepository.getExerciseTypeById(exercise.exerciseTypeId);
|
||||
String actualDay = exercise.dateAdd.year.toString()+"-"+
|
||||
exercise.dateAdd.month.toString()+"-"+
|
||||
exercise.dateAdd.day.toString();
|
||||
|
||||
if ( prevDay.compareTo(actualDay) != 0) {
|
||||
listExercisesPerDay = List<Node>();
|
||||
actualNode =
|
||||
Node(
|
||||
label: actualDay,
|
||||
key: exercise.dateAdd.toString(),
|
||||
expanded: true,
|
||||
children: listExercisesPerDay,
|
||||
icon: NodeIcon(
|
||||
codePoint: Icons.date_range.codePoint,
|
||||
color: "blue"
|
||||
)
|
||||
);
|
||||
nodes.add(actualNode);
|
||||
prevDay = actualDay;
|
||||
}
|
||||
|
||||
String exerciseName = AppLanguage().appLocal == Locale("en") ?
|
||||
exerciseType.name :
|
||||
exerciseType.nameTranslation;
|
||||
String unitQuantity = exerciseType.unitQuantity == "1" ?
|
||||
exercise.unitQuantity.toStringAsFixed(0)
|
||||
+ " " + AppLocalizations.of(context).translate(exerciseType.unitQuantityUnit) + " "
|
||||
: "";
|
||||
|
||||
String labelExercise =
|
||||
exerciseName + " " + unitQuantity
|
||||
+ exercise.quantity.toStringAsFixed(0) + " "
|
||||
+ AppLocalizations.of(context).translate(exercise.unit);
|
||||
listExercisesPerDay.add(
|
||||
Node(
|
||||
label: labelExercise,
|
||||
key: exercise.exerciseId.toString(),
|
||||
expanded: false,
|
||||
icon: NodeIcon(
|
||||
codePoint: Icons.repeat.codePoint,
|
||||
color: "blue"
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
});
|
||||
return nodes;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -69,7 +69,7 @@ class SettingsPage extends StatelessWidget{
|
||||
),
|
||||
),
|
||||
),
|
||||
bottomNavigationBar: BottomNavigator(bottomNavIndex: 3)
|
||||
bottomNavigationBar: BottomNavigator(bottomNavIndex: 4)
|
||||
|
||||
);
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ import 'dart:async';
|
||||
import 'package:aitrainer_app/animations/test_progress_animation.dart';
|
||||
import 'package:aitrainer_app/bloc/menu/menu_bloc.dart';
|
||||
import 'package:aitrainer_app/localization/app_localization.dart';
|
||||
import 'package:aitrainer_app/model/cache.dart';
|
||||
import 'package:aitrainer_app/repository/exercise_repository.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@ -29,9 +30,9 @@ class _AppBarNav extends State<AppBarNav> with SingleTickerProviderStateMixin {
|
||||
//AnimationController sizeController;
|
||||
MenuBloc menuBloc;
|
||||
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
|
||||
colorController =
|
||||
AnimationController(duration: Duration(seconds: 4), vsync: this);
|
||||
//sizeController =
|
||||
@ -68,8 +69,10 @@ class _AppBarNav extends State<AppBarNav> with SingleTickerProviderStateMixin {
|
||||
..addStatusListener((status) {
|
||||
if (status == AnimationStatus.completed) {
|
||||
Timer(Duration(seconds: 10), () {
|
||||
colorController.reset();
|
||||
colorController.forward();
|
||||
//colorController.reset();
|
||||
if ( mounted ) {
|
||||
colorController.forward();
|
||||
}
|
||||
});
|
||||
} else if (status == AnimationStatus.dismissed) {
|
||||
colorController.forward();
|
||||
@ -114,9 +117,14 @@ class _AppBarNav extends State<AppBarNav> with SingleTickerProviderStateMixin {
|
||||
}
|
||||
|
||||
Widget getAnimatedWidget() {
|
||||
ExerciseRepository exerciseRepository = ExerciseRepository();
|
||||
exerciseRepository.getExerciseList();
|
||||
if ( exerciseRepository.exerciseList == null || exerciseRepository.exerciseList.length == 0 ) {
|
||||
double percent = Cache().getPercentExercises();
|
||||
if ( percent == -1) {
|
||||
ExerciseRepository exerciseRepository = ExerciseRepository();
|
||||
exerciseRepository.getBaseExerciseFinishedPercent();
|
||||
percent = Cache().getPercentExercises();
|
||||
}
|
||||
int sizeExerciseList = Cache().getExercises() == null? 0 : Cache().getExercises().length;
|
||||
if ( sizeExerciseList == 0 ) {
|
||||
return Stack(
|
||||
alignment: Alignment.topLeft,
|
||||
children: [
|
||||
@ -128,7 +136,7 @@ class _AppBarNav extends State<AppBarNav> with SingleTickerProviderStateMixin {
|
||||
]
|
||||
);
|
||||
} else {
|
||||
double percent = 0.61;//exerciseRepository.getBaseExerciseFinishedPercent();
|
||||
|
||||
return Stack(
|
||||
alignment: Alignment.topLeft,
|
||||
children: [
|
||||
|
@ -1,6 +1,8 @@
|
||||
import 'package:aitrainer_app/localization/app_localization.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:gradient_bottom_navigation_bar/gradient_bottom_navigation_bar.dart';
|
||||
|
||||
// ignore: must_be_immutable
|
||||
class BottomNavigator extends StatefulWidget {
|
||||
int bottomNavIndex = 0;
|
||||
BottomNavigator({this.bottomNavIndex}) {
|
||||
@ -21,68 +23,97 @@ class _NawDrawerWidget extends State<BottomNavigator> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final Color bgrColor = Color(0xffb4f500);
|
||||
final Color bgrColorEnd = Colors.blue;
|
||||
final Color active = Colors.black;
|
||||
final Color inactive = Colors.black26;
|
||||
|
||||
return BottomNavigationBar(
|
||||
/*final Color bgrColor = Colors.black;
|
||||
final Color active = Colors.yellowAccent;
|
||||
final Color inactive = Colors.white60;*/
|
||||
//
|
||||
|
||||
return GradientBottomNavigationBar(
|
||||
currentIndex: widget.bottomNavIndex, // this will be set when a new tab is tapped
|
||||
backgroundColor: Colors.transparent,
|
||||
selectedItemColor: Colors.yellow,
|
||||
unselectedItemColor: Colors.lightGreen,
|
||||
//type: BottomNavigationBarType.shifting,
|
||||
showSelectedLabels: true,
|
||||
showUnselectedLabels: true,
|
||||
backgroundColorStart: bgrColorEnd,
|
||||
backgroundColorEnd: bgrColor,
|
||||
fixedColor: active,
|
||||
//selectedItemColor: active,
|
||||
//unselectedItemColor: inactive,
|
||||
//showSelectedLabels: true,
|
||||
//showUnselectedLabels: true,
|
||||
items: [
|
||||
BottomNavigationBarItem(
|
||||
backgroundColor: Colors.black12,
|
||||
icon: new Icon(Icons.home, color: Colors.lightGreen),
|
||||
activeIcon: new Icon(Icons.home, color: Colors.yellow,),
|
||||
title: new Text(AppLocalizations.of(context).translate("Home")),
|
||||
backgroundColor: bgrColor,
|
||||
icon: new Icon(Icons.home, color: inactive),
|
||||
activeIcon: new Icon(Icons.home, color: active,),
|
||||
title: new Text(AppLocalizations.of(context).translate("Home"),
|
||||
style: TextStyle(fontSize: 9)),
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
backgroundColor: Colors.black12,
|
||||
icon: new Icon(Icons.confirmation_number, color: Colors.lightGreen),
|
||||
activeIcon: new Icon(Icons.event, color: Colors.yellow,),
|
||||
title: new Text(AppLocalizations.of(context).translate("Events")),
|
||||
backgroundColor: bgrColor,
|
||||
icon: new Icon(Icons.trending_up, color: inactive),
|
||||
activeIcon: new Icon(Icons.trending_up, color: active,),
|
||||
title: new Text(AppLocalizations.of(context).translate("My Development"),
|
||||
style: TextStyle(fontSize: 9),),
|
||||
),
|
||||
|
||||
BottomNavigationBarItem(
|
||||
backgroundColor: Colors.black12,
|
||||
icon: Icon(Icons.person, color: Colors.lightGreen,),
|
||||
activeIcon: new Icon(Icons.person, color: Colors.yellow,),
|
||||
title: Text(AppLocalizations.of(context).translate("Account"))
|
||||
backgroundColor: bgrColor,
|
||||
icon: new Icon(Icons.featured_play_list, color: inactive),
|
||||
activeIcon: new Icon(Icons.featured_play_list, color: active,),
|
||||
title: new Text(AppLocalizations.of(context).translate("My Training Plan"),
|
||||
style: TextStyle(fontSize: 9),),
|
||||
),
|
||||
|
||||
BottomNavigationBarItem(
|
||||
backgroundColor: bgrColor,
|
||||
icon: Icon(Icons.person, color: inactive,),
|
||||
activeIcon: new Icon(Icons.person, color: active,),
|
||||
title: Text(AppLocalizations.of(context).translate("Account"),
|
||||
style: TextStyle(fontSize: 9),)
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
backgroundColor: Colors.black12,
|
||||
icon: Icon(Icons.settings, color: Colors.lightGreen),
|
||||
activeIcon: new Icon(Icons.settings, color: Colors.yellow,),
|
||||
title: Text(AppLocalizations.of(context).translate("Settings"))
|
||||
backgroundColor: bgrColor,
|
||||
icon: Icon(Icons.settings, color: inactive),
|
||||
activeIcon: new Icon(Icons.settings, color: active,),
|
||||
title: Text(AppLocalizations.of(context).translate("Settings"),
|
||||
style: TextStyle(fontSize: 9))
|
||||
)
|
||||
],
|
||||
onTap:(index) {
|
||||
setState(() {
|
||||
widget.bottomNavIndex = index;
|
||||
});
|
||||
switch (index) {
|
||||
case 0:
|
||||
Navigator.of(context).pop();
|
||||
Navigator.of(context).pushNamed('home');
|
||||
switch (index) {
|
||||
case 0:
|
||||
Navigator.of(context).pop();
|
||||
Navigator.of(context).pushNamed('home');
|
||||
|
||||
break;
|
||||
case 1:
|
||||
Navigator.of(context).pop();
|
||||
Navigator.of(context).pushNamed('mydevelopment');
|
||||
break;
|
||||
case 2:
|
||||
|
||||
break;
|
||||
case 1:
|
||||
//throw new StateError('This is a Dart exception on event.');
|
||||
|
||||
break;
|
||||
case 2:
|
||||
Navigator.of(context).pop();
|
||||
Navigator.of(context).pushNamed('account');
|
||||
break;
|
||||
case 3:
|
||||
Navigator.of(context).pop();
|
||||
Navigator.of(context).pushNamed('account');
|
||||
|
||||
break;
|
||||
case 3:
|
||||
Navigator.of(context).pop();
|
||||
Navigator.of(context).pushNamed('settings');
|
||||
break;
|
||||
case 4:
|
||||
Navigator.of(context).pop();
|
||||
Navigator.of(context).pushNamed('settings');
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -82,12 +82,9 @@ class MenuPageWidget extends StatelessWidget {
|
||||
AppLocalizations.of(context).translate('Please log in'),
|
||||
style: TextStyle(color: Colors.white))));
|
||||
} else {
|
||||
if (workoutTree.exerciseType.name == "Custom") {
|
||||
if (workoutTree.exerciseType.name == "Custom" && Cache().userLoggedIn.admin == 1) {
|
||||
Navigator.of(context).pushNamed('exerciseCustomPage',
|
||||
arguments: workoutTree.exerciseType);
|
||||
} else if (workoutTree.exerciseType.name == "Control") {
|
||||
Navigator.of(context).pushNamed('exerciseControlPage',
|
||||
arguments: workoutTree.exerciseType);
|
||||
} else {
|
||||
Navigator.of(context).pushNamed('exerciseNewPage',
|
||||
arguments: workoutTree.exerciseType);
|
||||
@ -108,17 +105,6 @@ class MenuPageWidget extends StatelessWidget {
|
||||
|
||||
dynamic _getButtonImage(WorkoutTree workoutTree) {
|
||||
dynamic image;
|
||||
/*String url = workoutTree.imageName;
|
||||
if ( workoutTree.imageName.startsWith("https") ) {
|
||||
image = FadeInImage.assetNetwork(
|
||||
placeholder: 'asset/image/dots.gif',
|
||||
image: url,
|
||||
height: 180,
|
||||
);
|
||||
} else {
|
||||
image = Image.asset(workoutTree.imageName, height: 180,);
|
||||
}*/
|
||||
|
||||
try {
|
||||
image = Image.asset(
|
||||
workoutTree.imageName,
|
||||
|
24
pubspec.lock
24
pubspec.lock
@ -42,14 +42,14 @@ packages:
|
||||
name: bloc
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "6.0.2"
|
||||
version: "6.0.3"
|
||||
bloc_test:
|
||||
dependency: "direct dev"
|
||||
description:
|
||||
name: bloc_test
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "7.0.2"
|
||||
version: "7.0.3"
|
||||
boolean_selector:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -250,7 +250,7 @@ packages:
|
||||
name: flutter_bloc
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "6.0.1"
|
||||
version: "6.0.4"
|
||||
flutter_driver:
|
||||
dependency: "direct dev"
|
||||
description: flutter
|
||||
@ -276,7 +276,7 @@ packages:
|
||||
name: flutter_keyboard_visibility
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "3.2.1"
|
||||
version: "3.2.2"
|
||||
flutter_launcher_icons:
|
||||
dependency: "direct dev"
|
||||
description:
|
||||
@ -308,6 +308,13 @@ packages:
|
||||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.0"
|
||||
flutter_treeview:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: flutter_treeview
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.6.0+1"
|
||||
flutter_web_plugins:
|
||||
dependency: transitive
|
||||
description: flutter
|
||||
@ -346,6 +353,13 @@ packages:
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.2.0"
|
||||
gradient_bottom_navigation_bar:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: gradient_bottom_navigation_bar
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.0.0+4"
|
||||
graphs:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -812,7 +826,7 @@ packages:
|
||||
name: uuid
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.2.0"
|
||||
version: "2.2.2"
|
||||
vector_math:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -32,13 +32,15 @@ dependencies:
|
||||
# firebase_messaging: ^6.0.16
|
||||
flutter_local_notifications: 1.1.1
|
||||
flutter_facebook_login: ^3.0.0
|
||||
flutter_bloc: ^6.0.1
|
||||
flutter_bloc: ^6.0.4
|
||||
equatable: ^1.2.4
|
||||
freezed: ^0.11.6
|
||||
flutter_form_bloc: ^0.19.0
|
||||
spider_chart: ^0.1.5
|
||||
rainbow_color: ^0.1.1
|
||||
percent_indicator: ^2.1.5
|
||||
gradient_bottom_navigation_bar: ^1.0.0+4
|
||||
flutter_treeview: ^0.6.0+1
|
||||
|
||||
mockito: ^4.1.1
|
||||
|
||||
@ -49,7 +51,7 @@ dev_dependencies:
|
||||
flutter_driver:
|
||||
sdk: flutter
|
||||
test: any
|
||||
bloc_test: ^7.0.2
|
||||
bloc_test: ^7.0.1
|
||||
|
||||
build_runner:
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user