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

Make system to ask to save email+password when create ULW #657

Merged
merged 1 commit into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import SwiftUI
extension PurchaseMPCWallet {
enum NavigationDestination: Hashable {
case enterTakeoverCredentials
case enterTakeoverPassword
case enterTakeoverPassword(email: String)
case enterTakeoverCode(email: String)
case takeover(MPCTakeoverCredentials)
case almostThere
Expand All @@ -26,8 +26,8 @@ extension PurchaseMPCWallet {
switch navigationDestination {
case .enterTakeoverCredentials:
PurchaseMPCWalletTakeoverEmailInAppView()
case .enterTakeoverPassword:
PurchaseMPCWalletTakeoverPasswordInAppView()
case .enterTakeoverPassword(let email):
PurchaseMPCWalletTakeoverPasswordInAppView(email: email)
case .enterTakeoverCode(let email):
MPCEnterTakeoverCodeInAppView(email: email)
case .takeover(let credentials):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ final class PurchaseMPCWalletViewModel: ObservableObject {
self.mpcTakeoverCredentials = MPCTakeoverCredentials(email: email,
password: "",
sendRecoveryLink: true)
navPath.append(.enterTakeoverPassword)
navPath.append(.enterTakeoverPassword(email: email))
case .didEnterTakeoverPassword(let password):
self.mpcTakeoverCredentials?.password = password
guard let mpcTakeoverCredentials else { return }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ private extension MPCOnboardingPurchaseTakeoverPasswordViewController {
}

func addChildView() {
let email = OnboardingData.mpcTakeoverCredentials?.email ?? ""
let mpcView = PurchaseMPCWalletTakeoverPasswordView(analyticsName: analyticsName,
email: email,
passwordCallback: { [weak self] password in
DispatchQueue.main.async {
self?.didEnterTakeoverPassword(password)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@ struct PurchaseMPCWalletTakeoverPasswordInAppView: View {

@EnvironmentObject var viewModel: PurchaseMPCWalletViewModel

let email: String

var body: some View {
PurchaseMPCWalletTakeoverPasswordView(analyticsName: .mpcPurchaseTakeoverPasswordInApp,
email: email,
passwordCallback: didEnterTakeoverPassword)
}

Expand All @@ -27,6 +30,6 @@ private extension PurchaseMPCWalletTakeoverPasswordInAppView {

#Preview {
PresentAsModalPreviewView {
PurchaseMPCWalletTakeoverPasswordInAppView()
PurchaseMPCWalletTakeoverPasswordInAppView(email: "qq@qq.qq")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ struct PurchaseMPCWalletTakeoverPasswordView: View, UserDataValidator, MPCWallet
@Environment(\.claimMPCWalletService) private var claimMPCWalletService

let analyticsName: Analytics.ViewName
let email: String // Required to ask to save password into keychain
let passwordCallback: (String)->()
@State private var emailInput: String = ""
@State private var passwordInput: String = ""
@State private var passwordErrors: [MPCWalletPasswordValidationError] = []
@State private var confirmPasswordInput: String = ""
Expand All @@ -24,7 +26,10 @@ struct PurchaseMPCWalletTakeoverPasswordView: View, UserDataValidator, MPCWallet
VStack(spacing: isIPSE ? 16 : 32) {
headerView()
VStack(alignment: .leading, spacing: isIPSE ? 8 : 24) {
passwordInputView()
ZStack(alignment: .top) {
hiddenEmailView()
passwordInputView()
}
confirmPasswordInputView()
}
Spacer()
Expand Down Expand Up @@ -66,6 +71,7 @@ struct PurchaseMPCWalletTakeoverPasswordView: View, UserDataValidator, MPCWallet
// MARK: - Private methods
private extension PurchaseMPCWalletTakeoverPasswordView {
func onAppear() {
emailInput = email
validatePasswordInput()
}

Expand All @@ -88,6 +94,20 @@ private extension PurchaseMPCWalletTakeoverPasswordView {
}
}

@ViewBuilder
func hiddenEmailView() -> some View {
UDTextFieldView(text: $emailInput,
placeholder: "",
hint: String.Constants.emailAssociatedWithWallet.localized(),
focusBehaviour: .default,
keyboardType: .emailAddress,
autocapitalization: .never,
autocorrectionDisabled: true,
isErrorState: false)
.opacity(0.01)
.allowsHitTesting(false)
}

@ViewBuilder
func passwordInputView() -> some View {
VStack(spacing: 8) {
Expand Down Expand Up @@ -212,5 +232,6 @@ private extension PurchaseMPCWalletTakeoverPasswordView {

#Preview {
PurchaseMPCWalletTakeoverPasswordView(analyticsName: .unspecified,
email: "qq@qq.qq",
passwordCallback: { _ in })
}