Skip to content

Commit

Permalink
feat(footer): 0.2.0 support custom footer
Browse files Browse the repository at this point in the history
  • Loading branch information
vokhuyetOz committed May 13, 2024
1 parent 5608b90 commit 0d0cca0
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 11 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ import { Messy } from '@vokhuyet/react-native-messy';
}}
user={{id: account?.user?.id}}
footerProps={{
hideEmoji: false;
hideFooterAction: false;
Send: <Image source={require('NewSendIcon.png')} />
onSend,
ExtraLeft: <ChatListExtraLeft />,
ExtraActionLeft: <ChatListExtraActionLeft />,
Expand Down Expand Up @@ -137,6 +140,9 @@ import { Messy } from '@vokhuyet/react-native-messy';
### TMessyFooterProps

```ts
hideEmoji?: false;
hideFooterAction?: false;
Send?: React.ReactNode;
onSend?: (message?: TMessyMessage) => Promise<void> | void;
inputProps?: TextInputProps;
ExtraLeft?: React.ReactNode;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@vokhuyet/react-native-messy",
"version": "0.1.9",
"version": "0.2.0",
"description": "chat ui",
"main": "lib/commonjs/index",
"module": "lib/module/index",
Expand Down
26 changes: 17 additions & 9 deletions src/MessyFooter/MessyFooter.default.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import React, {
type RefObject,
useCallback,
cloneElement,
isValidElement,
} from 'react';
import {
Image,
Expand Down Expand Up @@ -402,7 +403,18 @@ function MessyFooterTextInput({
function MessyFooterSend({ onPress }: TMessyFooterSend) {
const Sizes = useSizes();
const { footerProps } = useMessyPropsContext();

const renderSend = () => {
if (isValidElement(footerProps?.Send)) {
return footerProps.Send;
}
return (
<Image
source={require('../utils/images/send.png')}
style={{ width: Sizes.button_image, height: Sizes.button_image }}
resizeMode={'contain'}
/>
);
};
return (
<Pressable
disabled={footerProps?.disabled}
Expand All @@ -411,11 +423,7 @@ function MessyFooterSend({ onPress }: TMessyFooterSend) {
paddingLeft: Sizes.padding,
}}
>
<Image
source={require('../utils/images/send.png')}
style={{ width: Sizes.button_image, height: Sizes.button_image }}
resizeMode={'contain'}
/>
{renderSend()}
</Pressable>
);
}
Expand Down Expand Up @@ -485,7 +493,7 @@ export function MessyFooterDefault(props: TMessyFooterProps) {
let ExtraLeftWithProps = props.ExtraLeft;
if (props.ExtraLeft) {
ExtraLeftWithProps = cloneElement(props.ExtraLeft as React.ReactElement, {
animatedPosition: emojiShared,
animatedPosition: leftExtraShared,
});
}

Expand Down Expand Up @@ -519,11 +527,11 @@ export function MessyFooterDefault(props: TMessyFooterProps) {
textInputRef={textInputRef}
onChangeText={onChangeText}
/>
<MessyFooterEmoji emojiShared={emojiShared} />
{!props.hideEmoji && <MessyFooterEmoji emojiShared={emojiShared} />}
</View>
<MessyFooterSend onPress={onPressSendText} />
</View>
<MessyFooterAction />
{!props.hideFooterAction && <MessyFooterAction />}
</View>
{/* fakeview keyboard */}
<Animated.View style={fakeViewKeyboard} />
Expand Down
5 changes: 4 additions & 1 deletion src/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import type {
} from 'react-native';
import type { ParseShape } from 'react-native-parsed-text';
import type { Asset } from 'react-native-image-picker';
import { TColor } from './modules';
import type { TColor } from './modules';

type TListProps = Omit<
FlatListProps<any>,
Expand Down Expand Up @@ -122,8 +122,11 @@ export type TMessyMessage = {

export type TMessyFooterProps = Readonly<{
disabled?: boolean;
hideEmoji?: boolean;
hideFooterAction?: boolean;
onSend?: (message?: TMessyMessage) => Promise<void> | void;
inputProps?: TextInputProps;
Send?: React.ReactNode;
ExtraLeft?: React.ReactNode;
ExtraActionLeft?: React.ReactNode;
renderFooter?: FC<TMessyFooterProps>;
Expand Down

0 comments on commit 0d0cca0

Please sign in to comment.