do not offer MyWhoosh Link when not compatible

This commit is contained in:
Jonas Bark
2025-11-03 18:58:41 +01:00
parent c511ac32b6
commit ac550fad5b
5 changed files with 30 additions and 5 deletions

View File

@@ -75,6 +75,7 @@ jobs:
echo "${{ secrets.KEYSTORE_PROPERTIES }}" > android/keystore.properties;
- name: 🚀 Shorebird Patch macOS
if: false # patch doesn't work: https://github.com/jonasbark/swiftcontrol/issues/143
uses: shorebirdtech/shorebird-patch@v1
with:
platform: macos

View File

@@ -3,6 +3,7 @@ import 'dart:io';
import 'package:flutter/foundation.dart';
import 'package:swift_control/utils/keymap/buttons.dart';
import 'package:swift_control/utils/requirements/multi.dart';
class WhooshLink {
Socket? _socket;
@@ -138,4 +139,11 @@ class WhooshLink {
return 'No action available for button: $action';
}
}
bool isCompatible(Target target) {
return switch (target) {
Target.thisDevice => Platform.isAndroid || Platform.isWindows,
_ => true,
};
}
}

View File

@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:swift_control/bluetooth/devices/base_device.dart';
import 'package:swift_control/main.dart';
import 'package:swift_control/utils/actions/remote.dart';
import 'package:swift_control/widgets/small_progress_indicator.dart';
import 'package:url_launcher/url_launcher_string.dart';
@@ -28,6 +29,9 @@ class LinkDevice extends BaseDevice {
builder: (context, isConnected, _) {
return StatefulBuilder(
builder: (context, setState) {
final myWhooshExplanation = actionHandler is RemoteActions
? 'MyWhoosh Link allows you to do some additional features such as Emotes and turn directions.'
: 'MyWhoosh Link is optional, but allows you to do some additional features such as Emotes and turn directions.';
return Row(
children: [
Expanded(
@@ -49,10 +53,19 @@ class LinkDevice extends BaseDevice {
spacing: 12,
children: [
if (!settings.getMyWhooshLinkEnabled())
Text('Disabled')
Expanded(
child: Text(
myWhooshExplanation,
style: TextStyle(fontSize: 12),
),
)
else ...[
Text(
isConnected ? "Connected" : "Connecting to MyWhoosh...",
Expanded(
child: Text(
isConnected ? "Connected" : "Connecting to MyWhoosh...\n$myWhooshExplanation",
style: TextStyle(fontSize: 12),
),
),
if (!isConnected) SmallProgressIndicator(),
],

View File

@@ -334,7 +334,7 @@ class _DevicePageState extends State<DevicePage> with WidgetsBindingObserver {
if (connection.remoteDevices.isNotEmpty ||
actionHandler is RemoteActions ||
settings.getTrainerApp() is MyWhoosh ||
whooshLink.isCompatible(settings.getLastTarget()!) ||
actionHandler.supportedApp?.supportsZwiftEmulation == true)
Container(
margin: const EdgeInsets.only(bottom: 8.0),
@@ -358,7 +358,9 @@ class _DevicePageState extends State<DevicePage> with WidgetsBindingObserver {
(device) => device.showInformation(context),
),
if (settings.getTrainerApp() is MyWhoosh && !whooshLink.isConnected.value)
if (settings.getTrainerApp() is MyWhoosh &&
!whooshLink.isConnected.value &&
whooshLink.isCompatible(settings.getLastTarget()!))
LinkDevice('').showInformation(context),
if (settings.getTrainerApp()?.supportsZwiftEmulation == true)
ZwiftRequirement().build(context, () {

View File

@@ -309,6 +309,7 @@ class _PairWidgetState extends State<_PairWidget> {
if (settings.getTrainerApp() is MyWhoosh)
ElevatedButton(
onPressed: () async {
settings.setMyWhooshLinkEnabled(true);
Navigator.push(
context,
MaterialPageRoute(