Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Allow QuickReplies component container styles to be customised #2271

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions flow-typedefs/Bubble.js.flow
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ export type BubbleProps<TMessage: IMessage = IMessage> = $ReadOnly<{|
containerToPreviousStyle?: LeftRightStyle<ViewStyleProp>,
usernameStyle?: TextStyleProp,
quickReplyStyle?: ViewStyleProp,
quickReplyTextStyle?: TextStyleProp,
quickReplyContainerStyle?: ViewStyleProp,
onLongPress?: (context?: any, message?: any) => void,
onQuickReply?: (Array<Reply>) => void,
renderMessageImage?: (RenderMessageImageProps<TMessage>) => React.Node,
Expand Down
2 changes: 2 additions & 0 deletions flow-typedefs/GiftedChat.js.flow
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ export type GiftedChatProps<TMessage: IMessage = IMessage> = $ReadOnly<{|
},
optionTintColor?: string,
quickReplyStyle?: ViewStyleProp,
quickReplyTextStyle?: TextStyleProp,
quickReplyContainerStyle?: ViewStyleProp,
isCustomViewBottom?: boolean,
timeTextStyle?: LeftRightStyle<TextStyleProp>,
onPressAvatar?: User => void,
Expand Down
4 changes: 3 additions & 1 deletion flow-typedefs/QuickReplies.js.flow
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
// @flow
import * as React from 'react'
import type { IMessage, Reply } from './types'
import type { ViewStyleProp } from 'react-native/Libraries/StyleSheet/StyleSheet'
import type { ViewStyleProp, TextStyleProp } from 'react-native/Libraries/StyleSheet/StyleSheet'

export type QuickRepliesProps<TMessage: IMessage = IMessage> = $ReadOnly<{|
nextMessage?: TMessage,
currentMessage?: TMessage,
color?: string,
sendText?: string,
quickReplyStyle?: ViewStyleProp,
quickReplyTextStyle?: TextStyleProp,
quickReplyContainerStyle?: ViewStyleProp,
onQuickReply: (Array<Reply>) => void,
renderQuickReplySend?: () => React.Node,
|}>
Expand Down
3 changes: 3 additions & 0 deletions src/Bubble.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ export interface BubbleProps<TMessage extends IMessage> {
usernameStyle?: TextStyle
quickReplyStyle?: StyleProp<ViewStyle>
quickReplyTextStyle?: StyleProp<TextStyle>
quickReplyContainerStyle?: StyleProp<ViewStyle>
onPress?(context?: any, message?: any): void
onLongPress?(context?: any, message?: any): void
onQuickReply?(replies: Reply[]): void
Expand Down Expand Up @@ -335,6 +336,7 @@ export default class Bubble<
renderQuickReplySend,
quickReplyStyle,
quickReplyTextStyle,
quickReplyContainerStyle,
} = this.props
if (currentMessage && currentMessage.quickReplies) {
const { containerStyle, wrapperStyle, ...quickReplyProps } = this.props
Expand All @@ -348,6 +350,7 @@ export default class Bubble<
renderQuickReplySend={renderQuickReplySend}
quickReplyStyle={quickReplyStyle}
quickReplyTextStyle={quickReplyTextStyle}
quickReplyContainerStyle={quickReplyContainerStyle}
nextMessage={nextMessage}
/>
)
Expand Down
1 change: 1 addition & 0 deletions src/GiftedChat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ export interface GiftedChatProps<TMessage extends IMessage = IMessage> {
optionTintColor?: string
quickReplyStyle?: StyleProp<ViewStyle>
quickReplyTextStyle?: StyleProp<TextStyle>
quickReplyContainerStyle?: StyleProp<ViewStyle>
/* optional prop used to place customView below text, image and video views; default is false */
isCustomViewBottom?: boolean
/* infinite scroll up when reach the top of messages container, automatically call onLoadEarlier function if exist */
Expand Down
4 changes: 3 additions & 1 deletion src/QuickReplies.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export interface QuickRepliesProps<TMessage extends IMessage = IMessage> {
sendText?: string
quickReplyStyle?: StyleProp<ViewStyle>
quickReplyTextStyle?: StyleProp<TextStyle>
quickReplyContainerStyle?: StyleProp<ViewStyle>
onQuickReply?(reply: Reply[]): void
renderQuickReplySend?(): React.ReactNode
}
Expand All @@ -68,6 +69,7 @@ export function QuickReplies({
color = Color.peterRiver,
quickReplyStyle,
quickReplyTextStyle,
quickReplyContainerStyle,
onQuickReply,
sendText = 'Send',
renderQuickReplySend,
Expand Down Expand Up @@ -132,7 +134,7 @@ export function QuickReplies({
}

return (
<View style={styles.container}>
<View style={[styles.container, quickReplyContainerStyle]}>
{currentMessage!.quickReplies!.values.map(
(reply: Reply, index: number) => {
const selected = type === 'checkbox' && replies.find(sameReply(reply))
Expand Down