mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
Add cancel button
This commit is contained in:
parent
9662b3cb1e
commit
0620aba3bc
|
@ -39,7 +39,7 @@ class AppUpdateNag: NSObject {
|
||||||
self.versionService.fetchLatestVersion(lookupURL: lookupURL)
|
self.versionService.fetchLatestVersion(lookupURL: lookupURL)
|
||||||
}.then { appStoreRecord -> Void in
|
}.then { appStoreRecord -> Void in
|
||||||
guard appStoreRecord.version.compare(currentVersion, options: .numeric) == ComparisonResult.orderedDescending else {
|
guard appStoreRecord.version.compare(currentVersion, options: .numeric) == ComparisonResult.orderedDescending else {
|
||||||
Logger.debug("\(self.logTag) same old version: \(appStoreRecord)")
|
Logger.debug("\(self.logTag) remote version: \(appStoreRecord) is not newer than currentVersion: \(currentVersion)")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,20 +128,25 @@ class AppUpdateNag: NSObject {
|
||||||
func presentUpgradeNag(appStoreRecord: AppStoreRecord) {
|
func presentUpgradeNag(appStoreRecord: AppStoreRecord) {
|
||||||
let title = NSLocalizedString("APP_UPDATE_NAG_ALERT_TITLE", comment: "Title for the 'new app version available' alert.")
|
let title = NSLocalizedString("APP_UPDATE_NAG_ALERT_TITLE", comment: "Title for the 'new app version available' alert.")
|
||||||
|
|
||||||
let messageFormat = NSLocalizedString("APP_UPDATE_NAG_ALERT_MESSAGE_FORMAT", comment: "Message format for the 'new app version available' alert. Embeds: {{The latest app version number}}")
|
let bodyFormat = NSLocalizedString("APP_UPDATE_NAG_ALERT_MESSAGE_FORMAT", comment: "Message format for the 'new app version available' alert. Embeds: {{The latest app version number}}")
|
||||||
let message = String(format: messageFormat, appStoreRecord.version)
|
let bodyText = String(format: bodyFormat, appStoreRecord.version)
|
||||||
let buttonTitle = NSLocalizedString("APP_UPDATE_NAG_ALERT_UPDATE_BUTTON", comment: "Label for the 'update' button in the 'new app version available' alert.")
|
let updateButtonText = NSLocalizedString("APP_UPDATE_NAG_ALERT_UPDATE_BUTTON", comment: "Label for the 'update' button in the 'new app version available' alert.")
|
||||||
|
let dismissButtonText = NSLocalizedString("APP_UPDATE_NAG_ALERT_DISMISS_BUTTON", comment: "Label for the 'dismiss' button in the 'new app version available' alert.")
|
||||||
|
|
||||||
OWSAlerts.showAlert(title: title,
|
let alert = UIAlertController(title: title, message: bodyText, preferredStyle: .alert)
|
||||||
message: message,
|
|
||||||
buttonTitle: buttonTitle,
|
|
||||||
buttonAction: { [weak self] _ in
|
|
||||||
guard let strongSelf = self else {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
strongSelf.showAppStore(appStoreURL: appStoreRecord.appStoreURL)
|
let updateAction = UIAlertAction(title: updateButtonText, style: .default) { [weak self] _ in
|
||||||
})
|
guard let strongSelf = self else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
strongSelf.showAppStore(appStoreURL: appStoreRecord.appStoreURL)
|
||||||
|
}
|
||||||
|
|
||||||
|
alert.addAction(updateAction)
|
||||||
|
alert.addAction(UIAlertAction(title: dismissButtonText, style: .cancel, handler: nil))
|
||||||
|
|
||||||
|
OWSAlerts.showAlert(alert)
|
||||||
}
|
}
|
||||||
|
|
||||||
func showAppStore(appStoreURL: URL) {
|
func showAppStore(appStoreURL: URL) {
|
||||||
|
|
|
@ -77,7 +77,10 @@
|
||||||
/* Text prompting user to edit their profile name. */
|
/* Text prompting user to edit their profile name. */
|
||||||
"APP_SETTINGS_EDIT_PROFILE_NAME_PROMPT" = "Enter your name";
|
"APP_SETTINGS_EDIT_PROFILE_NAME_PROMPT" = "Enter your name";
|
||||||
|
|
||||||
/* Message format for the 'new app version available' alert. Embeds: {{The latest app version number.}}. */
|
/* Label for the 'dismiss' button in the 'new app version available' alert. */
|
||||||
|
"APP_UPDATE_NAG_ALERT_DISMISS_BUTTON" = "Not Now";
|
||||||
|
|
||||||
|
/* Message format for the 'new app version available' alert. Embeds: {{The latest app version number}} */
|
||||||
"APP_UPDATE_NAG_ALERT_MESSAGE_FORMAT" = "Version %@ is now available in the App Store.";
|
"APP_UPDATE_NAG_ALERT_MESSAGE_FORMAT" = "Version %@ is now available in the App Store.";
|
||||||
|
|
||||||
/* Title for the 'new app version available' alert. */
|
/* Title for the 'new app version available' alert. */
|
||||||
|
|
|
@ -22,6 +22,15 @@ import Foundation
|
||||||
CurrentAppContext().frontmostViewController()?.present(alertController, animated: true, completion: nil)
|
CurrentAppContext().frontmostViewController()?.present(alertController, animated: true, completion: nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@objc
|
||||||
|
public class func showAlert(_ alert: UIAlertController) {
|
||||||
|
guard let frontmostViewController = CurrentAppContext().frontmostViewController() else {
|
||||||
|
owsFail("\(self.logTag) in \(#function) frontmostViewController was unexpectedly nil")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
frontmostViewController.present(alert, animated: true, completion: nil)
|
||||||
|
}
|
||||||
|
|
||||||
@objc
|
@objc
|
||||||
public class func showAlert(title: String) {
|
public class func showAlert(title: String) {
|
||||||
self.showAlert(title: title, message: nil, buttonTitle: nil)
|
self.showAlert(title: title, message: nil, buttonTitle: nil)
|
||||||
|
|
Loading…
Reference in a new issue