2021-09-25 13:48:22 +05:30
|
|
|
import SwiftUI
|
|
|
|
|
|
|
|
struct InstanceDetailsSettingsView: View {
|
|
|
|
let instanceID: Instance.ID?
|
|
|
|
|
|
|
|
@State private var accountsChanged = false
|
|
|
|
@State private var presentingAccountForm = false
|
|
|
|
|
|
|
|
@EnvironmentObject<InstancesModel> private var instances
|
|
|
|
|
|
|
|
var instance: Instance! {
|
|
|
|
instances.find(instanceID)
|
|
|
|
}
|
|
|
|
|
|
|
|
var body: some View {
|
|
|
|
List {
|
|
|
|
Section(header: Text("Accounts")) {
|
2021-09-27 01:42:43 +05:30
|
|
|
ForEach(instance.accounts) { account in
|
2021-09-25 13:48:22 +05:30
|
|
|
Text(account.description)
|
|
|
|
#if !os(tvOS)
|
|
|
|
.swipeActions(edge: .trailing, allowsFullSwipe: false) {
|
|
|
|
Button("Remove", role: .destructive) {
|
|
|
|
instances.removeAccount(instance: instance, account: account)
|
|
|
|
accountsChanged.toggle()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
.redrawOn(change: accountsChanged)
|
|
|
|
|
|
|
|
Button("Add account...") {
|
|
|
|
presentingAccountForm = true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#if os(iOS)
|
|
|
|
.listStyle(.insetGrouped)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
.navigationTitle(instance.shortDescription)
|
|
|
|
.sheet(isPresented: $presentingAccountForm, onDismiss: { accountsChanged.toggle() }) {
|
|
|
|
AccountFormView(instance: instance)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|