Skip to content

Commit b565fa2

Browse files
committed
Copy con mode pin to clipboard
1 parent 47baedf commit b565fa2

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

lib/Frontend/Widgets/manage_gear.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import 'package:fl_chart/fl_chart.dart';
22
import 'package:flex_color_picker/flex_color_picker.dart';
33
import 'package:flutter/material.dart';
4+
import 'package:flutter/services.dart';
45
import 'package:flutter_riverpod/flutter_riverpod.dart';
56
import 'package:tail_app/Backend/move_lists.dart';
67
import 'package:tail_app/Frontend/Widgets/tutorial_card.dart';
@@ -271,13 +272,14 @@ class ManageGearConventionMode extends ConsumerWidget {
271272
builder: (context, connectivityState, child) => Switch(
272273
value: device.baseStoredDevice.conModeEnabled,
273274
onChanged: connectivityState == ConnectivityState.connected
274-
? (value) {
275+
? (value) async {
275276
//reject if gear disconnected
276277
if (value) {
277278
BluetoothMessage bluetoothMessage = BluetoothMessage(message: "SETPUSSKEY ${device.baseStoredDevice.conModePin}", device: device, timestamp: DateTime.timestamp());
278279
device.commandQueue.addCommand(bluetoothMessage);
279280
device.baseStoredDevice.conModeEnabled = true;
280281
ref.read(knownDevicesProvider.notifier).store();
282+
await Clipboard.setData(ClipboardData(text: device.baseStoredDevice.conModePin));
281283
} else {
282284
BluetoothMessage bluetoothMessage = BluetoothMessage(message: "STOPPUSSKEY", device: device, timestamp: DateTime.timestamp());
283285
device.commandQueue.addCommand(bluetoothMessage);

lib/Frontend/Widgets/pincode_dialog.dart

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import 'package:flutter/material.dart';
2+
import 'package:flutter/services.dart';
23
import 'package:go_router/go_router.dart';
34

45
import '../translation_string_definitions.dart';
@@ -12,7 +13,16 @@ class PincodeDialog extends StatelessWidget {
1213
Widget build(BuildContext context) {
1314
return AlertDialog(
1415
actionsAlignment: MainAxisAlignment.center,
15-
actions: [TextButton(onPressed: () => context.pop(), child: Text(ok()))],
16+
actions: [
17+
TextButton(
18+
onPressed: () async => await Clipboard.setData(ClipboardData(text: pin)),
19+
child: Text(manageGearConModePincodeCopy()),
20+
),
21+
TextButton(
22+
onPressed: () => context.pop(),
23+
child: Text(ok()),
24+
),
25+
],
1626
title: Text(manageGearConModePincodeTitle()),
1727
content: Column(
1828
crossAxisAlignment: CrossAxisAlignment.center,

lib/Frontend/translation_string_definitions.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,4 +397,6 @@ String manageGearConModeDescription() => Intl.message('Convention Mode is an add
397397

398398
String manageGearConModePincodeTitle() => Intl.message('View Pin Code', name: 'manageGearConModePincodeTitle', desc: 'The description for the pin mode button on the gear page');
399399

400+
String manageGearConModePincodeCopy() => Intl.message('Copy to Clipboard', name: 'manageGearConModePincodeCopy', desc: 'The description for copy to clipboard button on the pin code dialog');
401+
400402
String manageGearConModeToggleTitle() => Intl.message('Enable Convention Mode', name: 'manageGearConModeToggleTitle', desc: 'The description for the convention mode enabled button on the gear page');

0 commit comments

Comments
 (0)