Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NetP Design Review minus errors #1923

Merged
merged 29 commits into from
Aug 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
b242a64
Slide in invite success view
graeme Aug 15, 2023
bd58df7
Fix Share Feedback button color
graeme Aug 15, 2023
79e32f9
Removes AppTP from the settings
graeme Aug 15, 2023
840419d
Remove AppTP from Alpha builds
graeme Aug 15, 2023
4e9ca53
Include PacketTunnelProvider in Alpha builds
graeme Aug 15, 2023
4f4cbf8
Fix server info cell wrapping problem
graeme Aug 15, 2023
39b6feb
Fix toggle connecting state
graeme Aug 15, 2023
ed0b70a
Pad the header beyond the default inset
graeme Aug 15, 2023
dba3e87
Make text the correct colour
graeme Aug 15, 2023
760e521
Don't expose netP to iOS 14
graeme Aug 15, 2023
51a0c15
Hide parts of the networkprotectiondebugviewcontroller
graeme Aug 16, 2023
8d051b8
Go a little less wild on the AppTP deletion
graeme Aug 16, 2023
6858487
Tweak spacing between header elements
graeme Aug 16, 2023
1b4e529
Invite submit button should say Continue
graeme Aug 16, 2023
ead5f66
Fix primary button state
graeme Aug 16, 2023
a8849bb
Revert "Fix primary button state"
graeme Aug 16, 2023
ddf66f3
Add forgotten Localizable.strings file
graeme Aug 16, 2023
42ff0f1
Fix standard button colors
graeme Aug 16, 2023
3724e1a
Fix button disabled state
graeme Aug 16, 2023
1ee4054
On submit don't disable, prevent calling twice
graeme Aug 17, 2023
6f5019f
No press color change when disabled
graeme Aug 17, 2023
715494b
Fix icons
graeme Aug 17, 2023
1d65f07
Remove as yet unneeded strings
graeme Aug 18, 2023
50976fe
Revert "Include PacketTunnelProvider in Alpha builds"
graeme Aug 18, 2023
f3e362c
Revert "Revert "Include PacketTunnelProvider in Alpha builds""
graeme Aug 18, 2023
116a213
Package.resolve in case it helps
graeme Aug 18, 2023
de9c38a
Try removing test as a stab in the dark
graeme Aug 18, 2023
99135f7
Revert "Try removing test as a stab in the dark"
graeme Aug 18, 2023
0d90349
Fix hanging tests
graeme Aug 18, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions DuckDuckGo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -5838,7 +5838,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "# Conditionally embeds the PacketTunnelProvider extension for debug builds.\n# To be moved to the Embed App Extensions phase on release.\nif [ \"${CONFIGURATION}\" = \"Debug\" ]; then\n# Copy the extension\n cp -R \"${BUILT_PRODUCTS_DIR}/PacketTunnelProvider.appex\" \"${BUILT_PRODUCTS_DIR}/${PLUGINS_FOLDER_PATH}\"\nfi\n";
shellScript = "# Conditionally embeds the PacketTunnelProvider extension for debug builds.\n# To be moved to the Embed App Extensions phase on release.\nif [ \"${CONFIGURATION}\" = \"Debug\" ] || [ \"${CONFIGURATION}\" = \"Alpha\" ]; then\n# Copy the extension\n cp -R \"${BUILT_PRODUCTS_DIR}/PacketTunnelProvider.appex\" \"${BUILT_PRODUCTS_DIR}/${PLUGINS_FOLDER_PATH}\"\nfi\n";
};
/* End PBXShellScriptBuildPhase section */

