diff --git a/Mail/Components/BottomBarView.swift b/Mail/Components/BottomBarView.swift index ecc8be29d1..7877dc1a0a 100644 --- a/Mail/Components/BottomBarView.swift +++ b/Mail/Components/BottomBarView.swift @@ -1,4 +1,3 @@ -// /* Infomaniak Mail - iOS App Copyright (C) 2022 Infomaniak Network SA diff --git a/Mail/Components/ToolbarButton.swift b/Mail/Components/ToolbarButton.swift index 394548dfbe..dd8ecfba9b 100644 --- a/Mail/Components/ToolbarButton.swift +++ b/Mail/Components/ToolbarButton.swift @@ -20,30 +20,8 @@ import MailCore import MailResources import SwiftUI -// MARK: - Environment - -struct SmallToolbarKey: EnvironmentKey { - static var defaultValue = false -} - -extension EnvironmentValues { - var smallToolbar: Bool { - get { self[SmallToolbarKey.self] } - set { self[SmallToolbarKey.self] = newValue } - } -} - -extension View { - func smallToolbar(_ isSmall: Bool) -> some View { - environment(\.smallToolbar, isSmall) - } -} - -// MARK: - View - struct ToolbarButtonLabel: View { @Environment(\.verticalSizeClass) private var sizeClass - @Environment(\.smallToolbar) private var smallToolbar let text: String let icon: Image @@ -59,7 +37,7 @@ struct ToolbarButtonLabel: View { .resizable() .frame(width: 24, height: 24) } - .dynamicLabelStyle(sizeClass: sizeClass ?? .regular, smallToolbar: smallToolbar) + .dynamicLabelStyle(sizeClass: sizeClass ?? .regular) } } diff --git a/Mail/Views/Thread List/ThreadListModifiers.swift b/Mail/Views/Thread List/ThreadListModifiers.swift index ee17efdf9a..5c367cc39f 100644 --- a/Mail/Views/Thread List/ThreadListModifiers.swift +++ b/Mail/Views/Thread List/ThreadListModifiers.swift @@ -130,37 +130,6 @@ struct ThreadListToolbar: ViewModifier { .accessibilityLabel(MailResourcesStrings.Localizable.contentDescriptionUserAvatar) } } - - /*ToolbarItemGroup(placement: .bottomBar) { - if multipleSelectionViewModel.isEnabled { - HStack(spacing: 0) { - ForEach(multipleSelectionViewModel.toolbarActions) { action in - ToolbarButton( - text: action.shortTitle ?? action.title, - icon: action.icon - ) { - Task { - await tryOrDisplayError { - try await multipleSelectionViewModel.didTap( - action: action, - flushAlert: $flushAlert - ) - } - } - } - .disabled(action == .archive && splitViewManager.selectedFolder?.role == .archive) - } - - ToolbarButton( - text: MailResourcesStrings.Localizable.buttonMore, - icon: MailResourcesAsset.plusActions.swiftUIImage - ) { - multipleSelectionActionsTarget = .threads(Array(multipleSelectionViewModel.selectedItems), true) - } - } - .disabled(multipleSelectionViewModel.selectedItems.isEmpty) - } - }*/ } .bottomBar(isHidden: !multipleSelectionViewModel.isEnabled) { HStack(spacing: 0) { diff --git a/Mail/Views/Thread/ThreadView.swift b/Mail/Views/Thread/ThreadView.swift index afc294b663..da286175de 100644 --- a/Mail/Views/Thread/ThreadView.swift +++ b/Mail/Views/Thread/ThreadView.swift @@ -32,14 +32,6 @@ private struct ScrollOffsetPreferenceKey: PreferenceKey { } } -private struct ToolbarWidthPreferenceKey: PreferenceKey { - static var defaultValue: CGFloat = .zero - - static func reduce(value: inout CGFloat, nextValue: () -> CGFloat) { - value = nextValue() - } -} - struct ThreadView: View { @LazyInjectService private var matomo: MatomoUtils @@ -54,8 +46,6 @@ struct ThreadView: View { @State private var displayNavigationTitle = false @State private var replyOrReplyAllMessage: Message? - @State private var smallToolbar = true - @ObservedRealmObject var thread: Thread private let toolbarActions: [Action] = [.reply, .forward, .archive, .delete] @@ -85,20 +75,9 @@ struct ThreadView: View { } .background(MailResourcesAsset.backgroundColor.swiftUIColor) .coordinateSpace(name: "scrollView") - .overlay { - GeometryReader { proxy in - Color.clear.preference( - key: ToolbarWidthPreferenceKey.self, - value: proxy.size.width - ) - } - } .onPreferenceChange(ScrollOffsetPreferenceKey.self) { offset in displayNavigationTitle = offset.y < -85 } - .onPreferenceChange(ToolbarWidthPreferenceKey.self) { width in - smallToolbar = width < UIConstants.toolbarMinimumWidth - } .task { if thread.hasUnseenMessages { try? await mailboxManager.toggleRead(threads: [thread]) @@ -121,36 +100,6 @@ struct ThreadView: View { .foregroundColor(thread.flagged ? MailResourcesAsset.yellowColor.swiftUIColor : .accentColor) } } - /*ToolbarItemGroup(placement: .bottomBar) { - Group { - ForEach(toolbarActions) { action in - if action == .reply { - ToolbarButton(text: action.title, icon: action.icon) { - didTap(action: action) - } - .adaptivePanel(item: $replyOrReplyAllMessage) { message in - ReplyActionsView( - mailboxManager: mailboxManager, - message: message, - messageReply: $navigationStore.messageReply - ) - } - } else { - ToolbarButton(text: action.title, icon: action.icon) { - didTap(action: action) - } - .disabled(action == .archive && thread.folder?.role == .archive) - } - Spacer() - } - ActionsPanelButton(threads: [thread]) { - ToolbarButtonLabel(text: MailResourcesStrings.Localizable.buttonMore, - icon: MailResourcesAsset.plusActions.swiftUIImage) - } - } - .smallToolbar(smallToolbar) - } - */ } .bottomBar { ForEach(toolbarActions) { action in @@ -246,8 +195,8 @@ extension LabelStyle where Self == VerticalLabelStyle { extension Label { @ViewBuilder - func dynamicLabelStyle(sizeClass: UserInterfaceSizeClass, smallToolbar: Bool = false) -> some View { - if sizeClass == .compact || smallToolbar { + func dynamicLabelStyle(sizeClass: UserInterfaceSizeClass) -> some View { + if sizeClass == .compact { labelStyle(.iconOnly) } else { labelStyle(.vertical) diff --git a/MailCore/UI/UIConstants.swift b/MailCore/UI/UIConstants.swift index 7e34af47b5..a6089f802b 100644 --- a/MailCore/UI/UIConstants.swift +++ b/MailCore/UI/UIConstants.swift @@ -104,8 +104,6 @@ public enum UIConstants { public static let chipInsets = UIEdgeInsets(top: 4, left: 8, bottom: 4, right: 8) - public static let toolbarMinimumWidth: CGFloat = 328 - public static func isCompact(horizontalSizeClass: UserInterfaceSizeClass?, verticalSizeClass: UserInterfaceSizeClass?) -> Bool { return horizontalSizeClass == .compact || verticalSizeClass == .compact }