Skip to content

Commit

Permalink
fix: Add onDismiss
Browse files Browse the repository at this point in the history
  • Loading branch information
charlella committed May 8, 2024
1 parent 61d4795 commit d7955d3
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 20 deletions.
12 changes: 6 additions & 6 deletions Mail/Views/Menu Drawer/Actions/HelpView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
}

Expand All @@ -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)
Expand Down Expand Up @@ -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)
}
})
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions Mail/Views/Menu Drawer/Items/MenuDrawerItemsListView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -101,9 +101,9 @@ struct MenuDrawerItemsHelpListView: View {
BugTrackerView(isPresented: $isShowingBugTracker)
}
.customAlert(isPresented: $isShowingUpdateVersionAlert) {
UpdateVersionAlertView {
UpdateVersionAlertView(onLaterPressed: {
sendFeedback()
}
})
}
}

Expand Down
1 change: 1 addition & 0 deletions Mail/Views/Thread List/FlushFolderView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ struct FlushFolderView: View {
}
.textStyle(.bodySmallAccent)
}
.controlSize(.small)
.buttonStyle(.borderless)
}
.padding(value: .regular)
Expand Down
7 changes: 5 additions & 2 deletions Mail/Views/Thread List/ThreadListView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down Expand Up @@ -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"])
}
Expand Down
12 changes: 6 additions & 6 deletions Mail/Views/Thread List/UpdateVersionAlertView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ struct UpdateVersionAlertView: View {
.hasDismissedUpdateVersionView

var onLaterPressed: (() -> Void)?
var onDismiss: (() -> Void)?

var body: some View {
VStack(alignment: .leading, spacing: UIPadding.medium) {
Expand All @@ -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
}
}
}

Expand Down
3 changes: 1 addition & 2 deletions Mail/Views/Thread List/UpdateVersionView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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]
}
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion MailCore/Utils/Constants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down

0 comments on commit d7955d3

Please sign in to comment.