Skip to content

Commit

Permalink
Merge pull request #130 from boostcampwm2023/iOS/feat#129
Browse files Browse the repository at this point in the history
feat: Toast 기능 구현
  • Loading branch information
anyukyung authored Nov 30, 2023
2 parents 8316494 + ac24604 commit f270691
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
4 changes: 4 additions & 0 deletions iOS/Layover/Layover.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,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 */; };
Expand Down Expand Up @@ -185,6 +186,7 @@
835A61A52B0B4DDD002F22A5 /* Dashboard-Regular.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "Dashboard-Regular.ttf"; sourceTree = "<group>"; };
835A61A82B0B5A31002F22A5 /* LoginConfigurator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoginConfigurator.swift; sourceTree = "<group>"; };
835A61AA2B0B85FD002F22A5 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/LaunchScreen.strings; sourceTree = "<group>"; };
836C33862B15A29600ECAFB0 /* Toast.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Toast.swift; sourceTree = "<group>"; };
83C35E1A2B108C3500D8DD5C /* PlaybackView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlaybackView.swift; sourceTree = "<group>"; };
83C35E1D2B10923C00D8DD5C /* PlaybackCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlaybackCell.swift; sourceTree = "<group>"; };
FC25119F2B045C0A004717BC /* SignUpInteractor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SignUpInteractor.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -354,6 +356,7 @@
children = (
19743C042B06940D001E405A /* PlayerView.swift */,
19E79ABF2B0A85D0009EA9ED /* LoopingPlayerView.swift */,
836C33862B15A29600ECAFB0 /* Toast.swift */,
);
path = UIComponents;
sourceTree = "<group>";
Expand Down Expand Up @@ -786,6 +789,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 */,
FC5BE11C2B148D160036366D /* EditProfilePresenter.swift in Sources */,
Expand Down
39 changes: 39 additions & 0 deletions iOS/Layover/Layover/Scenes/UIComponents/Toast.swift
Original file line number Diff line number Diff line change
@@ -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<UIScene> = 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()
})
}
}

0 comments on commit f270691

Please sign in to comment.