-
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 #23 from NAGAZA-Team/Feature/map_serach_api
Map Search 화면 구현
- Loading branch information
Showing
24 changed files
with
652 additions
and
130 deletions.
There are no files selected for viewing
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
40 changes: 40 additions & 0 deletions
40
Nagaza/Sources/Data/Network/DataMapping/RecentKeywordResponseDTO.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,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 | ||
) | ||
} | ||
} |
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,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
39
Nagaza/Sources/Data/Repositories/Map/MapTarget+SampleData.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,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) | ||
} | ||
} | ||
} |
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,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 | ||
} | ||
} | ||
} | ||
|
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,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 | ||
} | ||
} |
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
12 changes: 12 additions & 0 deletions
12
Nagaza/Sources/Domain/Interfaces/Repositories/Map/MapRepositoryInterface.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,12 @@ | ||
// | ||
// MapRepositoryInterface.swift | ||
// Nagaza | ||
// | ||
// Created by SeungMin on 3/14/24. | ||
// | ||
|
||
import RxSwift | ||
|
||
protocol MapRepositoryInterface { | ||
func fetchRecentKeywordList() -> Single<RecentKeywordPage> | ||
} |
File renamed without changes.
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,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() | ||
} | ||
} |
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
29 changes: 29 additions & 0 deletions
29
Nagaza/Sources/Presentation/Base/NagazaCollectionViewCell.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,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() { } | ||
} |
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
Oops, something went wrong.