save recovery password screen

pull/891/head
ryanzhao 2 years ago
parent 87b84d0819
commit 69879f776a

@ -0,0 +1,12 @@
{
"images" : [
{
"filename" : "session_shield.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

@ -0,0 +1,211 @@
%PDF-1.7
1 0 obj
<< >>
endobj
2 0 obj
<< /Length 3 0 R >>
stream
/DeviceRGB CS
/DeviceRGB cs
q
1.000000 0.000000 -0.000000 1.000000 0.000000 0.000000 cm
1.000000 1.000000 1.000000 scn
49.334633 126.950821 m
50.829327 127.642830 52.390945 128.000000 53.974873 128.000000 c
53.997185 127.955353 l
55.536495 127.955353 57.053493 127.620506 58.570499 126.928497 c
60.422134 126.057899 62.318382 125.231949 64.214638 124.405998 c
66.400909 123.446114 l
76.685280 118.847580 l
80.033569 117.359520 83.381859 115.867729 86.731674 114.375259 c
91.572937 112.218292 96.417389 110.059906 101.269630 107.909317 c
105.842949 105.877922 108.341537 101.748169 107.962288 96.948730 c
107.933403 96.688660 107.941917 96.335075 107.951515 95.936394 c
107.951515 95.936325 l
107.951515 95.936249 l
107.956741 95.718994 107.962288 95.488365 107.962288 95.252182 c
107.984596 94.694107 107.984596 94.113708 107.984596 93.444016 c
107.917671 87.349838 107.917671 81.144058 107.984596 75.049881 c
107.984596 74.938263 l
107.962288 74.826645 l
107.962288 72.705963 l
107.961945 72.673149 l
107.961945 72.672882 l
107.961945 72.672630 l
107.939751 70.518188 107.917336 68.342102 107.850746 66.232300 c
107.739204 60.629227 106.668373 55.316360 105.731407 51.320549 c
105.664482 51.052666 l
105.575241 50.784790 l
104.772125 48.061386 103.857460 45.159393 102.675095 42.168114 c
101.091164 38.239273 99.016434 34.198807 96.317070 29.801178 c
96.205528 29.622604 l
96.071678 29.444016 l
92.881516 24.756180 89.914436 21.095222 86.746574 17.903038 c
81.548607 12.679451 75.681389 8.393440 69.278748 5.111969 c
69.178497 5.056236 69.072678 4.994934 68.966858 4.933632 c
68.966423 4.933380 l
68.965988 4.933128 l
68.860168 4.871826 68.754349 4.810524 68.654099 4.754791 c
68.319466 4.576210 l
67.984840 4.419945 l
64.861595 3.035927 61.136017 1.495636 57.053493 0.401817 c
56.964256 0.357162 l
56.875023 0.357162 l
55.893436 0.111610 54.889542 0.000000 53.930260 0.000000 c
52.970978 0.000000 51.989388 0.111618 50.940872 0.379494 c
47.126060 1.384033 43.244320 2.835014 39.407196 4.687828 c
39.340267 4.754791 l
39.273342 4.754791 l
28.319698 10.246246 19.217686 18.371811 12.212705 28.885933 c
11.900382 29.243111 l
11.565749 29.801178 l
9.134084 33.796997 7.304758 37.279388 5.810065 40.739449 c
4.586080 43.604507 3.683306 46.405296 2.808020 49.120804 c
2.753752 49.289154 l
2.419119 50.316010 l
2.262958 50.829437 l
2.151414 51.342865 l
2.084486 51.677719 2.017557 52.006996 1.950629 52.336266 c
1.950608 52.336380 l
1.950587 52.336494 l
1.883676 52.665672 1.816765 52.994850 1.749854 53.329613 c
1.699232 53.575539 l
1.699219 53.575607 l
1.246317 55.775368 0.780141 58.039604 0.500559 60.428322 c
0.003261 64.347023 0.006351 68.073151 0.009311 71.642471 c
0.009538 71.916031 0.009764 72.188675 0.009764 72.460411 c
0.009764 73.509590 l
0.009764 74.982910 l
0.009764 93.622604 l
0.009764 95.453087 l
0.009764 95.752060 0.012395 96.043137 0.014946 96.325409 c
0.019824 96.865105 0.024412 97.372620 0.009764 97.841644 c
-0.168707 102.172302 2.106796 105.833275 6.233933 107.730728 c
10.627651 109.683487 15.015795 111.636246 19.403938 113.589012 c
19.408436 113.591011 l
23.797327 115.544106 28.186220 117.497200 32.580688 119.450294 c
40.544949 122.999649 l
40.879578 123.155914 l
41.437302 123.423790 l
41.615772 123.513077 l
41.957554 123.664192 42.302170 123.818146 42.648605 123.972908 c
42.648685 123.972946 l
43.274567 124.252548 43.906399 124.534805 44.538231 124.807816 c
45.005077 125.015434 45.471924 125.221169 45.938225 125.426659 c
47.076279 125.928185 48.211067 126.428268 49.334633 126.950821 c
h
60.731567 69.257278 m
71.137421 63.562317 l
73.491379 62.273079 75.453232 60.385086 76.819412 58.094208 c
78.185593 55.803337 78.906326 53.193054 78.906830 50.534210 c
78.902847 46.884987 77.433609 43.386353 74.821503 40.805969 c
72.209389 38.225578 68.667755 36.774185 64.973663 36.770248 c
40.347225 36.770248 l
38.875854 36.753342 37.415718 37.025024 36.051395 37.569557 c
34.687077 38.114090 33.445698 38.920647 32.399181 39.942505 c
31.352661 40.964355 30.521807 42.181190 29.954748 43.522522 c
29.387691 44.863846 29.095703 46.302994 29.095703 47.756592 c
29.095703 49.210190 29.387691 50.649338 29.954748 51.990662 c
30.521807 53.331993 31.352661 54.548828 32.399181 55.570679 c
33.445698 56.592537 34.687077 57.399094 36.051395 57.943619 c
37.415718 58.488159 38.875854 58.759834 40.347225 58.742928 c
47.409363 58.742928 l
37.002003 64.439384 l
34.646851 65.727890 32.683659 67.615532 31.316151 69.906418 c
29.948641 72.197304 29.226643 74.807968 29.225073 77.467491 c
29.229452 81.116592 30.698812 84.614990 33.310841 87.195297 c
35.922867 89.775604 39.464275 91.227119 43.158237 91.231445 c
67.784683 91.231445 l
70.734459 91.231445 73.563416 90.073883 75.649231 88.013405 c
77.735031 85.952927 78.906830 83.158318 78.906830 80.244362 c
78.906830 77.330414 77.735031 74.535805 75.649231 72.475327 c
73.563416 70.414848 70.734459 69.257278 67.784683 69.257278 c
60.731567 69.257278 l
h
34.352322 71.519341 m
35.402977 69.803688 36.889698 68.389404 38.664833 67.416939 c
52.351204 59.930679 l
52.351204 71.139252 l
52.350403 71.541809 52.511208 71.928253 52.798370 72.213882 c
53.085529 72.499504 53.475616 72.660995 53.883114 72.662964 c
67.784683 72.662964 l
68.824905 72.663940 69.854095 72.873550 70.809875 73.279106 c
71.765656 73.684662 72.628113 74.277702 73.345001 75.022301 c
74.061890 75.766891 74.618263 76.647530 74.980400 77.610840 c
75.342529 78.574142 75.502892 79.600067 75.451752 80.626404 c
75.247101 84.705498 71.691200 87.827248 67.561966 87.827248 c
43.423084 87.827248 l
37.504612 87.827248 32.535683 83.042053 32.675632 77.196945 c
32.723633 75.192329 33.301666 73.235001 34.352322 71.519341 c
h
40.569939 40.174454 m
64.708817 40.174454 l
70.628799 40.174454 75.597725 44.959648 75.457779 50.797325 c
75.410927 52.803360 74.833282 54.762321 73.782288 56.479401 c
72.731293 58.196487 71.243576 59.611855 69.467072 60.584763 c
55.789726 68.071014 l
55.789726 56.860962 l
55.789925 56.661125 55.750252 56.463211 55.672981 56.278534 c
55.595703 56.093857 55.482338 55.926041 55.339371 55.784668 c
55.196404 55.643295 55.026630 55.531143 54.839760 55.454636 c
54.652885 55.378113 54.452583 55.338730 54.250290 55.338730 c
40.347225 55.338730 l
39.306999 55.337570 38.277840 55.127762 37.322128 54.722031 c
36.366421 54.316299 35.504063 53.723083 34.787315 52.978348 c
34.070572 52.233612 33.514370 51.352867 33.152420 50.389481 c
32.790470 49.426102 32.630310 48.400146 32.681652 47.373810 c
32.884804 43.296204 36.442207 40.174454 40.569939 40.174454 c
h
f*
n
Q
endstream
endobj
3 0 obj
6513
endobj
4 0 obj
<< /Annots []
/Type /Page
/MediaBox [ 0.000000 0.000000 108.000000 128.000000 ]
/Resources 1 0 R
/Contents 2 0 R
/Parent 5 0 R
>>
endobj
5 0 obj
<< /Kids [ 4 0 R ]
/Count 1
/Type /Pages
>>
endobj
6 0 obj
<< /Pages 5 0 R
/Type /Catalog
>>
endobj
xref
0 7
0000000000 65535 f
0000000010 00000 n
0000000034 00000 n
0000006603 00000 n
0000006626 00000 n
0000006801 00000 n
0000006875 00000 n
trailer
<< /ID [ (some) (id) ]
/Root 6 0 R
/Size 7
>>
startxref
6934
%%EOF

@ -666,6 +666,6 @@
"privacy_policy" = "Privacy Policy";
"onboarding_display_name_explanation" = "It can be your real name, an alias, or anything else you like — and you can change it any time.";
"onboarding_display_name_hint" = "Enter your display name";
"onboarding_recovery_password_title" = "Save your recovery password";
"onboarding_recovery_password_title" = "Save your\nrecovery password";
"onboarding_recovery_password_explanation" = "Use your password to load your account on new devices. Make sure it is stored in a safe place — and don't share it with anyone.";
"tap_to_copy" = "Tap to copy";

@ -82,7 +82,6 @@ struct DisplayNameView: View {
private func register() {
func showError(title: String, message: String = "") {
let modal: ConfirmationModal = ConfirmationModal(
targetView: self.host.controller?.view,
info: ConfirmationModal.Info(
title: title,
body: .text(message),
@ -111,9 +110,8 @@ struct DisplayNameView: View {
guard self.flow == .register else {
self.flow.completeRegistration()
// Go to the home screen
let homeVC: HomeVC = HomeVC()
self.host.controller?.navigationController?.setViewControllers([ homeVC ], animated: true)
// TODO: Go to the loading screen
return
}

@ -107,7 +107,56 @@ struct PNModeView: View {
}
private func register() {
UserDefaults.standard[.isUsingFullAPNs] = (currentSelection == .fast)
// If we are registering then we can just continue on
guard flow != .register else {
self.flow.completeRegistration()
// Go to recovery password screen
if let recoveryPasswordView = try? RecoveryPasswordView() {
let viewController: SessionHostingViewController = SessionHostingViewController(rootView: recoveryPasswordView)
viewController.setUpNavBarSessionIcon()
self.host.controller?.navigationController?.pushViewController(viewController, animated: true)
} else {
let modal = ConfirmationModal(
targetView: self.host.controller?.view,
info: ConfirmationModal.Info(
title: "ALERT_ERROR_TITLE".localized(),
body: .text("LOAD_RECOVERY_PASSWORD_ERROR".localized()),
cancelTitle: "BUTTON_OK".localized(),
cancelStyle: .alert_text
)
)
self.host.controller?.present(modal, animated: true)
}
return
}
// Check if we already have a profile name (ie. profile retrieval completed while waiting on
// this screen)
let existingProfileName: String? = Storage.shared
.read { db in
try Profile
.filter(id: getUserHexEncodedPublicKey(db))
.select(.name)
.asRequest(of: String.self)
.fetchOne(db)
}
guard existingProfileName?.isEmpty != false else {
// If we have one then we can go straight to the home screen
self.flow.completeRegistration()
// Go to the home screen
let homeVC: HomeVC = HomeVC()
self.host.controller?.navigationController?.setViewControllers([ homeVC ], animated: true)
return
}
// TODO: If we don't have one then show a loading indicator and try to retrieve the existing name
}
}

@ -8,6 +8,7 @@ import SessionUtilitiesKit
struct RecoveryPasswordView: View {
@EnvironmentObject var host: HostWrapper
@State private var copied: Bool = false
private let mnemonic: String
static let cornerRadius: CGFloat = 13
@ -35,19 +36,34 @@ struct RecoveryPasswordView: View {
) {
Spacer()
Text("onboarding_recovery_password_title".localized())
.bold()
.font(.system(size: Values.veryLargeFontSize))
.foregroundColor(themeColor: .textPrimary)
.padding(.vertical, Values.mediumSpacing)
HStack(
alignment: .bottom,
spacing: Values.smallSpacing
) {
Text("onboarding_recovery_password_title".localized())
.bold()
.font(.system(size: Values.veryLargeFontSize))
.foregroundColor(themeColor: .textPrimary)
Image("SessionShield")
.resizable()
.renderingMode(.template)
.foregroundColor(themeColor: .textPrimary)
.scaledToFit()
.frame(
maxWidth: Values.largeFontSize,
maxHeight: Values.largeFontSize
)
.padding(.bottom, Values.verySmallSpacing)
}
Text("onboarding_recovery_password_explanation".localized())
.font(.system(size: Values.smallFontSize))
.foregroundColor(themeColor: .textPrimary)
.padding(.vertical, Values.mediumSpacing)
Text(mnemonic)
.font(.spaceMono(size: Values.verySmallFontSize))
.multilineTextAlignment(.center)
.foregroundColor(themeColor: .primary)
.padding(.all, Values.largeSpacing)
.overlay(
@ -61,9 +77,10 @@ struct RecoveryPasswordView: View {
)
Button {
copyRecoveryPassword()
} label: {
Text("tap_to_copy".localized())
let buttonTitle: String = self.copied ? "copied".localized() : "tap_to_copy".localized()
Text(buttonTitle)
.font(.system(size: Values.verySmallFontSize))
.foregroundColor(themeColor: .textSecondary)
}
@ -78,7 +95,7 @@ struct RecoveryPasswordView: View {
Spacer()
Button {
finishRegister()
} label: {
Text("continue_2".localized())
.bold()
@ -100,10 +117,21 @@ struct RecoveryPasswordView: View {
}
}
}
private func copyRecoveryPassword() {
UIPasteboard.general.string = self.mnemonic
self.copied = true
}
private func finishRegister() {
let homeVC: HomeVC = HomeVC()
self.host.controller?.navigationController?.setViewControllers([ homeVC ], animated: true)
return
}
}
struct RecoveryPasswordView_Previews: PreviewProvider {
static var previews: some View {
RecoveryPasswordView(hardcode: "Voyage urban toyed maverick peculiar tuxedo penguin tree grass building listen speak withdraw terminal plane ")
RecoveryPasswordView(hardcode: "Voyage urban toyed maverick peculiar tuxedo penguin tree grass building listen speak")
}
}

Loading…
Cancel
Save