mirror of
https://github.com/maxgoedjen/secretive.git
synced 2024-11-22 13:37:07 +00:00
WIP
This commit is contained in:
parent
e94346583e
commit
ee850e58d1
@ -8,33 +8,36 @@ struct CreateSecretView<StoreType: SecretStoreModifiable>: View {
|
|||||||
|
|
||||||
@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"))
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
VStack {
|
VStack {
|
||||||
HStack {
|
HStack {
|
||||||
Image(nsImage: NSApplication.shared.applicationIconImage)
|
|
||||||
.resizable()
|
|
||||||
.frame(width: 64, height: 64)
|
|
||||||
.padding()
|
|
||||||
VStack {
|
VStack {
|
||||||
HStack {
|
HStack {
|
||||||
Text("Create a New Secret").bold()
|
Text("Create a New Secret")
|
||||||
|
.font(.largeTitle)
|
||||||
Spacer()
|
Spacer()
|
||||||
}
|
}
|
||||||
HStack {
|
HStack {
|
||||||
Text("Name:")
|
Text("Name:")
|
||||||
TextField("Shhhhh", text: $name).focusable()
|
TextField("Shhhhh", text: $name)
|
||||||
}
|
.focusable()
|
||||||
HStack {
|
|
||||||
VStack(spacing: 20) {
|
|
||||||
Picker("", selection: $requiresAuthentication) {
|
|
||||||
Text("Requires Authentication (Biometrics or Password) before each use").tag(true)
|
|
||||||
Text("Authentication not required when Mac is unlocked").tag(false)
|
|
||||||
}
|
|
||||||
.pickerStyle(RadioGroupPickerStyle())
|
|
||||||
}
|
|
||||||
Spacer()
|
|
||||||
}
|
}
|
||||||
|
ThumbnailPickerView(items: [
|
||||||
|
ThumbnailPickerView.Item(name: "Requires Authentication Before Use", thumbnail: Text("")),
|
||||||
|
ThumbnailPickerView.Item(name: "Notify on Use", thumbnail: Text(""))
|
||||||
|
], selection: $test)
|
||||||
|
// HStack {
|
||||||
|
// VStack(spacing: 20) {
|
||||||
|
// Picker("", selection: $requiresAuthentication) {
|
||||||
|
// Text("Requires Authentication (Biometrics or Password) before each use").tag(true)
|
||||||
|
// Text("Authentication not required when Mac is unlocked").tag(false)
|
||||||
|
// }
|
||||||
|
// .pickerStyle(SegmentedPickerStyle())
|
||||||
|
// }
|
||||||
|
// Spacer()
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
HStack {
|
HStack {
|
||||||
@ -56,6 +59,95 @@ struct CreateSecretView<StoreType: SecretStoreModifiable>: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct ThumbnailPickerView: View {
|
||||||
|
|
||||||
|
let items: [Item]
|
||||||
|
let selection: Binding<Item>
|
||||||
|
|
||||||
|
var body: some View {
|
||||||
|
HStack {
|
||||||
|
ForEach(items) { item in
|
||||||
|
Text(item.name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
extension ThumbnailPickerView {
|
||||||
|
|
||||||
|
struct Item: Identifiable {
|
||||||
|
let id = UUID()
|
||||||
|
let name: String
|
||||||
|
let thumbnail: AnyView
|
||||||
|
|
||||||
|
init<ViewType: View>(name: String, thumbnail: ViewType) {
|
||||||
|
self.name = name
|
||||||
|
self.thumbnail = AnyView(thumbnail)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@available(macOS 12.0, *)
|
||||||
|
struct AuthenticationView: View {
|
||||||
|
|
||||||
|
var body: some View {
|
||||||
|
ZStack {
|
||||||
|
if let mainScreen = NSScreen.main, let imageURL = NSWorkspace.shared.desktopImageURL(for: mainScreen) {
|
||||||
|
AsyncImage(url: imageURL) { phase in
|
||||||
|
switch phase {
|
||||||
|
case .empty, .failure:
|
||||||
|
Rectangle()
|
||||||
|
.foregroundColor(Color(.systemPurple))
|
||||||
|
case .success(let image):
|
||||||
|
// ScrollView {
|
||||||
|
image
|
||||||
|
.resizable()
|
||||||
|
// .scaleEffect(1)
|
||||||
|
// }
|
||||||
|
@unknown default:
|
||||||
|
Rectangle()
|
||||||
|
.foregroundColor(Color(.systemPurple))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
RoundedRectangle(cornerRadius: 15)
|
||||||
|
.aspectRatio(0.8, contentMode: .fit)
|
||||||
|
.foregroundColor(Color(.windowBackgroundColor))
|
||||||
|
.padding()
|
||||||
|
VStack {
|
||||||
|
Spacer()
|
||||||
|
Image(systemName: "touchid")
|
||||||
|
.resizable()
|
||||||
|
.aspectRatio(contentMode: .fit)
|
||||||
|
.frame(width: 100)
|
||||||
|
.foregroundColor(Color(.systemRed))
|
||||||
|
Spacer()
|
||||||
|
Text("Touch ID Prompt")
|
||||||
|
.font(.largeTitle)
|
||||||
|
.redacted(reason: .placeholder)
|
||||||
|
Spacer()
|
||||||
|
VStack {
|
||||||
|
Text("Touch ID Detail prompt.Detail two.")
|
||||||
|
.font(.title3)
|
||||||
|
Text("Touch ID Detail prompt.Detail two.")
|
||||||
|
.font(.title3)
|
||||||
|
}
|
||||||
|
.redacted(reason: .placeholder)
|
||||||
|
Spacer()
|
||||||
|
RoundedRectangle(cornerRadius: 10)
|
||||||
|
.frame(width: 275, height: 40, alignment: .center)
|
||||||
|
.foregroundColor(Color(.controlAccentColor))
|
||||||
|
RoundedRectangle(cornerRadius: 10)
|
||||||
|
.frame(width: 275, height: 40, alignment: .center)
|
||||||
|
.foregroundColor(Color(.unemphasizedSelectedContentBackgroundColor))
|
||||||
|
}.padding().padding()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
|
|
||||||
struct CreateSecretView_Previews: PreviewProvider {
|
struct CreateSecretView_Previews: PreviewProvider {
|
||||||
@ -63,6 +155,12 @@ 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))
|
||||||
|
if #available(macOS 12.0, *) {
|
||||||
|
AuthenticationView().environment(\.colorScheme, .dark)
|
||||||
|
AuthenticationView().environment(\.colorScheme, .light)
|
||||||
|
} else {
|
||||||
|
// Fallback on earlier versions
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user