Skip to content

Commit

Permalink
Rework filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
SMillerDev committed Jan 26, 2025
1 parent d46be51 commit 3d2881c
Show file tree
Hide file tree
Showing 13 changed files with 206 additions and 207 deletions.
22 changes: 7 additions & 15 deletions Fosdem.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,10 @@
925B0263298EB2A400AFA83D /* VideoPlayer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 925B0262298EB2A400AFA83D /* VideoPlayer.swift */; };
925F4A7D2B2863D8007E9D1D /* Localizable.xcstrings in Resources */ = {isa = PBXBuildFile; fileRef = 925F4A7C2B285A70007E9D1D /* Localizable.xcstrings */; };
926414702D4650CA001378EF /* Array.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9264146F2D4650C8001378EF /* Array.swift */; };
926414722D46BEE9001378EF /* EventList.swift in Sources */ = {isa = PBXBuildFile; fileRef = 926414712D46BEE9001378EF /* EventList.swift */; };
9268D79A298F251E0067A6B1 /* ListSettings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9268D799298F251E0067A6B1 /* ListSettings.swift */; };
92775AC22CFF7FEB00D44236 /* SectionedQuery in Frameworks */ = {isa = PBXBuildFile; productRef = 92775AC12CFF7FEB00D44236 /* SectionedQuery */; };
92775AC52CFF880500D44236 /* BookmarkList.swift in Sources */ = {isa = PBXBuildFile; fileRef = 92775AC42CFF87FD00D44236 /* BookmarkList.swift */; };
92775AC72CFF88BF00D44236 /* AuthorEventList.swift in Sources */ = {isa = PBXBuildFile; fileRef = 92775AC62CFF88BF00D44236 /* AuthorEventList.swift */; };
92775AC92CFF88F800D44236 /* TrackEventList.swift in Sources */ = {isa = PBXBuildFile; fileRef = 92775AC82CFF88F800D44236 /* TrackEventList.swift */; };
92775ACB2CFF8A9A00D44236 /* RoomEventList.swift in Sources */ = {isa = PBXBuildFile; fileRef = 92775ACA2CFF8A9A00D44236 /* RoomEventList.swift */; };
9290384C2C9613FD002201FC /* ScheduleFetchingActor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9290384B2C9613F6002201FC /* ScheduleFetchingActor.swift */; };
92B987FC2981CD10007574EB /* AboutView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 92B987FB2981CD10007574EB /* AboutView.swift */; };
92BB58562B5FB84400C54292 /* SettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 92BB58552B5FB84400C54292 /* SettingsView.swift */; };
Expand Down Expand Up @@ -101,11 +99,9 @@
925B0262298EB2A400AFA83D /* VideoPlayer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VideoPlayer.swift; sourceTree = "<group>"; };
925F4A7C2B285A70007E9D1D /* Localizable.xcstrings */ = {isa = PBXFileReference; lastKnownFileType = text.json.xcstrings; path = Localizable.xcstrings; sourceTree = "<group>"; };
9264146F2D4650C8001378EF /* Array.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Array.swift; sourceTree = "<group>"; };
926414712D46BEE9001378EF /* EventList.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EventList.swift; sourceTree = "<group>"; };
9268D799298F251E0067A6B1 /* ListSettings.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListSettings.swift; sourceTree = "<group>"; };
92775AC42CFF87FD00D44236 /* BookmarkList.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BookmarkList.swift; sourceTree = "<group>"; };
92775AC62CFF88BF00D44236 /* AuthorEventList.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AuthorEventList.swift; sourceTree = "<group>"; };
92775AC82CFF88F800D44236 /* TrackEventList.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TrackEventList.swift; sourceTree = "<group>"; };
92775ACA2CFF8A9A00D44236 /* RoomEventList.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RoomEventList.swift; sourceTree = "<group>"; };
9290384B2C9613F6002201FC /* ScheduleFetchingActor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScheduleFetchingActor.swift; sourceTree = "<group>"; };
92A2BDF92948CC5E0034864F /* FosdemTests.xctestplan */ = {isa = PBXFileReference; lastKnownFileType = text; name = FosdemTests.xctestplan; path = Fosdem.xcodeproj/FosdemTests.xctestplan; sourceTree = "<group>"; };
92A57B392988FD1C00C0BB78 /* Package.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Package.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -181,7 +177,6 @@
children = (
92775AC32CFF87F500D44236 /* Lists */,
92BB58552B5FB84400C54292 /* SettingsView.swift */,
92CE31B028FC4A940073813E /* EventListView.swift */,
92077D5028FF01C600BF8A03 /* EventDetailView.swift */,
92D9E7B9291D95E1007D203D /* EventDetailHeader.swift */,
924E15C229238AA5005A8EA2 /* ListItem.swift */,
Expand Down Expand Up @@ -255,11 +250,10 @@
92775AC32CFF87F500D44236 /* Lists */ = {
isa = PBXGroup;
children = (
92CE31B028FC4A940073813E /* EventListView.swift */,
92775AC42CFF87FD00D44236 /* BookmarkList.swift */,
92775AC62CFF88BF00D44236 /* AuthorEventList.swift */,
92775AC82CFF88F800D44236 /* TrackEventList.swift */,
926414712D46BEE9001378EF /* EventList.swift */,
920085652D42F2D70082719F /* ListStatusOverlay.swift */,
92775ACA2CFF8A9A00D44236 /* RoomEventList.swift */,
);
path = Lists;
sourceTree = "<group>";
Expand Down Expand Up @@ -451,8 +445,8 @@
14D277192205D07200740042 /* AppDelegate.swift in Sources */,
146A86792206ED84008A61AD /* Track.swift in Sources */,
92775AC52CFF880500D44236 /* BookmarkList.swift in Sources */,
926414722D46BEE9001378EF /* EventList.swift in Sources */,
925321602925716A004C7E5C /* EventUserInfo.swift in Sources */,
92775ACB2CFF8A9A00D44236 /* RoomEventList.swift in Sources */,
920085662D42F2D70082719F /* ListStatusOverlay.swift in Sources */,
142A8742222473A40034F6D7 /* UIColor+hexstring.swift in Sources */,
92CE31AF28FC49DC0073813E /* SettingsHelper.swift in Sources */,
Expand All @@ -468,12 +462,10 @@
142A873D2224651F0034F6D7 /* Hash.swift in Sources */,
926414702D4650CA001378EF /* Array.swift in Sources */,
924E15BE2922CCA9005A8EA2 /* RoomState.swift in Sources */,
92775AC92CFF88F800D44236 /* TrackEventList.swift in Sources */,
146A866F2205EFE9008A61AD /* Room.swift in Sources */,
146A86742205EFE9008A61AD /* Event.swift in Sources */,
146A86702205EFE9008A61AD /* Person.swift in Sources */,
92BD1D302B5C34F100DB8FC1 /* EventTypeColor.swift in Sources */,
92775AC72CFF88BF00D44236 /* AuthorEventList.swift in Sources */,
14D2774C2205D19D00740042 /* RemoteScheduleFetcher.swift in Sources */,
925B0261298EAE0E00AFA83D /* LiveIcon.swift in Sources */,
92BB58562B5FB84400C54292 /* SettingsView.swift in Sources */,
Expand Down Expand Up @@ -671,7 +663,7 @@
"@executable_path/Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 14.6;
MARKETING_VERSION = 1.3.0;
MARKETING_VERSION = 1.4.0;
PRODUCT_BUNDLE_IDENTIFIER = eu.seanmolenaar.Fosdem;
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
Expand Down Expand Up @@ -701,7 +693,7 @@
"@executable_path/Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 14.6;
MARKETING_VERSION = 1.3.0;
MARKETING_VERSION = 1.4.0;
PRODUCT_BUNDLE_IDENTIFIER = eu.seanmolenaar.Fosdem;
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
Expand Down
4 changes: 3 additions & 1 deletion Fosdem/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.3</string>
<string>1.4.0</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<key>LSApplicationCategoryType</key>
<string>public.app-category.reference</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UIBackgroundModes</key>
Expand Down
2 changes: 1 addition & 1 deletion Fosdem/Models/Event.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class Event {
public var lastUpdated: Date = Date()

public var room: Room
public var track: Track?
public var track: Track!
public var type: EventType?

public var userInfo: EventUserInfo?
Expand Down
15 changes: 9 additions & 6 deletions Fosdem/Views/EventDetailView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,11 @@ struct EventDetailView: View {
ShareLink("Share web link", item: event.getPublicLink(), message: Text(event.title))
}
ToolbarItem(placement: .primaryAction) {
Toggle(isOn: $event.isFavourite, label: {
Label("Favorite",
systemImage: event.userInfo!.favorite ? "bookmark.fill" : "bookmark")
.backgroundStyle(.clear)
}).onTapGesture(count: 1, perform: {
debugPrint(event.userInfo!.favorite)
Button(action: {
event.isFavourite.toggle()
if !event.isFavourite {
return
}
if event.start.timeIntervalSinceNow <= 0 {
return
}
Expand All @@ -133,6 +132,10 @@ struct EventDetailView: View {
UNUserNotificationCenter.current()
.removePendingNotificationRequests(withIdentifiers:
[event.userInfo!.notificationUUID!.uuidString])
}, label: {
Label("Favorite",
systemImage: event.userInfo!.favorite ? "bookmark.fill" : "bookmark")
.backgroundStyle(.clear)
})
}
}
Expand Down
98 changes: 0 additions & 98 deletions Fosdem/Views/EventListView.swift

This file was deleted.

3 changes: 3 additions & 0 deletions Fosdem/Views/EventTypeIcon.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ enum EventTypeIcon: String {
case maintrack = "road.lanes"
case certification = "checkmark.seal"
case bof = "bird"
case junior = "figure.and.child.holdinghands"
case none = "questionmark.circle"

static func getIconFor(_ string: String) -> EventTypeIcon {
Expand All @@ -33,6 +34,8 @@ enum EventTypeIcon: String {
return .bof
case "certification":
return .certification
case "junior":
return .junior
default:
return .none
}
Expand Down
8 changes: 5 additions & 3 deletions Fosdem/Views/ListItem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,11 @@ struct ListItem: View {
}
ShareLink("Share web link", item: event.getPublicLink(), message: Text(event.title))
}.swipeActions {
Button(action: { event.userInfo?.favorite.toggle() }, label: {
Label("Favorite", systemImage: event.userInfo?.favorite ?? false ? "star.fill" : "star")
}).tint(.orange)
Button(action: {
event.userInfo?.favorite.toggle()
}, label: {
Label("Favorite", systemImage: (event.userInfo?.favorite ?? false) ? "star.slash" : "star")
}).tint((event.userInfo?.favorite ?? false) ? .blue : .orange)
}
.onAppear {
event.userInfo?.lastSeen = Date()
Expand Down
64 changes: 59 additions & 5 deletions Fosdem/Views/ListSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,18 @@ class ListSettings: ObservableObject {
predicate = basePredicate
}
}

if onlyFuture {
let now = Date()
let basePredicate = #Predicate<Event> { $0.end > now }
let basePredicate = ListSettings.futurePredicate()
if predicate != nil {
predicate = #Predicate<Event> { predicate!.evaluate($0) && basePredicate.evaluate($0) }
} else {
predicate = basePredicate
}
}

if let query = query, !query.isEmpty {
let basePredicate = #Predicate<Event> {
$0.title.localizedStandardContains(query) || $0.trackName.localizedStandardContains(query)
}
let basePredicate = ListSettings.searchPredicate(query, type: type)
if predicate != nil {
predicate = #Predicate<Event> { predicate!.evaluate($0) && basePredicate.evaluate($0) }
} else {
Expand All @@ -63,10 +62,65 @@ class ListSettings: ObservableObject {

return predicate
}

private static func futurePredicate() -> Predicate<Event> {
let now = Date()
return #Predicate<Event> { $0.end > now }
}

private static func searchPredicate(_ searchText: String, type: ListPredicateType) -> Predicate<Event> {
var predicate = #Predicate<Event> { $0.title.localizedStandardContains(searchText) }
switch type {
case .track:
predicate = #Predicate<Event> {
$0.title.localizedStandardContains(searchText)
}
case .person:
predicate = #Predicate<Event> {
$0.title.localizedStandardContains(searchText) ||
!$0.authors.filter { author in
author.name.localizedStandardContains(searchText)
}.isEmpty
}
case .room:
predicate = #Predicate<Event> {
$0.title.localizedStandardContains(searchText) ||
$0.room.name.localizedStandardContains(searchText)
}
}

return predicate
}
}

enum ListPredicateType {
case person
case room
case track

static var all: [ListPredicateType] {
return [.track, .person, .room]
}

static func getName(_ type: ListPredicateType) -> String {
switch type {
case .person:
return "People"
case .room:
return "Rooms"
case .track:
return "Tracks"
}
}

static func getIcon(_ type: ListPredicateType) -> String {
switch type {
case .person:
return "person"
case .room:
return "door.left.hand.open"
case .track:
return "road.lanes"
}
}
}
34 changes: 0 additions & 34 deletions Fosdem/Views/Lists/AuthorEventList.swift

This file was deleted.

Loading

0 comments on commit 3d2881c

Please sign in to comment.