diff --git a/i18n/en.json b/i18n/en.json index 5315f9f..244ce60 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -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" } \ No newline at end of file diff --git a/i18n/hu.json b/i18n/hu.json index debfcca..f553264 100644 --- a/i18n/hu.json +++ b/i18n/hu.json @@ -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" } \ No newline at end of file diff --git a/lib/animations/test_progress_animation.dart b/lib/animations/test_progress_animation.dart index 7b1d6cc..f144723 100644 --- a/lib/animations/test_progress_animation.dart +++ b/lib/animations/test_progress_animation.dart @@ -1,4 +1,3 @@ -import 'package:aitrainer_app/localization/app_localization.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; diff --git a/lib/bloc/exercise_control_form_bloc.dart b/lib/bloc/exercise_control_form_bloc.dart index efbd8ec..7ce6808 100644 --- a/lib/bloc/exercise_control_form_bloc.dart +++ b/lib/bloc/exercise_control_form_bloc.dart @@ -6,6 +6,7 @@ class ExerciseControlFormBloc extends FormBloc { final ExerciseRepository exerciseRepository; int step = 1; final double percentToCalculate; + final bool readonly; final initialRMField = TextFieldBloc( ); @@ -30,7 +31,7 @@ class ExerciseControlFormBloc extends FormBloc { - ExerciseControlFormBloc({this.exerciseRepository, this.percentToCalculate}) { + ExerciseControlFormBloc({this.exerciseRepository, this.percentToCalculate, this.readonly}) { addFieldBlocs(fieldBlocs: [ initialRMField, quantity1Field, @@ -49,25 +50,19 @@ class ExerciseControlFormBloc extends FormBloc { 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 { //updatedRMField.updateInitialValue(calculate1RM(percent75: false).toStringAsFixed(0)); } - //await exerciseRepository.addExercise(); + if ( ! readonly ) { + await exerciseRepository.addExercise(); + } emitSuccess(canSubmitAgain: true); } on Exception catch (ex) { diff --git a/lib/bloc/settings/settings_bloc.dart b/lib/bloc/settings/settings_bloc.dart index 2b94ef9..af2d4b5 100644 --- a/lib/bloc/settings/settings_bloc.dart +++ b/lib/bloc/settings/settings_bloc.dart @@ -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'; diff --git a/lib/localization/app_language.dart b/lib/localization/app_language.dart index 2cf98d3..11fad94 100644 --- a/lib/localization/app_language.dart +++ b/lib/localization/app_language.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(); } } diff --git a/lib/main.dart b/lib/main.dart index 338231c..213155a 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -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', diff --git a/lib/model/cache.dart b/lib/model/cache.dart index a22104d..af29450 100644 --- a/lib/model/cache.dart +++ b/lib/model/cache.dart @@ -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; List _exercises; LinkedHashMap _tree = LinkedHashMap(); + 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); + } + } \ No newline at end of file diff --git a/lib/repository/exercise_repository.dart b/lib/repository/exercise_repository.dart index 10e2b77..885305f 100644 --- a/lib/repository/exercise_repository.dart +++ b/lib/repository/exercise_repository.dart @@ -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 checkedExerciseTypeId = List(); + List baseTreeItem = List(); + List checkedBaseTreeItem = List(); + int count1RMExercises = 0; + LinkedHashMap 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; } + } \ No newline at end of file diff --git a/lib/repository/menu_tree_repository.dart b/lib/repository/menu_tree_repository.dart index 4d39a5a..0526e0c 100644 --- a/lib/repository/menu_tree_repository.dart +++ b/lib/repository/menu_tree_repository.dart @@ -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(); Future createTree() async { - final AppLanguage appLanguage = AppLanguage(); bool isEnglish = appLanguage.appLocal == Locale('en'); + print("** Start creating tree on lang: " + appLanguage.appLocal.toString()); List 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; } diff --git a/lib/util/env.dart b/lib/util/env.dart new file mode 100644 index 0000000..894f096 --- /dev/null +++ b/lib/util/env.dart @@ -0,0 +1,3 @@ +class EnvironmentConfig { + static const test_env = String.fromEnvironment('test_env'); +} \ No newline at end of file diff --git a/lib/view/account.dart b/lib/view/account.dart index 8084fd5..485d53d 100644 --- a/lib/view/account.dart +++ b/lib/view/account.dart @@ -65,7 +65,7 @@ class AccountPage extends StatelessWidget { } ), ), - bottomNavigationBar: BottomNavigator(bottomNavIndex: 2)); + bottomNavigationBar: BottomNavigator(bottomNavIndex: 3)); } ListView accountWidget(BuildContext context, String customerName, AccountBloc accountBloc) { diff --git a/lib/view/custom_exercise_page.dart b/lib/view/custom_exercise_page.dart index f2e0102..1282e9b 100644 --- a/lib/view/custom_exercise_page.dart +++ b/lib/view/custom_exercise_page.dart @@ -277,7 +277,7 @@ class _CustomExerciseNewPageState extends State { 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 { 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 { 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 { { 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 { { args['exerciseRepository'] = bloc.exerciseRepository, args['percent'] = 0.5, + args['readonly'] = true, Navigator.of(context).pushNamed('exerciseControlPage', arguments: args ) }, diff --git a/lib/view/exercise_control_page.dart b/lib/view/exercise_control_page.dart index 963994e..5e1201a 100644 --- a/lib/view/exercise_control_page.dart +++ b/lib/view/exercise_control_page.dart @@ -22,10 +22,11 @@ class _ExerciseControlPage extends State { 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( builder: (context, state) { // ignore: close_sinks @@ -148,12 +149,7 @@ class _ExerciseControlPage extends State { 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, diff --git a/lib/view/exercise_new_page.dart b/lib/view/exercise_new_page.dart index 2673f43..30c7912 100644 --- a/lib/view/exercise_new_page.dart +++ b/lib/view/exercise_new_page.dart @@ -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 { } 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 { 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 { 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 { 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 ) + } + }, ) ], ) diff --git a/lib/view/mydevelopment_page.dart b/lib/view/mydevelopment_page.dart new file mode 100644 index 0000000..b6324e1 --- /dev/null +++ b/lib/view/mydevelopment_page.dart @@ -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 { + @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 nodeExercises(ExerciseRepository exerciseRepository) { + List nodes = List(); + List exercises = exerciseRepository.getExerciseList(); + + String prevDay = ""; + Node actualNode; + List 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(); + 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; + } +} + + diff --git a/lib/view/settings.dart b/lib/view/settings.dart index d2db3fd..03bad7d 100644 --- a/lib/view/settings.dart +++ b/lib/view/settings.dart @@ -69,7 +69,7 @@ class SettingsPage extends StatelessWidget{ ), ), ), - bottomNavigationBar: BottomNavigator(bottomNavIndex: 3) + bottomNavigationBar: BottomNavigator(bottomNavIndex: 4) ); } diff --git a/lib/widgets/app_bar.dart b/lib/widgets/app_bar.dart index 38eae78..d20d300 100644 --- a/lib/widgets/app_bar.dart +++ b/lib/widgets/app_bar.dart @@ -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 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 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 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 with SingleTickerProviderStateMixin { ] ); } else { - double percent = 0.61;//exerciseRepository.getBaseExerciseFinishedPercent(); + return Stack( alignment: Alignment.topLeft, children: [ diff --git a/lib/widgets/bottom_nav.dart b/lib/widgets/bottom_nav.dart index bf0c86a..4d9715c 100644 --- a/lib/widgets/bottom_nav.dart +++ b/lib/widgets/bottom_nav.dart @@ -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 { @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; - } - } ); } diff --git a/lib/widgets/menu_page_widget.dart b/lib/widgets/menu_page_widget.dart index 477f747..8dfd097 100644 --- a/lib/widgets/menu_page_widget.dart +++ b/lib/widgets/menu_page_widget.dart @@ -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, diff --git a/pubspec.lock b/pubspec.lock index e0c822f..a77334a 100644 --- a/pubspec.lock +++ b/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: diff --git a/pubspec.yaml b/pubspec.yaml index a6db8cc..0fef500 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -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: