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
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
617961b
Add convenience init for token store
graeme Jul 25, 2023
d7c5acf
Add a root view to choose which netp view to show
graeme Jul 25, 2023
c8b01ed
Create empty invite view
graeme Jul 26, 2023
7f5ced2
Show root and therefore invite view from settings
graeme Jul 26, 2023
e1f20e8
Add invite lock assets
graeme Jul 25, 2023
886a979
Implement initial invite view
graeme Jul 26, 2023
076e0cb
Add convenience init for redemption coordinator
graeme Jul 27, 2023
cef1497
Copy over some useful invite code from macOS
graeme Jul 27, 2023
219b29b
Remove invite entry from Status View
graeme Jul 28, 2023
6456bbf
Add some mocks and test helpers
graeme Jul 28, 2023
3c45169
Write tests + complete invite presentation logic
graeme Jul 28, 2023
eef4e9a
Add success view
graeme Jul 28, 2023
6914b2a
Replace delegation with completion handler
graeme Jul 28, 2023
27b3f09
Show an alert on error
graeme Jul 28, 2023
77c9c6f
Move ClearTextField out of Autofill
graeme Jul 28, 2023
6115e7d
Disable submit on empty string
graeme Jul 28, 2023
f3a81dc
Add submit button text
graeme Jul 28, 2023
0286d01
and the text
graeme Jul 28, 2023
598ab51
General tidy up
graeme Jul 28, 2023
c2c8f59
Pop 'n' push the root view on get started
graeme Jul 28, 2023
18dbdeb
Move mocks to BSK
graeme Jul 28, 2023
023f758
Make image correct size
graeme Jul 29, 2023
f000125
Reduce padding below message text
graeme Jul 31, 2023
196350f
Create NetPRootViewController for dark styling
graeme Jul 31, 2023
e5fbf53
Fix invite view dark text
graeme Jul 31, 2023
2429087
Remove unused colors
graeme Jul 31, 2023
e3c3b34
Add a nav title
graeme Jul 31, 2023
72c9596
Disable failing invite code error test
graeme Jul 31, 2023
4187e37
Disable user interaction on making network request
graeme Aug 2, 2023
fd3b43c
Fix typo in invite image name
graeme Aug 2, 2023
b532439
NetP invite code screen PR 1 (#1881)
graeme Aug 3, 2023
0d2dc8c
Merge remote-tracking branch 'origin/develop' into graeme/netp-invite…
graeme Aug 3, 2023
210a435
Point to updated BSK release
graeme Aug 3, 2023
b8a6492
Merge remote-tracking branch 'origin/develop' into graeme/netp-invite…
graeme Aug 3, 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
Prev Previous commit
Next Next commit
Disable submit on empty string
  • Loading branch information
graeme committed Jul 31, 2023
commit 6115e7dc01c413f694f9d24465e077271997299b
2 changes: 1 addition & 1 deletion DuckDuckGo/NetworkProtectionInviteView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ struct NetworkProtectionInviteView: View {
}, label: {
Text(UserText.appTPReportSubmit)
})
.buttonStyle(PrimaryButtonStyle())
.buttonStyle(PrimaryButtonStyle(disabled: model.shouldDisableSubmit))
.frame(height: 30)
}
.alert(isPresented: $model.shouldShowAlert) {
Expand Down
2 changes: 2 additions & 0 deletions DuckDuckGo/NetworkProtectionInviteViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,13 @@ final class NetworkProtectionInviteViewModel: ObservableObject {
didSet {
if oldValue != text {
text = text.uppercased()
shouldDisableSubmit = text.count == 0
}
}
}
var errorText: String = ""
@Published var shouldShowAlert: Bool = false
@Published var shouldDisableSubmit: Bool = true

private let redemptionCoordinator: NetworkProtectionCodeRedeeming
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

Expand Down
18 changes: 16 additions & 2 deletions DuckDuckGoTests/NetworkProtectionInviteViewModelTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,25 @@ import NetworkProtectionTestUtils
final class NetworkProtectionInviteViewModelTests: XCTestCase {

func test_text_alwaysUppercased() {
let viewModel = viewModel(withInjectedRedemptionCoordinator: .stubbed())
let viewModel = viewModel()
viewModel.text = "abcdefg"
XCTAssertEqual(viewModel.text, "ABCDEFG")
}

func test_text_emptyString_disableSubmit() {
let viewModel = viewModel()
viewModel.text = ""
XCTAssertTrue(viewModel.shouldDisableSubmit)
}

func test_text_nonEmptyString_enableSubmit() {
let viewModel = viewModel()
for _ in 0..<5 {
viewModel.text.append("D")
XCTAssertFalse(viewModel.shouldDisableSubmit)
}
}

func test_submit_successfulRedemption_changesCurrentStepToSuccess() async {
let viewModel = viewModel(withInjectedRedemptionCoordinator: .whereRedeemSucceeds())
await viewModel.submit()
Expand Down Expand Up @@ -68,7 +82,7 @@ final class NetworkProtectionInviteViewModelTests: XCTestCase {
XCTAssertTrue(didCallCompletion)
}

private func viewModel(withInjectedRedemptionCoordinator coordinator: NetworkProtectionCodeRedemptionCoordinator, completion: @escaping () -> Void = {}) -> NetworkProtectionInviteViewModel {
private func viewModel(withInjectedRedemptionCoordinator coordinator: NetworkProtectionCodeRedemptionCoordinator = .stubbed(), completion: @escaping () -> Void = {}) -> NetworkProtectionInviteViewModel {
NetworkProtectionInviteViewModel(redemptionCoordinator: coordinator, completion: completion)
}
}