PWD-7: apply styling to add-password form (#8)

This commit is contained in:
Markus Thielker 2025-01-24 17:51:30 +01:00 committed by GitHub
commit 2d11418aa6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -20,30 +20,44 @@ struct AddPasswordView: View {
VStack { VStack {
VStack { VStack {
Text("Add Password") Text("Add Password")
.font(.headline) .font(.title2)
Text("Create a new password to learn. It will be encrypted and stored securely.") Text("Create a new password to learn.")
Text("It will be encrypted and stored securely.")
} }
.padding(EdgeInsets(top: 0, leading: 0, bottom: 10, trailing: 0)) .padding(EdgeInsets(top: 0, leading: 0, bottom: 10, trailing: 0))
Form { Form {
TextField("Name", text: $name) TextField("Name", text: $name)
.textFieldStyle(PwdTextFieldStyle()) .textFieldStyle(PwdTextFieldStyle())
TextField("Value", text: $value) TextField("Value", text: $value)
.textFieldStyle(PwdTextFieldStyle()) .textFieldStyle(PwdTextFieldStyle())
}
Text("The password will not be visible again later. Make sure to save it somewhere else too!") Text("The password will not be visible again later. Make sure to save it somewhere else too!")
.font(.footnote) .font(.footnote)
HStack { HStack {
Button("Save") { PwdButton(label: Text("Save")) {
if name.isEmpty || value.isEmpty {
let alert = NSAlert()
alert.messageText = "Missing values"
alert.informativeText = "Make sure to fill in both name and value!"
alert.addButton(withTitle: "Okay")
alert.runModal()
return
}
viewModel.createPassword(name: name, value: value) viewModel.createPassword(name: name, value: value)
name = "" name = ""
value = "" value = ""
dismiss() dismiss()
} }
Button("Cancel") { PwdButton(label: Text("Cancel"), variant: .outline) {
dismiss() dismiss()
} }
} }
.padding(EdgeInsets(top: 10, leading: 0, bottom: 0, trailing: 0)) .padding(EdgeInsets(top: 10, leading: 0, bottom: 0, trailing: 0))
}
}.padding(20) }.padding(20)
} }
} }