1
0
mirror of https://github.com/metabolist/metatext synced 2024-12-29 03:01:07 +01:00
metatext-app-ios-iphone-ipad/Views/SwiftUI/DomainBlocksView.swift
Justin Mazzocchi ff8fd63e50
Organize views
2021-01-28 22:50:58 -08:00

51 lines
1.3 KiB
Swift

// Copyright © 2020 Metabolist. All rights reserved.
import SwiftUI
import ViewModels
struct DomainBlocksView: View {
@StateObject var viewModel: DomainBlocksViewModel
var body: some View {
Form {
ForEach(viewModel.domainBlocks, id: \.self) { domain in
Text(domain)
.onAppear {
if domain == viewModel.domainBlocks.last {
viewModel.request()
}
}
}
.onDelete {
guard let index = $0.first else { return }
viewModel.delete(domain: viewModel.domainBlocks[index])
}
if viewModel.loading {
ProgressView()
}
}
.onAppear {
viewModel.request()
}
.navigationTitle("preferences.blocked-domains")
.navigationBarTitleDisplayMode(.inline)
.toolbar {
ToolbarItem(placement: ToolbarItemPlacement.navigationBarTrailing) {
EditButton()
}
}
}
}
#if DEBUG
import PreviewViewModels
struct DomainBlocksView_Previews: PreviewProvider {
static var previews: some View {
NavigationView {
DomainBlocksView(viewModel: .preview)
}
}
}
#endif