Enter recovery password screen

This commit is contained in:
Ryan Zhao 2023-08-21 13:24:04 +10:00
parent 30b0620987
commit 90b2a4545c
27 changed files with 353 additions and 1 deletions

View File

@ -125,6 +125,7 @@
7B87EF442A8DA720002A0E8F /* SessionTextField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B87EF432A8DA720002A0E8F /* SessionTextField.swift */; };
7B87EF462A8DDA8E002A0E8F /* PNModeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B87EF452A8DDA8E002A0E8F /* PNModeView.swift */; };
7B87EF482A8DFBBF002A0E8F /* RecoveryPasswordView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B87EF472A8DFBBF002A0E8F /* RecoveryPasswordView.swift */; };
7B87EF4A2A92DFB4002A0E8F /* LoadAccountView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B87EF492A92DFB4002A0E8F /* LoadAccountView.swift */; };
7B8914772A7CAAE200A4C627 /* SessionHostingViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B8914762A7CAAE200A4C627 /* SessionHostingViewController.swift */; };
7B8C44C528B49DDA00FBE25F /* NewConversationVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B8C44C428B49DDA00FBE25F /* NewConversationVC.swift */; };
7B8D5FC428332600008324D9 /* VisibleMessage+Reaction.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B8D5FC328332600008324D9 /* VisibleMessage+Reaction.swift */; };
@ -1243,6 +1244,7 @@
7B87EF432A8DA720002A0E8F /* SessionTextField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SessionTextField.swift; sourceTree = "<group>"; };
7B87EF452A8DDA8E002A0E8F /* PNModeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PNModeView.swift; sourceTree = "<group>"; };
7B87EF472A8DFBBF002A0E8F /* RecoveryPasswordView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RecoveryPasswordView.swift; sourceTree = "<group>"; };
7B87EF492A92DFB4002A0E8F /* LoadAccountView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoadAccountView.swift; sourceTree = "<group>"; };
7B8914762A7CAAE200A4C627 /* SessionHostingViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SessionHostingViewController.swift; sourceTree = "<group>"; };
7B8C44C428B49DDA00FBE25F /* NewConversationVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NewConversationVC.swift; sourceTree = "<group>"; };
7B8D5FC328332600008324D9 /* VisibleMessage+Reaction.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "VisibleMessage+Reaction.swift"; sourceTree = "<group>"; };
@ -3011,6 +3013,7 @@
7B87EF412A8D9840002A0E8F /* DisplayNameView.swift */,
7B87EF452A8DDA8E002A0E8F /* PNModeView.swift */,
7B87EF472A8DFBBF002A0E8F /* RecoveryPasswordView.swift */,
7B87EF492A92DFB4002A0E8F /* LoadAccountView.swift */,
);
path = Onboarding;
sourceTree = "<group>";
@ -6166,6 +6169,7 @@
B8269D3D25C7B34D00488AB4 /* InputTextView.swift in Sources */,
7B0EFDF0275084AA00FFAAE7 /* CallMessageCell.swift in Sources */,
7B93D06A27CF173D00811CB6 /* MessageRequestsViewController.swift in Sources */,
7B87EF4A2A92DFB4002A0E8F /* LoadAccountView.swift in Sources */,
C3AAFFF225AE99710089E6DD /* AppDelegate.swift in Sources */,
B8BB82A5238F627000BA5194 /* HomeVC.swift in Sources */,
4521C3C01F59F3BA00B4C582 /* TextFieldHelper.swift in Sources */,

View File

@ -673,3 +673,7 @@
"home_empty_state_welcome" = "Welcome to Session";
"home_empty_state_no_conversation" = "You don't have any conversations yet";
"home_empty_state_instruction" = "Hit the plus button to start a chat, create a group, or join an official communitiy!";
"onboarding_recovery_password_tab_title" = "Recovery Password";
"onboarding_recovery_password_tab_explanation" = "To load your account, enter the recovery password that was given to you when you signed up.";
"onboarding_recovery_password_hint" = "Enter your recovery password";
"onboarding_load_account_title" = "Load Account";

