Skip to content

Commit 3d2881c

Browse files
committed
Rework filtering
1 parent d46be51 commit 3d2881c

File tree

13 files changed

+206
-207
lines changed

13 files changed

+206
-207
lines changed

Fosdem.xcodeproj/project.pbxproj

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,10 @@
3232
925B0263298EB2A400AFA83D /* VideoPlayer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 925B0262298EB2A400AFA83D /* VideoPlayer.swift */; };
3333
925F4A7D2B2863D8007E9D1D /* Localizable.xcstrings in Resources */ = {isa = PBXBuildFile; fileRef = 925F4A7C2B285A70007E9D1D /* Localizable.xcstrings */; };
3434
926414702D4650CA001378EF /* Array.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9264146F2D4650C8001378EF /* Array.swift */; };
35+
926414722D46BEE9001378EF /* EventList.swift in Sources */ = {isa = PBXBuildFile; fileRef = 926414712D46BEE9001378EF /* EventList.swift */; };
3536
9268D79A298F251E0067A6B1 /* ListSettings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9268D799298F251E0067A6B1 /* ListSettings.swift */; };
3637
92775AC22CFF7FEB00D44236 /* SectionedQuery in Frameworks */ = {isa = PBXBuildFile; productRef = 92775AC12CFF7FEB00D44236 /* SectionedQuery */; };
3738
92775AC52CFF880500D44236 /* BookmarkList.swift in Sources */ = {isa = PBXBuildFile; fileRef = 92775AC42CFF87FD00D44236 /* BookmarkList.swift */; };
38-
92775AC72CFF88BF00D44236 /* AuthorEventList.swift in Sources */ = {isa = PBXBuildFile; fileRef = 92775AC62CFF88BF00D44236 /* AuthorEventList.swift */; };
39-
92775AC92CFF88F800D44236 /* TrackEventList.swift in Sources */ = {isa = PBXBuildFile; fileRef = 92775AC82CFF88F800D44236 /* TrackEventList.swift */; };
40-
92775ACB2CFF8A9A00D44236 /* RoomEventList.swift in Sources */ = {isa = PBXBuildFile; fileRef = 92775ACA2CFF8A9A00D44236 /* RoomEventList.swift */; };
4139
9290384C2C9613FD002201FC /* ScheduleFetchingActor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9290384B2C9613F6002201FC /* ScheduleFetchingActor.swift */; };
4240
92B987FC2981CD10007574EB /* AboutView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 92B987FB2981CD10007574EB /* AboutView.swift */; };
4341
92BB58562B5FB84400C54292 /* SettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 92BB58552B5FB84400C54292 /* SettingsView.swift */; };
@@ -101,11 +99,9 @@
10199
925B0262298EB2A400AFA83D /* VideoPlayer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VideoPlayer.swift; sourceTree = "<group>"; };
102100
925F4A7C2B285A70007E9D1D /* Localizable.xcstrings */ = {isa = PBXFileReference; lastKnownFileType = text.json.xcstrings; path = Localizable.xcstrings; sourceTree = "<group>"; };
103101
9264146F2D4650C8001378EF /* Array.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Array.swift; sourceTree = "<group>"; };
102+
926414712D46BEE9001378EF /* EventList.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EventList.swift; sourceTree = "<group>"; };
104103
9268D799298F251E0067A6B1 /* ListSettings.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListSettings.swift; sourceTree = "<group>"; };
105104
92775AC42CFF87FD00D44236 /* BookmarkList.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BookmarkList.swift; sourceTree = "<group>"; };
106-
92775AC62CFF88BF00D44236 /* AuthorEventList.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AuthorEventList.swift; sourceTree = "<group>"; };
107-
92775AC82CFF88F800D44236 /* TrackEventList.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TrackEventList.swift; sourceTree = "<group>"; };
108-
92775ACA2CFF8A9A00D44236 /* RoomEventList.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RoomEventList.swift; sourceTree = "<group>"; };
109105
9290384B2C9613F6002201FC /* ScheduleFetchingActor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScheduleFetchingActor.swift; sourceTree = "<group>"; };
110106
92A2BDF92948CC5E0034864F /* FosdemTests.xctestplan */ = {isa = PBXFileReference; lastKnownFileType = text; name = FosdemTests.xctestplan; path = Fosdem.xcodeproj/FosdemTests.xctestplan; sourceTree = "<group>"; };
111107
92A57B392988FD1C00C0BB78 /* Package.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Package.swift; sourceTree = "<group>"; };
@@ -181,7 +177,6 @@
181177
children = (
182178
92775AC32CFF87F500D44236 /* Lists */,
183179
92BB58552B5FB84400C54292 /* SettingsView.swift */,
184-
92CE31B028FC4A940073813E /* EventListView.swift */,
185180
92077D5028FF01C600BF8A03 /* EventDetailView.swift */,
186181
92D9E7B9291D95E1007D203D /* EventDetailHeader.swift */,
187182
924E15C229238AA5005A8EA2 /* ListItem.swift */,
@@ -255,11 +250,10 @@
255250
92775AC32CFF87F500D44236 /* Lists */ = {
256251
isa = PBXGroup;
257252
children = (
253+
92CE31B028FC4A940073813E /* EventListView.swift */,
258254
92775AC42CFF87FD00D44236 /* BookmarkList.swift */,
259-
92775AC62CFF88BF00D44236 /* AuthorEventList.swift */,
260-
92775AC82CFF88F800D44236 /* TrackEventList.swift */,
255+
926414712D46BEE9001378EF /* EventList.swift */,
261256
920085652D42F2D70082719F /* ListStatusOverlay.swift */,
262-
92775ACA2CFF8A9A00D44236 /* RoomEventList.swift */,
263257
);
264258
path = Lists;
265259
sourceTree = "<group>";
@@ -451,8 +445,8 @@
451445
14D277192205D07200740042 /* AppDelegate.swift in Sources */,
452446
146A86792206ED84008A61AD /* Track.swift in Sources */,
453447
92775AC52CFF880500D44236 /* BookmarkList.swift in Sources */,
448+
926414722D46BEE9001378EF /* EventList.swift in Sources */,
454449
925321602925716A004C7E5C /* EventUserInfo.swift in Sources */,
455-
92775ACB2CFF8A9A00D44236 /* RoomEventList.swift in Sources */,
456450
920085662D42F2D70082719F /* ListStatusOverlay.swift in Sources */,
457451
142A8742222473A40034F6D7 /* UIColor+hexstring.swift in Sources */,
458452
92CE31AF28FC49DC0073813E /* SettingsHelper.swift in Sources */,
@@ -468,12 +462,10 @@
468462
142A873D2224651F0034F6D7 /* Hash.swift in Sources */,
469463
926414702D4650CA001378EF /* Array.swift in Sources */,
470464
924E15BE2922CCA9005A8EA2 /* RoomState.swift in Sources */,
471-
92775AC92CFF88F800D44236 /* TrackEventList.swift in Sources */,
472465
146A866F2205EFE9008A61AD /* Room.swift in Sources */,
473466
146A86742205EFE9008A61AD /* Event.swift in Sources */,
474467
146A86702205EFE9008A61AD /* Person.swift in Sources */,
475468
92BD1D302B5C34F100DB8FC1 /* EventTypeColor.swift in Sources */,
476-
92775AC72CFF88BF00D44236 /* AuthorEventList.swift in Sources */,
477469
14D2774C2205D19D00740042 /* RemoteScheduleFetcher.swift in Sources */,
478470
925B0261298EAE0E00AFA83D /* LiveIcon.swift in Sources */,
479471
92BB58562B5FB84400C54292 /* SettingsView.swift in Sources */,
@@ -671,7 +663,7 @@
671663
"@executable_path/Frameworks",
672664
);
673665
MACOSX_DEPLOYMENT_TARGET = 14.6;
674-
MARKETING_VERSION = 1.3.0;
666+
MARKETING_VERSION = 1.4.0;
675667
PRODUCT_BUNDLE_IDENTIFIER = eu.seanmolenaar.Fosdem;
676668
PRODUCT_NAME = "$(TARGET_NAME)";
677669
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
@@ -701,7 +693,7 @@
701693
"@executable_path/Frameworks",
702694
);
703695
MACOSX_DEPLOYMENT_TARGET = 14.6;
704-
MARKETING_VERSION = 1.3.0;
696+
MARKETING_VERSION = 1.4.0;
705697
PRODUCT_BUNDLE_IDENTIFIER = eu.seanmolenaar.Fosdem;
706698
PRODUCT_NAME = "$(TARGET_NAME)";
707699
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";

Fosdem/Info.plist

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,13 @@
1515
<key>CFBundlePackageType</key>
1616
<string>APPL</string>
1717
<key>CFBundleShortVersionString</key>
18-
<string>1.3</string>
18+
<string>1.4.0</string>
1919
<key>CFBundleVersion</key>
2020
<string>1</string>
2121
<key>ITSAppUsesNonExemptEncryption</key>
2222
<false/>
23+
<key>LSApplicationCategoryType</key>
24+
<string>public.app-category.reference</string>
2325
<key>LSRequiresIPhoneOS</key>
2426
<true/>
2527
<key>UIBackgroundModes</key>

Fosdem/Models/Event.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public class Event {
2424
public var lastUpdated: Date = Date()
2525

2626
public var room: Room
27-
public var track: Track?
27+
public var track: Track!
2828
public var type: EventType?
2929

3030
public var userInfo: EventUserInfo?

Fosdem/Views/EventDetailView.swift

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,11 @@ struct EventDetailView: View {
114114
ShareLink("Share web link", item: event.getPublicLink(), message: Text(event.title))
115115
}
116116
ToolbarItem(placement: .primaryAction) {
117-
Toggle(isOn: $event.isFavourite, label: {
118-
Label("Favorite",
119-
systemImage: event.userInfo!.favorite ? "bookmark.fill" : "bookmark")
120-
.backgroundStyle(.clear)
121-
}).onTapGesture(count: 1, perform: {
122-
debugPrint(event.userInfo!.favorite)
117+
Button(action: {
118+
event.isFavourite.toggle()
119+
if !event.isFavourite {
120+
return
121+
}
123122
if event.start.timeIntervalSinceNow <= 0 {
124123
return
125124
}
@@ -133,6 +132,10 @@ struct EventDetailView: View {
133132
UNUserNotificationCenter.current()
134133
.removePendingNotificationRequests(withIdentifiers:
135134
[event.userInfo!.notificationUUID!.uuidString])
135+
}, label: {
136+
Label("Favorite",
137+
systemImage: event.userInfo!.favorite ? "bookmark.fill" : "bookmark")
138+
.backgroundStyle(.clear)
136139
})
137140
}
138141
}

Fosdem/Views/EventListView.swift

Lines changed: 0 additions & 98 deletions
This file was deleted.

Fosdem/Views/EventTypeIcon.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ enum EventTypeIcon: String {
1515
case maintrack = "road.lanes"
1616
case certification = "checkmark.seal"
1717
case bof = "bird"
18+
case junior = "figure.and.child.holdinghands"
1819
case none = "questionmark.circle"
1920

2021
static func getIconFor(_ string: String) -> EventTypeIcon {
@@ -33,6 +34,8 @@ enum EventTypeIcon: String {
3334
return .bof
3435
case "certification":
3536
return .certification
37+
case "junior":
38+
return .junior
3639
default:
3740
return .none
3841
}

Fosdem/Views/ListItem.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,11 @@ struct ListItem: View {
6161
}
6262
ShareLink("Share web link", item: event.getPublicLink(), message: Text(event.title))
6363
}.swipeActions {
64-
Button(action: { event.userInfo?.favorite.toggle() }, label: {
65-
Label("Favorite", systemImage: event.userInfo?.favorite ?? false ? "star.fill" : "star")
66-
}).tint(.orange)
64+
Button(action: {
65+
event.userInfo?.favorite.toggle()
66+
}, label: {
67+
Label("Favorite", systemImage: (event.userInfo?.favorite ?? false) ? "star.slash" : "star")
68+
}).tint((event.userInfo?.favorite ?? false) ? .blue : .orange)
6769
}
6870
.onAppear {
6971
event.userInfo?.lastSeen = Date()

Fosdem/Views/ListSettings.swift

Lines changed: 59 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,19 +41,18 @@ class ListSettings: ObservableObject {
4141
predicate = basePredicate
4242
}
4343
}
44+
4445
if onlyFuture {
45-
let now = Date()
46-
let basePredicate = #Predicate<Event> { $0.end > now }
46+
let basePredicate = ListSettings.futurePredicate()
4747
if predicate != nil {
4848
predicate = #Predicate<Event> { predicate!.evaluate($0) && basePredicate.evaluate($0) }
4949
} else {
5050
predicate = basePredicate
5151
}
5252
}
53+
5354
if let query = query, !query.isEmpty {
54-
let basePredicate = #Predicate<Event> {
55-
$0.title.localizedStandardContains(query) || $0.trackName.localizedStandardContains(query)
56-
}
55+
let basePredicate = ListSettings.searchPredicate(query, type: type)
5756
if predicate != nil {
5857
predicate = #Predicate<Event> { predicate!.evaluate($0) && basePredicate.evaluate($0) }
5958
} else {
@@ -63,10 +62,65 @@ class ListSettings: ObservableObject {
6362

6463
return predicate
6564
}
65+
66+
private static func futurePredicate() -> Predicate<Event> {
67+
let now = Date()
68+
return #Predicate<Event> { $0.end > now }
69+
}
70+
71+
private static func searchPredicate(_ searchText: String, type: ListPredicateType) -> Predicate<Event> {
72+
var predicate = #Predicate<Event> { $0.title.localizedStandardContains(searchText) }
73+
switch type {
74+
case .track:
75+
predicate = #Predicate<Event> {
76+
$0.title.localizedStandardContains(searchText)
77+
}
78+
case .person:
79+
predicate = #Predicate<Event> {
80+
$0.title.localizedStandardContains(searchText) ||
81+
!$0.authors.filter { author in
82+
author.name.localizedStandardContains(searchText)
83+
}.isEmpty
84+
}
85+
case .room:
86+
predicate = #Predicate<Event> {
87+
$0.title.localizedStandardContains(searchText) ||
88+
$0.room.name.localizedStandardContains(searchText)
89+
}
90+
}
91+
92+
return predicate
93+
}
6694
}
6795

6896
enum ListPredicateType {
6997
case person
7098
case room
7199
case track
100+
101+
static var all: [ListPredicateType] {
102+
return [.track, .person, .room]
103+
}
104+
105+
static func getName(_ type: ListPredicateType) -> String {
106+
switch type {
107+
case .person:
108+
return "People"
109+
case .room:
110+
return "Rooms"
111+
case .track:
112+
return "Tracks"
113+
}
114+
}
115+
116+
static func getIcon(_ type: ListPredicateType) -> String {
117+
switch type {
118+
case .person:
119+
return "person"
120+
case .room:
121+
return "door.left.hand.open"
122+
case .track:
123+
return "road.lanes"
124+
}
125+
}
72126
}

Fosdem/Views/Lists/AuthorEventList.swift

Lines changed: 0 additions & 34 deletions
This file was deleted.

0 commit comments

Comments
 (0)