Skip to content

Commit

Permalink
Merge pull request #249 from skedgo/upstream
Browse files Browse the repository at this point in the history
Upstream
  • Loading branch information
nighthawk authored Feb 21, 2023
2 parents 0315035 + ee8af53 commit 63c4a67
Show file tree
Hide file tree
Showing 21 changed files with 86 additions and 172 deletions.
26 changes: 13 additions & 13 deletions Examples/CocoaPodsTest/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
PODS:
- GeoMonitor (0.1.1)
- Kingfisher (7.4.1)
- GeoMonitor (0.1.2)
- Kingfisher (7.6.1)
- RxCocoa (6.5.0):
- RxRelay (= 6.5.0)
- RxSwift (= 6.5.0)
- RxRelay (6.5.0):
- RxSwift (= 6.5.0)
- RxSwift (6.5.0)
- TGCardViewController (2.1.2)
- TripKit (4.3.0)
- TripKitInterApp (4.3.0):
- TripKit (~> 4.3.0)
- TripKitUI (4.3.0):
- GeoMonitor (~> 0.1)
- TripKit (4.4.2)
- TripKitInterApp (4.4.2):
- TripKit (~> 4.4.2)
- TripKitUI (4.4.2):
- GeoMonitor (~> 0.1.2)
- Kingfisher (~> 7.0)
- RxCocoa (~> 6.5)
- RxSwift (~> 6.5)
- TGCardViewController (>= 2.1)
- TripKit (~> 4.3.0)
- TripKit (~> 4.4.2)

DEPENDENCIES:
- TripKit (from `../../`)
Expand All @@ -42,15 +42,15 @@ EXTERNAL SOURCES:
:path: "../../"

SPEC CHECKSUMS:
GeoMonitor: 4f71326249934ee41b16772546f79e93205cac45
Kingfisher: cd762a593a61b2fbecf7645c00f9a801a3ebfc9c
GeoMonitor: 3af6b577d3f55007c3570c05ed20d0b97b18267e
Kingfisher: 93a3c6d0d551658a31e19f21747e1d15cb39d525
RxCocoa: 94f817b71c07517321eb4f9ad299112ca8af743b
RxRelay: 1de1523e604c72b6c68feadedd1af3b1b4d0ecbd
RxSwift: 5710a9e6b17f3c3d6e40d6e559b9fa1e813b2ef8
TGCardViewController: a19c5fad9f8352f75a7cd0663292d63c693b9947
TripKit: fca5aab1f4a6b2a4e2e2bb9d236192a528cc6ea7
TripKitInterApp: 4a61bcde573c741d107cd973dcbb15a3eba61026
TripKitUI: 309c28ef02d05a3111da454d6e990322abf9f7a6
TripKit: 529557ef943f1d2731c04b74ac92e326383d1637
TripKitInterApp: c038c575f9a490dd993200be8950dbe8ae936f78
TripKitUI: cdac5df250bede3dccbfe736bf06d44c3aaac7b9

PODFILE CHECKSUM: fd67bcba748ae215ff8d7ed6cf43555a3235bd4a

Expand Down

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.
55 changes: 42 additions & 13 deletions Sources/TripKit/server/TKWaypointRouter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ extension TKWaypointRouter {

TKRegionManager.shared.requireRegions { error in
guard let region = trip.request.startRegion else {
completion(.failure(TKWaypointRouter.WaypointError.couldNotFindRegionForTrip))
DispatchQueue.main.async {
completion(.failure(TKWaypointRouter.WaypointError.couldNotFindRegionForTrip))
}
return
}

Expand Down Expand Up @@ -101,11 +103,15 @@ extension TKWaypointRouter {

TKRegionManager.shared.requireRegions { result in
if case .failure(let error) = result {
completion(.failure(error))
DispatchQueue.main.async {
completion(.failure(error))
}
return
}
guard let region = segment.trip.request.startRegion else {
completion(.failure(TKWaypointRouter.WaypointError.couldNotFindRegionForTrip))
DispatchQueue.main.async {
completion(.failure(TKWaypointRouter.WaypointError.couldNotFindRegionForTrip))
}
return
}

Expand All @@ -118,7 +124,9 @@ extension TKWaypointRouter {
self.fetchTrip(input: input, region: region, into: segment.trip.request, completion: completion)

} catch {
completion(.failure(error))
DispatchQueue.main.async {
completion(.failure(error))
}
}
}
}
Expand All @@ -127,11 +135,15 @@ extension TKWaypointRouter {

TKRegionManager.shared.requireRegions { result in
if case .failure(let error) = result {
completion(.failure(error))
DispatchQueue.main.async {
completion(.failure(error))
}
return
}
guard let region = segment.trip.request.startRegion else {
completion(.failure(TKWaypointRouter.WaypointError.couldNotFindRegionForTrip))
DispatchQueue.main.async {
completion(.failure(TKWaypointRouter.WaypointError.couldNotFindRegionForTrip))
}
return
}

Expand All @@ -143,7 +155,9 @@ extension TKWaypointRouter {
self.fetchTrip(input: input, region: region, into: segment.trip.tripGroup, completion: completion)

} catch {
completion(.failure(error))
DispatchQueue.main.async {
completion(.failure(error))
}
}
}

Expand All @@ -158,12 +172,16 @@ extension TKWaypointRouter {
public static func fetchTrip(byMoving segment: TKSegment, to location: TKModeCoordinate, usingPrivateVehicles vehicles: [TKVehicular] = [], completion: @escaping (Result<Trip, Error>) -> Void) {
TKRegionManager.shared.requireRegions { result in
if case .failure(let error) = result {
completion(.failure(error))
DispatchQueue.main.async {
completion(.failure(error))
}
return
}

guard let region = segment.trip.request.startRegion else {
completion(.failure(TKWaypointRouter.WaypointError.couldNotFindRegionForTrip))
DispatchQueue.main.async {
completion(.failure(TKWaypointRouter.WaypointError.couldNotFindRegionForTrip))
}
return
}

Expand Down Expand Up @@ -192,7 +210,9 @@ extension TKWaypointRouter {
let input = buildInput(segments: segments, vehicles: vehicles)
self.fetchTrip(input: input, region: region, into: segment.trip.tripGroup, completion: completion)
} catch {
completion(.failure(error))
DispatchQueue.main.async {
completion(.failure(error))
}
}
}
}
Expand All @@ -219,12 +239,15 @@ extension TKWaypointRouter {
let response = try await fetchAndParse(input: input, region: region, into: context)
let routingResponse = try response.result.get()
TKRoutingParser.add(routingResponse, to: tripGroup, merge: false) { parserResult in
dispatchPrecondition(condition: .onQueue(.main))
completion(Result {
try parserResult.get().first.orThrow(WaypointError.fetchedResultsButGotNoTrip)
})
}
} catch {
completion(.failure(error))
DispatchQueue.main.async {
completion(.failure(error))
}
}
}
}
Expand All @@ -245,12 +268,15 @@ extension TKWaypointRouter {
let response = try await fetchAndParse(input: input, region: region, into: context)
let routingResponse = try response.result.get()
TKRoutingParser.add(routingResponse, to: request, merge: false) { parserResult in
dispatchPrecondition(condition: .onQueue(.main))
completion(Result {
try parserResult.get().first.orThrow(WaypointError.fetchedResultsButGotNoTrip)
})
}
} catch {
completion(.failure(error))
DispatchQueue.main.async {
completion(.failure(error))
}
}
}
}
Expand All @@ -262,12 +288,15 @@ extension TKWaypointRouter {
let response = try await fetchAndParse(input: input, region: region, into: context)
let routingResponse = try response.result.get()
TKRoutingParser.add(routingResponse, into: context) { parserResult in
dispatchPrecondition(condition: .onQueue(.main))
completion(Result {
try parserResult.get().trips.first.orThrow(WaypointError.fetchedResultsButGotNoTrip)
})
}
} catch {
completion(.failure(error))
DispatchQueue.main.async {
completion(.failure(error))
}
}
}
}
Expand Down

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ extension UIImageView {
convenience init(asRealTimeAccessoryImageAnimated animated: Bool, tintColor: UIColor? = nil) {
self.init()

let images = UIImageView.realTimeAccessoryImage(animated, tintColor: tintColor)
let images = UIImageView.realTimeAccessoryImage(animated)
if animated {
self.image = images.last
self.animationImages = images
Expand All @@ -26,49 +26,25 @@ extension UIImageView {
self.image = images.first
}
self.accessibilityLabel = Loc.RealTime
if let tintColor {
self.tintColor = tintColor
}
}

private static func realTimeAccessoryImage(_ animated: Bool, tintColor: UIColor? = nil) -> [UIImage] {
if animated {
var image1 = TripKitUIBundle.imageNamed("icon-signal-bars1")
var image2 = TripKitUIBundle.imageNamed("icon-signal-bars2")
var image3 = TripKitUIBundle.imageNamed("icon-signal-bars3")
private static func realTimeAccessoryImage(_ animated: Bool) -> [UIImage] {
if #available(iOS 16.0, *), animated {
let image1 = UIImage(systemName: "dot.radiowaves.forward", variableValue: 0.3)
let image2 = UIImage(systemName: "dot.radiowaves.forward", variableValue: 0.7)
let image3 = UIImage(systemName: "dot.radiowaves.forward", variableValue: 1.0)
return [image1, image2, image3, image3, image3, image3, image3, image3].compactMap { $0 }

} else if #available(iOS 14.0, *) {
// Right-pointing, all bars
return [UIImage(systemName: "dot.radiowaves.forward")].compactMap { $0 }

if let tintColor = tintColor {
image1 = image1.applying(tintColor: tintColor)
image2 = image2.applying(tintColor: tintColor)
image3 = image3.applying(tintColor: tintColor)
}
return [image1, image2, image3, image3, image3, image3, image3, image3]
} else {
return [TripKitUIBundle.imageNamed("icon-signal-bars3")]
// Up-pointing, like wifi, all bars
return [UIImage(systemName: "wifi")].compactMap { $0 }
}
}
}

extension UIImage {
func applying(tintColor: UIColor) -> UIImage {
let drawRect = CGRect(origin: .zero, size: size)
UIGraphicsBeginImageContextWithOptions(drawRect.size, false, 0)
guard
let context = UIGraphicsGetCurrentContext(),
let cgImage = self.cgImage
else { return self }

context.translateBy(x: 0, y: size.height)
context.scaleBy(x: 1, y: -1)

// draw original image
context.setBlendMode(.normal)
context.draw(cgImage, in: drawRect)

// draw color atop
context.setFillColor(tintColor.cgColor)
context.setBlendMode(.sourceAtop)
context.fill(drawRect)

let tinted = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
return tinted ?? self
}
}
Loading

0 comments on commit 63c4a67

Please sign in to comment.