diff --git a/lib/Frontend/Widgets/manage_gear.dart b/lib/Frontend/Widgets/manage_gear.dart index 711f59fe..1b0c4db1 100644 --- a/lib/Frontend/Widgets/manage_gear.dart +++ b/lib/Frontend/Widgets/manage_gear.dart @@ -1,6 +1,7 @@ import 'package:fl_chart/fl_chart.dart'; import 'package:flex_color_picker/flex_color_picker.dart'; import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:tail_app/Backend/move_lists.dart'; import 'package:tail_app/Frontend/Widgets/tutorial_card.dart'; @@ -271,13 +272,14 @@ class ManageGearConventionMode extends ConsumerWidget { builder: (context, connectivityState, child) => Switch( value: device.baseStoredDevice.conModeEnabled, onChanged: connectivityState == ConnectivityState.connected - ? (value) { + ? (value) async { //reject if gear disconnected if (value) { BluetoothMessage bluetoothMessage = BluetoothMessage(message: "SETPUSSKEY ${device.baseStoredDevice.conModePin}", device: device, timestamp: DateTime.timestamp()); device.commandQueue.addCommand(bluetoothMessage); device.baseStoredDevice.conModeEnabled = true; ref.read(knownDevicesProvider.notifier).store(); + await Clipboard.setData(ClipboardData(text: device.baseStoredDevice.conModePin)); } else { BluetoothMessage bluetoothMessage = BluetoothMessage(message: "STOPPUSSKEY", device: device, timestamp: DateTime.timestamp()); device.commandQueue.addCommand(bluetoothMessage); diff --git a/lib/Frontend/Widgets/pincode_dialog.dart b/lib/Frontend/Widgets/pincode_dialog.dart index 516cf73d..1a5ddc4b 100644 --- a/lib/Frontend/Widgets/pincode_dialog.dart +++ b/lib/Frontend/Widgets/pincode_dialog.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; import 'package:go_router/go_router.dart'; import '../translation_string_definitions.dart'; @@ -12,7 +13,16 @@ class PincodeDialog extends StatelessWidget { Widget build(BuildContext context) { return AlertDialog( actionsAlignment: MainAxisAlignment.center, - actions: [TextButton(onPressed: () => context.pop(), child: Text(ok()))], + actions: [ + TextButton( + onPressed: () async => await Clipboard.setData(ClipboardData(text: pin)), + child: Text(manageGearConModePincodeCopy()), + ), + TextButton( + onPressed: () => context.pop(), + child: Text(ok()), + ), + ], title: Text(manageGearConModePincodeTitle()), content: Column( crossAxisAlignment: CrossAxisAlignment.center, diff --git a/lib/Frontend/translation_string_definitions.dart b/lib/Frontend/translation_string_definitions.dart index 981e872b..9412b35f 100644 --- a/lib/Frontend/translation_string_definitions.dart +++ b/lib/Frontend/translation_string_definitions.dart @@ -397,4 +397,6 @@ String manageGearConModeDescription() => Intl.message('Convention Mode is an add String manageGearConModePincodeTitle() => Intl.message('View Pin Code', name: 'manageGearConModePincodeTitle', desc: 'The description for the pin mode button on the gear page'); +String manageGearConModePincodeCopy() => Intl.message('Copy to Clipboard', name: 'manageGearConModePincodeCopy', desc: 'The description for copy to clipboard button on the pin code dialog'); + String manageGearConModeToggleTitle() => Intl.message('Enable Convention Mode', name: 'manageGearConModeToggleTitle', desc: 'The description for the convention mode enabled button on the gear page');