feat: view to enable/disable Unstable Features

This commit is contained in:
naturecodevoid
2023-05-20 14:23:25 -07:00
parent 9c3461b0c6
commit 637a0354c5
8 changed files with 85 additions and 41 deletions

View File

@@ -405,6 +405,10 @@ internal enum L10n {
/// Trusted Sources
internal static let trustedSources = L10n.tr("Localizable", "SourcesView.trustedSources", fallback: "Trusted Sources")
}
internal enum UnstableFeaturesView {
/// UnstableFeaturesView
internal static let title = L10n.tr("Localizable", "UnstableFeaturesView.title", fallback: "Unstable Features")
}
}
// swiftlint:enable explicit_type_interface function_parameter_count identifier_name line_length
// swiftlint:enable nesting type_body_length type_name vertical_whitespace_opening_braces

View File

@@ -136,6 +136,15 @@ struct DevModeMenu: View {
LCManager.shared.isVisible = value
}
NavigationLink(L10n.UnstableFeaturesView.title) {
#if UNSTABLE
UnstableFeaturesView(allowDevModeOnlyFeatures: true)
#endif
}
#if !UNSTABLE
.disabled(true)
#endif
NavigationLink(L10n.DevModeView.dataExplorer) {
FileExplorer.normal(url: FileManager.default.altstoreSharedDirectory)
.navigationTitle(L10n.DevModeView.dataExplorer)

View File

@@ -113,6 +113,10 @@ struct SettingsView: View {
SiriShortcutSetupView(shortcut: shortcut)
}
}
NavigationLink("Show Refresh Attempts") {
RefreshAttemptsView()
}
} header: {
Text(L10n.SettingsView.refreshingApps)
} footer: {
@@ -162,15 +166,17 @@ struct SettingsView: View {
NavigationLink("Show Error Log") {
ErrorLogView()
}
NavigationLink("Show Refresh Attempts") {
RefreshAttemptsView()
}
NavigationLink(L10n.AdvancedSettingsView.title) {
AdvancedSettingsView()
}
#if UNSTABLE
NavigationLink(L10n.UnstableFeaturesView.title) {
UnstableFeaturesView(allowDevModeOnlyFeatures: false)
}
#endif
Toggle(L10n.SettingsView.debugLogging, isOn: self.$isDebugLoggingEnabled)
.onChange(of: self.isDebugLoggingEnabled) { value in
UserDefaults.shared.isDebugLoggingEnabled = value

View File

@@ -0,0 +1,35 @@
//
// UnstableFeaturesView.swift
// SideStore
//
// Created by naturecodevoid on 5/20/23.
// Copyright © 2023 SideStore. All rights reserved.
//
#if UNSTABLE
import SwiftUI
struct UnstableFeaturesView: View {
@ObservedObject private var shared = UnstableFeatures.shared
var allowDevModeOnlyFeatures: Bool
var body: some View {
List {
ForEach(shared.features.filter { feature, _ in feature != AvailableUnstableFeature.dummy && allowDevModeOnlyFeatures ? true : 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)!)
}
}
}.navigationTitle(L10n.UnstableFeaturesView.title)
}
}
struct UnstableFeaturesView_Previews: PreviewProvider {
static var previews: some View {
UnstableFeaturesView(allowDevModeOnlyFeatures: true)
}
}
#endif