2021-11-28 14:37:55 +00:00
|
|
|
import SwiftUI
|
|
|
|
|
|
|
|
struct AccountsNavigationLink: View {
|
2022-11-24 20:36:05 +00:00
|
|
|
@ObservedObject private var accounts = AccountsModel.shared
|
2021-11-28 14:37:55 +00:00
|
|
|
var instance: Instance
|
|
|
|
|
|
|
|
var body: some View {
|
|
|
|
NavigationLink(instance.longDescription) {
|
2022-07-21 21:52:09 +00:00
|
|
|
InstanceSettings(instance: instance)
|
2021-11-28 14:37:55 +00:00
|
|
|
}
|
|
|
|
.buttonStyle(.plain)
|
|
|
|
.contextMenu {
|
|
|
|
removeInstanceButton(instance)
|
2022-07-01 21:28:32 +00:00
|
|
|
|
|
|
|
#if os(tvOS)
|
|
|
|
Button("Cancel", role: .cancel) {}
|
|
|
|
#endif
|
2021-11-28 14:37:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private func removeInstanceButton(_ instance: Instance) -> some View {
|
2022-01-06 15:02:53 +00:00
|
|
|
Button {
|
|
|
|
removeAction(instance)
|
|
|
|
} label: {
|
|
|
|
Label("Remove", systemImage: "trash")
|
2021-11-28 14:37:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private func removeAction(_ instance: Instance) {
|
|
|
|
if accounts.current?.instance == instance {
|
|
|
|
accounts.setCurrent(nil)
|
|
|
|
}
|
2022-11-24 20:36:05 +00:00
|
|
|
InstancesModel.shared.remove(instance)
|
2021-11-28 14:37:55 +00:00
|
|
|
}
|
|
|
|
}
|