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 {
VStack(alignment: .leading) {
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)
Spacer()
@ -41,7 +41,7 @@ struct FilterRow: View {
Text(FilterV1.Context.allCases.filter { filter.contexts.contains($0) }.map(\.displayName).formatted())
.font(.subheadline)
if !mastodonController.instanceFeatures.filtersV2 && filter.keywordMOs.first!.wholeWord {
if !mastodonController.instanceFeatures.filtersV2 && filter.keywordMOs.first?.wholeWord == true {
Text("Whole word")
.font(.subheadline)
.foregroundColor(.secondary)

View File

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

View File

@ -96,10 +96,6 @@ class TimelineViewController: UIViewController, TimelineLikeCollectionViewContro
}
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