v1.26.10 login exception handling with bloc 8.0
This commit is contained in:
@@ -88,40 +88,59 @@ class LoginBloc extends Bloc<LoginEvent, LoginState> with Trans {
|
||||
|
||||
void _onSubmit(LoginSubmit event, Emitter<LoginState> emit) async {
|
||||
emit(LoginLoading());
|
||||
await userRepository.getUser();
|
||||
accountBloc.add(AccountLogInFinished(customer: Cache().userLoggedIn!));
|
||||
Track().track(TrackingEvent.login, eventValue: "email");
|
||||
Cache().setLoginType(LoginType.email);
|
||||
|
||||
emit(LoginSuccess());
|
||||
try {
|
||||
await userRepository.getUser();
|
||||
accountBloc.add(AccountLogInFinished(customer: Cache().userLoggedIn!));
|
||||
Track().track(TrackingEvent.login, eventValue: "email");
|
||||
Cache().setLoginType(LoginType.email);
|
||||
} on Exception catch(e) {
|
||||
emit(LoginError(message: e.toString()));
|
||||
} finally {
|
||||
emit(LoginSuccess());
|
||||
}
|
||||
}
|
||||
|
||||
void _onLoginFB(LoginFB event, Emitter<LoginState> emit) async {
|
||||
emit(LoginLoading());
|
||||
Cache().setLoginType(LoginType.fb);
|
||||
await userRepository.getUserByFB();
|
||||
accountBloc.add(AccountLogInFinished(customer: Cache().userLoggedIn!));
|
||||
Track().track(TrackingEvent.login, eventValue: "FB");
|
||||
emit(LoginSuccess());
|
||||
try {
|
||||
Cache().setLoginType(LoginType.fb);
|
||||
await userRepository.getUserByFB();
|
||||
accountBloc.add(AccountLogInFinished(customer: Cache().userLoggedIn!));
|
||||
Track().track(TrackingEvent.login, eventValue: "FB");
|
||||
} on Exception catch(e) {
|
||||
emit(LoginError(message: e.toString()));
|
||||
} finally {
|
||||
emit(LoginSuccess());
|
||||
}
|
||||
}
|
||||
|
||||
void _onLoginGoogle(LoginGoogle event, Emitter<LoginState> emit) async {
|
||||
emit(LoginLoading());
|
||||
Cache().setLoginType(LoginType.google);
|
||||
await userRepository.getUserByGoogle();
|
||||
accountBloc.add(AccountLogInFinished(customer: Cache().userLoggedIn!));
|
||||
Track().track(TrackingEvent.login, eventValue: "Google");
|
||||
try {
|
||||
Cache().setLoginType(LoginType.google);
|
||||
await userRepository.getUserByGoogle();
|
||||
accountBloc.add(AccountLogInFinished(customer: Cache().userLoggedIn!));
|
||||
Track().track(TrackingEvent.login, eventValue: "Google");
|
||||
|
||||
emit(LoginSuccess());
|
||||
} on Exception catch(e) {
|
||||
emit(LoginError(message: e.toString()));
|
||||
} finally {
|
||||
emit(LoginSuccess());
|
||||
}
|
||||
}
|
||||
|
||||
void _onLoginApple(LoginApple event, Emitter<LoginState> emit) async {
|
||||
emit(LoginLoading());
|
||||
Cache().setLoginType(LoginType.apple);
|
||||
await userRepository.getUserByApple();
|
||||
accountBloc.add(AccountLogInFinished(customer: Cache().userLoggedIn!));
|
||||
Track().track(TrackingEvent.login, eventValue: "Apple");
|
||||
emit(LoginSuccess());
|
||||
try {
|
||||
Cache().setLoginType(LoginType.apple);
|
||||
await userRepository.getUserByApple();
|
||||
accountBloc.add(AccountLogInFinished(customer: Cache().userLoggedIn!));
|
||||
Track().track(TrackingEvent.login, eventValue: "Apple");
|
||||
} on Exception catch(e) {
|
||||
emit(LoginError(message: e.toString()));
|
||||
} finally {
|
||||
emit(LoginSuccess());
|
||||
}
|
||||
}
|
||||
|
||||
void _onRegistrationSubmit(RegistrationSubmit event, Emitter<LoginState> emit) async {
|
||||
|
||||
@@ -161,7 +161,7 @@ class SalesBloc extends Bloc<SalesEvent, SalesState> with Logging {
|
||||
return;
|
||||
}
|
||||
|
||||
String productSetString = splitTestRepository.getSplitTestValue("product_set_2");
|
||||
String productSetString = splitTestRepository.getSplitTestValue("product_set_5");
|
||||
log("ProductSetString: $productSetString");
|
||||
try {
|
||||
productSet = int.parse(productSetString);
|
||||
|
||||
@@ -296,7 +296,7 @@ class DropdownSearchState<T> extends State<DropdownSearch<T?>> {
|
||||
initialValue: widget.selectedItem,
|
||||
builder: (FormFieldState<T> state) {
|
||||
if (state.value != value) {
|
||||
WidgetsBinding.instance!.addPostFrameCallback((_) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
state.didChange(value);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -182,7 +182,7 @@ class _SelectDialogState<T> extends State<SelectDialog<T?>> {
|
||||
content: _errorWidget(error),
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
child: new Text("OK"),
|
||||
child: const Text("OK"),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop(false);
|
||||
},
|
||||
|
||||
@@ -1127,7 +1127,7 @@ class _AnimationWrapperState extends State<_AnimationWrapper> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
WidgetsBinding.instance!.addPostFrameCallback((_) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
opacity = 1.0;
|
||||
|
||||
+17
-12
@@ -54,10 +54,11 @@ import 'package:flutter/services.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||
import 'package:aitrainer_app/util/app_localization.dart';
|
||||
import 'package:flutter_uxcam/flutter_uxcam.dart';
|
||||
//import 'package:flutter_uxcam/flutter_uxcam.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:matomo_tracker/matomo_tracker.dart';
|
||||
import 'package:sentry_flutter/sentry_flutter.dart';
|
||||
import 'package:flutter_smartlook/flutter_smartlook.dart';
|
||||
//import 'package:flutter_smartlook/flutter_smartlook.dart';
|
||||
import 'package:upgrader/upgrader.dart';
|
||||
import 'bloc/account/account_bloc.dart';
|
||||
import 'bloc/body_development/body_development_bloc.dart';
|
||||
@@ -104,7 +105,8 @@ Future<Null> _reportError(dynamic error, dynamic stackTrace) async {
|
||||
);
|
||||
final String platform = Platform.isAndroid ? "Android" : "iOS";
|
||||
final String version = Cache().packageInfo != null ? Cache().packageInfo!.version + "+" + Cache().packageInfo!.buildNumber : "";
|
||||
final sentryId = await Sentry.captureException(error, stackTrace: stackTrace, hint: "Platform: $platform, Version: $version, User: $customerId");
|
||||
final sentryId =
|
||||
await Sentry.captureException(error, stackTrace: stackTrace, hint: "Platform: $platform, Version: $version, User: $customerId");
|
||||
|
||||
print('Capture exception result : SentryId : $sentryId');
|
||||
}
|
||||
@@ -146,7 +148,12 @@ Future<Null> main() async {
|
||||
Future<void> initThirdParty() async {
|
||||
if (!isInDebugMode) {
|
||||
//await FlurryData.initialize(androidKey: "JNYCTCWBT34FM3J8TV36", iosKey: "3QBG7BSMGPDH24S8TRQP", enableLog: true);
|
||||
FlutterUxcam.optIntoSchematicRecordings();
|
||||
await MatomoTracker.instance.initialize(
|
||||
siteId: 3,
|
||||
url: 'https://matomo.workouttest.com/matomo.php',
|
||||
//visitorId: 'customer_1',
|
||||
);
|
||||
//FlutterUxcam.optIntoSchematicRecordings();
|
||||
}
|
||||
await FirebaseApi().initializeFlutterFire();
|
||||
}
|
||||
@@ -154,11 +161,11 @@ Future<Null> main() async {
|
||||
final WorkoutTreeRepository menuTreeRepository = WorkoutTreeRepository();
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
if (!isInDebugMode) {
|
||||
FlutterUxcam.startWithKey("wvdstyoml4tiwfd");
|
||||
//FlutterUxcam.startWithKey("wvdstyoml4tiwfd");
|
||||
|
||||
SetupOptions options = (new SetupOptionsBuilder('682883e5cd71a46160c4f6ed070530ee593f49c6')).build();
|
||||
Smartlook.setupAndStartRecording(options);
|
||||
Smartlook.setEventTrackingMode(EventTrackingMode.FULL_TRACKING);
|
||||
//SetupOptions options = (new SetupOptionsBuilder('682883e5cd71a46160c4f6ed070530ee593f49c6')).build();
|
||||
//Smartlook.setupAndStartRecording(options);
|
||||
//Smartlook.setEventTrackingMode(EventTrackingMode.FULL_TRACKING);
|
||||
}
|
||||
await initThirdParty();
|
||||
final FirebaseAnalytics analytics = FirebaseAnalytics.instance;
|
||||
@@ -194,7 +201,8 @@ Future<Null> main() async {
|
||||
BlocProvider<TestSetExecuteBloc>(
|
||||
create: (BuildContext context) => TestSetExecuteBloc(),
|
||||
),
|
||||
BlocProvider<TutorialBloc>(create: (BuildContext context) => TutorialBloc(tutorialName: ActivityDone.tutorialExecuteFirstTest.toStr())),
|
||||
BlocProvider<TutorialBloc>(
|
||||
create: (BuildContext context) => TutorialBloc(tutorialName: ActivityDone.tutorialExecuteFirstTest.toStr())),
|
||||
BlocProvider<TrainingPlanBloc>(create: (context) {
|
||||
final MenuBloc menuBloc = BlocProvider.of<MenuBloc>(context);
|
||||
return TrainingPlanBloc(menuBloc: menuBloc, trainingPlanRepository: TrainingPlanRepository());
|
||||
@@ -216,9 +224,6 @@ class WorkoutTestApp extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
|
||||
|
||||
// Only call clearSavedSettings() during testing to reset internal values.
|
||||
Upgrader().clearSavedSettings(); // REMOVE this for release builds
|
||||
Upgrader().installAppStoreListingURL(Platform.isAndroid
|
||||
? "https://play.google.com/store/apps/details?id=com.aitrainer.aitrainer_app"
|
||||
: "https://apps.apple.com/hu/app/workouttest/id1515271425");
|
||||
|
||||
+21
-11
@@ -34,12 +34,13 @@ import 'package:aitrainer_app/util/track.dart';
|
||||
import 'package:firebase_remote_config/firebase_remote_config.dart';
|
||||
//import 'package:flurry_data/flurry_data.dart';
|
||||
import 'package:flutter_facebook_auth/flutter_facebook_auth.dart';
|
||||
import 'package:flutter_uxcam/flutter_uxcam.dart';
|
||||
//import 'package:flutter_uxcam/flutter_uxcam.dart';
|
||||
import 'package:matomo_tracker/matomo_tracker.dart';
|
||||
import 'package:package_info/package_info.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:aitrainer_app/model/exercise_type.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:flutter_smartlook/flutter_smartlook.dart';
|
||||
//import 'package:flutter_smartlook/flutter_smartlook.dart';
|
||||
|
||||
import 'customer_exercise_device.dart';
|
||||
import 'exercise_device.dart';
|
||||
@@ -175,7 +176,7 @@ class Cache with Logging {
|
||||
List<Exercise>? _exercisesTrainee;
|
||||
ExercisePlan? _traineeExercisePlan;
|
||||
|
||||
RemoteConfig? remoteConfig;
|
||||
FirebaseRemoteConfig? remoteConfig;
|
||||
|
||||
LinkedHashMap<String, int> _badges = LinkedHashMap();
|
||||
|
||||
@@ -544,7 +545,8 @@ class Cache with Logging {
|
||||
|
||||
ExercisePlan? getMyExercisePlan() => _myExercisePlan;
|
||||
|
||||
void setMyExercisePlanDetails(LinkedHashMap<int, ExercisePlanDetail> listExercisePlanDetail) => _myExercisesPlanDetails = listExercisePlanDetail;
|
||||
void setMyExercisePlanDetails(LinkedHashMap<int, ExercisePlanDetail> listExercisePlanDetail) =>
|
||||
_myExercisesPlanDetails = listExercisePlanDetail;
|
||||
|
||||
void addToMyExercisePlanDetails(ExercisePlanDetail detail) => _myExercisesPlanDetails[detail.exerciseTypeId] = detail;
|
||||
|
||||
@@ -558,7 +560,8 @@ class Cache with Logging {
|
||||
|
||||
void deleteMyExercisePlanDetail(ExercisePlanDetail detail) => this.deleteMyExercisePlanDetailByExerciseTypeId(detail.exerciseTypeId);
|
||||
|
||||
void deletedMyExercisePlanDetail(ExercisePlanDetail detail) => this._myExercisesPlanDetails[detail.exerciseTypeId]!.change = ModelChange.deleted;
|
||||
void deletedMyExercisePlanDetail(ExercisePlanDetail detail) =>
|
||||
this._myExercisesPlanDetails[detail.exerciseTypeId]!.change = ModelChange.deleted;
|
||||
|
||||
void deleteMyExercisePlanDetailByExerciseTypeId(int exerciseTypeId) {
|
||||
this._myExercisesPlanDetails[exerciseTypeId]!.change = ModelChange.delete;
|
||||
@@ -686,14 +689,21 @@ class Cache with Logging {
|
||||
|
||||
Future<void> initCustomer(int customerId) async {
|
||||
log(" *** initCustomer");
|
||||
await PackageApi().getCustomerPackage(customerId);
|
||||
try {
|
||||
await PackageApi().getCustomerPackage(customerId);
|
||||
} on Exception catch (_) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isInDebugMode) {
|
||||
//FlurryData.setUserId(customerId.toString());
|
||||
FlutterUxcam.setUserProperty("username", customerId.toString());
|
||||
FlutterUxcam.setUserIdentity(customerId.toString());
|
||||
Smartlook.setUserIdentifier(customerId.toString());
|
||||
//FlutterUxcam.setUserProperty("username", customerId.toString());
|
||||
//FlutterUxcam.setUserIdentity(customerId.toString());
|
||||
//Smartlook.setUserIdentifier(customerId.toString());
|
||||
//Smartlook.instance.
|
||||
Track().track(TrackingEvent.enter);
|
||||
MatomoTracker.instance
|
||||
.trackEvent(eventName: TrackingEvent.enter.enumToString(), eventCategory: "", action: TrackingEvent.enter.enumToString(), eventValue: customerId);
|
||||
}
|
||||
|
||||
await Future.forEach(ActivityDone.values, (element) async {
|
||||
@@ -751,8 +761,8 @@ class Cache with Logging {
|
||||
List<Tutorial>? get tutorials => this._tutorials;
|
||||
setTutorials(List<Tutorial>? value) => this._tutorials = value;
|
||||
|
||||
RemoteConfig? getRemoteConfig() => this.remoteConfig;
|
||||
setRemoteConfig(RemoteConfig? remoteConfig) => this.remoteConfig = remoteConfig;
|
||||
FirebaseRemoteConfig? getRemoteConfig() => this.remoteConfig;
|
||||
setRemoteConfig(FirebaseRemoteConfig? remoteConfig) => this.remoteConfig = remoteConfig;
|
||||
|
||||
List<Description>? getDescriptions() => this._descriptions;
|
||||
setDescriptions(List<Description>? value) => this._descriptions = value;
|
||||
|
||||
@@ -2,8 +2,9 @@ import 'package:aitrainer_app/model/cache.dart';
|
||||
import 'package:aitrainer_app/service/logging.dart';
|
||||
import 'package:firebase_remote_config/firebase_remote_config.dart';
|
||||
|
||||
|
||||
class RemoteConfigRepository with Logging {
|
||||
RemoteConfig? remoteConfig;
|
||||
FirebaseRemoteConfig? remoteConfig;
|
||||
|
||||
String getConfigValue(String configKey, String baseValue) {
|
||||
String value = "";
|
||||
|
||||
@@ -3,8 +3,9 @@ import 'package:aitrainer_app/repository/description_repository.dart';
|
||||
import 'package:aitrainer_app/service/logging.dart';
|
||||
import 'package:firebase_remote_config/firebase_remote_config.dart';
|
||||
|
||||
|
||||
class SplitTestRepository with Logging {
|
||||
final RemoteConfig? _remoteConfig = Cache().remoteConfig;
|
||||
final FirebaseRemoteConfig? _remoteConfig = Cache().remoteConfig;
|
||||
final DescriptionRepository descriptionRepository = DescriptionRepository();
|
||||
|
||||
String getSplitTestValue(String remoteConfigKey) {
|
||||
|
||||
@@ -384,13 +384,14 @@ class FirebaseApi with logging.Logging {
|
||||
RemoteConfig? remoteConfig;
|
||||
try {
|
||||
remoteConfig = RemoteConfig.instance;
|
||||
await remoteConfig.setConfigSettings(RemoteConfigSettings(
|
||||
await remoteConfig.setConfigSettings(
|
||||
RemoteConfigSettings(
|
||||
fetchTimeout: const Duration(seconds: 10),
|
||||
minimumFetchInterval: const Duration(seconds: 1),
|
||||
));
|
||||
|
||||
RemoteConfigValue(null, ValueSource.valueStatic);
|
||||
Cache().setRemoteConfig(remoteConfig);
|
||||
//RemoteConfigValue(null, ValueSource.valueStatic);
|
||||
//Cache().setRemoteConfig(remoteConfig);
|
||||
} on Exception catch (e) {
|
||||
print('Unable to fetch remote config. Cached or default values will be used: $e');
|
||||
if (remoteConfig != null) {
|
||||
|
||||
@@ -44,62 +44,44 @@ class PackageApi {
|
||||
final List<String> headRecord = element.split("***");
|
||||
final Iterable json = jsonDecode(headRecord[1]);
|
||||
if (headRecord[0] == "ExerciseDevice") {
|
||||
final List<ExerciseDevice> devices =
|
||||
json.map((device) => ExerciseDevice.fromJson(device)).toList();
|
||||
final List<ExerciseDevice> devices = json.map((device) => ExerciseDevice.fromJson(device)).toList();
|
||||
Cache().setDevices(devices);
|
||||
} else if (headRecord[0] == "Product") {
|
||||
final List<Product> products =
|
||||
json.map((product) => Product.fromJson(product)).toList();
|
||||
final List<Product> products = json.map((product) => Product.fromJson(product)).toList();
|
||||
Cache().setProducts(products);
|
||||
} else if (headRecord[0] == "Property") {
|
||||
final List<Property> properties =
|
||||
json.map((property) => Property.fromJson(property)).toList();
|
||||
final List<Property> properties = json.map((property) => Property.fromJson(property)).toList();
|
||||
Cache().setProperties(properties);
|
||||
} else if (headRecord[0] == "ExerciseTree") {
|
||||
exerciseTree = json
|
||||
.map((exerciseTree) => ExerciseTree.fromJson(exerciseTree))
|
||||
.toList();
|
||||
exerciseTree = json.map((exerciseTree) => ExerciseTree.fromJson(exerciseTree)).toList();
|
||||
} else if (headRecord[0] == "ExerciseType") {
|
||||
final List<ExerciseType> exerciseTypes = json
|
||||
.map((exerciseType) => ExerciseType.fromJson(exerciseType))
|
||||
.toList();
|
||||
final List<ExerciseType> exerciseTypes = json.map((exerciseType) => ExerciseType.fromJson(exerciseType)).toList();
|
||||
await Future.forEach(exerciseTypes, (elem) async {
|
||||
final ExerciseType exerciseType = elem as ExerciseType;
|
||||
exerciseType.imageUrl = await ExerciseTypeApi()
|
||||
.buildImage(exerciseType.imageUrl, exerciseType.exerciseTypeId);
|
||||
exerciseType.imageUrl = await ExerciseTypeApi().buildImage(exerciseType.imageUrl, exerciseType.exerciseTypeId);
|
||||
});
|
||||
Cache().setExerciseTypes(exerciseTypes);
|
||||
} else if (headRecord[0] == "ExerciseAbility") {
|
||||
} else if (headRecord[0] == "ExercisePlanTemplate") {
|
||||
final List<ExercisePlanTemplate> exercisePlanTemplates = json
|
||||
.map((exercisePlanTemplate) =>
|
||||
ExercisePlanTemplate.fromJson(exercisePlanTemplate))
|
||||
.toList();
|
||||
final List<ExercisePlanTemplate> exercisePlanTemplates =
|
||||
json.map((exercisePlanTemplate) => ExercisePlanTemplate.fromJson(exercisePlanTemplate)).toList();
|
||||
Cache().setExercisePlanTemplates(exercisePlanTemplates);
|
||||
} else if (headRecord[0] == "ExerciseTreeParents") {
|
||||
exerciseTreeParents = json
|
||||
.map((exerciseTreeParent) =>
|
||||
ExerciseTreeParents.fromJson(exerciseTreeParent))
|
||||
.toList();
|
||||
exerciseTreeParents = json.map((exerciseTreeParent) => ExerciseTreeParents.fromJson(exerciseTreeParent)).toList();
|
||||
} else if (headRecord[0] == "Evaluation") {
|
||||
final List<Evaluation> evaluations =
|
||||
json.map((evaluation) => Evaluation.fromJson(evaluation)).toList();
|
||||
final List<Evaluation> evaluations = json.map((evaluation) => Evaluation.fromJson(evaluation)).toList();
|
||||
Cache().evaluations = evaluations;
|
||||
} else if (headRecord[0] == "Sport") {
|
||||
final List<Sport> sports =
|
||||
json.map((sport) => Sport.fromJson(sport)).toList();
|
||||
final List<Sport> sports = json.map((sport) => Sport.fromJson(sport)).toList();
|
||||
Cache().setSports(sports);
|
||||
} else if (headRecord[0] == "Tutorial") {
|
||||
final Iterable json = jsonDecode(headRecord[1]);
|
||||
final List<Tutorial> tutorials =
|
||||
json.map((tutorial) => Tutorial.fromJson(tutorial)).toList();
|
||||
final List<Tutorial> tutorials = json.map((tutorial) => Tutorial.fromJson(tutorial)).toList();
|
||||
|
||||
Cache().setTutorials(tutorials);
|
||||
} else if (headRecord[0] == "Description") {
|
||||
final Iterable json = jsonDecode(headRecord[1]);
|
||||
final List<Description>? descriptions = json
|
||||
.map((description) => Description.fromJson(description))
|
||||
.toList();
|
||||
final List<Description>? descriptions = json.map((description) => Description.fromJson(description)).toList();
|
||||
//print("Description: $descriptions");
|
||||
Cache().setDescriptions(descriptions);
|
||||
} else if (headRecord[0] == "Faq") {
|
||||
@@ -109,8 +91,7 @@ class PackageApi {
|
||||
Cache().setFaqs(faqs);
|
||||
} else if (headRecord[0] == "TrainingPlan") {
|
||||
final Iterable json = jsonDecode(headRecord[1]);
|
||||
final List<TrainingPlan>? plans =
|
||||
json.map((plan) => TrainingPlan.fromJson(plan)).toList();
|
||||
final List<TrainingPlan>? plans = json.map((plan) => TrainingPlan.fromJson(plan)).toList();
|
||||
|
||||
List<TrainingPlan> activePlans = [];
|
||||
if (plans != null) {
|
||||
@@ -123,38 +104,31 @@ class PackageApi {
|
||||
Cache().setTrainingPlans(activePlans);
|
||||
} else if (headRecord[0] == "SplitTests") {
|
||||
final Iterable json = jsonDecode(headRecord[1]);
|
||||
final List<SplitTest>? tests =
|
||||
json.map((test) => SplitTest.fromJson(test)).toList();
|
||||
final List<SplitTest>? tests = json.map((test) => SplitTest.fromJson(test)).toList();
|
||||
//print("A/B tests: $tests");
|
||||
Cache().setSplitTests(tests);
|
||||
} else if (headRecord[0] == "TrainingPlanDay") {
|
||||
final Iterable json = jsonDecode(headRecord[1]);
|
||||
final List<TrainingPlanDay>? days =
|
||||
json.map((day) => TrainingPlanDay.fromJson(day)).toList();
|
||||
final List<TrainingPlanDay>? days = json.map((day) => TrainingPlanDay.fromJson(day)).toList();
|
||||
Cache().setTrainingPlanDays(days);
|
||||
}
|
||||
});
|
||||
|
||||
exerciseTree =
|
||||
this.getExerciseTreeParents(exerciseTree, exerciseTreeParents);
|
||||
exerciseTree = this.getExerciseTreeParents(exerciseTree, exerciseTreeParents);
|
||||
|
||||
await Future.forEach(exerciseTree, (element) async {
|
||||
ExerciseTree tree = element as ExerciseTree;
|
||||
tree.imageUrl =
|
||||
await ExerciseTreeApi().buildImage(tree.imageUrl, tree.treeId);
|
||||
tree.imageUrl = await ExerciseTreeApi().buildImage(tree.imageUrl, tree.treeId);
|
||||
});
|
||||
Cache().setExerciseTree(exerciseTree);
|
||||
|
||||
TrainingPlanDayRepository trainingPlanDayRepository =
|
||||
TrainingPlanDayRepository();
|
||||
TrainingPlanDayRepository trainingPlanDayRepository = TrainingPlanDayRepository();
|
||||
trainingPlanDayRepository.assignTrainingPlanDays();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
List<ExerciseTree> getExerciseTreeParents(
|
||||
final List<ExerciseTree> exerciseTree,
|
||||
final List<ExerciseTreeParents> exerciseTreeParents) {
|
||||
List<ExerciseTree> getExerciseTreeParents(final List<ExerciseTree> exerciseTree, final List<ExerciseTreeParents> exerciseTreeParents) {
|
||||
List<ExerciseTree> copyList = ExerciseTreeApi().copyList(exerciseTree);
|
||||
|
||||
int treeIndex = 0;
|
||||
@@ -184,8 +158,7 @@ class PackageApi {
|
||||
|
||||
Future<void> getCustomerPackage(int customerId) async {
|
||||
try {
|
||||
final body = await _client.get(
|
||||
"app_customer_package/" + customerId.toString(), "");
|
||||
final body = await _client.get("app_customer_package/" + customerId.toString(), "");
|
||||
|
||||
final List<String> models = body.split("|||");
|
||||
await Future.forEach(models, (elem) async {
|
||||
@@ -197,33 +170,24 @@ class PackageApi {
|
||||
Cache().userLoggedIn = customer;
|
||||
} else if (headRecord[0] == "CustomerExerciseDevice") {
|
||||
final Iterable json = jsonDecode(headRecord[1]);
|
||||
final List<CustomerExerciseDevice> devices = json
|
||||
.map((device) => CustomerExerciseDevice.fromJson(device))
|
||||
.toList();
|
||||
final List<CustomerExerciseDevice> devices = json.map((device) => CustomerExerciseDevice.fromJson(device)).toList();
|
||||
Cache().setCustomerDevices(devices);
|
||||
// ToDo
|
||||
} else if (headRecord[0] == "Exercises") {
|
||||
final Iterable json = jsonDecode(headRecord[1]);
|
||||
final List<Exercise> exercises = json
|
||||
.map((exerciseType) => Exercise.fromJson(exerciseType))
|
||||
.toList();
|
||||
final List<Exercise> exercises = json.map((exerciseType) => Exercise.fromJson(exerciseType)).toList();
|
||||
Cache().setExercises(exercises);
|
||||
} else if (headRecord[0] == "Purchase") {
|
||||
final Iterable json = jsonDecode(headRecord[1]);
|
||||
final List<Purchase> purchases =
|
||||
json.map((purchase) => Purchase.fromJson(purchase)).toList();
|
||||
final List<Purchase> purchases = json.map((purchase) => Purchase.fromJson(purchase)).toList();
|
||||
Cache().setPurchases(purchases);
|
||||
} else if (headRecord[0] == "CustomerProperty") {
|
||||
final Iterable json = jsonDecode(headRecord[1]);
|
||||
final List<CustomerProperty> customerProperties = json
|
||||
.map((property) => CustomerProperty.fromJson(property))
|
||||
.toList();
|
||||
final List<CustomerProperty> customerProperties = json.map((property) => CustomerProperty.fromJson(property)).toList();
|
||||
CustomerApi().initProperties(customerProperties);
|
||||
} else if (headRecord[0] == "CustomerPropertyAll") {
|
||||
final Iterable json = jsonDecode(headRecord[1]);
|
||||
final List<CustomerProperty> allCustomerProperties = json
|
||||
.map((property) => CustomerProperty.fromJson(property))
|
||||
.toList();
|
||||
final List<CustomerProperty> allCustomerProperties = json.map((property) => CustomerProperty.fromJson(property)).toList();
|
||||
print(" All Properties ---- $allCustomerProperties");
|
||||
Cache().setCustomerPropertyAll(allCustomerProperties);
|
||||
} else if (headRecord[0] == "ExerciseResult") {
|
||||
@@ -235,14 +199,12 @@ class PackageApi {
|
||||
// ToDo */
|
||||
} else if (headRecord[0] == "CustomerActivity") {
|
||||
final Iterable json = jsonDecode(headRecord[1]);
|
||||
final List<CustomerActivity> customerActivities = json
|
||||
.map((activity) => CustomerActivity.fromJson(activity))
|
||||
.toList();
|
||||
final List<CustomerActivity> customerActivities = json.map((activity) => CustomerActivity.fromJson(activity)).toList();
|
||||
Cache().setCustomerActivities(customerActivities);
|
||||
}
|
||||
});
|
||||
} on NotFoundException catch (_) {
|
||||
throw Exception("Please log in");
|
||||
} on NotFoundException catch (e) {
|
||||
throw Exception("Please log in $e");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+6
-4
@@ -7,8 +7,9 @@ import 'package:aitrainer_app/model/tracking.dart' as model;
|
||||
import 'package:firebase_analytics/firebase_analytics.dart';
|
||||
import 'package:firebase_messaging/firebase_messaging.dart';
|
||||
//import 'package:flurry_data/flurry_data.dart';
|
||||
import 'package:flutter_uxcam/flutter_uxcam.dart';
|
||||
import 'package:flutter_smartlook/flutter_smartlook.dart';
|
||||
//import 'package:flutter_uxcam/flutter_uxcam.dart';
|
||||
//import 'package:flutter_smartlook/flutter_smartlook.dart';
|
||||
import 'package:matomo_tracker/matomo_tracker.dart';
|
||||
|
||||
class Track with Logging {
|
||||
static final Track _singleton = Track._internal();
|
||||
@@ -23,8 +24,8 @@ class Track with Logging {
|
||||
void track(TrackingEvent event, {String eventValue = ""}) {
|
||||
if (!isInDebugMode) {
|
||||
//FlurryData.logEvent(event.enumToString());
|
||||
Smartlook.setGlobalEventProperty(event.toString(), eventValue, false);
|
||||
FlutterUxcam.logEventWithProperties(event.enumToString(), {"value": eventValue});
|
||||
//Smartlook.setGlobalEventProperty(event.toString(), eventValue, false);
|
||||
//FlutterUxcam.logEventWithProperties(event.enumToString(), {"value": eventValue});
|
||||
model.Tracking tracking = model.Tracking();
|
||||
tracking.customerId = Cache().userLoggedIn == null ? 0 : Cache().userLoggedIn!.customerId!;
|
||||
tracking.event = event.enumToString();
|
||||
@@ -37,6 +38,7 @@ class Track with Logging {
|
||||
|
||||
FirebaseMessaging.instance.subscribeToTopic(event.enumToString());
|
||||
analytics.logEvent(name: event.enumToString(), parameters: {"value": eventValue});
|
||||
MatomoTracker.instance.trackEvent(eventName: event.enumToString(), eventCategory: "", action: eventValue, eventValue: tracking.customerId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+3
-11
@@ -70,17 +70,7 @@ class _HomePageState extends State<AitrainerHome> with Logging, Trans {
|
||||
return Scaffold(
|
||||
key: _scaffoldKey,
|
||||
body: UpgradeAlert(
|
||||
appcastConfig: cfg,
|
||||
dialogStyle: UpgradeDialogStyle.cupertino,
|
||||
countryCode: AppLanguage().appLocal.languageCode,
|
||||
showIgnore: false,
|
||||
showLater: false,
|
||||
showReleaseNotes: false,
|
||||
debugLogging: true,
|
||||
//debugAlwaysUpgrade: true,
|
||||
//debugDisplayOnce: true,
|
||||
//minAppVersion: Cache().packageInfo != null ? Cache().packageInfo!.version : "99.99.99",
|
||||
messages: MyLocalizedUpgraderMessages(context: context),
|
||||
upgrader: Upgrader(appcastConfig: cfg, messages: MyLocalizedUpgraderMessages(context: context)),
|
||||
child: BlocConsumer<SessionBloc, SessionState>(listener: (context, state) {
|
||||
if (state is SessionFailure) {
|
||||
showDialog(
|
||||
@@ -148,6 +138,8 @@ class MyLocalizedUpgraderMessages extends UpgraderMessages with Trans {
|
||||
return t('Want to update?');
|
||||
case UpgraderMessage.title:
|
||||
return t('Update App?');
|
||||
case UpgraderMessage.releaseNotes:
|
||||
return "";
|
||||
}
|
||||
|
||||
// Messages that are not provided above can still use the default values.
|
||||
|
||||
Reference in New Issue
Block a user