diff --git a/docs.json b/docs.json index 75e48e794..a8341c34a 100644 --- a/docs.json +++ b/docs.json @@ -2208,6 +2208,7 @@ "ui-kit/flutter/component-styling", "ui-kit/flutter/message-bubble-styling", "ui-kit/flutter/localize", + "ui-kit/flutter/rtl-support", "ui-kit/flutter/sound-manager" ] }, diff --git a/ui-kit/flutter/call-buttons.mdx b/ui-kit/flutter/call-buttons.mdx index 2e61ecdd4..f3be04043 100644 --- a/ui-kit/flutter/call-buttons.mdx +++ b/ui-kit/flutter/call-buttons.mdx @@ -17,7 +17,7 @@ description: "Add CometChat Flutter UI Kit call buttons for voice and video call | View slots | `callSettingsBuilder` | | Styling | `callButtonsStyle` — the app `ThemeData` does not reach inside a kit widget, so scope colours here. | | Prerequisites | `CometChatUIKit` initialised and a user logged in. | -| Full props | [11 props](#functionality) | +| Full props | [12 props](#functionality) | @@ -115,6 +115,23 @@ class _YourScreenState extends State with CometChatCallEventListener *** +## Layout Direction + +`CometChatCallButtons` follows the UI Kit's layout direction. Pass `layoutDirection` to set it for this component only. See [RTL Support](/ui-kit/flutter/rtl-support). + + + +```dart +CometChatCallButtons( + user: user, + layoutDirection: CometChatLayoutDirection.rtl, +) +``` + + + +*** + ## Customization ### Style @@ -148,3 +165,4 @@ CometChatCallButtons( | Video Call Icon | Custom video call icon | `videoCallIcon: Icon?` | | Voice Call Icon | Custom voice call icon | `voiceCallIcon: Icon?` | | Outgoing Call Configuration | Configure outgoing call | `outgoingCallConfiguration: CometChatOutgoingCallConfiguration?` | +| Layout Direction | Layout direction for the buttons: `ltr` or `rtl`. Overrides the UI Kit's global setting; `null` inherits it. See [RTL Support](/ui-kit/flutter/rtl-support) | `layoutDirection: CometChatLayoutDirection?` | diff --git a/ui-kit/flutter/call-logs.mdx b/ui-kit/flutter/call-logs.mdx index 73e32d059..96c3f9813 100644 --- a/ui-kit/flutter/call-logs.mdx +++ b/ui-kit/flutter/call-logs.mdx @@ -18,7 +18,7 @@ description: "Show CometChat Flutter UI Kit call logs with audio/video status, m | Styling | `callLogsStyle` — the app `ThemeData` does not reach inside a kit widget, so scope colours here. | | Layout | Fills its parent — place it in an `Expanded` (or a sized box) inside a `Column`, or layout throws an unbounded-height error at render. | | Prerequisites | `CometChatUIKit` initialised and a user logged in. | -| Full props | [33 props](#functionality) | +| Full props | [34 props](#functionality) | @@ -310,6 +310,7 @@ The `CometChatCallLogs` widget does not emit global events. | `titleView` | `Widget? Function(BuildContext, CallLog)?` | `null` | `titleView` to set title view for each callLog | | `showBackButton` | `bool?` | `null` | Toggle back button visibility | | `callLogsBloc` | `CallLogsBloc?` | `null` | `callLogsBloc` Optional external CallLogsBloc instance. | +| `layoutDirection` | `CometChatLayoutDirection?` | `null` | Layout direction for this component and everything inside it: `ltr` or `rtl`. Overrides the UI Kit's global setting; `null` inherits it. See [RTL Support](/ui-kit/flutter/rtl-support). | **Example — custom back button:** @@ -593,6 +594,22 @@ CometChatCallLogs( --- +## Layout Direction + +`CometChatCallLogs` follows the UI Kit's layout direction. Pass `layoutDirection` to set it for this component only: it overrides the global setting for `CometChatCallLogs` and everything inside it. See [RTL Support](/ui-kit/flutter/rtl-support). + + + +```dart +CometChatCallLogs( + layoutDirection: CometChatLayoutDirection.rtl, +) +``` + + + +--- + ## Style diff --git a/ui-kit/flutter/conversations.mdx b/ui-kit/flutter/conversations.mdx index 854afb5e6..fff7dd528 100644 --- a/ui-kit/flutter/conversations.mdx +++ b/ui-kit/flutter/conversations.mdx @@ -353,6 +353,7 @@ The component listens to these SDK events internally. No manual setup needed. | `searchBoxIcon` | `Widget?` | `null` | `searchBoxIcon` search box prefix icon | | `searchPadding` | `EdgeInsetsGeometry?` | `null` | `searchPadding` provides padding to the search | | `searchContentPadding` | `EdgeInsetsGeometry?` | `null` | `searchContentPadding` provides padding to the search content | +| `layoutDirection` | `CometChatLayoutDirection?` | `null` | Layout direction for this component and everything inside it: `ltr` or `rtl`. Overrides the UI Kit's global setting; `null` inherits it. See [RTL Support](/ui-kit/flutter/rtl-support). | --- @@ -685,6 +686,22 @@ CometChatConversations( --- +## Layout Direction + +`CometChatConversations` follows the UI Kit's layout direction. Pass `layoutDirection` to set it for this component only: it overrides the global setting for `CometChatConversations` and everything inside it. See [RTL Support](/ui-kit/flutter/rtl-support). + + + +```dart +CometChatConversations( + layoutDirection: CometChatLayoutDirection.rtl, +) +``` + + + +--- + ## Style diff --git a/ui-kit/flutter/customization-view-slots.mdx b/ui-kit/flutter/customization-view-slots.mdx index e3b6d5343..44c8ba954 100644 --- a/ui-kit/flutter/customization-view-slots.mdx +++ b/ui-kit/flutter/customization-view-slots.mdx @@ -142,7 +142,12 @@ Use individual slot properties (`leadingView`, `titleView`, `subtitleView`, `tra When you set `bubbleView` on a template, all other template slots (`headerView`, `contentView`, `footerView`, etc.) are ignored since the entire bubble is replaced. +## View Slots in RTL + +Views you pass into a slot are placed inside the component's layout direction. Use direction-aware values (`EdgeInsetsDirectional`, `AlignmentDirectional`, `TextAlign.start`) so they mirror with the rest of the component in RTL. See [Custom Views in RTL](/ui-kit/flutter/rtl-support#custom-views-in-rtl). + ## Related - [Message Template](/ui-kit/flutter/message-template) — Full template structure for message bubbles. - [Customization Overview](/ui-kit/flutter/customization-overview) — See all customization categories. +- [RTL Support](/ui-kit/flutter/rtl-support) — Show components right to left. diff --git a/ui-kit/flutter/group-members.mdx b/ui-kit/flutter/group-members.mdx index ed0af7fc0..08b28edb3 100644 --- a/ui-kit/flutter/group-members.mdx +++ b/ui-kit/flutter/group-members.mdx @@ -17,7 +17,7 @@ description: "Scrollable list of members in a group with scope indicators, searc | Styling | `style` — the app `ThemeData` does not reach inside a kit widget, so scope colours here. | | Layout | Fills its parent — place it in an `Expanded` (or a sized box) inside a `Column`, or layout throws an unbounded-height error at render. | | Prerequisites | `CometChatUIKit` initialised and a user logged in. | -| Full props | [45 props](#functionality) | +| Full props | [46 props](#functionality) | @@ -336,6 +336,7 @@ class _YourScreenState extends State with CometChatGroupEventListene | `hideKickMemberOption` | `bool?` | `null` | Hide kick option in action menu | | `hideScopeChangeOption` | `bool?` | `null` | Hide scope change option | | `usersStatusVisibility` | `bool?` | `true` | Show online/offline status | +| `layoutDirection` | `CometChatLayoutDirection?` | `null` | Layout direction for this component and everything inside it: `ltr` or `rtl`. Overrides the UI Kit's global setting; `null` inherits it. See [RTL Support](/ui-kit/flutter/rtl-support). | --- @@ -543,6 +544,23 @@ Member actions (kick, ban, scope change) are permission-aware based on the logge --- +## Layout Direction + +`CometChatGroupMembers` follows the UI Kit's layout direction. Pass `layoutDirection` to set it for this component only: it overrides the global setting for `CometChatGroupMembers` and everything inside it. See [RTL Support](/ui-kit/flutter/rtl-support). + + + +```dart +CometChatGroupMembers( + group: group, + layoutDirection: CometChatLayoutDirection.rtl, +) +``` + + + +--- + ## Style diff --git a/ui-kit/flutter/groups.mdx b/ui-kit/flutter/groups.mdx index 52e7239c9..1bef13b85 100644 --- a/ui-kit/flutter/groups.mdx +++ b/ui-kit/flutter/groups.mdx @@ -17,7 +17,7 @@ description: "Scrollable list of all available groups with search, avatars, grou | Styling | `groupsStyle` — the app `ThemeData` does not reach inside a kit widget, so scope colours here. | | Layout | Fills its parent — place it in an `Expanded` (or a sized box) inside a `Column`, or layout throws an unbounded-height error at render. | | Prerequisites | `CometChatUIKit` initialised and a user logged in. | -| Full props | [41 props](#functionality) | +| Full props | [42 props](#functionality) | @@ -287,6 +287,7 @@ The component listens to these SDK events internally. No manual setup needed. | `titleView` | `Widget? Function(BuildContext context, Group group)?` | `null` | `titleView` to set title view for each group | | `leadingView` | `Widget? Function(BuildContext context, Group group)?` | `null` | `leadingView` to set leading view for each group | | `trailingView` | `Widget? Function(BuildContext context, Group group)?` | `null` | `trailingView` to set tailView for each group | +| `layoutDirection` | `CometChatLayoutDirection?` | `null` | Layout direction for this component and everything inside it: `ltr` or `rtl`. Overrides the UI Kit's global setting; `null` inherits it. See [RTL Support](/ui-kit/flutter/rtl-support). | --- @@ -484,6 +485,22 @@ For `ListBase` override hooks (`onItemAdded`, `onItemRemoved`, `onItemUpdated`, --- +## Layout Direction + +`CometChatGroups` follows the UI Kit's layout direction. Pass `layoutDirection` to set it for this component only: it overrides the global setting for `CometChatGroups` and everything inside it. See [RTL Support](/ui-kit/flutter/rtl-support). + + + +```dart +CometChatGroups( + layoutDirection: CometChatLayoutDirection.rtl, +) +``` + + + +--- + ## Style diff --git a/ui-kit/flutter/llms-flutter-v6.mdx b/ui-kit/flutter/llms-flutter-v6.mdx index a8aded144..4d45e93fc 100644 --- a/ui-kit/flutter/llms-flutter-v6.mdx +++ b/ui-kit/flutter/llms-flutter-v6.mdx @@ -64,6 +64,12 @@ Widgets render through Flutter's own tree. Non-negotiables: rather than through `CometChatMessageComposer` never reaches an already-mounted `CometChatMessageList` — it only appears on that list's next fetch. Emit `CometChatMessageEvents.ccMessageSent(...)` in `onSuccess`. See [Events](/ui-kit/flutter/events). +- **RTL is `layoutDirection`, and it covers only the kit.** The default, `auto`, follows the + app's direction, so an Arabic locale is right to left with no extra code. `UIKitSettingsBuilder + ..layoutDirection` sets it for every kit component; a component's own `layoutDirection:` wins + for that component. The kit never changes the app's own screens, and wrapping a kit widget in + `Directionality` is ignored while the global setting is `ltr` or `rtl`. See + [RTL Support](/ui-kit/flutter/rtl-support). ## Hot path — usually no fetch needed For a plain "add chat" the install, `init → login → render`, and the core drop-in props are @@ -84,6 +90,7 @@ components, theming tokens, or feature enablement. - [Events](/ui-kit/flutter/events) - [Sound Manager](/ui-kit/flutter/sound-manager) - [Localize](/ui-kit/flutter/localize) +- [RTL Support](/ui-kit/flutter/rtl-support) - [Extensions](/ui-kit/flutter/extensions) - [Troubleshooting](/ui-kit/flutter/troubleshooting) diff --git a/ui-kit/flutter/localize.mdx b/ui-kit/flutter/localize.mdx index 29ed94940..9aae50c12 100644 --- a/ui-kit/flutter/localize.mdx +++ b/ui-kit/flutter/localize.mdx @@ -22,6 +22,10 @@ The UI Kit supports 19 languages: * Arabic (ar), German (de), English (en, en-GB), Spanish (es), French (fr), Hindi (hi), Hungarian (hu), Japanese (ja), Korean (ko), Lithuanian (lt), Malay (ms), Dutch (nl), Portuguese (pt), Russian (ru), Swedish (sv), Turkish (tr), Chinese (zh, zh-TW) + +Language and layout direction are separate settings. With an Arabic locale the UI Kit is right to left by default. To set the direction yourself, see [RTL Support](/ui-kit/flutter/rtl-support). + + ## Usage ### Integration diff --git a/ui-kit/flutter/message-composer.mdx b/ui-kit/flutter/message-composer.mdx index 9c567da2c..c8bad2395 100644 --- a/ui-kit/flutter/message-composer.mdx +++ b/ui-kit/flutter/message-composer.mdx @@ -18,7 +18,7 @@ description: "Configure CometChat Flutter UI Kit Message Composer for text, medi | Sending outside the composer | A message sent with `CometChat.send*Message` instead of through this widget must emit `CometChatMessageEvents.ccMessageSent(...)` in `onSuccess`, or an already-mounted `CometChatMessageList` never shows it. | | Stitching | Pair with `CometChatMessageHeader` and `CometChatMessageList`, passing the same `user` or `group` to all three. | | Prerequisites | `CometChatUIKit` initialised and a user logged in. | -| Full props | [76 props](#message-composer-properties) | +| Full props | [77 props](#message-composer-properties) | @@ -295,6 +295,7 @@ CometChatMessageComposer( | `attachmentErrorAlertStyle` | `CometChatAttachmentErrorAlertStyle?` | `null` | `attachmentErrorAlertStyle` styles every attachment error alert: the toast shown when a selection is over the count/size limit, and the alert stating why a staged attachment was rejected… | | `attachmentErrorSnackBarBuilder` | `SnackBar Function(BuildContext context, AttachmentTile tile)?` | `null` | `attachmentErrorSnackBarBuilder` fully replaces the default error snackbar. | | `onAttachmentErrorTap` | `void Function(BuildContext context, AttachmentTile tile)?` | `null` | `onAttachmentErrorTap` fully overrides the tap/hover action on an errored tile (skips showing the default/custom snackbar entirely). | +| `layoutDirection` | `CometChatLayoutDirection?` | `null` | Layout direction for this component and everything inside it: `ltr` or `rtl`. Overrides the UI Kit's global setting; `null` inherits it. See [RTL Support](/ui-kit/flutter/rtl-support). | *** @@ -399,6 +400,29 @@ CometChatMessageComposer( *** +## Layout Direction + +`CometChatMessageComposer` follows the UI Kit's layout direction. Pass `layoutDirection` to set it for this component only: it overrides the global setting for `CometChatMessageComposer` and everything inside it. See [RTL Support](/ui-kit/flutter/rtl-support). + + + +```dart +CometChatMessageComposer( + user: user, + layoutDirection: CometChatLayoutDirection.rtl, +) +``` + + + +The text field follows the line the cursor is on: an Arabic line makes it right to left, an English line left to right, and an empty field starts at the screen's start side. On iOS, the keyboard's language decides while typing. + + +Flutter's text field uses one direction for all of its lines. When a message mixes Arabic and English lines, all of them sit on one side while you type. Once the message is sent, its bubble places each line on its own side. + + +*** + ## Rich Text Formatting The composer ships with a WYSIWYG rich-text toolbar that parses Markdown as the user types and renders formatted spans in place. Configuration is done with three flat props. diff --git a/ui-kit/flutter/message-header.mdx b/ui-kit/flutter/message-header.mdx index de98d7700..438142161 100644 --- a/ui-kit/flutter/message-header.mdx +++ b/ui-kit/flutter/message-header.mdx @@ -17,7 +17,7 @@ description: "Configure CometChat Flutter UI Kit Message Header with user or gro | Styling | `messageHeaderStyle` — the app `ThemeData` does not reach inside a kit widget, so scope colours here. | | Stitching | Pair with `CometChatMessageList` and `CometChatMessageComposer`, passing the same `user` or `group` to all three. | | Prerequisites | `CometChatUIKit` initialised and a user logged in. | -| Full props | [37 props](#functionality) | +| Full props | [38 props](#functionality) | @@ -178,6 +178,7 @@ The component listens to these SDK events internally. No manual setup needed. | `newChatIcon` | `IconData?` | `null` | `newChatIcon` provides new chat icon | | `chatHistoryIcon` | `IconData?` | `null` | `chatHistoryIcon` provides chat history icon | | `messageHeaderBloc` | `MessageHeaderBloc?` | `null` | Your own bloc, used instead of the one the header creates. The header does not close it on dispose. See [BLoC Access](#bloc-access). *Available since v6.2.0.* | +| `layoutDirection` | `CometChatLayoutDirection?` | `null` | Layout direction for this component and everything inside it: `ltr` or `rtl`. Overrides the UI Kit's global setting; `null` inherits it. See [RTL Support](/ui-kit/flutter/rtl-support). | --- @@ -401,6 +402,23 @@ On v6.1.1 and earlier, `CometChatMessageHeader` has no `messageHeaderBloc` param --- +## Layout Direction + +`CometChatMessageHeader` follows the UI Kit's layout direction. Pass `layoutDirection` to set it for this component only: it overrides the global setting for `CometChatMessageHeader` and everything inside it. See [RTL Support](/ui-kit/flutter/rtl-support). + + + +```dart +CometChatMessageHeader( + user: user, + layoutDirection: CometChatLayoutDirection.rtl, +) +``` + + + +--- + ## Style diff --git a/ui-kit/flutter/message-list.mdx b/ui-kit/flutter/message-list.mdx index dfa9fe2ac..dc8651983 100644 --- a/ui-kit/flutter/message-list.mdx +++ b/ui-kit/flutter/message-list.mdx @@ -328,6 +328,7 @@ The component listens to SDK message events internally. No manual setup needed. | `flagReasonLocalizer` | `String Function(String reasonId)?` | `null` | Custom localizer that converts a flag-reason ID into a display string | | `hideFlagRemarkField` | `bool` | `false` | Hide the optional remark/context text field in the flag dialog | | `loadLastAgentConversation` | `bool` | `false` | Loads the most recent existing agent conversation on start | +| `layoutDirection` | `CometChatLayoutDirection?` | `null` | Layout direction for this component and everything inside it: `ltr` or `rtl`. Overrides the UI Kit's global setting; `null` inherits it. See [RTL Support](/ui-kit/flutter/rtl-support). | \* One of `user` or `group` is required. @@ -817,6 +818,23 @@ The BLoC exposes an `operationsStream` consumed by `CometChatAnimatedMessageList --- +## Layout Direction + +`CometChatMessageList` follows the UI Kit's layout direction. Pass `layoutDirection` to set it for this component only: it overrides the global setting for `CometChatMessageList` and everything inside it. See [RTL Support](/ui-kit/flutter/rtl-support). + + + +```dart +CometChatMessageList( + user: user, + layoutDirection: CometChatLayoutDirection.rtl, +) +``` + + + +--- + ## Style diff --git a/ui-kit/flutter/message-template.mdx b/ui-kit/flutter/message-template.mdx index cea828a92..1c6d893a1 100644 --- a/ui-kit/flutter/message-template.mdx +++ b/ui-kit/flutter/message-template.mdx @@ -30,6 +30,10 @@ The MessageBubble structure can be broken down into: 4. Bottom widget — Additional elements like link previews or "load more" buttons 5. Footer widget — Timestamp and delivery/read status + +`BubbleAlignment` names the side in left-to-right terms: `right` is a message you sent, `left` one you received, and `center` an action message. The names don't change in RTL, so `alignment == BubbleAlignment.right` still means "sent", even though a sent message sits on the left in an RTL layout. Build template views with direction-aware values such as `EdgeInsetsDirectional`, so they mirror with the bubble. See [Custom Views in RTL](/ui-kit/flutter/rtl-support#custom-views-in-rtl). + + ### Properties | Property | Description | diff --git a/ui-kit/flutter/methods.mdx b/ui-kit/flutter/methods.mdx index 4e10fa876..7f89397d4 100644 --- a/ui-kit/flutter/methods.mdx +++ b/ui-kit/flutter/methods.mdx @@ -41,6 +41,7 @@ The `UIKitSettings` is an important parameter of the `init()` function. It funct | enableCalls | Boolean | Turns on calling: `init()` initializes the Calls SDK and `login()` logs the user into it. Default `false`. See [Calling Integration](/ui-kit/flutter/calling-integration) | | callingConfiguration | CallingConfiguration | Settings for the call buttons, the outgoing call screen and group calls | | callPushBridge | CometChatCallPushBridge | Connects the UI Kit to the app's push ringer (`cometchat_voip`), so calls answered on the ring screen join on the UI Kit's call screen. Required for incoming calls on Android and iOS; not used on web | +| layoutDirection | CometChatLayoutDirection | Layout direction for every UI Kit component: `auto` (default, follows the app's direction), `ltr` or `rtl`. See [RTL Support](/ui-kit/flutter/rtl-support) | | offlineConfig | OfflineConfig | Turns on [offline support](/ui-kit/flutter/offline-support) (UI Kit 6.4.0 and Chat SDK 5.1.2 or later). Pass `OfflineConfig(enabled: true)`. Default: off | > **V6 Note:** The `extensions` and `aiFeature` parameters from V5 have been removed. Extensions are built-in and handled automatically by `MessageTemplateUtils`. No registration is needed. @@ -232,6 +233,28 @@ UIKitSettings uiKitSettings = (UIKitSettingsBuilder() ).build(); ``` +## Layout Direction + +Set the layout direction for every UI Kit component with `layoutDirection` at init, and change it later with `CometChatUIKit.setLayoutDirection`. A component's own `layoutDirection` parameter overrides it. See [RTL Support](/ui-kit/flutter/rtl-support). + +| Member | Description | +|---|---| +| `UIKitSettingsBuilder..layoutDirection` | Direction at init: `CometChatLayoutDirection.auto` (default), `.ltr` or `.rtl` | +| `CometChatUIKit.setLayoutDirection(CometChatLayoutDirection value)` | Changes the direction at runtime. Applies to screens opened afterwards; call it after `init()` | +| `CometChatUIKit.layoutDirection` | The current global direction | + +```dart +UIKitSettings uiKitSettings = (UIKitSettingsBuilder() + ..region = CometChatConfig.region + ..appId = CometChatConfig.appId + ..authKey = CometChatConfig.authKey + ..layoutDirection = CometChatLayoutDirection.rtl +).build(); + +// Later, for example from a settings screen: +CometChatUIKit.setLayoutDirection(CometChatLayoutDirection.ltr); +``` + ## AI Assistant Events The UI Kit provides a UI-level event system for AI assistant interactions via `CometChatAIAssistantEvents`. These events mirror the SDK-level `AIAssistantListener` but are scoped to the UI layer for component-level reactions. diff --git a/ui-kit/flutter/notification-feed.mdx b/ui-kit/flutter/notification-feed.mdx index fe3796b77..1fd35139f 100644 --- a/ui-kit/flutter/notification-feed.mdx +++ b/ui-kit/flutter/notification-feed.mdx @@ -16,7 +16,7 @@ description: "Full-screen notification feed component with category filtering, c | Styling | `style` — the app `ThemeData` does not reach inside a kit widget, so scope colours here. | | Layout | Fills its parent — place it in an `Expanded` (or a sized box) inside a `Column`, or layout throws an unbounded-height error at render. | | Prerequisites | `CometChatUIKit` initialised and a user logged in. | -| Full props | [18 props](#properties) | +| Full props | [19 props](#properties) | @@ -220,6 +220,7 @@ The component handles these automatically — no manual setup needed: | `style` | `CometChatNotificationFeedStyle?` | `null` | Style configuration for the notification feed. | | `cardThemeMode` | `CometChatCardThemeMode?` | `null` | Card renderer theme mode | | `cardThemeOverride` | `CometChatCardThemeOverride?` | `null` | Card renderer theme override | +| `layoutDirection` | `CometChatLayoutDirection?` | `null` | Layout direction for this component and everything inside it: `ltr` or `rtl`. Overrides the UI Kit's global setting; `null` inherits it. See [RTL Support](/ui-kit/flutter/rtl-support). | --- @@ -287,6 +288,22 @@ CometChatNotificationFeed( --- +## Layout Direction + +`CometChatNotificationFeed` follows the UI Kit's layout direction. Pass `layoutDirection` to set it for this component only: it overrides the global setting for `CometChatNotificationFeed` and everything inside it. See [RTL Support](/ui-kit/flutter/rtl-support). + + + +```dart +CometChatNotificationFeed( + layoutDirection: CometChatLayoutDirection.rtl, +) +``` + + + +--- + ## Style diff --git a/ui-kit/flutter/outgoing-call.mdx b/ui-kit/flutter/outgoing-call.mdx index 86fccfa7d..07b7b4073 100644 --- a/ui-kit/flutter/outgoing-call.mdx +++ b/ui-kit/flutter/outgoing-call.mdx @@ -17,7 +17,7 @@ description: "Full-screen view displaying recipient information and call status | View slots | `subtitleView` · `sessionSettingsBuilder` · `avatarView` · `titleView` · `cancelledView` — [details](#custom-view-slots) | | Styling | `outgoingCallStyle` — the app `ThemeData` does not reach inside a kit widget, so scope colours here. | | Prerequisites | `CometChatUIKit` initialised and a user logged in. | -| Full props | [17 props](#functionality) | +| Full props | [18 props](#functionality) | @@ -216,6 +216,7 @@ class _YourScreenState extends State with CometChatCallEventListener | `titleView` | `Widget? Function(BuildContext context, Call call)?` | `null` | Title view builder | | `cancelledView` | `Widget? Function(BuildContext context, Call call)?` | `null` | Cancelled view builder (bottom action button) | | `bloc` | `OutgoingCallBloc?` | `null` | Optional external BLoC for testing/injection | +| `layoutDirection` | `CometChatLayoutDirection?` | `null` | Layout direction for this component and everything inside it: `ltr` or `rtl`. Overrides the UI Kit's global setting; `null` inherits it. See [RTL Support](/ui-kit/flutter/rtl-support). | **Example — custom decline icon and disabled sound:** @@ -331,6 +332,24 @@ CometChatOutgoingCall( --- +## Layout Direction + +`CometChatOutgoingCall` follows the UI Kit's layout direction. Pass `layoutDirection` to set it for this component only: it overrides the global setting for `CometChatOutgoingCall` and everything inside it. See [RTL Support](/ui-kit/flutter/rtl-support). + + + +```dart +CometChatOutgoingCall( + user: user, + call: callObject, + layoutDirection: CometChatLayoutDirection.rtl, +) +``` + + + +--- + ## Style diff --git a/ui-kit/flutter/pinned-messages.mdx b/ui-kit/flutter/pinned-messages.mdx index 20fcd918d..955ab04e5 100644 --- a/ui-kit/flutter/pinned-messages.mdx +++ b/ui-kit/flutter/pinned-messages.mdx @@ -16,7 +16,7 @@ description: "A screen listing every pinned message in one conversation, with lo | Presentation | `CometChatPinnedMessages.show(context, ...)` pushes it on the nearest `Navigator`; or embed the widget directly. | | Styling | `style` — the app `ThemeData` does not reach inside a kit widget, so scope colours here. | | Prerequisites | `CometChatUIKit` initialised, a user logged in, and the Pin Message feature enabled for the app. | -| Full props | [7 props](#functionality) | +| Full props | [8 props](#functionality) | @@ -107,11 +107,31 @@ The list is fetched once on open, 100 at a time until exhausted, with a Retry ac | `showBackButton` | `bool` | `true` | Shows the app bar's back arrow, and makes a row tap pop the screen. Set it to `false` when the list is embedded in a host-owned panel — the tap then leaves the host's route alone. | | `hideAppBar` | `bool` | `false` | Drops the header entirely. Set it when the host already renders a title bar — a desktop side panel does, and two stacked headers is the result otherwise. | | `style` | `CometChatPinnedMessagesStyle?` | `null` | Styling overrides. | +| `layoutDirection` | `CometChatLayoutDirection?` | `null` | Layout direction for this component and everything inside it: `ltr` or `rtl`. Overrides the UI Kit's global setting; `null` inherits it. See [RTL Support](/ui-kit/flutter/rtl-support). | The `show` helper takes the same parameters after `context`. When the Message Header opens the screen for you, it forwards only `user`, `group`, `onItemTap` (from `onPinnedMessageItemTap`) and `style` (from `pinnedMessagesStyle`) — to set `hideUnpinOption` or the layout flags, handle `onPinnedMessagesTap` and call `show` yourself. --- +## Layout Direction + +`CometChatPinnedMessages` follows the UI Kit's layout direction. Pass `layoutDirection` to set it for this component only: it overrides the global setting for `CometChatPinnedMessages` and everything inside it. See [RTL Support](/ui-kit/flutter/rtl-support). + + + +```dart +CometChatPinnedMessages( + group: group, + layoutDirection: CometChatLayoutDirection.rtl, +) +``` + + + +`CometChatPinnedMessages.show(...)` opens the screen in the direction of the screen it's called from. + +--- + ## Style Rows are real message bubbles, so they follow your bubble styling. `CometChatPinnedMessagesStyle` styles the screen around them: diff --git a/ui-kit/flutter/rtl-support.mdx b/ui-kit/flutter/rtl-support.mdx new file mode 100644 index 000000000..fcc57cff3 --- /dev/null +++ b/ui-kit/flutter/rtl-support.mdx @@ -0,0 +1,251 @@ +--- +title: "RTL Support" +description: "Show CometChat Flutter UI Kit components right to left for Arabic and other RTL languages, globally or per component, with layoutDirection." +--- + + + +| Field | Value | +| --- | --- | +| Package | `cometchat_chat_uikit` | +| Import | `import 'package:cometchat_chat_uikit/cometchat_chat_uikit.dart';` | +| Purpose | Show UI Kit components right to left (RTL) or left to right (LTR), for the whole kit or for one component. | +| Global setting | `UIKitSettingsBuilder..layoutDirection` at init, `CometChatUIKit.setLayoutDirection(...)` at runtime | +| Per component | `layoutDirection` parameter on every screen component | +| Values | `CometChatLayoutDirection.auto` (default) · `.ltr` · `.rtl` | +| Default behavior | `auto` follows the app's own direction, so an app with an Arabic locale is RTL with no extra code | +| Related | [Localize](/ui-kit/flutter/localize) · [Methods](/ui-kit/flutter/methods) · [Customization Overview](/ui-kit/flutter/customization-overview) | + + + +## Overview + +Languages such as Arabic are read right to left. In an RTL layout, the UI Kit mirrors every component: avatars, names, buttons, message bubbles, menus and sheets swap sides, and arrows point the other way. + +Mirroring the layout doesn't mean flipping the content. The UI Kit keeps every piece of content readable: + +* Each message line reads in its own direction, so an English line in an Arabic chat still reads left to right. +* Names, mentions and numbers keep their order inside the text around them. +* Audio and video players stay left to right, as they do in every RTL app. + +## Layout Direction and Language + +Layout direction and language are two separate settings: + +| Setting | Decides | Set with | +| --- | --- | --- | +| Layout direction | Which side things sit on | `layoutDirection` | +| Language | Which strings are shown | The app's locale (see [Localize](/ui-kit/flutter/localize)) | + +By default the layout direction follows the language: an app whose locale is Arabic is RTL. You can also set them apart, for example an English app set to RTL, or an Arabic app kept LTR. + +## Turn On RTL + +### Follow the app's language (default) + +With the default value, `CometChatLayoutDirection.auto`, the UI Kit uses the direction the app is already in. `MaterialApp` makes the app RTL when its locale is an RTL language, so setting an Arabic locale is all you need: + + + +```dart +MaterialApp( + locale: const Locale('ar'), + supportedLocales: CometChatLocalize.supportedLocales, + localizationsDelegates: CometChatLocalize.localizationsDelegates, + home: const YourHomeScreen(), +) +``` + + + +See [Localize](/ui-kit/flutter/localize) for the full locale setup. + +### Set it for the whole UI Kit + +Pass `layoutDirection` in `UIKitSettings` to give every UI Kit component a fixed direction, whatever the language: + + + +```dart +UIKitSettings uiKitSettings = (UIKitSettingsBuilder() + ..appId = "your_appID" + ..region = "your_region" + ..authKey = "your_authKey" + ..layoutDirection = CometChatLayoutDirection.rtl +).build(); + +CometChatUIKit.init(uiKitSettings: uiKitSettings); +``` + + + +| Value | Result | +| --- | --- | +| `CometChatLayoutDirection.auto` | Follows the app's direction. This is the default, so apps that don't set it see no change. | +| `CometChatLayoutDirection.ltr` | Every UI Kit component is left to right. | +| `CometChatLayoutDirection.rtl` | Every UI Kit component is right to left. | + +### Change it at runtime + +Use `CometChatUIKit.setLayoutDirection` to change the direction while the app is running, for example from a settings screen. Read the current value with `CometChatUIKit.layoutDirection`. + + + +```dart +CometChatUIKit.setLayoutDirection(CometChatLayoutDirection.rtl); + +final current = CometChatUIKit.layoutDirection; // CometChatLayoutDirection.rtl +``` + + + + +The new direction applies to screens opened after the change. A screen that is already open keeps its direction until it is reopened. `init()` sets the direction again from `UIKitSettings.layoutDirection`, so call `setLayoutDirection` after `init()`. + + +## Set It Per Component + +Every screen component takes a `layoutDirection` parameter. It overrides the global setting for that component and everything inside it: + + + +```dart +// The whole kit is RTL, but this list stays LTR. +CometChatConversations( + layoutDirection: CometChatLayoutDirection.ltr, +) +``` + + + +Leave it `null` (or pass `auto`) to inherit the direction from the component around it, or from the global setting. + +These components take `layoutDirection`: + +| Chat | Calls | Messages | +| --- | --- | --- | +| [Conversations](/ui-kit/flutter/conversations) | [Call Buttons](/ui-kit/flutter/call-buttons) | [Message Header](/ui-kit/flutter/message-header) | +| [Users](/ui-kit/flutter/users) | [Call Logs](/ui-kit/flutter/call-logs) | [Message List](/ui-kit/flutter/message-list) | +| [Groups](/ui-kit/flutter/groups) | [Outgoing Call](/ui-kit/flutter/outgoing-call) | [Message Composer](/ui-kit/flutter/message-composer) | +| [Group Members](/ui-kit/flutter/group-members) | `CometChatOngoingCall` | [Threaded Messages Header](/ui-kit/flutter/threaded-messages-header) | +| [Search](/ui-kit/flutter/search) | | `CometChatMessageInformation` | +| [Notification Feed](/ui-kit/flutter/notification-feed) | | [Pinned Messages](/ui-kit/flutter/pinned-messages) | +| `CometChatAIAssistantChatHistory` | | [Saved Messages](/ui-kit/flutter/saved-messages) | + + +On Android and iOS, incoming calls ring on the system call screen, which follows the phone's language. The deprecated `CometChatIncomingCall` screen (web only) has no `layoutDirection`; it follows the app's direction. + + +## Which Setting Wins + +When settings disagree, the first rule that gives a direction wins: + +1. Audio and video players are always left to right. +2. The component's own `layoutDirection`, when it is `ltr` or `rtl`. +3. The nearest UI Kit component around it that has its own `layoutDirection`. +4. The global setting, when it is `ltr` or `rtl`. +5. The app's own direction, or left to right when there is none. + +So wrapping a component in Flutter's `Directionality` changes it only while the global setting is `auto`. To force one component's direction, use its `layoutDirection` parameter. + +## App Screens Outside the UI Kit + +The UI Kit never changes your app's direction. With a global `ltr` or `rtl`, the UI Kit's components follow it but your own screens stay as they are. To give your own screens the same direction, set the direction in `MaterialApp.builder`: + + + +```dart +MaterialApp( + locale: locale, + // ... + builder: (context, child) { + final direction = CometChatUIKit.layoutDirection.toTextDirection(); + if (direction == null) return child!; // auto: the locale decides + return Directionality(textDirection: direction, child: child!); + }, +) +``` + + + +With `auto` the locale decides for both your screens and the UI Kit, so nothing extra is needed. + +## What Changes in RTL + +### Layout + +Everything that has a side moves to the other one: avatars, titles, subtitles, timestamps, unread badges, receipts, buttons, the composer's actions, message bubbles, menus, sheets, swipe actions and list indicators. Sent messages sit on the left and received messages on the right. + +### Icons + +| Icon | In RTL | +| --- | --- | +| Arrows that point along the reading direction: back, forward, send, reply, reply in thread, and call-direction arrows (incoming, outgoing, missed) | Flip on every platform | +| Video camera, copy, chat and sticker | Flip on Android and web; stay as drawn on iOS and macOS, following Apple's guidelines | +| Everything else: phone handset, microphone, attach, emoji, close, search, receipt ticks, pin, media controls, file types, logos | Stay as drawn | + +Icons you pass into the UI Kit are drawn as you give them. For an arrow that should flip, use an icon with `matchTextDirection: true` (Material's arrow icons already have it). + +### What doesn't mirror + +* **Audio and video players**, including voice notes and the recorder: playback controls and progress bars stay left to right in every language. +* **Code blocks in AI assistant replies** stay left to right. + +### Message text + +* **Each line reads in its own direction.** The first letter of a line decides it: a line that starts with an English letter reads left to right, one that starts with an Arabic letter reads right to left. A line with no letters (only emoji or numbers) follows the bubble. +* **Names and mentions keep their place.** A user's name can't scramble the sentence around it, and a mention always reads `@name`, whatever the language of the name or the line. +* **Numbers and dates.** When the UI Kit's language is Arabic, dates, times and counts it formats use Arabic digits (٠١٢٣٤٥٦٧٨٩). An English app set to RTL keeps English dates and Western digits. Text you supply yourself, for example from a date formatter callback, is shown as given. +* **Text the UI Kit writes** keeps its language's order: in an English app set to RTL, "Delete this chat?" still ends with its question mark. + +## Custom Views in RTL + +Views you pass into the UI Kit (view slots, custom message templates, custom bubbles) are placed inside the component's direction, so they read `Directionality.of(context)` like any Flutter widget. Use direction-aware values so they mirror with the rest of the UI Kit: + +| Instead of | Use | +| --- | --- | +| `EdgeInsets.only(left: 8)` | `EdgeInsetsDirectional.only(start: 8)` | +| `Alignment.centerLeft` | `AlignmentDirectional.centerStart` | +| `BorderRadius.only(topLeft: ...)` | `BorderRadiusDirectional.only(topStart: ...)` | +| `Positioned(left: 0)` | `PositionedDirectional(start: 0)` | +| `TextAlign.left` | `TextAlign.start` | + + + +```dart +CometChatConversations( + subtitleView: (context, conversation) => Padding( + // Mirrors with the list: 8 px on the left in LTR, on the right in RTL. + padding: const EdgeInsetsDirectional.only(start: 8), + child: Text( + conversation.lastMessage?.sender?.name ?? '', + textAlign: TextAlign.start, + ), + ), +) +``` + + + +`Row`, `ListTile` and other Flutter layouts already follow the direction. + +## Languages + +The UI Kit ships Arabic translations. For another RTL language, such as Hebrew, Persian or Urdu, add the language as described in [Adding New Language Support](/ui-kit/flutter/localize#adding-new-language-support). Once its locale is set, `auto` lays the UI Kit out right to left. + +## Next Steps + + + + Set the UI Kit's language and translations + + + UIKitSettings and CometChatUIKit reference + + + Custom views, templates and styles + + + Common RTL questions + + diff --git a/ui-kit/flutter/saved-messages.mdx b/ui-kit/flutter/saved-messages.mdx index 1d38b95d9..2f6de8b9d 100644 --- a/ui-kit/flutter/saved-messages.mdx +++ b/ui-kit/flutter/saved-messages.mdx @@ -16,7 +16,7 @@ description: "A screen listing the logged-in user's saved messages across every | Presentation | No built-in entry point — push it from your own app chrome (a profile menu, a settings row, a tab). | | Styling | `style` — the app `ThemeData` does not reach inside a kit widget, so scope colours here. | | Prerequisites | `CometChatUIKit` initialised, a user logged in, and the Save Message feature enabled for the app. | -| Full props | [6 props](#functionality) | +| Full props | [7 props](#functionality) | @@ -95,6 +95,7 @@ The list is fetched once on open, 100 at a time until exhausted, with a Retry ac | `showBackButton` | `bool` | `true` | Shows the app-bar back button. | | `useCloseButton` | `bool` | `false` | Swaps the leading back arrow for a trailing ✕ with the title left-aligned — the chrome a desktop panel uses, where the screen is dismissed rather than navigated back from. Only read when `showBackButton` is `true`. | | `style` | `CometChatSavedMessagesStyle?` | `null` | Styling overrides. | +| `layoutDirection` | `CometChatLayoutDirection?` | `null` | Layout direction for this component and everything inside it: `ltr` or `rtl`. Overrides the UI Kit's global setting; `null` inherits it. See [RTL Support](/ui-kit/flutter/rtl-support). | ### Responsive presentation @@ -114,6 +115,22 @@ CometChatSavedMessages( --- +## Layout Direction + +`CometChatSavedMessages` follows the UI Kit's layout direction. Pass `layoutDirection` to set it for this component only: it overrides the global setting for `CometChatSavedMessages` and everything inside it. See [RTL Support](/ui-kit/flutter/rtl-support). + + + +```dart +CometChatSavedMessages( + layoutDirection: CometChatLayoutDirection.rtl, +) +``` + + + +--- + ## Style | Property | Applies to | diff --git a/ui-kit/flutter/search.mdx b/ui-kit/flutter/search.mdx index 1f82fab50..463268473 100644 --- a/ui-kit/flutter/search.mdx +++ b/ui-kit/flutter/search.mdx @@ -17,7 +17,7 @@ description: "Add CometChat Flutter UI Kit search for conversations and messages | Styling | `searchStyle` — the app `ThemeData` does not reach inside a kit widget, so scope colours here. | | Layout | Fills its parent — place it in an `Expanded` (or a sized box) inside a `Column`, or layout throws an unbounded-height error at render. | | Prerequisites | `CometChatUIKit` initialised and a user logged in. | -| Full props | [35 props](#functionality) | +| Full props | [36 props](#functionality) | @@ -222,6 +222,7 @@ CometChatSearch( | `searchAudioMessageView` | `Widget? Function(BuildContext, MediaMessage)?` | `null` | Replaces the row used for an audio-message result. | | `conversationsRequestBuilder` | `ConversationsRequestBuilder?` | `null` | `conversationsRequestBuilder` Request builder to fetch conversations. | | `messagesRequestBuilder` | `MessagesRequestBuilder?` | `null` | Request builder used to fetch message results. | +| `layoutDirection` | `CometChatLayoutDirection?` | `null` | Layout direction for this component and everything inside it: `ltr` or `rtl`. Overrides the UI Kit's global setting; `null` inherits it. See [RTL Support](/ui-kit/flutter/rtl-support). | --- @@ -315,6 +316,22 @@ The search widget uses `SearchBloc` internally: --- +## Layout Direction + +`CometChatSearch` follows the UI Kit's layout direction. Pass `layoutDirection` to set it for this component only: it overrides the global setting for `CometChatSearch` and everything inside it. See [RTL Support](/ui-kit/flutter/rtl-support). + + + +```dart +CometChatSearch( + layoutDirection: CometChatLayoutDirection.rtl, +) +``` + + + +--- + ## Style diff --git a/ui-kit/flutter/threaded-messages-header.mdx b/ui-kit/flutter/threaded-messages-header.mdx index b03a99c51..8ac408c72 100644 --- a/ui-kit/flutter/threaded-messages-header.mdx +++ b/ui-kit/flutter/threaded-messages-header.mdx @@ -16,7 +16,7 @@ description: "Header component for threaded conversations showing the parent mes | View slots | `messageActionView` — [details](#custom-view-slots) | | Styling | `style` — the app `ThemeData` does not reach inside a kit widget, so scope colours here. | | Prerequisites | `CometChatUIKit` initialised and a user logged in. | -| Full props | [14 props](#functionality) | +| Full props | [15 props](#functionality) | @@ -225,6 +225,7 @@ Set `threadSubscriptionVisibility: false` to hide the control, for example when | `typography` | `CometChatTypography?` | `null` | `typography` optional pre-cached typography for optimization | | `spacing` | `CometChatSpacing?` | `null` | `spacing` optional pre-cached spacing for optimization | | `threadedHeaderBloc` | `ThreadedHeaderBloc?` | `null` | Your own bloc, used instead of the one the header creates. The header neither initializes nor closes it. See [BLoC Access](#bloc-access). *Available since v6.2.0.* | +| `layoutDirection` | `CometChatLayoutDirection?` | `null` | Layout direction for this component and everything inside it: `ltr` or `rtl`. Overrides the UI Kit's global setting; `null` inherits it. See [RTL Support](/ui-kit/flutter/rtl-support). | --- @@ -310,6 +311,24 @@ class _ThreadScreenState extends State { --- +## Layout Direction + +`CometChatThreadedHeader` follows the UI Kit's layout direction. Pass `layoutDirection` to set it for this component only: it overrides the global setting for `CometChatThreadedHeader` and everything inside it. See [RTL Support](/ui-kit/flutter/rtl-support). + + + +```dart +CometChatThreadedHeader( + parentMessage: parentMessage, + loggedInUser: loggedInUser, + layoutDirection: CometChatLayoutDirection.rtl, +) +``` + + + +--- + ## Style diff --git a/ui-kit/flutter/troubleshooting.mdx b/ui-kit/flutter/troubleshooting.mdx index b766fc5cc..c96dcc515 100644 --- a/ui-kit/flutter/troubleshooting.mdx +++ b/ui-kit/flutter/troubleshooting.mdx @@ -103,6 +103,18 @@ description: "Troubleshoot CometChat Flutter UI Kit V6 setup, login, theming, st --- +## RTL + +| Symptom | Cause | Fix | +|---|---|---| +| UI Kit screens are RTL but the app's own screens aren't | The UI Kit's `layoutDirection` doesn't change the app's direction | Set the same direction in `MaterialApp.builder`. See [App Screens Outside the UI Kit](/ui-kit/flutter/rtl-support#app-screens-outside-the-ui-kit) | +| An open screen didn't flip after `setLayoutDirection` | A new direction applies to screens opened afterwards | Close and reopen the screen | +| Arabic text but a left-to-right layout | `layoutDirection` is set to `ltr`, globally or on the component | Use `CometChatLayoutDirection.auto` to follow the locale, or `rtl` | +| Wrapping a component in `Directionality` has no effect | A global `ltr` or `rtl` wins over the app's direction | Pass `layoutDirection` to the component instead | +| A custom view doesn't mirror in RTL | It uses `left`/`right` values | Use `EdgeInsetsDirectional`, `AlignmentDirectional` and `TextAlign.start`. See [Custom Views in RTL](/ui-kit/flutter/rtl-support#custom-views-in-rtl) | + +--- + ## Sound | Symptom | Cause | Fix | diff --git a/ui-kit/flutter/users.mdx b/ui-kit/flutter/users.mdx index b2eeae452..fb20c8506 100644 --- a/ui-kit/flutter/users.mdx +++ b/ui-kit/flutter/users.mdx @@ -17,7 +17,7 @@ description: "Scrollable list of all available users with search, avatars, names | Styling | `usersStyle` — the app `ThemeData` does not reach inside a kit widget, so scope colours here. | | Layout | Fills its parent — place it in an `Expanded` (or a sized box) inside a `Column`, or layout throws an unbounded-height error at render. | | Prerequisites | `CometChatUIKit` initialised and a user logged in. | -| Full props | [35 props](#functionality) | +| Full props | [36 props](#functionality) | @@ -276,6 +276,7 @@ The component listens to these SDK events internally. No manual setup needed. | `trailingView` | `Widget? Function(BuildContext context, User user)?` | `null` | Replaces the trailing slot of each user row. | | `usersBloc` | `UsersBloc?` | `null` | External BLoC instance. Pass one to share list state with another widget instead of letting this one create its own. | | `usersRequestBuilder` | `UsersRequestBuilder?` | `null` | `usersRequestBuilder` custom request builder for filtering users | +| `layoutDirection` | `CometChatLayoutDirection?` | `null` | Layout direction for this component and everything inside it: `ltr` or `rtl`. Overrides the UI Kit's global setting; `null` inherits it. See [RTL Support](/ui-kit/flutter/rtl-support). | --- @@ -498,6 +499,22 @@ For `ListBase` override hooks (`onItemAdded`, `onItemRemoved`, `onItemUpdated`, --- +## Layout Direction + +`CometChatUsers` follows the UI Kit's layout direction. Pass `layoutDirection` to set it for this component only: it overrides the global setting for `CometChatUsers` and everything inside it. See [RTL Support](/ui-kit/flutter/rtl-support). + + + +```dart +CometChatUsers( + layoutDirection: CometChatLayoutDirection.rtl, +) +``` + + + +--- + ## Style