@@ -9,6 +9,7 @@ import SwiftUI
99public struct MessageComposerView < Factory: ViewFactory > : View , KeyboardReadable {
1010 @Injected ( \. colors) private var colors
1111 @Injected ( \. fonts) private var fonts
12+ @Injected ( \. utils) private var utils
1213
1314 // Initial popup size, before the keyboard is shown.
1415 @State private var popupSize : CGFloat = 350
@@ -249,6 +250,18 @@ public struct MessageComposerView<Factory: ViewFactory>: View, KeyboardReadable
249250 viewModel. updateDraftMessage ( quotedMessage: quotedMessage)
250251 }
251252 } )
253+ . onReceive ( NotificationCenter . default. publisher ( for: . commandsOverlayHiddenNotification) ) { _ in
254+ guard utils. messageListConfig. hidesCommandsOverlayOnMessageListTap else {
255+ return
256+ }
257+ viewModel. composerCommand = nil
258+ }
259+ . onReceive ( NotificationCenter . default. publisher ( for: . attachmentPickerHiddenNotification) ) { _ in
260+ guard utils. messageListConfig. hidesAttachmentsPickersOnMessageListTap else {
261+ return
262+ }
263+ viewModel. pickerTypeState = . expanded( . none)
264+ }
252265 . accessibilityElement ( children: . contain)
253266 }
254267}
@@ -397,15 +410,13 @@ public struct ComposerInputView<Factory: ViewFactory>: View, KeyboardReadable {
397410 }
398411
399412 factory. makeComposerTextInputView (
400- options: ComposerTextInputViewOptions (
401- text: $text,
402- height: $textHeight,
403- selectedRangeLocation: $selectedRangeLocation,
404- placeholder: isInCooldown ? L10n . Composer. Placeholder. slowMode : L10n . Composer. Placeholder. message,
405- editable: !isInCooldown,
406- maxMessageLength: maxMessageLength,
407- currentHeight: textFieldHeight
408- )
413+ text: $text,
414+ height: $textHeight,
415+ selectedRangeLocation: $selectedRangeLocation,
416+ placeholder: isInCooldown ? L10n . Composer. Placeholder. slowMode : ( isChannelFrozen ? L10n . Composer. Placeholder. messageDisabled : L10n . Composer. Placeholder. message) ,
417+ editable: !isInputDisabled,
418+ maxMessageLength: maxMessageLength,
419+ currentHeight: textFieldHeight
409420 )
410421 . environmentObject ( viewModel)
411422 . accessibilityIdentifier ( " ComposerTextInputView " )
@@ -462,4 +473,22 @@ public struct ComposerInputView<Factory: ViewFactory>: View, KeyboardReadable {
462473 private var isInCooldown : Bool {
463474 cooldownDuration > 0
464475 }
476+
477+ private var isChannelFrozen : Bool {
478+ !viewModel. isSendMessageEnabled
479+ }
480+
481+ private var isInputDisabled : Bool {
482+ isInCooldown || isChannelFrozen
483+ }
484+ }
485+
486+ // MARK: - Notification Names
487+
488+ extension Notification . Name {
489+ /// Notification sent when the attachments picker should be hidden.
490+ static let attachmentPickerHiddenNotification = Notification . Name ( " attachmentPickerHiddenNotification " )
491+
492+ /// Notification sent when the commands overlay should be hidden.
493+ static let commandsOverlayHiddenNotification = Notification . Name ( " commandsOverlayHiddenNotification " )
465494}
0 commit comments