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

Fix crash on showing alert for in-app purchase #7499

Merged
merged 1 commit into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ios/MullvadVPN/Coordinators/LocationCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ extension LocationCoordinator: @preconcurrency LocationViewControllerWrapperDele
preferredStyle: UIDevice.current.userInterfaceIdiom == .pad ? .alert : .actionSheet
)
actionSheet.overrideUserInterfaceStyle = .dark
actionSheet.view.tintColor = UIColor(red: 0.0, green: 0.59, blue: 1.0, alpha: 1)
actionSheet.view.tintColor = .AlertController.tintColor

let addCustomListAction = UIAlertAction(
title: NSLocalizedString(
Expand Down
16 changes: 11 additions & 5 deletions ios/MullvadVPN/Extensions/UIAlertController+InAppPurchase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,26 @@ extension UIAlertController {
value: "Add Time",
comment: ""
)
let alert = UIAlertController(title: localizedString, message: nil, preferredStyle: .actionSheet)
let actionSheet = UIAlertController(
title: localizedString,
message: nil,
preferredStyle: UIDevice.current.userInterfaceIdiom == .pad ? .alert : .actionSheet
)
actionSheet.overrideUserInterfaceStyle = .dark
actionSheet.view.tintColor = .AlertController.tintColor
products.sortedByPrice().forEach { product in
guard let localizedTitle = product.customLocalizedTitle else {
return
}
let action = UIAlertAction(title: localizedTitle, style: .default, handler: { _ in
alert.dismiss(animated: true, completion: {
actionSheet.dismiss(animated: true, completion: {
didRequestPurchase(product)
})
})
action
.accessibilityIdentifier =
"\(AccessibilityIdentifier.purchaseButton.asString)_\(product.productIdentifier)"
alert.addAction(action)
actionSheet.addAction(action)
}
let cancelAction = UIAlertAction(title: NSLocalizedString(
"PRODUCT_LIST_CANCEL_BUTTON",
Expand All @@ -42,7 +48,7 @@ extension UIAlertController {
comment: ""
), style: .cancel)
cancelAction.accessibilityIdentifier = AccessibilityIdentifier.cancelPurchaseListButton.asString
alert.addAction(cancelAction)
return alert
actionSheet.addAction(cancelAction)
return actionSheet
}
}
4 changes: 4 additions & 0 deletions ios/MullvadVPN/UI appearance/UIColor+Palette.swift
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,10 @@ extension UIColor {
static let selectedColor = successColor
}

enum AlertController {
static let tintColor = UIColor(red: 0.0, green: 0.59, blue: 1.0, alpha: 1)
}

// Common colors
static let primaryColor = UIColor(red: 0.16, green: 0.30, blue: 0.45, alpha: 1.0)
static let secondaryColor = UIColor(red: 0.10, green: 0.18, blue: 0.27, alpha: 1.0)
Expand Down
Loading