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

🔀 :: (#583) 검색 탭의 의존성 관계를 재정의 합니다. #586

Merged
merged 27 commits into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
94aa9bb
:fire: :: 불필요한 코드 삭제
yongbeomkwak Jun 7, 2024
dcb03f1
:recycle: :: 디자인 시스템 v3 반영
yongbeomkwak Jun 7, 2024
6eebfc9
:zap: :: 검색 text를 afterSearchVC로 전달
yongbeomkwak Jun 7, 2024
9652a6a
🎨 :: 코드 Formatting 적용
yongbeomkwak Jun 7, 2024
4c0828f
:zap: :: 탭바 높이만큼 보정
yongbeomkwak Jun 7, 2024
471db3b
:zap: :: SongCart를 검색 결과 VC 이전
yongbeomkwak Jun 7, 2024
e0f6f53
🎨 :: 코드 Formatting 적용
yongbeomkwak Jun 7, 2024
27f6ab3
✅ :: 데모 앱 오류 해결
yongbeomkwak Jun 8, 2024
57756e7
:bulb: :: 워닝 추가
yongbeomkwak Jun 8, 2024
f04ca4a
:zap: :: 리스트 결과 화면에 맞는 Layout , section , DataSource 등 생성
yongbeomkwak Jun 8, 2024
faa3c4e
:zap: :: 리스트 검색 결과 디자인
yongbeomkwak Jun 8, 2024
0fa252c
🎨 :: 코드 Formatting 적용
yongbeomkwak Jun 8, 2024
24dde00
:zap: :: 플레이리스트 결과 화면 주입
yongbeomkwak Jun 8, 2024
7184fe2
🎨 :: 코드 Formatting 적용
yongbeomkwak Jun 8, 2024
1813d4b
:zap: :: Int -> Hashable
yongbeomkwak Jun 8, 2024
84294fa
🎨 :: 코드 Formatting 적용
yongbeomkwak Jun 8, 2024
08b62c7
Merge branch 'develop' into 583-refacory-dependency-on-search-feature
yongbeomkwak Jun 11, 2024
0c22c98
:poop: :: 중복코드 제거
yongbeomkwak Jun 11, 2024
a38676f
🎨 :: 코드 Formatting 적용
yongbeomkwak Jun 11, 2024
8ab1cbd
:poop: :: warning 및 임시 코드 제거
yongbeomkwak Jun 11, 2024
03c19af
🎨 :: 코드 Formatting 적용
yongbeomkwak Jun 11, 2024
b572eb2
:zap: :: 검색어를 공통 서비스에서 컴포넌트 생성 시 할당으로 변경
yongbeomkwak Jun 12, 2024
936dcf3
🎨 :: 코드 Formatting 적용
yongbeomkwak Jun 12, 2024
4ddfbe2
:zap: :: 오토 레이아웃 수정
yongbeomkwak Jun 12, 2024
7e44de1
🎨 :: 코드 Formatting 적용
yongbeomkwak Jun 12, 2024
65607cc
:zap: :: 검색 전에 악뮤 추천 플리 뷰컨 의존성 주입
yongbeomkwak Jun 12, 2024
07eb3b9
🎨 :: 코드 Formatting 적용
yongbeomkwak Jun 12, 2024
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
8 changes: 8 additions & 0 deletions Projects/App/Sources/Application/AppComponent+Search.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,12 @@ extension AppComponent {
var songSearchResultFactory: any SongSearchResultFactory {
SongSearchResultComponent(parent: self)
}

var listSearchResultFactory: any ListSearchResultFactory {
ListSearchResultComponent(parent: self)
}

var wakmusicRecommendComponent: WakmusicRecommendComponent {
WakmusicRecommendComponent(parent: self)
}
}
39 changes: 36 additions & 3 deletions Projects/App/Sources/Application/NeedleGenerated.swift
Original file line number Diff line number Diff line change
Expand Up @@ -563,8 +563,8 @@ private class AfterSearchDependency61822c19bc2eb46d7c52Provider: AfterSearchDepe
var songSearchResultFactory: any SongSearchResultFactory {
return appComponent.songSearchResultFactory
}
var containSongsFactory: any ContainSongsFactory {
return appComponent.containSongsFactory
var listSearchResultFactory: any ListSearchResultFactory {
return appComponent.listSearchResultFactory
}
private let appComponent: AppComponent
init(appComponent: AppComponent) {
Expand All @@ -575,6 +575,22 @@ private class AfterSearchDependency61822c19bc2eb46d7c52Provider: AfterSearchDepe
private func factoryeb2da679e35e2c4fb9a5f47b58f8f304c97af4d5(_ component: NeedleFoundation.Scope) -> AnyObject {
return AfterSearchDependency61822c19bc2eb46d7c52Provider(appComponent: parent1(component) as! AppComponent)
}
private class WakmusicRecommendDependency7d2e1de16b5802ae90ceProvider: WakmusicRecommendDependency {
var fetchRecommendPlayListUseCase: any FetchRecommendPlayListUseCase {
return appComponent.fetchRecommendPlayListUseCase
}
var playlistDetailFactory: any PlaylistDetailFactory {
return appComponent.playlistDetailFactory
}
private let appComponent: AppComponent
init(appComponent: AppComponent) {
self.appComponent = appComponent
}
}
/// ^->AppComponent->WakmusicRecommendComponent
private func factoryaf1c3535530356714983f47b58f8f304c97af4d5(_ component: NeedleFoundation.Scope) -> AnyObject {
return WakmusicRecommendDependency7d2e1de16b5802ae90ceProvider(appComponent: parent1(component) as! AppComponent)
}
private class SearchDependencya86903a2c751a4f762e8Provider: SearchDependency {
var beforeSearchComponent: BeforeSearchComponent {
return appComponent.beforeSearchComponent
Expand Down Expand Up @@ -604,6 +620,9 @@ private class BeforeSearchDependencyebdecb1d478a4766488dProvider: BeforeSearchDe
var textPopUpFactory: any TextPopUpFactory {
return appComponent.textPopUpFactory
}
var wakmusicRecommendComponent: WakmusicRecommendComponent {
return appComponent.wakmusicRecommendComponent
}
private let appComponent: AppComponent
init(appComponent: AppComponent) {
self.appComponent = appComponent
Expand Down Expand Up @@ -1174,7 +1193,18 @@ extension NewSongsContentComponent: Registration {
extension AfterSearchComponent: Registration {
public func registerItems() {
keyPathToName[\AfterSearchDependency.songSearchResultFactory] = "songSearchResultFactory-any SongSearchResultFactory"
keyPathToName[\AfterSearchDependency.containSongsFactory] = "containSongsFactory-any ContainSongsFactory"
keyPathToName[\AfterSearchDependency.listSearchResultFactory] = "listSearchResultFactory-any ListSearchResultFactory"
}
}
extension WakmusicRecommendComponent: Registration {
public func registerItems() {
keyPathToName[\WakmusicRecommendDependency.fetchRecommendPlayListUseCase] = "fetchRecommendPlayListUseCase-any FetchRecommendPlayListUseCase"
keyPathToName[\WakmusicRecommendDependency.playlistDetailFactory] = "playlistDetailFactory-any PlaylistDetailFactory"
}
}
extension ListSearchResultComponent: Registration {
public func registerItems() {

}
}
extension SongSearchResultComponent: Registration {
Expand All @@ -1194,6 +1224,7 @@ extension BeforeSearchComponent: Registration {
keyPathToName[\BeforeSearchDependency.playlistDetailFactory] = "playlistDetailFactory-any PlaylistDetailFactory"
keyPathToName[\BeforeSearchDependency.fetchRecommendPlayListUseCase] = "fetchRecommendPlayListUseCase-any FetchRecommendPlayListUseCase"
keyPathToName[\BeforeSearchDependency.textPopUpFactory] = "textPopUpFactory-any TextPopUpFactory"
keyPathToName[\BeforeSearchDependency.wakmusicRecommendComponent] = "wakmusicRecommendComponent-WakmusicRecommendComponent"
}
}
extension ContainSongsComponent: Registration {
Expand Down Expand Up @@ -1353,6 +1384,8 @@ private func registerProviderFactory(_ componentPath: String, _ factory: @escapi
registerProviderFactory("^->AppComponent->HomeComponent", factory67229cdf0f755562b2b1f47b58f8f304c97af4d5)
registerProviderFactory("^->AppComponent->NewSongsContentComponent", factorye130e1fbfcbc622a4c38f47b58f8f304c97af4d5)
registerProviderFactory("^->AppComponent->AfterSearchComponent", factoryeb2da679e35e2c4fb9a5f47b58f8f304c97af4d5)
registerProviderFactory("^->AppComponent->WakmusicRecommendComponent", factoryaf1c3535530356714983f47b58f8f304c97af4d5)
registerProviderFactory("^->AppComponent->ListSearchResultComponent", factoryEmptyDependencyProvider)
registerProviderFactory("^->AppComponent->SongSearchResultComponent", factoryEmptyDependencyProvider)
registerProviderFactory("^->AppComponent->SearchComponent", factorye3d049458b2ccbbcb3b6f47b58f8f304c97af4d5)
registerProviderFactory("^->AppComponent->BeforeSearchComponent", factory9bb852337d5550979293f47b58f8f304c97af4d5)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ final class AppDelegate: UIResponder, UIApplicationDelegate {
reactor: WakmusicRecommendReactor(fetchRecommendPlayListUseCase: fetchPlayListUseCase)
)

let component = SongSearchResultViewController(reactor: SongSearchResultReactor())
let component = SongSearchResultViewController(reactor: SongSearchResultReactor("1234"))
let component2 = ListSearchResultViewController(reactor: ListSearchResultReactor("text"))

let viewController = Inject.ViewControllerHost(
UINavigationController(rootViewController: component)
UINavigationController(rootViewController: component2)
)
window?.rootViewController = viewController
window?.makeKeyAndVisible()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import UIKit

public protocol ListSearchResultFactory {
func makeView(_ text: String) -> UIViewController
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import Foundation
import UIKit

public protocol SongSearchResultFactory {
func makeView() -> UIViewController
func makeView(_ text: String) -> UIViewController
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ import SongsDomainInterface

public protocol AfterSearchDependency: Dependency {
var songSearchResultFactory: any SongSearchResultFactory { get }
var containSongsFactory: any ContainSongsFactory { get }
var listSearchResultFactory: any ListSearchResultFactory { get }
}

public final class AfterSearchComponent: Component<AfterSearchDependency> {
public func makeView() -> AfterSearchViewController {
public func makeView(text: String) -> AfterSearchViewController {
return AfterSearchViewController.viewController(
songSearchResultFactory: dependency.songSearchResultFactory,
containSongsFactory: dependency.containSongsFactory,
reactor: .init()
listSearchResultFactory: dependency.listSearchResultFactory,
reactor: .init(text: text)
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ public protocol BeforeSearchDependency: Dependency {
var playlistDetailFactory: any PlaylistDetailFactory { get }
var fetchRecommendPlayListUseCase: any FetchRecommendPlayListUseCase { get }
var textPopUpFactory: any TextPopUpFactory { get }
var wakmusicRecommendComponent: WakmusicRecommendComponent { get }
}

public final class BeforeSearchComponent: Component<BeforeSearchDependency> {
public func makeView() -> BeforeSearchContentViewController {
return BeforeSearchContentViewController(
wakmusicRecommendComponent: dependency.wakmusicRecommendComponent,
textPopUpFactory: dependency.textPopUpFactory,
playlistDetailFactory: dependency.playlistDetailFactory,
reactor: BeforeSearchReactor(fetchRecommendPlayListUseCase: dependency.fetchRecommendPlayListUseCase)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import BaseFeature
import BaseFeatureInterface
import Foundation
import NeedleFoundation
import SearchFeatureInterface
import UIKit

public final class ListSearchResultComponent: Component<EmptyDependency>, ListSearchResultFactory {
public func makeView(_ text: String) -> UIViewController {
ListSearchResultViewController(reactor: ListSearchResultReactor(text))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import SearchFeatureInterface
import UIKit

public final class SongSearchResultComponent: Component<EmptyDependency>, SongSearchResultFactory {
public func makeView() -> UIViewController {
SongSearchResultViewController(reactor: SongSearchResultReactor())
public func makeView(_ text: String) -> UIViewController {
SongSearchResultViewController(reactor: SongSearchResultReactor(text))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import UIKit

public protocol WakmusicRecommendDependency: Dependency {
var fetchRecommendPlayListUseCase: any FetchRecommendPlayListUseCase { get }
var playlistDetailFacotry: any PlaylistDetailFactory { get }
var playlistDetailFactory: any PlaylistDetailFactory { get }
}

public final class WakmusicRecommendComponent: Component<WakmusicRecommendDependency> {
Expand All @@ -16,7 +16,7 @@ public final class WakmusicRecommendComponent: Component<WakmusicRecommendDepend
)

return WakmusicRecommendViewController(
playlistDetailFactory: dependency.playlistDetailFacotry,
playlistDetailFactory: dependency.playlistDetailFactory,
reactor: reactor
)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import Foundation

internal enum ListSearchResultSection: Hashable {
case list

var title: String {
switch self {
case .list:
"노래"
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Foundation

internal enum SongSearchResultSection: Int {
case song = 0
internal enum SongSearchResultSection: Hashable {
case song

var title: String {
switch self {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import UIKit
import Utility

final class ListSearchResultCollectionViewLayout: UICollectionViewCompositionalLayout {
init() {
super.init { _, _ in

return ListSearchResultCollectionViewLayout.configureLayout()
}
}

@available(*, unavailable)
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}

extension ListSearchResultCollectionViewLayout {
private static func configureLayout() -> NSCollectionLayoutSection {
let itemSize = NSCollectionLayoutSize(
widthDimension: .fractionalWidth(1.0),
heightDimension: .fractionalHeight(1.0)
)

let headerLayout = NSCollectionLayoutSize(widthDimension: .fractionalWidth(1.0), heightDimension: .absolute(30))

let header = NSCollectionLayoutBoundarySupplementaryItem(
layoutSize: headerLayout,
elementKind: SearchResultHeaderView.kind,
alignment: .top
)

let item: NSCollectionLayoutItem = NSCollectionLayoutItem(layoutSize: itemSize)
let groupSize = NSCollectionLayoutSize(
widthDimension: .fractionalWidth(1.0),
heightDimension: .absolute(60.0)
)
let group = NSCollectionLayoutGroup.horizontal(layoutSize: groupSize, subitems: [item])

let section = NSCollectionLayoutSection(group: group)
section.contentInsets = NSDirectionalEdgeInsets(top: .zero, leading: 20.0, bottom: 20.0, trailing: 20.0)
section.boundarySupplementaryItems = [header]

return section
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ extension SongSearchResultCollectionViewLayout {
let item: NSCollectionLayoutItem = NSCollectionLayoutItem(layoutSize: itemSize)
let groupSize = NSCollectionLayoutSize(
widthDimension: .fractionalWidth(1.0),
heightDimension: .fractionalWidth(0.16)
heightDimension: .absolute(60.0)
)
let group = NSCollectionLayoutGroup.horizontal(layoutSize: groupSize, subitems: [item])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,86 +7,45 @@ import SongsDomainInterface
public final class AfterSearchReactor: Reactor {
var disposeBag: DisposeBag = DisposeBag()

public enum Action {
case updateData(String)
}
private let service: any SearchCommonService

public enum Action {}

public enum Mutation {
case updateData([[Int]])
case updateText(String)
}

public struct State {
var dataSource: [[Int]]
var text: String
}

public var initialState: State

init() {
init(service: some SearchCommonService = DefaultSearchCommonService.shared, text: String) {
self.initialState = State(
dataSource: [],
text: ""
text: text
)
self.service = service
}

deinit {
LogManager.printDebug("\(Self.self)")
}

public func mutate(action: Action) -> Observable<Mutation> {
switch action {
case let .updateData(text):
return fetchData(text)
}
}
public func mutate(action: Action) -> Observable<Mutation> {}

public func reduce(state: State, mutation: Mutation) -> State {
var newState = state

switch mutation {
case let .updateData(data):
newState.dataSource = data
case let .updateText(text):
newState.text = text
}

return newState
}
}

private extension AfterSearchReactor {
func fetchData(_ text: String) -> Observable<Mutation> {
return Observable.just(SearchResultEntity(song: [], artist: [], remix: []))
.asObservable()
.map { res in

let r1 = res.song
let r2 = res.artist
let r3 = res.remix

let limitCount: Int = 3

// let all: [SearchSectionModel] = [
// SearchSectionModel(
// model: (.song, r1.count),
// items: r1.count > limitCount ? Array(r1[0 ... limitCount - 1]) : r1
// ),
// SearchSectionModel(
// model: (.artist, r2.count),
// items: r2.count > limitCount ? Array(r2[0 ... limitCount - 1]) : r2
// ),
// SearchSectionModel(
// model: (.remix, r3.count),
// items: r3.count > limitCount ? Array(r3[0 ... limitCount - 1]) : r3
// )
// ]
//
var results: [[Int]] = []
// results.append(all)
// results.append([SearchSectionModel(model: (.song, r1.count), items: r1)])
// results.append([SearchSectionModel(model: (.artist, r2.count), items: r2)])
// results.append([SearchSectionModel(model: (.remix, r3.count), items: r3)])

return results
}
.map { Mutation.updateData($0) }
}
#warning("유즈케이스 주입")
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public final class BeforeSearchReactor: Reactor {
self.initialState = State(
showRecommend: true,
dataSource: [],
isLoading: true
isLoading: false
)
}

Expand Down
Loading
Loading