From b6450ba47ccd1ebdf7076618d77bb6029875c94d Mon Sep 17 00:00:00 2001 From: Jonas Bark Date: Fri, 2 Jan 2026 20:42:23 +0100 Subject: [PATCH] restore button --- CHANGELOG.md | 5 --- lib/utils/iap/revenuecat_service.dart | 59 ++++++--------------------- lib/widgets/iap_status_widget.dart | 14 +++++++ pubspec.yaml | 2 +- 4 files changed, 28 insertions(+), 52 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 74c4c49..b6c1274 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,3 @@ -### 4.3.0 (unreleased) -**Features**: -- media key support for Windows and macOS -- App is now available in Italian (thanks to Connect_Thanks2613) - ### 4.2.0 (20-12-2025) BikeControl now offers a free trial period of 5 days for all features, so you can test everything before deciding to purchase a license. Please contact the support if you experience any issues! diff --git a/lib/utils/iap/revenuecat_service.dart b/lib/utils/iap/revenuecat_service.dart index 368d61a..1987c9f 100644 --- a/lib/utils/iap/revenuecat_service.dart +++ b/lib/utils/iap/revenuecat_service.dart @@ -5,8 +5,6 @@ import 'package:bike_control/bluetooth/devices/zwift/protocol/zp.pb.dart' as zp; import 'package:bike_control/bluetooth/messages/notification.dart'; import 'package:bike_control/main.dart'; import 'package:bike_control/utils/core.dart'; -import 'package:bike_control/widgets/ui/loading_widget.dart'; -import 'package:bike_control/widgets/ui/small_progress_indicator.dart'; import 'package:bike_control/widgets/ui/toast.dart'; import 'package:dartx/dartx.dart'; import 'package:flutter/foundation.dart'; @@ -226,50 +224,19 @@ class RevenueCatService { Future purchaseFullVersion(BuildContext context) async { // Direct the user to the paywall for a better experience if (Platform.isMacOS) { - showDropdown( - context: context, - builder: (c) => DropdownMenu( - children: [ - MenuButton( - child: LoadingWidget( - futureCallback: () async { - await restorePurchases(); - closeOverlay(c); - }, - renderChild: (isLoading, tap) => TextButton( - onPressed: tap, - child: isLoading ? SmallProgressIndicator() : const Text('Restore Purchase').small, - ), - ), - ), - MenuButton( - child: LoadingWidget( - futureCallback: () async { - try { - final offerings = await Purchases.getOfferings(); - final purchaseParams = PurchaseParams.package(offerings.current!.availablePackages.first); - PurchaseResult result = await Purchases.purchase(purchaseParams); - core.connection.signalNotification( - LogNotification('Purchase result: $result'), - ); - closeOverlay(c); - } on PlatformException catch (e) { - var errorCode = PurchasesErrorHelper.getErrorCode(e); - if (errorCode != PurchasesErrorCode.purchaseCancelledError) { - buildToast(context, title: e.message); - } - closeOverlay(c); - } - }, - renderChild: (isLoading, tap) => TextButton( - onPressed: tap, - child: isLoading ? SmallProgressIndicator() : const Text('Purchase'), - ), - ), - ), - ], - ), - ); + try { + final offerings = await Purchases.getOfferings(); + final purchaseParams = PurchaseParams.package(offerings.current!.availablePackages.first); + PurchaseResult result = await Purchases.purchase(purchaseParams); + core.connection.signalNotification( + LogNotification('Purchase result: $result'), + ); + } on PlatformException catch (e) { + var errorCode = PurchasesErrorHelper.getErrorCode(e); + if (errorCode != PurchasesErrorCode.purchaseCancelledError) { + buildToast(context, title: e.message); + } + } } else { await presentPaywall(); } diff --git a/lib/widgets/iap_status_widget.dart b/lib/widgets/iap_status_widget.dart index 1693eaa..ecbc699 100644 --- a/lib/widgets/iap_status_widget.dart +++ b/lib/widgets/iap_status_widget.dart @@ -6,6 +6,7 @@ import 'package:bike_control/gen/l10n.dart'; import 'package:bike_control/utils/core.dart'; import 'package:bike_control/utils/i18n_extension.dart'; import 'package:bike_control/utils/iap/iap_manager.dart'; +import 'package:bike_control/widgets/ui/loading_widget.dart'; import 'package:bike_control/widgets/ui/small_progress_indicator.dart'; import 'package:bike_control/widgets/ui/toast.dart'; import 'package:http/http.dart' as http; @@ -416,6 +417,19 @@ class _IAPStatusWidgetState extends State { }, ), ), + if (Platform.isMacOS) + Padding( + padding: const EdgeInsets.only(left: 42.0, top: 8.0, bottom: 8), + child: LoadingWidget( + futureCallback: () async { + await IAPManager.instance.restorePurchases(); + }, + renderChild: (isLoading, tap) => LinkButton( + onPressed: tap, + child: isLoading ? SmallProgressIndicator() : const Text('Restore Purchase').small, + ), + ), + ), Padding( padding: const EdgeInsets.only(left: 42.0, top: 8.0), child: Text(AppLocalizations.of(context).fullVersionDescription).xSmall, diff --git a/pubspec.yaml b/pubspec.yaml index c604e1e..454708b 100755 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: bike_control description: "BikeControl - Control your virtual riding" publish_to: 'none' # Remove this line if you wish to publish to pub.dev -version: 4.3.0+71 +version: 4.2.4+71 environment: sdk: ^3.9.0