diff --git a/iOS/Layover/Layover.xcodeproj/project.pbxproj b/iOS/Layover/Layover.xcodeproj/project.pbxproj index 51a80cc..9093d03 100644 --- a/iOS/Layover/Layover.xcodeproj/project.pbxproj +++ b/iOS/Layover/Layover.xcodeproj/project.pbxproj @@ -55,6 +55,7 @@ 835A61A22B068115002F22A5 /* PlaybackInteractor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 835A619C2B068115002F22A5 /* PlaybackInteractor.swift */; }; 835A61A62B0B4DDD002F22A5 /* Dashboard-Regular.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 835A61A52B0B4DDD002F22A5 /* Dashboard-Regular.ttf */; }; 835A61A92B0B5A31002F22A5 /* LoginConfigurator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 835A61A82B0B5A31002F22A5 /* LoginConfigurator.swift */; }; + 836C33872B15A29600ECAFB0 /* Toast.swift in Sources */ = {isa = PBXBuildFile; fileRef = 836C33862B15A29600ECAFB0 /* Toast.swift */; }; 83C35E1B2B108C3500D8DD5C /* PlaybackView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 83C35E1A2B108C3500D8DD5C /* PlaybackView.swift */; }; 83C35E1E2B10923C00D8DD5C /* PlaybackCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 83C35E1D2B10923C00D8DD5C /* PlaybackCell.swift */; }; FC2511A02B045C0A004717BC /* SignUpInteractor.swift in Sources */ = {isa = PBXBuildFile; fileRef = FC25119F2B045C0A004717BC /* SignUpInteractor.swift */; }; @@ -174,6 +175,7 @@ 835A61A52B0B4DDD002F22A5 /* Dashboard-Regular.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "Dashboard-Regular.ttf"; sourceTree = ""; }; 835A61A82B0B5A31002F22A5 /* LoginConfigurator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoginConfigurator.swift; sourceTree = ""; }; 835A61AA2B0B85FD002F22A5 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/LaunchScreen.strings; sourceTree = ""; }; + 836C33862B15A29600ECAFB0 /* Toast.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Toast.swift; sourceTree = ""; }; 83C35E1A2B108C3500D8DD5C /* PlaybackView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlaybackView.swift; sourceTree = ""; }; 83C35E1D2B10923C00D8DD5C /* PlaybackCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlaybackCell.swift; sourceTree = ""; }; FC25119F2B045C0A004717BC /* SignUpInteractor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SignUpInteractor.swift; sourceTree = ""; }; @@ -335,6 +337,7 @@ children = ( 19743C042B06940D001E405A /* PlayerView.swift */, 19E79ABF2B0A85D0009EA9ED /* LoopingPlayerView.swift */, + 836C33862B15A29600ECAFB0 /* Toast.swift */, ); path = UIComponents; sourceTree = ""; @@ -743,6 +746,7 @@ 1972CCDF2B14C9B000C3C762 /* Notification.Name+.swift in Sources */, FC2511AF2B04EAD9004717BC /* MapPresenter.swift in Sources */, 19AACFCA2B0F7C3B0088143E /* Response.swift in Sources */, + 836C33872B15A29600ECAFB0 /* Toast.swift in Sources */, FC767F972B1224B80088CF9B /* IntroduceDTO.swift in Sources */, 1972CCD42B138E6B00C3C762 /* SignUpRouter.swift in Sources */, FC68E2A32B0233BC001AABFF /* NetworkError.swift in Sources */, diff --git a/iOS/Layover/Layover/Scenes/UIComponents/Toast.swift b/iOS/Layover/Layover/Scenes/UIComponents/Toast.swift new file mode 100644 index 0000000..7a4d486 --- /dev/null +++ b/iOS/Layover/Layover/Scenes/UIComponents/Toast.swift @@ -0,0 +1,39 @@ +// +// Toast.swift +// Layover +// +// Created by 황지웅 on 11/28/23. +// Copyright © 2023 CodeBomber. All rights reserved. +// + +import UIKit + +final class Toast { + static let shared = Toast() + + private init() {} + + func showToast(message: String) { + let scenes: Set = UIApplication.shared.connectedScenes + let windowScene: UIWindowScene? = scenes.first as? UIWindowScene + guard let window: UIWindow = windowScene?.windows.first else { return } + let toastLabel: UILabel = UILabel() + toastLabel.backgroundColor = .background + 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 + }, completion: { _ in + toastLabel.removeFromSuperview() + }) + } +}