From 341dd1007460edb021497276402d427c26e966ca Mon Sep 17 00:00:00 2001 From: Andreas Bauer Date: Sun, 17 Nov 2024 12:44:24 +0100 Subject: [PATCH] Move ProgressView out of the Label, add Spacer --- .../Scanning/NearbyDeviceRow.swift | 24 +++++++++++++++++++ .../Scanning/PeripheralSecondaryLabel.swift | 3 +-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/Sources/SpeziDevicesUI/Scanning/NearbyDeviceRow.swift b/Sources/SpeziDevicesUI/Scanning/NearbyDeviceRow.swift index 0b3c1b6..483d76b 100644 --- a/Sources/SpeziDevicesUI/Scanning/NearbyDeviceRow.swift +++ b/Sources/SpeziDevicesUI/Scanning/NearbyDeviceRow.swift @@ -26,6 +26,14 @@ public struct NearbyDeviceRow: View { } .tint(.primary) + Spacer() + + if peripheral.state == .connecting || peripheral.state == .disconnecting { + ProgressView() + .accessibilityRemoveTraits(.updatesFrequently) + .foregroundStyle(.secondary) + } + if secondaryActionClosure != nil && peripheral.state == .connected { ListInfoButton(Text("Device Details", bundle: .module), action: deviceDetailsAction) } @@ -113,6 +121,22 @@ public struct NearbyDeviceRow: View { print("Clicked") } secondaryAction: { } + + let peripheral = MockBluetoothPeripheral(label: "MyDevice 2", state: .connected) + NearbyDeviceRow(peripheral: MockBluetoothPeripheral(label: "MyDevice 2", state: .connected)) { + print("Clicked") + } secondaryAction: { + print("Secondary Clicked!") + } label: { + ListRow { + PeripheralLabel(peripheral) + Text("RSSI: -64") + } content: { + PeripheralSecondaryLabel(peripheral) + } + + } + } } #endif diff --git a/Sources/SpeziDevicesUI/Scanning/PeripheralSecondaryLabel.swift b/Sources/SpeziDevicesUI/Scanning/PeripheralSecondaryLabel.swift index 4ad2860..503cdc5 100644 --- a/Sources/SpeziDevicesUI/Scanning/PeripheralSecondaryLabel.swift +++ b/Sources/SpeziDevicesUI/Scanning/PeripheralSecondaryLabel.swift @@ -37,8 +37,7 @@ public struct PeripheralSecondaryLabel: View { } else { switch peripheral.state { case .connecting, .disconnecting: - ProgressView() - .accessibilityRemoveTraits(.updatesFrequently) + EmptyView() case .connected: Text("Connected", bundle: .module) case .disconnected: