Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
e0978e2
Add basic project structure from Xcode
csambrosio01 Jan 10, 2023
548193f
Add basic coordnator structure
csambrosio01 Jan 10, 2023
1c2048b
Fix .gitignore
csambrosio01 Jan 10, 2023
769f1d7
Create basic API structure and environment
csambrosio01 Jan 10, 2023
51cbbc1
Create APIHandler, an extension for its decode and ServiceError, to e…
csambrosio01 Jan 10, 2023
a0633e1
Add APILoader with basic structure to call API using URL Session
csambrosio01 Jan 10, 2023
ce40f6a
Add new TrendingAPI and TrendingDTOs to call API, also add implementa…
csambrosio01 Jan 10, 2023
3738b65
Add call to method that actually applies API Key
csambrosio01 Jan 10, 2023
d551fb9
Create basic HomeViewController structure
csambrosio01 Jan 11, 2023
b083b54
Add HomeView and initialize it with Trending and TopRated view contro…
csambrosio01 Jan 11, 2023
429e5d3
Create TrendingView with label and collection view
csambrosio01 Jan 11, 2023
c3fbfbb
Move TrendingResult to DTO folder
csambrosio01 Jan 11, 2023
a1c6212
Create TrendingListViewModel and TrendingViewModel, also add logic to…
csambrosio01 Jan 11, 2023
c49779c
Add TrendingCollectionViewCell and update Collection View with its in…
csambrosio01 Jan 11, 2023
46cd58c
Remove .DS_Store files
csambrosio01 Jan 12, 2023
03498a2
Remove xcuserdatad
csambrosio01 Jan 12, 2023
419ff8b
Fix navigationController in Coordinator pattern
csambrosio01 Jan 12, 2023
cd89954
Make backend configuration more developer friendly
csambrosio01 Jan 12, 2023
ff9a002
Improve APILoader with a more understandable code
csambrosio01 Jan 12, 2023
3fb9f5b
Create struct for TrendingParams
csambrosio01 Jan 12, 2023
3c3e9f7
Create extension for collection view delegate and datasource
csambrosio01 Jan 12, 2023
bf175db
Minor refactorings to make CollectionView horizontal
csambrosio01 Jan 12, 2023
0dc3525
Fix spaces between cells and cells that was with empty title
csambrosio01 Jan 12, 2023
b626ea8
Add TopRatedAPI and path for it in API Path
csambrosio01 Jan 13, 2023
73db253
Create TopRatedListViewModel and also delete TopRatedViewController
csambrosio01 Jan 13, 2023
ab03662
Add title to TrendingListViewModel
csambrosio01 Jan 13, 2023
3a907d0
Fix typo
csambrosio01 Jan 13, 2023
bf6152e
Make TrendingView and TrendingViewController accept TopRated logic
csambrosio01 Jan 13, 2023
ef6f77d
Refactor HomeView, HomeViewController and MainCoordinator to add TopR…
csambrosio01 Jan 13, 2023
cafc1bf
Hide navigation bar
csambrosio01 Jan 13, 2023
0d31ed1
Change API parameter to .movie
csambrosio01 Jan 13, 2023
c17ad13
Create Movie and MovieAPI to get movie details
csambrosio01 Jan 14, 2023
d374c1e
Create MovieViewModel that calls API and have all information needed …
csambrosio01 Jan 14, 2023
a53b445
Create MovieView and MovieViewController
csambrosio01 Jan 14, 2023
85a1bdd
Detect click in cell and redirects to MovieViewController
csambrosio01 Jan 14, 2023
f2218f4
Fix Xcode warning'
csambrosio01 Jan 14, 2023
22d729f
Create MockURLProtocol and tests for TrendingListViewModel
csambrosio01 Jan 14, 2023
f4b5f73
Rename TrendingTests to TrendingListViewModelSpec
csambrosio01 Jan 14, 2023
9a3bba4
Move TrendingListViewModelSpec to new folder and delete base test file
csambrosio01 Jan 14, 2023
6d34b14
Mock files that was inserted in the wrong way
csambrosio01 Jan 14, 2023
28f0072
Minor fixes in TrendingListViewModelSpec and add test for error call
csambrosio01 Jan 14, 2023
0033593
Create tests for TopRatedListViewModel
csambrosio01 Jan 14, 2023
a0328b9
Create tests for MovieViewModel
csambrosio01 Jan 14, 2023
66e6a15
Create tests for TrendingViewModel
csambrosio01 Jan 14, 2023
79c7de5
Create tests for MainCoordinator
csambrosio01 Jan 14, 2023
10ee06a
Fix broken test
csambrosio01 Jan 14, 2023
bba1846
Add favorite swipe action and favorite repository to store favorites
csambrosio01 Jan 14, 2023
b8d90c8
Fix navigation bar hide and show
csambrosio01 Jan 14, 2023
abfcecf
Create favorite movies screen
csambrosio01 Jan 14, 2023
5e57792
Fix MovieView
csambrosio01 Jan 16, 2023
ae01fac
Minor fixes in favorites view
csambrosio01 Jan 16, 2023
7ea1aff
Remove unused class
csambrosio01 Jan 16, 2023
be3aae0
Add animation for delete a movie in favorites repository
csambrosio01 Jan 16, 2023
dc32820
Fix function that deletes elements from repository and also fix anima…
csambrosio01 Jan 16, 2023
19b456a
Save movieId in view model instead of view controller
csambrosio01 Jan 17, 2023
ea3ded3
Refact tests to extract duplicated code
csambrosio01 Jan 17, 2023
9216529
Fix warning
csambrosio01 Jan 17, 2023
38dbf70
Refact get all favorites to use compactMap
csambrosio01 Jan 17, 2023
23abeba
Fix MainCoordinatorSpec to actually test MainCoordinator logic
csambrosio01 Jan 17, 2023
5deb073
Remove not used variables from TrendingReulst and Movie
csambrosio01 Jan 17, 2023
469d119
Write testes for FavoriteRepository and remove UI Example tests
csambrosio01 Jan 17, 2023
e2c15f6
Add comments and minor fixes in the code
csambrosio01 Jan 17, 2023
17c12af
Remove comment
csambrosio01 Jan 17, 2023
0a15fd8
Remame TrendingViewController and it sub files to MovieList
csambrosio01 Jan 17, 2023
0d4f42a
Fix click in a movie when in favorite screen
csambrosio01 Jan 17, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
**/xcuserdata
**.xcuserstate
*.DS_Store
963 changes: 963 additions & 0 deletions MyMovies.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
36 changes: 36 additions & 0 deletions MyMovies/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//
// AppDelegate.swift
// MyMovies
//
// Created by Caio dos Santos Ambrosio on 1/10/23.
//