View File

@ -673,3 +673,7 @@
"home_empty_state_welcome" = "Welcome to Session";
"home_empty_state_no_conversation" = "You don't have any conversations yet";
"home_empty_state_instruction" = "Hit the plus button to start a chat, create a group, or join an official communitiy!";
"onboarding_recovery_password_tab_title" = "Recovery Password";
"onboarding_recovery_password_tab_explanation" = "To load your account, enter the recovery password that was given to you when you signed up.";
"onboarding_recovery_password_hint" = "Enter your recovery password";
"onboarding_load_account_title" = "Load Account";

View File

@ -673,3 +673,7 @@
"home_empty_state_welcome" = "Welcome to Session";
"home_empty_state_no_conversation" = "You don't have any conversations yet";
"home_empty_state_instruction" = "Hit the plus button to start a chat, create a group, or join an official communitiy!";
"onboarding_recovery_password_tab_title" = "Recovery Password";
"onboarding_recovery_password_tab_explanation" = "To load your account, enter the recovery password that was given to you when you signed up.";
"onboarding_recovery_password_hint" = "Enter your recovery password";
"onboarding_load_account_title" = "Load Account";

View File

@ -673,3 +673,7 @@
"home_empty_state_welcome" = "Welcome to Session";
"home_empty_state_no_conversation" = "You don't have any conversations yet";
"home_empty_state_instruction" = "Hit the plus button to start a chat, create a group, or join an official communitiy!";
"onboarding_recovery_password_tab_title" = "Recovery Password";
"onboarding_recovery_password_tab_explanation" = "To load your account, enter the recovery password that was given to you when you signed up.";
"onboarding_recovery_password_hint" = "Enter your recovery password";
"onboarding_load_account_title" = "Load Account";

View File

@ -673,3 +673,7 @@
"home_empty_state_welcome" = "Welcome to Session";
"home_empty_state_no_conversation" = "You don't have any conversations yet";
"home_empty_state_instruction" = "Hit the plus button to start a chat, create a group, or join an official communitiy!";
"onboarding_recovery_password_tab_title" = "Recovery Password";
"onboarding_recovery_password_tab_explanation" = "To load your account, enter the recovery password that was given to you when you signed up.";
"onboarding_recovery_password_hint" = "Enter your recovery password";
"onboarding_load_account_title" = "Load Account";

View File

@ -673,3 +673,7 @@
"home_empty_state_welcome" = "Welcome to Session";
"home_empty_state_no_conversation" = "You don't have any conversations yet";
"home_empty_state_instruction" = "Hit the plus button to start a chat, create a group, or join an official communitiy!";
"onboarding_recovery_password_tab_title" = "Recovery Password";
"onboarding_recovery_password_tab_explanation" = "To load your account, enter the recovery password that was given to you when you signed up.";
"onboarding_recovery_password_hint" = "Enter your recovery password";
"onboarding_load_account_title" = "Load Account";

View File

@ -673,3 +673,7 @@
"home_empty_state_welcome" = "Welcome to Session";
"home_empty_state_no_conversation" = "You don't have any conversations yet";
"home_empty_state_instruction" = "Hit the plus button to start a chat, create a group, or join an official communitiy!";
"onboarding_recovery_password_tab_title" = "Recovery Password";
"onboarding_recovery_password_tab_explanation" = "To load your account, enter the recovery password that was given to you when you signed up.";
"onboarding_recovery_password_hint" = "Enter your recovery password";
"onboarding_load_account_title" = "Load Account";

View File

