2023-06-28 18:14:15 +03:00
|
|
|
/*
|
2023-10-10 09:54:25 +03:00
|
|
|
* Copyright (C) 2022-2024 Yubico.
|
2023-06-28 18:14:15 +03:00
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2024-01-18 16:22:23 +03:00
|
|
|
import 'package:flutter/gestures.dart';
|
2023-06-28 18:14:15 +03:00
|
|
|
import 'package:flutter/material.dart';
|
2023-11-27 13:41:05 +03:00
|
|
|
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
2023-06-28 18:14:15 +03:00
|
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
2024-03-08 11:30:47 +03:00
|
|
|
import 'package:material_symbols_icons/symbols.dart';
|
2023-06-28 18:14:15 +03:00
|
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
|
|
|
2023-08-30 16:28:44 +03:00
|
|
|
import '../../android/state.dart';
|
2023-06-28 18:14:15 +03:00
|
|
|
import '../../core/state.dart';
|
|
|
|
import '../../management/models.dart';
|
|
|
|
import '../models.dart';
|
|
|
|
import '../state.dart';
|
|
|
|
import 'device_avatar.dart';
|
2023-07-03 12:27:25 +03:00
|
|
|
import 'keys.dart' as keys;
|
2024-02-02 16:28:37 +03:00
|
|
|
import 'keys.dart';
|
2023-06-28 18:14:15 +03:00
|
|
|
|
|
|
|
final _hiddenDevicesProvider =
|
|
|
|
StateNotifierProvider<_HiddenDevicesNotifier, List<String>>(
|
|
|
|
(ref) => _HiddenDevicesNotifier(ref.watch(prefProvider)));
|
|
|
|
|
|
|
|
class _HiddenDevicesNotifier extends StateNotifier<List<String>> {
|
|
|
|
static const String _key = 'DEVICE_PICKER_HIDDEN';
|
|
|
|
final SharedPreferences _prefs;
|
2023-10-10 09:54:25 +03:00
|
|
|
|
2023-06-28 18:14:15 +03:00
|
|
|
_HiddenDevicesNotifier(this._prefs) : super(_prefs.getStringList(_key) ?? []);
|
|
|
|
|
|
|
|
void showAll() {
|
|
|
|
state = [];
|
|
|
|
_prefs.setStringList(_key, state);
|
|
|
|
}
|
|
|
|
|
|
|
|
void hideDevice(DevicePath devicePath) {
|
|
|
|
state = [...state, devicePath.key];
|
|
|
|
_prefs.setStringList(_key, state);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class DevicePickerContent extends ConsumerWidget {
|
|
|
|
final bool extended;
|
2024-01-18 16:22:23 +03:00
|
|
|
|
2024-01-17 19:44:00 +03:00
|
|
|
const DevicePickerContent({super.key, this.extended = true});
|
2023-06-28 18:14:15 +03:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
|
|
|
final l10n = AppLocalizations.of(context)!;
|
|
|
|
final hidden = ref.watch(_hiddenDevicesProvider);
|
|
|
|
final devices = ref
|
|
|
|
.watch(attachedDevicesProvider)
|
|
|
|
.where((e) => !hidden.contains(e.path.key))
|
|
|
|
.toList();
|
|
|
|
final currentNode = ref.watch(currentDeviceProvider);
|
|
|
|
|
|
|
|
final showUsb = isDesktop && devices.whereType<UsbYubiKeyNode>().isEmpty;
|
|
|
|
|
2023-08-30 16:28:44 +03:00
|
|
|
Widget? androidNoKeyWidget;
|
|
|
|
if (isAndroid && devices.isEmpty) {
|
|
|
|
var hasNfcSupport = ref.watch(androidNfcSupportProvider);
|
|
|
|
var isNfcEnabled = ref.watch(androidNfcStateProvider);
|
|
|
|
final subtitle = hasNfcSupport && isNfcEnabled
|
|
|
|
? l10n.l_insert_or_tap_yk
|
|
|
|
: l10n.l_insert_yk;
|
|
|
|
|
|
|
|
androidNoKeyWidget = _DeviceRow(
|
2024-03-08 14:56:35 +03:00
|
|
|
leading: const DeviceAvatar(
|
|
|
|
child: Padding(
|
|
|
|
padding: EdgeInsets.all(8.0),
|
|
|
|
child: Icon(Symbols.usb),
|
|
|
|
)),
|
2023-08-30 16:28:44 +03:00
|
|
|
title: l10n.l_no_yk_present,
|
|
|
|
subtitle: subtitle,
|
|
|
|
onTap: () {
|
|
|
|
ref.read(currentDeviceProvider.notifier).setCurrentDevice(null);
|
|
|
|
},
|
|
|
|
selected: currentNode == null,
|
|
|
|
extended: extended,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2023-06-28 18:14:15 +03:00
|
|
|
List<Widget> children = [
|
|
|
|
if (showUsb)
|
|
|
|
_DeviceRow(
|
2024-03-08 14:56:35 +03:00
|
|
|
leading: const DeviceAvatar(
|
|
|
|
child: Padding(
|
|
|
|
padding: EdgeInsets.all(8.0),
|
|
|
|
child: Icon(Symbols.usb),
|
|
|
|
)),
|
2023-06-28 18:14:15 +03:00
|
|
|
title: l10n.s_usb,
|
|
|
|
subtitle: l10n.l_no_yk_present,
|
|
|
|
onTap: () {
|
|
|
|
ref.read(currentDeviceProvider.notifier).setCurrentDevice(null);
|
|
|
|
},
|
|
|
|
selected: currentNode == null,
|
|
|
|
extended: extended,
|
|
|
|
),
|
2023-11-27 13:41:05 +03:00
|
|
|
if (androidNoKeyWidget != null) androidNoKeyWidget,
|
2023-06-28 18:14:15 +03:00
|
|
|
...devices.map(
|
|
|
|
(e) => e.path == currentNode?.path
|
|
|
|
? _buildCurrentDeviceRow(
|
|
|
|
context,
|
|
|
|
ref,
|
|
|
|
e,
|
|
|
|
ref.watch(currentDeviceDataProvider),
|
|
|
|
extended,
|
|
|
|
)
|
|
|
|
: e.map(
|
|
|
|
usbYubiKey: (node) => _buildDeviceRow(
|
|
|
|
context,
|
|
|
|
ref,
|
|
|
|
node,
|
|
|
|
node.info,
|
|
|
|
extended,
|
|
|
|
),
|
|
|
|
nfcReader: (node) => _NfcDeviceRow(node, extended: extended),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
];
|
|
|
|
|
2024-04-10 10:39:53 +03:00
|
|
|
return Column(children: children);
|
2023-06-28 18:14:15 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
String _getDeviceInfoString(BuildContext context, DeviceInfo info) {
|
|
|
|
final l10n = AppLocalizations.of(context)!;
|
|
|
|
final serial = info.serial;
|
|
|
|
return [
|
|
|
|
if (serial != null) l10n.s_sn_serial(serial),
|
|
|
|
if (info.version.isAtLeast(1))
|
|
|
|
l10n.s_fw_version(info.version)
|
|
|
|
else
|
|
|
|
l10n.s_unknown_type,
|
|
|
|
].join(' ');
|
|
|
|
}
|
|
|
|
|
|
|
|
List<String> _getDeviceStrings(
|
|
|
|
BuildContext context, DeviceNode node, AsyncValue<YubiKeyData> data) {
|
|
|
|
final l10n = AppLocalizations.of(context)!;
|
|
|
|
final messages = data.whenOrNull(
|
|
|
|
data: (data) => [data.name, _getDeviceInfoString(context, data.info)],
|
|
|
|
error: (error, _) => switch (error) {
|
|
|
|
'device-inaccessible' => [node.name, l10n.s_yk_inaccessible],
|
|
|
|
'unknown-device' => [l10n.s_unknown_device],
|
|
|
|
_ => null,
|
|
|
|
},
|
|
|
|
) ??
|
|
|
|
[l10n.l_no_yk_present];
|
|
|
|
|
|
|
|
// Add the NFC reader name, unless it's already included (as device name, like on Android)
|
|
|
|
if (node is NfcReaderNode && !messages.contains(node.name)) {
|
|
|
|
messages.add(node.name);
|
|
|
|
}
|
|
|
|
|
|
|
|
return messages;
|
|
|
|
}
|
|
|
|
|
2024-01-18 16:22:23 +03:00
|
|
|
class _DeviceMenuButton extends ConsumerWidget {
|
2024-01-23 12:42:56 +03:00
|
|
|
final List<PopupMenuItem> menuItems;
|
2024-01-18 16:22:23 +03:00
|
|
|
final double opacity;
|
|
|
|
|
2024-01-23 12:42:56 +03:00
|
|
|
const _DeviceMenuButton({required this.menuItems, required this.opacity});
|
2024-01-18 16:22:23 +03:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
|
|
|
return Theme(
|
|
|
|
data: Theme.of(Navigator.of(context).context), // use app theme
|
|
|
|
child: Opacity(
|
|
|
|
opacity: menuItems.isNotEmpty ? opacity : 0.0,
|
|
|
|
child: PopupMenuButton(
|
2024-02-07 11:19:13 +03:00
|
|
|
key: yubikeyPopupMenuButton,
|
2024-01-18 16:22:23 +03:00
|
|
|
enabled: menuItems.isNotEmpty,
|
2024-03-08 11:30:47 +03:00
|
|
|
icon: const Icon(Symbols.more_horiz),
|
2024-01-18 16:22:23 +03:00
|
|
|
tooltip: '',
|
|
|
|
iconColor: Theme.of(context).listTileTheme.textColor,
|
|
|
|
itemBuilder: (context) {
|
|
|
|
return menuItems;
|
|
|
|
},
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-01-23 12:42:56 +03:00
|
|
|
class _DeviceRow extends ConsumerStatefulWidget {
|
2023-06-28 18:14:15 +03:00
|
|
|
final Widget leading;
|
|
|
|
final String title;
|
|
|
|
final String subtitle;
|
|
|
|
final bool extended;
|
|
|
|
final bool selected;
|
2023-10-10 09:54:25 +03:00
|
|
|
final Color? background;
|
2024-01-18 16:22:23 +03:00
|
|
|
final DeviceNode? node;
|
2023-06-28 18:14:15 +03:00
|
|
|
final void Function() onTap;
|
|
|
|
|
|
|
|
const _DeviceRow({
|
|
|
|
super.key,
|
|
|
|
required this.leading,
|
|
|
|
required this.title,
|
|
|
|
required this.subtitle,
|
|
|
|
required this.extended,
|
|
|
|
required this.selected,
|
2023-10-10 09:54:25 +03:00
|
|
|
this.background,
|
2024-01-18 16:22:23 +03:00
|
|
|
this.node,
|
2023-06-28 18:14:15 +03:00
|
|
|
required this.onTap,
|
|
|
|
});
|
|
|
|
|
2024-01-18 16:22:23 +03:00
|
|
|
@override
|
2024-01-23 12:42:56 +03:00
|
|
|
ConsumerState<_DeviceRow> createState() => _DeviceRowState();
|
2024-01-18 16:22:23 +03:00
|
|
|
}
|
|
|
|
|
2024-01-23 12:42:56 +03:00
|
|
|
class _DeviceRowState extends ConsumerState<_DeviceRow> {
|
2024-01-18 16:22:23 +03:00
|
|
|
bool _showContextMenu = false;
|
|
|
|
|
2023-06-28 18:14:15 +03:00
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2024-01-23 12:42:56 +03:00
|
|
|
final menuItems = _getMenuItems(context, ref, widget.node);
|
2024-01-18 16:22:23 +03:00
|
|
|
final tooltip = '${widget.title}\n${widget.subtitle}';
|
2024-01-16 16:11:37 +03:00
|
|
|
final themeData = Theme.of(context);
|
2024-01-18 16:22:23 +03:00
|
|
|
final seedColor = !widget.selected || widget.background == null
|
2024-01-16 16:11:37 +03:00
|
|
|
? themeData.colorScheme.primary
|
2024-01-18 16:22:23 +03:00
|
|
|
: widget.background!;
|
2024-01-16 16:11:37 +03:00
|
|
|
final colorScheme = ColorScheme.fromSeed(
|
|
|
|
seedColor: seedColor, brightness: themeData.brightness);
|
2024-01-18 16:22:23 +03:00
|
|
|
final localThemeData = widget.selected
|
2024-01-16 16:11:37 +03:00
|
|
|
? themeData.copyWith(
|
|
|
|
colorScheme: colorScheme,
|
|
|
|
listTileTheme: themeData.listTileTheme.copyWith(
|
2024-01-18 16:22:23 +03:00
|
|
|
tileColor: widget.background != null
|
2024-01-23 16:03:21 +03:00
|
|
|
? colorScheme.primary
|
2024-01-16 16:11:37 +03:00
|
|
|
: themeData.colorScheme.primary,
|
2024-01-18 16:22:23 +03:00
|
|
|
textColor: widget.selected ? colorScheme.onPrimary : null,
|
|
|
|
iconColor: widget.selected ? colorScheme.onPrimary : null,
|
2024-01-16 16:11:37 +03:00
|
|
|
),
|
|
|
|
)
|
|
|
|
: themeData;
|
2024-01-18 16:22:23 +03:00
|
|
|
if (widget.extended) {
|
2023-06-28 18:14:15 +03:00
|
|
|
return Tooltip(
|
2024-01-18 16:22:23 +03:00
|
|
|
message: '', // no tooltip for drawer
|
2024-01-16 16:11:37 +03:00
|
|
|
child: Theme(
|
|
|
|
data: localThemeData,
|
2024-01-18 16:22:23 +03:00
|
|
|
child: MouseRegion(
|
|
|
|
onEnter: (PointerEnterEvent event) {
|
|
|
|
setState(() {
|
|
|
|
_showContextMenu = true;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
onExit: (PointerExitEvent event) {
|
|
|
|
setState(() {
|
|
|
|
_showContextMenu = false;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
child: ListTile(
|
|
|
|
shape: RoundedRectangleBorder(
|
|
|
|
borderRadius: BorderRadius.circular(48)),
|
|
|
|
contentPadding:
|
|
|
|
const EdgeInsets.symmetric(horizontal: 8, vertical: 0),
|
|
|
|
horizontalTitleGap: 8,
|
|
|
|
leading: widget.leading,
|
2024-03-06 23:06:48 +03:00
|
|
|
trailing: menuItems.isNotEmpty
|
|
|
|
? _DeviceMenuButton(
|
|
|
|
menuItems: menuItems,
|
|
|
|
opacity: widget.selected
|
|
|
|
? 1.0
|
|
|
|
: _showContextMenu
|
|
|
|
? 0.3
|
|
|
|
: 0.0,
|
|
|
|
)
|
|
|
|
: null,
|
2024-01-18 16:22:23 +03:00
|
|
|
title: Text(
|
|
|
|
widget.title,
|
|
|
|
overflow: TextOverflow.fade,
|
|
|
|
softWrap: false,
|
2024-01-16 16:11:37 +03:00
|
|
|
),
|
2024-01-18 16:22:23 +03:00
|
|
|
subtitle: Text(widget.subtitle,
|
|
|
|
overflow: TextOverflow.fade, softWrap: false),
|
|
|
|
dense: true,
|
|
|
|
onTap: widget.onTap,
|
2024-01-16 14:01:27 +03:00
|
|
|
),
|
|
|
|
),
|
2023-06-28 18:14:15 +03:00
|
|
|
),
|
|
|
|
);
|
|
|
|
} else {
|
2024-01-23 19:15:26 +03:00
|
|
|
void showMenuFn(details) {
|
2024-01-23 12:42:56 +03:00
|
|
|
showMenu(
|
|
|
|
context: context,
|
|
|
|
position: RelativeRect.fromLTRB(
|
|
|
|
details.globalPosition.dx,
|
|
|
|
details.globalPosition.dy,
|
|
|
|
details.globalPosition.dx,
|
|
|
|
0,
|
|
|
|
),
|
|
|
|
items: menuItems,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return GestureDetector(
|
2024-01-23 19:15:26 +03:00
|
|
|
onSecondaryTapDown:
|
|
|
|
isDesktop && menuItems.isNotEmpty ? showMenuFn : null,
|
|
|
|
onLongPressStart: isAndroid ? showMenuFn : null,
|
2024-01-23 12:42:56 +03:00
|
|
|
child: Padding(
|
2024-04-10 10:39:53 +03:00
|
|
|
padding: const EdgeInsets.symmetric(vertical: 6.5),
|
2024-01-23 12:42:56 +03:00
|
|
|
child: widget.selected
|
|
|
|
? IconButton.filled(
|
2024-01-23 16:41:29 +03:00
|
|
|
tooltip: isDesktop ? tooltip : null,
|
2024-01-23 12:42:56 +03:00
|
|
|
icon: widget.leading,
|
2024-03-08 14:56:35 +03:00
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 8),
|
2024-01-23 12:42:56 +03:00
|
|
|
onPressed: widget.onTap,
|
|
|
|
)
|
|
|
|
: IconButton(
|
2024-01-23 16:41:29 +03:00
|
|
|
tooltip: isDesktop ? tooltip : null,
|
2024-01-23 12:42:56 +03:00
|
|
|
icon: widget.leading,
|
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 8),
|
|
|
|
onPressed: widget.onTap,
|
|
|
|
color: colorScheme.secondary,
|
|
|
|
),
|
|
|
|
),
|
2023-06-28 18:14:15 +03:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2024-01-23 12:42:56 +03:00
|
|
|
|
|
|
|
List<PopupMenuItem> _getMenuItems(
|
|
|
|
BuildContext context, WidgetRef ref, DeviceNode? node) {
|
|
|
|
final l10n = AppLocalizations.of(context)!;
|
|
|
|
final hidden = ref.watch(_hiddenDevicesProvider);
|
|
|
|
|
|
|
|
return [
|
2024-01-23 16:41:29 +03:00
|
|
|
if (isDesktop && hidden.isNotEmpty)
|
2024-01-23 12:42:56 +03:00
|
|
|
PopupMenuItem(
|
|
|
|
enabled: hidden.isNotEmpty,
|
|
|
|
onTap: () {
|
|
|
|
ref.read(_hiddenDevicesProvider.notifier).showAll();
|
|
|
|
},
|
|
|
|
child: ListTile(
|
|
|
|
title: Text(l10n.s_show_hidden_devices),
|
2024-03-08 11:30:47 +03:00
|
|
|
leading: const Icon(Symbols.visibility),
|
2024-01-23 12:42:56 +03:00
|
|
|
dense: true,
|
|
|
|
contentPadding: EdgeInsets.zero,
|
|
|
|
enabled: hidden.isNotEmpty,
|
|
|
|
),
|
|
|
|
),
|
2024-01-23 16:41:29 +03:00
|
|
|
if (isDesktop && node is NfcReaderNode)
|
2024-01-23 12:42:56 +03:00
|
|
|
PopupMenuItem(
|
|
|
|
onTap: () {
|
|
|
|
ref.read(_hiddenDevicesProvider.notifier).hideDevice(node.path);
|
|
|
|
},
|
|
|
|
child: ListTile(
|
|
|
|
title: Text(l10n.s_hide_device),
|
2024-03-08 11:30:47 +03:00
|
|
|
leading: const Icon(Symbols.visibility_off),
|
2024-01-23 12:42:56 +03:00
|
|
|
dense: true,
|
|
|
|
contentPadding: EdgeInsets.zero,
|
|
|
|
),
|
2024-01-24 16:30:01 +03:00
|
|
|
),
|
2024-01-23 12:42:56 +03:00
|
|
|
];
|
|
|
|
}
|
2023-06-28 18:14:15 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
_DeviceRow _buildDeviceRow(
|
|
|
|
BuildContext context,
|
|
|
|
WidgetRef ref,
|
|
|
|
DeviceNode node,
|
|
|
|
DeviceInfo? info,
|
|
|
|
bool extended,
|
|
|
|
) {
|
|
|
|
final l10n = AppLocalizations.of(context)!;
|
|
|
|
final subtitle = node.when(
|
|
|
|
usbYubiKey: (_, __, ___, info) => info == null
|
|
|
|
? l10n.s_yk_inaccessible
|
|
|
|
: _getDeviceInfoString(context, info),
|
|
|
|
nfcReader: (_, __) => l10n.s_select_to_scan,
|
|
|
|
);
|
2023-10-10 09:54:25 +03:00
|
|
|
|
2024-01-23 14:36:13 +03:00
|
|
|
final keyCustomization =
|
2024-01-24 19:13:03 +03:00
|
|
|
ref.watch(keyCustomizationManagerProvider)[info?.serial];
|
2024-01-24 13:14:55 +03:00
|
|
|
String displayName = keyCustomization?.name ?? node.name;
|
2023-10-10 09:54:25 +03:00
|
|
|
|
2023-06-28 18:14:15 +03:00
|
|
|
return _DeviceRow(
|
|
|
|
key: ValueKey(node.path.key),
|
2024-01-17 19:44:00 +03:00
|
|
|
leading: DeviceAvatar.deviceNode(node),
|
2023-10-10 09:54:25 +03:00
|
|
|
title: displayName,
|
2023-06-28 18:14:15 +03:00
|
|
|
subtitle: subtitle,
|
|
|
|
extended: extended,
|
|
|
|
selected: false,
|
2024-01-18 16:22:23 +03:00
|
|
|
node: node,
|
2023-06-28 18:14:15 +03:00
|
|
|
onTap: () {
|
|
|
|
ref.read(currentDeviceProvider.notifier).setCurrentDevice(node);
|
|
|
|
},
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
_DeviceRow _buildCurrentDeviceRow(
|
|
|
|
BuildContext context,
|
|
|
|
WidgetRef ref,
|
|
|
|
DeviceNode node,
|
|
|
|
AsyncValue<YubiKeyData> data,
|
|
|
|
bool extended,
|
|
|
|
) {
|
|
|
|
final messages = _getDeviceStrings(context, node, data);
|
|
|
|
if (messages.length > 2) {
|
2024-01-16 12:28:22 +03:00
|
|
|
// Don't show reader name
|
2023-06-28 18:14:15 +03:00
|
|
|
messages.removeLast();
|
|
|
|
}
|
|
|
|
final title = messages.removeAt(0);
|
|
|
|
final subtitle = messages.join('\n');
|
|
|
|
|
2024-01-23 14:36:13 +03:00
|
|
|
final keyCustomization =
|
2024-01-24 21:21:45 +03:00
|
|
|
ref.watch(keyCustomizationManagerProvider)[data.valueOrNull?.info.serial];
|
2024-01-24 13:14:55 +03:00
|
|
|
String displayName = keyCustomization?.name ?? title;
|
|
|
|
Color? displayColor = keyCustomization?.color;
|
2023-10-10 09:54:25 +03:00
|
|
|
|
2023-06-28 18:14:15 +03:00
|
|
|
return _DeviceRow(
|
2023-07-03 12:27:25 +03:00
|
|
|
key: keys.deviceInfoListTile,
|
2023-06-28 18:14:15 +03:00
|
|
|
leading: data.maybeWhen(
|
|
|
|
data: (data) =>
|
2024-01-17 19:44:00 +03:00
|
|
|
DeviceAvatar.yubiKeyData(data, radius: extended ? null : 16),
|
|
|
|
orElse: () => DeviceAvatar.deviceNode(node, radius: extended ? null : 16),
|
2023-06-28 18:14:15 +03:00
|
|
|
),
|
2023-10-10 09:54:25 +03:00
|
|
|
title: displayName,
|
2023-06-28 18:14:15 +03:00
|
|
|
subtitle: subtitle,
|
|
|
|
extended: extended,
|
2023-10-10 09:54:25 +03:00
|
|
|
background: displayColor,
|
2023-06-28 18:14:15 +03:00
|
|
|
selected: true,
|
2024-01-18 16:22:23 +03:00
|
|
|
node: node,
|
2023-06-28 18:14:15 +03:00
|
|
|
onTap: () {},
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
class _NfcDeviceRow extends ConsumerWidget {
|
|
|
|
final DeviceNode node;
|
|
|
|
final bool extended;
|
|
|
|
|
|
|
|
const _NfcDeviceRow(this.node, {required this.extended});
|
|
|
|
|
|
|
|
@override
|
2024-01-18 16:22:23 +03:00
|
|
|
Widget build(BuildContext context, WidgetRef ref) =>
|
|
|
|
_buildDeviceRow(context, ref, node, null, extended);
|
2023-06-28 18:14:15 +03:00
|
|
|
}
|