From e2e996d43fb3faf629c8535b0836b2081da45382 Mon Sep 17 00:00:00 2001 From: Max Goedjen Date: Fri, 8 Apr 2022 18:20:40 -0700 Subject: [PATCH] . --- .../Secretive/Views/CreateSecretView.swift | 47 ++++++++++--------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/Sources/Secretive/Views/CreateSecretView.swift b/Sources/Secretive/Views/CreateSecretView.swift index eca8b10..90c81b5 100644 --- a/Sources/Secretive/Views/CreateSecretView.swift +++ b/Sources/Secretive/Views/CreateSecretView.swift @@ -2,13 +2,13 @@ import SwiftUI import SecretKit struct CreateSecretView: View { - + @ObservedObject var store: StoreType @Binding var showing: Bool - + @State private var name = "" @State private var requiresAuthentication = true - + var body: some View { VStack { HStack { @@ -56,24 +56,25 @@ struct CreateSecretView: View { } }.padding() } - + func save() { try! store.create(name: name, requiresAuthentication: requiresAuthentication) showing = false } + } struct ThumbnailPickerView: View { - + private let items: [Item] @Binding var selection: ValueType - + init(items: [ThumbnailPickerView.Item], selection: Binding) { self.items = items _selection = selection } - - + + var body: some View { HStack(alignment: .top) { ForEach(items) { item in @@ -96,18 +97,18 @@ struct ThumbnailPickerView: View { } } } - + } extension ThumbnailPickerView { - + struct Item: Identifiable { let id = UUID() let value: ValueType let name: String let description: String let thumbnail: AnyView - + init(value: ValueType, name: String, description: String, thumbnail: ViewType) { self.value = value self.name = name @@ -115,14 +116,14 @@ extension ThumbnailPickerView { self.thumbnail = AnyView(thumbnail) } } - + } @MainActor class SystemBackground: ObservableObject { - + static let shared = SystemBackground() @Published var image: NSImage? - + private init() { if let mainScreen = NSScreen.main, let imageURL = NSWorkspace.shared.desktopImageURL(for: mainScreen) { image = NSImage(contentsOf: imageURL) @@ -130,14 +131,14 @@ extension ThumbnailPickerView { image = nil } } - + } @available(macOS 12.0, *) struct SystemBackgroundView: View { - + let anchor: UnitPoint - + var body: some View { if let x = SystemBackground.shared.image { Image(nsImage: x) @@ -154,7 +155,7 @@ struct SystemBackgroundView: View { @available(macOS 12.0, *) struct AuthenticationView: View { - + var body: some View { ZStack { SystemBackgroundView(anchor: .center) @@ -192,15 +193,15 @@ struct AuthenticationView: View { .foregroundStyle(.ultraThickMaterial) ) .padding() - + } } - + } @available(macOS 12.0, *) struct NotificationView: View { - + var body: some View { ZStack { SystemBackgroundView(anchor: .topTrailing) @@ -238,13 +239,13 @@ struct NotificationView: View { } } } - + } #if DEBUG struct CreateSecretView_Previews: PreviewProvider { - + static var previews: some View { Group { CreateSecretView(store: Preview.StoreModifiable(), showing: .constant(true))