import UIKit

@main
class AppDelegate: UIResponder, UIApplicationDelegate {



func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
return true
}

// MARK: UISceneSession Lifecycle

func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
// Called when a new scene session is being created.
// Use this method to select a configuration to create the new scene with.
return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
}

func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {
// Called when the user discards a scene session.
// If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
// Use this method to release any resources that were specific to the discarded scenes, as they will not return.
}


}

11 changes: 11 additions & 0 deletions MyMovies/Assets.xcassets/AccentColor.colorset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"colors" : [
{
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
13 changes: 13 additions & 0 deletions MyMovies/Assets.xcassets/AppIcon.appiconset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"images" : [
{
"idiom" : "universal",
"platform" : "ios",
"size" : "1024x1024"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
6 changes: 6 additions & 0 deletions MyMovies/Assets.xcassets/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
25 changes: 25 additions & 0 deletions MyMovies/Base.lproj/LaunchScreen.storyboard
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.16" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.12"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="EHf-IW-A2E">
<objects>
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" xcode11CocoaTouchSystemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="53" y="375"/>
</scene>
</scenes>
</document>
19 changes: 19 additions & 0 deletions MyMovies/Coordinator/Coordinator.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//
// Coordinator.swift
// MyMovies
//
// Created by Caio dos Santos Ambrosio on 1/10/23.
//

import UIKit

protocol Coordinator {
var navigationController: UINavigationController { get }

func eventOccurred(with type: Event, parameters params: Any?)
func start()
}

protocol Coordinating {
var coordinator: Coordinator? { get set }
}
12 changes: 12 additions & 0 deletions MyMovies/Coordinator/Event.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//
// Event.swift
// MyMovies
//
// Created by Caio dos Santos Ambrosio on 1/13/23.
//

import Foundation

enum Event {
case movieClicked, favoriteClicked
}
64 changes: 64 additions & 0 deletions MyMovies/Coordinator/MainCoordinator.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
//
// MainCoordinator.swift
// MyMovies
//
// Created by Caio dos Santos Ambrosio on 1/10/23.
//

import UIKit

class MainCoordinator: Coordinator {

let navigationController: UINavigationController

init(navigationController: UINavigationController) {
self.navigationController = navigationController
}

func eventOccurred(with type: Event, parameters params: Any?) {
switch type {
case .movieClicked:
guard let movieId = params as? Int64 else { return }

let api = MovieAPI()
let apiLoader = APILoader(apiHandler: api)
let viewModel = MovieViewModel(apiLoader: apiLoader, movieId: movieId)
let viewController = MovieViewController(movieViewModel: viewModel)

navigationController.pushViewController(viewController, animated: true)

case .favoriteClicked:
let repository = FavoriteRepository()
let viewModel = FavoriteViewModel(favoriteRepository: repository)
let viewController = MovieListViewController(favoriteViewModel: viewModel, coordinator: self)

navigationController.pushViewController(viewController, animated: true)
}
}

func start() {
let apiTrending = TrendingAPI()
let apiLoaderTrending = APILoader(apiHandler: apiTrending)
let trendingViewModel = TrendingListViewModel(apiLoader: apiLoaderTrending)
let trendingViewController = MovieListViewController(
trendingListViewModel: trendingViewModel,
coordinator: self
)

let apiTopRated = TopRatedAPI()
let apiLoaderTopRated = APILoader(apiHandler: apiTopRated)
let topRatedListViewModel = TopRatedListViewModel(apiLoader: apiLoaderTopRated)
let topRatedViewController = MovieListViewController(
topRatedListViewModel: topRatedListViewModel,
coordinator: self
)

let viewController = HomeViewController(
trendingViewController: trendingViewController,
topRatedViewController: topRatedViewController,
coordinator: self
)

navigationController.setViewControllers([viewController], animated: false)
}
}
29 changes: 29 additions & 0 deletions MyMovies/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>BASE_API_KEY</key>
<string>$(BASE_API_KEY)</string>
<key>BASE_IMAGE_URL</key>
<string>$(BASE_IMAGE_URL)</string>
<key>BASE_URL</key>
<string>$(BASE_URL)</string>
<key>UIApplicationSceneManifest</key>
<dict>
<key>UIApplicationSupportsMultipleScenes</key>
<false/>
<key>UISceneConfigurations</key>
<dict>
<key>UIWindowSceneSessionRoleApplication</key>
<array>
<dict>
<key>UISceneConfigurationName</key>
<string>Default Configuration</string>
<key>UISceneDelegateClassName</key>
<string>$(PRODUCT_MODULE_NAME).SceneDelegate</string>
</dict>
</array>
</dict>
</dict>
</dict>
</plist>
23 changes: 23 additions & 0 deletions MyMovies/Model/DTO/Movie.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//
// Movie.swift
// MyMovies
//
// Created by Caio dos Santos Ambrosio on 1/13/23.
//

import Foundation

struct Movie: Decodable {
let genres: [Genre]
let originalTitle: String?
let overview: String?
let posterPath: String?
let releaseDate: String?
let title: String?
let voteAverage: Double
let voteCount: Int64
}

struct Genre: Decodable {
let name: String
}
15 changes: 15 additions & 0 deletions MyMovies/Model/DTO/TrendingDTO.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//
// TrendingDTO.swift
// MyMovies
//
// Created by Caio dos Santos Ambrosio on 1/10/23.
//

import Foundation

struct TrendingDTO: Decodable {
let page: Int?
let results: [TrendingResult]?
let totalPages: Int?
let totalResults: Int?
}
15 changes: 15 additions & 0 deletions MyMovies/Model/DTO/TrendingResult.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//
// TrendingResult.swift
// MyMovies
//
// Created by Caio dos Santos Ambrosio on 1/10/23.
//

import Foundation

struct TrendingResult: Codable {
let posterPath: String?
let id: Int64?
let originalTitle: String?
let name: String?
}
Loading