From d7955d31c2e6ca2a787146ee03c327ac442ca2d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charle=CC=80ne=20Hoareau?= Date: Wed, 8 May 2024 09:31:52 +0200 Subject: [PATCH] fix: Add onDismiss --- Mail/Views/Menu Drawer/Actions/HelpView.swift | 12 ++++++------ .../Menu Drawer/Items/MenuDrawerItemsListView.swift | 6 +++--- Mail/Views/Thread List/FlushFolderView.swift | 1 + Mail/Views/Thread List/ThreadListView.swift | 7 +++++-- Mail/Views/Thread List/UpdateVersionAlertView.swift | 12 ++++++------ Mail/Views/Thread List/UpdateVersionView.swift | 3 +-- MailCore/Utils/Constants.swift | 2 +- 7 files changed, 23 insertions(+), 20 deletions(-) diff --git a/Mail/Views/Menu Drawer/Actions/HelpView.swift b/Mail/Views/Menu Drawer/Actions/HelpView.swift index 14ecde19dd..3f9fd08908 100644 --- a/Mail/Views/Menu Drawer/Actions/HelpView.swift +++ b/Mail/Views/Menu Drawer/Actions/HelpView.swift @@ -30,17 +30,17 @@ struct HelpView: View { let title: String let destination: URL - let openUpdateVersionAlert: Bool + let shouldOpenUpdateVersionAlert: Bool static let faq = HelpAction( title: MailResourcesStrings.Localizable.helpFAQ, destination: URLConstants.faq.url, - openUpdateVersionAlert: false + shouldOpenUpdateVersionAlert: false ) static let chatbot = HelpAction( title: MailResourcesStrings.Localizable.helpChatbot, destination: URLConstants.chatbot.url, - openUpdateVersionAlert: true + shouldOpenUpdateVersionAlert: true ) } @@ -56,7 +56,7 @@ struct HelpView: View { ForEach(actions) { action in VStack(alignment: .leading, spacing: 0) { Button { - if action.openUpdateVersionAlert && Constants.canOSBeUpdated { + if action.shouldOpenUpdateVersionAlert && Constants.isUsingABreakableOSVersion { updateVersionAlert = action } else { openURL(action.destination) @@ -87,9 +87,9 @@ struct HelpView: View { .background(MailResourcesAsset.backgroundColor.swiftUIColor) .navigationBarTitle(MailResourcesStrings.Localizable.buttonHelp, displayMode: .inline) .customAlert(item: $updateVersionAlert) { action in - UpdateVersionAlertView { + UpdateVersionAlertView(onLaterPressed: { openURL(action.destination) - } + }) } } } diff --git a/Mail/Views/Menu Drawer/Items/MenuDrawerItemsListView.swift b/Mail/Views/Menu Drawer/Items/MenuDrawerItemsListView.swift index ef359bef06..f480d2fbcb 100644 --- a/Mail/Views/Menu Drawer/Items/MenuDrawerItemsListView.swift +++ b/Mail/Views/Menu Drawer/Items/MenuDrawerItemsListView.swift @@ -81,7 +81,7 @@ struct MenuDrawerItemsHelpListView: View { MenuDrawerItemCell(icon: MailResourcesAsset.feedback, label: MailResourcesStrings.Localizable.buttonFeedback, matomoName: "feedback") { - if Constants.canOSBeUpdated { + if Constants.isUsingABreakableOSVersion { isShowingUpdateVersionAlert = true } else { sendFeedback() @@ -101,9 +101,9 @@ struct MenuDrawerItemsHelpListView: View { BugTrackerView(isPresented: $isShowingBugTracker) } .customAlert(isPresented: $isShowingUpdateVersionAlert) { - UpdateVersionAlertView { + UpdateVersionAlertView(onLaterPressed: { sendFeedback() - } + }) } } diff --git a/Mail/Views/Thread List/FlushFolderView.swift b/Mail/Views/Thread List/FlushFolderView.swift index ad282d2210..224e5aa28e 100644 --- a/Mail/Views/Thread List/FlushFolderView.swift +++ b/Mail/Views/Thread List/FlushFolderView.swift @@ -70,6 +70,7 @@ struct FlushFolderView: View { } .textStyle(.bodySmallAccent) } + .controlSize(.small) .buttonStyle(.borderless) } .padding(value: .regular) diff --git a/Mail/Views/Thread List/ThreadListView.swift b/Mail/Views/Thread List/ThreadListView.swift index e88feb9f0a..a1660c7d4c 100644 --- a/Mail/Views/Thread List/ThreadListView.swift +++ b/Mail/Views/Thread List/ThreadListView.swift @@ -101,7 +101,8 @@ struct ThreadListView: View { ListVerticalInsetView(height: UIPadding.verySmall) } - if Constants.canOSBeUpdated && !hasDismissedUpdateVersionView && viewModel.frozenFolder.role == .inbox { + if Constants.isUsingABreakableOSVersion && !hasDismissedUpdateVersionView && viewModel.frozenFolder + .role == .inbox { UpdateVersionView(isShowingUpdateAlert: $isShowingUpdateAlert) .threadListCellAppearance() } @@ -201,7 +202,9 @@ struct ThreadListView: View { FlushFolderAlertView(flushAlert: item, folder: viewModel.frozenFolder) } .customAlert(isPresented: $isShowingUpdateAlert) { - UpdateVersionAlertView() + UpdateVersionAlertView(onDismiss: { + hasDismissedUpdateVersionView = true + }) } .matomoView(view: [MatomoUtils.View.threadListView.displayName, "Main"]) } diff --git a/Mail/Views/Thread List/UpdateVersionAlertView.swift b/Mail/Views/Thread List/UpdateVersionAlertView.swift index 7e93f8a353..46dd382b7e 100644 --- a/Mail/Views/Thread List/UpdateVersionAlertView.swift +++ b/Mail/Views/Thread List/UpdateVersionAlertView.swift @@ -32,6 +32,7 @@ struct UpdateVersionAlertView: View { .hasDismissedUpdateVersionView var onLaterPressed: (() -> Void)? + var onDismiss: (() -> Void)? var body: some View { VStack(alignment: .leading, spacing: UIPadding.medium) { @@ -43,22 +44,21 @@ struct UpdateVersionAlertView: View { ModalButtonsView(primaryButtonTitle: MailResourcesStrings.Localizable.buttonUpdate, secondaryButtonTitle: MailResourcesStrings.Localizable.buttonLater, primaryButtonAction: updateVersion, - secondaryButtonAction: dismissUpdateVersionView) + secondaryButtonAction: laterButton) + } + .onDisappear { + onDismiss?() } } private func updateVersion() { matomo.track(eventWithCategory: .updateVersion, name: "update") openURL(DeeplinkConstants.iosPreferences) - dismissUpdateVersionView() } - private func dismissUpdateVersionView() { + private func laterButton() { matomo.track(eventWithCategory: .updateVersion, name: "later") onLaterPressed?() - withAnimation { - hasDismissedUpdateVersionView = true - } } } diff --git a/Mail/Views/Thread List/UpdateVersionView.swift b/Mail/Views/Thread List/UpdateVersionView.swift index cb6dd06bf5..eb11f9e482 100644 --- a/Mail/Views/Thread List/UpdateVersionView.swift +++ b/Mail/Views/Thread List/UpdateVersionView.swift @@ -31,7 +31,6 @@ struct UpdateVersionView: View { VStack(alignment: .leading, spacing: 0) { HStack(alignment: .iconAndMultilineTextAlignment, spacing: UIPadding.small) { IKIcon(MailResourcesAsset.warning) - .foregroundStyle(MailResourcesAsset.orangeColor) .alignmentGuide(.iconAndMultilineTextAlignment) { d in d[VerticalAlignment.center] } @@ -51,9 +50,9 @@ struct UpdateVersionView: View { isShowingUpdateAlert = true } label: { Text(MailResourcesStrings.Localizable.moreInfo) - .textStyle(.bodySmallAccent) } .buttonStyle(.ikLink()) + .controlSize(.small) .padding(.leading, value: .regular) IKDivider(type: .full) diff --git a/MailCore/Utils/Constants.swift b/MailCore/Utils/Constants.swift index 9b3eaa2ce5..154e6cb9bb 100644 --- a/MailCore/Utils/Constants.swift +++ b/MailCore/Utils/Constants.swift @@ -225,7 +225,7 @@ public enum Constants { } } - public static var canOSBeUpdated: Bool { + public static var isUsingABreakableOSVersion: Bool { @InjectService var platformDetector: PlatformDetectable guard !platformDetector.isMac else { return false }