remove navigation view wrapper

This commit is contained in:
ryanzhao 2023-08-25 13:50:51 +10:00
parent 6741575f04
commit 42bfb63c19
6 changed files with 361 additions and 373 deletions

View File

@ -18,76 +18,74 @@ struct DisplayNameView: View {
}
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: .leading,
spacing: 0
) {
Spacer(minLength: 0)
let title: String = (self.flow == .register) ? "vc_display_name_title_2".localized() : "onboarding_display_name_title_new".localized()
Text(title)
.bold()
.font(.system(size: Values.veryLargeFontSize))
.foregroundColor(themeColor: .textPrimary)
Spacer(minLength: 0)
.frame(maxHeight: 2 * Values.mediumSpacing)
let explanation: String = (self.flow == .register) ? "onboarding_display_name_explanation".localized() : "onboarding_display_name_explanation_new".localized()
Text(explanation)
.font(.system(size: Values.smallFontSize))
.foregroundColor(themeColor: .textPrimary)
.fixedSize(horizontal: false, vertical: true)
Spacer(minLength: 0)
.frame(maxHeight: 2 * Values.mediumSpacing)
SessionTextField(
$displayName,
placeholder: "onboarding_display_name_hint".localized(),
error: $error
)
Spacer(minLength: 0)
.frame(maxHeight: Values.massiveSpacing)
Spacer(minLength: 0)
}
.padding(.horizontal, Values.veryLargeSpacing)
.padding(.bottom, Values.largeButtonHeight)
VStack() {
Spacer(minLength: 0)
Button {
register()
} 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)
ZStack(alignment: .center) {
if #available(iOS 14.0, *) {
ThemeManager.currentTheme.colorSwiftUI(for: .backgroundPrimary).ignoresSafeArea()
} else {
ThemeManager.currentTheme.colorSwiftUI(for: .backgroundPrimary)
}
VStack(
alignment: .leading,
spacing: 0
) {
Spacer(minLength: 0)
let title: String = (self.flow == .register) ? "vc_display_name_title_2".localized() : "onboarding_display_name_title_new".localized()
Text(title)
.bold()
.font(.system(size: Values.veryLargeFontSize))
.foregroundColor(themeColor: .textPrimary)
Spacer(minLength: 0)
.frame(maxHeight: 2 * Values.mediumSpacing)
let explanation: String = (self.flow == .register) ? "onboarding_display_name_explanation".localized() : "onboarding_display_name_explanation_new".localized()
Text(explanation)
.font(.system(size: Values.smallFontSize))
.foregroundColor(themeColor: .textPrimary)
.fixedSize(horizontal: false, vertical: true)
Spacer(minLength: 0)
.frame(maxHeight: 2 * Values.mediumSpacing)
SessionTextField(
$displayName,
placeholder: "onboarding_display_name_hint".localized(),
error: $error
)
Spacer(minLength: 0)
.frame(maxHeight: Values.massiveSpacing)
Spacer(minLength: 0)
}
.padding(.horizontal, Values.veryLargeSpacing)
.padding(.bottom, Values.largeButtonHeight)
VStack() {
Spacer(minLength: 0)
Button {
register()
} 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)
}
}

View File

@ -12,116 +12,114 @@ struct LandingView: View {
@State var numberOfBubblesShown: Int = 0
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)
}
ZStack(alignment: .center) {
if #available(iOS 14.0, *) {
ThemeManager.currentTheme.colorSwiftUI(for: .backgroundPrimary).ignoresSafeArea()
} else {
ThemeManager.currentTheme.colorSwiftUI(for: .backgroundPrimary)
}
VStack(
alignment: .center,
spacing: 0
) {
Spacer(minLength: 0)
VStack(
alignment: .center,
spacing: 0
) {
Spacer(minLength: 0)
Text("onboarding_landing_title".localized())
.bold()
.font(.system(size: Values.veryLargeFontSize))
.foregroundColor(themeColor: .textPrimary)
Spacer(minLength: 0)
.frame(maxHeight: 2 * Values.mediumSpacing)
FakeChat($numberOfBubblesShown)
.onAppear {
guard numberOfBubblesShown < 4 else { return }
Timer.scheduledTimerOnMainThread(withTimeInterval: 0.2, repeats: false) { _ in
Text("onboarding_landing_title".localized())
.bold()
.font(.system(size: Values.veryLargeFontSize))
.foregroundColor(themeColor: .textPrimary)
Spacer(minLength: 0)
.frame(maxHeight: 2 * Values.mediumSpacing)
FakeChat($numberOfBubblesShown)
.onAppear {
guard numberOfBubblesShown < 4 else { return }
Timer.scheduledTimerOnMainThread(withTimeInterval: 0.2, repeats: false) { _ in
withAnimation(.spring().speed(0.68)) {
numberOfBubblesShown = 1
}
Timer.scheduledTimerOnMainThread(withTimeInterval: 1.5, repeats: true) { timer in
withAnimation(.spring().speed(0.68)) {
numberOfBubblesShown = 1
}
Timer.scheduledTimerOnMainThread(withTimeInterval: 1.5, repeats: true) { timer in
withAnimation(.spring().speed(0.68)) {
numberOfBubblesShown += 1
if numberOfBubblesShown >= 4 {
timer.invalidate()
}
numberOfBubblesShown += 1
if numberOfBubblesShown >= 4 {
timer.invalidate()
}
}
}
}
Spacer(minLength: 0)
.frame(maxHeight: Values.massiveSpacing)
Spacer(minLength: 0)
}
.padding(.vertical, Values.mediumSpacing)
.padding(.bottom, 3 * Values.largeButtonHeight)
}
VStack(
alignment: .center,
spacing: Values.mediumSpacing
) {
Spacer()
Button {
register()
} label: {
Text("onboarding_landing_register_button_title".localized())
.bold()
.font(.system(size: Values.smallFontSize))
.foregroundColor(themeColor: .sessionButton_primaryFilledText)
.frame(
maxWidth: .infinity,
maxHeight: Values.largeButtonHeight,
alignment: .center
)
.backgroundColor(themeColor: .sessionButton_primaryFilledBackground)
.cornerRadius(Values.largeButtonHeight / 2)
}
.padding(.horizontal, Values.massiveSpacing)
Button {
restore()
} label: {
Text("onboarding_landing_restore_button_title".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)
Button {
openLegalUrl()
} label: {
let attributedText: NSAttributedString = {
let text = String(format: "onboarding_T&C".localized(), "terms_of_service".localized(), "privacy_policy".localized())
let result = NSMutableAttributedString(
string: text,
attributes: [ .font : UIFont.systemFont(ofSize: Values.verySmallFontSize)]
)
result.addAttribute(.font, value: UIFont.boldSystemFont(ofSize: Values.verySmallFontSize), range: (text as NSString).range(of: "terms_of_service".localized()))
result.addAttribute(.font, value: UIFont.boldSystemFont(ofSize: Values.verySmallFontSize), range: (text as NSString).range(of: "privacy_policy".localized()))
return result
}()
AttributedText(attributedText)
.foregroundColor(themeColor: .textPrimary)
}
.padding(.horizontal, Values.massiveSpacing)
Spacer(minLength: 0)
.frame(maxHeight: Values.massiveSpacing)
Spacer(minLength: 0)
}
.padding(.vertical, Values.mediumSpacing)
.padding(.bottom, 3 * Values.largeButtonHeight)
VStack(
alignment: .center,
spacing: Values.mediumSpacing
) {
Spacer()
Button {
register()
} label: {
Text("onboarding_landing_register_button_title".localized())
.bold()
.font(.system(size: Values.smallFontSize))
.foregroundColor(themeColor: .sessionButton_primaryFilledText)
.frame(
maxWidth: .infinity,
maxHeight: Values.largeButtonHeight,
alignment: .center
)
.backgroundColor(themeColor: .sessionButton_primaryFilledBackground)
.cornerRadius(Values.largeButtonHeight / 2)
}
.padding(.horizontal, Values.massiveSpacing)
Button {
restore()
} label: {
Text("onboarding_landing_restore_button_title".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)
Button {
openLegalUrl()
} label: {
let attributedText: NSAttributedString = {
let text = String(format: "onboarding_T&C".localized(), "terms_of_service".localized(), "privacy_policy".localized())
let result = NSMutableAttributedString(
string: text,
attributes: [ .font : UIFont.systemFont(ofSize: Values.verySmallFontSize)]
)
result.addAttribute(.font, value: UIFont.boldSystemFont(ofSize: Values.verySmallFontSize), range: (text as NSString).range(of: "terms_of_service".localized()))
result.addAttribute(.font, value: UIFont.boldSystemFont(ofSize: Values.verySmallFontSize), range: (text as NSString).range(of: "privacy_policy".localized()))
return result
}()
AttributedText(attributedText)
.foregroundColor(themeColor: .textPrimary)
}
.padding(.horizontal, Values.massiveSpacing)
}
}
}

View File

@ -15,33 +15,31 @@ struct LoadAccountView: View {
@State private var errorString: String? = nil
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)
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,
error: $errorString,
continueWithMnemonic: continueWithMnemonic
)
}
VStack(
spacing: 0
){
CustomTopTabBar(tabIndex: $tabIndex)
.frame(maxWidth: .infinity)
if tabIndex == 0 {
EnterRecoveryPasswordView(
$recoveryPassword,
error: $errorString,
continueWithMnemonic: continueWithMnemonic
)
}
else {
ScanQRCodeView(
$hexEncodedSeed,
error: $errorString,
continueWithhexEncodedSeed: continueWithhexEncodedSeed
)
}
else {
ScanQRCodeView(
$hexEncodedSeed,
error: $errorString,
continueWithhexEncodedSeed: continueWithhexEncodedSeed
)
}
}
}

View File

@ -20,42 +20,40 @@ struct LoadingView: View {
}
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)
.onAppear {
progress()
observeProfileRetrieving()
}
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)
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)
.onAppear {
progress()
observeProfileRetrieving()
}
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)
}
}

