Files
swiftcontrol/lib/widgets/go_pro_dialog.dart
Jonas Bark 74bb2737ba fix: UI feedback round — remembered devices, Click V2 unlock, paywall, Pro dialog
- Remembered controllers offer a single "Forget" instead of two disconnect
  variants: there is no link to drop on a device that isn't here.
- Click V2: drop the unlock-mode dropdown and the new-unlock-method toggle.
  The explainer stays the one place the mode is chosen — it also does the
  follow-on work (un-ignoring the left puck, the right-side-only remap,
  cancelling the reset timer) that the bare dropdown never did. "Set up
  again" now sits on the right puck's card too.
- Paywall: the Base column reads "Basis"/"Base" rather than "VOLL"/"FULL",
  and the one-time Base card moves above the Pro plans so top-to-bottom
  matches the comparison table's left-to-right.
- A remembered controller's own settings page shows its button mapping
  again. The gate counted live controllers only and KeymapExplanation
  looked its filterDevice up in the live list, so the page fell through to
  a warning about connection methods, which had nothing to do with it.
- showGoProDialog takes a feature name for its title, so the keymap sync
  cloud icon says what it does instead of only "Pro Feature".

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-13 07:50:34 +02:00

62 lines
2.1 KiB
Dart

import 'package:bike_control/gen/l10n.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:shadcn_flutter/shadcn_flutter.dart';
/// Shows a dialog prompting the user to upgrade to Pro.
///
/// [featureName] names the thing the rider just reached for. Pass it wherever
/// the entry point is an icon or a toggle: "Pro Feature" alone tells them the
/// price of something they never found out the name of.
///
/// Returns true if the user initiated a purchase, false otherwise.
Future<bool> showGoProDialog(BuildContext context, {String? featureName}) async {
final iapManager = IAPManager.instance;
final result = await showDialog<bool>(
context: context,
builder: (c) => Container(
constraints: BoxConstraints(maxWidth: 400),
child: AlertDialog(
title: Row(
children: [
Icon(Icons.workspace_premium, color: Colors.orange),
const SizedBox(width: 8),
Expanded(child: Text(featureName ?? 'Pro Feature')),
],
),
content: Text(AppLocalizations.of(c).thisFeatureIsOnlyAvailableWithPro),
actions: [
Button.secondary(
onPressed: () => Navigator.of(c).pop(false),
child: Text(c.i18n.cancel),
),
LoadingWidget(
futureCallback: () async {
await iapManager.purchaseSubscription(context);
if (c.mounted) {
Navigator.of(c).pop(true);
}
},
renderChild: (isLoading, tap) => PrimaryButton(
onPressed: tap,
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
isLoading ? SmallProgressIndicator() : Icon(Icons.workspace_premium, size: 16),
const SizedBox(width: 8),
Text(c.i18n.goPro),
],
),
),
),
],
),
),
);
return result ?? false;
}