Expand Down Expand Up @@ -8229,7 +8229,7 @@
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG APP_TRACKING_PROTECTION NETWORK_PROTECTION";
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG NETWORK_PROTECTION";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
TARGETED_DEVICE_FAMILY = "1,2";
VALID_ARCHS = "$(ARCHS_STANDARD_64_BIT)";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@
},
{
"package": "TrackerRadarKit",
"repositoryURL": "https://github.com/duckduckgo/TrackerRadarKit.git",
"repositoryURL": "https://github.com/duckduckgo/TrackerRadarKit",
"state": {
"branch": null,
"revision": "4684440d03304e7638a2c8086895367e90987463",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"images" : [
{
"filename" : "Invite-Lock-96.pdf",
"filename" : "lock-100.pdf",
"idiom" : "universal"
}
],
Expand Down
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"images" : [
{
"filename" : "Invite-Lock-Success-96.pdf",
"filename" : "lock-success-100.pdf",
"idiom" : "universal"
}
],
Expand Down
Binary file not shown.
Binary file not shown.
11 changes: 1 addition & 10 deletions DuckDuckGo/Assets.xcassets/VPN.imageset/Contents.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,7 @@
"images" : [
{
"filename" : "VPN.pdf",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
"idiom" : "universal"
}
],
"info" : {
Expand Down
11 changes: 1 addition & 10 deletions DuckDuckGo/Assets.xcassets/VPNDisabled.imageset/Contents.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,7 @@
"images" : [
{
"filename" : "VPNDisabled.pdf",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
"idiom" : "universal"
}
],
"info" : {
Expand Down
28 changes: 26 additions & 2 deletions DuckDuckGo/NetworkProtectionDebugViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,13 @@
//

import UIKit

#if NETWORK_PROTECTION

import NetworkProtection

#endif

final class NetworkProtectionDebugViewController: UITableViewController {
private let titles = [
Sections.keychain: "Keychain"
Expand All @@ -37,6 +42,15 @@ final class NetworkProtectionDebugViewController: UITableViewController {

}

enum SimulateFailureRows: Int, CaseIterable {

case tunnelFailure
case controllerFailure

}

#if NETWORK_PROTECTION

private let tokenStore: NetworkProtectionTokenStore

init?(coder: NSCoder,
Expand All @@ -51,6 +65,8 @@ final class NetworkProtectionDebugViewController: UITableViewController {
self.init(coder: coder, tokenStore: NetworkProtectionKeychainTokenStore())
}

#endif

override func numberOfSections(in tableView: UITableView) -> Int {
return Sections.allCases.count
}
Expand Down Expand Up @@ -88,12 +104,13 @@ final class NetworkProtectionDebugViewController: UITableViewController {
}
}

#if NETWORK_PROTECTION

override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
switch Sections(rawValue: indexPath.section) {
case .keychain:
switch KeychainRows(rawValue: indexPath.row) {
case .clearAuthToken:
try? tokenStore.deleteToken()
case .clearAuthToken: clearAuthToken()
default: break
}
default: break
Expand All @@ -102,4 +119,11 @@ final class NetworkProtectionDebugViewController: UITableViewController {
tableView.deselectRow(at: indexPath, animated: true)
}

// MARK: Selection Actions

private func clearAuthToken() {
try? tokenStore.deleteToken()
}

#endif
}
32 changes: 23 additions & 9 deletions DuckDuckGo/NetworkProtectionInviteView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,16 @@ struct NetworkProtectionInviteView: View {
@ObservedObject var model: NetworkProtectionInviteViewModel

var body: some View {
switch model.currentStep {
case .codeEntry:
codeEntryView
case .success:
successView
Group {
switch model.currentStep {
case .codeEntry:
codeEntryView
case .success:
successView
}
}
.transition(.slideFromRight)
.animation(.default, value: model.currentStep.isSuccess)
}

@ViewBuilder
Expand All @@ -54,12 +58,13 @@ struct NetworkProtectionInviteView: View {
.background(Color.textFieldBackground)
.cornerRadius(10)
.disabled(model.shouldDisableTextField)
Button(UserText.inviteDialogSubmitButton) {
Button(UserText.inviteDialogContinueButton) {
Task {
await model.submit()
}
}
.buttonStyle(PrimaryButtonStyle(disabled: model.shouldDisableSubmit))
.disabled(model.shouldDisableSubmit)
}
.alert(isPresented: $model.shouldShowAlert) {
Alert(
Expand Down Expand Up @@ -99,16 +104,16 @@ private struct NetworkProtectionInviteMessageView<Content>: View where Content:
Text(messageData.title)
.font(.system(size: 22, weight: .semibold))
.multilineTextAlignment(.center)
.foregroundColor(.primary)
.foregroundColor(.textPrimary)
Text(messageData.message)
.font(.system(size: 16))
.multilineTextAlignment(.center)
.foregroundColor(.secondary)
.foregroundColor(.textSecondary)
.padding(.bottom, 16)
interactiveContent()
Spacer()
Text(UserText.netPInviteOnlyMessage)
.foregroundColor(.secondary)
.foregroundColor(.textSecondary)
.font(.system(size: 13))
.multilineTextAlignment(.center)
}
Expand All @@ -128,7 +133,16 @@ private struct NetworkProtectionInviteMessageData {
let footer = UserText.netPInviteOnlyMessage
}

extension AnyTransition {
static var slideFromRight: AnyTransition {
AnyTransition.asymmetric(
insertion: .move(edge: .trailing),
removal: .move(edge: .leading))}
}

private extension Color {
static let textPrimary = Color(designSystemColor: .textPrimary)
static let textSecondary = Color(designSystemColor: .textSecondary)
static let textFieldBackground = Color(designSystemColor: .surface)
static let viewBackground = Color(designSystemColor: .background)
}
Expand Down
13 changes: 11 additions & 2 deletions DuckDuckGo/NetworkProtectionInviteViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ import NetworkProtection

enum NetworkProtectionInviteStep {
case codeEntry, success

var isSuccess: Bool {
self == .success
}
}

final class NetworkProtectionInviteViewModel: ObservableObject {
Expand All @@ -49,13 +53,18 @@ final class NetworkProtectionInviteViewModel: ObservableObject {
self.redemptionCoordinator = redemptionCoordinator
}

private var isLoading = false

@MainActor
func submit() async {
shouldDisableSubmit = true
guard !isLoading else {
return
}
isLoading = true
shouldDisableTextField = true
defer {
shouldDisableSubmit = false
shouldDisableTextField = false
isLoading = false
}
do {
try await redemptionCoordinator.redeem(text.trimmingWhitespace())
Expand Down
37 changes: 20 additions & 17 deletions DuckDuckGo/NetworkProtectionStatusView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ struct NetworkProtectionStatusView: View {
VStack(alignment: .leading, spacing: 4) {
Text(UserText.netPStatusViewTitle)
.font(.system(size: 16))
.foregroundColor(.primary)
.foregroundColor(.textPrimary)
Text(statusModel.statusMessage)
.font(.system(size: 13))
.foregroundColor(.secondary)
.foregroundColor(.textSecondary)
}

Toggle("", isOn: Binding(
Expand All @@ -58,7 +58,7 @@ struct NetworkProtectionStatusView: View {
}
))
.disabled(statusModel.shouldDisableToggle)
.toggleStyle(SwitchToggleStyle(tint: .toggleColor))
.toggleStyle(SwitchToggleStyle(tint: .controlColor))
}
.listRowBackground(Color.cellBackground)
} header: {
Expand All @@ -73,8 +73,8 @@ struct NetworkProtectionStatusView: View {
@ViewBuilder
private func header() -> some View {
HStack {
Spacer()
VStack(alignment: .center, spacing: 16) {
Spacer(minLength: 0)
VStack(alignment: .center, spacing: 8) {
Image(statusModel.statusImageID)
.resizable()
.scaledToFit()
Expand All @@ -83,15 +83,18 @@ struct NetworkProtectionStatusView: View {
Text(statusModel.headerTitle)
.font(.system(size: 17, weight: .semibold))
.multilineTextAlignment(.center)
.foregroundColor(.primary)
.foregroundColor(.textPrimary)
Text(UserText.netPStatusHeaderMessage)
.font(.system(size: 13))
.multilineTextAlignment(.center)
.foregroundColor(.secondary)
.foregroundColor(.textSecondary)
.padding(.bottom, 8)
}
.padding(.bottom, 4)
// Pads beyond the default header inset
.padding(.horizontal, -16)
.background(Color.viewBackground)
Spacer()
Spacer(minLength: 0)
}
}

Expand All @@ -113,7 +116,7 @@ struct NetworkProtectionStatusView: View {
)
}
} header: {
Text(UserText.netPStatusViewConnectionDetails).foregroundColor(.primary)
Text(UserText.netPStatusViewConnectionDetails).foregroundColor(.textPrimary)
} footer: {
inviteOnlyFooter()
}
Expand All @@ -123,8 +126,8 @@ struct NetworkProtectionStatusView: View {
private func inviteOnlyFooter() -> some View {
// Needs to be inlined like this for the markdown parsing to work
Text("\(UserText.netPInviteOnlyMessage) [\(UserText.netPStatusViewShareFeedback)](https://form.asana.com/?k=_wNLt6YcT5ILpQjDuW0Mxw&d=137249556945)")
.foregroundColor(.secondary)
.accentColor(.accentColor)
.foregroundColor(.textSecondary)
.accentColor(Color.controlColor)
.font(.system(size: 13))
.padding(.top, 6)
}
Expand All @@ -140,11 +143,11 @@ private struct NetworkProtectionServerItemView: View {
Image(imageID)
Text(title)
.font(.system(size: 16))
.foregroundColor(.primary)
Spacer()
.foregroundColor(.textPrimary)
Spacer(minLength: 2)
Text(value)
.font(.system(size: 16))
.foregroundColor(.secondary)
.foregroundColor(.textSecondary)
}
.listRowBackground(Color.cellBackground)
}
Expand Down Expand Up @@ -186,11 +189,11 @@ private extension View {
}

private extension Color {
static let titleText = Color(designSystemColor: .textPrimary)
static let messageText = Color(designSystemColor: .textSecondary)
static let textPrimary = Color(designSystemColor: .textPrimary)
static let textSecondary = Color(designSystemColor: .textSecondary)
static let cellBackground = Color(designSystemColor: .surface)
static let viewBackground = Color(designSystemColor: .background)
static let toggleColor = Color(designSystemColor: .accent)
static let controlColor = Color(designSystemColor: .accent)
}

struct NetworkProtectionStatusView_Previews: PreviewProvider {
Expand Down
Loading