Skip to content

Commit

Permalink
[Feat] sopt-makers#327 - 콕 버튼 터치 시 userId를 전달
Browse files Browse the repository at this point in the history
  • Loading branch information
lsj8706 committed Dec 19, 2023
1 parent f4461dc commit 5e25812
Show file tree
Hide file tree
Showing 11 changed files with 24 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ final public class PokeNotificationListContentView: UIView {
// NOTE: NotifcationDetailView에서는 description의 numberOfLine Value가 2에요
private let isDetailView: Bool

private var userId: Int?

// MARK: - View Lifecycle
public init(
isDetailView: Bool = true,
Expand Down Expand Up @@ -138,6 +140,7 @@ extension PokeNotificationListContentView {

extension PokeNotificationListContentView {
public func configure(with model: NotificationListContentModel) {
self.userId = model.userId
self.profileImageView.setImage(with: model.avatarUrl, relation: model.pokeRelation)
self.nameLabel.text = model.name
self.partInfoLabel.text = model.partInfomation
Expand All @@ -151,8 +154,8 @@ extension PokeNotificationListContentView {
// TBD
}

public func signalForPokeButtonClicked() -> Driver<Void> {
self.pokeKokButton.tap
public func signalForPokeButtonClicked() -> Driver<Int?> {
self.pokeKokButton.tap.map { self.userId }.asDriver()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ public final class PokeProfileCardView: UIView {

// MARK: - Properties

typealias UserId = String
typealias UserId = Int

lazy var kokButtonTap: Driver<UserId?> = kokButton.tap.map { self.userId }.asDriver()

var userId: String?
var userId: Int?

// MARK: - UI Components

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ public final class PokeProfileListView: UIView {

// MARK: - Properties

typealias UserId = String
typealias UserId = Int

lazy var kokButtonTap: Driver<UserId?> = kokButton.tap.map { self.userId }.asDriver()

var viewType: ProfileListType

var userId: String?
var userId: Int?

// MARK: - UI Components

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//

public struct NotificationListContentModel {
let userId: Int
let avatarUrl: String
let pokeRelation: PokeRelation
let name: String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Foundation

public struct ProfileCardContentModel {
let userId: String
let userId: Int
let avatarUrl: String
let name: String
let partInfomation: String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Foundation

public struct ProfileListContentModel {
let userId: String
let userId: Int
let avatarUrl: String
let name: String
let partInfomation: String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,8 @@ extension PokeMainVC {
.rightButtonTap,
friendSectionHeaderButtonTap: friendSectionHeaderView
.rightButtonTap,
pokedSectionKokButtonTap: PassthroughSubject<String?, Never>()
.asDriver(),
pokedSectionKokButtonTap: pokedUserContentView
.signalForPokeButtonClicked(),
friendSectionKokButtonTap: friendSectionContentView
.kokButtonTap,
nearbyFriendsSectionKokButtonTap: firstProfileCardGroupView
Expand All @@ -216,11 +216,11 @@ extension PokeMainVC {
// 테스트를 위해 더미 데이터를 넣도록 임시 세팅
pokedSectionHeaderView.rightButtonTap
.sink { _ in
self.friendSectionContentView.setData(with: .init(userId: "1234aa", avatarUrl: "sdafasdf", name: "test1", partInfomation: "ios", pokeCount: 3, relation: .bestFriend))
self.friendSectionContentView.setData(with: .init(userId: 1234, avatarUrl: "sdafasdf", name: "test1", partInfomation: "ios", pokeCount: 3, relation: .bestFriend))

self.firstProfileCardGroupView.setProfileCard(with: [.init(userId: "777", avatarUrl: "sdafds", name: "test2", partInfomation: "server"), .init(userId: "999", avatarUrl: "", name: "test3", partInfomation: "pm")], friendName: "someone")
self.firstProfileCardGroupView.setProfileCard(with: [.init(userId: 77, avatarUrl: "sdafds", name: "test2", partInfomation: "server"), .init(userId: 999, avatarUrl: "", name: "test3", partInfomation: "pm")], friendName: "someone")

self.secondProfileCardGroupView.setProfileCard(with: [.init(userId: "001", avatarUrl: "sdafds", name: "test4", partInfomation: "server")], friendName: "aaa")
self.secondProfileCardGroupView.setProfileCard(with: [.init(userId: 1, avatarUrl: "sdafds", name: "test4", partInfomation: "server")], friendName: "aaa")
}.store(in: cancelBag)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import PokeFeatureInterface
public class PokeMainViewModel:
PokeMainViewModelType {

typealias UserId = String
typealias UserId = Int

public var onNaviBackTap: (() -> Void)?
public var onMyFriendsTap: (() -> Void)?
Expand Down Expand Up @@ -108,7 +108,8 @@ extension PokeMainViewModel {
useCase.pokedToMeUser.sink { [weak self] pokeUserModel in
guard let self = self else { return }
print("모델: \(pokeUserModel)")
let notificationListContentModel = NotificationListContentModel(avatarUrl: pokeUserModel.profileImage,
let notificationListContentModel = NotificationListContentModel(userId: pokeUserModel.userId,
avatarUrl: pokeUserModel.profileImage,
pokeRelation: PokeRelation(rawValue: pokeUserModel.relationName) ?? .newFriend,
name: pokeUserModel.name,
partInfomation: pokeUserModel.part,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public final class ProfileCardGroupView: UIView {

// MARK: - Properties

typealias UserId = String
typealias UserId = Int

lazy var kokButtonTap: Driver<UserId?> = leftProfileCardView.kokButtonTap
.merge(with: rightProfileCardView.kokButtonTap)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,9 @@ extension PokeMyFriendsVC {
let output = viewModel.transform(from: input, cancelBag: cancelBag)

// TODO: 임시로 데이터를 넣기 위한 코드 -> 서버 연결 후 제거 예정
self.newFriendsSectionView.setData(friendsCount: 84, models: [.init(userId: "", avatarUrl: "", name: "가나다", partInfomation: "33기 안드로이드", pokeCount: 4, relation: .newFriend), .init(userId: "", avatarUrl: "", name: "가나다", partInfomation: "33기 안드로이드", pokeCount: 4, relation: .newFriend)])
self.newFriendsSectionView.setData(friendsCount: 84, models: [.init(userId: 1, avatarUrl: "", name: "가나다", partInfomation: "33기 안드로이드", pokeCount: 4, relation: .newFriend), .init(userId: 2, avatarUrl: "", name: "가나다", partInfomation: "33기 안드로이드", pokeCount: 4, relation: .newFriend)])

self.bestFriendsSectionView.setData(friendsCount: 100, models: [.init(userId: "", avatarUrl: "", name: "가나다", partInfomation: "33기 안드로이드", pokeCount: 4, relation: .newFriend), .init(userId: "", avatarUrl: "", name: "가나다", partInfomation: "33기 서버", pokeCount: 4, relation: .newFriend)])
self.bestFriendsSectionView.setData(friendsCount: 100, models: [.init(userId: 3, avatarUrl: "", name: "가나다", partInfomation: "33기 안드로이드", pokeCount: 4, relation: .newFriend), .init(userId: 4, avatarUrl: "", name: "가나다", partInfomation: "33기 서버", pokeCount: 4, relation: .newFriend)])

self.soulmateSectionView.setData(friendsCount: 2, models: [])
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public final class PokeFriendsSectionGroupView: UIView {

// MARK: - Properties

typealias UserId = String
typealias UserId = Int

lazy var headerRightButtonTap: Driver<PokeRelation> = headerView.rightButtonTap.map { self.relation }.asDriver()
let kokButtonTap = PassthroughSubject<UserId?, Never>()
Expand Down

0 comments on commit 5e25812

Please sign in to comment.