mirror of
https://github.com/maxgoedjen/secretive.git
synced 2026-03-05 09:24:49 +01:00
Structure
This commit is contained in:
@@ -1,13 +1,6 @@
|
||||
//
|
||||
// AppDelegate.swift
|
||||
// Secretive
|
||||
//
|
||||
// Created by Max Goedjen on 2/18/20.
|
||||
// Copyright © 2020 Max Goedjen. All rights reserved.
|
||||
//
|
||||
|
||||
import Cocoa
|
||||
import SwiftUI
|
||||
import SecretKit
|
||||
|
||||
@NSApplicationMain
|
||||
class AppDelegate: NSObject, NSApplicationDelegate {
|
||||
@@ -16,10 +9,11 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
||||
|
||||
|
||||
func applicationDidFinishLaunching(_ aNotification: Notification) {
|
||||
// Create the SwiftUI view that provides the window contents.
|
||||
let contentView = ContentView()
|
||||
|
||||
// Create the window and set the content view.
|
||||
let secureEnclave = SecureEnclave.Store()
|
||||
let contentView = ContentView(store: secureEnclave)
|
||||
|
||||
// Create the window and set the content view.
|
||||
window = NSWindow(
|
||||
contentRect: NSRect(x: 0, y: 0, width: 480, height: 300),
|
||||
styleMask: [.titled, .closable, .miniaturizable, .resizable, .fullSizeContentView],
|
||||
|
||||
@@ -7,17 +7,33 @@
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
import SecretKit
|
||||
|
||||
struct ContentView<StoreType: SecretStore>: View {
|
||||
|
||||
@ObservedObject var store: StoreType
|
||||
|
||||
@State var pk: String = ""
|
||||
|
||||
struct ContentView: View {
|
||||
var body: some View {
|
||||
Text("Hello, World!")
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||||
HSplitView {
|
||||
List {
|
||||
ForEach(store.secrets) { secret in
|
||||
Text(secret.id)
|
||||
}
|
||||
}.listStyle(SidebarListStyle())
|
||||
Form {
|
||||
Text("Public Key")
|
||||
}
|
||||
}
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
struct ContentView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
ContentView()
|
||||
ContentView(store: Preview.Store(numberOfRandomSecrets: 10))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
36
Secretive/Preview Content/PreviewStore.swift
Normal file
36
Secretive/Preview Content/PreviewStore.swift
Normal file
@@ -0,0 +1,36 @@
|
||||
import Foundation
|
||||
import SecretKit
|
||||
|
||||
enum Preview {}
|
||||
|
||||
extension Preview {
|
||||
|
||||
struct Secret: SecretKit.Secret {
|
||||
|
||||
let id = UUID().uuidString
|
||||
var name: String {
|
||||
return id
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
extension Preview {
|
||||
|
||||
class Store: SecretStore, ObservableObject {
|
||||
|
||||
@Published var secrets: [Secret] = []
|
||||
|
||||
init(secrets: [Secret]) {
|
||||
self.secrets.append(contentsOf: secrets)
|
||||
}
|
||||
|
||||
init(numberOfRandomSecrets: Int) {
|
||||
let new = (0...numberOfRandomSecrets).map { _ in Secret() }
|
||||
self.secrets.append(contentsOf: new)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user