From eef02dcca1194b0ac1418d6c9a0841030045d35d Mon Sep 17 00:00:00 2001 From: cheykrym Date: Thu, 18 Dec 2025 03:08:18 +0300 Subject: [PATCH] patch --- yobble/Resources/Localizable.xcstrings | 74 ++++++++++++++++++++++++++ yobble/Services/AppUpdateChecker.swift | 44 ++++++++++----- yobble/yobbleApp.swift | 8 ++- 3 files changed, 112 insertions(+), 14 deletions(-) diff --git a/yobble/Resources/Localizable.xcstrings b/yobble/Resources/Localizable.xcstrings index 140618a..3b07bcf 100644 --- a/yobble/Resources/Localizable.xcstrings +++ b/yobble/Resources/Localizable.xcstrings @@ -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" : { diff --git a/yobble/Services/AppUpdateChecker.swift b/yobble/Services/AppUpdateChecker.swift index ee69cda..10c1474 100644 --- a/yobble/Services/AppUpdateChecker.swift +++ b/yobble/Services/AppUpdateChecker.swift @@ -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" } diff --git a/yobble/yobbleApp.swift b/yobble/yobbleApp.swift index 9d0e361..8c2ebe4 100644 --- a/yobble/yobbleApp.swift +++ b/yobble/yobbleApp.swift @@ -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,