This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var locationSearchViewModel: LocationSearchViewModel { | |
| let placeService = PlaceApiService(apiClient: apiClient) | |
| let viewModel = LocationSearchViewModel(service: placeService) | |
| viewModel.coordinatorDelegate = self | |
| return viewModel | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class PlaceApiService { | |
| let apiClient: ApiClient | |
| // MARK: - Init | |
| init(apiClient: ApiClient) { | |
| self.apiClient = apiClient | |
| } | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| protocol PlaceService { | |
| func prefetchPlaces(completion: @escaping (Result<[Place]>) -> Void) | |
| func getPlaces(withText text: String, completion: @escaping (Result<[Place]>) -> Void) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func tripCount() -> Int { | |
| return trips.count | |
| } | |
| func trip(forRow row: Int) -> TripViewDataType { | |
| let trip = trips[row] | |
| return TripViewData(trip: trip) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| struct TripViewData: TripViewDataType { | |
| var departureTime: String { | |
| return DateHelper.timeFormatter.string(from: trip.departure) | |
| } | |
| var shouldShowTerminals: Bool { | |
| return !(trip is Flight) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| protocol TripViewDataType { | |
| var departureTime: String { get } | |
| var shouldShowTerminals: Bool { get } | |
| var departureTerminal: String { get } | |
| var accentColor: UIColor { get } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class LocationSearchViewController: UIViewController { | |
| // MARK: - Properties | |
| var viewModel: LocationSearchViewModelType! { | |
| didSet { | |
| viewModel.viewDelegate = self | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| extension LocationSearchViewModel: LocationSearchViewModelType { | |
| // MARK: - Data Source | |
| var shouldShowHeader: Bool { | |
| return !isSearching | |
| } | |
| var headerText: String { | |
| return "Search" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class LocationSearchViewModel { | |
| // MARK: - Delegates | |
| weak var coordinatorDelegate: LocationSearchViewModelCoordinatorDelegate? | |
| weak var viewDelegate: LocationSearchViewModelViewDelegate? | |
| // MARK: - Properties |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| protocol LocationSearchViewModelType { | |
| weak var viewDelegate: LocationSearchViewModelViewDelegate? { get set } | |
| // Data Source | |
| var shouldShowHeader: Bool { get } | |
| var headerText: String { get } |
NewerOlder