Skip to content

Commit

Permalink
πŸ”§ μ—…λ‘œλ“œ ν”„λ‘œκ·Έλ ˆμŠ€λ°”, ν† μŠ€νŠΈ κ°œμ„ 
Browse files Browse the repository at this point in the history
  • Loading branch information
anyukyung committed Dec 9, 2023
1 parent 887ff69 commit f8b1863
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 21 deletions.
1 change: 1 addition & 0 deletions iOS/Layover/Layover/Extensions/Notification.Name+.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
31 changes: 16 additions & 15 deletions iOS/Layover/Layover/SceneDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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: "μ—…λ‘œλ“œμ— μ‹€νŒ¨ν–ˆμŠ΅λ‹ˆλ‹€ πŸ’¦")
}
}

Expand All @@ -93,14 +97,17 @@ extension SceneDelegate {
name: .refreshTokenDidExpired,
object: nil)
NotificationCenter.default.removeObserver(self,
name: .refreshTokenDidExpired,
name: .uploadTaskStart,
object: nil)
NotificationCenter.default.removeObserver(self,
name: .progressChanged,
object: nil)
NotificationCenter.default.removeObserver(self,
name: .uploadTaskDidComplete,
object: nil)
NotificationCenter.default.removeObserver(self,
name: .uploadTaskDidFail,
object: nil)
}

@objc private func routeToLoginViewController() {
Expand All @@ -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,
Expand All @@ -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)
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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초의 μ˜μƒλ§Œ 올릴 수 μžˆμ–΄μš” πŸ‘€")
}
}

}
15 changes: 10 additions & 5 deletions iOS/Layover/Layover/Scenes/UIComponents/Toast.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,22 +40,27 @@ 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)
toastLabel.text = message
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()
})
})
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down

0 comments on commit f8b1863

Please sign in to comment.