[FIX] `AttachedActions`'s button (#3989)

* fix: `AttachedActions`'s button

* fix: text color

* update: `Message.storyshot`
This commit is contained in:
Gerzon Z 2022-03-30 17:55:57 -04:00 committed by GitHub
parent f56bf819d2
commit 49c92cfa7b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 4 deletions

View File

@ -13,6 +13,15 @@ import MessageContext from './Context';
import { useTheme } from '../../theme'; import { useTheme } from '../../theme';
import { IAttachment } from '../../definitions'; import { IAttachment } from '../../definitions';
import CollapsibleQuote from './Components/CollapsibleQuote'; import CollapsibleQuote from './Components/CollapsibleQuote';
import openLink from '../../utils/openLink';
import { themes } from '../../constants/colors';
export type TElement = {
type: string;
msg?: string;
url?: string;
text: string;
};
const AttachedActions = ({ attachment }: IMessageAttachedActions) => { const AttachedActions = ({ attachment }: IMessageAttachedActions) => {
if (!attachment.actions) { if (!attachment.actions) {
@ -21,15 +30,26 @@ const AttachedActions = ({ attachment }: IMessageAttachedActions) => {
const { onAnswerButtonPress } = useContext(MessageContext); const { onAnswerButtonPress } = useContext(MessageContext);
const { theme } = useTheme(); const { theme } = useTheme();
const attachedButtons = attachment.actions.map((element: { type: string; msg: string; text: string }) => { const attachedButtons = attachment.actions.map((element: TElement) => {
const onPress = () => {
if (element.msg) {
onAnswerButtonPress(element.msg);
}
if (element.url) {
openLink(element.url);
}
};
if (element.type === 'button') { if (element.type === 'button') {
return <Button theme={theme} onPress={() => onAnswerButtonPress(element.msg)} title={element.text} />; return <Button theme={theme} onPress={onPress} title={element.text} />;
} }
return null; return null;
}); });
return ( return (
<> <>
<Text style={styles.text}>{attachment.text}</Text> <Text style={[styles.text, { color: themes[theme].bodyText }]}>{attachment.text}</Text>
{attachedButtons} {attachedButtons}
</> </>
); );

File diff suppressed because one or more lines are too long