WT1.1.0+40 Premium feature settings
This commit is contained in:
parent
5c7a3d67e8
commit
9755cc764a
BIN
asset/image/WT_black_G_background.png
Normal file
BIN
asset/image/WT_black_G_background.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.8 MiB |
BIN
asset/image/WT_plainblack_background.png
Normal file
BIN
asset/image/WT_plainblack_background.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.6 MiB |
BIN
asset/image/WT_sales_background.png
Normal file
BIN
asset/image/WT_sales_background.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.4 MiB |
BIN
asset/image/WT_sales_background_3x5.png
Normal file
BIN
asset/image/WT_sales_background_3x5.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.3 MiB |
@ -11,12 +11,12 @@ PODS:
|
|||||||
- Firebase/Messaging (6.33.0):
|
- Firebase/Messaging (6.33.0):
|
||||||
- Firebase/CoreOnly
|
- Firebase/CoreOnly
|
||||||
- FirebaseMessaging (~> 4.7.0)
|
- FirebaseMessaging (~> 4.7.0)
|
||||||
- firebase_auth (0.18.3-1):
|
- firebase_auth (0.18.4-1):
|
||||||
- Firebase/Auth (~> 6.33.0)
|
- Firebase/Auth (~> 6.33.0)
|
||||||
- Firebase/CoreOnly (~> 6.33.0)
|
- Firebase/CoreOnly (~> 6.33.0)
|
||||||
- firebase_core
|
- firebase_core
|
||||||
- Flutter
|
- Flutter
|
||||||
- firebase_core (0.5.2-1):
|
- firebase_core (0.5.3):
|
||||||
- Firebase/CoreOnly (~> 6.33.0)
|
- Firebase/CoreOnly (~> 6.33.0)
|
||||||
- Flutter
|
- Flutter
|
||||||
- firebase_messaging (7.0.3):
|
- firebase_messaging (7.0.3):
|
||||||
@ -61,6 +61,8 @@ PODS:
|
|||||||
- Flutter
|
- Flutter
|
||||||
- Flurry-iOS-SDK/FlurrySDK (11.1.1)
|
- Flurry-iOS-SDK/FlurrySDK (11.1.1)
|
||||||
- Flutter (1.0.0)
|
- Flutter (1.0.0)
|
||||||
|
- flutter_inapp_purchase (0.0.1):
|
||||||
|
- Flutter
|
||||||
- flutter_keyboard_visibility (0.0.1):
|
- flutter_keyboard_visibility (0.0.1):
|
||||||
- Flutter
|
- Flutter
|
||||||
- FMDB (2.7.5):
|
- FMDB (2.7.5):
|
||||||
@ -111,6 +113,7 @@ DEPENDENCIES:
|
|||||||
- firebase_messaging (from `.symlinks/plugins/firebase_messaging/ios`)
|
- firebase_messaging (from `.symlinks/plugins/firebase_messaging/ios`)
|
||||||
- flurry (from `.symlinks/plugins/flurry/ios`)
|
- flurry (from `.symlinks/plugins/flurry/ios`)
|
||||||
- Flutter (from `Flutter`)
|
- Flutter (from `Flutter`)
|
||||||
|
- flutter_inapp_purchase (from `.symlinks/plugins/flutter_inapp_purchase/ios`)
|
||||||
- flutter_keyboard_visibility (from `.symlinks/plugins/flutter_keyboard_visibility/ios`)
|
- flutter_keyboard_visibility (from `.symlinks/plugins/flutter_keyboard_visibility/ios`)
|
||||||
- health (from `.symlinks/plugins/health/ios`)
|
- health (from `.symlinks/plugins/health/ios`)
|
||||||
- path_provider (from `.symlinks/plugins/path_provider/ios`)
|
- path_provider (from `.symlinks/plugins/path_provider/ios`)
|
||||||
@ -150,6 +153,8 @@ EXTERNAL SOURCES:
|
|||||||
:path: ".symlinks/plugins/flurry/ios"
|
:path: ".symlinks/plugins/flurry/ios"
|
||||||
Flutter:
|
Flutter:
|
||||||
:path: Flutter
|
:path: Flutter
|
||||||
|
flutter_inapp_purchase:
|
||||||
|
:path: ".symlinks/plugins/flutter_inapp_purchase/ios"
|
||||||
flutter_keyboard_visibility:
|
flutter_keyboard_visibility:
|
||||||
:path: ".symlinks/plugins/flutter_keyboard_visibility/ios"
|
:path: ".symlinks/plugins/flutter_keyboard_visibility/ios"
|
||||||
health:
|
health:
|
||||||
@ -165,8 +170,8 @@ SPEC CHECKSUMS:
|
|||||||
device_info: d7d233b645a32c40dfdc212de5cf646ca482f175
|
device_info: d7d233b645a32c40dfdc212de5cf646ca482f175
|
||||||
devicelocale: feebbe5e7a30adb8c4f83185de1b50ff19b44f00
|
devicelocale: feebbe5e7a30adb8c4f83185de1b50ff19b44f00
|
||||||
Firebase: 8db6f2d1b2c5e2984efba4949a145875a8f65fe5
|
Firebase: 8db6f2d1b2c5e2984efba4949a145875a8f65fe5
|
||||||
firebase_auth: cb33b01b51904969161403bbcb20036519f0c578
|
firebase_auth: d5159db3873478d1ac839af7b10d2f831516136a
|
||||||
firebase_core: 7423d688a1c6f2f2d859d64ae26991be39989781
|
firebase_core: 5d6a02f3d85acd5f8321c2d6d62877626a670659
|
||||||
firebase_messaging: 0aea2cd5885b65e19ede58ee3507f485c992cc75
|
firebase_messaging: 0aea2cd5885b65e19ede58ee3507f485c992cc75
|
||||||
FirebaseAuth: c92d49ada7948d1a23466e3db17bc4c2039dddc3
|
FirebaseAuth: c92d49ada7948d1a23466e3db17bc4c2039dddc3
|
||||||
FirebaseCore: d889d9e12535b7f36ac8bfbf1713a0836a3012cd
|
FirebaseCore: d889d9e12535b7f36ac8bfbf1713a0836a3012cd
|
||||||
@ -177,6 +182,7 @@ SPEC CHECKSUMS:
|
|||||||
flurry: 15b01f664ab1367c62b50291541ea7f78ca85aad
|
flurry: 15b01f664ab1367c62b50291541ea7f78ca85aad
|
||||||
Flurry-iOS-SDK: 8f3f7fce27177002f15f145eede88dc1b9ac0cd0
|
Flurry-iOS-SDK: 8f3f7fce27177002f15f145eede88dc1b9ac0cd0
|
||||||
Flutter: 0e3d915762c693b495b44d77113d4970485de6ec
|
Flutter: 0e3d915762c693b495b44d77113d4970485de6ec
|
||||||
|
flutter_inapp_purchase: 5c6a1ac3f11b11d0c8c0321c0c41c1f05805e4c8
|
||||||
flutter_keyboard_visibility: 0339d06371254c3eb25eeb90ba8d17dca8f9c069
|
flutter_keyboard_visibility: 0339d06371254c3eb25eeb90ba8d17dca8f9c069
|
||||||
FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a
|
FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a
|
||||||
GoogleDataTransport: f56af7caa4ed338dc8e138a5d7c5973e66440833
|
GoogleDataTransport: f56af7caa4ed338dc8e138a5d7c5973e66440833
|
||||||
|
@ -366,7 +366,7 @@
|
|||||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||||
CLANG_ENABLE_MODULES = YES;
|
CLANG_ENABLE_MODULES = YES;
|
||||||
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
|
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
|
||||||
CURRENT_PROJECT_VERSION = 39;
|
CURRENT_PROJECT_VERSION = 40;
|
||||||
DEVELOPMENT_TEAM = SFJJBDCU6Z;
|
DEVELOPMENT_TEAM = SFJJBDCU6Z;
|
||||||
ENABLE_BITCODE = NO;
|
ENABLE_BITCODE = NO;
|
||||||
FRAMEWORK_SEARCH_PATHS = (
|
FRAMEWORK_SEARCH_PATHS = (
|
||||||
@ -509,7 +509,7 @@
|
|||||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||||
CLANG_ENABLE_MODULES = YES;
|
CLANG_ENABLE_MODULES = YES;
|
||||||
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
|
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
|
||||||
CURRENT_PROJECT_VERSION = 39;
|
CURRENT_PROJECT_VERSION = 40;
|
||||||
DEVELOPMENT_TEAM = SFJJBDCU6Z;
|
DEVELOPMENT_TEAM = SFJJBDCU6Z;
|
||||||
ENABLE_BITCODE = NO;
|
ENABLE_BITCODE = NO;
|
||||||
FRAMEWORK_SEARCH_PATHS = (
|
FRAMEWORK_SEARCH_PATHS = (
|
||||||
@ -544,7 +544,7 @@
|
|||||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||||
CLANG_ENABLE_MODULES = YES;
|
CLANG_ENABLE_MODULES = YES;
|
||||||
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
|
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
|
||||||
CURRENT_PROJECT_VERSION = 39;
|
CURRENT_PROJECT_VERSION = 40;
|
||||||
DEVELOPMENT_TEAM = SFJJBDCU6Z;
|
DEVELOPMENT_TEAM = SFJJBDCU6Z;
|
||||||
ENABLE_BITCODE = NO;
|
ENABLE_BITCODE = NO;
|
||||||
FRAMEWORK_SEARCH_PATHS = (
|
FRAMEWORK_SEARCH_PATHS = (
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import 'dart:math';
|
import 'dart:math';
|
||||||
|
|
||||||
import 'package:aitrainer_app/repository/exercise_repository.dart';
|
import 'package:aitrainer_app/repository/exercise_repository.dart';
|
||||||
import 'package:flutter_form_bloc/flutter_form_bloc.dart';
|
import 'package:flutter_form_bloc/flutter_form_bloc.dart';
|
||||||
|
|
||||||
@ -18,19 +17,21 @@ class CustomExerciseFormBloc extends FormBloc<String, String> {
|
|||||||
);
|
);
|
||||||
|
|
||||||
//1RM calculated Fields
|
//1RM calculated Fields
|
||||||
final rmWendlerField = TextFieldBloc( initialValue: "0",);
|
final rmWendlerField = TextFieldBloc(
|
||||||
final rmMayhewField = TextFieldBloc( initialValue: "0");
|
initialValue: "0",
|
||||||
final rmOconnerField = TextFieldBloc( initialValue: "0");
|
);
|
||||||
final rmWathenField = TextFieldBloc( initialValue: "0");
|
final rmMayhewField = TextFieldBloc(initialValue: "0");
|
||||||
final rmAverageField = TextFieldBloc( initialValue: "0");
|
final rmOconnerField = TextFieldBloc(initialValue: "0");
|
||||||
final rm90Field = TextFieldBloc( initialValue: "0");
|
final rmWathenField = TextFieldBloc(initialValue: "0");
|
||||||
final rm80Field = TextFieldBloc( initialValue: "0");
|
final rmAverageField = TextFieldBloc(initialValue: "0");
|
||||||
final rm75Field = TextFieldBloc( initialValue: "0");
|
final rm90Field = TextFieldBloc(initialValue: "0");
|
||||||
final rm75WendlerField = TextFieldBloc( initialValue: "0");
|
final rm80Field = TextFieldBloc(initialValue: "0");
|
||||||
final rm75OconnorField = TextFieldBloc( initialValue: "0");
|
final rm75Field = TextFieldBloc(initialValue: "0");
|
||||||
final rm70Field = TextFieldBloc( initialValue: "0");
|
final rm75WendlerField = TextFieldBloc(initialValue: "0");
|
||||||
final rm60Field = TextFieldBloc( initialValue: "0");
|
final rm75OconnorField = TextFieldBloc(initialValue: "0");
|
||||||
final rm50Field = TextFieldBloc( initialValue: "0");
|
final rm70Field = TextFieldBloc(initialValue: "0");
|
||||||
|
final rm60Field = TextFieldBloc(initialValue: "0");
|
||||||
|
final rm50Field = TextFieldBloc(initialValue: "0");
|
||||||
|
|
||||||
CustomExerciseFormBloc({this.exerciseRepository}) {
|
CustomExerciseFormBloc({this.exerciseRepository}) {
|
||||||
addFieldBlocs(fieldBlocs: [
|
addFieldBlocs(fieldBlocs: [
|
||||||
@ -64,7 +65,6 @@ class CustomExerciseFormBloc extends FormBloc<String, String> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
void onSubmitting() async {
|
void onSubmitting() async {
|
||||||
print("on Submitting Custom form");
|
|
||||||
try {
|
try {
|
||||||
emitLoading(progress: 30);
|
emitLoading(progress: 30);
|
||||||
// Emit either Loaded or Error
|
// Emit either Loaded or Error
|
||||||
@ -78,30 +78,27 @@ class CustomExerciseFormBloc extends FormBloc<String, String> {
|
|||||||
void calculate1RM() {
|
void calculate1RM() {
|
||||||
double weight = exerciseRepository.exercise.unitQuantity;
|
double weight = exerciseRepository.exercise.unitQuantity;
|
||||||
double repeat = exerciseRepository.exercise.quantity;
|
double repeat = exerciseRepository.exercise.quantity;
|
||||||
if ( weight == 0 || repeat == 0) {
|
if (weight == 0 || repeat == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
print("Calculating 1RM");
|
|
||||||
exerciseRepository.rmWendler = weight * repeat * 0.0333 + weight;
|
exerciseRepository.rmWendler = weight * repeat * 0.0333 + weight;
|
||||||
rmWendlerField.updateValue(exerciseRepository.rmWendler.toStringAsFixed(1));
|
rmWendlerField.updateValue(exerciseRepository.rmWendler.toStringAsFixed(1));
|
||||||
exerciseRepository.rmOconner = weight * (1 + repeat / 40);
|
exerciseRepository.rmOconner = weight * (1 + repeat / 40);
|
||||||
rmOconnerField.updateValue(exerciseRepository.rmOconner.toStringAsFixed(1));
|
rmOconnerField.updateValue(exerciseRepository.rmOconner.toStringAsFixed(1));
|
||||||
exerciseRepository.rmMayhew =
|
exerciseRepository.rmMayhew = 100 * weight / (52.2 + 41.9 * pow(e, -0.055 * repeat));
|
||||||
100 * weight / (52.2 + 41.9 * pow(e, -0.055 * repeat));
|
|
||||||
rmMayhewField.updateValue(exerciseRepository.rmMayhew.toStringAsFixed(1));
|
rmMayhewField.updateValue(exerciseRepository.rmMayhew.toStringAsFixed(1));
|
||||||
exerciseRepository.rmWathen =
|
exerciseRepository.rmWathen = 100 * weight / (48.8 + 53.8 * pow(e, -0.075 * repeat));
|
||||||
100 * weight / (48.8 + 53.8 * pow(e, -0.075 * repeat));
|
|
||||||
rmWathenField.updateValue(exerciseRepository.rmWathen.toStringAsFixed(1));
|
rmWathenField.updateValue(exerciseRepository.rmWathen.toStringAsFixed(1));
|
||||||
double average = (exerciseRepository.rmWendler + exerciseRepository.rmOconner)/2;
|
double average = (exerciseRepository.rmWendler + exerciseRepository.rmOconner) / 2;
|
||||||
rmAverageField.updateValue(average.toStringAsFixed(1));
|
rmAverageField.updateValue(average.toStringAsFixed(1));
|
||||||
rm90Field.updateValue((average*0.9).toStringAsFixed(1));
|
rm90Field.updateValue((average * 0.9).toStringAsFixed(1));
|
||||||
rm80Field.updateValue((average*0.8).toStringAsFixed(1));
|
rm80Field.updateValue((average * 0.8).toStringAsFixed(1));
|
||||||
rm75Field.updateValue((average*0.75).toStringAsFixed(1));
|
rm75Field.updateValue((average * 0.75).toStringAsFixed(1));
|
||||||
rm75OconnorField.updateValue((exerciseRepository.rmOconner*0.75).toStringAsFixed(1));
|
rm75OconnorField.updateValue((exerciseRepository.rmOconner * 0.75).toStringAsFixed(1));
|
||||||
rm75WendlerField.updateValue((exerciseRepository.rmWendler*0.75).toStringAsFixed(1));
|
rm75WendlerField.updateValue((exerciseRepository.rmWendler * 0.75).toStringAsFixed(1));
|
||||||
rm70Field.updateValue((average*0.7).toStringAsFixed(1));
|
rm70Field.updateValue((average * 0.7).toStringAsFixed(1));
|
||||||
rm60Field.updateValue((average*0.6).toStringAsFixed(1));
|
rm60Field.updateValue((average * 0.6).toStringAsFixed(1));
|
||||||
rm50Field.updateValue((average*0.5).toStringAsFixed(1));
|
rm50Field.updateValue((average * 0.5).toStringAsFixed(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
//@override
|
//@override
|
||||||
|
@ -104,7 +104,6 @@ class CustomerChangeFormBloc extends FormBloc<String, String> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
void onSubmitting() async {
|
void onSubmitting() async {
|
||||||
print("on Submitting Customer Change form");
|
|
||||||
try {
|
try {
|
||||||
emitLoading(progress: 30);
|
emitLoading(progress: 30);
|
||||||
// Emit either Loaded or Error
|
// Emit either Loaded or Error
|
||||||
|
@ -29,13 +29,11 @@ class CustomerExerciseDeviceBloc extends Bloc<CustomerExerciseDeviceEvent, Custo
|
|||||||
yield CustomerExerciseDeviceReady();
|
yield CustomerExerciseDeviceReady();
|
||||||
} else if (event is CustomerExerciseDeviceAdd) {
|
} else if (event is CustomerExerciseDeviceAdd) {
|
||||||
yield CustomerExerciseDeviceLoading();
|
yield CustomerExerciseDeviceLoading();
|
||||||
print("Add device " + event.device.exerciseDeviceId.toString());
|
|
||||||
//await Future.delayed(const Duration(seconds: 2), () => "2");
|
//await Future.delayed(const Duration(seconds: 2), () => "2");
|
||||||
await repository.addDevice(event.device);
|
await repository.addDevice(event.device);
|
||||||
Cache().initBadges();
|
Cache().initBadges();
|
||||||
yield CustomerExerciseDeviceReady();
|
yield CustomerExerciseDeviceReady();
|
||||||
} else if (event is CustomerExerciseDeviceRemove) {
|
} else if (event is CustomerExerciseDeviceRemove) {
|
||||||
print("Remove device " + event.device.exerciseDeviceId.toString());
|
|
||||||
yield CustomerExerciseDeviceLoading();
|
yield CustomerExerciseDeviceLoading();
|
||||||
await repository.removeDevice(event.device);
|
await repository.removeDevice(event.device);
|
||||||
Cache().initBadges();
|
Cache().initBadges();
|
||||||
|
@ -6,6 +6,7 @@ import 'package:aitrainer_app/model/exercise.dart';
|
|||||||
import 'package:aitrainer_app/model/workout_menu_tree.dart';
|
import 'package:aitrainer_app/model/workout_menu_tree.dart';
|
||||||
import 'package:aitrainer_app/repository/exercise_repository.dart';
|
import 'package:aitrainer_app/repository/exercise_repository.dart';
|
||||||
import 'package:aitrainer_app/repository/workout_tree_repository.dart';
|
import 'package:aitrainer_app/repository/workout_tree_repository.dart';
|
||||||
|
import 'package:aitrainer_app/service/logging.dart';
|
||||||
import 'package:aitrainer_app/util/calculate.dart';
|
import 'package:aitrainer_app/util/calculate.dart';
|
||||||
import 'package:aitrainer_app/util/common.dart';
|
import 'package:aitrainer_app/util/common.dart';
|
||||||
import 'package:aitrainer_app/util/group_data.dart';
|
import 'package:aitrainer_app/util/group_data.dart';
|
||||||
@ -48,18 +49,16 @@ class GroupDate extends GroupData with Calculate, Common {
|
|||||||
|
|
||||||
GroupDate({this.inputList, this.outputList});
|
GroupDate({this.inputList, this.outputList});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
double getQuantityByDate(Exercise exercise) {
|
double getQuantityByDate(Exercise exercise) {
|
||||||
double sum = 0;
|
double sum = 0;
|
||||||
if ( this.diagramType == DiagramType.sumMass ) {
|
if (this.diagramType == DiagramType.sumMass) {
|
||||||
if ( exercise.unitQuantity != null ) {
|
if (exercise.unitQuantity != null) {
|
||||||
sum = exercise.quantity * exercise.unitQuantity;
|
sum = exercise.quantity * exercise.unitQuantity;
|
||||||
} else {
|
} else {
|
||||||
sum = exercise.quantity;
|
sum = exercise.quantity;
|
||||||
}
|
}
|
||||||
} else if ( this.diagramType == DiagramType.oneRepMax || this.diagramType == DiagramType.percent ) {
|
} else if (this.diagramType == DiagramType.oneRepMax || this.diagramType == DiagramType.percent) {
|
||||||
if ( exercise.unitQuantity != null ) {
|
if (exercise.unitQuantity != null) {
|
||||||
sum = calculate1RM(exercise.quantity, exercise.unitQuantity);
|
sum = calculate1RM(exercise.quantity, exercise.unitQuantity);
|
||||||
} else {
|
} else {
|
||||||
sum = exercise.quantity;
|
sum = exercise.quantity;
|
||||||
@ -93,8 +92,8 @@ class GroupDate extends GroupData with Calculate, Common {
|
|||||||
Exercise tempExercise;
|
Exercise tempExercise;
|
||||||
inputList.forEach((element) {
|
inputList.forEach((element) {
|
||||||
tempExercise = element;
|
tempExercise = element;
|
||||||
if ( this.checkNewType(element)) {
|
if (this.checkNewType(element)) {
|
||||||
if ( _origDatePart == null ) {
|
if (_origDatePart == null) {
|
||||||
this.addTempData(element);
|
this.addTempData(element);
|
||||||
} else {
|
} else {
|
||||||
this.temp2Output(_origExercise);
|
this.temp2Output(_origExercise);
|
||||||
@ -105,7 +104,7 @@ class GroupDate extends GroupData with Calculate, Common {
|
|||||||
this.addTempData(element);
|
this.addTempData(element);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if ( tempExercise != null) {
|
if (tempExercise != null) {
|
||||||
this.temp2Output(tempExercise);
|
this.temp2Output(tempExercise);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -134,7 +133,6 @@ class GroupDate extends GroupData with Calculate, Common {
|
|||||||
=========== CHART DATA CLASS
|
=========== CHART DATA CLASS
|
||||||
*/
|
*/
|
||||||
class GroupChart extends GroupData with Calculate {
|
class GroupChart extends GroupData with Calculate {
|
||||||
|
|
||||||
final List<dynamic> inputList;
|
final List<dynamic> inputList;
|
||||||
LinkedHashMap<int, ChartDataExtended> outputList = LinkedHashMap();
|
LinkedHashMap<int, ChartDataExtended> outputList = LinkedHashMap();
|
||||||
|
|
||||||
@ -149,7 +147,7 @@ class GroupChart extends GroupData with Calculate {
|
|||||||
GroupChart({this.inputList, this.outputList});
|
GroupChart({this.inputList, this.outputList});
|
||||||
|
|
||||||
double getBasePercent(Exercise exercise) {
|
double getBasePercent(Exercise exercise) {
|
||||||
if ( exercise.unitQuantity != null ) {
|
if (exercise.unitQuantity != null) {
|
||||||
this._basePercent = calculate1RM(exercise.quantity, exercise.unitQuantity);
|
this._basePercent = calculate1RM(exercise.quantity, exercise.unitQuantity);
|
||||||
} else {
|
} else {
|
||||||
this._basePercent = exercise.quantity;
|
this._basePercent = exercise.quantity;
|
||||||
@ -160,14 +158,14 @@ class GroupChart extends GroupData with Calculate {
|
|||||||
double getDiagramValue(Exercise exercise) {
|
double getDiagramValue(Exercise exercise) {
|
||||||
double value = 0;
|
double value = 0;
|
||||||
|
|
||||||
if ( diagramType == DiagramType.percent) {
|
if (diagramType == DiagramType.percent) {
|
||||||
if ( exercise.unitQuantity != null ) {
|
if (exercise.unitQuantity != null) {
|
||||||
double oneRepMax = calculate1RM(exercise.quantity, exercise.unitQuantity);
|
double oneRepMax = calculate1RM(exercise.quantity, exercise.unitQuantity);
|
||||||
value = (oneRepMax / this._basePercent) * 100;
|
value = (oneRepMax / this._basePercent) * 100;
|
||||||
} else {
|
} else {
|
||||||
value = (exercise.quantity / this._basePercent ) * 100;
|
value = (exercise.quantity / this._basePercent) * 100;
|
||||||
}
|
}
|
||||||
} else if ( diagramType == DiagramType.oneRepMax || diagramType == DiagramType.sumMass) {
|
} else if (diagramType == DiagramType.oneRepMax || diagramType == DiagramType.sumMass) {
|
||||||
value = exercise.calculated;
|
value = exercise.calculated;
|
||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
@ -175,7 +173,6 @@ class GroupChart extends GroupData with Calculate {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
void addTempData(Exercise exercise) {
|
void addTempData(Exercise exercise) {
|
||||||
|
|
||||||
double diagramValue = this.getDiagramValue(exercise);
|
double diagramValue = this.getDiagramValue(exercise);
|
||||||
|
|
||||||
if (_maxData < diagramValue) {
|
if (_maxData < diagramValue) {
|
||||||
@ -185,32 +182,27 @@ class GroupChart extends GroupData with Calculate {
|
|||||||
_minData = diagramValue;
|
_minData = diagramValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
BarChartGroupData data = BarChartGroupData(
|
BarChartGroupData data = BarChartGroupData(x: exercise.dateAdd.millisecondsSinceEpoch, barRods: [
|
||||||
x: exercise.dateAdd.millisecondsSinceEpoch,
|
BarChartRodData(y: diagramValue, width: 12, colors: [Colors.lightBlue, Colors.lightBlueAccent])
|
||||||
barRods: [
|
]);
|
||||||
BarChartRodData(y: diagramValue, width: 12, colors: [Colors.lightBlue, Colors.lightBlueAccent])
|
|
||||||
]
|
|
||||||
);
|
|
||||||
_chartData.add(data);
|
_chartData.add(data);
|
||||||
_origExerciseTypeId = exercise.exerciseTypeId;
|
_origExerciseTypeId = exercise.exerciseTypeId;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool checkNewType(Exercise exercise) {
|
bool checkNewType(Exercise exercise) {
|
||||||
return _origExerciseTypeId != exercise.exerciseTypeId;
|
return _origExerciseTypeId != exercise.exerciseTypeId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void iteration() {
|
void iteration() {
|
||||||
|
|
||||||
this.resetTemp();
|
this.resetTemp();
|
||||||
Exercise tempExercise;
|
Exercise tempExercise;
|
||||||
inputList.forEach((element) {
|
inputList.forEach((element) {
|
||||||
tempExercise = element;
|
tempExercise = element;
|
||||||
|
|
||||||
if ( this.checkNewType(element)) {
|
if (this.checkNewType(element)) {
|
||||||
if ( _origExerciseTypeId == null ) {
|
if (_origExerciseTypeId == null) {
|
||||||
_basePercent = getBasePercent(element);
|
_basePercent = getBasePercent(element);
|
||||||
this.addTempData(element);
|
this.addTempData(element);
|
||||||
} else {
|
} else {
|
||||||
@ -223,7 +215,7 @@ class GroupChart extends GroupData with Calculate {
|
|||||||
this.addTempData(element);
|
this.addTempData(element);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if ( tempExercise != null) {
|
if (tempExercise != null) {
|
||||||
this.temp2Output(tempExercise);
|
this.temp2Output(tempExercise);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -234,9 +226,8 @@ class GroupChart extends GroupData with Calculate {
|
|||||||
int gridInterval = (dInterval / 3).floor();
|
int gridInterval = (dInterval / 3).floor();
|
||||||
|
|
||||||
ChartDataExtended extended;
|
ChartDataExtended extended;
|
||||||
if ( outputList[_origExerciseTypeId] == null ) {
|
if (outputList[_origExerciseTypeId] == null) {
|
||||||
extended = ChartDataExtended(
|
extended = ChartDataExtended(data: _chartData, interval: dInterval, gridInterval: gridInterval);
|
||||||
data: _chartData, interval: dInterval, gridInterval: gridInterval);
|
|
||||||
outputList[_origExerciseTypeId] = extended;
|
outputList[_origExerciseTypeId] = extended;
|
||||||
} else {
|
} else {
|
||||||
extended = outputList[_origExerciseTypeId];
|
extended = outputList[_origExerciseTypeId];
|
||||||
@ -252,7 +243,6 @@ class GroupChart extends GroupData with Calculate {
|
|||||||
_maxData = 0;
|
_maxData = 0;
|
||||||
_chartData = List();
|
_chartData = List();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class ChartDataExtended {
|
class ChartDataExtended {
|
||||||
@ -272,7 +262,6 @@ class ChartDataExtended {
|
|||||||
};
|
};
|
||||||
listBarChartData.add(barChartData);
|
listBarChartData.add(barChartData);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
var chartData = {
|
var chartData = {
|
||||||
"data": listBarChartData.toString(),
|
"data": listBarChartData.toString(),
|
||||||
@ -281,10 +270,9 @@ class ChartDataExtended {
|
|||||||
};
|
};
|
||||||
return chartData;
|
return chartData;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class DevelopmentByMuscleBloc extends Bloc<DevelopmentByMuscleEvent, DevelopmentByMuscleState> with Calculate {
|
class DevelopmentByMuscleBloc extends Bloc<DevelopmentByMuscleEvent, DevelopmentByMuscleState> with Calculate, Logging {
|
||||||
final WorkoutTreeRepository workoutTreeRepository;
|
final WorkoutTreeRepository workoutTreeRepository;
|
||||||
final ExerciseRepository exerciseRepository = ExerciseRepository();
|
final ExerciseRepository exerciseRepository = ExerciseRepository();
|
||||||
LinkedHashMap<int, ChartDataExtended> listChartData = LinkedHashMap();
|
LinkedHashMap<int, ChartDataExtended> listChartData = LinkedHashMap();
|
||||||
@ -294,12 +282,9 @@ class DevelopmentByMuscleBloc extends Bloc<DevelopmentByMuscleEvent, Development
|
|||||||
double basePercent = 0;
|
double basePercent = 0;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
DevelopmentByMuscleBloc({
|
DevelopmentByMuscleBloc({this.workoutTreeRepository}) : super(DevelopmentByMuscleStateInitial());
|
||||||
this.workoutTreeRepository}) :
|
|
||||||
super(DevelopmentByMuscleStateInitial());
|
|
||||||
|
|
||||||
Future<void> getData() async {
|
Future<void> getData() async {
|
||||||
|
|
||||||
workoutTreeRepository.sortedTree = null;
|
workoutTreeRepository.sortedTree = null;
|
||||||
workoutTreeRepository.sortByMuscleType();
|
workoutTreeRepository.sortByMuscleType();
|
||||||
|
|
||||||
@ -311,7 +296,6 @@ class DevelopmentByMuscleBloc extends Bloc<DevelopmentByMuscleEvent, Development
|
|||||||
});
|
});
|
||||||
|
|
||||||
this.getChartData();
|
this.getChartData();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void getChartData() {
|
void getChartData() {
|
||||||
@ -331,21 +315,18 @@ class DevelopmentByMuscleBloc extends Bloc<DevelopmentByMuscleEvent, Development
|
|||||||
groupChart.iteration();
|
groupChart.iteration();
|
||||||
listChartData = groupChart.outputList;
|
listChartData = groupChart.outputList;
|
||||||
|
|
||||||
|
|
||||||
listChartData.forEach((key, value) {
|
listChartData.forEach((key, value) {
|
||||||
print ("typeid " + key.toString() + " chardata " + value.toJson().toString());
|
trace("typeid " + key.toString() + " chardata " + value.toJson().toString());
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
List<Exercise> groupByDate(List<Exercise> exercises) {
|
List<Exercise> groupByDate(List<Exercise> exercises) {
|
||||||
List<Exercise> groupedExercises = List();
|
List<Exercise> groupedExercises = List();
|
||||||
|
|
||||||
exercises = sort(exercises, false);
|
exercises = sort(exercises, false);
|
||||||
exercises.forEach((exercise) {
|
exercises.forEach((exercise) {
|
||||||
print ("Date exercise " + exercise.toJsonDatePart().toString());
|
trace("Date exercise " + exercise.toJsonDatePart().toString());
|
||||||
});
|
});
|
||||||
|
|
||||||
GroupDate groupDate = GroupDate(inputList: exercises, outputList: groupedExercises);
|
GroupDate groupDate = GroupDate(inputList: exercises, outputList: groupedExercises);
|
||||||
@ -358,12 +339,11 @@ class DevelopmentByMuscleBloc extends Bloc<DevelopmentByMuscleEvent, Development
|
|||||||
print("Grouped " + element.toJsonDatePart().toString());
|
print("Grouped " + element.toJsonDatePart().toString());
|
||||||
});*/
|
});*/
|
||||||
|
|
||||||
|
|
||||||
return groupedExercises;
|
return groupedExercises;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Exercise> sort(List<Exercise> exercises, bool asc) {
|
List<Exercise> sort(List<Exercise> exercises, bool asc) {
|
||||||
exercises.sort( (a, b) {
|
exercises.sort((a, b) {
|
||||||
var aDateId = a.exerciseTypeId.toString() + "_" + a.datePart.toString();
|
var aDateId = a.exerciseTypeId.toString() + "_" + a.datePart.toString();
|
||||||
var bDateId = b.exerciseTypeId.toString() + "_" + b.datePart.toString();
|
var bDateId = b.exerciseTypeId.toString() + "_" + b.datePart.toString();
|
||||||
|
|
||||||
@ -383,13 +363,13 @@ class DevelopmentByMuscleBloc extends Bloc<DevelopmentByMuscleEvent, Development
|
|||||||
yield DevelopmentByMuscleLoadingState();
|
yield DevelopmentByMuscleLoadingState();
|
||||||
await getData();
|
await getData();
|
||||||
yield DevelopmentByMuscleReadyState();
|
yield DevelopmentByMuscleReadyState();
|
||||||
} else if ( event is DevelopmentByMuscleDiagramTypeChange ) {
|
} else if (event is DevelopmentByMuscleDiagramTypeChange) {
|
||||||
yield DevelopmentByMuscleLoadingState();
|
yield DevelopmentByMuscleLoadingState();
|
||||||
String type = event.diagramType;
|
String type = event.diagramType;
|
||||||
this.diagramType = type;
|
this.diagramType = type;
|
||||||
getChartData();
|
getChartData();
|
||||||
yield DevelopmentByMuscleReadyState();
|
yield DevelopmentByMuscleReadyState();
|
||||||
} else if ( event is DevelopmentByMuscleDateRateChange ) {
|
} else if (event is DevelopmentByMuscleDateRateChange) {
|
||||||
yield DevelopmentByMuscleLoadingState();
|
yield DevelopmentByMuscleLoadingState();
|
||||||
String dateRate = event.dateRate;
|
String dateRate = event.dateRate;
|
||||||
this.dateRate = dateRate;
|
this.dateRate = dateRate;
|
||||||
|
@ -59,14 +59,14 @@ class ExerciseControlBloc extends Bloc<ExerciseControlEvent, ExerciseControlStat
|
|||||||
if (event.step == step) {
|
if (event.step == step) {
|
||||||
step++;
|
step++;
|
||||||
scrollOffset = step * 200.0;
|
scrollOffset = step * 200.0;
|
||||||
print("step " +
|
/* print("step " +
|
||||||
step.toString() +
|
step.toString() +
|
||||||
" quantity " +
|
" quantity " +
|
||||||
quantity.toString() +
|
quantity.toString() +
|
||||||
" origQuantity: " +
|
" origQuantity: " +
|
||||||
origQuantity.toString() +
|
origQuantity.toString() +
|
||||||
" scrollOffset: " +
|
" scrollOffset: " +
|
||||||
scrollOffset.toString());
|
scrollOffset.toString()); */
|
||||||
repeats.add(quantity);
|
repeats.add(quantity);
|
||||||
quantity = origQuantity;
|
quantity = origQuantity;
|
||||||
exerciseRepository.end = DateTime.now();
|
exerciseRepository.end = DateTime.now();
|
||||||
|
@ -71,7 +71,6 @@ class ExerciseExecutePlanAddBloc extends Bloc<ExerciseExecutePlanAddEvent, Exerc
|
|||||||
exerciseRepository.exercise.exercisePlanDetailId = exercisePlanRepository.getActualPlanDetail().exercisePlanDetailId;
|
exerciseRepository.exercise.exercisePlanDetailId = exercisePlanRepository.getActualPlanDetail().exercisePlanDetailId;
|
||||||
exerciseRepository.exercise.unit = workoutTree.exerciseType.unit;
|
exerciseRepository.exercise.unit = workoutTree.exerciseType.unit;
|
||||||
workoutTree.executed = true;
|
workoutTree.executed = true;
|
||||||
print("On Submitting Exercise Execute Plan Add " + exerciseRepository.exercise.toJson().toString());
|
|
||||||
await exerciseRepository.addExercise();
|
await exerciseRepository.addExercise();
|
||||||
Flurry.logEvent("ExecuteExercisePlan");
|
Flurry.logEvent("ExecuteExercisePlan");
|
||||||
step++;
|
step++;
|
||||||
|
@ -343,8 +343,6 @@ class ExerciseNewBloc extends Bloc<ExerciseNewEvent, ExerciseNewState> {
|
|||||||
}
|
}
|
||||||
final double distortionWidth = mediaWidth / baseWidth;
|
final double distortionWidth = mediaWidth / baseWidth;
|
||||||
final double distortionHeight = mediaHeight / baseHeight;
|
final double distortionHeight = mediaHeight / baseHeight;
|
||||||
print("W m " + mediaWidth.toString() + " b" + baseWidth.toString() + " d: " + distortionWidth.toString());
|
|
||||||
print("H m " + mediaHeight.toString() + " b" + baseHeight.toString() + " d: " + distortionHeight.toString());
|
|
||||||
this.bmiAngle = (bmi * 90 / 25) - 90;
|
this.bmiAngle = (bmi * 90 / 25) - 90;
|
||||||
if (bmi < 18.5) {
|
if (bmi < 18.5) {
|
||||||
goalBMI = 19;
|
goalBMI = 19;
|
||||||
|
@ -25,16 +25,16 @@ class ExercisePlanCustomAddBloc extends Bloc<ExercisePlanCustomAddEvent, Exercis
|
|||||||
double quantity;
|
double quantity;
|
||||||
double serie;
|
double serie;
|
||||||
double quantityUnit;
|
double quantityUnit;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
ExercisePlanCustomAddBloc({this.exercisePlanRepository, this.planBloc, this.workoutMenuTree}) : super(ExercisePlanCustomAddInitial()) {
|
ExercisePlanCustomAddBloc({this.exercisePlanRepository, this.planBloc, this.workoutMenuTree}) : super(ExercisePlanCustomAddInitial()) {
|
||||||
exercisePlanRepository.setActualPlanDetailByExerciseType(workoutMenuTree.exerciseType);
|
exercisePlanRepository.setActualPlanDetailByExerciseType(workoutMenuTree.exerciseType);
|
||||||
quantity = exercisePlanRepository.getActualPlanDetail().repeats != null ?
|
quantity =
|
||||||
exercisePlanRepository.getActualPlanDetail().repeats.toDouble() : 12;
|
exercisePlanRepository.getActualPlanDetail().repeats != null ? exercisePlanRepository.getActualPlanDetail().repeats.toDouble() : 12;
|
||||||
serie = exercisePlanRepository.getActualPlanDetail().serie != null ?
|
serie = exercisePlanRepository.getActualPlanDetail().serie != null ? exercisePlanRepository.getActualPlanDetail().serie.toDouble() : 3;
|
||||||
exercisePlanRepository.getActualPlanDetail().serie.toDouble() : 3;
|
quantityUnit = exercisePlanRepository.getActualPlanDetail().weightEquation != null
|
||||||
quantityUnit = exercisePlanRepository.getActualPlanDetail().weightEquation != null ?
|
? double.parse(exercisePlanRepository.getActualPlanDetail().weightEquation)
|
||||||
double.parse(exercisePlanRepository.getActualPlanDetail().weightEquation) : 30;
|
: 30;
|
||||||
|
|
||||||
exercisePlanRepository.getActualPlanDetail().weightEquation = quantityUnit.toString();
|
exercisePlanRepository.getActualPlanDetail().weightEquation = quantityUnit.toString();
|
||||||
exercisePlanRepository.getActualPlanDetail().serie = serie.toInt();
|
exercisePlanRepository.getActualPlanDetail().serie = serie.toInt();
|
||||||
@ -47,24 +47,24 @@ class ExercisePlanCustomAddBloc extends Bloc<ExercisePlanCustomAddEvent, Exercis
|
|||||||
if (event is ExercisePlanCustomAddLoad) {
|
if (event is ExercisePlanCustomAddLoad) {
|
||||||
yield ExercisePlanCustomAddLoading();
|
yield ExercisePlanCustomAddLoading();
|
||||||
yield ExercisePlanCustomAddReady();
|
yield ExercisePlanCustomAddReady();
|
||||||
} else if ( event is ExercisePlanCustomAddChangeSerie ) {
|
} else if (event is ExercisePlanCustomAddChangeSerie) {
|
||||||
yield ExercisePlanCustomAddLoading();
|
yield ExercisePlanCustomAddLoading();
|
||||||
serie = event.quantity;
|
serie = event.quantity;
|
||||||
exercisePlanRepository.getActualPlanDetail().serie = event.quantity.toInt();
|
exercisePlanRepository.getActualPlanDetail().serie = event.quantity.toInt();
|
||||||
yield ExercisePlanCustomAddReady();
|
yield ExercisePlanCustomAddReady();
|
||||||
} else if ( event is ExercisePlanCustomAddChangeQuantity ) {
|
} else if (event is ExercisePlanCustomAddChangeQuantity) {
|
||||||
yield ExercisePlanCustomAddLoading();
|
yield ExercisePlanCustomAddLoading();
|
||||||
quantity = event.quantity;
|
quantity = event.quantity;
|
||||||
exercisePlanRepository.getActualPlanDetail().repeats = event.quantity.toInt();
|
exercisePlanRepository.getActualPlanDetail().repeats = event.quantity.toInt();
|
||||||
yield ExercisePlanCustomAddReady();
|
yield ExercisePlanCustomAddReady();
|
||||||
} else if ( event is ExercisePlanCustomAddChangeQuantityUnit ) {
|
} else if (event is ExercisePlanCustomAddChangeQuantityUnit) {
|
||||||
yield ExercisePlanCustomAddLoading();
|
yield ExercisePlanCustomAddLoading();
|
||||||
quantityUnit = event.quantity;
|
quantityUnit = event.quantity;
|
||||||
exercisePlanRepository.getActualPlanDetail().weightEquation = event.quantity.toStringAsFixed(0);
|
exercisePlanRepository.getActualPlanDetail().weightEquation = event.quantity.toStringAsFixed(0);
|
||||||
yield ExercisePlanCustomAddReady();
|
yield ExercisePlanCustomAddReady();
|
||||||
} else if ( event is ExercisePlanCustomAddSubmit) {
|
} else if (event is ExercisePlanCustomAddSubmit) {
|
||||||
yield ExercisePlanCustomAddLoading();
|
yield ExercisePlanCustomAddLoading();
|
||||||
if ( exercisePlanRepository.exercisePlanDetails[exercisePlanRepository.getActualPlanDetail()] == null ) {
|
if (exercisePlanRepository.exercisePlanDetails[exercisePlanRepository.getActualPlanDetail()] == null) {
|
||||||
exercisePlanRepository.getActualPlanDetail().change = ExercisePlanDetailChange.add;
|
exercisePlanRepository.getActualPlanDetail().change = ExercisePlanDetailChange.add;
|
||||||
} else {
|
} else {
|
||||||
exercisePlanRepository.getActualPlanDetail().change = ExercisePlanDetailChange.update;
|
exercisePlanRepository.getActualPlanDetail().change = ExercisePlanDetailChange.update;
|
||||||
@ -72,9 +72,8 @@ class ExercisePlanCustomAddBloc extends Bloc<ExercisePlanCustomAddEvent, Exercis
|
|||||||
exercisePlanRepository.addDetailToPlan();
|
exercisePlanRepository.addDetailToPlan();
|
||||||
planBloc.add(ExercisePlanAddExercise(exercisePlanDetail: exercisePlanRepository.getActualPlanDetail()));
|
planBloc.add(ExercisePlanAddExercise(exercisePlanDetail: exercisePlanRepository.getActualPlanDetail()));
|
||||||
yield ExercisePlanCustomAddReady();
|
yield ExercisePlanCustomAddReady();
|
||||||
} else if ( event is ExercisePlanCustomAddRemove ) {
|
} else if (event is ExercisePlanCustomAddRemove) {
|
||||||
yield ExercisePlanCustomAddLoading();
|
yield ExercisePlanCustomAddLoading();
|
||||||
print("Remove " + exercisePlanRepository.getActualPlanDetail().exerciseType.name);
|
|
||||||
exercisePlanRepository.getActualPlanDetail().change = ExercisePlanDetailChange.delete;
|
exercisePlanRepository.getActualPlanDetail().change = ExercisePlanDetailChange.delete;
|
||||||
planBloc.add(ExercisePlanRemoveExercise(exercisePlanDetail: exercisePlanRepository.getActualPlanDetail()));
|
planBloc.add(ExercisePlanRemoveExercise(exercisePlanDetail: exercisePlanRepository.getActualPlanDetail()));
|
||||||
|
|
||||||
|
@ -47,11 +47,8 @@ class LoginFormBloc extends FormBloc<String, String> with Common {
|
|||||||
} else {
|
} else {
|
||||||
// Emit either Loaded or Error
|
// Emit either Loaded or Error
|
||||||
await PropertyApi().getProperties();
|
await PropertyApi().getProperties();
|
||||||
print("properties OK");
|
|
||||||
await userRepository.getUser();
|
await userRepository.getUser();
|
||||||
print("get User OK");
|
|
||||||
await ExerciseTypeApi().getExerciseTypes();
|
await ExerciseTypeApi().getExerciseTypes();
|
||||||
print("exerciesTypes OK");
|
|
||||||
await ExerciseTreeApi().getExerciseTree();
|
await ExerciseTreeApi().getExerciseTree();
|
||||||
if (Cache().userLoggedIn != null && Cache().userLoggedIn.customerId > 0) {
|
if (Cache().userLoggedIn != null && Cache().userLoggedIn.customerId > 0) {
|
||||||
ExerciseRepository exerciseRepository = ExerciseRepository();
|
ExerciseRepository exerciseRepository = ExerciseRepository();
|
||||||
|
@ -7,6 +7,7 @@ import 'package:aitrainer_app/model/workout_menu_tree.dart';
|
|||||||
import 'package:aitrainer_app/repository/exercise_device_repository.dart';
|
import 'package:aitrainer_app/repository/exercise_device_repository.dart';
|
||||||
import 'package:aitrainer_app/repository/exercise_repository.dart';
|
import 'package:aitrainer_app/repository/exercise_repository.dart';
|
||||||
import 'package:aitrainer_app/repository/workout_tree_repository.dart';
|
import 'package:aitrainer_app/repository/workout_tree_repository.dart';
|
||||||
|
import 'package:aitrainer_app/service/logging.dart';
|
||||||
import 'package:aitrainer_app/util/trans.dart';
|
import 'package:aitrainer_app/util/trans.dart';
|
||||||
import 'package:bloc/bloc.dart';
|
import 'package:bloc/bloc.dart';
|
||||||
import 'package:equatable/equatable.dart';
|
import 'package:equatable/equatable.dart';
|
||||||
@ -16,7 +17,7 @@ import 'package:meta/meta.dart';
|
|||||||
part 'menu_event.dart';
|
part 'menu_event.dart';
|
||||||
part 'menu_state.dart';
|
part 'menu_state.dart';
|
||||||
|
|
||||||
class MenuBloc extends Bloc<MenuEvent, MenuState> with Trans {
|
class MenuBloc extends Bloc<MenuEvent, MenuState> with Trans, Logging {
|
||||||
final WorkoutTreeRepository menuTreeRepository;
|
final WorkoutTreeRepository menuTreeRepository;
|
||||||
final ExerciseRepository exerciseRepository = ExerciseRepository();
|
final ExerciseRepository exerciseRepository = ExerciseRepository();
|
||||||
ExerciseDeviceRepository exerciseDeviceRepository = ExerciseDeviceRepository();
|
ExerciseDeviceRepository exerciseDeviceRepository = ExerciseDeviceRepository();
|
||||||
@ -48,7 +49,7 @@ class MenuBloc extends Bloc<MenuEvent, MenuState> with Trans {
|
|||||||
}
|
}
|
||||||
if (context == null) return;
|
if (context == null) return;
|
||||||
percent = percent * 100;
|
percent = percent * 100;
|
||||||
print("Percent " + percent.toString());
|
log("Percent " + percent.toString());
|
||||||
if (percent == -1 || percent == 0) {
|
if (percent == -1 || percent == 0) {
|
||||||
infoTitle = t("Greetings!");
|
infoTitle = t("Greetings!");
|
||||||
infoText = t("The purpose is to measure you physical condition") +
|
infoText = t("The purpose is to measure you physical condition") +
|
||||||
@ -69,7 +70,7 @@ class MenuBloc extends Bloc<MenuEvent, MenuState> with Trans {
|
|||||||
|
|
||||||
menuTreeRepository.sortByMuscleType();
|
menuTreeRepository.sortByMuscleType();
|
||||||
missingTreeName = exerciseRepository.nextMissingBaseExercise(menuTreeRepository.sortedTree);
|
missingTreeName = exerciseRepository.nextMissingBaseExercise(menuTreeRepository.sortedTree);
|
||||||
//print("Missing " + missingTreeName);
|
//log("Missing " + missingTreeName);
|
||||||
if (missingTreeName != null) {
|
if (missingTreeName != null) {
|
||||||
if (percent > 0) {
|
if (percent > 0) {
|
||||||
infoText = t("Please continue your tests with a") + " '" + missingTreeName + "' " + t("exercise!");
|
infoText = t("Please continue your tests with a") + " '" + missingTreeName + "' " + t("exercise!");
|
||||||
@ -163,7 +164,7 @@ class MenuBloc extends Bloc<MenuEvent, MenuState> with Trans {
|
|||||||
ability = ExerciseAbility.none;
|
ability = ExerciseAbility.none;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
print("Ability: " + ability.toString() + " name:" + name);
|
log("Ability: " + ability.toString() + " name:" + name);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool selectedDevice(int deviceId) {
|
bool selectedDevice(int deviceId) {
|
||||||
|
@ -4,6 +4,7 @@ import 'package:aitrainer_app/model/cache.dart';
|
|||||||
import 'package:aitrainer_app/model/result.dart';
|
import 'package:aitrainer_app/model/result.dart';
|
||||||
import 'package:aitrainer_app/repository/exercise_repository.dart';
|
import 'package:aitrainer_app/repository/exercise_repository.dart';
|
||||||
import 'package:aitrainer_app/repository/exercise_result_repository.dart';
|
import 'package:aitrainer_app/repository/exercise_result_repository.dart';
|
||||||
|
import 'package:aitrainer_app/service/logging.dart';
|
||||||
import 'package:bloc/bloc.dart';
|
import 'package:bloc/bloc.dart';
|
||||||
import 'package:equatable/equatable.dart';
|
import 'package:equatable/equatable.dart';
|
||||||
import 'package:flutter_form_bloc/flutter_form_bloc.dart';
|
import 'package:flutter_form_bloc/flutter_form_bloc.dart';
|
||||||
@ -12,7 +13,7 @@ import 'package:health/health.dart';
|
|||||||
part 'result_event.dart';
|
part 'result_event.dart';
|
||||||
part 'result_state.dart';
|
part 'result_state.dart';
|
||||||
|
|
||||||
class ResultBloc extends Bloc<ResultEvent, ResultState> {
|
class ResultBloc extends Bloc<ResultEvent, ResultState> with Logging {
|
||||||
final ExerciseResultRepository resultRepository;
|
final ExerciseResultRepository resultRepository;
|
||||||
final ExerciseRepository exerciseRepository;
|
final ExerciseRepository exerciseRepository;
|
||||||
List<HealthDataPoint> _healthDataList = List();
|
List<HealthDataPoint> _healthDataList = List();
|
||||||
@ -46,6 +47,7 @@ class ResultBloc extends Bloc<ResultEvent, ResultState> {
|
|||||||
|
|
||||||
await _fetchHealthData();
|
await _fetchHealthData();
|
||||||
_matchExerciseData();
|
_matchExerciseData();
|
||||||
|
await resultRepository.saveExerciseResults();
|
||||||
yield ResultReady();
|
yield ResultReady();
|
||||||
}
|
}
|
||||||
} on Exception catch (ex) {
|
} on Exception catch (ex) {
|
||||||
@ -55,25 +57,28 @@ class ResultBloc extends Bloc<ResultEvent, ResultState> {
|
|||||||
|
|
||||||
void _matchExerciseData() {
|
void _matchExerciseData() {
|
||||||
resultRepository.getResults().forEach((element) {
|
resultRepository.getResults().forEach((element) {
|
||||||
|
element.dateFrom = startTime;
|
||||||
|
element.dateTo = endTime;
|
||||||
|
element.exerciseId = exerciseRepository.actualExerciseList[0].exerciseId;
|
||||||
switch (element.item) {
|
switch (element.item) {
|
||||||
case ResultItem.bpm_avg:
|
case ResultItem.bpm_avg:
|
||||||
element.data = _gethHealthDataPointValueAvg(HealthDataType.HEART_RATE).toStringAsFixed(0);
|
element.data = _gethHealthDataPointValueAvg(HealthDataType.HEART_RATE);
|
||||||
break;
|
break;
|
||||||
case ResultItem.bpm_min:
|
case ResultItem.bpm_min:
|
||||||
element.data = element.data = _gethHealthDataPointValueMin(HealthDataType.HEART_RATE).toStringAsFixed(0);
|
element.data = element.data = _gethHealthDataPointValueMin(HealthDataType.HEART_RATE);
|
||||||
break;
|
break;
|
||||||
case ResultItem.bpm_max:
|
case ResultItem.bpm_max:
|
||||||
element.data = element.data = _gethHealthDataPointValueMax(HealthDataType.HEART_RATE).toStringAsFixed(0);
|
element.data = element.data = _gethHealthDataPointValueMax(HealthDataType.HEART_RATE);
|
||||||
break;
|
break;
|
||||||
case ResultItem.calorie:
|
case ResultItem.calorie:
|
||||||
element.data = _gethHealthDataPointValueSum(HealthDataType.ACTIVE_ENERGY_BURNED).toStringAsFixed(0);
|
element.data = _gethHealthDataPointValueSum(HealthDataType.ACTIVE_ENERGY_BURNED);
|
||||||
break;
|
break;
|
||||||
case ResultItem.development_percent_bodypart:
|
case ResultItem.development_percent_bodypart:
|
||||||
// TODO: Handle this case.
|
// TODO: Handle this case.
|
||||||
break;
|
break;
|
||||||
case ResultItem.distance:
|
case ResultItem.distance:
|
||||||
if (exerciseRepository.exerciseType.unit == "meter") {
|
if (exerciseRepository.exerciseType.unit == "meter") {
|
||||||
element.data = exerciseRepository.exercise.quantity.toStringAsFixed(0);
|
element.data = exerciseRepository.exercise.quantity;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ResultItem.fatburn_percent:
|
case ResultItem.fatburn_percent:
|
||||||
@ -92,9 +97,9 @@ class ResultBloc extends Bloc<ResultEvent, ResultState> {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (counter > 0) {
|
if (counter > 0) {
|
||||||
element.data = (burnCounter / counter * 100).toStringAsFixed(2);
|
element.data = (burnCounter / counter * 100);
|
||||||
} else {
|
} else {
|
||||||
element.data = "0";
|
element.data = 0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ResultItem.speed_max:
|
case ResultItem.speed_max:
|
||||||
@ -106,11 +111,11 @@ class ResultBloc extends Bloc<ResultEvent, ResultState> {
|
|||||||
exerciseRepository.actualExerciseList.forEach((element) {
|
exerciseRepository.actualExerciseList.forEach((element) {
|
||||||
value += element.quantity;
|
value += element.quantity;
|
||||||
});
|
});
|
||||||
element.data = value.toStringAsFixed(0);
|
element.data = value;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ResultItem.steps:
|
case ResultItem.steps:
|
||||||
element.data = _gethHealthDataPointValueSum(HealthDataType.STEPS).toStringAsFixed(0);
|
element.data = _gethHealthDataPointValueSum(HealthDataType.STEPS);
|
||||||
break;
|
break;
|
||||||
/* case ResultItem.time:
|
/* case ResultItem.time:
|
||||||
final Duration duration = this.endTime.difference(this.startTime);
|
final Duration duration = this.endTime.difference(this.startTime);
|
||||||
@ -122,7 +127,7 @@ class ResultBloc extends Bloc<ResultEvent, ResultState> {
|
|||||||
exerciseRepository.actualExerciseList.forEach((element) {
|
exerciseRepository.actualExerciseList.forEach((element) {
|
||||||
value += element.quantity * element.unitQuantity;
|
value += element.quantity * element.unitQuantity;
|
||||||
});
|
});
|
||||||
element.data = value.toStringAsFixed(0);
|
element.data = value;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -195,13 +200,13 @@ class ResultBloc extends Bloc<ResultEvent, ResultState> {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
print("Get Health data between " + startTime.toString() + " AND " + endTime.toString());
|
log("Get Health data between " + startTime.toString() + " AND " + endTime.toString());
|
||||||
_healthDataList = await health.getHealthDataFromTypes(this.startTime, this.endTime, types);
|
_healthDataList = await health.getHealthDataFromTypes(this.startTime, this.endTime, types);
|
||||||
_healthDataList.forEach((element) {
|
_healthDataList.forEach((element) {
|
||||||
print(element.toString());
|
log(element.toString());
|
||||||
});
|
});
|
||||||
} on Exception catch (e) {
|
} on Exception catch (e) {
|
||||||
print("Caught exception in getHealthDataFromTypes: $e");
|
log("Caught exception in getHealthDataFromTypes: $e");
|
||||||
throw Exception(e);
|
throw Exception(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
79
lib/bloc/sales/sales_bloc.dart
Normal file
79
lib/bloc/sales/sales_bloc.dart
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
import 'dart:async';
|
||||||
|
import 'dart:math';
|
||||||
|
|
||||||
|
import 'package:aitrainer_app/model/cache.dart';
|
||||||
|
import 'package:aitrainer_app/model/product.dart';
|
||||||
|
import 'package:aitrainer_app/model/product_test.dart';
|
||||||
|
import 'package:aitrainer_app/service/logging.dart';
|
||||||
|
import 'package:aitrainer_app/service/product_test_service.dart';
|
||||||
|
import 'package:bloc/bloc.dart';
|
||||||
|
import 'package:equatable/equatable.dart';
|
||||||
|
|
||||||
|
part 'sales_event.dart';
|
||||||
|
part 'sales_state.dart';
|
||||||
|
|
||||||
|
class SalesBloc extends Bloc<SalesEvent, SalesState> with Logging {
|
||||||
|
List<ProductTest> tests = List();
|
||||||
|
List<Product> product2Display = List();
|
||||||
|
int productSet = -1;
|
||||||
|
SalesBloc() : super(SalesInitial());
|
||||||
|
|
||||||
|
@override
|
||||||
|
Stream<SalesState> mapEventToState(
|
||||||
|
SalesEvent event,
|
||||||
|
) async* {
|
||||||
|
try {
|
||||||
|
if (event is SalesLoad) {
|
||||||
|
yield SalesLoading();
|
||||||
|
this.getProductSet();
|
||||||
|
yield SalesReady();
|
||||||
|
} else if (event is SalesPurchase) {
|
||||||
|
final int productId = event.productId;
|
||||||
|
trace("Requesting purchase for" + productId.toString());
|
||||||
|
//PlatformPurchaseApi().requestPurchase(null);
|
||||||
|
}
|
||||||
|
} on Exception catch (ex) {
|
||||||
|
yield SalesError(message: ex.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void getProductSet() {
|
||||||
|
int productId = 0;
|
||||||
|
this.tests = Cache().productTests;
|
||||||
|
|
||||||
|
if (tests.isEmpty) {
|
||||||
|
var rand = Random.secure();
|
||||||
|
productSet = rand.nextInt(5) + 1;
|
||||||
|
} else {
|
||||||
|
trace("Previous ProductTest: " + tests[0].toJson().toString());
|
||||||
|
productId = tests[0].productId;
|
||||||
|
for (var elem in Cache().products) {
|
||||||
|
Product product = elem as Product;
|
||||||
|
if (product.productId == productId) {
|
||||||
|
productSet = product.productSet;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ProductTest productTest = ProductTest();
|
||||||
|
trace("ProductSet: " + productSet.toString());
|
||||||
|
for (var elem in Cache().products) {
|
||||||
|
Product product = elem as Product;
|
||||||
|
if (product.productSet == productSet) {
|
||||||
|
productId = product.productId;
|
||||||
|
product2Display.add(product);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
product2Display.sort((a, b) {
|
||||||
|
return a.sort < b.sort ? a.sort : b.sort;
|
||||||
|
});
|
||||||
|
|
||||||
|
productTest.productId = productId;
|
||||||
|
productTest.customerId = Cache().userLoggedIn.customerId;
|
||||||
|
productTest.dateView = DateTime.now();
|
||||||
|
ProductTestApi().saveProductTest(productTest);
|
||||||
|
Cache().productTests.add(productTest);
|
||||||
|
}
|
||||||
|
}
|
17
lib/bloc/sales/sales_event.dart
Normal file
17
lib/bloc/sales/sales_event.dart
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
part of 'sales_bloc.dart';
|
||||||
|
|
||||||
|
abstract class SalesEvent extends Equatable {
|
||||||
|
const SalesEvent();
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Object> get props => [];
|
||||||
|
}
|
||||||
|
|
||||||
|
class SalesLoad extends SalesEvent {
|
||||||
|
const SalesLoad();
|
||||||
|
}
|
||||||
|
|
||||||
|
class SalesPurchase extends SalesEvent {
|
||||||
|
final int productId;
|
||||||
|
const SalesPurchase({this.productId});
|
||||||
|
}
|
28
lib/bloc/sales/sales_state.dart
Normal file
28
lib/bloc/sales/sales_state.dart
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
part of 'sales_bloc.dart';
|
||||||
|
|
||||||
|
abstract class SalesState extends Equatable {
|
||||||
|
const SalesState();
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Object> get props => [];
|
||||||
|
}
|
||||||
|
|
||||||
|
class SalesInitial extends SalesState {
|
||||||
|
const SalesInitial();
|
||||||
|
}
|
||||||
|
|
||||||
|
class SalesLoading extends SalesState {
|
||||||
|
const SalesLoading();
|
||||||
|
}
|
||||||
|
|
||||||
|
class SalesReady extends SalesState {
|
||||||
|
const SalesReady();
|
||||||
|
}
|
||||||
|
|
||||||
|
class SalesError extends SalesState {
|
||||||
|
final String message;
|
||||||
|
const SalesError({this.message});
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Object> get props => [message];
|
||||||
|
}
|
@ -2,16 +2,18 @@ import 'dart:async';
|
|||||||
|
|
||||||
import 'package:aitrainer_app/bloc/settings/settings_bloc.dart';
|
import 'package:aitrainer_app/bloc/settings/settings_bloc.dart';
|
||||||
import 'package:aitrainer_app/localization/app_language.dart';
|
import 'package:aitrainer_app/localization/app_language.dart';
|
||||||
|
import 'package:aitrainer_app/service/logging.dart';
|
||||||
|
import 'package:aitrainer_app/util/platform_purchase.dart';
|
||||||
import 'package:aitrainer_app/util/session.dart';
|
import 'package:aitrainer_app/util/session.dart';
|
||||||
import 'package:bloc/bloc.dart';
|
import 'package:bloc/bloc.dart';
|
||||||
import 'package:equatable/equatable.dart';
|
import 'package:equatable/equatable.dart';
|
||||||
import 'package:meta/meta.dart';
|
|
||||||
|
|
||||||
part 'session_event.dart';
|
part 'session_event.dart';
|
||||||
part 'session_state.dart';
|
part 'session_state.dart';
|
||||||
|
|
||||||
class SessionBloc extends Bloc<SessionEvent, SessionState> {
|
class SessionBloc extends Bloc<SessionEvent, SessionState> with Logging {
|
||||||
final Session session;
|
final Session session;
|
||||||
|
|
||||||
SessionBloc({this.session}) : super(SessionInitial());
|
SessionBloc({this.session}) : super(SessionInitial());
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -20,23 +22,26 @@ class SessionBloc extends Bloc<SessionEvent, SessionState> {
|
|||||||
) async* {
|
) async* {
|
||||||
try {
|
try {
|
||||||
if (event is SessionStart) {
|
if (event is SessionStart) {
|
||||||
|
log(" -------- Session starting...");
|
||||||
yield SessionLoading();
|
yield SessionLoading();
|
||||||
// ignore: close_sinks
|
// ignore: close_sinks
|
||||||
SettingsBloc settingsBloc = event.settingsBloc;
|
SettingsBloc settingsBloc = event.settingsBloc;
|
||||||
await session.fetchSessionAndNavigate();
|
await session.fetchSessionAndNavigate();
|
||||||
|
await PlatformPurchaseApi().initPurchasePlatformState();
|
||||||
String lang = AppLanguage().appLocal.languageCode;
|
String lang = AppLanguage().appLocal.languageCode;
|
||||||
print("Change lang to $lang");
|
log("Change lang to $lang");
|
||||||
settingsBloc.add(SettingsChangeLanguage(language: lang));
|
settingsBloc.add(SettingsChangeLanguage(language: lang));
|
||||||
yield SessionReady();
|
yield SessionReady();
|
||||||
}
|
}
|
||||||
} on Exception catch(ex) {
|
} on Exception catch (ex) {
|
||||||
yield SessionFailure(message: ex.toString());
|
yield SessionFailure(message: ex.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> close() async {
|
Future<void> close() async {
|
||||||
await this.close(); super.close();
|
await this.close();
|
||||||
|
PlatformPurchaseApi().close();
|
||||||
|
super.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
part of 'session_bloc.dart';
|
part of 'session_bloc.dart';
|
||||||
|
|
||||||
@immutable
|
|
||||||
abstract class SessionEvent extends Equatable {
|
abstract class SessionEvent extends Equatable {
|
||||||
const SessionEvent();
|
const SessionEvent();
|
||||||
|
|
||||||
@ -15,4 +14,3 @@ class SessionStart extends SessionEvent {
|
|||||||
@override
|
@override
|
||||||
List<Object> get props => [settingsBloc];
|
List<Object> get props => [settingsBloc];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
part of 'session_bloc.dart';
|
part of 'session_bloc.dart';
|
||||||
|
|
||||||
@immutable
|
|
||||||
abstract class SessionState extends Equatable {
|
abstract class SessionState extends Equatable {
|
||||||
const SessionState();
|
const SessionState();
|
||||||
|
|
||||||
@ -26,7 +25,4 @@ class SessionFailure extends SessionState {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
List<Object> get props => [message];
|
List<Object> get props => [message];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@ import 'dart:async';
|
|||||||
import 'package:aitrainer_app/localization/app_language.dart';
|
import 'package:aitrainer_app/localization/app_language.dart';
|
||||||
import 'package:aitrainer_app/localization/app_localization.dart';
|
import 'package:aitrainer_app/localization/app_localization.dart';
|
||||||
import 'package:aitrainer_app/model/cache.dart';
|
import 'package:aitrainer_app/model/cache.dart';
|
||||||
|
import 'package:aitrainer_app/service/logging.dart';
|
||||||
import 'package:bloc/bloc.dart';
|
import 'package:bloc/bloc.dart';
|
||||||
import 'package:equatable/equatable.dart';
|
import 'package:equatable/equatable.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
@ -12,7 +13,7 @@ import 'package:meta/meta.dart';
|
|||||||
part 'settings_event.dart';
|
part 'settings_event.dart';
|
||||||
part 'settings_state.dart';
|
part 'settings_state.dart';
|
||||||
|
|
||||||
class SettingsBloc extends Bloc<SettingsEvent, SettingsState> {
|
class SettingsBloc extends Bloc<SettingsEvent, SettingsState> with Logging {
|
||||||
String language;
|
String language;
|
||||||
Locale _locale;
|
Locale _locale;
|
||||||
BuildContext context;
|
BuildContext context;
|
||||||
@ -48,7 +49,7 @@ class SettingsBloc extends Bloc<SettingsEvent, SettingsState> {
|
|||||||
yield SettingsLoading();
|
yield SettingsLoading();
|
||||||
|
|
||||||
bool selectedHardwareBefore = await Cache().selectedHardwareBefore();
|
bool selectedHardwareBefore = await Cache().selectedHardwareBefore();
|
||||||
print("selectedBefore " + selectedHardwareBefore.toString());
|
log("selectedBefore " + selectedHardwareBefore.toString());
|
||||||
if (!selectedHardwareBefore) {
|
if (!selectedHardwareBefore) {
|
||||||
await _accessHealthData();
|
await _accessHealthData();
|
||||||
}
|
}
|
||||||
@ -73,11 +74,11 @@ class SettingsBloc extends Bloc<SettingsEvent, SettingsState> {
|
|||||||
final HealthFactory health = HealthFactory();
|
final HealthFactory health = HealthFactory();
|
||||||
DateTime now = DateTime.now();
|
DateTime now = DateTime.now();
|
||||||
List<HealthDataPoint> _healthDataList = await health.getHealthDataFromTypes(now.subtract(Duration(minutes: 5)), now, types);
|
List<HealthDataPoint> _healthDataList = await health.getHealthDataFromTypes(now.subtract(Duration(minutes: 5)), now, types);
|
||||||
print(_healthDataList.toString());
|
log(_healthDataList.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _changeLang(String lang) async {
|
Future<void> _changeLang(String lang) async {
|
||||||
print("_change to $lang");
|
log("_change to $lang");
|
||||||
switch (lang) {
|
switch (lang) {
|
||||||
case "English":
|
case "English":
|
||||||
case "en":
|
case "en":
|
||||||
@ -97,15 +98,15 @@ class SettingsBloc extends Bloc<SettingsEvent, SettingsState> {
|
|||||||
|
|
||||||
Future<void> loadLang() async {
|
Future<void> loadLang() async {
|
||||||
if (_locale != null) {
|
if (_locale != null) {
|
||||||
print(" -- Loading lang $_locale");
|
log(" -- Loading lang $_locale");
|
||||||
if (context != null) {
|
if (context != null) {
|
||||||
AppLocalizations.of(context).setLocale(_locale);
|
AppLocalizations.of(context).setLocale(_locale);
|
||||||
await AppLocalizations.of(context).load();
|
await AppLocalizations.of(context).load();
|
||||||
} else {
|
} else {
|
||||||
print("no context, does not load");
|
log("no context, does not load");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
print("no locale, does not load");
|
log("no locale, does not load");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
|
import 'package:aitrainer_app/service/logging.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:shared_preferences/shared_preferences.dart';
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
|
|
||||||
class AppLanguage{
|
class AppLanguage with Logging {
|
||||||
static final AppLanguage _singleton = AppLanguage._internal();
|
static final AppLanguage _singleton = AppLanguage._internal();
|
||||||
|
|
||||||
Locale _appLocale = Locale('en');
|
Locale _appLocale = Locale('en');
|
||||||
@ -21,27 +22,25 @@ class AppLanguage{
|
|||||||
Future<void> fetchLocale() async {
|
Future<void> fetchLocale() async {
|
||||||
var prefs = await SharedPreferences.getInstance();
|
var prefs = await SharedPreferences.getInstance();
|
||||||
String langCode = prefs.getString('language_code');
|
String langCode = prefs.getString('language_code');
|
||||||
print(" ---- lang code $langCode");
|
log(" ---- lang code $langCode");
|
||||||
if ( langCode == null) {
|
if (langCode == null) {
|
||||||
_appLocale = Locale('en');
|
_appLocale = Locale('en');
|
||||||
} else {
|
} else {
|
||||||
_appLocale = Locale(langCode);
|
_appLocale = Locale(langCode);
|
||||||
}
|
}
|
||||||
print(" ---- Fetched lang: " + _appLocale.toString());
|
log(" ---- Fetched lang: " + _appLocale.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
getLocale(SharedPreferences prefs) {
|
getLocale(SharedPreferences prefs) {
|
||||||
String langCode = prefs.getString('language_code');
|
String langCode = prefs.getString('language_code');
|
||||||
if ( langCode == null) {
|
if (langCode == null) {
|
||||||
_appLocale = Locale('en');
|
_appLocale = Locale('en');
|
||||||
langCode = "en";
|
langCode = "en";
|
||||||
}
|
}
|
||||||
_appLocale = Locale(langCode);
|
_appLocale = Locale(langCode);
|
||||||
print(" ---- Get lang: " + _appLocale.toString() + " lang code $langCode");
|
log(" ---- Get lang: " + _appLocale.toString() + " lang code $langCode");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void changeLanguage(Locale type) async {
|
void changeLanguage(Locale type) async {
|
||||||
var prefs = await SharedPreferences.getInstance();
|
var prefs = await SharedPreferences.getInstance();
|
||||||
if (_appLocale == type) {
|
if (_appLocale == type) {
|
||||||
@ -56,6 +55,6 @@ class AppLanguage{
|
|||||||
await prefs.setString('language_code', 'en');
|
await prefs.setString('language_code', 'en');
|
||||||
await prefs.setString('countryCode', 'US');
|
await prefs.setString('countryCode', 'US');
|
||||||
}
|
}
|
||||||
print(" ---- Stored lang: " + _appLocale.toString());
|
log(" ---- Stored lang: " + _appLocale.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'dart:ui';
|
import 'dart:ui';
|
||||||
|
|
||||||
|
import 'package:aitrainer_app/service/logging.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
|
|
||||||
class AppLocalizations {
|
class AppLocalizations with Logging {
|
||||||
Locale locale;
|
Locale locale;
|
||||||
bool isTest;
|
bool isTest;
|
||||||
|
|
||||||
@ -27,7 +28,7 @@ class AppLocalizations {
|
|||||||
|
|
||||||
Future<bool> load() async {
|
Future<bool> load() async {
|
||||||
// Load the language JSON file from the "lang" folder
|
// Load the language JSON file from the "lang" folder
|
||||||
print(" -- load language pieces " + locale.languageCode);
|
log(" -- load language pieces " + locale.languageCode);
|
||||||
String jsonString = await rootBundle.loadString('i18n/${locale.languageCode}.json');
|
String jsonString = await rootBundle.loadString('i18n/${locale.languageCode}.json');
|
||||||
Map<String, dynamic> jsonMap = json.decode(jsonString);
|
Map<String, dynamic> jsonMap = json.decode(jsonString);
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
import 'package:aitrainer_app/bloc/sales/sales_bloc.dart';
|
||||||
import 'package:aitrainer_app/push_notifications.dart';
|
import 'package:aitrainer_app/push_notifications.dart';
|
||||||
import 'package:aitrainer_app/repository/customer_repository.dart';
|
import 'package:aitrainer_app/repository/customer_repository.dart';
|
||||||
import 'package:aitrainer_app/repository/workout_tree_repository.dart';
|
import 'package:aitrainer_app/repository/workout_tree_repository.dart';
|
||||||
@ -29,6 +30,7 @@ import 'package:aitrainer_app/view/mydevelopment_page.dart';
|
|||||||
import 'package:aitrainer_app/view/myexcercise_plan_page.dart';
|
import 'package:aitrainer_app/view/myexcercise_plan_page.dart';
|
||||||
import 'package:aitrainer_app/view/registration.dart';
|
import 'package:aitrainer_app/view/registration.dart';
|
||||||
import 'package:aitrainer_app/view/reset_password.dart';
|
import 'package:aitrainer_app/view/reset_password.dart';
|
||||||
|
import 'package:aitrainer_app/view/sales_page.dart';
|
||||||
import 'package:aitrainer_app/view/settings.dart';
|
import 'package:aitrainer_app/view/settings.dart';
|
||||||
import 'package:aitrainer_app/widgets/home.dart';
|
import 'package:aitrainer_app/widgets/home.dart';
|
||||||
import 'package:flurry/flurry.dart';
|
import 'package:flurry/flurry.dart';
|
||||||
@ -218,6 +220,7 @@ class WorkoutTestApp extends StatelessWidget {
|
|||||||
'mydevelopmentMusclePage': (context) => MyDevelopmentMusclePage(),
|
'mydevelopmentMusclePage': (context) => MyDevelopmentMusclePage(),
|
||||||
'mydevelopmentBodyPage': (context) => MyDevelopmentBodyPage(),
|
'mydevelopmentBodyPage': (context) => MyDevelopmentBodyPage(),
|
||||||
'evaluationPage': (context) => EvaluationPage(),
|
'evaluationPage': (context) => EvaluationPage(),
|
||||||
|
'salesPage': (context) => SalesPage(),
|
||||||
},
|
},
|
||||||
initialRoute: 'home',
|
initialRoute: 'home',
|
||||||
title: 'WorkoutTest',
|
title: 'WorkoutTest',
|
||||||
|
@ -5,14 +5,19 @@ import 'package:aitrainer_app/model/exercise_plan_detail.dart';
|
|||||||
import 'package:aitrainer_app/model/exercise_tree.dart';
|
import 'package:aitrainer_app/model/exercise_tree.dart';
|
||||||
import 'package:aitrainer_app/model/exercise.dart';
|
import 'package:aitrainer_app/model/exercise.dart';
|
||||||
import 'package:aitrainer_app/model/model_change.dart';
|
import 'package:aitrainer_app/model/model_change.dart';
|
||||||
|
import 'package:aitrainer_app/model/product.dart';
|
||||||
|
import 'package:aitrainer_app/model/product_test.dart';
|
||||||
import 'package:aitrainer_app/model/property.dart';
|
import 'package:aitrainer_app/model/property.dart';
|
||||||
|
import 'package:aitrainer_app/model/purchase.dart';
|
||||||
import 'package:aitrainer_app/model/workout_menu_tree.dart';
|
import 'package:aitrainer_app/model/workout_menu_tree.dart';
|
||||||
import 'package:aitrainer_app/repository/customer_repository.dart';
|
import 'package:aitrainer_app/repository/customer_repository.dart';
|
||||||
import 'package:aitrainer_app/repository/exercise_repository.dart';
|
import 'package:aitrainer_app/repository/exercise_repository.dart';
|
||||||
import 'package:aitrainer_app/service/customer_exercise_device_service.dart';
|
import 'package:aitrainer_app/service/customer_exercise_device_service.dart';
|
||||||
|
import 'package:aitrainer_app/service/customer_service.dart';
|
||||||
import 'package:aitrainer_app/service/exercise_device_service.dart';
|
import 'package:aitrainer_app/service/exercise_device_service.dart';
|
||||||
import 'package:aitrainer_app/service/exercise_tree_service.dart';
|
import 'package:aitrainer_app/service/exercise_tree_service.dart';
|
||||||
import 'package:aitrainer_app/service/exercisetype_service.dart';
|
import 'package:aitrainer_app/service/exercisetype_service.dart';
|
||||||
|
import 'package:aitrainer_app/service/logging.dart';
|
||||||
import 'package:aitrainer_app/util/env.dart';
|
import 'package:aitrainer_app/util/env.dart';
|
||||||
import 'package:flurry/flurry.dart';
|
import 'package:flurry/flurry.dart';
|
||||||
import 'package:shared_preferences/shared_preferences.dart';
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
@ -43,7 +48,7 @@ enum SharePrefsChange {
|
|||||||
- is_logged_in
|
- is_logged_in
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class Cache {
|
class Cache with Logging {
|
||||||
static final Cache _singleton = Cache._internal();
|
static final Cache _singleton = Cache._internal();
|
||||||
|
|
||||||
// Keys to store and fetch data from SharedPreferences
|
// Keys to store and fetch data from SharedPreferences
|
||||||
@ -65,6 +70,7 @@ class Cache {
|
|||||||
String authToken = "";
|
String authToken = "";
|
||||||
Customer userLoggedIn;
|
Customer userLoggedIn;
|
||||||
String firebaseUid;
|
String firebaseUid;
|
||||||
|
Purchase purchased;
|
||||||
|
|
||||||
bool firstLoad = true;
|
bool firstLoad = true;
|
||||||
|
|
||||||
@ -74,6 +80,10 @@ class Cache {
|
|||||||
List<Exercise> _exercises;
|
List<Exercise> _exercises;
|
||||||
ExercisePlan _myExercisePlan;
|
ExercisePlan _myExercisePlan;
|
||||||
List<Property> _properties;
|
List<Property> _properties;
|
||||||
|
List<Product> _products;
|
||||||
|
List<Purchase> _purchases;
|
||||||
|
List<ProductTest> _productTests;
|
||||||
|
|
||||||
List<ExerciseDevice> _devices;
|
List<ExerciseDevice> _devices;
|
||||||
List<CustomerExerciseDevice> _customerDevices;
|
List<CustomerExerciseDevice> _customerDevices;
|
||||||
|
|
||||||
@ -130,7 +140,7 @@ class Cache {
|
|||||||
|
|
||||||
void getHardware(SharedPreferences prefs) {
|
void getHardware(SharedPreferences prefs) {
|
||||||
final bool hasHardware = prefs.getBool(Cache.hardwareKey);
|
final bool hasHardware = prefs.getBool(Cache.hardwareKey);
|
||||||
print("Has Hardware: " + hasHardware.toString());
|
//log("Has Hardware: " + hasHardware.toString());
|
||||||
this.hasHardware = hasHardware;
|
this.hasHardware = hasHardware;
|
||||||
if (hasHardware == null) {
|
if (hasHardware == null) {
|
||||||
this.hasHardware = false;
|
this.hasHardware = false;
|
||||||
@ -182,11 +192,11 @@ class Cache {
|
|||||||
return mediaUrl;
|
return mediaUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
afterRegistration(Customer customer) {
|
afterRegistration(Customer customer) async {
|
||||||
Future<SharedPreferences> prefs = SharedPreferences.getInstance();
|
Future<SharedPreferences> prefs = SharedPreferences.getInstance();
|
||||||
|
|
||||||
userLoggedIn = customer;
|
userLoggedIn = customer;
|
||||||
setPreferences(prefs, SharePrefsChange.registration, customer.customerId, Cache().firebaseUid);
|
await setPreferences(prefs, SharePrefsChange.registration, customer.customerId, Cache().firebaseUid);
|
||||||
}
|
}
|
||||||
|
|
||||||
afterLogin(Customer customer) async {
|
afterLogin(Customer customer) async {
|
||||||
@ -211,43 +221,28 @@ class Cache {
|
|||||||
_traineeExercisePlan = null;
|
_traineeExercisePlan = null;
|
||||||
_exercises = List();
|
_exercises = List();
|
||||||
_myExercisesPlanDetails = LinkedHashMap();
|
_myExercisesPlanDetails = LinkedHashMap();
|
||||||
print("Trainees is null? " + (_trainee == null).toString());
|
log("Trainees is null? " + (_trainee == null).toString());
|
||||||
Future<SharedPreferences> prefs = SharedPreferences.getInstance();
|
Future<SharedPreferences> prefs = SharedPreferences.getInstance();
|
||||||
await setPreferences(prefs, SharePrefsChange.logout, 0, "");
|
await setPreferences(prefs, SharePrefsChange.logout, 0, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
setPreferences(Future<SharedPreferences> prefs, SharePrefsChange type, int customerId, String firebaseUid) async {
|
Future<void> setPreferences(Future<SharedPreferences> prefs, SharePrefsChange type, int customerId, String firebaseUid) async {
|
||||||
SharedPreferences sharedPreferences;
|
SharedPreferences sharedPreferences;
|
||||||
sharedPreferences = await prefs;
|
sharedPreferences = await prefs;
|
||||||
|
|
||||||
DateTime now = DateTime.now();
|
DateTime now = DateTime.now();
|
||||||
sharedPreferences.setString(Cache.lastStoreDateKey, now.toString());
|
sharedPreferences.setString(Cache.lastStoreDateKey, now.toString());
|
||||||
ExerciseRepository exerciseRepository = ExerciseRepository();
|
|
||||||
if (type == SharePrefsChange.registration) {
|
if (type == SharePrefsChange.registration) {
|
||||||
Cache().startPage = "home";
|
|
||||||
Flurry.setUserId(customerId.toString());
|
|
||||||
sharedPreferences.setInt(Cache.customerIdKey, customerId);
|
sharedPreferences.setInt(Cache.customerIdKey, customerId);
|
||||||
sharedPreferences.setBool(Cache.isRegisteredKey, true);
|
sharedPreferences.setBool(Cache.isRegisteredKey, true);
|
||||||
sharedPreferences.setBool(Cache.isLoggedInKey, true);
|
sharedPreferences.setBool(Cache.isLoggedInKey, true);
|
||||||
sharedPreferences.setString(Cache.firebaseUidKey, firebaseUid);
|
sharedPreferences.setString(Cache.firebaseUidKey, firebaseUid);
|
||||||
await ExerciseTypeApi().getExerciseTypes();
|
await initCustomer(customerId);
|
||||||
await ExerciseTreeApi().getExerciseTree();
|
|
||||||
await ExerciseDeviceApi().getDevices();
|
|
||||||
final customerDevices = await CustomerExerciseDeviceApi().getDevices(customerId);
|
|
||||||
Cache().setCustomerDevices(customerDevices);
|
|
||||||
await exerciseRepository.getExercisesByCustomer(customerId);
|
|
||||||
} else if (type == SharePrefsChange.login) {
|
} else if (type == SharePrefsChange.login) {
|
||||||
Flurry.setUserId(customerId.toString());
|
|
||||||
Cache().startPage = "home";
|
|
||||||
sharedPreferences.setInt(Cache.customerIdKey, customerId);
|
sharedPreferences.setInt(Cache.customerIdKey, customerId);
|
||||||
sharedPreferences.setString(Cache.firebaseUidKey, firebaseUid);
|
sharedPreferences.setString(Cache.firebaseUidKey, firebaseUid);
|
||||||
sharedPreferences.setBool(Cache.isLoggedInKey, true);
|
sharedPreferences.setBool(Cache.isLoggedInKey, true);
|
||||||
await ExerciseTypeApi().getExerciseTypes();
|
await initCustomer(customerId);
|
||||||
await ExerciseTreeApi().getExerciseTree();
|
|
||||||
await ExerciseDeviceApi().getDevices();
|
|
||||||
final customerDevices = await CustomerExerciseDeviceApi().getDevices(customerId);
|
|
||||||
Cache().setCustomerDevices(customerDevices);
|
|
||||||
await exerciseRepository.getExercisesByCustomer(customerId);
|
|
||||||
} else if (type == SharePrefsChange.logout) {
|
} else if (type == SharePrefsChange.logout) {
|
||||||
sharedPreferences.setBool(Cache.isLoggedInKey, false);
|
sharedPreferences.setBool(Cache.isLoggedInKey, false);
|
||||||
sharedPreferences.setInt(Cache.customerIdKey, 0);
|
sharedPreferences.setInt(Cache.customerIdKey, 0);
|
||||||
@ -279,6 +274,16 @@ class Cache {
|
|||||||
|
|
||||||
List<ExerciseType> getExerciseTypes() => this._exerciseTypes;
|
List<ExerciseType> getExerciseTypes() => this._exerciseTypes;
|
||||||
|
|
||||||
|
ExerciseType getExercise(int exerciseTypeId) {
|
||||||
|
ExerciseType exerciseType;
|
||||||
|
this._exerciseTypes.forEach((element) {
|
||||||
|
if (element.exerciseTypeId == exerciseTypeId) {
|
||||||
|
exerciseType = element;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return exerciseType;
|
||||||
|
}
|
||||||
|
|
||||||
List<ExerciseTree> getExerciseTree() => this._exerciseTree;
|
List<ExerciseTree> getExerciseTree() => this._exerciseTree;
|
||||||
|
|
||||||
List<Exercise> getExercises() => this._exercises;
|
List<Exercise> getExercises() => this._exercises;
|
||||||
@ -402,6 +407,34 @@ class Cache {
|
|||||||
setBadgeNr("home", 1);
|
setBadgeNr("home", 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
print("Badges: " + _badges.toString());
|
log("Badges: " + _badges.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
List get products => _products;
|
||||||
|
void setProducts(List value) => _products = value;
|
||||||
|
|
||||||
|
List get purchases => _purchases;
|
||||||
|
setPurchases(List value) => _purchases = value;
|
||||||
|
|
||||||
|
List get productTests => _productTests;
|
||||||
|
set productTests(List value) => _productTests = value;
|
||||||
|
|
||||||
|
Future<void> initCustomer(int customerId) async {
|
||||||
|
log(" *** initCustomer");
|
||||||
|
await CustomerApi().getCustomer(customerId);
|
||||||
|
Cache().startPage = "home";
|
||||||
|
Flurry.setUserId(customerId.toString());
|
||||||
|
await ExerciseTypeApi().getExerciseTypes();
|
||||||
|
await ExerciseTreeApi().getExerciseTree();
|
||||||
|
await ExerciseDeviceApi().getDevices();
|
||||||
|
final customerDevices = await CustomerExerciseDeviceApi().getDevices(customerId);
|
||||||
|
Cache().setCustomerDevices(customerDevices);
|
||||||
|
|
||||||
|
ExerciseRepository exerciseRepository = ExerciseRepository();
|
||||||
|
await exerciseRepository.getExercisesByCustomer(customerId);
|
||||||
|
|
||||||
|
CustomerRepository customerRepository = CustomerRepository(customer: this.userLoggedIn);
|
||||||
|
await customerRepository.getPurchase();
|
||||||
|
await customerRepository.getProductTests();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,8 +12,7 @@ class Exercise {
|
|||||||
|
|
||||||
String datePart;
|
String datePart;
|
||||||
double calculated;
|
double calculated;
|
||||||
|
String summary;
|
||||||
|
|
||||||
|
|
||||||
Exercise({this.exerciseTypeId, this.customerId, this.quantity, this.dateAdd});
|
Exercise({this.exerciseTypeId, this.customerId, this.quantity, this.dateAdd});
|
||||||
|
|
||||||
@ -24,13 +23,12 @@ class Exercise {
|
|||||||
this.quantity = json['quantity'];
|
this.quantity = json['quantity'];
|
||||||
this.unit = json['unit'];
|
this.unit = json['unit'];
|
||||||
this.unitQuantity = json['unitQuantity'];
|
this.unitQuantity = json['unitQuantity'];
|
||||||
this.dateAdd = DateTime.parse( json['dateAdd'] );
|
this.dateAdd = DateTime.parse(json['dateAdd']);
|
||||||
this.datePart = DateFormat('yyyy-MM-dd').format(this.dateAdd);
|
this.datePart = DateFormat('yyyy-MM-dd').format(this.dateAdd);
|
||||||
this.calculated = quantity;
|
this.calculated = quantity;
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<String, dynamic> toJson() =>
|
Map<String, dynamic> toJson() => {
|
||||||
{
|
|
||||||
"exerciseTypeId": exerciseTypeId,
|
"exerciseTypeId": exerciseTypeId,
|
||||||
"customerId": customerId,
|
"customerId": customerId,
|
||||||
"quantity": quantity,
|
"quantity": quantity,
|
||||||
@ -40,17 +38,15 @@ class Exercise {
|
|||||||
"exercisePlanDetailId": exercisePlanDetailId,
|
"exercisePlanDetailId": exercisePlanDetailId,
|
||||||
};
|
};
|
||||||
|
|
||||||
Map<String, dynamic> toJsonDatePart() =>
|
Map<String, dynamic> toJsonDatePart() => {
|
||||||
{
|
"exerciseTypeId": exerciseTypeId,
|
||||||
"exerciseTypeId": exerciseTypeId,
|
"customerId": customerId,
|
||||||
"customerId": customerId,
|
"quantity": quantity,
|
||||||
"quantity": quantity,
|
'calculated': calculated,
|
||||||
'calculated': calculated,
|
"unit": unit,
|
||||||
"unit": unit,
|
"unitQuantity": unitQuantity,
|
||||||
"unitQuantity": unitQuantity,
|
"datePart": this.datePart,
|
||||||
"datePart": this.datePart,
|
};
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
Exercise copy() {
|
Exercise copy() {
|
||||||
Exercise newExercise = Exercise();
|
Exercise newExercise = Exercise();
|
||||||
@ -63,4 +59,4 @@ class Exercise {
|
|||||||
newExercise.exercisePlanDetailId = this.exercisePlanDetailId;
|
newExercise.exercisePlanDetailId = this.exercisePlanDetailId;
|
||||||
return newExercise;
|
return newExercise;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,8 @@ class ExerciseResult {
|
|||||||
|
|
||||||
ResultExt resultExtension;
|
ResultExt resultExtension;
|
||||||
|
|
||||||
|
ExerciseResult();
|
||||||
|
|
||||||
Map<String, dynamic> toJson() {
|
Map<String, dynamic> toJson() {
|
||||||
String formattedDateTo;
|
String formattedDateTo;
|
||||||
if (dateTo != null) {
|
if (dateTo != null) {
|
||||||
|
@ -59,7 +59,6 @@ class FitnessItem {
|
|||||||
FitnessState selected;
|
FitnessState selected;
|
||||||
elements.forEach((element) {
|
elements.forEach((element) {
|
||||||
if (element.value == value) {
|
if (element.value == value) {
|
||||||
print("selected " + element.value);
|
|
||||||
selected = element;
|
selected = element;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -3,15 +3,49 @@ class Product {
|
|||||||
String name;
|
String name;
|
||||||
String description;
|
String description;
|
||||||
String type;
|
String type;
|
||||||
|
String appVersion;
|
||||||
|
int sort;
|
||||||
|
int productSet;
|
||||||
DateTime validFrom;
|
DateTime validFrom;
|
||||||
DateTime validTo;
|
DateTime validTo;
|
||||||
|
String productIdIos;
|
||||||
|
String productIdAndroid;
|
||||||
|
double priceIos;
|
||||||
|
double priceAndroid;
|
||||||
|
|
||||||
Product.fromJson(Map json) {
|
Product.fromJson(Map json) {
|
||||||
this.productId = json['productId'];
|
this.productId = json['productId'];
|
||||||
this.name = json['name'];
|
this.name = json['name'];
|
||||||
this.description = json['description'];
|
this.description = json['description'];
|
||||||
this.type = json['type'];
|
this.type = json['type'];
|
||||||
this.validFrom = json['validFrom'];
|
this.appVersion = json['appVersion'];
|
||||||
this.validTo = json['validTo'];
|
this.sort = json['sort'];
|
||||||
|
this.productSet = json['productSet'];
|
||||||
|
this.validFrom = json['validFrom'] == null ? null : DateTime.parse(json['validFrom']);
|
||||||
|
this.validTo = json['validTo'] == null ? null : DateTime.parse(json['validTo']);
|
||||||
|
this.productIdIos = json['productIdIos'];
|
||||||
|
this.productIdAndroid = json['productIdAndroid'];
|
||||||
|
this.priceIos = json['priceIos'];
|
||||||
|
this.priceAndroid = json['priceAndroid'];
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString() {
|
||||||
|
Map<String, dynamic> json = {
|
||||||
|
'productId': this.productId,
|
||||||
|
'name': this.name,
|
||||||
|
'description': this.description,
|
||||||
|
'type': this.type,
|
||||||
|
'appVersion': this.appVersion,
|
||||||
|
'sort': this.sort,
|
||||||
|
'productSet': this.productSet,
|
||||||
|
'validFrom': this.validFrom,
|
||||||
|
'validTo': validTo,
|
||||||
|
'productIdIos': this.productIdIos,
|
||||||
|
'productIdAndroid': this.productIdAndroid,
|
||||||
|
'priceIos': this.priceIos,
|
||||||
|
'priceAndroid': this.priceAndroid,
|
||||||
|
};
|
||||||
|
return json.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
import 'package:intl/intl.dart';
|
||||||
|
|
||||||
class ProductTest {
|
class ProductTest {
|
||||||
int productTestId;
|
int productTestId;
|
||||||
int customerId;
|
int customerId;
|
||||||
@ -6,11 +8,32 @@ class ProductTest {
|
|||||||
DateTime dateView;
|
DateTime dateView;
|
||||||
bool purchaseClick;
|
bool purchaseClick;
|
||||||
|
|
||||||
|
ProductTest();
|
||||||
|
|
||||||
ProductTest.fromJson(Map json) {
|
ProductTest.fromJson(Map json) {
|
||||||
this.productTestId = json['productTestId'];
|
this.productTestId = json['productTestId'];
|
||||||
this.customerId = json['customerId'];
|
this.customerId = json['customerId'];
|
||||||
this.productId = json['productId'];
|
this.productId = json['productId'];
|
||||||
this.dateView = json['dateView'];
|
this.dateView = DateTime.parse(json['dateView']);
|
||||||
this.purchaseClick = json['purchaseClick'];
|
this.purchaseClick = json['purchaseClick'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
if (productTestId != null) {
|
||||||
|
return {
|
||||||
|
"productTestId": productTestId,
|
||||||
|
"customerId": customerId,
|
||||||
|
"productId": productId,
|
||||||
|
"dateView": DateFormat('yyyy-MM-dd HH:mm:ss').format(this.dateView),
|
||||||
|
"purchaseClick": purchaseClick
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
return {
|
||||||
|
"customerId": customerId,
|
||||||
|
"productId": productId,
|
||||||
|
"dateView": DateFormat('yyyy-MM-dd HH:mm:ss').format(this.dateView),
|
||||||
|
"purchaseClick": purchaseClick
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import 'package:flutter_form_bloc/flutter_form_bloc.dart';
|
import 'package:intl/intl.dart';
|
||||||
|
|
||||||
class Purchase {
|
class Purchase {
|
||||||
int purchaseId;
|
int purchaseId;
|
||||||
@ -13,13 +13,12 @@ class Purchase {
|
|||||||
this.purchaseId = json['purchaseId'];
|
this.purchaseId = json['purchaseId'];
|
||||||
this.customerId = json['customerId'];
|
this.customerId = json['customerId'];
|
||||||
this.productId = json['productId'];
|
this.productId = json['productId'];
|
||||||
this.dateAdd = json['dateAdd'];
|
this.dateAdd = DateTime.parse(json['dateAdd']);
|
||||||
this.purchaseSum = json['purchaseSum'];
|
this.purchaseSum = json['purchaseSum'];
|
||||||
this.customerId = json['currency'];
|
this.currency = json['currency'];
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<String, dynamic> toJson() =>
|
Map<String, dynamic> toJson() => {
|
||||||
{
|
|
||||||
"purchaseId": purchaseId,
|
"purchaseId": purchaseId,
|
||||||
"customerId": customerId,
|
"customerId": customerId,
|
||||||
"productId": productId,
|
"productId": productId,
|
||||||
|
@ -72,7 +72,11 @@ extension ResultItemExt on ResultItem {
|
|||||||
class ResultExt {
|
class ResultExt {
|
||||||
final String itemString;
|
final String itemString;
|
||||||
ResultItem item;
|
ResultItem item;
|
||||||
String data = "0";
|
double data = 0;
|
||||||
|
int exerciseId;
|
||||||
|
DateTime dateFrom;
|
||||||
|
|
||||||
|
DateTime dateTo;
|
||||||
|
|
||||||
ResultExt({this.itemString}) {
|
ResultExt({this.itemString}) {
|
||||||
ResultItem.values.forEach((element) {
|
ResultItem.values.forEach((element) {
|
||||||
@ -84,9 +88,13 @@ class ResultExt {
|
|||||||
|
|
||||||
String getDescription() => item.description;
|
String getDescription() => item.description;
|
||||||
String getImage() => "asset/image/" + item.image;
|
String getImage() => "asset/image/" + item.image;
|
||||||
bool isHardware() {
|
bool isHardware() => item.isHardware;
|
||||||
return item.isHardware;
|
int get getExerciseId => exerciseId;
|
||||||
}
|
set setExerciseId(int exerciseId) => this.exerciseId = exerciseId;
|
||||||
|
set setDateFrom(DateTime dateFrom) => this.dateFrom = dateFrom;
|
||||||
|
DateTime get getDateFrom => dateFrom;
|
||||||
|
set setDateTo(DateTime dateTo) => this.dateTo = dateTo;
|
||||||
|
DateTime get getDateTo => dateTo;
|
||||||
|
|
||||||
bool equals(ResultItem item) => this.item.equals(item);
|
bool equals(ResultItem item) => this.item.equals(item);
|
||||||
bool equalsString(String item) => this.item.equalsString(item);
|
bool equalsString(String item) => this.item.equalsString(item);
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
|
import 'package:aitrainer_app/service/logging.dart';
|
||||||
import 'package:firebase_messaging/firebase_messaging.dart';
|
import 'package:firebase_messaging/firebase_messaging.dart';
|
||||||
|
|
||||||
class PushNotificationsManager {
|
class PushNotificationsManager with Logging {
|
||||||
PushNotificationsManager._();
|
PushNotificationsManager._();
|
||||||
|
|
||||||
factory PushNotificationsManager() => _instance;
|
factory PushNotificationsManager() => _instance;
|
||||||
@ -16,9 +17,9 @@ class PushNotificationsManager {
|
|||||||
_firebaseMessaging.requestNotificationPermissions();
|
_firebaseMessaging.requestNotificationPermissions();
|
||||||
_firebaseMessaging.configure();
|
_firebaseMessaging.configure();
|
||||||
|
|
||||||
// For testing purposes print the Firebase Messaging token
|
// For testing purposes log the Firebase Messaging token
|
||||||
String token = await _firebaseMessaging.getToken();
|
String token = await _firebaseMessaging.getToken();
|
||||||
print("FirebaseMessaging token: $token");
|
log("FirebaseMessaging token: $token");
|
||||||
|
|
||||||
_initialized = true;
|
_initialized = true;
|
||||||
}
|
}
|
||||||
|
@ -45,8 +45,6 @@ class CustomerExerciseDeviceRepository {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> removeDevice(ExerciseDevice device) async {
|
Future<void> removeDevice(ExerciseDevice device) async {
|
||||||
print("Remove " + device.name);
|
|
||||||
|
|
||||||
CustomerExerciseDevice found;
|
CustomerExerciseDevice found;
|
||||||
if (_devices != null) {
|
if (_devices != null) {
|
||||||
this._devices.forEach((element) {
|
this._devices.forEach((element) {
|
||||||
|
@ -3,8 +3,14 @@ import 'dart:collection';
|
|||||||
import 'package:aitrainer_app/model/cache.dart';
|
import 'package:aitrainer_app/model/cache.dart';
|
||||||
import 'package:aitrainer_app/model/customer.dart';
|
import 'package:aitrainer_app/model/customer.dart';
|
||||||
import 'package:aitrainer_app/model/customer_property.dart';
|
import 'package:aitrainer_app/model/customer_property.dart';
|
||||||
|
import 'package:aitrainer_app/model/product_test.dart';
|
||||||
|
import 'package:aitrainer_app/model/purchase.dart';
|
||||||
import 'package:aitrainer_app/repository/property_repository.dart';
|
import 'package:aitrainer_app/repository/property_repository.dart';
|
||||||
import 'package:aitrainer_app/service/customer_service.dart';
|
import 'package:aitrainer_app/service/customer_service.dart';
|
||||||
|
import 'package:aitrainer_app/service/logging.dart';
|
||||||
|
import 'package:aitrainer_app/service/product_test_service.dart';
|
||||||
|
import 'package:aitrainer_app/service/purchase.dart';
|
||||||
|
import 'package:aitrainer_app/util/not_found_exception.dart';
|
||||||
|
|
||||||
class GenderItem {
|
class GenderItem {
|
||||||
GenderItem(this.dbValue, this.name);
|
GenderItem(this.dbValue, this.name);
|
||||||
@ -12,7 +18,7 @@ class GenderItem {
|
|||||||
String name;
|
String name;
|
||||||
}
|
}
|
||||||
|
|
||||||
class CustomerRepository {
|
class CustomerRepository with Logging {
|
||||||
Customer customer;
|
Customer customer;
|
||||||
Customer _trainee;
|
Customer _trainee;
|
||||||
List<Customer> _trainees;
|
List<Customer> _trainees;
|
||||||
@ -244,4 +250,33 @@ class CustomerRepository {
|
|||||||
});
|
});
|
||||||
return _trainee;
|
return _trainee;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<List<Purchase>> getPurchase() async {
|
||||||
|
int customerId = Cache().userLoggedIn.customerId;
|
||||||
|
List<Purchase> purchases = await PurchaseApi().getPurchasesByCustomer(customerId);
|
||||||
|
return purchases;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> addPurchase(Purchase purchase) async {
|
||||||
|
await PurchaseApi().savePurchase(purchase);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<List<ProductTest>> getProductTests() async {
|
||||||
|
List<ProductTest> tests = List();
|
||||||
|
try {
|
||||||
|
int customerId = Cache().userLoggedIn.customerId;
|
||||||
|
tests = await ProductTestApi().getProductTestByCustomer(customerId);
|
||||||
|
} on NotFoundException catch (ex) {
|
||||||
|
log("Product Tests not found");
|
||||||
|
Cache().productTests = tests;
|
||||||
|
} on Exception catch (ex) {
|
||||||
|
log(ex.toString());
|
||||||
|
Cache().productTests = tests;
|
||||||
|
}
|
||||||
|
return tests;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> addProductTest(ProductTest productTest) async {
|
||||||
|
await ProductTestApi().saveProductTest(productTest);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -151,7 +151,6 @@ class ExercisePlanRepository {
|
|||||||
|
|
||||||
exercisePlan = await ExercisePlanApi().getLastExercisePlan(customerId);
|
exercisePlan = await ExercisePlanApi().getLastExercisePlan(customerId);
|
||||||
newPlan = (exercisePlan == null);
|
newPlan = (exercisePlan == null);
|
||||||
print("New plan: " + newPlan.toString());
|
|
||||||
Cache().setMyExercisePlan(exercisePlan);
|
Cache().setMyExercisePlan(exercisePlan);
|
||||||
return exercisePlan;
|
return exercisePlan;
|
||||||
}
|
}
|
||||||
|
@ -1,17 +1,20 @@
|
|||||||
import 'dart:collection';
|
import 'dart:collection';
|
||||||
|
|
||||||
|
import 'package:aitrainer_app/localization/app_language.dart';
|
||||||
import 'package:aitrainer_app/model/cache.dart';
|
import 'package:aitrainer_app/model/cache.dart';
|
||||||
import 'package:aitrainer_app/model/customer.dart';
|
import 'package:aitrainer_app/model/customer.dart';
|
||||||
import 'package:aitrainer_app/model/exercise.dart';
|
import 'package:aitrainer_app/model/exercise.dart';
|
||||||
import 'package:aitrainer_app/model/exercise_type.dart';
|
import 'package:aitrainer_app/model/exercise_type.dart';
|
||||||
import 'package:aitrainer_app/model/workout_menu_tree.dart';
|
import 'package:aitrainer_app/model/workout_menu_tree.dart';
|
||||||
import 'package:aitrainer_app/service/exercise_service.dart';
|
import 'package:aitrainer_app/service/exercise_service.dart';
|
||||||
|
import 'package:flutter_form_bloc/flutter_form_bloc.dart';
|
||||||
|
|
||||||
class ExerciseRepository {
|
class ExerciseRepository {
|
||||||
Exercise exercise;
|
Exercise exercise;
|
||||||
Customer customer;
|
Customer customer;
|
||||||
ExerciseType exerciseType;
|
ExerciseType exerciseType;
|
||||||
List<Exercise> exerciseList;
|
List<Exercise> exerciseList;
|
||||||
|
List<Exercise> exerciseLogList = List();
|
||||||
List<Exercise> actualExerciseList = List();
|
List<Exercise> actualExerciseList = List();
|
||||||
|
|
||||||
double rmWendler = 0;
|
double rmWendler = 0;
|
||||||
@ -78,8 +81,11 @@ class ExerciseRepository {
|
|||||||
modelExercise.unitQuantity = null;
|
modelExercise.unitQuantity = null;
|
||||||
}
|
}
|
||||||
this.actualExerciseList.add(modelExercise);
|
this.actualExerciseList.add(modelExercise);
|
||||||
|
int index = this.actualExerciseList.length - 1;
|
||||||
|
|
||||||
Exercise savedExercise = await ExerciseApi().addExercise(modelExercise);
|
Exercise savedExercise = await ExerciseApi().addExercise(modelExercise);
|
||||||
|
|
||||||
|
this.actualExerciseList[index].exerciseId = savedExercise.exerciseId;
|
||||||
if (customer.customerId == Cache().userLoggedIn.customerId) {
|
if (customer.customerId == Cache().userLoggedIn.customerId) {
|
||||||
Cache().addExercise(savedExercise);
|
Cache().addExercise(savedExercise);
|
||||||
} else if (Cache().getTrainee() != null && customer.customerId == Cache().getTrainee().customerId) {
|
} else if (Cache().getTrainee() != null && customer.customerId == Cache().getTrainee().customerId) {
|
||||||
@ -238,5 +244,44 @@ class ExerciseRepository {
|
|||||||
return actualExerciseType;
|
return actualExerciseType;
|
||||||
}
|
}
|
||||||
|
|
||||||
void sortByDate() => exerciseList.sort((a, b) => b.dateAdd.compareTo(a.dateAdd));
|
void sortByDate() {
|
||||||
|
exerciseList.sort((a, b) => b.dateAdd.compareTo(a.dateAdd));
|
||||||
|
|
||||||
|
this.exerciseLogList = List();
|
||||||
|
String summary = "";
|
||||||
|
|
||||||
|
String prevDate = DateFormat("yyyy-MM-dd", AppLanguage().appLocal.toString()).format(exerciseList[0].dateAdd);
|
||||||
|
int prevExerciseTypeId = exerciseList[0].exerciseTypeId;
|
||||||
|
Exercise prevExercise = exerciseList[0];
|
||||||
|
int prevCount = 0;
|
||||||
|
for (int i = 0; i < this.exerciseList.length; i++) {
|
||||||
|
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)) {
|
||||||
|
ExerciseType exerciseType = Cache().getExercise(prevExercise.exerciseTypeId);
|
||||||
|
String unit = exerciseType.unitQuantityUnit != null ? exerciseType.unitQuantityUnit : prevExercise.unit;
|
||||||
|
prevExercise.summary = summary + " " + unit;
|
||||||
|
exerciseLogList.add(prevExercise);
|
||||||
|
//print("Log add " + exercise.toJson().toString());
|
||||||
|
summary = "";
|
||||||
|
prevCount = 0;
|
||||||
|
}
|
||||||
|
String delimiter = "";
|
||||||
|
if (prevCount > 0) delimiter = ", ";
|
||||||
|
summary += delimiter + exercise.quantity.toStringAsFixed(0);
|
||||||
|
ExerciseType exerciseType = Cache().getExercise(exercise.exerciseTypeId);
|
||||||
|
if (exerciseType.unitQuantity == "1") {
|
||||||
|
summary += "x" + exercise.unitQuantity.toStringAsFixed(0);
|
||||||
|
}
|
||||||
|
//print(" --- sum " + exerciseType.name + " $summary");
|
||||||
|
|
||||||
|
prevExerciseTypeId = exerciseTypeId;
|
||||||
|
prevDate = exerciseDate;
|
||||||
|
prevExercise = exercise;
|
||||||
|
prevCount++;
|
||||||
|
}
|
||||||
|
;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
|
import 'package:aitrainer_app/model/cache.dart';
|
||||||
|
import 'package:aitrainer_app/model/exercise_result.dart';
|
||||||
import 'package:aitrainer_app/model/result.dart';
|
import 'package:aitrainer_app/model/result.dart';
|
||||||
|
import 'package:aitrainer_app/service/exercise_result_service.dart';
|
||||||
|
|
||||||
enum ResultType { running, man, woman, none }
|
enum ResultType { running, man, woman, none }
|
||||||
|
|
||||||
@ -37,4 +40,17 @@ class ExerciseResultRepository {
|
|||||||
}
|
}
|
||||||
|
|
||||||
List<ResultExt> getResults() => this._results;
|
List<ResultExt> getResults() => this._results;
|
||||||
|
|
||||||
|
Future<void> saveExerciseResults() async {
|
||||||
|
this._results.forEach((result) async {
|
||||||
|
ExerciseResult exerciseResult = ExerciseResult();
|
||||||
|
exerciseResult.customerId = Cache().userLoggedIn.customerId;
|
||||||
|
exerciseResult.exerciseId = result.exerciseId;
|
||||||
|
exerciseResult.dateFrom = result.dateFrom;
|
||||||
|
exerciseResult.dateTo = result.dateTo;
|
||||||
|
exerciseResult.resultType = result.itemString;
|
||||||
|
exerciseResult.value = result.data;
|
||||||
|
await ExerciseResultApi().saveExerciseResult(exerciseResult);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ import 'package:aitrainer_app/model/workout_menu_tree.dart';
|
|||||||
import 'package:aitrainer_app/repository/exercise_repository.dart';
|
import 'package:aitrainer_app/repository/exercise_repository.dart';
|
||||||
import 'package:aitrainer_app/service/exercise_tree_service.dart';
|
import 'package:aitrainer_app/service/exercise_tree_service.dart';
|
||||||
import 'package:aitrainer_app/service/exercisetype_service.dart';
|
import 'package:aitrainer_app/service/exercisetype_service.dart';
|
||||||
|
import 'package:aitrainer_app/service/logging.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
class Antagonist {
|
class Antagonist {
|
||||||
@ -29,7 +30,7 @@ class Antagonist {
|
|||||||
static int calfNr = 8;
|
static int calfNr = 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
class WorkoutTreeRepository {
|
class WorkoutTreeRepository with Logging {
|
||||||
final LinkedHashMap tree = LinkedHashMap<String, WorkoutMenuTree>();
|
final LinkedHashMap tree = LinkedHashMap<String, WorkoutMenuTree>();
|
||||||
SplayTreeMap sortedTree = SplayTreeMap<String, List<WorkoutMenuTree>>();
|
SplayTreeMap sortedTree = SplayTreeMap<String, List<WorkoutMenuTree>>();
|
||||||
bool isEnglish;
|
bool isEnglish;
|
||||||
@ -48,7 +49,7 @@ class WorkoutTreeRepository {
|
|||||||
|
|
||||||
Future<void> createTree() async {
|
Future<void> createTree() async {
|
||||||
isEnglish = AppLanguage().appLocal == Locale('en');
|
isEnglish = AppLanguage().appLocal == Locale('en');
|
||||||
print("** Start creating tree on lang: " + AppLanguage().appLocal.languageCode);
|
log("** Start creating tree on lang: " + AppLanguage().appLocal.languageCode);
|
||||||
|
|
||||||
List<ExerciseTree> exerciseTree = Cache().getExerciseTree();
|
List<ExerciseTree> exerciseTree = Cache().getExerciseTree();
|
||||||
if (exerciseTree == null || exerciseTree.length == 0) {
|
if (exerciseTree == null || exerciseTree.length == 0) {
|
||||||
@ -61,7 +62,7 @@ class WorkoutTreeRepository {
|
|||||||
}
|
}
|
||||||
|
|
||||||
exerciseTree.forEach((treeItem) async {
|
exerciseTree.forEach((treeItem) async {
|
||||||
//print(" -- TreeItem " + treeItem.toJson().toString() + " active " + treeItem.active.toString());
|
//log(" -- TreeItem " + treeItem.toJson().toString() + " active " + treeItem.active.toString());
|
||||||
if (treeItem.active == true) {
|
if (treeItem.active == true) {
|
||||||
String treeName = isEnglish ? treeItem.name : treeItem.nameTranslation;
|
String treeName = isEnglish ? treeItem.name : treeItem.nameTranslation;
|
||||||
String assetImage = 'asset/menu/' + treeItem.imageUrl.substring(7);
|
String assetImage = 'asset/menu/' + treeItem.imageUrl.substring(7);
|
||||||
@ -99,7 +100,7 @@ class WorkoutTreeRepository {
|
|||||||
);
|
);
|
||||||
menuItem = this.setWorkoutTypes(menuItem, treeItem);
|
menuItem = this.setWorkoutTypes(menuItem, treeItem);
|
||||||
this.tree[treeItem.name + "_" + treeItem.parentId.toString()] = menuItem;
|
this.tree[treeItem.name + "_" + treeItem.parentId.toString()] = menuItem;
|
||||||
//print("WorkoutMenuTree item " + menuItem.toJson().toString());
|
//log("WorkoutMenuTree item " + menuItem.toJson().toString());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -119,19 +120,19 @@ class WorkoutTreeRepository {
|
|||||||
WorkoutMenuTree menuItem = WorkoutMenuTree(exerciseType.exerciseTypeId, parentId, exerciseTypeName, assetImage, Colors.white,
|
WorkoutMenuTree menuItem = WorkoutMenuTree(exerciseType.exerciseTypeId, parentId, exerciseTypeName, assetImage, Colors.white,
|
||||||
24, true, exerciseType.exerciseTypeId, exerciseType, exerciseType.base, is1RM, isEndurance, isRunning, exerciseType.name);
|
24, true, exerciseType.exerciseTypeId, exerciseType, exerciseType.base, is1RM, isEndurance, isRunning, exerciseType.name);
|
||||||
this.tree[exerciseType.name] = menuItem;
|
this.tree[exerciseType.name] = menuItem;
|
||||||
print("WorkoutMenuTree item " + menuItem.toJson().toString());
|
//log("WorkoutMenuTree item " + menuItem.toJson().toString());
|
||||||
print("ExerciseType in Menu item " +
|
/* log("ExerciseType in Menu item " +
|
||||||
exerciseType.toJson().toString() +
|
exerciseType.toJson().toString() +
|
||||||
" is1RM: " +
|
" is1RM: " +
|
||||||
is1RM.toString() +
|
is1RM.toString() +
|
||||||
" isEndurance: " +
|
" isEndurance: " +
|
||||||
isEndurance.toString());
|
isEndurance.toString()); */
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
//print("No Parents " + exerciseType.toJson().toString());
|
//log("No Parents " + exerciseType.toJson().toString());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
//print("ExerciseType missing data: " + exerciseType.exerciseTypeId.toString());
|
//log("ExerciseType missing data: " + exerciseType.exerciseTypeId.toString());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -166,7 +167,7 @@ class WorkoutTreeRepository {
|
|||||||
WorkoutMenuTree treeItem = value as WorkoutMenuTree;
|
WorkoutMenuTree treeItem = value as WorkoutMenuTree;
|
||||||
if (treeItem.id == treeId) {
|
if (treeItem.id == treeId) {
|
||||||
isTreeItemRunning = isTreeItemRunning || treeItem.isRunning;
|
isTreeItemRunning = isTreeItemRunning || treeItem.isRunning;
|
||||||
//print (treeItem.name + " 1RM " + treeItem.is1RM.toString() );
|
//log (treeItem.name + " 1RM " + treeItem.is1RM.toString() );
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -180,7 +181,7 @@ class WorkoutTreeRepository {
|
|||||||
WorkoutMenuTree treeItem = value as WorkoutMenuTree;
|
WorkoutMenuTree treeItem = value as WorkoutMenuTree;
|
||||||
if (treeItem.id == treeId) {
|
if (treeItem.id == treeId) {
|
||||||
isTreeItem1RM = isTreeItem1RM || treeItem.is1RM;
|
isTreeItem1RM = isTreeItem1RM || treeItem.is1RM;
|
||||||
//print (treeItem.name + " 1RM " + treeItem.is1RM.toString() );
|
//log (treeItem.name + " 1RM " + treeItem.is1RM.toString() );
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -194,7 +195,7 @@ class WorkoutTreeRepository {
|
|||||||
WorkoutMenuTree treeItem = value as WorkoutMenuTree;
|
WorkoutMenuTree treeItem = value as WorkoutMenuTree;
|
||||||
if (treeItem.id == treeId) {
|
if (treeItem.id == treeId) {
|
||||||
isTreeItemEndurance = isTreeItemEndurance || treeItem.isEndurance;
|
isTreeItemEndurance = isTreeItemEndurance || treeItem.isEndurance;
|
||||||
//print(treeItem.id.toString() + " " + treeItem.name + " Endurance? " + treeItem.isEndurance.toString());
|
//log(treeItem.id.toString() + " " + treeItem.name + " Endurance? " + treeItem.isEndurance.toString());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -208,7 +209,7 @@ class WorkoutTreeRepository {
|
|||||||
WorkoutMenuTree workoutTree = value;
|
WorkoutMenuTree workoutTree = value;
|
||||||
isChild = isChild && workoutTree.child;
|
isChild = isChild && workoutTree.child;
|
||||||
});
|
});
|
||||||
//print("Check child " + parentId.toString() + " child: " + isChild.toString());
|
//log("Check child " + parentId.toString() + " child: " + isChild.toString());
|
||||||
return isChild;
|
return isChild;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,20 +1,22 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
import 'package:aitrainer_app/service/logging.dart';
|
||||||
import 'package:aitrainer_app/util/common.dart';
|
import 'package:aitrainer_app/util/common.dart';
|
||||||
import 'package:aitrainer_app/util/not_found_exception.dart';
|
import 'package:aitrainer_app/util/not_found_exception.dart';
|
||||||
import 'package:http/http.dart' as http;
|
import 'package:http/http.dart' as http;
|
||||||
import 'package:aitrainer_app/model/cache.dart';
|
import 'package:aitrainer_app/model/cache.dart';
|
||||||
|
|
||||||
class APIClient with Common {
|
class APIClient with Common, Logging {
|
||||||
Future<String> get(String endPoint, String param) async {
|
Future<String> get(String endPoint, String param) async {
|
||||||
final url = Cache.getBaseUrl() + endPoint + param;
|
final url = Cache.getBaseUrl() + endPoint + param;
|
||||||
print("-------- API get " + url);
|
trace("-------- API get " + url);
|
||||||
String authToken = Cache().getAuthToken();
|
String authToken = Cache().getAuthToken();
|
||||||
if (authToken.length == 0) {
|
if (authToken.length == 0) {
|
||||||
var responseJson = await APIClient.authenticateUser(Cache.username, Cache.password);
|
var responseJson = await this.authenticateUser(Cache.username, Cache.password);
|
||||||
authToken = responseJson['token'];
|
authToken = responseJson['token'];
|
||||||
|
Cache().authToken = authToken;
|
||||||
}
|
}
|
||||||
final response = await http.get(url, headers: {'Content-Type': 'application/json', 'Authorization': "Bearer " + authToken});
|
final response = await http.get(url, headers: {'Content-Type': 'application/json', 'Authorization': "Bearer " + authToken});
|
||||||
print(" ------------get response code: " + response.statusCode.toString());
|
trace(" ------------get response code: " + response.statusCode.toString());
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
return utf8.decode(response.bodyBytes);
|
return utf8.decode(response.bodyBytes);
|
||||||
} else if (response.statusCode == 404) {
|
} else if (response.statusCode == 404) {
|
||||||
@ -26,10 +28,10 @@ class APIClient with Common {
|
|||||||
|
|
||||||
Future<String> post(String endPoint, String body) async {
|
Future<String> post(String endPoint, String body) async {
|
||||||
final url = Cache.getBaseUrl() + endPoint;
|
final url = Cache.getBaseUrl() + endPoint;
|
||||||
print(" ------------ http/post endpoint $endPoint body $body - url: $url ");
|
trace(" ------------ http/post body $body - url: $url ");
|
||||||
String authToken = Cache().getAuthToken();
|
String authToken = Cache().getAuthToken();
|
||||||
if (authToken.length == 0) {
|
if (authToken.length == 0) {
|
||||||
var responseJson = await APIClient.authenticateUser(Cache.username, Cache.password);
|
var responseJson = await this.authenticateUser(Cache.username, Cache.password);
|
||||||
authToken = responseJson['token'];
|
authToken = responseJson['token'];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -38,18 +40,18 @@ class APIClient with Common {
|
|||||||
headers: {'Content-Type': 'application/json; charset=UTF-8', 'Authorization': "Bearer " + authToken},
|
headers: {'Content-Type': 'application/json; charset=UTF-8', 'Authorization': "Bearer " + authToken},
|
||||||
body: body,
|
body: body,
|
||||||
);
|
);
|
||||||
print(" ------------post response code: " + response.statusCode.toString());
|
trace(" ------------post response code: " + response.statusCode.toString());
|
||||||
final String decodedResponse = utf8convert(response.body);
|
final String decodedResponse = utf8convert(response.body);
|
||||||
print(" ------------ response: $decodedResponse");
|
trace(" ------------ response: $decodedResponse");
|
||||||
return decodedResponse;
|
return decodedResponse;
|
||||||
}
|
}
|
||||||
|
|
||||||
static dynamic authenticateUser(String email, String password) async {
|
dynamic authenticateUser(String email, String password) async {
|
||||||
var uri = Cache.getBaseUrl() + "authenticate";
|
var uri = Cache.getBaseUrl() + "authenticate";
|
||||||
|
|
||||||
try {
|
try {
|
||||||
final body = '{"username":"$email", "password":"$password"}';
|
final body = '{"username":"$email", "password":"$password"}';
|
||||||
print("authentication with $email");
|
trace("authentication with $email");
|
||||||
final response = await http.post(uri, headers: {'Authorization': '1', 'Content-Type': 'application/json'}, body: body);
|
final response = await http.post(uri, headers: {'Authorization': '1', 'Content-Type': 'application/json'}, body: body);
|
||||||
final responseCode = response.statusCode;
|
final responseCode = response.statusCode;
|
||||||
if (responseCode != 200) {
|
if (responseCode != 200) {
|
||||||
@ -65,7 +67,7 @@ class APIClient with Common {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static fetch(var authToken, var endPoint) async {
|
Future<void> fetch(var authToken, var endPoint) async {
|
||||||
var uri = Cache.getBaseUrl() + endPoint;
|
var uri = Cache.getBaseUrl() + endPoint;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -77,7 +79,7 @@ class APIClient with Common {
|
|||||||
final responseJson = json.decode(response.body);
|
final responseJson = json.decode(response.body);
|
||||||
return responseJson;
|
return responseJson;
|
||||||
} catch (exception) {
|
} catch (exception) {
|
||||||
print(exception);
|
log(exception);
|
||||||
if (exception.toString().contains('SocketException')) {
|
if (exception.toString().contains('SocketException')) {
|
||||||
return 'NetworkError';
|
return 'NetworkError';
|
||||||
} else {
|
} else {
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
import 'package:aitrainer_app/model/customer_exercise_device.dart';
|
import 'package:aitrainer_app/model/customer_exercise_device.dart';
|
||||||
|
import 'package:aitrainer_app/service/logging.dart';
|
||||||
import 'package:aitrainer_app/util/not_found_exception.dart';
|
import 'package:aitrainer_app/util/not_found_exception.dart';
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
import 'api.dart';
|
import 'api.dart';
|
||||||
|
|
||||||
class CustomerExerciseDeviceApi {
|
class CustomerExerciseDeviceApi with Logging {
|
||||||
final APIClient _client = new APIClient();
|
final APIClient _client = new APIClient();
|
||||||
|
|
||||||
Future<List<CustomerExerciseDevice>> getDevices(int customerId) async {
|
Future<List<CustomerExerciseDevice>> getDevices(int customerId) async {
|
||||||
@ -14,7 +15,7 @@ class CustomerExerciseDeviceApi {
|
|||||||
final Iterable json = jsonDecode(body);
|
final Iterable json = jsonDecode(body);
|
||||||
devices = json.map((device) => CustomerExerciseDevice.fromJson(device)).toList();
|
devices = json.map((device) => CustomerExerciseDevice.fromJson(device)).toList();
|
||||||
} on NotFoundException catch (e) {
|
} on NotFoundException catch (e) {
|
||||||
print("No devices found");
|
log("No devices found");
|
||||||
}
|
}
|
||||||
return devices;
|
return devices;
|
||||||
}
|
}
|
||||||
@ -23,7 +24,7 @@ class CustomerExerciseDeviceApi {
|
|||||||
CustomerExerciseDevice savedDevice;
|
CustomerExerciseDevice savedDevice;
|
||||||
try {
|
try {
|
||||||
final String body = JsonEncoder().convert(device.toJson());
|
final String body = JsonEncoder().convert(device.toJson());
|
||||||
print(" --- add customer_exercise_device: " + body);
|
log(" --- add customer_exercise_device: " + body);
|
||||||
final String responseBody = await _client.post("customer_exercise_device", body);
|
final String responseBody = await _client.post("customer_exercise_device", body);
|
||||||
savedDevice = CustomerExerciseDevice.fromJson(jsonDecode(responseBody));
|
savedDevice = CustomerExerciseDevice.fromJson(jsonDecode(responseBody));
|
||||||
} on Exception catch (e) {
|
} on Exception catch (e) {
|
||||||
@ -34,7 +35,7 @@ class CustomerExerciseDeviceApi {
|
|||||||
|
|
||||||
Future<void> removeDevice(int id) async {
|
Future<void> removeDevice(int id) async {
|
||||||
try {
|
try {
|
||||||
print(" --- delete customer_exercise_device: " + id.toString());
|
log(" --- delete customer_exercise_device: " + id.toString());
|
||||||
await _client.post("customer_exercise_device/delete/" + id.toString(), "");
|
await _client.post("customer_exercise_device/delete/" + id.toString(), "");
|
||||||
} on Exception catch (e) {
|
} on Exception catch (e) {
|
||||||
throw new Exception(e.toString());
|
throw new Exception(e.toString());
|
||||||
|
@ -6,8 +6,9 @@ import 'package:aitrainer_app/model/property.dart';
|
|||||||
import 'package:aitrainer_app/model/user.dart';
|
import 'package:aitrainer_app/model/user.dart';
|
||||||
import 'package:aitrainer_app/service/api.dart';
|
import 'package:aitrainer_app/service/api.dart';
|
||||||
import 'package:aitrainer_app/model/cache.dart';
|
import 'package:aitrainer_app/model/cache.dart';
|
||||||
|
import 'package:aitrainer_app/service/logging.dart';
|
||||||
|
|
||||||
class CustomerApi {
|
class CustomerApi with Logging {
|
||||||
final APIClient _client = new APIClient();
|
final APIClient _client = new APIClient();
|
||||||
|
|
||||||
Future<List<Customer>> getRealCustomers(String param) async {
|
Future<List<Customer>> getRealCustomers(String param) async {
|
||||||
@ -20,24 +21,24 @@ class CustomerApi {
|
|||||||
|
|
||||||
Future<void> saveCustomer(Customer customer) async {
|
Future<void> saveCustomer(Customer customer) async {
|
||||||
String body = JsonEncoder().convert(customer.toJson());
|
String body = JsonEncoder().convert(customer.toJson());
|
||||||
print(" ===== saving customer id: " + customer.customerId.toString() + ":" + body);
|
log(" ===== saving customer id: " + customer.customerId.toString() + ":" + body);
|
||||||
await _client.post("customers/" + customer.customerId.toString(), body);
|
await _client.post("customers/" + customer.customerId.toString(), body);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> updateFirebaseUid(int customerId, String uid) async {
|
Future<void> updateFirebaseUid(int customerId, String uid) async {
|
||||||
print(" ===== update Firebase uid : " + customerId.toString() + ": " + uid);
|
log(" ===== update Firebase uid : " + customerId.toString() + ": " + uid);
|
||||||
await _client.post("customers/update_firebase_uid/" + customerId.toString(), uid);
|
await _client.post("customers/update_firebase_uid/" + customerId.toString(), uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> addCustomer(Customer customer) async {
|
Future<void> addCustomer(Customer customer) async {
|
||||||
String body = JsonEncoder().convert(customer.toJson());
|
String body = JsonEncoder().convert(customer.toJson());
|
||||||
print(" ===== add new customer: " + body);
|
log(" ===== add new customer: " + body);
|
||||||
await _client.post("customers", body);
|
await _client.post("customers", body);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> addUser(User user) async {
|
Future<void> addUser(User user) async {
|
||||||
String body = JsonEncoder().convert(user.toJson());
|
String body = JsonEncoder().convert(user.toJson());
|
||||||
print(" ===== add new user: " + body);
|
log(" ===== add new user: " + body);
|
||||||
final String responseBody = await _client.post("registration", body);
|
final String responseBody = await _client.post("registration", body);
|
||||||
Customer customer;
|
Customer customer;
|
||||||
try {
|
try {
|
||||||
@ -55,7 +56,7 @@ class CustomerApi {
|
|||||||
|
|
||||||
Future<void> getUser(User user) async {
|
Future<void> getUser(User user) async {
|
||||||
String body = JsonEncoder().convert(user.toJson());
|
String body = JsonEncoder().convert(user.toJson());
|
||||||
print(" ===== login the user: " + body);
|
log(" ===== login the user: " + body);
|
||||||
final String responseBody = await _client.post("login", body);
|
final String responseBody = await _client.post("login", body);
|
||||||
Customer customer;
|
Customer customer;
|
||||||
try {
|
try {
|
||||||
@ -67,7 +68,7 @@ class CustomerApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> getUserByEmail(String email) async {
|
Future<void> getUserByEmail(String email) async {
|
||||||
print(" ===== User getByEmail : " + email);
|
log(" ===== User getByEmail : " + email);
|
||||||
final String responseBody = await _client.get("customers/find_by_email/" + email, "");
|
final String responseBody = await _client.get("customers/find_by_email/" + email, "");
|
||||||
Customer customer;
|
Customer customer;
|
||||||
try {
|
try {
|
||||||
@ -87,20 +88,21 @@ class CustomerApi {
|
|||||||
|
|
||||||
Future<void> getCustomer(int customerId) async {
|
Future<void> getCustomer(int customerId) async {
|
||||||
String body = "";
|
String body = "";
|
||||||
print(" ===== get the customer by id: " + customerId.toString());
|
log(" ===== get the customer by id: " + customerId.toString());
|
||||||
try {
|
try {
|
||||||
final String responseBody = await _client.get("customers/" + customerId.toString(), body);
|
final String responseBody = await _client.get("customers/" + customerId.toString(), body);
|
||||||
Customer customer = Customer.fromJson(jsonDecode(responseBody));
|
Customer customer = Customer.fromJson(jsonDecode(responseBody));
|
||||||
print(" --- Customer: " + customer.toJson().toString());
|
log(" --- Customer: " + customer.toJson().toString());
|
||||||
|
Cache().userLoggedIn = customer;
|
||||||
final List properties = await this.getActualProperties(customerId);
|
final List properties = await this.getActualProperties(customerId);
|
||||||
print(" ---- Props: " + properties.toString());
|
//log(" ---- Props: " + properties.toJson().toString());
|
||||||
Cache().afterRegistration(customer);
|
//await Cache().initCustomer(customerId);
|
||||||
if (properties != null) {
|
if (properties != null) {
|
||||||
this._initProperties(properties);
|
this._initProperties(properties);
|
||||||
}
|
}
|
||||||
} on Exception catch (exception) {
|
} on Exception catch (exception) {
|
||||||
print("Exception: " + exception.toString());
|
log("Exception: " + exception.toString());
|
||||||
print(" === go to registration ");
|
log(" === go to registration ");
|
||||||
Cache().logout();
|
Cache().logout();
|
||||||
Cache().startPage = "registration";
|
Cache().startPage = "registration";
|
||||||
}
|
}
|
||||||
@ -130,13 +132,13 @@ class CustomerApi {
|
|||||||
Future<Customer> getTrainee(int customerId) async {
|
Future<Customer> getTrainee(int customerId) async {
|
||||||
String body = "";
|
String body = "";
|
||||||
Customer customer;
|
Customer customer;
|
||||||
print(" ===== get Trainee customer by id: " + customerId.toString());
|
log(" ===== get Trainee customer by id: " + customerId.toString());
|
||||||
try {
|
try {
|
||||||
final String responseBody = await _client.get("customers/" + customerId.toString(), body);
|
final String responseBody = await _client.get("customers/" + customerId.toString(), body);
|
||||||
customer = Customer.fromJson(jsonDecode(responseBody));
|
customer = Customer.fromJson(jsonDecode(responseBody));
|
||||||
print(" --- Trainee: " + customer.toJson().toString());
|
log(" --- Trainee: " + customer.toJson().toString());
|
||||||
} catch (exception) {
|
} catch (exception) {
|
||||||
print("Exception: " + exception.toString());
|
log("Exception: " + exception.toString());
|
||||||
throw Exception(exception);
|
throw Exception(exception);
|
||||||
}
|
}
|
||||||
return customer;
|
return customer;
|
||||||
@ -144,14 +146,14 @@ class CustomerApi {
|
|||||||
|
|
||||||
Future<List<Customer>> getTrainees(int trainerId) async {
|
Future<List<Customer>> getTrainees(int trainerId) async {
|
||||||
List<Customer> trainees = List<Customer>();
|
List<Customer> trainees = List<Customer>();
|
||||||
print("Get trainees list");
|
log("Get trainees list");
|
||||||
try {
|
try {
|
||||||
String body = "";
|
String body = "";
|
||||||
final String responseBody = await _client.get("customers/trainees/" + trainerId.toString(), body);
|
final String responseBody = await _client.get("customers/trainees/" + trainerId.toString(), body);
|
||||||
final Iterable json = jsonDecode(responseBody);
|
final Iterable json = jsonDecode(responseBody);
|
||||||
trainees = json.map((customer) => Customer.fromJson(customer)).toList();
|
trainees = json.map((customer) => Customer.fromJson(customer)).toList();
|
||||||
} catch (exception) {
|
} catch (exception) {
|
||||||
print("Exception: " + exception.toString());
|
log("Exception: " + exception.toString());
|
||||||
throw Exception(exception);
|
throw Exception(exception);
|
||||||
}
|
}
|
||||||
return trainees;
|
return trainees;
|
||||||
@ -174,18 +176,18 @@ class CustomerApi {
|
|||||||
|
|
||||||
if (properties != null) {
|
if (properties != null) {
|
||||||
properties.forEach((element) {
|
properties.forEach((element) {
|
||||||
print("Property " + element.toString());
|
//log("Property " + element.toString());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} on Exception catch (ex) {
|
} on Exception catch (ex) {
|
||||||
print(ex.toString());
|
log(ex.toString());
|
||||||
}
|
}
|
||||||
return properties;
|
return properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> addProperty(CustomerProperty property) async {
|
Future<void> addProperty(CustomerProperty property) async {
|
||||||
String body = JsonEncoder().convert(property.toJson());
|
String body = JsonEncoder().convert(property.toJson());
|
||||||
print(" ===== add new customer property: " + body);
|
log(" ===== add new customer property: " + body);
|
||||||
final String responseBody = await _client.post("customer_property", body);
|
final String responseBody = await _client.post("customer_property", body);
|
||||||
try {
|
try {
|
||||||
int status = jsonDecode(responseBody)['status'];
|
int status = jsonDecode(responseBody)['status'];
|
||||||
|
@ -1,41 +1,34 @@
|
|||||||
import 'package:aitrainer_app/model/exercise_plan.dart';
|
import 'package:aitrainer_app/model/exercise_plan.dart';
|
||||||
import 'package:aitrainer_app/model/exercise_plan_detail.dart';
|
import 'package:aitrainer_app/model/exercise_plan_detail.dart';
|
||||||
|
import 'package:aitrainer_app/service/logging.dart';
|
||||||
import 'package:aitrainer_app/util/not_found_exception.dart';
|
import 'package:aitrainer_app/util/not_found_exception.dart';
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'api.dart';
|
import 'api.dart';
|
||||||
|
|
||||||
class ExercisePlanApi {
|
class ExercisePlanApi with Logging {
|
||||||
final APIClient _client = new APIClient();
|
final APIClient _client = new APIClient();
|
||||||
|
|
||||||
Future<ExercisePlan> saveExercisePlan(ExercisePlan exercisePlan) async {
|
Future<ExercisePlan> saveExercisePlan(ExercisePlan exercisePlan) async {
|
||||||
String body = JsonEncoder().convert(exercisePlan.toJson());
|
String body = JsonEncoder().convert(exercisePlan.toJson());
|
||||||
print(" ===== saving exercisePlan $exercisePlan");
|
log(" ===== saving exercisePlan $exercisePlan");
|
||||||
ExercisePlan savedExercisePlan;
|
ExercisePlan savedExercisePlan;
|
||||||
try {
|
try {
|
||||||
final String responseBody = await _client.post(
|
final String responseBody = await _client.post("exercise_plan", body);
|
||||||
"exercise_plan",
|
|
||||||
body);
|
|
||||||
savedExercisePlan = ExercisePlan.fromJson(jsonDecode(responseBody));
|
savedExercisePlan = ExercisePlan.fromJson(jsonDecode(responseBody));
|
||||||
|
} on Exception catch (e) {
|
||||||
} on Exception catch(e) {
|
|
||||||
throw new Exception(e.toString());
|
throw new Exception(e.toString());
|
||||||
}
|
}
|
||||||
return savedExercisePlan;
|
return savedExercisePlan;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<ExercisePlan> updateExercisePlan(
|
Future<ExercisePlan> updateExercisePlan(ExercisePlan exercisePlan, int exercisePlanId) async {
|
||||||
ExercisePlan exercisePlan,
|
|
||||||
int exercisePlanId) async {
|
|
||||||
String body = JsonEncoder().convert(exercisePlan.toJson());
|
String body = JsonEncoder().convert(exercisePlan.toJson());
|
||||||
print(" ===== update exercisePlan $exercisePlan");
|
log(" ===== update exercisePlan $exercisePlan");
|
||||||
ExercisePlan updatedExercisePlan;
|
ExercisePlan updatedExercisePlan;
|
||||||
try {
|
try {
|
||||||
final String responseBody = await _client.post(
|
final String responseBody = await _client.post("exercise_plan/" + exercisePlanId.toString(), body);
|
||||||
"exercise_plan/" + exercisePlanId.toString(),
|
|
||||||
body);
|
|
||||||
updatedExercisePlan = ExercisePlan.fromJson(jsonDecode(responseBody));
|
updatedExercisePlan = ExercisePlan.fromJson(jsonDecode(responseBody));
|
||||||
|
} on Exception catch (e) {
|
||||||
} on Exception catch(e) {
|
|
||||||
throw new Exception(e.toString());
|
throw new Exception(e.toString());
|
||||||
}
|
}
|
||||||
return updatedExercisePlan;
|
return updatedExercisePlan;
|
||||||
@ -43,44 +36,36 @@ class ExercisePlanApi {
|
|||||||
|
|
||||||
Future<ExercisePlanDetail> saveExercisePlanDetail(ExercisePlanDetail exercisePlanDetail) async {
|
Future<ExercisePlanDetail> saveExercisePlanDetail(ExercisePlanDetail exercisePlanDetail) async {
|
||||||
String body = JsonEncoder().convert(exercisePlanDetail.toJson());
|
String body = JsonEncoder().convert(exercisePlanDetail.toJson());
|
||||||
print(" ===== save exercisePlanDetail $exercisePlanDetail");
|
log(" ===== save exercisePlanDetail $exercisePlanDetail");
|
||||||
ExercisePlanDetail savedExercisePlanDetail;
|
ExercisePlanDetail savedExercisePlanDetail;
|
||||||
try {
|
try {
|
||||||
final String responseBody = await _client.post(
|
final String responseBody = await _client.post("exercise_plan_detail", body);
|
||||||
"exercise_plan_detail",
|
|
||||||
body);
|
|
||||||
savedExercisePlanDetail = ExercisePlanDetail.fromJson(jsonDecode(responseBody));
|
savedExercisePlanDetail = ExercisePlanDetail.fromJson(jsonDecode(responseBody));
|
||||||
} on Exception catch(e) {
|
} on Exception catch (e) {
|
||||||
throw new Exception(e.toString());
|
throw new Exception(e.toString());
|
||||||
}
|
}
|
||||||
return savedExercisePlanDetail;
|
return savedExercisePlanDetail;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<ExercisePlanDetail> updateExercisePlanDetail(ExercisePlanDetail exercisePlanDetail,
|
Future<ExercisePlanDetail> updateExercisePlanDetail(ExercisePlanDetail exercisePlanDetail, int exercisePlanDetailId) async {
|
||||||
int exercisePlanDetailId) async {
|
|
||||||
String body = JsonEncoder().convert(exercisePlanDetail.toJson());
|
String body = JsonEncoder().convert(exercisePlanDetail.toJson());
|
||||||
print(" ===== update exercisePlanDetail $exercisePlanDetail");
|
log(" ===== update exercisePlanDetail $exercisePlanDetail");
|
||||||
ExercisePlanDetail savedExercisePlanDetail;
|
ExercisePlanDetail savedExercisePlanDetail;
|
||||||
try {
|
try {
|
||||||
final String responseBody = await _client.post(
|
final String responseBody = await _client.post("exercise_plan_detail/" + exercisePlanDetailId.toString(), body);
|
||||||
"exercise_plan_detail/" + exercisePlanDetailId.toString(),
|
|
||||||
body);
|
|
||||||
savedExercisePlanDetail = ExercisePlanDetail.fromJson(jsonDecode(responseBody));
|
savedExercisePlanDetail = ExercisePlanDetail.fromJson(jsonDecode(responseBody));
|
||||||
} on Exception catch(e) {
|
} on Exception catch (e) {
|
||||||
throw new Exception(e.toString());
|
throw new Exception(e.toString());
|
||||||
}
|
}
|
||||||
return savedExercisePlanDetail;
|
return savedExercisePlanDetail;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> deleteExercisePlanDetail(int exercisePlanDetailId) async {
|
Future<void> deleteExercisePlanDetail(int exercisePlanDetailId) async {
|
||||||
print(" ===== delete exercisePlanDetail $exercisePlanDetailId");
|
log(" ===== delete exercisePlanDetail $exercisePlanDetailId");
|
||||||
String body = "";
|
String body = "";
|
||||||
try {
|
try {
|
||||||
await _client.post(
|
await _client.post("exercise_plan_detail/delete/" + exercisePlanDetailId.toString(), body);
|
||||||
"exercise_plan_detail/delete/" + exercisePlanDetailId.toString(),
|
} on Exception catch (e) {
|
||||||
body);
|
|
||||||
|
|
||||||
} on Exception catch(e) {
|
|
||||||
throw new Exception(e.toString());
|
throw new Exception(e.toString());
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@ -88,14 +73,11 @@ class ExercisePlanApi {
|
|||||||
|
|
||||||
Future<void> deleteExercisePlan(int exercisePlanId) async {
|
Future<void> deleteExercisePlan(int exercisePlanId) async {
|
||||||
String body = "";
|
String body = "";
|
||||||
print(" ===== delete exercisePlan $exercisePlanId");
|
log(" ===== delete exercisePlan $exercisePlanId");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await _client.post(
|
await _client.post("exercise_plan/delete/" + exercisePlanId.toString(), body);
|
||||||
"exercise_plan/delete/" + exercisePlanId.toString(),
|
} on Exception catch (e) {
|
||||||
body);
|
|
||||||
|
|
||||||
} on Exception catch(e) {
|
|
||||||
throw new Exception(e.toString());
|
throw new Exception(e.toString());
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@ -103,16 +85,14 @@ class ExercisePlanApi {
|
|||||||
|
|
||||||
Future<ExercisePlan> getLastExercisePlan(int customerId) async {
|
Future<ExercisePlan> getLastExercisePlan(int customerId) async {
|
||||||
String body = "";
|
String body = "";
|
||||||
print(" ===== get last exercisePlan $customerId");
|
log(" ===== get last exercisePlan $customerId");
|
||||||
ExercisePlan exercisePlan;
|
ExercisePlan exercisePlan;
|
||||||
try {
|
try {
|
||||||
final String responseBody = await _client.get(
|
final String responseBody = await _client.get("exercise_plan/last/" + customerId.toString(), body);
|
||||||
"exercise_plan/last/" + customerId.toString(),
|
|
||||||
body);
|
|
||||||
exercisePlan = ExercisePlan.fromJson(jsonDecode(responseBody));
|
exercisePlan = ExercisePlan.fromJson(jsonDecode(responseBody));
|
||||||
} on Exception catch(e) {
|
} on Exception catch (e) {
|
||||||
if ( e is NotFoundException) {
|
if (e is NotFoundException) {
|
||||||
print("ExercisePlan not found for " + customerId.toString());
|
log("ExercisePlan not found for " + customerId.toString());
|
||||||
return exercisePlan;
|
return exercisePlan;
|
||||||
} else {
|
} else {
|
||||||
throw new Exception(e.toString());
|
throw new Exception(e.toString());
|
||||||
@ -123,22 +103,16 @@ class ExercisePlanApi {
|
|||||||
|
|
||||||
Future<List<ExercisePlanDetail>> getExercisePlanDetail(int exercisePlanId) async {
|
Future<List<ExercisePlanDetail>> getExercisePlanDetail(int exercisePlanId) async {
|
||||||
String body = "";
|
String body = "";
|
||||||
print(" ===== get exercisePlanDetail $exercisePlanId");
|
log(" ===== get exercisePlanDetail $exercisePlanId");
|
||||||
List<ExercisePlanDetail> listExercisePlanDetail;
|
List<ExercisePlanDetail> listExercisePlanDetail;
|
||||||
try {
|
try {
|
||||||
final String responseBody = await _client.get(
|
final String responseBody = await _client.get("exercise_plan_detail/" + exercisePlanId.toString(), body);
|
||||||
"exercise_plan_detail/" + exercisePlanId.toString(),
|
log("response body:" + responseBody);
|
||||||
body);
|
|
||||||
print("response body:" + responseBody);
|
|
||||||
final Iterable json = jsonDecode(responseBody);
|
final Iterable json = jsonDecode(responseBody);
|
||||||
listExercisePlanDetail = json.map( (planDetail) => ExercisePlanDetail.fromJson(planDetail) ) .toList();
|
listExercisePlanDetail = json.map((planDetail) => ExercisePlanDetail.fromJson(planDetail)).toList();
|
||||||
} on Exception catch(e) {
|
} on Exception catch (e) {
|
||||||
throw new Exception(e.toString());
|
throw new Exception(e.toString());
|
||||||
}
|
}
|
||||||
return listExercisePlanDetail;
|
return listExercisePlanDetail;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
28
lib/service/exercise_result_service.dart
Normal file
28
lib/service/exercise_result_service.dart
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
import 'dart:convert';
|
||||||
|
|
||||||
|
import 'package:aitrainer_app/model/exercise_result.dart';
|
||||||
|
import 'package:aitrainer_app/service/logging.dart';
|
||||||
|
|
||||||
|
import 'api.dart';
|
||||||
|
|
||||||
|
class ExerciseResultApi with Logging {
|
||||||
|
final APIClient _client = new APIClient();
|
||||||
|
|
||||||
|
Future<void> saveExerciseResult(ExerciseResult exerciseResult) async {
|
||||||
|
String body = JsonEncoder().convert(exerciseResult.toJson());
|
||||||
|
log(" ===== saving exercise result:" + body);
|
||||||
|
await _client.post("exercise_result", body);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<List<ExerciseResult>> getExerciseResultsByCustomer(int customerId) async {
|
||||||
|
final body = await _client.get("exercise_result/", customerId.toString());
|
||||||
|
final Iterable json = jsonDecode(body);
|
||||||
|
final List<ExerciseResult> exerciseResults = json.map((exerciseResult) {
|
||||||
|
ExerciseResult item = ExerciseResult.fromJson(exerciseResult);
|
||||||
|
return item;
|
||||||
|
}).toList();
|
||||||
|
//exercises.sort( (a, b) => b.dateAdd.compareTo(a.dateAdd) );
|
||||||
|
|
||||||
|
return exerciseResults;
|
||||||
|
}
|
||||||
|
}
|
@ -1,8 +1,9 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'package:aitrainer_app/model/exercise.dart';
|
import 'package:aitrainer_app/model/exercise.dart';
|
||||||
import 'package:aitrainer_app/service/api.dart';
|
import 'package:aitrainer_app/service/api.dart';
|
||||||
|
import 'package:aitrainer_app/service/logging.dart';
|
||||||
|
|
||||||
class ExerciseApi {
|
class ExerciseApi with Logging {
|
||||||
final APIClient _client = new APIClient();
|
final APIClient _client = new APIClient();
|
||||||
|
|
||||||
Future<List<Exercise>> getExerciseTypes(String param) async {
|
Future<List<Exercise>> getExerciseTypes(String param) async {
|
||||||
@ -15,7 +16,7 @@ class ExerciseApi {
|
|||||||
|
|
||||||
Future<void> saveExercise(Exercise exercise) async {
|
Future<void> saveExercise(Exercise exercise) async {
|
||||||
String body = JsonEncoder().convert(exercise.toJson());
|
String body = JsonEncoder().convert(exercise.toJson());
|
||||||
print(" ===== saving exercise id: " + exercise.exerciseId.toString() + ":" + body);
|
log(" ===== saving exercise id: " + exercise.exerciseId.toString() + ":" + body);
|
||||||
await _client.post("exercises/" + exercise.exerciseId.toString(), body);
|
await _client.post("exercises/" + exercise.exerciseId.toString(), body);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -33,7 +34,7 @@ class ExerciseApi {
|
|||||||
|
|
||||||
Future<Exercise> addExercise(Exercise exercise) async {
|
Future<Exercise> addExercise(Exercise exercise) async {
|
||||||
String body = JsonEncoder().convert(exercise.toJson());
|
String body = JsonEncoder().convert(exercise.toJson());
|
||||||
print(" ===== add new exercise: " + body);
|
log(" ===== add new exercise: " + body);
|
||||||
final String response = await _client.post("exercises", body);
|
final String response = await _client.post("exercises", body);
|
||||||
final Exercise savedExercise = Exercise.fromJson(jsonDecode(response));
|
final Exercise savedExercise = Exercise.fromJson(jsonDecode(response));
|
||||||
return savedExercise;
|
return savedExercise;
|
||||||
@ -41,7 +42,7 @@ class ExerciseApi {
|
|||||||
|
|
||||||
Future<void> deleteExercise(Exercise exercise) async {
|
Future<void> deleteExercise(Exercise exercise) async {
|
||||||
int exerciseId = exercise.exerciseId;
|
int exerciseId = exercise.exerciseId;
|
||||||
print(" ===== delete exercise: " + exerciseId.toString());
|
log(" ===== delete exercise: " + exerciseId.toString());
|
||||||
await _client.post("exercises/" + exerciseId.toString(), "");
|
await _client.post("exercises/" + exerciseId.toString(), "");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ class ExerciseTreeApi {
|
|||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
print("ExerciseTree " + element.toJson().toString());
|
//print("ExerciseTree " + element.toJson().toString());
|
||||||
treeIndex++;
|
treeIndex++;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -2,8 +2,9 @@ import 'dart:convert';
|
|||||||
import 'package:aitrainer_app/model/cache.dart';
|
import 'package:aitrainer_app/model/cache.dart';
|
||||||
import 'package:aitrainer_app/model/exercise_type.dart';
|
import 'package:aitrainer_app/model/exercise_type.dart';
|
||||||
import 'package:aitrainer_app/service/api.dart';
|
import 'package:aitrainer_app/service/api.dart';
|
||||||
|
import 'package:aitrainer_app/service/logging.dart';
|
||||||
|
|
||||||
class ExerciseTypeApi {
|
class ExerciseTypeApi with Logging {
|
||||||
final APIClient _client = new APIClient();
|
final APIClient _client = new APIClient();
|
||||||
|
|
||||||
Future<List<ExerciseType>> getExerciseTypes() async {
|
Future<List<ExerciseType>> getExerciseTypes() async {
|
||||||
@ -16,13 +17,13 @@ class ExerciseTypeApi {
|
|||||||
|
|
||||||
Future<void> saveExerciseType(ExerciseType exerciseType) async {
|
Future<void> saveExerciseType(ExerciseType exerciseType) async {
|
||||||
String body = JsonEncoder().convert(exerciseType.toJson());
|
String body = JsonEncoder().convert(exerciseType.toJson());
|
||||||
print(" ===== saving exerciseType id: " + exerciseType.exerciseTypeId.toString() + ":" + body);
|
log(" ===== saving exerciseType id: " + exerciseType.exerciseTypeId.toString() + ":" + body);
|
||||||
await _client.post("exercise_type/" + exerciseType.exerciseTypeId.toString(), body);
|
await _client.post("exercise_type/" + exerciseType.exerciseTypeId.toString(), body);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> addExerciseType(ExerciseType exerciseType) async {
|
Future<void> addExerciseType(ExerciseType exerciseType) async {
|
||||||
String body = JsonEncoder().convert(exerciseType.toJson());
|
String body = JsonEncoder().convert(exerciseType.toJson());
|
||||||
print(" ===== add new exerciseType: " + body);
|
log(" ===== add new exerciseType: " + body);
|
||||||
await _client.post("exercise_type", body);
|
await _client.post("exercise_type", body);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
import 'package:aitrainer_app/model/cache.dart';
|
import 'package:aitrainer_app/model/cache.dart';
|
||||||
|
import 'package:aitrainer_app/service/logging.dart';
|
||||||
import 'package:firebase_auth/firebase_auth.dart';
|
import 'package:firebase_auth/firebase_auth.dart';
|
||||||
import 'package:firebase_core/firebase_core.dart';
|
import 'package:firebase_core/firebase_core.dart';
|
||||||
//import 'package:flutter_facebook_auth/flutter_facebook_auth.dart';
|
//import 'package:flutter_facebook_auth/flutter_facebook_auth.dart';
|
||||||
|
|
||||||
class FirebaseApi {
|
class FirebaseApi with Logging {
|
||||||
static FirebaseApi _instance;
|
static FirebaseApi _instance;
|
||||||
|
|
||||||
static final FirebaseAuth auth = FirebaseAuth.instance;
|
static final FirebaseAuth auth = FirebaseAuth.instance;
|
||||||
@ -29,7 +30,7 @@ class FirebaseApi {
|
|||||||
await Firebase.initializeApp();
|
await Firebase.initializeApp();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// Set `_error` state to true if Firebase initialization fails
|
// Set `_error` state to true if Firebase initialization fails
|
||||||
print("Error initializing Firebase");
|
log("Error initializing Firebase");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,10 +41,10 @@ class FirebaseApi {
|
|||||||
Cache().firebaseUid = userCredential.user.uid;
|
Cache().firebaseUid = userCredential.user.uid;
|
||||||
} on FirebaseAuthException catch (e) {
|
} on FirebaseAuthException catch (e) {
|
||||||
if (e.code == 'user-not-found') {
|
if (e.code == 'user-not-found') {
|
||||||
print('No user found for that email.');
|
log('No user found for that email.');
|
||||||
rc = SIGN_IN_NOT_FOUND;
|
rc = SIGN_IN_NOT_FOUND;
|
||||||
} else if (e.code == 'wrong-password') {
|
} else if (e.code == 'wrong-password') {
|
||||||
print('Wrong password provided for that user.');
|
log('Wrong password provided for that user.');
|
||||||
rc = SIGN_IN_WRONG_PWD;
|
rc = SIGN_IN_WRONG_PWD;
|
||||||
throw Exception("Customer does not exist or the password is wrong");
|
throw Exception("Customer does not exist or the password is wrong");
|
||||||
}
|
}
|
||||||
@ -59,16 +60,16 @@ class FirebaseApi {
|
|||||||
Cache().firebaseUid = userCredential.user.uid;
|
Cache().firebaseUid = userCredential.user.uid;
|
||||||
} on FirebaseAuthException catch (e) {
|
} on FirebaseAuthException catch (e) {
|
||||||
if (e.code == 'weak-password') {
|
if (e.code == 'weak-password') {
|
||||||
print('The password provided is too weak.');
|
log('The password provided is too weak.');
|
||||||
rc = REGISTER_WEAK_PWD;
|
rc = REGISTER_WEAK_PWD;
|
||||||
throw Exception("Password too short");
|
throw Exception("Password too short");
|
||||||
} else if (e.code == 'email-already-in-use') {
|
} else if (e.code == 'email-already-in-use') {
|
||||||
print('The account already exists for that email.');
|
log('The account already exists for that email.');
|
||||||
rc = REGISTER_EMAIL_IN_USE;
|
rc = REGISTER_EMAIL_IN_USE;
|
||||||
throw Exception("The email address has been registered already");
|
throw Exception("The email address has been registered already");
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print(e);
|
log(e);
|
||||||
throw Exception(e.toString());
|
throw Exception(e.toString());
|
||||||
}
|
}
|
||||||
return rc;
|
return rc;
|
||||||
|
16
lib/service/logging.dart
Normal file
16
lib/service/logging.dart
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
import 'package:aitrainer_app/util/env.dart';
|
||||||
|
import 'package:intl/intl.dart';
|
||||||
|
|
||||||
|
mixin Logging {
|
||||||
|
void log(String message) {
|
||||||
|
DateTime time = DateTime.now();
|
||||||
|
print(DateFormat('yyyy-MM-dd HH:mm:ss ').format(time) + message);
|
||||||
|
}
|
||||||
|
|
||||||
|
void trace(String message) {
|
||||||
|
String testEnv = EnvironmentConfig.test_env;
|
||||||
|
if (testEnv == "1") {
|
||||||
|
log(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
17
lib/service/product_service.dart
Normal file
17
lib/service/product_service.dart
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
import 'dart:convert';
|
||||||
|
|
||||||
|
import 'package:aitrainer_app/model/cache.dart';
|
||||||
|
import 'package:aitrainer_app/model/product.dart';
|
||||||
|
import 'package:aitrainer_app/service/api.dart';
|
||||||
|
|
||||||
|
class ProductApi {
|
||||||
|
final APIClient _client = new APIClient();
|
||||||
|
|
||||||
|
Future<List<Product>> getProducts() async {
|
||||||
|
final body = await _client.get("product/", "");
|
||||||
|
final Iterable json = jsonDecode(body);
|
||||||
|
final List<Product> products = json.map((product) => Product.fromJson(product)).toList();
|
||||||
|
Cache().setProducts(products);
|
||||||
|
return products;
|
||||||
|
}
|
||||||
|
}
|
23
lib/service/product_test_service.dart
Normal file
23
lib/service/product_test_service.dart
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
import 'package:aitrainer_app/model/cache.dart';
|
||||||
|
import 'package:aitrainer_app/model/product_test.dart';
|
||||||
|
import 'package:aitrainer_app/service/logging.dart';
|
||||||
|
import 'dart:convert';
|
||||||
|
import 'api.dart';
|
||||||
|
|
||||||
|
class ProductTestApi with Logging {
|
||||||
|
final APIClient _client = new APIClient();
|
||||||
|
|
||||||
|
Future<List<ProductTest>> getProductTestByCustomer(int customerId) async {
|
||||||
|
final body = await _client.get("product_test/customer/" + customerId.toString(), "");
|
||||||
|
final Iterable json = jsonDecode(body);
|
||||||
|
final List<ProductTest> productTests = json.map((productTest) => ProductTest.fromJson(productTest)).toList();
|
||||||
|
Cache().productTests = productTests;
|
||||||
|
return productTests;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> saveProductTest(ProductTest productTest) async {
|
||||||
|
String body = JsonEncoder().convert(productTest.toJson());
|
||||||
|
log(" ===== saving productTest:" + body);
|
||||||
|
await _client.post("product_test/", body);
|
||||||
|
}
|
||||||
|
}
|
23
lib/service/purchase.dart
Normal file
23
lib/service/purchase.dart
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
import 'package:aitrainer_app/model/cache.dart';
|
||||||
|
import 'package:aitrainer_app/model/purchase.dart';
|
||||||
|
import 'package:aitrainer_app/service/logging.dart';
|
||||||
|
import 'dart:convert';
|
||||||
|
import 'api.dart';
|
||||||
|
|
||||||
|
class PurchaseApi with Logging {
|
||||||
|
final APIClient _client = new APIClient();
|
||||||
|
|
||||||
|
Future<List<Purchase>> getPurchasesByCustomer(int customerId) async {
|
||||||
|
final body = await _client.get("purchase/customer/" + customerId.toString(), "");
|
||||||
|
final Iterable json = jsonDecode(body);
|
||||||
|
final List<Purchase> purchases = json.map((purchase) => Purchase.fromJson(purchase)).toList();
|
||||||
|
Cache().setPurchases(purchases);
|
||||||
|
return purchases;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> savePurchase(Purchase purchase) async {
|
||||||
|
String body = JsonEncoder().convert(purchase.toJson());
|
||||||
|
log(" ===== saving purchase:" + body);
|
||||||
|
await _client.post("purchase/", body);
|
||||||
|
}
|
||||||
|
}
|
@ -4,6 +4,7 @@ import 'package:aitrainer_app/localization/app_language.dart';
|
|||||||
import 'package:aitrainer_app/model/cache.dart';
|
import 'package:aitrainer_app/model/cache.dart';
|
||||||
import 'package:aitrainer_app/model/exercise_type.dart';
|
import 'package:aitrainer_app/model/exercise_type.dart';
|
||||||
import 'package:aitrainer_app/repository/user_repository.dart';
|
import 'package:aitrainer_app/repository/user_repository.dart';
|
||||||
|
import 'package:aitrainer_app/util/env.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
|
|
||||||
@ -15,26 +16,23 @@ class DateRate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mixin Common {
|
mixin Common {
|
||||||
|
|
||||||
final EMAIL_ERROR = "Please type a right email address here.";
|
final EMAIL_ERROR = "Please type a right email address here.";
|
||||||
final PASSWORD_ERROR = "The password must have at least 8 characters.";
|
final PASSWORD_ERROR = "The password must have at least 8 characters.";
|
||||||
|
|
||||||
|
String toJson(Map<String, String> map) {
|
||||||
|
|
||||||
String toJson( Map<String, String> map ) {
|
|
||||||
String rc = "{";
|
String rc = "{";
|
||||||
map.forEach((key, value) {
|
map.forEach((key, value) {
|
||||||
rc += "'$key':'$value'";
|
rc += "'$key':'$value'";
|
||||||
});
|
});
|
||||||
rc += "}";
|
rc += "}";
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
ExerciseType getExerciseType( int exerciseTypeId ) {
|
ExerciseType getExerciseType(int exerciseTypeId) {
|
||||||
ExerciseType returnElement;
|
ExerciseType returnElement;
|
||||||
List<ExerciseType> listExerciseType = Cache().getExerciseTypes();
|
List<ExerciseType> listExerciseType = Cache().getExerciseTypes();
|
||||||
if ( listExerciseType != null ) {
|
if (listExerciseType != null) {
|
||||||
for ( var element in listExerciseType ) {
|
for (var element in listExerciseType) {
|
||||||
if (exerciseTypeId == element.exerciseTypeId) {
|
if (exerciseTypeId == element.exerciseTypeId) {
|
||||||
returnElement = element;
|
returnElement = element;
|
||||||
break;
|
break;
|
||||||
@ -44,12 +42,12 @@ mixin Common {
|
|||||||
return returnElement;
|
return returnElement;
|
||||||
}
|
}
|
||||||
|
|
||||||
String getDateLocale( DateTime datetime, bool timeDisplay ) {
|
String getDateLocale(DateTime datetime, bool timeDisplay) {
|
||||||
var date = datetime;
|
var date = datetime;
|
||||||
|
|
||||||
String dateName = DateFormat(DateFormat.YEAR_MONTH_DAY, AppLanguage().appLocal.toString()).format(date.toUtc());
|
String dateName = DateFormat(DateFormat.YEAR_MONTH_DAY, AppLanguage().appLocal.toString()).format(date.toUtc());
|
||||||
if ( timeDisplay ) {
|
if (timeDisplay) {
|
||||||
dateName += " " +DateFormat(DateFormat.HOUR_MINUTE, AppLanguage().appLocal.toString()).format(date.toUtc());
|
dateName += " " + DateFormat(DateFormat.HOUR_MINUTE, AppLanguage().appLocal.toString()).format(date.toUtc());
|
||||||
}
|
}
|
||||||
|
|
||||||
return dateName;
|
return dateName;
|
||||||
@ -60,8 +58,8 @@ mixin Common {
|
|||||||
return utf8.decode(bytes);
|
return utf8.decode(bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
double mediaSizeWidth( BuildContext context ) {
|
double mediaSizeWidth(BuildContext context) {
|
||||||
return MediaQuery.of(context).size.width;
|
return MediaQuery.of(context).size.width;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool validateEmail(UserRepository userRepository) {
|
bool validateEmail(UserRepository userRepository) {
|
||||||
@ -74,8 +72,7 @@ mixin Common {
|
|||||||
|
|
||||||
bool validatePassword(UserRepository userRepository) {
|
bool validatePassword(UserRepository userRepository) {
|
||||||
final password = userRepository.user.password;
|
final password = userRepository.user.password;
|
||||||
final RegExp _passwordRegExp =
|
final RegExp _passwordRegExp = RegExp(r'^(?=.*[A-Za-z0-9])(?=.*\d)[A-Za-z\d]{7,}$');
|
||||||
RegExp(r'^(?=.*[A-Za-z0-9])(?=.*\d)[A-Za-z\d]{7,}$');
|
|
||||||
|
|
||||||
return _passwordRegExp.hasMatch(password);
|
return _passwordRegExp.hasMatch(password);
|
||||||
}
|
}
|
||||||
@ -88,16 +85,15 @@ mixin Common {
|
|||||||
|
|
||||||
String getDatePart(DateTime date, String dateRate) {
|
String getDatePart(DateTime date, String dateRate) {
|
||||||
String datePart = DateFormat('MM.dd', AppLanguage().appLocal.toString()).format(date);
|
String datePart = DateFormat('MM.dd', AppLanguage().appLocal.toString()).format(date);
|
||||||
if ( dateRate == DateRate.weekly ) {
|
if (dateRate == DateRate.weekly) {
|
||||||
datePart = weekNumber(date).toString();
|
datePart = weekNumber(date).toString();
|
||||||
} else if ( dateRate == DateRate.monthly ) {
|
} else if (dateRate == DateRate.monthly) {
|
||||||
datePart = DateFormat('MMM', AppLanguage().appLocal.toString()).format(date);
|
datePart = DateFormat('MMM', AppLanguage().appLocal.toString()).format(date);
|
||||||
} else if ( dateRate == DateRate.yearly ) {
|
} else if (dateRate == DateRate.yearly) {
|
||||||
datePart = DateFormat('y', AppLanguage().appLocal.toString()).format(date);
|
datePart = DateFormat('y', AppLanguage().appLocal.toString()).format(date);
|
||||||
} else if ( dateRate == DateRate.daily ) {
|
} else if (dateRate == DateRate.daily) {
|
||||||
datePart = DateFormat('MM.dd', AppLanguage().appLocal.toString()).format(date);
|
datePart = DateFormat('MM.dd', AppLanguage().appLocal.toString()).format(date);
|
||||||
}
|
}
|
||||||
return datePart;
|
return datePart;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
||||||
|
115
lib/util/platform_purchase.dart
Normal file
115
lib/util/platform_purchase.dart
Normal file
@ -0,0 +1,115 @@
|
|||||||
|
import 'dart:async';
|
||||||
|
|
||||||
|
import 'package:aitrainer_app/service/logging.dart';
|
||||||
|
import 'package:flutter_inapp_purchase/flutter_inapp_purchase.dart';
|
||||||
|
|
||||||
|
class PlatformPurchaseApi with Logging {
|
||||||
|
static final PlatformPurchaseApi _singleton = PlatformPurchaseApi._internal();
|
||||||
|
|
||||||
|
StreamSubscription _purchaseUpdatedSubscription;
|
||||||
|
StreamSubscription _purchaseErrorSubscription;
|
||||||
|
StreamSubscription _conectionSubscription;
|
||||||
|
String _platformVersion = 'Unknown';
|
||||||
|
List<IAPItem> _items = [];
|
||||||
|
List<PurchasedItem> _purchases = [];
|
||||||
|
|
||||||
|
final List<String> _productLists = List();
|
||||||
|
/* Platform.isAndroid
|
||||||
|
? [
|
||||||
|
'android.test.purchased',
|
||||||
|
'point_1000',
|
||||||
|
'5000_point',
|
||||||
|
'android.test.canceled',
|
||||||
|
]
|
||||||
|
: ['com.cooni.point1000', 'com.cooni.point5000'];
|
||||||
|
*/
|
||||||
|
|
||||||
|
factory PlatformPurchaseApi() {
|
||||||
|
return _singleton;
|
||||||
|
}
|
||||||
|
|
||||||
|
PlatformPurchaseApi._internal();
|
||||||
|
|
||||||
|
void close() {
|
||||||
|
if (_conectionSubscription != null) {
|
||||||
|
_conectionSubscription.cancel();
|
||||||
|
_conectionSubscription = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Platform messages are asynchronous, so we initialize in an async method.
|
||||||
|
Future<void> initPurchasePlatformState() async {
|
||||||
|
String platformVersion;
|
||||||
|
// Platform messages may fail, so we use a try/catch PlatformException.
|
||||||
|
try {
|
||||||
|
platformVersion = await FlutterInappPurchase.instance.platformVersion;
|
||||||
|
} on Exception {
|
||||||
|
platformVersion = 'Failed to get platform version for InAppPurchase.';
|
||||||
|
log(platformVersion);
|
||||||
|
}
|
||||||
|
|
||||||
|
// prepare
|
||||||
|
var result = await FlutterInappPurchase.instance.initConnection;
|
||||||
|
log('result: $result');
|
||||||
|
|
||||||
|
_platformVersion = platformVersion;
|
||||||
|
|
||||||
|
// refresh items for android
|
||||||
|
try {
|
||||||
|
String msg = await FlutterInappPurchase.instance.consumeAllItems;
|
||||||
|
log('consumeAllItems: $msg');
|
||||||
|
} catch (err) {
|
||||||
|
log('consumeAllItems error: $err');
|
||||||
|
}
|
||||||
|
|
||||||
|
_conectionSubscription = FlutterInappPurchase.connectionUpdated.listen((connected) {
|
||||||
|
log('connected: $connected');
|
||||||
|
});
|
||||||
|
|
||||||
|
_purchaseUpdatedSubscription = FlutterInappPurchase.purchaseUpdated.listen((productItem) {
|
||||||
|
log('purchase-updated: $productItem');
|
||||||
|
});
|
||||||
|
|
||||||
|
_purchaseErrorSubscription = FlutterInappPurchase.purchaseError.listen((purchaseError) {
|
||||||
|
log('purchase-error: $purchaseError');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void requestPurchase(IAPItem item) {
|
||||||
|
//FlutterInappPurchase.instance.requestPurchase(item.productId);
|
||||||
|
FlutterInappPurchase.instance.requestPurchase("WT_monthly");
|
||||||
|
}
|
||||||
|
|
||||||
|
Future _getProduct() async {
|
||||||
|
List<IAPItem> items = await FlutterInappPurchase.instance.getProducts(_productLists);
|
||||||
|
for (var item in items) {
|
||||||
|
log('${item.toString()}');
|
||||||
|
this._items.add(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
this._items = items;
|
||||||
|
this._purchases = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
Future _getPurchases() async {
|
||||||
|
List<PurchasedItem> items = await FlutterInappPurchase.instance.getAvailablePurchases();
|
||||||
|
for (var item in items) {
|
||||||
|
log('${item.toString()}');
|
||||||
|
this._purchases.add(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
this._items = [];
|
||||||
|
this._purchases = items;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future _getPurchaseHistory() async {
|
||||||
|
List<PurchasedItem> items = await FlutterInappPurchase.instance.getPurchaseHistory();
|
||||||
|
for (var item in items) {
|
||||||
|
log('${item.toString()}');
|
||||||
|
this._purchases.add(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
this._items = [];
|
||||||
|
this._purchases = items;
|
||||||
|
}
|
||||||
|
}
|
@ -1,39 +1,34 @@
|
|||||||
import 'package:aitrainer_app/localization/app_language.dart';
|
import 'package:aitrainer_app/localization/app_language.dart';
|
||||||
import 'package:aitrainer_app/localization/app_localization.dart';
|
import 'package:aitrainer_app/localization/app_localization.dart';
|
||||||
import 'package:aitrainer_app/model/customer_exercise_device.dart';
|
|
||||||
import 'package:aitrainer_app/repository/exercise_repository.dart';
|
|
||||||
import 'package:aitrainer_app/service/api.dart';
|
import 'package:aitrainer_app/service/api.dart';
|
||||||
import 'package:aitrainer_app/service/customer_exercise_device_service.dart';
|
|
||||||
import 'package:aitrainer_app/service/customer_service.dart';
|
|
||||||
import 'package:aitrainer_app/service/exercise_device_service.dart';
|
|
||||||
import 'package:aitrainer_app/service/exercise_tree_service.dart';
|
|
||||||
import 'package:aitrainer_app/service/exercisetype_service.dart';
|
|
||||||
import 'package:aitrainer_app/service/firebase_api.dart';
|
import 'package:aitrainer_app/service/firebase_api.dart';
|
||||||
|
import 'package:aitrainer_app/service/logging.dart';
|
||||||
|
import 'package:aitrainer_app/service/product_service.dart';
|
||||||
import 'package:aitrainer_app/service/property_service.dart';
|
import 'package:aitrainer_app/service/property_service.dart';
|
||||||
import 'package:devicelocale/devicelocale.dart';
|
import 'package:devicelocale/devicelocale.dart';
|
||||||
import 'package:flurry/flurry.dart';
|
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
|
import 'package:mockito/mockito.dart';
|
||||||
import 'package:shared_preferences/shared_preferences.dart';
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
import 'package:aitrainer_app/model/cache.dart';
|
import 'package:aitrainer_app/model/cache.dart';
|
||||||
|
|
||||||
class Session {
|
class Session with Logging {
|
||||||
Future<SharedPreferences> _prefs = SharedPreferences.getInstance();
|
Future<SharedPreferences> _prefs = SharedPreferences.getInstance();
|
||||||
|
|
||||||
SharedPreferences _sharedPreferences;
|
SharedPreferences _sharedPreferences;
|
||||||
|
|
||||||
fetchSessionAndNavigate() async {
|
fetchSessionAndNavigate() async {
|
||||||
print(" -- Session: await prefs..");
|
log(" -- Session: await prefs..");
|
||||||
_sharedPreferences = await _prefs;
|
_sharedPreferences = await _prefs;
|
||||||
|
|
||||||
if (Cache().firstLoad) {
|
if (Cache().firstLoad) {
|
||||||
print(" -- Session: fetch locale..");
|
log(" -- Session: fetch locale..");
|
||||||
await AppLanguage().getLocale(_sharedPreferences);
|
await AppLanguage().getLocale(_sharedPreferences);
|
||||||
await AppLocalizations.delegate.load(AppLanguage().appLocal);
|
await AppLocalizations.delegate.load(AppLanguage().appLocal);
|
||||||
print(" -- Session: fetch token..");
|
log(" -- Session: fetch token..");
|
||||||
Cache().setServerAddress(_sharedPreferences);
|
Cache().setServerAddress(_sharedPreferences);
|
||||||
Cache().getHardware(_sharedPreferences);
|
Cache().getHardware(_sharedPreferences);
|
||||||
await _fetchToken(_sharedPreferences);
|
await _fetchToken(_sharedPreferences);
|
||||||
print(" -- FireBase init..");
|
log(" -- FireBase init..");
|
||||||
await FirebaseApi().initializeFlutterFire();
|
await FirebaseApi().initializeFlutterFire();
|
||||||
//initDeviceLocale();
|
//initDeviceLocale();
|
||||||
|
|
||||||
@ -50,15 +45,15 @@ class Session {
|
|||||||
try {
|
try {
|
||||||
languages = await Devicelocale.preferredLanguages;
|
languages = await Devicelocale.preferredLanguages;
|
||||||
Cache().deviceLanguages = languages;
|
Cache().deviceLanguages = languages;
|
||||||
print("device langs " + languages.toString());
|
log("device langs " + languages.toString());
|
||||||
} on PlatformException {
|
} on PlatformException {
|
||||||
print("Error obtaining preferred languages");
|
log("Error obtaining preferred languages");
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
currentLocale = await Devicelocale.currentLocale;
|
currentLocale = await Devicelocale.currentLocale;
|
||||||
print("Device currentlocale " + currentLocale);
|
log("Device currentlocale " + currentLocale);
|
||||||
} on PlatformException {
|
} on PlatformException {
|
||||||
print("Error obtaining current locale");
|
log("Error obtaining current locale");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,18 +61,19 @@ class Session {
|
|||||||
Auth flow of the user, see auth.dart
|
Auth flow of the user, see auth.dart
|
||||||
*/
|
*/
|
||||||
_fetchToken(SharedPreferences prefs) async {
|
_fetchToken(SharedPreferences prefs) async {
|
||||||
var responseJson = await APIClient.authenticateUser(Cache.username, Cache.password);
|
var responseJson = await APIClient().authenticateUser(Cache.username, Cache.password);
|
||||||
int customerId = 0;
|
int customerId = 0;
|
||||||
print("--- Lang: " + AppLanguage().appLocal.toString());
|
log("--- Lang: " + AppLanguage().appLocal.toString());
|
||||||
if (responseJson['error'] != null) {
|
if (responseJson['error'] != null) {
|
||||||
print("************** Here big error - no authentication");
|
log("************** Here big error - no authentication");
|
||||||
} else if (responseJson['token'] != null) {
|
} else if (responseJson['token'] != null) {
|
||||||
prefs.setString(Cache.authTokenKey, responseJson['token']);
|
prefs.setString(Cache.authTokenKey, responseJson['token']);
|
||||||
Cache().authToken = responseJson['token'];
|
Cache().authToken = responseJson['token'];
|
||||||
Cache().firebaseUid = prefs.get(Cache.firebaseUidKey);
|
Cache().firebaseUid = prefs.get(Cache.firebaseUidKey);
|
||||||
await PropertyApi().getProperties();
|
await PropertyApi().getProperties();
|
||||||
|
await ProductApi().getProducts();
|
||||||
if (prefs.get(Cache.customerIdKey) == null) {
|
if (prefs.get(Cache.customerIdKey) == null) {
|
||||||
print("************** Registration");
|
log("************** Registration");
|
||||||
// registration
|
// registration
|
||||||
prefs.setBool(Cache.isRegisteredKey, true);
|
prefs.setBool(Cache.isRegisteredKey, true);
|
||||||
Cache().startPage = "registration";
|
Cache().startPage = "registration";
|
||||||
@ -90,31 +86,21 @@ class Session {
|
|||||||
lastStoreDate.difference(minStoreDate) > Duration(days: 10) ||
|
lastStoreDate.difference(minStoreDate) > Duration(days: 10) ||
|
||||||
prefs.get(Cache.isLoggedInKey) == null ||
|
prefs.get(Cache.isLoggedInKey) == null ||
|
||||||
prefs.get(Cache.isLoggedInKey) == false) {
|
prefs.get(Cache.isLoggedInKey) == false) {
|
||||||
print("************* Login");
|
log("************* Login");
|
||||||
Cache().startPage = "login";
|
Cache().startPage = "login";
|
||||||
} else {
|
} else {
|
||||||
// only
|
// only
|
||||||
if (Cache().firebaseUid == null) {
|
if (Cache().firebaseUid == null) {
|
||||||
print("************* firebaseUid is null, Login");
|
log("************* firebaseUid is null, Login");
|
||||||
Cache().startPage = "login";
|
Cache().startPage = "login";
|
||||||
} else {
|
} else {
|
||||||
// get API customer
|
// get API customer
|
||||||
customerId = prefs.getInt(Cache.customerIdKey);
|
customerId = prefs.getInt(Cache.customerIdKey);
|
||||||
await CustomerApi().getCustomer(customerId);
|
|
||||||
Cache().startPage = "home";
|
Cache().startPage = "home";
|
||||||
Flurry.setUserId(customerId.toString());
|
await Cache().initCustomer(customerId);
|
||||||
await ExerciseTypeApi().getExerciseTypes();
|
|
||||||
await ExerciseTreeApi().getExerciseTree();
|
|
||||||
await ExerciseDeviceApi().getDevices();
|
|
||||||
final customerDevices = await CustomerExerciseDeviceApi().getDevices(customerId);
|
|
||||||
Cache().setCustomerDevices(customerDevices);
|
|
||||||
if (customerId > 0) {
|
|
||||||
ExerciseRepository exerciseRepository = ExerciseRepository();
|
|
||||||
await exerciseRepository.getExercisesByCustomer(customerId);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
print("--- Session finished");
|
log("--- Session finished");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ import 'package:aitrainer_app/bloc/custom_exercise_form_bloc.dart';
|
|||||||
import 'package:aitrainer_app/localization/app_localization.dart';
|
import 'package:aitrainer_app/localization/app_localization.dart';
|
||||||
import 'package:aitrainer_app/model/exercise_type.dart';
|
import 'package:aitrainer_app/model/exercise_type.dart';
|
||||||
import 'package:aitrainer_app/repository/exercise_repository.dart';
|
import 'package:aitrainer_app/repository/exercise_repository.dart';
|
||||||
|
import 'package:aitrainer_app/service/logging.dart';
|
||||||
import 'package:aitrainer_app/widgets/splash.dart';
|
import 'package:aitrainer_app/widgets/splash.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
@ -15,7 +16,7 @@ class CustomExercisePage extends StatefulWidget {
|
|||||||
_CustomExerciseNewPageState createState() => _CustomExerciseNewPageState();
|
_CustomExerciseNewPageState createState() => _CustomExerciseNewPageState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _CustomExerciseNewPageState extends State<CustomExercisePage> {
|
class _CustomExerciseNewPageState extends State<CustomExercisePage> with Logging {
|
||||||
final GlobalKey<ScaffoldState> _scaffoldKey = new GlobalKey<ScaffoldState>();
|
final GlobalKey<ScaffoldState> _scaffoldKey = new GlobalKey<ScaffoldState>();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -23,8 +24,7 @@ class _CustomExerciseNewPageState extends State<CustomExercisePage> {
|
|||||||
final ExerciseType exerciseType = ModalRoute.of(context).settings.arguments;
|
final ExerciseType exerciseType = ModalRoute.of(context).settings.arguments;
|
||||||
|
|
||||||
return BlocProvider(
|
return BlocProvider(
|
||||||
create: (context) =>
|
create: (context) => CustomExerciseFormBloc(exerciseRepository: ExerciseRepository()),
|
||||||
CustomExerciseFormBloc(exerciseRepository: ExerciseRepository()),
|
|
||||||
child: Builder(builder: (context) {
|
child: Builder(builder: (context) {
|
||||||
final exerciseBloc = BlocProvider.of<CustomExerciseFormBloc>(context);
|
final exerciseBloc = BlocProvider.of<CustomExerciseFormBloc>(context);
|
||||||
exerciseBloc.exerciseRepository.setExerciseType(exerciseType);
|
exerciseBloc.exerciseRepository.setExerciseType(exerciseType);
|
||||||
@ -59,93 +59,58 @@ class _CustomExerciseNewPageState extends State<CustomExercisePage> {
|
|||||||
onFailure: (context, state) {
|
onFailure: (context, state) {
|
||||||
LoadingDialog.hide(context);
|
LoadingDialog.hide(context);
|
||||||
Scaffold.of(context).showSnackBar(SnackBar(
|
Scaffold.of(context).showSnackBar(SnackBar(
|
||||||
backgroundColor: Colors.orange,
|
backgroundColor: Colors.orange, content: Text(state.failureResponse, style: TextStyle(color: Colors.white))));
|
||||||
content: Text(state.failureResponse,
|
|
||||||
style: TextStyle(color: Colors.white))));
|
|
||||||
},
|
},
|
||||||
child: Container(
|
child: Container(
|
||||||
width: MediaQuery.of(context).size.width,
|
width: MediaQuery.of(context).size.width,
|
||||||
height: MediaQuery.of(context).size.height,
|
height: MediaQuery.of(context).size.height,
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
image: DecorationImage(
|
image: DecorationImage(
|
||||||
image:
|
image: AssetImage('asset/image/WT_light_background.png'),
|
||||||
AssetImage('asset/image/WT_light_background.png'),
|
|
||||||
fit: BoxFit.fill,
|
fit: BoxFit.fill,
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
child: CustomScrollView(
|
child: CustomScrollView(scrollDirection: Axis.vertical, slivers: [
|
||||||
scrollDirection: Axis.vertical,
|
SliverList(
|
||||||
slivers: [
|
delegate: SliverChildListDelegate([
|
||||||
SliverList(
|
Container(
|
||||||
delegate: SliverChildListDelegate(
|
padding: EdgeInsets.only(top: 20, left: 25, right: 25),
|
||||||
[
|
alignment: Alignment.center,
|
||||||
Container(
|
child: Column(mainAxisAlignment: MainAxisAlignment.center, children: [
|
||||||
padding: EdgeInsets.only(top:20,left:25, right:25),
|
Text("Custom Exercise",
|
||||||
alignment: Alignment.center,
|
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 14, color: Colors.deepOrange)),
|
||||||
child: Column(
|
columnQuantityUnit(exerciseBloc),
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
columnQuantity(exerciseBloc),
|
||||||
children: [
|
])),
|
||||||
Text("Custom Exercise",
|
]),
|
||||||
style: TextStyle(
|
),
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
fontSize: 14,
|
|
||||||
color: Colors.deepOrange)),
|
|
||||||
columnQuantityUnit(exerciseBloc),
|
|
||||||
columnQuantity(exerciseBloc),
|
|
||||||
]
|
|
||||||
)
|
|
||||||
),
|
|
||||||
]
|
|
||||||
),
|
|
||||||
|
|
||||||
),
|
|
||||||
gridCalculation(exerciseBloc)
|
gridCalculation(exerciseBloc)
|
||||||
]
|
]))));
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
Column columnQuantityUnit(CustomExerciseFormBloc bloc) {
|
Column columnQuantityUnit(CustomExerciseFormBloc bloc) {
|
||||||
Column column = Column();
|
Column column = Column();
|
||||||
if (bloc.exerciseRepository.exerciseType != null &&
|
if (bloc.exerciseRepository.exerciseType != null && bloc.exerciseRepository.exerciseType.unitQuantity == "1") {
|
||||||
bloc.exerciseRepository.exerciseType.unitQuantity == "1") {
|
|
||||||
column = Column(children: [
|
column = Column(children: [
|
||||||
TextFieldBlocBuilder(
|
TextFieldBlocBuilder(
|
||||||
textFieldBloc: bloc.unitQuantityField,
|
textFieldBloc: bloc.unitQuantityField,
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
style: TextStyle(
|
style: TextStyle(fontSize: 16, color: Colors.lightBlue, fontWeight: FontWeight.bold),
|
||||||
fontSize: 16,
|
inputFormatters: [FilteringTextInputFormatter.allow(RegExp(r"[\d.]"))],
|
||||||
color: Colors.lightBlue,
|
onChanged: (input) => {log("UnitQuantity value $input"), bloc.exerciseRepository.setUnitQuantity(double.parse(input))},
|
||||||
fontWeight: FontWeight.bold),
|
|
||||||
inputFormatters: [
|
|
||||||
FilteringTextInputFormatter.allow(RegExp(r"[\d.]"))
|
|
||||||
],
|
|
||||||
onChanged: (input) => {
|
|
||||||
print("UnitQuantity value $input"),
|
|
||||||
bloc.exerciseRepository.setUnitQuantity(double.parse(input))
|
|
||||||
},
|
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
fillColor: Colors.white,
|
fillColor: Colors.white,
|
||||||
filled: false,
|
filled: false,
|
||||||
hintStyle: TextStyle(
|
hintStyle: TextStyle(fontSize: 12, color: Colors.black54, fontWeight: FontWeight.w100),
|
||||||
fontSize: 12,
|
hintText: AppLocalizations.of(context).translate("The number of the exercise done with"),
|
||||||
color: Colors.black54,
|
|
||||||
fontWeight: FontWeight.w100),
|
|
||||||
hintText: AppLocalizations.of(context)
|
|
||||||
.translate("The number of the exercise done with"),
|
|
||||||
labelStyle: TextStyle(fontSize: 12, color: Colors.lightBlue),
|
labelStyle: TextStyle(fontSize: 12, color: Colors.lightBlue),
|
||||||
labelText: AppLocalizations.of(context).translate(
|
labelText: AppLocalizations.of(context).translate(bloc.exerciseRepository.exerciseType.unitQuantityUnit),
|
||||||
bloc.exerciseRepository.exerciseType.unitQuantityUnit),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
new InkWell(
|
new InkWell(
|
||||||
child: new Text(
|
child: new Text(AppLocalizations.of(context).translate(bloc.exerciseRepository.exerciseType.unitQuantityUnit),
|
||||||
AppLocalizations.of(context).translate(
|
|
||||||
bloc.exerciseRepository.exerciseType.unitQuantityUnit),
|
|
||||||
style: TextStyle(fontSize: 12)),
|
style: TextStyle(fontSize: 12)),
|
||||||
),
|
),
|
||||||
]);
|
]);
|
||||||
@ -158,29 +123,20 @@ class _CustomExerciseNewPageState extends State<CustomExercisePage> {
|
|||||||
TextFieldBlocBuilder(
|
TextFieldBlocBuilder(
|
||||||
textFieldBloc: bloc.quantityField,
|
textFieldBloc: bloc.quantityField,
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
style: TextStyle(
|
style: TextStyle(fontSize: 20, color: Colors.deepOrange, fontWeight: FontWeight.bold),
|
||||||
fontSize: 20,
|
inputFormatters: [FilteringTextInputFormatter.allow(RegExp(r"[\d.]"))],
|
||||||
color: Colors.deepOrange,
|
|
||||||
fontWeight: FontWeight.bold),
|
|
||||||
inputFormatters: [
|
|
||||||
FilteringTextInputFormatter.allow(RegExp(r"[\d.]"))
|
|
||||||
],
|
|
||||||
onChanged: (input) => {
|
onChanged: (input) => {
|
||||||
print("Quantity value $input"),
|
log("Quantity value $input"),
|
||||||
bloc.exerciseRepository.setQuantity(double.parse(input)),
|
bloc.exerciseRepository.setQuantity(double.parse(input)),
|
||||||
bloc.exerciseRepository
|
bloc.exerciseRepository.setUnit(bloc.exerciseRepository.exerciseType.unit)
|
||||||
.setUnit(bloc.exerciseRepository.exerciseType.unit)
|
|
||||||
},
|
},
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
fillColor: Colors.white,
|
fillColor: Colors.white,
|
||||||
filled: false,
|
filled: false,
|
||||||
hintStyle: TextStyle(
|
hintStyle: TextStyle(fontSize: 12, color: Colors.black54, fontWeight: FontWeight.w100),
|
||||||
fontSize: 12, color: Colors.black54, fontWeight: FontWeight.w100),
|
hintText: AppLocalizations.of(context).translate("The number of the exercise"),
|
||||||
hintText: AppLocalizations.of(context)
|
|
||||||
.translate("The number of the exercise"),
|
|
||||||
labelStyle: TextStyle(fontSize: 12, color: Colors.deepOrange),
|
labelStyle: TextStyle(fontSize: 12, color: Colors.deepOrange),
|
||||||
labelText: AppLocalizations.of(context)
|
labelText: AppLocalizations.of(context).translate(bloc.exerciseRepository.exerciseType.unit),
|
||||||
.translate(bloc.exerciseRepository.exerciseType.unit),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
]);
|
]);
|
||||||
@ -191,18 +147,18 @@ class _CustomExerciseNewPageState extends State<CustomExercisePage> {
|
|||||||
SliverGrid gridCalculation(CustomExerciseFormBloc bloc) {
|
SliverGrid gridCalculation(CustomExerciseFormBloc bloc) {
|
||||||
LinkedHashMap args = LinkedHashMap();
|
LinkedHashMap args = LinkedHashMap();
|
||||||
return SliverGrid(
|
return SliverGrid(
|
||||||
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
||||||
crossAxisCount: 3,
|
crossAxisCount: 3,
|
||||||
mainAxisSpacing: 10.0,
|
mainAxisSpacing: 10.0,
|
||||||
crossAxisSpacing: 10.0,
|
crossAxisSpacing: 10.0,
|
||||||
childAspectRatio: 2.0,
|
childAspectRatio: 2.0,
|
||||||
),
|
),
|
||||||
delegate: SliverChildListDelegate(
|
delegate: SliverChildListDelegate(
|
||||||
[
|
[
|
||||||
TextFieldBlocBuilder(
|
TextFieldBlocBuilder(
|
||||||
readOnly: true,
|
readOnly: true,
|
||||||
textFieldBloc: bloc.rmWendlerField,
|
textFieldBloc: bloc.rmWendlerField,
|
||||||
padding: EdgeInsets.only(left:10),
|
padding: EdgeInsets.only(left: 10),
|
||||||
style: TextStyle(color: Colors.deepOrange, fontSize: 12),
|
style: TextStyle(color: Colors.deepOrange, fontSize: 12),
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
border: InputBorder.none,
|
border: InputBorder.none,
|
||||||
@ -210,9 +166,9 @@ class _CustomExerciseNewPageState extends State<CustomExercisePage> {
|
|||||||
filled: false,
|
filled: false,
|
||||||
labelText: "1RM by Wendler: ",
|
labelText: "1RM by Wendler: ",
|
||||||
)),
|
)),
|
||||||
TextFieldBlocBuilder(
|
TextFieldBlocBuilder(
|
||||||
readOnly: true,
|
readOnly: true,
|
||||||
padding: EdgeInsets.only(left:10),
|
padding: EdgeInsets.only(left: 10),
|
||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
textFieldBloc: bloc.rmWathenField,
|
textFieldBloc: bloc.rmWathenField,
|
||||||
style: TextStyle(color: Colors.deepOrange, fontSize: 12),
|
style: TextStyle(color: Colors.deepOrange, fontSize: 12),
|
||||||
@ -222,9 +178,9 @@ class _CustomExerciseNewPageState extends State<CustomExercisePage> {
|
|||||||
filled: false,
|
filled: false,
|
||||||
labelText: "1RM by Wahten: ",
|
labelText: "1RM by Wahten: ",
|
||||||
)),
|
)),
|
||||||
TextFieldBlocBuilder(
|
TextFieldBlocBuilder(
|
||||||
readOnly: true,
|
readOnly: true,
|
||||||
padding: EdgeInsets.only(left:10),
|
padding: EdgeInsets.only(left: 10),
|
||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
textFieldBloc: bloc.rmOconnerField,
|
textFieldBloc: bloc.rmOconnerField,
|
||||||
style: TextStyle(color: Colors.deepOrange, fontSize: 12),
|
style: TextStyle(color: Colors.deepOrange, fontSize: 12),
|
||||||
@ -234,9 +190,9 @@ class _CustomExerciseNewPageState extends State<CustomExercisePage> {
|
|||||||
filled: false,
|
filled: false,
|
||||||
labelText: "1RM by O'Conner: ",
|
labelText: "1RM by O'Conner: ",
|
||||||
)),
|
)),
|
||||||
TextFieldBlocBuilder(
|
TextFieldBlocBuilder(
|
||||||
readOnly: true,
|
readOnly: true,
|
||||||
padding: EdgeInsets.only(left:10),
|
padding: EdgeInsets.only(left: 10),
|
||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
textFieldBloc: bloc.rmMayhewField,
|
textFieldBloc: bloc.rmMayhewField,
|
||||||
style: TextStyle(color: Colors.deepOrange, fontSize: 12),
|
style: TextStyle(color: Colors.deepOrange, fontSize: 12),
|
||||||
@ -246,9 +202,9 @@ class _CustomExerciseNewPageState extends State<CustomExercisePage> {
|
|||||||
filled: false,
|
filled: false,
|
||||||
labelText: "1RM by Mayhew: ",
|
labelText: "1RM by Mayhew: ",
|
||||||
)),
|
)),
|
||||||
TextFieldBlocBuilder(
|
TextFieldBlocBuilder(
|
||||||
readOnly: true,
|
readOnly: true,
|
||||||
padding: EdgeInsets.only(left:10),
|
padding: EdgeInsets.only(left: 10),
|
||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
textFieldBloc: bloc.rmAverageField,
|
textFieldBloc: bloc.rmAverageField,
|
||||||
style: TextStyle(color: Colors.blueAccent, fontSize: 12),
|
style: TextStyle(color: Colors.blueAccent, fontSize: 12),
|
||||||
@ -259,138 +215,133 @@ class _CustomExerciseNewPageState extends State<CustomExercisePage> {
|
|||||||
labelText: "1RM Average: ",
|
labelText: "1RM Average: ",
|
||||||
)),
|
)),
|
||||||
TextFieldBlocBuilder(
|
TextFieldBlocBuilder(
|
||||||
readOnly: true,
|
readOnly: true,
|
||||||
padding: EdgeInsets.only(left:10),
|
padding: EdgeInsets.only(left: 10),
|
||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
textFieldBloc: bloc.rm90Field,
|
textFieldBloc: bloc.rm90Field,
|
||||||
style: TextStyle(color: Colors.deepOrange, fontSize: 12),
|
style: TextStyle(color: Colors.deepOrange, fontSize: 12),
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
border: InputBorder.none,
|
border: InputBorder.none,
|
||||||
fillColor: Colors.white,
|
fillColor: Colors.white,
|
||||||
filled: false,
|
filled: false,
|
||||||
labelText: "1RM 90%: ",
|
labelText: "1RM 90%: ",
|
||||||
)),
|
)),
|
||||||
|
|
||||||
TextFieldBlocBuilder(
|
TextFieldBlocBuilder(
|
||||||
readOnly: true,
|
readOnly: true,
|
||||||
padding: EdgeInsets.only(left:10),
|
padding: EdgeInsets.only(left: 10),
|
||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
textFieldBloc: bloc.rm75Field,
|
textFieldBloc: bloc.rm75Field,
|
||||||
style: TextStyle(color: Colors.deepOrange, fontSize: 12, fontWeight: FontWeight.normal),
|
style: TextStyle(color: Colors.deepOrange, fontSize: 12, fontWeight: FontWeight.normal),
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
border: InputBorder.none,
|
border: InputBorder.none,
|
||||||
fillColor: Colors.white,
|
fillColor: Colors.white,
|
||||||
filled: false,
|
filled: false,
|
||||||
labelText: "1RM 75%: ",
|
labelText: "1RM 75%: ",
|
||||||
)),
|
)),
|
||||||
TextFieldBlocBuilder(
|
TextFieldBlocBuilder(
|
||||||
readOnly: true,
|
readOnly: true,
|
||||||
padding: EdgeInsets.only(left:10),
|
padding: EdgeInsets.only(left: 10),
|
||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
textFieldBloc: bloc.rm75OconnorField,
|
textFieldBloc: bloc.rm75OconnorField,
|
||||||
style: TextStyle(color: Colors.deepOrange, fontSize: 12, fontWeight: FontWeight.normal),
|
style: TextStyle(color: Colors.deepOrange, fontSize: 12, fontWeight: FontWeight.normal),
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
border: InputBorder.none,
|
border: InputBorder.none,
|
||||||
fillColor: Colors.white,
|
fillColor: Colors.white,
|
||||||
filled: false,
|
filled: false,
|
||||||
labelText: "1RM 75%: by O'Connor",
|
labelText: "1RM 75%: by O'Connor",
|
||||||
)),
|
)),
|
||||||
TextFieldBlocBuilder(
|
TextFieldBlocBuilder(
|
||||||
readOnly: true,
|
readOnly: true,
|
||||||
padding: EdgeInsets.only(left:10),
|
padding: EdgeInsets.only(left: 10),
|
||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
textFieldBloc: bloc.rm75WendlerField,
|
textFieldBloc: bloc.rm75WendlerField,
|
||||||
style: TextStyle(color: Colors.deepOrange, fontSize: 12, fontWeight: FontWeight.normal),
|
style: TextStyle(color: Colors.deepOrange, fontSize: 12, fontWeight: FontWeight.normal),
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
border: InputBorder.none,
|
border: InputBorder.none,
|
||||||
fillColor: Colors.white,
|
fillColor: Colors.white,
|
||||||
filled: false,
|
filled: false,
|
||||||
labelText: "1RM 75% by Wendler: ",
|
labelText: "1RM 75% by Wendler: ",
|
||||||
)),
|
)),
|
||||||
TextFieldBlocBuilder(
|
TextFieldBlocBuilder(
|
||||||
readOnly: true,
|
readOnly: true,
|
||||||
padding: EdgeInsets.only(left:10),
|
padding: EdgeInsets.only(left: 10),
|
||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
textFieldBloc: bloc.rm80Field,
|
textFieldBloc: bloc.rm80Field,
|
||||||
style: TextStyle(color: Colors.deepOrange, fontSize: 12),
|
style: TextStyle(color: Colors.deepOrange, fontSize: 12),
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
border: InputBorder.none,
|
border: InputBorder.none,
|
||||||
fillColor: Colors.white,
|
fillColor: Colors.white,
|
||||||
filled: false,
|
filled: false,
|
||||||
labelText: "1RM 80%: ",
|
labelText: "1RM 80%: ",
|
||||||
)),
|
)),
|
||||||
TextFieldBlocBuilder(
|
TextFieldBlocBuilder(
|
||||||
readOnly: true,
|
readOnly: true,
|
||||||
padding: EdgeInsets.only(left:10),
|
padding: EdgeInsets.only(left: 10),
|
||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
textFieldBloc: bloc.rm70Field,
|
textFieldBloc: bloc.rm70Field,
|
||||||
style: TextStyle(color: Colors.deepOrange, fontSize: 12),
|
style: TextStyle(color: Colors.deepOrange, fontSize: 12),
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
border: InputBorder.none,
|
border: InputBorder.none,
|
||||||
fillColor: Colors.white,
|
fillColor: Colors.white,
|
||||||
filled: false,
|
filled: false,
|
||||||
labelText: "1RM 70%: ",
|
labelText: "1RM 70%: ",
|
||||||
)),
|
)),
|
||||||
TextFieldBlocBuilder(
|
TextFieldBlocBuilder(
|
||||||
readOnly: true,
|
readOnly: true,
|
||||||
padding: EdgeInsets.only(left:10),
|
padding: EdgeInsets.only(left: 10),
|
||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
textFieldBloc: bloc.rm60Field,
|
textFieldBloc: bloc.rm60Field,
|
||||||
style: TextStyle(color: Colors.deepOrange, fontSize: 12),
|
style: TextStyle(color: Colors.deepOrange, fontSize: 12),
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
border: InputBorder.none,
|
border: InputBorder.none,
|
||||||
fillColor: Colors.white,
|
fillColor: Colors.white,
|
||||||
filled: false,
|
filled: false,
|
||||||
labelText: "1RM 60%: ",
|
labelText: "1RM 60%: ",
|
||||||
)),
|
)),
|
||||||
TextFieldBlocBuilder(
|
TextFieldBlocBuilder(
|
||||||
readOnly: true,
|
readOnly: true,
|
||||||
padding: EdgeInsets.only(left:10),
|
padding: EdgeInsets.only(left: 10),
|
||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
textFieldBloc: bloc.rm50Field,
|
textFieldBloc: bloc.rm50Field,
|
||||||
style: TextStyle(color: Colors.deepOrange, fontSize: 12),
|
style: TextStyle(color: Colors.deepOrange, fontSize: 12),
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
border: InputBorder.none,
|
border: InputBorder.none,
|
||||||
fillColor: Colors.white,
|
fillColor: Colors.white,
|
||||||
filled: false,
|
filled: false,
|
||||||
labelText: "1RM 50%: ",
|
labelText: "1RM 50%: ",
|
||||||
)
|
)),
|
||||||
),
|
|
||||||
RaisedButton(
|
RaisedButton(
|
||||||
padding: EdgeInsets.all(0),
|
padding: EdgeInsets.all(0),
|
||||||
textColor: Colors.white,
|
textColor: Colors.white,
|
||||||
color: Colors.blue,
|
color: Colors.blue,
|
||||||
focusColor: Colors.blueAccent,
|
focusColor: Colors.blueAccent,
|
||||||
onPressed: () =>
|
onPressed: () => {
|
||||||
{
|
args['exerciseRepository'] = bloc.exerciseRepository,
|
||||||
args['exerciseRepository'] = bloc.exerciseRepository,
|
args['percent'] = 0.75,
|
||||||
args['percent'] = 0.75,
|
args['readonly'] = true,
|
||||||
args['readonly'] = true,
|
Navigator.of(context).pushNamed('exerciseControlPage', arguments: args)
|
||||||
Navigator.of(context).pushNamed('exerciseControlPage',
|
},
|
||||||
arguments: args)
|
child: Text(
|
||||||
},
|
"Control with 75%",
|
||||||
child: Text("Control with 75%",
|
style: TextStyle(fontSize: 12),
|
||||||
style: TextStyle(fontSize: 12),)
|
)),
|
||||||
),
|
|
||||||
RaisedButton(
|
RaisedButton(
|
||||||
padding: EdgeInsets.all(0),
|
padding: EdgeInsets.all(0),
|
||||||
textColor: Colors.white,
|
textColor: Colors.white,
|
||||||
color: Colors.green,
|
color: Colors.green,
|
||||||
focusColor: Colors.blueAccent,
|
focusColor: Colors.blueAccent,
|
||||||
onPressed: () =>
|
onPressed: () => {
|
||||||
{
|
args['exerciseRepository'] = bloc.exerciseRepository,
|
||||||
args['exerciseRepository'] = bloc.exerciseRepository,
|
args['percent'] = 0.5,
|
||||||
args['percent'] = 0.5,
|
args['readonly'] = true,
|
||||||
args['readonly'] = true,
|
Navigator.of(context).pushNamed('exerciseControlPage', arguments: args)
|
||||||
Navigator.of(context).pushNamed('exerciseControlPage',
|
},
|
||||||
arguments: args )
|
child: Text(
|
||||||
},
|
"Control with 50%",
|
||||||
child: Text("Control with 50%",
|
style: TextStyle(fontSize: 12),
|
||||||
style: TextStyle(fontSize: 12),)
|
)),
|
||||||
),
|
],
|
||||||
],
|
));
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -24,8 +24,7 @@ class _CustomerBodyTypePageState extends State<CustomerBodyTypePage> {
|
|||||||
String selected;
|
String selected;
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final CustomerRepository customerRepository =
|
final CustomerRepository customerRepository = ModalRoute.of(context).settings.arguments;
|
||||||
ModalRoute.of(context).settings.arguments;
|
|
||||||
final double cWidth = MediaQuery.of(context).size.width * 0.75;
|
final double cWidth = MediaQuery.of(context).size.width * 0.75;
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
@ -51,12 +50,10 @@ class _CustomerBodyTypePageState extends State<CustomerBodyTypePage> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
child: BlocProvider(
|
child: BlocProvider(
|
||||||
create: (context) =>
|
create: (context) => CustomerChangeBloc(customerRepository: customerRepository),
|
||||||
CustomerChangeBloc(customerRepository: customerRepository),
|
|
||||||
child: Builder(builder: (context) {
|
child: Builder(builder: (context) {
|
||||||
// ignore: close_sinks
|
// ignore: close_sinks
|
||||||
CustomerChangeBloc changeBloc =
|
CustomerChangeBloc changeBloc = BlocProvider.of<CustomerChangeBloc>(context);
|
||||||
BlocProvider.of<CustomerChangeBloc>(context);
|
|
||||||
|
|
||||||
return Column(
|
return Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
@ -67,14 +64,9 @@ class _CustomerBodyTypePageState extends State<CustomerBodyTypePage> {
|
|||||||
alignment: WrapAlignment.center,
|
alignment: WrapAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
AppLocalizations.of(context)
|
AppLocalizations.of(context).translate("Your Body Type"),
|
||||||
.translate("Your Body Type"),
|
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
style: TextStyle(
|
style: TextStyle(color: Colors.orange, fontSize: 42, fontFamily: 'Arial', fontWeight: FontWeight.w900),
|
||||||
color: Colors.orange,
|
|
||||||
fontSize: 42,
|
|
||||||
fontFamily: 'Arial',
|
|
||||||
fontWeight: FontWeight.w900),
|
|
||||||
)
|
)
|
||||||
]),
|
]),
|
||||||
Divider(),
|
Divider(),
|
||||||
@ -83,25 +75,17 @@ class _CustomerBodyTypePageState extends State<CustomerBodyTypePage> {
|
|||||||
width: cWidth,
|
width: cWidth,
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(AppLocalizations.of(context).translate("Endomorph"),
|
||||||
AppLocalizations.of(context)
|
|
||||||
.translate("Endomorph"),
|
|
||||||
textWidthBasis: TextWidthBasis.longestLine,
|
textWidthBasis: TextWidthBasis.longestLine,
|
||||||
style: TextStyle(
|
style: TextStyle(color: Colors.blue, fontSize: 32, fontFamily: 'Arial', fontWeight: FontWeight.w900)),
|
||||||
color: Colors.blue,
|
|
||||||
fontSize: 32,
|
|
||||||
fontFamily: 'Arial',
|
|
||||||
fontWeight: FontWeight.w900)),
|
|
||||||
],
|
],
|
||||||
)),
|
)),
|
||||||
padding: EdgeInsets.all(10.0),
|
padding: EdgeInsets.all(10.0),
|
||||||
shape: getShape(
|
shape: getShape(customerRepository, BodyTypeItem.endomorph),
|
||||||
customerRepository, BodyTypeItem.endomorph),
|
|
||||||
onPressed: () => {
|
onPressed: () => {
|
||||||
setState(() {
|
setState(() {
|
||||||
selected = BodyTypeItem.endomorph;
|
selected = BodyTypeItem.endomorph;
|
||||||
changeBloc.add(CustomerBodyTypeChange(bodyType: selected));
|
changeBloc.add(CustomerBodyTypeChange(bodyType: selected));
|
||||||
print(selected);
|
|
||||||
}),
|
}),
|
||||||
}),
|
}),
|
||||||
Divider(),
|
Divider(),
|
||||||
@ -112,13 +96,8 @@ class _CustomerBodyTypePageState extends State<CustomerBodyTypePage> {
|
|||||||
children: [
|
children: [
|
||||||
InkWell(
|
InkWell(
|
||||||
child: Text(
|
child: Text(
|
||||||
AppLocalizations.of(context)
|
AppLocalizations.of(context).translate("Ectomorph"),
|
||||||
.translate("Ectomorph"),
|
style: TextStyle(color: Colors.blue, fontSize: 32, fontFamily: 'Arial', fontWeight: FontWeight.w900),
|
||||||
style: TextStyle(
|
|
||||||
color: Colors.blue,
|
|
||||||
fontSize: 32,
|
|
||||||
fontFamily: 'Arial',
|
|
||||||
fontWeight: FontWeight.w900),
|
|
||||||
),
|
),
|
||||||
highlightColor: Colors.white,
|
highlightColor: Colors.white,
|
||||||
),
|
),
|
||||||
@ -126,13 +105,11 @@ class _CustomerBodyTypePageState extends State<CustomerBodyTypePage> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
padding: EdgeInsets.all(10.0),
|
padding: EdgeInsets.all(10.0),
|
||||||
shape: getShape(customerRepository, BodyTypeItem.ectomorph ),
|
shape: getShape(customerRepository, BodyTypeItem.ectomorph),
|
||||||
|
|
||||||
onPressed: () => {
|
onPressed: () => {
|
||||||
setState(() {
|
setState(() {
|
||||||
selected = BodyTypeItem.ectomorph;
|
selected = BodyTypeItem.ectomorph;
|
||||||
changeBloc.add(CustomerBodyTypeChange(bodyType: selected));
|
changeBloc.add(CustomerBodyTypeChange(bodyType: selected));
|
||||||
print(selected);
|
|
||||||
}),
|
}),
|
||||||
}),
|
}),
|
||||||
Divider(),
|
Divider(),
|
||||||
@ -143,13 +120,8 @@ class _CustomerBodyTypePageState extends State<CustomerBodyTypePage> {
|
|||||||
children: [
|
children: [
|
||||||
InkWell(
|
InkWell(
|
||||||
child: Text(
|
child: Text(
|
||||||
AppLocalizations.of(context)
|
AppLocalizations.of(context).translate("Mesomorph"),
|
||||||
.translate("Mesomorph"),
|
style: TextStyle(color: Colors.blue, fontSize: 32, fontFamily: 'Arial', fontWeight: FontWeight.w900),
|
||||||
style: TextStyle(
|
|
||||||
color: Colors.blue,
|
|
||||||
fontSize: 32,
|
|
||||||
fontFamily: 'Arial',
|
|
||||||
fontWeight: FontWeight.w900),
|
|
||||||
),
|
),
|
||||||
highlightColor: Colors.white,
|
highlightColor: Colors.white,
|
||||||
),
|
),
|
||||||
@ -157,22 +129,18 @@ class _CustomerBodyTypePageState extends State<CustomerBodyTypePage> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
padding: EdgeInsets.all(10.0),
|
padding: EdgeInsets.all(10.0),
|
||||||
shape: getShape(customerRepository, BodyTypeItem.mesomorph ),
|
shape: getShape(customerRepository, BodyTypeItem.mesomorph),
|
||||||
onPressed: () => {
|
onPressed: () => {
|
||||||
setState(() {
|
setState(() {
|
||||||
selected = BodyTypeItem.mesomorph;
|
selected = BodyTypeItem.mesomorph;
|
||||||
changeBloc.add(CustomerBodyTypeChange(bodyType: selected));
|
changeBloc.add(CustomerBodyTypeChange(bodyType: selected));
|
||||||
|
|
||||||
print(selected);
|
|
||||||
}),
|
}),
|
||||||
}),
|
}),
|
||||||
Divider(),
|
Divider(),
|
||||||
RaisedButton(
|
RaisedButton(
|
||||||
color: Colors.orange,
|
color: Colors.orange,
|
||||||
textColor: Colors.white,
|
textColor: Colors.white,
|
||||||
child: InkWell(
|
child: InkWell(child: Text(AppLocalizations.of(context).translate("Next"))),
|
||||||
child: Text(
|
|
||||||
AppLocalizations.of(context).translate("Next"))),
|
|
||||||
onPressed: () => {
|
onPressed: () => {
|
||||||
changeBloc.add(CustomerSave()),
|
changeBloc.add(CustomerSave()),
|
||||||
Navigator.of(context).pop(),
|
Navigator.of(context).pop(),
|
||||||
|
@ -180,7 +180,6 @@ class CustomerExerciseDevicePage extends StatelessWidget with Trans {
|
|||||||
}
|
}
|
||||||
|
|
||||||
List<Widget> getDevices(CustomerExerciseDeviceBloc bloc, double cWidth, double cHeight) {
|
List<Widget> getDevices(CustomerExerciseDeviceBloc bloc, double cWidth, double cHeight) {
|
||||||
print("height " + cHeight.toString());
|
|
||||||
final bool isEnglish = AppLanguage().appLocal.languageCode == "en";
|
final bool isEnglish = AppLanguage().appLocal.languageCode == "en";
|
||||||
this.listDevice = List();
|
this.listDevice = List();
|
||||||
final devices = bloc.devices;
|
final devices = bloc.devices;
|
||||||
@ -211,7 +210,6 @@ class CustomerExerciseDevicePage extends StatelessWidget with Trans {
|
|||||||
}
|
}
|
||||||
|
|
||||||
List<Widget> getDevicesPlace(CustomerExerciseDeviceBloc bloc, double cWidth, cHeight) {
|
List<Widget> getDevicesPlace(CustomerExerciseDeviceBloc bloc, double cWidth, cHeight) {
|
||||||
print("height " + cHeight.toString() + " width " + cWidth.toString());
|
|
||||||
final bool isEnglish = AppLanguage().appLocal.languageCode == "en";
|
final bool isEnglish = AppLanguage().appLocal.languageCode == "en";
|
||||||
this.listDevice = List();
|
this.listDevice = List();
|
||||||
final devices = bloc.devices;
|
final devices = bloc.devices;
|
||||||
@ -243,7 +241,6 @@ class CustomerExerciseDevicePage extends StatelessWidget with Trans {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void changeButtonShape(ExerciseDevice device, CustomerExerciseDeviceBloc bloc) {
|
void changeButtonShape(ExerciseDevice device, CustomerExerciseDeviceBloc bloc) {
|
||||||
print("Device clicked: " + device.name);
|
|
||||||
if (bloc.hasCustomerDevice(device.exerciseDeviceId)) {
|
if (bloc.hasCustomerDevice(device.exerciseDeviceId)) {
|
||||||
bloc.add(CustomerExerciseDeviceRemove(device: device));
|
bloc.add(CustomerExerciseDeviceRemove(device: device));
|
||||||
} else {
|
} else {
|
||||||
|
@ -101,7 +101,6 @@ class _CustomerFitnessPageState extends State<CustomerFitnessPage> {
|
|||||||
setState(() {
|
setState(() {
|
||||||
selected = FitnessState.beginner;
|
selected = FitnessState.beginner;
|
||||||
changeBloc.add(CustomerFitnessChange(fitness: selected));
|
changeBloc.add(CustomerFitnessChange(fitness: selected));
|
||||||
print(selected);
|
|
||||||
}),
|
}),
|
||||||
}),
|
}),
|
||||||
Divider(),
|
Divider(),
|
||||||
|
@ -12,19 +12,16 @@ class GoalsItem {
|
|||||||
|
|
||||||
// ignore: must_be_immutable
|
// ignore: must_be_immutable
|
||||||
class CustomerGoalPage extends StatefulWidget {
|
class CustomerGoalPage extends StatefulWidget {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<StatefulWidget> createState() => _CustomerGoalPage();
|
State<StatefulWidget> createState() => _CustomerGoalPage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class _CustomerGoalPage extends State<CustomerGoalPage> {
|
class _CustomerGoalPage extends State<CustomerGoalPage> {
|
||||||
String selected;
|
String selected;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final CustomerRepository customerRepository =
|
final CustomerRepository customerRepository = ModalRoute.of(context).settings.arguments;
|
||||||
ModalRoute.of(context).settings.arguments;
|
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
@ -51,111 +48,80 @@ class _CustomerGoalPage extends State<CustomerGoalPage> {
|
|||||||
height: double.infinity,
|
height: double.infinity,
|
||||||
width: double.infinity,
|
width: double.infinity,
|
||||||
child: BlocProvider(
|
child: BlocProvider(
|
||||||
create: (context) =>
|
create: (context) => CustomerChangeBloc(customerRepository: customerRepository),
|
||||||
CustomerChangeBloc(customerRepository: customerRepository),
|
|
||||||
child: Builder(builder: (context) {
|
child: Builder(builder: (context) {
|
||||||
CustomerChangeBloc changeBloc =
|
CustomerChangeBloc changeBloc = BlocProvider.of<CustomerChangeBloc>(context);
|
||||||
BlocProvider.of<CustomerChangeBloc>(context);
|
|
||||||
|
|
||||||
|
|
||||||
return SingleChildScrollView(
|
return SingleChildScrollView(
|
||||||
child: Center(
|
child: Center(
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
Divider(),
|
Divider(),
|
||||||
InkWell(
|
InkWell(
|
||||||
child: Text(
|
child: Text(
|
||||||
AppLocalizations.of(context)
|
AppLocalizations.of(context).translate("Set Your Goals"),
|
||||||
.translate("Set Your Goals"),
|
style: TextStyle(color: Colors.orange, fontSize: 50, fontFamily: 'Arial', fontWeight: FontWeight.w900),
|
||||||
style: TextStyle(
|
),
|
||||||
color: Colors.orange,
|
highlightColor: Colors.white,
|
||||||
fontSize: 50,
|
),
|
||||||
fontFamily: 'Arial',
|
Stack(alignment: Alignment.bottomLeft, overflow: Overflow.visible, children: [
|
||||||
fontWeight: FontWeight.w900),
|
FlatButton(
|
||||||
),
|
child: Image.asset(
|
||||||
highlightColor: Colors.white,
|
"asset/image/Gain_muscle.png",
|
||||||
|
height: 180,
|
||||||
),
|
),
|
||||||
Stack(
|
padding: EdgeInsets.all(0.0),
|
||||||
alignment: Alignment.bottomLeft,
|
shape: getShape(changeBloc, GoalsItem.muscle),
|
||||||
overflow: Overflow.visible,
|
onPressed: () => {
|
||||||
children: [
|
setState(() {
|
||||||
FlatButton(
|
selected = GoalsItem.muscle;
|
||||||
child: Image.asset(
|
changeBloc.add(CustomerGoalChange(goal: GoalsItem.muscle));
|
||||||
"asset/image/Gain_muscle.png",
|
|
||||||
height: 180,
|
|
||||||
),
|
|
||||||
padding: EdgeInsets.all(0.0),
|
|
||||||
shape: getShape(changeBloc, GoalsItem.muscle),
|
|
||||||
onPressed: () => {
|
|
||||||
print("gain muscle"),
|
|
||||||
setState((){
|
|
||||||
selected = GoalsItem.muscle;
|
|
||||||
changeBloc.add(CustomerGoalChange(goal: GoalsItem.muscle));
|
|
||||||
}),
|
|
||||||
|
|
||||||
}),
|
}),
|
||||||
InkWell(
|
}),
|
||||||
child: Text(
|
InkWell(
|
||||||
AppLocalizations.of(context)
|
child: Text(
|
||||||
.translate("Gain Muscle"),
|
AppLocalizations.of(context).translate("Gain Muscle"),
|
||||||
style: TextStyle(
|
style: TextStyle(color: Colors.white, fontSize: 32, fontFamily: 'Arial', fontWeight: FontWeight.w900),
|
||||||
color: Colors.white,
|
),
|
||||||
fontSize: 32,
|
highlightColor: Colors.white,
|
||||||
fontFamily: 'Arial',
|
)
|
||||||
fontWeight: FontWeight.w900),
|
]),
|
||||||
),
|
Divider(),
|
||||||
highlightColor: Colors.white,
|
Stack(alignment: Alignment.bottomLeft, overflow: Overflow.visible, children: [
|
||||||
)
|
FlatButton(
|
||||||
]),
|
child: Image.asset(
|
||||||
Divider(),
|
"asset/image/WT_weight_loss.png",
|
||||||
Stack(
|
height: 180,
|
||||||
alignment: Alignment.bottomLeft,
|
),
|
||||||
overflow: Overflow.visible,
|
padding: EdgeInsets.all(0.0),
|
||||||
children: [
|
shape: getShape(changeBloc, GoalsItem.weight),
|
||||||
FlatButton(
|
onPressed: () => {
|
||||||
child: Image.asset(
|
setState(() {
|
||||||
"asset/image/WT_weight_loss.png",
|
selected = GoalsItem.muscle;
|
||||||
height: 180,
|
changeBloc.add(CustomerGoalChange(goal: GoalsItem.weight));
|
||||||
),
|
}),
|
||||||
padding: EdgeInsets.all(0.0),
|
}),
|
||||||
shape: getShape(changeBloc, GoalsItem.weight),
|
InkWell(
|
||||||
onPressed: () => {
|
child: Text(
|
||||||
print("weight_loss"),
|
AppLocalizations.of(context).translate("Loose Weight"),
|
||||||
setState((){
|
style: TextStyle(color: Colors.white, fontSize: 32, fontFamily: 'Arial', fontWeight: FontWeight.w900),
|
||||||
selected = GoalsItem.muscle;
|
),
|
||||||
changeBloc.add(CustomerGoalChange(goal: GoalsItem.weight));
|
highlightColor: Colors.white,
|
||||||
}),
|
)
|
||||||
|
]),
|
||||||
}),
|
Divider(),
|
||||||
InkWell(
|
RaisedButton(
|
||||||
child: Text(
|
color: Colors.orange,
|
||||||
AppLocalizations.of(context)
|
textColor: Colors.white,
|
||||||
.translate("Loose Weight"),
|
child: InkWell(child: Text(AppLocalizations.of(context).translate("Next"))),
|
||||||
style: TextStyle(
|
onPressed: () => {
|
||||||
color: Colors.white,
|
//changingViewModel.saveCustomer(),
|
||||||
fontSize: 32,
|
changeBloc.add(CustomerSave()),
|
||||||
fontFamily: 'Arial',
|
Navigator.of(context).pop(),
|
||||||
fontWeight: FontWeight.w900),
|
Navigator.of(context).pushNamed("customerFitnessPage", arguments: changeBloc.customerRepository)
|
||||||
),
|
},
|
||||||
highlightColor: Colors.white,
|
)
|
||||||
)
|
],
|
||||||
]),
|
|
||||||
Divider(),
|
|
||||||
RaisedButton(
|
|
||||||
color: Colors.orange,
|
|
||||||
textColor: Colors.white,
|
|
||||||
child: InkWell(
|
|
||||||
child: Text(
|
|
||||||
AppLocalizations.of(context).translate("Next"))),
|
|
||||||
onPressed: () => {
|
|
||||||
//changingViewModel.saveCustomer(),
|
|
||||||
changeBloc.add(CustomerSave()),
|
|
||||||
Navigator.of(context).pop(),
|
|
||||||
Navigator.of(context).pushNamed("customerFitnessPage",
|
|
||||||
arguments: changeBloc.customerRepository)
|
|
||||||
},
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
));
|
));
|
||||||
}),
|
}),
|
||||||
|
@ -41,7 +41,6 @@ class EvaluationPage extends StatelessWidget with Trans {
|
|||||||
resultType = ResultType.running;
|
resultType = ResultType.running;
|
||||||
imageUrl = 'asset/image/WT_Results_for_runners.png';
|
imageUrl = 'asset/image/WT_Results_for_runners.png';
|
||||||
}
|
}
|
||||||
print("ResultType: " + resultType.toString());
|
|
||||||
setContext(context);
|
setContext(context);
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBarMin(
|
appBar: AppBarMin(
|
||||||
@ -489,7 +488,7 @@ class EvaluationPage extends StatelessWidget with Trans {
|
|||||||
width: 10,
|
width: 10,
|
||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
element.data,
|
element.data.toStringAsFixed(0),
|
||||||
style: GoogleFonts.archivoBlack(fontSize: 28, color: blur ? Colors.white30 : Colors.white),
|
style: GoogleFonts.archivoBlack(fontSize: 28, color: blur ? Colors.white30 : Colors.white),
|
||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
|
@ -175,59 +175,12 @@ class _ExerciseExecuteAddPage extends State<ExerciseExecutePlanAddPage> with Tra
|
|||||||
),
|
),
|
||||||
Text(t("repeat")),
|
Text(t("repeat")),
|
||||||
]),
|
]),
|
||||||
|
|
||||||
/*TextFieldBlocBuilder(
|
|
||||||
readOnly: exerciseBloc.step != i+1,
|
|
||||||
textFieldBloc: exerciseBloc.unitQuantity1Field,
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 18,
|
|
||||||
color: Colors.black54,
|
|
||||||
fontWeight: FontWeight.bold),
|
|
||||||
inputFormatters: [
|
|
||||||
FilteringTextInputFormatter.allow(RegExp(r"[\d.]"))
|
|
||||||
],
|
|
||||||
|
|
||||||
decoration: InputDecoration(
|
|
||||||
fillColor: Colors.white,
|
|
||||||
filled: false,
|
|
||||||
hintStyle: TextStyle(
|
|
||||||
fontSize: 14, color: Colors.black54, fontWeight: FontWeight.w100),
|
|
||||||
labelStyle: TextStyle(fontSize: 14, color: Colors.deepOrange, fontWeight: FontWeight.normal),
|
|
||||||
labelText: exerciseBloc.exerciseRepository.exerciseType.unitQuantityUnit,
|
|
||||||
),
|
|
||||||
),*/
|
|
||||||
/*TextFieldBlocBuilder(
|
|
||||||
readOnly: exerciseBloc.step != i+1,
|
|
||||||
textFieldBloc: exerciseBloc.quantity1Field,
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 18,
|
|
||||||
color: Colors.deepOrange,
|
|
||||||
fontWeight: FontWeight.bold),
|
|
||||||
inputFormatters: [
|
|
||||||
FilteringTextInputFormatter.allow(RegExp(r"[\d.]"))
|
|
||||||
],
|
|
||||||
|
|
||||||
decoration: InputDecoration(
|
|
||||||
fillColor: Colors.white,
|
|
||||||
filled: false,
|
|
||||||
hintStyle: TextStyle(
|
|
||||||
fontSize: 14, color: Colors.black54, fontWeight: FontWeight.w100),
|
|
||||||
hintText: t("The number of the exercise"),
|
|
||||||
labelStyle: TextStyle(fontSize: 14, color: Colors.deepOrange, fontWeight: FontWeight.normal),
|
|
||||||
labelText: t("Please repeat with") + " "+ exerciseBloc.unitQuantity1Field.value + " " +
|
|
||||||
exerciseBloc.exerciseRepository.exerciseType.unitQuantityUnit + " " +
|
|
||||||
exerciseBloc.exercisePlanRepository.getActualPlanDetail().repeats.toString() + " " + t("times!"),
|
|
||||||
),
|
|
||||||
),*/
|
|
||||||
RaisedButton(
|
RaisedButton(
|
||||||
padding: EdgeInsets.all(0),
|
padding: EdgeInsets.all(0),
|
||||||
textColor: Colors.white,
|
textColor: Colors.white,
|
||||||
color: exerciseBloc.step == i + 1 ? Colors.blue : Colors.black26,
|
color: exerciseBloc.step == i + 1 ? Colors.blue : Colors.black26,
|
||||||
focusColor: Colors.blueAccent,
|
focusColor: Colors.blueAccent,
|
||||||
onPressed: () => {
|
onPressed: () => {
|
||||||
print("Submit step " + exerciseBloc.step.toString() + " (i) " + i.toString()),
|
|
||||||
if (exerciseBloc.step == i + 1) {exerciseBloc.add(ExerciseExecutePlanAddSubmit())},
|
if (exerciseBloc.step == i + 1) {exerciseBloc.add(ExerciseExecutePlanAddSubmit())},
|
||||||
if (i + 1 == exerciseBloc.countSteps) {Navigator.of(context).pop()}
|
if (i + 1 == exerciseBloc.countSteps) {Navigator.of(context).pop()}
|
||||||
},
|
},
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
import 'dart:collection';
|
import 'dart:collection';
|
||||||
import 'package:aitrainer_app/bloc/exercise_log/exercise_log_bloc.dart';
|
import 'package:aitrainer_app/bloc/exercise_log/exercise_log_bloc.dart';
|
||||||
|
import 'package:aitrainer_app/library/custom_icon_icons.dart';
|
||||||
import 'package:aitrainer_app/widgets/app_bar.dart';
|
import 'package:aitrainer_app/widgets/app_bar.dart';
|
||||||
import 'package:aitrainer_app/widgets/bottom_nav.dart';
|
import 'package:aitrainer_app/widgets/bottom_nav.dart';
|
||||||
|
import 'package:aitrainer_app/widgets/dialog_premium.dart';
|
||||||
import 'package:aitrainer_app/widgets/splash.dart';
|
import 'package:aitrainer_app/widgets/splash.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
@ -34,7 +36,7 @@ class _ExerciseLogPage extends State<ExerciseLogPage> with Trans, Common {
|
|||||||
create: (context) => ExerciseLogBloc(exerciseRepository: ExerciseRepository())..add(ExerciseLogLoad()),
|
create: (context) => ExerciseLogBloc(exerciseRepository: ExerciseRepository())..add(ExerciseLogLoad()),
|
||||||
child: BlocConsumer<ExerciseLogBloc, ExerciseLogState>(listener: (context, state) {
|
child: BlocConsumer<ExerciseLogBloc, ExerciseLogState>(listener: (context, state) {
|
||||||
if (state is ExerciseLogLoading) {
|
if (state is ExerciseLogLoading) {
|
||||||
//LoadingDialog.show(context);
|
return LoadingDialog();
|
||||||
} else if (state is ExerciseLogError) {
|
} else if (state is ExerciseLogError) {
|
||||||
//LoadingDialog.hide(context);
|
//LoadingDialog.hide(context);
|
||||||
Scaffold.of(context).showSnackBar(
|
Scaffold.of(context).showSnackBar(
|
||||||
@ -45,7 +47,10 @@ class _ExerciseLogPage extends State<ExerciseLogPage> with Trans, Common {
|
|||||||
if (state is ExerciseLogReady) {
|
if (state is ExerciseLogReady) {
|
||||||
//LoadingDialog.hide(context);
|
//LoadingDialog.hide(context);
|
||||||
return getExerciseLog(customerId, exerciseBloc);
|
return getExerciseLog(customerId, exerciseBloc);
|
||||||
|
} else if (state is ExerciseLogLoading) {
|
||||||
|
return LoadingDialog();
|
||||||
} else {
|
} else {
|
||||||
|
//LoadingDialog.hide(context);
|
||||||
return getExerciseLog(customerId, exerciseBloc);
|
return getExerciseLog(customerId, exerciseBloc);
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
@ -59,8 +64,8 @@ class _ExerciseLogPage extends State<ExerciseLogPage> with Trans, Common {
|
|||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
image: DecorationImage(
|
image: DecorationImage(
|
||||||
image: customerId == Cache().userLoggedIn.customerId
|
image: customerId == Cache().userLoggedIn.customerId
|
||||||
? AssetImage('asset/image/WT_light_background.png')
|
? AssetImage('asset/image/WT_black_background.png')
|
||||||
: AssetImage('asset/image/WT_menu_dark.png'),
|
: AssetImage('asset/image/WT_light_background.png'),
|
||||||
fit: BoxFit.cover,
|
fit: BoxFit.cover,
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
),
|
),
|
||||||
@ -123,7 +128,7 @@ class _ExerciseLogPage extends State<ExerciseLogPage> with Trans, Common {
|
|||||||
|
|
||||||
List<Exercise> listExercises = List();
|
List<Exercise> listExercises = List();
|
||||||
String origDate = "";
|
String origDate = "";
|
||||||
exerciseRepository.exerciseList.forEach((exercise) {
|
exerciseRepository.exerciseLogList.forEach((exercise) {
|
||||||
String exerciseDate = DateFormat("yyyy-MM-dd", AppLanguage().appLocal.toString()).format(exercise.dateAdd);
|
String exerciseDate = DateFormat("yyyy-MM-dd", AppLanguage().appLocal.toString()).format(exercise.dateAdd);
|
||||||
|
|
||||||
if (origDate != exerciseDate) {
|
if (origDate != exerciseDate) {
|
||||||
@ -168,25 +173,16 @@ class _ExerciseLogPage extends State<ExerciseLogPage> with Trans, Common {
|
|||||||
ExerciseType exerciseType = exerciseRepository.getExerciseTypeById(exercise.exerciseTypeId);
|
ExerciseType exerciseType = exerciseRepository.getExerciseTypeById(exercise.exerciseTypeId);
|
||||||
String exerciseName = isEnglish ? exerciseType.name : exerciseType.nameTranslation;
|
String exerciseName = isEnglish ? exerciseType.name : exerciseType.nameTranslation;
|
||||||
|
|
||||||
String unitQuantity =
|
|
||||||
exerciseType.unitQuantity == "1" ? exercise.unitQuantity.toStringAsFixed(0) + " " + t(exerciseType.unitQuantityUnit) + " " : "";
|
|
||||||
|
|
||||||
String labelExercise = unitQuantity + exercise.quantity.toStringAsFixed(0) + " " + t(exercise.unit);
|
|
||||||
|
|
||||||
list.add(
|
list.add(
|
||||||
Card(
|
Card(
|
||||||
margin: EdgeInsets.only(left: 10, top: 5),
|
margin: EdgeInsets.only(left: 10, top: 5),
|
||||||
color: Colors.white54,
|
color: Colors.white54,
|
||||||
child: Container(
|
child: Container(
|
||||||
padding: const EdgeInsets.only(left: 5, top: 0, right: 5, bottom: 0),
|
padding: const EdgeInsets.only(left: 15, top: 0, right: 5, bottom: 0),
|
||||||
child: Row(mainAxisAlignment: MainAxisAlignment.start, children: [
|
child: Row(mainAxisAlignment: MainAxisAlignment.start, children: [
|
||||||
Icon(Icons.accessibility, color: Colors.black12),
|
|
||||||
SizedBox(
|
|
||||||
width: 10,
|
|
||||||
),
|
|
||||||
Flexible(
|
Flexible(
|
||||||
fit: FlexFit.tight,
|
fit: FlexFit.tight,
|
||||||
flex: 8,
|
flex: 20,
|
||||||
child: Text(
|
child: Text(
|
||||||
exerciseName,
|
exerciseName,
|
||||||
style: TextStyle(fontSize: 12, color: Colors.black),
|
style: TextStyle(fontSize: 12, color: Colors.black),
|
||||||
@ -195,17 +191,35 @@ class _ExerciseLogPage extends State<ExerciseLogPage> with Trans, Common {
|
|||||||
Flexible(
|
Flexible(
|
||||||
fit: FlexFit.tight,
|
fit: FlexFit.tight,
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
width: 10,
|
width: 5,
|
||||||
)),
|
)),
|
||||||
Text(
|
|
||||||
labelExercise,
|
|
||||||
style: TextStyle(fontSize: 9, color: Colors.blueAccent.shade700),
|
|
||||||
),
|
|
||||||
Flexible(
|
Flexible(
|
||||||
fit: FlexFit.tight,
|
fit: FlexFit.tight,
|
||||||
child: SizedBox(
|
flex: 20,
|
||||||
width: 10,
|
child: Text(
|
||||||
|
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();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
GestureDetector(
|
||||||
|
child: Image.asset(
|
||||||
|
'asset/image/lock.png',
|
||||||
|
height: 25,
|
||||||
|
width: 25,
|
||||||
|
),
|
||||||
|
onTap: () {
|
||||||
|
evaluation();
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
),
|
||||||
IconButton(
|
IconButton(
|
||||||
icon: Icon(Icons.delete, color: Colors.black12),
|
icon: Icon(Icons.delete, color: Colors.black12),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
@ -220,6 +234,19 @@ class _ExerciseLogPage extends State<ExerciseLogPage> with Trans, Common {
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void evaluation() {
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (BuildContext context) {
|
||||||
|
return DialogPremium(
|
||||||
|
title: "Go Premium",
|
||||||
|
descriptions: "Unleash your potential with WorkoutTest Premium!",
|
||||||
|
description2: "Enjoy also this premium fetaure to show all old evaluation data of your successful exercises.",
|
||||||
|
text: "OK",
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
void confirmationDialog(ExerciseLogBloc bloc, Exercise exercise) {
|
void confirmationDialog(ExerciseLogBloc bloc, Exercise exercise) {
|
||||||
ExerciseType exerciseType = bloc.exerciseRepository.getExerciseTypeById(exercise.exerciseTypeId);
|
ExerciseType exerciseType = bloc.exerciseRepository.getExerciseTypeById(exercise.exerciseTypeId);
|
||||||
String exerciseName = AppLanguage().appLocal == Locale("en") ? exerciseType.name : exerciseType.nameTranslation;
|
String exerciseName = AppLanguage().appLocal == Locale("en") ? exerciseType.name : exerciseType.nameTranslation;
|
||||||
@ -260,11 +287,7 @@ class _ExerciseLogPage extends State<ExerciseLogPage> with Trans, Common {
|
|||||||
),
|
),
|
||||||
FlatButton(
|
FlatButton(
|
||||||
child: Text(t("Yes")),
|
child: Text(t("Yes")),
|
||||||
onPressed: () => {
|
onPressed: () => {bloc.add(ExerciseLogDelete(exercise: exercise)), Navigator.pop(context)},
|
||||||
print("delete exercise: " + exercise.toJson().toString()),
|
|
||||||
bloc.add(ExerciseLogDelete(exercise: exercise)),
|
|
||||||
Navigator.pop(context)
|
|
||||||
},
|
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
));
|
));
|
||||||
|
@ -9,6 +9,7 @@ import 'package:aitrainer_app/model/exercise_ability.dart';
|
|||||||
import 'package:aitrainer_app/model/exercise_type.dart';
|
import 'package:aitrainer_app/model/exercise_type.dart';
|
||||||
import 'package:aitrainer_app/repository/customer_repository.dart';
|
import 'package:aitrainer_app/repository/customer_repository.dart';
|
||||||
import 'package:aitrainer_app/repository/exercise_repository.dart';
|
import 'package:aitrainer_app/repository/exercise_repository.dart';
|
||||||
|
import 'package:aitrainer_app/service/logging.dart';
|
||||||
import 'package:aitrainer_app/util/trans.dart';
|
import 'package:aitrainer_app/util/trans.dart';
|
||||||
import 'package:aitrainer_app/widgets/app_bar.dart';
|
import 'package:aitrainer_app/widgets/app_bar.dart';
|
||||||
import 'package:aitrainer_app/widgets/bmi_widget.dart';
|
import 'package:aitrainer_app/widgets/bmi_widget.dart';
|
||||||
@ -27,7 +28,7 @@ class ExerciseNewPage extends StatefulWidget {
|
|||||||
_ExerciseNewPageState createState() => _ExerciseNewPageState();
|
_ExerciseNewPageState createState() => _ExerciseNewPageState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _ExerciseNewPageState extends State<ExerciseNewPage> with Trans {
|
class _ExerciseNewPageState extends State<ExerciseNewPage> with Trans, Logging {
|
||||||
final FocusNode _nodeText1 = FocusNode();
|
final FocusNode _nodeText1 = FocusNode();
|
||||||
final FocusNode _nodeText2 = FocusNode();
|
final FocusNode _nodeText2 = FocusNode();
|
||||||
|
|
||||||
@ -123,7 +124,7 @@ class _ExerciseNewPageState extends State<ExerciseNewPage> with Trans {
|
|||||||
exerciseDescription = "";
|
exerciseDescription = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
//print(exerciseBloc.exerciseRepository.exerciseType.name);
|
//log(exerciseBloc.exerciseRepository.exerciseType.name);
|
||||||
|
|
||||||
if (exerciseBloc.exerciseRepository.exerciseType.name == "BMR") {
|
if (exerciseBloc.exerciseRepository.exerciseType.name == "BMR") {
|
||||||
return BMR(exerciseBloc: exerciseBloc);
|
return BMR(exerciseBloc: exerciseBloc);
|
||||||
@ -409,7 +410,6 @@ class _ExerciseNewPageState extends State<ExerciseNewPage> with Trans {
|
|||||||
|
|
||||||
void confirmationDialog(ExerciseNewBloc bloc, MenuBloc menuBloc) {
|
void confirmationDialog(ExerciseNewBloc bloc, MenuBloc menuBloc) {
|
||||||
LinkedHashMap args = LinkedHashMap();
|
LinkedHashMap args = LinkedHashMap();
|
||||||
print("exercise validated " + bloc.exerciseRepository.exercise.quantity.toString());
|
|
||||||
if (bloc.exerciseRepository.exercise.quantity == null) {
|
if (bloc.exerciseRepository.exercise.quantity == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -459,7 +459,7 @@ class _ExerciseNewPageState extends State<ExerciseNewPage> with Trans {
|
|||||||
bloc.add(ExerciseNewSubmit()),
|
bloc.add(ExerciseNewSubmit()),
|
||||||
Navigator.pop(context),
|
Navigator.pop(context),
|
||||||
Navigator.pop(context),
|
Navigator.pop(context),
|
||||||
print("Ability " +
|
log("Ability " +
|
||||||
menuBloc.ability.toString() +
|
menuBloc.ability.toString() +
|
||||||
" exerciseType 1rm " +
|
" exerciseType 1rm " +
|
||||||
bloc.exerciseRepository.exerciseType.is1RM().toString()),
|
bloc.exerciseRepository.exerciseType.is1RM().toString()),
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
|
import 'dart:async';
|
||||||
import 'dart:collection';
|
import 'dart:collection';
|
||||||
import 'package:aitrainer_app/library/radar_chart.dart';
|
import 'package:aitrainer_app/library/radar_chart.dart';
|
||||||
import 'package:aitrainer_app/widgets/app_bar.dart';
|
import 'package:aitrainer_app/widgets/app_bar.dart';
|
||||||
import 'package:aitrainer_app/widgets/bottom_nav.dart';
|
import 'package:aitrainer_app/widgets/bottom_nav.dart';
|
||||||
|
import 'package:aitrainer_app/widgets/dialog_premium.dart';
|
||||||
import 'package:aitrainer_app/widgets/splash.dart';
|
import 'package:aitrainer_app/widgets/splash.dart';
|
||||||
import 'package:flutter/scheduler.dart';
|
import 'package:flutter/scheduler.dart';
|
||||||
import 'package:aitrainer_app/model/cache.dart';
|
import 'package:aitrainer_app/model/cache.dart';
|
||||||
@ -17,12 +19,30 @@ class MyDevelopmentBodyPage extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _MyDevelopmentBodyPage extends State<MyDevelopmentBodyPage> with Trans, Common {
|
class _MyDevelopmentBodyPage extends State<MyDevelopmentBodyPage> with Trans, Common {
|
||||||
|
bool isStart = false;
|
||||||
// ignore: close_sinks
|
// ignore: close_sinks
|
||||||
BodyDevelopmentBloc bloc;
|
BodyDevelopmentBloc bloc;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
|
Timer(
|
||||||
|
Duration(milliseconds: 2000),
|
||||||
|
() => {
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
barrierDismissible: false,
|
||||||
|
builder: (BuildContext context) {
|
||||||
|
return DialogPremium(
|
||||||
|
title: "Go Premium",
|
||||||
|
descriptions: "Unleash your potential with WorkoutTest Premium!",
|
||||||
|
description2: "The Body Development feature is reachable if you finished the second 100% test-circles",
|
||||||
|
text: "OK",
|
||||||
|
onTap: () => {Navigator.of(context).pop(), Navigator.of(context).pop()},
|
||||||
|
onCancel: () => {Navigator.of(context).pop(), Navigator.of(context).pop()},
|
||||||
|
);
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
/// We require the initializers to run after the loading screen is rendered
|
/// We require the initializers to run after the loading screen is rendered
|
||||||
SchedulerBinding.instance.addPostFrameCallback((_) {
|
SchedulerBinding.instance.addPostFrameCallback((_) {
|
||||||
@ -38,13 +58,14 @@ class _MyDevelopmentBodyPage extends State<MyDevelopmentBodyPage> with Trans, Co
|
|||||||
setContext(context);
|
setContext(context);
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBarNav(depth: 1),
|
appBar: AppBarNav(depth: 1),
|
||||||
body: Container(
|
body: Container(
|
||||||
padding: EdgeInsets.all(20),
|
padding: EdgeInsets.all(20),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
image: DecorationImage(
|
image: DecorationImage(
|
||||||
image: customerId == Cache().userLoggedIn.customerId ? AssetImage('asset/image/WT_light_background.png'):
|
image: customerId == Cache().userLoggedIn.customerId
|
||||||
AssetImage('asset/image/WT_menu_dark.png'),
|
? AssetImage('asset/image/WT_light_background.png')
|
||||||
|
: AssetImage('asset/image/WT_menu_dark.png'),
|
||||||
fit: BoxFit.cover,
|
fit: BoxFit.cover,
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
),
|
),
|
||||||
@ -56,29 +77,24 @@ class _MyDevelopmentBodyPage extends State<MyDevelopmentBodyPage> with Trans, Co
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
if ( state is BodyDevelopmentInitial) {
|
if (state is BodyDevelopmentInitial) {
|
||||||
return Container();
|
return Container();
|
||||||
} else {
|
} else {
|
||||||
return developmentWidget(customerId);
|
return developmentWidget(customerId);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
)
|
)),
|
||||||
|
bottomNavigationBar: BottomNavigator(bottomNavIndex: 1),
|
||||||
),
|
|
||||||
bottomNavigationBar: BottomNavigator(bottomNavIndex: 1),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget developmentWidget(int customerId) {
|
Widget developmentWidget(int customerId) {
|
||||||
return Column(
|
return Column(children: [
|
||||||
children: [
|
explanationWidget(),
|
||||||
explanationWidget(),
|
Expanded(
|
||||||
Expanded(
|
child: exerciseWidget(customerId),
|
||||||
child: exerciseWidget(customerId),
|
),
|
||||||
),
|
]);
|
||||||
|
|
||||||
]
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget exerciseWidget(int customerId) {
|
Widget exerciseWidget(int customerId) {
|
||||||
@ -91,39 +107,33 @@ class _MyDevelopmentBodyPage extends State<MyDevelopmentBodyPage> with Trans, Co
|
|||||||
|
|
||||||
Widget explanationWidget() {
|
Widget explanationWidget() {
|
||||||
return Card(
|
return Card(
|
||||||
color: Colors.white60,
|
color: Colors.white60,
|
||||||
child: Container(
|
child: Container(
|
||||||
padding: EdgeInsets.only(left: 10, right: 5, top: 12, bottom: 8),
|
padding: EdgeInsets.only(left: 10, right: 5, top: 12, bottom: 8),
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||||
children: [
|
|
||||||
Row(
|
|
||||||
children: [
|
children: [
|
||||||
Icon(
|
Row(
|
||||||
Icons.info,
|
children: [
|
||||||
color: Colors.orangeAccent,
|
Icon(
|
||||||
|
Icons.info,
|
||||||
|
color: Colors.orangeAccent,
|
||||||
|
),
|
||||||
|
Text(" "),
|
||||||
|
Text(
|
||||||
|
t("My Body Development"),
|
||||||
|
style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
Divider(
|
||||||
|
color: Colors.transparent,
|
||||||
),
|
),
|
||||||
Text(" "),
|
|
||||||
Text(
|
Text(
|
||||||
t("My Body Development"),
|
t("You see here your whole body development by muscle groups."),
|
||||||
style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
|
style: TextStyle(fontSize: 12, fontWeight: FontWeight.normal),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
)));
|
||||||
Divider(
|
|
||||||
color: Colors.transparent,
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
t("You see here your whole body development by muscle groups."),
|
|
||||||
style: TextStyle(fontSize: 12, fontWeight: FontWeight.normal),
|
|
||||||
),
|
|
||||||
|
|
||||||
],
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
|
import 'dart:async';
|
||||||
import 'dart:collection';
|
import 'dart:collection';
|
||||||
import 'package:aitrainer_app/util/trans.dart';
|
import 'package:aitrainer_app/util/trans.dart';
|
||||||
import 'package:aitrainer_app/widgets/app_bar.dart';
|
import 'package:aitrainer_app/widgets/app_bar.dart';
|
||||||
|
import 'package:aitrainer_app/widgets/dialog_premium.dart';
|
||||||
import 'package:aitrainer_app/widgets/treeview_parent_widget.dart';
|
import 'package:aitrainer_app/widgets/treeview_parent_widget.dart';
|
||||||
import 'package:fl_chart/fl_chart.dart';
|
import 'package:fl_chart/fl_chart.dart';
|
||||||
import 'package:aitrainer_app/util/common.dart';
|
import 'package:aitrainer_app/util/common.dart';
|
||||||
@ -8,7 +10,6 @@ import 'package:aitrainer_app/bloc/development_by_muscle/development_by_muscle_b
|
|||||||
import 'package:aitrainer_app/model/workout_menu_tree.dart';
|
import 'package:aitrainer_app/model/workout_menu_tree.dart';
|
||||||
import 'package:aitrainer_app/library/tree_view.dart';
|
import 'package:aitrainer_app/library/tree_view.dart';
|
||||||
import 'package:aitrainer_app/widgets/bottom_nav.dart';
|
import 'package:aitrainer_app/widgets/bottom_nav.dart';
|
||||||
import 'package:aitrainer_app/widgets/splash.dart';
|
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/rendering.dart';
|
import 'package:flutter/rendering.dart';
|
||||||
@ -29,6 +30,23 @@ class _MyDevelopmentMuscleState extends State<MyDevelopmentMusclePage> with Comm
|
|||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
|
Timer(
|
||||||
|
Duration(milliseconds: 2000),
|
||||||
|
() => {
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
barrierDismissible: false,
|
||||||
|
builder: (BuildContext context) {
|
||||||
|
return DialogPremium(
|
||||||
|
title: "Go Premium",
|
||||||
|
descriptions: "Unleash your potential with WorkoutTest Premium!",
|
||||||
|
description2: "The Muscle Development feature is reachable if you finished the first 100% test-circles",
|
||||||
|
text: "OK",
|
||||||
|
onTap: () => {Navigator.of(context).pop(), Navigator.of(context).pop()},
|
||||||
|
onCancel: () => {Navigator.of(context).pop(), Navigator.of(context).pop()},
|
||||||
|
);
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
/// We require the initializers to run after the loading screen is rendered
|
/// We require the initializers to run after the loading screen is rendered
|
||||||
SchedulerBinding.instance.addPostFrameCallback((_) {
|
SchedulerBinding.instance.addPostFrameCallback((_) {
|
||||||
|
@ -3,6 +3,7 @@ import 'dart:collection';
|
|||||||
import 'package:aitrainer_app/model/cache.dart';
|
import 'package:aitrainer_app/model/cache.dart';
|
||||||
import 'package:aitrainer_app/repository/customer_repository.dart';
|
import 'package:aitrainer_app/repository/customer_repository.dart';
|
||||||
import 'package:aitrainer_app/repository/exercise_repository.dart';
|
import 'package:aitrainer_app/repository/exercise_repository.dart';
|
||||||
|
import 'package:aitrainer_app/widgets/dialog_premium.dart';
|
||||||
import 'package:google_fonts/google_fonts.dart';
|
import 'package:google_fonts/google_fonts.dart';
|
||||||
import 'package:aitrainer_app/util/trans.dart';
|
import 'package:aitrainer_app/util/trans.dart';
|
||||||
import 'package:aitrainer_app/widgets/app_bar.dart';
|
import 'package:aitrainer_app/widgets/app_bar.dart';
|
||||||
@ -25,7 +26,6 @@ class _MyDevelopmentPage extends State<MyDevelopmentPage> with Trans {
|
|||||||
setContext(context);
|
setContext(context);
|
||||||
double mediaWidth = MediaQuery.of(context).size.width;
|
double mediaWidth = MediaQuery.of(context).size.width;
|
||||||
double imageWidth = (mediaWidth - 45) / 2;
|
double imageWidth = (mediaWidth - 45) / 2;
|
||||||
print("Media: " + mediaWidth.toString() + " imageWidth: " + imageWidth.toString());
|
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBarNav(depth: 0),
|
appBar: AppBarNav(depth: 0),
|
||||||
@ -46,13 +46,11 @@ class _MyDevelopmentPage extends State<MyDevelopmentPage> with Trans {
|
|||||||
textAlignment: Alignment.topCenter,
|
textAlignment: Alignment.topCenter,
|
||||||
text: t("My Exercise Logs"),
|
text: t("My Exercise Logs"),
|
||||||
style: GoogleFonts.robotoMono(
|
style: GoogleFonts.robotoMono(
|
||||||
textStyle: TextStyle(
|
textStyle: TextStyle(
|
||||||
fontSize: 14,
|
fontSize: 14,
|
||||||
color: Colors.orange,
|
color: Colors.orange,
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
backgroundColor: Colors.black54.withOpacity(0.4)
|
backgroundColor: Colors.black54.withOpacity(0.4))),
|
||||||
)
|
|
||||||
),
|
|
||||||
image: "asset/image/edzesnaplom400400.jpg",
|
image: "asset/image/edzesnaplom400400.jpg",
|
||||||
left: 5,
|
left: 5,
|
||||||
onTap: () => this.callBackExerciseLog(exerciseRepository, customerRepository),
|
onTap: () => this.callBackExerciseLog(exerciseRepository, customerRepository),
|
||||||
@ -64,10 +62,10 @@ class _MyDevelopmentPage extends State<MyDevelopmentPage> with Trans {
|
|||||||
text: t("My Whole Body Development"),
|
text: t("My Whole Body Development"),
|
||||||
style: GoogleFonts.robotoMono(
|
style: GoogleFonts.robotoMono(
|
||||||
textStyle: TextStyle(
|
textStyle: TextStyle(
|
||||||
fontSize: 14,
|
fontSize: 14,
|
||||||
color: Colors.orange,
|
color: Colors.orange,
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
backgroundColor: Colors.black54.withOpacity(0.4)),
|
backgroundColor: Colors.black54.withOpacity(0.4)),
|
||||||
),
|
),
|
||||||
image: "asset/image/testemfejl400x400.jpg",
|
image: "asset/image/testemfejl400x400.jpg",
|
||||||
left: 5,
|
left: 5,
|
||||||
@ -82,11 +80,11 @@ class _MyDevelopmentPage extends State<MyDevelopmentPage> with Trans {
|
|||||||
textAlignment: Alignment.topLeft,
|
textAlignment: Alignment.topLeft,
|
||||||
text: t("Development Of Muscles"),
|
text: t("Development Of Muscles"),
|
||||||
style: GoogleFonts.robotoMono(
|
style: GoogleFonts.robotoMono(
|
||||||
textStyle: TextStyle(
|
textStyle: TextStyle(
|
||||||
fontSize: 14,
|
fontSize: 14,
|
||||||
color: Colors.orange,
|
color: Colors.orange,
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
backgroundColor: Colors.black54.withOpacity(0.4))),
|
backgroundColor: Colors.black54.withOpacity(0.4))),
|
||||||
image: "asset/image/izomcsop400400.jpg",
|
image: "asset/image/izomcsop400400.jpg",
|
||||||
left: 5,
|
left: 5,
|
||||||
onTap: () => {Navigator.of(context).pushNamed('mydevelopmentMusclePage', arguments: args)},
|
onTap: () => {Navigator.of(context).pushNamed('mydevelopmentMusclePage', arguments: args)},
|
||||||
@ -98,13 +96,26 @@ class _MyDevelopmentPage extends State<MyDevelopmentPage> with Trans {
|
|||||||
textAlignment: Alignment.topLeft,
|
textAlignment: Alignment.topLeft,
|
||||||
text: t("Predictions"),
|
text: t("Predictions"),
|
||||||
style: GoogleFonts.robotoMono(
|
style: GoogleFonts.robotoMono(
|
||||||
textStyle: TextStyle(
|
textStyle: TextStyle(
|
||||||
fontSize: 14,
|
fontSize: 14,
|
||||||
color: Colors.orange,
|
color: Colors.orange,
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
backgroundColor: Colors.black54.withOpacity(0.4))),
|
backgroundColor: Colors.black54.withOpacity(0.4))),
|
||||||
image: "asset/image/predictions.jpg",
|
image: "asset/image/predictions.jpg",
|
||||||
onTap: () => {},
|
onTap: () => {
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (BuildContext context) {
|
||||||
|
return DialogPremium(
|
||||||
|
title: "Go Premium",
|
||||||
|
descriptions: "Unleash your potential with WorkoutTest Premium!",
|
||||||
|
description2: "The Predictions feature is reachable if you finished the second 100% test-circles",
|
||||||
|
text: "OK",
|
||||||
|
onTap: () => {Navigator.of(context).pop()},
|
||||||
|
onCancel: () => {Navigator.of(context).pop()},
|
||||||
|
);
|
||||||
|
})
|
||||||
|
},
|
||||||
isLocked: true,
|
isLocked: true,
|
||||||
),
|
),
|
||||||
hiddenWidget(customerRepository, exerciseRepository),
|
hiddenWidget(customerRepository, exerciseRepository),
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
import 'dart:collection';
|
import 'dart:collection';
|
||||||
import 'package:aitrainer_app/model/cache.dart';
|
import 'package:aitrainer_app/model/cache.dart';
|
||||||
import 'package:aitrainer_app/repository/exercise_repository.dart';
|
import 'package:aitrainer_app/repository/exercise_repository.dart';
|
||||||
|
import 'package:aitrainer_app/service/logging.dart';
|
||||||
import 'package:aitrainer_app/util/trans.dart';
|
import 'package:aitrainer_app/util/trans.dart';
|
||||||
import 'package:aitrainer_app/widgets/app_bar.dart';
|
import 'package:aitrainer_app/widgets/app_bar.dart';
|
||||||
import 'package:aitrainer_app/widgets/bottom_nav.dart';
|
import 'package:aitrainer_app/widgets/bottom_nav.dart';
|
||||||
|
import 'package:aitrainer_app/widgets/dialog_premium.dart';
|
||||||
import 'package:aitrainer_app/widgets/image_button.dart';
|
import 'package:aitrainer_app/widgets/image_button.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
@ -14,7 +16,7 @@ class MyExercisePlanPage extends StatefulWidget {
|
|||||||
_MyExercisePlanPage createState() => _MyExercisePlanPage();
|
_MyExercisePlanPage createState() => _MyExercisePlanPage();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _MyExercisePlanPage extends State<MyExercisePlanPage> with Trans {
|
class _MyExercisePlanPage extends State<MyExercisePlanPage> with Trans, Logging {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final ExerciseRepository exerciseRepository = ExerciseRepository();
|
final ExerciseRepository exerciseRepository = ExerciseRepository();
|
||||||
@ -23,114 +25,146 @@ class _MyExercisePlanPage extends State<MyExercisePlanPage> with Trans {
|
|||||||
|
|
||||||
double mediaWidth = MediaQuery.of(context).size.width;
|
double mediaWidth = MediaQuery.of(context).size.width;
|
||||||
double imageWidth = (mediaWidth - 45) / 2;
|
double imageWidth = (mediaWidth - 45) / 2;
|
||||||
print("Media: " + mediaWidth.toString() + " imageWidth: " + imageWidth.toString());
|
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBarNav(depth: 0),
|
appBar: AppBarNav(depth: 0),
|
||||||
body: Container(
|
body: Container(
|
||||||
padding: EdgeInsets.all(10),
|
padding: EdgeInsets.all(10),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
image: DecorationImage(
|
image: DecorationImage(
|
||||||
image: AssetImage('asset/image/WT_menu_dark.png'),
|
image: AssetImage('asset/image/WT_menu_dark.png'),
|
||||||
fit: BoxFit.cover,
|
fit: BoxFit.cover,
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
),
|
|
||||||
),
|
|
||||||
child: CustomScrollView(
|
|
||||||
scrollDirection: Axis.vertical,
|
|
||||||
slivers:
|
|
||||||
[
|
|
||||||
SliverGrid(
|
|
||||||
delegate: SliverChildListDelegate(
|
|
||||||
[
|
|
||||||
ImageButton(
|
|
||||||
width: imageWidth,
|
|
||||||
textAlignment: Alignment.topLeft,
|
|
||||||
text: t("Execute My Selected Training Plan"),
|
|
||||||
style: GoogleFonts.robotoMono(
|
|
||||||
textStyle: TextStyle(fontSize: 14, color: Colors.orange, fontWeight: FontWeight.bold,
|
|
||||||
backgroundColor: Colors.black54.withOpacity(0.4))),
|
|
||||||
image: "asset/image/exercise_plan_execute.jpg",
|
|
||||||
top: 130,
|
|
||||||
left: 5,
|
|
||||||
onTap:() => {
|
|
||||||
args['customerId'] = Cache().userLoggedIn.customerId,
|
|
||||||
Navigator.of(context).pushNamed('exerciseExecutePlanPage',
|
|
||||||
arguments: args)
|
|
||||||
},
|
|
||||||
isLocked: false,
|
|
||||||
),
|
|
||||||
|
|
||||||
ImageButton(
|
|
||||||
width: imageWidth,
|
|
||||||
textAlignment: Alignment.topLeft,
|
|
||||||
text: t("Edit My Custom Plan"),
|
|
||||||
style: GoogleFonts.robotoMono(
|
|
||||||
textStyle: TextStyle(fontSize: 14, color: Colors.orange, fontWeight: FontWeight.bold,
|
|
||||||
backgroundColor: Colors.black54.withOpacity(0.4))),
|
|
||||||
image: "asset/image/exercise_plan_custom.jpg",
|
|
||||||
left: 5,
|
|
||||||
onTap:() => {
|
|
||||||
args['exerciseRepository'] = exerciseRepository,
|
|
||||||
args['customerId'] = Cache().userLoggedIn.customerId,
|
|
||||||
Navigator.of(context).pushNamed('exercisePlanCustomPage',
|
|
||||||
arguments: args)
|
|
||||||
},
|
|
||||||
isLocked: false,
|
|
||||||
),
|
|
||||||
|
|
||||||
ImageButton(
|
|
||||||
width: imageWidth,
|
|
||||||
textAlignment: Alignment.topLeft,
|
|
||||||
text: t("Suggested Training Plan"),
|
|
||||||
style: GoogleFonts.robotoMono(
|
|
||||||
textStyle: TextStyle(fontSize: 14, color: Colors.orange, fontWeight: FontWeight.bold,
|
|
||||||
backgroundColor: Colors.black54.withOpacity(0.4))),
|
|
||||||
image: "asset/image/exercise_plan_suggested.jpg",
|
|
||||||
left: 5,
|
|
||||||
onTap:() => {
|
|
||||||
|
|
||||||
},
|
|
||||||
isLocked: true,
|
|
||||||
),
|
|
||||||
|
|
||||||
ImageButton(
|
|
||||||
width: imageWidth,
|
|
||||||
textAlignment: Alignment.topLeft,
|
|
||||||
text: t("My Special Plan"),
|
|
||||||
style: GoogleFonts.robotoMono(
|
|
||||||
textStyle: TextStyle(fontSize: 14, color: Colors.orange, fontWeight: FontWeight.bold,
|
|
||||||
backgroundColor: Colors.black54.withOpacity(0.4))),
|
|
||||||
image: "asset/image/exercise_plan_special.jpg",
|
|
||||||
left: 5,
|
|
||||||
onTap:() => {
|
|
||||||
|
|
||||||
},
|
|
||||||
isLocked: true,
|
|
||||||
),
|
|
||||||
|
|
||||||
ImageButton(
|
|
||||||
width: imageWidth,
|
|
||||||
textAlignment: Alignment.topLeft,
|
|
||||||
text: t("My Arnold's Plan"),
|
|
||||||
style: GoogleFonts.robotoMono(
|
|
||||||
textStyle: TextStyle(fontSize: 14, color: Colors.orange, fontWeight: FontWeight.bold,
|
|
||||||
backgroundColor: Colors.black54.withOpacity(0.4))),
|
|
||||||
image: "asset/image/exercise_plan_stars.jpg",
|
|
||||||
left: 5,
|
|
||||||
onTap:() => {
|
|
||||||
|
|
||||||
},
|
|
||||||
isLocked: true,
|
|
||||||
),
|
|
||||||
|
|
||||||
|
|
||||||
hiddenPlanWidget(exerciseRepository),
|
|
||||||
hiddenTrainingWidget(),
|
|
||||||
|
|
||||||
|
|
||||||
]
|
|
||||||
),
|
),
|
||||||
|
),
|
||||||
|
child: CustomScrollView(scrollDirection: Axis.vertical, slivers: [
|
||||||
|
SliverGrid(
|
||||||
|
delegate: SliverChildListDelegate([
|
||||||
|
ImageButton(
|
||||||
|
width: imageWidth,
|
||||||
|
textAlignment: Alignment.topLeft,
|
||||||
|
text: t("Execute My Selected Training Plan"),
|
||||||
|
style: GoogleFonts.robotoMono(
|
||||||
|
textStyle: TextStyle(
|
||||||
|
fontSize: 14,
|
||||||
|
color: Colors.orange,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
backgroundColor: Colors.black54.withOpacity(0.4))),
|
||||||
|
image: "asset/image/exercise_plan_execute.jpg",
|
||||||
|
top: 130,
|
||||||
|
left: 5,
|
||||||
|
onTap: () => {
|
||||||
|
args['customerId'] = Cache().userLoggedIn.customerId,
|
||||||
|
Navigator.of(context).pushNamed('exerciseExecutePlanPage', arguments: args)
|
||||||
|
},
|
||||||
|
isLocked: false,
|
||||||
|
),
|
||||||
|
ImageButton(
|
||||||
|
width: imageWidth,
|
||||||
|
textAlignment: Alignment.topLeft,
|
||||||
|
text: t("Edit My Custom Plan"),
|
||||||
|
style: GoogleFonts.robotoMono(
|
||||||
|
textStyle: TextStyle(
|
||||||
|
fontSize: 14,
|
||||||
|
color: Colors.orange,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
backgroundColor: Colors.black54.withOpacity(0.4))),
|
||||||
|
image: "asset/image/exercise_plan_custom.jpg",
|
||||||
|
left: 5,
|
||||||
|
onTap: () => {
|
||||||
|
args['exerciseRepository'] = exerciseRepository,
|
||||||
|
args['customerId'] = Cache().userLoggedIn.customerId,
|
||||||
|
Navigator.of(context).pushNamed('exercisePlanCustomPage', arguments: args)
|
||||||
|
},
|
||||||
|
isLocked: false,
|
||||||
|
),
|
||||||
|
ImageButton(
|
||||||
|
width: imageWidth,
|
||||||
|
textAlignment: Alignment.topLeft,
|
||||||
|
text: t("Suggested Training Plan"),
|
||||||
|
style: GoogleFonts.robotoMono(
|
||||||
|
textStyle: TextStyle(
|
||||||
|
fontSize: 14,
|
||||||
|
color: Colors.orange,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
backgroundColor: Colors.black54.withOpacity(0.4))),
|
||||||
|
image: "asset/image/exercise_plan_suggested.jpg",
|
||||||
|
left: 5,
|
||||||
|
onTap: () => {
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (BuildContext context) {
|
||||||
|
return DialogPremium(
|
||||||
|
title: "Go Premium",
|
||||||
|
descriptions: "Unleash your potential with WorkoutTest Premium!",
|
||||||
|
description2: "The Suggested Training Plan is reachable if you finished the first 100% test-circles",
|
||||||
|
text: "OK",
|
||||||
|
onTap: () => {Navigator.of(context).pop()},
|
||||||
|
onCancel: () => {Navigator.of(context).pop()},
|
||||||
|
);
|
||||||
|
})
|
||||||
|
},
|
||||||
|
isLocked: true,
|
||||||
|
),
|
||||||
|
ImageButton(
|
||||||
|
width: imageWidth,
|
||||||
|
textAlignment: Alignment.topLeft,
|
||||||
|
text: t("My Special Plan"),
|
||||||
|
style: GoogleFonts.robotoMono(
|
||||||
|
textStyle: TextStyle(
|
||||||
|
fontSize: 14,
|
||||||
|
color: Colors.orange,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
backgroundColor: Colors.black54.withOpacity(0.4))),
|
||||||
|
image: "asset/image/exercise_plan_special.jpg",
|
||||||
|
left: 5,
|
||||||
|
onTap: () => {
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (BuildContext context) {
|
||||||
|
return DialogPremium(
|
||||||
|
title: "Go Premium",
|
||||||
|
descriptions: "Unleash your potential with WorkoutTest Premium!",
|
||||||
|
description2: "The Special Plan is reachable if you finished the first 100% test-circles",
|
||||||
|
text: "OK",
|
||||||
|
onTap: () => {Navigator.of(context).pop()},
|
||||||
|
onCancel: () => {Navigator.of(context).pop()},
|
||||||
|
);
|
||||||
|
})
|
||||||
|
},
|
||||||
|
isLocked: true,
|
||||||
|
),
|
||||||
|
ImageButton(
|
||||||
|
width: imageWidth,
|
||||||
|
textAlignment: Alignment.topLeft,
|
||||||
|
text: t("Star's Exercise Plan"),
|
||||||
|
style: GoogleFonts.robotoMono(
|
||||||
|
textStyle: TextStyle(
|
||||||
|
fontSize: 14,
|
||||||
|
color: Colors.orange,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
backgroundColor: Colors.black54.withOpacity(0.4))),
|
||||||
|
image: "asset/image/exercise_plan_stars.jpg",
|
||||||
|
left: 5,
|
||||||
|
onTap: () => {
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (BuildContext context) {
|
||||||
|
return DialogPremium(
|
||||||
|
title: "Go Premium",
|
||||||
|
descriptions: "Unleash your potential with WorkoutTest Premium!",
|
||||||
|
description2: "The Star's Exericise Plan is reachable if you finished the second 100% test-circles",
|
||||||
|
text: "OK",
|
||||||
|
onTap: () => {Navigator.of(context).pop()},
|
||||||
|
onCancel: () => {Navigator.of(context).pop()},
|
||||||
|
);
|
||||||
|
})
|
||||||
|
},
|
||||||
|
isLocked: true,
|
||||||
|
),
|
||||||
|
hiddenPlanWidget(exerciseRepository),
|
||||||
|
hiddenTrainingWidget(),
|
||||||
|
]),
|
||||||
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
||||||
crossAxisCount: 2,
|
crossAxisCount: 2,
|
||||||
mainAxisSpacing: 15.0,
|
mainAxisSpacing: 15.0,
|
||||||
@ -138,30 +172,27 @@ class _MyExercisePlanPage extends State<MyExercisePlanPage> with Trans {
|
|||||||
childAspectRatio: 1.0,
|
childAspectRatio: 1.0,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
]
|
])),
|
||||||
)
|
bottomNavigationBar: BottomNavigator(bottomNavIndex: 2));
|
||||||
),
|
|
||||||
bottomNavigationBar: BottomNavigator(bottomNavIndex: 2));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget hiddenPlanWidget(ExerciseRepository exerciseRepository) {
|
Widget hiddenPlanWidget(ExerciseRepository exerciseRepository) {
|
||||||
final LinkedHashMap args = LinkedHashMap();
|
final LinkedHashMap args = LinkedHashMap();
|
||||||
if ( Cache().getTrainee() != null ) {
|
if (Cache().getTrainee() != null) {
|
||||||
return FlatButton(
|
return FlatButton(
|
||||||
padding: EdgeInsets.all(20),
|
padding: EdgeInsets.all(20),
|
||||||
textColor: Colors.white,
|
textColor: Colors.white,
|
||||||
color: Colors.black12,
|
color: Colors.black12,
|
||||||
focusColor: Colors.blueAccent,
|
focusColor: Colors.blueAccent,
|
||||||
onPressed: () =>
|
onPressed: () => {
|
||||||
{
|
args['exerciseRepository'] = exerciseRepository,
|
||||||
args['exerciseRepository'] = exerciseRepository,
|
args['customerId'] = Cache().getTrainee().customerId,
|
||||||
args['customerId'] = Cache().getTrainee().customerId,
|
Navigator.of(context).pushNamed('exercisePlanCustomPage', arguments: args)
|
||||||
Navigator.of(context).pushNamed('exercisePlanCustomPage',
|
},
|
||||||
arguments: args)
|
child: Text(
|
||||||
},
|
t("My Trainee's Plan"),
|
||||||
child: Text(t("My Trainee's Plan"),
|
style: TextStyle(fontSize: 18),
|
||||||
style: TextStyle(fontSize: 18),)
|
));
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
return Container();
|
return Container();
|
||||||
}
|
}
|
||||||
@ -169,27 +200,23 @@ class _MyExercisePlanPage extends State<MyExercisePlanPage> with Trans {
|
|||||||
|
|
||||||
Widget hiddenTrainingWidget() {
|
Widget hiddenTrainingWidget() {
|
||||||
final LinkedHashMap args = LinkedHashMap();
|
final LinkedHashMap args = LinkedHashMap();
|
||||||
if ( Cache().getTrainee() != null ) {
|
if (Cache().getTrainee() != null) {
|
||||||
print ("!!Trainee: " + Cache().getTrainee().firstname + " " + Cache().getTrainee().name);
|
log("!!Trainee: " + Cache().getTrainee().firstname + " " + Cache().getTrainee().name);
|
||||||
return FlatButton(
|
return FlatButton(
|
||||||
padding: EdgeInsets.all(20),
|
padding: EdgeInsets.all(20),
|
||||||
textColor: Colors.white,
|
textColor: Colors.white,
|
||||||
color: Colors.black12,
|
color: Colors.black12,
|
||||||
focusColor: Colors.blueAccent,
|
focusColor: Colors.blueAccent,
|
||||||
onPressed: () =>
|
onPressed: () => {
|
||||||
{
|
args['customerId'] = Cache().getTrainee().customerId,
|
||||||
args['customerId'] = Cache().getTrainee().customerId,
|
Navigator.of(context).pushNamed('exerciseExecutePlanPage', arguments: args)
|
||||||
Navigator.of(context).pushNamed('exerciseExecutePlanPage',
|
},
|
||||||
arguments: args)
|
child: Text(
|
||||||
},
|
t("Execute My Trainee's Training Plan"),
|
||||||
child: Text(t("Execute My Trainee's Training Plan"),
|
style: TextStyle(fontSize: 18),
|
||||||
style: TextStyle(fontSize: 18),)
|
));
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
return Container();
|
return Container();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
199
lib/view/sales_page.dart
Normal file
199
lib/view/sales_page.dart
Normal file
@ -0,0 +1,199 @@
|
|||||||
|
import 'package:aitrainer_app/bloc/sales/sales_bloc.dart';
|
||||||
|
import 'package:aitrainer_app/util/trans.dart';
|
||||||
|
import 'package:aitrainer_app/widgets/app_bar_min.dart';
|
||||||
|
import 'package:aitrainer_app/widgets/sales_button.dart';
|
||||||
|
import 'package:aitrainer_app/widgets/splash.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
import 'package:google_fonts/google_fonts.dart';
|
||||||
|
|
||||||
|
// ignore: must_be_immutable
|
||||||
|
class SalesPage extends StatelessWidget with Trans {
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
setContext(context);
|
||||||
|
return BlocProvider(
|
||||||
|
create: (context) => SalesBloc()..add(SalesLoad()),
|
||||||
|
child: BlocConsumer<SalesBloc, SalesState>(listener: (context, state) {
|
||||||
|
if (state is SalesError) {
|
||||||
|
Scaffold.of(context).showSnackBar(
|
||||||
|
SnackBar(backgroundColor: Colors.orange, content: Text(state.message, style: TextStyle(color: Colors.white))));
|
||||||
|
} else if (state is SalesLoading) {
|
||||||
|
return LoadingDialog();
|
||||||
|
}
|
||||||
|
}, builder: (context, state) {
|
||||||
|
final salesBloc = BlocProvider.of<SalesBloc>(context);
|
||||||
|
return salesWidget(salesBloc);
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget salesWidget(SalesBloc bloc) {
|
||||||
|
final double mediaWidth = MediaQuery.of(context).size.width;
|
||||||
|
final double imageWidth = (mediaWidth - 5) / 2;
|
||||||
|
return Scaffold(
|
||||||
|
appBar: AppBarMin(
|
||||||
|
back: true,
|
||||||
|
),
|
||||||
|
body: Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
image: DecorationImage(
|
||||||
|
image: AssetImage('asset/image/WT_black_background.png'),
|
||||||
|
fit: BoxFit.cover,
|
||||||
|
alignment: Alignment.center,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: CustomScrollView(scrollDirection: Axis.vertical, slivers: [
|
||||||
|
SliverList(
|
||||||
|
delegate: SliverChildListDelegate([
|
||||||
|
Divider(),
|
||||||
|
Container(
|
||||||
|
padding: EdgeInsets.only(left: 65, right: 65),
|
||||||
|
child: Text("Unleash Your Development Now!",
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
maxLines: 4,
|
||||||
|
softWrap: true,
|
||||||
|
style: GoogleFonts.archivoBlack(
|
||||||
|
fontSize: 30,
|
||||||
|
color: Colors.white,
|
||||||
|
shadows: <Shadow>[
|
||||||
|
Shadow(
|
||||||
|
offset: Offset(5.0, 5.0),
|
||||||
|
blurRadius: 12.0,
|
||||||
|
color: Colors.black54,
|
||||||
|
),
|
||||||
|
Shadow(
|
||||||
|
offset: Offset(-3.0, 3.0),
|
||||||
|
blurRadius: 12.0,
|
||||||
|
color: Colors.black54,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
))),
|
||||||
|
Divider(),
|
||||||
|
Container(
|
||||||
|
padding: EdgeInsets.only(left: 45, right: 45),
|
||||||
|
child: Text("Learn about your development, enjoy AI-driven predictions of all of your skills and bodyparts.",
|
||||||
|
textAlign: TextAlign.left,
|
||||||
|
maxLines: 4,
|
||||||
|
softWrap: true,
|
||||||
|
style: GoogleFonts.inter(
|
||||||
|
fontSize: 16,
|
||||||
|
color: Colors.white,
|
||||||
|
))),
|
||||||
|
SizedBox(
|
||||||
|
height: 50,
|
||||||
|
),
|
||||||
|
])),
|
||||||
|
SliverGrid(
|
||||||
|
delegate: SliverChildListDelegate(getButtons(bloc)
|
||||||
|
/* [
|
||||||
|
SalesButton(
|
||||||
|
title: "Annual",
|
||||||
|
price: "9970 Ft / év",
|
||||||
|
desc1: "Development programs",
|
||||||
|
desc2: "Suggestions based on your actual status",
|
||||||
|
desc3: "Special customized training plans",
|
||||||
|
descStyle: GoogleFonts.inter(fontSize: 10, color: Colors.blue[800]),
|
||||||
|
badgeText: "2 months free",
|
||||||
|
badgeColor: Colors.orange,
|
||||||
|
style: GoogleFonts.archivoBlack(fontSize: 14, color: Colors.blue[800]),
|
||||||
|
onTap: () {
|
||||||
|
print("1");
|
||||||
|
//bloc.sessionBloc.add(event)
|
||||||
|
},
|
||||||
|
),
|
||||||
|
SalesButton(
|
||||||
|
title: "Annual",
|
||||||
|
price: "10970 Ft / év",
|
||||||
|
desc1: "Development programs",
|
||||||
|
desc2: "Suggestions based on your actual status",
|
||||||
|
desc3: "Special customized training plans",
|
||||||
|
desc4: "AI driven predictions",
|
||||||
|
descStyle: GoogleFonts.inter(fontSize: 10, color: Colors.blue[800]),
|
||||||
|
badgeText: "one month free",
|
||||||
|
badgeColor: Colors.orange,
|
||||||
|
style: GoogleFonts.archivoBlack(fontSize: 14, color: Colors.blue[800]),
|
||||||
|
onTap: () => {print("2")},
|
||||||
|
),
|
||||||
|
SalesButton(
|
||||||
|
title: "Monthly",
|
||||||
|
price: "970 Ft / hó",
|
||||||
|
desc1: "Development programs",
|
||||||
|
desc2: "Suggestions based on your actual status",
|
||||||
|
desc3: "Special customized training plans",
|
||||||
|
desc4: "AI driven predictions",
|
||||||
|
descStyle: GoogleFonts.inter(fontSize: 10, color: Colors.blue[800]),
|
||||||
|
badgeColor: Colors.transparent,
|
||||||
|
style: GoogleFonts.archivoBlack(fontSize: 14, color: Colors.blue[800]),
|
||||||
|
onTap: () => {print("3")},
|
||||||
|
),
|
||||||
|
] */
|
||||||
|
),
|
||||||
|
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
||||||
|
crossAxisCount: 3,
|
||||||
|
mainAxisSpacing: 10.0,
|
||||||
|
crossAxisSpacing: 10.0,
|
||||||
|
childAspectRatio: 0.55,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SliverList(
|
||||||
|
delegate: SliverChildListDelegate([
|
||||||
|
SizedBox(
|
||||||
|
height: 30,
|
||||||
|
),
|
||||||
|
Container(
|
||||||
|
padding: EdgeInsets.only(left: 55, right: 55),
|
||||||
|
child: Text(
|
||||||
|
"Subscription Conditions",
|
||||||
|
style: GoogleFonts.inter(fontSize: 14, fontWeight: FontWeight.bold, color: Colors.white),
|
||||||
|
)),
|
||||||
|
Divider(),
|
||||||
|
Container(
|
||||||
|
padding: EdgeInsets.only(left: 55, right: 55),
|
||||||
|
child: Text(
|
||||||
|
"Payment will be charged to your account. Subscription automatically renews unless auto-renew is turned off at least 24 hourse before the end of the current period",
|
||||||
|
style: GoogleFonts.inter(fontSize: 12, color: Colors.white),
|
||||||
|
)),
|
||||||
|
Divider(),
|
||||||
|
Container(
|
||||||
|
padding: EdgeInsets.only(left: 55, right: 55),
|
||||||
|
child: Text(
|
||||||
|
"Account will be charged for renewal within 24 hours prior to the end of the current period",
|
||||||
|
style: GoogleFonts.inter(fontSize: 12, color: Colors.white),
|
||||||
|
)),
|
||||||
|
])),
|
||||||
|
])));
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Widget> getButtons(SalesBloc bloc) {
|
||||||
|
List<Widget> buttons = List();
|
||||||
|
|
||||||
|
bloc.product2Display.forEach((element) {
|
||||||
|
final String title = element.sort == 3 ? "Montly" : "Annual";
|
||||||
|
final String interval = element.sort == 3 ? " / month" : " / year";
|
||||||
|
final String desc4 = element.sort == 1 ? "" : "AI driven predictions";
|
||||||
|
String badge;
|
||||||
|
if (element.sort == 2) {
|
||||||
|
badge = "14% discount";
|
||||||
|
} else if (element.sort == 1) {
|
||||||
|
badge = "2 months free";
|
||||||
|
}
|
||||||
|
Widget button = SalesButton(
|
||||||
|
title: title,
|
||||||
|
price: element.description + interval,
|
||||||
|
desc1: "Development programs",
|
||||||
|
desc2: "Suggestions based on your actual status",
|
||||||
|
desc3: "Special customized training plans",
|
||||||
|
desc4: desc4,
|
||||||
|
descStyle: GoogleFonts.inter(fontSize: 10, color: Colors.blue[800]),
|
||||||
|
badgeText: badge,
|
||||||
|
badgeColor: element.sort == 3 ? Colors.transparent : Colors.orange,
|
||||||
|
style: GoogleFonts.archivoBlack(fontSize: 14, color: Colors.blue[800]),
|
||||||
|
onTap: () => {bloc.add(SalesPurchase(productId: element.productId))},
|
||||||
|
);
|
||||||
|
buttons.add(button);
|
||||||
|
});
|
||||||
|
|
||||||
|
return buttons;
|
||||||
|
}
|
||||||
|
}
|
@ -35,6 +35,8 @@ class SettingsPage extends StatelessWidget with Trans {
|
|||||||
child: Form(
|
child: Form(
|
||||||
child: BlocConsumer<SettingsBloc, SettingsState>(listener: (context, state) {
|
child: BlocConsumer<SettingsBloc, SettingsState>(listener: (context, state) {
|
||||||
if (state is SettingsError) {
|
if (state is SettingsError) {
|
||||||
|
Scaffold.of(context).showSnackBar(
|
||||||
|
SnackBar(backgroundColor: Colors.orange, content: Text(state.message, style: TextStyle(color: Colors.white))));
|
||||||
} else if (state is SettingsReady) {
|
} else if (state is SettingsReady) {
|
||||||
menuBloc.add(MenuRecreateTree());
|
menuBloc.add(MenuRecreateTree());
|
||||||
} else if (state is SettingsLoading) {
|
} else if (state is SettingsLoading) {
|
||||||
|
@ -245,7 +245,7 @@ class _BMIState extends State<BMI> with Trans {
|
|||||||
icon: Icon(Icons.save),
|
icon: Icon(Icons.save),
|
||||||
hoverColor: Colors.blueAccent,
|
hoverColor: Colors.blueAccent,
|
||||||
color: widget.exerciseBloc.changedWeight ? Colors.blue[200] : Colors.black54,
|
color: widget.exerciseBloc.changedWeight ? Colors.blue[200] : Colors.black54,
|
||||||
onPressed: () => {print("Save"), widget.exerciseBloc.add(ExerciseNewSaveWeight())})
|
onPressed: () => {widget.exerciseBloc.add(ExerciseNewSaveWeight())})
|
||||||
],
|
],
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
@ -191,7 +191,6 @@ class _BMRState extends State<BMR> with Trans {
|
|||||||
selectedItem: FitnessItem().getItem(fitnessLevel),
|
selectedItem: FitnessItem().getItem(fitnessLevel),
|
||||||
itemAsString: (data) => t(data.stateText),
|
itemAsString: (data) => t(data.stateText),
|
||||||
onChanged: (data) {
|
onChanged: (data) {
|
||||||
print(data);
|
|
||||||
widget.exerciseBloc.add(ExerciseNewFitnessLevelChange(value: data.value));
|
widget.exerciseBloc.add(ExerciseNewFitnessLevelChange(value: data.value));
|
||||||
},
|
},
|
||||||
dropdownBuilder: _customDropDownItem,
|
dropdownBuilder: _customDropDownItem,
|
||||||
@ -290,7 +289,7 @@ class _BMRState extends State<BMR> with Trans {
|
|||||||
icon: Icon(Icons.save),
|
icon: Icon(Icons.save),
|
||||||
hoverColor: Colors.blueAccent,
|
hoverColor: Colors.blueAccent,
|
||||||
color: widget.exerciseBloc.changedWeight ? Colors.blue[200] : Colors.black54,
|
color: widget.exerciseBloc.changedWeight ? Colors.blue[200] : Colors.black54,
|
||||||
onPressed: () => {print("Save"), widget.exerciseBloc.add(ExerciseNewSaveWeight())})
|
onPressed: () => {widget.exerciseBloc.add(ExerciseNewSaveWeight())})
|
||||||
],
|
],
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
205
lib/widgets/dialog_premium.dart
Normal file
205
lib/widgets/dialog_premium.dart
Normal file
@ -0,0 +1,205 @@
|
|||||||
|
import 'dart:async';
|
||||||
|
|
||||||
|
import 'package:aitrainer_app/library/custom_icon_icons.dart';
|
||||||
|
import 'package:aitrainer_app/util/trans.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:google_fonts/google_fonts.dart';
|
||||||
|
|
||||||
|
// ignore: must_be_immutable
|
||||||
|
class DialogPremium extends StatefulWidget {
|
||||||
|
final String title, descriptions, text;
|
||||||
|
final VoidCallback onTap;
|
||||||
|
final VoidCallback onCancel;
|
||||||
|
String description2;
|
||||||
|
final Image img;
|
||||||
|
|
||||||
|
DialogPremium({Key key, this.title, this.descriptions, this.description2, this.text, this.img, this.onTap, this.onCancel})
|
||||||
|
: super(key: key) {
|
||||||
|
description2 = description2 ?? "";
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
_DialogPremiumState createState() {
|
||||||
|
return _DialogPremiumState();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class _DialogPremiumState extends State<DialogPremium> with Trans {
|
||||||
|
bool isStart = true;
|
||||||
|
Timer _timer;
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
setContext(context);
|
||||||
|
return Dialog(
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(31),
|
||||||
|
),
|
||||||
|
elevation: 0,
|
||||||
|
backgroundColor: Colors.transparent,
|
||||||
|
child: contentBox(context),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
isStart = true;
|
||||||
|
_timer = Timer.periodic(
|
||||||
|
Duration(milliseconds: 1000),
|
||||||
|
(Timer timer) => setState(() {
|
||||||
|
isStart = !isStart;
|
||||||
|
}));
|
||||||
|
super.initState();
|
||||||
|
}
|
||||||
|
|
||||||
|
contentBox(context) {
|
||||||
|
return Stack(alignment: AlignmentDirectional.topStart, children: [
|
||||||
|
Stack(
|
||||||
|
children: <Widget>[
|
||||||
|
Container(
|
||||||
|
padding: EdgeInsets.only(left: 20, top: 24, right: 20, bottom: 30),
|
||||||
|
margin: EdgeInsets.only(top: 30),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
borderRadius: BorderRadius.circular(24),
|
||||||
|
boxShadow: [BoxShadow(color: Colors.black, offset: Offset(0, 10), blurRadius: 10)],
|
||||||
|
image: DecorationImage(
|
||||||
|
image: AssetImage('asset/image/WT_black_G_background.png'),
|
||||||
|
fit: BoxFit.cover,
|
||||||
|
alignment: Alignment.center,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: <Widget>[
|
||||||
|
SizedBox(
|
||||||
|
height: 5,
|
||||||
|
),
|
||||||
|
Stack(
|
||||||
|
alignment: AlignmentDirectional.topEnd,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
widget.title + " ",
|
||||||
|
style: GoogleFonts.archivoBlack(
|
||||||
|
fontSize: 24,
|
||||||
|
color: Colors.yellow[400],
|
||||||
|
shadows: <Shadow>[
|
||||||
|
Shadow(
|
||||||
|
offset: Offset(5.0, 5.0),
|
||||||
|
blurRadius: 12.0,
|
||||||
|
color: Colors.black54,
|
||||||
|
),
|
||||||
|
Shadow(
|
||||||
|
offset: Offset(-3.0, 3.0),
|
||||||
|
blurRadius: 12.0,
|
||||||
|
color: Colors.black54,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Positioned(
|
||||||
|
right: 3,
|
||||||
|
top: 0,
|
||||||
|
child: AnimatedSwitcher(
|
||||||
|
duration: Duration(milliseconds: 900),
|
||||||
|
//reverseDuration: Duration(milliseconds: 200),
|
||||||
|
transitionBuilder: (Widget child, Animation<double> animation) {
|
||||||
|
return FadeTransition(child: child, opacity: animation);
|
||||||
|
},
|
||||||
|
child: isStart
|
||||||
|
? Icon(
|
||||||
|
CustomIcon.star_2,
|
||||||
|
color: Colors.yellow[300],
|
||||||
|
)
|
||||||
|
: Offstage() /* Icon(
|
||||||
|
CustomIcon.exclamation_circle,
|
||||||
|
color: Colors.yellow[300],
|
||||||
|
) */
|
||||||
|
)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: 35,
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
widget.descriptions,
|
||||||
|
style: GoogleFonts.inter(
|
||||||
|
fontSize: 14,
|
||||||
|
color: Colors.white,
|
||||||
|
shadows: <Shadow>[
|
||||||
|
Shadow(
|
||||||
|
offset: Offset(5.0, 5.0),
|
||||||
|
blurRadius: 12.0,
|
||||||
|
color: Colors.black54,
|
||||||
|
),
|
||||||
|
Shadow(
|
||||||
|
offset: Offset(-3.0, 3.0),
|
||||||
|
blurRadius: 12.0,
|
||||||
|
color: Colors.black54,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: 15,
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
widget.description2,
|
||||||
|
style: GoogleFonts.inter(
|
||||||
|
fontSize: 14,
|
||||||
|
color: Colors.white,
|
||||||
|
shadows: <Shadow>[
|
||||||
|
Shadow(
|
||||||
|
offset: Offset(5.0, 5.0),
|
||||||
|
blurRadius: 12.0,
|
||||||
|
color: Colors.black54,
|
||||||
|
),
|
||||||
|
Shadow(
|
||||||
|
offset: Offset(-3.0, 3.0),
|
||||||
|
blurRadius: 12.0,
|
||||||
|
color: Colors.black54,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: 62,
|
||||||
|
),
|
||||||
|
Align(
|
||||||
|
alignment: Alignment.center,
|
||||||
|
child: GestureDetector(
|
||||||
|
onTap: widget.onTap ?? widget.onTap,
|
||||||
|
child: Stack(
|
||||||
|
alignment: Alignment.center,
|
||||||
|
children: [
|
||||||
|
Image.asset('asset/icon/gomb_orange_c.png', width: 100, height: 45),
|
||||||
|
Text(
|
||||||
|
t("OK"),
|
||||||
|
style: TextStyle(fontSize: 16, color: Colors.white),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
))),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
GestureDetector(
|
||||||
|
onTap: () => widget.onCancel == null ? Navigator.of(context).pop() : widget.onCancel,
|
||||||
|
child: CircleAvatar(
|
||||||
|
backgroundColor: Colors.transparent,
|
||||||
|
radius: 28,
|
||||||
|
child: Text(
|
||||||
|
"X",
|
||||||
|
style: GoogleFonts.archivoBlack(fontSize: 32, color: Colors.white54),
|
||||||
|
),
|
||||||
|
)),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_timer.cancel();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,7 @@
|
|||||||
import 'package:aitrainer_app/bloc/session/session_bloc.dart';
|
import 'package:aitrainer_app/bloc/session/session_bloc.dart';
|
||||||
import 'package:aitrainer_app/bloc/settings/settings_bloc.dart';
|
import 'package:aitrainer_app/bloc/settings/settings_bloc.dart';
|
||||||
import 'package:aitrainer_app/model/cache.dart';
|
import 'package:aitrainer_app/model/cache.dart';
|
||||||
|
import 'package:aitrainer_app/service/logging.dart';
|
||||||
import 'package:aitrainer_app/view/login.dart';
|
import 'package:aitrainer_app/view/login.dart';
|
||||||
import 'package:aitrainer_app/view/menu_page.dart';
|
import 'package:aitrainer_app/view/menu_page.dart';
|
||||||
import 'package:aitrainer_app/view/registration.dart';
|
import 'package:aitrainer_app/view/registration.dart';
|
||||||
@ -11,7 +12,6 @@ import 'package:flutter/widgets.dart';
|
|||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'loading.dart';
|
import 'loading.dart';
|
||||||
|
|
||||||
|
|
||||||
// ignore: must_be_immutable
|
// ignore: must_be_immutable
|
||||||
class AitrainerHome extends StatefulWidget {
|
class AitrainerHome extends StatefulWidget {
|
||||||
_HomePageState _state;
|
_HomePageState _state;
|
||||||
@ -22,7 +22,7 @@ class AitrainerHome extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class _HomePageState extends State<AitrainerHome> {
|
class _HomePageState extends State<AitrainerHome> with Logging {
|
||||||
GlobalKey<ScaffoldState> _scaffoldKey = new GlobalKey<ScaffoldState>();
|
GlobalKey<ScaffoldState> _scaffoldKey = new GlobalKey<ScaffoldState>();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -37,7 +37,7 @@ class _HomePageState extends State<AitrainerHome> {
|
|||||||
|
|
||||||
Future runDelayedEvent() async {
|
Future runDelayedEvent() async {
|
||||||
await Future.delayed(Duration(seconds: 2), () async {
|
await Future.delayed(Duration(seconds: 2), () async {
|
||||||
if ( context != null) {
|
if (context != null) {
|
||||||
// ignore: close_sinks
|
// ignore: close_sinks
|
||||||
SessionBloc sessionBloc = BlocProvider.of<SessionBloc>(context);
|
SessionBloc sessionBloc = BlocProvider.of<SessionBloc>(context);
|
||||||
if (sessionBloc.state != SessionReady()) {
|
if (sessionBloc.state != SessionReady()) {
|
||||||
@ -49,45 +49,40 @@ class _HomePageState extends State<AitrainerHome> {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
key: _scaffoldKey,
|
key: _scaffoldKey,
|
||||||
body: Container(
|
body: BlocConsumer<SessionBloc, SessionState>(listener: (context, state) {
|
||||||
child: BlocConsumer<SessionBloc, SessionState>(
|
if (state is SessionFailure) {
|
||||||
listener: (context, state) {
|
Scaffold.of(context).showSnackBar(SnackBar(
|
||||||
if ( state is SessionFailure) {
|
content: Text(
|
||||||
Scaffold.of(context).showSnackBar(SnackBar(
|
state.message,
|
||||||
content: Text(
|
),
|
||||||
state.message,
|
backgroundColor: Colors.orange,
|
||||||
),
|
));
|
||||||
backgroundColor: Colors.orange,
|
}
|
||||||
));
|
}, builder: (context, state) {
|
||||||
}
|
if (state is SessionInitial) {
|
||||||
},
|
return LoadingScreenMain();
|
||||||
builder: (context, state) {
|
} else if (state is SessionLoading) {
|
||||||
if (state is SessionInitial) {
|
log("loading");
|
||||||
return LoadingScreenMain();
|
return LoadingScreenMain();
|
||||||
} else if (state is SessionLoading) {
|
} else if (state is SessionReady) {
|
||||||
print("loading");
|
log("ready menu with " + Cache().startPage);
|
||||||
return LoadingScreenMain();
|
if (Cache().startPage == 'login') {
|
||||||
} else if (state is SessionReady) {
|
return LoginPage();
|
||||||
print("ready menu with " + Cache().startPage);
|
} else if (Cache().startPage == 'registration') {
|
||||||
if (Cache().startPage == 'login') {
|
return RegistrationPage();
|
||||||
return LoginPage();
|
} else {
|
||||||
} else if (Cache().startPage == 'registration') {
|
return MenuPage(parent: 0);
|
||||||
return RegistrationPage();
|
|
||||||
} else {
|
|
||||||
return MenuPage(parent: 0);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
print("else");
|
|
||||||
return MenuPage(parent: 0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
),
|
} else {
|
||||||
),
|
log("else");
|
||||||
//bottomNavigationBar: BottomNavigator(bottomNavIndex: 0),
|
return MenuPage(parent: 0);
|
||||||
|
}
|
||||||
|
}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ class ImageButton extends StatelessWidget {
|
|||||||
final String text;
|
final String text;
|
||||||
TextStyle style = TextStyle(fontSize: 14);
|
TextStyle style = TextStyle(fontSize: 14);
|
||||||
final String image;
|
final String image;
|
||||||
final double top;
|
double top;
|
||||||
final double left;
|
final double left;
|
||||||
double height;
|
double height;
|
||||||
double width;
|
double width;
|
||||||
@ -49,9 +49,10 @@ class ImageButton extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
double top =
|
if (top == null) {
|
||||||
height - (style.fontSize - 5) * text.length - 2 * left < 0 ? height - 2 * style.fontSize - 22 : height - style.fontSize - 17;
|
top = height - (style.fontSize - 5) * text.length - 2 * left < 0 ? height - 2 * style.fontSize - 22 : height - style.fontSize - 17;
|
||||||
//print("Top: " + top.toStringAsFixed(0) + " length: " + ((style.fontSize - 5) * text.length).toString());
|
//print("Top: " + top.toStringAsFixed(0) + " length: " + ((style.fontSize - 5) * text.length).toString());
|
||||||
|
}
|
||||||
return Stack(
|
return Stack(
|
||||||
//alignment: textAlignment,
|
//alignment: textAlignment,
|
||||||
fit: StackFit.passthrough,
|
fit: StackFit.passthrough,
|
||||||
|
@ -94,10 +94,7 @@ class MenuInfoWidget extends StatelessWidget with Common {
|
|||||||
link,
|
link,
|
||||||
style: TextStyle(color: Colors.lightBlueAccent, fontSize: textSize, fontFamily: 'Arial', fontWeight: textWeight),
|
style: TextStyle(color: Colors.lightBlueAccent, fontSize: textSize, fontFamily: 'Arial', fontWeight: textWeight),
|
||||||
),
|
),
|
||||||
onTap: () => {
|
onTap: () =>
|
||||||
missingId = bloc.menuTreeRepository.getMissingTreeIdByName(bloc.missingTreeName),
|
{missingId = bloc.menuTreeRepository.getMissingTreeIdByName(bloc.missingTreeName), bloc.add(MenuTreeJump(parent: missingId))});
|
||||||
print("menu " + missingId.toString()),
|
|
||||||
bloc.add(MenuTreeJump(parent: missingId))
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
98
lib/widgets/sales_button.dart
Normal file
98
lib/widgets/sales_button.dart
Normal file
@ -0,0 +1,98 @@
|
|||||||
|
import 'package:badges/badges.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:google_fonts/google_fonts.dart';
|
||||||
|
|
||||||
|
// ignore: must_be_immutable
|
||||||
|
class SalesButton extends StatelessWidget {
|
||||||
|
TextStyle style = TextStyle(fontSize: 14);
|
||||||
|
TextStyle descStyle = TextStyle(fontSize: 14);
|
||||||
|
final String title;
|
||||||
|
final String price;
|
||||||
|
final String desc1;
|
||||||
|
final String desc2;
|
||||||
|
final String desc3;
|
||||||
|
String desc4;
|
||||||
|
final String badgeText;
|
||||||
|
final Color badgeColor;
|
||||||
|
final VoidCallback onTap;
|
||||||
|
|
||||||
|
SalesButton(
|
||||||
|
{this.title,
|
||||||
|
this.price,
|
||||||
|
this.desc1,
|
||||||
|
this.desc2,
|
||||||
|
this.desc3,
|
||||||
|
this.desc4,
|
||||||
|
this.badgeText,
|
||||||
|
this.badgeColor,
|
||||||
|
this.onTap,
|
||||||
|
this.style,
|
||||||
|
this.descStyle}) {
|
||||||
|
style = style ??
|
||||||
|
GoogleFonts.archivoBlack(
|
||||||
|
fontSize: 14,
|
||||||
|
);
|
||||||
|
desc4 = desc4 ?? "";
|
||||||
|
}
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return GestureDetector(
|
||||||
|
onTap: onTap,
|
||||||
|
child: Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
image: DecorationImage(
|
||||||
|
image: AssetImage('asset/image/WT_sales_background_3x5.png'),
|
||||||
|
fit: BoxFit.cover,
|
||||||
|
alignment: Alignment.center,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: Badge(
|
||||||
|
position: BadgePosition.topEnd(end: -3, top: -5),
|
||||||
|
padding: EdgeInsets.all(5),
|
||||||
|
badgeColor: badgeColor,
|
||||||
|
borderRadius: BorderRadius.circular(5),
|
||||||
|
shape: BadgeShape.square,
|
||||||
|
badgeContent: badgeText != null
|
||||||
|
? Text(badgeText,
|
||||||
|
style: TextStyle(
|
||||||
|
color: Colors.white,
|
||||||
|
backgroundColor: badgeColor,
|
||||||
|
fontSize: 12,
|
||||||
|
))
|
||||||
|
: Text("",
|
||||||
|
style: TextStyle(
|
||||||
|
color: Colors.transparent,
|
||||||
|
backgroundColor: Colors.transparent,
|
||||||
|
fontSize: 1,
|
||||||
|
)),
|
||||||
|
child: Container(
|
||||||
|
child: Center(
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
Divider(
|
||||||
|
color: Colors.transparent,
|
||||||
|
),
|
||||||
|
Divider(
|
||||||
|
color: Colors.transparent,
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
title,
|
||||||
|
style: GoogleFonts.archivoBlack(color: Colors.black54),
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
price,
|
||||||
|
style: style,
|
||||||
|
),
|
||||||
|
Container(
|
||||||
|
padding: EdgeInsets.only(top: 5, left: 3, right: 3, bottom: 4), child: Text(desc1, maxLines: 2, style: descStyle)),
|
||||||
|
Container(padding: EdgeInsets.only(left: 3, right: 3, bottom: 4), child: Text(desc2, maxLines: 2, style: descStyle)),
|
||||||
|
Container(padding: EdgeInsets.only(left: 3, right: 3, bottom: 4), child: Text(desc3, maxLines: 2, style: descStyle)),
|
||||||
|
Container(
|
||||||
|
padding: EdgeInsets.only(left: 3, right: 3),
|
||||||
|
child: Text(desc4, maxLines: 2, style: GoogleFonts.inter(fontSize: 10, color: Colors.red[800])))
|
||||||
|
],
|
||||||
|
),
|
||||||
|
)),
|
||||||
|
)));
|
||||||
|
}
|
||||||
|
}
|
95
pubspec.lock
95
pubspec.lock
@ -49,14 +49,14 @@ packages:
|
|||||||
name: badges
|
name: badges
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.1.4"
|
version: "1.1.6"
|
||||||
bloc:
|
bloc:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: bloc
|
name: bloc
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "6.1.0"
|
version: "6.1.1"
|
||||||
bloc_test:
|
bloc_test:
|
||||||
dependency: "direct dev"
|
dependency: "direct dev"
|
||||||
description:
|
description:
|
||||||
@ -77,14 +77,14 @@ packages:
|
|||||||
name: build
|
name: build
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.5.1"
|
version: "1.6.0"
|
||||||
build_config:
|
build_config:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: build_config
|
name: build_config
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.4.3"
|
version: "0.4.5"
|
||||||
build_daemon:
|
build_daemon:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -98,21 +98,21 @@ packages:
|
|||||||
name: build_resolvers
|
name: build_resolvers
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.4.3"
|
version: "1.5.1"
|
||||||
build_runner:
|
build_runner:
|
||||||
dependency: "direct dev"
|
dependency: "direct dev"
|
||||||
description:
|
description:
|
||||||
name: build_runner
|
name: build_runner
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.10.6"
|
version: "1.10.11"
|
||||||
build_runner_core:
|
build_runner_core:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: build_runner_core
|
name: build_runner_core
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "6.1.1"
|
version: "6.1.5"
|
||||||
built_collection:
|
built_collection:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -147,7 +147,7 @@ packages:
|
|||||||
name: checked_yaml
|
name: checked_yaml
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.0.2"
|
version: "1.0.4"
|
||||||
cli_util:
|
cli_util:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -266,35 +266,35 @@ packages:
|
|||||||
name: file
|
name: file
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "6.0.0-nullsafety.2"
|
version: "5.2.1"
|
||||||
firebase_auth:
|
firebase_auth:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: firebase_auth
|
name: firebase_auth
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.18.3+1"
|
version: "0.18.4+1"
|
||||||
firebase_auth_platform_interface:
|
firebase_auth_platform_interface:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: firebase_auth_platform_interface
|
name: firebase_auth_platform_interface
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.3"
|
version: "2.1.4"
|
||||||
firebase_auth_web:
|
firebase_auth_web:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: firebase_auth_web
|
name: firebase_auth_web
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.3.2+1"
|
version: "0.3.2+3"
|
||||||
firebase_core:
|
firebase_core:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: firebase_core
|
name: firebase_core
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.5.2+1"
|
version: "0.5.3"
|
||||||
firebase_core_platform_interface:
|
firebase_core_platform_interface:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -329,7 +329,7 @@ packages:
|
|||||||
name: fl_chart
|
name: fl_chart
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.12.0"
|
version: "0.12.1"
|
||||||
flurry:
|
flurry:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@ -349,11 +349,6 @@ packages:
|
|||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "6.1.1"
|
version: "6.1.1"
|
||||||
flutter_driver:
|
|
||||||
dependency: "direct dev"
|
|
||||||
description: flutter
|
|
||||||
source: sdk
|
|
||||||
version: "0.0.0"
|
|
||||||
flutter_form_bloc:
|
flutter_form_bloc:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@ -361,6 +356,13 @@ packages:
|
|||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.19.0"
|
version: "0.19.0"
|
||||||
|
flutter_inapp_purchase:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: flutter_inapp_purchase
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "3.0.1"
|
||||||
flutter_keyboard_visibility:
|
flutter_keyboard_visibility:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -381,7 +383,7 @@ packages:
|
|||||||
source: sdk
|
source: sdk
|
||||||
version: "0.0.0"
|
version: "0.0.0"
|
||||||
flutter_test:
|
flutter_test:
|
||||||
dependency: transitive
|
dependency: "direct dev"
|
||||||
description: flutter
|
description: flutter
|
||||||
source: sdk
|
source: sdk
|
||||||
version: "0.0.0"
|
version: "0.0.0"
|
||||||
@ -403,7 +405,7 @@ packages:
|
|||||||
name: freezed
|
name: freezed
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.12.3"
|
version: "0.12.6"
|
||||||
freezed_annotation:
|
freezed_annotation:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -411,11 +413,6 @@ packages:
|
|||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.12.0"
|
version: "0.12.0"
|
||||||
fuchsia_remote_debug_protocol:
|
|
||||||
dependency: transitive
|
|
||||||
description: flutter
|
|
||||||
source: sdk
|
|
||||||
version: "0.0.0"
|
|
||||||
glob:
|
glob:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -514,13 +511,6 @@ packages:
|
|||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "3.1.1"
|
version: "3.1.1"
|
||||||
json_rpc_2:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: json_rpc_2
|
|
||||||
url: "https://pub.dartlang.org"
|
|
||||||
source: hosted
|
|
||||||
version: "2.2.2"
|
|
||||||
keyboard_actions:
|
keyboard_actions:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@ -583,7 +573,7 @@ packages:
|
|||||||
name: node_io
|
name: node_io
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.1.1"
|
version: "1.2.0"
|
||||||
node_preamble:
|
node_preamble:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -667,7 +657,7 @@ packages:
|
|||||||
name: percent_indicator
|
name: percent_indicator
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.8"
|
version: "2.1.9"
|
||||||
petitparser:
|
petitparser:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -681,7 +671,7 @@ packages:
|
|||||||
name: platform
|
name: platform
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "3.0.0-nullsafety.2"
|
version: "2.2.1"
|
||||||
plugin_platform_interface:
|
plugin_platform_interface:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -702,14 +692,14 @@ packages:
|
|||||||
name: process
|
name: process
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "4.0.0-nullsafety.2"
|
version: "3.0.13"
|
||||||
provider:
|
provider:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: provider
|
name: provider
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "4.3.2+2"
|
version: "4.3.2+3"
|
||||||
pub_semver:
|
pub_semver:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -723,7 +713,7 @@ packages:
|
|||||||
name: pubspec_parse
|
name: pubspec_parse
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.1.5"
|
version: "0.1.7"
|
||||||
quiver:
|
quiver:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -821,7 +811,7 @@ packages:
|
|||||||
name: shelf_static
|
name: shelf_static
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.2.8"
|
version: "0.2.9+1"
|
||||||
shelf_web_socket:
|
shelf_web_socket:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -840,7 +830,7 @@ packages:
|
|||||||
name: source_gen
|
name: source_gen
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.9.8"
|
version: "0.9.10+1"
|
||||||
source_map_stack_trace:
|
source_map_stack_trace:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -918,13 +908,6 @@ packages:
|
|||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.1.0-nullsafety.1"
|
version: "1.1.0-nullsafety.1"
|
||||||
sync_http:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: sync_http
|
|
||||||
url: "https://pub.dartlang.org"
|
|
||||||
source: hosted
|
|
||||||
version: "0.2.0"
|
|
||||||
synchronized:
|
synchronized:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -966,7 +949,7 @@ packages:
|
|||||||
name: timing
|
name: timing
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.1.1+2"
|
version: "0.1.1+3"
|
||||||
toggle_switch:
|
toggle_switch:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@ -1009,13 +992,6 @@ packages:
|
|||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "5.5.0"
|
version: "5.5.0"
|
||||||
vm_service_client:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: vm_service_client
|
|
||||||
url: "https://pub.dartlang.org"
|
|
||||||
source: hosted
|
|
||||||
version: "0.2.6+2"
|
|
||||||
watcher:
|
watcher:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -1030,13 +1006,6 @@ packages:
|
|||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.1.0"
|
version: "1.1.0"
|
||||||
webdriver:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: webdriver
|
|
||||||
url: "https://pub.dartlang.org"
|
|
||||||
source: hosted
|
|
||||||
version: "2.1.2"
|
|
||||||
webkit_inspection_protocol:
|
webkit_inspection_protocol:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
16
pubspec.yaml
16
pubspec.yaml
@ -15,10 +15,10 @@ 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.
|
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
|
||||||
# Read more about iOS versioning at
|
# Read more about iOS versioning at
|
||||||
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
||||||
version: 1.1.2+39
|
version: 1.1.2+40
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ">=2.10.0 <3.0.0"
|
sdk: ">=2.7.0 <3.0.0"
|
||||||
|
|
||||||
dependencies:
|
dependencies:
|
||||||
flutter:
|
flutter:
|
||||||
@ -45,6 +45,7 @@ dependencies:
|
|||||||
health: ^2.0.9
|
health: ^2.0.9
|
||||||
stop_watch_timer: ^0.6.0+1
|
stop_watch_timer: ^0.6.0+1
|
||||||
#geolocator: ^6.1.13
|
#geolocator: ^6.1.13
|
||||||
|
flutter_inapp_purchase: ^3.0.1
|
||||||
|
|
||||||
|
|
||||||
firebase_core: ^0.5.2
|
firebase_core: ^0.5.2
|
||||||
@ -62,10 +63,13 @@ dependencies:
|
|||||||
flutter_localizations:
|
flutter_localizations:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
|
|
||||||
|
#dependency_overrides:
|
||||||
|
# flutter_driver:
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_driver:
|
test: '>=1.0.0 <2.0.0'
|
||||||
|
flutter_test:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
test: any
|
|
||||||
bloc_test: ^7.1.0
|
bloc_test: ^7.1.0
|
||||||
|
|
||||||
build_runner:
|
build_runner:
|
||||||
@ -109,12 +113,16 @@ flutter:
|
|||||||
- asset/image/WT01_loading_layers.png
|
- asset/image/WT01_loading_layers.png
|
||||||
- asset/image/WT_menu_backround.png
|
- asset/image/WT_menu_backround.png
|
||||||
- asset/image/WT_black_background.png
|
- asset/image/WT_black_background.png
|
||||||
|
- asset/image/WT_black_G_background.png
|
||||||
|
- asset/image/WT_plainblack_background.png
|
||||||
- asset/image/WT_menu.png
|
- asset/image/WT_menu.png
|
||||||
- asset/image/WT_login.png
|
- asset/image/WT_login.png
|
||||||
- asset/image/WT_OK.png
|
- asset/image/WT_OK.png
|
||||||
- asset/image/dots.gif
|
- asset/image/dots.gif
|
||||||
- asset/image/WT_long_logo.png
|
- asset/image/WT_long_logo.png
|
||||||
- asset/image/WT_light_background.png
|
- asset/image/WT_light_background.png
|
||||||
|
- asset/image/WT_sales_background.png
|
||||||
|
- asset/image/WT_sales_background_3x5.png
|
||||||
- asset/image/WT_menu_dark.png
|
- asset/image/WT_menu_dark.png
|
||||||
- asset/image/Gain_muscle.png
|
- asset/image/Gain_muscle.png
|
||||||
- asset/image/WT_weight_loss.png
|
- asset/image/WT_weight_loss.png
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
import 'package:flutter_driver/driver_extension.dart';
|
//import 'package:flutter_driver/driver_extension.dart';
|
||||||
import 'package:aitrainer_app/main.dart' as app;
|
import 'package:aitrainer_app/main.dart' as app;
|
||||||
|
|
||||||
void main() {
|
/* void main() {
|
||||||
// This line enables the extension.
|
// This line enables the extension.
|
||||||
enableFlutterDriverExtension();
|
enableFlutterDriverExtension();
|
||||||
|
|
||||||
// Call the `main()` function of the app, or call `runApp` with
|
// Call the `main()` function of the app, or call `runApp` with
|
||||||
// any widget you are interested in testing.
|
// any widget you are interested in testing.
|
||||||
app.main();
|
app.main();
|
||||||
}
|
} */
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
// Imports the Flutter Driver API.
|
// Imports the Flutter Driver API.
|
||||||
import 'package:flutter_driver/flutter_driver.dart';
|
//import 'package:flutter_driver/flutter_driver.dart';
|
||||||
import 'package:test/test.dart';
|
import 'package:test/test.dart';
|
||||||
|
|
||||||
import '../lib/helper/database.dart';
|
import '../lib/helper/database.dart';
|
||||||
|
/*
|
||||||
void main() {
|
void main() {
|
||||||
FlutterDriver driver;
|
FlutterDriver driver;
|
||||||
group('Login App', () {
|
group('Login App', () {
|
||||||
@ -18,3 +18,4 @@ void main() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user