-
Notifications
You must be signed in to change notification settings - Fork 0
Добавление функции оплаты и подготовка к релизу в AppStore #77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 15 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
5172f8e
build: измена конфигурация ios проекта в связи с изменением аккаунта …
neekeetuh 4584621
feat: добавлена тестовая версия логики покупки про версии через аппстор
neekeetuh 12f85bb
fix: удаление возможности пользователя со статусом про попадать на эк…
neekeetuh 0c4e4d4
refactor: вынесение констант
neekeetuh 384b694
fix: вынесение цены про версии в локализацию + исправление ошибок лок…
neekeetuh ad3d1f5
refactor: удаление ненужного метода в инициализации провайдера про ве…
neekeetuh c324429
style: добавление параметра для использования non-nullable локализации
neekeetuh 92475a8
style: вынесение переменной с апи ключом в класс, где она используется
neekeetuh e8d8362
refactor: вынесение ассетов в отдельные классы
neekeetuh fc0cb7b
fix: вынесение добавления listener'a на обновление пользовательской и…
neekeetuh 4218d04
fix: улучшение читабельности методов + добавление обработки ошибки по…
neekeetuh ac28497
feat: добавление обработки ошибки покупки товара на ui
neekeetuh baad32b
fix: удаление лишнего consumer'а
neekeetuh 5a94522
fix: изменение логики взаимодействия модулей
neekeetuh 26e1f19
fix: изменение способа инъекции зависимостей для репозитория
neekeetuh 6c882f7
fix: отказ от реактивного спобоса обновления статуса пользователя в п…
neekeetuh 30ba166
Merge branch 'develop' of https://github.com/Student-Labs-2024/aurora…
neekeetuh 30bd629
fix: удаление константных строк, которые должны использоваться через …
neekeetuh 502be15
fix: исправление ошибки, при которой в локальную бд записывались лока…
neekeetuh 9e52e4e
feat + refactor: добавление возможности восстановления покупок пользо…
neekeetuh c468439
refactor: вынесение данных, хранящихся в провайдере в классы состояни…
neekeetuh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| arb-dir: lib/l10n | ||
| template-arb-file: en.arb | ||
| output-localization-file: app_localizations.dart | ||
| nullable-getter: false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| sealed class Assets { | ||
| static const handbook = "assets/images/icons/handbook.svg"; | ||
| static const loading = "assets/images/icons/loading.svg"; | ||
| static const board = "assets/images/board.svg"; | ||
| static const advantage = 'assets/images/icons/advantage.svg'; | ||
| static const backArrowIcon = "assets/images/icons/back_arrow_icon.svg"; | ||
| static const pointLight = "assets/images/icons/point_light.svg"; | ||
| static const darkSwitch = "assets/images/icons/dark_switch.svg"; | ||
| static const lightSwitch = "assets/images/icons/light_switch.svg"; | ||
| static const proSparkles = 'assets/images/icons/pro_sparkles.svg'; | ||
| static const sun = 'assets/images/icons/sun.svg'; | ||
| static const moon = 'assets/images/icons/moon.svg'; | ||
| static const explosion = 'assets/images/icons/explosion.svg'; | ||
| static const lamp = 'assets/images/icons/lamp.svg'; | ||
| static const book = 'assets/images/icons/book.svg'; | ||
| static const chessPiece = 'assets/images/icons/chess_piece.svg'; | ||
| static const leftBigArrowIcon = "assets/images/icons/left_big_arrow_icon.svg"; | ||
| static const rightBigArrowIcon = | ||
| "assets/images/icons/right_big_arrow_icon.svg"; | ||
| static const questionIcon = "assets/images/icons/question_icon.svg"; | ||
| } | ||
|
|
||
| sealed class AssetsPieces { | ||
| static const bishop = 'assets/images/pieces/bishop.svg'; | ||
| static const rook = 'assets/images/pieces/rook.svg'; | ||
| static const knight = 'assets/images/pieces/knight.svg'; | ||
| static const queen = 'assets/images/pieces/queen.svg'; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,3 @@ | ||
| export "colors.dart"; | ||
| export "text_styles.dart"; | ||
| export "string_constants.dart"; | ||
| export 'gradient_consts.dart'; |
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| import 'package:flutter/material.dart'; | ||
|
|
||
| abstract interface class IInAppPurchaseDataSource { | ||
| Future<bool> buyProduct(String productId); | ||
| Future<bool> checkStatus(String productId); | ||
| void init(ValueNotifier<bool> notifier); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| import 'package:flutter/material.dart'; | ||
| import 'package:frontend/data_sources/in_app_purchase_data_source.dart'; | ||
| import 'package:purchases_flutter/purchases_flutter.dart'; | ||
|
|
||
| class RevenueCatDataSource implements IInAppPurchaseDataSource { | ||
| //The key of a product should be the same as an entitlement name attached to it | ||
| static const _proVersionKey = 'chessknock_pro_version'; | ||
| @override | ||
| Future<bool> buyProduct(String productId) async { | ||
| final product = (await Purchases.getProducts([productId])).first; | ||
| final customerInfo = await Purchases.purchaseStoreProduct(product); | ||
| final isPro = customerInfo.entitlements.active[productId] != null; | ||
| return isPro; | ||
| } | ||
|
|
||
| @override | ||
| Future<bool> checkStatus(String productId) async { | ||
| final customerInfo = await Purchases.getCustomerInfo(); | ||
| return customerInfo.entitlements.active.containsKey(productId); | ||
| } | ||
|
|
||
| @override | ||
| void init(ValueNotifier<bool> notifier) { | ||
| try { | ||
| Purchases.addCustomerInfoUpdateListener((info) { | ||
| info.entitlements.active.containsKey(_proVersionKey) | ||
| ? notifier.value = true | ||
| : notifier.value = false; | ||
| }); | ||
| } catch (e) { | ||
| throw Exception('function type should be void Function(bool)'); | ||
|
Nailloon marked this conversation as resolved.
Outdated
|
||
| } | ||
| } | ||
| } | ||
|
neekeetuh marked this conversation as resolved.
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
|
neekeetuh marked this conversation as resolved.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,20 +1,51 @@ | ||
| import 'package:flutter/material.dart'; | ||
| import 'package:frontend/repositories/in_app_purchase_repository.dart'; | ||
|
|
||
| class ProVersionProvider extends ChangeNotifier { | ||
| //The key of a product should be the same as an entitlement name attached to it | ||
| static const _proVersionKey = 'chessknock_pro_version'; | ||
|
|
||
| bool _isProStatus = false; | ||
| bool _isPurchaseError = false; | ||
|
|
||
| final InAppPurchaseRepository _repository; | ||
|
|
||
| ProVersionProvider({required InAppPurchaseRepository repository}) | ||
| : _repository = repository { | ||
| _init(); | ||
| } | ||
|
|
||
| void _init() async { | ||
| _setProStatus(_repository.getStatus()); | ||
| } | ||
|
|
||
| void _setProStatus(bool status) { | ||
| _isProStatus = status; | ||
| notifyListeners(); | ||
| } | ||
|
|
||
| void upgradeToPro() { | ||
| _setProStatus(true); | ||
| void _setPurchaseError(bool isError) { | ||
| _isPurchaseError = isError; | ||
| notifyListeners(); | ||
| } | ||
|
|
||
| Future<void> upgradeToPro() async { | ||
| try { | ||
| await _repository.buyProduct(_proVersionKey); | ||
| final isPro = _repository.getStatus(); | ||
| _setProStatus(isPro); | ||
| _setPurchaseError(false); | ||
| } catch (_) { | ||
| _setPurchaseError(true); | ||
| await Future.delayed(const Duration(milliseconds: 100)); | ||
| _setPurchaseError(false); | ||
| } | ||
| } | ||
|
|
||
| void downgradeFromPro() { | ||
| _setProStatus(false); | ||
| } | ||
|
|
||
| bool get isPro => _isProStatus; | ||
| bool get isPurchaseError => _isPurchaseError; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| import 'package:flutter/material.dart'; | ||
| import 'package:frontend/data_sources/in_app_purchase_data_source.dart'; | ||
|
|
||
| class InAppPurchaseRepository { | ||
| final IInAppPurchaseDataSource _dataSource; | ||
| final ValueNotifier<bool> _proStatusNotifier; | ||
|
|
||
| InAppPurchaseRepository( | ||
| {required IInAppPurchaseDataSource dataSource, | ||
| required ValueNotifier<bool> proStatusNotifier}) | ||
| : _dataSource = dataSource, | ||
| _proStatusNotifier = proStatusNotifier { | ||
| _init(); | ||
| } | ||
|
|
||
| Future<bool> buyProduct(String productId) { | ||
| return _dataSource.buyProduct(productId); | ||
| } | ||
|
|
||
| Future<bool> checkStatus(String productId) { | ||
| return _dataSource.checkStatus(productId); | ||
| } | ||
|
|
||
| void _init() { | ||
| _dataSource.init(_proStatusNotifier); | ||
| } | ||
|
|
||
| bool getStatus() { | ||
|
Nailloon marked this conversation as resolved.
Outdated
|
||
| return _proStatusNotifier.value; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.