Skip to content

Commit

Permalink
Merge pull request #432 from sopt-makers/release
Browse files Browse the repository at this point in the history
[Merge] Release -> Develop
  • Loading branch information
meltsplit authored Nov 9, 2024
2 parents afecc6d + e167c41 commit 9a97e24
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 39 deletions.
2 changes: 1 addition & 1 deletion SOPT-iOS/Projects/Core/Sources/Utils/setImage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public extension UIImageView {

private func setNewImage(with urlString: String, placeholder: UIImage? = nil, completion: ((UIImage?) -> Void)? = nil) {
guard let url = URL(string: urlString) else { return }
let resource = ImageResource(downloadURL: url, cacheKey: urlString)
let resource = KF.ImageResource(downloadURL: url, cacheKey: urlString)

self.kf.setImage(
with: resource,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,23 +142,27 @@ public class ListDetailVC: UIViewController, ListDetailViewControllable {
extension ListDetailVC {
private func bindViewModels() {
let rightButtonTapped = naviBar.rightButtonTapped
.map { self.sceneType }
.withUnretained(self)
.map { owner, _ in
owner.sceneType
}
.asDriver()

let bottomButtonTapped = bottomButton
.publisher(for: .touchUpInside)
.map { _ in
if self.sceneType == .edit {
self.bottomButton.setEnabled(false)
.withUnretained(self)
.map { owner, _ in
if owner.sceneType == .edit {
owner.bottomButton.setEnabled(false)
}
if self.sceneType == .none {
if owner.sceneType == .none {
self.showDimmerView()
}
let content = self.textView.text
let content = owner.textView.text
return ListDetailRequestModel(
missionId: self.viewModel.missionId ?? 0,
missionId: owner.viewModel.missionId ?? 0,
content: content ?? "",
activityDate: self.missionDateTextField.getText() ?? ""
activityDate: owner.missionDateTextField.getText() ?? ""
)
}
.asDriver()
Expand All @@ -174,50 +178,54 @@ extension ListDetailVC {

output.$listDetailModel
.compactMap { $0 }
.sink { model in
.withUnretained(self)
.sink { owner, model in
if model.image.isEmpty {
AlertUtils.presentNetworkAlertVC(theme: .soptamp,animated: true) {
self.backgroundDimmerView.removeFromSuperview()
owner.backgroundDimmerView.removeFromSuperview()
}
} else {
self.setData(model)
if self.sceneType == .none {
self.onComplete?(self.starLevel) {
owner.setData(model)
if owner.sceneType == .none {
owner.onComplete?(owner.starLevel) {
UIView.animate(withDuration: 0.2, delay: 0, animations: {
self.backgroundDimmerView.alpha = 0
owner.backgroundDimmerView.alpha = 0
}) { _ in
self.backgroundDimmerView.removeFromSuperview()
owner.backgroundDimmerView.removeFromSuperview()
}
}
}
self.sceneType = .completed
self.reloadData(self.sceneType)
owner.sceneType = .completed
owner.reloadData(owner.sceneType)
}
}.store(in: self.cancelBag)

output.editSuccessed
.sink { successed in
.withUnretained(self)
.sink { owner, successed in
if successed {
self.reloadData(.completed)
self.showToast(message: I18N.ListDetail.editCompletedToast)
owner.reloadData(.completed)
owner.showToast(message: I18N.ListDetail.editCompletedToast)
} else {
AlertUtils.presentNetworkAlertVC(theme: .soptamp, animated: true)
}
}.store(in: self.cancelBag)

output.showDeleteAlert
.sink { delete in
.withUnretained(self)
.sink { owner, delete in
if delete {
self.presentDeleteAlertVC()
owner.presentDeleteAlertVC()
} else {
self.reloadData(.edit)
owner.reloadData(.edit)
}
}.store(in: self.cancelBag)

output.deleteSuccessed
.sink { success in
.withUnretained(self)
.sink { owner, success in
if success {
self.navigationController?.popViewController(animated: true)
owner.navigationController?.popViewController(animated: true)
} else {
AlertUtils.presentNetworkAlertVC(theme: .soptamp, animated: true)
}
Expand All @@ -228,7 +236,7 @@ extension ListDetailVC {
guard self.sceneType != .none else { return }

if let imageURL = URL(string: model.image) {
self.missionImageView.kf.setImage(with: imageURL)
self.missionImageView.setImage(with: imageURL.absoluteString)
}
self.missionDateTextField.setText(with: model.activityDate)
self.missionDateTextField.setIsEnabled(false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,16 +119,18 @@ extension ListDetailViewModel {
var requestModel = requestModel
return Just(requestModel.updateImgUrl(to: presignedUrl)).asDriver()
}
.sink { requestModel in
if self.sceneType == ListDetailSceneType.none {
self.useCase.postStamp(stampData: requestModel)
.withUnretained(self)
.sink { owner, requestModel in
if owner.sceneType == ListDetailSceneType.none {
owner.useCase.postStamp(stampData: requestModel)
} else {
self.useCase.putStamp(stampData: requestModel)
owner.useCase.putStamp(stampData: requestModel)
}
}.store(in: self.cancelBag)

input.rightButtonTapped
.sink { sceneType in
.withUnretained(self)
.sink { owner, sceneType in
switch sceneType {
case .completed:
output.showDeleteAlert.send(false)
Expand All @@ -140,8 +142,9 @@ extension ListDetailViewModel {
}.store(in: self.cancelBag)

input.deleteButtonTapped
.sink { _ in
self.useCase.deleteStamp(stampId: self.stampId)
.withUnretained(self)
.sink { owner, _ in
owner.useCase.deleteStamp(stampId: owner.stampId)
}.store(in: self.cancelBag)

return output
Expand All @@ -153,20 +156,24 @@ extension ListDetailViewModel {
let deleteSuccess = useCase.deleteSuccess

listDetailModel.asDriver()
.compactMap {
self.stampId = $0.stampId
return $0
.withUnretained(self)
.compactMap { owner, model in
owner.stampId = model.stampId
owner.uploadedUrl = model.image
return model
}
.assign(to: \.self.listDetailModel, on: output)
.store(in: self.cancelBag)

editSuccess.asDriver()
.sink { success in
.withUnretained(self)
.sink { owner, success in
output.editSuccessed.send(success)
}.store(in: self.cancelBag)

deleteSuccess.asDriver()
.sink { success in
.withUnretained(self)
.sink { owner, success in
output.deleteSuccessed.send(success)
}.store(in: self.cancelBag)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//

import UIKit
import Combine

import Core

Expand Down

0 comments on commit 9a97e24

Please sign in to comment.