-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds option + click support for our VPN menu to show some useful debu…
…g information
- Loading branch information
1 parent
21845c7
commit 30dafb0
Showing
7 changed files
with
185 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
...tionMac/Sources/NetworkProtectionUI/Views/DebugInformationView/DebugInformationView.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
// | ||
// DebugInformationView.swift | ||
// | ||
// Copyright © 2023 DuckDuckGo. All rights reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
|
||
import SwiftUI | ||
import SwiftUIExtensions | ||
import Combine | ||
import NetworkProtection | ||
|
||
public struct DebugInformationView: View { | ||
|
||
@Environment(\.colorScheme) private var colorScheme | ||
@Environment(\.isEnabled) private var isEnabled | ||
@Environment(\.dismiss) private var dismiss | ||
|
||
// MARK: - Model | ||
|
||
/// The view model that this instance will use. | ||
/// | ||
@ObservedObject var model: DebugInformationViewModel | ||
|
||
// MARK: - Initializers | ||
|
||
public init(model: DebugInformationViewModel) { | ||
self.model = model | ||
} | ||
|
||
// MARK: - View Contents | ||
|
||
public var body: some View { | ||
Group { | ||
VStack(alignment: .leading, spacing: 0) { | ||
informationRow(title: "Bundle Path", details: model.bundlePath) | ||
informationRow(title: "Version", details: model.version) | ||
} | ||
|
||
Divider() | ||
.padding(EdgeInsets(top: 5, leading: 9, bottom: 5, trailing: 9)) | ||
} | ||
} | ||
|
||
// MARK: - Composite Views | ||
|
||
private func informationRow(title: String, details: String) -> some View { | ||
VStack(spacing: 2) { | ||
HStack { | ||
Text(title) | ||
.padding(.leading, 24) | ||
.opacity(0.6) | ||
.font(.system(size: 12, weight: .bold, design: .default)) | ||
.fixedSize() | ||
|
||
Spacer() | ||
} | ||
|
||
HStack { | ||
Text(details) | ||
.makeSelectable() | ||
.multilineText() | ||
.padding(.leading, 24) | ||
.opacity(0.6) | ||
.font(.system(size: 12, weight: .regular, design: .default)) | ||
|
||
Spacer() | ||
} | ||
} | ||
.padding(EdgeInsets(top: 4, leading: 10, bottom: 4, trailing: 9)) | ||
} | ||
|
||
// MARK: - Rows | ||
|
||
private func dividerRow() -> some View { | ||
Divider() | ||
.padding(EdgeInsets(top: 5, leading: 9, bottom: 5, trailing: 9)) | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
...ac/Sources/NetworkProtectionUI/Views/DebugInformationView/DebugInformationViewModel.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// | ||
// DebugInformationViewModel.swift | ||
// | ||
// Copyright © 2023 DuckDuckGo. All rights reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
|
||
import Combine | ||
import Foundation | ||
import NetworkProtection | ||
import SwiftUI | ||
|
||
@MainActor | ||
public final class DebugInformationViewModel: ObservableObject { | ||
|
||
var bundlePath: String | ||
var version: String | ||
|
||
// MARK: - Initialization & Deinitialization | ||
|
||
public init(bundle: Bundle = .main) { | ||
bundlePath = bundle.bundlePath | ||
|
||
// swiftlint:disable:next force_cast | ||
let shortVersion = Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as! String | ||
|
||
// swiftlint:disable:next force_cast | ||
let buildNumber = Bundle.main.object(forInfoDictionaryKey: "CFBundleVersion") as! String | ||
|
||
version = shortVersion + " (build: " + buildNumber + ")" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters