From e5f5f305ddc5fece41e571bd4a9dac630f658eb2 Mon Sep 17 00:00:00 2001 From: bossanyit Date: Tue, 8 Jun 2021 17:02:39 +0200 Subject: [PATCH] WT 1.1.18+9 sales page products --- lib/bloc/sales/sales_bloc.dart | 4 +-- lib/repository/user_repository.dart | 8 ++++-- lib/service/api.dart | 3 +++ lib/view/sales_page.dart | 40 +---------------------------- pubspec.yaml | 2 +- 5 files changed, 13 insertions(+), 44 deletions(-) diff --git a/lib/bloc/sales/sales_bloc.dart b/lib/bloc/sales/sales_bloc.dart index 1f02350..4716255 100644 --- a/lib/bloc/sales/sales_bloc.dart +++ b/lib/bloc/sales/sales_bloc.dart @@ -30,7 +30,7 @@ class SalesBloc extends Bloc with Logging { String? salesText; String? premiumFunctions = ""; - void init() async { + Future init() async { if (Cache().userLoggedIn == null) { throw Exception("Please log in"); } @@ -60,7 +60,7 @@ class SalesBloc extends Bloc with Logging { if (event is SalesLoad) { log(" -- start SalesLoad"); yield SalesLoading(); - init(); + await init(); yield SalesReady(); log(" -- finish SalesLoad"); } else if (event is SalesPurchase) { diff --git a/lib/repository/user_repository.dart b/lib/repository/user_repository.dart index 8531450..f679e7a 100644 --- a/lib/repository/user_repository.dart +++ b/lib/repository/user_repository.dart @@ -34,8 +34,12 @@ class UserRepository with Logging { await CustomerApi().addUser(modelUser); } } catch (e) { - log(e.toString()); - throw new Exception(e); + final String message = e.toString(); + log(message); + if (message.contains("CERT_ALREADY_IN_HASH_TABLE")) { + } else { + throw new Exception(e); + } } } diff --git a/lib/service/api.dart b/lib/service/api.dart index db84eca..608f72d 100644 --- a/lib/service/api.dart +++ b/lib/service/api.dart @@ -28,6 +28,7 @@ class APIClient with Common, Logging { final body = '{"username":"$email", "password":"$password"}'; request.write(body); HttpClientResponse result = await request.close(); + client.close(); if (result.statusCode != 200) { trace("authentication response: ${result.statusCode}"); throw Exception("Network error, try again later!"); @@ -58,6 +59,7 @@ class APIClient with Common, Logging { //request.contentLength = body.length; request.write(body); HttpClientResponse result = await request.close(); + client.close(); trace(" ------------post response code: " + result.statusCode.toString()); if (result.statusCode == 200) { return await result.transform(utf8.decoder).join(); @@ -90,6 +92,7 @@ class APIClient with Common, Logging { request.headers.set('Content-Type', 'application/json'); request.headers.set('Authorization', 'Bearer $authToken'); HttpClientResponse result = await request.close(); + client.close(); trace(" ------------get response code: " + result.statusCode.toString()); if (result.statusCode == 200) { return await result.transform(utf8.decoder).join(); diff --git a/lib/view/sales_page.dart b/lib/view/sales_page.dart index d017c63..44caab2 100644 --- a/lib/view/sales_page.dart +++ b/lib/view/sales_page.dart @@ -173,7 +173,7 @@ class SalesPage extends StatelessWidget with Trans, Logging { darkShadow: true, blurRadius: 12, animationCurve: Curves.easeIn, - height: 150, + height: 180, width: 160, onTap: () => bloc.add(SalesPurchase(productId: bloc.product2Display[idx].productId)), isMultiColor: true, @@ -217,13 +217,6 @@ class SalesPage extends StatelessWidget with Trans, Logging { fontWeight: FontWeight.bold, fontSize: FontSize(16), textAlign: TextAlign.center, - /* textShadow: [ - Shadow( - offset: Offset(3.0, 3.0), - blurRadius: 4.0, - color: Colors.black54, - ), - ], */ ), "h1": Style( color: Colors.blue[400], @@ -342,35 +335,4 @@ class SalesPage extends StatelessWidget with Trans, Logging { }, )); } - - List getButtons(SalesBloc bloc) { - List buttons = []; - - bloc.product2Display.forEach((element) { - final String title = element.sort == 3 ? t("Montly") : t("Annual"); - final String desc4 = element.sort == 1 ? "" : t("Predictions with Artificial Intelligence"); - String? badge; - if (element.sort == 2) { - badge = t("14% discount"); - } else if (element.sort == 1) { - badge = t("2 months free"); - } - Widget button = SalesButton( - title: title, - price: element.localizedPrice!, - desc1: t("Development programs"), - desc2: t("Suggestions based on your actual status"), - desc3: t("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; - } } diff --git a/pubspec.yaml b/pubspec.yaml index 3b35878..25cbe46 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -15,7 +15,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. # Read more about iOS versioning at # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html -version: 1.1.18+87 +version: 1.1.18+88 environment: sdk: ">=2.12.0 <3.0.0"