mirror of
https://github.com/maxgoedjen/secretive.git
synced 2025-04-10 17:47:19 +00:00
.
This commit is contained in:
parent
9c5eceb4a2
commit
0bbf950216
@ -75,6 +75,7 @@
|
|||||||
ignoresPersistentStateOnLaunch = "NO"
|
ignoresPersistentStateOnLaunch = "NO"
|
||||||
debugDocumentVersioning = "YES"
|
debugDocumentVersioning = "YES"
|
||||||
debugServiceExtension = "internal"
|
debugServiceExtension = "internal"
|
||||||
|
enableGPUValidationMode = "1"
|
||||||
allowLocationSimulation = "YES">
|
allowLocationSimulation = "YES">
|
||||||
<BuildableProductRunnable
|
<BuildableProductRunnable
|
||||||
runnableDebuggingMode = "0">
|
runnableDebuggingMode = "0">
|
||||||
|
@ -2,13 +2,13 @@ import SwiftUI
|
|||||||
import SecretKit
|
import SecretKit
|
||||||
|
|
||||||
struct CreateSecretView<StoreType: SecretStoreModifiable>: View {
|
struct CreateSecretView<StoreType: SecretStoreModifiable>: View {
|
||||||
|
|
||||||
@ObservedObject var store: StoreType
|
@ObservedObject var store: StoreType
|
||||||
@Binding var showing: Bool
|
@Binding var showing: Bool
|
||||||
|
|
||||||
@State private var name = ""
|
@State private var name = ""
|
||||||
@State private var requiresAuthentication = true
|
@State private var requiresAuthentication = true
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
VStack {
|
VStack {
|
||||||
HStack {
|
HStack {
|
||||||
@ -56,7 +56,7 @@ struct CreateSecretView<StoreType: SecretStoreModifiable>: View {
|
|||||||
}
|
}
|
||||||
}.padding()
|
}.padding()
|
||||||
}
|
}
|
||||||
|
|
||||||
func save() {
|
func save() {
|
||||||
try! store.create(name: name, requiresAuthentication: requiresAuthentication)
|
try! store.create(name: name, requiresAuthentication: requiresAuthentication)
|
||||||
showing = false
|
showing = false
|
||||||
@ -64,16 +64,16 @@ struct CreateSecretView<StoreType: SecretStoreModifiable>: View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct ThumbnailPickerView<ValueType: Hashable>: View {
|
struct ThumbnailPickerView<ValueType: Hashable>: View {
|
||||||
|
|
||||||
private let items: [Item<ValueType>]
|
private let items: [Item<ValueType>]
|
||||||
@Binding var selection: ValueType
|
@Binding var selection: ValueType
|
||||||
|
|
||||||
init(items: [ThumbnailPickerView<ValueType>.Item<ValueType>], selection: Binding<ValueType>) {
|
init(items: [ThumbnailPickerView<ValueType>.Item<ValueType>], selection: Binding<ValueType>) {
|
||||||
self.items = items
|
self.items = items
|
||||||
_selection = selection
|
_selection = selection
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
HStack(alignment: .top) {
|
HStack(alignment: .top) {
|
||||||
ForEach(items) { item in
|
ForEach(items) { item in
|
||||||
@ -96,18 +96,18 @@ struct ThumbnailPickerView<ValueType: Hashable>: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
extension ThumbnailPickerView {
|
extension ThumbnailPickerView {
|
||||||
|
|
||||||
struct Item<ValueType: Hashable>: Identifiable {
|
struct Item<ValueType: Hashable>: Identifiable {
|
||||||
let id = UUID()
|
let id = UUID()
|
||||||
let value: ValueType
|
let value: ValueType
|
||||||
let name: String
|
let name: String
|
||||||
let description: String
|
let description: String
|
||||||
let thumbnail: AnyView
|
let thumbnail: AnyView
|
||||||
|
|
||||||
init<ViewType: View>(value: ValueType, name: String, description: String, thumbnail: ViewType) {
|
init<ViewType: View>(value: ValueType, name: String, description: String, thumbnail: ViewType) {
|
||||||
self.value = value
|
self.value = value
|
||||||
self.name = name
|
self.name = name
|
||||||
@ -115,32 +115,36 @@ extension ThumbnailPickerView {
|
|||||||
self.thumbnail = AnyView(thumbnail)
|
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)
|
||||||
|
} else {
|
||||||
|
image = nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@available(macOS 12.0, *)
|
@available(macOS 12.0, *)
|
||||||
struct SystemBackgroundView: View {
|
struct SystemBackgroundView: View {
|
||||||
|
|
||||||
let anchor: UnitPoint
|
let anchor: UnitPoint
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
if let mainScreen = NSScreen.main, let imageURL = NSWorkspace.shared.desktopImageURL(for: mainScreen) {
|
if let x = SystemBackground.shared.image {
|
||||||
AsyncImage(url: imageURL) { phase in
|
Image(nsImage: x)
|
||||||
switch phase {
|
.resizable()
|
||||||
case .empty, .failure:
|
.scaleEffect(3, anchor: anchor)
|
||||||
Rectangle()
|
.clipped()
|
||||||
.foregroundColor(Color(.systemPurple))
|
.allowsHitTesting(false)
|
||||||
case .success(let image):
|
|
||||||
image
|
|
||||||
.resizable()
|
|
||||||
.scaleEffect(3, anchor: anchor)
|
|
||||||
.clipped()
|
|
||||||
.allowsHitTesting(false)
|
|
||||||
@unknown default:
|
|
||||||
Rectangle()
|
|
||||||
.foregroundColor(Color(.systemPurple))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
Rectangle()
|
Rectangle()
|
||||||
.foregroundColor(Color(.systemPurple))
|
.foregroundColor(Color(.systemPurple))
|
||||||
@ -150,7 +154,7 @@ struct SystemBackgroundView: View {
|
|||||||
|
|
||||||
@available(macOS 12.0, *)
|
@available(macOS 12.0, *)
|
||||||
struct AuthenticationView: View {
|
struct AuthenticationView: View {
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
ZStack {
|
ZStack {
|
||||||
SystemBackgroundView(anchor: .center)
|
SystemBackgroundView(anchor: .center)
|
||||||
@ -188,15 +192,15 @@ struct AuthenticationView: View {
|
|||||||
.foregroundStyle(.ultraThickMaterial)
|
.foregroundStyle(.ultraThickMaterial)
|
||||||
)
|
)
|
||||||
.padding()
|
.padding()
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@available(macOS 12.0, *)
|
@available(macOS 12.0, *)
|
||||||
struct NotificationView: View {
|
struct NotificationView: View {
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
ZStack {
|
ZStack {
|
||||||
SystemBackgroundView(anchor: .topTrailing)
|
SystemBackgroundView(anchor: .topTrailing)
|
||||||
@ -222,11 +226,11 @@ struct NotificationView: View {
|
|||||||
.foregroundColor(.primary)
|
.foregroundColor(.primary)
|
||||||
}
|
}
|
||||||
}.padding()
|
}.padding()
|
||||||
.redacted(reason: .placeholder)
|
.redacted(reason: .placeholder)
|
||||||
.background(
|
.background(
|
||||||
RoundedRectangle(cornerRadius: 15)
|
RoundedRectangle(cornerRadius: 15)
|
||||||
.foregroundStyle(.ultraThickMaterial)
|
.foregroundStyle(.ultraThickMaterial)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
Spacer()
|
Spacer()
|
||||||
}
|
}
|
||||||
@ -234,13 +238,13 @@ struct NotificationView: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
|
|
||||||
struct CreateSecretView_Previews: PreviewProvider {
|
struct CreateSecretView_Previews: PreviewProvider {
|
||||||
|
|
||||||
static var previews: some View {
|
static var previews: some View {
|
||||||
Group {
|
Group {
|
||||||
CreateSecretView(store: Preview.StoreModifiable(), showing: .constant(true))
|
CreateSecretView(store: Preview.StoreModifiable(), showing: .constant(true))
|
||||||
|
Loading…
Reference in New Issue
Block a user