patch
This commit is contained in:
parent
43a9d477a9
commit
eef02dcca1
@ -120,6 +120,40 @@
|
||||
"Email не подтверждён. Подтвердите, чтобы активировать дополнительные проверки." : {
|
||||
"comment" : "Описание необходимости подтверждения email"
|
||||
},
|
||||
"ForceUpdate.Message" : {
|
||||
"comment" : "Force update alert message",
|
||||
"localizations" : {
|
||||
"en" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "This version is no longer supported. Please update the app."
|
||||
}
|
||||
},
|
||||
"ru" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "Эта версия приложения устарела и больше не поддерживается. Пожалуйста, обновите приложение."
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"ForceUpdate.Title" : {
|
||||
"comment" : "Force update alert title",
|
||||
"localizations" : {
|
||||
"en" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "Update required"
|
||||
}
|
||||
},
|
||||
"ru" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "Требуется обновление"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"Fun Fest" : {
|
||||
"comment" : "Fun Fest",
|
||||
"localizations" : {
|
||||
@ -149,6 +183,12 @@
|
||||
},
|
||||
"Login must not end with 'bot' for non-bot accounts" : {
|
||||
|
||||
},
|
||||
"NeedUpdate.Message" : {
|
||||
"comment" : "Need update alert message"
|
||||
},
|
||||
"NeedUpdate.Title" : {
|
||||
"comment" : "Need update alert title"
|
||||
},
|
||||
"OK" : {
|
||||
"comment" : "Common OK\nProfile update alert button\nОбщий текст кнопки OK",
|
||||
@ -204,6 +244,40 @@
|
||||
},
|
||||
"Qr" : {
|
||||
|
||||
},
|
||||
"SoftUpdate.Message" : {
|
||||
"comment" : "Soft update alert message",
|
||||
"localizations" : {
|
||||
"en" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "A new version is available. Some features may stop working correctly soon."
|
||||
}
|
||||
},
|
||||
"ru" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "Вышла новая версия приложения. Некоторые функции могут скоро работать некорректно."
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"SoftUpdate.Title" : {
|
||||
"comment" : "Soft update alert title",
|
||||
"localizations" : {
|
||||
"en" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "Update available"
|
||||
}
|
||||
},
|
||||
"ru" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "Доступно обновление"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"Yobble" : {
|
||||
"localizations" : {
|
||||
|
||||
@ -3,18 +3,40 @@ import UIKit
|
||||
|
||||
struct AppUpdateNotice: Identifiable {
|
||||
enum Kind {
|
||||
case need
|
||||
case force
|
||||
case soft
|
||||
}
|
||||
|
||||
let id = UUID()
|
||||
let kind: Kind
|
||||
let title: String
|
||||
let message: String
|
||||
let appStoreURL: URL
|
||||
|
||||
var title: String {
|
||||
switch kind {
|
||||
case .need:
|
||||
return NSLocalizedString("NeedUpdate.Title", comment: "Need update alert title")
|
||||
case .force:
|
||||
return NSLocalizedString("ForceUpdate.Title", comment: "Force update alert title")
|
||||
case .soft:
|
||||
return NSLocalizedString("SoftUpdate.Title", comment: "Soft update alert title")
|
||||
}
|
||||
}
|
||||
|
||||
var message: String {
|
||||
switch kind {
|
||||
case .need:
|
||||
return NSLocalizedString("NeedUpdate.Message", comment: "Need update alert message")
|
||||
case .force:
|
||||
return NSLocalizedString("ForceUpdate.Message", comment: "Force update alert message")
|
||||
case .soft:
|
||||
return NSLocalizedString("SoftUpdate.Message", comment: "Soft update alert message")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final class AppUpdateChecker: ObservableObject {
|
||||
@Published private(set) var needUpdateNotice: AppUpdateNotice?
|
||||
@Published private(set) var softUpdateNotice: AppUpdateNotice?
|
||||
@Published private(set) var forceUpdateNotice: AppUpdateNotice?
|
||||
|
||||
@ -90,22 +112,20 @@ final class AppUpdateChecker: ObservableObject {
|
||||
print("buildNumber", buildNumber)
|
||||
print("config", config.notSupportedBuild, config.minSupportedBuild, config.recommendedBuild)
|
||||
|
||||
let requiresDoUpdate = buildNumber <= config.notSupportedBuild
|
||||
if requiresDoUpdate, let info = config.forceUpdate {
|
||||
forceUpdateNotice = AppUpdateNotice(kind: .force, title: info.title, message: info.message, appStoreURL: appStoreURL)
|
||||
let requiresNeedUpdate = buildNumber <= config.notSupportedBuild
|
||||
if requiresNeedUpdate {
|
||||
needUpdateNotice = AppUpdateNotice(kind: .need, appStoreURL: appStoreURL)
|
||||
return
|
||||
}
|
||||
|
||||
let requiresForcedUpdate = buildNumber < config.minSupportedBuild
|
||||
if requiresForcedUpdate, let info = config.forceUpdate {
|
||||
forceUpdateNotice = AppUpdateNotice(kind: .force, title: info.title, message: info.message, appStoreURL: appStoreURL)
|
||||
if requiresForcedUpdate {
|
||||
forceUpdateNotice = AppUpdateNotice(kind: .force, appStoreURL: appStoreURL)
|
||||
return
|
||||
}
|
||||
|
||||
let needsSoftUpdate = buildNumber < config.recommendedBuild
|
||||
if needsSoftUpdate, let info = config.softUpdate {
|
||||
softUpdateNotice = AppUpdateNotice(kind: .soft, title: info.title, message: info.message, appStoreURL: appStoreURL)
|
||||
return
|
||||
if buildNumber < config.recommendedBuild {
|
||||
softUpdateNotice = AppUpdateNotice(kind: .soft, appStoreURL: appStoreURL)
|
||||
}
|
||||
}
|
||||
|
||||
@ -135,8 +155,6 @@ private struct RemoteBuildConfiguration: Decodable {
|
||||
case notSupportedBuild = "not_supported_build"
|
||||
case minSupportedBuild = "min_supported_build"
|
||||
case recommendedBuild = "recommended_build"
|
||||
case forceUpdate = "force_update"
|
||||
case softUpdate = "soft_update"
|
||||
case appStoreURL = "appstore_url"
|
||||
}
|
||||
|
||||
|
||||
@ -91,7 +91,13 @@ struct yobbleApp: App {
|
||||
)
|
||||
}
|
||||
.overlay(alignment: .center) {
|
||||
if let notice = updateChecker.forceUpdateNotice {
|
||||
if let notice = updateChecker.needUpdateNotice {
|
||||
ForceUpdateView(
|
||||
title: notice.title,
|
||||
message: notice.message,
|
||||
onUpdate: { updateChecker.openAppStore() }
|
||||
)
|
||||
} else if let notice = updateChecker.forceUpdateNotice {
|
||||
ForceUpdateView(
|
||||
title: notice.title,
|
||||
message: notice.message,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user