-
Notifications
You must be signed in to change notification settings - Fork 8
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 #1136 from wakmusic/1135-add-credit-profile-image
π :: (#1135) ν¬λ λ§ μμ μ νλ‘ν μ΄λ―Έμ§ μ§μ
- Loading branch information
Showing
15 changed files
with
155 additions
and
15 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
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
5 changes: 5 additions & 0 deletions
5
Projects/Domains/CreditDomain/Interface/UseCase/FetchCreditProfileImageURLUseCase.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,5 @@ | ||
import RxSwift | ||
|
||
public protocol FetchCreditProfileImageURLUseCase { | ||
func execute(name: String) -> Single<String> | ||
} |
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
9 changes: 9 additions & 0 deletions
9
...ects/Domains/CreditDomain/Sources/ResponseDTO/FetchCreditProfileImageURLResponseDTO.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,9 @@ | ||
import Foundation | ||
|
||
struct FetchCreditProfileImageURLResponseDTO: Decodable { | ||
let profileURL: String | ||
|
||
enum CodingKeys: String, CodingKey { | ||
case profileURL = "profileUrl" | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
Projects/Domains/CreditDomain/Sources/UseCase/FetchCreditProfileImageURLUseCaseImpl.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,16 @@ | ||
import CreditDomainInterface | ||
import RxSwift | ||
|
||
public final class FetchCreditProfileImageURLUseCaseImpl: FetchCreditProfileImageURLUseCase { | ||
private let creditRepository: any CreditRepository | ||
|
||
public init( | ||
creditRepository: any CreditRepository | ||
) { | ||
self.creditRepository = creditRepository | ||
} | ||
|
||
public func execute(name: String) -> Single<String> { | ||
creditRepository.fetchCreditProfileImageURL(name: name) | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
Projects/Domains/CreditDomain/Testing/UseCase/FetchCreditProfileImageURLUseCaseSpy.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,17 @@ | ||
import CreditDomainInterface | ||
import RxSwift | ||
import SongsDomainInterface | ||
|
||
public final class FetchCreditProfileImageURLUseCaseSpy: FetchCreditProfileImageURLUseCase { | ||
public var callCount = 0 | ||
public var handler: (String) -> Single<String> = { _ in fatalError() } | ||
|
||
public init() {} | ||
|
||
public func execute( | ||
name: String | ||
) -> Single<String> { | ||
callCount += 1 | ||
return handler(name) | ||
} | ||
} |
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
7 changes: 6 additions & 1 deletion
7
...ures/CreditSongListFeature/Sources/CreditSongList/Component/CreditSongListComponent.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
42 changes: 37 additions & 5 deletions
42
Projects/Features/CreditSongListFeature/Sources/CreditSongList/CreditSongListReactor.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 |
---|---|---|
@@ -1,27 +1,59 @@ | ||
import CreditDomainInterface | ||
import ReactorKit | ||
|
||
final class CreditSongListReactor: Reactor { | ||
enum Action {} | ||
enum Mutation {} | ||
enum Action { | ||
case viewDidLoad | ||
} | ||
|
||
enum Mutation { | ||
case updateProfileImageURL(String?) | ||
} | ||
|
||
struct State { | ||
var workerName: String | ||
var profileImageURL: String? | ||
} | ||
|
||
let initialState: State | ||
internal let workerName: String | ||
private let fetchCreditProfileImageURLUseCase: FetchCreditProfileImageURLUseCase | ||
|
||
init(workerName: String) { | ||
init( | ||
workerName: String, | ||
fetchCreditProfileImageURLUseCase: FetchCreditProfileImageURLUseCase | ||
) { | ||
self.initialState = .init( | ||
workerName: workerName | ||
) | ||
self.workerName = workerName | ||
self.fetchCreditProfileImageURLUseCase = fetchCreditProfileImageURLUseCase | ||
} | ||
|
||
func mutate(action: Action) -> Observable<Mutation> { | ||
.empty() | ||
switch action { | ||
case .viewDidLoad: | ||
return viewDidLoad() | ||
} | ||
} | ||
|
||
func reduce(state: State, mutation: Mutation) -> State { | ||
state | ||
var newState = state | ||
|
||
switch mutation { | ||
case let .updateProfileImageURL(url): | ||
newState.profileImageURL = url | ||
} | ||
|
||
return newState | ||
} | ||
} | ||
|
||
private extension CreditSongListReactor { | ||
func viewDidLoad() -> Observable<Mutation> { | ||
fetchCreditProfileImageURLUseCase | ||
.execute(name: workerName) | ||
.map { Mutation.updateProfileImageURL($0) } | ||
.asObservable() | ||
} | ||
} |
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