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 Invite code screen PR 2 #1883

Merged
merged 34 commits into from
Aug 3, 2023
Merged

NetP Invite code screen PR 2 #1883

merged 34 commits into from
Aug 3, 2023

Conversation

graeme
Copy link
Contributor

@graeme graeme commented Jul 31, 2023

Task/Issue URL: https://app.asana.com/0/0/1205084446087083/f
BSK PR: duckduckgo/BrowserServicesKit#441
CC:

Description:

Second PR for the NetP Invite Code flow. You can find designs in the linked task above. This builds upon #1881 and adds to the existing Invite Code presentation logic in the NetworkProtectionInviteViewModel. It also fleshes out and designs the NetworkProtectionInviteView which has two states:

  • codeEntry
  • success

This also adds some tests which required some mocks / test helpers for types in the NetworkProtection library in BSK. As we will likely need these on macOS when we come to add more tests there, I added a NetworkProtectionTestUtils library to BSK. This PR points to that BSK branch so I will make sure to point to the BSK release once that’s approved. BSK PR linked above.

Steps to test this PR:

  1. Check out this branch
  2. Run the app
  3. Ensure you’re authenticated as internal
  4. Navigate to the Settings
  5. Select Network Protection
  6. If you’ve already enabled it, tap the button to clear the invite code then navigate back and select the NetP item again
  7. Enter a random string and submit it to trigger the error label.
  8. Now enter an invite code from Network Protection Invite Codes and submit it
  9. The success screen will be shown. Click Get Started to launch the status view

Copy Testing:

  • Use of correct apostrophes in new copy, ie rather than '

Orientation Testing:

  • Portrait
  • Landscape

Device Testing:

  • iPhone SE (1st Gen)
  • iPhone 8
  • iPhone X
  • iPhone 14 Pro
  • iPad

OS Testing:

  • iOS 14
  • iOS 15
  • iOS 16

Theme Testing:

  • Light theme
  • Dark theme

Internal references:

Software Engineering Expectations
Technical Design Template

@graeme graeme changed the base branch from develop to graeme/netp-invite-code-pr-1 July 31, 2023 17:14
@github-actions
Copy link

github-actions bot commented Jul 31, 2023

Warnings
⚠️ PR has more than 500 lines of code changing. Consider splitting into smaller PRs if possible.

Generated by 🚫 dangerJS against b8a6492

@graeme graeme force-pushed the graeme/netp-invite-code-pr-2 branch from f4a6d42 to 088c616 Compare July 31, 2023 17:59
@graeme graeme force-pushed the graeme/netp-invite-code-pr-1 branch from 47e63f4 to 7f5ced2 Compare July 31, 2023 18:04
@graeme graeme force-pushed the graeme/netp-invite-code-pr-2 branch from 088c616 to 2e94e51 Compare July 31, 2023 18:11
@graeme graeme force-pushed the graeme/netp-invite-code-pr-2 branch from 2e94e51 to 72c9596 Compare July 31, 2023 18:20
@graeme graeme mentioned this pull request Jul 31, 2023
13 tasks
@@ -236,43 +236,6 @@ struct AutofillLoginDetailsView: View {
}
}

struct ClearTextField: View {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes more sense in the shared DuckUI library

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This confused me a bit because it was ultimately moved to a different file right next to this one.

That's fine, but just adding a comment to make sure that was the intention.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My comment was incorrect, it was actually moved into its own file in the shared UI components folder, not library. DuckUI doesn’t seem to have much in it at all. Nonetheless, I thought it didn’t make much sense in the AutofillLoginDetailsView file when it’s now being used from a couple of places.

private static let errorEvents: EventMapping<NetworkProtectionError> = .init { _, _, _, _ in

}
private let completion: () -> Void
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Used to pop the nav stack and navigate to the status view

}

// MARK: Dev only. Will be removed during https://app.asana.com/0/0/1205084446087078/f
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was using this same ViewModel for the basic invite code entry on the status view. Rather than move it in there, I will keep these functions here for now until I’ve added a replacement, probably in the debug menu, as part of the status view subtask.


