@planningcenter/chat-react-native 1.6.2-rc.2 → 1.7.0-rc.0
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/message_reaction.d.ts +8 -0
- package/build/components/conversation/message_reaction.d.ts.map +1 -0
- package/build/components/conversation/message_reaction.js +44 -0
- package/build/components/conversation/message_reaction.js.map +1 -0
- package/build/components/display/badge.d.ts +58 -0
- package/build/components/display/badge.d.ts.map +1 -0
- package/build/components/display/badge.js +186 -0
- package/build/components/display/badge.js.map +1 -0
- package/build/components/display/button_color_utils.d.ts +1 -1
- package/build/components/display/index.d.ts +1 -0
- package/build/components/display/index.d.ts.map +1 -1
- package/build/components/display/index.js +1 -0
- package/build/components/display/index.js.map +1 -1
- package/build/hooks/use_conversation_messages.d.ts +45 -0
- package/build/hooks/use_conversation_messages.d.ts.map +1 -0
- package/build/hooks/use_conversation_messages.js +33 -0
- package/build/hooks/use_conversation_messages.js.map +1 -0
- package/build/hooks/use_suspense_api.d.ts +3 -2
- package/build/hooks/use_suspense_api.d.ts.map +1 -1
- package/build/hooks/use_suspense_api.js +3 -2
- package/build/hooks/use_suspense_api.js.map +1 -1
- package/build/navigation/index.d.ts +5 -0
- package/build/navigation/index.d.ts.map +1 -1
- package/build/navigation/index.js +9 -3
- package/build/navigation/index.js.map +1 -1
- package/build/screens/conversation_screen.d.ts.map +1 -1
- package/build/screens/conversation_screen.js +91 -37
- package/build/screens/conversation_screen.js.map +1 -1
- package/build/screens/design_system_screen.d.ts.map +1 -1
- package/build/screens/design_system_screen.js +407 -338
- package/build/screens/design_system_screen.js.map +1 -1
- package/build/screens/message_actions_screen.d.ts +10 -0
- package/build/screens/message_actions_screen.d.ts.map +1 -0
- package/build/screens/message_actions_screen.js +128 -0
- package/build/screens/message_actions_screen.js.map +1 -0
- package/build/types/api_primitives.d.ts +1 -2
- package/build/types/api_primitives.d.ts.map +1 -1
- package/build/types/api_primitives.js.map +1 -1
- package/build/utils/cache/index.d.ts +2 -0
- package/build/utils/cache/index.d.ts.map +1 -0
- package/build/utils/cache/index.js +2 -0
- package/build/utils/cache/index.js.map +1 -0
- package/build/utils/cache/page_mutations.d.ts +37 -0
- package/build/utils/cache/page_mutations.d.ts.map +1 -0
- package/build/utils/cache/page_mutations.js +42 -0
- package/build/utils/cache/page_mutations.js.map +1 -0
- package/build/utils/index.d.ts +1 -0
- package/build/utils/index.d.ts.map +1 -1
- package/build/utils/index.js +1 -0
- package/build/utils/index.js.map +1 -1
- package/build/utils/theme.d.ts +16 -0
- package/build/utils/theme.d.ts.map +1 -1
- package/build/utils/theme.js +31 -0
- package/build/utils/theme.js.map +1 -1
- package/build/vendor/tapestry/tokens.d.ts +30 -0
- package/build/vendor/tapestry/tokens.d.ts.map +1 -1
- package/build/vendor/tapestry/tokens.js +30 -0
- package/build/vendor/tapestry/tokens.js.map +1 -1
- package/package.json +3 -2
- package/src/__tests__/utils/cache/page_mutations.ts +206 -0
- package/src/components/conversation/message_reaction.tsx +57 -0
- package/src/components/display/badge.tsx +323 -0
- package/src/components/display/index.ts +1 -0
- package/src/hooks/use_conversation_messages.ts +43 -0
- package/src/hooks/use_suspense_api.ts +16 -2
- package/src/navigation/index.tsx +9 -3
- package/src/screens/conversation_screen.tsx +111 -40
- package/src/screens/design_system_screen.tsx +712 -580
- package/src/screens/message_actions_screen.tsx +167 -0
- package/src/types/api_primitives.ts +1 -1
- package/src/utils/cache/index.ts +1 -0
- package/src/utils/cache/page_mutations.ts +66 -0
- package/src/utils/index.ts +1 -0
- package/src/utils/theme.ts +47 -0
- package/src/vendor/tapestry/tokens.ts +30 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/navigation/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,EAAE,0BAA0B,EAAE,MAAM,gCAAgC,CAAA;AAC3E,OAAO,EAAE,QAAQ,E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B;gBACD,WAAW,EAAE,GAAG,EAAE,CAAC,CACjB,CAAC,gBAAgB,CACf,OAAO,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,CAC3B,SAAS,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,EAAG,CAAC,EACrD,CACH;aACF,CAAC;SACH;QACD,YAAY,EAAE;YACZ,MAAM,EAAE,kBAAkB;SAC3B;QACD,cAAc,EAAE;YACd,MAAM,EAAE,oBAAoB;YAC5B,gEAAgE;YAChE,OAAO,EAAE,kBAAkB;SAC5B;QACD,QAAQ,EAAE;YACR,MAAM,EAAE,QAAQ;YAChB,OAAO,EAAE;gBACP,KAAK,EAAE,KAAK;aACb;YACD,OAAO,EAAE;gBACP,IAAI,EAAE,GAAG;aACV;SACF;KACF;CACF,CAAC,CAAA","sourcesContent":["import React from 'react'\nimport { StaticParamList } from '@react-navigation/native'\nimport { createNativeStackNavigator } from '@react-navigation/native-stack'\nimport { NotFound } from '../screens/not_found'\nimport { ScreenLayout } from './screenLayout'\nimport { ConversationsScreen } from '../screens/conversations_screen'\nimport { ConversationScreen } from '../screens/conversation_screen'\nimport { HeaderBackButton, HeaderButton } from '@react-navigation/elements'\nimport { Icon } from '../components'\nimport { MessageActionsScreen, ReactScreenOptions } from '../screens/message_actions_screen'\n\nexport const ChatStack = createNativeStackNavigator({\n screenLayout: ScreenLayout,\n screens: {\n Conversations: {\n screen: ConversationsScreen,\n options: ({ route, navigation }) => ({\n headerTitle: (route.params as { title?: string })?.title ?? 'Chat',\n headerLeft: () => (\n <HeaderButton>\n <Icon name=\"general.threeReducingHorizontalBars\" size={18} />\n </HeaderButton>\n ),\n headerRight: () => (\n <HeaderBackButton\n onPress={navigation.goBack}\n backImage={() => <Icon name=\"general.x\" size={18} />}\n />\n ),\n }),\n },\n Conversation: {\n screen: ConversationScreen,\n },\n MessageActions: {\n screen: MessageActionsScreen,\n // Something about sheetAllowedDetents declared inline breaks TS\n options: ReactScreenOptions,\n },\n NotFound: {\n screen: NotFound,\n options: {\n title: '404',\n },\n linking: {\n path: '*',\n },\n },\n },\n})\n\ntype ChatStackParamList = StaticParamList<typeof ChatStack>\n\ndeclare global {\n namespace ReactNavigation {\n interface RootParamList extends ChatStackParamList {}\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conversation_screen.d.ts","sourceRoot":"","sources":["../../src/screens/conversation_screen.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"conversation_screen.d.ts","sourceRoot":"","sources":["../../src/screens/conversation_screen.tsx"],"names":[],"mappings":"AACA,OAAO,EACL,iBAAiB,EAGlB,MAAM,0BAA0B,CAAA;AAEjC,OAAO,KAAoB,MAAM,OAAO,CAAA;AAUxC,MAAM,MAAM,uBAAuB,GAAG,iBAAiB,CAAC;IACtD,eAAe,EAAE,MAAM,CAAA;IACvB,mBAAmB,EAAE,MAAM,CAAA;CAC5B,CAAC,CAAA;AAEF,wBAAgB,kBAAkB,CAAC,EAAE,KAAK,EAAE,EAAE,uBAAuB,qBA6CpE"}
|
|
@@ -1,12 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PlatformPressable } from '@react-navigation/elements';
|
|
2
|
+
import { useNavigation, useTheme as useNavigationTheme, } from '@react-navigation/native';
|
|
3
|
+
import colorFunction from 'color';
|
|
2
4
|
import React, { useEffect } from 'react';
|
|
3
|
-
import { FlatList,
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
5
|
+
import { FlatList, StyleSheet, TextInput, View } from 'react-native';
|
|
6
|
+
import { SafeAreaView } from 'react-native-safe-area-context';
|
|
7
|
+
import { MessageReaction } from '../components/conversation/message_reaction';
|
|
8
|
+
import { Avatar, Text } from '../components/display';
|
|
6
9
|
import { useTheme } from '../hooks';
|
|
10
|
+
import { useConversationMessages } from '../hooks/use_conversation_messages';
|
|
11
|
+
import { useSuspenseGet } from '../hooks/use_suspense_api';
|
|
7
12
|
export function ConversationScreen({ route }) {
|
|
8
13
|
const navigation = useNavigation();
|
|
9
14
|
const { conversation_id } = route.params;
|
|
15
|
+
const styles = useStyles();
|
|
10
16
|
const { data: conversation } = useSuspenseGet({
|
|
11
17
|
url: `/me/conversations/${conversation_id}`,
|
|
12
18
|
data: {
|
|
@@ -15,55 +21,103 @@ export function ConversationScreen({ route }) {
|
|
|
15
21
|
},
|
|
16
22
|
},
|
|
17
23
|
});
|
|
18
|
-
const {
|
|
19
|
-
|
|
20
|
-
data: {
|
|
21
|
-
perPage: 25,
|
|
22
|
-
fields: {
|
|
23
|
-
Message: ['text', 'mine'],
|
|
24
|
-
},
|
|
25
|
-
},
|
|
24
|
+
const { messages, refetch, isRefetching, fetchNextPage } = useConversationMessages({
|
|
25
|
+
conversation_id,
|
|
26
26
|
});
|
|
27
27
|
useEffect(() => {
|
|
28
28
|
navigation.setOptions({ title: conversation?.title });
|
|
29
29
|
}, [conversation, conversation_id, navigation]);
|
|
30
|
-
return (<SafeAreaView style={styles.container}>
|
|
31
|
-
<FlatList inverted contentContainerStyle={styles.listContainer} refreshing={isRefetching} onRefresh={refetch} data={
|
|
30
|
+
return (<SafeAreaView style={styles.container} edges={['top', 'bottom', 'left', 'right']}>
|
|
31
|
+
<FlatList inverted contentContainerStyle={styles.listContainer} refreshing={isRefetching} onRefresh={refetch} data={messages} keyExtractor={item => item.id} renderItem={({ item }) => <Message {...item} conversation_id={conversation_id}/>} onEndReached={() => fetchNextPage()}/>
|
|
32
32
|
<View style={styles.textInputContainer}>
|
|
33
33
|
<TextInput aria-disabled={true} placeholder="Send a message" onChangeText={() => console.log('TODO: Implement sending a message')} value="" style={styles.textInput}/>
|
|
34
34
|
</View>
|
|
35
35
|
</SafeAreaView>);
|
|
36
36
|
}
|
|
37
|
-
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
37
|
+
const useStyles = () => {
|
|
38
|
+
const navigationTheme = useNavigationTheme();
|
|
39
|
+
return StyleSheet.create({
|
|
40
|
+
container: {
|
|
41
|
+
flex: 1,
|
|
42
|
+
justifyContent: 'center',
|
|
43
|
+
backgroundColor: navigationTheme.colors.card,
|
|
44
|
+
},
|
|
45
|
+
listContainer: {
|
|
46
|
+
gap: 12,
|
|
47
|
+
paddingHorizontal: 16,
|
|
48
|
+
paddingVertical: 12,
|
|
49
|
+
},
|
|
50
|
+
textInputContainer: {
|
|
51
|
+
borderTopWidth: 1,
|
|
52
|
+
padding: 12,
|
|
53
|
+
backgroundColor: navigationTheme.colors.card,
|
|
54
|
+
},
|
|
55
|
+
textInput: { borderRadius: 16, borderWidth: 1, padding: 12 },
|
|
56
|
+
});
|
|
57
|
+
};
|
|
58
|
+
function Message(props) {
|
|
59
|
+
const { text, conversation_id, reactionCounts } = props;
|
|
60
|
+
const styles = useMessageStyles(props);
|
|
61
|
+
const navigation = useNavigation();
|
|
62
|
+
const handleMessagePress = () => {
|
|
63
|
+
navigation.navigate('MessageActions', {
|
|
64
|
+
message_id: props.id,
|
|
65
|
+
conversation_id,
|
|
66
|
+
});
|
|
67
|
+
};
|
|
68
|
+
// TODO: open the reaction screen to show who reacted
|
|
69
|
+
const handleReactionPress = handleMessagePress;
|
|
70
|
+
if (!text)
|
|
71
|
+
return null;
|
|
72
|
+
return (<View style={styles.message}>
|
|
73
|
+
{!props.mine && (<View style={styles.messageAuthor}>
|
|
74
|
+
<Avatar size={'md'} sourceUri={props.author.avatar}/>
|
|
75
|
+
</View>)}
|
|
76
|
+
<View style={styles.messageContent}>
|
|
77
|
+
{!props.mine && (<Text variant="tertiary" style={styles.authorName}>
|
|
78
|
+
{props.author.name}
|
|
79
|
+
</Text>)}
|
|
80
|
+
<PlatformPressable style={styles.messageBubble} onLongPress={handleMessagePress}>
|
|
81
|
+
<Text style={styles.messageText}>{text}</Text>
|
|
82
|
+
</PlatformPressable>
|
|
83
|
+
<View style={styles.messageReactions}>
|
|
84
|
+
{reactionCounts.map(reaction => (<MessageReaction key={reaction.value} reaction={reaction} onPress={handleReactionPress}/>))}
|
|
85
|
+
</View>
|
|
86
|
+
</View>
|
|
87
|
+
</View>);
|
|
41
88
|
}
|
|
42
89
|
const useMessageStyles = ({ mine }) => {
|
|
43
90
|
const { colors } = useTheme();
|
|
91
|
+
const activeColor = colorFunction(colors.interaction).alpha(0.2).string();
|
|
44
92
|
return StyleSheet.create({
|
|
45
93
|
message: {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
94
|
+
gap: 8,
|
|
95
|
+
flexDirection: mine ? 'row-reverse' : 'row',
|
|
96
|
+
},
|
|
97
|
+
messageContent: {
|
|
98
|
+
gap: 8,
|
|
99
|
+
flexShrink: 1,
|
|
100
|
+
},
|
|
101
|
+
messageAuthor: {
|
|
102
|
+
flexDirection: 'row',
|
|
103
|
+
gap: 8,
|
|
104
|
+
},
|
|
105
|
+
authorName: {},
|
|
106
|
+
authorAvatar: {},
|
|
107
|
+
messageBubble: {
|
|
108
|
+
backgroundColor: mine ? activeColor : colors.fillColorNeutral070,
|
|
109
|
+
borderRadius: 12,
|
|
110
|
+
paddingVertical: 6,
|
|
111
|
+
paddingHorizontal: 8,
|
|
112
|
+
},
|
|
113
|
+
messageText: {
|
|
52
114
|
color: colors.textColorDefaultPrimary,
|
|
53
115
|
},
|
|
116
|
+
messageReactions: {
|
|
117
|
+
flexDirection: 'row',
|
|
118
|
+
gap: 4,
|
|
119
|
+
justifyContent: mine ? 'flex-end' : 'flex-start',
|
|
120
|
+
},
|
|
54
121
|
});
|
|
55
122
|
};
|
|
56
|
-
const styles = StyleSheet.create({
|
|
57
|
-
container: {
|
|
58
|
-
flex: 1,
|
|
59
|
-
justifyContent: 'center',
|
|
60
|
-
},
|
|
61
|
-
listContainer: {
|
|
62
|
-
gap: 12,
|
|
63
|
-
paddingHorizontal: 16,
|
|
64
|
-
paddingTop: 12,
|
|
65
|
-
},
|
|
66
|
-
textInputContainer: { borderTopWidth: 1, padding: 12 },
|
|
67
|
-
textInput: { borderRadius: 16, borderWidth: 1, padding: 12 },
|
|
68
|
-
});
|
|
69
123
|
//# sourceMappingURL=conversation_screen.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conversation_screen.js","sourceRoot":"","sources":["../../src/screens/conversation_screen.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAqB,aAAa,EAAE,MAAM,0BAA0B,CAAA;AAC3E,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACxC,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AAClF,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAA;AAC5C,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AAEhF,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAOnC,MAAM,UAAU,kBAAkB,CAAC,EAAE,KAAK,EAA2B;IACnE,MAAM,UAAU,GAAG,aAAa,EAAE,CAAA;IAClC,MAAM,EAAE,eAAe,EAAE,GAAG,KAAK,CAAC,MAAM,CAAA;IAExC,MAAM,EAAE,IAAI,EAAE,YAAY,EAAE,GAAG,cAAc,CAAuB;QAClE,GAAG,EAAE,qBAAqB,eAAe,EAAE;QAC3C,IAAI,EAAE;YACJ,MAAM,EAAE;gBACN,YAAY,EAAE,CAAC,OAAO,CAAC;aACxB;SACF;KACF,CAAC,CAAA;IAEF,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,GAAG,oBAAoB,CAAkB;QAC3F,GAAG,EAAE,qBAAqB,eAAe,WAAW;QACpD,IAAI,EAAE;YACJ,OAAO,EAAE,EAAE;YACX,MAAM,EAAE;gBACN,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC;aAC1B;SACF;KACF,CAAC,CAAA;IAE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A;IAExC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,CAAA;AACnD,CAAC;AAED,MAAM,gBAAgB,GAAG,CAAC,EAAE,IAAI,EAAmB,EAAE,EAAE;IACrD,MAAM,EAAE,MAAM,EAAE,GAAG,QAAQ,EAAE,CAAA;IAE7B,OAAO,UAAU,CAAC,MAAM,CAAC;QACvB,OAAO,EAAE;YACP,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,YAAY;YAC3C,eAAe,EAAE,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,mBAAmB,CAAC,CAAC,CAAC,MAAM,CAAC,uBAAuB;YACnF,YAAY,EAAE,EAAE;YAChB,sBAAsB,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;YACrC,uBAAuB,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE;YACtC,OAAO,EAAE,EAAE;YACX,KAAK,EAAE,MAAM,CAAC,uBAAuB;SACtC;KACF,CAAC,CAAA;AACJ,CAAC,CAAA;AAED,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;IAC/B,SAAS,EAAE;QACT,IAAI,EAAE,CAAC;QACP,cAAc,EAAE,QAAQ;KACzB;IACD,aAAa,EAAE;QACb,GAAG,EAAE,EAAE;QACP,iBAAiB,EAAE,EAAE;QACrB,UAAU,EAAE,EAAE;KACf;IACD,kBAAkB,EAAE,EAAE,cAAc,EAAE,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE;IACtD,SAAS,EAAE,EAAE,YAAY,EAAE,EAAE,EAAE,WAAW,EAAE,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE;CAC7D,CAAC,CAAA","sourcesContent":["import { StaticScreenProps, useNavigation } from '@react-navigation/native'\nimport React, { useEffect } from 'react'\nimport { FlatList, SafeAreaView, StyleSheet, TextInput, View } from 'react-native'\nimport { Text } from '../components/display'\nimport { useSuspenseGet, useSuspensePaginator } from '../hooks/use_suspense_api'\nimport { ConversationResource, MessageResource } from '../types'\nimport { useTheme } from '../hooks'\n\nexport type ConversationScreenProps = StaticScreenProps<{\n conversation_id: string\n chat_group_graph_id: string\n}>\n\nexport function ConversationScreen({ route }: ConversationScreenProps) {\n const navigation = useNavigation()\n const { conversation_id } = route.params\n\n const { data: conversation } = useSuspenseGet<ConversationResource>({\n url: `/me/conversations/${conversation_id}`,\n data: {\n fields: {\n Conversation: ['title'],\n },\n },\n })\n\n const { data, refetch, isRefetching, fetchNextPage } = useSuspensePaginator<MessageResource>({\n url: `/me/conversations/${conversation_id}/messages`,\n data: {\n perPage: 25,\n fields: {\n Message: ['text', 'mine'],\n },\n },\n })\n\n useEffect(() => {\n navigation.setOptions({ title: conversation?.title })\n }, [conversation, conversation_id, navigation])\n\n return (\n <SafeAreaView style={styles.container}>\n <FlatList\n inverted\n contentContainerStyle={styles.listContainer}\n refreshing={isRefetching}\n onRefresh={refetch}\n data={data}\n keyExtractor={item => item.id}\n renderItem={({ item }) => <Message {...item} />}\n onEndReached={() => fetchNextPage()}\n />\n <View style={styles.textInputContainer}>\n <TextInput\n aria-disabled={true}\n placeholder=\"Send a message\"\n onChangeText={() => console.log('TODO: Implement sending a message')}\n value=\"\"\n style={styles.textInput}\n />\n </View>\n </SafeAreaView>\n )\n}\n\nfunction Message(message: MessageResource) {\n const { text } = message\n const styles = useMessageStyles(message)\n\n return <Text style={styles.message}>{text}</Text>\n}\n\nconst useMessageStyles = ({ mine }: MessageResource) => {\n const { colors } = useTheme()\n\n return StyleSheet.create({\n message: {\n alignSelf: mine ? 'flex-end' : 'flex-start',\n backgroundColor: mine ? colors.fillColorNeutral040 : colors.fillColorNeutral050Base,\n borderRadius: 16,\n borderBottomLeftRadius: mine ? 16 : 0,\n borderBottomRightRadius: mine ? 0 : 16,\n padding: 12,\n color: colors.textColorDefaultPrimary,\n },\n })\n}\n\nconst styles = StyleSheet.create({\n container: {\n flex: 1,\n justifyContent: 'center',\n },\n listContainer: {\n gap: 12,\n paddingHorizontal: 16,\n paddingTop: 12,\n },\n textInputContainer: { borderTopWidth: 1, padding: 12 },\n textInput: { borderRadius: 16, borderWidth: 1, padding: 12 },\n})\n"]}
|
|
1
|
+
{"version":3,"file":"conversation_screen.js","sourceRoot":"","sources":["../../src/screens/conversation_screen.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAA;AAC9D,OAAO,EAEL,aAAa,EACb,QAAQ,IAAI,kBAAkB,GAC/B,MAAM,0BAA0B,CAAA;AACjC,OAAO,aAAa,MAAM,OAAO,CAAA;AACjC,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACxC,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAA;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,6CAA6C,CAAA;AAC7E,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAA;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AACnC,OAAO,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAA;AAC5E,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAA;AAQ1D,MAAM,UAAU,kBAAkB,CAAC,EAAE,KAAK,EAA2B;IACnE,MAAM,UAAU,GAAG,aAAa,EAAE,CAAA;IAClC,MAAM,EAAE,eAAe,EAAE,GAAG,KAAK,CAAC,MAAM,CAAA;IACxC,MAAM,MAAM,GAAG,SAAS,EAAE,CAAA;IAE1B,MAAM,EAAE,IAAI,EAAE,YAAY,EAAE,GAAG,cAAc,CAAuB;QAClE,GAAG,EAAE,qBAAqB,eAAe,EAA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AAC,CACJ;QAAA,EAAE,IAAI,CACR;MAAA,EAAE,IAAI,CACR;IAAA,EAAE,IAAI,CAAC,CACR,CAAA;AACH,CAAC;AAED,MAAM,gBAAgB,GAAG,CAAC,EAAE,IAAI,EAAmB,EAAE,EAAE;IACrD,MAAM,EAAE,MAAM,EAAE,GAAG,QAAQ,EAAE,CAAA;IAC7B,MAAM,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;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,UAAU,EAAE,EAAE;QACd,YAAY,EAAE,EAAE;QAChB,aAAa,EAAE;YACb,eAAe,EAAE,IAAI,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,mBAAmB;YAChE,YAAY,EAAE,EAAE;YAChB,eAAe,EAAE,CAAC;YAClB,iBAAiB,EAAE,CAAC;SACrB;QACD,WAAW,EAAE;YACX,KAAK,EAAE,MAAM,CAAC,uBAAuB;SACtC;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 {\n StaticScreenProps,\n useNavigation,\n useTheme as useNavigationTheme,\n} from '@react-navigation/native'\nimport colorFunction from 'color'\nimport React, { useEffect } from 'react'\nimport { FlatList, StyleSheet, TextInput, View } from 'react-native'\nimport { SafeAreaView } from 'react-native-safe-area-context'\nimport { MessageReaction } from '../components/conversation/message_reaction'\nimport { Avatar, Text } from '../components/display'\nimport { useTheme } from '../hooks'\nimport { useConversationMessages } from '../hooks/use_conversation_messages'\nimport { useSuspenseGet } from '../hooks/use_suspense_api'\nimport { ConversationResource, MessageResource } from '../types'\n\nexport type ConversationScreenProps = StaticScreenProps<{\n conversation_id: string\n chat_group_graph_id: string\n}>\n\nexport function ConversationScreen({ route }: ConversationScreenProps) {\n const navigation = useNavigation()\n const { conversation_id } = route.params\n const styles = useStyles()\n\n const { data: conversation } = useSuspenseGet<ConversationResource>({\n url: `/me/conversations/${conversation_id}`,\n data: {\n fields: {\n Conversation: ['title'],\n },\n },\n })\n\n const { messages, refetch, isRefetching, fetchNextPage } = useConversationMessages({\n conversation_id,\n })\n\n useEffect(() => {\n navigation.setOptions({ title: conversation?.title })\n }, [conversation, conversation_id, navigation])\n\n return (\n <SafeAreaView style={styles.container} edges={['top', 'bottom', 'left', 'right']}>\n <FlatList\n inverted\n contentContainerStyle={styles.listContainer}\n refreshing={isRefetching}\n onRefresh={refetch}\n data={messages}\n keyExtractor={item => item.id}\n renderItem={({ item }) => <Message {...item} conversation_id={conversation_id} />}\n onEndReached={() => fetchNextPage()}\n />\n <View style={styles.textInputContainer}>\n <TextInput\n aria-disabled={true}\n placeholder=\"Send a message\"\n onChangeText={() => console.log('TODO: Implement sending a message')}\n value=\"\"\n style={styles.textInput}\n />\n </View>\n </SafeAreaView>\n )\n}\n\nconst useStyles = () => {\n const navigationTheme = useNavigationTheme()\n\n return StyleSheet.create({\n container: {\n flex: 1,\n justifyContent: 'center',\n backgroundColor: navigationTheme.colors.card,\n },\n listContainer: {\n gap: 12,\n paddingHorizontal: 16,\n paddingVertical: 12,\n },\n textInputContainer: {\n borderTopWidth: 1,\n padding: 12,\n backgroundColor: navigationTheme.colors.card,\n },\n textInput: { borderRadius: 16, borderWidth: 1, padding: 12 },\n })\n}\n\nfunction Message(props: MessageResource & { conversation_id: string }) {\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 // TODO: open the reaction screen to show who reacted\n const handleReactionPress = handleMessagePress\n\n if (!text) return null\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 && (\n <Text variant=\"tertiary\" style={styles.authorName}>\n {props.author.name}\n </Text>\n )}\n <PlatformPressable style={styles.messageBubble} onLongPress={handleMessagePress}>\n <Text style={styles.messageText}>{text}</Text>\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 authorName: {},\n authorAvatar: {},\n messageBubble: {\n backgroundColor: mine ? activeColor : colors.fillColorNeutral070,\n borderRadius: 12,\n paddingVertical: 6,\n paddingHorizontal: 8,\n },\n messageText: {\n color: colors.textColorDefaultPrimary,\n },\n messageReactions: {\n flexDirection: 'row',\n gap: 4,\n justifyContent: mine ? 'flex-end' : 'flex-start',\n },\n })\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"design_system_screen.d.ts","sourceRoot":"","sources":["../../src/screens/design_system_screen.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"design_system_screen.d.ts","sourceRoot":"","sources":["../../src/screens/design_system_screen.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAA;AAuDvC,wBAAgB,kBAAkB,sBAgBjC"}
|