From 20cd42f38365c1f1c036036c32afa88ad978f3b3 Mon Sep 17 00:00:00 2001 From: GeonH0 Date: Mon, 24 Jun 2024 17:54:40 +0900 Subject: [PATCH 1/7] =?UTF-8?q?Feat:=20MainTabbar=20=EC=A0=95=EC=9D=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Tabbar/MainTabBarController.swift | 80 +++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 HomeCafeRecipes/HomeCafeRecipes/Presentation/Tabbar/MainTabBarController.swift diff --git a/HomeCafeRecipes/HomeCafeRecipes/Presentation/Tabbar/MainTabBarController.swift b/HomeCafeRecipes/HomeCafeRecipes/Presentation/Tabbar/MainTabBarController.swift new file mode 100644 index 0000000..e873957 --- /dev/null +++ b/HomeCafeRecipes/HomeCafeRecipes/Presentation/Tabbar/MainTabBarController.swift @@ -0,0 +1,80 @@ +// +// CustomTabBarController.swift +// HomeCafeRecipes +// +// Created by 김건호 on 6/20/24. +// + +import UIKit + +class MainTabBarController: UITabBarController, UITabBarControllerDelegate { + + private let addButton = UIButton(type: .custom) + + override func viewDidLoad() { + super.viewDidLoad() + self.delegate = self + setupButton() + setupTabBar() + setupActionButton() + } + + private func setupButton() { + addButton.backgroundColor = .blue + addButton.setTitle("+", for: .normal) + addButton.setTitleColor(.white, for: .normal) + addButton.layer.cornerRadius = 32 + addButton.layer.shadowColor = UIColor.black.cgColor + addButton.layer.shadowOpacity = 0.3 + addButton.layer.shadowOffset = CGSize(width: 0, height: 2) + addButton.layer.shadowRadius = 10 + } + + private func setupTabBar() { + let baseneworkServie = BaseNetworkService() + let networkService = DefaultRecipeFetchService(networkService: baseneworkServie) + let repository = DefaultFeedListRepository(networkService: networkService) + let searchrepository = DefaultSearchFeedRepository(networkService: networkService) + let fetchFeedListUseCase = DefaultFetchFeedListUseCase(repository: repository) + let searchFeedListUsecase = DefaultSearchFeedListUseCase(repository: searchrepository) + + let recipeListViewModel = RecipeListInteractor(fetchFeedListUseCase: fetchFeedListUseCase, searchFeedListUseCase: searchFeedListUsecase) + + let recipeListVC = RecipeListViewController(interactor: recipeListViewModel) + recipeListVC.tabBarItem = UITabBarItem(title: "Recipes", image: UIImage(systemName: "list.bullet"), tag: 0) + + let favoritesVC = UIViewController() + favoritesVC.view.backgroundColor = .white + favoritesVC.tabBarItem = UITabBarItem(title: "Favorites", image: UIImage(systemName: "bookmark"), tag: 1) + + viewControllers = [recipeListVC, favoritesVC] + } + + private func setupActionButton() { + addButton.addTarget(self, action: #selector(didTapActionButton), for: .touchUpInside) + self.view.addSubview(addButton) + addButton.translatesAutoresizingMaskIntoConstraints = false + NSLayoutConstraint.activate([ + addButton.centerXAnchor.constraint(equalTo: tabBar.centerXAnchor), + addButton.centerYAnchor.constraint(equalTo: tabBar.topAnchor), + addButton.widthAnchor.constraint(equalToConstant: 64), + addButton.heightAnchor.constraint(equalToConstant: 64) + ]) + } + + @objc private func didTapActionButton() { + let alert = UIAlertController(title: "게시물 작성", message: "어떤 게시물을 작성하실 건가요?", preferredStyle: .actionSheet) + alert.addAction(UIAlertAction(title: "Coffee", style: .default, handler: { [weak self] _ in + guard let self = self else { return } + let addRecipeVC = AddRecipeViewController(recipeType: .coffee) + self.navigationController?.pushViewController(addRecipeVC, animated: true) + })) + alert.addAction(UIAlertAction(title: "Dessert", style: .default, handler: { [weak self] _ in + guard let self = self else { return } + let addRecipeVC = AddRecipeViewController(recipeType: .dessert) + self.navigationController?.pushViewController(addRecipeVC, animated: true) + })) + alert.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: nil)) + self.present(alert, animated: true, completion: nil) + } +} From 5cd2dd9b42ce39af8d56167cbf1cd85eab6ff0c3 Mon Sep 17 00:00:00 2001 From: GeonH0 Date: Tue, 25 Jun 2024 22:40:56 +0900 Subject: [PATCH 2/7] =?UTF-8?q?Fix:=20size=20=EC=A0=95=EC=9D=98=ED=9B=84?= =?UTF-8?q?=20cornerRadius=20=EC=84=A0=EC=96=B8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Presentation/Tabbar/MainTabBarController.swift | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/HomeCafeRecipes/HomeCafeRecipes/Presentation/Tabbar/MainTabBarController.swift b/HomeCafeRecipes/HomeCafeRecipes/Presentation/Tabbar/MainTabBarController.swift index e873957..57b7008 100644 --- a/HomeCafeRecipes/HomeCafeRecipes/Presentation/Tabbar/MainTabBarController.swift +++ b/HomeCafeRecipes/HomeCafeRecipes/Presentation/Tabbar/MainTabBarController.swift @@ -10,7 +10,8 @@ import UIKit class MainTabBarController: UITabBarController, UITabBarControllerDelegate { private let addButton = UIButton(type: .custom) - + private let buttonSize: CGFloat = 64 + override func viewDidLoad() { super.viewDidLoad() self.delegate = self @@ -23,7 +24,7 @@ class MainTabBarController: UITabBarController, UITabBarControllerDelegate { addButton.backgroundColor = .blue addButton.setTitle("+", for: .normal) addButton.setTitleColor(.white, for: .normal) - addButton.layer.cornerRadius = 32 + addButton.layer.cornerRadius = buttonSize * 0.5 addButton.layer.shadowColor = UIColor.black.cgColor addButton.layer.shadowOpacity = 0.3 addButton.layer.shadowOffset = CGSize(width: 0, height: 2) From eaa4f9c5549e9bd03c743dc7910b7ef3f81682c2 Mon Sep 17 00:00:00 2001 From: GeonH0 Date: Tue, 25 Jun 2024 22:41:24 +0900 Subject: [PATCH 3/7] =?UTF-8?q?Fix:=20=ED=83=80=EC=9D=B4=ED=8B=80=20?= =?UTF-8?q?=ED=8F=B0=ED=8A=B8=20=EC=82=AC=EC=9D=B4=EC=A6=88=20=EC=A1=B0?= =?UTF-8?q?=EC=A0=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Presentation/Tabbar/MainTabBarController.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/HomeCafeRecipes/HomeCafeRecipes/Presentation/Tabbar/MainTabBarController.swift b/HomeCafeRecipes/HomeCafeRecipes/Presentation/Tabbar/MainTabBarController.swift index 57b7008..e277e40 100644 --- a/HomeCafeRecipes/HomeCafeRecipes/Presentation/Tabbar/MainTabBarController.swift +++ b/HomeCafeRecipes/HomeCafeRecipes/Presentation/Tabbar/MainTabBarController.swift @@ -23,6 +23,7 @@ class MainTabBarController: UITabBarController, UITabBarControllerDelegate { private func setupButton() { addButton.backgroundColor = .blue addButton.setTitle("+", for: .normal) + addButton.titleLabel?.font = UIFont.systemFont(ofSize: 40) addButton.setTitleColor(.white, for: .normal) addButton.layer.cornerRadius = buttonSize * 0.5 addButton.layer.shadowColor = UIColor.black.cgColor From 087f6e1ce49798b0a6ecda1d197344260113cd53 Mon Sep 17 00:00:00 2001 From: GeonH0 Date: Tue, 25 Jun 2024 22:41:43 +0900 Subject: [PATCH 4/7] =?UTF-8?q?Fix:=20guard=EB=AC=B8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Presentation/Tabbar/MainTabBarController.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/HomeCafeRecipes/HomeCafeRecipes/Presentation/Tabbar/MainTabBarController.swift b/HomeCafeRecipes/HomeCafeRecipes/Presentation/Tabbar/MainTabBarController.swift index e277e40..2806646 100644 --- a/HomeCafeRecipes/HomeCafeRecipes/Presentation/Tabbar/MainTabBarController.swift +++ b/HomeCafeRecipes/HomeCafeRecipes/Presentation/Tabbar/MainTabBarController.swift @@ -63,16 +63,16 @@ class MainTabBarController: UITabBarController, UITabBarControllerDelegate { addButton.heightAnchor.constraint(equalToConstant: 64) ]) } - + @objc private func didTapActionButton() { let alert = UIAlertController(title: "게시물 작성", message: "어떤 게시물을 작성하실 건가요?", preferredStyle: .actionSheet) alert.addAction(UIAlertAction(title: "Coffee", style: .default, handler: { [weak self] _ in - guard let self = self else { return } + guard let self else { return } let addRecipeVC = AddRecipeViewController(recipeType: .coffee) self.navigationController?.pushViewController(addRecipeVC, animated: true) })) alert.addAction(UIAlertAction(title: "Dessert", style: .default, handler: { [weak self] _ in - guard let self = self else { return } + guard let self else { return } let addRecipeVC = AddRecipeViewController(recipeType: .dessert) self.navigationController?.pushViewController(addRecipeVC, animated: true) })) From d76a2a2983cbe0cbc3fb43627af4360a604165c9 Mon Sep 17 00:00:00 2001 From: GeonH0 Date: Sat, 29 Jun 2024 23:00:39 +0900 Subject: [PATCH 5/7] =?UTF-8?q?Feat:=20addButton=20CGSize=20extension=20?= =?UTF-8?q?=EC=A0=95=EC=9D=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Presentation/Extensions/CGSize+addButton.swift | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 HomeCafeRecipes/HomeCafeRecipes/Presentation/Extensions/CGSize+addButton.swift diff --git a/HomeCafeRecipes/HomeCafeRecipes/Presentation/Extensions/CGSize+addButton.swift b/HomeCafeRecipes/HomeCafeRecipes/Presentation/Extensions/CGSize+addButton.swift new file mode 100644 index 0000000..d64ee4d --- /dev/null +++ b/HomeCafeRecipes/HomeCafeRecipes/Presentation/Extensions/CGSize+addButton.swift @@ -0,0 +1,14 @@ +// +// CGSize+addButton.swift +// HomeCafeRecipes +// +// Created by 김건호 on 6/29/24. +// + +import CoreGraphics + +extension CGSize { + init(all: CGFloat) { + self.init(width: all, height: all) + } +} From fc347c44ff0c0796bcf370a5aadc2c5974c0fb32 Mon Sep 17 00:00:00 2001 From: GeonH0 Date: Sat, 29 Jun 2024 23:01:24 +0900 Subject: [PATCH 6/7] =?UTF-8?q?Fix:=20=EB=B2=84=ED=8A=BC=20=EC=82=AC?= =?UTF-8?q?=EC=9D=B4=EC=A6=88=20=EC=A0=81=EC=9A=A9=20=EB=B0=8F=20=EB=B2=84?= =?UTF-8?q?=ED=8A=BC=20size=20=EB=84=A4=EC=9D=B4=EB=B0=8D=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Presentation/Tabbar/MainTabBarController.swift | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/HomeCafeRecipes/HomeCafeRecipes/Presentation/Tabbar/MainTabBarController.swift b/HomeCafeRecipes/HomeCafeRecipes/Presentation/Tabbar/MainTabBarController.swift index 2806646..09d39ce 100644 --- a/HomeCafeRecipes/HomeCafeRecipes/Presentation/Tabbar/MainTabBarController.swift +++ b/HomeCafeRecipes/HomeCafeRecipes/Presentation/Tabbar/MainTabBarController.swift @@ -10,7 +10,7 @@ import UIKit class MainTabBarController: UITabBarController, UITabBarControllerDelegate { private let addButton = UIButton(type: .custom) - private let buttonSize: CGFloat = 64 + private let buttonSize = CGSize(all: 64.0) override func viewDidLoad() { super.viewDidLoad() @@ -25,7 +25,7 @@ class MainTabBarController: UITabBarController, UITabBarControllerDelegate { addButton.setTitle("+", for: .normal) addButton.titleLabel?.font = UIFont.systemFont(ofSize: 40) addButton.setTitleColor(.white, for: .normal) - addButton.layer.cornerRadius = buttonSize * 0.5 + addButton.layer.cornerRadius = buttonSize.width * 0.5 addButton.layer.shadowColor = UIColor.black.cgColor addButton.layer.shadowOpacity = 0.3 addButton.layer.shadowOffset = CGSize(width: 0, height: 2) @@ -59,8 +59,8 @@ class MainTabBarController: UITabBarController, UITabBarControllerDelegate { NSLayoutConstraint.activate([ addButton.centerXAnchor.constraint(equalTo: tabBar.centerXAnchor), addButton.centerYAnchor.constraint(equalTo: tabBar.topAnchor), - addButton.widthAnchor.constraint(equalToConstant: 64), - addButton.heightAnchor.constraint(equalToConstant: 64) + addButton.widthAnchor.constraint(equalToConstant: buttonSize.width), + addButton.heightAnchor.constraint(equalToConstant: buttonSize.height) ]) } From 3611d8b4fe752c08eae6b95c42d42d68845ce20e Mon Sep 17 00:00:00 2001 From: GeonH0 Date: Wed, 3 Jul 2024 21:06:54 +0900 Subject: [PATCH 7/7] =?UTF-8?q?Fix:=20Deafault=20=EC=A0=9C=EA=B1=B0=20?= =?UTF-8?q?=ED=9B=84=20Impl=EB=A1=9C=20=EB=84=A4=EC=9D=B4=EB=B0=8D=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Data/Network/RecipeFetchService.swift | 4 ++-- .../Data/Repositories/FeedListRepository.swift | 2 +- .../Data/Repositories/SearchFeedListRepository.swift | 2 +- .../Domain/UseCases/FetchFeedListUseCase.swift | 2 +- .../Domain/UseCases/SearchFeedUseCase.swift | 2 +- .../Presentation/Tabbar/MainTabBarController.swift | 10 +++++----- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/HomeCafeRecipes/HomeCafeRecipes/Data/Network/RecipeFetchService.swift b/HomeCafeRecipes/HomeCafeRecipes/Data/Network/RecipeFetchService.swift index 135c541..4e23f5b 100644 --- a/HomeCafeRecipes/HomeCafeRecipes/Data/Network/RecipeFetchService.swift +++ b/HomeCafeRecipes/HomeCafeRecipes/Data/Network/RecipeFetchService.swift @@ -13,7 +13,7 @@ protocol RecipeFetchService { func searchRecipes(title: String, pageNumber: Int) -> Single<[Recipe]> } -class DefaultRecipeFetchService: RecipeFetchService { +class RecipeFetchServiceImpl: RecipeFetchService { private let networkService: NetworkService private static let baseURL: URL = URL(string: "https://meog0.store/api")! @@ -22,7 +22,7 @@ class DefaultRecipeFetchService: RecipeFetchService { } private func makeURL(endpoint: String, queryItems: [URLQueryItem]) -> URL? { - let URL = DefaultRecipeFetchService.baseURL.appendingPathComponent(endpoint) + let URL = RecipeFetchServiceImpl.baseURL.appendingPathComponent(endpoint) var URLComponents = URLComponents(url: URL, resolvingAgainstBaseURL: false) URLComponents?.queryItems = queryItems return URLComponents?.url diff --git a/HomeCafeRecipes/HomeCafeRecipes/Data/Repositories/FeedListRepository.swift b/HomeCafeRecipes/HomeCafeRecipes/Data/Repositories/FeedListRepository.swift index 2fda774..21be892 100644 --- a/HomeCafeRecipes/HomeCafeRecipes/Data/Repositories/FeedListRepository.swift +++ b/HomeCafeRecipes/HomeCafeRecipes/Data/Repositories/FeedListRepository.swift @@ -11,7 +11,7 @@ protocol FeedListRepository { func fetchRecipes(pageNumber: Int) -> Single<[Recipe]> } -class DefaultFeedListRepository: FeedListRepository { +class FeedListRepositoryImpl: FeedListRepository { private let networkService: RecipeFetchService init(networkService: RecipeFetchService) { diff --git a/HomeCafeRecipes/HomeCafeRecipes/Data/Repositories/SearchFeedListRepository.swift b/HomeCafeRecipes/HomeCafeRecipes/Data/Repositories/SearchFeedListRepository.swift index 6b4b21d..027cf74 100644 --- a/HomeCafeRecipes/HomeCafeRecipes/Data/Repositories/SearchFeedListRepository.swift +++ b/HomeCafeRecipes/HomeCafeRecipes/Data/Repositories/SearchFeedListRepository.swift @@ -11,7 +11,7 @@ protocol SearchFeedListRepository { func searchRecipes(title: String, pageNumber: Int) -> Single<[Recipe]> } -class DefaultSearchFeedRepository: SearchFeedListRepository { +class SearchFeedRepositoryImpl: SearchFeedListRepository { private let networkService: RecipeFetchService diff --git a/HomeCafeRecipes/HomeCafeRecipes/Domain/UseCases/FetchFeedListUseCase.swift b/HomeCafeRecipes/HomeCafeRecipes/Domain/UseCases/FetchFeedListUseCase.swift index f5b4152..35a96e1 100644 --- a/HomeCafeRecipes/HomeCafeRecipes/Domain/UseCases/FetchFeedListUseCase.swift +++ b/HomeCafeRecipes/HomeCafeRecipes/Domain/UseCases/FetchFeedListUseCase.swift @@ -11,7 +11,7 @@ protocol FetchFeedListUseCase { func execute(pageNumber: Int) -> Single> } -class DefaultFetchFeedListUseCase: FetchFeedListUseCase { +class FetchFeedListUseCaseImpl: FetchFeedListUseCase { private let repository: FeedListRepository init(repository: FeedListRepository) { diff --git a/HomeCafeRecipes/HomeCafeRecipes/Domain/UseCases/SearchFeedUseCase.swift b/HomeCafeRecipes/HomeCafeRecipes/Domain/UseCases/SearchFeedUseCase.swift index 68fd1c3..f65e639 100644 --- a/HomeCafeRecipes/HomeCafeRecipes/Domain/UseCases/SearchFeedUseCase.swift +++ b/HomeCafeRecipes/HomeCafeRecipes/Domain/UseCases/SearchFeedUseCase.swift @@ -11,7 +11,7 @@ protocol SearchFeedListUseCase { func execute(title: String,pageNumber: Int) -> Single> } -class DefaultSearchFeedListUseCase: SearchFeedListUseCase { +class SearchFeedListUseCaseImpl: SearchFeedListUseCase { private let repository: SearchFeedListRepository init(repository: SearchFeedListRepository) { diff --git a/HomeCafeRecipes/HomeCafeRecipes/Presentation/Tabbar/MainTabBarController.swift b/HomeCafeRecipes/HomeCafeRecipes/Presentation/Tabbar/MainTabBarController.swift index 09d39ce..e592ca4 100644 --- a/HomeCafeRecipes/HomeCafeRecipes/Presentation/Tabbar/MainTabBarController.swift +++ b/HomeCafeRecipes/HomeCafeRecipes/Presentation/Tabbar/MainTabBarController.swift @@ -34,11 +34,11 @@ class MainTabBarController: UITabBarController, UITabBarControllerDelegate { private func setupTabBar() { let baseneworkServie = BaseNetworkService() - let networkService = DefaultRecipeFetchService(networkService: baseneworkServie) - let repository = DefaultFeedListRepository(networkService: networkService) - let searchrepository = DefaultSearchFeedRepository(networkService: networkService) - let fetchFeedListUseCase = DefaultFetchFeedListUseCase(repository: repository) - let searchFeedListUsecase = DefaultSearchFeedListUseCase(repository: searchrepository) + let networkService = RecipeFetchServiceImpl(networkService: baseneworkServie) + let repository = FeedListRepositoryImpl(networkService: networkService) + let searchrepository = SearchFeedRepositoryImpl(networkService: networkService) + let fetchFeedListUseCase = FetchFeedListUseCaseImpl(repository: repository) + let searchFeedListUsecase = SearchFeedListUseCaseImpl(repository: searchrepository) let recipeListViewModel = RecipeListInteractor(fetchFeedListUseCase: fetchFeedListUseCase, searchFeedListUseCase: searchFeedListUsecase)