feat - Busbud mobile app coding challenge - iOS - Amanda Paiva #24
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Implement the Busbud mobile app coding challenge, forked from coding-challenge-native-b.
This is a native MVVM iOS application that utilizes Busbud's API to display a list of nearby cities.
This app is localized in English and Brazilian Portuguese (pt-BR) using Localizable.strings files.
Motivation and Context
This implementation fulfills the requirements of the Busbud coding challenge by:
This project showcases skills in API integration, iOS development, and clean code practices.
Changes Included
Core Feature Implementation:
City.swift: Created theCitymodel to represent location data, including properties for name, latitude, longitude, and distance.CityService.swift: Developed a service for fetching city data and calculating distances between cities and the user's location.CityViewModel.swift: Added logic to manage data fetching, filtering, and presenting nearby cities in the view.User Interface:
NearbyCitiesView.swift: Displays a list of nearby cities usingCityViewModeland handles user interactions.CityDetailsView.swift: Displays detailed information about a selected city.Error Scenarios
The app handles different error scenarios, represented by the
ViewStateenumeration. Each state is responsible for displaying specific messages to the user depending on the conditions.1.
permissionDenied2.
obtainingLocationCityViewModelis instantiated and thelocationManagerstarts fetching the user's location. During this time, the app is trying to obtain the location to proceed with fetching nearby cities.3.
cities4.
error(String)Error Handling Details
viewStateis changed to.errorwith the message "Location is not available".viewStateis changed to.errorwith the message "Failed to fetch cities".viewStateis changed to.errorwith the message "No cities found nearby".CLLocationManager: If theCLLocationManagerfails to obtain the location, theviewStateis changed to.error.Utilities and Extensions:
CLLocation+Extensions.swift: ExtendedCLLocationwith utility methods for calculating distances.Double+Extensions.swift: Added formatting utilities for displaying distance values.App Configuration:
BusBudiOSChallengeApp.swift: Integrated the Nearby Cities feature into the app's navigation structure.Localizable.stringsfiles to support English (en) and Portuguese (pt-BR) translations.Unit Test:
CityServiceTests.swift: Verified the correctness of city data fetching and distance calculations.CityViewModelTests.swift: Tested the view model logic for handling and presenting city data.DistanceCalculateTests.swift: Ensured accurate distance calculations using utility extensions.Project Configuration:
.pbxproj,.xcworkspace) to reflect new files and dependencies.Testing and Verification
XCTestachieve high coverage for services, view models, and utilities.How Has This Been Tested?
CityViewModelandDistanceCalculatecomponents.pbxprojfile.This project was developed with:
Screenshots:
Instructions to Clone and Run the Project
Prerequisites
Ensure that you have the following tools installed on your machine:
Cloning the Repository
Open your terminal.
Navigate to the directory where you want to clone the repository.
Run the following command: