Skip to content

Commit

Permalink
[Feat] Team-Sopetit#117 - 세션종료 alert 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
ahra1221 committed Feb 1, 2024
1 parent 57a9145 commit fc931f2
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 23 deletions.
5 changes: 5 additions & 0 deletions Sopetit-iOS/Sopetit-iOS/Global/Literals/StringLiterals.swift
Original file line number Diff line number Diff line change
Expand Up @@ -135,4 +135,9 @@ enum I18N {
static let guideNotion = "https://softie-link.notion.site/6a65faa32923410a84ff6a63c47cf752?pvs=4"
static let feedbackFoam = "https://docs.google.com/forms/d/e/1FAIpQLSfEtF_qWDu9mI1IcEBPTWsoBVCwPa0wunQK600EcjOMbz8upQ/viewform?usp=sf_link"
}

enum SessionExpiredAlert {
static let title = "인증 세션이 만료되었습니다."
static let message = "원활한 앱 사용을 위해\n다시 로그인 해주세요."
}
}
43 changes: 20 additions & 23 deletions Sopetit-iOS/Sopetit-iOS/Global/Utils/MakeAlert.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,28 @@

import UIKit

/**
- Description:
요청하는(OK,취소)버튼만 있는 UIAlertController를 간편하게 만들기 위한 extension입니다.
- parameters:
- title: 알림창에 뜨는 타이틀 부분입니다.
- message: 타이틀 밑에 뜨는 메세지 부분입니다.
- okAction: 확인버튼을 눌렀을 때 동작하는 부분입니다.
- cancelAction: 취소버튼을 눌렀을 때 동작하는 부분입니다.
- completion: 해당 UIAlertController가 띄워졌을 때, 동작하는 부분입니다.
*/

extension UIViewController {
func makeAlert(title: String,
message: String,
okAction: ((UIAlertAction) -> Void)? = nil,
completion: (() -> Void)? = nil) {

func makeSessionExpiredAlert() {
makeVibrate()
let alertViewController = UIAlertController(title: title, message: message,
preferredStyle: .alert)
let okAction = UIAlertAction(title: "확인", style: .default, handler: okAction)
let alertViewController = UIAlertController(
title: I18N.SessionExpiredAlert.title,
message: I18N.SessionExpiredAlert.message,
preferredStyle: .alert)
let okAction = UIAlertAction(title: "확인", style: .default) { _ in
self.moveToLoginView()
}
alertViewController.addAction(okAction)
self.present(alertViewController, animated: true, completion: completion)
self.present(alertViewController, animated: true, completion: nil)
}

private func moveToLoginView() {
guard let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene,
let keyWindow = windowScene.windows.first else {
return
}

let nav = UINavigationController(rootViewController: LoginViewController())
keyWindow.rootViewController = nav
}
}

0 comments on commit fc931f2

Please sign in to comment.