Merge profile to dashboard
This commit is contained in:
@@ -0,0 +1,78 @@
|
||||
import Foundation
|
||||
import Libbox
|
||||
import Library
|
||||
import QRCode
|
||||
import SwiftUI
|
||||
|
||||
private extension CGColor {
|
||||
static var labelColor: CGColor {
|
||||
#if canImport(UIKit)
|
||||
UIColor.label.cgColor
|
||||
#elseif canImport(AppKit)
|
||||
NSColor.labelColor.cgColor
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@MainActor
|
||||
public struct QRCodeContentView: View {
|
||||
private let profileName: String
|
||||
private let remoteURL: String
|
||||
|
||||
public init(profileName: String, remoteURL: String) {
|
||||
self.profileName = profileName
|
||||
self.remoteURL = remoteURL
|
||||
}
|
||||
|
||||
public var body: some View {
|
||||
VStack {
|
||||
Spacer()
|
||||
QRCodeViewUI(
|
||||
content: LibboxGenerateRemoteProfileImportLink(profileName, remoteURL),
|
||||
errorCorrection: .low,
|
||||
foregroundColor: .labelColor,
|
||||
backgroundColor: CGColor(gray: 1.0, alpha: 0.0)
|
||||
)
|
||||
#if os(macOS)
|
||||
.frame(minWidth: 300, minHeight: 300)
|
||||
#endif
|
||||
Spacer()
|
||||
}
|
||||
.padding()
|
||||
}
|
||||
}
|
||||
|
||||
@MainActor
|
||||
public struct QRCodeSheet: View {
|
||||
private let profileName: String
|
||||
private let remoteURL: String
|
||||
|
||||
public init(profileName: String, remoteURL: String) {
|
||||
self.profileName = profileName
|
||||
self.remoteURL = remoteURL
|
||||
}
|
||||
|
||||
public var body: some View {
|
||||
#if os(iOS) || os(tvOS)
|
||||
if #available(iOS 16.0, tvOS 17.0, *) {
|
||||
NavigationStackCompat {
|
||||
QRCodeContentView(profileName: profileName, remoteURL: remoteURL)
|
||||
.navigationTitle("Share QR Code")
|
||||
#if os(iOS)
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
#endif
|
||||
}
|
||||
.presentationDetents([.medium])
|
||||
.presentationDragIndicator(.visible)
|
||||
} else {
|
||||
NavigationStackCompat {
|
||||
QRCodeContentView(profileName: profileName, remoteURL: remoteURL)
|
||||
.navigationTitle("Share QR Code")
|
||||
#if os(iOS)
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user