Add swipe to remove accounts in Preferences
This commit is contained in:
parent
14e8c11f02
commit
ee90b20f7f
|
@ -37,7 +37,21 @@ struct PreferencesView: View {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}.onDelete { (indices: IndexSet) in
|
||||||
|
var indices = indices
|
||||||
|
var logoutFromCurrent = false
|
||||||
|
if let index = indices.first(where: { localData.accounts[$0] == localData.getMostRecentAccount() }) {
|
||||||
|
logoutFromCurrent = true
|
||||||
|
indices.remove(index)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
localData.accounts.remove(atOffsets: indices)
|
||||||
|
|
||||||
|
if logoutFromCurrent {
|
||||||
|
self.logoutPressed()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Button(action: {
|
Button(action: {
|
||||||
NotificationCenter.default.post(name: .addAccount, object: nil)
|
NotificationCenter.default.post(name: .addAccount, object: nil)
|
||||||
}) {
|
}) {
|
||||||
|
|
Loading…
Reference in New Issue