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

WR-196: Require and inform about update #7

Merged
merged 2 commits into from
Jun 12, 2023
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 WaiterRobot/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class AppDelegate: NSObject, UIApplicationDelegate {
let logger = koin.logger(tag: "AppDelegate")
logger.d { "initialized Koin" }

KMMResourcesLocalizationKt.localizationBundle = Bundle(for: L.self)
KMMResourcesLocalizationKt.localizationBundle = Bundle(for: shared.L.self)
logger.d { "initialized localization bundle" }

return true
Expand Down
9 changes: 7 additions & 2 deletions WaiterRobot/Core/Globals.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ var koin: IosKoinComponent {
}

// Shortcut for localization
var S: L.Companion {
get { L.Companion.shared }
@available(*, deprecated, renamed: "L")
var S: shared.L.Companion {
get { shared.L.Companion.shared }
}

var L: shared.L.Companion {
get { shared.L.Companion.shared }
}
36 changes: 36 additions & 0 deletions WaiterRobot/Ui/UpdateApp/UpdateAppScreen.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import SwiftUI
import shared

struct UpdateAppScreen: View {
var body: some View {
VStack{
Text(L.app.forceUpdate.message())
.multilineTextAlignment(.center)

Button {
guard let storeUrl = VersionChecker.shared.storeUrl,
let url = URL(string: storeUrl)
else {
return
}

DispatchQueue.main.async {
UIApplication.shared.open(url, options: [:], completionHandler: nil)
}
} label: {
Text(L.app.forceUpdate.openStore(value0: "App Store"))
}.padding()
}
.padding()
.navigationTitle(L.app.forceUpdate.title())
.navigationBarTitleDisplayMode(.inline)
}
}

struct UpdateAppScreen_Previews: PreviewProvider {
static var previews: some View {
NavigationView {
UpdateAppScreen()
}
}
}
29 changes: 29 additions & 0 deletions WaiterRobot/WaiterRobotApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ struct WaiterRobotApp: App {
@UIApplicationDelegateAdaptor var appDelegate: AppDelegate

@State private var snackBarMessage: String? = nil
@State private var showUpdateAvailableAlert: Bool = false
@StateObject private var navigator: UIPilot<Screen> = UIPilot(initial: Screen.RootScreen.shared, debug: true)
@StateObject private var strongVM = ObservableViewModel(vm: koin.rootVM())

Expand All @@ -32,6 +33,7 @@ struct WaiterRobotApp: App {
case is Screen.LoginScannerScreen: LoginScannerScreen()
case is Screen.SwitchEventScreen: SwitchEventScreen()
case is Screen.SettingsScreen: SettingsScreen()
case is Screen.UpdateApp: UpdateAppScreen()
case let s as Screen.RegisterScreen: RegisterScreen(createToken: s.createToken)
case let s as Screen.TableDetailScreen: TableDetailScreen(table: s.table)
case let s as Screen.OrderScreen: OrderScreen(table: s.table, initialItemId: s.initialItemId)
Expand Down Expand Up @@ -85,6 +87,33 @@ struct WaiterRobotApp: App {
.onOpenURL { url in
vm.actual.onDeepLink(url: url.absoluteString)
}
.alert(
S.app.updateAvailable.title(),
isPresented: $showUpdateAvailableAlert
) {
Button(S.dialog.cancel(), role: .cancel) {
showUpdateAvailableAlert = false
}

Button (S.app.forceUpdate.openStore(value0: "App Store")) {
guard let storeUrl = VersionChecker.shared.storeUrl,
let url = URL(string: storeUrl)
else {
return
}

DispatchQueue.main.async {
UIApplication.shared.open(url, options: [:], completionHandler: nil)
}
}
} message: {
Text(S.app.updateAvailable.message())
}
.onAppear {
VersionChecker.shared.checkVersion {
showUpdateAvailableAlert = true
}
}
}
}
}
2 changes: 1 addition & 1 deletion project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ fileGroups:
packages:
shared:
url: https://github.com/DatepollSystems/waiterrobot-mobile_android-shared.git
version: "1.0.4-lava-1685977221"
version: "1.0.4-lava-1686511182"
UIPilot:
url: https://github.com/canopas/UIPilot.git
from: 1.3.1
Expand Down