-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Toast 위치 및 layout 수정 #250
Toast 위치 및 layout 수정 #250
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
수고하셨습니다 ~
KCS/KCS/Util/SystemImage.swift
Outdated
static let toast = UIImage(systemName: "exclamationmark.circle") | ||
static let exclamationmark = UIImage(systemName: "exclamationmark.circle") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
같은 system image를 두번 선언했네요. 하나만 남겨두고 나머지는 지워주세요.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
수정했습니다.
func showToast(message: String) { | ||
let toastView = makeToastView(message: message) | ||
|
||
let windows = UIApplication.shared.connectedScenes | ||
let scene = windows.first { $0.activationState == .foregroundActive } | ||
if let windowScene = scene as? UIWindowScene, let windowView = windowScene.windows.first { | ||
windowView.addSubview(toastView) | ||
NSLayoutConstraint.activate([ | ||
toastView.centerXAnchor.constraint(equalTo: windowView.safeAreaLayoutGuide.centerXAnchor), | ||
toastView.bottomAnchor.constraint(equalTo: windowView.safeAreaLayoutGuide.bottomAnchor, constant: -372) | ||
]) | ||
} | ||
|
||
UIView.animate( | ||
withDuration: 0.4, | ||
delay: 0, | ||
options: .curveEaseIn, | ||
animations: { | ||
toastView.alpha = 1.0 | ||
}, | ||
completion: { _ in | ||
UIView.animate( | ||
withDuration: 0.6, | ||
delay: 2.0, | ||
options: .curveEaseOut, | ||
animations: { | ||
toastView.alpha = 0.0 | ||
}, completion: { _ in | ||
toastView.removeFromSuperview() | ||
} | ||
) | ||
} | ||
) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HomeViewController에 존재하는 함수와 동일한 로직을 가지고있는 함수로 보입니다. 해당 함수는 extension을에 구현을 해두고 사용해도 될 것 같은데 이렇게 구현한 이유가 궁금합니다.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
동일한 로직이지만 SearchViewController에서는 view.addSubview 하는 방식으로 수정했습니다.
extension으로 수정하는 것은 불가능한 구조입니다!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
수고하셨습니다! 추후 Toast는 확실히 리팩토링이 필요해 보이네요.
⭐️ Issue Number
🚩 Summary
🛠️ Technical Concerns
Toast의 디자인과 위치
AOS에서는 Toast가 기본 제공 라이브러리이다.

그렇기 때문에, 항상 노출되는 위치에서 노출되고 다른 앱과 같은 이미지의 Toast로 제공되어야 사용자에 혼란을 야기하지 않는다.
iOS는 기본으로 제공되는 Toast가 없기 때문에 Toast의 디자인과 위치를 AOS에 맞추는 것으로 합의했다.
present와 Toast
다른 UIViewController가 present되어 있는데 그 뒤의 UIViewController에서 Toast를 불러오면 present되어있는 UIViewController 뒤에 Toast가 나와서 사용자의 눈에 보이지 않는다.
그렇기 때문에 windowScene을 사용하여 UIViewController와 상관없이 Toast를 띄워줬다.
📋 To Do