diff --git a/asset/menu/leg_abductor.jpg b/asset/menu/leg_abductor.jpg new file mode 100644 index 0000000..add4b11 Binary files /dev/null and b/asset/menu/leg_abductor.jpg differ diff --git a/i18n/en.json b/i18n/en.json index 7e6994f..4c5ba68 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -400,6 +400,7 @@ "Or, you can redifine this exercise queue in the Compact Test menu":"Or, you can redifine this exercise queue in the Compact Test menu", "you are able to do 12-20 repeats with":"you are able to do 12-20 repeats with", "You have an active Test Set!":"You have an active Test Set!", + "Do you want to override it?":"Do you want to override it?", "Press OK to continue":"Press OK to continue", "Continue":"Continue", " your ":" your ", diff --git a/i18n/hu.json b/i18n/hu.json index cdac4f0..830090c 100644 --- a/i18n/hu.json +++ b/i18n/hu.json @@ -396,6 +396,7 @@ "Or, you can redifine this exercise queue in the Compact Test menu":"Vagy változtatsd meg a gyakorlatokat a Tesztközpontban", "you are able to do 12-20 repeats with":"amivel képes vagy 12-20 ismétlésre", "You have an active Test Set!":"Van egy aktiv tesztköröd!", + "Do you want to override it?":"Felülírod?", "Press OK to continue":"Nyomd meg az OK-t a folytatáshoz", "Continue":"Folytatsd", " your ":": ", diff --git a/ios/Flutter/AppFrameworkInfo.plist b/ios/Flutter/AppFrameworkInfo.plist index 3158eba..cae6543 100644 --- a/ios/Flutter/AppFrameworkInfo.plist +++ b/ios/Flutter/AppFrameworkInfo.plist @@ -21,6 +21,6 @@ CFBundleVersion 1.0 MinimumOSVersion - 10.0 + 12.0 diff --git a/ios/Flutter/Debug.xcconfig b/ios/Flutter/Debug.xcconfig index e8efba1..715f00a 100644 --- a/ios/Flutter/Debug.xcconfig +++ b/ios/Flutter/Debug.xcconfig @@ -1,2 +1,3 @@ #include "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" -#include "Generated.xcconfig" +#include "./Generated.xcconfig" +IPHONEOS_DEPLOYMENT_TARGET = 12.0 diff --git a/ios/Flutter/Release.xcconfig b/ios/Flutter/Release.xcconfig index 399e934..ff13634 100644 --- a/ios/Flutter/Release.xcconfig +++ b/ios/Flutter/Release.xcconfig @@ -1,2 +1,3 @@ #include "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" -#include "Generated.xcconfig" +#include "./Generated.xcconfig" +IPHONEOS_DEPLOYMENT_TARGET = 12.0 diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 0920532..e3ce06e 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -171,6 +171,8 @@ PODS: - Purchases (= 3.9.2) - shared_preferences (0.0.1): - Flutter + - smartlook (0.0.5): + - Flutter - sqflite (0.0.2): - Flutter - FMDB (>= 2.7.5) @@ -199,6 +201,7 @@ DEPENDENCIES: - path_provider (from `.symlinks/plugins/path_provider/ios`) - purchases_flutter (from `.symlinks/plugins/purchases_flutter/ios`) - shared_preferences (from `.symlinks/plugins/shared_preferences/ios`) + - smartlook (from `.symlinks/plugins/smartlook/ios`) - sqflite (from `.symlinks/plugins/sqflite/ios`) - video_player (from `.symlinks/plugins/video_player/ios`) - wakelock (from `.symlinks/plugins/wakelock/ios`) @@ -267,6 +270,8 @@ EXTERNAL SOURCES: :path: ".symlinks/plugins/purchases_flutter/ios" shared_preferences: :path: ".symlinks/plugins/shared_preferences/ios" + smartlook: + :path: ".symlinks/plugins/smartlook/ios" sqflite: :path: ".symlinks/plugins/sqflite/ios" video_player: @@ -319,6 +324,7 @@ SPEC CHECKSUMS: PurchasesCoreSwift: ea4eabae180416e580ac60366f41aa1fefec0693 PurchasesHybridCommon: d9bfb34309db4c9ba82a6f7f3a6275c13befdca7 shared_preferences: af6bfa751691cdc24be3045c43ec037377ada40d + smartlook: bda0b1561935a02ef0fea5448258d5ac75027859 sqflite: 6d358c025f5b867b29ed92fc697fd34924e11904 video_player: 9cc823b1d9da7e8427ee591e8438bfbcde500e6e wakelock: bfc7955c418d0db797614075aabbc58a39ab5107 diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index 7c37065..856caf9 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -388,7 +388,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; - CURRENT_PROJECT_VERSION = 3; + CURRENT_PROJECT_VERSION = 5; DEVELOPMENT_TEAM = SFJJBDCU6Z; ENABLE_BITCODE = NO; FRAMEWORK_SEARCH_PATHS = ( @@ -531,7 +531,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; - CURRENT_PROJECT_VERSION = 3; + CURRENT_PROJECT_VERSION = 5; DEVELOPMENT_TEAM = SFJJBDCU6Z; ENABLE_BITCODE = NO; FRAMEWORK_SEARCH_PATHS = ( @@ -566,7 +566,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; - CURRENT_PROJECT_VERSION = 3; + CURRENT_PROJECT_VERSION = 5; DEVELOPMENT_TEAM = SFJJBDCU6Z; ENABLE_BITCODE = NO; FRAMEWORK_SEARCH_PATHS = ( diff --git a/ios/Runner/Info.plist b/ios/Runner/Info.plist index c1bb7ff..da4d36f 100644 --- a/ios/Runner/Info.plist +++ b/ios/Runner/Info.plist @@ -44,7 +44,7 @@ fbshareextension LSMinimumSystemVersion - 10.0 + 12.0 LSRequiresIPhoneOS NSAppTransportSecurity diff --git a/lib/bloc/development_by_muscle/development_by_muscle_bloc.dart b/lib/bloc/development_by_muscle/development_by_muscle_bloc.dart index 94f8cd7..3101f07 100644 --- a/lib/bloc/development_by_muscle/development_by_muscle_bloc.dart +++ b/lib/bloc/development_by_muscle/development_by_muscle_bloc.dart @@ -1,6 +1,7 @@ import 'dart:async'; import 'dart:collection'; +import 'package:aitrainer_app/model/cache.dart'; import 'package:aitrainer_app/util/app_language.dart'; import 'package:aitrainer_app/model/exercise.dart'; import 'package:aitrainer_app/model/workout_menu_tree.dart'; @@ -113,6 +114,9 @@ class GroupDate extends GroupData with Calculate, Common { @override void temp2Output(Exercise exercise) { + if (exercise.unitQuantity == null) { + return; + } Exercise newExercise = exercise.copy(); newExercise.datePart = _origDatePart; if (this.diagramType == DiagramType.oneRepMax || this.diagramType == DiagramType.percent) { @@ -284,9 +288,7 @@ class DevelopmentByMuscleBloc extends Bloc getData() async { workoutTreeRepository.sortedTree = null; @@ -365,6 +367,8 @@ class DevelopmentByMuscleBloc extends Bloc { try { if (event is ExerciseLogLoad) { yield ExerciseLogLoading(); + await Cache().setExerciseLogSeen(); Track().track(TrackingEvent.exercise_log_open); yield ExerciseLogReady(); } else if (event is ExerciseLogDelete) { diff --git a/lib/bloc/exercise_new/exercise_new_bloc.dart b/lib/bloc/exercise_new/exercise_new_bloc.dart index bd525da..0e28f3c 100644 --- a/lib/bloc/exercise_new/exercise_new_bloc.dart +++ b/lib/bloc/exercise_new/exercise_new_bloc.dart @@ -94,6 +94,7 @@ class ExerciseNewBloc extends Bloc with Logg yield ExerciseNewReady(); } else if (event is ExerciseNewQuantityUnitChange) { yield ExerciseNewLoading(); + log("Event quantityUnit " + event.quantity.toStringAsFixed(0)); exerciseRepository.setUnitQuantity(event.quantity); unitQuantity = event.quantity; yield ExerciseNewReady(); @@ -147,7 +148,7 @@ class ExerciseNewBloc extends Bloc with Logg yield ExerciseNewLoading(); exerciseRepository.end = DateTime.now(); await exerciseRepository.addExercise(); - exerciseRepository.initExercise(); +// exerciseRepository.initExercise(); menuBloc.add(MenuTreeDown(parent: 0)); Cache().initBadges(); Track().track(TrackingEvent.exercise_new, eventValue: exerciseRepository.exerciseType.name); diff --git a/lib/bloc/login/login_bloc.dart b/lib/bloc/login/login_bloc.dart index 1a00855..e6b9910 100644 --- a/lib/bloc/login/login_bloc.dart +++ b/lib/bloc/login/login_bloc.dart @@ -4,8 +4,6 @@ import 'package:aitrainer_app/bloc/account/account_bloc.dart'; import 'package:aitrainer_app/model/cache.dart'; import 'package:aitrainer_app/repository/customer_repository.dart'; import 'package:aitrainer_app/repository/user_repository.dart'; -import 'package:aitrainer_app/service/exercise_tree_service.dart'; -import 'package:aitrainer_app/service/exercise_type_service.dart'; import 'package:aitrainer_app/util/common.dart'; import 'package:aitrainer_app/util/enums.dart'; import 'package:aitrainer_app/util/track.dart'; @@ -25,12 +23,7 @@ class LoginBloc extends Bloc with Trans { final bool isRegistration; bool dataPolicyAllowed = false; bool obscure = true; - LoginBloc({this.accountBloc, this.userRepository, this.context, this.isRegistration}) : super(LoginInitial()) { - if (isRegistration) { - ExerciseTreeApi().getExerciseTree(); - ExerciseTypeApi().getExerciseTypes(); - } - } + LoginBloc({this.accountBloc, this.userRepository, this.context, this.isRegistration}) : super(LoginInitial()); @override Stream mapEventToState( diff --git a/lib/bloc/settings/settings_bloc.dart b/lib/bloc/settings/settings_bloc.dart index 18aa73a..a702296 100644 --- a/lib/bloc/settings/settings_bloc.dart +++ b/lib/bloc/settings/settings_bloc.dart @@ -43,11 +43,11 @@ class SettingsBloc extends Bloc with Logging { _locale = AppLanguage().appLocal; yield SettingsReady(_locale); } else if (event is SettingsSetServer) { - yield SettingsLoading(); + //yield SettingsLoading(); final bool live = event.live; Cache().setServer(live); Track().track(TrackingEvent.settings_server, eventValue: live.toString()); - yield SettingsReady(_locale); + //yield SettingsReady(_locale); } else if (event is SettingsSetHardware) { yield SettingsLoading(); diff --git a/lib/bloc/test_set_edit/test_set_edit_bloc.dart b/lib/bloc/test_set_edit/test_set_edit_bloc.dart index a381265..ca27793 100644 --- a/lib/bloc/test_set_edit/test_set_edit_bloc.dart +++ b/lib/bloc/test_set_edit/test_set_edit_bloc.dart @@ -21,6 +21,7 @@ part 'test_set_edit_state.dart'; class TestSetEditBloc extends Bloc { final String templateName; final String templateNameTranslation; + String templateDescription; final WorkoutTreeRepository workoutTreeRepository; final MenuBloc menuBloc; final List _exerciseTypes = List(); @@ -33,6 +34,7 @@ class TestSetEditBloc extends Bloc { Cache().exercisePlanTemplates.forEach((element) { final ExercisePlanTemplate template = element as ExercisePlanTemplate; if (template.name == templateName) { + templateDescription = template.descriptionTranslation; template.exerciseTypes.forEach((id) { final ExerciseType exerciseType = Cache().getExerciseTypeById(id); _exerciseTypes.add(exerciseType); @@ -77,7 +79,7 @@ class TestSetEditBloc extends Bloc { yield TestSetEditLoading(); ExercisePlan exercisePlan = ExercisePlan(templateNameTranslation, Cache().userLoggedIn.customerId); exercisePlan.private = true; - exercisePlan.type = ExerciseAbility.mini_test_set.toString(); + exercisePlan.type = ExerciseAbility.mini_test_set.enumToString(); exercisePlan.dateAdd = DateTime.now(); ExercisePlan savedExercisePlan = await ExercisePlanApi().saveExercisePlan(exercisePlan); diff --git a/lib/bloc/test_set_execute/test_set_execute_bloc.dart b/lib/bloc/test_set_execute/test_set_execute_bloc.dart index 7ff9a99..b9e106c 100644 --- a/lib/bloc/test_set_execute/test_set_execute_bloc.dart +++ b/lib/bloc/test_set_execute/test_set_execute_bloc.dart @@ -54,7 +54,6 @@ class TestSetExecuteBloc extends Bloc element.exerciseType = exerciseType; } this.setPlanDetailState(element); - print("exercises of ${element.exerciseTypeId}: ${element.exercises}"); }); } } @@ -88,6 +87,15 @@ class TestSetExecuteBloc extends Bloc } await Cache().deleteActiveExercisePlan(); } + } else if (event is TestSetExecuteDeleteAllActive) { + print("DeleteAll Test Set: ${exercisePlan.type}"); + if (exercisePlan != null) { + exercisePlan = null; + if (exercisePlanDetails != null) { + exercisePlanDetails.removeRange(0, exercisePlanDetails.length - 1); + } + await Cache().deleteActiveExercisePlan(); + } } else if (event is TestSetExecuteExerciseFinished) { yield TestSetExecuteLoading(); exercisePlanDetails.forEach((element) { @@ -120,11 +128,11 @@ class TestSetExecuteBloc extends Bloc exercisePlan = ExercisePlan(Cache().userLoggedIn.name + " Custom Test", Cache().userLoggedIn.customerId); exercisePlan.private = true; exercisePlan.dateAdd = DateTime.now(); + exercisePlan.type = ExerciseAbility.paralell_test.enumToString(); ExercisePlan savedExercisePlan = await ExercisePlanApi().saveExercisePlan(exercisePlan); exercisePlan = savedExercisePlan; exercisePlanDetails = List(); } - exercisePlan.type = ExerciseAbility.paralell_test.enumToString(); if (!this.existsInPlanDetails(event.exerciseTypeId)) { ExercisePlanDetail exercisePlanDetail = ExercisePlanDetail(event.exerciseTypeId); diff --git a/lib/bloc/test_set_execute/test_set_execute_event.dart b/lib/bloc/test_set_execute/test_set_execute_event.dart index fc588c1..a23fd8b 100644 --- a/lib/bloc/test_set_execute/test_set_execute_event.dart +++ b/lib/bloc/test_set_execute/test_set_execute_event.dart @@ -52,3 +52,7 @@ class TestSetExecuteDeleteExercise extends TestSetExecuteEvent { class TestSetExecuteDeleteActive extends TestSetExecuteEvent { const TestSetExecuteDeleteActive(); } + +class TestSetExecuteDeleteAllActive extends TestSetExecuteEvent { + const TestSetExecuteDeleteAllActive(); +} diff --git a/lib/main.dart b/lib/main.dart index 4371ba6..b2e2cf9 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -47,6 +47,7 @@ import 'package:flutter_localizations/flutter_localizations.dart'; import 'package:aitrainer_app/util/app_localization.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:sentry/sentry.dart'; +import 'package:smartlook/smartlook.dart'; import 'bloc/account/account_bloc.dart'; import 'bloc/body_development/body_development_bloc.dart'; import 'bloc/development_by_muscle/development_by_muscle_bloc.dart'; @@ -165,7 +166,18 @@ Future main() async { } Future initFlurry() async { - await Flurry.initialize(androidKey: "JNYCTCWBT34FM3J8TV36", iosKey: "3QBG7BSMGPDH24S8TRQP", enableLog: true); + if (!isInDebugMode) { + await Flurry.initialize(androidKey: "JNYCTCWBT34FM3J8TV36", iosKey: "3QBG7BSMGPDH24S8TRQP", enableLog: true); + + SetupOptions options = (new SetupOptionsBuilder('682883e5cd71a46160c4f6ed070530ee593f49c6') + ..Fps = 2 + ..StartNewSession = true) + .build(); + + Smartlook.setupAndStartRecording(options); + Smartlook.enableCrashlytics(true); + Smartlook.setEventTrackingMode(EventTrackingMode.FULL_TRACKING); + } } class WorkoutTestApp extends StatelessWidget { diff --git a/lib/model/cache.dart b/lib/model/cache.dart index 6d5d8aa..602daa8 100644 --- a/lib/model/cache.dart +++ b/lib/model/cache.dart @@ -16,6 +16,7 @@ import 'package:aitrainer_app/repository/customer_repository.dart'; import 'package:aitrainer_app/service/firebase_api.dart'; import 'package:aitrainer_app/service/logging.dart'; import 'package:aitrainer_app/service/package_service.dart'; +import 'package:aitrainer_app/main.dart'; import 'package:aitrainer_app/util/enums.dart'; import 'package:aitrainer_app/util/env.dart'; import 'package:aitrainer_app/util/track.dart'; @@ -25,6 +26,7 @@ import 'package:package_info/package_info.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:aitrainer_app/model/exercise_type.dart'; import 'package:intl/intl.dart'; +import 'package:smartlook/smartlook.dart'; import 'customer_exercise_device.dart'; import 'exercise_device.dart'; @@ -69,6 +71,8 @@ class Cache with Logging { static final String activeExercisePlanKey = 'active_exercise_plan'; static final String activeExercisePlanDateKey = 'active_exercise_plan_date'; static final String activeExercisePlanDetailsKey = 'active_exercise_details_plan'; + static final String exerciseLogSeenKey = 'exercise_log_seen'; + static final String muscleDevelopmentSeenKey = 'muscle_development_seen_key'; static String baseUrl = 'http://aitrainer.info:8888/api/'; static final String mediaUrl = 'https://aitrainer.info:4343/media/'; @@ -111,7 +115,6 @@ class Cache with Logging { Customer _trainee; List _exercisesTrainee; ExercisePlan _traineeExercisePlan; - List _traineeExercisesPlanDetail; LinkedHashMap _badges = LinkedHashMap(); @@ -120,6 +123,8 @@ class Cache with Logging { String testEnvironment; bool liveServer = true; bool hasHardware = false; + bool isExerciseLogSeen = false; + bool isMuscleDevelopmentSeen = false; factory Cache() { return _singleton; @@ -246,10 +251,14 @@ class Cache with Logging { void setServerAddress(SharedPreferences prefs) { if (this.testEnvironment == "1") { baseUrl = 'http://aitrainer.app:8899/api/'; + print("TestEnv $baseUrl"); return; } final bool live = prefs.getBool(Cache.serverKey); if (live == null) { + baseUrl = 'http://aitrainer.app:8888/api/'; + print("Live Env $baseUrl"); + liveServer = true; return; } liveServer = live; @@ -258,6 +267,8 @@ class Cache with Logging { } else { baseUrl = 'http://aitrainer.app:8899/api/'; } + + print("Env $baseUrl"); } Future setLoginTypeFromPrefs() async { @@ -364,7 +375,7 @@ class Cache with Logging { sharedPreferences.setString(Cache.firebaseUidKey, null); sharedPreferences.setString(authTokenKey, ""); } - await initBadges(); + initBadges(); } void setExerciseTypes(List exerciseTypes) { @@ -487,13 +498,14 @@ class Cache with Logging { } } - Future initBadges() async { + void initBadges() async { CustomerRepository customerRepository = CustomerRepository(); _badges = LinkedHashMap(); customerRepository.setCustomer(userLoggedIn); int _ecto = customerRepository.getCustomerPropertyValue(PropertyEnum.Ectomorph.toStr()).toInt(); int _mezo = customerRepository.getCustomerPropertyValue(PropertyEnum.Mesomorph.toStr()).toInt(); int _endo = customerRepository.getCustomerPropertyValue(PropertyEnum.Endomorph.toStr()).toInt(); + //print("endo " + _endo.toString() + " mezo " + _mezo.toString()); if (this.userLoggedIn != null) { if (this.userLoggedIn.birthYear == null || this.userLoggedIn.birthYear == 0) { @@ -524,7 +536,7 @@ class Cache with Logging { } if (this._exercises == null || this._exercises.length == 0) { setBadge("home", true); - setBadge("Strength", true); + setBadge("Muscle Build / Shape Toning", true); setBadge("Cardio", true); } if (customerRepository.getHeight() == 0) { @@ -541,6 +553,16 @@ class Cache with Logging { setBadge("FitnessLevel", true); setBadge("account", true); } + if (this._exercises != null && this._exercises.isNotEmpty) { + if (!isExerciseLogSeen) { + setBadge("exerciseLog", true); + setBadge("development", true); + } + if (!isMuscleDevelopmentSeen) { + setBadge("muscleDevelopment", true); + setBadge("development", true); + } + } } log("Badges: " + _badges.toString()); } @@ -557,12 +579,18 @@ class Cache with Logging { Future initCustomer(int customerId) async { log(" *** initCustomer"); await PackageApi().getCustomerPackage(customerId); - Flurry.setUserId(customerId.toString()); + + if (!isInDebugMode) { + Flurry.setUserId(customerId.toString()); + Smartlook.setUserIdentifier(customerId.toString()); + Track().track(TrackingEvent.enter); + } await setLoginTypeFromPrefs(); await getActiveExercisePlan(); + await isExerciseLogSeenPrefs(); + await isMuscleDevelopmentSeenPrefs(); Cache().startPage = "home"; - Track().track(TrackingEvent.enter); } AccessToken get getAccessTokenFacebook => accessTokenFacebook; @@ -573,4 +601,39 @@ class Cache with Logging { List get exercisePlanTemplates => this._exercisePlanTemplates; setExercisePlanTemplates(value) => this._exercisePlanTemplates = value; + + setExerciseLogSeen() async { + Future prefs = SharedPreferences.getInstance(); + SharedPreferences sharedPreferences = await prefs; + isExerciseLogSeen = true; + sharedPreferences.setBool(Cache.exerciseLogSeenKey, true); + } + + Future isExerciseLogSeenPrefs() async { + Future prefs = SharedPreferences.getInstance(); + SharedPreferences sharedPreferences = await prefs; + isExerciseLogSeen = sharedPreferences.getBool(Cache.exerciseLogSeenKey); + if (isExerciseLogSeen == null) { + isExerciseLogSeen = false; + } + //print("ExerciseLogSeen $isExerciseLogSeen"); + return isExerciseLogSeen; + } + + setMuscleDevelopmentSeen() async { + Future prefs = SharedPreferences.getInstance(); + SharedPreferences sharedPreferences = await prefs; + isMuscleDevelopmentSeen = true; + sharedPreferences.setBool(Cache.muscleDevelopmentSeenKey, true); + } + + Future isMuscleDevelopmentSeenPrefs() async { + Future prefs = SharedPreferences.getInstance(); + SharedPreferences sharedPreferences = await prefs; + isMuscleDevelopmentSeen = sharedPreferences.getBool(Cache.muscleDevelopmentSeenKey); + if (isMuscleDevelopmentSeen == null) { + isMuscleDevelopmentSeen = false; + } + return isMuscleDevelopmentSeen; + } } diff --git a/lib/model/exercise_plan_template.dart b/lib/model/exercise_plan_template.dart index f2c9f0f..b4ed2fc 100644 --- a/lib/model/exercise_plan_template.dart +++ b/lib/model/exercise_plan_template.dart @@ -1,3 +1,7 @@ +import 'dart:ui'; + +import 'package:aitrainer_app/util/app_language.dart'; + class ExercisePlanTemplate { int exercisePlanTemplateId; String name; @@ -12,9 +16,11 @@ class ExercisePlanTemplate { this.name = json['name']; this.description = json['description']; this.templateType = json['templateType']; - this.nameTranslation = json['translations'] != null && (json['translations']).length > 0 ? json['translations'][0]['name'] : this.name; - this.descriptionTranslation = - json['translations'] != null && (json['translations']).length > 0 ? json['translations'][0]['description'] : this.description; + if (json['translations'].length > 0) { + this.nameTranslation = AppLanguage().appLocal == Locale('hu') ? json['translations'][0]['name'] : json['name']; + this.descriptionTranslation = AppLanguage().appLocal == Locale('hu') ? json['translations'][0]['description'] : json['description']; + } + if (json['details'] != null && (json['details']).length > 0) { List details = json['details']; details.forEach((element) { diff --git a/lib/repository/exercise_device_repository.dart b/lib/repository/exercise_device_repository.dart index 9dfbc33..601f545 100644 --- a/lib/repository/exercise_device_repository.dart +++ b/lib/repository/exercise_device_repository.dart @@ -27,7 +27,13 @@ class ExerciseDeviceRepository { } bool isGymElement(String name) { - return name == "Cable" || name == "Baar" || name == "Gym Machine" || name == "Dumbbells" || name == "Barbell"; + return name == "Cable" || + name == "Baar" || + name == "Gym Machine" || + name == "Dumbbells" || + name == "Barbell" || + name == "HOME" || + name == "STREET"; } List getGymDevices() { diff --git a/lib/repository/exercise_repository.dart b/lib/repository/exercise_repository.dart index 966a370..2d2ab84 100644 --- a/lib/repository/exercise_repository.dart +++ b/lib/repository/exercise_repository.dart @@ -276,7 +276,13 @@ class ExerciseRepository { return; } - exerciseList.sort((a, b) => b.dateAdd.compareTo(a.dateAdd)); + exerciseList.sort((a, b) { + final String datePartA = DateFormat('yyyyMMdd', AppLanguage().appLocal.toString()).format(a.dateAdd); + String aId = a.exerciseTypeId.toString() + "_" + datePartA; + final String datePartB = DateFormat('yyyyMMdd', AppLanguage().appLocal.toString()).format(b.dateAdd); + String bId = b.exerciseTypeId.toString() + "_" + datePartB; + return aId.compareTo(bId); + }); this.exerciseLogList = List(); String summary = ""; @@ -289,8 +295,8 @@ class ExerciseRepository { Exercise exercise = exerciseList[i]; int exerciseTypeId = exercise.exerciseTypeId; String exerciseDate = DateFormat("yyyy-MM-dd", AppLanguage().appLocal.toString()).format(exercise.dateAdd); - //print(" -- $prevExerciseTypeId - $prevDate"); - if (!(exerciseTypeId == prevExerciseTypeId && prevDate == exerciseDate)) { + print(" -- $prevExerciseTypeId - '$prevDate' against $exerciseTypeId - '$exerciseDate'"); + if (exerciseTypeId != prevExerciseTypeId || prevDate != exerciseDate) { ExerciseType exerciseType = Cache().getExerciseTypeById(prevExercise.exerciseTypeId); String unit = exerciseType.unitQuantityUnit != null ? exerciseType.unitQuantityUnit : prevExercise.unit; prevExercise.summary = summary + " " + unit; @@ -308,12 +314,14 @@ class ExerciseRepository { if (exerciseType.unitQuantity == "1") { summary += "x" + exercise.unitQuantity.toStringAsFixed(0); } - //print(" --- sum " + exerciseType.name + " $summary"); + print(" --- sum " + exerciseType.name + " $summary"); prevExerciseTypeId = exerciseTypeId; prevDate = exerciseDate; prevExercise = exercise; prevCount++; } + prevExercise.summary = summary; + exerciseLogList.add(prevExercise); } } diff --git a/lib/repository/workout_tree_repository.dart b/lib/repository/workout_tree_repository.dart index 07f5b94..9309f0c 100644 --- a/lib/repository/workout_tree_repository.dart +++ b/lib/repository/workout_tree_repository.dart @@ -26,7 +26,7 @@ class WorkoutTreeRepository with Logging { WorkoutType workoutType; final List menuAsExercise = List(); - Future createTree() async { + void createTree() { //if (Cache().getExerciseTree().length > 0 || Cache().getWorkoutMenuTree().length > 0) return; isEnglish = AppLanguage().appLocal == Locale('en'); log("** Start creating tree on lang: " + @@ -35,14 +35,7 @@ class WorkoutTreeRepository with Logging { Cache().getExerciseTree().length.toString()); List exerciseTree = Cache().getExerciseTree(); - if (exerciseTree == null || exerciseTree.length == 0) { - exerciseTree = await ExerciseTreeApi().getExerciseTree(); - } - List exerciseTypes = Cache().getExerciseTypes(); - if (exerciseTypes == null || exerciseTypes.length == 0) { - exerciseTypes = await ExerciseTypeApi().getExerciseTypes(); - } exerciseTree.sort((a, b) => a.sort.compareTo(b.sort)); @@ -177,7 +170,7 @@ class WorkoutTreeRepository with Logging { WorkoutMenuTree treeItem = value as WorkoutMenuTree; if (treeItem.id == treeId) { isTreeItem1RM = isTreeItem1RM || treeItem.is1RM; - //log (treeItem.name + " 1RM " + treeItem.is1RM.toString() ); + //log(treeItem.name + " 1RM " + treeItem.is1RM.toString()); } }); @@ -305,7 +298,7 @@ class WorkoutTreeRepository with Logging { WorkoutMenuTree workoutTree = value as WorkoutMenuTree; if (!workoutTree.nameEnglish.contains('Muscle Build') && workoutTree.is1RM && workoutTree.exerciseTypeId == 0) { String treeName = getAntagonistSort(workoutTree.nameEnglish) + ". " + workoutTree.name; - print("TreeName $treeName ${workoutTree.name}"); + //print("TreeName $treeName ${workoutTree.name}"); sortedTree[treeName] = this.getBranchList(workoutTree.id); } }); diff --git a/lib/service/exercise_tree_service.dart b/lib/service/exercise_tree_service.dart index 1a13cd3..6d1b69f 100644 --- a/lib/service/exercise_tree_service.dart +++ b/lib/service/exercise_tree_service.dart @@ -21,6 +21,7 @@ class ExerciseTreeApi with Logging { await Future.forEach(exerciseTree, (element) async { element.imageUrl = await buildImage(element.imageUrl, element.treeId); }); + exerciseTree = await getExerciseTreeParents(exerciseTree); log("ExerciseTree downloaded"); Cache().setExerciseTree(exerciseTree); } diff --git a/lib/service/package_service.dart b/lib/service/package_service.dart index 1f76553..d2cd43e 100644 --- a/lib/service/package_service.dart +++ b/lib/service/package_service.dart @@ -66,7 +66,6 @@ class PackageApi { exerciseTree = this.getExerciseTreeParents(exerciseTree, exerciseTreeParents); if (exerciseTree != null) { await Future.forEach(exerciseTree, (element) async { - print("Tree ${element.toJson()}"); element.imageUrl = await ExerciseTreeApi().buildImage(element.imageUrl, element.treeId); }); Cache().setExerciseTree(exerciseTree); diff --git a/lib/util/common.dart b/lib/util/common.dart index 1add7a9..7646013 100644 --- a/lib/util/common.dart +++ b/lib/util/common.dart @@ -113,8 +113,11 @@ mixin Common { } static Widget badgedIcon(Color color, IconData icon, String badgeKey) { - bool show = Cache().getBadges()[badgeKey] != null; - int counter = Cache().getBadges()[badgeKey] != null ? Cache().getBadges()[badgeKey] : 0; + //print("BadgetIcon: " + Cache().getBadges().toString()); + int badgeValue = Cache().getBadges()[badgeKey]; + bool show = (badgeValue != null); + int counter = show ? badgeValue : 0; + //print("show $show BadgeKey $badgeKey count $counter"); return Badge( position: BadgePosition.topEnd(top: -10, end: -10), animationDuration: Duration(milliseconds: 500), diff --git a/lib/util/track.dart b/lib/util/track.dart index f39e09e..d0e0aaa 100644 --- a/lib/util/track.dart +++ b/lib/util/track.dart @@ -5,6 +5,7 @@ import 'package:aitrainer_app/service/tracking_service.dart'; import 'package:aitrainer_app/util/enums.dart'; import 'package:flurry/flurry.dart'; import 'package:aitrainer_app/model/tracking.dart' as model; +import 'package:smartlook/smartlook.dart'; class Track with Logging { static final Track _singleton = Track._internal(); @@ -18,6 +19,7 @@ class Track with Logging { void track(TrackingEvent event, {String eventValue = ""}) { if (!isInDebugMode) { Flurry.logEvent(event.toString()); + Smartlook.setGlobalEventProperty(event.toString(), eventValue, false); model.Tracking tracking = model.Tracking(); tracking.customerId = Cache().userLoggedIn.customerId; tracking.event = event.enumToString(); diff --git a/lib/view/exercise_log_page.dart b/lib/view/exercise_log_page.dart index bcb370f..219b8ad 100644 --- a/lib/view/exercise_log_page.dart +++ b/lib/view/exercise_log_page.dart @@ -85,6 +85,7 @@ class _ExerciseLogPage extends State with Trans, Common { } else if (Cache().getTrainee() != null && customerId == Cache().getTrainee().customerId) { exerciseRepository.exerciseList = exerciseRepository.getExerciseListTrainee(); } + //print("ExerciseList ${exerciseRepository.exerciseList}"); exerciseRepository.sortByDate(); List listWidget = List(); @@ -146,6 +147,7 @@ class _ExerciseLogPage extends State with Trans, Common { origDate = exerciseDate; } }); + //print("ListExerices $listExercises"); if (listExercises.length > 0) { listWidget.add(Container( margin: const EdgeInsets.only(left: 4.0), @@ -194,27 +196,12 @@ class _ExerciseLogPage extends State with Trans, Common { exercise.summary == null ? "" : exercise.summary, style: TextStyle(fontSize: 12, color: Colors.blue[800]), )), - Stack( - children: [ - IconButton( - iconSize: 36, - icon: Icon(CustomIcon.heart_1, color: Colors.blue[800]), - onPressed: () { - evaluation(exerciseRepository, exercise); - }, - ), - Cache().hasPurchased - ? Offstage() - : GestureDetector( - child: Image.asset( - 'asset/image/lock.png', - height: 25, - width: 25, - ), - onTap: () { - evaluation(exerciseRepository, exercise); - }), - ], + IconButton( + iconSize: 36, + icon: Icon(CustomIcon.heart_1, color: Colors.orange[800]), + onPressed: () { + evaluation(exerciseRepository, exercise); + }, ), IconButton( icon: Icon(Icons.delete, color: Colors.black12), @@ -295,7 +282,25 @@ class _ExerciseLogPage extends State with Trans, Common { ), FlatButton( child: Text(t("Yes")), - onPressed: () => {bloc.add(ExerciseLogDelete(exercise: exercise)), Navigator.pop(context)}, + onPressed: () { + Navigator.pop(context); + if (!Cache().hasPurchased) { + showDialog( + context: context, + builder: (BuildContext context) { + return DialogPremium( + unlocked: Cache().hasPurchased, + unlockRound: 1, + unlockedText: t("Enjoy also this premium fetaure to delete mistyped old exercises."), + function: "Delete Exercise", + onTap: () => {Navigator.of(context).pop()}, + onCancel: () => {Navigator.of(context).pop()}, + ); + }); + } else { + bloc.add(ExerciseLogDelete(exercise: exercise)); + } + }, ) ], )); diff --git a/lib/view/exercise_new_page.dart b/lib/view/exercise_new_page.dart index 33cdd15..28ea790 100644 --- a/lib/view/exercise_new_page.dart +++ b/lib/view/exercise_new_page.dart @@ -3,6 +3,7 @@ import 'dart:collection'; import 'package:aitrainer_app/bloc/exercise_new/exercise_new_bloc.dart'; import 'package:aitrainer_app/bloc/menu/menu_bloc.dart'; import 'package:aitrainer_app/bloc/test_set_execute/test_set_execute_bloc.dart'; +import 'package:aitrainer_app/library/custom_icon_icons.dart'; import 'package:aitrainer_app/model/cache.dart'; import 'package:aitrainer_app/model/exercise_ability.dart'; import 'package:aitrainer_app/model/exercise_type.dart'; @@ -20,6 +21,7 @@ import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_form_bloc/flutter_form_bloc.dart'; +import 'package:google_fonts/google_fonts.dart'; import 'package:modal_progress_hud/modal_progress_hud.dart'; class ExerciseNewPage extends StatefulWidget { @@ -115,9 +117,18 @@ class _ExerciseNewPageState extends State with Trans, Logging { exerciseBloc.add(ExerciseNewQuantityChange(quantity: double.parse(value))); }, onUnitQuantityChanged: (value) => exerciseBloc.add(ExerciseNewQuantityUnitChange(quantity: double.parse(value))), - onSubmit: () => confirmationDialog(exerciseBloc, menuBloc), + //onSubmit: () => confirmationDialog(exerciseBloc, menuBloc), exerciseTypeId: exerciseType.exerciseTypeId, )), + floatingActionButton: FloatingActionButton.extended( + onPressed: () => save(exerciseBloc, menuBloc), + backgroundColor: Colors.orange[800], + icon: Icon(CustomIcon.save), + label: Text( + t("Save"), + style: GoogleFonts.inter(fontWeight: FontWeight.bold, fontSize: 16), + ), + ), bottomNavigationBar: BottomBarMultipleExercises( isSet: false, exerciseTypeId: exerciseType.exerciseTypeId, @@ -125,7 +136,18 @@ class _ExerciseNewPageState extends State with Trans, Logging { ); } - void confirmationDialog(ExerciseNewBloc bloc, MenuBloc menuBloc) { + void save(ExerciseNewBloc bloc, MenuBloc menuBloc) { + // ignore: close_sinks + final TestSetExecuteBloc executeBloc = BlocProvider.of(context); + + if (executeBloc != null && executeBloc.existsActivePlan() == true) { + confirmationOverride(bloc); + } else { + confirmationSave(bloc, menuBloc); + } + } + + void confirmationSave(ExerciseNewBloc bloc, MenuBloc menuBloc) { if (bloc.exerciseRepository.exercise.quantity == null) { return; } @@ -173,17 +195,49 @@ class _ExerciseNewPageState extends State with Trans, Logging { ), FlatButton( child: Text(t("Yes")), - onPressed: () => { - bloc.exerciseRepository.setCustomer(Cache().userLoggedIn), - bloc.add(ExerciseNewSubmit()), - Navigator.pop(context), - if (executeBloc.existsActivePlan() == true) - { - executeBloc.add(TestSetExecuteExerciseFinished( - exerciseTypeId: bloc.exerciseRepository.exerciseType.exerciseTypeId, - quantity: bloc.exerciseRepository.exercise.quantity, - unitQuantity: bloc.exerciseRepository.exercise.unitQuantity)), - } + onPressed: () { + saveAll(bloc); + if (executeBloc.existsActivePlan() == true) { + executeBloc.add(TestSetExecuteExerciseFinished( + exerciseTypeId: bloc.exerciseRepository.exerciseType.exerciseTypeId, + quantity: bloc.exerciseRepository.exercise.quantity, + unitQuantity: bloc.exerciseRepository.exercise.unitQuantity)); + } + Navigator.pop(context); + }, + ) + ], + )); + } + + void saveAll(ExerciseNewBloc bloc) { + bloc.exerciseRepository.setCustomer(Cache().userLoggedIn); + bloc.add(ExerciseNewSubmit()); + } + + void confirmationOverride(ExerciseNewBloc bloc) { + // ignore: close_sinks + final TestSetExecuteBloc executeBloc = BlocProvider.of(context); + showCupertinoDialog( + useRootNavigator: true, + context: context, + builder: (_) => CupertinoAlertDialog( + title: Text(t("You have an active Test Set!"), style: GoogleFonts.archivoBlack(fontSize: 20, color: Colors.red[800])), + content: Column(children: [ + Divider(), + Text(t("Do you want to override it?"), style: GoogleFonts.archivoBlack(fontSize: 16, color: Colors.blue[800])), + ]), + actions: [ + FlatButton( + child: Text(t("No"), style: GoogleFonts.archivoBlack(fontSize: 16, color: Colors.blue[800])), + onPressed: () => Navigator.pop(context), + ), + FlatButton( + child: Text(t("Yes"), style: GoogleFonts.archivoBlack(fontSize: 16, color: Colors.red[800])), + onPressed: () { + Navigator.pop(context); + executeBloc.add(TestSetExecuteDeleteAllActive()); + saveAll(bloc); }, ) ], diff --git a/lib/view/mydevelopment_page.dart b/lib/view/mydevelopment_page.dart index 7a4bc05..fbf0056 100644 --- a/lib/view/mydevelopment_page.dart +++ b/lib/view/mydevelopment_page.dart @@ -6,6 +6,7 @@ import 'package:aitrainer_app/repository/exercise_repository.dart'; import 'package:aitrainer_app/util/enums.dart'; import 'package:aitrainer_app/util/track.dart'; import 'package:aitrainer_app/widgets/dialog_premium.dart'; +import 'package:badges/badges.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:aitrainer_app/util/trans.dart'; import 'package:aitrainer_app/widgets/app_bar.dart'; @@ -29,6 +30,11 @@ class _MyDevelopmentPage extends State with Trans { double mediaWidth = MediaQuery.of(context).size.width; double imageWidth = (mediaWidth - 45) / 2; + bool showExerciseLogBadge = Cache().getBadges()["exerciseLog"] != null; + int counterExerciseLogBadge = Cache().getBadges()["exerciseLog"] != null ? Cache().getBadges()["exerciseLog"] : 0; + bool showMuscleDevelopmentBadge = Cache().getBadges()["muscleDevelopment"] != null; + int counterMuscleDevelopmentBadge = Cache().getBadges()["muscleDevelopment"] != null ? Cache().getBadges()["muscleDevelopment"] : 0; + return Scaffold( appBar: AppBarNav(depth: 0), body: Container( @@ -43,21 +49,33 @@ class _MyDevelopmentPage extends State with Trans { child: CustomScrollView(scrollDirection: Axis.vertical, slivers: [ SliverGrid( delegate: SliverChildListDelegate([ - ImageButton( - width: imageWidth, - textAlignment: Alignment.topCenter, - text: t("My Exercise Logs"), - style: GoogleFonts.robotoMono( - textStyle: TextStyle( - fontSize: 14, + Badge( + padding: EdgeInsets.all(8), + position: BadgePosition.topEnd(top: -5, end: -3), + animationDuration: Duration(milliseconds: 500), + animationType: BadgeAnimationType.slide, + badgeColor: Colors.red, + showBadge: showExerciseLogBadge, + badgeContent: Text(counterExerciseLogBadge.toString(), + style: TextStyle( color: Colors.white, - fontWeight: FontWeight.bold, - backgroundColor: Colors.black54.withOpacity(0.4))), - image: "asset/image/edzesnaplom400400.jpg", - left: 5, - onTap: () => this.callBackExerciseLog(exerciseRepository, customerRepository), - isLocked: false, - ), + fontSize: 16, + )), + child: ImageButton( + width: imageWidth, + textAlignment: Alignment.topCenter, + text: t("My Exercise Logs"), + style: GoogleFonts.robotoMono( + textStyle: TextStyle( + fontSize: 14, + color: Colors.white, + fontWeight: FontWeight.bold, + backgroundColor: Colors.black54.withOpacity(0.4))), + image: "asset/image/edzesnaplom400400.jpg", + left: 5, + onTap: () => this.callBackExerciseLog(exerciseRepository, customerRepository), + isLocked: false, + )), ImageButton( width: imageWidth, textAlignment: Alignment.topLeft, @@ -96,21 +114,33 @@ class _MyDevelopmentPage extends State with Trans { }, isLocked: true, ), */ - ImageButton( - width: imageWidth, - textAlignment: Alignment.topLeft, - text: t("Development Of Muscles"), - style: GoogleFonts.robotoMono( - textStyle: TextStyle( - fontSize: 14, + Badge( + padding: EdgeInsets.all(8), + position: BadgePosition.topEnd(top: -5, end: -3), + animationDuration: Duration(milliseconds: 500), + animationType: BadgeAnimationType.slide, + badgeColor: Colors.red, + showBadge: showMuscleDevelopmentBadge, + badgeContent: Text(counterMuscleDevelopmentBadge.toString(), + style: TextStyle( color: Colors.white, - fontWeight: FontWeight.bold, - backgroundColor: Colors.black54.withOpacity(0.4))), - image: "asset/image/izomcsop400400.jpg", - left: 5, - onTap: () => {Navigator.of(context).pushNamed('mydevelopmentMusclePage', arguments: args)}, - isLocked: true, - ), + fontSize: 16, + )), + child: ImageButton( + width: imageWidth, + textAlignment: Alignment.topLeft, + text: t("Development Of Muscles"), + style: GoogleFonts.robotoMono( + textStyle: TextStyle( + fontSize: 14, + color: Colors.white, + fontWeight: FontWeight.bold, + backgroundColor: Colors.black54.withOpacity(0.4))), + image: "asset/image/izomcsop400400.jpg", + left: 5, + onTap: () => {Navigator.of(context).pushNamed('mydevelopmentMusclePage', arguments: args)}, + isLocked: true, + )), ImageButton( width: imageWidth, left: 5, diff --git a/lib/view/settings.dart b/lib/view/settings.dart index 24bafab..85e6087 100644 --- a/lib/view/settings.dart +++ b/lib/view/settings.dart @@ -86,6 +86,7 @@ class SettingsPage extends StatelessWidget with Trans { title: Container(), ); } + print("Live: ${Cache().liveServer}"); return ListTile( leading: Icon(Icons.data_usage_sharp), subtitle: Text("For Test purpuses select Test-Server. After that please restart the the App"), diff --git a/lib/view/test_set_edit.dart b/lib/view/test_set_edit.dart index 3dd0dd5..deecd75 100644 --- a/lib/view/test_set_edit.dart +++ b/lib/view/test_set_edit.dart @@ -136,8 +136,8 @@ class TestSetEdit extends StatelessWidget with Trans { barrierDismissible: false, builder: (BuildContext context) { return DialogCommon( - title: "Own Body", - descriptions: t("execute these exercises with maximum repeats. Leave at least 3 min rest time between time"), + title: bloc.templateNameTranslation, + descriptions: bloc.templateDescription, text: "OK", onTap: () => {Navigator.of(context).pop()}, onCancel: () => {Navigator.of(context).pop()}, @@ -182,7 +182,9 @@ class TestSetEdit extends StatelessWidget with Trans { } alternatives.forEach((element) { - list.add(getImageStack(element, menuBloc, bloc)); + if (workoutTree.exerciseTypeId != element.exerciseTypeId) { + list.add(getImageStack(element, menuBloc, bloc)); + } }); return list; diff --git a/lib/view/test_set_new.dart b/lib/view/test_set_new.dart index e652dcc..d130dbb 100644 --- a/lib/view/test_set_new.dart +++ b/lib/view/test_set_new.dart @@ -2,6 +2,7 @@ import 'dart:collection'; import 'package:aitrainer_app/bloc/test_set_execute/test_set_execute_bloc.dart'; import 'package:aitrainer_app/bloc/test_set_new/test_set_new_bloc.dart'; +import 'package:aitrainer_app/library/custom_icon_icons.dart'; import 'package:aitrainer_app/model/exercise_plan_detail.dart'; import 'package:aitrainer_app/model/exercise_type.dart'; import 'package:aitrainer_app/repository/exercise_repository.dart'; @@ -11,6 +12,7 @@ import 'package:aitrainer_app/widgets/bottom_bar_multiple_exercises.dart'; import 'package:aitrainer_app/widgets/exercise_save.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:google_fonts/google_fonts.dart'; import 'package:modal_progress_hud/modal_progress_hud.dart'; // ignore: must_be_immutable @@ -67,6 +69,18 @@ class TestSetNew extends StatelessWidget with Trans { ); }), )), + floatingActionButton: FloatingActionButton.extended( + onPressed: () => { + Navigator.of(context).pop(), + bloc.add(TestSetNewSubmit()), + }, + backgroundColor: Colors.orange[800], + icon: Icon(CustomIcon.save), + label: Text( + t("Save"), + style: GoogleFonts.inter(fontWeight: FontWeight.bold, fontSize: 16), + ), + ), bottomNavigationBar: BottomBarMultipleExercises( isSet: executeBloc.miniTestSet == true, exerciseTypeId: exerciseType.exerciseTypeId, @@ -76,20 +90,21 @@ class TestSetNew extends StatelessWidget with Trans { Widget getExercises(TestSetNewBloc bloc) { return ExerciseSave( - exerciseName: bloc.exerciseType.nameTranslation, - exerciseDescription: bloc.exerciseType.descriptionTranslation, - exerciseTask: t("Please take a relative bigger weight and repeat 12-20 times"), - unit: bloc.exerciseType.unit, - unitQuantityUnit: bloc.exerciseType.unitQuantityUnit, - hasUnitQuantity: bloc.exerciseType.unitQuantityUnit != null, - onQuantityChanged: (value) { - bloc.add(TestSetNewChangeQuantity(quantity: double.parse(value))); - }, - onUnitQuantityChanged: (value) => bloc.add(TestSetNewChangeQuantityUnit(quantity: double.parse(value))), - exerciseTypeId: bloc.exerciseType.exerciseTypeId, - onSubmit: () { + exerciseName: bloc.exerciseType.nameTranslation, + exerciseDescription: bloc.exerciseType.descriptionTranslation, + exerciseTask: t("Please take a relative bigger weight and repeat 12-20 times"), + unit: bloc.exerciseType.unit, + unitQuantityUnit: bloc.exerciseType.unitQuantityUnit, + hasUnitQuantity: bloc.exerciseType.unitQuantityUnit != null, + onQuantityChanged: (value) { + bloc.add(TestSetNewChangeQuantity(quantity: double.parse(value))); + }, + onUnitQuantityChanged: (value) => bloc.add(TestSetNewChangeQuantityUnit(quantity: double.parse(value))), + exerciseTypeId: bloc.exerciseType.exerciseTypeId, + /* onSubmit: () { Navigator.of(context).pop(); bloc.add(TestSetNewSubmit()); - }); + } */ + ); } } diff --git a/lib/widgets/app_bar.dart b/lib/widgets/app_bar.dart index 5968f48..9868a91 100644 --- a/lib/widgets/app_bar.dart +++ b/lib/widgets/app_bar.dart @@ -143,7 +143,7 @@ class _AppBarNav extends State with SingleTickerProviderStateMixin, C Widget getAnimatedWidget() { double cWidth = mediaSizeWidth(context); double percent = Cache().getPercentExercises(); - if (percent == -1) { + if (percent == -1 || percent.isNaN) { menuBloc.menuTreeRepository.createTree(); ExerciseRepository exerciseRepository = ExerciseRepository(); exerciseRepository.getBaseExerciseFinishedPercent(); @@ -152,7 +152,7 @@ class _AppBarNav extends State with SingleTickerProviderStateMixin, C percent = 0; } } - if (percent == null) { + if (percent == null || percent.isNaN) { percent = 0; } int sizeExerciseList = Cache().getExercises() == null ? 0 : Cache().getExercises().length; diff --git a/lib/widgets/bottom_nav.dart b/lib/widgets/bottom_nav.dart index a533d68..9c8a1af 100644 --- a/lib/widgets/bottom_nav.dart +++ b/lib/widgets/bottom_nav.dart @@ -1,5 +1,4 @@ import 'package:aitrainer_app/library/gradient_bottom_navigation_bar.dart'; -import 'package:aitrainer_app/util/app_localization.dart'; import 'package:aitrainer_app/model/cache.dart'; import 'package:aitrainer_app/service/logging.dart'; import 'package:aitrainer_app/util/common.dart'; @@ -25,13 +24,6 @@ class _NawDrawerWidget extends State with Trans, Logging { super.initState(); } - @override - void didUpdateWidget(BottomNavigator oldWidget) { - Cache().initBadges(); - - super.didUpdateWidget(oldWidget); - } - @override void didChangeDependencies() { Cache().initBadges(); @@ -56,28 +48,25 @@ class _NawDrawerWidget extends State with Trans, Logging { backgroundColor: bgrColor, icon: Common.badgedIcon(inactive, Icons.home, "home"), activeIcon: Common.badgedIcon(active, Icons.home, "home"), - title: new Text(t("Home"), style: TextStyle(fontSize: 12)), + title: Text(t("Home"), style: TextStyle(fontSize: 12)), ), BottomNavigationBarItem( backgroundColor: bgrColor, - icon: new Icon(Icons.trending_up, color: inactive), - activeIcon: new Icon( - Icons.trending_up, - color: active, - ), - title: new Text( + icon: Common.badgedIcon(inactive, Icons.trending_up, "development"), + activeIcon: Common.badgedIcon(active, Icons.trending_up, "development"), + title: Text( t("My Development"), style: TextStyle(fontSize: 12), ), ), BottomNavigationBarItem( backgroundColor: bgrColor, - icon: new Icon(Icons.featured_play_list, color: inactive), - activeIcon: new Icon( + icon: Icon(Icons.featured_play_list, color: inactive), + activeIcon: Icon( Icons.featured_play_list, color: active, ), - title: new Text( + title: Text( t("My Training Plan"), style: TextStyle(fontSize: 12), ), @@ -87,7 +76,7 @@ class _NawDrawerWidget extends State with Trans, Logging { icon: Common.badgedIcon(inactive, Icons.person, "account"), activeIcon: Common.badgedIcon(active, Icons.person, "account"), title: Text( - AppLocalizations.of(context).translate("Account"), + t("Account"), style: TextStyle(fontSize: 12), )), BottomNavigationBarItem( @@ -95,11 +84,6 @@ class _NawDrawerWidget extends State with Trans, Logging { icon: Icon(Icons.settings, color: inactive), activeIcon: Icon(Icons.settings, color: active), title: Text(t("Settings"), style: TextStyle(fontSize: 12))), - /* BottomNavigationBarItem( - backgroundColor: bgrColor, - icon: Icon(Icons.multiple_stop, color: inactive), - activeIcon: Icon(Icons.multiple_stop, color: active), - title: Text(t("Multi test"), style: TextStyle(fontSize: 12))) */ ], onTap: (index) { setState(() { diff --git a/lib/widgets/exercise_save.dart b/lib/widgets/exercise_save.dart index 944d366..80b6d0b 100644 --- a/lib/widgets/exercise_save.dart +++ b/lib/widgets/exercise_save.dart @@ -231,7 +231,7 @@ class _ExerciseSaveState extends State with Trans { Divider( color: Colors.transparent, ), - FlatButton( + /* FlatButton( onPressed: () { widget.onSubmit(); /* showDialog( @@ -251,7 +251,7 @@ class _ExerciseSaveState extends State with Trans { style: TextStyle(fontSize: 16, color: Colors.white), ), ], - )), + )), */ ]), ))); } diff --git a/lib/widgets/image_button.dart b/lib/widgets/image_button.dart index bfc9de2..dcc4563 100644 --- a/lib/widgets/image_button.dart +++ b/lib/widgets/image_button.dart @@ -114,8 +114,8 @@ class ImageButton extends StatelessWidget { : GestureDetector( child: Image.asset( 'asset/image/lock.png', - height: 150, - width: 150, + height: 50, + width: 50, ), onTap: onTap ?? onTap, )) diff --git a/lib/widgets/menu_page_widget.dart b/lib/widgets/menu_page_widget.dart index 7fbc2ed..debe861 100644 --- a/lib/widgets/menu_page_widget.dart +++ b/lib/widgets/menu_page_widget.dart @@ -53,7 +53,7 @@ class _MenuPageWidgetState extends State with Trans, Logging { } }); animation.addListener(() { - setState(() {}); + //setState(() {}); }); } @@ -65,6 +65,13 @@ class _MenuPageWidgetState extends State with Trans, Logging { super.initState(); } + @override + bool didUpdateWidget(MenuPageWidget oldWidget) { + super.didUpdateWidget(oldWidget); + scrollController.animateTo(40, duration: Duration(milliseconds: 300), curve: Curves.easeIn); + return true; + } + @override Widget build(BuildContext context) { menuBloc = BlocProvider.of(context); @@ -247,10 +254,10 @@ class _MenuPageWidgetState extends State with Trans, Logging { SliverGrid sliverList = SliverGrid( delegate: SliverChildListDelegate(list), gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( - crossAxisCount: 3, - mainAxisSpacing: 1.0, - crossAxisSpacing: 1.0, - childAspectRatio: 3, + crossAxisCount: 4, + mainAxisSpacing: 1.5, + crossAxisSpacing: 1.5, + childAspectRatio: 2.5, )); return sliverList; } diff --git a/pubspec.lock b/pubspec.lock index e35c843..290dd08 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -985,6 +985,13 @@ packages: description: flutter source: sdk version: "0.0.99" + smartlook: + dependency: "direct main" + description: + name: smartlook + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.6" source_gen: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 9a42498..186d134 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -15,7 +15,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. # Read more about iOS versioning at # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html -version: 1.1.10+60 +version: 1.1.10+61 environment: sdk: ">=2.7.0 <3.0.0" @@ -54,6 +54,10 @@ dependencies: audioplayer: ^0.8.1 ezanimation: ^0.4.1 confetti: ^0.5.5 + crypto: ^2.1.5 + transparent_image: ^1.0.0 + #auto_animated: ^2.1.0 + carousel_slider: ^3.0.0 firebase_core: ^0.5.0 @@ -63,11 +67,8 @@ dependencies: flutter_facebook_auth: ^2.0.0+1 google_sign_in: ^4.5.9 apple_sign_in: ^0.1.0 - crypto: ^2.1.5 - transparent_image: ^1.0.0 - #auto_animated: ^2.1.0 - carousel_slider: ^3.0.0 - + + smartlook: ^1.0.6 flurry: ^0.0.7 animated_widgets: ^1.0.6 @@ -288,6 +289,7 @@ flutter: - asset/menu/incline_press.jpg - asset/menu/incline_pushups.jpg - asset/menu/incline_triceps_extension.jpg + - asset/menu/leg_abductor.jpg - asset/menu/leg_curls.jpg - asset/menu/leg_extension.jpg - asset/menu/legpress.jpg