Skip to content

Commit

Permalink
[Feat] sopt-makers#336 - 콕 찌르기 메인의 랜덤 유저 추천 영역의 친구 프로필 이미지 터치 시 플그 웹뷰…
Browse files Browse the repository at this point in the history
…로 라우팅
  • Loading branch information
lsj8706 committed Dec 26, 2023
1 parent 3e738cb commit 62b46c6
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import Networks
extension PokeFriendRandomUserEntity {
public func toDomain() -> PokeFriendRandomUserModel {
return PokeFriendRandomUserModel(friendId: friendId,
playgroundId: playgroundId,
friendName: friendName,
friendProfileImage: friendProfileImage,
friendList: friendList.map { $0.toDomain() })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ import Foundation

public struct PokeFriendRandomUserModel {
public let friendId: Int
public let playgroundId: Int
public let friendName, friendProfileImage: String
public let friendList: [PokeUserModel]

public init(friendId: Int, friendName: String, friendProfileImage: String, friendList: [PokeUserModel]) {
public init(friendId: Int, playgroundId: Int, friendName: String, friendProfileImage: String, friendList: [PokeUserModel]) {
self.friendId = friendId
self.playgroundId = playgroundId
self.friendName = friendName
self.friendProfileImage = friendProfileImage
self.friendList = friendList
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public final class PokeMainVC: UIViewController, PokeMainViewControllable {
}

private let refreshControl = UIRefreshControl()

// MARK: - initialization

public init(viewModel: PokeMainViewModel) {
Expand Down Expand Up @@ -119,7 +119,7 @@ extension PokeMainVC {
}

private func setStackView() {
self.contentStackView.addArrangedSubviews(pokedSectionGroupView,
self.contentStackView.addArrangedSubviews(pokedSectionGroupView,
friendSectionGroupView,
recommendPokeLabel,
firstProfileCardGroupView,
Expand Down Expand Up @@ -211,6 +211,11 @@ extension PokeMainVC {
firstProfileCardGroupView.profileImageTap,
secondProfileCardGroupView.profileImageTap).asDriver()

let randomUserSectionFriendProfileImageTap = Publishers.Merge(
firstProfileCardGroupView.friendProfileImageTap,
secondProfileCardGroupView.friendProfileImageTap
).asDriver()

let input = PokeMainViewModel
.Input(
viewDidLoad: Just(()).asDriver(),
Expand All @@ -230,7 +235,8 @@ extension PokeMainVC {
.merge(with: secondProfileCardGroupView.kokButtonTap)
.asDriver(),
refreshRequest: refreshControl.publisher(for: .valueChanged).mapVoid().asDriver(),
profileImageTap: profileImageTap
profileImageTap: profileImageTap,
randomUserSectionFriendProfileImageTap: randomUserSectionFriendProfileImageTap
)

let output = viewModel.transform(from: input, cancelBag: cancelBag)
Expand Down Expand Up @@ -271,9 +277,9 @@ extension PokeMainVC {
.withUnretained(self)
.sink { owner, updatedUser in
let pokeUserViews = [owner.pokedUserContentView,
owner.friendSectionContentView,
owner.firstProfileCardGroupView,
owner.secondProfileCardGroupView]
owner.friendSectionContentView,
owner.firstProfileCardGroupView,
owner.secondProfileCardGroupView]
.compactMap { $0 as? PokeCompatible }

pokeUserViews.forEach { pokeUserView in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public class PokeMainViewModel:
let nearbyFriendsSectionKokButtonTap: Driver<PokeUserModel?>
let refreshRequest: Driver<Void>
let profileImageTap: Driver<PokeUserModel?>
let randomUserSectionFriendProfileImageTap: Driver<Int?>
}

// MARK: - Outputs
Expand Down Expand Up @@ -121,6 +122,12 @@ extension PokeMainViewModel {
self?.onProfileImageTapped?(user.playgroundId)
}.store(in: cancelBag)

input.randomUserSectionFriendProfileImageTap
.compactMap { $0 }
.sink { [weak self] playgroundId in
self?.onProfileImageTapped?(playgroundId)
}.store(in: cancelBag)

return output
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,18 @@ public final class ProfileCardGroupView: UIView, PokeCompatible {
.merge(with: rightProfileCardView.kokButtonTap)
.asDriver()


lazy var friendProfileImageTap: Driver<Int?> = friendProfileImageView
.gesture()
.map { _ in self.friendPlaygroundId }
.asDriver()

lazy var profileImageTap: Driver<PokeUserModel?> = Publishers.Merge(leftProfileCardView.profileTapped,
rightProfileCardView.profileTapped)
.asDriver()
rightProfileCardView.profileTapped).asDriver()

let cancelBag = CancelBag()

private var friendPlaygroundId: Int?

// MARK: - UI Components

Expand All @@ -40,7 +47,6 @@ public final class ProfileCardGroupView: UIView, PokeCompatible {
$0.font = UIFont.MDS.title7
}


private let emptyFriendView = PokeEmptyView().setText(with: I18N.Poke.emptyFriendDescription)

private let leftProfileCardView = PokeProfileCardView(frame: .zero).then {
Expand Down Expand Up @@ -114,6 +120,7 @@ extension ProfileCardGroupView {
extension ProfileCardGroupView {

func setData(with model: PokeFriendRandomUserModel) {
self.friendPlaygroundId = model.playgroundId
self.friendNameLabel.text = model.friendName
self.friendProfileImageView.setImage(with: model.friendProfileImage, placeholder: DSKitAsset.Assets.iconDefaultProfile.image)
let randomUsers = model.friendList.prefix(2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Foundation

public struct PokeFriendRandomUserEntity: Codable {
public let friendId: Int
public let playgroundId: Int
public let friendName, friendProfileImage: String
public let friendList: [PokeUserEntity]
}

0 comments on commit 62b46c6

Please sign in to comment.