Skip to content

Commit

Permalink
๐ŸŽจ :: [#282] Edit MainVC Authority Chaking Add "ํ•™์ƒํšŒ"
Browse files Browse the repository at this point in the history
  • Loading branch information
Xixn2 committed Nov 23, 2024
1 parent 22a67ec commit 0eb9d1c
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 23 deletions.
54 changes: 34 additions & 20 deletions Projects/App/Sources/Application/SceneDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
let adminIsSwitchOn = defaults.bool(forKey: "isSwitchMakeOn")

checkForUpdates { needsUpdate in
if needsUpdate {
print("์—…๋ฐ์ดํŠธ ํ•„์š”")
self.showUpdatePopup()
} else {
print("์ตœ์‹  ๋ฒ„์ „์ž…๋‹ˆ๋‹ค")
}
if needsUpdate {
print("์—…๋ฐ์ดํŠธ ํ•„์š”")
self.showUpdatePopup()
} else {
print("์ตœ์‹  ๋ฒ„์ „์ž…๋‹ˆ๋‹ค")
}
}

applySavedTheme()

Expand All @@ -47,9 +47,23 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
DispatchQueue.main.async {
if authority == "ROLE_STUDENT_COUNCIL" {
if adminIsSwitchOn {
print("Admin Screen: AdminQRViewController")
self.window?.rootViewController = UINavigationController(rootViewController: AdminQRViewController())
} else {
print("Admin Screen: AdminMainViewController")

let adminMainVC = AdminMainViewController()
let navigationController = UINavigationController(rootViewController: adminMainVC)
self.window?.rootViewController = navigationController

DispatchQueue.main.async {
let adminQRVC = AdminQRViewController()

UIView.performWithoutAnimation {
navigationController.pushViewController(adminQRVC, animated: false)
}
}
}


else {
print("Admin Screen: AdminMainViewController")
self.window?.rootViewController = UINavigationController(rootViewController: AdminMainViewController())
}
Expand Down Expand Up @@ -88,7 +102,7 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
completion(false)
return
}

let url = URL(string: "https://itunes.apple.com/lookup?bundleId=\(bundleID)")!
let task = URLSession.shared.dataTask(with: url) { data, response, error in
guard let data = data, error == nil else {
Expand All @@ -99,7 +113,7 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
if let json = try JSONSerialization.jsonObject(with: data, options: []) as? [String: Any],
let results = json["results"] as? [[String: Any]],
let appStoreVersion = results.first?["version"] as? String {

let currentVersion = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String
if let currentVersion = currentVersion, currentVersion.compare(appStoreVersion, options: .numeric) == .orderedAscending {
completion(true)
Expand All @@ -115,36 +129,36 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
}
task.resume()
}

private func showUpdatePopup() {
let alertController = UIAlertController(
title: "์—…๋ฐ์ดํŠธ ์•Œ๋ฆผ",
message: "๋” ๋‚˜์€ ์„œ๋น„์Šค๋ฅผ ์œ„ํ•ด ๊ณฐ์Šค๊ฐ€ ์ˆ˜์ •๋˜์—ˆ์–ด์š”!\n์—…๋ฐ์ดํŠธํ•ด ์ฃผ์‹œ๊ฒ ์–ด์š”?",
preferredStyle: .alert
)

let updateAction = UIAlertAction(title: "ํ™•์ธ", style: .default) { _ in
if let url = URL(string: "https://apps.apple.com/kr/app/goms/id6502936560") {
UIApplication.shared.open(url)
}
}

alertController.addAction(updateAction)

DispatchQueue.main.asyncAfter(deadline: .now() + 1.0) {
self.window?.rootViewController?.present(alertController, animated: true) {
print("์—…๋ฐ์ดํŠธ ํŒ์—… ํ‘œ์‹œ๋จ")
}
}
}

func sceneDidDisconnect(_ scene: UIScene) {}

func sceneDidBecomeActive(_ scene: UIScene) {}

func sceneWillResignActive(_ scene: UIScene) {}

func sceneWillEnterForeground(_ scene: UIScene) {}

func sceneDidEnterBackground(_ scene: UIScene) {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ public class AdminMainViewController: BaseViewController, UICollectionViewDataSo
private let basicsProfileView = ProfileCardView()
private let authViewModel = AuthViewModel()
private let profileViewModel = ProfileViewModel()
private let profileView = MainProfileView()
let refreshControl = UIRefreshControl()

let scrollView = UIScrollView().then {
Expand All @@ -33,8 +34,6 @@ public class AdminMainViewController: BaseViewController, UICollectionViewDataSo
$0.expandedTouchArea = 30
}

private let profileView = MainProfileView()

private let latecomerLabel = UILabel().then {
$0.text = "์ง€๊ฐ์ž TOP 3"
$0.setDynamicTextColor(darkModeColor: .white, lightModeColor: .black)
Expand Down Expand Up @@ -321,6 +320,7 @@ public class AdminMainViewController: BaseViewController, UICollectionViewDataSo

profileView.nameLabel.text = viewModel.profileData?.name
basicsProfileView.nameLabel.text = viewModel.profileData?.name

if viewModel.profileData?.major == Major.sw.rawValue {
profileView.studentInformationLabel.text = "\(grade)๊ธฐ | SW๊ฐœ๋ฐœ"
basicsProfileView.studentInformationLabel.text = "\(grade)๊ธฐ | SW๊ฐœ๋ฐœ"
Expand All @@ -331,6 +331,13 @@ public class AdminMainViewController: BaseViewController, UICollectionViewDataSo
profileView.studentInformationLabel.text = "\(grade)๊ธฐ | AI"
basicsProfileView.studentInformationLabel.text = "\(grade)๊ธฐ | AI"
}

if let authority = viewModel.profileData?.authority {
if authority == "ROLE_STUDENT_COUNCIL" {
profileView.profileStatus.text = "ํ•™์ƒํšŒ"
basicsProfileView.myOutingStatusLabel.text = "ํ•™์ƒํšŒ"
}
}
}

// MARK: - Selector
Expand All @@ -339,7 +346,7 @@ public class AdminMainViewController: BaseViewController, UICollectionViewDataSo
navigationController?.pushViewController(outingVC, animated: true)
}

@objc func qrButtonTapped() {
@objc public func qrButtonTapped() {
qrButton.isUserInteractionEnabled = false
let adminQRVC = AdminQRViewController()
navigationController?.pushViewController(adminQRVC, animated: true)
Expand Down

0 comments on commit 0eb9d1c

Please sign in to comment.