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

[Feat] #400 - 솝탬프 신고 기능 및 네트워크 오류 모달 추가 #403

Merged
merged 9 commits into from
Oct 16, 2024
Prev Previous commit
Next Next commit
[Feat] #400 - 신고 기능 뷰 바인딩
  • Loading branch information
dlwogus0128 committed Oct 15, 2024
commit 5c341d35dcb4baa8da976f03f7cb85492c709f85
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public class MissionListVC: UIViewController, MissionListViewControllable {
public var onCurrentGenerationRankingButtonTap: ((RankingViewType) -> Void)?
public var onGuideTap: (() -> Void)?
public var onCellTap: ((MissionListModel, String?) -> Void)?
public var onReportButtonTap: (() -> Void)?

private var usersActiveGenerationStatus: UsersActiveGenerationStatusViewResponse?

Expand Down Expand Up @@ -243,6 +244,12 @@ extension MissionListVC {
owner.onNaviBackTap?()
}.store(in: self.cancelBag)
}

naviBar.reportButtonTapped
.withUnretained(self)
.sink { owner, _ in
owner.onReportButtonTap?()
}.store(in: cancelBag)

partRankingFloatingButton.publisher(for: .touchUpInside)
.withUnretained(self)
Expand Down Expand Up @@ -270,7 +277,8 @@ extension MissionListVC {
let input = MissionListViewModel.Input(
viewDidLoad: Driver<Void>.just(()),
viewWillAppear: viewWillAppear.asDriver(),
missionTypeSelected: missionTypeMenuSelected
missionTypeSelected: missionTypeMenuSelected,
reportUrlButtonTapped: naviBar.reportButtonTapped
)
let output = self.viewModel.transform(from: input, cancelBag: self.cancelBag)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@ public class MissionListViewModel: ViewModelType {
let viewDidLoad: Driver<Void>
let viewWillAppear: Driver<Void>
let missionTypeSelected: CurrentValueSubject<MissionListFetchType, Never>
let reportUrlButtonTapped: Driver<Void>
}

// MARK: - Outputs

public class Output: NSObject {
@Published var missionListModel: [MissionListModel]?
@Published var usersActivateGenerationStatus: UsersActiveGenerationStatusViewResponse?
@Published var reportUrl: SoptampReportUrlModel?
}

// MARK: - init
Expand Down Expand Up @@ -66,6 +68,12 @@ extension MissionListViewModel {
owner.useCase.fetchMissionList(type: fetchType)
}.store(in: cancelBag)

input.reportUrlButtonTapped
.withUnretained(self)
.sink { owner, url in
owner.useCase.getReportUrl()
}.store(in: cancelBag)

return output
}

Expand Down Expand Up @@ -100,5 +108,11 @@ extension MissionListViewModel {
.sink { usersActivateGenerationStatus in
output.usersActivateGenerationStatus = usersActivateGenerationStatus
}.store(in: self.cancelBag)

self.useCase.reportUrl
.asDriver()
.sink { url in
output.reportUrl = url
}.store(in: cancelBag)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ public class STNavigationBar: UIView {
private var naviType: NaviType!
private var rightButtonClosure: (() -> Void)?
private var leftButtonClosure: (() -> Void)?
private var reportButtonClosure: (() -> Void)?

public var rightButtonTapped: Driver<Void> {
rightButton.publisher(for: .touchUpInside)
.map { _ in () }
Expand All @@ -56,6 +58,11 @@ public class STNavigationBar: UIView {
.map { _ in () }
.asDriver()
}
public var reportButtonTapped: Driver<Void> {
reportButton.publisher(for: .touchUpInside)
.map { _ in () }
.asDriver()
}

// MARK: - Initialize

Expand Down Expand Up @@ -131,6 +138,13 @@ extension STNavigationBar {
return self
}

@discardableResult
public func reportButtonAction(_ closure: (() -> Void)? = nil) -> Self {
self.reportButtonClosure = closure
self.reportButton.addTarget(self, action: #selector(tappedReportButton), for: .touchUpInside)
return self
}

@discardableResult
public func resetLeftButtonAction(_ closure: (() -> Void)? = nil) -> Self {
self.leftButtonClosure = closure
Expand Down Expand Up @@ -201,6 +215,11 @@ extension STNavigationBar {
private func tappedLeftButton() {
self.leftButtonClosure?()
}

@objc
private func tappedReportButton() {
self.reportButtonClosure?()
}
}

// MARK: - UI & Layout
Expand Down