diff --git a/ntfy/Views/SettingsView.swift b/ntfy/Views/SettingsView.swift index a2c5d05..f6393ed 100644 --- a/ntfy/Views/SettingsView.swift +++ b/ntfy/Views/SettingsView.swift @@ -88,11 +88,34 @@ struct UsersView: View { .navigationTitle(selectedUser == nil ? "Add user" : "Edit user") .navigationBarTitleDisplayMode(.inline) .toolbar { - ToolbarItem(placement: .navigationBarLeading) { - Button(action: cancelAction) { - Text("Cancel") + ToolbarItem(placement: .navigationBarLeading) { + // Sigh, for iOS 14 we need to add a "Delete" menu item, because it doesn't support + // swipe actions. Quite annoying. + + if #available(iOS 15.0, *) { + Button(action: cancelAction) { + Text("Cancel") + } + } else { + if selectedUser == nil { + Button("Cancel") { + cancelAction() + } + } else { + Menu { + Button("Cancel") { + cancelAction() + } + Button("Delete") { + deleteAction() + } + } label: { + Image(systemName: "ellipsis.circle") + .padding([.leading], 40) + } + } + } } - } ToolbarItem(placement: .navigationBarTrailing) { Button(action: saveAction) { Text("Save") @@ -117,6 +140,11 @@ struct UsersView: View { resetAndHide() } + private func deleteAction() { + store.delete(user: selectedUser!) + resetAndHide() + } + private func isValid() -> Bool { if selectedUser == nil { // New user if baseUrl.range(of: "^https?://.+", options: .regularExpression, range: nil, locale: nil) == nil { diff --git a/ntfy/Views/SubscriptionAddView.swift b/ntfy/Views/SubscriptionAddView.swift index 7822bf3..1390b7b 100644 --- a/ntfy/Views/SubscriptionAddView.swift +++ b/ntfy/Views/SubscriptionAddView.swift @@ -97,7 +97,7 @@ struct SubscriptionAddView: View { VStack(alignment: .leading, spacing: 0) { Form { Section( - footer: Text("This topic requires that you login with username and password. The user will be stored on your device, and will be re-used for other topics.") + footer: Text("This topic requires that you log in with username and password. The user will be stored on your device, and will be re-used for other topics.") ) { TextField("Username", text: $username) .disableAutocapitalization()