forked from duckduckgo/iOS
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NetP Invite code screen PR 2 (duckduckgo#1883)
Task/Issue URL: https://app.asana.com/0/0/1205084446087083/f BSK PR: duckduckgo/BrowserServicesKit#441 Description: Second PR for the NetP Invite Code flow. You can find designs in the linked task above. This builds upon duckduckgo#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.
- Loading branch information
Showing
18 changed files
with
547 additions
and
98 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
12 changes: 12 additions & 0 deletions
12
DuckDuckGo/Assets.xcassets/InviteLock.imageset/Contents.json
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,12 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"filename" : "Invite-Lock-96.pdf", | ||
"idiom" : "universal" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
Binary file not shown.
12 changes: 12 additions & 0 deletions
12
DuckDuckGo/Assets.xcassets/InviteLockSuccess.imageset/Contents.json
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,12 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"filename" : "Invite-Lock-Success-96.pdf", | ||
"idiom" : "universal" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
Binary file added
BIN
+6.53 KB
DuckDuckGo/Assets.xcassets/InviteLockSuccess.imageset/Invite-Lock-Success-96.pdf
Binary file not shown.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// | ||
// ClearTextField.swift | ||
// DuckDuckGo | ||
// | ||
// 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 | ||
|
||
struct ClearTextField: View { | ||
var placeholderText: String | ||
@Binding var text: String | ||
var autoCapitalizationType: UITextAutocapitalizationType = .none | ||
var disableAutoCorrection = true | ||
var keyboardType: UIKeyboardType = .default | ||
var secure = false | ||
|
||
@State private var closeButtonVisible = false | ||
|
||
var body: some View { | ||
HStack { | ||
TextField(placeholderText, text: $text) { editing in | ||
closeButtonVisible = editing | ||
} onCommit: { | ||
closeButtonVisible = false | ||
} | ||
.autocapitalization(autoCapitalizationType) | ||
.disableAutocorrection(disableAutoCorrection) | ||
.keyboardType(keyboardType) | ||
.label4Style(design: secure && text.count > 0 ? .monospaced : .default) | ||
|
||
Spacer() | ||
Image("Clear-16") | ||
.opacity(closeButtonOpacity) | ||
.onTapGesture { self.text = "" } | ||
} | ||
} | ||
|
||
private var closeButtonOpacity: Double { | ||
if text == "" || !closeButtonVisible { | ||
return 0 | ||
} | ||
return 1 | ||
} | ||
} |
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
Oops, something went wrong.