From 5f4ecfd4a2d1d2b09ea6d7b8479df166c8236b89 Mon Sep 17 00:00:00 2001 From: Ryan Zhao Date: Mon, 21 Aug 2023 17:22:36 +1000 Subject: [PATCH] WIP: loading view --- Session.xcodeproj/project.pbxproj | 4 + .../Translations/de.lproj/Localizable.strings | 2 + .../Translations/en.lproj/Localizable.strings | 2 + .../Translations/es.lproj/Localizable.strings | 2 + .../Translations/fa.lproj/Localizable.strings | 2 + .../Translations/fi.lproj/Localizable.strings | 2 + .../Translations/fr.lproj/Localizable.strings | 2 + .../Translations/hi.lproj/Localizable.strings | 2 + .../Translations/hr.lproj/Localizable.strings | 2 + .../id-ID.lproj/Localizable.strings | 2 + .../Translations/it.lproj/Localizable.strings | 2 + .../Translations/ja.lproj/Localizable.strings | 2 + .../Translations/nl.lproj/Localizable.strings | 2 + .../Translations/pl.lproj/Localizable.strings | 2 + .../pt_BR.lproj/Localizable.strings | 2 + .../Translations/ru.lproj/Localizable.strings | 2 + .../Translations/si.lproj/Localizable.strings | 2 + .../Translations/sk.lproj/Localizable.strings | 2 + .../Translations/sv.lproj/Localizable.strings | 2 + .../Translations/th.lproj/Localizable.strings | 2 + .../vi-VN.lproj/Localizable.strings | 2 + .../zh-Hant.lproj/Localizable.strings | 2 + .../zh_CN.lproj/Localizable.strings | 2 + Session/Onboarding/LoadAccountView.swift | 30 ++--- Session/Onboarding/LoadingView.swift | 117 ++++++++++++++++++ Session/Onboarding/PNModeView.swift | 6 +- .../Style Guide/Themes/SwiftUI+Theme.swift | 12 +- SessionUIKit/Style Guide/Values.swift | 2 + 28 files changed, 197 insertions(+), 18 deletions(-) create mode 100644 Session/Onboarding/LoadingView.swift diff --git a/Session.xcodeproj/project.pbxproj b/Session.xcodeproj/project.pbxproj index 4e2c60abb..399caa073 100644 --- a/Session.xcodeproj/project.pbxproj +++ b/Session.xcodeproj/project.pbxproj @@ -126,6 +126,7 @@ 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 */; }; + 7B87EF4C2A933355002A0E8F /* LoadingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B87EF4B2A933355002A0E8F /* LoadingView.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 */; }; @@ -1245,6 +1246,7 @@ 7B87EF452A8DDA8E002A0E8F /* PNModeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PNModeView.swift; sourceTree = ""; }; 7B87EF472A8DFBBF002A0E8F /* RecoveryPasswordView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RecoveryPasswordView.swift; sourceTree = ""; }; 7B87EF492A92DFB4002A0E8F /* LoadAccountView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoadAccountView.swift; sourceTree = ""; }; + 7B87EF4B2A933355002A0E8F /* LoadingView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoadingView.swift; sourceTree = ""; }; 7B8914762A7CAAE200A4C627 /* SessionHostingViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SessionHostingViewController.swift; sourceTree = ""; }; 7B8C44C428B49DDA00FBE25F /* NewConversationVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NewConversationVC.swift; sourceTree = ""; }; 7B8D5FC328332600008324D9 /* VisibleMessage+Reaction.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "VisibleMessage+Reaction.swift"; sourceTree = ""; }; @@ -3014,6 +3016,7 @@ 7B87EF452A8DDA8E002A0E8F /* PNModeView.swift */, 7B87EF472A8DFBBF002A0E8F /* RecoveryPasswordView.swift */, 7B87EF492A92DFB4002A0E8F /* LoadAccountView.swift */, + 7B87EF4B2A933355002A0E8F /* LoadingView.swift */, ); path = Onboarding; sourceTree = ""; @@ -6113,6 +6116,7 @@ FD37EA1728AC5605003AE748 /* NotificationContentViewModel.swift in Sources */, B886B4A72398B23E00211ABE /* QRCodeVC.swift in Sources */, 4C586926224FAB83003FD070 /* AVAudioSession+OWS.m in Sources */, + 7B87EF4C2A933355002A0E8F /* LoadingView.swift in Sources */, FD87DD0028B820F200AF0F98 /* BlockedContactCell.swift in Sources */, C331FFF42558FF0300070591 /* PNOptionView.swift in Sources */, 7BB92B3F28C825FD0082762F /* NewConversationViewModel.swift in Sources */, diff --git a/Session/Meta/Translations/de.lproj/Localizable.strings b/Session/Meta/Translations/de.lproj/Localizable.strings index 6702f2e08..8c89e6ab2 100644 --- a/Session/Meta/Translations/de.lproj/Localizable.strings +++ b/Session/Meta/Translations/de.lproj/Localizable.strings @@ -677,3 +677,5 @@ "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"; +"onboarding_load_account_waiting" = "One moment please.."; +"onboarding_loading_account" = "Loading your account"; diff --git a/Session/Meta/Translations/en.lproj/Localizable.strings b/Session/Meta/Translations/en.lproj/Localizable.strings index 85f4f71ae..c2cfd575d 100644 --- a/Session/Meta/Translations/en.lproj/Localizable.strings +++ b/Session/Meta/Translations/en.lproj/Localizable.strings @@ -677,3 +677,5 @@ "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"; +"onboarding_load_account_waiting" = "One moment please.."; +"onboarding_loading_account" = "Loading your account"; diff --git a/Session/Meta/Translations/es.lproj/Localizable.strings b/Session/Meta/Translations/es.lproj/Localizable.strings index 758ef4449..c43511fbb 100644 --- a/Session/Meta/Translations/es.lproj/Localizable.strings +++ b/Session/Meta/Translations/es.lproj/Localizable.strings @@ -677,3 +677,5 @@ "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"; +"onboarding_load_account_waiting" = "One moment please.."; +"onboarding_loading_account" = "Loading your account"; diff --git a/Session/Meta/Translations/fa.lproj/Localizable.strings b/Session/Meta/Translations/fa.lproj/Localizable.strings index 61c37bee2..d57306657 100644 --- a/Session/Meta/Translations/fa.lproj/Localizable.strings +++ b/Session/Meta/Translations/fa.lproj/Localizable.strings @@ -677,3 +677,5 @@ "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"; +"onboarding_load_account_waiting" = "One moment please.."; +"onboarding_loading_account" = "Loading your account"; diff --git a/Session/Meta/Translations/fi.lproj/Localizable.strings b/Session/Meta/Translations/fi.lproj/Localizable.strings index dce1cff2b..fe4bb5765 100644 --- a/Session/Meta/Translations/fi.lproj/Localizable.strings +++ b/Session/Meta/Translations/fi.lproj/Localizable.strings @@ -677,3 +677,5 @@ "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"; +"onboarding_load_account_waiting" = "One moment please.."; +"onboarding_loading_account" = "Loading your account"; diff --git a/Session/Meta/Translations/fr.lproj/Localizable.strings b/Session/Meta/Translations/fr.lproj/Localizable.strings index 734143a09..4f2c97f16 100644 --- a/Session/Meta/Translations/fr.lproj/Localizable.strings +++ b/Session/Meta/Translations/fr.lproj/Localizable.strings @@ -677,3 +677,5 @@ "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"; +"onboarding_load_account_waiting" = "One moment please.."; +"onboarding_loading_account" = "Loading your account"; diff --git a/Session/Meta/Translations/hi.lproj/Localizable.strings b/Session/Meta/Translations/hi.lproj/Localizable.strings index b3c2b7dc4..9f041760b 100644 --- a/Session/Meta/Translations/hi.lproj/Localizable.strings +++ b/Session/Meta/Translations/hi.lproj/Localizable.strings @@ -677,3 +677,5 @@ "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"; +"onboarding_load_account_waiting" = "One moment please.."; +"onboarding_loading_account" = "Loading your account"; diff --git a/Session/Meta/Translations/hr.lproj/Localizable.strings b/Session/Meta/Translations/hr.lproj/Localizable.strings index c70d7e9ce..2221280e4 100644 --- a/Session/Meta/Translations/hr.lproj/Localizable.strings +++ b/Session/Meta/Translations/hr.lproj/Localizable.strings @@ -677,3 +677,5 @@ "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"; +"onboarding_load_account_waiting" = "One moment please.."; +"onboarding_loading_account" = "Loading your account"; diff --git a/Session/Meta/Translations/id-ID.lproj/Localizable.strings b/Session/Meta/Translations/id-ID.lproj/Localizable.strings index 92bf3f657..7de933f5e 100644 --- a/Session/Meta/Translations/id-ID.lproj/Localizable.strings +++ b/Session/Meta/Translations/id-ID.lproj/Localizable.strings @@ -677,3 +677,5 @@ "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"; +"onboarding_load_account_waiting" = "One moment please.."; +"onboarding_loading_account" = "Loading your account"; diff --git a/Session/Meta/Translations/it.lproj/Localizable.strings b/Session/Meta/Translations/it.lproj/Localizable.strings index 8173c064a..b400b542d 100644 --- a/Session/Meta/Translations/it.lproj/Localizable.strings +++ b/Session/Meta/Translations/it.lproj/Localizable.strings @@ -677,3 +677,5 @@ "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"; +"onboarding_load_account_waiting" = "One moment please.."; +"onboarding_loading_account" = "Loading your account"; diff --git a/Session/Meta/Translations/ja.lproj/Localizable.strings b/Session/Meta/Translations/ja.lproj/Localizable.strings index f2bfe16b6..308c35b31 100644 --- a/Session/Meta/Translations/ja.lproj/Localizable.strings +++ b/Session/Meta/Translations/ja.lproj/Localizable.strings @@ -677,3 +677,5 @@ "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"; +"onboarding_load_account_waiting" = "One moment please.."; +"onboarding_loading_account" = "Loading your account"; diff --git a/Session/Meta/Translations/nl.lproj/Localizable.strings b/Session/Meta/Translations/nl.lproj/Localizable.strings index a71ea74aa..c0d17a963 100644 --- a/Session/Meta/Translations/nl.lproj/Localizable.strings +++ b/Session/Meta/Translations/nl.lproj/Localizable.strings @@ -677,3 +677,5 @@ "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"; +"onboarding_load_account_waiting" = "One moment please.."; +"onboarding_loading_account" = "Loading your account"; diff --git a/Session/Meta/Translations/pl.lproj/Localizable.strings b/Session/Meta/Translations/pl.lproj/Localizable.strings index 4911c9ce4..61ec7dc35 100644 --- a/Session/Meta/Translations/pl.lproj/Localizable.strings +++ b/Session/Meta/Translations/pl.lproj/Localizable.strings @@ -677,3 +677,5 @@ "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"; +"onboarding_load_account_waiting" = "One moment please.."; +"onboarding_loading_account" = "Loading your account"; diff --git a/Session/Meta/Translations/pt_BR.lproj/Localizable.strings b/Session/Meta/Translations/pt_BR.lproj/Localizable.strings index e0f86bcd5..419057be9 100644 --- a/Session/Meta/Translations/pt_BR.lproj/Localizable.strings +++ b/Session/Meta/Translations/pt_BR.lproj/Localizable.strings @@ -677,3 +677,5 @@ "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"; +"onboarding_load_account_waiting" = "One moment please.."; +"onboarding_loading_account" = "Loading your account"; diff --git a/Session/Meta/Translations/ru.lproj/Localizable.strings b/Session/Meta/Translations/ru.lproj/Localizable.strings index 025dec6ad..ca20dd6b6 100644 --- a/Session/Meta/Translations/ru.lproj/Localizable.strings +++ b/Session/Meta/Translations/ru.lproj/Localizable.strings @@ -677,3 +677,5 @@ "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"; +"onboarding_load_account_waiting" = "One moment please.."; +"onboarding_loading_account" = "Loading your account"; diff --git a/Session/Meta/Translations/si.lproj/Localizable.strings b/Session/Meta/Translations/si.lproj/Localizable.strings index e4d1bb7c0..15ddc2f21 100644 --- a/Session/Meta/Translations/si.lproj/Localizable.strings +++ b/Session/Meta/Translations/si.lproj/Localizable.strings @@ -677,3 +677,5 @@ "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"; +"onboarding_load_account_waiting" = "One moment please.."; +"onboarding_loading_account" = "Loading your account"; diff --git a/Session/Meta/Translations/sk.lproj/Localizable.strings b/Session/Meta/Translations/sk.lproj/Localizable.strings index 31b267a4c..829d27ba4 100644 --- a/Session/Meta/Translations/sk.lproj/Localizable.strings +++ b/Session/Meta/Translations/sk.lproj/Localizable.strings @@ -677,3 +677,5 @@ "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"; +"onboarding_load_account_waiting" = "One moment please.."; +"onboarding_loading_account" = "Loading your account"; diff --git a/Session/Meta/Translations/sv.lproj/Localizable.strings b/Session/Meta/Translations/sv.lproj/Localizable.strings index fcf53f493..b1c2a8853 100644 --- a/Session/Meta/Translations/sv.lproj/Localizable.strings +++ b/Session/Meta/Translations/sv.lproj/Localizable.strings @@ -677,3 +677,5 @@ "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"; +"onboarding_load_account_waiting" = "One moment please.."; +"onboarding_loading_account" = "Loading your account"; diff --git a/Session/Meta/Translations/th.lproj/Localizable.strings b/Session/Meta/Translations/th.lproj/Localizable.strings index d7b4c8041..494a1efff 100644 --- a/Session/Meta/Translations/th.lproj/Localizable.strings +++ b/Session/Meta/Translations/th.lproj/Localizable.strings @@ -677,3 +677,5 @@ "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"; +"onboarding_load_account_waiting" = "One moment please.."; +"onboarding_loading_account" = "Loading your account"; diff --git a/Session/Meta/Translations/vi-VN.lproj/Localizable.strings b/Session/Meta/Translations/vi-VN.lproj/Localizable.strings index 31cc17823..0a425b5bb 100644 --- a/Session/Meta/Translations/vi-VN.lproj/Localizable.strings +++ b/Session/Meta/Translations/vi-VN.lproj/Localizable.strings @@ -677,3 +677,5 @@ "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"; +"onboarding_load_account_waiting" = "One moment please.."; +"onboarding_loading_account" = "Loading your account"; diff --git a/Session/Meta/Translations/zh-Hant.lproj/Localizable.strings b/Session/Meta/Translations/zh-Hant.lproj/Localizable.strings index b98ffe2ac..049a55e6f 100644 --- a/Session/Meta/Translations/zh-Hant.lproj/Localizable.strings +++ b/Session/Meta/Translations/zh-Hant.lproj/Localizable.strings @@ -677,3 +677,5 @@ "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"; +"onboarding_load_account_waiting" = "One moment please.."; +"onboarding_loading_account" = "Loading your account"; diff --git a/Session/Meta/Translations/zh_CN.lproj/Localizable.strings b/Session/Meta/Translations/zh_CN.lproj/Localizable.strings index c4175fa00..e8c4f03e2 100644 --- a/Session/Meta/Translations/zh_CN.lproj/Localizable.strings +++ b/Session/Meta/Translations/zh_CN.lproj/Localizable.strings @@ -677,3 +677,5 @@ "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"; +"onboarding_load_account_waiting" = "One moment please.."; +"onboarding_loading_account" = "Loading your account"; diff --git a/Session/Onboarding/LoadAccountView.swift b/Session/Onboarding/LoadAccountView.swift index d24abc67b..bfc5efd92 100644 --- a/Session/Onboarding/LoadAccountView.swift +++ b/Session/Onboarding/LoadAccountView.swift @@ -29,7 +29,8 @@ struct LoadAccountView: View { if tabIndex == 0 { EnterRecoveryPasswordView( $recoveryPassword, - error: $error + error: $error, + continueWithSeed: continueWithSeed ) } else { @@ -40,18 +41,12 @@ struct LoadAccountView: View { } } - func continueWithSeed(_ seed: Data, onError: (() -> ())?) { + func continueWithSeed() { + let mnemonic = recoveryPassword.lowercased() + guard let hexEncodedSeed = try? Mnemonic.decode(mnemonic: mnemonic) else { return } + let seed = Data(hex: hexEncodedSeed) 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) + //TODO: show error return } let (ed25519KeyPair, x25519KeyPair) = try! Identity.generate(from: seed) @@ -139,9 +134,16 @@ struct EnterRecoveryPasswordView: View{ @Binding var recoveryPassword: String @Binding var error: String? - init(_ recoveryPassword: Binding, error: Binding) { + var continueWithSeed: (() -> Void)? + + init( + _ recoveryPassword: Binding, + error: Binding, + continueWithSeed: (() -> Void)? + ) { self._recoveryPassword = recoveryPassword self._error = error + self.continueWithSeed = continueWithSeed } var body: some View{ @@ -177,7 +179,7 @@ struct EnterRecoveryPasswordView: View{ Spacer() Button { - + continueWithSeed?() } label: { Text("continue_2".localized()) .bold() diff --git a/Session/Onboarding/LoadingView.swift b/Session/Onboarding/LoadingView.swift new file mode 100644 index 000000000..321ff599e --- /dev/null +++ b/Session/Onboarding/LoadingView.swift @@ -0,0 +1,117 @@ +// Copyright © 2023 Rangeproof Pty Ltd. All rights reserved. + +import SwiftUI +import SessionUIKit +import SessionMessagingKit +import SignalUtilitiesKit + +struct LoadingView: View { + @EnvironmentObject var host: HostWrapper + + @State var percentage: Double = 0 + + private let flow: Onboarding.Flow + + public init(flow: Onboarding.Flow) { + self.flow = flow + progress() + } + + var body: some View { + NavigationView { + ZStack(alignment: .center) { + if #available(iOS 14.0, *) { + ThemeManager.currentTheme.colorSwiftUI(for: .backgroundPrimary).ignoresSafeArea() + } else { + ThemeManager.currentTheme.colorSwiftUI(for: .backgroundPrimary) + } + + VStack( + alignment: .center, + spacing: Values.mediumSpacing + ) { + Spacer() + + CircularProgressView($percentage) + .padding(.horizontal, Values.massiveSpacing) + .padding(.bottom, Values.mediumSpacing) + + Text("onboarding_load_account_waiting".localized()) + .bold() + .font(.system(size: Values.mediumLargeFontSize)) + .foregroundColor(themeColor: .textPrimary) + + Text("onboarding_loading_account".localized()) + .font(.system(size: Values.smallFontSize)) + .foregroundColor(themeColor: .textPrimary) + + Spacer() + } + .padding(.horizontal, Values.veryLargeSpacing) + .padding(.bottom, Values.massiveSpacing + Values.largeButtonHeight) + } + } + } + + private func progress() { + guard percentage < 1 else { return } + print(percentage) + Timer.scheduledTimer( + withTimeInterval: 0.15, + repeats: false, + block: { _ in + percentage += 0.01 + progress() + }) + } +} + +struct CircularProgressView: View { + @Binding var percentage: Double + + private var progress: Double { + return $percentage.wrappedValue * 0.85 + } + + init(_ percentage: Binding) { + self._percentage = percentage + } + + var body: some View { + ZStack { + Circle() + .trim(from: 0, to: 0.85) + .stroke( + themeColor: .borderSeparator, + style: StrokeStyle( + lineWidth: 20, + lineCap: .round + ) + ) + .rotationEffect(.degrees(117)) + + Circle() + .trim(from: 0, to: progress) + .stroke( + themeColor: .primary, + style: StrokeStyle( + lineWidth: 20, + lineCap: .round + ) + ) + .rotationEffect(.degrees(117)) + .animation(.easeOut, value: progress) + + Text(String(format: "%.0f%%", $percentage.wrappedValue * 100)) + .bold() + .font(.system(size: Values.superLargeFontSize)) + .foregroundColor(themeColor: .textPrimary) + } + } +} + +struct LoadingView_Previews: PreviewProvider { + static var previews: some View { + LoadingView(flow: .link) + } +} diff --git a/Session/Onboarding/PNModeView.swift b/Session/Onboarding/PNModeView.swift index 54ea4550e..65c1067f8 100644 --- a/Session/Onboarding/PNModeView.swift +++ b/Session/Onboarding/PNModeView.swift @@ -155,8 +155,10 @@ struct PNModeView: View { return } - // TODO: If we don't have one then show a loading indicator and try to retrieve the existing name - + // If we don't have one then show a loading indicator and try to retrieve the existing name + let viewController: SessionHostingViewController = SessionHostingViewController(rootView: LoadingView(flow: flow)) + viewController.setUpNavBarSessionIcon() + self.host.controller?.navigationController?.pushViewController(viewController, animated: true) } } diff --git a/SessionUIKit/Style Guide/Themes/SwiftUI+Theme.swift b/SessionUIKit/Style Guide/Themes/SwiftUI+Theme.swift index e9362bf81..aad414acc 100644 --- a/SessionUIKit/Style Guide/Themes/SwiftUI+Theme.swift +++ b/SessionUIKit/Style Guide/Themes/SwiftUI+Theme.swift @@ -23,9 +23,17 @@ public extension Shape { ) } - func stroke(themeColor: ThemeValue) -> some View { + func stroke(themeColor: ThemeValue, lineWidth: CGFloat = 1) -> some View { return self.stroke( - ThemeManager.currentTheme.colorSwiftUI(for: themeColor) ?? Color.primary + ThemeManager.currentTheme.colorSwiftUI(for: themeColor) ?? Color.primary, + lineWidth: lineWidth + ) + } + + func stroke(themeColor: ThemeValue, style: StrokeStyle) -> some View { + return self.stroke( + ThemeManager.currentTheme.colorSwiftUI(for: themeColor) ?? Color.primary, + style: style ) } } diff --git a/SessionUIKit/Style Guide/Values.swift b/SessionUIKit/Style Guide/Values.swift index 78b65c565..ef3a2fa20 100644 --- a/SessionUIKit/Style Guide/Values.swift +++ b/SessionUIKit/Style Guide/Values.swift @@ -13,8 +13,10 @@ public final class Values : NSObject { @objc public static let verySmallFontSize = isIPhone5OrSmaller ? CGFloat(10) : CGFloat(12) @objc public static let smallFontSize = isIPhone5OrSmaller ? CGFloat(13) : CGFloat(15) @objc public static let mediumFontSize = isIPhone5OrSmaller ? CGFloat(15) : CGFloat(17) + @objc public static let mediumLargeFontSize = isIPhone5OrSmaller ? CGFloat(17) : CGFloat(19) @objc public static let largeFontSize = isIPhone5OrSmaller ? CGFloat(20) : CGFloat(22) @objc public static let veryLargeFontSize = isIPhone5OrSmaller ? CGFloat(24) : CGFloat(26) + @objc public static let superLargeFontSize = isIPhone5OrSmaller ? CGFloat(31) : CGFloat(33) @objc public static let massiveFontSize = CGFloat(50) // MARK: - Element Sizes