Skip to content

Commit

Permalink
refactor: Fix init
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthieu-dgl committed Dec 18, 2024
1 parent 7c4c01e commit c042289
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 17 deletions.
18 changes: 10 additions & 8 deletions Mail/Views/New Message/AutocompletionCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,15 @@ struct AutocompletionCell: View {
init(
addRecipient: @escaping @MainActor (any ContactAutocompletable) -> Void,
autocompletion: any ContactAutocompletable,
hightlight: String?,
highlight: String?,
alreadyAppend: Bool,
unknownRecipient: Bool,
title: String,
subtitle: String
) {
self.addRecipient = addRecipient
self.autocompletion = autocompletion
self.highlight = highlight
self.alreadyAppend = alreadyAppend
self.unknownRecipient = unknownRecipient
self.title = title
Expand All @@ -86,15 +87,15 @@ struct AutocompletionCell: View {
}

init(
addRecipient: @escaping @MainActor (AddressBook) -> Void,
autocompletion: AddressBook,
addRecipient: @escaping @MainActor (GroupContact) -> Void,
autocompletion: GroupContact,
highlight: String?,
alreadyAppend: Bool,
unknownRecipient: Bool,
title: String,
subtitle: String
) {
self.addRecipient = { addRecipient($0 as! AddressBook) }
self.addRecipient = { addRecipient($0 as! GroupContact) }
self.autocompletion = autocompletion
self.alreadyAppend = alreadyAppend
self.unknownRecipient = unknownRecipient
Expand All @@ -103,16 +104,17 @@ struct AutocompletionCell: View {
}

init(
addRecipient: @escaping @MainActor (GroupContact) -> Void,
autocompletion: GroupContact,
addRecipient: @escaping @MainActor (AddressBook) -> Void,
autocompletion: AddressBook,
highlight: String?,
alreadyAppend: Bool,
unknownRecipient: Bool,
title: String,
subtitle: String
) {
self.addRecipient = { addRecipient($0 as! GroupContact) }
self.addRecipient = { addRecipient($0 as! AddressBook) }
self.autocompletion = autocompletion
self.highlight = highlight
self.alreadyAppend = alreadyAppend
self.unknownRecipient = unknownRecipient
self.title = title
Expand Down Expand Up @@ -151,7 +153,7 @@ struct AutocompletionCell: View {
AutocompletionCell(
addRecipient: { _ in /* Preview */ },
autocompletion: PreviewHelper.sampleMergedContact,
hightlight: "",
highlight: "",
alreadyAppend: false,
unknownRecipient: false,
title: "",
Expand Down
6 changes: 2 additions & 4 deletions Mail/Views/New Message/AutocompletionView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ extension Recipient: @retroactive ContactAutocompletable {
}

struct AutocompletionView: View {
private static let maxAutocompleteCount = 10

@EnvironmentObject private var mailboxManager: MailboxManager

@State private var shouldAddUserProposal = false
Expand Down Expand Up @@ -70,7 +68,7 @@ struct AutocompletionView: View {
AutocompletionCell(
addRecipient: addRecipient,
autocompletion: groupContact,
hightlight: textDebounce.text,
highlight: textDebounce.text,
alreadyAppend: addedRecipients.contains { $0.id == contact.contactId },
unknownRecipient: isUserProposal,
title: groupContact.name,
Expand All @@ -80,7 +78,7 @@ struct AutocompletionView: View {
AutocompletionCell(
addRecipient: addRecipient,
autocompletion: addressBookContact,
hightlight: textDebounce.text,
highlight: textDebounce.text,
alreadyAppend: addedRecipients.contains { $0.id == contact.contactId },
unknownRecipient: isUserProposal,
title: addressBookContact.name,
Expand Down
3 changes: 0 additions & 3 deletions Mail/Views/New Message/ComposeMessageHeaderView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ struct ComposeMessageHeaderView: View {
focusedField: _focusedField,
type: .to,
areCCAndBCCEmpty: draft.cc.isEmpty && draft.bcc.isEmpty,
totalRecipients: totalRecipients,
isRecipientLimitExceeded: isRecipientLimitExceeded
)
.accessibilityLabel(MailResourcesStrings.Localizable.toTitle)
Expand All @@ -70,7 +69,6 @@ struct ComposeMessageHeaderView: View {
autocompletionType: $autocompletionType,
focusedField: _focusedField,
type: .cc,
totalRecipients: totalRecipients,
isRecipientLimitExceeded: isRecipientLimitExceeded
)
.accessibilityLabel(MailResourcesStrings.Localizable.ccTitle)
Expand All @@ -81,7 +79,6 @@ struct ComposeMessageHeaderView: View {
autocompletionType: $autocompletionType,
focusedField: _focusedField,
type: .bcc,
totalRecipients: totalRecipients,
isRecipientLimitExceeded: isRecipientLimitExceeded
)
.accessibilityLabel(MailResourcesStrings.Localizable.bccTitle)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ struct ComposeMessageCellRecipients: View {
let type: ComposeViewFieldType
var areCCAndBCCEmpty = false

let totalRecipients: Int
let isRecipientLimitExceeded: Bool

/// It should be displayed only for the field to if cc and bcc are empty and when autocompletion is not displayed
Expand Down Expand Up @@ -208,7 +207,6 @@ struct ComposeMessageCellRecipients: View {
showRecipientsFields: .constant(false),
autocompletionType: .constant(nil),
type: .bcc,
totalRecipients: 0,
isRecipientLimitExceeded: false
)
.environmentObject(PreviewHelper.sampleMailboxManager)
Expand Down

0 comments on commit c042289

Please sign in to comment.