[FIX] `AttachedActions`'s button (#3989)
* fix: `AttachedActions`'s button * fix: text color * update: `Message.storyshot`
This commit is contained in:
parent
f56bf819d2
commit
49c92cfa7b
|
@ -13,6 +13,15 @@ import MessageContext from './Context';
|
|||
import { useTheme } from '../../theme';
|
||||
import { IAttachment } from '../../definitions';
|
||||
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) => {
|
||||
if (!attachment.actions) {
|
||||
|
@ -21,15 +30,26 @@ const AttachedActions = ({ attachment }: IMessageAttachedActions) => {
|
|||
const { onAnswerButtonPress } = useContext(MessageContext);
|
||||
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') {
|
||||
return <Button theme={theme} onPress={() => onAnswerButtonPress(element.msg)} title={element.text} />;
|
||||
return <Button theme={theme} onPress={onPress} title={element.text} />;
|
||||
}
|
||||
|
||||
return null;
|
||||
});
|
||||
return (
|
||||
<>
|
||||
<Text style={styles.text}>{attachment.text}</Text>
|
||||
<Text style={[styles.text, { color: themes[theme].bodyText }]}>{attachment.text}</Text>
|
||||
{attachedButtons}
|
||||
</>
|
||||
);
|
||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue