diff --git a/Mail/Components/BottomBarView.swift b/Mail/Components/BottomBarView.swift
index 2d4c85bc4..b7926a522 100644
--- a/Mail/Components/BottomBarView.swift
+++ b/Mail/Components/BottomBarView.swift
@@ -16,17 +16,10 @@
along with this program. If not, see .
*/
+import MailCore
import MailResources
import SwiftUI
-struct BottomSafeAreaKey: PreferenceKey {
- static var defaultValue: CGFloat = .zero
-
- static func reduce(value: inout CGFloat, nextValue: () -> CGFloat) {
- value = nextValue()
- }
-}
-
struct BottomBar: ViewModifier {
let isVisible: Bool
@ViewBuilder var items: () -> Items
@@ -59,8 +52,8 @@ struct BottomBarView: View {
items()
Spacer(minLength: 8)
}
- .padding(.top, 8)
- .padding(.bottom, hasBottomSafeArea ? 4 : 8)
+ .padding(.top, UIConstants.bottomBarVerticalPadding)
+ .padding(.bottom, hasBottomSafeArea ? UIConstants.bottomBarSmallVerticalPadding : UIConstants.bottomBarVerticalPadding)
.background(MailResourcesAsset.backgroundTabBarColor.swiftUIColor)
.overlay(alignment: .top) {
Divider()
@@ -68,10 +61,7 @@ struct BottomBarView: View {
.overlay(Color(uiColor: .systemGray3))
}
.overlay {
- GeometryReader { proxy in
- Color.clear
- .preference(key: BottomSafeAreaKey.self, value: proxy.safeAreaInsets.bottom)
- }
+ ViewGeometry(key: BottomSafeAreaKey.self, property: \.safeAreaInsets.bottom)
}
.onPreferenceChange(BottomSafeAreaKey.self) { value in
hasBottomSafeArea = value > 0
diff --git a/Mail/Utils/GeometryReaderHelpers.swift b/Mail/Utils/GeometryReaderHelpers.swift
new file mode 100644
index 000000000..c8f677d3f
--- /dev/null
+++ b/Mail/Utils/GeometryReaderHelpers.swift
@@ -0,0 +1,47 @@
+/*
+ Infomaniak Mail - iOS App
+ Copyright (C) 2022 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
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+ */
+
+import SwiftUI
+
+struct ViewWidthKey: PreferenceKey {
+ static var defaultValue: CGFloat = .zero
+
+ static func reduce(value: inout CGFloat, nextValue: () -> CGFloat) {
+ value = max(value, nextValue())
+ }
+}
+
+struct BottomSafeAreaKey: PreferenceKey {
+ static var defaultValue: CGFloat = .zero
+
+ static func reduce(value: inout CGFloat, nextValue: () -> CGFloat) {
+ value = nextValue()
+ }
+}
+
+struct ViewGeometry: View where K: PreferenceKey {
+ let key: K.Type
+ let property: KeyPath
+
+ var body: some View {
+ GeometryReader { proxy in
+ Color.clear
+ .preference(key: key, value: proxy[keyPath: property])
+ }
+ }
+}
diff --git a/Mail/Views/Thread/MessageHeaderDetailView.swift b/Mail/Views/Thread/MessageHeaderDetailView.swift
index 58a26abdd..f8d774d21 100644
--- a/Mail/Views/Thread/MessageHeaderDetailView.swift
+++ b/Mail/Views/Thread/MessageHeaderDetailView.swift
@@ -25,23 +25,6 @@ import RealmSwift
import SwiftUI
import WrappingHStack
-struct ViewWidthKey: PreferenceKey {
- static var defaultValue: CGFloat = .zero
-
- static func reduce(value: inout CGFloat, nextValue: () -> CGFloat) {
- value = max(value, nextValue())
- }
-}
-
-struct ViewGeometry: View {
- var body: some View {
- GeometryReader { geometry in
- Color.clear
- .preference(key: ViewWidthKey.self, value: geometry.size.width)
- }
- }
-}
-
struct MessageHeaderDetailView: View {
@ObservedRealmObject var message: Message
@@ -109,7 +92,7 @@ struct RecipientLabel: View {
HStack(alignment: .top) {
Text(title)
.textStyle(.bodySmallSecondary)
- .background(ViewGeometry())
+ .background(ViewGeometry(key: ViewWidthKey.self, property: \.size.width))
.frame(width: labelWidth, alignment: .leading)
VStack(alignment: .leading, spacing: 4) {
ForEach(recipients, id: \.self) { recipient in
diff --git a/MailCore/UI/UIConstants.swift b/MailCore/UI/UIConstants.swift
index 3a7b9540d..83a360536 100644
--- a/MailCore/UI/UIConstants.swift
+++ b/MailCore/UI/UIConstants.swift
@@ -101,6 +101,9 @@ public enum UIConstants {
public static let buttonsRadius: CGFloat = 16
public static let buttonsIconSize: CGFloat = 16
+ public static let bottomBarVerticalPadding: CGFloat = 8
+ public static let bottomBarSmallVerticalPadding: CGFloat = 4
+
public static let bottomSheetHorizontalPadding: CGFloat = 24
public static let componentsMaxWidth: CGFloat = 496