Polish Password Checker Demo

This commit is contained in:
david-swift 2024-07-04 21:45:13 +02:00
parent 8014a6ea4d
commit c17730e89d

View File

@ -70,6 +70,8 @@ struct PasswordCheckerDemo: View {
struct WindowContent: View { struct WindowContent: View {
@State private var password = "" @State private var password = ""
@State private var copied: Signal = .init()
var checkStatus: [String: Bool] { var checkStatus: [String: Bool] {
PasswordChecker.allCases.enumerated().reduce([String: Bool]()) { dict, checker in PasswordChecker.allCases.enumerated().reduce([String: Bool]()) { dict, checker in
var dict = dict var dict = dict
@ -86,14 +88,17 @@ struct PasswordCheckerDemo: View {
.suffix { .suffix {
Button(icon: .default(icon: .editCopy)) { Button(icon: .default(icon: .editCopy)) {
State<Any>.copy(password) State<Any>.copy(password)
copied.signal()
} }
.flat() .flat()
.verticalCenter() .verticalCenter()
.tooltip("Copy")
Button(icon: .default(icon: .editClear)) { Button(icon: .default(icon: .editClear)) {
password = "" password = ""
} }
.flat() .flat()
.verticalCenter() .verticalCenter()
.tooltip("Clear")
} }
} }
} }
@ -108,6 +113,7 @@ struct PasswordCheckerDemo: View {
} }
} }
.padding() .padding()
.toast("Copied to clipboard", signal: copied)
.frame(minWidth: 340, minHeight: 400) .frame(minWidth: 340, minHeight: 400)
.topToolbar { .topToolbar {
HeaderBar.empty() HeaderBar.empty()