var body: some View {
let inviteViewModel = NetworkProtectionInviteViewModel(
Copy link
Contributor Author

@graeme graeme Jul 31, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not idea for now. It would be good to use a more elegant dependency injection mechanism than letting the View do it. But for now, this will do. Once the rest of the feature is more fleshed out, I’ll tidy this up.

Copy link
Contributor

@diegoreymendez diegoreymendez Aug 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's a "DI mechanism"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dependency injection (updated original comment)


import SwiftUI

final class NetworkProtectionRootViewController: UIHostingController<NetworkProtectionRootView> {
Copy link
Contributor Author

@graeme graeme Jul 31, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This subclass is needed so we can apply some styling to background of the root view. This will probably be a better place to manage the dependency injection in the future too.

@@ -64,38 +64,22 @@ struct NetworkProtectionStatusView: View {
@ViewBuilder
func inviteCodeEntry() -> some View {
Section {
VStack(alignment: .leading) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gets rid of the initial dev-designed invite entry on the dev-designed status view

let statusView = NetworkProtectionRootView()
let hostingController = UIHostingController(rootView: statusView)
hostingController.view.backgroundColor = UIColor(Color(designSystemColor: .background))
// This will be tidied up as part of https://app.asana.com/0/0/1205084446087078/f
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will probably pull this out into a presenter / launcher / router type class.

XCTAssertEqual(viewModel.currentStep, .codeEntry)
}

// Disabled this test but keeping it around to document the behaviour. It is failing inexplicably.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For some reason, errors thrown in the library are not caught in the main app. This does not apply in production, only the test environment. You can manually test this to be sure by entering an incorrect invite code.

@graeme graeme requested a review from diegoreymendez July 31, 2023 19:27
@graeme graeme marked this pull request as ready for review July 31, 2023 19:27
@graeme graeme changed the title NetP invite code pr 2 NetP Invite code screen PR 2 Jul 31, 2023
Copy link
Contributor

@diegoreymendez diegoreymendez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@graeme - Adding some comments for your consideration. The implementation looks clean and mostly to be working fine.

Please let me know what you think about my comments, so we can move ahead - if we find agreement in the comments I'd even be happy to tackle it in a follow up if you so prefer.

Additional points:

  • The invite code input screen felt like it wasn't working at first and the Submit button remained enabled for a bit allowing me to click it 3 times before it worked. I'm not sure what's behind this, but I suspect it's network related... it may be a good idea to offer some visual cue that you've submitted (maybe disable the button?).
  • I have to long-press the "Clear invite code" button for it to highlight.

"branch": null,
"revision": "f255099c2c373d7b0c484849b8903831e7b717ce",
"version": "71.0.0"
"branch": "graeme/network-protection-test-utils",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Friendly visual reminder to help you update the BSK version before merging.

{
"images" : [
{
"filename" : "Intive-Lock-Success-96.pdf",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should "Intive" be "Invite"? This typo is present apparently in several file names, but I'm adding a single note here to avoid overcluttering the PR with comments.

@@ -236,43 +236,6 @@ struct AutofillLoginDetailsView: View {
}
}

struct ClearTextField: View {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This confused me a bit because it was ultimately moved to a different file right next to this one.

That's fine, but just adding a comment to make sure that was the intention.

@graeme
Copy link
Contributor Author

graeme commented Aug 2, 2023

@diegoreymendez I’ve address the typo in the InviteLockSuccess image and I’m now disabling the textfield and submit button when the request is loading. However, I’m not going to put any work into fixing the Clear Invite Code button as it’s a development button for making testing easier and it will be removed in the next task.

Base automatically changed from graeme/netp-invite-code-pr-1 to develop August 3, 2023 08:56
@diegoreymendez
Copy link
Contributor

However, I’m not going to put any work into fixing the Clear Invite Code button as it’s a development button for making testing easier and it will be removed in the next task.

That's fine for me.

About this one though:

The invite code input screen felt like it wasn't working at first and the Submit button remained enabled for a bit allowing me to click it 3 times before it worked. I'm not sure what's behind this, but I suspect it's network related... it may be a good idea to offer some visual cue that you've submitted (maybe disable the button?).

This is also not blocking, but disabling the button may be a good way to signal to the user that a request is ongoing.

That said, since nothing is truly blocking here I'll move ahead to approve.

graeme added 4 commits August 3, 2023 11:15
Task/Issue URL: https://app.asana.com/0/0/1205084446087083/f
Description:
First PR for the NetP Invite Code flow. You can find designs in the linked task above. This first PR is just to add a root view which will choose between either the (initially empty) Invite or the Status View.
@graeme graeme merged commit c1d0cba into develop Aug 3, 2023
@graeme graeme deleted the graeme/netp-invite-code-pr-2 branch August 3, 2023 10:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants