@planningcenter/chat-react-native 3.4.1-rc.0 → 3.4.1-rc.2

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.
@@ -1,5 +1,10 @@
1
1
  import React from 'react';
2
- export declare function ImageAttachment({ attachment }: {
2
+ export type MetaProps = {
3
+ authorName: string;
4
+ createdAt: string;
5
+ };
6
+ export declare function ImageAttachment({ attachment, metaProps, }: {
3
7
  attachment: any;
8
+ metaProps: MetaProps;
4
9
  }): React.JSX.Element;
5
10
  //# sourceMappingURL=image_attachment.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"image_attachment.d.ts","sourceRoot":"","sources":["../../../../src/components/conversation/attachments/image_attachment.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAGzB,wBAAgB,eAAe,CAAC,EAAE,UAAU,EAAE,EAAE;IAAE,UAAU,EAAE,GAAG,CAAA;CAAE,qBAelE"}
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;AAgC7D,MAAM,MAAM,SAAS,GAAG;IACtB,UAAU,EAAE,MAAM,CAAA;IAClB,SAAS,EAAE,MAAM,CAAA;CAClB,CAAA;AAED,wBAAgB,eAAe,CAAC,EAC9B,UAAU,EACV,SAAS,GACV,EAAE;IACD,UAAU,EAAE,GAAG,CAAA;IACf,SAAS,EAAE,SAAS,CAAA;CACrB,qBAwDA"}
@@ -1,16 +1,81 @@
1
- import React from 'react';
2
- import { View, Image, StyleSheet } from 'react-native';
3
- export function ImageAttachment({ attachment }) {
1
+ import React, { useCallback, useMemo, useState } from 'react';
2
+ import { Image, StyleSheet, Modal, Pressable, useWindowDimensions, SafeAreaView, View, Linking, } from 'react-native';
3
+ import { Gesture, GestureDetector, GestureHandlerRootView, } from 'react-native-gesture-handler';
4
+ import Animated, { runOnJS, useAnimatedStyle, useSharedValue, withTiming, } from 'react-native-reanimated';
5
+ import { tokens } from '../../../vendor/tapestry/tokens';
6
+ import { IconButton, Heading, Text } from '../../display';
7
+ import colorFunction from 'color';
8
+ import { formatDatePreview } from '../../../utils/date';
9
+ const PAN_THRESHOLD_PX = 300;
10
+ export function ImageAttachment({ attachment, metaProps, }) {
4
11
  const styles = useStyles();
12
+ const [visible, setVisible] = useState(false);
13
+ // shared values run on the native UI thread and prevents clogging up the JS thread
14
+ const dismissY = useSharedValue(0);
15
+ const opacity = useSharedValue(1);
16
+ const resetAnimations = useCallback(() => {
17
+ dismissY.value = withTiming(0);
18
+ opacity.value = withTiming(1);
19
+ }, [dismissY, opacity]);
20
+ const handleCloseModal = useCallback(() => {
21
+ setVisible(false);
22
+ resetAnimations();
23
+ }, [setVisible, resetAnimations]);
24
+ const panGesture = Gesture.Pan()
25
+ .onUpdate(e => {
26
+ dismissY.value = e.translationY;
27
+ opacity.value = 1 - Math.abs(e.translationY) / PAN_THRESHOLD_PX;
28
+ })
29
+ .onEnd(() => {
30
+ runOnJS(handleCloseModal)(); // Ensures we can call a JS function
31
+ });
32
+ const animatedImageStyle = useAnimatedStyle(() => ({
33
+ transform: [{ translateY: dismissY.value }],
34
+ opacity: opacity.value,
35
+ }));
5
36
  const { attributes } = attachment;
6
37
  const { url, urlMedium, filename, metadata = {} } = attributes;
7
38
  const width = metadata.width || 100;
8
39
  const height = metadata.height || 100;
9
- return (<View style={styles.container}>
10
- <Image source={{ uri: urlMedium || url }} style={[styles.image, { aspectRatio: width / height }]} accessibilityLabel={filename}/>
11
- </View>);
40
+ return (<>
41
+ <Pressable style={styles.container} onPress={() => setVisible(true)}>
42
+ <Image source={{ uri: urlMedium || url }} style={[styles.image, { aspectRatio: width / height }]} accessibilityLabel={filename}/>
43
+ </Pressable>
44
+ <LightboxModal visible={visible} handleCloseModal={handleCloseModal} uri={urlMedium || url} metaProps={metaProps} panGesture={panGesture} animatedImageStyle={animatedImageStyle}/>
45
+ </>);
12
46
  }
47
+ const LightboxModal = ({ uri, visible, handleCloseModal, metaProps, panGesture, animatedImageStyle, }) => {
48
+ const styles = useStyles();
49
+ const { authorName, createdAt } = metaProps;
50
+ const handleOpenInBrowser = () => {
51
+ Linking.openURL(uri);
52
+ };
53
+ return (<Modal visible={visible} transparent animationType="fade" onRequestClose={handleCloseModal}>
54
+ <SafeAreaView style={styles.modal}>
55
+ <GestureHandlerRootView>
56
+ <GestureDetector gesture={panGesture}>
57
+ <Animated.Image source={{ uri }} style={[styles.lightboxImage, animatedImageStyle]} resizeMode="contain"/>
58
+ </GestureDetector>
59
+ <View style={styles.actionToolbar} accessibilityRole="toolbar">
60
+ <View style={styles.actionToolbarTextMeta}>
61
+ <Heading variant="h3" style={styles.actionToolbarTitle} numberOfLines={1}>
62
+ {authorName}
63
+ </Heading>
64
+ <Text variant="tertiary" style={styles.actionToolbarSubtitle}>
65
+ {formatDatePreview(createdAt)}
66
+ </Text>
67
+ </View>
68
+ <IconButton onPress={handleOpenInBrowser} name="general.newWindow" accessibilityRole="link" accessibilityLabel="Open image in browser" accessibilityHint="Image can be downloaded and shared through the browser." style={styles.actionButton} iconStyle={styles.actionButtonIcon} size="lg"/>
69
+ <IconButton onPress={handleCloseModal} name="general.x" accessibilityLabel="Close image" style={styles.actionButton} iconStyle={styles.actionButtonIcon}/>
70
+ </View>
71
+ </GestureHandlerRootView>
72
+ </SafeAreaView>
73
+ </Modal>);
74
+ };
13
75
  const useStyles = () => {
76
+ const { width: windowWidth } = useWindowDimensions();
77
+ const backgroundColor = tokens.colorNeutral7;
78
+ const transparentBackgroundColor = useMemo(() => colorFunction(backgroundColor).alpha(0.8).toString(), [backgroundColor]);
14
79
  return StyleSheet.create({
15
80
  container: {
16
81
  maxWidth: '100%',
@@ -19,6 +84,50 @@ const useStyles = () => {
19
84
  borderRadius: 8,
20
85
  minWidth: 200,
21
86
  },
87
+ modal: {
88
+ flex: 1,
89
+ backgroundColor,
90
+ justifyContent: 'center',
91
+ alignItems: 'center',
92
+ },
93
+ lightboxImage: {
94
+ width: windowWidth,
95
+ height: '100%',
96
+ },
97
+ actionToolbar: {
98
+ width: '100%',
99
+ position: 'absolute',
100
+ top: 0,
101
+ flexDirection: 'row',
102
+ alignItems: 'center',
103
+ gap: 20,
104
+ paddingHorizontal: 16,
105
+ paddingTop: 16,
106
+ paddingBottom: 8,
107
+ backgroundColor: transparentBackgroundColor,
108
+ },
109
+ actionToolbarTextMeta: {
110
+ flex: 1,
111
+ },
112
+ actionToolbarTitle: {
113
+ marginRight: 'auto',
114
+ flexShrink: 1,
115
+ color: tokens.colorNeutral88,
116
+ },
117
+ actionToolbarSubtitle: {
118
+ color: tokens.colorNeutral68,
119
+ },
120
+ actionButton: {
121
+ backgroundColor,
122
+ height: 40,
123
+ width: 40,
124
+ borderRadius: 50,
125
+ borderWidth: 1,
126
+ borderColor: tokens.colorNeutral24,
127
+ },
128
+ actionButtonIcon: {
129
+ color: tokens.colorNeutral88,
130
+ },
22
131
  });
23
132
  };
24
133
  //# sourceMappingURL=image_attachment.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"image_attachment.js","sourceRoot":"","sources":["../../../../src/components/conversation/attachments/image_attachment.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAEtD,MAAM,UAAU,eAAe,CAAC,EAAE,UAAU,EAAuB;IACjE,MAAM,MAAM,GAAG,SAAS,EAAE,CAAA;IAC1B,MAAM,EAAE,UAAU,EAAE,GAAG,UAAU,CAAA;IACjC,MAAM,EAAE,GAAG,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,GAAG,EAAE,EAAE,GAAG,UAAU,CAAA;IAC9D,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,IAAI,GAAG,CAAA;IACnC,MAAM,MAAM,GAAG,QAAQ,CAAC,MAAM,IAAI,GAAG,CAAA;IACrC,OAAO,CACL,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,CAC5B;MAAA,CAAC,KAAK,CACJ,MAAM,CAAC,CAAC,EAAE,GAAG,EAAE,SAAS,IAAI,GAAG,EAAE,CAAC,CAClC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,EAAE,EAAE,WAAW,EAAE,KAAK,GAAG,MAAM,EAAE,CAAC,CAAC,CACvD,kBAAkB,CAAC,CAAC,QAAQ,CAAC,EAEjC;IAAA,EAAE,IAAI,CAAC,CACR,CAAA;AACH,CAAC;AAED,MAAM,SAAS,GAAG,GAAG,EAAE;IACrB,OAAO,UAAU,CAAC,MAAM,CAAC;QACvB,SAAS,EAAE;YACT,QAAQ,EAAE,MAAM;SACjB;QACD,KAAK,EAAE;YACL,YAAY,EAAE,CAAC;YACf,QAAQ,EAAE,GAAG;SACd;KACF,CAAC,CAAA;AACJ,CAAC,CAAA","sourcesContent":["import React from 'react'\nimport { View, Image, StyleSheet } from 'react-native'\n\nexport function ImageAttachment({ attachment }: { attachment: any }) {\n const styles = useStyles()\n const { attributes } = attachment\n const { url, urlMedium, filename, metadata = {} } = attributes\n const width = metadata.width || 100\n const height = metadata.height || 100\n return (\n <View style={styles.container}>\n <Image\n source={{ uri: urlMedium || url }}\n style={[styles.image, { aspectRatio: width / height }]}\n accessibilityLabel={filename}\n />\n </View>\n )\n}\n\nconst useStyles = () => {\n return StyleSheet.create({\n container: {\n maxWidth: '100%',\n },\n image: {\n borderRadius: 8,\n minWidth: 200,\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,KAAK,EACL,UAAU,EACV,KAAK,EACL,SAAS,EACT,m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CAAC,cAAc;SAC7B;KACF,CAAC,CAAA;AACJ,CAAC,CAAA","sourcesContent":["import React, { useCallback, useMemo, useState } from 'react'\nimport {\n Image,\n StyleSheet,\n Modal,\n Pressable,\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 Animated, {\n runOnJS,\n useAnimatedStyle,\n useSharedValue,\n withTiming,\n type AnimatedStyle,\n} from 'react-native-reanimated'\nimport { tokens } from '../../../vendor/tapestry/tokens'\nimport { IconButton, Heading, Text } from '../../display'\nimport colorFunction from 'color'\nimport { formatDatePreview } from '../../../utils/date'\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}: {\n attachment: any\n metaProps: MetaProps\n}) {\n const styles = useStyles()\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 const { attributes } = attachment\n const { url, urlMedium, filename, metadata = {} } = attributes\n const width = metadata.width || 100\n const height = metadata.height || 100\n\n return (\n <>\n <Pressable style={styles.container} onPress={() => setVisible(true)}>\n <Image\n source={{ uri: urlMedium || url }}\n style={[styles.image, { aspectRatio: width / height }]}\n accessibilityLabel={filename}\n />\n </Pressable>\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 <Animated.Image\n source={{ uri }}\n style={[styles.lightboxImage, animatedImageStyle]}\n resizeMode=\"contain\"\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\nconst useStyles = () => {\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 image: {\n borderRadius: 8,\n minWidth: 200,\n },\n modal: {\n flex: 1,\n backgroundColor,\n justifyContent: 'center',\n alignItems: 'center',\n },\n lightboxImage: {\n width: windowWidth,\n height: '100%',\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":"message.d.ts","sourceRoot":"","sources":["../../../src/components/conversation/message.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,MAAM,OAAO,CAAA;AAKzB,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAM7C;;GAEG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,eAAe,GAAG;IAAE,eAAe,EAAE,MAAM,CAAA;CAAE,qBAiD3E"}
1
+ {"version":3,"file":"message.d.ts","sourceRoot":"","sources":["../../../src/components/conversation/message.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,MAAM,OAAO,CAAA;AAKzB,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAM7C;;GAEG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,eAAe,GAAG;IAAE,eAAe,EAAE,MAAM,CAAA;CAAE,qBAsD3E"}
@@ -29,6 +29,10 @@ export function Message(props) {
29
29
  reaction_value: reaction.value,
30
30
  });
31
31
  };
32
+ const metaProps = {
33
+ authorName: props.author.name,
34
+ createdAt: props.createdAt,
35
+ };
32
36
  return (<View style={styles.message}>
33
37
  {!props.mine && (<View style={styles.messageAuthor}>
34
38
  <Avatar size={'md'} sourceUri={props.author.avatar}/>
@@ -37,7 +41,7 @@ export function Message(props) {
37
41
  {!props.mine && <Text variant="tertiary">{props.author.name}</Text>}
38
42
  <PlatformPressable style={styles.messageBubble} onLongPress={handleMessagePress}>
39
43
  <ErrorBoundary>
40
- <MessageAttachments attachments={props.attachments}/>
44
+ <MessageAttachments attachments={props.attachments} metaProps={metaProps}/>
41
45
  </ErrorBoundary>
42
46
  {text && (<View style={styles.messageText}>
43
47
  <MessageMarkdown text={text}/>
@@ -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;AAEpD;;GAEG;AACH,MAAM,UAAU,OAAO,CAA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;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'\n\n/** Message\n * Component for display of a message within a conversation list\n */\nexport function Message(props: MessageResource & { conversation_id: number }) {\n const { text, conversation_id, reactionCounts } = props\n const styles = useMessageStyles(props)\n const navigation = useNavigation()\n const handleMessagePress = () => {\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 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={handleMessagePress}>\n <ErrorBoundary>\n <MessageAttachments attachments={props.attachments} />\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,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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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;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'\n\n/** Message\n * Component for display of a message within a conversation list\n */\nexport function Message(props: MessageResource & { conversation_id: number }) {\n const { text, conversation_id, reactionCounts } = props\n const styles = useMessageStyles(props)\n const navigation = useNavigation()\n const handleMessagePress = () => {\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 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={handleMessagePress}>\n <ErrorBoundary>\n <MessageAttachments attachments={props.attachments} metaProps={metaProps} />\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,6 +1,8 @@
1
1
  import React from 'react';
2
2
  import { DenormalizedAttachmentResource } from '../../types/resources/denormalized_attachment_resource';
3
+ import { type MetaProps } from './attachments/image_attachment';
3
4
  export declare function MessageAttachments(props: {
4
5
  attachments: DenormalizedAttachmentResource[];
6
+ metaProps: MetaProps;
5
7
  }): React.JSX.Element | null;
6
8
  //# sourceMappingURL=message_attachments.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"message_attachments.d.ts","sourceRoot":"","sources":["../../../src/components/conversation/message_attachments.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,EAAE,8BAA8B,EAAE,MAAM,wDAAwD,CAAA;AAQvG,wBAAgB,kBAAkB,CAAC,KAAK,EAAE;IAAE,WAAW,EAAE,8BAA8B,EAAE,CAAA;CAAE,4BAyB1F"}
1
+ {"version":3,"file":"message_attachments.d.ts","sourceRoot":"","sources":["../../../src/components/conversation/message_attachments.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,EAAE,8BAA8B,EAAE,MAAM,wDAAwD,CAAA;AAMvG,OAAO,EAAmB,KAAK,SAAS,EAAE,MAAM,gCAAgC,CAAA;AAEhF,wBAAgB,kBAAkB,CAAC,KAAK,EAAE;IACxC,WAAW,EAAE,8BAA8B,EAAE,CAAA;IAC7C,SAAS,EAAE,SAAS,CAAA;CACrB,4BA+BA"}
@@ -8,14 +8,14 @@ import { ExpandedLink } from './attachments/expanded_link';
8
8
  import { ImageAttachment } from './attachments/image_attachment';
9
9
  export function MessageAttachments(props) {
10
10
  const styles = useStyles();
11
- const { attachments } = props;
11
+ const { attachments, metaProps } = props;
12
12
  if (!attachments || attachments.length === 0)
13
13
  return null;
14
14
  return (<View style={styles.attachmentsContainer}>
15
15
  {attachments.map(attachment => {
16
16
  switch (attachment.type) {
17
17
  case 'MessageAttachment':
18
- return <MessageAttachment key={attachment.id} attachment={attachment}/>;
18
+ return (<MessageAttachment key={attachment.id} attachment={attachment} metaProps={metaProps}/>);
19
19
  case 'giphy':
20
20
  return (<GiphyAttachment key={attachment.id || attachment.titleLink} attachment={attachment}/>);
21
21
  case 'ExpandedLink':
@@ -26,13 +26,13 @@ export function MessageAttachments(props) {
26
26
  })}
27
27
  </View>);
28
28
  }
29
- function MessageAttachment({ attachment }) {
29
+ function MessageAttachment({ attachment, metaProps }) {
30
30
  const { attributes } = attachment;
31
31
  const contentType = attributes?.contentType;
32
32
  const basicType = contentType ? contentType.split('/')[0] : '';
33
33
  switch (basicType) {
34
34
  case 'image':
35
- return <ImageAttachment attachment={attachment}/>;
35
+ return <ImageAttachment attachment={attachment} metaProps={metaProps}/>;
36
36
  case 'video':
37
37
  return <VideoAttachment attachment={attachment}/>;
38
38
  case 'audio':
@@ -1 +1 @@
1
- {"version":3,"file":"message_attachments.js","sourceRoot":"","sources":["../../../src/components/conversation/message_attachments.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAE/C,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAA;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAA;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAA;AAChE,OAAO,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAA;AAC7E,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAA;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAA;AAEhE,MAAM,UAAU,kBAAkB,CAAC,KAAwD;IACzF,MAAM,MAAM,GAAG,SAAS,EAAE,CAAA;IAC1B,MAAM,EAAE,WAAW,EAAE,GAAG,KAAK,CAAA;IAC7B,IAAI,CAAC,WAAW,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,IAAI,CAAA;IACzD,OAAO,CACL,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,oBAAoB,CAAC,CACvC;MAAA,CAAC,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC,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,UAAU,CAAC,CAAC,UAAU,CAAC,EAAG,CAAA;IAC5D,CAAC;AACH,CAAC;AAED,MAAM,SAAS,GAAG,GAAG,EAAE;IACrB,OAAO,UAAU,CAAC,MAAM,CAAC;QACvB,oBAAoB,EAAE;YACpB,GAAG,EAAE,CAAC;YACN,OAAO,EAAE,CAAC;SACX;KACF,CAAC,CAAA;AACJ,CAAC,CAAA","sourcesContent":["import React from 'react'\nimport { View, StyleSheet } from 'react-native'\nimport { DenormalizedAttachmentResource } from '../../types/resources/denormalized_attachment_resource'\nimport { AudioAttachment } from './attachments/audio_attachment'\nimport { VideoAttachment } from './attachments/video_attachment'\nimport { GiphyAttachment } from './attachments/giphy_attachment'\nimport { GenericFileAttachment } from './attachments/generic_file_attachment'\nimport { ExpandedLink } from './attachments/expanded_link'\nimport { ImageAttachment } from './attachments/image_attachment'\n\nexport function MessageAttachments(props: { attachments: DenormalizedAttachmentResource[] }) {\n const styles = useStyles()\n const { attachments } = props\n if (!attachments || attachments.length === 0) return null\n return (\n <View style={styles.attachmentsContainer}>\n {attachments.map(attachment => {\n switch (attachment.type) {\n case 'MessageAttachment':\n return <MessageAttachment key={attachment.id} attachment={attachment} />\n case 'giphy':\n return (\n <GiphyAttachment\n key={attachment.id || attachment.titleLink}\n attachment={attachment}\n />\n )\n case 'ExpandedLink':\n return <ExpandedLink key={attachment.id} attachment={attachment} />\n default:\n return null\n }\n })}\n </View>\n )\n}\n\nfunction MessageAttachment({ attachment }: { attachment: any }) {\n const { attributes } = attachment\n const contentType = attributes?.contentType\n const basicType = contentType ? contentType.split('/')[0] : ''\n switch (basicType) {\n case 'image':\n return <ImageAttachment attachment={attachment} />\n case 'video':\n return <VideoAttachment attachment={attachment} />\n case 'audio':\n return <AudioAttachment attachment={attachment} />\n default:\n return <GenericFileAttachment attachment={attachment} />\n }\n}\n\nconst useStyles = () => {\n return StyleSheet.create({\n attachmentsContainer: {\n gap: 4,\n padding: 2,\n },\n })\n}\n"]}
1
+ {"version":3,"file":"message_attachments.js","sourceRoot":"","sources":["../../../src/components/conversation/message_attachments.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAE/C,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAA;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAA;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAA;AAChE,OAAO,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAA;AAC7E,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAA;AAC1D,OAAO,EAAE,eAAe,EAAkB,MAAM,gCAAgC,CAAA;AAEhF,MAAM,UAAU,kBAAkB,CAAC,KAGlC;IACC,MAAM,MAAM,GAAG,SAAS,EAAE,CAAA;IAC1B,MAAM,EAAE,WAAW,EAAE,SAAS,EAAE,GAAG,KAAK,CAAA;IACxC,IAAI,CAAC,WAAW,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,IAAI,CAAA;IACzD,OAAO,CACL,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,oBAAoB,CAAC,CACvC;MAAA,CAAC,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE;YAC5B,QAAQ,UAAU,CAAC,IAAI,EAAE,CAAC;gBACxB,KAAK,mBAAmB;oBACtB,OAAO,CACL,CAAC,iBAAiB,CAChB,GAAG,CAAC,CAAC,UAAU,CAAC,EAAE,CAAC,CACnB,UAAU,CAAC,CAAC,UAAU,CAAC,CACvB,SAAS,CAAC,CAAC,SAAS,CAAC,EACrB,CACH,CAAA;gBACH,KAAK,OAAO;oBACV,OAAO,CACL,CAAC,eAAe,CACd,GAAG,CAAC,CAAC,UAAU,CAAC,EAAE,IAAI,UAAU,CAAC,SAAS,CAAC,CAC3C,UAAU,CAAC,CAAC,UAAU,CAAC,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achmentResource } from '../../types/resources/denormalized_attachment_resource'\nimport { AudioAttachment } from './attachments/audio_attachment'\nimport { VideoAttachment } from './attachments/video_attachment'\nimport { GiphyAttachment } from './attachments/giphy_attachment'\nimport { GenericFileAttachment } from './attachments/generic_file_attachment'\nimport { ExpandedLink } from './attachments/expanded_link'\nimport { ImageAttachment, type MetaProps } from './attachments/image_attachment'\n\nexport function MessageAttachments(props: {\n attachments: DenormalizedAttachmentResource[]\n metaProps: MetaProps\n}) {\n const styles = useStyles()\n const { attachments, metaProps } = props\n if (!attachments || attachments.length === 0) return null\n return (\n <View style={styles.attachmentsContainer}>\n {attachments.map(attachment => {\n switch (attachment.type) {\n case 'MessageAttachment':\n return (\n <MessageAttachment\n key={attachment.id}\n attachment={attachment}\n metaProps={metaProps}\n />\n )\n case 'giphy':\n return (\n <GiphyAttachment\n key={attachment.id || attachment.titleLink}\n attachment={attachment}\n />\n )\n case 'ExpandedLink':\n return <ExpandedLink key={attachment.id} attachment={attachment} />\n default:\n return null\n }\n })}\n </View>\n )\n}\n\nfunction MessageAttachment({ attachment, metaProps }: { attachment: any; metaProps: MetaProps }) {\n const { attributes } = attachment\n const contentType = attributes?.contentType\n const basicType = contentType ? contentType.split('/')[0] : ''\n switch (basicType) {\n case 'image':\n return <ImageAttachment attachment={attachment} metaProps={metaProps} />\n case 'video':\n return <VideoAttachment attachment={attachment} />\n case 'audio':\n return <AudioAttachment attachment={attachment} />\n default:\n return <GenericFileAttachment attachment={attachment} />\n }\n}\n\nconst useStyles = () => {\n return StyleSheet.create({\n attachmentsContainer: {\n gap: 4,\n padding: 2,\n },\n })\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"message_form.d.ts","sourceRoot":"","sources":["../../../src/components/conversation/message_form.tsx"],"names":[],"mappings":"AACA,OAAO,KAAuD,MAAM,OAAO,CAAA;AAC3E,OAAO,EAA+B,SAAS,EAAE,MAAM,cAAc,CAAA;AAGrE,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAYlD,eAAO,MAAM,WAAW;;;;;;CAMvB,CAAA;AAED,UAAU,qBAAsB,SAAQ,SAAS;IAC/C,YAAY,EAAE,oBAAoB,CAAA;CACnC;AAqBD,iBAAS,eAAe,CAAC,EAAE,YAAY,EAAE,QAAQ,EAAE,EAAE,qBAAqB,qBAkGzE;AAiCD,iBAAS,gBAAgB,sBA4BxB;AAED,iBAAS,oBAAoB,sBAe5B;AAED,iBAAS,2BAA2B,6BA8EnC;AAED,iBAAS,mBAAmB,6BA4B3B"}
1
+ {"version":3,"file":"message_form.d.ts","sourceRoot":"","sources":["../../../src/components/conversation/message_form.tsx"],"names":[],"mappings":"AACA,OAAO,KAAuD,MAAM,OAAO,CAAA;AAC3E,OAAO,EAA+B,SAAS,EAAE,MAAM,cAAc,CAAA;AAGrE,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAYlD,eAAO,MAAM,WAAW;;;;;;CAMvB,CAAA;AAED,UAAU,qBAAsB,SAAQ,SAAS;IAC/C,YAAY,EAAE,oBAAoB,CAAA;CACnC;AAwBD,iBAAS,eAAe,CAAC,EAAE,YAAY,EAAE,QAAQ,EAAE,EAAE,qBAAqB,qBAkGzE;AAiCD,iBAAS,gBAAgB,sBAgCxB;AAED,iBAAS,oBAAoB,sBAe5B;AAED,iBAAS,2BAA2B,6BA8EnC;AAED,iBAAS,mBAAmB,6BA6B3B"}
@@ -24,6 +24,8 @@ const MessageFormContext = React.createContext({
24
24
  usingGiphy: false,
25
25
  setUsingGiphy: (_usingGiphy) => { },
26
26
  });
27
+ const GIPHY_MAX_LENGTH = 50;
28
+ const MAX_MESSAGE_LENGTH = 5000;
27
29
  function MessageFormRoot({ conversation, children }) {
28
30
  const { giphyApiKey } = useContext(ChatContext);
29
31
  const canGiphy = !!giphyApiKey;
@@ -132,12 +134,14 @@ function MessageFormInput() {
132
134
  const attachmentError = attachmentUploader?.errorMessage;
133
135
  return (<View style={styles.textInputBoundary}>
134
136
  <MessageFormAttachments />
135
- <View style={styles.textInput}>
137
+ <View style={styles.textInputRow}>
136
138
  {usingGiphy ? (<View style={styles.giphyBadge}>
137
139
  <Text>/Giphy</Text>
138
140
  </View>) : null}
139
141
 
140
- <TextInput aria-disabled={true} placeholder="Send a message" onChangeText={setText} value={text} onSubmitEditing={onSubmit}/>
142
+ <View style={styles.textInput}>
143
+ <TextInput multiline={true} aria-disabled={true} placeholder="Send a message" onChangeText={setText} value={text} maxLength={usingGiphy ? GIPHY_MAX_LENGTH : MAX_MESSAGE_LENGTH} onSubmitEditing={onSubmit}/>
144
+ </View>
141
145
  </View>
142
146
 
143
147
  {attachmentError ? <Text style={styles.inputErrorMessage}>{attachmentError}</Text> : null}
@@ -200,14 +204,14 @@ function MessageFormAttachmentPicker() {
200
204
  </View>);
201
205
  }
202
206
  function MessageFormCommands() {
203
- const { canGiphy, usingGiphy, setUsingGiphy } = React.useContext(MessageFormContext);
207
+ const { text, canGiphy, usingGiphy, setUsingGiphy } = React.useContext(MessageFormContext);
204
208
  if (!canGiphy) {
205
209
  return null;
206
210
  }
207
211
  if (usingGiphy) {
208
212
  return (<IconButton accessibilityLabel="Exit Giphy Search" size="md" appearance="neutral" name={'general.x'} onPress={() => setUsingGiphy(false)}/>);
209
213
  }
210
- return (<IconButton accessibilityLabel="Search Giphy" size="md" appearance="neutral" name={'general.bolt'} onPress={() => setUsingGiphy(true)}/>);
214
+ return (<IconButton accessibilityLabel="Search Giphy" size="md" appearance="neutral" name={'general.bolt'} onPress={() => setUsingGiphy(true)} disabled={text.length > GIPHY_MAX_LENGTH}/>);
211
215
  }
212
216
  const useMessageFormStyles = () => {
213
217
  const theme = useTheme();
@@ -231,10 +235,14 @@ const useMessageFormStyles = () => {
231
235
  flex: 1,
232
236
  gap: 12,
233
237
  },
234
- textInput: {
238
+ textInputRow: {
235
239
  flexDirection: 'row',
240
+ alignItems: 'center',
236
241
  gap: 12,
237
242
  },
243
+ textInput: {
244
+ flex: 1,
245
+ },
238
246
  giphyBadge: {
239
247
  backgroundColor: theme.colors.fillColorNeutral050Base,
240
248
  borderRadius: 24,
@@ -1 +1 @@
1
- {"version":3,"file":"message_form.js","sourceRoot":"","sources":["../../../src/components/conversation/message_form.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,QAAQ,IAAI,kBAAkB,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAA;AAClG,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAC3E,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,IAAI,EAAa,MAAM,cAAc,CAAA;AACrE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAEtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAA;AAEjE,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AACzD,OAAO,EAAE,WAAW,EAAqB,MAAM,6BAA6B,CAAA;AAC5E,OAAO,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAA;AAK3E,OAAO,EAAE,0BAA0B,EAAE,MAAM,8CAA8C,CAAA;AAEzF,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,IAAI,EAAE,eAAe;IACrB,SAAS,EAAE,gBAAgB;IAC3B,YAAY,EAAE,oBAAoB;IAClC,gBAAgB,EAAE,2BAA2B;IAC7C,QAAQ,EAAE,mBAAmB;CAC9B,CAAA;AAMD,MAAM,kBAAkB,GAAG,KAAK,CAAC,aAAa,CAS3C;IACD,IAAI,EAAE,EAAE;IACR,OAAO,EAAE,CAAC,KAAa,EAAE,EAAE,GAAE,CAAC;IAC9B,QAAQ,EAAE,GAAG,EAAE,GAAE,CAAC;IAClB,QAAQ,EAAE,KAAK;IACf,QAAQ,EAAE,KAAK;IACf,UAAU,EAAE,KAAK;IACjB,aAAa,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AY,EAAE,EAAE;YAChB,OAAO,EAAE,CAAC;YACV,iBAAiB,EAAE,EAAE;SACtB;QACD,aAAa,EAAE;YACb,YAAY,EAAE,EAAE;YAChB,MAAM,EAAE,EAAE;YACV,KAAK,EAAE,EAAE;SACV;QACD,gBAAgB,EAAE;YAChB,QAAQ,EAAE,UAAU;SACrB;QACD,uBAAuB,EAAE;YACvB,QAAQ,EAAE,UAAU;YACpB,IAAI,EAAE,CAAC;YACP,MAAM,EAAE,EAAE;YACV,MAAM,EAAE,EAAE;YACV,GAAG,EAAE,EAAE;SACR;QACD,sBAAsB,EAAE;YACtB,aAAa,EAAE,KAAK;YACpB,GAAG,EAAE,CAAC;SACP;QACD,iBAAiB,EAAE;YACjB,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,eAAe;YACnC,QAAQ,EAAE,EAAE;SACb;KACF,CAAC,CAAA;AACJ,CAAC,CAAA","sourcesContent":["import { useNavigation, useTheme as useNavigationTheme, useRoute } from '@react-navigation/native'\nimport React, { useCallback, useContext, useEffect, useState } from 'react'\nimport { StyleSheet, TextInput, View, ViewProps } from 'react-native'\nimport { IconButton, Text } from '../../components'\nimport { useTheme } from '../../hooks'\nimport { ConversationResource } from '../../types'\nimport { useMessageCreate } from '../../hooks/use_message_create'\nimport { ConversationScreenProps } from '../../screens/conversation_screen'\nimport { ChatContext } from '../../contexts/chat_context'\nimport { ImagePicker, ImagePickerResult } from '../../utils/native_adapters'\nimport { useAttachmentUploader } from '../../hooks/use_attachment_uploader'\nimport {\n DenormalizedAttachmentResourceForCreate,\n DenormalizedMessageAttachmentResourceForCreate,\n} from '../../types/resources/denormalized_attachment_resource'\nimport { MessageFormAttachmentImage } from './message_form/message_form_attachment_image'\n\nexport const MessageForm = {\n Root: MessageFormRoot,\n TextInput: MessageFormInput,\n SubmitButton: MessageFormSubmitBtn,\n AttachmentPicker: MessageFormAttachmentPicker,\n Commands: MessageFormCommands,\n}\n\ninterface MessagesFormRootProps extends ViewProps {\n conversation: ConversationResource\n}\n\nconst MessageFormContext = React.createContext<{\n text: string\n setText: (text: string) => void\n onSubmit: () => void\n disabled: boolean\n canGiphy: boolean\n usingGiphy: boolean\n setUsingGiphy: (usingGiphy: boolean) => void\n attachmentUploader?: ReturnType<typeof useAttachmentUploader>\n}>({\n text: '',\n setText: (_text: string) => {},\n onSubmit: () => {},\n disabled: false,\n canGiphy: false,\n usingGiphy: false,\n setUsingGiphy: (_usingGiphy: boolean) => {},\n})\n\nfunction MessageFormRoot({ conversation, children }: MessagesFormRootProps) {\n const { giphyApiKey } = useContext(ChatContext)\n const canGiphy = !!giphyApiKey\n const styles = useMessageFormStyles()\n const [text, setText] = React.useState('')\n const [usingGiphy, setUsingGiphy] = useState(false)\n const navigation = useNavigation()\n const route = useRoute() as ConversationScreenProps['route']\n const {\n status,\n isPending,\n reset: resetMutation,\n mutate,\n } = useMessageCreate({\n conversationId: conversation.id,\n })\n const attachmentUploader = useAttachmentUploader({\n conversationId: conversation.id,\n })\n const resetAttachmentUploader = attachmentUploader.reset\n\n const reset = useCallback(() => {\n resetAttachmentUploader()\n resetMutation()\n setText('')\n setUsingGiphy(false)\n }, [resetAttachmentUploader, resetMutation])\n\n useEffect(() => {\n if (canGiphy && !usingGiphy && text.startsWith('/giphy ')) {\n setUsingGiphy(true)\n setText('')\n }\n }, [canGiphy, text, usingGiphy])\n\n useEffect(() => {\n switch (status) {\n case 'success':\n reset()\n break\n }\n }, [reset, status])\n\n useEffect(() => {\n if (route.params.clear_input) {\n reset()\n navigation.setParams({ ...route.params, clear_input: false })\n }\n }, [reset, navigation, route.params])\n\n const canSubmit = (() => {\n if (isPending) return false\n if (attachmentUploader?.pendingUploads) return false\n if (text.length > 0) return true\n if (attachmentUploader?.attachments?.length) return true\n return false\n })()\n const disabled = !canSubmit\n\n const handleSubmit = () => {\n if (!canSubmit) return\n\n if (canGiphy && usingGiphy) {\n TextInput.State.blurTextInput(TextInput.State.currentlyFocusedInput())\n navigation.navigate('SendGiphy', {\n conversation_id: conversation.id,\n search_term: text,\n })\n } else {\n let attachmentsForSubmit: DenormalizedAttachmentResourceForCreate[] = []\n if (attachmentUploader?.attachmentIds) {\n attachmentsForSubmit = attachmentUploader.attachmentIds.map(\n (id: string): DenormalizedMessageAttachmentResourceForCreate => ({\n type: 'MessageAttachment',\n id,\n })\n )\n }\n mutate({ text, attachments: attachmentsForSubmit })\n }\n }\n\n return (\n <MessageFormContext.Provider\n value={{\n text,\n setText,\n onSubmit: handleSubmit,\n disabled,\n canGiphy,\n usingGiphy,\n setUsingGiphy,\n attachmentUploader,\n }}\n >\n <View style={styles.textInputContainer}>{children}</View>\n </MessageFormContext.Provider>\n )\n}\n\nfunction MessageFormAttachments() {\n const styles = useMessageFormStyles()\n const { attachmentUploader } = React.useContext(MessageFormContext)\n const numberOfAttachments = attachmentUploader?.attachments?.length || 0\n const attachments = attachmentUploader?.attachments || []\n\n if (numberOfAttachments === 0) {\n return null\n }\n\n return (\n <View style={styles.messageFormAttachments}>\n {attachments.map(attachment => {\n return (\n <MessageFormAttachmentImage\n key={attachment.file.uri}\n uri={attachment.file.uri}\n alt={attachment.file.name}\n status={attachment.status}\n width={attachment.file.width}\n height={attachment.file.height}\n removeAttachment={() => {\n attachmentUploader?.removeAttachment(attachment)\n }}\n />\n )\n })}\n </View>\n )\n}\n\nfunction MessageFormInput() {\n const styles = useMessageFormStyles()\n const { text, setText, onSubmit, usingGiphy, attachmentUploader } =\n React.useContext(MessageFormContext)\n const attachmentError = attachmentUploader?.errorMessage\n\n return (\n <View style={styles.textInputBoundary}>\n <MessageFormAttachments />\n <View style={styles.textInput}>\n {usingGiphy ? (\n <View style={styles.giphyBadge}>\n <Text>/Giphy</Text>\n </View>\n ) : null}\n\n <TextInput\n aria-disabled={true}\n placeholder=\"Send a message\"\n onChangeText={setText}\n value={text}\n onSubmitEditing={onSubmit}\n />\n </View>\n\n {attachmentError ? <Text style={styles.inputErrorMessage}>{attachmentError}</Text> : null}\n </View>\n )\n}\n\nfunction MessageFormSubmitBtn() {\n const styles = useMessageFormStyles()\n const { onSubmit, disabled, usingGiphy } = React.useContext(MessageFormContext)\n\n return (\n <IconButton\n disabled={disabled}\n accessibilityLabel={usingGiphy ? 'Search Giphy' : 'Send message'}\n size=\"md\"\n appearance=\"neutral\"\n style={styles.textInputSend}\n name={usingGiphy ? 'general.search' : 'general.upArrow'}\n onPress={onSubmit}\n />\n )\n}\n\nfunction MessageFormAttachmentPicker() {\n const styles = useMessageFormStyles()\n const { usingGiphy, attachmentUploader } = React.useContext(MessageFormContext)\n const [isOpen, setIsOpen] = useState(false)\n\n function uploadImagePickerResult(result: ImagePickerResult) {\n if (result.canceled) {\n return\n }\n\n const filteredAssets = result.assets\n .filter(asset => {\n return asset.fileSize && asset.fileName && asset.mimeType\n })\n .map(asset => {\n return {\n uri: asset.uri,\n name: asset.fileName as string,\n type: asset.mimeType as string,\n size: asset.fileSize as number,\n height: asset.height,\n width: asset.width,\n }\n })\n\n attachmentUploader?.handleFilesAttached(filteredAssets)\n }\n\n const openCamera = async () => {\n setIsOpen(false)\n let result = await ImagePicker.openCameraAsync()\n if (!result.canceled) {\n uploadImagePickerResult(result)\n }\n }\n\n const pickImage = async () => {\n setIsOpen(false)\n let result = await ImagePicker.openImageLibraryAsync()\n if (!result.canceled) {\n uploadImagePickerResult(result)\n }\n }\n\n if (usingGiphy) {\n return null\n }\n\n return (\n // TODO: Design Pass\n <View style={styles.attachmentPicker}>\n {isOpen && (\n <View style={styles.attachmentPickerButtons}>\n <IconButton\n accessibilityLabel=\"Take a photo\"\n size=\"md\"\n appearance=\"neutral\"\n name={'general.videoCamera'}\n onPress={openCamera}\n />\n <IconButton\n accessibilityLabel=\"Choose a photo\"\n size=\"md\"\n appearance=\"neutral\"\n name={'churchCenter.photosIos'}\n onPress={pickImage}\n />\n </View>\n )}\n <IconButton\n accessibilityLabel=\"File Menu\"\n size=\"md\"\n appearance=\"neutral\"\n name={'general.outlinedPlusCircle'}\n onPress={() => setIsOpen(!isOpen)}\n />\n </View>\n )\n}\n\nfunction MessageFormCommands() {\n const { canGiphy, usingGiphy, setUsingGiphy } = React.useContext(MessageFormContext)\n\n if (!canGiphy) {\n return null\n }\n\n if (usingGiphy) {\n return (\n <IconButton\n accessibilityLabel=\"Exit Giphy Search\"\n size=\"md\"\n appearance=\"neutral\"\n name={'general.x'}\n onPress={() => setUsingGiphy(false)}\n />\n )\n }\n\n return (\n <IconButton\n accessibilityLabel=\"Search Giphy\"\n size=\"md\"\n appearance=\"neutral\"\n name={'general.bolt'}\n onPress={() => setUsingGiphy(true)}\n />\n )\n}\n\nconst useMessageFormStyles = () => {\n const theme = useTheme()\n const navigationTheme = useNavigationTheme()\n\n return StyleSheet.create({\n textInputContainer: {\n borderColor: theme.colors.fillColorNeutral050Base,\n borderTopWidth: 1,\n padding: 12,\n backgroundColor: navigationTheme.colors.card,\n flexDirection: 'row',\n alignItems: 'center',\n gap: 12,\n },\n textInputBoundary: {\n borderRadius: 24,\n borderWidth: 1,\n padding: 12,\n paddingHorizontal: 20,\n borderColor: theme.colors.fillColorNeutral050Base,\n flex: 1,\n gap: 12,\n },\n textInput: {\n flexDirection: 'row',\n gap: 12,\n },\n giphyBadge: {\n backgroundColor: theme.colors.fillColorNeutral050Base,\n borderRadius: 24,\n padding: 8,\n paddingHorizontal: 12,\n },\n textInputSend: {\n borderRadius: 24,\n height: 36,\n width: 36,\n },\n attachmentPicker: {\n position: 'relative',\n },\n attachmentPickerButtons: {\n position: 'absolute',\n left: 0,\n bottom: 40,\n zIndex: 10,\n gap: 16,\n },\n messageFormAttachments: {\n flexDirection: 'row',\n gap: 8,\n },\n inputErrorMessage: {\n color: theme.colors.statusErrorText,\n fontSize: 14,\n },\n })\n}\n"]}
1
+ {"version":3,"file":"message_form.js","sourceRoot":"","sources":["../../../src/components/conversation/message_form.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,QAAQ,IAAI,kBAAkB,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAA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,YAAY,EAAE;YACZ,aAAa,EAAE,KAAK;YACpB,UAAU,EAAE,QAAQ;YACpB,GAAG,EAAE,EAAE;SACR;QACD,SAAS,EAAE;YACT,IAAI,EAAE,CAAC;SACR;QACD,UAAU,EAAE;YACV,eAAe,EAAE,KAAK,CAAC,MAAM,CAAC,uBAAuB;YACrD,YAAY,EAAE,EAAE;YAChB,OAAO,EAAE,CAAC;YACV,iBAAiB,EAAE,EAAE;SACtB;QACD,aAAa,EAAE;YACb,YAAY,EAAE,EAAE;YAChB,MAAM,EAAE,EAAE;YACV,KAAK,EAAE,EAAE;SACV;QACD,gBAAgB,EAAE;YAChB,QAAQ,EAAE,UAAU;SACrB;QACD,uBAAuB,EAAE;YACvB,QAAQ,EAAE,UAAU;YACpB,IAAI,EAAE,CAAC;YACP,MAAM,EAAE,EAAE;YACV,MAAM,EAAE,EAAE;YACV,GAAG,EAAE,EAAE;SACR;QACD,sBAAsB,EAAE;YACtB,aAAa,EAAE,KAAK;YACpB,GAAG,EAAE,CAAC;SACP;QACD,iBAAiB,EAAE;YACjB,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,eAAe;YACnC,QAAQ,EAAE,EAAE;SACb;KACF,CAAC,CAAA;AACJ,CAAC,CAAA","sourcesContent":["import { useNavigation, useTheme as useNavigationTheme, useRoute } from '@react-navigation/native'\nimport React, { useCallback, useContext, useEffect, useState } from 'react'\nimport { StyleSheet, TextInput, View, ViewProps } from 'react-native'\nimport { IconButton, Text } from '../../components'\nimport { useTheme } from '../../hooks'\nimport { ConversationResource } from '../../types'\nimport { useMessageCreate } from '../../hooks/use_message_create'\nimport { ConversationScreenProps } from '../../screens/conversation_screen'\nimport { ChatContext } from '../../contexts/chat_context'\nimport { ImagePicker, ImagePickerResult } from '../../utils/native_adapters'\nimport { useAttachmentUploader } from '../../hooks/use_attachment_uploader'\nimport {\n DenormalizedAttachmentResourceForCreate,\n DenormalizedMessageAttachmentResourceForCreate,\n} from '../../types/resources/denormalized_attachment_resource'\nimport { MessageFormAttachmentImage } from './message_form/message_form_attachment_image'\n\nexport const MessageForm = {\n Root: MessageFormRoot,\n TextInput: MessageFormInput,\n SubmitButton: MessageFormSubmitBtn,\n AttachmentPicker: MessageFormAttachmentPicker,\n Commands: MessageFormCommands,\n}\n\ninterface MessagesFormRootProps extends ViewProps {\n conversation: ConversationResource\n}\n\nconst MessageFormContext = React.createContext<{\n text: string\n setText: (text: string) => void\n onSubmit: () => void\n disabled: boolean\n canGiphy: boolean\n usingGiphy: boolean\n setUsingGiphy: (usingGiphy: boolean) => void\n attachmentUploader?: ReturnType<typeof useAttachmentUploader>\n}>({\n text: '',\n setText: (_text: string) => {},\n onSubmit: () => {},\n disabled: false,\n canGiphy: false,\n usingGiphy: false,\n setUsingGiphy: (_usingGiphy: boolean) => {},\n})\n\nconst GIPHY_MAX_LENGTH = 50\nconst MAX_MESSAGE_LENGTH = 5000\n\nfunction MessageFormRoot({ conversation, children }: MessagesFormRootProps) {\n const { giphyApiKey } = useContext(ChatContext)\n const canGiphy = !!giphyApiKey\n const styles = useMessageFormStyles()\n const [text, setText] = React.useState('')\n const [usingGiphy, setUsingGiphy] = useState(false)\n const navigation = useNavigation()\n const route = useRoute() as ConversationScreenProps['route']\n const {\n status,\n isPending,\n reset: resetMutation,\n mutate,\n } = useMessageCreate({\n conversationId: conversation.id,\n })\n const attachmentUploader = useAttachmentUploader({\n conversationId: conversation.id,\n })\n const resetAttachmentUploader = attachmentUploader.reset\n\n const reset = useCallback(() => {\n resetAttachmentUploader()\n resetMutation()\n setText('')\n setUsingGiphy(false)\n }, [resetAttachmentUploader, resetMutation])\n\n useEffect(() => {\n if (canGiphy && !usingGiphy && text.startsWith('/giphy ')) {\n setUsingGiphy(true)\n setText('')\n }\n }, [canGiphy, text, usingGiphy])\n\n useEffect(() => {\n switch (status) {\n case 'success':\n reset()\n break\n }\n }, [reset, status])\n\n useEffect(() => {\n if (route.params.clear_input) {\n reset()\n navigation.setParams({ ...route.params, clear_input: false })\n }\n }, [reset, navigation, route.params])\n\n const canSubmit = (() => {\n if (isPending) return false\n if (attachmentUploader?.pendingUploads) return false\n if (text.length > 0) return true\n if (attachmentUploader?.attachments?.length) return true\n return false\n })()\n const disabled = !canSubmit\n\n const handleSubmit = () => {\n if (!canSubmit) return\n\n if (canGiphy && usingGiphy) {\n TextInput.State.blurTextInput(TextInput.State.currentlyFocusedInput())\n navigation.navigate('SendGiphy', {\n conversation_id: conversation.id,\n search_term: text,\n })\n } else {\n let attachmentsForSubmit: DenormalizedAttachmentResourceForCreate[] = []\n if (attachmentUploader?.attachmentIds) {\n attachmentsForSubmit = attachmentUploader.attachmentIds.map(\n (id: string): DenormalizedMessageAttachmentResourceForCreate => ({\n type: 'MessageAttachment',\n id,\n })\n )\n }\n mutate({ text, attachments: attachmentsForSubmit })\n }\n }\n\n return (\n <MessageFormContext.Provider\n value={{\n text,\n setText,\n onSubmit: handleSubmit,\n disabled,\n canGiphy,\n usingGiphy,\n setUsingGiphy,\n attachmentUploader,\n }}\n >\n <View style={styles.textInputContainer}>{children}</View>\n </MessageFormContext.Provider>\n )\n}\n\nfunction MessageFormAttachments() {\n const styles = useMessageFormStyles()\n const { attachmentUploader } = React.useContext(MessageFormContext)\n const numberOfAttachments = attachmentUploader?.attachments?.length || 0\n const attachments = attachmentUploader?.attachments || []\n\n if (numberOfAttachments === 0) {\n return null\n }\n\n return (\n <View style={styles.messageFormAttachments}>\n {attachments.map(attachment => {\n return (\n <MessageFormAttachmentImage\n key={attachment.file.uri}\n uri={attachment.file.uri}\n alt={attachment.file.name}\n status={attachment.status}\n width={attachment.file.width}\n height={attachment.file.height}\n removeAttachment={() => {\n attachmentUploader?.removeAttachment(attachment)\n }}\n />\n )\n })}\n </View>\n )\n}\n\nfunction MessageFormInput() {\n const styles = useMessageFormStyles()\n const { text, setText, onSubmit, usingGiphy, attachmentUploader } =\n React.useContext(MessageFormContext)\n const attachmentError = attachmentUploader?.errorMessage\n\n return (\n <View style={styles.textInputBoundary}>\n <MessageFormAttachments />\n <View style={styles.textInputRow}>\n {usingGiphy ? (\n <View style={styles.giphyBadge}>\n <Text>/Giphy</Text>\n </View>\n ) : null}\n\n <View style={styles.textInput}>\n <TextInput\n multiline={true}\n aria-disabled={true}\n placeholder=\"Send a message\"\n onChangeText={setText}\n value={text}\n maxLength={usingGiphy ? GIPHY_MAX_LENGTH : MAX_MESSAGE_LENGTH}\n onSubmitEditing={onSubmit}\n />\n </View>\n </View>\n\n {attachmentError ? <Text style={styles.inputErrorMessage}>{attachmentError}</Text> : null}\n </View>\n )\n}\n\nfunction MessageFormSubmitBtn() {\n const styles = useMessageFormStyles()\n const { onSubmit, disabled, usingGiphy } = React.useContext(MessageFormContext)\n\n return (\n <IconButton\n disabled={disabled}\n accessibilityLabel={usingGiphy ? 'Search Giphy' : 'Send message'}\n size=\"md\"\n appearance=\"neutral\"\n style={styles.textInputSend}\n name={usingGiphy ? 'general.search' : 'general.upArrow'}\n onPress={onSubmit}\n />\n )\n}\n\nfunction MessageFormAttachmentPicker() {\n const styles = useMessageFormStyles()\n const { usingGiphy, attachmentUploader } = React.useContext(MessageFormContext)\n const [isOpen, setIsOpen] = useState(false)\n\n function uploadImagePickerResult(result: ImagePickerResult) {\n if (result.canceled) {\n return\n }\n\n const filteredAssets = result.assets\n .filter(asset => {\n return asset.fileSize && asset.fileName && asset.mimeType\n })\n .map(asset => {\n return {\n uri: asset.uri,\n name: asset.fileName as string,\n type: asset.mimeType as string,\n size: asset.fileSize as number,\n height: asset.height,\n width: asset.width,\n }\n })\n\n attachmentUploader?.handleFilesAttached(filteredAssets)\n }\n\n const openCamera = async () => {\n setIsOpen(false)\n let result = await ImagePicker.openCameraAsync()\n if (!result.canceled) {\n uploadImagePickerResult(result)\n }\n }\n\n const pickImage = async () => {\n setIsOpen(false)\n let result = await ImagePicker.openImageLibraryAsync()\n if (!result.canceled) {\n uploadImagePickerResult(result)\n }\n }\n\n if (usingGiphy) {\n return null\n }\n\n return (\n // TODO: Design Pass\n <View style={styles.attachmentPicker}>\n {isOpen && (\n <View style={styles.attachmentPickerButtons}>\n <IconButton\n accessibilityLabel=\"Take a photo\"\n size=\"md\"\n appearance=\"neutral\"\n name={'general.videoCamera'}\n onPress={openCamera}\n />\n <IconButton\n accessibilityLabel=\"Choose a photo\"\n size=\"md\"\n appearance=\"neutral\"\n name={'churchCenter.photosIos'}\n onPress={pickImage}\n />\n </View>\n )}\n <IconButton\n accessibilityLabel=\"File Menu\"\n size=\"md\"\n appearance=\"neutral\"\n name={'general.outlinedPlusCircle'}\n onPress={() => setIsOpen(!isOpen)}\n />\n </View>\n )\n}\n\nfunction MessageFormCommands() {\n const { text, canGiphy, usingGiphy, setUsingGiphy } = React.useContext(MessageFormContext)\n\n if (!canGiphy) {\n return null\n }\n\n if (usingGiphy) {\n return (\n <IconButton\n accessibilityLabel=\"Exit Giphy Search\"\n size=\"md\"\n appearance=\"neutral\"\n name={'general.x'}\n onPress={() => setUsingGiphy(false)}\n />\n )\n }\n\n return (\n <IconButton\n accessibilityLabel=\"Search Giphy\"\n size=\"md\"\n appearance=\"neutral\"\n name={'general.bolt'}\n onPress={() => setUsingGiphy(true)}\n disabled={text.length > GIPHY_MAX_LENGTH}\n />\n )\n}\n\nconst useMessageFormStyles = () => {\n const theme = useTheme()\n const navigationTheme = useNavigationTheme()\n\n return StyleSheet.create({\n textInputContainer: {\n borderColor: theme.colors.fillColorNeutral050Base,\n borderTopWidth: 1,\n padding: 12,\n backgroundColor: navigationTheme.colors.card,\n flexDirection: 'row',\n alignItems: 'center',\n gap: 12,\n },\n textInputBoundary: {\n borderRadius: 24,\n borderWidth: 1,\n padding: 12,\n paddingHorizontal: 20,\n borderColor: theme.colors.fillColorNeutral050Base,\n flex: 1,\n gap: 12,\n },\n textInputRow: {\n flexDirection: 'row',\n alignItems: 'center',\n gap: 12,\n },\n textInput: {\n flex: 1,\n },\n giphyBadge: {\n backgroundColor: theme.colors.fillColorNeutral050Base,\n borderRadius: 24,\n padding: 8,\n paddingHorizontal: 12,\n },\n textInputSend: {\n borderRadius: 24,\n height: 36,\n width: 36,\n },\n attachmentPicker: {\n position: 'relative',\n },\n attachmentPickerButtons: {\n position: 'absolute',\n left: 0,\n bottom: 40,\n zIndex: 10,\n gap: 16,\n },\n messageFormAttachments: {\n flexDirection: 'row',\n gap: 8,\n },\n inputErrorMessage: {\n color: theme.colors.statusErrorText,\n fontSize: 14,\n },\n })\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@planningcenter/chat-react-native",
3
- "version": "3.4.1-rc.0",
3
+ "version": "3.4.1-rc.2",
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": "e70b0efaccfa2ff290bc072deb9bb928b98ae49a"
57
+ "gitHead": "a9ddceace400b15a185d59d7466cef5b81582002"
58
58
  }
@@ -1,24 +1,181 @@
1
- import React from 'react'
2
- import { View, Image, StyleSheet } from 'react-native'
1
+ import React, { useCallback, useMemo, useState } from 'react'
2
+ import {
3
+ Image,
4
+ StyleSheet,
5
+ Modal,
6
+ Pressable,
7
+ useWindowDimensions,
8
+ SafeAreaView,
9
+ View,
10
+ Linking,
11
+ ImageStyle,
12
+ } from 'react-native'
13
+ import {
14
+ Gesture,
15
+ GestureDetector,
16
+ GestureHandlerRootView,
17
+ type PanGesture,
18
+ } from 'react-native-gesture-handler'
19
+ import Animated, {
20
+ runOnJS,
21
+ useAnimatedStyle,
22
+ useSharedValue,
23
+ withTiming,
24
+ type AnimatedStyle,
25
+ } from 'react-native-reanimated'
26
+ import { tokens } from '../../../vendor/tapestry/tokens'
27
+ import { IconButton, Heading, Text } from '../../display'
28
+ import colorFunction from 'color'
29
+ import { formatDatePreview } from '../../../utils/date'
3
30
 
4
- export function ImageAttachment({ attachment }: { attachment: any }) {
31
+ const PAN_THRESHOLD_PX = 300
32
+
33
+ export type MetaProps = {
34
+ authorName: string
35
+ createdAt: string
36
+ }
37
+
38
+ export function ImageAttachment({
39
+ attachment,
40
+ metaProps,
41
+ }: {
42
+ attachment: any
43
+ metaProps: MetaProps
44
+ }) {
5
45
  const styles = useStyles()
46
+ const [visible, setVisible] = useState(false)
47
+
48
+ // shared values run on the native UI thread and prevents clogging up the JS thread
49
+ const dismissY = useSharedValue(0)
50
+ const opacity = useSharedValue(1)
51
+
52
+ const resetAnimations = useCallback(() => {
53
+ dismissY.value = withTiming(0)
54
+ opacity.value = withTiming(1)
55
+ }, [dismissY, opacity])
56
+
57
+ const handleCloseModal = useCallback(() => {
58
+ setVisible(false)
59
+ resetAnimations()
60
+ }, [setVisible, resetAnimations])
61
+
62
+ const panGesture = Gesture.Pan()
63
+ .onUpdate(e => {
64
+ dismissY.value = e.translationY
65
+ opacity.value = 1 - Math.abs(e.translationY) / PAN_THRESHOLD_PX
66
+ })
67
+ .onEnd(() => {
68
+ runOnJS(handleCloseModal)() // Ensures we can call a JS function
69
+ })
70
+
71
+ const animatedImageStyle = useAnimatedStyle(() => ({
72
+ transform: [{ translateY: dismissY.value }],
73
+ opacity: opacity.value,
74
+ }))
75
+
6
76
  const { attributes } = attachment
7
77
  const { url, urlMedium, filename, metadata = {} } = attributes
8
78
  const width = metadata.width || 100
9
79
  const height = metadata.height || 100
80
+
10
81
  return (
11
- <View style={styles.container}>
12
- <Image
13
- source={{ uri: urlMedium || url }}
14
- style={[styles.image, { aspectRatio: width / height }]}
15
- accessibilityLabel={filename}
82
+ <>
83
+ <Pressable style={styles.container} onPress={() => setVisible(true)}>
84
+ <Image
85
+ source={{ uri: urlMedium || url }}
86
+ style={[styles.image, { aspectRatio: width / height }]}
87
+ accessibilityLabel={filename}
88
+ />
89
+ </Pressable>
90
+ <LightboxModal
91
+ visible={visible}
92
+ handleCloseModal={handleCloseModal}
93
+ uri={urlMedium || url}
94
+ metaProps={metaProps}
95
+ panGesture={panGesture}
96
+ animatedImageStyle={animatedImageStyle}
16
97
  />
17
- </View>
98
+ </>
99
+ )
100
+ }
101
+
102
+ interface LightboxModalProps {
103
+ visible: boolean
104
+ handleCloseModal: () => void
105
+ uri: string
106
+ metaProps: MetaProps
107
+ panGesture: PanGesture
108
+ animatedImageStyle: AnimatedStyle<ImageStyle>
109
+ }
110
+
111
+ const LightboxModal = ({
112
+ uri,
113
+ visible,
114
+ handleCloseModal,
115
+ metaProps,
116
+ panGesture,
117
+ animatedImageStyle,
118
+ }: LightboxModalProps) => {
119
+ const styles = useStyles()
120
+
121
+ const { authorName, createdAt } = metaProps
122
+
123
+ const handleOpenInBrowser = () => {
124
+ Linking.openURL(uri)
125
+ }
126
+
127
+ return (
128
+ <Modal visible={visible} transparent animationType="fade" onRequestClose={handleCloseModal}>
129
+ <SafeAreaView style={styles.modal}>
130
+ <GestureHandlerRootView>
131
+ <GestureDetector gesture={panGesture}>
132
+ <Animated.Image
133
+ source={{ uri }}
134
+ style={[styles.lightboxImage, animatedImageStyle]}
135
+ resizeMode="contain"
136
+ />
137
+ </GestureDetector>
138
+ <View style={styles.actionToolbar} accessibilityRole="toolbar">
139
+ <View style={styles.actionToolbarTextMeta}>
140
+ <Heading variant="h3" style={styles.actionToolbarTitle} numberOfLines={1}>
141
+ {authorName}
142
+ </Heading>
143
+ <Text variant="tertiary" style={styles.actionToolbarSubtitle}>
144
+ {formatDatePreview(createdAt)}
145
+ </Text>
146
+ </View>
147
+ <IconButton
148
+ onPress={handleOpenInBrowser}
149
+ name="general.newWindow"
150
+ accessibilityRole="link"
151
+ accessibilityLabel="Open image in browser"
152
+ accessibilityHint="Image can be downloaded and shared through the browser."
153
+ style={styles.actionButton}
154
+ iconStyle={styles.actionButtonIcon}
155
+ size="lg"
156
+ />
157
+ <IconButton
158
+ onPress={handleCloseModal}
159
+ name="general.x"
160
+ accessibilityLabel="Close image"
161
+ style={styles.actionButton}
162
+ iconStyle={styles.actionButtonIcon}
163
+ />
164
+ </View>
165
+ </GestureHandlerRootView>
166
+ </SafeAreaView>
167
+ </Modal>
18
168
  )
19
169
  }
20
170
 
21
171
  const useStyles = () => {
172
+ const { width: windowWidth } = useWindowDimensions()
173
+ const backgroundColor = tokens.colorNeutral7
174
+ const transparentBackgroundColor = useMemo(
175
+ () => colorFunction(backgroundColor).alpha(0.8).toString(),
176
+ [backgroundColor]
177
+ )
178
+
22
179
  return StyleSheet.create({
23
180
  container: {
24
181
  maxWidth: '100%',
@@ -27,5 +184,49 @@ const useStyles = () => {
27
184
  borderRadius: 8,
28
185
  minWidth: 200,
29
186
  },
187
+ modal: {
188
+ flex: 1,
189
+ backgroundColor,
190
+ justifyContent: 'center',
191
+ alignItems: 'center',
192
+ },
193
+ lightboxImage: {
194
+ width: windowWidth,
195
+ height: '100%',
196
+ },
197
+ actionToolbar: {
198
+ width: '100%',
199
+ position: 'absolute',
200
+ top: 0,
201
+ flexDirection: 'row',
202
+ alignItems: 'center',
203
+ gap: 20,
204
+ paddingHorizontal: 16,
205
+ paddingTop: 16,
206
+ paddingBottom: 8,
207
+ backgroundColor: transparentBackgroundColor,
208
+ },
209
+ actionToolbarTextMeta: {
210
+ flex: 1,
211
+ },
212
+ actionToolbarTitle: {
213
+ marginRight: 'auto',
214
+ flexShrink: 1,
215
+ color: tokens.colorNeutral88,
216
+ },
217
+ actionToolbarSubtitle: {
218
+ color: tokens.colorNeutral68,
219
+ },
220
+ actionButton: {
221
+ backgroundColor,
222
+ height: 40,
223
+ width: 40,
224
+ borderRadius: 50,
225
+ borderWidth: 1,
226
+ borderColor: tokens.colorNeutral24,
227
+ },
228
+ actionButtonIcon: {
229
+ color: tokens.colorNeutral88,
230
+ },
30
231
  })
31
232
  }
@@ -33,6 +33,11 @@ export function Message(props: MessageResource & { conversation_id: number }) {
33
33
  })
34
34
  }
35
35
 
36
+ const metaProps = {
37
+ authorName: props.author.name,
38
+ createdAt: props.createdAt,
39
+ }
40
+
36
41
  return (
37
42
  <View style={styles.message}>
38
43
  {!props.mine && (
@@ -44,7 +49,7 @@ export function Message(props: MessageResource & { conversation_id: number }) {
44
49
  {!props.mine && <Text variant="tertiary">{props.author.name}</Text>}
45
50
  <PlatformPressable style={styles.messageBubble} onLongPress={handleMessagePress}>
46
51
  <ErrorBoundary>
47
- <MessageAttachments attachments={props.attachments} />
52
+ <MessageAttachments attachments={props.attachments} metaProps={metaProps} />
48
53
  </ErrorBoundary>
49
54
  {text && (
50
55
  <View style={styles.messageText}>
@@ -6,18 +6,27 @@ import { VideoAttachment } from './attachments/video_attachment'
6
6
  import { GiphyAttachment } from './attachments/giphy_attachment'
7
7
  import { GenericFileAttachment } from './attachments/generic_file_attachment'
8
8
  import { ExpandedLink } from './attachments/expanded_link'
9
- import { ImageAttachment } from './attachments/image_attachment'
9
+ import { ImageAttachment, type MetaProps } from './attachments/image_attachment'
10
10
 
11
- export function MessageAttachments(props: { attachments: DenormalizedAttachmentResource[] }) {
11
+ export function MessageAttachments(props: {
12
+ attachments: DenormalizedAttachmentResource[]
13
+ metaProps: MetaProps
14
+ }) {
12
15
  const styles = useStyles()
13
- const { attachments } = props
16
+ const { attachments, metaProps } = props
14
17
  if (!attachments || attachments.length === 0) return null
15
18
  return (
16
19
  <View style={styles.attachmentsContainer}>
17
20
  {attachments.map(attachment => {
18
21
  switch (attachment.type) {
19
22
  case 'MessageAttachment':
20
- return <MessageAttachment key={attachment.id} attachment={attachment} />
23
+ return (
24
+ <MessageAttachment
25
+ key={attachment.id}
26
+ attachment={attachment}
27
+ metaProps={metaProps}
28
+ />
29
+ )
21
30
  case 'giphy':
22
31
  return (
23
32
  <GiphyAttachment
@@ -35,13 +44,13 @@ export function MessageAttachments(props: { attachments: DenormalizedAttachmentR
35
44
  )
36
45
  }
37
46
 
38
- function MessageAttachment({ attachment }: { attachment: any }) {
47
+ function MessageAttachment({ attachment, metaProps }: { attachment: any; metaProps: MetaProps }) {
39
48
  const { attributes } = attachment
40
49
  const contentType = attributes?.contentType
41
50
  const basicType = contentType ? contentType.split('/')[0] : ''
42
51
  switch (basicType) {
43
52
  case 'image':
44
- return <ImageAttachment attachment={attachment} />
53
+ return <ImageAttachment attachment={attachment} metaProps={metaProps} />
45
54
  case 'video':
46
55
  return <VideoAttachment attachment={attachment} />
47
56
  case 'audio':
@@ -46,6 +46,9 @@ const MessageFormContext = React.createContext<{
46
46
  setUsingGiphy: (_usingGiphy: boolean) => {},
47
47
  })
48
48
 
49
+ const GIPHY_MAX_LENGTH = 50
50
+ const MAX_MESSAGE_LENGTH = 5000
51
+
49
52
  function MessageFormRoot({ conversation, children }: MessagesFormRootProps) {
50
53
  const { giphyApiKey } = useContext(ChatContext)
51
54
  const canGiphy = !!giphyApiKey
@@ -186,20 +189,24 @@ function MessageFormInput() {
186
189
  return (
187
190
  <View style={styles.textInputBoundary}>
188
191
  <MessageFormAttachments />
189
- <View style={styles.textInput}>
192
+ <View style={styles.textInputRow}>
190
193
  {usingGiphy ? (
191
194
  <View style={styles.giphyBadge}>
192
195
  <Text>/Giphy</Text>
193
196
  </View>
194
197
  ) : null}
195
198
 
196
- <TextInput
197
- aria-disabled={true}
198
- placeholder="Send a message"
199
- onChangeText={setText}
200
- value={text}
201
- onSubmitEditing={onSubmit}
202
- />
199
+ <View style={styles.textInput}>
200
+ <TextInput
201
+ multiline={true}
202
+ aria-disabled={true}
203
+ placeholder="Send a message"
204
+ onChangeText={setText}
205
+ value={text}
206
+ maxLength={usingGiphy ? GIPHY_MAX_LENGTH : MAX_MESSAGE_LENGTH}
207
+ onSubmitEditing={onSubmit}
208
+ />
209
+ </View>
203
210
  </View>
204
211
 
205
212
  {attachmentError ? <Text style={styles.inputErrorMessage}>{attachmentError}</Text> : null}
@@ -305,7 +312,7 @@ function MessageFormAttachmentPicker() {
305
312
  }
306
313
 
307
314
  function MessageFormCommands() {
308
- const { canGiphy, usingGiphy, setUsingGiphy } = React.useContext(MessageFormContext)
315
+ const { text, canGiphy, usingGiphy, setUsingGiphy } = React.useContext(MessageFormContext)
309
316
 
310
317
  if (!canGiphy) {
311
318
  return null
@@ -330,6 +337,7 @@ function MessageFormCommands() {
330
337
  appearance="neutral"
331
338
  name={'general.bolt'}
332
339
  onPress={() => setUsingGiphy(true)}
340
+ disabled={text.length > GIPHY_MAX_LENGTH}
333
341
  />
334
342
  )
335
343
  }
@@ -357,10 +365,14 @@ const useMessageFormStyles = () => {
357
365
  flex: 1,
358
366
  gap: 12,
359
367
  },
360
- textInput: {
368
+ textInputRow: {
361
369
  flexDirection: 'row',
370
+ alignItems: 'center',
362
371
  gap: 12,
363
372
  },
373
+ textInput: {
374
+ flex: 1,
375
+ },
364
376
  giphyBadge: {
365
377
  backgroundColor: theme.colors.fillColorNeutral050Base,
366
378
  borderRadius: 24,