mirror of
https://github.com/maxgoedjen/secretive.git
synced 2024-11-22 13:37:07 +00:00
WIP
This commit is contained in:
parent
ee850e58d1
commit
964ef1e201
@ -2,14 +2,14 @@ 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
|
||||||
@State private var test: ThumbnailPickerView.Item = ThumbnailPickerView.Item(name: "Test", thumbnail: Text("Hello"))
|
@State private var test: ThumbnailPickerView.Item = ThumbnailPickerView.Item(name: "Test", thumbnail: Text("Hello"))
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
VStack {
|
VStack {
|
||||||
HStack {
|
HStack {
|
||||||
@ -28,16 +28,16 @@ struct CreateSecretView<StoreType: SecretStoreModifiable>: View {
|
|||||||
ThumbnailPickerView.Item(name: "Requires Authentication Before Use", thumbnail: Text("")),
|
ThumbnailPickerView.Item(name: "Requires Authentication Before Use", thumbnail: Text("")),
|
||||||
ThumbnailPickerView.Item(name: "Notify on Use", thumbnail: Text(""))
|
ThumbnailPickerView.Item(name: "Notify on Use", thumbnail: Text(""))
|
||||||
], selection: $test)
|
], selection: $test)
|
||||||
// HStack {
|
// HStack {
|
||||||
// VStack(spacing: 20) {
|
// VStack(spacing: 20) {
|
||||||
// Picker("", selection: $requiresAuthentication) {
|
// Picker("", selection: $requiresAuthentication) {
|
||||||
// Text("Requires Authentication (Biometrics or Password) before each use").tag(true)
|
// Text("Requires Authentication (Biometrics or Password) before each use").tag(true)
|
||||||
// Text("Authentication not required when Mac is unlocked").tag(false)
|
// Text("Authentication not required when Mac is unlocked").tag(false)
|
||||||
// }
|
// }
|
||||||
// .pickerStyle(SegmentedPickerStyle())
|
// .pickerStyle(SegmentedPickerStyle())
|
||||||
// }
|
// }
|
||||||
// Spacer()
|
// Spacer()
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
HStack {
|
HStack {
|
||||||
@ -52,7 +52,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
|
||||||
@ -60,10 +60,10 @@ struct CreateSecretView<StoreType: SecretStoreModifiable>: View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct ThumbnailPickerView: View {
|
struct ThumbnailPickerView: View {
|
||||||
|
|
||||||
let items: [Item]
|
let items: [Item]
|
||||||
let selection: Binding<Item>
|
let selection: Binding<Item>
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
HStack {
|
HStack {
|
||||||
ForEach(items) { item in
|
ForEach(items) { item in
|
||||||
@ -71,27 +71,27 @@ struct ThumbnailPickerView: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
extension ThumbnailPickerView {
|
extension ThumbnailPickerView {
|
||||||
|
|
||||||
struct Item: Identifiable {
|
struct Item: Identifiable {
|
||||||
let id = UUID()
|
let id = UUID()
|
||||||
let name: String
|
let name: String
|
||||||
let thumbnail: AnyView
|
let thumbnail: AnyView
|
||||||
|
|
||||||
init<ViewType: View>(name: String, thumbnail: ViewType) {
|
init<ViewType: View>(name: String, thumbnail: ViewType) {
|
||||||
self.name = name
|
self.name = name
|
||||||
self.thumbnail = AnyView(thumbnail)
|
self.thumbnail = AnyView(thumbnail)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@available(macOS 12.0, *)
|
@available(macOS 12.0, *)
|
||||||
struct AuthenticationView: View {
|
struct AuthenticationView: View {
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
ZStack {
|
ZStack {
|
||||||
if let mainScreen = NSScreen.main, let imageURL = NSWorkspace.shared.desktopImageURL(for: mainScreen) {
|
if let mainScreen = NSScreen.main, let imageURL = NSWorkspace.shared.desktopImageURL(for: mainScreen) {
|
||||||
@ -101,11 +101,9 @@ struct AuthenticationView: View {
|
|||||||
Rectangle()
|
Rectangle()
|
||||||
.foregroundColor(Color(.systemPurple))
|
.foregroundColor(Color(.systemPurple))
|
||||||
case .success(let image):
|
case .success(let image):
|
||||||
// ScrollView {
|
image
|
||||||
image
|
.resizable()
|
||||||
.resizable()
|
.scaleEffect(3)
|
||||||
// .scaleEffect(1)
|
|
||||||
// }
|
|
||||||
@unknown default:
|
@unknown default:
|
||||||
Rectangle()
|
Rectangle()
|
||||||
.foregroundColor(Color(.systemPurple))
|
.foregroundColor(Color(.systemPurple))
|
||||||
@ -145,13 +143,13 @@ struct AuthenticationView: View {
|
|||||||
}.padding().padding()
|
}.padding().padding()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#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