@ -673,3 +673,7 @@
"home_empty_state_welcome" = "Welcome to Session";
"home_empty_state_no_conversation" = "You don't have any conversations yet";
"home_empty_state_instruction" = "Hit the plus button to start a chat, create a group, or join an official communitiy!";
"onboarding_recovery_password_tab_title" = "Recovery Password";
"onboarding_recovery_password_tab_explanation" = "To load your account, enter the recovery password that was given to you when you signed up.";
"onboarding_recovery_password_hint" = "Enter your recovery password";
"onboarding_load_account_title" = "Load Account";

View File

@ -673,3 +673,7 @@
"home_empty_state_welcome" = "Welcome to Session";
"home_empty_state_no_conversation" = "You don't have any conversations yet";
"home_empty_state_instruction" = "Hit the plus button to start a chat, create a group, or join an official communitiy!";
"onboarding_recovery_password_tab_title" = "Recovery Password";
"onboarding_recovery_password_tab_explanation" = "To load your account, enter the recovery password that was given to you when you signed up.";
"onboarding_recovery_password_hint" = "Enter your recovery password";
"onboarding_load_account_title" = "Load Account";

View File

@ -673,3 +673,7 @@
"home_empty_state_welcome" = "Welcome to Session";
"home_empty_state_no_conversation" = "You don't have any conversations yet";
"home_empty_state_instruction" = "Hit the plus button to start a chat, create a group, or join an official communitiy!";
"onboarding_recovery_password_tab_title" = "Recovery Password";
"onboarding_recovery_password_tab_explanation" = "To load your account, enter the recovery password that was given to you when you signed up.";
"onboarding_recovery_password_hint" = "Enter your recovery password";
"onboarding_load_account_title" = "Load Account";

View File

@ -673,3 +673,7 @@
"home_empty_state_welcome" = "Welcome to Session";
"home_empty_state_no_conversation" = "You don't have any conversations yet";
"home_empty_state_instruction" = "Hit the plus button to start a chat, create a group, or join an official communitiy!";
"onboarding_recovery_password_tab_title" = "Recovery Password";
"onboarding_recovery_password_tab_explanation" = "To load your account, enter the recovery password that was given to you when you signed up.";
"onboarding_recovery_password_hint" = "Enter your recovery password";
"onboarding_load_account_title" = "Load Account";

View File

@ -673,3 +673,7 @@
"home_empty_state_welcome" = "Welcome to Session";
"home_empty_state_no_conversation" = "You don't have any conversations yet";
"home_empty_state_instruction" = "Hit the plus button to start a chat, create a group, or join an official communitiy!";
"onboarding_recovery_password_tab_title" = "Recovery Password";
"onboarding_recovery_password_tab_explanation" = "To load your account, enter the recovery password that was given to you when you signed up.";
"onboarding_recovery_password_hint" = "Enter your recovery password";
"onboarding_load_account_title" = "Load Account";

View File

@ -673,3 +673,7 @@
"home_empty_state_welcome" = "Welcome to Session";
"home_empty_state_no_conversation" = "You don't have any conversations yet";
"home_empty_state_instruction" = "Hit the plus button to start a chat, create a group, or join an official communitiy!";
"onboarding_recovery_password_tab_title" = "Recovery Password";
"onboarding_recovery_password_tab_explanation" = "To load your account, enter the recovery password that was given to you when you signed up.";
"onboarding_recovery_password_hint" = "Enter your recovery password";
"onboarding_load_account_title" = "Load Account";

View File

@ -673,3 +673,7 @@
"home_empty_state_welcome" = "Welcome to Session";
"home_empty_state_no_conversation" = "You don't have any conversations yet";
"home_empty_state_instruction" = "Hit the plus button to start a chat, create a group, or join an official communitiy!";
"onboarding_recovery_password_tab_title" = "Recovery Password";
"onboarding_recovery_password_tab_explanation" = "To load your account, enter the recovery password that was given to you when you signed up.";
"onboarding_recovery_password_hint" = "Enter your recovery password";
"onboarding_load_account_title" = "Load Account";

View File

