-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
32 changed files
with
549 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
// | ||
// ForceAppUpdate.swift | ||
// ArtemisKit | ||
// | ||
// Created by Anian Schleyer on 10.02.25. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct ForceAppUpdateViewModifier: ViewModifier { | ||
@Binding var updateRequirement: UpdateRequirement | ||
|
||
private var presentUpdateSheet: Binding<Bool> { | ||
Binding( | ||
get: { | ||
updateRequirement != .upToDate | ||
}, | ||
set: { newValue in | ||
if !newValue { | ||
updateRequirement = .upToDate | ||
} | ||
} | ||
) | ||
} | ||
|
||
func body(content: Content) -> some View { | ||
content | ||
.sheet(isPresented: presentUpdateSheet) { | ||
UpdateAvailableView(updateRequirement: updateRequirement) | ||
.interactiveDismissDisabled() | ||
} | ||
} | ||
} | ||
|
||
private struct UpdateAvailableView: View { | ||
@Environment(\.openURL) var openURL | ||
@Environment(\.dismiss) var dismiss | ||
let updateRequirement: UpdateRequirement | ||
|
||
var body: some View { | ||
ScrollView { | ||
VStack(spacing: .xl) { | ||
Image(systemName: "app.badge.fill") | ||
.resizable() | ||
.scaledToFit() | ||
.frame(width: 100, height: 100) | ||
.foregroundStyle(.blue) | ||
.padding(.top) | ||
|
||
Text(R.string.localizable.updateAvailable()) | ||
.font(.title.bold()) | ||
|
||
Text(R.string.localizable.updateDescription()) | ||
.multilineTextAlignment(.center) | ||
|
||
switch updateRequirement { | ||
case let .requiresUpdate(current, min): | ||
Text(R.string.localizable.smallestVersion(current, min)) | ||
.foregroundStyle(.secondary) | ||
.multilineTextAlignment(.center) | ||
default: | ||
EmptyView() | ||
} | ||
} | ||
} | ||
.contentMargins(.xl, for: .scrollContent) | ||
.frame(maxWidth: .infinity, maxHeight: .infinity) | ||
.safeAreaInset(edge: .bottom) { | ||
VStack(spacing: 20) { | ||
Button { | ||
if let url = URL(string: "https://apps.apple.com/app/artemis-learning/id6478965616") { | ||
openURL(url) | ||
} | ||
} label: { | ||
Text(R.string.localizable.download()) | ||
.frame(maxWidth: .infinity) | ||
.padding(.vertical, .m) | ||
} | ||
.buttonStyle(.borderedProminent) | ||
|
||
if updateRequirement == .recommendsUpdate { | ||
Button(R.string.localizable.notNow()) { | ||
dismiss() | ||
} | ||
} | ||
} | ||
.padding(20) | ||
.frame(maxWidth: .infinity) | ||
.background(.bar) | ||
} | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
ArtemisKit/Sources/ArtemisKit/Resources/en.lproj/Localizable.strings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
"updateAvailable" = "New update available"; | ||
"updateDescription" = "Please update Artemis to the latest version to ensure you have a smooth experience.\nYou can download the latest version from the App Store."; | ||
"smallestVersion" = "You are currently using version %@ while the oldest version currently supported is %@."; | ||
"download" = "Download"; | ||
"notNow" = "Not now"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.