More improvements to unstable features and advanced settings

- added description of what they are and notice if there are none available
- move them to advanced settings
- add alert for unstable features in dev mode if the build does not have them enabled
- move stuff out of the danger zone and into anisette section in advanced settings
This commit is contained in:
naturecodevoid
2023-05-24 21:01:11 -07:00
parent a8917f095e
commit 2219035cd0
7 changed files with 107 additions and 47 deletions

View File

@@ -40,27 +40,38 @@ struct AdvancedSettingsView: View {
var body: some View {
List {
Section {
Picker(L10n.AdvancedSettingsView.anisette, selection: $selectedAnisetteServer) {
Picker(L10n.AdvancedSettingsView.AnisetteSettings.server, selection: $selectedAnisetteServer) {
ForEach(anisetteServers) { server in
Text(server.display)
}
}
}
Section {
Toggle(L10n.AdvancedSettingsView.DangerZone.usePreferred, isOn: $usePreferred)
Toggle(L10n.AdvancedSettingsView.AnisetteSettings.usePreferred, isOn: $usePreferred)
HStack {
Text(L10n.AdvancedSettingsView.DangerZone.anisetteURL)
Text(L10n.AdvancedSettingsView.AnisetteSettings.anisetteURL)
TextField("", text: $anisetteURL)
.autocapitalization(.none)
.autocorrectionDisabled(true)
}
} header: {
Text(L10n.AdvancedSettingsView.dangerZone)
Text(L10n.AdvancedSettingsView.anisetteSettings)
} footer: {
Text(L10n.AdvancedSettingsView.dangerZoneInfo)
Text(L10n.AdvancedSettingsView.AnisetteSettings.footer)
}
#if UNSTABLE // TODO: remove this once we have more settings for the danger zone.
Section {
#if UNSTABLE
NavigationLink(L10n.UnstableFeaturesView.title) {
UnstableFeaturesView(inDevMode: false)
}
.foregroundColor(.red)
#endif
} header: {
Text(L10n.AdvancedSettingsView.dangerZone)
}
#endif
}
.navigationTitle(L10n.AdvancedSettingsView.title)
.enableInjection()

View File

@@ -128,6 +128,10 @@ struct DevModeMenu: View {
@AppStorage("isConsoleEnabled")
var isConsoleEnabled: Bool = false
#if !UNSTABLE
@State var isUnstableAlertShowing = false
#endif
var body: some View {
List {
Section {
@@ -143,6 +147,10 @@ struct DevModeMenu: View {
}
#if !UNSTABLE
.disabled(true)
.alert(isPresented: $isUnstableAlertShowing) {
Alert(title: Text(L10n.DevModeView.unstableFeaturesNightlyOnly))
}
.onTapGesture { isUnstableAlertShowing = true }
#endif
NavigationLink(L10n.DevModeView.dataExplorer) {

View File

@@ -104,6 +104,10 @@ struct SettingsView: View {
}
Section {
NavigationLink("Show Refresh Attempts") {
RefreshAttemptsView()
}
Toggle(isOn: self.$isBackgroundRefreshEnabled, label: {
Text(L10n.SettingsView.backgroundRefresh)
})
@@ -113,10 +117,6 @@ struct SettingsView: View {
SiriShortcutSetupView(shortcut: shortcut)
}
}
NavigationLink("Show Refresh Attempts") {
RefreshAttemptsView()
}
} header: {
Text(L10n.SettingsView.refreshingApps)
} footer: {
@@ -171,12 +171,6 @@ struct SettingsView: View {
AdvancedSettingsView()
}
#if UNSTABLE
NavigationLink(L10n.UnstableFeaturesView.title) {
UnstableFeaturesView(inDevMode: false)
}
#endif
Toggle(L10n.SettingsView.debugLogging, isOn: self.$isDebugLoggingEnabled)
.onChange(of: self.isDebugLoggingEnabled) { value in
UserDefaults.shared.isDebugLoggingEnabled = value

View File

@@ -10,20 +10,36 @@
import SwiftUI
struct UnstableFeaturesView: View {
@ObservedObject private var shared = UnstableFeatures.shared
@ObservedObject private var iO = Inject.observer
var inDevMode: Bool
var body: some View {
List {
ForEach(shared.features.filter { feature, _ in feature != .dummy && (inDevMode || feature.availableOutsideDevMode()) }.sorted(by: { _, _ in true }), id: \.key) { feature, _ in
Toggle(isOn: Binding(get: { UnstableFeatures.enabled(feature) }, set: { newValue in UnstableFeatures.set(feature, enabled: newValue) })) {
Text(String(describing: feature))
let link = "https://github.com/SideStore/SideStore/issues/\(feature.rawValue)"
Link(link, destination: URL(string: link)!)
let features = UnstableFeatures.getFeatures(inDevMode)
let description = L10n.UnstableFeaturesView.description + (features.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)) {
Text(string).font(.callout).foregroundColor(.primary)
} else {
Text(description).font(.callout).foregroundColor(.primary)
}
}.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) })) {
Text(String(describing: feature))
let link = "https://github.com/SideStore/SideStore/issues/\(feature.rawValue)"
Link(link, destination: URL(string: link)!)
}
}
}
}.navigationTitle(L10n.UnstableFeaturesView.title)
}
.navigationTitle(L10n.UnstableFeaturesView.title)
.enableInjection()
}
}