mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-14 09:13:25 +01:00
More improvements and fixes (see commit description)
- put SwiftUI in an unstable feature - Add Reset adi.pb to SwiftUI settings - Add localizations to more things such as Error Log and Refresh Attempts - Move debug logging into Advanced Settings - Add padding to version text at the bottom of SwiftUI settings - Add some things to Unstable Features such as nesting the Feature enum in UnstableFeatures and allowing on enable/disable hooks - Don't use ObservableObject for UnstableFeatures as it's not needed - fix a bug with unstable features where the toggle would be reverted if you go into another tab and then back - Use SwiftUI advanced settings in UIKit
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
import minimuxer
|
||||
|
||||
private struct Server: Identifiable {
|
||||
var id: String { value }
|
||||
@@ -37,6 +38,9 @@ struct AdvancedSettingsView: View {
|
||||
@AppStorage("customAnisetteURL")
|
||||
var selectedAnisetteServer: String = ""
|
||||
|
||||
@AppStorage("isDebugLoggingEnabled")
|
||||
var isDebugLoggingEnabled: Bool = false
|
||||
|
||||
var body: some View {
|
||||
List {
|
||||
Section {
|
||||
@@ -60,8 +64,13 @@ struct AdvancedSettingsView: View {
|
||||
Text(L10n.AdvancedSettingsView.AnisetteSettings.footer)
|
||||
}
|
||||
|
||||
#if UNSTABLE // TODO: remove this once we have more settings for the danger zone.
|
||||
Section {
|
||||
Toggle(L10n.AdvancedSettingsView.DangerZone.debugLogging, isOn: self.$isDebugLoggingEnabled)
|
||||
.onChange(of: self.isDebugLoggingEnabled) { value in
|
||||
UserDefaults.shared.isDebugLoggingEnabled = value
|
||||
set_debug(value)
|
||||
}
|
||||
|
||||
#if UNSTABLE
|
||||
NavigationLink(L10n.UnstableFeaturesView.title) {
|
||||
UnstableFeaturesView(inDevMode: false)
|
||||
@@ -71,7 +80,6 @@ struct AdvancedSettingsView: View {
|
||||
} header: {
|
||||
Text(L10n.AdvancedSettingsView.dangerZone)
|
||||
}
|
||||
#endif
|
||||
}
|
||||
.navigationTitle(L10n.AdvancedSettingsView.title)
|
||||
.enableInjection()
|
||||
|
||||
@@ -107,7 +107,7 @@ struct ErrorLogView: View {
|
||||
}
|
||||
}
|
||||
}
|
||||
.navigationBarTitle("Error Log")
|
||||
.navigationBarTitle(L10n.ErrorLogView.title)
|
||||
.toolbar {
|
||||
ToolbarItemGroup(placement: .navigationBarTrailing) {
|
||||
ModalNavigationLink {
|
||||
|
||||
@@ -55,7 +55,7 @@ struct RefreshAttemptsView: View {
|
||||
}
|
||||
}
|
||||
.background(self.listBackground)
|
||||
.navigationTitle("Refresh Attempts")
|
||||
.navigationTitle(L10n.RefreshAttemptsView.title)
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
|
||||
@@ -31,13 +31,11 @@ struct SettingsView: View {
|
||||
@AppStorage("isDevModeEnabled")
|
||||
var isDevModeEnabled: Bool = false
|
||||
|
||||
@AppStorage("isDebugLoggingEnabled")
|
||||
var isDebugLoggingEnabled: Bool = false
|
||||
|
||||
@State var isShowingConnectAppleIDView = false
|
||||
@State var isShowingResetPairingFileConfirmation = false
|
||||
@State var isShowingDevModePrompt = false
|
||||
@State var isShowingDevModeMenu = false
|
||||
@State var isShowingResetAdiPbConfirmation = false
|
||||
|
||||
@State var externalURLToShow: URL?
|
||||
@State var quickLookURL: URL?
|
||||
@@ -104,7 +102,7 @@ struct SettingsView: View {
|
||||
}
|
||||
|
||||
Section {
|
||||
NavigationLink("Show Refresh Attempts") {
|
||||
NavigationLink(L10n.SettingsView.showRefreshAttempts) {
|
||||
RefreshAttemptsView()
|
||||
}
|
||||
|
||||
@@ -163,7 +161,7 @@ struct SettingsView: View {
|
||||
}
|
||||
|
||||
Section {
|
||||
NavigationLink("Show Error Log") {
|
||||
NavigationLink(L10n.SettingsView.showErrorLog) {
|
||||
ErrorLogView()
|
||||
}
|
||||
|
||||
@@ -171,12 +169,6 @@ struct SettingsView: View {
|
||||
AdvancedSettingsView()
|
||||
}
|
||||
|
||||
Toggle(L10n.SettingsView.debugLogging, isOn: self.$isDebugLoggingEnabled)
|
||||
.onChange(of: self.isDebugLoggingEnabled) { value in
|
||||
UserDefaults.shared.isDebugLoggingEnabled = value
|
||||
set_debug(value)
|
||||
}
|
||||
|
||||
AsyncFallibleButton(action: self.exportLogs, label: { execute in Text(L10n.SettingsView.exportLogs) })
|
||||
|
||||
if MailComposeView.canSendMail {
|
||||
@@ -191,18 +183,27 @@ struct SettingsView: View {
|
||||
}
|
||||
}
|
||||
|
||||
SwiftUI.Button(L10n.SettingsView.switchToUIKit, action: self.switchToUIKit)
|
||||
|
||||
SwiftUI.Button(L10n.SettingsView.resetImageCache, action: self.resetImageCache)
|
||||
.foregroundColor(.red)
|
||||
|
||||
SwiftUI.Button("Reset Pairing File") {
|
||||
SwiftUI.Button(L10n.SettingsView.resetPairingFile) {
|
||||
self.isShowingResetPairingFileConfirmation = true
|
||||
}
|
||||
.foregroundColor(.red)
|
||||
.actionSheet(isPresented: self.$isShowingResetPairingFileConfirmation) {
|
||||
ActionSheet(title: Text("Are you sure to reset the pairing file?"), message: Text("You can reset the pairing file when you cannot sideload apps or enable JIT. SideStore will close when the file has been deleted."), buttons: [
|
||||
.destructive(Text("Delete and Reset"), action: self.resetPairingFile),
|
||||
ActionSheet(title: Text(L10n.SettingsView.ResetPairingFile.title), message: Text(L10n.SettingsView.ResetPairingFile.description), buttons: [
|
||||
.destructive(Text(L10n.SettingsView.resetPairingFile), action: self.resetPairingFile),
|
||||
.cancel()
|
||||
])
|
||||
}
|
||||
|
||||
SwiftUI.Button(L10n.SettingsView.resetAdiPb) {
|
||||
self.isShowingResetAdiPbConfirmation = true
|
||||
}
|
||||
.foregroundColor(.red)
|
||||
.actionSheet(isPresented: self.$isShowingResetAdiPbConfirmation) {
|
||||
ActionSheet(title: Text(L10n.SettingsView.ResetAdiPb.title), message: Text(L10n.SettingsView.ResetAdiPb.description), buttons: [
|
||||
.destructive(Text(L10n.SettingsView.resetAdiPb), action: self.resetAdiPb),
|
||||
.cancel()
|
||||
])
|
||||
}
|
||||
@@ -225,13 +226,11 @@ struct SettingsView: View {
|
||||
}
|
||||
|
||||
|
||||
Section {
|
||||
|
||||
} footer: {
|
||||
Section {} footer: {
|
||||
Text("SideStore \(appVersion)")
|
||||
.multilineTextAlignment(.center)
|
||||
.frame(maxWidth: .infinity)
|
||||
}
|
||||
}.padding([.bottom], 32)
|
||||
}
|
||||
.listStyle(InsetGroupedListStyle())
|
||||
.navigationTitle(L10n.SettingsView.title)
|
||||
@@ -253,13 +252,10 @@ struct SettingsView: View {
|
||||
.enableInjection()
|
||||
}
|
||||
|
||||
|
||||
// var appleIDSection: some View {
|
||||
//
|
||||
// }
|
||||
|
||||
|
||||
|
||||
func connectAppleID() {
|
||||
guard let rootViewController = UIApplication.shared.keyWindow?.rootViewController else {
|
||||
return
|
||||
@@ -293,13 +289,6 @@ struct SettingsView: View {
|
||||
}
|
||||
}
|
||||
|
||||
func switchToUIKit() {
|
||||
let storyboard = UIStoryboard(name: "Main", bundle: .main)
|
||||
let rootVC = storyboard.instantiateViewController(withIdentifier: "tabBarController") as! TabBarController
|
||||
|
||||
UIApplication.shared.keyWindow?.rootViewController = rootVC
|
||||
}
|
||||
|
||||
func resetImageCache() {
|
||||
do {
|
||||
let url = try FileManager.default.url(
|
||||
@@ -334,6 +323,13 @@ struct SettingsView: View {
|
||||
}
|
||||
}
|
||||
|
||||
func resetAdiPb() {
|
||||
if Keychain.shared.adiPb != nil {
|
||||
Keychain.shared.adiPb = nil
|
||||
print("Cleared adi.pb from keychain")
|
||||
}
|
||||
}
|
||||
|
||||
func exportLogs() throws {
|
||||
let path = FileManager.default.documentsDirectory.appendingPathComponent("sidestore.log")
|
||||
var text = LCManager.shared.currentText
|
||||
|
||||
@@ -12,13 +12,20 @@ import SwiftUI
|
||||
struct UnstableFeaturesView: View {
|
||||
@ObservedObject private var iO = Inject.observer
|
||||
|
||||
// Keeping a cache of the features allows us to reload the view every time we change one
|
||||
// If we don't reload the view there is a bug where the toggle will be reset to previous value if you go to another tab and then back
|
||||
@State private var featureCache: [(key: UnstableFeatures.Feature, value: Bool)]
|
||||
|
||||
var inDevMode: Bool
|
||||
|
||||
init(inDevMode: Bool) {
|
||||
self.inDevMode = inDevMode
|
||||
self.featureCache = UnstableFeatures.getFeatures(inDevMode)
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
List {
|
||||
let features = UnstableFeatures.getFeatures(inDevMode)
|
||||
|
||||
let description = L10n.UnstableFeaturesView.description + (features.count <= 0 ? "\n\n" + L10n.UnstableFeaturesView.noUnstableFeatures : "")
|
||||
let description = L10n.UnstableFeaturesView.description + (featureCache.count <= 0 ? "\n\n" + L10n.UnstableFeaturesView.noUnstableFeatures : "")
|
||||
Section {} footer: {
|
||||
if #available(iOS 15.0, *),
|
||||
let string = try? AttributedString(markdown: description, options: AttributedString.MarkdownParsingOptions(interpretedSyntax: .inlineOnlyPreservingWhitespace)) {
|
||||
@@ -28,9 +35,13 @@ struct UnstableFeaturesView: View {
|
||||
}
|
||||
}.listRowInsets(EdgeInsets(top: 8, leading: 0, bottom: 8, trailing: 0))
|
||||
|
||||
if features.count > 0 {
|
||||
ForEach(features.sorted(by: { _, _ in true }), id: \.key) { feature, _ in
|
||||
Toggle(isOn: Binding(get: { UnstableFeatures.enabled(feature) }, set: { newValue in UnstableFeatures.set(feature, enabled: newValue) })) {
|
||||
if featureCache.count > 0 {
|
||||
ForEach(featureCache.sorted(by: { _, _ in true }), id: \.key) { feature, _ in
|
||||
Toggle(isOn: Binding(get: { UnstableFeatures.enabled(feature) }, set: { newValue in
|
||||
UnstableFeatures.set(feature, enabled: newValue)
|
||||
// Update the cache so we reload the view (this fixes the toggle resetting to the previous value if you go to another tab and then back)
|
||||
featureCache = UnstableFeatures.getFeatures(inDevMode)
|
||||
})) {
|
||||
Text(String(describing: feature))
|
||||
let link = "https://github.com/SideStore/SideStore/issues/\(feature.rawValue)"
|
||||
Link(link, destination: URL(string: link)!)
|
||||
|
||||
Reference in New Issue
Block a user