View File

@ -39,70 +39,68 @@ struct PNModeView: View {
]
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)
}
ZStack(alignment: .center) {
if #available(iOS 14.0, *) {
ThemeManager.currentTheme.colorSwiftUI(for: .backgroundPrimary).ignoresSafeArea()
} else {
ThemeManager.currentTheme.colorSwiftUI(for: .backgroundPrimary)
}
VStack(
alignment: .leading,
spacing: Values.mediumSpacing
) {
Spacer()
Text("vc_pn_mode_title".localized())
.bold()
.font(.system(size: Values.veryLargeFontSize))
.foregroundColor(themeColor: .textPrimary)
.padding(.vertical, Values.mediumSpacing)
VStack(
alignment: .leading,
spacing: Values.mediumSpacing
) {
Spacer()
Text("vc_pn_mode_title".localized())
.bold()
.font(.system(size: Values.veryLargeFontSize))
.foregroundColor(themeColor: .textPrimary)
.padding(.vertical, Values.mediumSpacing)
VStack(
alignment: .leading,
spacing: Values.mediumSpacing)
{
ForEach(
0...(options.count - 1),
id: \.self
) { index in
PNOptionView(
currentSelection: $currentSelection,
info: options[index]
)
}
spacing: Values.mediumSpacing)
{
ForEach(
0...(options.count - 1),
id: \.self
) { index in
PNOptionView(
currentSelection: $currentSelection,
info: options[index]
)
}
Spacer()
}
.padding(.horizontal, Values.veryLargeSpacing)
.padding(.bottom, Values.massiveSpacing + Values.largeButtonHeight)
VStack() {
Spacer()
Button {
register()
} 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)
Spacer()
}
.padding(.horizontal, Values.veryLargeSpacing)
.padding(.bottom, Values.massiveSpacing + Values.largeButtonHeight)
VStack() {
Spacer()
Button {
register()
} 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)
}
}

