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