@planningcenter/chat-react-native 3.5.0 → 3.5.1-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/components/conversation/attachments/audio_attachment.d.ts.map +1 -1
- package/build/components/conversation/attachments/audio_attachment.js +2 -1
- package/build/components/conversation/attachments/audio_attachment.js.map +1 -1
- package/build/components/conversation/attachments/expanded_link.d.ts.map +1 -1
- package/build/components/conversation/attachments/expanded_link.js +2 -1
- package/build/components/conversation/attachments/expanded_link.js.map +1 -1
- package/build/components/conversation/attachments/generic_file_attachment.d.ts.map +1 -1
- package/build/components/conversation/attachments/generic_file_attachment.js +2 -1
- package/build/components/conversation/attachments/generic_file_attachment.js.map +1 -1
- package/build/components/conversation/attachments/giphy_attachment.d.ts.map +1 -1
- package/build/components/conversation/attachments/giphy_attachment.js +2 -1
- package/build/components/conversation/attachments/giphy_attachment.js.map +1 -1
- package/build/components/conversation/attachments/image_attachment.d.ts.map +1 -1
- package/build/components/conversation/attachments/image_attachment.js +3 -1
- package/build/components/conversation/attachments/image_attachment.js.map +1 -1
- package/build/components/conversation/attachments/video_attachment.d.ts.map +1 -1
- package/build/components/conversation/attachments/video_attachment.js +3 -1
- package/build/components/conversation/attachments/video_attachment.js.map +1 -1
- package/build/components/conversation/message.d.ts.map +1 -1
- package/build/components/conversation/message.js +42 -19
- package/build/components/conversation/message.js.map +1 -1
- package/build/components/display/action_button.js +5 -2
- package/build/components/display/action_button.js.map +1 -1
- package/build/screens/conversation_screen.d.ts.map +1 -1
- package/build/screens/conversation_screen.js +2 -2
- package/build/screens/conversation_screen.js.map +1 -1
- package/build/utils/styles.d.ts +1 -0
- package/build/utils/styles.d.ts.map +1 -1
- package/build/utils/styles.js +1 -0
- package/build/utils/styles.js.map +1 -1
- package/package.json +2 -2
- package/src/components/conversation/attachments/audio_attachment.tsx +3 -0
- package/src/components/conversation/attachments/expanded_link.tsx +7 -1
- package/src/components/conversation/attachments/generic_file_attachment.tsx +3 -0
- package/src/components/conversation/attachments/giphy_attachment.tsx +2 -0
- package/src/components/conversation/attachments/image_attachment.tsx +3 -0
- package/src/components/conversation/attachments/video_attachment.tsx +4 -0
- package/src/components/conversation/message.tsx +77 -33
- package/src/components/display/action_button.tsx +6 -2
- package/src/screens/conversation_screen.tsx +2 -2
- package/src/utils/styles.ts +2 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"audio_attachment.d.ts","sourceRoot":"","sources":["../../../../src/components/conversation/attachments/audio_attachment.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,EAAE,qCAAqC,EAAE,MAAM,2DAA2D,CAAA;AAQjH,wBAAgB,eAAe,CAAC,EAC9B,UAAU,EACV,4BAA4B,GAC7B,EAAE;IACD,UAAU,EAAE,qCAAqC,CAAA;IACjD,4BAA4B,EAAE,CAAC,UAAU,EAAE,qCAAqC,KAAK,IAAI,CAAA;CAC1F,
|
|
1
|
+
{"version":3,"file":"audio_attachment.d.ts","sourceRoot":"","sources":["../../../../src/components/conversation/attachments/audio_attachment.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,EAAE,qCAAqC,EAAE,MAAM,2DAA2D,CAAA;AAQjH,wBAAgB,eAAe,CAAC,EAC9B,UAAU,EACV,4BAA4B,GAC7B,EAAE;IACD,UAAU,EAAE,qCAAqC,CAAA;IACjD,4BAA4B,EAAE,CAAC,UAAU,EAAE,qCAAqC,KAAK,IAAI,CAAA;CAC1F,qBAqDA"}
|
|
@@ -8,6 +8,7 @@ import { Audio } from '../../../utils/native_adapters';
|
|
|
8
8
|
import { PlatformPressable } from '@react-navigation/elements';
|
|
9
9
|
export function AudioAttachment({ attachment, onMessageAttachmentLongPress, }) {
|
|
10
10
|
const styles = useStyles();
|
|
11
|
+
const { colors } = useTheme();
|
|
11
12
|
const { attributes } = attachment;
|
|
12
13
|
const { url, filename } = attributes;
|
|
13
14
|
const sound = Audio.useAudio(url);
|
|
@@ -28,7 +29,7 @@ export function AudioAttachment({ attachment, onMessageAttachmentLongPress, }) {
|
|
|
28
29
|
return 'Loading...';
|
|
29
30
|
}
|
|
30
31
|
}
|
|
31
|
-
return (<PlatformPressable onLongPress={() => onMessageAttachmentLongPress(attachment)} accessibilityHint="Long press for more options">
|
|
32
|
+
return (<PlatformPressable onLongPress={() => onMessageAttachmentLongPress(attachment)} android_ripple={{ color: colors.androidRippleNeutral, foreground: true }} accessibilityHint="Long press for more options">
|
|
32
33
|
<AttachmentCard>
|
|
33
34
|
<View style={styles.container}>
|
|
34
35
|
<IconButton name={sound.isPlaying ? 'services.pause' : 'services.play'} size="md" accessibilityLabel={sound.isPlaying ? 'Pause' : 'Play'} onPress={toggleAudio} disabled={!sound} style={styles.button}/>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"audio_attachment.js","sourceRoot":"","sources":["../../../../src/components/conversation/attachments/audio_attachment.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAErD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC1C,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAA;AACvE,OAAO,EAAE,MAAM,EAAE,MAAM,iCAAiC,CAAA;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,gCAAgC,CAAA;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAA;AAE9D,MAAM,UAAU,eAAe,CAAC,EAC9B,UAAU,EACV,4BAA4B,GAI7B;IACC,MAAM,MAAM,GAAG,SAAS,EAAE,CAAA;IAC1B,MAAM,EAAE,UAAU,EAAE,GAAG,UAAU,CAAA;IACjC,MAAM,E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AAE,CAAC;YACP,UAAU,EAAE,EAAE;YACd,GAAG,EAAE,CAAC;SACP;QACD,iBAAiB,EAAE;YACjB,MAAM,EAAE,CAAC;YACT,eAAe,EAAE,MAAM;YACvB,YAAY,EAAE,GAAG;YACjB,QAAQ,EAAE,QAAQ;SACnB;QACD,WAAW,EAAE;YACX,MAAM,EAAE,MAAM;YACd,eAAe,EAAE,MAAM;SACxB;QACD,YAAY,EAAE;YACZ,QAAQ,EAAE,MAAM,CAAC,UAAU;YAC3B,KAAK,EAAE,MAAM,CAAC,yBAAyB;SACxC;KACF,CAAC,CAAA;AACJ,CAAC,CAAA","sourcesContent":["import React from 'react'\nimport { View, Text, StyleSheet } from 'react-native'\nimport { DenormalizedMessageAttachmentResource } from '../../../types/resources/denormalized_attachment_resource'\nimport { IconButton } from '../../display'\nimport { AttachmentCard, AttachmentCardTitle } from './attachment_card'\nimport { tokens } from '../../../vendor/tapestry/tokens'\nimport { useTheme } from '../../../hooks'\nimport { Audio } from '../../../utils/native_adapters'\nimport { PlatformPressable } from '@react-navigation/elements'\n\nexport function AudioAttachment({\n attachment,\n onMessageAttachmentLongPress,\n}: {\n attachment: DenormalizedMessageAttachmentResource\n onMessageAttachmentLongPress: (attachment: DenormalizedMessageAttachmentResource) => void\n}) {\n const styles = useStyles()\n const { attributes } = attachment\n const { url, filename } = attributes\n const sound = Audio.useAudio(url)\n\n function toggleAudio() {\n if (!sound.isPlaying) {\n sound.play()\n } else {\n sound.pause()\n }\n }\n\n const progress = sound.duration > 0 ? sound.position / sound.duration : 0\n\n function durationText() {\n if (sound.duration > 0) {\n return `${Math.floor(sound.position / 1000)}s / ${Math.floor(sound.duration / 1000)}s`\n } else {\n return 'Loading...'\n }\n }\n\n return (\n <PlatformPressable\n onLongPress={() => onMessageAttachmentLongPress(attachment)}\n accessibilityHint=\"Long press for more options\"\n >\n <AttachmentCard>\n <View style={styles.container}>\n <IconButton\n name={sound.isPlaying ? 'services.pause' : 'services.play'}\n size=\"md\"\n accessibilityLabel={sound.isPlaying ? 'Pause' : 'Play'}\n onPress={toggleAudio}\n disabled={!sound}\n style={styles.button}\n />\n <View style={styles.details}>\n <AttachmentCardTitle>{filename}</AttachmentCardTitle>\n <View style={styles.progressContainer}>\n <View style={[styles.progressBar, { width: `${progress * 100}%` }]} />\n </View>\n <Text style={styles.durationText}>{durationText()}</Text>\n </View>\n </View>\n </AttachmentCard>\n </PlatformPressable>\n )\n}\n\nconst useStyles = () => {\n const { colors } = useTheme()\n\n return StyleSheet.create({\n container: {\n flexDirection: 'row',\n },\n button: {\n width: 42,\n height: 42,\n justifyContent: 'center',\n alignItems: 'center',\n borderRadius: 25,\n backgroundColor: '#eee',\n borderColor: '#aaa',\n borderWidth: 1,\n },\n buttonText: {\n fontSize: 32,\n lineHeight: 32,\n },\n details: {\n flex: 1,\n marginLeft: 10,\n gap: 5,\n },\n progressContainer: {\n height: 5,\n backgroundColor: '#ccc',\n borderRadius: 2.5,\n overflow: 'hidden',\n },\n progressBar: {\n height: '100%',\n backgroundColor: 'blue',\n },\n durationText: {\n fontSize: tokens.fontSizeXs,\n color: colors.textColorDefaultSecondary,\n },\n })\n}\n"]}
|
|
1
|
+
{"version":3,"file":"audio_attachment.js","sourceRoot":"","sources":["../../../../src/components/conversation/attachments/audio_attachment.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAErD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC1C,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAA;AACvE,OAAO,EAAE,MAAM,EAAE,MAAM,iCAAiC,CAAA;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,gCAAgC,CAAA;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,4B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aAAa,EAAE,KAAK;SACrB;QACD,MAAM,EAAE;YACN,KAAK,EAAE,EAAE;YACT,MAAM,EAAE,EAAE;YACV,cAAc,EAAE,QAAQ;YACxB,UAAU,EAAE,QAAQ;YACpB,YAAY,EAAE,EAAE;YAChB,eAAe,EAAE,MAAM;YACvB,WAAW,EAAE,MAAM;YACnB,WAAW,EAAE,CAAC;SACf;QACD,UAAU,EAAE;YACV,QAAQ,EAAE,EAAE;YACZ,UAAU,EAAE,EAAE;SACf;QACD,OAAO,EAAE;YACP,IAAI,EAAE,CAAC;YACP,UAAU,EAAE,EAAE;YACd,GAAG,EAAE,CAAC;SACP;QACD,iBAAiB,EAAE;YACjB,MAAM,EAAE,CAAC;YACT,eAAe,EAAE,MAAM;YACvB,YAAY,EAAE,GAAG;YACjB,QAAQ,EAAE,QAAQ;SACnB;QACD,WAAW,EAAE;YACX,MAAM,EAAE,MAAM;YACd,eAAe,EAAE,MAAM;SACxB;QACD,YAAY,EAAE;YACZ,QAAQ,EAAE,MAAM,CAAC,UAAU;YAC3B,KAAK,EAAE,MAAM,CAAC,yBAAyB;SACxC;KACF,CAAC,CAAA;AACJ,CAAC,CAAA","sourcesContent":["import React from 'react'\nimport { View, Text, StyleSheet } from 'react-native'\nimport { DenormalizedMessageAttachmentResource } from '../../../types/resources/denormalized_attachment_resource'\nimport { IconButton } from '../../display'\nimport { AttachmentCard, AttachmentCardTitle } from './attachment_card'\nimport { tokens } from '../../../vendor/tapestry/tokens'\nimport { useTheme } from '../../../hooks'\nimport { Audio } from '../../../utils/native_adapters'\nimport { PlatformPressable } from '@react-navigation/elements'\n\nexport function AudioAttachment({\n attachment,\n onMessageAttachmentLongPress,\n}: {\n attachment: DenormalizedMessageAttachmentResource\n onMessageAttachmentLongPress: (attachment: DenormalizedMessageAttachmentResource) => void\n}) {\n const styles = useStyles()\n const { colors } = useTheme()\n\n const { attributes } = attachment\n const { url, filename } = attributes\n const sound = Audio.useAudio(url)\n\n function toggleAudio() {\n if (!sound.isPlaying) {\n sound.play()\n } else {\n sound.pause()\n }\n }\n\n const progress = sound.duration > 0 ? sound.position / sound.duration : 0\n\n function durationText() {\n if (sound.duration > 0) {\n return `${Math.floor(sound.position / 1000)}s / ${Math.floor(sound.duration / 1000)}s`\n } else {\n return 'Loading...'\n }\n }\n\n return (\n <PlatformPressable\n onLongPress={() => onMessageAttachmentLongPress(attachment)}\n android_ripple={{ color: colors.androidRippleNeutral, foreground: true }}\n accessibilityHint=\"Long press for more options\"\n >\n <AttachmentCard>\n <View style={styles.container}>\n <IconButton\n name={sound.isPlaying ? 'services.pause' : 'services.play'}\n size=\"md\"\n accessibilityLabel={sound.isPlaying ? 'Pause' : 'Play'}\n onPress={toggleAudio}\n disabled={!sound}\n style={styles.button}\n />\n <View style={styles.details}>\n <AttachmentCardTitle>{filename}</AttachmentCardTitle>\n <View style={styles.progressContainer}>\n <View style={[styles.progressBar, { width: `${progress * 100}%` }]} />\n </View>\n <Text style={styles.durationText}>{durationText()}</Text>\n </View>\n </View>\n </AttachmentCard>\n </PlatformPressable>\n )\n}\n\nconst useStyles = () => {\n const { colors } = useTheme()\n\n return StyleSheet.create({\n container: {\n flexDirection: 'row',\n },\n button: {\n width: 42,\n height: 42,\n justifyContent: 'center',\n alignItems: 'center',\n borderRadius: 25,\n backgroundColor: '#eee',\n borderColor: '#aaa',\n borderWidth: 1,\n },\n buttonText: {\n fontSize: 32,\n lineHeight: 32,\n },\n details: {\n flex: 1,\n marginLeft: 10,\n gap: 5,\n },\n progressContainer: {\n height: 5,\n backgroundColor: '#ccc',\n borderRadius: 2.5,\n overflow: 'hidden',\n },\n progressBar: {\n height: '100%',\n backgroundColor: 'blue',\n },\n durationText: {\n fontSize: tokens.fontSizeXs,\n color: colors.textColorDefaultSecondary,\n },\n })\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expanded_link.d.ts","sourceRoot":"","sources":["../../../../src/components/conversation/attachments/expanded_link.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAIzB,OAAO,EAAE,0CAA0C,EAAE,MAAM,2DAA2D,CAAA;AAGtH,wBAAgB,YAAY,CAAC,EAC3B,UAAU,EACV,kBAAkB,GACnB,EAAE;IACD,UAAU,EAAE,0CAA0C,CAAA;IACtD,kBAAkB,EAAE,MAAM,IAAI,CAAA;CAC/B,
|
|
1
|
+
{"version":3,"file":"expanded_link.d.ts","sourceRoot":"","sources":["../../../../src/components/conversation/attachments/expanded_link.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAIzB,OAAO,EAAE,0CAA0C,EAAE,MAAM,2DAA2D,CAAA;AAGtH,wBAAgB,YAAY,CAAC,EAC3B,UAAU,EACV,kBAAkB,GACnB,EAAE;IACD,UAAU,EAAE,0CAA0C,CAAA;IACtD,kBAAkB,EAAE,MAAM,IAAI,CAAA;CAC/B,qBA8BA"}
|
|
@@ -5,6 +5,7 @@ import { tokens } from '../../../vendor/tapestry/tokens';
|
|
|
5
5
|
import { PlatformPressable } from '@react-navigation/elements';
|
|
6
6
|
export function ExpandedLink({ attachment, onMessageLongPress, }) {
|
|
7
7
|
const styles = useStyles();
|
|
8
|
+
const { colors } = useTheme();
|
|
8
9
|
const { attributes } = attachment;
|
|
9
10
|
const { url, title, description, imageUrl, imageHeight, imageWidth } = attributes;
|
|
10
11
|
const aspectRatio = imageWidth && imageHeight ? imageWidth / imageHeight : 1;
|
|
@@ -12,7 +13,7 @@ export function ExpandedLink({ attachment, onMessageLongPress, }) {
|
|
|
12
13
|
if (url)
|
|
13
14
|
Linking.openURL(url);
|
|
14
15
|
}
|
|
15
|
-
return (<PlatformPressable style={styles.container} onPress={openUrl} onLongPress={onMessageLongPress}>
|
|
16
|
+
return (<PlatformPressable style={styles.container} android_ripple={{ color: colors.androidRippleNeutral, foreground: true }} onPress={openUrl} onLongPress={onMessageLongPress}>
|
|
16
17
|
{imageUrl && (<Image source={{ uri: imageUrl }} style={[styles.image, { aspectRatio }]} alt={title}/>)}
|
|
17
18
|
{(title || description) && (<View style={styles.textWrapper}>
|
|
18
19
|
{title && <Text style={styles.title}>{title}</Text>}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expanded_link.js","sourceRoot":"","sources":["../../../../src/components/conversation/attachments/expanded_link.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AACrE,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,iCAAiC,CAAA;AAExD,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAA;AAE9D,MAAM,UAAU,YAAY,CAAC,EAC3B,UAAU,EACV,kBAAkB,GAInB;IACC,MAAM,MAAM,GAAG,SAAS,EAAE,CAAA;IAC1B,MAAM,EAAE,UAAU,EAAE,GAAG,UAAU,CAAA;IACjC,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,WAAW,EAAE,UAAU,EAAE,GAAG,UAAU,CAAA;IAEjF,MAAM,WAAW,GAAG,UAAU,IAAI,WAAW,CAAC,CAAC,CAAC,UAAU,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,CAAA;IAE5E,KAAK,UAAU,OAAO;QACpB,IAAI,GAAG;YAAE,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;IAC/B,CAAC;IAED,OAAO,CACL,CAAC,iBAAiB,
|
|
1
|
+
{"version":3,"file":"expanded_link.js","sourceRoot":"","sources":["../../../../src/components/conversation/attachments/expanded_link.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,IAAI,EAAE,MA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I,WAAW,CAAC,IAAI,CACzB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,CAC9B;UAAA,CAAC,KAAK,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,CACnD;UAAA,CAAC,WAAW,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,WAAW,CAAC,EAAE,IAAI,CAAC,CACvE;QAAA,EAAE,IAAI,CAAC,CACR,CACH;IAAA,EAAE,iBAAiB,CAAC,CACrB,CAAA;AACH,CAAC;AAED,MAAM,SAAS,GAAG,GAAG,EAAE;IACrB,MAAM,EAAE,MAAM,EAAE,GAAG,QAAQ,EAAE,CAAA;IAE7B,OAAO,UAAU,CAAC,MAAM,CAAC;QACvB,SAAS,EAAE,EAAE;QACb,KAAK,EAAE;YACL,YAAY,EAAE,CAAC;SAChB;QACD,WAAW,EAAE;YACX,GAAG,EAAE,CAAC;YACN,OAAO,EAAE,CAAC;SACX;QACD,KAAK,EAAE;YACL,QAAQ,EAAE,MAAM,CAAC,UAAU;YAC3B,UAAU,EAAE,MAAM,CAAC,gBAAgB;YACnC,KAAK,EAAE,MAAM,CAAC,uBAAuB;SACtC;QACD,WAAW,EAAE;YACX,QAAQ,EAAE,MAAM,CAAC,UAAU;YAC3B,KAAK,EAAE,MAAM,CAAC,uBAAuB;SACtC;KACF,CAAC,CAAA;AACJ,CAAC,CAAA","sourcesContent":["import React from 'react'\nimport { Image, Linking, StyleSheet, Text, View } from 'react-native'\nimport { useTheme } from '../../../hooks'\nimport { tokens } from '../../../vendor/tapestry/tokens'\nimport { DenormalizedExpandedLinkAttachmentResource } from '../../../types/resources/denormalized_attachment_resource'\nimport { PlatformPressable } from '@react-navigation/elements'\n\nexport function ExpandedLink({\n attachment,\n onMessageLongPress,\n}: {\n attachment: DenormalizedExpandedLinkAttachmentResource\n onMessageLongPress: () => void\n}) {\n const styles = useStyles()\n const { colors } = useTheme()\n const { attributes } = attachment\n const { url, title, description, imageUrl, imageHeight, imageWidth } = attributes\n\n const aspectRatio = imageWidth && imageHeight ? imageWidth / imageHeight : 1\n\n async function openUrl() {\n if (url) Linking.openURL(url)\n }\n\n return (\n <PlatformPressable\n style={styles.container}\n android_ripple={{ color: colors.androidRippleNeutral, foreground: true }}\n onPress={openUrl}\n onLongPress={onMessageLongPress}\n >\n {imageUrl && (\n <Image source={{ uri: imageUrl }} style={[styles.image, { aspectRatio }]} alt={title} />\n )}\n {(title || description) && (\n <View style={styles.textWrapper}>\n {title && <Text style={styles.title}>{title}</Text>}\n {description && <Text style={styles.description}>{description}</Text>}\n </View>\n )}\n </PlatformPressable>\n )\n}\n\nconst useStyles = () => {\n const { colors } = useTheme()\n\n return StyleSheet.create({\n container: {},\n image: {\n borderRadius: 8,\n },\n textWrapper: {\n gap: 4,\n padding: 8,\n },\n title: {\n fontSize: tokens.fontSizeSm,\n fontWeight: tokens.fontWeightMedium,\n color: colors.textColorDefaultPrimary,\n },\n description: {\n fontSize: tokens.fontSizeXs,\n color: colors.textColorDefaultPrimary,\n },\n })\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generic_file_attachment.d.ts","sourceRoot":"","sources":["../../../../src/components/conversation/attachments/generic_file_attachment.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,EAAE,qCAAqC,EAAE,MAAM,2DAA2D,CAAA;AAOjH,wBAAgB,qBAAqB,CAAC,EACpC,UAAU,EACV,4BAA4B,GAC7B,EAAE;IACD,UAAU,EAAE,qCAAqC,CAAA;IACjD,4BAA4B,EAAE,CAAC,UAAU,EAAE,qCAAqC,KAAK,IAAI,CAAA;CAC1F,
|
|
1
|
+
{"version":3,"file":"generic_file_attachment.d.ts","sourceRoot":"","sources":["../../../../src/components/conversation/attachments/generic_file_attachment.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,EAAE,qCAAqC,EAAE,MAAM,2DAA2D,CAAA;AAOjH,wBAAgB,qBAAqB,CAAC,EACpC,UAAU,EACV,4BAA4B,GAC7B,EAAE;IACD,UAAU,EAAE,qCAAqC,CAAA;IACjD,4BAA4B,EAAE,CAAC,UAAU,EAAE,qCAAqC,KAAK,IAAI,CAAA;CAC1F,qBA6BA;AA4BD,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,uJAWjD"}
|
|
@@ -7,10 +7,11 @@ import { useTheme } from '../../../hooks';
|
|
|
7
7
|
import { PlatformPressable } from '@react-navigation/elements';
|
|
8
8
|
export function GenericFileAttachment({ attachment, onMessageAttachmentLongPress, }) {
|
|
9
9
|
const styles = useStyles();
|
|
10
|
+
const { colors } = useTheme();
|
|
10
11
|
const { url, filename, contentType } = attachment.attributes;
|
|
11
12
|
const iconName = getAttachmentIconName(contentType);
|
|
12
13
|
const fileTypeLabel = contentType === 'application/pdf' ? 'PDF' : 'file';
|
|
13
|
-
return (<PlatformPressable onLongPress={() => onMessageAttachmentLongPress(attachment)} accessibilityHint="Long press for more options">
|
|
14
|
+
return (<PlatformPressable onLongPress={() => onMessageAttachmentLongPress(attachment)} android_ripple={{ color: colors.androidRippleNeutral, foreground: true }} accessibilityHint="Long press for more options">
|
|
14
15
|
<AttachmentCard>
|
|
15
16
|
<View style={styles.container}>
|
|
16
17
|
<View style={styles.stack}>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generic_file_attachment.js","sourceRoot":"","sources":["../../../../src/components/conversation/attachments/generic_file_attachment.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AAE/C,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAA;A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B,CAAC,CACrB,CAAA;AACH,CAAC;AAED,MAAM,SAAS,GAAG,GAAG,EAAE;IACrB,MAAM,EAAE,MAAM,EAAE,GAAG,QAAQ,EAAE,CAAA;IAE7B,OAAO,UAAU,CAAC,MAAM,CAAC;QACvB,SAAS,EAAE;YACT,OAAO,EAAE,CAAC;YACV,GAAG,EAAE,CAAC;YACN,aAAa,EAAE,KAAK;YACpB,UAAU,EAAE,QAAQ;YACpB,cAAc,EAAE,eAAe;YAC/B,SAAS,EAAE,EAAE;SACd;QACD,KAAK,EAAE;YACL,GAAG,EAAE,CAAC;YACN,aAAa,EAAE,KAAK;YACpB,UAAU,EAAE,QAAQ;YACpB,QAAQ,EAAE,KAAK;SAChB;QACD,IAAI,EAAE;YACJ,KAAK,EAAE,MAAM,CAAC,uBAAuB;YACrC,KAAK,EAAE,EAAE;YACT,MAAM,EAAE,EAAE;SACX;KACF,CAAC,CAAA;AACJ,CAAC,CAAA;AAED,MAAM,UAAU,qBAAqB,CAAC,IAAY;IAChD,MAAM,OAAO,GAAG,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAA;IACzC,MAAM,OAAO,GAAG,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAA;IACzC,MAAM,OAAO,GAAG,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAA;IACzC,MAAM,KAAK,GAAG,IAAI,KAAK,iBAAiB,CAAA;IAExC,IAAI,OAAO;QAAE,OAAO,2BAA2B,CAAA;IAC/C,IAAI,OAAO;QAAE,OAAO,2BAA2B,CAAA;IAC/C,IAAI,OAAO;QAAE,OAAO,2BAA2B,CAAA;IAC/C,IAAI,KAAK;QAAE,OAAO,yBAAyB,CAAA;IAC3C,OAAO,6BAA6B,CAAA;AACtC,CAAC","sourcesContent":["import React from 'react'\nimport { StyleSheet, View } from 'react-native'\nimport { DenormalizedMessageAttachmentResource } from '../../../types/resources/denormalized_attachment_resource'\nimport { AttachmentCard, AttachmentCardTitle } from './attachment_card'\nimport { Icon } from '../../display'\nimport { DownloadAttachmentButton } from './download_attachment_button'\nimport { useTheme } from '../../../hooks'\nimport { PlatformPressable } from '@react-navigation/elements'\n\nexport function GenericFileAttachment({\n attachment,\n onMessageAttachmentLongPress,\n}: {\n attachment: DenormalizedMessageAttachmentResource\n onMessageAttachmentLongPress: (attachment: DenormalizedMessageAttachmentResource) => void\n}) {\n const styles = useStyles()\n const { url, filename, contentType } = attachment.attributes\n const iconName = getAttachmentIconName(contentType)\n const fileTypeLabel = contentType === 'application/pdf' ? 'PDF' : 'file'\n\n return (\n <PlatformPressable\n onLongPress={() => onMessageAttachmentLongPress(attachment)}\n accessibilityHint=\"Long press for more options\"\n >\n <AttachmentCard>\n <View style={styles.container}>\n <View style={styles.stack}>\n <Icon name={iconName} />\n <AttachmentCardTitle>{filename}</AttachmentCardTitle>\n </View>\n <DownloadAttachmentButton\n to={url}\n filename={filename}\n title={`Download ${fileTypeLabel}`}\n />\n </View>\n </AttachmentCard>\n </PlatformPressable>\n )\n}\n\nconst useStyles = () => {\n const { colors } = useTheme()\n\n return StyleSheet.create({\n container: {\n padding: 8,\n gap: 4,\n flexDirection: 'row',\n alignItems: 'center',\n justifyContent: 'space-between',\n minHeight: 48,\n },\n stack: {\n gap: 4,\n flexDirection: 'row',\n alignItems: 'center',\n maxWidth: '70%',\n },\n icon: {\n color: colors.textColorDefaultPrimary,\n width: 24,\n height: 24,\n },\n })\n}\n\nexport function getAttachmentIconName(type: string) {\n const isImage = type.startsWith('image/')\n const isVideo = type.startsWith('video/')\n const isAudio = type.startsWith('audio/')\n const isPdf = type === 'application/pdf'\n\n if (isImage) return 'general.outlinedImageFile'\n if (isVideo) return 'general.outlinedVideoFile'\n if (isAudio) return 'general.outlinedMusicFile'\n if (isPdf) return 'general.outlinedPdfFile'\n return 'general.outlinedGenericFile'\n}\n"]}
|
|
1
|
+
{"version":3,"file":"generic_file_attachment.js","sourceRoot":"","sources":["../../../../src/components/conversation/attachments/generic_file_attachment.tsx"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,OAAO,2BAA2B,CAAA;IAC/C,IAAI,OAAO;QAAE,OAAO,2BAA2B,CAAA;IAC/C,IAAI,OAAO;QAAE,OAAO,2BAA2B,CAAA;IAC/C,IAAI,KAAK;QAAE,OAAO,yBAAyB,CAAA;IAC3C,OAAO,6BAA6B,CAAA;AACtC,CAAC","sourcesContent":["import React from 'react'\nimport { StyleSheet, View } from 'react-native'\nimport { DenormalizedMessageAttachmentResource } from '../../../types/resources/denormalized_attachment_resource'\nimport { AttachmentCard, AttachmentCardTitle } from './attachment_card'\nimport { Icon } from '../../display'\nimport { DownloadAttachmentButton } from './download_attachment_button'\nimport { useTheme } from '../../../hooks'\nimport { PlatformPressable } from '@react-navigation/elements'\n\nexport function GenericFileAttachment({\n attachment,\n onMessageAttachmentLongPress,\n}: {\n attachment: DenormalizedMessageAttachmentResource\n onMessageAttachmentLongPress: (attachment: DenormalizedMessageAttachmentResource) => void\n}) {\n const styles = useStyles()\n const { colors } = useTheme()\n\n const { url, filename, contentType } = attachment.attributes\n const iconName = getAttachmentIconName(contentType)\n const fileTypeLabel = contentType === 'application/pdf' ? 'PDF' : 'file'\n\n return (\n <PlatformPressable\n onLongPress={() => onMessageAttachmentLongPress(attachment)}\n android_ripple={{ color: colors.androidRippleNeutral, foreground: true }}\n accessibilityHint=\"Long press for more options\"\n >\n <AttachmentCard>\n <View style={styles.container}>\n <View style={styles.stack}>\n <Icon name={iconName} />\n <AttachmentCardTitle>{filename}</AttachmentCardTitle>\n </View>\n <DownloadAttachmentButton\n to={url}\n filename={filename}\n title={`Download ${fileTypeLabel}`}\n />\n </View>\n </AttachmentCard>\n </PlatformPressable>\n )\n}\n\nconst useStyles = () => {\n const { colors } = useTheme()\n\n return StyleSheet.create({\n container: {\n padding: 8,\n gap: 4,\n flexDirection: 'row',\n alignItems: 'center',\n justifyContent: 'space-between',\n minHeight: 48,\n },\n stack: {\n gap: 4,\n flexDirection: 'row',\n alignItems: 'center',\n maxWidth: '70%',\n },\n icon: {\n color: colors.textColorDefaultPrimary,\n width: 24,\n height: 24,\n },\n })\n}\n\nexport function getAttachmentIconName(type: string) {\n const isImage = type.startsWith('image/')\n const isVideo = type.startsWith('video/')\n const isAudio = type.startsWith('audio/')\n const isPdf = type === 'application/pdf'\n\n if (isImage) return 'general.outlinedImageFile'\n if (isVideo) return 'general.outlinedVideoFile'\n if (isAudio) return 'general.outlinedMusicFile'\n if (isPdf) return 'general.outlinedPdfFile'\n return 'general.outlinedGenericFile'\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"giphy_attachment.d.ts","sourceRoot":"","sources":["../../../../src/components/conversation/attachments/giphy_attachment.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAIzB,OAAO,EAAE,mCAAmC,EAAE,MAAM,2DAA2D,CAAA;AAG/G,wBAAgB,eAAe,CAAC,EAC9B,UAAU,EACV,kBAAkB,GACnB,EAAE;IACD,UAAU,EAAE,mCAAmC,CAAA;IAC/C,kBAAkB,EAAE,MAAM,IAAI,CAAA;CAC/B,
|
|
1
|
+
{"version":3,"file":"giphy_attachment.d.ts","sourceRoot":"","sources":["../../../../src/components/conversation/attachments/giphy_attachment.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAIzB,OAAO,EAAE,mCAAmC,EAAE,MAAM,2DAA2D,CAAA;AAG/G,wBAAgB,eAAe,CAAC,EAC9B,UAAU,EACV,kBAAkB,GACnB,EAAE;IACD,UAAU,EAAE,mCAAmC,CAAA;IAC/C,kBAAkB,EAAE,MAAM,IAAI,CAAA;CAC/B,qBA+BA"}
|
|
@@ -5,6 +5,7 @@ import { useTheme } from '../../../hooks';
|
|
|
5
5
|
import { PlatformPressable } from '@react-navigation/elements';
|
|
6
6
|
export function GiphyAttachment({ attachment, onMessageLongPress, }) {
|
|
7
7
|
const styles = useStyles();
|
|
8
|
+
const { colors } = useTheme();
|
|
8
9
|
const { title, titleLink, giphy } = attachment;
|
|
9
10
|
const { url } = giphy.fixedWidth;
|
|
10
11
|
const { width, height } = assertKeysAreNumbers(giphy.fixedWidth);
|
|
@@ -14,7 +15,7 @@ export function GiphyAttachment({ attachment, onMessageLongPress, }) {
|
|
|
14
15
|
Linking.openURL(titleLink);
|
|
15
16
|
}
|
|
16
17
|
}
|
|
17
|
-
return (<PlatformPressable onPress={handlePress} onLongPress={onMessageLongPress} style={styles.container}>
|
|
18
|
+
return (<PlatformPressable onPress={handlePress} onLongPress={onMessageLongPress} style={styles.container} android_ripple={{ color: colors.androidRippleNeutral, foreground: true }}>
|
|
18
19
|
<Image source={{ uri: url }} style={[styles.image, { width, height }]} accessibilityLabel={title}/>
|
|
19
20
|
<Text style={styles.link}>
|
|
20
21
|
<Text style={styles.tag}>/giphy</Text> {title}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"giphy_attachment.js","sourceRoot":"","sources":["../../../../src/components/conversation/attachments/giphy_attachment.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAC/D,OAAO,EAAE,MAAM,EAAE,MAAM,iCAAiC,CAAA;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAEzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAA;AAE9D,MAAM,UAAU,eAAe,CAAC,EAC9B,UAAU,EACV,kBAAkB,GAInB;IACC,MAAM,MAAM,GAAG,SAAS,EAAE,CAAA;IAC1B,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,GAAG,UAAU,CAAA;IAC9C,MAAM,EAAE,GAAG,EAAE,GAAG,KAAK,CAAC,UAAU,CAAA;IAChC,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,oBAAoB,CAAC,KAAK,CAAC,UAAU,CAAC,CAAA;IAEhE,SAAS,WAAW;QAClB,IAAI,SAAS,EAAE,CAAC;YACd,6CAA6C;YAC7C,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,CAAA;QAC5B,CAAC;IACH,CAAC;IAED,OAAO,CACL,CAAC,iBAAiB,CAChB,OAAO,CAAC,CAAC,WAAW,CAAC,CACrB,WAAW,CAAC,CAAC,kBAAkB,CAAC,CAChC,KAAK,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,
|
|
1
|
+
{"version":3,"file":"giphy_attachment.js","sourceRoot":"","sources":["../../../../src/components/conversation/attachments/giphy_attachment.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAC/D,OAAO,EAAE,MAAM,EAAE,MAAM,iCAAiC,CAAA;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAEzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAA;AAE9D,MAAM,UAAU,eAAe,CAAC,EAC9B,UAAU,EACV,kBAAkB,GAInB;IACC,MAAM,MAAM,GAAG,SAAS,EAAE,CAAA;IAC1B,MAAM,EAAE,MAAM,EAAE,GAAG,QAAQ,EAAE,CAAA;IAC7B,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,GAAG,UAAU,CAAA;IAC9C,MAAM,EAAE,GAAG,EAAE,GAAG,KAAK,CAAC,UAAU,CAAA;IAChC,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,oBAAoB,CAAC,KAAK,CAAC,UAAU,CAAC,CAAA;IAEhE,SAAS,WAAW;QAClB,IAAI,SAAS,EAAE,CAAC;YACd,6CAA6C;YAC7C,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,CAAA;QAC5B,CAAC;IACH,CAAC;IAED,OAAO,CACL,CAAC,iBAAiB,CAChB,OAAO,CAAC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;IACtB,CAAC;IAED,OAAO,CAAC,CAAA;AACV,CAAC,CAAA;AAED,MAAM,SAAS,GAAG,GAAG,EAAE;IACrB,MAAM,EAAE,MAAM,EAAE,GAAG,QAAQ,EAAE,CAAA;IAC7B,OAAO,UAAU,CAAC,MAAM,CAAC;QACvB,SAAS,EAAE;YACT,GAAG,EAAE,CAAC;SACP;QACD,KAAK,EAAE;YACL,YAAY,EAAE,CAAC;SAChB;QACD,IAAI,EAAE;YACJ,QAAQ,EAAE,MAAM,CAAC,UAAU;YAC3B,KAAK,EAAE,MAAM,CAAC,2BAA2B;YACzC,iBAAiB,EAAE,CAAC;YACpB,eAAe,EAAE,CAAC;SACnB;QACD,GAAG,EAAE;YACH,UAAU,EAAE,MAAM;SACnB;KACF,CAAC,CAAA;AACJ,CAAC,CAAA","sourcesContent":["import React from 'react'\nimport { Text, Image, StyleSheet, Linking } from 'react-native'\nimport { tokens } from '../../../vendor/tapestry/tokens'\nimport { useTheme } from '../../../hooks'\nimport { DenormalizedGiphyAttachmentResource } from '../../../types/resources/denormalized_attachment_resource'\nimport { PlatformPressable } from '@react-navigation/elements'\n\nexport function GiphyAttachment({\n attachment,\n onMessageLongPress,\n}: {\n attachment: DenormalizedGiphyAttachmentResource\n onMessageLongPress: () => void\n}) {\n const styles = useStyles()\n const { colors } = useTheme()\n const { title, titleLink, giphy } = attachment\n const { url } = giphy.fixedWidth\n const { width, height } = assertKeysAreNumbers(giphy.fixedWidth)\n\n function handlePress() {\n if (titleLink) {\n // Open Giphy link in the default web browser\n Linking.openURL(titleLink)\n }\n }\n\n return (\n <PlatformPressable\n onPress={handlePress}\n onLongPress={onMessageLongPress}\n style={styles.container}\n android_ripple={{ color: colors.androidRippleNeutral, foreground: true }}\n >\n <Image\n source={{ uri: url }}\n style={[styles.image, { width, height }]}\n accessibilityLabel={title}\n />\n <Text style={styles.link}>\n <Text style={styles.tag}>/giphy</Text> {title}\n </Text>\n </PlatformPressable>\n )\n}\n\nconst assertKeysAreNumbers = (obj: Object): Record<any, number> => {\n return Object.fromEntries(Object.entries(obj).map(([key, value]) => [key, assertNumber(value)]))\n}\n\nconst assertNumber = (value: string): number => {\n if (typeof value === 'number') return value\n\n if (typeof value === 'string' && !isNaN(Number(value))) {\n return Number(value)\n }\n\n return 0\n}\n\nconst useStyles = () => {\n const { colors } = useTheme()\n return StyleSheet.create({\n container: {\n gap: 4,\n },\n image: {\n borderRadius: 8,\n },\n link: {\n fontSize: tokens.fontSizeSm,\n color: colors.fillColorInteractionDefault,\n paddingHorizontal: 8,\n paddingVertical: 6,\n },\n tag: {\n fontWeight: 'bold',\n },\n })\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"image_attachment.d.ts","sourceRoot":"","sources":["../../../../src/components/conversation/attachments/image_attachment.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAyC,MAAM,OAAO,CAAA;AA2B7D,OAAO,EAAE,qCAAqC,EAAE,MAAM,2DAA2D,CAAA;
|
|
1
|
+
{"version":3,"file":"image_attachment.d.ts","sourceRoot":"","sources":["../../../../src/components/conversation/attachments/image_attachment.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAyC,MAAM,OAAO,CAAA;AA2B7D,OAAO,EAAE,qCAAqC,EAAE,MAAM,2DAA2D,CAAA;AAMjH,MAAM,MAAM,SAAS,GAAG;IACtB,UAAU,EAAE,MAAM,CAAA;IAClB,SAAS,EAAE,MAAM,CAAA;CAClB,CAAA;AAED,wBAAgB,eAAe,CAAC,EAC9B,UAAU,EACV,SAAS,EACT,4BAA4B,GAC7B,EAAE;IACD,UAAU,EAAE,qCAAqC,CAAA;IACjD,SAAS,EAAE,SAAS,CAAA;IACpB,4BAA4B,EAAE,CAAC,UAAU,EAAE,qCAAqC,KAAK,IAAI,CAAA;CAC1F,qBA8DA"}
|
|
@@ -7,10 +7,12 @@ import { IconButton, Image, Heading, Text } from '../../display';
|
|
|
7
7
|
import colorFunction from 'color';
|
|
8
8
|
import { formatDatePreview } from '../../../utils/date';
|
|
9
9
|
import { PlatformPressable } from '@react-navigation/elements';
|
|
10
|
+
import { useTheme } from '../../../hooks';
|
|
10
11
|
const PAN_THRESHOLD_PX = 300;
|
|
11
12
|
export function ImageAttachment({ attachment, metaProps, onMessageAttachmentLongPress, }) {
|
|
12
13
|
const { attributes } = attachment;
|
|
13
14
|
const { url, urlMedium, filename, metadata = {} } = attributes;
|
|
15
|
+
const { colors } = useTheme();
|
|
14
16
|
const styles = useStyles({ imageWidth: metadata.width, imageHeight: metadata.height });
|
|
15
17
|
const [visible, setVisible] = useState(false);
|
|
16
18
|
// shared values run on the native UI thread and prevents clogging up the JS thread
|
|
@@ -37,7 +39,7 @@ export function ImageAttachment({ attachment, metaProps, onMessageAttachmentLong
|
|
|
37
39
|
opacity: opacity.value,
|
|
38
40
|
}));
|
|
39
41
|
return (<>
|
|
40
|
-
<PlatformPressable style={styles.container} onPress={() => setVisible(true)} onLongPress={() => onMessageAttachmentLongPress(attachment)} accessibilityHint="Long press for more options">
|
|
42
|
+
<PlatformPressable style={styles.container} onPress={() => setVisible(true)} onLongPress={() => onMessageAttachmentLongPress(attachment)} android_ripple={{ color: colors.androidRippleNeutral, foreground: true }} accessibilityHint="Long press for more options">
|
|
41
43
|
<Image source={{ uri: urlMedium || url }} style={styles.image} wrapperStyle={styles.imageWrapper} alt={filename}/>
|
|
42
44
|
</PlatformPressable>
|
|
43
45
|
<LightboxModal visible={visible} handleCloseModal={handleCloseModal} uri={urlMedium || url} metaProps={metaProps} panGesture={panGesture} animatedImageStyle={animatedImageStyle}/>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"image_attachment.js","sourceRoot":"","sources":["../../../../src/components/conversation/attachments/image_attachment.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAC7D,OAAO,EACL,UAAU,EACV,KAAK,EACL,mBAAmB,EACnB,YAAY,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,IAAI,EAAE,CAAC;SACR;QACD,kBAAkB,EAAE;YAClB,WAAW,EAAE,MAAM;YACnB,UAAU,EAAE,CAAC;YACb,KAAK,EAAE,MAAM,CAAC,cAAc;SAC7B;QACD,qBAAqB,EAAE;YACrB,KAAK,EAAE,MAAM,CAAC,cAAc;SAC7B;QACD,YAAY,EAAE;YACZ,eAAe;YACf,MAAM,EAAE,EAAE;YACV,KAAK,EAAE,EAAE;YACT,YAAY,EAAE,EAAE;YAChB,WAAW,EAAE,CAAC;YACd,WAAW,EAAE,MAAM,CAAC,cAAc;SACnC;QACD,gBAAgB,EAAE;YAChB,KAAK,EAAE,MAAM,CAAC,cAAc;SAC7B;KACF,CAAC,CAAA;AACJ,CAAC,CAAA","sourcesContent":["import React, { useCallback, useMemo, useState } from 'react'\nimport {\n StyleSheet,\n Modal,\n useWindowDimensions,\n SafeAreaView,\n View,\n Linking,\n ImageStyle,\n} from 'react-native'\nimport {\n Gesture,\n GestureDetector,\n GestureHandlerRootView,\n type PanGesture,\n} from 'react-native-gesture-handler'\nimport {\n runOnJS,\n useAnimatedStyle,\n useSharedValue,\n withTiming,\n type AnimatedStyle,\n} from 'react-native-reanimated'\nimport { tokens } from '../../../vendor/tapestry/tokens'\nimport { IconButton, Image, Heading, Text } from '../../display'\nimport colorFunction from 'color'\nimport { formatDatePreview } from '../../../utils/date'\nimport { DenormalizedMessageAttachmentResource } from '../../../types/resources/denormalized_attachment_resource'\nimport { PlatformPressable } from '@react-navigation/elements'\n\nconst PAN_THRESHOLD_PX = 300\n\nexport type MetaProps = {\n authorName: string\n createdAt: string\n}\n\nexport function ImageAttachment({\n attachment,\n metaProps,\n onMessageAttachmentLongPress,\n}: {\n attachment: DenormalizedMessageAttachmentResource\n metaProps: MetaProps\n onMessageAttachmentLongPress: (attachment: DenormalizedMessageAttachmentResource) => void\n}) {\n const { attributes } = attachment\n const { url, urlMedium, filename, metadata = {} } = attributes\n\n const styles = useStyles({ imageWidth: metadata.width, imageHeight: metadata.height })\n const [visible, setVisible] = useState(false)\n\n // shared values run on the native UI thread and prevents clogging up the JS thread\n const dismissY = useSharedValue(0)\n const opacity = useSharedValue(1)\n\n const resetAnimations = useCallback(() => {\n dismissY.value = withTiming(0)\n opacity.value = withTiming(1)\n }, [dismissY, opacity])\n\n const handleCloseModal = useCallback(() => {\n setVisible(false)\n resetAnimations()\n }, [setVisible, resetAnimations])\n\n const panGesture = Gesture.Pan()\n .onUpdate(e => {\n dismissY.value = e.translationY\n opacity.value = 1 - Math.abs(e.translationY) / PAN_THRESHOLD_PX\n })\n .onEnd(() => {\n runOnJS(handleCloseModal)() // Ensures we can call a JS function\n })\n\n const animatedImageStyle = useAnimatedStyle(() => ({\n transform: [{ translateY: dismissY.value }],\n opacity: opacity.value,\n }))\n\n return (\n <>\n <PlatformPressable\n style={styles.container}\n onPress={() => setVisible(true)}\n onLongPress={() => onMessageAttachmentLongPress(attachment)}\n accessibilityHint=\"Long press for more options\"\n >\n <Image\n source={{ uri: urlMedium || url }}\n style={styles.image}\n wrapperStyle={styles.imageWrapper}\n alt={filename}\n />\n </PlatformPressable>\n <LightboxModal\n visible={visible}\n handleCloseModal={handleCloseModal}\n uri={urlMedium || url}\n metaProps={metaProps}\n panGesture={panGesture}\n animatedImageStyle={animatedImageStyle}\n />\n </>\n )\n}\n\ninterface LightboxModalProps {\n visible: boolean\n handleCloseModal: () => void\n uri: string\n metaProps: MetaProps\n panGesture: PanGesture\n animatedImageStyle: AnimatedStyle<ImageStyle>\n}\n\nconst LightboxModal = ({\n uri,\n visible,\n handleCloseModal,\n metaProps,\n panGesture,\n animatedImageStyle,\n}: LightboxModalProps) => {\n const styles = useStyles()\n\n const { authorName, createdAt } = metaProps\n\n const handleOpenInBrowser = () => {\n Linking.openURL(uri)\n }\n\n return (\n <Modal visible={visible} transparent animationType=\"fade\" onRequestClose={handleCloseModal}>\n <SafeAreaView style={styles.modal}>\n <GestureHandlerRootView>\n <GestureDetector gesture={panGesture}>\n <Image\n source={{ uri }}\n loadingBackgroundStyles={styles.lightboxImageLoading}\n style={styles.lightboxImage}\n animatedImageStyle={animatedImageStyle}\n resizeMode=\"contain\"\n animated={true}\n alt=\"\"\n />\n </GestureDetector>\n <View style={styles.actionToolbar} accessibilityRole=\"toolbar\">\n <View style={styles.actionToolbarTextMeta}>\n <Heading variant=\"h3\" style={styles.actionToolbarTitle} numberOfLines={1}>\n {authorName}\n </Heading>\n <Text variant=\"tertiary\" style={styles.actionToolbarSubtitle}>\n {formatDatePreview(createdAt)}\n </Text>\n </View>\n <IconButton\n onPress={handleOpenInBrowser}\n name=\"general.newWindow\"\n accessibilityRole=\"link\"\n accessibilityLabel=\"Open image in browser\"\n accessibilityHint=\"Image can be downloaded and shared through the browser.\"\n style={styles.actionButton}\n iconStyle={styles.actionButtonIcon}\n size=\"lg\"\n />\n <IconButton\n onPress={handleCloseModal}\n name=\"general.x\"\n accessibilityLabel=\"Close image\"\n style={styles.actionButton}\n iconStyle={styles.actionButtonIcon}\n />\n </View>\n </GestureHandlerRootView>\n </SafeAreaView>\n </Modal>\n )\n}\n\ninterface UseStylesProps {\n imageWidth?: number\n imageHeight?: number\n}\n\nconst useStyles = ({ imageWidth = 100, imageHeight = 100 }: UseStylesProps = {}) => {\n const { width: windowWidth } = useWindowDimensions()\n const backgroundColor = tokens.colorNeutral7\n const transparentBackgroundColor = useMemo(\n () => colorFunction(backgroundColor).alpha(0.8).toString(),\n [backgroundColor]\n )\n\n return StyleSheet.create({\n container: {\n maxWidth: '100%',\n },\n imageWrapper: {\n minWidth: 200,\n aspectRatio: imageWidth / imageHeight,\n },\n image: {\n borderRadius: 8,\n },\n modal: {\n flex: 1,\n backgroundColor,\n justifyContent: 'center',\n alignItems: 'center',\n },\n lightboxImage: {\n height: '100%',\n width: windowWidth,\n backgroundColor,\n },\n lightboxImageLoading: {\n backgroundColor,\n },\n actionToolbar: {\n width: '100%',\n position: 'absolute',\n top: 0,\n flexDirection: 'row',\n alignItems: 'center',\n gap: 20,\n paddingHorizontal: 16,\n paddingTop: 16,\n paddingBottom: 8,\n backgroundColor: transparentBackgroundColor,\n },\n actionToolbarTextMeta: {\n flex: 1,\n },\n actionToolbarTitle: {\n marginRight: 'auto',\n flexShrink: 1,\n color: tokens.colorNeutral88,\n },\n actionToolbarSubtitle: {\n color: tokens.colorNeutral68,\n },\n actionButton: {\n backgroundColor,\n height: 40,\n width: 40,\n borderRadius: 50,\n borderWidth: 1,\n borderColor: tokens.colorNeutral24,\n },\n actionButtonIcon: {\n color: tokens.colorNeutral88,\n },\n })\n}\n"]}
|
|
1
|
+
{"version":3,"file":"image_attachment.js","sourceRoot":"","sources":["../../../../src/components/conversation/attachments/image_attachment.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAC7D,OAAO,EACL,UAAU,EACV,KAAK,EACL,mBAAmB,EACnB,YAAY,EACZ,IAAI,EACJ,OAAO,GAER,MAAM,cAAc,CAAA;AACrB,OAAO,EACL,OAAO,EACP,eAAe,EACf,sBAAsB,GAEvB,MAAM,8BAA8B,CAAA;AACrC,OAAO,EACL,OAAO,EACP,gBAAgB,EAChB,cAAc,EACd,UAAU,GAEX,MAAM,yBAAyB,CAAA;AAChC,OAAO,EAAE,MAAM,EAAE,MAAM,iCAAiC,CAAA;AACxD,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAA;AAChE,OAAO,aAAa,MAAM,OAAO,CAAA;AACjC,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAEvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAA;AAC9D,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAEzC,MAAM,gBAAgB,GAAG,GAAG,CAAA;AAO5B,MAAM,UAAU,eAAe,CAAC,EAC9B,UAAU,EACV,SAAS,EACT,4BAA4B,G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ACJ,CAAC,CAAA","sourcesContent":["import React, { useCallback, useMemo, useState } from 'react'\nimport {\n StyleSheet,\n Modal,\n useWindowDimensions,\n SafeAreaView,\n View,\n Linking,\n ImageStyle,\n} from 'react-native'\nimport {\n Gesture,\n GestureDetector,\n GestureHandlerRootView,\n type PanGesture,\n} from 'react-native-gesture-handler'\nimport {\n runOnJS,\n useAnimatedStyle,\n useSharedValue,\n withTiming,\n type AnimatedStyle,\n} from 'react-native-reanimated'\nimport { tokens } from '../../../vendor/tapestry/tokens'\nimport { IconButton, Image, Heading, Text } from '../../display'\nimport colorFunction from 'color'\nimport { formatDatePreview } from '../../../utils/date'\nimport { DenormalizedMessageAttachmentResource } from '../../../types/resources/denormalized_attachment_resource'\nimport { PlatformPressable } from '@react-navigation/elements'\nimport { useTheme } from '../../../hooks'\n\nconst PAN_THRESHOLD_PX = 300\n\nexport type MetaProps = {\n authorName: string\n createdAt: string\n}\n\nexport function ImageAttachment({\n attachment,\n metaProps,\n onMessageAttachmentLongPress,\n}: {\n attachment: DenormalizedMessageAttachmentResource\n metaProps: MetaProps\n onMessageAttachmentLongPress: (attachment: DenormalizedMessageAttachmentResource) => void\n}) {\n const { attributes } = attachment\n const { url, urlMedium, filename, metadata = {} } = attributes\n const { colors } = useTheme()\n\n const styles = useStyles({ imageWidth: metadata.width, imageHeight: metadata.height })\n const [visible, setVisible] = useState(false)\n\n // shared values run on the native UI thread and prevents clogging up the JS thread\n const dismissY = useSharedValue(0)\n const opacity = useSharedValue(1)\n\n const resetAnimations = useCallback(() => {\n dismissY.value = withTiming(0)\n opacity.value = withTiming(1)\n }, [dismissY, opacity])\n\n const handleCloseModal = useCallback(() => {\n setVisible(false)\n resetAnimations()\n }, [setVisible, resetAnimations])\n\n const panGesture = Gesture.Pan()\n .onUpdate(e => {\n dismissY.value = e.translationY\n opacity.value = 1 - Math.abs(e.translationY) / PAN_THRESHOLD_PX\n })\n .onEnd(() => {\n runOnJS(handleCloseModal)() // Ensures we can call a JS function\n })\n\n const animatedImageStyle = useAnimatedStyle(() => ({\n transform: [{ translateY: dismissY.value }],\n opacity: opacity.value,\n }))\n\n return (\n <>\n <PlatformPressable\n style={styles.container}\n onPress={() => setVisible(true)}\n onLongPress={() => onMessageAttachmentLongPress(attachment)}\n android_ripple={{ color: colors.androidRippleNeutral, foreground: true }}\n accessibilityHint=\"Long press for more options\"\n >\n <Image\n source={{ uri: urlMedium || url }}\n style={styles.image}\n wrapperStyle={styles.imageWrapper}\n alt={filename}\n />\n </PlatformPressable>\n <LightboxModal\n visible={visible}\n handleCloseModal={handleCloseModal}\n uri={urlMedium || url}\n metaProps={metaProps}\n panGesture={panGesture}\n animatedImageStyle={animatedImageStyle}\n />\n </>\n )\n}\n\ninterface LightboxModalProps {\n visible: boolean\n handleCloseModal: () => void\n uri: string\n metaProps: MetaProps\n panGesture: PanGesture\n animatedImageStyle: AnimatedStyle<ImageStyle>\n}\n\nconst LightboxModal = ({\n uri,\n visible,\n handleCloseModal,\n metaProps,\n panGesture,\n animatedImageStyle,\n}: LightboxModalProps) => {\n const styles = useStyles()\n\n const { authorName, createdAt } = metaProps\n\n const handleOpenInBrowser = () => {\n Linking.openURL(uri)\n }\n\n return (\n <Modal visible={visible} transparent animationType=\"fade\" onRequestClose={handleCloseModal}>\n <SafeAreaView style={styles.modal}>\n <GestureHandlerRootView>\n <GestureDetector gesture={panGesture}>\n <Image\n source={{ uri }}\n loadingBackgroundStyles={styles.lightboxImageLoading}\n style={styles.lightboxImage}\n animatedImageStyle={animatedImageStyle}\n resizeMode=\"contain\"\n animated={true}\n alt=\"\"\n />\n </GestureDetector>\n <View style={styles.actionToolbar} accessibilityRole=\"toolbar\">\n <View style={styles.actionToolbarTextMeta}>\n <Heading variant=\"h3\" style={styles.actionToolbarTitle} numberOfLines={1}>\n {authorName}\n </Heading>\n <Text variant=\"tertiary\" style={styles.actionToolbarSubtitle}>\n {formatDatePreview(createdAt)}\n </Text>\n </View>\n <IconButton\n onPress={handleOpenInBrowser}\n name=\"general.newWindow\"\n accessibilityRole=\"link\"\n accessibilityLabel=\"Open image in browser\"\n accessibilityHint=\"Image can be downloaded and shared through the browser.\"\n style={styles.actionButton}\n iconStyle={styles.actionButtonIcon}\n size=\"lg\"\n />\n <IconButton\n onPress={handleCloseModal}\n name=\"general.x\"\n accessibilityLabel=\"Close image\"\n style={styles.actionButton}\n iconStyle={styles.actionButtonIcon}\n />\n </View>\n </GestureHandlerRootView>\n </SafeAreaView>\n </Modal>\n )\n}\n\ninterface UseStylesProps {\n imageWidth?: number\n imageHeight?: number\n}\n\nconst useStyles = ({ imageWidth = 100, imageHeight = 100 }: UseStylesProps = {}) => {\n const { width: windowWidth } = useWindowDimensions()\n const backgroundColor = tokens.colorNeutral7\n const transparentBackgroundColor = useMemo(\n () => colorFunction(backgroundColor).alpha(0.8).toString(),\n [backgroundColor]\n )\n\n return StyleSheet.create({\n container: {\n maxWidth: '100%',\n },\n imageWrapper: {\n minWidth: 200,\n aspectRatio: imageWidth / imageHeight,\n },\n image: {\n borderRadius: 8,\n },\n modal: {\n flex: 1,\n backgroundColor,\n justifyContent: 'center',\n alignItems: 'center',\n },\n lightboxImage: {\n height: '100%',\n width: windowWidth,\n backgroundColor,\n },\n lightboxImageLoading: {\n backgroundColor,\n },\n actionToolbar: {\n width: '100%',\n position: 'absolute',\n top: 0,\n flexDirection: 'row',\n alignItems: 'center',\n gap: 20,\n paddingHorizontal: 16,\n paddingTop: 16,\n paddingBottom: 8,\n backgroundColor: transparentBackgroundColor,\n },\n actionToolbarTextMeta: {\n flex: 1,\n },\n actionToolbarTitle: {\n marginRight: 'auto',\n flexShrink: 1,\n color: tokens.colorNeutral88,\n },\n actionToolbarSubtitle: {\n color: tokens.colorNeutral68,\n },\n actionButton: {\n backgroundColor,\n height: 40,\n width: 40,\n borderRadius: 50,\n borderWidth: 1,\n borderColor: tokens.colorNeutral24,\n },\n actionButtonIcon: {\n color: tokens.colorNeutral88,\n },\n })\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"video_attachment.d.ts","sourceRoot":"","sources":["../../../../src/components/conversation/attachments/video_attachment.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA2B,MAAM,OAAO,CAAA;AAE/C,OAAO,EAAE,qCAAqC,EAAE,MAAM,2DAA2D,CAAA;
|
|
1
|
+
{"version":3,"file":"video_attachment.d.ts","sourceRoot":"","sources":["../../../../src/components/conversation/attachments/video_attachment.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA2B,MAAM,OAAO,CAAA;AAE/C,OAAO,EAAE,qCAAqC,EAAE,MAAM,2DAA2D,CAAA;AAOjH,wBAAgB,eAAe,CAAC,EAC9B,UAAU,EACV,4BAA4B,GAC7B,EAAE;IACD,UAAU,EAAE,qCAAqC,CAAA;IACjD,4BAA4B,EAAE,CAAC,UAAU,EAAE,qCAAqC,KAAK,IAAI,CAAA;CAC1F,qBAsDA"}
|
|
@@ -4,7 +4,9 @@ import { MESSAGE_ATTACHMENT_WIDTH_SINGLE } from './constants';
|
|
|
4
4
|
import { IconButton } from '../../display';
|
|
5
5
|
import { Video } from '../../../utils/native_adapters';
|
|
6
6
|
import { PlatformPressable } from '@react-navigation/elements';
|
|
7
|
+
import { useTheme } from '../../../hooks';
|
|
7
8
|
export function VideoAttachment({ attachment, onMessageAttachmentLongPress, }) {
|
|
9
|
+
const { colors } = useTheme();
|
|
8
10
|
const { attributes } = attachment;
|
|
9
11
|
const { width = MESSAGE_ATTACHMENT_WIDTH_SINGLE, height = MESSAGE_ATTACHMENT_WIDTH_SINGLE } = attributes.metadata || {};
|
|
10
12
|
const { url } = attributes;
|
|
@@ -23,7 +25,7 @@ export function VideoAttachment({ attachment, onMessageAttachmentLongPress, }) {
|
|
|
23
25
|
}
|
|
24
26
|
const viewRef = useRef(null);
|
|
25
27
|
return (<View style={styles.container} ref={viewRef}>
|
|
26
|
-
<PlatformPressable onLongPress={() => onMessageAttachmentLongPress(attachment)} accessibilityHint="Long press for more options">
|
|
28
|
+
<PlatformPressable onLongPress={() => onMessageAttachmentLongPress(attachment)} android_ripple={{ color: colors.androidRippleNeutral, foreground: true }} accessibilityHint="Long press for more options">
|
|
27
29
|
<Video.Player ref={videoRef} source={{ uri: url }} aspectRatio={width / height} style={styles.video} onFullscreenPlayerWillDismiss={onFullscreenPlayerWillDismiss}/>
|
|
28
30
|
{!isOpen && (<View style={styles.playButtonWrapper}>
|
|
29
31
|
<IconButton name="services.play" size="md" accessibilityLabel="Play Video" onPress={openVideo} style={styles.button}/>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"video_attachment.js","sourceRoot":"","sources":["../../../../src/components/conversation/attachments/video_attachment.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAC/C,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAE/C,OAAO,EAAE,+BAA+B,EAAE,MAAM,aAAa,CAAA;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC1C,OAAO,EAAE,KAAK,EAAqB,MAAM,gCAAgC,CAAA;AACzE,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAA;
|
|
1
|
+
{"version":3,"file":"video_attachment.js","sourceRoot":"","sources":["../../../../src/components/conversation/attachments/video_attachment.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAC/C,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAE/C,OAAO,EAAE,+BAA+B,EAAE,MAAM,aAAa,CAAA;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC1C,OAAO,EAAE,KAAK,EAAqB,MAAM,gCAAgC,CAAA;AACzE,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAA;AAC9D,OAAO,EA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AAQ;QACpB,YAAY,EAAE,EAAE;QAChB,eAAe,EAAE,MAAM;QACvB,WAAW,EAAE,MAAM;QACnB,WAAW,EAAE,CAAC;KACf;CACF,CAAC,CAAA","sourcesContent":["import React, { useRef, useState } from 'react'\nimport { View, StyleSheet } from 'react-native'\nimport { DenormalizedMessageAttachmentResource } from '../../../types/resources/denormalized_attachment_resource'\nimport { MESSAGE_ATTACHMENT_WIDTH_SINGLE } from './constants'\nimport { IconButton } from '../../display'\nimport { Video, VideoPlayerHandle } from '../../../utils/native_adapters'\nimport { PlatformPressable } from '@react-navigation/elements'\nimport { useTheme } from '../../../hooks'\n\nexport function VideoAttachment({\n attachment,\n onMessageAttachmentLongPress,\n}: {\n attachment: DenormalizedMessageAttachmentResource\n onMessageAttachmentLongPress: (attachment: DenormalizedMessageAttachmentResource) => void\n}) {\n const { colors } = useTheme()\n\n const { attributes } = attachment\n const { width = MESSAGE_ATTACHMENT_WIDTH_SINGLE, height = MESSAGE_ATTACHMENT_WIDTH_SINGLE } =\n attributes.metadata || {}\n const { url } = attributes\n\n const videoRef = useRef<VideoPlayerHandle>(null)\n const [isOpen, setIsOpen] = useState(false)\n\n function openVideo() {\n if (!isOpen && videoRef.current) {\n videoRef.current.presentFullscreenPlayer()\n videoRef.current.play()\n setIsOpen(true)\n }\n }\n\n function onFullscreenPlayerWillDismiss() {\n videoRef.current?.pause()\n setIsOpen(false)\n }\n\n const viewRef = useRef<View>(null)\n\n return (\n <View style={styles.container} ref={viewRef}>\n <PlatformPressable\n onLongPress={() => onMessageAttachmentLongPress(attachment)}\n android_ripple={{ color: colors.androidRippleNeutral, foreground: true }}\n accessibilityHint=\"Long press for more options\"\n >\n <Video.Player\n ref={videoRef}\n source={{ uri: url }}\n aspectRatio={width / height}\n style={styles.video}\n onFullscreenPlayerWillDismiss={onFullscreenPlayerWillDismiss}\n />\n {!isOpen && (\n <View style={styles.playButtonWrapper}>\n <IconButton\n name=\"services.play\"\n size=\"md\"\n accessibilityLabel=\"Play Video\"\n onPress={openVideo}\n style={styles.button}\n />\n </View>\n )}\n </PlatformPressable>\n </View>\n )\n}\n\nconst styles = StyleSheet.create({\n container: {\n maxWidth: 320,\n maxHeight: 320,\n },\n video: {\n width: '100%',\n height: 'auto',\n backgroundColor: 'black',\n borderRadius: 8,\n },\n playButtonWrapper: {\n position: 'absolute',\n top: 0,\n left: 0,\n right: 0,\n bottom: 0,\n justifyContent: 'center',\n alignItems: 'center',\n },\n button: {\n width: 42,\n height: 42,\n justifyContent: 'center',\n alignItems: 'center',\n borderRadius: 25,\n backgroundColor: '#eee',\n borderColor: '#aaa',\n borderWidth: 1,\n },\n})\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message.d.ts","sourceRoot":"","sources":["../../../src/components/conversation/message.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"message.d.ts","sourceRoot":"","sources":["../../../src/components/conversation/message.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAA;AAKzB,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAe7C;;GAEG;AACH,UAAU,YAAa,SAAQ,eAAe;IAC5C,4BAA4B,EAAE,OAAO,CAAA;IACrC,eAAe,EAAE,MAAM,CAAA;CACxB;AAED,wBAAgB,OAAO,CAAC,KAAK,EAAE,YAAY,qBA2G1C"}
|
|
@@ -1,18 +1,38 @@
|
|
|
1
|
-
import { PlatformPressable } from '@react-navigation/elements';
|
|
2
1
|
import { useNavigation } from '@react-navigation/native';
|
|
3
2
|
import colorFunction from 'color';
|
|
4
3
|
import React from 'react';
|
|
5
|
-
import { StyleSheet, View } from 'react-native';
|
|
4
|
+
import { Platform, Pressable, StyleSheet, View } from 'react-native';
|
|
6
5
|
import { MessageReaction } from '../../components/conversation/message_reaction';
|
|
7
6
|
import { Avatar, Text } from '../../components/display';
|
|
8
7
|
import { useTheme } from '../../hooks';
|
|
9
8
|
import { MessageAttachments } from './message_attachments';
|
|
10
9
|
import ErrorBoundary from '../page/error_boundary';
|
|
11
10
|
import { MessageMarkdown } from './message_markdown';
|
|
11
|
+
import { CONVERSATION_MESSAGE_LIST_PADDING_HORIZONTAL } from '../../utils/styles';
|
|
12
|
+
import Animated, { useSharedValue, useAnimatedStyle, withTiming, interpolateColor, Easing, } from 'react-native-reanimated';
|
|
12
13
|
export function Message(props) {
|
|
13
14
|
const { conversation_id, canDeleteNonAuthoredMessages, text, reactionCounts } = props;
|
|
14
15
|
const styles = useMessageStyles(props);
|
|
15
16
|
const navigation = useNavigation();
|
|
17
|
+
const { colors } = useTheme();
|
|
18
|
+
const hasReactions = reactionCounts.length > 0;
|
|
19
|
+
const bgFadeProgress = useSharedValue(0);
|
|
20
|
+
const pressedColor = Platform.select({
|
|
21
|
+
ios: colors.fillColorNeutral050Base,
|
|
22
|
+
default: 'transparent',
|
|
23
|
+
});
|
|
24
|
+
const animatedBackgroundColor = useAnimatedStyle(() => {
|
|
25
|
+
const backgroundColor = interpolateColor(bgFadeProgress.value, [0, 1], ['transparent', pressedColor]);
|
|
26
|
+
return {
|
|
27
|
+
backgroundColor,
|
|
28
|
+
};
|
|
29
|
+
});
|
|
30
|
+
const handlePressIn = () => {
|
|
31
|
+
bgFadeProgress.value = withTiming(1, { duration: 300, easing: Easing.inOut(Easing.ease) });
|
|
32
|
+
};
|
|
33
|
+
const handlePressOut = () => {
|
|
34
|
+
bgFadeProgress.value = withTiming(0, { duration: 300, easing: Easing.inOut(Easing.ease) });
|
|
35
|
+
};
|
|
16
36
|
const handleMessageLongPress = () => {
|
|
17
37
|
navigation.navigate('MessageActions', {
|
|
18
38
|
message_id: props.id,
|
|
@@ -40,25 +60,27 @@ export function Message(props) {
|
|
|
40
60
|
authorName: props.author.name,
|
|
41
61
|
createdAt: props.createdAt,
|
|
42
62
|
};
|
|
43
|
-
return (<
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
<
|
|
51
|
-
<
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
63
|
+
return (<Pressable onLongPress={handleMessageLongPress} onPressIn={handlePressIn} onPressOut={handlePressOut} android_ripple={{ color: colors.androidRippleNeutral }} accessibilityHint="Long press to view message actions like reacting and copying.">
|
|
64
|
+
<Animated.View style={[styles.message, animatedBackgroundColor]}>
|
|
65
|
+
{!props.mine && (<View style={styles.messageAuthor}>
|
|
66
|
+
<Avatar size={'md'} sourceUri={props.author.avatar}/>
|
|
67
|
+
</View>)}
|
|
68
|
+
<View style={styles.messageContent}>
|
|
69
|
+
{!props.mine && <Text variant="tertiary">{props.author.name}</Text>}
|
|
70
|
+
<View style={styles.messageBubble}>
|
|
71
|
+
<ErrorBoundary>
|
|
72
|
+
<MessageAttachments attachments={props.attachments} metaProps={metaProps} onMessageAttachmentLongPress={handleMessageAttachmentLongPress} onMessageLongPress={handleMessageLongPress}/>
|
|
73
|
+
</ErrorBoundary>
|
|
74
|
+
{text && (<View style={styles.messageText}>
|
|
75
|
+
<MessageMarkdown text={text}/>
|
|
76
|
+
</View>)}
|
|
77
|
+
</View>
|
|
78
|
+
{hasReactions && (<View style={styles.messageReactions}>
|
|
79
|
+
{reactionCounts.map(reaction => (<MessageReaction key={reaction.value} reaction={reaction} onPress={handleReactionPress}/>))}
|
|
55
80
|
</View>)}
|
|
56
|
-
</PlatformPressable>
|
|
57
|
-
<View style={styles.messageReactions}>
|
|
58
|
-
{reactionCounts.map(reaction => (<MessageReaction key={reaction.value} reaction={reaction} onPress={handleReactionPress}/>))}
|
|
59
81
|
</View>
|
|
60
|
-
</View>
|
|
61
|
-
</
|
|
82
|
+
</Animated.View>
|
|
83
|
+
</Pressable>);
|
|
62
84
|
}
|
|
63
85
|
const useMessageStyles = ({ mine }) => {
|
|
64
86
|
const { colors } = useTheme();
|
|
@@ -67,6 +89,7 @@ const useMessageStyles = ({ mine }) => {
|
|
|
67
89
|
message: {
|
|
68
90
|
gap: 8,
|
|
69
91
|
flexDirection: mine ? 'row-reverse' : 'row',
|
|
92
|
+
paddingHorizontal: CONVERSATION_MESSAGE_LIST_PADDING_HORIZONTAL,
|
|
70
93
|
},
|
|
71
94
|
messageContent: {
|
|
72
95
|
gap: 8,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message.js","sourceRoot":"","sources":["../../../src/components/conversation/message.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAA;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AACxD,OAAO,aAAa,MAAM,OAAO,CAAA;AACjC,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,gDAAgD,CAAA;AAChF,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAA;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAGtC,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAA;AAC1D,OAAO,aAAa,MAAM,wBAAwB,CAAA;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AAWpD,MAAM,UAAU,OAAO,CAAC,KAAmB;IACzC,MAAM,EAAE,eAAe,EAAE,4BAA4B,EAAE,IAAI,EAAE,cAAc,EAAE,GAAG,KAAK,CAAA;IACrF,MAAM,MAAM,GAAG,gBAAgB,CAAC,KAAK,CAAC,CAAA;IACtC,MAAM,UAAU,GAAG,aAAa,EAAE,CAAA;IAElC,MAAM,sBAAsB,GAAG,GAAG,EAAE;QAClC,UAAU,CAAC,QAAQ,CAAC,gBAAgB,EAAE;YACpC,UAAU,EAAE,KAAK,CAAC,EAAE;YACpB,eAAe;SAChB,CAAC,CAAA;IACJ,CAAC,CAAA;IACD,MAAM,mBAAmB,GAAG,CAAC,QAA+B,EAAE,EA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G,EAAE,CAAC;YACN,aAAa,EAAE,IAAI,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,KAAK;SAC5C;QACD,cAAc,EAAE;YACd,GAAG,EAAE,CAAC;YACN,UAAU,EAAE,CAAC;SACd;QACD,aAAa,EAAE;YACb,aAAa,EAAE,KAAK;YACpB,GAAG,EAAE,CAAC;SACP;QACD,aAAa,EAAE;YACb,eAAe,EAAE,IAAI,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,mBAAmB;YAChE,YAAY,EAAE,CAAC;YACf,QAAQ,EAAE,GAAG;SACd;QACD,WAAW,EAAE;YACX,eAAe,EAAE,CAAC;YAClB,iBAAiB,EAAE,CAAC;SACrB;QACD,gBAAgB,EAAE;YAChB,aAAa,EAAE,KAAK;YACpB,GAAG,EAAE,CAAC;YACN,cAAc,EAAE,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,YAAY;SACjD;KACF,CAAC,CAAA;AACJ,CAAC,CAAA","sourcesContent":["import { PlatformPressable } from '@react-navigation/elements'\nimport { useNavigation } from '@react-navigation/native'\nimport colorFunction from 'color'\nimport React from 'react'\nimport { StyleSheet, View } from 'react-native'\nimport { MessageReaction } from '../../components/conversation/message_reaction'\nimport { Avatar, Text } from '../../components/display'\nimport { useTheme } from '../../hooks'\nimport { MessageResource } from '../../types'\nimport { ReactionCountResource } from '../../types/resources/reaction'\nimport { MessageAttachments } from './message_attachments'\nimport ErrorBoundary from '../page/error_boundary'\nimport { MessageMarkdown } from './message_markdown'\nimport { DenormalizedMessageAttachmentResource } from '../../types/resources/denormalized_attachment_resource'\n\n/** Message\n * Component for display of a message within a conversation list\n */\ninterface MessageProps extends MessageResource {\n canDeleteNonAuthoredMessages: boolean\n conversation_id: number\n}\n\nexport function Message(props: MessageProps) {\n const { conversation_id, canDeleteNonAuthoredMessages, text, reactionCounts } = props\n const styles = useMessageStyles(props)\n const navigation = useNavigation()\n\n const handleMessageLongPress = () => {\n navigation.navigate('MessageActions', {\n message_id: props.id,\n conversation_id,\n })\n }\n const handleReactionPress = (reaction: ReactionCountResource) => {\n navigation.navigate('Reactions', {\n message_id: props.id,\n conversation_id,\n reaction_value: reaction.value,\n })\n }\n\n const handleMessageAttachmentLongPress = (attachment: DenormalizedMessageAttachmentResource) => {\n navigation.navigate('AttachmentActions', {\n attachmentId: attachment?.id,\n attachmentContentType: attachment?.attributes.contentType,\n attachmentUrl: attachment?.attributes.url,\n conversation_id,\n canDeleteNonAuthoredMessages,\n myMessage: props.mine,\n })\n }\n\n const metaProps = {\n authorName: props.author.name,\n createdAt: props.createdAt,\n }\n\n return (\n <View style={styles.message}>\n {!props.mine && (\n <View style={styles.messageAuthor}>\n <Avatar size={'md'} sourceUri={props.author.avatar} />\n </View>\n )}\n <View style={styles.messageContent}>\n {!props.mine && <Text variant=\"tertiary\">{props.author.name}</Text>}\n <PlatformPressable style={styles.messageBubble} onLongPress={handleMessageLongPress}>\n <ErrorBoundary>\n <MessageAttachments\n attachments={props.attachments}\n metaProps={metaProps}\n onMessageAttachmentLongPress={handleMessageAttachmentLongPress}\n onMessageLongPress={handleMessageLongPress}\n />\n </ErrorBoundary>\n {text && (\n <View style={styles.messageText}>\n <MessageMarkdown text={text} />\n </View>\n )}\n </PlatformPressable>\n <View style={styles.messageReactions}>\n {reactionCounts.map(reaction => (\n <MessageReaction\n key={reaction.value}\n reaction={reaction}\n onPress={handleReactionPress}\n />\n ))}\n </View>\n </View>\n </View>\n )\n}\n\nconst useMessageStyles = ({ mine }: MessageResource) => {\n const { colors } = useTheme()\n const activeColor = colorFunction(colors.interaction).alpha(0.2).string()\n\n return StyleSheet.create({\n message: {\n gap: 8,\n flexDirection: mine ? 'row-reverse' : 'row',\n },\n messageContent: {\n gap: 8,\n flexShrink: 1,\n },\n messageAuthor: {\n flexDirection: 'row',\n gap: 8,\n },\n messageBubble: {\n backgroundColor: mine ? activeColor : colors.fillColorNeutral070,\n borderRadius: 8,\n maxWidth: 232,\n },\n messageText: {\n paddingVertical: 6,\n paddingHorizontal: 8,\n },\n messageReactions: {\n flexDirection: 'row',\n gap: 4,\n justifyContent: mine ? 'flex-end' : 'flex-start',\n },\n })\n}\n"]}
|
|
1
|
+
{"version":3,"file":"message.js","sourceRoot":"","sources":["../../../src/components/conversation/message.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AACxD,OAAO,aAAa,MAAM,OAAO,CAAA;AACjC,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AACpE,OAAO,EAAE,eAAe,EAAE,MAAM,gDAAgD,CAAA;AAChF,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAA;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAGtC,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAA;AAC1D,OAAO,aAAa,MAAM,wBAAwB,CAAA;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AAEpD,OAAO,EAAE,4CAA4C,EAAE,MAAM,oBAAoB,CAAA;AACjF,OAAO,QAAQ,EAAE,EACf,cAAc,EACd,gBAAgB,EAChB,UAAU,EACV,gBAAgB,EAChB,MAAM,GACP,MAAM,yBAAyB,CAAA;AAUhC,MAAM,UAAU,OAAO,CAAC,KAAmB;IACzC,MAAM,EAAE,eAAe,EAAE,4BAA4B,EAAE,IAAI,EAAE,cAAc,EAAE,GAAG,KAAK,CAAA;IACrF,MAAM,MAAM,GAAG,gBAAgB,CAAC,KAAK,CAAC,CAAA;IACtC,MAAM,UAAU,GAAG,aAAa,EAAE,CAAA;IAClC,MAAM,EAAE,MAAM,EAAE,GAAG,QAAQ,EAAE,CAAA;IAC7B,MAAM,YAAY,GAAG,cAAc,CAAC,MAAM,GAAG,CAAC,C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WAAW,GAAG,aAAa,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,CAAA;IAEzE,OAAO,UAAU,CAAC,MAAM,CAAC;QACvB,OAAO,EAAE;YACP,GAAG,EAAE,CAAC;YACN,aAAa,EAAE,IAAI,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,KAAK;YAC3C,iBAAiB,EAAE,4CAA4C;SAChE;QACD,cAAc,EAAE;YACd,GAAG,EAAE,CAAC;YACN,UAAU,EAAE,CAAC;SACd;QACD,aAAa,EAAE;YACb,aAAa,EAAE,KAAK;YACpB,GAAG,EAAE,CAAC;SACP;QACD,aAAa,EAAE;YACb,eAAe,EAAE,IAAI,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,mBAAmB;YAChE,YAAY,EAAE,CAAC;YACf,QAAQ,EAAE,GAAG;SACd;QACD,WAAW,EAAE;YACX,eAAe,EAAE,CAAC;YAClB,iBAAiB,EAAE,CAAC;SACrB;QACD,gBAAgB,EAAE;YAChB,aAAa,EAAE,KAAK;YACpB,GAAG,EAAE,CAAC;YACN,cAAc,EAAE,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,YAAY;SACjD;KACF,CAAC,CAAA;AACJ,CAAC,CAAA","sourcesContent":["import { useNavigation } from '@react-navigation/native'\nimport colorFunction from 'color'\nimport React from 'react'\nimport { Platform, Pressable, StyleSheet, View } from 'react-native'\nimport { MessageReaction } from '../../components/conversation/message_reaction'\nimport { Avatar, Text } from '../../components/display'\nimport { useTheme } from '../../hooks'\nimport { MessageResource } from '../../types'\nimport { ReactionCountResource } from '../../types/resources/reaction'\nimport { MessageAttachments } from './message_attachments'\nimport ErrorBoundary from '../page/error_boundary'\nimport { MessageMarkdown } from './message_markdown'\nimport { DenormalizedMessageAttachmentResource } from '../../types/resources/denormalized_attachment_resource'\nimport { CONVERSATION_MESSAGE_LIST_PADDING_HORIZONTAL } from '../../utils/styles'\nimport Animated, {\n useSharedValue,\n useAnimatedStyle,\n withTiming,\n interpolateColor,\n Easing,\n} from 'react-native-reanimated'\n\n/** Message\n * Component for display of a message within a conversation list\n */\ninterface MessageProps extends MessageResource {\n canDeleteNonAuthoredMessages: boolean\n conversation_id: number\n}\n\nexport function Message(props: MessageProps) {\n const { conversation_id, canDeleteNonAuthoredMessages, text, reactionCounts } = props\n const styles = useMessageStyles(props)\n const navigation = useNavigation()\n const { colors } = useTheme()\n const hasReactions = reactionCounts.length > 0\n\n const bgFadeProgress = useSharedValue(0)\n const pressedColor = Platform.select({\n ios: colors.fillColorNeutral050Base,\n default: 'transparent',\n })\n const animatedBackgroundColor = useAnimatedStyle(() => {\n const backgroundColor = interpolateColor(\n bgFadeProgress.value,\n [0, 1],\n ['transparent', pressedColor]\n )\n return {\n backgroundColor,\n }\n })\n\n const handlePressIn = () => {\n bgFadeProgress.value = withTiming(1, { duration: 300, easing: Easing.inOut(Easing.ease) })\n }\n\n const handlePressOut = () => {\n bgFadeProgress.value = withTiming(0, { duration: 300, easing: Easing.inOut(Easing.ease) })\n }\n\n const handleMessageLongPress = () => {\n navigation.navigate('MessageActions', {\n message_id: props.id,\n conversation_id,\n })\n }\n const handleReactionPress = (reaction: ReactionCountResource) => {\n navigation.navigate('Reactions', {\n message_id: props.id,\n conversation_id,\n reaction_value: reaction.value,\n })\n }\n\n const handleMessageAttachmentLongPress = (attachment: DenormalizedMessageAttachmentResource) => {\n navigation.navigate('AttachmentActions', {\n attachmentId: attachment?.id,\n attachmentContentType: attachment?.attributes.contentType,\n attachmentUrl: attachment?.attributes.url,\n conversation_id,\n canDeleteNonAuthoredMessages,\n myMessage: props.mine,\n })\n }\n\n const metaProps = {\n authorName: props.author.name,\n createdAt: props.createdAt,\n }\n\n return (\n <Pressable\n onLongPress={handleMessageLongPress}\n onPressIn={handlePressIn}\n onPressOut={handlePressOut}\n android_ripple={{ color: colors.androidRippleNeutral }}\n accessibilityHint=\"Long press to view message actions like reacting and copying.\"\n >\n <Animated.View style={[styles.message, animatedBackgroundColor]}>\n {!props.mine && (\n <View style={styles.messageAuthor}>\n <Avatar size={'md'} sourceUri={props.author.avatar} />\n </View>\n )}\n <View style={styles.messageContent}>\n {!props.mine && <Text variant=\"tertiary\">{props.author.name}</Text>}\n <View style={styles.messageBubble}>\n <ErrorBoundary>\n <MessageAttachments\n attachments={props.attachments}\n metaProps={metaProps}\n onMessageAttachmentLongPress={handleMessageAttachmentLongPress}\n onMessageLongPress={handleMessageLongPress}\n />\n </ErrorBoundary>\n {text && (\n <View style={styles.messageText}>\n <MessageMarkdown text={text} />\n </View>\n )}\n </View>\n {hasReactions && (\n <View style={styles.messageReactions}>\n {reactionCounts.map(reaction => (\n <MessageReaction\n key={reaction.value}\n reaction={reaction}\n onPress={handleReactionPress}\n />\n ))}\n </View>\n )}\n </View>\n </Animated.View>\n </Pressable>\n )\n}\n\nconst useMessageStyles = ({ mine }: MessageResource) => {\n const { colors } = useTheme()\n const activeColor = colorFunction(colors.interaction).alpha(0.2).string()\n\n return StyleSheet.create({\n message: {\n gap: 8,\n flexDirection: mine ? 'row-reverse' : 'row',\n paddingHorizontal: CONVERSATION_MESSAGE_LIST_PADDING_HORIZONTAL,\n },\n messageContent: {\n gap: 8,\n flexShrink: 1,\n },\n messageAuthor: {\n flexDirection: 'row',\n gap: 8,\n },\n messageBubble: {\n backgroundColor: mine ? activeColor : colors.fillColorNeutral070,\n borderRadius: 8,\n maxWidth: 232,\n },\n messageText: {\n paddingVertical: 6,\n paddingHorizontal: 8,\n },\n messageReactions: {\n flexDirection: 'row',\n gap: 4,\n justifyContent: mine ? 'flex-end' : 'flex-start',\n },\n })\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { useState } from 'react';
|
|
2
|
-
import { Animated, LayoutAnimation, StyleSheet, View } from 'react-native';
|
|
2
|
+
import { Animated, LayoutAnimation, StyleSheet, useWindowDimensions, View } from 'react-native';
|
|
3
3
|
import { Button } from './button';
|
|
4
4
|
import { useEffect } from 'react';
|
|
5
5
|
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
|
@@ -26,10 +26,13 @@ export const ActionButton = ({ visible = true, disabled = false, onPress, title,
|
|
|
26
26
|
</View>
|
|
27
27
|
</Animated.View>);
|
|
28
28
|
};
|
|
29
|
+
const SCALE_THAT_BUTTONS_WRAP = 1.2;
|
|
29
30
|
const useStyles = () => {
|
|
31
|
+
const { fontScale } = useWindowDimensions();
|
|
30
32
|
const { bottom } = useSafeAreaInsets();
|
|
31
33
|
const { colors } = useTheme();
|
|
32
34
|
const containerVerticalPadding = 16;
|
|
35
|
+
const isButtonsWrapping = fontScale >= SCALE_THAT_BUTTONS_WRAP;
|
|
33
36
|
return StyleSheet.create({
|
|
34
37
|
container: {
|
|
35
38
|
backgroundColor: colors.surfaceColor090,
|
|
@@ -42,7 +45,7 @@ const useStyles = () => {
|
|
|
42
45
|
},
|
|
43
46
|
buttonRow: {
|
|
44
47
|
flexDirection: 'row',
|
|
45
|
-
justifyContent: 'space-between',
|
|
48
|
+
justifyContent: isButtonsWrapping ? 'center' : 'space-between',
|
|
46
49
|
alignItems: 'center',
|
|
47
50
|
gap: 16,
|
|
48
51
|
flexWrap: 'wrap-reverse',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"action_button.js","sourceRoot":"","sources":["../../../src/components/display/action_button.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AACvC,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"action_button.js","sourceRoot":"","sources":["../../../src/components/display/action_button.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AACvC,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,UAAU,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AQ,EAAE,cAAc;SACzB;QACD,eAAe,EAAE;YACf,QAAQ,EAAE,CAAC;SACZ;QACD,QAAQ,EAAE;YACR,SAAS,EAAE,QAAQ;SACpB;KACF,CAAC,CAAA;AACJ,CAAC,CAAA","sourcesContent":["import React, { useState } from 'react'\nimport { Animated, LayoutAnimation, StyleSheet, useWindowDimensions, View } from 'react-native'\nimport { Button } from './button'\nimport { useEffect } from 'react'\nimport { useSafeAreaInsets } from 'react-native-safe-area-context'\nimport { useTheme } from '../../hooks'\nimport { Text } from './text'\nimport { IconString } from './icon'\n\nexport const ActionButton = ({\n visible = true,\n disabled = false,\n onPress,\n title,\n infoText,\n buttonIconNameLeft,\n secondaryButton,\n}: {\n visible?: boolean\n disabled?: boolean\n onPress: () => void\n title: string\n infoText?: string\n buttonIconNameLeft?: IconString\n secondaryButton?: React.ReactNode\n}) => {\n const styles = useStyles()\n const [show, setShow] = useState(visible)\n\n useEffect(() => {\n if (show === visible) return\n\n setShow(visible)\n LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut)\n }, [show, visible])\n\n if (!visible) return null\n\n return (\n <Animated.View style={styles.container}>\n {Boolean(infoText) && (\n <Text style={styles.infoText} variant=\"footnote\">\n {infoText}\n </Text>\n )}\n <View style={styles.buttonRow}>\n {secondaryButton}\n <Button\n variant=\"fill\"\n size=\"lg\"\n onPress={onPress}\n title={title}\n disabled={disabled}\n style={secondaryButton ? null : styles.fullWidthButton}\n iconNameLeft={buttonIconNameLeft}\n />\n </View>\n </Animated.View>\n )\n}\n\nconst SCALE_THAT_BUTTONS_WRAP = 1.2\n\nconst useStyles = () => {\n const { fontScale } = useWindowDimensions()\n const { bottom } = useSafeAreaInsets()\n const { colors } = useTheme()\n const containerVerticalPadding = 16\n const isButtonsWrapping = fontScale >= SCALE_THAT_BUTTONS_WRAP\n\n return StyleSheet.create({\n container: {\n backgroundColor: colors.surfaceColor090,\n paddingHorizontal: 24,\n paddingTop: containerVerticalPadding,\n paddingBottom: bottom + containerVerticalPadding,\n borderTopWidth: 1,\n borderTopColor: colors.fillColorNeutral060,\n gap: 16,\n },\n buttonRow: {\n flexDirection: 'row',\n justifyContent: isButtonsWrapping ? 'center' : 'space-between',\n alignItems: 'center',\n gap: 16,\n flexWrap: 'wrap-reverse',\n },\n fullWidthButton: {\n flexGrow: 1,\n },\n infoText: {\n textAlign: 'center',\n },\n })\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conversation_screen.d.ts","sourceRoot":"","sources":["../../src/screens/conversation_screen.tsx"],"names":[],"mappings":"AAGA,OAAO,EAGL,iBAAiB,EAIlB,MAAM,0BAA0B,CAAA;AAEjC,OAAO,KAAiC,MAAM,OAAO,CAAA;AAUrD,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"conversation_screen.d.ts","sourceRoot":"","sources":["../../src/screens/conversation_screen.tsx"],"names":[],"mappings":"AAGA,OAAO,EAGL,iBAAiB,EAIlB,MAAM,0BAA0B,CAAA;AAEjC,OAAO,KAAiC,MAAM,OAAO,CAAA;AAUrD,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAU1C,KAAK,sBAAsB,GAAG;IAC5B,eAAe,EAAE,MAAM,CAAA;IACvB,mBAAmB,CAAC,EAAE,MAAM,CAAA;IAC5B,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,kBAAkB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CACnC,CAAA;AAED,MAAM,MAAM,uBAAuB,GAAG,iBAAiB,CAAC,sBAAsB,CAAC,CAAA;AAE/E,wBAAgB,kBAAkB,CAAC,EAAE,KAAK,EAAE,EAAE,uBAAuB,qBA6EpE;AAED,MAAM,MAAM,aAAa,GAAG;IAAE,IAAI,EAAE,eAAe,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAA;AAwC/E,eAAO,MAAM,aAAa,OAAQ,eAAe,EAAE,wCAkClD,CAAA"}
|
|
@@ -17,6 +17,7 @@ import { getRelativeDateStatus } from '../utils/date';
|
|
|
17
17
|
import { EmptyConversationBlankState } from '../components/conversation/empty_conversation_blank_state';
|
|
18
18
|
import { LeaderDisabledRepliesBanner, MemberDisabledRepliesBanner, } from '../components/conversation/disabled_replies_banners';
|
|
19
19
|
import { useConversationMessagesJoltEvents } from '../hooks/use_conversation_messages_jolt_events';
|
|
20
|
+
import { CONVERSATION_MESSAGE_LIST_PADDING_HORIZONTAL } from '../utils/styles';
|
|
20
21
|
export function ConversationScreen({ route }) {
|
|
21
22
|
const styles = useStyles();
|
|
22
23
|
const navigation = useNavigation();
|
|
@@ -76,7 +77,7 @@ const useDateSeparatorStyles = () => {
|
|
|
76
77
|
container: {
|
|
77
78
|
alignItems: 'center',
|
|
78
79
|
flexDirection: 'row',
|
|
79
|
-
paddingHorizontal:
|
|
80
|
+
paddingHorizontal: CONVERSATION_MESSAGE_LIST_PADDING_HORIZONTAL,
|
|
80
81
|
paddingVertical: 16,
|
|
81
82
|
},
|
|
82
83
|
separator: {
|
|
@@ -169,7 +170,6 @@ const useStyles = () => {
|
|
|
169
170
|
},
|
|
170
171
|
listContainer: {
|
|
171
172
|
gap: 12,
|
|
172
|
-
paddingHorizontal: 16,
|
|
173
173
|
paddingVertical: 12,
|
|
174
174
|
},
|
|
175
175
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conversation_screen.js","sourceRoot":"","sources":["../../src/screens/conversation_screen.tsx"],"names":[],"mappings":"AAAA,mBAAmB;AACnB,OAAO,EAAE,IAAI,IAAI,UAAU,EAAE,MAAM,8BAA8B,CAAA;AACjE,OAAO,EAAE,WAAW,EAAoB,iBAAiB,EAAE,MAAM,4BAA4B,CAAA;AAC7F,OAAO,EACL,aAAa,EAGb,aAAa,EACb,QAAQ,IAAI,kBAAkB,EAC9B,QAAQ,GACT,MAAM,0BAA0B,CAAA;AACjC,OAAO,MAAM,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aACvB,CAAC,CAAA;QACJ,CAAC,CAAC,CAAA;IACJ,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,mBAAmB,CAAC,CAAC,CAAA;AAC/C,CAAC,CAAA","sourcesContent":["// @ts-expect-error\nimport { date as formatDate } from '@planningcenter/datetime-fmt'\nimport { HeaderTitle, HeaderTitleProps, PlatformPressable } from '@react-navigation/elements'\nimport {\n CommonActions,\n RouteProp,\n StaticScreenProps,\n useNavigation,\n useTheme as useNavigationTheme,\n useRoute,\n} from '@react-navigation/native'\nimport moment from 'moment'\nimport React, { useCallback, useEffect } from 'react'\nimport { FlatList, Platform, StyleSheet, View } from 'react-native'\nimport { useSafeAreaInsets } from 'react-native-safe-area-context'\nimport { Badge, Icon, Text } from '../components'\nimport { Message } from '../components/conversation/message'\nimport { MessageForm } from '../components/conversation/message_form'\nimport { KeyboardView } from '../components/display/keyboard_view'\nimport { useTheme } from '../hooks'\nimport { useConversation } from '../hooks/use_conversation'\nimport { useConversationMessages } from '../hooks/use_conversation_messages'\nimport { MessageResource } from '../types'\nimport { getRelativeDateStatus } from '../utils/date'\nimport { EmptyConversationBlankState } from '../components/conversation/empty_conversation_blank_state'\nimport {\n LeaderDisabledRepliesBanner,\n MemberDisabledRepliesBanner,\n} from '../components/conversation/disabled_replies_banners'\nimport { useConversationMessagesJoltEvents } from '../hooks/use_conversation_messages_jolt_events'\n\ntype ConversationRouteProps = {\n conversation_id: number\n chat_group_graph_id?: string\n clear_input?: boolean\n editing_message_id?: number | null\n}\n\nexport type ConversationScreenProps = StaticScreenProps<ConversationRouteProps>\n\nexport function ConversationScreen({ route }: ConversationScreenProps) {\n const styles = useStyles()\n const navigation = useNavigation()\n\n const { conversation_id, editing_message_id } = route.params\n const { data: conversation } = useConversation(route.params)\n const { messages, refetch, isRefetching, fetchNextPage } = useConversationMessages({\n conversation_id,\n })\n useConversationMessagesJoltEvents({ conversationId: conversation_id })\n useEnsureConversationsRouteExists()\n const messagesWithSeparators = groupMessages(messages)\n const noMessages = messagesWithSeparators.length === 0\n\n const { repliesDisabled, memberAbility } = conversation\n const canReply = memberAbility?.canReply\n const showLeaderDisabledReplyBanner = canReply && repliesDisabled\n const canDeleteNonAuthoredMessages = memberAbility?.canDeleteNonAuthoredMessages ?? false\n\n // Seems to be necessary to define this way so we get the route picked up\n const headerTitle = useCallback(\n (props: HeaderTitleProps) => <PressableHeaderTitle {...props} />,\n []\n )\n\n const currentlyEditingMessage = messages.find(m => String(m.id) === String(editing_message_id))\n\n useEffect(() => {\n navigation.setOptions({ headerTitle, title: conversation?.title })\n }, [conversation, conversation_id, navigation, headerTitle, conversation?.title])\n\n return (\n <View style={styles.container}>\n <KeyboardView>\n {noMessages ? (\n <EmptyConversationBlankState />\n ) : (\n <FlatList\n inverted\n contentContainerStyle={styles.listContainer}\n refreshing={isRefetching}\n onRefresh={refetch}\n data={messagesWithSeparators}\n keyExtractor={item => item.id}\n renderItem={({ item }) => {\n if (item.type === 'DateSeparator') {\n return <InlineDateSeparator {...item} />\n }\n\n return (\n <Message\n {...item}\n canDeleteNonAuthoredMessages={canDeleteNonAuthoredMessages}\n conversation_id={conversation_id}\n />\n )\n }}\n onEndReached={() => fetchNextPage()}\n />\n )}\n {showLeaderDisabledReplyBanner && <LeaderDisabledRepliesBanner />}\n {canReply ? (\n <MessageForm.Root\n conversation={conversation}\n currentlyEditingMessage={currentlyEditingMessage}\n >\n <MessageForm.AttachmentPicker />\n <MessageForm.Commands />\n <MessageForm.TextInput />\n <MessageForm.SubmitButton />\n </MessageForm.Root>\n ) : (\n <MemberDisabledRepliesBanner />\n )}\n </KeyboardView>\n </View>\n )\n}\n\nexport type DateSeparator = { type: 'DateSeparator'; id: string; date: string }\n\nfunction InlineDateSeparator({ date }: DateSeparator) {\n const styles = useDateSeparatorStyles()\n const { isThisYear } = getRelativeDateStatus(date)\n const showYear = !isThisYear\n const dateStamp = formatDate(date, { style: 'long', year: showYear })\n\n return (\n <View style={styles.container}>\n <View style={styles.separator} />\n <Text variant=\"footnote\" style={styles.dateText}>\n {dateStamp}\n </Text>\n <View style={styles.separator} />\n </View>\n )\n}\n\nconst useDateSeparatorStyles = () => {\n const theme = useTheme()\n return StyleSheet.create({\n container: {\n alignItems: 'center',\n flexDirection: 'row',\n paddingHorizontal: 16,\n paddingVertical: 16,\n },\n separator: {\n flex: 1,\n height: 1,\n borderTopWidth: 1,\n borderTopColor: theme.colors.borderColorDefaultBase,\n },\n dateText: {\n paddingHorizontal: 8,\n },\n })\n}\n\nexport const groupMessages = (ms: MessageResource[]) => {\n let enrichedMessages: (MessageResource | DateSeparator)[] = []\n let encounteredOneOfMyMessages = false\n\n ms.forEach((message, i) => {\n const prevMessage = ms[i + 1]\n const nextMessage = ms[i - 1]\n const date = moment(message.createdAt).format('YYYY-MM-DD')\n const prevMessageDifferentAuthor = message.author?.id !== prevMessage?.author?.id\n const nextMessageDifferentAuthor = message.author?.id !== nextMessage?.author?.id\n const prevMessageMoreThan5Minutes =\n prevMessage &&\n new Date(message.createdAt).getTime() - new Date(prevMessage.createdAt).getTime() > 60000 * 5\n const nextMessageMoreThan5Minutes =\n nextMessage &&\n new Date(nextMessage.createdAt).getTime() - new Date(message.createdAt).getTime() > 60000 * 5\n\n if (message.mine && !encounteredOneOfMyMessages) {\n encounteredOneOfMyMessages = true\n message.myLatestInConversation = true\n } else {\n message.myLatestInConversation = false\n }\n message.lastInGroup = !nextMessage || nextMessageDifferentAuthor || nextMessageMoreThan5Minutes\n message.renderAuthor =\n !message.mine && (!prevMessage || prevMessageDifferentAuthor || prevMessageMoreThan5Minutes)\n\n enrichedMessages.push(message)\n if (!prevMessage || date !== moment(prevMessage.createdAt).format('YYYY-MM-DD')) {\n enrichedMessages.push({ type: 'DateSeparator', id: `day-divider-${message.id}`, date })\n }\n })\n\n return enrichedMessages\n}\n\nconst PressableHeaderTitle = ({ style, children }: HeaderTitleProps) => {\n const styles = usePressableHeaderStyle()\n const navigation = useNavigation()\n\n const route = useRoute() as ConversationScreenProps['route']\n\n const { data: conversation } = useConversation(route.params)\n const badge = conversation.badges?.[0]\n const resourceType = badge?.pcoResourceType || ''\n const productName = badge?.appName\n const name = badge?.text || undefined\n\n return (\n <PlatformPressable\n style={styles.container}\n onPress={() =>\n navigation.navigate('ConversationDetails', { conversation_id: conversation?.id })\n }\n >\n <View style={styles.titleWrapper}>\n <HeaderTitle style={[styles.title, style]}>{children}</HeaderTitle>\n <Icon name=\"general.downChevron\" size={12} />\n </View>\n <Badge\n variant=\"metaSubtle\"\n productLogoName={productName}\n label={resourceType}\n metaLabel={name}\n style={styles.badge}\n />\n </PlatformPressable>\n )\n}\n\nconst usePressableHeaderStyle = () => {\n return StyleSheet.create({\n container: {\n alignItems: Platform.select({ android: 'flex-start', default: 'center' }),\n },\n titleWrapper: {\n alignItems: 'center',\n columnGap: 4,\n flexDirection: 'row',\n },\n title: {\n padding: 0,\n margin: 0,\n },\n badge: {\n alignSelf: Platform.select({ android: 'flex-start', default: 'center' }),\n marginTop: 2,\n },\n })\n}\n\nconst useStyles = () => {\n const navigationTheme = useNavigationTheme()\n const { bottom } = useSafeAreaInsets()\n\n return StyleSheet.create({\n container: {\n flex: 1,\n justifyContent: 'center',\n backgroundColor: navigationTheme.colors.card,\n paddingBottom: bottom,\n },\n listContainer: {\n gap: 12,\n paddingHorizontal: 16,\n paddingVertical: 12,\n },\n })\n}\n\n/**\n * useEnsureConversationsRouteExists\n */\nconst useEnsureConversationsRouteExists = () => {\n const navigation = useNavigation()\n const { params } = useRoute<RouteProp<ConversationScreenProps['route']>>()\n\n useEffect(() => {\n const navigationState = navigation.getState()\n const routes = navigationState?.routes || []\n const conversationsRoute = routes.find(r => r.name === 'Conversations')\n\n if (conversationsRoute) return\n\n navigation.dispatch(state => {\n return CommonActions.reset({\n ...state,\n routes: [\n { name: 'Conversations', params: { chat_group_graph_id: params?.chat_group_graph_id } },\n ...routes,\n ],\n index: state.index + 1,\n })\n })\n }, [navigation, params?.chat_group_graph_id])\n}\n"]}
|
|
1
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AC,CAAC,IAAI,KAAK,eAAe,CAAC,CAAA;QAEvE,IAAI,kBAAkB;YAAE,OAAM;QAE9B,UAAU,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;YAC1B,OAAO,aAAa,CAAC,KAAK,CAAC;gBACzB,GAAG,KAAK;gBACR,MAAM,EAAE;oBACN,EAAE,IAAI,EAAE,eAAe,EAAE,MAAM,EAAE,EAAE,mBAAmB,EAAE,MAAM,EAAE,mBAAmB,EAAE,EAAE;oBACvF,GAAG,MAAM;iBACV;gBACD,KAAK,EAAE,KAAK,CAAC,KAAK,GAAG,CAAC;aACvB,CAAC,CAAA;QACJ,CAAC,CAAC,CAAA;IACJ,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,mBAAmB,CAAC,CAAC,CAAA;AAC/C,CAAC,CAAA","sourcesContent":["// @ts-expect-error\nimport { date as formatDate } from '@planningcenter/datetime-fmt'\nimport { HeaderTitle, HeaderTitleProps, PlatformPressable } from '@react-navigation/elements'\nimport {\n CommonActions,\n RouteProp,\n StaticScreenProps,\n useNavigation,\n useTheme as useNavigationTheme,\n useRoute,\n} from '@react-navigation/native'\nimport moment from 'moment'\nimport React, { useCallback, useEffect } from 'react'\nimport { FlatList, Platform, StyleSheet, View } from 'react-native'\nimport { useSafeAreaInsets } from 'react-native-safe-area-context'\nimport { Badge, Icon, Text } from '../components'\nimport { Message } from '../components/conversation/message'\nimport { MessageForm } from '../components/conversation/message_form'\nimport { KeyboardView } from '../components/display/keyboard_view'\nimport { useTheme } from '../hooks'\nimport { useConversation } from '../hooks/use_conversation'\nimport { useConversationMessages } from '../hooks/use_conversation_messages'\nimport { MessageResource } from '../types'\nimport { getRelativeDateStatus } from '../utils/date'\nimport { EmptyConversationBlankState } from '../components/conversation/empty_conversation_blank_state'\nimport {\n LeaderDisabledRepliesBanner,\n MemberDisabledRepliesBanner,\n} from '../components/conversation/disabled_replies_banners'\nimport { useConversationMessagesJoltEvents } from '../hooks/use_conversation_messages_jolt_events'\nimport { CONVERSATION_MESSAGE_LIST_PADDING_HORIZONTAL } from '../utils/styles'\n\ntype ConversationRouteProps = {\n conversation_id: number\n chat_group_graph_id?: string\n clear_input?: boolean\n editing_message_id?: number | null\n}\n\nexport type ConversationScreenProps = StaticScreenProps<ConversationRouteProps>\n\nexport function ConversationScreen({ route }: ConversationScreenProps) {\n const styles = useStyles()\n const navigation = useNavigation()\n\n const { conversation_id, editing_message_id } = route.params\n const { data: conversation } = useConversation(route.params)\n const { messages, refetch, isRefetching, fetchNextPage } = useConversationMessages({\n conversation_id,\n })\n useConversationMessagesJoltEvents({ conversationId: conversation_id })\n useEnsureConversationsRouteExists()\n const messagesWithSeparators = groupMessages(messages)\n const noMessages = messagesWithSeparators.length === 0\n\n const { repliesDisabled, memberAbility } = conversation\n const canReply = memberAbility?.canReply\n const showLeaderDisabledReplyBanner = canReply && repliesDisabled\n const canDeleteNonAuthoredMessages = memberAbility?.canDeleteNonAuthoredMessages ?? false\n\n // Seems to be necessary to define this way so we get the route picked up\n const headerTitle = useCallback(\n (props: HeaderTitleProps) => <PressableHeaderTitle {...props} />,\n []\n )\n\n const currentlyEditingMessage = messages.find(m => String(m.id) === String(editing_message_id))\n\n useEffect(() => {\n navigation.setOptions({ headerTitle, title: conversation?.title })\n }, [conversation, conversation_id, navigation, headerTitle, conversation?.title])\n\n return (\n <View style={styles.container}>\n <KeyboardView>\n {noMessages ? (\n <EmptyConversationBlankState />\n ) : (\n <FlatList\n inverted\n contentContainerStyle={styles.listContainer}\n refreshing={isRefetching}\n onRefresh={refetch}\n data={messagesWithSeparators}\n keyExtractor={item => item.id}\n renderItem={({ item }) => {\n if (item.type === 'DateSeparator') {\n return <InlineDateSeparator {...item} />\n }\n\n return (\n <Message\n {...item}\n canDeleteNonAuthoredMessages={canDeleteNonAuthoredMessages}\n conversation_id={conversation_id}\n />\n )\n }}\n onEndReached={() => fetchNextPage()}\n />\n )}\n {showLeaderDisabledReplyBanner && <LeaderDisabledRepliesBanner />}\n {canReply ? (\n <MessageForm.Root\n conversation={conversation}\n currentlyEditingMessage={currentlyEditingMessage}\n >\n <MessageForm.AttachmentPicker />\n <MessageForm.Commands />\n <MessageForm.TextInput />\n <MessageForm.SubmitButton />\n </MessageForm.Root>\n ) : (\n <MemberDisabledRepliesBanner />\n )}\n </KeyboardView>\n </View>\n )\n}\n\nexport type DateSeparator = { type: 'DateSeparator'; id: string; date: string }\n\nfunction InlineDateSeparator({ date }: DateSeparator) {\n const styles = useDateSeparatorStyles()\n const { isThisYear } = getRelativeDateStatus(date)\n const showYear = !isThisYear\n const dateStamp = formatDate(date, { style: 'long', year: showYear })\n\n return (\n <View style={styles.container}>\n <View style={styles.separator} />\n <Text variant=\"footnote\" style={styles.dateText}>\n {dateStamp}\n </Text>\n <View style={styles.separator} />\n </View>\n )\n}\n\nconst useDateSeparatorStyles = () => {\n const theme = useTheme()\n return StyleSheet.create({\n container: {\n alignItems: 'center',\n flexDirection: 'row',\n paddingHorizontal: CONVERSATION_MESSAGE_LIST_PADDING_HORIZONTAL,\n paddingVertical: 16,\n },\n separator: {\n flex: 1,\n height: 1,\n borderTopWidth: 1,\n borderTopColor: theme.colors.borderColorDefaultBase,\n },\n dateText: {\n paddingHorizontal: 8,\n },\n })\n}\n\nexport const groupMessages = (ms: MessageResource[]) => {\n let enrichedMessages: (MessageResource | DateSeparator)[] = []\n let encounteredOneOfMyMessages = false\n\n ms.forEach((message, i) => {\n const prevMessage = ms[i + 1]\n const nextMessage = ms[i - 1]\n const date = moment(message.createdAt).format('YYYY-MM-DD')\n const prevMessageDifferentAuthor = message.author?.id !== prevMessage?.author?.id\n const nextMessageDifferentAuthor = message.author?.id !== nextMessage?.author?.id\n const prevMessageMoreThan5Minutes =\n prevMessage &&\n new Date(message.createdAt).getTime() - new Date(prevMessage.createdAt).getTime() > 60000 * 5\n const nextMessageMoreThan5Minutes =\n nextMessage &&\n new Date(nextMessage.createdAt).getTime() - new Date(message.createdAt).getTime() > 60000 * 5\n\n if (message.mine && !encounteredOneOfMyMessages) {\n encounteredOneOfMyMessages = true\n message.myLatestInConversation = true\n } else {\n message.myLatestInConversation = false\n }\n message.lastInGroup = !nextMessage || nextMessageDifferentAuthor || nextMessageMoreThan5Minutes\n message.renderAuthor =\n !message.mine && (!prevMessage || prevMessageDifferentAuthor || prevMessageMoreThan5Minutes)\n\n enrichedMessages.push(message)\n if (!prevMessage || date !== moment(prevMessage.createdAt).format('YYYY-MM-DD')) {\n enrichedMessages.push({ type: 'DateSeparator', id: `day-divider-${message.id}`, date })\n }\n })\n\n return enrichedMessages\n}\n\nconst PressableHeaderTitle = ({ style, children }: HeaderTitleProps) => {\n const styles = usePressableHeaderStyle()\n const navigation = useNavigation()\n\n const route = useRoute() as ConversationScreenProps['route']\n\n const { data: conversation } = useConversation(route.params)\n const badge = conversation.badges?.[0]\n const resourceType = badge?.pcoResourceType || ''\n const productName = badge?.appName\n const name = badge?.text || undefined\n\n return (\n <PlatformPressable\n style={styles.container}\n onPress={() =>\n navigation.navigate('ConversationDetails', { conversation_id: conversation?.id })\n }\n >\n <View style={styles.titleWrapper}>\n <HeaderTitle style={[styles.title, style]}>{children}</HeaderTitle>\n <Icon name=\"general.downChevron\" size={12} />\n </View>\n <Badge\n variant=\"metaSubtle\"\n productLogoName={productName}\n label={resourceType}\n metaLabel={name}\n style={styles.badge}\n />\n </PlatformPressable>\n )\n}\n\nconst usePressableHeaderStyle = () => {\n return StyleSheet.create({\n container: {\n alignItems: Platform.select({ android: 'flex-start', default: 'center' }),\n },\n titleWrapper: {\n alignItems: 'center',\n columnGap: 4,\n flexDirection: 'row',\n },\n title: {\n padding: 0,\n margin: 0,\n },\n badge: {\n alignSelf: Platform.select({ android: 'flex-start', default: 'center' }),\n marginTop: 2,\n },\n })\n}\n\nconst useStyles = () => {\n const navigationTheme = useNavigationTheme()\n const { bottom } = useSafeAreaInsets()\n\n return StyleSheet.create({\n container: {\n flex: 1,\n justifyContent: 'center',\n backgroundColor: navigationTheme.colors.card,\n paddingBottom: bottom,\n },\n listContainer: {\n gap: 12,\n paddingVertical: 12,\n },\n })\n}\n\n/**\n * useEnsureConversationsRouteExists\n */\nconst useEnsureConversationsRouteExists = () => {\n const navigation = useNavigation()\n const { params } = useRoute<RouteProp<ConversationScreenProps['route']>>()\n\n useEffect(() => {\n const navigationState = navigation.getState()\n const routes = navigationState?.routes || []\n const conversationsRoute = routes.find(r => r.name === 'Conversations')\n\n if (conversationsRoute) return\n\n navigation.dispatch(state => {\n return CommonActions.reset({\n ...state,\n routes: [\n { name: 'Conversations', params: { chat_group_graph_id: params?.chat_group_graph_id } },\n ...routes,\n ],\n index: state.index + 1,\n })\n })\n }, [navigation, params?.chat_group_graph_id])\n}\n"]}
|
package/build/utils/styles.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export declare const MAX_FONT_SIZE_MULTIPLIER = 1.5;
|
|
2
|
+
export declare const CONVERSATION_MESSAGE_LIST_PADDING_HORIZONTAL = 16;
|
|
2
3
|
export declare const platformFontWeightMedium: "500" | "700" | undefined;
|
|
3
4
|
export declare const platformFontWeightBold: "600" | "700" | undefined;
|
|
4
5
|
export declare const platformPressedOpacityStyle: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../src/utils/styles.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,wBAAwB,MAAM,CAAA;AAE3C,eAAO,MAAM,wBAAwB,2BAGnC,CAAA;AAEF,eAAO,MAAM,sBAAsB,2BAGjC,CAAA;AAEF,eAAO,MAAM,2BAA2B;;aAGtC,CAAA"}
|
|
1
|
+
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../src/utils/styles.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,wBAAwB,MAAM,CAAA;AAE3C,eAAO,MAAM,4CAA4C,KAAK,CAAA;AAE9D,eAAO,MAAM,wBAAwB,2BAGnC,CAAA;AAEF,eAAO,MAAM,sBAAsB,2BAGjC,CAAA;AAEF,eAAO,MAAM,2BAA2B;;aAGtC,CAAA"}
|
package/build/utils/styles.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Platform } from 'react-native';
|
|
2
2
|
import { tokens } from '../vendor/tapestry/tokens';
|
|
3
3
|
export const MAX_FONT_SIZE_MULTIPLIER = 1.5;
|
|
4
|
+
export const CONVERSATION_MESSAGE_LIST_PADDING_HORIZONTAL = 16; // TODO: move to `screens/conversation/utils/styles` when `/screens/conversation` is created
|
|
4
5
|
export const platformFontWeightMedium = Platform.select({
|
|
5
6
|
ios: tokens.fontWeightMedium,
|
|
6
7
|
android: tokens.fontWeightBold,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styles.js","sourceRoot":"","sources":["../../src/utils/styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAA;AAElD,MAAM,CAAC,MAAM,wBAAwB,GAAG,GAAG,CAAA;AAE3C,MAAM,CAAC,MAAM,wBAAwB,GAAG,QAAQ,CAAC,MAAM,CAAC;IACtD,GAAG,EAAE,MAAM,CAAC,gBAAgB;IAC5B,OAAO,EAAE,MAAM,CAAC,cAAc;CAC/B,CAAC,CAAA;AAEF,MAAM,CAAC,MAAM,sBAAsB,GAAG,QAAQ,CAAC,MAAM,CAAC;IACpD,GAAG,EAAE,MAAM,CAAC,kBAAkB;IAC9B,OAAO,EAAE,MAAM,CAAC,cAAc;CAC/B,CAAC,CAAA;AAEF,MAAM,CAAC,MAAM,2BAA2B,GAAG,QAAQ,CAAC,MAAM,CAAC;IACzD,GAAG,EAAE,EAAE,OAAO,EAAE,GAAG,EAAE;IACrB,OAAO,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE;CACxB,CAAC,CAAA","sourcesContent":["import { Platform } from 'react-native'\nimport { tokens } from '../vendor/tapestry/tokens'\n\nexport const MAX_FONT_SIZE_MULTIPLIER = 1.5\n\nexport const platformFontWeightMedium = Platform.select({\n ios: tokens.fontWeightMedium,\n android: tokens.fontWeightBold,\n})\n\nexport const platformFontWeightBold = Platform.select({\n ios: tokens.fontWeightSemiBold,\n android: tokens.fontWeightBold,\n})\n\nexport const platformPressedOpacityStyle = Platform.select({\n ios: { opacity: 0.5 },\n android: { opacity: 1 },\n})\n"]}
|
|
1
|
+
{"version":3,"file":"styles.js","sourceRoot":"","sources":["../../src/utils/styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAA;AAElD,MAAM,CAAC,MAAM,wBAAwB,GAAG,GAAG,CAAA;AAE3C,MAAM,CAAC,MAAM,4CAA4C,GAAG,EAAE,CAAA,CAAC,4FAA4F;AAE3J,MAAM,CAAC,MAAM,wBAAwB,GAAG,QAAQ,CAAC,MAAM,CAAC;IACtD,GAAG,EAAE,MAAM,CAAC,gBAAgB;IAC5B,OAAO,EAAE,MAAM,CAAC,cAAc;CAC/B,CAAC,CAAA;AAEF,MAAM,CAAC,MAAM,sBAAsB,GAAG,QAAQ,CAAC,MAAM,CAAC;IACpD,GAAG,EAAE,MAAM,CAAC,kBAAkB;IAC9B,OAAO,EAAE,MAAM,CAAC,cAAc;CAC/B,CAAC,CAAA;AAEF,MAAM,CAAC,MAAM,2BAA2B,GAAG,QAAQ,CAAC,MAAM,CAAC;IACzD,GAAG,EAAE,EAAE,OAAO,EAAE,GAAG,EAAE;IACrB,OAAO,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE;CACxB,CAAC,CAAA","sourcesContent":["import { Platform } from 'react-native'\nimport { tokens } from '../vendor/tapestry/tokens'\n\nexport const MAX_FONT_SIZE_MULTIPLIER = 1.5\n\nexport const CONVERSATION_MESSAGE_LIST_PADDING_HORIZONTAL = 16 // TODO: move to `screens/conversation/utils/styles` when `/screens/conversation` is created\n\nexport const platformFontWeightMedium = Platform.select({\n ios: tokens.fontWeightMedium,\n android: tokens.fontWeightBold,\n})\n\nexport const platformFontWeightBold = Platform.select({\n ios: tokens.fontWeightSemiBold,\n android: tokens.fontWeightBold,\n})\n\nexport const platformPressedOpacityStyle = Platform.select({\n ios: { opacity: 0.5 },\n android: { opacity: 1 },\n})\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@planningcenter/chat-react-native",
|
|
3
|
-
"version": "3.5.
|
|
3
|
+
"version": "3.5.1-rc.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -54,5 +54,5 @@
|
|
|
54
54
|
"prettier": "^3.4.2",
|
|
55
55
|
"typescript": "<5.6.0"
|
|
56
56
|
},
|
|
57
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "71488f876a4ba05c9dd2888ce413676311cd88f3"
|
|
58
58
|
}
|
|
@@ -16,6 +16,8 @@ export function AudioAttachment({
|
|
|
16
16
|
onMessageAttachmentLongPress: (attachment: DenormalizedMessageAttachmentResource) => void
|
|
17
17
|
}) {
|
|
18
18
|
const styles = useStyles()
|
|
19
|
+
const { colors } = useTheme()
|
|
20
|
+
|
|
19
21
|
const { attributes } = attachment
|
|
20
22
|
const { url, filename } = attributes
|
|
21
23
|
const sound = Audio.useAudio(url)
|
|
@@ -41,6 +43,7 @@ export function AudioAttachment({
|
|
|
41
43
|
return (
|
|
42
44
|
<PlatformPressable
|
|
43
45
|
onLongPress={() => onMessageAttachmentLongPress(attachment)}
|
|
46
|
+
android_ripple={{ color: colors.androidRippleNeutral, foreground: true }}
|
|
44
47
|
accessibilityHint="Long press for more options"
|
|
45
48
|
>
|
|
46
49
|
<AttachmentCard>
|
|
@@ -13,6 +13,7 @@ export function ExpandedLink({
|
|
|
13
13
|
onMessageLongPress: () => void
|
|
14
14
|
}) {
|
|
15
15
|
const styles = useStyles()
|
|
16
|
+
const { colors } = useTheme()
|
|
16
17
|
const { attributes } = attachment
|
|
17
18
|
const { url, title, description, imageUrl, imageHeight, imageWidth } = attributes
|
|
18
19
|
|
|
@@ -23,7 +24,12 @@ export function ExpandedLink({
|
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
return (
|
|
26
|
-
<PlatformPressable
|
|
27
|
+
<PlatformPressable
|
|
28
|
+
style={styles.container}
|
|
29
|
+
android_ripple={{ color: colors.androidRippleNeutral, foreground: true }}
|
|
30
|
+
onPress={openUrl}
|
|
31
|
+
onLongPress={onMessageLongPress}
|
|
32
|
+
>
|
|
27
33
|
{imageUrl && (
|
|
28
34
|
<Image source={{ uri: imageUrl }} style={[styles.image, { aspectRatio }]} alt={title} />
|
|
29
35
|
)}
|
|
@@ -15,6 +15,8 @@ export function GenericFileAttachment({
|
|
|
15
15
|
onMessageAttachmentLongPress: (attachment: DenormalizedMessageAttachmentResource) => void
|
|
16
16
|
}) {
|
|
17
17
|
const styles = useStyles()
|
|
18
|
+
const { colors } = useTheme()
|
|
19
|
+
|
|
18
20
|
const { url, filename, contentType } = attachment.attributes
|
|
19
21
|
const iconName = getAttachmentIconName(contentType)
|
|
20
22
|
const fileTypeLabel = contentType === 'application/pdf' ? 'PDF' : 'file'
|
|
@@ -22,6 +24,7 @@ export function GenericFileAttachment({
|
|
|
22
24
|
return (
|
|
23
25
|
<PlatformPressable
|
|
24
26
|
onLongPress={() => onMessageAttachmentLongPress(attachment)}
|
|
27
|
+
android_ripple={{ color: colors.androidRippleNeutral, foreground: true }}
|
|
25
28
|
accessibilityHint="Long press for more options"
|
|
26
29
|
>
|
|
27
30
|
<AttachmentCard>
|
|
@@ -13,6 +13,7 @@ export function GiphyAttachment({
|
|
|
13
13
|
onMessageLongPress: () => void
|
|
14
14
|
}) {
|
|
15
15
|
const styles = useStyles()
|
|
16
|
+
const { colors } = useTheme()
|
|
16
17
|
const { title, titleLink, giphy } = attachment
|
|
17
18
|
const { url } = giphy.fixedWidth
|
|
18
19
|
const { width, height } = assertKeysAreNumbers(giphy.fixedWidth)
|
|
@@ -29,6 +30,7 @@ export function GiphyAttachment({
|
|
|
29
30
|
onPress={handlePress}
|
|
30
31
|
onLongPress={onMessageLongPress}
|
|
31
32
|
style={styles.container}
|
|
33
|
+
android_ripple={{ color: colors.androidRippleNeutral, foreground: true }}
|
|
32
34
|
>
|
|
33
35
|
<Image
|
|
34
36
|
source={{ uri: url }}
|
|
@@ -27,6 +27,7 @@ import colorFunction from 'color'
|
|
|
27
27
|
import { formatDatePreview } from '../../../utils/date'
|
|
28
28
|
import { DenormalizedMessageAttachmentResource } from '../../../types/resources/denormalized_attachment_resource'
|
|
29
29
|
import { PlatformPressable } from '@react-navigation/elements'
|
|
30
|
+
import { useTheme } from '../../../hooks'
|
|
30
31
|
|
|
31
32
|
const PAN_THRESHOLD_PX = 300
|
|
32
33
|
|
|
@@ -46,6 +47,7 @@ export function ImageAttachment({
|
|
|
46
47
|
}) {
|
|
47
48
|
const { attributes } = attachment
|
|
48
49
|
const { url, urlMedium, filename, metadata = {} } = attributes
|
|
50
|
+
const { colors } = useTheme()
|
|
49
51
|
|
|
50
52
|
const styles = useStyles({ imageWidth: metadata.width, imageHeight: metadata.height })
|
|
51
53
|
const [visible, setVisible] = useState(false)
|
|
@@ -84,6 +86,7 @@ export function ImageAttachment({
|
|
|
84
86
|
style={styles.container}
|
|
85
87
|
onPress={() => setVisible(true)}
|
|
86
88
|
onLongPress={() => onMessageAttachmentLongPress(attachment)}
|
|
89
|
+
android_ripple={{ color: colors.androidRippleNeutral, foreground: true }}
|
|
87
90
|
accessibilityHint="Long press for more options"
|
|
88
91
|
>
|
|
89
92
|
<Image
|
|
@@ -5,6 +5,7 @@ import { MESSAGE_ATTACHMENT_WIDTH_SINGLE } from './constants'
|
|
|
5
5
|
import { IconButton } from '../../display'
|
|
6
6
|
import { Video, VideoPlayerHandle } from '../../../utils/native_adapters'
|
|
7
7
|
import { PlatformPressable } from '@react-navigation/elements'
|
|
8
|
+
import { useTheme } from '../../../hooks'
|
|
8
9
|
|
|
9
10
|
export function VideoAttachment({
|
|
10
11
|
attachment,
|
|
@@ -13,6 +14,8 @@ export function VideoAttachment({
|
|
|
13
14
|
attachment: DenormalizedMessageAttachmentResource
|
|
14
15
|
onMessageAttachmentLongPress: (attachment: DenormalizedMessageAttachmentResource) => void
|
|
15
16
|
}) {
|
|
17
|
+
const { colors } = useTheme()
|
|
18
|
+
|
|
16
19
|
const { attributes } = attachment
|
|
17
20
|
const { width = MESSAGE_ATTACHMENT_WIDTH_SINGLE, height = MESSAGE_ATTACHMENT_WIDTH_SINGLE } =
|
|
18
21
|
attributes.metadata || {}
|
|
@@ -40,6 +43,7 @@ export function VideoAttachment({
|
|
|
40
43
|
<View style={styles.container} ref={viewRef}>
|
|
41
44
|
<PlatformPressable
|
|
42
45
|
onLongPress={() => onMessageAttachmentLongPress(attachment)}
|
|
46
|
+
android_ripple={{ color: colors.androidRippleNeutral, foreground: true }}
|
|
43
47
|
accessibilityHint="Long press for more options"
|
|
44
48
|
>
|
|
45
49
|
<Video.Player
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { PlatformPressable } from '@react-navigation/elements'
|
|
2
1
|
import { useNavigation } from '@react-navigation/native'
|
|
3
2
|
import colorFunction from 'color'
|
|
4
3
|
import React from 'react'
|
|
5
|
-
import { StyleSheet, View } from 'react-native'
|
|
4
|
+
import { Platform, Pressable, StyleSheet, View } from 'react-native'
|
|
6
5
|
import { MessageReaction } from '../../components/conversation/message_reaction'
|
|
7
6
|
import { Avatar, Text } from '../../components/display'
|
|
8
7
|
import { useTheme } from '../../hooks'
|
|
@@ -12,6 +11,14 @@ import { MessageAttachments } from './message_attachments'
|
|
|
12
11
|
import ErrorBoundary from '../page/error_boundary'
|
|
13
12
|
import { MessageMarkdown } from './message_markdown'
|
|
14
13
|
import { DenormalizedMessageAttachmentResource } from '../../types/resources/denormalized_attachment_resource'
|
|
14
|
+
import { CONVERSATION_MESSAGE_LIST_PADDING_HORIZONTAL } from '../../utils/styles'
|
|
15
|
+
import Animated, {
|
|
16
|
+
useSharedValue,
|
|
17
|
+
useAnimatedStyle,
|
|
18
|
+
withTiming,
|
|
19
|
+
interpolateColor,
|
|
20
|
+
Easing,
|
|
21
|
+
} from 'react-native-reanimated'
|
|
15
22
|
|
|
16
23
|
/** Message
|
|
17
24
|
* Component for display of a message within a conversation list
|
|
@@ -25,6 +32,32 @@ export function Message(props: MessageProps) {
|
|
|
25
32
|
const { conversation_id, canDeleteNonAuthoredMessages, text, reactionCounts } = props
|
|
26
33
|
const styles = useMessageStyles(props)
|
|
27
34
|
const navigation = useNavigation()
|
|
35
|
+
const { colors } = useTheme()
|
|
36
|
+
const hasReactions = reactionCounts.length > 0
|
|
37
|
+
|
|
38
|
+
const bgFadeProgress = useSharedValue(0)
|
|
39
|
+
const pressedColor = Platform.select({
|
|
40
|
+
ios: colors.fillColorNeutral050Base,
|
|
41
|
+
default: 'transparent',
|
|
42
|
+
})
|
|
43
|
+
const animatedBackgroundColor = useAnimatedStyle(() => {
|
|
44
|
+
const backgroundColor = interpolateColor(
|
|
45
|
+
bgFadeProgress.value,
|
|
46
|
+
[0, 1],
|
|
47
|
+
['transparent', pressedColor]
|
|
48
|
+
)
|
|
49
|
+
return {
|
|
50
|
+
backgroundColor,
|
|
51
|
+
}
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
const handlePressIn = () => {
|
|
55
|
+
bgFadeProgress.value = withTiming(1, { duration: 300, easing: Easing.inOut(Easing.ease) })
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const handlePressOut = () => {
|
|
59
|
+
bgFadeProgress.value = withTiming(0, { duration: 300, easing: Easing.inOut(Easing.ease) })
|
|
60
|
+
}
|
|
28
61
|
|
|
29
62
|
const handleMessageLongPress = () => {
|
|
30
63
|
navigation.navigate('MessageActions', {
|
|
@@ -57,40 +90,50 @@ export function Message(props: MessageProps) {
|
|
|
57
90
|
}
|
|
58
91
|
|
|
59
92
|
return (
|
|
60
|
-
<
|
|
61
|
-
{
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
<
|
|
70
|
-
<
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
93
|
+
<Pressable
|
|
94
|
+
onLongPress={handleMessageLongPress}
|
|
95
|
+
onPressIn={handlePressIn}
|
|
96
|
+
onPressOut={handlePressOut}
|
|
97
|
+
android_ripple={{ color: colors.androidRippleNeutral }}
|
|
98
|
+
accessibilityHint="Long press to view message actions like reacting and copying."
|
|
99
|
+
>
|
|
100
|
+
<Animated.View style={[styles.message, animatedBackgroundColor]}>
|
|
101
|
+
{!props.mine && (
|
|
102
|
+
<View style={styles.messageAuthor}>
|
|
103
|
+
<Avatar size={'md'} sourceUri={props.author.avatar} />
|
|
104
|
+
</View>
|
|
105
|
+
)}
|
|
106
|
+
<View style={styles.messageContent}>
|
|
107
|
+
{!props.mine && <Text variant="tertiary">{props.author.name}</Text>}
|
|
108
|
+
<View style={styles.messageBubble}>
|
|
109
|
+
<ErrorBoundary>
|
|
110
|
+
<MessageAttachments
|
|
111
|
+
attachments={props.attachments}
|
|
112
|
+
metaProps={metaProps}
|
|
113
|
+
onMessageAttachmentLongPress={handleMessageAttachmentLongPress}
|
|
114
|
+
onMessageLongPress={handleMessageLongPress}
|
|
115
|
+
/>
|
|
116
|
+
</ErrorBoundary>
|
|
117
|
+
{text && (
|
|
118
|
+
<View style={styles.messageText}>
|
|
119
|
+
<MessageMarkdown text={text} />
|
|
120
|
+
</View>
|
|
121
|
+
)}
|
|
122
|
+
</View>
|
|
123
|
+
{hasReactions && (
|
|
124
|
+
<View style={styles.messageReactions}>
|
|
125
|
+
{reactionCounts.map(reaction => (
|
|
126
|
+
<MessageReaction
|
|
127
|
+
key={reaction.value}
|
|
128
|
+
reaction={reaction}
|
|
129
|
+
onPress={handleReactionPress}
|
|
130
|
+
/>
|
|
131
|
+
))}
|
|
80
132
|
</View>
|
|
81
133
|
)}
|
|
82
|
-
</PlatformPressable>
|
|
83
|
-
<View style={styles.messageReactions}>
|
|
84
|
-
{reactionCounts.map(reaction => (
|
|
85
|
-
<MessageReaction
|
|
86
|
-
key={reaction.value}
|
|
87
|
-
reaction={reaction}
|
|
88
|
-
onPress={handleReactionPress}
|
|
89
|
-
/>
|
|
90
|
-
))}
|
|
91
134
|
</View>
|
|
92
|
-
</View>
|
|
93
|
-
</
|
|
135
|
+
</Animated.View>
|
|
136
|
+
</Pressable>
|
|
94
137
|
)
|
|
95
138
|
}
|
|
96
139
|
|
|
@@ -102,6 +145,7 @@ const useMessageStyles = ({ mine }: MessageResource) => {
|
|
|
102
145
|
message: {
|
|
103
146
|
gap: 8,
|
|
104
147
|
flexDirection: mine ? 'row-reverse' : 'row',
|
|
148
|
+
paddingHorizontal: CONVERSATION_MESSAGE_LIST_PADDING_HORIZONTAL,
|
|
105
149
|
},
|
|
106
150
|
messageContent: {
|
|
107
151
|
gap: 8,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { useState } from 'react'
|
|
2
|
-
import { Animated, LayoutAnimation, StyleSheet, View } from 'react-native'
|
|
2
|
+
import { Animated, LayoutAnimation, StyleSheet, useWindowDimensions, View } from 'react-native'
|
|
3
3
|
import { Button } from './button'
|
|
4
4
|
import { useEffect } from 'react'
|
|
5
5
|
import { useSafeAreaInsets } from 'react-native-safe-area-context'
|
|
@@ -59,10 +59,14 @@ export const ActionButton = ({
|
|
|
59
59
|
)
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
+
const SCALE_THAT_BUTTONS_WRAP = 1.2
|
|
63
|
+
|
|
62
64
|
const useStyles = () => {
|
|
65
|
+
const { fontScale } = useWindowDimensions()
|
|
63
66
|
const { bottom } = useSafeAreaInsets()
|
|
64
67
|
const { colors } = useTheme()
|
|
65
68
|
const containerVerticalPadding = 16
|
|
69
|
+
const isButtonsWrapping = fontScale >= SCALE_THAT_BUTTONS_WRAP
|
|
66
70
|
|
|
67
71
|
return StyleSheet.create({
|
|
68
72
|
container: {
|
|
@@ -76,7 +80,7 @@ const useStyles = () => {
|
|
|
76
80
|
},
|
|
77
81
|
buttonRow: {
|
|
78
82
|
flexDirection: 'row',
|
|
79
|
-
justifyContent: 'space-between',
|
|
83
|
+
justifyContent: isButtonsWrapping ? 'center' : 'space-between',
|
|
80
84
|
alignItems: 'center',
|
|
81
85
|
gap: 16,
|
|
82
86
|
flexWrap: 'wrap-reverse',
|
|
@@ -28,6 +28,7 @@ import {
|
|
|
28
28
|
MemberDisabledRepliesBanner,
|
|
29
29
|
} from '../components/conversation/disabled_replies_banners'
|
|
30
30
|
import { useConversationMessagesJoltEvents } from '../hooks/use_conversation_messages_jolt_events'
|
|
31
|
+
import { CONVERSATION_MESSAGE_LIST_PADDING_HORIZONTAL } from '../utils/styles'
|
|
31
32
|
|
|
32
33
|
type ConversationRouteProps = {
|
|
33
34
|
conversation_id: number
|
|
@@ -142,7 +143,7 @@ const useDateSeparatorStyles = () => {
|
|
|
142
143
|
container: {
|
|
143
144
|
alignItems: 'center',
|
|
144
145
|
flexDirection: 'row',
|
|
145
|
-
paddingHorizontal:
|
|
146
|
+
paddingHorizontal: CONVERSATION_MESSAGE_LIST_PADDING_HORIZONTAL,
|
|
146
147
|
paddingVertical: 16,
|
|
147
148
|
},
|
|
148
149
|
separator: {
|
|
@@ -261,7 +262,6 @@ const useStyles = () => {
|
|
|
261
262
|
},
|
|
262
263
|
listContainer: {
|
|
263
264
|
gap: 12,
|
|
264
|
-
paddingHorizontal: 16,
|
|
265
265
|
paddingVertical: 12,
|
|
266
266
|
},
|
|
267
267
|
})
|
package/src/utils/styles.ts
CHANGED
|
@@ -3,6 +3,8 @@ import { tokens } from '../vendor/tapestry/tokens'
|
|
|
3
3
|
|
|
4
4
|
export const MAX_FONT_SIZE_MULTIPLIER = 1.5
|
|
5
5
|
|
|
6
|
+
export const CONVERSATION_MESSAGE_LIST_PADDING_HORIZONTAL = 16 // TODO: move to `screens/conversation/utils/styles` when `/screens/conversation` is created
|
|
7
|
+
|
|
6
8
|
export const platformFontWeightMedium = Platform.select({
|
|
7
9
|
ios: tokens.fontWeightMedium,
|
|
8
10
|
android: tokens.fontWeightBold,
|