WT1.1.3 build 2 iOS. Apple SignIn, Google SignIn

This commit is contained in:
bossanyit
2021-01-17 09:30:57 +01:00
parent 4bd1950ffd
commit d44fefe9af
31 changed files with 811 additions and 249 deletions
+43 -1
View File
@@ -21,6 +21,7 @@ class LoginBloc extends Bloc<LoginEvent, LoginState> with Trans {
final BuildContext context;
final bool isRegistration;
bool dataPolicyAllowed = false;
bool obscure = true;
LoginBloc({this.accountBloc, this.userRepository, this.context, this.isRegistration}) : super(LoginInitial());
@override
@@ -51,6 +52,20 @@ class LoginBloc extends Bloc<LoginEvent, LoginState> with Trans {
Flurry.logEvent("Login");
Flurry.logEvent("LoginFB");
yield LoginSuccess();
} else if (event is LoginGoogle) {
yield LoginLoading();
await userRepository.getUserByGoogle();
accountBloc.add(AccountLogInFinished(customer: Cache().userLoggedIn));
Flurry.logEvent("Login");
Flurry.logEvent("LoginGoogle");
yield LoginSuccess();
} else if (event is LoginApple) {
yield LoginLoading();
await userRepository.getUserByApple();
accountBloc.add(AccountLogInFinished(customer: Cache().userLoggedIn));
Flurry.logEvent("Login");
Flurry.logEvent("LoginApple");
yield LoginSuccess();
} else if (event is RegistrationSubmit) {
yield LoginLoading();
if (!this.dataPolicyAllowed) {
@@ -75,9 +90,36 @@ class LoginBloc extends Bloc<LoginEvent, LoginState> with Trans {
Flurry.logEvent("RegistrationFB");
Flurry.logEvent("Registration");
yield LoginSuccess();
} else if (event is RegistrationGoogle) {
yield LoginLoading();
if (!this.dataPolicyAllowed) {
yield LoginError();
throw Exception("Please accept our data policy");
}
await userRepository.addUserGoogle();
accountBloc.add(AccountLogInFinished(customer: Cache().userLoggedIn));
await saveCustomer();
Flurry.logEvent("RegistrationGoogle");
Flurry.logEvent("Registration");
yield LoginSuccess();
} else if (event is RegistrationApple) {
yield LoginLoading();
if (!this.dataPolicyAllowed) {
yield LoginError();
throw Exception("Please accept our data policy");
}
await userRepository.addUserApple();
accountBloc.add(AccountLogInFinished(customer: Cache().userLoggedIn));
await saveCustomer();
Flurry.logEvent("RegistrationApple");
Flurry.logEvent("Registration");
yield LoginSuccess();
} else if (event is DataProtectionClicked) {
this.dataPolicyAllowed = event.marked;
yield LoginLoading();
this.dataPolicyAllowed = !dataPolicyAllowed;
yield LoginReady();
} else if (event is LoginPasswordChangeObscure) {
this.obscure = !this.obscure;
}
} on Exception catch (e) {
yield LoginError(message: e.toString());
+16
View File
@@ -35,6 +35,14 @@ class LoginFB extends LoginEvent {
const LoginFB();
}
class LoginGoogle extends LoginEvent {
const LoginGoogle();
}
class LoginApple extends LoginEvent {
const LoginApple();
}
class DataProtectionClicked extends LoginEvent {
final bool marked;
const DataProtectionClicked({this.marked});
@@ -47,3 +55,11 @@ class RegistrationSubmit extends LoginEvent {
class RegistrationFB extends LoginEvent {
const RegistrationFB();
}
class RegistrationGoogle extends LoginEvent {
const RegistrationGoogle();
}
class RegistrationApple extends LoginEvent {
const RegistrationApple();
}
+5 -5
View File
@@ -29,14 +29,14 @@ class SalesBloc extends Bloc<SalesEvent, SalesState> with Logging {
if (event is SalesLoad) {
yield SalesLoading();
//Flurry.logEvent("SalesPageOpen");
await PlatformPurchaseApi().initPurchasePlatformState();
this.getProductSet();
// await PlatformPurchaseApi().initPurchasePlatformState();
// this.getProductSet();
yield SalesReady();
} else if (event is SalesPurchase) {
final int productId = event.productId;
trace("Requesting purchase for" + productId.toString());
//Flurry.logEvent("PurchaseRequest");
PlatformPurchaseApi().purchase(getSelectedProduct(productId));
// PlatformPurchaseApi().purchase(getSelectedProduct(productId));
}
} on Exception catch (ex) {
yield SalesError(message: ex.toString());
@@ -53,7 +53,7 @@ class SalesBloc extends Bloc<SalesEvent, SalesState> with Logging {
return prod;
}
String getLocalizedPrice(String productId) {
/* String getLocalizedPrice(String productId) {
String price = "";
for (var product in PlatformPurchaseApi().getIAPItems()) {
if (Platform.isAndroid) {
@@ -109,5 +109,5 @@ class SalesBloc extends Bloc<SalesEvent, SalesState> with Logging {
productTest.dateView = DateTime.now();
//ProductTestApi().saveProductTest(productTest);
//Cache().productTests.add(productTest);
}
} */
}
+1 -1
View File
@@ -42,7 +42,7 @@ class SessionBloc extends Bloc<SessionEvent, SessionState> with Logging {
@override
Future<void> close() async {
await this.close();
PlatformPurchaseApi().close();
//PlatformPurchaseApi().close();
super.close();
}
}