mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-14 17:23: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:
@@ -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