Add Delete button for iOS 14
This commit is contained in:
parent
50f502436f
commit
67819f440c
2 changed files with 33 additions and 5 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue