Skip to content

Commit 31480df

Browse files
rgravinaXuqiuyeLi
authored andcommitted
Xcode 12.5 Support and handling of optional venue and location.
- Use xcframeworks for dependencies - Remove equality methods on structs, because Equatable is enough. - Handle optional venue and location. - Removed the Result dependency, as it isn't needed in new versions of Swift. Signed-off-by: Summer Li <[email protected]>
1 parent 76e158c commit 31480df

File tree

11 files changed

+191
-175
lines changed

11 files changed

+191
-175
lines changed

ios/Cartfile

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
github "Thomvis/BrightFutures"
2-
github "antitypical/Result"
32
github "PureLayout/PureLayout"
43

ios/Cartfile.resolved

-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,4 @@ github "PureLayout/PureLayout" "3.1.9"
22
github "Quick/Nimble" "v9.2.0"
33
github "Quick/Quick" "v4.0.0"
44
github "Thomvis/BrightFutures" "8.0.1"
5-
github "antitypical/Result" "5.0.0"
65
github "derekleerock/Succinct" "v0.4.33"

ios/Makefile

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
bootstrap:
2-
@carthage bootstrap --platform iOS --no-use-binaries --cache-builds
2+
@carthage bootstrap --use-xcframeworks --platform iOS --no-use-binaries --cache-builds
33

44
update:
5-
@carthage update --platform iOS --no-use-binaries --cache-builds
5+
@carthage update --use-xcframeworks --platform iOS --no-use-binaries --cache-builds
66

77
units:
8-
@xcodebuild -project WWCode_Tokyo_iOS.xcodeproj -scheme "WWCode_Tokyo_iOS" -destination "platform=iOS Simulator,OS=latest,name=iPhone 11" build test
8+
@xcodebuild -project WWCode_Tokyo_iOS.xcodeproj -scheme "WWCode_Tokyo_iOS" -destination "platform=iOS Simulator,OS=latest,name=iPhone 12" build test
99

1010
ci: bootstrap units
1111

ios/WWCode_Tokyo_iOS.xcodeproj/project.pbxproj

+38-90
Large diffs are not rendered by default.

ios/WWCode_Tokyo_iOS.xcodeproj/xcshareddata/xcschemes/WWCode_Tokyo_iOS.xcscheme

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "1130"
3+
LastUpgradeVersion = "1250"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,22 @@
11
import Foundation
22

3-
struct Venue: Codable {
4-
let name: String
5-
let lat: Double
6-
let lon: Double
7-
let address: String
8-
let city: String
9-
10-
static func ==(lhs: Venue, rhs: Venue) -> Bool {
11-
return
12-
lhs.name == rhs.name &&
13-
lhs.lat == rhs.lat &&
14-
lhs.lon == rhs.lon &&
15-
lhs.address == rhs.address &&
16-
lhs.city == rhs.city
17-
}
18-
}
19-
20-
struct Event: Codable {
3+
struct Event: Codable, Equatable {
214
let name: String
225
let startDateTime: String
236
let endDateTime: String
247
let description: String
25-
let venue: Venue
8+
let venue: Venue?
269
let link: String
2710
}
2811

29-
extension Event: Equatable {
30-
static func ==(lhs: Event, rhs: Event) -> Bool {
31-
return
32-
lhs.name == rhs.name &&
33-
lhs.startDateTime == rhs.startDateTime &&
34-
lhs.endDateTime == rhs.endDateTime &&
35-
lhs.description == rhs.description &&
36-
lhs.venue == rhs.venue &&
37-
lhs.link == rhs.link
38-
}
12+
struct Venue: Codable, Equatable {
13+
let name: String
14+
let location: Location?
15+
}
16+
17+
struct Location: Codable, Equatable {
18+
let lat: Double
19+
let lon: Double
20+
let address: String
21+
let city: String
3922
}

ios/WWCode_Tokyo_iOS/UI/EventDetail/EventViewController.swift

+4-2
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,10 @@ fileprivate extension EventViewController {
169169
}
170170

171171
func configureVenue() {
172-
venueName.text = event.venue.name
173-
venueAddress.text = "\(event.venue.address) \(event.venue.city)"
172+
venueName.text = event.venue?.name
173+
if let location = event.venue?.location {
174+
venueAddress.text = "\(location.address) \(location.city)"
175+
}
174176
}
175177

176178
func configureRegistration() {

ios/WWCode_Tokyo_iOS/UI/EventList/EventTableViewCell.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class EventTableViewCell: UITableViewCell {
3939

4040
timeLabel.text = "\(timeLabelFormatter.string(from: startDateTime)) - \(timeLabelFormatter.string(from: endDateTime))"
4141

42-
venueNameLabel.text = event.venue.name
42+
venueNameLabel.text = event.venue?.name
4343
}
4444
}
4545

ios/WWCode_Tokyo_iOSTests/Components/Events/EventFixture.swift

+8-4
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22

33
struct EventFixture {
44
static func JavaScript() -> Event {
5-
let venue = Venue(
6-
name: "Code Chrysalis",
5+
let location = Location(
76
lat: 1.23,
87
lon: 4.56,
98
address: "venue address",
109
city: "venue city")
10+
let venue = Venue(
11+
name: "Code Chrysalis",
12+
location: location)
1113

1214
return Event(
1315
name: "WTF is JavaScript?! Talk + Workshop for Beginners with WWCode & Automattic",
@@ -19,12 +21,14 @@ struct EventFixture {
1921
}
2022

2123
static func Hackathon() -> Event {
22-
let venue = Venue(
23-
name: "Mercari",
24+
let location = Location(
2425
lat: 1.23,
2526
lon: 4.56,
2627
address: "venue address",
2728
city: "venue city")
29+
let venue = Venue(
30+
name: "Mercari",
31+
location: location)
2832

2933
return Event(
3034
name: "Hackathon 101 with Junction Tokyo",

ios/WWCode_Tokyo_iOSTests/Components/Events/NetworkEventRepositoryTest.swift

+102-26
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class NetworkEventRepositoryTest: QuickSpec {
2020
expect(spyHttp.get_argument_endpoint).to(equal("/api/events/upcoming"))
2121
}
2222

23-
it("get upcoming events return upcoming events") {
23+
it("returns events for in person events") {
2424
var events: [Event]? = nil
2525
AsyncExpectation.execute() { expectation in
2626
eventRepository
@@ -30,7 +30,6 @@ class NetworkEventRepositoryTest: QuickSpec {
3030
expectation.fulfill()
3131
}
3232

33-
// We can use a multi-string literal
3433
let jsonResponse = """
3534
[
3635
{
@@ -40,10 +39,12 @@ class NetworkEventRepositoryTest: QuickSpec {
4039
"description": "some description",
4140
"venue": {
4241
"name": "venue name",
43-
"lat": 1.23,
44-
"lon": 4.56,
45-
"address": "venue address",
46-
"city": "venue city"
42+
"location": {
43+
"lat": 1.23,
44+
"lon": 4.56,
45+
"address": "venue address",
46+
"city": "venue city"
47+
}
4748
},
4849
"link": "example.com"
4950
},
@@ -54,10 +55,12 @@ class NetworkEventRepositoryTest: QuickSpec {
5455
"description": "some description",
5556
"venue": {
5657
"name": "venue name",
57-
"lat": 1.23,
58-
"lon": 4.56,
59-
"address": "venue address",
60-
"city": "venue city"
58+
"location": {
59+
"lat": 1.23,
60+
"lon": 4.56,
61+
"address": "venue address",
62+
"city": "venue city"
63+
}
6164
},
6265
"link": "example2.com"
6366
}
@@ -71,14 +74,86 @@ class NetworkEventRepositoryTest: QuickSpec {
7174
expect(events?.first?.startDateTime).to(equal("2021-06-12T18:30:00"))
7275
expect(events?.first?.endDateTime).to(equal("2021-06-12T21:30:00"))
7376
expect(events?.first?.description).to(equal("some description"))
74-
expect(events?.first?.venue.name).to(equal("venue name"))
75-
expect(events?.first?.venue.lat).to(equal(1.23))
76-
expect(events?.first?.venue.lon).to(equal(4.56))
77-
expect(events?.first?.venue.address).to(equal("venue address"))
78-
expect(events?.first?.venue.city).to(equal("venue city"))
77+
expect(events?.first?.venue?.name).to(equal("venue name"))
78+
expect(events?.first?.venue?.location?.lat).to(equal(1.23))
79+
expect(events?.first?.venue?.location?.lon).to(equal(4.56))
80+
expect(events?.first?.venue?.location?.address).to(equal("venue address"))
81+
expect(events?.first?.venue?.location?.city).to(equal("venue city"))
7982
expect(events?.first?.link).to(equal("example.com"))
8083
}
81-
84+
85+
it("returns events for in online events") {
86+
var events: [Event]? = nil
87+
AsyncExpectation.execute() { expectation in
88+
eventRepository
89+
.getUpcomingEvents()
90+
.onSuccess { returnedEvents in
91+
events = returnedEvents
92+
expectation.fulfill()
93+
}
94+
95+
let jsonResponse = """
96+
[
97+
{
98+
"name": "Online Livehouse",
99+
"startDateTime": "2021-06-12T18:30:00",
100+
"endDateTime": "2021-06-12T21:30:00",
101+
"description": "some description",
102+
"venue": {
103+
"name": "Online event",
104+
"location": null
105+
},
106+
"link": "example.com"
107+
}
108+
]
109+
"""
110+
spyHttp.get_returnPromise.success(jsonResponse.data(using: .utf8)!)
111+
}
112+
113+
expect(events?.count).to(equal(1))
114+
expect(events?.first?.name).to(equal("Online Livehouse"))
115+
expect(events?.first?.startDateTime).to(equal("2021-06-12T18:30:00"))
116+
expect(events?.first?.endDateTime).to(equal("2021-06-12T21:30:00"))
117+
expect(events?.first?.description).to(equal("some description"))
118+
expect(events?.first?.venue?.name).to(equal("Online event"))
119+
expect(events?.first?.venue?.location).to(beNil())
120+
expect(events?.first?.link).to(equal("example.com"))
121+
}
122+
123+
it("returns events events with no venue") {
124+
var events: [Event]? = nil
125+
AsyncExpectation.execute() { expectation in
126+
eventRepository
127+
.getUpcomingEvents()
128+
.onSuccess { returnedEvents in
129+
events = returnedEvents
130+
expectation.fulfill()
131+
}
132+
133+
let jsonResponse = """
134+
[
135+
{
136+
"name": "Online Livehouse",
137+
"startDateTime": "2021-06-12T18:30:00",
138+
"endDateTime": "2021-06-12T21:30:00",
139+
"description": "some description",
140+
"venue": null,
141+
"link": "example.com"
142+
}
143+
]
144+
"""
145+
spyHttp.get_returnPromise.success(jsonResponse.data(using: .utf8)!)
146+
}
147+
148+
expect(events?.count).to(equal(1))
149+
expect(events?.first?.name).to(equal("Online Livehouse"))
150+
expect(events?.first?.startDateTime).to(equal("2021-06-12T18:30:00"))
151+
expect(events?.first?.endDateTime).to(equal("2021-06-12T21:30:00"))
152+
expect(events?.first?.description).to(equal("some description"))
153+
expect(events?.first?.venue).to(beNil())
154+
expect(events?.first?.link).to(equal("example.com"))
155+
}
156+
82157
it("getPastEvents requests GET /api/events/past") {
83158
let _ = eventRepository.getPastEvents()
84159

@@ -95,7 +170,6 @@ class NetworkEventRepositoryTest: QuickSpec {
95170
expectation.fulfill()
96171
}
97172

98-
// We can use a multi-string literal
99173
let jsonResponse = """
100174
[
101175
{
@@ -105,10 +179,12 @@ class NetworkEventRepositoryTest: QuickSpec {
105179
"description": "description",
106180
"venue": {
107181
"name": "venue name",
108-
"lat": 1.23,
109-
"lon": 4.56,
110-
"address": "venue address",
111-
"city": "venue city"
182+
"location": {
183+
"lat": 1.23,
184+
"lon": 4.56,
185+
"address": "venue address",
186+
"city": "venue city"
187+
}
112188
},
113189
"link": "example.com"
114190
}
@@ -122,11 +198,11 @@ class NetworkEventRepositoryTest: QuickSpec {
122198
expect(events?.first?.startDateTime).to(equal("2020-02-29T19:30:00"))
123199
expect(events?.first?.endDateTime).to(equal("2020-02-29T21:30:00"))
124200
expect(events?.first?.description).to(equal("description"))
125-
expect(events?.first?.venue.name).to(equal("venue name"))
126-
expect(events?.first?.venue.lat).to(equal(1.23))
127-
expect(events?.first?.venue.lon).to(equal(4.56))
128-
expect(events?.first?.venue.address).to(equal("venue address"))
129-
expect(events?.first?.venue.city).to(equal("venue city"))
201+
expect(events?.first?.venue?.name).to(equal("venue name"))
202+
expect(events?.first?.venue?.location?.lat).to(equal(1.23))
203+
expect(events?.first?.venue?.location?.lon).to(equal(4.56))
204+
expect(events?.first?.venue?.location?.address).to(equal("venue address"))
205+
expect(events?.first?.venue?.location?.city).to(equal("venue city"))
130206
expect(events?.first?.link).to(equal("example.com"))
131207
}
132208
}

0 commit comments

Comments
 (0)