Skip to content

Commit

Permalink
Bug fixes re: route colors, configurable distance to hide stations
Browse files Browse the repository at this point in the history
  • Loading branch information
elliottwilliams committed Oct 14, 2017
1 parent 2787813 commit c148632
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 5 deletions.
1 change: 1 addition & 0 deletions Proper/Configuration/BartConfig.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ struct BartAgencyConfig: AgencyConfig {
let name = "BART"
let region = MKCoordinateRegionMakeWithDistance(
CLLocationCoordinate2D(latitude: 37.784128, longitude: -122.4570273), 33_000, 20_000)
let maxLatitudeSpanForStations: CLLocationDegrees = 10.0/111
let timeResolution = TimeInterval(30)

let badgeForRoute: (MutableRoute) -> Property<String?> = { _ in .init(value: nil) }
Expand Down
1 change: 1 addition & 0 deletions Proper/Configuration/CitybusConfig.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ struct CitybusAgencyConfig: AgencyConfig {
let name = "CityBus"
let region = MKCoordinateRegionMakeWithDistance(
CLLocationCoordinate2D(latitude: 40.424758, longitude: -86.913649), 500, 500)
let maxLatitudeSpanForStations: CLLocationDegrees = 3.5/111
let timeResolution = TimeInterval(30)

let badgeForRoute: (MutableRoute) -> Property<String?> = { .init(value: $0.shortName) }
Expand Down
1 change: 1 addition & 0 deletions Proper/Configuration/ConfigProtocols.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ protocol AgencyConfig {
var key: String { get }
var name: String { get }
var region: MKCoordinateRegion { get }
var maxLatitudeSpanForStations: CLLocationDegrees { get }
var timeResolution: TimeInterval { get }
var badgeForRoute: (MutableRoute) -> Property<String?> { get }
var titleForRoute: (MutableRoute) -> Property<String?> { get }
Expand Down
2 changes: 1 addition & 1 deletion Proper/Models/MutableModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ extension MutableModel {

func attachOrApply<M: MutableModel>(to property: MutableProperty<M?>, from update: M.FromModel?) throws {
guard let update = update else { return }
if let mutable = property.value {
if let mutable = property.value, mutable.identifier == update.identifier {
try mutable.apply(update)
} else {
property.value = try attachMutable(from: update) as M
Expand Down
8 changes: 4 additions & 4 deletions Proper/Views/ArrivalTableViewCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class ArrivalTableViewCell: UITableViewCell {
disposable?.dispose()
}

func apply(arrival: Arrival) {
func apply(arrival: Arrival, route: SignalProducer<MutableRoute, NoError>) {
self.disposable?.dispose()
let disposable = CompositeDisposable()

Expand All @@ -51,9 +51,9 @@ class ArrivalTableViewCell: UITableViewCell {
let title = Config.shared.map({ $0.agency.titleForArrival(arrival) }).flatten(.latest)
disposable += title.producer
.startWithValues({ self.routeTitle.text = $0 })
disposable += arrival.route.color.producer.skipNil().startWithValues({ self.badge.color = $0 })
disposable += arrival.route.producer.start()

disposable += route.flatMap(.latest, transform: { $0.color.producer }).skipNil()
.startWithValues({ self.badge.color = $0 })

disposable += ArrivalsViewModel.label(for: arrival).startWithValues({ self.routeTimer.text = $0 })
self.disposable = disposable
Expand Down

0 comments on commit c148632

Please sign in to comment.