From aff061180f812dabd9d176cf84b37262d642a11d Mon Sep 17 00:00:00 2001 From: Philippe Weidmann Date: Tue, 18 Jun 2024 12:46:43 +0200 Subject: [PATCH] fix: Add MenuHeaderView to toolbar only on macOS --- Mail/Views/Menu Drawer/MenuHeaderView.swift | 72 ++++++++++++++------- MailCore/UI/UIConstants.swift | 3 +- 2 files changed, 52 insertions(+), 23 deletions(-) diff --git a/Mail/Views/Menu Drawer/MenuHeaderView.swift b/Mail/Views/Menu Drawer/MenuHeaderView.swift index 9b8927a69c..ee52b725d1 100644 --- a/Mail/Views/Menu Drawer/MenuHeaderView.swift +++ b/Mail/Views/Menu Drawer/MenuHeaderView.swift @@ -16,6 +16,8 @@ along with this program. If not, see . */ +import InfomaniakCore +import InfomaniakDI import MailCore import MailCoreUI import MailResources @@ -23,33 +25,59 @@ import SwiftUI import UIKit struct MenuHeaderView: View { + @LazyInjectService private var platformDetector: PlatformDetectable + @EnvironmentObject private var mainViewState: MainViewState + private var menuDrawerLogoHeight: CGFloat { + platformDetector.isMac ? UIConstants.menuDrawerLogoMacOSHeight : UIConstants.menuDrawerLogoHeight + } + var body: some View { - HStack { - MailResourcesAsset.logoText.swiftUIImage - .resizable() - .scaledToFit() - .frame(height: UIConstants.menuDrawerLogoHeight) - - Spacer() - - Button { - mainViewState.settingsViewConfig = SettingsViewConfig(baseNavigationPath: []) - } label: { - IKIcon(MailResourcesAsset.cog, size: .large) + if platformDetector.isMac { + ZStack {} + .toolbar { + ToolbarItem(placement: .topBarLeading) { + logoImage + } + ToolbarItem(placement: .topBarTrailing) { + settingsButton + } + } + } else { + HStack { + logoImage + + Spacer() + + settingsButton } - .buttonStyle(.borderless) - .accessibilityLabel(MailResourcesStrings.Localizable.settingsTitle) - .frame(width: UIConstants.menuDrawerLogoHeight, height: UIConstants.menuDrawerLogoHeight) - .contentShape(Rectangle()) + .padding(.vertical, value: .regular) + .padding(.leading, value: .medium) + .padding(.trailing, value: .verySmall) + .background(MailResourcesAsset.backgroundSecondaryColor.swiftUIColor) + .clipped() + .shadow(color: MailResourcesAsset.menuDrawerShadowColor.swiftUIColor, radius: 1, x: 0, y: 2) + } + } + + var logoImage: some View { + MailResourcesAsset.logoText.swiftUIImage + .resizable() + .scaledToFit() + .frame(height: menuDrawerLogoHeight) + } + + var settingsButton: some View { + Button { + mainViewState.settingsViewConfig = SettingsViewConfig(baseNavigationPath: []) + } label: { + IKIcon(MailResourcesAsset.cog, size: .large) } - .padding(.vertical, value: .regular) - .padding(.leading, value: .medium) - .padding(.trailing, value: .verySmall) - .background(MailResourcesAsset.backgroundSecondaryColor.swiftUIColor) - .clipped() - .shadow(color: MailResourcesAsset.menuDrawerShadowColor.swiftUIColor, radius: 1, x: 0, y: 2) + .buttonStyle(.borderless) + .accessibilityLabel(MailResourcesStrings.Localizable.settingsTitle) + .frame(width: menuDrawerLogoHeight, height: menuDrawerLogoHeight) + .contentShape(Rectangle()) } } diff --git a/MailCore/UI/UIConstants.swift b/MailCore/UI/UIConstants.swift index 909599712a..a7dd0f88e2 100644 --- a/MailCore/UI/UIConstants.swift +++ b/MailCore/UI/UIConstants.swift @@ -1,6 +1,6 @@ /* Infomaniak Mail - iOS App - Copyright (C) 2022 Infomaniak Network SA + Copyright (C) 2024 Infomaniak Network SA This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -88,6 +88,7 @@ public extension UIConstants { static let menuDrawerMaxWidth: CGFloat = 352 static let menuDrawerTrailingSpacing: CGFloat = 64 static let menuDrawerLogoHeight: CGFloat = 48 + static let menuDrawerLogoMacOSHeight: CGFloat = 32 static let menuDrawerQuotaSize: CGFloat = 40 static let unreadIconSize: CGFloat = 8