Skip to content
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

Merged
merged 8 commits into from
Feb 14, 2024
Merged

Conversation

SungMinCho-Kor
Copy link
Contributor

⭐️ Issue Number

🚩 Summary

  • Toast 안드로이드와 일치
  • 검색 Toast 구현

🛠️ Technical Concerns

Toast의 디자인과 위치

AOS에서는 Toast가 기본 제공 라이브러리이다.
그렇기 때문에, 항상 노출되는 위치에서 노출되고 다른 앱과 같은 이미지의 Toast로 제공되어야 사용자에 혼란을 야기하지 않는다.
iOS는 기본으로 제공되는 Toast가 없기 때문에 Toast의 디자인과 위치를 AOS에 맞추는 것으로 합의했다.
image

present와 Toast

다른 UIViewController가 present되어 있는데 그 뒤의 UIViewController에서 Toast를 불러오면 present되어있는 UIViewController 뒤에 Toast가 나와서 사용자의 눈에 보이지 않는다.
그렇기 때문에 windowScene을 사용하여 UIViewController와 상관없이 Toast를 띄워줬다.

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: -61)
    ])
}

📋 To Do

  • Toast 리팩토링

@SungMinCho-Kor SungMinCho-Kor added ✨ Feature 기능 관련 작업 📱 Layout 레이아웃 관련 작업 labels Feb 14, 2024
@SungMinCho-Kor SungMinCho-Kor added this to the 4.0 milestone Feb 14, 2024
@SungMinCho-Kor SungMinCho-Kor requested a review from k2645 February 14, 2024 17:59
@SungMinCho-Kor SungMinCho-Kor self-assigned this Feb 14, 2024
Copy link
Contributor

@k2645 k2645 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

수고하셨습니다 ~

Comment on lines 17 to 18
static let toast = UIImage(systemName: "exclamationmark.circle")
static let exclamationmark = UIImage(systemName: "exclamationmark.circle")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

같은 system image를 두번 선언했네요. 하나만 남겨두고 나머지는 지워주세요.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

수정했습니다.

Comment on lines 324 to 357
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()
}
)
}
)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HomeViewController에 존재하는 함수와 동일한 로직을 가지고있는 함수로 보입니다. 해당 함수는 extension을에 구현을 해두고 사용해도 될 것 같은데 이렇게 구현한 이유가 궁금합니다.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

동일한 로직이지만 SearchViewController에서는 view.addSubview 하는 방식으로 수정했습니다.
extension으로 수정하는 것은 불가능한 구조입니다!

@SungMinCho-Kor SungMinCho-Kor requested a review from k2645 February 14, 2024 18:58
Copy link
Contributor

@k2645 k2645 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

수고하셨습니다! 추후 Toast는 확실히 리팩토링이 필요해 보이네요.

@SungMinCho-Kor SungMinCho-Kor merged commit 2f14685 into develop Feb 14, 2024
@SungMinCho-Kor SungMinCho-Kor deleted the feature/toast-layout(#247) branch February 14, 2024 19:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ Feature 기능 관련 작업 📱 Layout 레이아웃 관련 작업
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants