Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Small fixes for macOS #1456

Merged
merged 3 commits into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 {}
PhilippeWeidmann marked this conversation as resolved.
Show resolved Hide resolved
.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)
}
}

private var logoImage: some View {
MailResourcesAsset.logoText.swiftUIImage
.resizable()
.scaledToFit()
.frame(height: menuDrawerLogoHeight)
}

private 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
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ struct CurrentComposeMailboxView: View {
.padding(.bottom, value: .medium)

if let defaultMailbox = viewModel.defaultMailbox,
let account = accountManager.account(for: defaultMailbox.userId) {
SelectedMailboxView(account: account, selectedMailbox: defaultMailbox)
let mailboxManager = accountManager.getMailboxManager(for: defaultMailbox) {
SelectedMailboxView(selectedMailboxManager: mailboxManager)
.frame(maxHeight: .infinity, alignment: .top)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ struct SelectComposeMailboxView: View {
}

if let selectedMailbox = viewModel.selectedMailbox,
let account = accountManager.account(for: selectedMailbox.userId), viewModel.selectionMade {
SelectedMailboxView(account: account, selectedMailbox: selectedMailbox)
let mailboxManager = accountManager.getMailboxManager(for: selectedMailbox) {
SelectedMailboxView(selectedMailboxManager: mailboxManager)
.padding(.horizontal, value: .small)
.padding(.bottom, value: .regular)
}
Expand Down
15 changes: 8 additions & 7 deletions Mail/Views/New Message/Select Mailbox/SelectedMailboxView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,16 @@ import MailResources
import SwiftUI

struct SelectedMailboxView: View {
@EnvironmentObject private var mailboxManager: MailboxManager

let account: Account
let selectedMailbox: Mailbox
let selectedMailboxManager: MailboxManager

var body: some View {
HStack(spacing: UIPadding.small) {
AvatarView(mailboxManager: mailboxManager, contactConfiguration: .user(user: account.user), size: 40)
Text(selectedMailbox.email)
AvatarView(
mailboxManager: selectedMailboxManager,
contactConfiguration: .user(user: selectedMailboxManager.account.user),
size: 40
)
Text(selectedMailboxManager.mailbox.email)
.textStyle(.body)
.frame(maxWidth: .infinity, alignment: .leading)
MailResourcesAsset.checkmarkCircleFill.swiftUIImage
Expand All @@ -48,5 +49,5 @@ struct SelectedMailboxView: View {
}

#Preview {
SelectedMailboxView(account: PreviewHelper.sampleAccount, selectedMailbox: PreviewHelper.sampleMailbox)
SelectedMailboxView(selectedMailboxManager: PreviewHelper.sampleMailboxManager)
}
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ struct MessageHeaderDetailView: View {
}

struct RecipientLabel: View {
@EnvironmentObject var mailboxManager: MailboxManager

@Binding var labelWidth: CGFloat
let title: String
let recipients: RealmSwift.List<Recipient>
Expand Down Expand Up @@ -112,6 +114,8 @@ struct RecipientLabel: View {
}
.adaptivePanel(item: $contactViewRecipient) { recipient in
ContactActionsView(recipient: recipient)
.environmentObject(mailboxManager)
// We need to manually pass environmentObject because of a bug with SwiftUI end popovers on macOS
}
}
.padding(.bottom, 2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ struct MessageHeaderSummaryView: View {
}
.adaptivePanel(item: $contactViewRecipient) { recipient in
ContactActionsView(recipient: recipient)
.environmentObject(mailboxManager)
// We need to manually pass environmentObject because of a bug with SwiftUI end popovers on macOS
}
.disabled(!isMessageInteractive)
}
Expand Down
1 change: 1 addition & 0 deletions MailCore/UI/UIConstants.swift
Original file line number Diff line number Diff line change
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
Loading