@ -673,3 +673,7 @@
"home_empty_state_welcome" = "Welcome to Session";
"home_empty_state_no_conversation" = "You don't have any conversations yet";
"home_empty_state_instruction" = "Hit the plus button to start a chat, create a group, or join an official communitiy!";
"onboarding_recovery_password_tab_title" = "Recovery Password";
"onboarding_recovery_password_tab_explanation" = "To load your account, enter the recovery password that was given to you when you signed up.";
"onboarding_recovery_password_hint" = "Enter your recovery password";
"onboarding_load_account_title" = "Load Account";

View File

@ -673,3 +673,7 @@
"home_empty_state_welcome" = "Welcome to Session";
"home_empty_state_no_conversation" = "You don't have any conversations yet";
"home_empty_state_instruction" = "Hit the plus button to start a chat, create a group, or join an official communitiy!";
"onboarding_recovery_password_tab_title" = "Recovery Password";
"onboarding_recovery_password_tab_explanation" = "To load your account, enter the recovery password that was given to you when you signed up.";
"onboarding_recovery_password_hint" = "Enter your recovery password";
"onboarding_load_account_title" = "Load Account";

View File

@ -673,3 +673,7 @@
"home_empty_state_welcome" = "Welcome to Session";
"home_empty_state_no_conversation" = "You don't have any conversations yet";
"home_empty_state_instruction" = "Hit the plus button to start a chat, create a group, or join an official communitiy!";
"onboarding_recovery_password_tab_title" = "Recovery Password";
"onboarding_recovery_password_tab_explanation" = "To load your account, enter the recovery password that was given to you when you signed up.";
"onboarding_recovery_password_hint" = "Enter your recovery password";
"onboarding_load_account_title" = "Load Account";

View File

@ -673,3 +673,7 @@
"home_empty_state_welcome" = "Welcome to Session";
"home_empty_state_no_conversation" = "You don't have any conversations yet";
"home_empty_state_instruction" = "Hit the plus button to start a chat, create a group, or join an official communitiy!";
"onboarding_recovery_password_tab_title" = "Recovery Password";
"onboarding_recovery_password_tab_explanation" = "To load your account, enter the recovery password that was given to you when you signed up.";
"onboarding_recovery_password_hint" = "Enter your recovery password";
"onboarding_load_account_title" = "Load Account";

View File

@ -673,3 +673,7 @@
"home_empty_state_welcome" = "Welcome to Session";
"home_empty_state_no_conversation" = "You don't have any conversations yet";
"home_empty_state_instruction" = "Hit the plus button to start a chat, create a group, or join an official communitiy!";
"onboarding_recovery_password_tab_title" = "Recovery Password";
"onboarding_recovery_password_tab_explanation" = "To load your account, enter the recovery password that was given to you when you signed up.";
"onboarding_recovery_password_hint" = "Enter your recovery password";
"onboarding_load_account_title" = "Load Account";

View File

@ -673,3 +673,7 @@
"home_empty_state_welcome" = "Welcome to Session";
"home_empty_state_no_conversation" = "You don't have any conversations yet";
"home_empty_state_instruction" = "Hit the plus button to start a chat, create a group, or join an official communitiy!";
"onboarding_recovery_password_tab_title" = "Recovery Password";
"onboarding_recovery_password_tab_explanation" = "To load your account, enter the recovery password that was given to you when you signed up.";
"onboarding_recovery_password_hint" = "Enter your recovery password";
"onboarding_load_account_title" = "Load Account";

View File

@ -673,3 +673,7 @@
"home_empty_state_welcome" = "Welcome to Session";
"home_empty_state_no_conversation" = "You don't have any conversations yet";
"home_empty_state_instruction" = "Hit the plus button to start a chat, create a group, or join an official communitiy!";
"onboarding_recovery_password_tab_title" = "Recovery Password";
"onboarding_recovery_password_tab_explanation" = "To load your account, enter the recovery password that was given to you when you signed up.";
"onboarding_recovery_password_hint" = "Enter your recovery password";
"onboarding_load_account_title" = "Load Account";

View File

@ -673,3 +673,7 @@
"home_empty_state_welcome" = "Welcome to Session";
"home_empty_state_no_conversation" = "You don't have any conversations yet";
"home_empty_state_instruction" = "Hit the plus button to start a chat, create a group, or join an official communitiy!";
"onboarding_recovery_password_tab_title" = "Recovery Password";
"onboarding_recovery_password_tab_explanation" = "To load your account, enter the recovery password that was given to you when you signed up.";
"onboarding_recovery_password_hint" = "Enter your recovery password";
"onboarding_load_account_title" = "Load Account";

View File

@ -35,7 +35,6 @@ struct DisplayNameView: View {
.bold()
.font(.system(size: Values.veryLargeFontSize))
.foregroundColor(themeColor: .textPrimary)
.padding(.vertical, Values.mediumSpacing)
Text("onboarding_display_name_explanation".localized())
.font(.system(size: Values.smallFontSize))

View File

@ -118,7 +118,11 @@ struct LandingView: View {
}
private func restore() {
Onboarding.Flow.register.unregister()
let viewController: SessionHostingViewController = SessionHostingViewController(rootView: LoadAccountView())
viewController.setNavBarTitle("onboarding_load_account_title".localized())
self.host.controller?.navigationController?.pushViewController(viewController, animated: true)
}
}

View File

