From 75e0e323fdbee534b91f94db4bcde2b2ac680c1f Mon Sep 17 00:00:00 2001 From: Elena Willen Date: Thu, 21 Mar 2024 13:48:50 +0100 Subject: [PATCH] fix: Navigation back animation --- .../ComposeMessageIntentView.swift | 36 ++++---- .../New Message/ComposeMessageView.swift | 72 ++++++++-------- .../CurrentComposeMailboxView.swift | 82 ++++++++++--------- 3 files changed, 96 insertions(+), 94 deletions(-) diff --git a/Mail/Views/New Message/ComposeMessageIntentView.swift b/Mail/Views/New Message/ComposeMessageIntentView.swift index 61b081c138..c3f12b4a8d 100644 --- a/Mail/Views/New Message/ComposeMessageIntentView.swift +++ b/Mail/Views/New Message/ComposeMessageIntentView.swift @@ -47,29 +47,25 @@ struct ComposeMessageIntentView: View, IntentViewable { } var body: some View { - NavigationView { - if composeMessageIntent.shouldSelectMailbox { - CurrentComposeMailboxView(composeMessageIntent: $composeMessageIntent) + if composeMessageIntent.shouldSelectMailbox { + CurrentComposeMailboxView(composeMessageIntent: $composeMessageIntent) + } else { + if let resolvedIntent = resolvedIntent.wrappedValue { + ComposeMessageView( + draft: resolvedIntent.draft, + mailboxManager: resolvedIntent.mailboxManager, + messageReply: resolvedIntent.messageReply, + attachments: attachments + ) + .environmentObject(resolvedIntent.mailboxManager) } else { - if let resolvedIntent = resolvedIntent.wrappedValue { - ComposeMessageView( - draft: resolvedIntent.draft, - mailboxManager: resolvedIntent.mailboxManager, - messageReply: resolvedIntent.messageReply, - attachments: attachments - ) - .environmentObject(resolvedIntent.mailboxManager) - } else { - ProgressView() - .progressViewStyle(.circular) - .task { - await initFromIntent() - } - } + ProgressView() + .progressViewStyle(.circular) + .task { + await initFromIntent() + } } } - .interactiveDismissDisabled() - .navigationViewStyle(.stack) } func initFromIntent() async { diff --git a/Mail/Views/New Message/ComposeMessageView.swift b/Mail/Views/New Message/ComposeMessageView.swift index 45aa70fda2..06b813bb1b 100644 --- a/Mail/Views/New Message/ComposeMessageView.swift +++ b/Mail/Views/New Message/ComposeMessageView.swift @@ -137,26 +137,46 @@ struct ComposeMessageView: View { // MARK: - View var body: some View { - ScrollView { - VStack(spacing: 0) { - ComposeMessageHeaderView( - draft: draft, - focusedField: _focusedField, - autocompletionType: $autocompletionType, - currentSignature: $currentSignature - ) - - if autocompletionType == nil && !isLoadingContent { - ComposeMessageBodyView( + NavigationView { + ScrollView { + VStack(spacing: 0) { + ComposeMessageHeaderView( draft: draft, - editorModel: $editorModel, - editorFocus: $editorFocus, - currentSignature: $currentSignature, - isShowingAIPrompt: $aiModel.isShowingPrompt, - attachmentsManager: attachmentsManager, - alert: alert, - messageReply: messageReply + focusedField: _focusedField, + autocompletionType: $autocompletionType, + currentSignature: $currentSignature ) + + if autocompletionType == nil && !isLoadingContent { + ComposeMessageBodyView( + draft: draft, + editorModel: $editorModel, + editorFocus: $editorFocus, + currentSignature: $currentSignature, + isShowingAIPrompt: $aiModel.isShowingPrompt, + attachmentsManager: attachmentsManager, + alert: alert, + messageReply: messageReply + ) + } + } + } + .navigationTitle(MailResourcesStrings.Localizable.buttonNewMessage) + .navigationBarTitleDisplayMode(.inline) + .interactiveDismissDisabled() + .navigationViewStyle(.stack) + .toolbar { + ToolbarItem(placement: .navigationBarLeading) { + if !platformDetector.isMac { + CloseButton(dismissHandler: didTouchDismiss) + } + } + + ToolbarItem(placement: .navigationBarTrailing) { + Button(action: didTouchSend) { + Label(MailResourcesStrings.Localizable.send, image: MailResourcesAsset.send.name) + } + .disabled(isSendButtonDisabled) } } } @@ -187,22 +207,6 @@ struct ComposeMessageView: View { let rectTop = CGRect(x: 0, y: 0, width: 1, height: 1) scrollView?.scrollRectToVisible(rectTop, animated: true) } - .navigationTitle(MailResourcesStrings.Localizable.buttonNewMessage) - .navigationBarTitleDisplayMode(.inline) - .toolbar { - ToolbarItem(placement: .navigationBarLeading) { - if !platformDetector.isMac { - CloseButton(dismissHandler: didTouchDismiss) - } - } - - ToolbarItem(placement: .navigationBarTrailing) { - Button(action: didTouchSend) { - Label(MailResourcesStrings.Localizable.send, image: MailResourcesAsset.send.name) - } - .disabled(isSendButtonDisabled) - } - } .safeAreaInset(edge: .bottom) { ExternalTagBottomView(externalTag: draft.displayExternalTag(mailboxManager: mailboxManager)) } diff --git a/Mail/Views/New Message/Select Mailbox/CurrentComposeMailboxView.swift b/Mail/Views/New Message/Select Mailbox/CurrentComposeMailboxView.swift index 707d815fba..609ddccefd 100644 --- a/Mail/Views/New Message/Select Mailbox/CurrentComposeMailboxView.swift +++ b/Mail/Views/New Message/Select Mailbox/CurrentComposeMailboxView.swift @@ -44,52 +44,54 @@ struct CurrentComposeMailboxView: View { } var body: some View { - VStack(spacing: 0) { - accentColor.mailboxImage.swiftUIImage - .padding(.bottom, value: .regular) - - Text(MailResourcesStrings.Localizable.composeMailboxCurrentTitle) - .textStyle(.header2) - .multilineTextAlignment(.center) - .padding(.bottom, value: .medium) - - if let selectedMailbox = viewModel.selectedMailbox, - let account = accountManager.account(for: selectedMailbox.userId) { - SelectedMailboxView(account: account, selectedMailbox: selectedMailbox) - .frame(maxHeight: .infinity, alignment: .top) - } - - VStack(spacing: UIPadding.regular) { - Button(MailResourcesStrings.Localizable.buttonContinue, action: viewModel.validateMailboxChoice) - .buttonStyle(.ikPlain) + NavigationView { + VStack(spacing: 0) { + accentColor.mailboxImage.swiftUIImage + .padding(.bottom, value: .regular) + + Text(MailResourcesStrings.Localizable.composeMailboxCurrentTitle) + .textStyle(.header2) + .multilineTextAlignment(.center) + .padding(.bottom, value: .medium) + + if let selectedMailbox = viewModel.selectedMailbox, + let account = accountManager.account(for: selectedMailbox.userId) { + SelectedMailboxView(account: account, selectedMailbox: selectedMailbox) + .frame(maxHeight: .infinity, alignment: .top) + } - NavigationLink(destination: SelectComposeMailboxView( - composeMessageIntent: $composeMessageIntent, - viewModel: viewModel - )) { - Text(MailResourcesStrings.Localizable.buttonSendWithDifferentAddress) - .textStyle(.bodyMediumAccent) + VStack(spacing: UIPadding.regular) { + Button(MailResourcesStrings.Localizable.buttonContinue, action: viewModel.validateMailboxChoice) + .buttonStyle(.ikPlain) + + NavigationLink(destination: SelectComposeMailboxView( + composeMessageIntent: $composeMessageIntent, + viewModel: viewModel + )) { + Text(MailResourcesStrings.Localizable.buttonSendWithDifferentAddress) + .textStyle(.bodyMediumAccent) + } + .buttonStyle(.ikLink()) + .padding(.bottom, UIPadding.onBoardingBottomButtons) } - .buttonStyle(.ikLink()) - .padding(.bottom, UIPadding.onBoardingBottomButtons) + .ikButtonFullWidth(true) + .controlSize(.large) + .padding(.horizontal, value: .small) } - .ikButtonFullWidth(true) - .controlSize(.large) - .padding(.horizontal, value: .small) - } - .padding(.horizontal, value: .regular) - .mailboxCellStyle(.account) - .onAppear(perform: viewModel.initDefaultAccountAndMailbox) - .backButtonDisplayMode(.minimal) - .navigationBarTitleDisplayMode(.inline) - .toolbar { - ToolbarItem(placement: .navigationBarLeading) { - if !platformDetector.isMac { - CloseButton(dismissHandler: dismissMessageView) + .padding(.horizontal, value: .regular) + .mailboxCellStyle(.account) + .onAppear(perform: viewModel.initDefaultAccountAndMailbox) + .backButtonDisplayMode(.minimal) + .navigationBarTitleDisplayMode(.inline) + .toolbar { + ToolbarItem(placement: .navigationBarLeading) { + if !platformDetector.isMac { + CloseButton(dismissHandler: dismissMessageView) + } } } + .matomoView(view: [MatomoUtils.View.bottomSheet.displayName, "CurrentComposeMailboxView"]) } - .matomoView(view: [MatomoUtils.View.bottomSheet.displayName, "CurrentComposeMailboxView"]) } private func dismissMessageView() {