-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from just1103/search
네트워크 및 목록 화면을 구현했습니다.
- Loading branch information
Showing
24 changed files
with
1,088 additions
and
81 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// | ||
// Array+Subscript.swift | ||
// BookFinder | ||
// | ||
// Created by Hyoju Son on 2022/07/31. | ||
// | ||
|
||
import Foundation | ||
|
||
extension Array { | ||
subscript(safe index: Int) -> Element? { | ||
return indices ~= index ? self[index] : nil | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// | ||
// UIColor+CustomColor.swift | ||
// BookFinder | ||
// | ||
// Created by Hyoju Son on 2022/07/31. | ||
// | ||
|
||
import UIKit | ||
|
||
extension UIColor { | ||
static let background: UIColor = #colorLiteral(red: 0.9524367452, green: 0.9455882907, blue: 0.9387311935, alpha: 1) | ||
static let lightGreen: UIColor = #colorLiteral(red: 0.5567998886, green: 0.7133290172, blue: 0.6062341332, alpha: 1) | ||
static let darkGreen: UIColor = #colorLiteral(red: 0.137904644, green: 0.3246459067, blue: 0.2771841288, alpha: 1) | ||
static let lightGray = #colorLiteral(red: 0.9137251377, green: 0.9137259126, blue: 0.9309338927, alpha: 1) // light mode의 systemGray6 | ||
static let mediumLightGray = #colorLiteral(red: 0.8196074367, green: 0.8196083307, blue: 0.8411096334, alpha: 1) // light mode의 systemGray4 | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// | ||
// UIImageView+Load+Cache.swift | ||
// BookFinder | ||
// | ||
// Created by Hyoju Son on 2022/07/31. | ||
// | ||
|
||
import UIKit | ||
|
||
extension UIImageView { | ||
func loadCachedImage(of key: String) { | ||
let cacheKey = NSString(string: key) | ||
if let cachedImage = ImageCacheManager.shared.object(forKey: cacheKey) { | ||
self.image = cachedImage | ||
return | ||
} | ||
|
||
DispatchQueue.global().async { | ||
guard | ||
let url = URL(string: key), | ||
var urlCompoentns = URLComponents(url: url, resolvingAgainstBaseURL: false) | ||
else { return } | ||
|
||
urlCompoentns.scheme = "https" | ||
|
||
guard | ||
let imageURL = urlCompoentns.url, | ||
let imageData = try? Data(contentsOf: imageURL), | ||
let loadedImage = UIImage(data: imageData) | ||
else { return } | ||
|
||
ImageCacheManager.shared.setObject(loadedImage, forKey: cacheKey) | ||
|
||
DispatchQueue.main.async { | ||
self.image = loadedImage | ||
} | ||
} | ||
} | ||
} |
This file contains 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
This file was deleted.
Oops, something went wrong.
This file contains 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
45 changes: 45 additions & 0 deletions
45
BookFinder/Presentation/SearchListPage/SearchListCoordinator.swift
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// | ||
// SearchCoordinator.swift | ||
// BookFinder | ||
// | ||
// Created by Hyoju Son on 2022/07/31. | ||
// | ||
|
||
import UIKit | ||
|
||
final class SearchListCoordinator: CoordinatorProtocol { | ||
// MARK: - Properties | ||
var navigationController: UINavigationController? | ||
var childCoordinators = [CoordinatorProtocol]() | ||
var type: CoordinatorType = .searchList | ||
|
||
// MARK: - Initializers | ||
init(navigationController: UINavigationController) { | ||
self.navigationController = navigationController | ||
} | ||
|
||
// MARK: - Methods | ||
func start() { | ||
showSearchListPage() | ||
} | ||
|
||
private func showSearchListPage() { | ||
guard let navigationController = navigationController else { return } | ||
let searchListViewModel = SearchListViewModel(coordinator: self) | ||
let searchListViewController = SearchListViewController(viewModel: searchListViewModel) | ||
|
||
navigationController.pushViewController(searchListViewController, animated: false) | ||
} | ||
|
||
func showDetailPage(with bookItem: BookItem) { | ||
guard let navigationController = navigationController else { return } | ||
// let detailCoordinator = DetailCoordinator(navigationController: navigationController) | ||
// childCoordinators.append(detailCoordinator) | ||
// detailCoordinator.start() | ||
} | ||
|
||
// func removeFromChildCoordinators(coordinator: CoordinatorProtocol) { | ||
// let updatedChildCoordinators = childCoordinators.filter { $0 !== coordinator } | ||
// childCoordinators = updatedChildCoordinators | ||
// } | ||
} |
Oops, something went wrong.