Filters view UI tweaks

This commit is contained in:
Shadowfacts 2022-12-03 14:47:21 -05:00
parent f71804f094
commit fcf95ba8c1
3 changed files with 22 additions and 24 deletions

View File

@ -16,7 +16,7 @@ struct FilterRow: View {
var body: some View { var body: some View {
VStack(alignment: .leading) { VStack(alignment: .leading) {
HStack(alignment: .top) { HStack(alignment: .top) {
Text(mastodonController.instanceFeatures.filtersV2 ? filter.title ?? "" : filter.keywordMOs.first!.keyword) Text(mastodonController.instanceFeatures.filtersV2 ? filter.title ?? "" : filter.keywordMOs.first?.keyword ?? "")
.font(.headline) .font(.headline)
Spacer() Spacer()
@ -41,7 +41,7 @@ struct FilterRow: View {
Text(FilterV1.Context.allCases.filter { filter.contexts.contains($0) }.map(\.displayName).formatted()) Text(FilterV1.Context.allCases.filter { filter.contexts.contains($0) }.map(\.displayName).formatted())
.font(.subheadline) .font(.subheadline)
if !mastodonController.instanceFeatures.filtersV2 && filter.keywordMOs.first!.wholeWord { if !mastodonController.instanceFeatures.filtersV2 && filter.keywordMOs.first?.wholeWord == true {
Text("Whole word") Text("Whole word")
.font(.subheadline) .font(.subheadline)
.foregroundColor(.secondary) .foregroundColor(.secondary)

View File

@ -82,7 +82,9 @@ struct FiltersList: View {
} }
} }
@ViewBuilder
private func filtersSection(_ filters: [FilterMO], header: some View) -> some View { private func filtersSection(_ filters: [FilterMO], header: some View) -> some View {
if !filters.isEmpty {
Section { Section {
ForEach(filters, id: \.id) { filter in ForEach(filters, id: \.id) { filter in
NavigationLink { NavigationLink {
@ -94,9 +96,8 @@ struct FiltersList: View {
Button(role: .destructive) { Button(role: .destructive) {
deleteFilter(filter) deleteFilter(filter)
} label: { } label: {
Text("Delete Filter") Label("Delete Filter", systemImage: "trash")
} }
} }
} }
.onDelete { indices in .onDelete { indices in
@ -108,6 +109,7 @@ struct FiltersList: View {
header header
} }
} }
}
private func deleteFilter(_ filter: FilterMO) { private func deleteFilter(_ filter: FilterMO) {
Task { Task {

View File

@ -96,10 +96,6 @@ class TimelineViewController: UIViewController, TimelineLikeCollectionViewContro
} }
NotificationCenter.default.addObserver(self, selector: #selector(sceneWillEnterForeground), name: UIScene.willEnterForegroundNotification, object: nil) NotificationCenter.default.addObserver(self, selector: #selector(sceneWillEnterForeground), name: UIScene.willEnterForegroundNotification, object: nil)
mastodonController.run(Client.getFiltersV2()) { response in
print(response)
}
} }
// separate method because InstanceTimelineViewController needs to be able to customize it // separate method because InstanceTimelineViewController needs to be able to customize it