From 737d904807eefc53c4ac50d228ee50d83deb332a Mon Sep 17 00:00:00 2001 From: Markus Thielker Date: Fri, 24 Jan 2025 17:49:10 +0100 Subject: [PATCH 1/2] PWD-7: customise add-password form style --- password/view/add/AddView.swift | 36 ++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/password/view/add/AddView.swift b/password/view/add/AddView.swift index 4e58d9d..d430aee 100644 --- a/password/view/add/AddView.swift +++ b/password/view/add/AddView.swift @@ -20,30 +20,34 @@ struct AddPasswordView: View { VStack { VStack { Text("Add Password") - .font(.headline) - Text("Create a new password to learn. It will be encrypted and stored securely.") + .font(.title2) + 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)) + Form { TextField("Name", text: $name) .textFieldStyle(PwdTextFieldStyle()) TextField("Value", text: $value) .textFieldStyle(PwdTextFieldStyle()) - Text("The password will not be visible again later. Make sure to save it somewhere else too!") - .font(.footnote) - HStack { - Button("Save") { - viewModel.createPassword(name: name, value: value) - name = "" - value = "" - dismiss() - } - Button("Cancel") { - dismiss() - } - } - .padding(EdgeInsets(top: 10, leading: 0, bottom: 0, trailing: 0)) } + + Text("The password will not be visible again later. Make sure to save it somewhere else too!") + .font(.footnote) + HStack { + PwdButton(label: Text("Save")) { + viewModel.createPassword(name: name, value: value) + name = "" + value = "" + dismiss() + } + PwdButton(label: Text("Cancel"), variant: .outline) { + dismiss() + } + } + .padding(EdgeInsets(top: 10, leading: 0, bottom: 0, trailing: 0)) + }.padding(20) } } -- 2.47.2 From 083ca1f03091c25db45016182be533f529b3a063 Mon Sep 17 00:00:00 2001 From: Markus Thielker Date: Fri, 24 Jan 2025 17:49:56 +0100 Subject: [PATCH 2/2] PWD-7: check for empty values before creation --- password/view/add/AddView.swift | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/password/view/add/AddView.swift b/password/view/add/AddView.swift index d430aee..ad4eff4 100644 --- a/password/view/add/AddView.swift +++ b/password/view/add/AddView.swift @@ -37,6 +37,16 @@ struct AddPasswordView: View { .font(.footnote) HStack { 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) name = "" value = "" -- 2.47.2