You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: migrations/redesign/message_composer.md
+8-10Lines changed: 8 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -202,12 +202,10 @@ StreamComponentFactory(
202
202
203
203
## Message Input Placeholder API
204
204
205
-
The input placeholder text (the dimmed text shown inside the input field when it is empty) is now driven by a sealed-class hierarchy that adapts to the current input state. The previous `HintType` enum and `HintGetter` typedef have been removed, and the customization hook on `StreamMessageInput` is now called `placeholderBuilder`.
205
+
The input placeholder text (the dimmed text shown inside the input field when it is empty) is now driven by a sealed-class hierarchy that adapts to the current input state. The previous `HintType` enum and `HintGetter` typedef have been removed, and the customization hook on `StreamMessageComposer` is now called `placeholderBuilder`.
206
206
207
207
The new placeholder types live in `lib/src/message_input/message_input_placeholder.dart` and are re-exported from `package:stream_chat_flutter/stream_chat_flutter.dart`.
208
208
209
-
> **Layered model.** The placeholder *resolution* (state machine that turns controller state into a string) lives on `StreamMessageInput`, the higher-level full-featured widget. The lower-level `StreamChatMessageComposer` design-system component stays a pure UI primitive and accepts a plain `String placeholder` — see [StreamChatMessageComposer (new)](#streamchatmessagecomposer-new). If you build directly on `StreamChatMessageComposer`, call `MessageInputPlaceholder.resolve(controller)` and your own builder yourself, then pass the resulting string in.
210
-
211
209
### What was removed
212
210
213
211
| Removed | Replacement |
@@ -216,8 +214,8 @@ The new placeholder types live in `lib/src/message_input/message_input_placehold
|`Command? resolveActiveMessageInputCommand(context, controller)`| Removed. Use `controller.message.command` (a `String?`) directly. The SDK no longer looks up the full `Command` object from the channel config when resolving the placeholder. |
219
-
|`String? defaultMessageInputHintGetter(...)`| Removed from the public API. The default behaviour is now baked into `StreamMessageInput.placeholderBuilder`'s default value. To customize, supply your own builder with an exhaustive `switch` over [`MessageInputPlaceholder`](#sealed-class-state-shape). |
|`String? defaultMessageInputHintGetter(...)`| Removed from the public API. The default behaviour is now baked into `StreamMessageComposer.placeholderBuilder`'s default value. To customize, supply your own builder with an exhaustive `switch` over [`MessageInputPlaceholder`](#sealed-class-state-shape). |
@@ -257,15 +255,15 @@ Each case carries the contextual data relevant to that input state. Pattern-matc
257
255
| Case | Field | Type | Description |
258
256
|------|-------|------|-------------|
259
257
|`WriteMessagePlaceholder`|`isEditing`|`bool`|`true` when the input is editing an existing message instead of composing a new one. Useful for swapping the placeholder while editing. |
260
-
|`SlowModePlaceholder`|`cooldownTimeOut`|`int`| Remaining slow-mode cooldown in seconds. Mirrors `StreamMessageInputController.cooldownTimeOut`. |
258
+
|`SlowModePlaceholder`|`cooldownTimeOut`|`int`| Remaining slow-mode cooldown in seconds. Mirrors `StreamMessageComposerController.cooldownTimeOut`. |
261
259
|`SlowModePlaceholder`|`cooldown`|`Duration`| Convenience getter wrapping `cooldownTimeOut` for formatting timer strings. |
262
260
|`CommandPlaceholder`|`command`|`String`| Active command name (e.g. `'giphy'`, `'mute'`, `'ban'`, or any backend-defined command). |
263
261
|`AttachmentsPlaceholder`|`attachments`|`List<Attachment>`| Pending attachments held by the input. OG link previews are still included — filter via `Attachment.ogScrapeUrl` if you only want user-added ones. |
264
262
265
263
Example using the new fields (note that the sealed type forces an exhaustive switch — every case must be handled):
266
264
267
265
```dart
268
-
StreamMessageInput(
266
+
StreamMessageComposer(
269
267
placeholderBuilder: (context, placeholder) {
270
268
final translations = context.translations;
271
269
return switch (placeholder) {
@@ -310,7 +308,7 @@ StreamMessageInput(
310
308
**After:**
311
309
312
310
```dart
313
-
StreamMessageInput(
311
+
StreamMessageComposer(
314
312
placeholderBuilder: (context, placeholder) {
315
313
return switch (placeholder) {
316
314
SlowModePlaceholder() => 'Slow mode is on',
@@ -327,7 +325,7 @@ StreamMessageInput(
327
325
For backend-defined custom commands, pattern-match the relevant `CommandPlaceholder.command` values and use the SDK's localized labels for everything else:
328
326
329
327
```dart
330
-
StreamMessageInput(
328
+
StreamMessageComposer(
331
329
placeholderBuilder: (context, placeholder) {
332
330
final translations = context.translations;
333
331
return switch (placeholder) {
@@ -431,6 +429,6 @@ The following public widgets are provided as building blocks for custom attachme
431
429
-[ ] Replace `quotedMessageBuilder` / `quotedMessageAttachmentThumbnailBuilders` with `messageComposerInputHeader` or `messageComposerAttachment` overrides in `StreamComponentFactory`
432
430
-[ ] If adopting `StreamMessageComposer` directly, wire up your own send/attachment logic via `onSendPressed` and `onAttachmentButtonPressed`
433
431
-[ ] Move any composer UI customizations to `StreamComponentFactory`
434
-
-[ ] Rename `StreamMessageInput.hintGetter` to `placeholderBuilder` and rewrite the callback to switch over `MessageInputPlaceholder` cases (`SlowModePlaceholder`, `CommandPlaceholder`, `AttachmentsPlaceholder`, `WriteMessagePlaceholder`) instead of the removed `HintType` enum. If you build directly on `StreamChatMessageComposer`, compute the placeholder string yourself via `MessageInputPlaceholder.resolve(controller)` and pass it via the `placeholder: String` parameter.
432
+
-[ ] Rename `StreamMessageInput.hintGetter` to `StreamMessageComposer.placeholderBuilder` and rewrite the callback to switch over `MessageInputPlaceholder` cases (`SlowModePlaceholder`, `CommandPlaceholder`, `AttachmentsPlaceholder`, `WriteMessagePlaceholder`) instead of the removed `HintType` enum.
435
433
-[ ] Review the new placeholder precedence (`slowMode > command > attachments > writeMessage`) and override `placeholderBuilder` if you need to preserve the old order
436
434
-[ ] Add command-specific placeholders for any backend-defined commands you ship by pattern-matching on `CommandPlaceholder.command` in your `placeholderBuilder`
0 commit comments