Skip to content

Commit 7f3a5a8

Browse files
committed
add missing props to the readme. options -> actions
1 parent fd76dc6 commit 7f3a5a8

5 files changed

Lines changed: 37 additions & 27 deletions

File tree

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,10 +355,12 @@ interface QuickReplies {
355355
- **`messageContainerRef`** _(FlatList ref)_ - Ref to the flatlist
356356
- **`textInputRef`** _(TextInput ref)_ - Ref to the text input
357357
- **`messages`** _(Array)_ - Messages to display
358+
- **`messagesContainerStyle`** _(Object)_ - Custom style for the messages container
358359
- **`isTyping`** _(Bool)_ - Typing Indicator state; default `false`. If you use`renderFooter` it will override this.
359360
- **`keyboardBottomOffset`** _(Integer)_ - Distance between the bottom of the screen and bottom of the `GiftedChat` component. Useful when you have a tab bar or navigation bar; default is `0`. Needed for correct keyboard avoiding behavior. Without it you might see gap between the keyboard and the input toolbar if you have a tab bar, navigation bar, or safe area.
360361
- **`isKeyboardInternallyHandled`** _(Bool)_ - Determine whether to handle keyboard awareness inside the plugin. If you have your own keyboard handling outside the plugin set this to false; default is `true`
361362
- **`text`** _(String)_ - Input text; default is `undefined`, but if specified, it will override GiftedChat's internal state (e.g. for redux; [see notes below](#notes-for-redux))
363+
- **`initialText`** _(String)_ - Initial text to display in the input field
362364
- **`onInputTextChanged`** _(Function)_ - Callback when the input text changes
363365
- **`messageIdGenerator`** _(Function)_ - Generate an id for new messages. Defaults to UUID v4, generated by [uuid](https://github.com/kelektiv/node-uuid)
364366
- **`user`** _(Object)_ - User sending the messages: `{ _id, name, avatar }`
@@ -400,13 +402,17 @@ interface QuickReplies {
400402
- **`renderMessageText`** _(Function)_ - Custom message text
401403
- **`renderMessageImage`** _(Function)_ - Custom message image
402404
- **`renderMessageVideo`** _(Function)_ - Custom message video
405+
- **`renderMessageAudio`** _(Function)_ - Custom message audio
403406
- **`imageProps`** _(Object)_ - Extra props to be passed to the [`<Image>`](https://reactnative.dev/docs/image.html) component created by the default `renderMessageImage`
407+
- **`imageStyle`** _(Object)_ - Custom style for message images
404408
- **`videoProps`** _(Object)_ - Extra props to be passed to the video component created by the required `renderMessageVideo`
405409
- **`isCustomViewBottom`** _(Bool)_ - Determine whether renderCustomView is displayed before or after the text, image and video views; default is `false`
406410
- **`renderCustomView`** _(Function)_ - Custom view inside the bubble
407411
- **`renderDay`** _(Function)_ - Custom day above a message
408412
- **`renderTime`** _(Function)_ - Custom time inside a message
413+
- **`timeTextStyle`** _(Object)_ - Custom text style for time inside messages (supports left/right styles)
409414
- **`renderFooter`** _(Function)_ - Custom footer component on the ListView, e.g. `'User is typing...'`; see [App.tsx](/example/App.tsx) for an example. Overrides default typing indicator that triggers when `isTyping` is true.
415+
- **`renderTypingIndicator`** _(Function)_ - Custom typing indicator component
410416
- **`renderChatEmpty`** _(Function)_ - Custom component to render in the ListView when messages are empty
411417
- **`renderChatFooter`** _(Function)_ - Custom component to render below the MessageContainer (separate from the ListView)
412418
- **`renderInputToolbar`** _(Function)_ - Custom message composer container
@@ -415,6 +421,9 @@ interface QuickReplies {
415421
- **`renderSend`** _(Function)_ - Custom send button; you can pass children to the original `Send` component quite easily, for example, to use a custom icon ([example](https://github.com/FaridSafi/react-native-gifted-chat/pull/487))
416422
- **`renderAccessory`** _(Function)_ - Custom second line of actions below the message composer
417423
- **`onPressActionButton`** _(Function)_ - Callback when the Action button is pressed (if set, the default `actionSheet` will not be used)
424+
- **`actionSheet`** _(Function)_ - Custom action sheet interface for showing action options
425+
- **`actions`** _(Array)_ - Custom action options for the input toolbar action button; array of objects with `title` (string) and `action` (function) properties
426+
- **`actionSheetOptionTintColor`** _(String)_ - Tint color for action sheet options
418427
- **`focusOnInputWhenOpeningKeyboard`** _(Bool)_ - Focus on <TextInput> automatically when opening the keyboard; default `true`
419428
- **`minInputToolbarHeight`** _(Integer)_ - Minimum height of the input toolbar; default is `44`
420429
- **`listProps`** _(Object)_ - Extra props to be passed to the messages [`<FlatList>`](https://reactnative.dev/docs/flatlist.html); some props can't be overridden, see the code in `MessageContainer.render()` for details
@@ -463,9 +472,12 @@ Example:
463472
* **`onQuickReply`** _(Function)_ - Callback when sending a quick reply (to backend server)
464473
* **`renderQuickReplies`** _(Function)_ - Custom all quick reply view
465474
* **`quickReplyStyle`** _(StyleProp<ViewStyle>)_ - Custom quick reply view style
475+
* **`quickReplyTextStyle`** _(StyleProp<TextStyle>)_ - Custom text style for quick reply buttons
476+
* **`quickReplyContainerStyle`** _(StyleProp<ViewStyle>)_ - Custom container style for quick replies
466477
* **`renderQuickReplySend`** _(Function)_ - Custom quick reply **send** view
467478
* **`shouldUpdateMessage`** _(Function)_ - Lets the message component know when to update outside of normal cases.
468479
* **`typingIndicatorStyle`** _(StyleProp<ViewStyle>)_ - Custom style for the TypingIndicator component.
480+
* **`handleOnScroll`** _(Function)_ - Custom scroll event handler for the message list
469481

470482
## Notes for [Redux](https://github.com/reactjs/redux)
471483

src/Actions.tsx

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ import { useChatContext } from './GiftedChatContext'
1414
import stylesCommon from './styles'
1515

1616
export interface ActionsProps {
17-
options?: { [key: string]: () => void }
18-
optionTintColor?: string
17+
actions?: Array<{ title: string, action: () => void }>
18+
actionSheetOptionTintColor?: string
1919
icon?: () => ReactNode
2020
wrapperStyle?: StyleProp<ViewStyle>
2121
iconTextStyle?: StyleProp<TextStyle>
@@ -24,8 +24,8 @@ export interface ActionsProps {
2424
}
2525

2626
export function Actions ({
27-
options,
28-
optionTintColor = Color.optionTintColor,
27+
actions,
28+
actionSheetOptionTintColor = Color.optionTintColor,
2929
icon,
3030
wrapperStyle,
3131
iconTextStyle,
@@ -35,28 +35,26 @@ export function Actions ({
3535
const { actionSheet } = useChatContext()
3636

3737
const onActionsPress = useCallback(() => {
38-
if (!options)
38+
if (!actions?.length)
3939
return
4040

41-
const optionKeys = Object.keys(options)
42-
const cancelButtonIndex = optionKeys.indexOf('Cancel')
41+
const titles = actions.map(item => item.title)
4342

4443
actionSheet().showActionSheetWithOptions(
4544
{
46-
options: optionKeys,
47-
cancelButtonIndex,
48-
tintColor: optionTintColor,
45+
options: titles,
46+
cancelButtonIndex: titles.length - 1,
47+
tintColor: actionSheetOptionTintColor,
4948
},
50-
(buttonIndex: number | undefined) => {
49+
(buttonIndex?: number) => {
5150
if (buttonIndex === undefined)
5251
return
5352

54-
const key = optionKeys[buttonIndex]
55-
if (key)
56-
options[key]()
53+
const item = actions[buttonIndex]
54+
item.action?.()
5755
}
5856
)
59-
}, [actionSheet, options, optionTintColor])
57+
}, [actionSheet, actions, actionSheetOptionTintColor])
6058

6159
const renderIcon = useCallback(() => {
6260
if (icon)

src/GiftedChat/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import Animated, {
2727
withTiming,
2828
runOnJS,
2929
} from 'react-native-reanimated'
30+
import { SafeAreaProvider } from 'react-native-safe-area-context'
3031
import { Actions } from '../Actions'
3132
import { Avatar } from '../Avatar'
3233
import Bubble from '../Bubble'
@@ -45,14 +46,13 @@ import { Send } from '../Send'
4546
import stylesCommon from '../styles'
4647
import { SystemMessage } from '../SystemMessage'
4748
import { Time } from '../Time'
49+
4850
import {
4951
IMessage,
5052
} from '../types'
51-
5253
import * as utils from '../utils'
5354
import styles from './styles'
5455
import { GiftedChatProps } from './types'
55-
import { SafeAreaProvider } from 'react-native-safe-area-context'
5656

5757
dayjs.extend(localizedFormat)
5858

src/GiftedChat/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ export interface GiftedChatProps<TMessage extends IMessage> extends Partial<Mess
7777
minComposerHeight?: number
7878
/* composer min Height */
7979
maxComposerHeight?: number
80-
options?: { [key: string]: () => void }
81-
optionTintColor?: string
80+
actions?: Array<{ title: string, action: () => void }>
81+
actionSheetOptionTintColor?: string
8282
quickReplyStyle?: StyleProp<ViewStyle>
8383
quickReplyTextStyle?: StyleProp<TextStyle>
8484
quickReplyContainerStyle?: StyleProp<ViewStyle>

src/InputToolbar.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import { Send, SendProps } from './Send'
88
import { IMessage } from './types'
99

1010
export interface InputToolbarProps<TMessage extends IMessage> {
11-
options?: { [key: string]: () => void }
12-
optionTintColor?: string
11+
actions?: Array<{ title: string, action: () => void }>
12+
actionSheetOptionTintColor?: string
1313
containerStyle?: StyleProp<ViewStyle>
1414
primaryStyle?: StyleProp<ViewStyle>
1515
accessoryStyle?: StyleProp<ViewStyle>
@@ -31,8 +31,8 @@ export function InputToolbar<TMessage extends IMessage = IMessage> (
3131
renderComposer,
3232
renderSend,
3333
renderAccessory,
34-
options,
35-
optionTintColor,
34+
actions,
35+
actionSheetOptionTintColor,
3636
icon,
3737
wrapperStyle,
3838
containerStyle,
@@ -43,8 +43,8 @@ export function InputToolbar<TMessage extends IMessage = IMessage> (
4343
const actionsFragment = useMemo(() => {
4444
const props = {
4545
onPressActionButton,
46-
options,
47-
optionTintColor,
46+
actions,
47+
actionSheetOptionTintColor,
4848
icon,
4949
wrapperStyle,
5050
containerStyle,
@@ -56,8 +56,8 @@ export function InputToolbar<TMessage extends IMessage = IMessage> (
5656
}, [
5757
renderActions,
5858
onPressActionButton,
59-
options,
60-
optionTintColor,
59+
actions,
60+
actionSheetOptionTintColor,
6161
icon,
6262
wrapperStyle,
6363
containerStyle,

0 commit comments

Comments
 (0)