Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

지역설정 화면 구현 #25

Merged
merged 13 commits into from
Mar 20, 2024
Merged
Changes from 1 commit
Commits
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
Prev Previous commit
Merge branch 'develop' into Feature/LocationFilter
Jeon0976 authored Mar 20, 2024
commit 451d7b02cfe929cc47b3462d8cd61811149f224a
Original file line number Diff line number Diff line change
@@ -12,11 +12,26 @@ final class MapSceneDIContainer: MapFlowCoordinaterDependencies {
MapViewController.create(with: makeMapViewModel(actions: actions))
}

private func makeMapViewModel(actions: MapViewModelActions) -> MapViewModel
{
private func makeMapViewModel(actions: MapViewModelActions) -> MapViewModel {
MapViewModel(actions: actions)
}

func makeMapSearchViewController(actions: MapSearchViewModelActions) -> MapSearchViewController {
MapSearchViewController.create(with: makeMapSearchViewModel(actions: actions))
}

private func makeMapUseCase() -> MapRepositoryInterface {
return MapRepository(
isStub: true,
sampleStatusCode: 200,
customEndpointClosure: nil
)
}

private func makeMapSearchViewModel(actions: MapSearchViewModelActions) -> MapSearchViewModel {
MapSearchViewModel(mapUseCase: makeMapUseCase(), actions: actions)
}

func makeMapFlowCoordinator(navigationController: UINavigationController) -> MapFlowCoordinator {
MapFlowCoordinator(
navigationController: navigationController,
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
//
// KeywordResponseDTO.swift
// Nagaza
//
// Created by SeungMin on 3/14/24.
//

struct RecentKeywordResponse: Decodable {
let keywordList: [RecentKeywordResponseDTO]
let page: Int
let totalPages: Int

enum CodingKeys: String, CodingKey {
case keywordList
case page
case totalPages = "total_pages"
}
}

struct RecentKeywordResponseDTO: Decodable {
let keyword: String
}

extension RecentKeywordResponse {
func toDomain() -> RecentKeywordPage {
return RecentKeywordPage(
keywordList: self.keywordList.map { $0.toDomain() },
page: self.page,
totalPages: self.totalPages
)
}
}

extension RecentKeywordResponseDTO {
func toDomain() -> RecentKeyword {
return RecentKeyword(
keyword: self.keyword
)
}
}
28 changes: 28 additions & 0 deletions Nagaza/Sources/Data/Repositories/Map/MapRepository.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//
// MapRepository.swift
// Nagaza
//
// Created by SeungMin on 3/14/24.
//

import RxSwift
import Moya

final class MapRepository: ProviderProtocol {
typealias Target = MapTarget
var provider: MoyaProvider<Target>

init(isStub: Bool, sampleStatusCode: Int, customEndpointClosure: ((Target) -> Moya.Endpoint)?) {
self.provider = Self.consProvider(isStub, sampleStatusCode, customEndpointClosure)
}
}

extension MapRepository: MapRepositoryInterface {
func fetchRecentKeywordList() -> Single<RecentKeywordPage> {
request(
type: RecentKeywordResponse.self,
target: .fetchRecentKeywordList
)
.map { $0.toDomain() }
}
}
39 changes: 39 additions & 0 deletions Nagaza/Sources/Data/Repositories/Map/MapTarget+SampleData.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//
// MapTarget+SampleData.swift
// Nagaza
//
// Created by SeungMin on 3/14/24.
//

import Foundation

import Moya

extension MapTarget {
var sampleData: Data {
switch self {
case .fetchRecentKeywordList:
return Data(
"""
{
"keywordList": [
{
"keyword": "리그오브디저트"
},
{
"keyword": "방탈출"
},
{
"keyword": "풀문"
},
{
"keyword": "마스터키"
}
],
"page": 1,
"total_pages": 1
}
""".utf8)
}
}
}
36 changes: 36 additions & 0 deletions Nagaza/Sources/Data/Repositories/Map/MapTarget.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//
// MapTarget.swift
// Nagaza
//
// Created by SeungMin on 3/14/24.
//

import Moya

enum MapTarget {
case fetchRecentKeywordList
}

extension MapTarget: BaseTargetType {
var path: String {
switch self {
case .fetchRecentKeywordList:
return "v1/search/keyword"
}
}

var method: Moya.Method {
switch self {
case .fetchRecentKeywordList:
return .get
}
}

var task: Moya.Task {
switch self {
case .fetchRecentKeywordList:
return .requestPlain
}
}
}

33 changes: 33 additions & 0 deletions Nagaza/Sources/Domain/Entities/RecentKeyword.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
//
// RecentKeyword.swift
// Nagaza
//
// Created by SeungMin on 3/13/24.
//

import Foundation

enum SearchSection {
case home
}

struct RecentKeyword: Hashable {
let identifier = UUID()
let keyword: String
}

struct RecentKeywordPage {
let keywordList: [RecentKeyword]
let page: Int
let totalPages: Int
}

extension RecentKeyword {
public func hash(into hasher: inout Hasher) {
hasher.combine(identifier)
}

public static func == (lhs: RecentKeyword, rhs: RecentKeyword) -> Bool {
lhs.identifier == rhs.identifier
}
}
Original file line number Diff line number Diff line change
@@ -5,8 +5,6 @@
// Created by SeungMin on 1/6/24.
//

import Foundation

import RxSwift

protocol HomeRepositoryInterface {
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//
// MapRepositoryInterface.swift
// Nagaza
//
// Created by SeungMin on 3/14/24.
//

import RxSwift

protocol MapRepositoryInterface {
func fetchRecentKeywordList() -> Single<RecentKeywordPage>
}
24 changes: 24 additions & 0 deletions Nagaza/Sources/Domain/UseCases/Home/HomeUseCase.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//
// HomeUseCase.swift
// Nagaza
//
// Created by SeungMin on 1/6/24.
//

import RxSwift

final class HomeUseCase {
private let repository: HomeRepositoryInterface

init(roomsRepository: HomeRepositoryInterface) {
self.repository = roomsRepository
}

func fetchCafesList() -> Single<CafesPage> {
return repository.fetchCafesList()
}

func fetchRoomsList(cafeId: Int) -> Single<RoomsPage> {
return repository.fetchRoomsList(cafeId: cafeId)
}
}
20 changes: 20 additions & 0 deletions Nagaza/Sources/Domain/UseCases/Map/MapUseCase.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//
// MapUseCase.swift
// Nagaza
//
// Created by SeungMin on 3/14/24.
//

import RxSwift

final class MapUseCase {
private let repository: MapRepositoryInterface

init(roomsRepository: MapRepositoryInterface) {
self.repository = roomsRepository
}

func fetchCafesList() -> Single<RecentKeywordPage> {
return repository.fetchRecentKeywordList()
}
}
10 changes: 7 additions & 3 deletions Nagaza/Sources/Presentation/Base/NagazaBaseViewController.swift
Original file line number Diff line number Diff line change
@@ -33,9 +33,13 @@ class NagazaBaseViewController: UIViewController {

/// Set up Navigation Bar
func navigationSetting() {
navigationController?.navigationBar.backIndicatorImage = NagazaAsset.Images.icArrowRightGray.image
navigationController?.navigationBar.backIndicatorTransitionMaskImage = NagazaAsset.Images.icArrowRightGray.image
navigationController?.navigationBar.tintColor = .white
navigationController?.navigationBar.tintColor = NagazaAsset.Colors.gray3.color
navigationItem.backBarButtonItem = UIBarButtonItem(
title: nil,
style: .plain,
target: nil,
action: nil
)

let navBarAppearance = UINavigationBarAppearance()
navBarAppearance.configureWithOpaqueBackground()
29 changes: 29 additions & 0 deletions Nagaza/Sources/Presentation/Base/NagazaCollectionViewCell.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//
// NagazaCollectionViewCell.swift
// Nagaza
//
// Created by SeungMin on 3/14/24.
//

import UIKit
import RxSwift

class NagazaCollectionViewCell: UICollectionViewCell {
var disposeBag = DisposeBag()

override init(frame: CGRect) {
super.init(frame: frame)
makeUI()
}

required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

override func prepareForReuse() {
self.disposeBag = DisposeBag()
super.prepareForReuse()
}

func makeUI() { }
}
Original file line number Diff line number Diff line change
@@ -9,6 +9,7 @@ import UIKit

protocol MapFlowCoordinaterDependencies {
func makeMapViewController(actions: MapViewModelActions) -> MapViewController
func makeMapSearchViewController(actions: MapSearchViewModelActions) -> MapSearchViewController
}

final class MapFlowCoordinator: Coordinator {
@@ -37,13 +38,19 @@ final class MapFlowCoordinator: Coordinator {
}

func start() {
let actions = MapViewModelActions()
let actions = MapViewModelActions(toMapSearch: toMapSearch)
let vc = dependencies.makeMapViewController(actions: actions)

navigationController.setNavigationBarHidden(false, animated: false)
navigationController.pushViewController(vc, animated: false)
navigationController = UINavigationController(rootViewController: vc)

mapVC = vc
}

func toMapSearch() {
let actions = MapSearchViewModelActions()
let vc = dependencies.makeMapSearchViewController(actions: actions)

navigationController.pushViewController(vc, animated: true)
}
}
Original file line number Diff line number Diff line change
@@ -54,11 +54,12 @@ final class HomeViewController: NagazaBaseViewController {

private lazy var recommendedThemeView = RecommendThemeView()

private lazy var themesCollectionView: UICollectionView = {
let layout = UICollectionViewCompositionalLayout.listLayout(withEstimatedHeight: 215)

let collectionView = UICollectionView(frame: .zero, collectionViewLayout: layout)
collectionView.isScrollEnabled = false
private lazy var scrollView = UIScrollView()

private lazy var recommendedContainer: UIView = {
let view = UIView()
view.backgroundColor = .clear
add(child: recommendedThemeViewController, container: view)

return collectionView
}()
@@ -248,10 +249,10 @@ extension HomeViewController {
let roomCellRegistraition = UICollectionView.CellRegistration<CellType, ModelType> { [weak self] cell, indexPath, item in

cell.bind(with: item)
// cell.delegate = self
// cell.delegate = self
}

let headerRegistration = UICollectionView.SupplementaryRegistration<SectionHeaderView>(elementKind: ElementKind.sectionHeader) { supplementaryView, elementKind, indexPath in
let headerRegistration = UICollectionView.SupplementaryRegistration<SectionHeaderView>(elementKind: UICollectionView.elementKindSectionHeader) { supplementaryView, elementKind, indexPath in
let sectionType = HomeSectionType(rawValue: indexPath.section) ?? .comic
supplementaryView.themeLabel.text = sectionType.title
}
Original file line number Diff line number Diff line change
@@ -190,7 +190,7 @@ final class ThemeCell: UICollectionViewCell {
self.titleLabel.text = model.name
self.branchLabel.text = model.area
self.ratedLabel.text = String(model.total)
self.posterImageView.loadImage(from: model.imageUrlString)
// self.posterImageView.loadImage(from: model.imageUrlString)
}

private func updatePosterImage() {
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.