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