Skip to content

Commit

Permalink
fix: Add MenuHeaderView to toolbar only on macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilippeWeidmann committed Jun 18, 2024
1 parent f62b28e commit aff0611
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 23 deletions.
72 changes: 50 additions & 22 deletions Mail/Views/Menu Drawer/MenuHeaderView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,40 +16,68 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

import InfomaniakCore
import InfomaniakDI
import MailCore
import MailCoreUI
import MailResources
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())
}
}

Expand Down
3 changes: 2 additions & 1 deletion MailCore/UI/UIConstants.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
Infomaniak Mail - iOS App
Copyright (C) 2022 Infomaniak Network SA
Copyright (C) 2024 Infomaniak Network SA

Check warning on line 3 in MailCore/UI/UIConstants.swift

View workflow job for this annotation

GitHub Actions / SwiftFormat

Use specified source file header template for all files. (fileHeader)
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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit aff0611

Please sign in to comment.