mirror of
https://github.com/jonasbark/swiftcontrol.git
synced 2026-11-29 09:11:17 +01:00
cleanup
This commit is contained in:
@@ -591,12 +591,12 @@ class ProxyDevice extends BluetoothDevice {
|
||||
);
|
||||
}
|
||||
|
||||
ActionResult handleTrainerAction(InGameAction action) {
|
||||
ActionResult handleTrainerAction(ControllerButton button, InGameAction action) {
|
||||
final l10n = AppLocalizations.current;
|
||||
final def = emulator.fitnessBike;
|
||||
if (def == null) {
|
||||
// Internal-only diagnostic; not user-visible toast copy.
|
||||
return NotHandled('No active FitnessBikeDefinition', button: null);
|
||||
return NotHandled('No active FitnessBikeDefinition', button: button);
|
||||
}
|
||||
switch (action) {
|
||||
case InGameAction.shiftUp:
|
||||
@@ -610,37 +610,37 @@ class ProxyDevice extends BluetoothDevice {
|
||||
} else {
|
||||
final didChange = def.shiftUp();
|
||||
return didChange
|
||||
? Ignored(l10n.trainerShiftedUp(def.currentGear.value), button: null)
|
||||
: Ignored(l10n.trainerAlreadyHighestGear, button: null);
|
||||
? Ignored(l10n.trainerShiftedUp(def.currentGear.value), button: button)
|
||||
: Ignored(l10n.trainerAlreadyHighestGear, button: button);
|
||||
}
|
||||
case InGameAction.shiftDown:
|
||||
if (def.trainerMode.value == TrainerMode.ergMode) {
|
||||
final current = def.ergTargetPower.value ?? 150;
|
||||
def.setManualErgPower(current - 10);
|
||||
return Success(l10n.trainerErgTarget(def.ergTargetPower.value ?? current), button: null);
|
||||
return Success(l10n.trainerErgTarget(def.ergTargetPower.value ?? current), button: button);
|
||||
} else {
|
||||
final didChange = def.shiftDown();
|
||||
return didChange
|
||||
? Ignored(l10n.trainerShiftedDown(def.currentGear.value), button: null)
|
||||
: Ignored(l10n.trainerAlreadyLowestGear, button: null);
|
||||
? Ignored(l10n.trainerShiftedDown(def.currentGear.value), button: button)
|
||||
: Ignored(l10n.trainerAlreadyLowestGear, button: button);
|
||||
}
|
||||
case InGameAction.trainerSwitchMode:
|
||||
if (def.trainerMode.value == TrainerMode.ergMode) {
|
||||
def.exitErgMode();
|
||||
return Success(l10n.trainerSwitchedToSim, button: null);
|
||||
return Success(l10n.trainerSwitchedToSim, button: button);
|
||||
} else {
|
||||
final current = def.ergTargetPower.value ?? 150;
|
||||
def.setManualErgPower(current);
|
||||
return Success(l10n.trainerSwitchedToErg(current), button: null);
|
||||
return Success(l10n.trainerSwitchedToErg(current), button: button);
|
||||
}
|
||||
case InGameAction.trainerIntensityUp:
|
||||
def.adjustIntensity(0.05);
|
||||
return Success(l10n.trainerIntensityIncreased, button: null);
|
||||
return Success(l10n.trainerIntensityIncreased, button: button);
|
||||
case InGameAction.trainerIntensityDown:
|
||||
def.adjustIntensity(-0.05);
|
||||
return Success(l10n.trainerIntensityDecreased, button: null);
|
||||
return Success(l10n.trainerIntensityDecreased, button: button);
|
||||
default:
|
||||
return NotHandled('', button: null);
|
||||
return NotHandled('', button: button);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@
|
||||
"actionCategoryShifting": "Schalten",
|
||||
"actionCategorySteering": "Lenken",
|
||||
"actionCategoryOther": "Sonstiges",
|
||||
"trialDaysAvailable": "{days}-tägige Testversion verfügbar",
|
||||
"trialDaysAvailable": "{days}-tägige Testversion",
|
||||
"@trialDaysAvailable": {
|
||||
"placeholders": {
|
||||
"days": {
|
||||
|
||||
@@ -735,7 +735,7 @@ class _PaywallState extends State<Paywall> {
|
||||
AppLocalizations.of(context).fullVersion,
|
||||
style: const TextStyle(
|
||||
color: Color(0xFF07070A),
|
||||
fontSize: 24,
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w800,
|
||||
),
|
||||
),
|
||||
@@ -743,7 +743,7 @@ class _PaywallState extends State<Paywall> {
|
||||
Text(
|
||||
_pricing.fullVersionSubtitle,
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
fontSize: 14,
|
||||
color: Color(0xFF4E4E53),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -218,7 +218,7 @@ abstract class BaseActions {
|
||||
);
|
||||
}
|
||||
await IAPManager.instance.incrementCommandCount();
|
||||
final result = proxy.handleTrainerAction(keyPair.inGameAction!);
|
||||
final result = proxy.handleTrainerAction(keyPair.buttons.firstOrNull ?? button, keyPair.inGameAction!);
|
||||
// Ignored e.g. when already in highest gear
|
||||
// Success when action was executed and the action should not be sent to connected trainer
|
||||
// NotHandled means the e.g. gear changes should still be sent to the trainer, so we continue with the regular flow
|
||||
|
||||
@@ -30,7 +30,7 @@ Future<bool> showGoProDialog(BuildContext context) async {
|
||||
),
|
||||
LoadingWidget(
|
||||
futureCallback: () async {
|
||||
await iapManager.purchaseSubscription(c);
|
||||
await iapManager.purchaseSubscription(context);
|
||||
if (c.mounted) {
|
||||
Navigator.of(c).pop(true);
|
||||
}
|
||||
|
||||
2
prop
2
prop
Submodule prop updated: 5633536d13...d15719e99a
@@ -1,4 +1,5 @@
|
||||
import 'package:bike_control/bluetooth/devices/proxy/proxy_device.dart';
|
||||
import 'package:bike_control/bluetooth/devices/zwift/constants.dart';
|
||||
import 'package:bike_control/gen/l10n.dart';
|
||||
import 'package:bike_control/utils/actions/base_actions.dart';
|
||||
import 'package:bike_control/utils/core.dart';
|
||||
@@ -35,7 +36,7 @@ Future<void> main() async {
|
||||
|
||||
test('trainerUp in sim mode shifts up', () {
|
||||
def.setTargetGear(5);
|
||||
final result = device.handleTrainerAction(InGameAction.shiftUp);
|
||||
final result = device.handleTrainerAction(ZwiftButtons.shiftDownLeft, InGameAction.shiftUp);
|
||||
// Sim-mode shifts report Ignored (with the gear message) — the shift is
|
||||
// fully handled here and nothing must be forwarded to the trainer app.
|
||||
expect(result, isA<Ignored>());
|
||||
@@ -44,35 +45,35 @@ Future<void> main() async {
|
||||
|
||||
test('trainerUp in erg mode raises power', () {
|
||||
def.setManualErgPower(150);
|
||||
final result = device.handleTrainerAction(InGameAction.shiftUp);
|
||||
final result = device.handleTrainerAction(ZwiftButtons.shiftDownLeft, InGameAction.shiftUp);
|
||||
expect(result, isA<Success>());
|
||||
expect(def.ergTargetPower.value, 160);
|
||||
});
|
||||
|
||||
test('trainerDown in sim mode shifts down', () {
|
||||
def.setTargetGear(5);
|
||||
final result = device.handleTrainerAction(InGameAction.shiftDown);
|
||||
final result = device.handleTrainerAction(ZwiftButtons.shiftDownLeft, InGameAction.shiftDown);
|
||||
expect(result, isA<Ignored>());
|
||||
expect(def.currentGear.value, 4);
|
||||
});
|
||||
|
||||
test('trainerDown in erg mode lowers power', () {
|
||||
def.setManualErgPower(150);
|
||||
final result = device.handleTrainerAction(InGameAction.shiftDown);
|
||||
final result = device.handleTrainerAction(ZwiftButtons.shiftDownLeft, InGameAction.shiftDown);
|
||||
expect(result, isA<Success>());
|
||||
expect(def.ergTargetPower.value, 140);
|
||||
});
|
||||
|
||||
test('trainerSwitchMode toggles from sim to erg', () {
|
||||
def.exitErgMode(); // start in sim
|
||||
final result = device.handleTrainerAction(InGameAction.trainerSwitchMode);
|
||||
final result = device.handleTrainerAction(ZwiftButtons.shiftDownLeft, InGameAction.trainerSwitchMode);
|
||||
expect(result, isA<Success>());
|
||||
expect(def.trainerMode.value, TrainerMode.ergMode);
|
||||
});
|
||||
|
||||
test('trainerSwitchMode toggles from erg back to sim', () {
|
||||
def.setManualErgPower(150); // now in erg
|
||||
final result = device.handleTrainerAction(InGameAction.trainerSwitchMode);
|
||||
final result = device.handleTrainerAction(ZwiftButtons.shiftDownLeft, InGameAction.trainerSwitchMode);
|
||||
expect(result, isA<Success>());
|
||||
expect(def.trainerMode.value, isNot(TrainerMode.ergMode));
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user