Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,29 @@ import DesignSystem
import UIKit

public class SharePhotoViewController: BaseViewController, ViewControllerConfigure {
// MARK: Properties

private let navigationView = UIView()
private let photoView = UIImageView()
private let bottomView = SharePhotoBottomView()

public init() {
// MARK: Dependencies

private let viewModel: SharePhotoViewModel

// MARK: Initializer

public init(viewModel: SharePhotoViewModel) {
self.viewModel = viewModel
super.init(nibName: nil, bundle: nil)
}

required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

// MARK: Life cycle

public override func viewDidLoad() {
super.viewDidLoad()

Expand All @@ -25,6 +36,8 @@ public class SharePhotoViewController: BaseViewController, ViewControllerConfigu
bindOutput()
}

// MARK: Setup View

public func addViews() {
[navigationView, photoView, bottomView].forEach {
view.addSubview($0)
Expand All @@ -51,12 +64,11 @@ public class SharePhotoViewController: BaseViewController, ViewControllerConfigu
}
}

// MARK: Image가 원래는 바인딩 되어야 함
public func configureUI() {
view.backgroundColor = PTGColor.gray90.color

photoView.image = PTGImage.frameIcon.image
photoView.backgroundColor = PTGColor.gray50.color
photoView.image = convertToImage(with: viewModel.photoData)
photoView.backgroundColor = .clear
photoView.contentMode = .scaleAspectFit
}

Expand All @@ -66,14 +78,10 @@ public class SharePhotoViewController: BaseViewController, ViewControllerConfigu
self?.showShareSheet()
}
.store(in: &cancellables)

bottomView.saveButtonTapped
.sink { [weak self] _ in
self?.saveImage()
}
.store(in: &cancellables)
}

// MARK: Functions

private func showShareSheet() {
if let image = photoView.image {
let activityViewController = UIActivityViewController(
Expand All @@ -84,8 +92,7 @@ public class SharePhotoViewController: BaseViewController, ViewControllerConfigu
}
}

// TODO: 권한 요청 및 사진앱에 저장
private func saveImage() {

private func convertToImage(with data: Data) -> UIImage? {
return UIImage(data: data)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import Combine
import Foundation
import PhotoGetherDomainInterface

public final class SharePhotoViewModel {
public private(set) var photoData: Data

public init(component: SharePhotoComponent) {
self.photoData = component.image
}
}