From 69ad632acffc9224a64d79e9d6fd8f4eaa39c2f2 Mon Sep 17 00:00:00 2001 From: Filip Sasala <31418257+plajdo@users.noreply.github.com> Date: Tue, 19 Mar 2024 15:50:34 +0100 Subject: [PATCH] feature: Hide unused settings --- .../Providers/AppDebugModeProvider.swift | 2 +- Sources/AppDebugMode/Views/AppDebugView.swift | 41 +++++++++++-------- 2 files changed, 26 insertions(+), 17 deletions(-) diff --git a/Sources/AppDebugMode/Providers/AppDebugModeProvider.swift b/Sources/AppDebugMode/Providers/AppDebugModeProvider.swift index f90ecb6..9f6278e 100644 --- a/Sources/AppDebugMode/Providers/AppDebugModeProvider.swift +++ b/Sources/AppDebugMode/Providers/AppDebugModeProvider.swift @@ -51,7 +51,7 @@ public final class AppDebugModeProvider { public extension AppDebugModeProvider { func setup( - serversCollections: [ApiServerCollection], + serversCollections: [ApiServerCollection] = [], onServerChange: (() -> Void)? = nil, cacheManager: Any? = nil, firebaseMessaging: AnyObject? = nil diff --git a/Sources/AppDebugMode/Views/AppDebugView.swift b/Sources/AppDebugMode/Views/AppDebugView.swift index 45f0f5c..498ac05 100644 --- a/Sources/AppDebugMode/Views/AppDebugView.swift +++ b/Sources/AppDebugMode/Views/AppDebugView.swift @@ -27,8 +27,10 @@ struct AppDebugView: View { // MARK: - Init init(serversCollections: [ApiServerCollection]) { - self.screens = [ - Screen( + self.screens = [] + + if !AppDebugModeProvider.shared.serversCollections.isEmpty { + self.screens.append(Screen( title: "Server settings", image: Image(systemName: "server.rack"), destination: AnyView(ServersCollectionsView( @@ -36,14 +38,15 @@ struct AppDebugView: View { serversCollections: serversCollections ) )) - ), - Screen( - title: "User profiles", - image: Image(systemName: "person.2"), - destination: AnyView(UserProfilesPickerView()) - ) - ] - + )) + } + + self.screens.append(Screen( + title: "User profiles", + image: Image(systemName: "person.2"), + destination: AnyView(UserProfilesPickerView()) + )) + if let pushNotificationsProvider = AppDebugModeProvider.shared.pushNotificationsProvider { self.screens.append(Screen( title: "Push notifications", @@ -51,18 +54,24 @@ struct AppDebugView: View { destination: AnyView(PushNotificationsSettingsView(pushNotificationsProvider: pushNotificationsProvider)) )) } - - self.screens.append(contentsOf: [ - Screen( + + if !CacheProvider.shared.userDefaultValues.isEmpty { + self.screens.append(Screen( title: "User defaults", image: Image(systemName: "externaldrive"), destination: AnyView(UserDefaultsSettingsView()) - ), - Screen( + )) + } + + if !CacheProvider.shared.keychainValues.isEmpty { + self.screens.append(Screen( title: "Keychain settings", image: Image(systemName: "key"), destination: AnyView(KeychainSettingsView()) - ), + )) + } + + self.screens.append(contentsOf: [ Screen( title: "App directory", image: Image(systemName: "folder"),