From b19cf80d9cfd716368954c4b7e31a3767d3b73ba Mon Sep 17 00:00:00 2001 From: anyukyung <1018dbrud@gmail.com> Date: Sun, 10 Dec 2023 01:17:28 +0900 Subject: [PATCH 1/6] =?UTF-8?q?=F0=9F=90=9B=20VideoEditor=20=EC=A7=84?= =?UTF-8?q?=EC=9E=85=EC=8B=9C=20=EA=B8=B0=EC=A1=B4=20=EB=8F=99=EC=98=81?= =?UTF-8?q?=EC=83=81=20mute?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Scenes/EditVideo/EditVideoViewController.swift | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/iOS/Layover/Layover/Scenes/EditVideo/EditVideoViewController.swift b/iOS/Layover/Layover/Scenes/EditVideo/EditVideoViewController.swift index e62532c..180f2e8 100644 --- a/iOS/Layover/Layover/Scenes/EditVideo/EditVideoViewController.swift +++ b/iOS/Layover/Layover/Scenes/EditVideo/EditVideoViewController.swift @@ -114,6 +114,7 @@ final class EditVideoViewController: BaseViewController { } @objc private func cutButtonDidTap() { + loopingPlayerView.player?.isMuted = true guard let videoPath = originalVideoURL?.path() else { return } if UIVideoEditorController.canEditVideo(atPath: videoPath) { let editController = UIVideoEditorController() @@ -139,7 +140,18 @@ extension EditVideoViewController: UINavigationControllerDelegate, UIVideoEditor func videoEditorController(_ editor: UIVideoEditorController, didSaveEditedVideoToPath editedVideoPath: String) { let editedVideoURL = NSURL(fileURLWithPath: editedVideoPath) as URL interactor?.fetchVideo(request: EditVideoModels.FetchVideo.Request(editedVideoURL: editedVideoURL)) - dismiss(animated: true) + loopingPlayerView.player?.isMuted = soundButton.isSelected + editor.dismiss(animated: true) + } + + func videoEditorControllerDidCancel(_ editor: UIVideoEditorController) { + loopingPlayerView.player?.isMuted = soundButton.isSelected + editor.dismiss(animated: true) + } + + func videoEditorController(_ editor: UIVideoEditorController, didFailWithError error: Error) { + loopingPlayerView.player?.isMuted = soundButton.isSelected + editor.dismiss(animated: true) } } From e3473302d6d0851b7df5fea1f16f2a5c484065d9 Mon Sep 17 00:00:00 2001 From: kong <1018dbrud@gmail.com> Date: Sun, 10 Dec 2023 02:37:28 +0900 Subject: [PATCH 2/6] =?UTF-8?q?=F0=9F=90=9B=20=EB=B7=B0=20=EC=A7=84?= =?UTF-8?q?=EC=9E=85=EC=8B=9C=20=EB=8F=99=EC=98=81=EC=83=81=20mute=20?= =?UTF-8?q?=EC=9C=A0=EC=A7=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../EditVideo/EditVideoViewController.swift | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/iOS/Layover/Layover/Scenes/EditVideo/EditVideoViewController.swift b/iOS/Layover/Layover/Scenes/EditVideo/EditVideoViewController.swift index 180f2e8..1c7817a 100644 --- a/iOS/Layover/Layover/Scenes/EditVideo/EditVideoViewController.swift +++ b/iOS/Layover/Layover/Scenes/EditVideo/EditVideoViewController.swift @@ -114,7 +114,7 @@ final class EditVideoViewController: BaseViewController { } @objc private func cutButtonDidTap() { - loopingPlayerView.player?.isMuted = true + loopingPlayerView.player?.pause() guard let videoPath = originalVideoURL?.path() else { return } if UIVideoEditorController.canEditVideo(atPath: videoPath) { let editController = UIVideoEditorController() @@ -140,18 +140,24 @@ extension EditVideoViewController: UINavigationControllerDelegate, UIVideoEditor func videoEditorController(_ editor: UIVideoEditorController, didSaveEditedVideoToPath editedVideoPath: String) { let editedVideoURL = NSURL(fileURLWithPath: editedVideoPath) as URL interactor?.fetchVideo(request: EditVideoModels.FetchVideo.Request(editedVideoURL: editedVideoURL)) - loopingPlayerView.player?.isMuted = soundButton.isSelected - editor.dismiss(animated: true) + editor.dismiss(animated: true) { [weak self] in + guard let self else { return } + self.loopingPlayerView.play() + } } func videoEditorControllerDidCancel(_ editor: UIVideoEditorController) { - loopingPlayerView.player?.isMuted = soundButton.isSelected - editor.dismiss(animated: true) + editor.dismiss(animated: true) { [weak self] in + guard let self else { return } + self.loopingPlayerView.play() + } } func videoEditorController(_ editor: UIVideoEditorController, didFailWithError error: Error) { - loopingPlayerView.player?.isMuted = soundButton.isSelected - editor.dismiss(animated: true) + editor.dismiss(animated: true) { [weak self] in + guard let self else { return } + self.loopingPlayerView.play() + } } } @@ -167,6 +173,7 @@ extension EditVideoViewController: EditVideoDisplayLogic { loopStart: .zero, duration: viewModel.duration) loopingPlayerView.play() + loopingPlayerView.player?.isMuted = soundButton.isSelected nextButton.isEnabled = viewModel.canNext } From c0d2f035168c2306f6dfd8b8d30e4dedf258a352 Mon Sep 17 00:00:00 2001 From: kong <1018dbrud@gmail.com> Date: Sun, 10 Dec 2023 02:37:55 +0900 Subject: [PATCH 3/6] =?UTF-8?q?=F0=9F=90=9B=20=EC=88=98=EC=A0=95=EB=90=9C?= =?UTF-8?q?=20videoURL=EB=A1=9C=20=EB=B0=98=EC=98=81=20=EC=95=88=EB=90=98?= =?UTF-8?q?=EB=8A=94=20=EB=B2=84=EA=B7=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Layover/Scenes/EditVideo/EditVideoInteractor.swift | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/iOS/Layover/Layover/Scenes/EditVideo/EditVideoInteractor.swift b/iOS/Layover/Layover/Scenes/EditVideo/EditVideoInteractor.swift index 0709dab..ff7f2c8 100644 --- a/iOS/Layover/Layover/Scenes/EditVideo/EditVideoInteractor.swift +++ b/iOS/Layover/Layover/Scenes/EditVideo/EditVideoInteractor.swift @@ -36,8 +36,11 @@ final class EditVideoInteractor: EditVideoBusinessLogic, EditVideoDataStore { func fetchVideo(request: EditVideoModels.FetchVideo.Request) { let isEdited = request.editedVideoURL != nil - guard let videoURL = isEdited ? request.editedVideoURL : videoURL else { return } + if let editedVideoURL = request.editedVideoURL { + videoURL = editedVideoURL + } + guard let videoURL else { return } Task { let duration = try await AVAsset(url: videoURL).load(.duration) let seconds = CMTimeGetSeconds(duration) From 887ff6944643f60368cfaba60ed38a3447215bba Mon Sep 17 00:00:00 2001 From: kong <1018dbrud@gmail.com> Date: Sun, 10 Dec 2023 02:39:09 +0900 Subject: [PATCH 4/6] =?UTF-8?q?=F0=9F=90=9B=20=EC=97=85=EB=A1=9C=EB=93=9C?= =?UTF-8?q?=20=EC=9A=94=EC=B2=AD=EC=8B=9C=20=ED=97=A4=EB=8D=94=EC=97=90=20?= =?UTF-8?q?mimeType=20=EB=B3=B4=EB=82=B4=EB=8F=84=EB=A1=9D=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Layover/Network/Provider/Provider.swift | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/iOS/Layover/Layover/Network/Provider/Provider.swift b/iOS/Layover/Layover/Network/Provider/Provider.swift index 89bf2d1..8247158 100644 --- a/iOS/Layover/Layover/Network/Provider/Provider.swift +++ b/iOS/Layover/Layover/Network/Provider/Provider.swift @@ -6,6 +6,8 @@ // import Foundation +import UniformTypeIdentifiers + import OSLog protocol ProviderType { @@ -40,15 +42,15 @@ extension ProviderType { } func upload(fromFile: URL, - to url: String, - method: HTTPMethod = .PUT, - sessionTaskDelegate: URLSessionTaskDelegate? = nil, - delegateQueue: OperationQueue? = nil) async throws -> Data { + to url: String, + method: HTTPMethod = .PUT, + sessionTaskDelegate: URLSessionTaskDelegate? = nil, + delegateQueue: OperationQueue? = nil) async throws -> Data { return try await upload(fromFile: fromFile, - to: url, - method: method, - sessionTaskDelegate: sessionTaskDelegate, - delegateQueue: delegateQueue) + to: url, + method: method, + sessionTaskDelegate: sessionTaskDelegate, + delegateQueue: delegateQueue) } } @@ -159,9 +161,10 @@ class Provider: ProviderType { sessionTaskDelegate: URLSessionTaskDelegate? = nil, delegateQueue: OperationQueue? = nil) async throws -> Data { guard let url = URL(string: url) else { throw NetworkError.components } + guard let mimeType = UTType(filenameExtension: fromFile.pathExtension)?.preferredMIMEType else { throw NetworkError.unknown } var request = URLRequest(url: url, cachePolicy: .reloadIgnoringLocalCacheData) request.httpMethod = method.rawValue - request.setValue("video/\(fromFile.pathExtension)", forHTTPHeaderField: "Content-Type") + request.setValue(mimeType, forHTTPHeaderField: "Content-Type") let (data, response) = try await session.upload(for: request, fromFile: fromFile, delegate: sessionTaskDelegate) From f8b18639530a2426c1df7d511d5da696e3ba06db Mon Sep 17 00:00:00 2001 From: kong <1018dbrud@gmail.com> Date: Sun, 10 Dec 2023 03:33:03 +0900 Subject: [PATCH 5/6] =?UTF-8?q?=F0=9F=94=A7=20=EC=97=85=EB=A1=9C=EB=93=9C?= =?UTF-8?q?=20=ED=94=84=EB=A1=9C=EA=B7=B8=EB=A0=88=EC=8A=A4=EB=B0=94,=20?= =?UTF-8?q?=ED=86=A0=EC=8A=A4=ED=8A=B8=20=EA=B0=9C=EC=84=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Extensions/Notification.Name+.swift | 1 + iOS/Layover/Layover/SceneDelegate.swift | 31 ++++++++++--------- .../EditVideo/EditVideoViewController.swift | 4 +++ .../Layover/Scenes/UIComponents/Toast.swift | 15 ++++++--- .../Scenes/UploadPost/UploadPostWorker.swift | 2 +- 5 files changed, 32 insertions(+), 21 deletions(-) diff --git a/iOS/Layover/Layover/Extensions/Notification.Name+.swift b/iOS/Layover/Layover/Extensions/Notification.Name+.swift index ebb5e37..55386f2 100644 --- a/iOS/Layover/Layover/Extensions/Notification.Name+.swift +++ b/iOS/Layover/Layover/Extensions/Notification.Name+.swift @@ -13,4 +13,5 @@ extension Notification.Name { static let uploadTaskStart = Notification.Name("uploadTaskStart") static let progressChanged = Notification.Name("progressChanged") static let uploadTaskDidComplete = Notification.Name("uploadTaskDidComplete") + static let uploadTaskDidFail = Notification.Name("uploadTaskDidFail") } diff --git a/iOS/Layover/Layover/SceneDelegate.swift b/iOS/Layover/Layover/SceneDelegate.swift index 3f219ee..1e9df84 100644 --- a/iOS/Layover/Layover/SceneDelegate.swift +++ b/iOS/Layover/Layover/SceneDelegate.swift @@ -81,10 +81,14 @@ extension SceneDelegate { self?.showProgressView() } NotificationCenter.default.addObserver(forName: .progressChanged, object: nil, queue: .main) { [weak self] notification in - self?.progressChanged(notification) + guard let progress = notification.userInfo?["progress"] as? Float else { return } + self?.progressView.setProgress(progress, animated: true) } NotificationCenter.default.addObserver(forName: .uploadTaskDidComplete, object: nil, queue: .main) { [weak self] _ in - self?.removeProgressView() + self?.removeProgressView(message: "업로드가 완료되었습니다 ✨") + } + NotificationCenter.default.addObserver(forName: .uploadTaskDidFail, object: nil, queue: .main) { [weak self] _ in + self?.removeProgressView(message: "업로드에 실패했습니다 💦") } } @@ -93,7 +97,7 @@ extension SceneDelegate { name: .refreshTokenDidExpired, object: nil) NotificationCenter.default.removeObserver(self, - name: .refreshTokenDidExpired, + name: .uploadTaskStart, object: nil) NotificationCenter.default.removeObserver(self, name: .progressChanged, @@ -101,6 +105,9 @@ extension SceneDelegate { NotificationCenter.default.removeObserver(self, name: .uploadTaskDidComplete, object: nil) + NotificationCenter.default.removeObserver(self, + name: .uploadTaskDidFail, + object: nil) } @objc private func routeToLoginViewController() { @@ -113,8 +120,10 @@ extension SceneDelegate { private func showProgressView() { guard let progressViewWidth = window?.screen.bounds.width, let windowHeight = window?.screen.bounds.height, - let tabBarViewController = window?.rootViewController as? UITabBarController else { return } - let tabBarHeight: CGFloat = tabBarViewController.tabBar.frame.height + let navigationController = window?.rootViewController as? UINavigationController, + let tabBarController = navigationController.topViewController as? UITabBarController + else { return } + let tabBarHeight: CGFloat = tabBarController.tabBar.frame.height progressView.progress = 0 progressView.tintColor = .primaryPurple progressView.frame = CGRect(x: 0, @@ -124,17 +133,9 @@ extension SceneDelegate { window?.addSubview(progressView) } - - private func progressChanged(_ notification: Notification) { - guard let progress = notification.userInfo?["progress"] as? Float else { return } - progressView.setProgress(progress, animated: true) - if progress == 1 { - Toast.shared.showToast(message: "업로드가 완료되었습니다 ✨") - } - } - - private func removeProgressView() { + private func removeProgressView(message: String) { progressView.removeFromSuperview() + Toast.shared.showToast(message: message) } } diff --git a/iOS/Layover/Layover/Scenes/EditVideo/EditVideoViewController.swift b/iOS/Layover/Layover/Scenes/EditVideo/EditVideoViewController.swift index 1c7817a..f615178 100644 --- a/iOS/Layover/Layover/Scenes/EditVideo/EditVideoViewController.swift +++ b/iOS/Layover/Layover/Scenes/EditVideo/EditVideoViewController.swift @@ -175,6 +175,10 @@ extension EditVideoViewController: EditVideoDisplayLogic { loopingPlayerView.play() loopingPlayerView.player?.isMuted = soundButton.isSelected nextButton.isEnabled = viewModel.canNext + + if !viewModel.canNext { + Toast.shared.showToast(message: "3초 ~ 60초의 영상만 올릴 수 있어요 👀") + } } } diff --git a/iOS/Layover/Layover/Scenes/UIComponents/Toast.swift b/iOS/Layover/Layover/Scenes/UIComponents/Toast.swift index 56ec2e3..b8f5d71 100644 --- a/iOS/Layover/Layover/Scenes/UIComponents/Toast.swift +++ b/iOS/Layover/Layover/Scenes/UIComponents/Toast.swift @@ -40,7 +40,8 @@ final class Toast { let windowScene: UIWindowScene? = scenes.first as? UIWindowScene guard let window: UIWindow = windowScene?.windows.first else { return } let toastLabel: ToastLabel = ToastLabel() - toastLabel.backgroundColor = .background + toastLabel.alpha = 0 + toastLabel.backgroundColor = .background.withAlphaComponent(0.8) toastLabel.textColor = .layoverWhite toastLabel.textAlignment = .center toastLabel.font = .loFont(type: .body2) @@ -48,14 +49,18 @@ final class Toast { toastLabel.layer.cornerRadius = 8 toastLabel.clipsToBounds = true toastLabel.numberOfLines = 1 - toastLabel.layer.opacity = 0.8 toastLabel.frame.size = toastLabel.intrinsicContentSize window.addSubview(toastLabel) toastLabel.center = window.center - UIView.animate(withDuration: 2.0, delay: 0.1, options: .curveEaseOut, animations: { - toastLabel.alpha = 0.0 + + UIView.animate(withDuration: 0.3, delay: 0.5, options: .curveEaseOut, animations: { + toastLabel.alpha = 1.0 }, completion: { _ in - toastLabel.removeFromSuperview() + UIView.animate(withDuration: 1.0, delay: 1.0, options: .curveEaseOut, animations: { + toastLabel.alpha = 0.0 + }, completion: { _ in + toastLabel.removeFromSuperview() + }) }) } } diff --git a/iOS/Layover/Layover/Scenes/UploadPost/UploadPostWorker.swift b/iOS/Layover/Layover/Scenes/UploadPost/UploadPostWorker.swift index 7719d91..8d91918 100644 --- a/iOS/Layover/Layover/Scenes/UploadPost/UploadPostWorker.swift +++ b/iOS/Layover/Layover/Scenes/UploadPost/UploadPostWorker.swift @@ -62,7 +62,7 @@ final class UploadPostWorker: NSObject, UploadPostWorkerProtocol { return true } catch { os_log(.error, log: .data, "Failed to upload Video: %@", error.localizedDescription) - NotificationCenter.default.post(name: .uploadTaskDidComplete, object: nil) + NotificationCenter.default.post(name: .uploadTaskDidFail, object: nil) return false } } From 90d3e3b6f1c69fafe0bc6550e76d3f8ba81684fd Mon Sep 17 00:00:00 2001 From: kong <1018dbrud@gmail.com> Date: Sun, 10 Dec 2023 19:00:49 +0900 Subject: [PATCH 6/6] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20=EB=A6=AC=EB=B7=B0?= =?UTF-8?q?=EC=82=AC=ED=95=AD=20=EB=B0=98=EC=98=81,=20=EC=A3=BC=EC=86=8C?= =?UTF-8?q?=20=EA=B8=B8=EC=96=B4=EC=A7=88=20=EA=B2=BD=EC=9A=B0=20=EB=A0=88?= =?UTF-8?q?=EC=9D=B4=EC=95=84=EC=9B=83=20=EB=8C=80=EC=9D=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Layover/DesignSystem/LOImageLabel.swift | 2 ++ .../UploadPost/UploadPostViewController.swift | 17 +++++++---------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/iOS/Layover/Layover/DesignSystem/LOImageLabel.swift b/iOS/Layover/Layover/DesignSystem/LOImageLabel.swift index f30387f..30e6556 100644 --- a/iOS/Layover/Layover/DesignSystem/LOImageLabel.swift +++ b/iOS/Layover/Layover/DesignSystem/LOImageLabel.swift @@ -20,6 +20,7 @@ final class LOImageLabel: UIView { let label = UILabel() label.font = .loFont(type: .body2Semibold) label.textAlignment = .left + label.numberOfLines = 1 return label }() @@ -54,6 +55,7 @@ final class LOImageLabel: UIView { titleLabel.topAnchor.constraint(equalTo: topAnchor), titleLabel.leadingAnchor.constraint(equalTo: iconImageView.trailingAnchor, constant: 10), + titleLabel.trailingAnchor.constraint(equalTo: trailingAnchor), titleLabel.bottomAnchor.constraint(equalTo: bottomAnchor) ]) } diff --git a/iOS/Layover/Layover/Scenes/UploadPost/UploadPostViewController.swift b/iOS/Layover/Layover/Scenes/UploadPost/UploadPostViewController.swift index 0836844..2b789ef 100644 --- a/iOS/Layover/Layover/Scenes/UploadPost/UploadPostViewController.swift +++ b/iOS/Layover/Layover/Scenes/UploadPost/UploadPostViewController.swift @@ -77,6 +77,8 @@ final class UploadPostViewController: BaseViewController { private let currentAddressLabel: UILabel = { let label = UILabel() label.font = .loFont(type: .body2) + label.numberOfLines = 1 + label.adjustsFontSizeToFitWidth = true return label }() @@ -143,10 +145,7 @@ final class UploadPostViewController: BaseViewController { super.setConstraints() view.addSubviews(scrollView, uploadButton) scrollView.addSubview(contentView) - [scrollView, uploadButton, contentView].forEach { - $0.translatesAutoresizingMaskIntoConstraints = false - } - + [scrollView, uploadButton, contentView].forEach { $0.translatesAutoresizingMaskIntoConstraints = false } NSLayoutConstraint.activate([ scrollView.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor), scrollView.leadingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leadingAnchor, constant: 16), @@ -164,16 +163,13 @@ final class UploadPostViewController: BaseViewController { uploadButton.bottomAnchor.constraint(equalTo: view.keyboardLayoutGuide.topAnchor), uploadButton.heightAnchor.constraint(equalToConstant: 50) ]) - setContentViewSubviewsConstraints() } private func setContentViewSubviewsConstraints() { contentView.addSubviews(thumbnailImageView, titleImageLabel, titleTextField, tagImageLabel, tagStackView, addTagButton, locationImageLabel, currentAddressLabel, contentImageLabel, contentTextView) - contentView.subviews.forEach { - $0.translatesAutoresizingMaskIntoConstraints = false - } + contentView.subviews.forEach { $0.translatesAutoresizingMaskIntoConstraints = false } NSLayoutConstraint.activate([ thumbnailImageView.topAnchor.constraint(equalTo: contentView.topAnchor, constant: 10), thumbnailImageView.widthAnchor.constraint(equalToConstant: 156), @@ -204,15 +200,16 @@ final class UploadPostViewController: BaseViewController { locationImageLabel.topAnchor.constraint(equalTo: tagStackView.bottomAnchor, constant: 22), locationImageLabel.leadingAnchor.constraint(equalTo: contentView.leadingAnchor), + locationImageLabel.widthAnchor.constraint(greaterThanOrEqualToConstant: 60), locationImageLabel.heightAnchor.constraint(equalToConstant: 22), currentAddressLabel.centerYAnchor.constraint(equalTo: locationImageLabel.centerYAnchor), + currentAddressLabel.leadingAnchor.constraint(equalTo: locationImageLabel.trailingAnchor, constant: 15), currentAddressLabel.trailingAnchor.constraint(equalTo: contentView.trailingAnchor), - currentAddressLabel.leadingAnchor.constraint(equalTo: locationImageLabel.trailingAnchor), contentImageLabel.topAnchor.constraint(equalTo: locationImageLabel.bottomAnchor, constant: 22), contentImageLabel.leadingAnchor.constraint(equalTo: contentView.leadingAnchor), - contentImageLabel.trailingAnchor.constraint(equalTo: currentAddressLabel.leadingAnchor), + contentImageLabel.trailingAnchor.constraint(equalTo: contentView.trailingAnchor), contentImageLabel.heightAnchor.constraint(equalToConstant: 22), contentTextView.topAnchor.constraint(equalTo: contentImageLabel.bottomAnchor, constant: 10),