Skip to content

Commit a6dddc3

Browse files
authored
feat(ui): add critical app update screen (#148)
1 parent 989c0e4 commit a6dddc3

File tree

4 files changed

+41
-5
lines changed

4 files changed

+41
-5
lines changed

Bitkit/AppScene.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ struct AppScene: View {
2525
@State private var isPinVerified: Bool = false
2626
@State private var showRecoveryScreen = false
2727

28+
// Check if there's a critical update available
29+
private var hasCriticalUpdate: Bool {
30+
AppUpdateService.shared.availableUpdate?.critical == true
31+
}
32+
2833
init() {
2934
let sheetViewModel = SheetViewModel()
3035
let navigationViewModel = NavigationViewModel()
@@ -98,6 +103,8 @@ struct AppScene: View {
98103
if showRecoveryScreen {
99104
RecoveryRouter()
100105
.accentColor(.white)
106+
} else if hasCriticalUpdate {
107+
AppUpdateScreen()
101108
} else {
102109
walletContent
103110
}

Bitkit/Views/AppUpdateScreen.swift

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import SwiftUI
2+
3+
struct AppUpdateScreen: View {
4+
var body: some View {
5+
OnboardingView(
6+
navTitle: t("other__update_critical_nav_title"),
7+
title: t("other__update_critical_title"),
8+
description: t("other__update_critical_text"),
9+
imageName: "exclamation-mark",
10+
buttonText: t("other__update_critical_button"),
11+
showBackButton: false,
12+
showMenuButton: false,
13+
onButtonPress: {
14+
openAppStore()
15+
},
16+
imagePosition: .center,
17+
testID: "CriticalUpdate"
18+
)
19+
.navigationBarHidden(true)
20+
}
21+
22+
private func openAppStore() {
23+
UIApplication.shared.open(URL(string: Env.appStoreUrl)!)
24+
}
25+
}

Bitkit/Views/OnboardingView.swift

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ struct OnboardingView: View {
99
let onButtonPress: () -> Void
1010

1111
// Optional parameters with defaults
12-
let navTitle: String?
12+
let navTitle: String
13+
let showBackButton: Bool
14+
let showMenuButton: Bool
1315
let titleColor: Color
1416
let accentColor: Color
1517
let imagePosition: ImagePosition
@@ -26,17 +28,21 @@ struct OnboardingView: View {
2628
description: String,
2729
imageName: String,
2830
buttonText: String,
31+
showBackButton: Bool? = nil,
32+
showMenuButton: Bool? = nil,
2933
onButtonPress: @escaping () -> Void,
3034
titleColor: Color = .textPrimary,
3135
accentColor: Color = .brandAccent,
3236
imagePosition: ImagePosition = .bottom,
3337
testID: String? = nil
3438
) {
35-
self.navTitle = navTitle
39+
self.navTitle = navTitle ?? ""
3640
self.title = title
3741
self.description = description
3842
self.imageName = imageName
3943
self.buttonText = buttonText
44+
self.showBackButton = showBackButton ?? true
45+
self.showMenuButton = showMenuButton ?? true
4046
self.onButtonPress = onButtonPress
4147
self.titleColor = titleColor
4248
self.accentColor = accentColor
@@ -46,7 +52,7 @@ struct OnboardingView: View {
4652

4753
var body: some View {
4854
VStack(spacing: 0) {
49-
NavigationBar(title: navTitle ?? "")
55+
NavigationBar(title: navTitle, showBackButton: showBackButton, showMenuButton: showMenuButton)
5056

5157
VStack(spacing: 0) {
5258
VStack {

Bitkit/Views/Sheets/AppUpdateSheet.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ struct AppUpdateSheet: View {
1010
@EnvironmentObject private var sheets: SheetViewModel
1111
let config: AppUpdateSheetItem
1212

13-
private let appUpdateService = AppUpdateService.shared
14-
1513
var body: some View {
1614
Sheet(id: .appUpdate, data: config) {
1715
SheetIntro(

0 commit comments

Comments
 (0)