From 205650f627967816f950e39b4b130780a55a8d50 Mon Sep 17 00:00:00 2001 From: Sophia Liu <91706701+s0phialiu@users.noreply.github.com> Date: Wed, 21 Feb 2024 20:13:17 -0600 Subject: [PATCH] Quick fix: Default alert color to white (#583) * fix alert color to white * made error messages more detailed, changed alert text to white on phones with dark mode, bumped version up --- HackIllinois.xcodeproj/project.pbxproj | 4 ++-- .../HIScanMentorViewController.swift | 10 +++++--- .../HIScanPointsShopViewController.swift | 9 +++++--- .../HIScanQRCodeViewController.swift | 23 ++++++++++++++----- 4 files changed, 32 insertions(+), 14 deletions(-) diff --git a/HackIllinois.xcodeproj/project.pbxproj b/HackIllinois.xcodeproj/project.pbxproj index ed5819b8..4fbd345f 100644 --- a/HackIllinois.xcodeproj/project.pbxproj +++ b/HackIllinois.xcodeproj/project.pbxproj @@ -1375,7 +1375,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 2024.2.2; + MARKETING_VERSION = 2024.2.3; ONLY_ACTIVE_ARCH = YES; OTHER_SWIFT_FLAGS = "$(inherited) \"-D\" \"COCOAPODS\" -Xfrontend -warn-long-expression-type-checking=150"; PRODUCT_BUNDLE_IDENTIFIER = org.hackillinois.ios; @@ -1407,7 +1407,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 2024.2.2; + MARKETING_VERSION = 2024.2.3; ONLY_ACTIVE_ARCH = YES; PRODUCT_BUNDLE_IDENTIFIER = org.hackillinois.ios; PRODUCT_NAME = "$(TARGET_NAME)"; diff --git a/HackIllinois/ViewControllers/HIScanMentorViewController.swift b/HackIllinois/ViewControllers/HIScanMentorViewController.swift index ffcd2977..eb1064fd 100644 --- a/HackIllinois/ViewControllers/HIScanMentorViewController.swift +++ b/HackIllinois/ViewControllers/HIScanMentorViewController.swift @@ -210,15 +210,19 @@ extension HIScanMentorViewController: AVCaptureMetadataOutputObjectsDelegate { error = false default: alertTitle = "\n\nError!" - alertMessage = "\nSomething isn't quite right." + alertMessage = "\nThis QR code is invalid or you have already checked in to this mentor's office hours." self.respondingToQRCodeFound = true } // Create custom alert for attendee check in functionality let alert = UIAlertController(title: alertTitle, message: alertMessage, preferredStyle: .alert) + let titleFont = UIFont(name: "MontserratRoman-Bold", size: 22) let messageFont = UIFont(name: "MontserratRoman-Medium", size: 16) - let titleColor = #colorLiteral(red: 0.337254902, green: 0.1411764706, blue: 0.06666666667, alpha: 1) - let messageColor = #colorLiteral(red: 0.337254902, green: 0.1411764706, blue: 0.06666666667, alpha: 1) + + let userInterfaceStyle = traitCollection.userInterfaceStyle + let titleColor: UIColor = (userInterfaceStyle == .dark) ? UIColor.white : #colorLiteral(red: 0.337254902, green: 0.1411764706, blue: 0.06666666667, alpha: 1) + let messageColor: UIColor = (userInterfaceStyle == .dark) ? UIColor.white : #colorLiteral(red: 0.337254902, green: 0.1411764706, blue: 0.06666666667, alpha: 1) + let attributedTitle = NSAttributedString(string: alertTitle, attributes: [NSAttributedString.Key.font: titleFont as Any, NSAttributedString.Key.foregroundColor: titleColor]) let attributedMessage = NSAttributedString(string: alertMessage, attributes: [NSAttributedString.Key.font: messageFont as Any, NSAttributedString.Key.foregroundColor: messageColor]) alert.setValue(attributedTitle, forKey: "attributedTitle") diff --git a/HackIllinois/ViewControllers/HIScanPointsShopViewController.swift b/HackIllinois/ViewControllers/HIScanPointsShopViewController.swift index e87cf9e1..f809f4aa 100644 --- a/HackIllinois/ViewControllers/HIScanPointsShopViewController.swift +++ b/HackIllinois/ViewControllers/HIScanPointsShopViewController.swift @@ -222,15 +222,18 @@ extension HIScanPointsShopViewController: AVCaptureMetadataOutputObjectsDelegate self.respondingToQRCodeFound = true default: alertTitle = "\n\nError!" - alertMessage = "\nSomething isn't quite right." + alertMessage = "\nSomething isn't quite right. Double check your coins amount and make sure you have the correct QR code." self.respondingToQRCodeFound = true } // Create custom alert for points shop let alert = UIAlertController(title: alertTitle, message: alertMessage, preferredStyle: .alert) + let titleFont = UIFont(name: "MontserratRoman-Bold", size: 22) let messageFont = UIFont(name: "MontserratRoman-Medium", size: 16) - let titleColor = #colorLiteral(red: 0.337254902, green: 0.1411764706, blue: 0.06666666667, alpha: 1) - let messageColor = #colorLiteral(red: 0.337254902, green: 0.1411764706, blue: 0.06666666667, alpha: 1) + + let userInterfaceStyle = traitCollection.userInterfaceStyle + let titleColor: UIColor = (userInterfaceStyle == .dark) ? UIColor.white : #colorLiteral(red: 0.337254902, green: 0.1411764706, blue: 0.06666666667, alpha: 1) + let messageColor: UIColor = (userInterfaceStyle == .dark) ? UIColor.white : #colorLiteral(red: 0.337254902, green: 0.1411764706, blue: 0.06666666667, alpha: 1) let attributedTitle = NSAttributedString(string: alertTitle, attributes: [NSAttributedString.Key.font: titleFont as Any, NSAttributedString.Key.foregroundColor: titleColor]) let attributedMessage = NSAttributedString(string: alertMessage, attributes: [NSAttributedString.Key.font: messageFont as Any, NSAttributedString.Key.foregroundColor: messageColor]) alert.setValue(attributedTitle, forKey: "attributedTitle") diff --git a/HackIllinois/ViewControllers/HIScanQRCodeViewController.swift b/HackIllinois/ViewControllers/HIScanQRCodeViewController.swift index 8f139d6e..e9574fe7 100644 --- a/HackIllinois/ViewControllers/HIScanQRCodeViewController.swift +++ b/HackIllinois/ViewControllers/HIScanQRCodeViewController.swift @@ -271,15 +271,19 @@ extension HIScanQRCodeViewController: AVCaptureMetadataOutputObjectsDelegate { self.respondingToQRCodeFound = true default: alertTitle = "\n\nError!" - alertMessage = "\nSomething isn't quite right." + alertMessage = "\nYou may have the incorrect QR code or you have already checked into this event." self.respondingToQRCodeFound = true } // Create custom alert for attendee check in functionality let alert = UIAlertController(title: alertTitle, message: alertMessage, preferredStyle: .alert) + let titleFont = UIFont(name: "MontserratRoman-Bold", size: 22) let messageFont = UIFont(name: "MontserratRoman-Medium", size: 16) - let titleColor = #colorLiteral(red: 0.337254902, green: 0.1411764706, blue: 0.06666666667, alpha: 1) - let messageColor = #colorLiteral(red: 0.337254902, green: 0.1411764706, blue: 0.06666666667, alpha: 1) + + let userInterfaceStyle = traitCollection.userInterfaceStyle + let titleColor: UIColor = (userInterfaceStyle == .dark) ? UIColor.white : #colorLiteral(red: 0.337254902, green: 0.1411764706, blue: 0.06666666667, alpha: 1) + let messageColor: UIColor = (userInterfaceStyle == .dark) ? UIColor.white : #colorLiteral(red: 0.337254902, green: 0.1411764706, blue: 0.06666666667, alpha: 1) + let attributedTitle = NSAttributedString(string: alertTitle, attributes: [NSAttributedString.Key.font: titleFont as Any, NSAttributedString.Key.foregroundColor: titleColor]) let attributedMessage = NSAttributedString(string: alertMessage, attributes: [NSAttributedString.Key.font: messageFont as Any, NSAttributedString.Key.foregroundColor: messageColor]) alert.setValue(attributedTitle, forKey: "attributedTitle") @@ -330,14 +334,19 @@ extension HIScanQRCodeViewController: AVCaptureMetadataOutputObjectsDelegate { self.respondingToQRCodeFound = true case "The operation couldn’t be completed. (APIManager.APIRequestError error 0.)": alertTitle = "Error!" - alertMessage = "Your QR code is either invalid/expired or you have already checked into this event." + alertMessage = "The QR code is either invalid/expired or the user has already checked into this event." + self.respondingToQRCodeFound = true + case "Incorrect type of QR code": + alertTitle = "Error!" + alertMessage = "This is not a valid user QR code." self.respondingToQRCodeFound = true default: alertTitle = "Error!" - alertMessage = "Something isn't quite right." + alertMessage = "The QR code is either invalid/expired or the user has already checked into this event." self.respondingToQRCodeFound = true } let alert = UIAlertController(title: alertTitle, message: alertMessage, preferredStyle: .alert) + if alertTitle == "Success!" { alert.addAction( UIAlertAction(title: "OK", style: .default, handler: { _ in @@ -423,8 +432,10 @@ extension HIScanQRCodeViewController: AVCaptureMetadataOutputObjectsDelegate { } .authorize(with: HIApplicationStateController.shared.user) .launch() - } + } else { + self.handleStaffCheckInAlert(status: "Incorrect type of QR code") } + } } else { respondingToQRCodeFound = false HIAPI.UserService.userScanEvent(userToken: user.token, eventID: code)