View File

@ -25,100 +25,98 @@ struct RecoveryPasswordView: View {
}
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)
}
ZStack(alignment: .center) {
if #available(iOS 14.0, *) {
ThemeManager.currentTheme.colorSwiftUI(for: .backgroundPrimary).ignoresSafeArea()
} else {
ThemeManager.currentTheme.colorSwiftUI(for: .backgroundPrimary)
}
VStack(
alignment: .leading,
spacing: Values.mediumSpacing
) {
Spacer()
VStack(
alignment: .leading,
spacing: Values.mediumSpacing
HStack(
alignment: .bottom,
spacing: Values.smallSpacing
) {
Spacer()
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))
Text("onboarding_recovery_password_title".localized())
.bold()
.font(.system(size: Values.veryLargeFontSize))
.foregroundColor(themeColor: .textPrimary)
Text(mnemonic)
.font(.spaceMono(size: Values.verySmallFontSize))
.multilineTextAlignment(.center)
.foregroundColor(themeColor: .primary)
.frame(maxWidth: .infinity)
.padding(.all, Values.largeSpacing)
.overlay(
RoundedRectangle(
cornerSize: CGSize(
width: Self.cornerRadius,
height: Self.cornerRadius
)
)
.stroke(themeColor: .borderSeparator)
Image("SessionShield")
.resizable()
.renderingMode(.template)
.foregroundColor(themeColor: .textPrimary)
.scaledToFit()
.frame(
maxWidth: Values.largeFontSize,
maxHeight: Values.largeFontSize
)
Button {
copyRecoveryPassword()
} label: {
let buttonTitle: String = self.copied ? "copied".localized() : "tap_to_copy".localized()
Text(buttonTitle)
.font(.system(size: Values.verySmallFontSize))
.foregroundColor(themeColor: .textSecondary)
}
.frame(maxWidth: .infinity)
Spacer()
.padding(.bottom, Values.verySmallSpacing)
}
.padding(.horizontal, Values.veryLargeSpacing)
.padding(.bottom, Values.massiveSpacing + Values.largeButtonHeight)
VStack() {
Spacer()
Button {
finishRegister()
} label: {
Text("continue_2".localized())
.bold()
.font(.system(size: Values.smallFontSize))
.foregroundColor(themeColor: .sessionButton_text)
.frame(
maxWidth: .infinity,
maxHeight: Values.largeButtonHeight,
alignment: .center
Text("onboarding_recovery_password_explanation".localized())
.font(.system(size: Values.smallFontSize))
.foregroundColor(themeColor: .textPrimary)
Text(mnemonic)
.font(.spaceMono(size: Values.verySmallFontSize))
.multilineTextAlignment(.center)
.foregroundColor(themeColor: .primary)
.frame(maxWidth: .infinity)
.padding(.all, Values.largeSpacing)
.overlay(
RoundedRectangle(
cornerSize: CGSize(
width: Self.cornerRadius,
height: Self.cornerRadius
)
.overlay(
Capsule()
.stroke(themeColor: .sessionButton_border)
)
}
.padding(.horizontal, Values.massiveSpacing)
)
.stroke(themeColor: .borderSeparator)
)
Button {
copyRecoveryPassword()
} label: {
let buttonTitle: String = self.copied ? "copied".localized() : "tap_to_copy".localized()
Text(buttonTitle)
.font(.system(size: Values.verySmallFontSize))
.foregroundColor(themeColor: .textSecondary)
}
.padding(.vertical, Values.mediumSpacing)
.frame(maxWidth: .infinity)
Spacer()
}
.padding(.horizontal, Values.veryLargeSpacing)
.padding(.bottom, Values.massiveSpacing + Values.largeButtonHeight)
VStack() {
Spacer()
Button {
finishRegister()
} 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)
}
}