Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feature/FeedDetailDomainData
Browse files Browse the repository at this point in the history
GeonH0 authored Jul 10, 2024
2 parents 60b8600 + 57475e0 commit a388cf6
Showing 7 changed files with 101 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -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 let apiConfig: APIConfig

Original file line number Diff line number Diff line change
@@ -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) {
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@ protocol SearchFeedListRepository {
func searchRecipes(title: String, pageNumber: Int) -> Single<[Recipe]>
}

class DefaultSearchFeedRepository: SearchFeedListRepository {
class SearchFeedRepositoryImpl: SearchFeedListRepository {

private let networkService: RecipeFetchService

Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@ protocol FetchFeedListUseCase {
func execute(pageNumber: Int) -> Single<Result<[Recipe], Error>>
}

class DefaultFetchFeedListUseCase: FetchFeedListUseCase {
class FetchFeedListUseCaseImpl: FetchFeedListUseCase {
private let repository: FeedListRepository

init(repository: FeedListRepository) {
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@ protocol SearchFeedListUseCase {
func execute(title: String,pageNumber: Int) -> Single<Result<[Recipe], Error>>
}

class DefaultSearchFeedListUseCase: SearchFeedListUseCase {
class SearchFeedListUseCaseImpl: SearchFeedListUseCase {
private let repository: SearchFeedListRepository

init(repository: SearchFeedListRepository) {
Original file line number Diff line number Diff line change
@@ -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)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
//
// CustomTabBarController.swift
// HomeCafeRecipes
//
// Created by 김건호 on 6/20/24.
//

import UIKit

class MainTabBarController: UITabBarController, UITabBarControllerDelegate {

private let addButton = UIButton(type: .custom)
private let buttonSize = CGSize(all: 64.0)

override func viewDidLoad() {
super.viewDidLoad()
self.delegate = self
setupButton()
setupTabBar()
setupActionButton()
}

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.width * 0.5
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 = 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)

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: buttonSize.width),
addButton.heightAnchor.constraint(equalToConstant: buttonSize.height)
])
}

@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 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 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)
}
}

0 comments on commit a388cf6

Please sign in to comment.