restore button

This commit is contained in:
Jonas Bark
2026-01-02 20:42:23 +01:00
parent 2917814ecc
commit b6450ba47c
4 changed files with 28 additions and 52 deletions

View File

@@ -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!

View File

@@ -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<void> 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();
}

View File

@@ -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<IAPStatusWidget> {
},
),
),
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,

View File

@@ -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