mirror of
https://github.com/leonboe1/QuickDrop.git
synced 2026-11-11 02:51:11 +00:00
Cleanup TrustedDevicesView
This commit is contained in:
1 parent
0e1fab8faa
commit
02e8af22ab
3 files changed
+35
-55
No files matched your search
@@ -1719,8 +1719,8 @@
|
||||
MTL_FAST_MATH = YES;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
SDKROOT = macosx;
|
||||
SHARED_BUILD = 111;
|
||||
SHARED_VERSION = 2.10.6;
|
||||
SHARED_BUILD = 112;
|
||||
SHARED_VERSION = 2.11;
|
||||
STRING_CATALOG_GENERATE_SYMBOLS = YES;
|
||||
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
|
||||
SWIFT_EMIT_LOC_STRINGS = YES;
|
||||
@@ -1782,8 +1782,8 @@
|
||||
MTL_ENABLE_DEBUG_INFO = NO;
|
||||
MTL_FAST_MATH = YES;
|
||||
SDKROOT = macosx;
|
||||
SHARED_BUILD = 111;
|
||||
SHARED_VERSION = 2.10.6;
|
||||
SHARED_BUILD = 112;
|
||||
SHARED_VERSION = 2.11;
|
||||
STRING_CATALOG_GENERATE_SYMBOLS = YES;
|
||||
SWIFT_COMPILATION_MODE = wholemodule;
|
||||
SWIFT_EMIT_LOC_STRINGS = YES;
|
||||
|
||||
@@ -124,7 +124,7 @@
|
||||
"location" : "https://github.com/siteline/swiftui-introspect",
|
||||
"state" : {
|
||||
"branch" : "main",
|
||||
"revision" : "b10fc8a284abb9bd908d77243d2ba3b3d8ea6ebc"
|
||||
"revision" : "6ba9bd2a09c5c1f9a3542cc841b5c5e2c44ac744"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
@@ -5,10 +5,8 @@
|
||||
// Created by Leon Böttger on 23.08.25.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
#if !os(macOS)
|
||||
import LUI
|
||||
#endif
|
||||
import SwiftUI
|
||||
|
||||
struct TrustedDevicesView: View {
|
||||
@StateObject private var store = TrustStore.shared
|
||||
@@ -17,38 +15,28 @@ struct TrustedDevicesView: View {
|
||||
@State private var showRemoveAlert = false
|
||||
|
||||
var body: some View {
|
||||
VStack {
|
||||
if store.trustedCertificates.isEmpty {
|
||||
VStack(spacing: 12) {
|
||||
Text("NoTrustedDevices")
|
||||
.font(.headline)
|
||||
.foregroundColor(.secondary)
|
||||
Text("TrustedDevicesDescription")
|
||||
.font(.subheadline)
|
||||
.foregroundColor(.secondary)
|
||||
NavigationSubView(header: isMac() ? "" : "TrustedDevices") {
|
||||
VStack {
|
||||
if store.trustedCertificates.isEmpty {
|
||||
VStack(spacing: 12) {
|
||||
Text("NoTrustedDevices")
|
||||
.font(.headline)
|
||||
.foregroundColor(.secondary)
|
||||
Text("TrustedDevicesDescription")
|
||||
.font(.subheadline)
|
||||
.foregroundColor(.secondary)
|
||||
}
|
||||
.multilineTextAlignment(.center)
|
||||
.padding()
|
||||
.frame(maxHeight: .infinity)
|
||||
} else {
|
||||
CustomSection(footer: "TrustedDevicesDescription") {
|
||||
devicesView
|
||||
.padding(.vertical, 4)
|
||||
}
|
||||
}
|
||||
.multilineTextAlignment(.center)
|
||||
.padding()
|
||||
.frame(maxHeight: .infinity)
|
||||
} else {
|
||||
|
||||
#if !os(macOS)
|
||||
CustomSection(footer: "TrustedDevicesDescription") {
|
||||
devicesView
|
||||
.padding(.vertical, 4)
|
||||
}
|
||||
#else
|
||||
List {
|
||||
devicesView
|
||||
|
||||
Text("TrustedDevicesDescription")
|
||||
.font(.footnote)
|
||||
.fixedSize(horizontal: false, vertical: true)
|
||||
.foregroundColor(.secondary)
|
||||
.padding(.top, 4)
|
||||
}
|
||||
#endif
|
||||
}
|
||||
.padding(.top, isMac() ? 18 : 0)
|
||||
}
|
||||
.animation(.default, value: store.trustedCertificates)
|
||||
.alert(isPresented: $showRemoveAlert) {
|
||||
@@ -71,32 +59,24 @@ struct TrustedDevicesView: View {
|
||||
if let cert = store.trustedCertificates[key] {
|
||||
HStack {
|
||||
VStack(alignment: .leading, spacing: 4) {
|
||||
Text(cert.device.name ?? "Unknown".localized())
|
||||
.font(.headline)
|
||||
|
||||
// macOS 11: use DateFormatter instead of .formatted
|
||||
Text(Self.dateFormatter.string(from: cert.creationDate))
|
||||
.font(.subheadline)
|
||||
.foregroundColor(.secondary)
|
||||
LUIText(cert.device.name ?? "Unknown".localized(), isBold: true)
|
||||
LUIText(Self.dateFormatter.string(from: cert.creationDate), color: .mainColor.opacity(0.7))
|
||||
}
|
||||
|
||||
Spacer()
|
||||
Button(action: {
|
||||
|
||||
LUIButton {
|
||||
deviceToRemove = key
|
||||
showRemoveAlert = true
|
||||
}) {
|
||||
Image(systemName: "minus.circle.fill")
|
||||
.font(.system(size: 20))
|
||||
.foregroundColor(.red)
|
||||
} label: {
|
||||
ReorderListIcon(imageName: "minus.circle.fill", color: .red)
|
||||
}
|
||||
.buttonStyle(BorderlessButtonStyle())
|
||||
}
|
||||
.padding(.vertical, 8)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: - DateFormatter for macOS 11
|
||||
private static let dateFormatter: DateFormatter = {
|
||||
let formatter = DateFormatter()
|
||||
formatter.dateStyle = .medium
|
||||
@@ -107,7 +87,7 @@ struct TrustedDevicesView: View {
|
||||
|
||||
|
||||
#Preview {
|
||||
TrustedDevicesView()
|
||||
TrustedDevicesView()
|
||||
.onAppear {
|
||||
|
||||
var cert1 = Sharing_Nearby_PublicCertificate()
|
||||
@@ -120,6 +100,6 @@ struct TrustedDevicesView: View {
|
||||
cert2.secretID = Data([0x0A, 0x0B, 0x0C, 0x0D])
|
||||
|
||||
TrustStore.shared.addTrusted(certificate: cert2, device: RemoteDeviceInfo(name: "iPhone", type: .phone))
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user