diff --git a/Passepartout.xcodeproj/project.pbxproj b/Passepartout.xcodeproj/project.pbxproj index 4177518a..5bf0914d 100644 --- a/Passepartout.xcodeproj/project.pbxproj +++ b/Passepartout.xcodeproj/project.pbxproj @@ -31,7 +31,7 @@ 0E0F4C6629C84CF60022E884 /* LogoView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E0F4C6529C84CF60022E884 /* LogoView.swift */; }; 0E1AD5CC2A2682DA002AE6E6 /* AppError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E1AD5CB2A2682DA002AE6E6 /* AppError.swift */; }; 0E1AD5CE2A268645002AE6E6 /* Errors+L10n.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E1AD5CD2A268645002AE6E6 /* Errors+L10n.swift */; }; - 0E1B5F5C29C506AD00FE7D18 /* ProfileView+Diagnostics.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E1B5F5B29C506AC00FE7D18 /* ProfileView+Diagnostics.swift */; }; + 0E1B5F5C29C506AD00FE7D18 /* DiagnosticsSection.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E1B5F5B29C506AC00FE7D18 /* DiagnosticsSection.swift */; }; 0E1F5628287F0ECB00F8ADD7 /* ProviderProfileItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E1F5627287F0ECB00F8ADD7 /* ProviderProfileItem.swift */; }; 0E1F562B287F0EF100F8ADD7 /* ProviderProfileItem+ViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E1F5629287F0EEE00F8ADD7 /* ProviderProfileItem+ViewModel.swift */; }; 0E293851285A70AC002A6E0E /* AppPreference.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E293850285A70AC002A6E0E /* AppPreference.swift */; }; @@ -319,7 +319,7 @@ 0E0F4C6529C84CF60022E884 /* LogoView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LogoView.swift; sourceTree = ""; }; 0E1AD5CB2A2682DA002AE6E6 /* AppError.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppError.swift; sourceTree = ""; }; 0E1AD5CD2A268645002AE6E6 /* Errors+L10n.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Errors+L10n.swift"; sourceTree = ""; }; - 0E1B5F5B29C506AC00FE7D18 /* ProfileView+Diagnostics.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ProfileView+Diagnostics.swift"; sourceTree = ""; }; + 0E1B5F5B29C506AC00FE7D18 /* DiagnosticsSection.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DiagnosticsSection.swift; sourceTree = ""; }; 0E1C0A52238FFF97009FC087 /* pl */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = pl; path = pl.lproj/InfoPlist.strings; sourceTree = ""; }; 0E1F5627287F0ECB00F8ADD7 /* ProviderProfileItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProviderProfileItem.swift; sourceTree = ""; }; 0E1F5629287F0EEE00F8ADD7 /* ProviderProfileItem+ViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ProviderProfileItem+ViewModel.swift"; sourceTree = ""; }; @@ -645,6 +645,7 @@ 0EF2213027E674BD001D0BD7 /* AddProviderViewModel.swift */, 0E71ACF827C12E4800F85C4B /* CreditsView.swift */, 0E71ACF627C107C900F85C4B /* DebugLogView.swift */, + 0E1B5F5B29C506AC00FE7D18 /* DiagnosticsSection.swift */, 0E5683B827C2825D00EAF1CD /* DiagnosticsView.swift */, 0ED1D6DB27DBA41700983466 /* DiagnosticsView+OpenVPN.swift */, 0ED1D6DD27DBA42100983466 /* DiagnosticsView+WireGuard.swift */, @@ -671,7 +672,6 @@ 0ED30DD127EA1F650057D8A3 /* PaywallView+Purchase.swift */, 0E44689527B051C300A14CE4 /* ProfileView.swift */, 0E92D7C527F103300033CB7B /* ProfileView+Configuration.swift */, - 0E1B5F5B29C506AC00FE7D18 /* ProfileView+Diagnostics.swift */, 0E92D7C827F1042A0033CB7B /* ProfileView+Extra.swift */, 0E3CD482280DAE92007075C0 /* ProfileView+MainMenu.swift */, 0E3B7FD927E51A0200C66F13 /* ProfileView+Provider.swift */, @@ -1491,7 +1491,7 @@ 0E2A8D4F27B04BBA00207D04 /* OrganizerView.swift in Sources */, 0E49F6BB27D7638300385834 /* EndpointAdvancedView+OpenVPN.swift in Sources */, 0E71ACEF27C106B500F85C4B /* ProviderPresetView.swift in Sources */, - 0E1B5F5C29C506AD00FE7D18 /* ProfileView+Diagnostics.swift in Sources */, + 0E1B5F5C29C506AD00FE7D18 /* DiagnosticsSection.swift in Sources */, 0EF2212F27E66F60001D0BD7 /* AddProfileView.swift in Sources */, 0E96D2FC2871D94E005EFBCF /* DefaultLightProfileManager.swift in Sources */, 0EF0FAF627DD0211007EB181 /* PaywallView.swift in Sources */, diff --git a/Passepartout/App/Views/ProfileView+Diagnostics.swift b/Passepartout/App/Views/DiagnosticsSection.swift similarity index 63% rename from Passepartout/App/Views/ProfileView+Diagnostics.swift rename to Passepartout/App/Views/DiagnosticsSection.swift index cdcb8537..d8653c27 100644 --- a/Passepartout/App/Views/ProfileView+Diagnostics.swift +++ b/Passepartout/App/Views/DiagnosticsSection.swift @@ -1,5 +1,5 @@ // -// ProfileView+Diagnostics.swift +// DiagnosticsSection.swift // Passepartout // // Created by Davide De Rosa on 3/17/23. @@ -26,20 +26,15 @@ import PassepartoutLibrary import SwiftUI -extension ProfileView { - struct DiagnosticsSection: View { - @ObservedObject var currentProfile: ObservableProfile +struct DiagnosticsSection: View { + @ObservedObject var currentProfile: ObservableProfile - var body: some View { - Section { - NavigationLink { - DiagnosticsView( - vpnProtocol: currentProfile.value.currentVPNProtocol, - providerName: currentProfile.value.header.providerName - ) - } label: { - Text(L10n.Diagnostics.title) - } + var body: some View { + Section { + NavigationLink { + DiagnosticsView(profile: currentProfile.value) + } label: { + Text(L10n.Diagnostics.title) } } } diff --git a/Passepartout/App/Views/DiagnosticsView+OpenVPN.swift b/Passepartout/App/Views/DiagnosticsView+OpenVPN.swift index 67f6cf2b..dab8a77b 100644 --- a/Passepartout/App/Views/DiagnosticsView+OpenVPN.swift +++ b/Passepartout/App/Views/DiagnosticsView+OpenVPN.swift @@ -118,7 +118,7 @@ private extension DiagnosticsView.OpenVPNView { var debugLogSection: some View { Section { - DiagnosticsView.DebugLogSection(appLogURL: appLogURL, tunnelLogURL: tunnelLogURL) + DiagnosticsView.DebugLogGroup(appLogURL: appLogURL, tunnelLogURL: tunnelLogURL) Toggle(L10n.Diagnostics.Items.MasksPrivateData.caption, isOn: $vpnManager.masksPrivateData) } header: { Text(L10n.DebugLog.title) diff --git a/Passepartout/App/Views/DiagnosticsView+WireGuard.swift b/Passepartout/App/Views/DiagnosticsView+WireGuard.swift index 74cec185..ef96db63 100644 --- a/Passepartout/App/Views/DiagnosticsView+WireGuard.swift +++ b/Passepartout/App/Views/DiagnosticsView+WireGuard.swift @@ -41,7 +41,7 @@ extension DiagnosticsView { var body: some View { List { Section { - DebugLogSection(appLogURL: appLogURL, tunnelLogURL: tunnelLogURL) + DebugLogGroup(appLogURL: appLogURL, tunnelLogURL: tunnelLogURL) } header: { Text(L10n.DebugLog.title) } diff --git a/Passepartout/App/Views/DiagnosticsView.swift b/Passepartout/App/Views/DiagnosticsView.swift index 8e9960f1..d47b5fb2 100644 --- a/Passepartout/App/Views/DiagnosticsView.swift +++ b/Passepartout/App/Views/DiagnosticsView.swift @@ -27,29 +27,52 @@ import PassepartoutLibrary import SwiftUI struct DiagnosticsView: View { - let vpnProtocol: VPNProtocolType - - let providerName: ProviderName? + let profile: Profile var body: some View { Group { - switch vpnProtocol { - case .openVPN: - DiagnosticsView.OpenVPNView( - providerName: providerName - ) - - case .wireGuard: - DiagnosticsView.WireGuardView( - providerName: providerName - ) + if !profile.isPlaceholder { + vpnView + } else { + genericView } }.navigationTitle(L10n.Diagnostics.title) } } +private extension DiagnosticsView { + var vpnView: some View { + Group { + switch profile.currentVPNProtocol { + case .openVPN: + DiagnosticsView.OpenVPNView( + providerName: profile.header.providerName + ) + + case .wireGuard: + DiagnosticsView.WireGuardView( + providerName: profile.header.providerName + ) + } + } + } + + var genericView: some View { + List { + Section { + DebugLogGroup( + appLogURL: Passepartout.shared.logger.logFile, + tunnelLogURL: nil + ) + } header: { + Text(L10n.DebugLog.title) + } + } + } +} + extension DiagnosticsView { - struct DebugLogSection: View { + struct DebugLogGroup: View { let appLogURL: URL? let tunnelLogURL: URL? @@ -65,7 +88,7 @@ extension DiagnosticsView { // MARK: - -private extension DiagnosticsView.DebugLogSection { +private extension DiagnosticsView.DebugLogGroup { var appLink: some View { navigationLink( withTitle: L10n.Diagnostics.Items.AppLog.title, diff --git a/Passepartout/App/Views/SettingsView.swift b/Passepartout/App/Views/SettingsView.swift index 73c9d390..bbe66c61 100644 --- a/Passepartout/App/Views/SettingsView.swift +++ b/Passepartout/App/Views/SettingsView.swift @@ -47,6 +47,7 @@ struct SettingsView: View { #if !targetEnvironment(macCatalyst) preferencesSection #endif + DiagnosticsSection(currentProfile: profileManager.currentProfile) aboutSection }.toolbar { themeCloseItem(presentationMode: presentationMode)