@ -0,0 +1,207 @@
// Copyright © 2023 Rangeproof Pty Ltd. All rights reserved.
import SwiftUI
import SessionUIKit
import SignalUtilitiesKit
import SessionUtilitiesKit
struct LoadAccountView: View {
@EnvironmentObject var host: HostWrapper
@State var tabIndex = 0
@State private var recoveryPassword: String = ""
var body: some View {
NavigationView {
ZStack(alignment: .topLeading) {
if #available(iOS 14.0, *) {
ThemeManager.currentTheme.colorSwiftUI(for: .backgroundPrimary).ignoresSafeArea()
} else {
ThemeManager.currentTheme.colorSwiftUI(for: .backgroundPrimary)
}
VStack(
spacing: 0
){
CustomTopTabBar(tabIndex: $tabIndex)
.frame(maxWidth: .infinity)
if tabIndex == 0 {
EnterRecoveryPasswordView($recoveryPassword)
}
else {
ScanQRCodeView()
}
}
}
}
}
func continueWithSeed(_ seed: Data, onError: (() -> ())?) {
if (seed.count != 16) {
let modal: ConfirmationModal = ConfirmationModal(
info: ConfirmationModal.Info(
title: "invalid_recovery_phrase".localized(),
body: .text("INVALID_RECOVERY_PHRASE_MESSAGE".localized()),
cancelTitle: "BUTTON_OK".localized(),
cancelStyle: .alert_text,
afterClosed: onError
)
)
self.host.controller?.present(modal, animated: true)
return
}
let (ed25519KeyPair, x25519KeyPair) = try! Identity.generate(from: seed)
Onboarding.Flow.link
.preregister(
with: seed,
ed25519KeyPair: ed25519KeyPair,
x25519KeyPair: x25519KeyPair
)
// Otherwise continue on to request push notifications permissions
let viewController: SessionHostingViewController = SessionHostingViewController(rootView: PNModeView(flow: .link))
viewController.setUpNavBarSessionIcon()
self.host.controller?.navigationController?.pushViewController(viewController, animated: true)
}
}
struct TabBarButton: View {
@Binding var isSelected: Bool
let text: String
var body: some View {
ZStack(
alignment: .bottom
) {
Text(text)
.bold()
.font(.system(size: Values.mediumFontSize))
.foregroundColor(themeColor: .textPrimary)
.padding(.bottom, 5)
.frame(
maxWidth: .infinity,
maxHeight: .infinity
)
if isSelected {
Rectangle()
.foregroundColor(themeColor: .primary)
.frame(
maxWidth: .infinity,
maxHeight: 5
)
.padding(.horizontal, Values.verySmallSpacing)
}
}
}
}
struct CustomTopTabBar: View {
@Binding var tabIndex: Int
private static let height = isIPhone5OrSmaller ? CGFloat(32) : CGFloat(48)
var body: some View {
HStack(spacing: 0) {
TabBarButton(
isSelected: .constant(tabIndex == 0),
text: "onboarding_recovery_password_tab_title".localized()
)
.onTapGesture { onButtonTapped(index: 0) }
TabBarButton(
isSelected: .constant(tabIndex == 1),
text: "vc_qr_code_view_scan_qr_code_tab_title".localized()
)
.onTapGesture { onButtonTapped(index: 1) }
}
.frame(
maxWidth: .infinity,
maxHeight: Self.height
)
.border(width: 1, edges: [.bottom], color: .borderSeparator)
}
private func onButtonTapped(index: Int) {
withAnimation(.easeInOut(duration: 0.2)) {
tabIndex = index
}
}
}
struct EnterRecoveryPasswordView: View{
@Binding var recoveryPassword: String
init(_ recoveryPassword: Binding<String>) {
self._recoveryPassword = recoveryPassword
}
var body: some View{
ZStack(alignment: .center) {
VStack(
alignment: .leading,
spacing: Values.mediumSpacing
) {
Spacer()
Text("onboarding_recovery_password_tab_title".localized())
.bold()
.font(.system(size: Values.veryLargeFontSize))
.foregroundColor(themeColor: .textPrimary)
Text("onboarding_recovery_password_tab_explanation".localized())
.font(.system(size: Values.smallFontSize))
.foregroundColor(themeColor: .textPrimary)
.padding(.vertical, Values.mediumSpacing)
SessionTextField(
$recoveryPassword,
placeholder: "onboarding_recovery_password_hint".localized()
)
Spacer()
}
.padding(.horizontal, Values.veryLargeSpacing)
.padding(.bottom, Values.massiveSpacing + Values.largeButtonHeight)
VStack() {
Spacer()
Button {
} label: {
Text("continue_2".localized())
.bold()
.font(.system(size: Values.smallFontSize))
.foregroundColor(themeColor: .sessionButton_text)
.frame(
maxWidth: .infinity,
maxHeight: Values.largeButtonHeight,
alignment: .center
)
.overlay(
Capsule()
.stroke(themeColor: .sessionButton_border)
)
}
.padding(.horizontal, Values.massiveSpacing)
}
.padding(.vertical, Values.mediumSpacing)
}
}
}
struct ScanQRCodeView: View{
var body: some View{
ZStack{
}
}
}
struct LoadAccountView_Previews: PreviewProvider {
static var previews: some View {
LoadAccountView()
}
}

View File

@ -35,3 +35,53 @@ extension UIViewController {
self.present(toPresent, animated: true, completion: nil)
}
}
struct EdgeBorder: Shape {
var width: CGFloat
var edges: [Edge]
func path(in rect: CGRect) -> Path {
var path = Path()
for edge in edges {
var x: CGFloat {
switch edge {
case .top, .bottom, .leading: return rect.minX
case .trailing: return rect.maxX - width
}
}
var y: CGFloat {
switch edge {
case .top, .leading, .trailing: return rect.minY
case .bottom: return rect.maxY - width
}
}
var w: CGFloat {
switch edge {
case .top, .bottom: return rect.width
case .leading, .trailing: return self.width
}
}
var h: CGFloat {
switch edge {
case .top, .bottom: return self.width
case .leading, .trailing: return rect.height
}
}
path.addPath(Path(CGRect(x: x, y: y, width: w, height: h)))
}
return path
}
}
extension View {
public func border(width: CGFloat, edges: [Edge], color: ThemeValue) -> some View {
overlay(
EdgeBorder(width: width, edges: edges)
.foregroundColor(themeColor: color)
)
}
}