From 67cfa49e2d647325dc8a0e64fb5ec1d5ca88a4ff Mon Sep 17 00:00:00 2001 From: Dmitry Date: Mon, 5 Aug 2024 03:12:20 +0300 Subject: [PATCH] stuff --- lib/features/purchase/in_app_purchase.dart | 4 +- .../purchase/rustore/mnemo_rustore.dart | 222 +++++++++--------- lib/features/tests/progress_widget.dart | 2 +- .../common_test_question_widget.dart | 13 +- .../firebase_config_repository.dart | 2 +- lib/widgets/card_pack/buy_pack_page.dart | 1 - pubspec.lock | 16 -- pubspec.yaml | 4 +- 8 files changed, 128 insertions(+), 136 deletions(-) diff --git a/lib/features/purchase/in_app_purchase.dart b/lib/features/purchase/in_app_purchase.dart index 2f7d87b..99253e1 100644 --- a/lib/features/purchase/in_app_purchase.dart +++ b/lib/features/purchase/in_app_purchase.dart @@ -3,7 +3,6 @@ import 'dart:developer'; import 'dart:io'; import 'package:flutter/material.dart'; -import 'package:flutter_rustore_billing/pigeons/rustore.dart'; import 'package:in_app_purchase/in_app_purchase.dart'; import 'package:mnemo_cards_common/mnemo_cards_common.dart'; import 'package:url_launcher/url_launcher_string.dart'; @@ -31,7 +30,8 @@ class InAppPurchaseService { Future buyPack(CardPackBuyDto dto) async { try { if (RUSTORE_BUILD) { - return RustorePurchaseService().buyPack(dto); + // return RustorePurchaseService().buyPack(dto); + return false; } else { final pack = await _getPackStoreProduct(dto); final result = await _buyItemInStore(pack.first); diff --git a/lib/features/purchase/rustore/mnemo_rustore.dart b/lib/features/purchase/rustore/mnemo_rustore.dart index cba00d2..4b43433 100644 --- a/lib/features/purchase/rustore/mnemo_rustore.dart +++ b/lib/features/purchase/rustore/mnemo_rustore.dart @@ -1,112 +1,110 @@ -import 'dart:developer'; - -import 'package:auto_route/auto_route.dart'; -import 'package:flutter_rustore_billing/flutter_rustore_billing.dart'; -import 'package:mnemo_cards/features/analytics/analytics.dart'; -import 'package:mnemo_cards/flags.dart'; -import 'package:mnemo_cards/main.dart'; -import 'package:mnemo_cards_common/mnemo_cards_common.dart'; - -import '../../../di/locator.dart'; -import '../../../domain/router/dialogs.dart'; - -class RustorePurchaseService { - Future init() async { - return RustoreBillingClient.initialize( - "2063563896", - "mnemocards://iamback", - true, - ).then((value) { - print("initialize success: $value"); - return true; - }, onError: (err) { - print("initialize err: $err"); - return false; - }); - } - - Future buyPack(CardPackBuyDto dto) async { - if (dto.rustoreId == null) { - return false; - } - if (!await init()) { - return false; - } - if (!await RustoreBillingClient.available().then((value) { - print("available success $value"); - return true; - }, onError: (err) { - print("available err: $err"); - return false; - })) { - return false; - } - final product = (await RustoreBillingClient.products([dto.rustoreId])) - .products - .firstOrNull; - if (product == null) { - return false; - } - try { - final result = await RustoreBillingClient.purchase(dto.rustoreId!, null); - try { - try { - // creating payment to check it later - // in case there will be an error after confirmation - await locator.repository.checkPayment( - itemId: result.successPurchase!.productId, - key: result.successPurchase!.subscriptionToken!, - paymentSystem: androidPaymentSystem, - ); - } catch (e, s) { - Analytics.buyError( - dto, - PaymentSystem.rustore, - message: 'Error when creating payment', - ); - log('Error when creating payment', error: e, stackTrace: s); - showErrorDialog( - 'Технические шоколадки...\n\nПопробуйте позже или обновите приложение до последней версии'); - return false; - } - final p = await RustoreBillingClient.confirm( - result.successPurchase!.subscriptionToken!, - ); - if (p.success) { - final r = await locator.repository.checkPayment( - itemId: result.successPurchase!.productId, - key: result.successPurchase!.subscriptionToken!, - paymentSystem: androidPaymentSystem, - ); - if (r) { - return r; - } else { - Analytics.buyError( - dto, - PaymentSystem.rustore, - message: 'Error when confirming payment', - ); - showErrorDialog( - 'Технические шоколадки...\n\nДоступ откроется в течение 5 мин', - ); - } - } - } catch (e, s) { - log('Error when confirming purchase', error: e, stackTrace: s); - Analytics.crashlyticsError( - e: e, - s: s, - message: 'Error when confirming rustore purchase', - ); - } - } catch (e, s) { - log('Error when processing purchase', error: e, stackTrace: s); - Analytics.crashlyticsError( - e: e, - s: s, - message: 'Error when processing rustore purchase', - ); - } - return false; - } -} +// import 'dart:developer'; +// +// import 'package:flutter_rustore_billing/flutter_rustore_billing.dart'; +// import 'package:mnemo_cards/features/analytics/analytics.dart'; +// import 'package:mnemo_cards/flags.dart'; +// import 'package:mnemo_cards_common/mnemo_cards_common.dart'; +// +// import '../../../di/locator.dart'; +// import '../../../domain/router/dialogs.dart'; +// +// class RustorePurchaseService { +// Future init() async { +// return RustoreBillingClient.initialize( +// "2063563896", +// "mnemocards://iamback", +// true, +// ).then((value) { +// print("initialize success: $value"); +// return true; +// }, onError: (err) { +// print("initialize err: $err"); +// return false; +// }); +// } +// +// Future buyPack(CardPackBuyDto dto) async { +// if (dto.rustoreId == null) { +// return false; +// } +// if (!await init()) { +// return false; +// } +// if (!await RustoreBillingClient.available().then((value) { +// print("available success $value"); +// return true; +// }, onError: (err) { +// print("available err: $err"); +// return false; +// })) { +// return false; +// } +// final product = (await RustoreBillingClient.products([dto.rustoreId])) +// .products +// .firstOrNull; +// if (product == null) { +// return false; +// } +// try { +// final result = await RustoreBillingClient.purchase(dto.rustoreId!, null); +// try { +// try { +// // creating payment to check it later +// // in case there will be an error after confirmation +// await locator.repository.checkPayment( +// itemId: result.successPurchase!.productId, +// key: result.successPurchase!.subscriptionToken!, +// paymentSystem: androidPaymentSystem, +// ); +// } catch (e, s) { +// Analytics.buyError( +// dto, +// PaymentSystem.rustore, +// message: 'Error when creating payment', +// ); +// log('Error when creating payment', error: e, stackTrace: s); +// showErrorDialog( +// 'Технические шоколадки...\n\nПопробуйте позже или обновите приложение до последней версии'); +// return false; +// } +// final p = await RustoreBillingClient.confirm( +// result.successPurchase!.subscriptionToken!, +// ); +// if (p.success) { +// final r = await locator.repository.checkPayment( +// itemId: result.successPurchase!.productId, +// key: result.successPurchase!.subscriptionToken!, +// paymentSystem: androidPaymentSystem, +// ); +// if (r) { +// return r; +// } else { +// Analytics.buyError( +// dto, +// PaymentSystem.rustore, +// message: 'Error when confirming payment', +// ); +// showErrorDialog( +// 'Технические шоколадки...\n\nДоступ откроется в течение 5 мин', +// ); +// } +// } +// } catch (e, s) { +// log('Error when confirming purchase', error: e, stackTrace: s); +// Analytics.crashlyticsError( +// e: e, +// s: s, +// message: 'Error when confirming rustore purchase', +// ); +// } +// } catch (e, s) { +// log('Error when processing purchase', error: e, stackTrace: s); +// Analytics.crashlyticsError( +// e: e, +// s: s, +// message: 'Error when processing rustore purchase', +// ); +// } +// return false; +// } +// } diff --git a/lib/features/tests/progress_widget.dart b/lib/features/tests/progress_widget.dart index 838d167..becefa0 100644 --- a/lib/features/tests/progress_widget.dart +++ b/lib/features/tests/progress_widget.dart @@ -76,7 +76,7 @@ class _ProgressWidgetState extends State { widget.popText!, style: TextStyle( fontSize: 16, - fontWeight: FontWeight.w400, + fontWeight: FontWeight.w700, ), ), ), diff --git a/lib/features/tests/test_widgets/common_test_question_widget.dart b/lib/features/tests/test_widgets/common_test_question_widget.dart index 4e18105..161d0ec 100644 --- a/lib/features/tests/test_widgets/common_test_question_widget.dart +++ b/lib/features/tests/test_widgets/common_test_question_widget.dart @@ -1,3 +1,4 @@ +import 'package:auto_size_text/auto_size_text.dart'; import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:mnemo_cards/managers/audio_player.dart'; @@ -73,7 +74,7 @@ class CommonTestQuestionWidget extends StatelessWidget { ), ), ), - if (text != null) + if (text != null && audio != null) Container( alignment: Alignment.center, padding: const EdgeInsets.only(top: 8.0), @@ -100,6 +101,16 @@ class CommonTestQuestionWidget extends StatelessWidget { ) ], ), + ) + else if (text != null) + Container( + alignment: Alignment.center, + padding: const EdgeInsets.only(top: 8.0), + child: AutoSizeText( + text!, + style: theme.headlineLarge, + textAlign: TextAlign.center, + ), ), ], ); diff --git a/lib/managers/repository/firebase_config_repository.dart b/lib/managers/repository/firebase_config_repository.dart index f214d8e..8713c8e 100644 --- a/lib/managers/repository/firebase_config_repository.dart +++ b/lib/managers/repository/firebase_config_repository.dart @@ -7,7 +7,7 @@ class FirebaseRepository { static ConfigModel? _lastConfig; static ConfigModel get appConfig { - update(); + // update(); return _lastConfig!; } diff --git a/lib/widgets/card_pack/buy_pack_page.dart b/lib/widgets/card_pack/buy_pack_page.dart index 8b7be8c..72cfc02 100644 --- a/lib/widgets/card_pack/buy_pack_page.dart +++ b/lib/widgets/card_pack/buy_pack_page.dart @@ -181,7 +181,6 @@ class _BuyButton extends StatelessWidget { height: 120.h, alignment: Alignment.center, decoration: BoxDecoration( - color: Colors.white, border: Border.all(color: borderGray), borderRadius: BorderRadius.circular(16.0), ), diff --git a/pubspec.lock b/pubspec.lock index 2e5c735..9e9524a 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -494,14 +494,6 @@ packages: url: "https://pub.dev" source: hosted version: "2.0.20" - flutter_rustore_billing: - dependency: "direct main" - description: - name: flutter_rustore_billing - sha256: "95905fec5ab46f7d0e798469c847423aa4dac07461a6111892be3f34c48a5b75" - url: "https://pub.dev" - source: hosted - version: "6.0.1" flutter_screenutil: dependency: "direct main" description: @@ -624,14 +616,6 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.2" - go_router: - dependency: transitive - description: - name: go_router - sha256: b465e99ce64ba75e61c8c0ce3d87b66d8ac07f0b35d0a7e0263fcfc10f99e836 - url: "https://pub.dev" - source: hosted - version: "13.2.5" google_identity_services_web: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 956e1f2..7645a64 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -2,7 +2,7 @@ name: mnemo_cards description: Mnemo publish_to: 'none' -version: 1.0.2+15 +version: 1.0.2+16 environment: sdk: '>=3.1.3 <4.0.0' @@ -65,7 +65,7 @@ dependencies: url_launcher: ^6.2.6 # RUSTORE - flutter_rustore_billing: ^6.0.1 +# flutter_rustore_billing: ^6.0.1 collection: any freezed_annotation: any