Skip to content

Commit

Permalink
fix: Navigation back animation
Browse files Browse the repository at this point in the history
  • Loading branch information
Lnamw committed Mar 21, 2024
1 parent 8344006 commit 75e0e32
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 94 deletions.
36 changes: 16 additions & 20 deletions Mail/Views/New Message/ComposeMessageIntentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
72 changes: 38 additions & 34 deletions Mail/Views/New Message/ComposeMessageView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}
Expand Down Expand Up @@ -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))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit 75e0e32

Please sign in to comment.