From fe30692a3fff0a4dcccd1fd4f60d7135e33a96ed Mon Sep 17 00:00:00 2001 From: Greg Bolsinga Date: Fri, 11 Oct 2024 19:03:34 -0700 Subject: [PATCH] add LocationFilterToolbarContent to summary toolbar The summary will have this if the category is location filterable. --- .../ArchiveCategory+LocationFilterable.swift | 17 +++++++++++++ .../Site/Music/UI/ArchiveCategoryDetail.swift | 4 ++++ Sources/Site/Music/UI/ArtistsSummary.swift | 1 - .../Music/UI/LocationFilterModifier.swift | 24 ------------------- Sources/Site/Music/UI/ShowsSummary.swift | 1 - Sources/Site/Music/UI/VenuesSummary.swift | 1 - 6 files changed, 21 insertions(+), 27 deletions(-) create mode 100644 Sources/Site/Music/UI/ArchiveCategory+LocationFilterable.swift delete mode 100644 Sources/Site/Music/UI/LocationFilterModifier.swift diff --git a/Sources/Site/Music/UI/ArchiveCategory+LocationFilterable.swift b/Sources/Site/Music/UI/ArchiveCategory+LocationFilterable.swift new file mode 100644 index 0000000..8b14cf9 --- /dev/null +++ b/Sources/Site/Music/UI/ArchiveCategory+LocationFilterable.swift @@ -0,0 +1,17 @@ +// +// ArchiveCategory+LocationFilterable.swift +// site +// +// Created by Greg Bolsinga on 10/11/24. +// + +extension ArchiveCategory { + var isLocationFilterable: Bool { + switch self { + case .today, .stats: + false + case .shows, .venues, .artists: + true + } + } +} diff --git a/Sources/Site/Music/UI/ArchiveCategoryDetail.swift b/Sources/Site/Music/UI/ArchiveCategoryDetail.swift index 03aca81..335fab8 100644 --- a/Sources/Site/Music/UI/ArchiveCategoryDetail.swift +++ b/Sources/Site/Music/UI/ArchiveCategoryDetail.swift @@ -35,6 +35,10 @@ struct ArchiveCategoryDetail: View { } ) .toolbar { + if category.isLocationFilterable { + @Bindable var bindableNearbyModel = nearbyModel + LocationFilterToolbarContent(isOn: $bindableNearbyModel.locationFilter.toggle) + } ArchiveSharableToolbarContent( item: ArchiveCategoryLinkable(vault: model.vault, category: category)) } diff --git a/Sources/Site/Music/UI/ArtistsSummary.swift b/Sources/Site/Music/UI/ArtistsSummary.swift index 6f0e977..98fd6a5 100644 --- a/Sources/Site/Music/UI/ArtistsSummary.swift +++ b/Sources/Site/Music/UI/ArtistsSummary.swift @@ -24,7 +24,6 @@ struct ArtistsSummary: View { locationAuthorization: model.locationAuthorization, geocodingProgress: model.geocodingProgress, filteredDataIsEmpty: artistDigests.isEmpty ) - .locationFilter(nearbyModel) } } diff --git a/Sources/Site/Music/UI/LocationFilterModifier.swift b/Sources/Site/Music/UI/LocationFilterModifier.swift deleted file mode 100644 index 0ea4773..0000000 --- a/Sources/Site/Music/UI/LocationFilterModifier.swift +++ /dev/null @@ -1,24 +0,0 @@ -// -// LocationFilterModifier.swift -// -// -// Created by Greg Bolsinga on 10/5/23. -// - -import SwiftUI - -struct LocationFilterModifier: ViewModifier { - let model: NearbyModel - - func body(content: Content) -> some View { - @Bindable var bindableModel = model - content - .toolbar { LocationFilterToolbarContent(isOn: $bindableModel.locationFilter.toggle) } - } -} - -extension View { - func locationFilter(_ model: NearbyModel) -> some View { - modifier(LocationFilterModifier(model: model)) - } -} diff --git a/Sources/Site/Music/UI/ShowsSummary.swift b/Sources/Site/Music/UI/ShowsSummary.swift index 79cf29b..b0d3f99 100644 --- a/Sources/Site/Music/UI/ShowsSummary.swift +++ b/Sources/Site/Music/UI/ShowsSummary.swift @@ -19,7 +19,6 @@ struct ShowsSummary: View { locationAuthorization: model.locationAuthorization, geocodingProgress: model.geocodingProgress, filteredDataIsEmpty: decadesMap.isEmpty ) - .locationFilter(nearbyModel) } } diff --git a/Sources/Site/Music/UI/VenuesSummary.swift b/Sources/Site/Music/UI/VenuesSummary.swift index ac11efa..ecfb574 100644 --- a/Sources/Site/Music/UI/VenuesSummary.swift +++ b/Sources/Site/Music/UI/VenuesSummary.swift @@ -24,7 +24,6 @@ struct VenuesSummary: View { locationAuthorization: model.locationAuthorization, geocodingProgress: model.geocodingProgress, filteredDataIsEmpty: venueDigests.isEmpty ) - .locationFilter(nearbyModel) } }