WIP: loading view

This commit is contained in:
Ryan Zhao 2023-08-21 17:22:36 +10:00
parent abaf3ddf89
commit 5f4ecfd4a2
28 changed files with 197 additions and 18 deletions

View File

@ -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 = "<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>"; };
7B87EF4B2A933355002A0E8F /* LoadingView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoadingView.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>"; };
@ -3014,6 +3016,7 @@
7B87EF452A8DDA8E002A0E8F /* PNModeView.swift */,
7B87EF472A8DFBBF002A0E8F /* RecoveryPasswordView.swift */,
7B87EF492A92DFB4002A0E8F /* LoadAccountView.swift */,
7B87EF4B2A933355002A0E8F /* LoadingView.swift */,
);
path = Onboarding;
sourceTree = "<group>";
@ -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 */,

View File

@ -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";

View File

@ -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";

View File

@ -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";

View File

@ -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";

View File

@ -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";

View File

@ -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";

View File

@ -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";

View File

@ -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";

View File

@ -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";

View File

@ -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";

View File

@ -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";

View File

@ -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";

View File

@ -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";

View File

@ -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";

View File

@ -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";

View File

@ -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";

View File

@ -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";

View File

@ -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";

View File

@ -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";

View File

@ -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";

View File

@ -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";

View File

@ -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";

View File

@ -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<String>, error: Binding<String?>) {
var continueWithSeed: (() -> Void)?
init(
_ recoveryPassword: Binding<String>,
error: Binding<String?>,
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()

View File

@ -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<Double>) {
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)
}
}

View File

@ -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)
}
}

View File

@ -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
)
}
}

View File

@ -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