diff --git a/Mail/Views/New Message/V2/ComposeMessageHeaderViewV2.swift b/Mail/Views/New Message/V2/ComposeMessageHeaderViewV2.swift
index 544911878..de911fb00 100644
--- a/Mail/Views/New Message/V2/ComposeMessageHeaderViewV2.swift
+++ b/Mail/Views/New Message/V2/ComposeMessageHeaderViewV2.swift
@@ -32,7 +32,7 @@ struct ComposeMessageHeaderViewV2: View {
@Binding var autocompletionType: ComposeViewFieldType?
var body: some View {
- VStack {
+ VStack(spacing: UIConstants.composeViewVerticalSpacing) {
ComposeMessageCellStaticTextV2(
autocompletionType: $autocompletionType,
type: .from,
@@ -43,6 +43,7 @@ struct ComposeMessageHeaderViewV2: View {
recipients: $draft.to,
showRecipientsFields: $showRecipientsFields,
autocompletionType: $autocompletionType,
+ focusedField: _focusedField,
type: .to
)
@@ -51,6 +52,7 @@ struct ComposeMessageHeaderViewV2: View {
recipients: $draft.cc,
showRecipientsFields: $showRecipientsFields,
autocompletionType: $autocompletionType,
+ focusedField: _focusedField,
type: .cc
)
@@ -58,11 +60,17 @@ struct ComposeMessageHeaderViewV2: View {
recipients: $draft.bcc,
showRecipientsFields: $showRecipientsFields,
autocompletionType: $autocompletionType,
+ focusedField: _focusedField,
type: .bcc
)
}
- ComposeMessageCellTextFieldV2(text: $draft.subject, autocompletionType: $autocompletionType, type: .subject)
+ ComposeMessageCellTextFieldV2(
+ text: $draft.subject,
+ autocompletionType: $autocompletionType,
+ focusedField: _focusedField,
+ type: .subject
+ )
}
.padding(.horizontal, 16)
.onAppear {
diff --git a/Mail/Views/New Message/V2/Header Cells/ComposeMessageCellRecipientsV2.swift b/Mail/Views/New Message/V2/Header Cells/ComposeMessageCellRecipientsV2.swift
index 1ac712d7a..e71fe5f55 100644
--- a/Mail/Views/New Message/V2/Header Cells/ComposeMessageCellRecipientsV2.swift
+++ b/Mail/Views/New Message/V2/Header Cells/ComposeMessageCellRecipientsV2.swift
@@ -31,16 +31,18 @@ struct ComposeMessageCellRecipientsV2: View {
@Binding var showRecipientsFields: Bool
@Binding var autocompletionType: ComposeViewFieldType?
+ @FocusState var focusedField: ComposeViewFieldType?
+
let type: ComposeViewFieldType
var body: some View {
- VStack {
+ VStack(spacing: UIConstants.composeViewVerticalSpacing) {
if autocompletionType == nil || autocompletionType == type {
HStack {
Text(type.title)
.textStyle(.bodySecondary)
- RecipientFieldV2(currentText: $currentText, recipients: $recipients, type: type) {
+ RecipientFieldV2(currentText: $currentText, recipients: $recipients, focusedField: _focusedField, type: type) {
if let bestMatch = autocompletion.first {
addNewRecipient(bestMatch)
}
@@ -64,6 +66,9 @@ struct ComposeMessageCellRecipientsV2: View {
)
}
}
+ .onTapGesture {
+ focusedField = type
+ }
.onChange(of: currentText) { newValue in
withAnimation {
if newValue.isEmpty {
diff --git a/Mail/Views/New Message/V2/Header Cells/ComposeMessageCellStaticTextV2.swift b/Mail/Views/New Message/V2/Header Cells/ComposeMessageCellStaticTextV2.swift
index bb8fe3ab1..69af623ca 100644
--- a/Mail/Views/New Message/V2/Header Cells/ComposeMessageCellStaticTextV2.swift
+++ b/Mail/Views/New Message/V2/Header Cells/ComposeMessageCellStaticTextV2.swift
@@ -16,6 +16,7 @@
along with this program. If not, see .
*/
+import MailCore
import SwiftUI
struct ComposeMessageCellStaticTextV2: View {
@@ -26,7 +27,7 @@ struct ComposeMessageCellStaticTextV2: View {
var body: some View {
if autocompletionType == nil {
- VStack {
+ VStack(spacing: UIConstants.composeViewVerticalSpacing) {
HStack {
Text(type.title)
.textStyle(.bodySecondary)
diff --git a/Mail/Views/New Message/V2/Header Cells/ComposeMessageCellTextFieldV2.swift b/Mail/Views/New Message/V2/Header Cells/ComposeMessageCellTextFieldV2.swift
index e17f55b8e..07cfaf4a4 100644
--- a/Mail/Views/New Message/V2/Header Cells/ComposeMessageCellTextFieldV2.swift
+++ b/Mail/Views/New Message/V2/Header Cells/ComposeMessageCellTextFieldV2.swift
@@ -16,26 +16,33 @@
along with this program. If not, see .
*/
+import MailCore
import SwiftUI
struct ComposeMessageCellTextFieldV2: View {
@Binding var text: String
@Binding var autocompletionType: ComposeViewFieldType?
+ @FocusState var focusedField: ComposeViewFieldType?
+
let type: ComposeViewFieldType
var body: some View {
if autocompletionType == nil {
- VStack {
+ VStack(spacing: UIConstants.composeViewVerticalSpacing) {
HStack {
Text(type.title)
.textStyle(.bodySecondary)
TextField("", text: $text)
+ .focused($focusedField, equals: .subject)
}
.frame(maxWidth: .infinity, alignment: .leading)
IKDivider()
}
+ .onTapGesture {
+ focusedField = type
+ }
}
}
}
diff --git a/MailCore/UI/UIConstants.swift b/MailCore/UI/UIConstants.swift
index 3c5fb0a56..f2ebd3ac2 100644
--- a/MailCore/UI/UIConstants.swift
+++ b/MailCore/UI/UIConstants.swift
@@ -101,6 +101,8 @@ public enum UIConstants {
public static let buttonsRadius: CGFloat = 16
public static let buttonsIconSize: CGFloat = 16
+ public static let composeViewVerticalSpacing: CGFloat = 12
+
public static let bottomBarVerticalPadding: CGFloat = 8
public static let bottomBarSmallVerticalPadding: CGFloat = 4
public static let bottomBarHorizontalMinimumSpace: CGFloat = 8