WT 1.1.18+4 A/B Test sales page
This commit is contained in:
@@ -1,59 +0,0 @@
|
||||
import 'dart:async';
|
||||
import 'package:aitrainer_app/model/exercise_type.dart';
|
||||
import 'package:aitrainer_app/model/workout_menu_tree.dart';
|
||||
import 'package:aitrainer_app/repository/exercise_plan_repository.dart';
|
||||
import 'package:aitrainer_app/repository/workout_tree_repository.dart';
|
||||
import 'package:bloc/bloc.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
|
||||
part 'exercise_execute_plan_event.dart';
|
||||
|
||||
part 'exercise_execute_plan_state.dart';
|
||||
|
||||
class ExerciseExecutePlanBloc extends Bloc<ExerciseExecutePlanEvent, ExerciseExecutePlanState> {
|
||||
final WorkoutTreeRepository menuTreeRepository;
|
||||
final ExercisePlanRepository exercisePlanRepository = ExercisePlanRepository();
|
||||
int? customerId;
|
||||
int selectedNumber = 0;
|
||||
|
||||
@override
|
||||
ExerciseExecutePlanBloc({required this.menuTreeRepository}) : super(ExerciseByPlanStateInitial());
|
||||
|
||||
Future<void> getData() async {
|
||||
exercisePlanRepository.setCustomerId(customerId!);
|
||||
await exercisePlanRepository.getLastExercisePlan();
|
||||
await exercisePlanRepository.getExercisePlanDetails();
|
||||
menuTreeRepository.sortedTree.clear();
|
||||
menuTreeRepository.sortByMuscleType();
|
||||
|
||||
menuTreeRepository.sortedTree.forEach((key, value) {
|
||||
List<WorkoutMenuTree> listWorkoutTree = value;
|
||||
listWorkoutTree.forEach((workoutTree) {
|
||||
workoutTree.selected = false;
|
||||
if (exercisePlanRepository.getExercisePlanDetailSize() > 0) {
|
||||
if (exercisePlanRepository.getExercisePlanDetailByExerciseId(workoutTree.exerciseTypeId) != null) {
|
||||
workoutTree.selected = true;
|
||||
this.selectedNumber++;
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Stream<ExerciseExecutePlanState> mapEventToState(ExerciseExecutePlanEvent event) async* {
|
||||
try {
|
||||
if (event is ExerciseByPlanLoad) {
|
||||
yield ExerciseByPlanLoading();
|
||||
await this.getData();
|
||||
yield ExerciseByPlanReady();
|
||||
} else if (event is AddExerciseByPlanEvent) {
|
||||
yield ExerciseByPlanLoading();
|
||||
yield ExerciseByPlanReady();
|
||||
}
|
||||
} on Exception catch (e) {
|
||||
yield ExerciseByPlanError(message: e.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
part of 'exercise_execute_plan_bloc.dart';
|
||||
|
||||
@immutable
|
||||
abstract class ExerciseExecutePlanEvent extends Equatable {
|
||||
const ExerciseExecutePlanEvent();
|
||||
|
||||
@override
|
||||
List<Object> get props => [];
|
||||
}
|
||||
|
||||
class AddExerciseByPlanEvent extends ExerciseExecutePlanEvent {
|
||||
final ExerciseType exerciseType;
|
||||
const AddExerciseByPlanEvent({required this.exerciseType});
|
||||
|
||||
@override
|
||||
List<Object> get props => [exerciseType];
|
||||
}
|
||||
|
||||
class ExerciseByPlanLoad extends ExerciseExecutePlanEvent {
|
||||
const ExerciseByPlanLoad();
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
part of 'exercise_execute_plan_bloc.dart';
|
||||
|
||||
@immutable
|
||||
abstract class ExerciseExecutePlanState extends Equatable {
|
||||
const ExerciseExecutePlanState();
|
||||
|
||||
@override
|
||||
List<Object> get props => [];
|
||||
}
|
||||
|
||||
class ExerciseByPlanStateInitial extends ExerciseExecutePlanState {
|
||||
const ExerciseByPlanStateInitial();
|
||||
}
|
||||
|
||||
class ExerciseByPlanLoading extends ExerciseExecutePlanState {
|
||||
const ExerciseByPlanLoading();
|
||||
}
|
||||
|
||||
// updated screen
|
||||
class ExerciseByPlanReady extends ExerciseExecutePlanState {
|
||||
const ExerciseByPlanReady();
|
||||
}
|
||||
|
||||
// error splash screen
|
||||
class ExerciseByPlanError extends ExerciseExecutePlanState {
|
||||
final String message;
|
||||
const ExerciseByPlanError({required this.message});
|
||||
|
||||
@override
|
||||
List<Object> get props => [message];
|
||||
}
|
||||
@@ -1,99 +0,0 @@
|
||||
import 'dart:async';
|
||||
import 'package:aitrainer_app/bloc/exercise_execute_plan/exercise_execute_plan_bloc.dart';
|
||||
import 'package:aitrainer_app/model/cache.dart';
|
||||
import 'package:aitrainer_app/model/customer.dart';
|
||||
import 'package:aitrainer_app/model/workout_menu_tree.dart';
|
||||
import 'package:aitrainer_app/repository/exercise_plan_repository.dart';
|
||||
import 'package:aitrainer_app/repository/exercise_repository.dart';
|
||||
import 'package:aitrainer_app/util/enums.dart';
|
||||
import 'package:aitrainer_app/util/track.dart';
|
||||
import 'package:bloc/bloc.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
|
||||
part 'exercise_execute_plan_add_event.dart';
|
||||
|
||||
part 'exercise_execute_plan_add_state.dart';
|
||||
|
||||
class ExerciseExecutePlanAddBloc extends Bloc<ExerciseExecutePlanAddEvent, ExerciseExecutePlanAddState> {
|
||||
final ExerciseRepository exerciseRepository;
|
||||
final ExercisePlanRepository exercisePlanRepository;
|
||||
final WorkoutMenuTree workoutTree;
|
||||
final ExerciseExecutePlanBloc planBloc;
|
||||
final int customerId;
|
||||
|
||||
late Customer customer;
|
||||
int step = 1;
|
||||
int countSteps = 1;
|
||||
|
||||
double? quantity;
|
||||
double? unitQuantity;
|
||||
|
||||
double scrollOffset = 0;
|
||||
|
||||
@override
|
||||
ExerciseExecutePlanAddBloc(
|
||||
{required this.exerciseRepository,
|
||||
required this.exercisePlanRepository,
|
||||
required this.customerId,
|
||||
required this.workoutTree,
|
||||
required this.planBloc})
|
||||
: super(ExerciseExecutePlanAddInitial());
|
||||
|
||||
void init() {
|
||||
exerciseRepository.exerciseType = workoutTree.exerciseType;
|
||||
if (Cache().userLoggedIn!.customerId == customerId) {
|
||||
customer = Cache().userLoggedIn!;
|
||||
} else if (Cache().getTrainee()!.customerId == customerId) {
|
||||
customer = Cache().getTrainee()!;
|
||||
}
|
||||
exercisePlanRepository.setActualPlanDetailByExerciseType(workoutTree.exerciseType!);
|
||||
exerciseRepository.customer = customer;
|
||||
countSteps = exercisePlanRepository.getActualPlanDetail()!.serie!;
|
||||
if (exercisePlanRepository.getActualPlanDetail()!.weightEquation == null) {
|
||||
unitQuantity = 0.0;
|
||||
} else {
|
||||
unitQuantity = double.parse(exercisePlanRepository.getActualPlanDetail()!.weightEquation!);
|
||||
}
|
||||
quantity = exercisePlanRepository.getActualPlanDetail()!.repeats!.toDouble();
|
||||
|
||||
exerciseRepository.setQuantity(quantity!);
|
||||
exerciseRepository.setUnitQuantity(unitQuantity!);
|
||||
}
|
||||
|
||||
@override
|
||||
Stream<ExerciseExecutePlanAddState> mapEventToState(ExerciseExecutePlanAddEvent event) async* {
|
||||
try {
|
||||
if (event is ExerciseExecutePlanAddLoad) {
|
||||
yield ExerciseExecutePlanAddLoading();
|
||||
init();
|
||||
Track().track(TrackingEvent.my_exercise_plan_execute_open);
|
||||
yield ExerciseExecutePlanAddReady();
|
||||
} else if (event is ExerciseExecutePlanAddChangeQuantity) {
|
||||
yield ExerciseExecutePlanAddLoading();
|
||||
quantity = event.quantity;
|
||||
exerciseRepository.setQuantity(quantity!);
|
||||
yield ExerciseExecutePlanAddReady();
|
||||
} else if (event is ExerciseExecutePlanAddChangeUnitQuantity) {
|
||||
yield ExerciseExecutePlanAddLoading();
|
||||
unitQuantity = event.quantity;
|
||||
exerciseRepository.setUnitQuantity(unitQuantity!);
|
||||
yield ExerciseExecutePlanAddReady();
|
||||
} else if (event is ExerciseExecutePlanAddSubmit) {
|
||||
yield ExerciseExecutePlanAddLoading();
|
||||
exerciseRepository.exercise!.exercisePlanDetailId = exercisePlanRepository.getActualPlanDetail()!.exercisePlanDetailId;
|
||||
exerciseRepository.exercise!.unit = workoutTree.exerciseType!.unit;
|
||||
workoutTree.executed = true;
|
||||
await exerciseRepository.addExercise();
|
||||
exerciseRepository.initExercise();
|
||||
Track().track(TrackingEvent.my_exercise_plan_execute_save);
|
||||
step++;
|
||||
scrollOffset = step * 200.0;
|
||||
planBloc.add(ExerciseByPlanLoad());
|
||||
yield ExerciseExecutePlanAddReady();
|
||||
}
|
||||
} on Exception catch (e) {
|
||||
yield ExerciseExecutePlanAddError(message: e.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
part of 'exercise_execute_plan_add_bloc.dart';
|
||||
|
||||
@immutable
|
||||
abstract class ExerciseExecutePlanAddEvent extends Equatable {
|
||||
const ExerciseExecutePlanAddEvent();
|
||||
|
||||
@override
|
||||
List<Object> get props => [];
|
||||
}
|
||||
|
||||
class ExerciseExecutePlanAddLoad extends ExerciseExecutePlanAddEvent {
|
||||
const ExerciseExecutePlanAddLoad();
|
||||
}
|
||||
|
||||
class ExerciseExecutePlanAddChangeQuantity extends ExerciseExecutePlanAddEvent {
|
||||
final double quantity;
|
||||
const ExerciseExecutePlanAddChangeQuantity({required this.quantity});
|
||||
|
||||
@override
|
||||
List<Object> get props => [quantity];
|
||||
}
|
||||
|
||||
class ExerciseExecutePlanAddChangeUnitQuantity extends ExerciseExecutePlanAddEvent {
|
||||
final double quantity;
|
||||
const ExerciseExecutePlanAddChangeUnitQuantity({required this.quantity});
|
||||
|
||||
@override
|
||||
List<Object> get props => [quantity];
|
||||
}
|
||||
|
||||
class ExerciseExecutePlanAddSubmit extends ExerciseExecutePlanAddEvent {
|
||||
const ExerciseExecutePlanAddSubmit();
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
part of 'exercise_execute_plan_add_bloc.dart';
|
||||
|
||||
@immutable
|
||||
abstract class ExerciseExecutePlanAddState extends Equatable {
|
||||
const ExerciseExecutePlanAddState();
|
||||
|
||||
@override
|
||||
List<Object> get props => [];
|
||||
}
|
||||
|
||||
class ExerciseExecutePlanAddInitial extends ExerciseExecutePlanAddState {
|
||||
const ExerciseExecutePlanAddInitial();
|
||||
}
|
||||
|
||||
class ExerciseExecutePlanAddLoading extends ExerciseExecutePlanAddState {
|
||||
const ExerciseExecutePlanAddLoading();
|
||||
}
|
||||
|
||||
// updated screen
|
||||
class ExerciseExecutePlanAddReady extends ExerciseExecutePlanAddState {
|
||||
const ExerciseExecutePlanAddReady();
|
||||
}
|
||||
|
||||
// error splash screen
|
||||
class ExerciseExecutePlanAddError extends ExerciseExecutePlanAddState {
|
||||
final String message;
|
||||
const ExerciseExecutePlanAddError({required this.message});
|
||||
|
||||
@override
|
||||
List<Object> get props => [message];
|
||||
}
|
||||
@@ -3,6 +3,7 @@ import 'dart:async';
|
||||
import 'package:aitrainer_app/bloc/account/account_bloc.dart';
|
||||
import 'package:aitrainer_app/model/cache.dart';
|
||||
import 'package:aitrainer_app/repository/customer_repository.dart';
|
||||
import 'package:aitrainer_app/repository/split_test_respository.dart';
|
||||
import 'package:aitrainer_app/repository/user_repository.dart';
|
||||
import 'package:aitrainer_app/util/common.dart';
|
||||
import 'package:aitrainer_app/util/enums.dart';
|
||||
@@ -19,14 +20,27 @@ class LoginBloc extends Bloc<LoginEvent, LoginState> with Trans {
|
||||
final AccountBloc accountBloc;
|
||||
final UserRepository userRepository;
|
||||
final CustomerRepository customerRepository = CustomerRepository();
|
||||
final SplitTestRepository splitTestRepository = SplitTestRepository();
|
||||
final BuildContext context;
|
||||
final bool isRegistration;
|
||||
bool dataPolicyAllowed = false;
|
||||
bool emailSubscription = false;
|
||||
bool obscure = true;
|
||||
|
||||
Color testColor = Colors.green[800]!;
|
||||
bool emailCheckbox = true;
|
||||
|
||||
LoginBloc({required this.accountBloc, required this.userRepository, required this.context, required this.isRegistration})
|
||||
: super(LoginInitial());
|
||||
: super(LoginInitial()) {
|
||||
String colorString = splitTestRepository.getSplitTestValue("registration_skip");
|
||||
if (colorString == "red") {
|
||||
testColor = Colors.red[800]!;
|
||||
}
|
||||
String emailCheckboxString = splitTestRepository.getSplitTestValue("email_checkbox");
|
||||
if (emailCheckboxString == "0") {
|
||||
emailCheckbox = false;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Stream<LoginState> mapEventToState(
|
||||
|
||||
@@ -66,7 +66,7 @@ class MenuBloc extends Bloc<MenuEvent, MenuState> with Trans, Logging {
|
||||
workoutItem = event.item;
|
||||
|
||||
if (workoutItem != null) {
|
||||
setAbility(workoutItem!.nameEnglish);
|
||||
setAbility(workoutItem!.internalName);
|
||||
}
|
||||
final LinkedHashMap<String, WorkoutMenuTree> branch = menuTreeRepository.getBranch(event.parent);
|
||||
|
||||
@@ -80,7 +80,7 @@ class MenuBloc extends Bloc<MenuEvent, MenuState> with Trans, Logging {
|
||||
|
||||
LinkedHashMap<String, WorkoutMenuTree> branch;
|
||||
if (workoutItem != null) {
|
||||
setAbility(workoutItem!.nameEnglish);
|
||||
setAbility(workoutItem!.internalName);
|
||||
branch = menuTreeRepository.getBranch(workoutItem!.parent);
|
||||
await getImages(branch);
|
||||
}
|
||||
@@ -92,7 +92,7 @@ class MenuBloc extends Bloc<MenuEvent, MenuState> with Trans, Logging {
|
||||
workoutItem = menuTreeRepository.getParentItem(parent);
|
||||
|
||||
if (workoutItem != null) {
|
||||
setAbility(workoutItem!.nameEnglish);
|
||||
setAbility(workoutItem!.internalName);
|
||||
}
|
||||
final LinkedHashMap<String, WorkoutMenuTree> branch = menuTreeRepository.getBranch(workoutItem!.parent);
|
||||
await getImages(branch);
|
||||
@@ -119,22 +119,19 @@ class MenuBloc extends Bloc<MenuEvent, MenuState> with Trans, Logging {
|
||||
|
||||
void setAbility(String name) {
|
||||
switch (name) {
|
||||
case "Muscle Build / Shape Toning":
|
||||
case "one_rep_max":
|
||||
ability = ExerciseAbility.oneRepMax;
|
||||
break;
|
||||
case "Endurance":
|
||||
ability = ExerciseAbility.endurance;
|
||||
break;
|
||||
case "Cardio":
|
||||
case "cardio":
|
||||
ability = ExerciseAbility.running;
|
||||
break;
|
||||
case "Test Center":
|
||||
case "test_center":
|
||||
ability = ExerciseAbility.mini_test_set;
|
||||
break;
|
||||
case "Training Plans":
|
||||
case "training_plans":
|
||||
ability = ExerciseAbility.training;
|
||||
break;
|
||||
case "My Body":
|
||||
case "my_body":
|
||||
ability = ExerciseAbility.none;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
import 'dart:math' as 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/model/purchase.dart';
|
||||
import 'package:aitrainer_app/repository/description_repository.dart';
|
||||
import 'package:aitrainer_app/repository/split_test_respository.dart';
|
||||
import 'package:aitrainer_app/service/logging.dart';
|
||||
import 'package:aitrainer_app/service/purchase_service.dart';
|
||||
import 'package:aitrainer_app/util/enums.dart';
|
||||
@@ -14,37 +13,43 @@ import 'package:aitrainer_app/util/purchases.dart';
|
||||
import 'package:aitrainer_app/util/track.dart';
|
||||
import 'package:bloc/bloc.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:firebase_remote_config/firebase_remote_config.dart';
|
||||
import 'package:purchases_flutter/offering_wrapper.dart';
|
||||
|
||||
part 'sales_event.dart';
|
||||
part 'sales_state.dart';
|
||||
|
||||
class SalesBloc extends Bloc<SalesEvent, SalesState> with Logging {
|
||||
List<ProductTest>? tests = [];
|
||||
List<Product> product2Display = [];
|
||||
List<String> productText2Display = ["WorkoutTest annual", "WorkoutTest montly"];
|
||||
final SplitTestRepository splitTestRepository = SplitTestRepository();
|
||||
|
||||
int productSet = -1;
|
||||
final DescriptionRepository descriptionRepository = DescriptionRepository();
|
||||
SalesBloc() : super(SalesInitial());
|
||||
|
||||
String? salesText;
|
||||
String? premiumFunctions = "";
|
||||
|
||||
String salesButtonText = "<h1>Workout Test Monthly</h1><p>localizedPrice</p><p><small>cancel any time</small></p>";
|
||||
Product? offeredProduct;
|
||||
|
||||
Product? getProductByName(String name) {
|
||||
Product? product;
|
||||
if (product2Display.isNotEmpty) {
|
||||
product2Display.forEach((element) {
|
||||
if (element.type == name) {
|
||||
product = element;
|
||||
salesButtonText = salesButtonText.replaceFirst(RegExp(r'localizedPrice'), product!.localizedPrice!);
|
||||
print("Localized Price ${product!.localizedPrice!} - Text: $salesButtonText");
|
||||
}
|
||||
});
|
||||
void init() async {
|
||||
if (Cache().userLoggedIn == null) {
|
||||
throw Exception("Please log in");
|
||||
}
|
||||
|
||||
return product;
|
||||
salesText = splitTestRepository.getSplitTestValue("sales_page_text_a");
|
||||
if (salesText == null || salesText!.isEmpty) {
|
||||
salesText = descriptionRepository.getDescriptionByName("sales_page_text_a");
|
||||
}
|
||||
print("sales Text: $salesText");
|
||||
getProductsTexts();
|
||||
|
||||
premiumFunctions = descriptionRepository.getDescriptionByName("premium_functions");
|
||||
if (premiumFunctions == null || premiumFunctions!.isEmpty) {
|
||||
premiumFunctions = "";
|
||||
}
|
||||
|
||||
await RevenueCatPurchases().getOfferings();
|
||||
this.getProductSet();
|
||||
Track().track(TrackingEvent.sales_page);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -53,33 +58,11 @@ class SalesBloc extends Bloc<SalesEvent, SalesState> with Logging {
|
||||
) async* {
|
||||
try {
|
||||
if (event is SalesLoad) {
|
||||
log(" -- start SalesLoad");
|
||||
yield SalesLoading();
|
||||
log("Load Sales");
|
||||
if (Cache().userLoggedIn == null) {
|
||||
throw Exception("Please log in");
|
||||
}
|
||||
|
||||
String descriptionName = "sales_page_text";
|
||||
RemoteConfig? remoteConfig = Cache().remoteConfig;
|
||||
if (remoteConfig != null) {
|
||||
remoteConfig.fetchAndActivate();
|
||||
Map config = remoteConfig.getAll();
|
||||
RemoteConfigValue? value = config['sales_page_text_a'];
|
||||
if (value != null) {
|
||||
log("RemoteConfig sales_page_text value: ${value.asString()}");
|
||||
if (value.asString() == "1") {
|
||||
descriptionName = "sales_page_text_a";
|
||||
}
|
||||
}
|
||||
}
|
||||
await RevenueCatPurchases().getOfferings();
|
||||
this.getProductSet();
|
||||
salesText = descriptionRepository.getDescriptionByName(descriptionName);
|
||||
log(salesText!);
|
||||
salesButtonText = descriptionRepository.getDescriptionByName("sales_button_monthly");
|
||||
offeredProduct = getProductByName("wt_sub_2_3");
|
||||
Track().track(TrackingEvent.sales_page);
|
||||
init();
|
||||
yield SalesReady();
|
||||
log(" -- finish SalesLoad");
|
||||
} else if (event is SalesPurchase) {
|
||||
if (Cache().hasPurchased) {
|
||||
throw Exception("You have already a successfull subscription");
|
||||
@@ -104,28 +87,34 @@ class SalesBloc extends Bloc<SalesEvent, SalesState> with Logging {
|
||||
} else {
|
||||
yield SalesError(message: "No selected product");
|
||||
}
|
||||
} else if (event is SalesChangeSubscription) {
|
||||
yield SalesLoading();
|
||||
print("offered product .. $offeredProduct");
|
||||
if (offeredProduct != null) {
|
||||
if (offeredProduct!.type == "wt_sub_2_3") {
|
||||
print("go yearly");
|
||||
salesButtonText = descriptionRepository.getDescriptionByName("sales_button_yearly");
|
||||
offeredProduct = getProductByName("wt_sub_2_1");
|
||||
} else {
|
||||
print("go monthly");
|
||||
salesButtonText = descriptionRepository.getDescriptionByName("sales_button_monthly");
|
||||
offeredProduct = getProductByName("wt_sub_2_3");
|
||||
}
|
||||
}
|
||||
|
||||
yield SalesReady();
|
||||
}
|
||||
} on Exception catch (ex) {
|
||||
yield SalesError(message: ex.toString());
|
||||
}
|
||||
}
|
||||
|
||||
void getProductsTexts() {
|
||||
Product product;
|
||||
if (product2Display.isNotEmpty) {
|
||||
String salesButtonText;
|
||||
product2Display.forEach((element) {
|
||||
product = element;
|
||||
if (product.sort == 3) {
|
||||
salesButtonText = descriptionRepository.getDescriptionByName("sales_button_monthly");
|
||||
productText2Display[1] = salesButtonText.replaceFirst(RegExp(r'localizedPrice'), product.localizedPrice!);
|
||||
} else if (product.sort == 1) {
|
||||
salesButtonText = descriptionRepository.getDescriptionByName("sales_button_yearly");
|
||||
productText2Display[0] = salesButtonText.replaceFirst(RegExp(r'localizedPrice'), product.localizedPrice!);
|
||||
}
|
||||
});
|
||||
}
|
||||
print("product Text $productText2Display");
|
||||
|
||||
splitTestRepository.getSplitTestValue("product_set_2");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
Product? getSelectedProduct(int productId) {
|
||||
Product? prod;
|
||||
for (var product in this.product2Display) {
|
||||
@@ -161,38 +150,37 @@ class SalesBloc extends Bloc<SalesEvent, SalesState> with Logging {
|
||||
}
|
||||
|
||||
void getProductSet() {
|
||||
int productId = 0;
|
||||
//this.tests = Cache().productTests;
|
||||
List<Product>? products = Cache().products;
|
||||
if (products == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* if (tests != null && tests!.isEmpty) {
|
||||
var rand = math.Random.secure();
|
||||
productSet = rand.nextInt(5) + 1;
|
||||
} else {
|
||||
trace("Previous ProductTest: " + tests![0].toJson().toString());
|
||||
productId = tests![0].productId;
|
||||
for (var elem in products) {
|
||||
final Product product = elem;
|
||||
if (product.productId == productId) {
|
||||
productSet = product.productSet;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} */
|
||||
String productSetString = splitTestRepository.getSplitTestValue("product_set_2");
|
||||
log("ProductSetString: $productSetString");
|
||||
try {
|
||||
productSet = int.parse(productSetString);
|
||||
} on Exception catch (e) {
|
||||
log("Define the right productset!");
|
||||
productSet = 2;
|
||||
}
|
||||
|
||||
//ProductTest productTest = ProductTest();
|
||||
log("ProductSet: $productSet");
|
||||
|
||||
productSet = 2;
|
||||
log("ProductSet: " + productSet.toString());
|
||||
for (var elem in products) {
|
||||
Product product = elem;
|
||||
|
||||
if (product.productSet == productSet) {
|
||||
productId = product.productId;
|
||||
final String platformProductId = Platform.isAndroid ? product.productIdAndroid! : product.productIdIos!;
|
||||
String? platformProductId;
|
||||
if (product.productIdAndroid == null || product.productIdIos == null) {
|
||||
log("Define the product ID for the different Platforms!!");
|
||||
} else {
|
||||
platformProductId = Platform.isAndroid ? product.productIdAndroid! : product.productIdIos!;
|
||||
}
|
||||
|
||||
if (platformProductId == null) {
|
||||
log("Not defined platform product id!!");
|
||||
platformProductId = "";
|
||||
}
|
||||
product.localizedPrice = getLocalizedPrice(platformProductId, product);
|
||||
log("product with localized price: $product");
|
||||
product2Display.add(product);
|
||||
@@ -203,10 +191,6 @@ class SalesBloc extends Bloc<SalesEvent, SalesState> with Logging {
|
||||
return a.sort < b.sort ? -1 : 1;
|
||||
});
|
||||
|
||||
//productTest.productId = productId;
|
||||
//productTest.customerId = Cache().userLoggedIn!.customerId!;
|
||||
//productTest.dateView = DateTime.now();
|
||||
//ProductTestApi().saveProductTest(productTest);
|
||||
//Cache().productTests.add(productTest);
|
||||
this.getProductsTexts();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,11 +92,16 @@ class TrainingPlanBloc extends Bloc<TrainingPlanEvent, TrainingPlanState> {
|
||||
event.detail.state = ExercisePlanDetailState.inProgress;
|
||||
}
|
||||
|
||||
// recalculate the weight to the original planned repeats
|
||||
if (event.detail.isTest && event.detail.exercises.length == 1) {
|
||||
trainingPlanRepository.recalculateDetail(_myPlan!.trainingPlanId!, event.detail);
|
||||
}
|
||||
|
||||
exercise.trainingPlanDetailsId = _myPlan!.trainingPlanId;
|
||||
|
||||
// save Exercise
|
||||
await ExerciseApi().addExercise(exercise);
|
||||
Cache().addExercise(exercise);
|
||||
Exercise savedExercise = await ExerciseApi().addExercise(exercise);
|
||||
Cache().addExercise(savedExercise);
|
||||
|
||||
Cache().myTrainingPlan = _myPlan;
|
||||
await Cache().saveMyTrainingPlan();
|
||||
@@ -108,7 +113,6 @@ class TrainingPlanBloc extends Bloc<TrainingPlanEvent, TrainingPlanState> {
|
||||
}
|
||||
} else if (event is TrainingPlanSkipExercise) {
|
||||
yield TrainingPlanLoading();
|
||||
print("Skipping ${event.detail.exerciseTypeId}");
|
||||
event.detail.state = ExercisePlanDetailState.skipped;
|
||||
Cache().myTrainingPlan = _myPlan;
|
||||
await Cache().saveMyTrainingPlan();
|
||||
@@ -378,7 +382,8 @@ class TrainingPlanBloc extends Bloc<TrainingPlanEvent, TrainingPlanState> {
|
||||
return 0;
|
||||
}
|
||||
if (_myPlan == null || _myPlan!.details.isEmpty) {
|
||||
throw Exception("No defined Training Plan");
|
||||
// throw Exception("No defined Training Plan");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (dayNames.isEmpty || dayNames.length == 1) {
|
||||
@@ -402,7 +407,7 @@ class TrainingPlanBloc extends Bloc<TrainingPlanEvent, TrainingPlanState> {
|
||||
}
|
||||
activeDayIndex++;
|
||||
}
|
||||
print("Active Day Index: $activeDayIndex");
|
||||
|
||||
if (activeDayIndex >= dayNames.length) {
|
||||
activeDayIndex = 0;
|
||||
this.add(TrainingPlanGoToRestart());
|
||||
@@ -481,4 +486,17 @@ class TrainingPlanBloc extends Bloc<TrainingPlanEvent, TrainingPlanState> {
|
||||
|
||||
return value.toStringAsFixed(0);
|
||||
}
|
||||
|
||||
bool existsAddedExerciseTypeInTree(String name) {
|
||||
bool exists = false;
|
||||
final List<WorkoutMenuTree>? listWorkoutTree = menuBloc.menuTreeRepository.sortedTree[name];
|
||||
if (listWorkoutTree != null) {
|
||||
listWorkoutTree.forEach((element) {
|
||||
if (element.exerciseType!.trainingPlanState.equalsTo(ExerciseTypeTrainingPlanState.added)) {
|
||||
exists = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
return exists;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user