@planningcenter/chat-react-native 3.7.0 → 3.7.1-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/components/conversation/message_reaction.d.ts +1 -0
- package/build/components/conversation/message_reaction.d.ts.map +1 -1
- package/build/components/conversation/message_reaction.js +6 -1
- package/build/components/conversation/message_reaction.js.map +1 -1
- package/build/components/primitive/form_sheet.d.ts +4 -2
- package/build/components/primitive/form_sheet.d.ts.map +1 -1
- package/build/components/primitive/form_sheet.js +3 -3
- package/build/components/primitive/form_sheet.js.map +1 -1
- package/build/screens/message_actions_screen.js +8 -3
- package/build/screens/message_actions_screen.js.map +1 -1
- package/build/screens/reactions_screen.d.ts +1 -2
- package/build/screens/reactions_screen.d.ts.map +1 -1
- package/build/screens/reactions_screen.js +51 -37
- package/build/screens/reactions_screen.js.map +1 -1
- package/package.json +2 -2
- package/src/components/conversation/message_reaction.tsx +7 -0
- package/src/components/primitive/form_sheet.tsx +7 -3
- package/src/screens/message_actions_screen.tsx +9 -2
- package/src/screens/reactions_screen.tsx +59 -41
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message_reaction.d.ts","sourceRoot":"","sources":["../../../src/components/conversation/message_reaction.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAkB,MAAM,OAAO,CAAA;AAKtC,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAA;AACtE,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"message_reaction.d.ts","sourceRoot":"","sources":["../../../src/components/conversation/message_reaction.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAkB,MAAM,OAAO,CAAA;AAKtC,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAA;AACtE,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAG7C,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,qBAAqB,CAAC,OAAO,CAAC,EAAE,MAAM,CAM1E,CAAA;AAED,wBAAgB,eAAe,CAAC,EAC9B,QAAQ,EACR,WAAW,EACX,OAAO,EACP,cAAc,GACf,EAAE;IACD,QAAQ,EAAE,qBAAqB,CAAA;IAC/B,WAAW,EAAE,CAAC,SAAS,EAAE,qBAAqB,KAAK,IAAI,CAAA;IACvD,OAAO,EAAE,eAAe,CAAA;IACxB,cAAc,EAAE,MAAM,CAAA;CACvB,4BA8BA;AAED,eAAO,MAAM,iBAAiB,aAAc;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE;;;;;;;;;;;;;;;;;;;;;CA+B3D,CAAA"}
|
|
@@ -5,6 +5,7 @@ import { StyleSheet } from 'react-native';
|
|
|
5
5
|
import { Text } from '../../components/display';
|
|
6
6
|
import { useTheme } from '../../hooks';
|
|
7
7
|
import { useMessageReactionToggle } from '../../hooks/use_message_reaction_toggle';
|
|
8
|
+
import { useCreateAndroidRippleColor } from '../../hooks/use_create_android_ripple_color';
|
|
8
9
|
export const REACTION_EMOJIS = {
|
|
9
10
|
thumbs_up: '👍',
|
|
10
11
|
thumbs_down: '👎',
|
|
@@ -18,6 +19,9 @@ export function MessageReaction({ reaction, onLongPress, message, conversationId
|
|
|
18
19
|
conversation_id: conversationId,
|
|
19
20
|
message,
|
|
20
21
|
});
|
|
22
|
+
const { colors } = useTheme();
|
|
23
|
+
const baseRippleColor = reaction.mine ? colors.interaction : colors.fillColorNeutral060;
|
|
24
|
+
const androidRippleColor = useCreateAndroidRippleColor({ color: baseRippleColor });
|
|
21
25
|
if (!reaction.count)
|
|
22
26
|
return null;
|
|
23
27
|
if (!REACTION_EMOJIS[reaction.value])
|
|
@@ -25,7 +29,7 @@ export function MessageReaction({ reaction, onLongPress, message, conversationId
|
|
|
25
29
|
const handlePress = () => {
|
|
26
30
|
handleReactionToggle({ value: reaction.value, mine: !!reaction.mine });
|
|
27
31
|
};
|
|
28
|
-
return (<PlatformPressable key={reaction.value} style={styles.reaction} onLongPress={() => onLongPress(reaction)} onPress={handlePress}>
|
|
32
|
+
return (<PlatformPressable key={reaction.value} style={styles.reaction} onLongPress={() => onLongPress(reaction)} onPress={handlePress} android_ripple={{ color: androidRippleColor, borderless: false, foreground: true }}>
|
|
29
33
|
<Text style={styles.reactionEmoji}>{REACTION_EMOJIS[reaction.value]}</Text>
|
|
30
34
|
<Text style={styles.reactionText}>{reaction.count}</Text>
|
|
31
35
|
</PlatformPressable>);
|
|
@@ -50,6 +54,7 @@ export const useReactionStyles = ({ mine }) => {
|
|
|
50
54
|
borderColor: mine ? activeBorderColor : 'transparent',
|
|
51
55
|
backgroundColor: mine ? activeBackgroundColor : colors.fillColorNeutral060,
|
|
52
56
|
borderRadius: 16,
|
|
57
|
+
overflow: 'hidden',
|
|
53
58
|
paddingVertical: 4,
|
|
54
59
|
paddingHorizontal: 8,
|
|
55
60
|
flexDirection: 'row',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message_reaction.js","sourceRoot":"","sources":["../../../src/components/conversation/message_reaction.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAA;AAC9D,OAAO,aAAa,MAAM,OAAO,CAAA;AACjC,OAAO,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAA;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AACtC,OAAO,EAAE,wBAAwB,EAAE,MAAM,yCAAyC,CAAA;
|
|
1
|
+
{"version":3,"file":"message_reaction.js","sourceRoot":"","sources":["../../../src/components/conversation/message_reaction.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAA;AAC9D,OAAO,aAAa,MAAM,OAAO,CAAA;AACjC,OAAO,KAAK,EAAE,EAAE,OAAO,E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AAO,aAAa,CAAC,MAAM,CAAC,WAAW,CAAC;aACrC,GAAG,EAAE;aACL,SAAS,CAAC,MAAM,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aAC3C,MAAM,EAAE,CAAA;IACb,CAAC,EAAE,CAAC,MAAM,CAAC,WAAW,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAA;IAErC,OAAO,UAAU,CAAC,MAAM,CAAC;QACvB,QAAQ,EAAE;YACR,WAAW,EAAE,CAAC;YACd,WAAW,EAAE,IAAI,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,aAAa;YACrD,eAAe,EAAE,IAAI,CAAC,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,MAAM,CAAC,mBAAmB;YAC1E,YAAY,EAAE,EAAE;YAChB,QAAQ,EAAE,QAAQ;YAClB,eAAe,EAAE,CAAC;YAClB,iBAAiB,EAAE,CAAC;YACpB,aAAa,EAAE,KAAK;YACpB,UAAU,EAAE,QAAQ;YACpB,GAAG,EAAE,CAAC;SACP;QACD,aAAa,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,UAAU,EAAE,CAAC,EAAE;QAC9C,YAAY,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC,uBAAuB,EAAE;KACtE,CAAC,CAAA;AACJ,CAAC,CAAA","sourcesContent":["import { PlatformPressable } from '@react-navigation/elements'\nimport colorFunction from 'color'\nimport React, { useMemo } from 'react'\nimport { StyleSheet } from 'react-native'\nimport { Text } from '../../components/display'\nimport { useTheme } from '../../hooks'\nimport { useMessageReactionToggle } from '../../hooks/use_message_reaction_toggle'\nimport { ReactionCountResource } from '../../types/resources/reaction'\nimport { MessageResource } from '../../types'\nimport { useCreateAndroidRippleColor } from '../../hooks/use_create_android_ripple_color'\n\nexport const REACTION_EMOJIS: Record<ReactionCountResource['value'], string> = {\n thumbs_up: '👍',\n thumbs_down: '👎',\n pray: '🙏',\n laugh: '😂',\n heart: '❤️',\n}\n\nexport function MessageReaction({\n reaction,\n onLongPress,\n message,\n conversationId,\n}: {\n reaction: ReactionCountResource\n onLongPress: (_reaction: ReactionCountResource) => void\n message: MessageResource\n conversationId: number\n}) {\n const styles = useReactionStyles(reaction)\n const { handleReactionToggle } = useMessageReactionToggle({\n conversation_id: conversationId,\n message,\n })\n\n const { colors } = useTheme()\n const baseRippleColor = reaction.mine ? colors.interaction : colors.fillColorNeutral060\n const androidRippleColor = useCreateAndroidRippleColor({ color: baseRippleColor })\n\n if (!reaction.count) return null\n if (!REACTION_EMOJIS[reaction.value]) return null\n\n const handlePress = () => {\n handleReactionToggle({ value: reaction.value, mine: !!reaction.mine })\n }\n\n return (\n <PlatformPressable\n key={reaction.value}\n style={styles.reaction}\n onLongPress={() => onLongPress(reaction)}\n onPress={handlePress}\n android_ripple={{ color: androidRippleColor, borderless: false, foreground: true }}\n >\n <Text style={styles.reactionEmoji}>{REACTION_EMOJIS[reaction.value]}</Text>\n <Text style={styles.reactionText}>{reaction.count}</Text>\n </PlatformPressable>\n )\n}\n\nexport const useReactionStyles = ({ mine }: { mine: number }) => {\n const { colors } = useTheme()\n const activeBorderColor = useMemo(() => {\n return colorFunction(colors.interaction)\n .hsl()\n .lightness(colors.name === 'dark' ? 20 : 80)\n .string()\n }, [colors.interaction, colors.name])\n const activeBackgroundColor = useMemo(() => {\n return colorFunction(colors.interaction)\n .hsl()\n .lightness(colors.name === 'dark' ? 12 : 92)\n .string()\n }, [colors.interaction, colors.name])\n\n return StyleSheet.create({\n reaction: {\n borderWidth: 1,\n borderColor: mine ? activeBorderColor : 'transparent',\n backgroundColor: mine ? activeBackgroundColor : colors.fillColorNeutral060,\n borderRadius: 16,\n overflow: 'hidden',\n paddingVertical: 4,\n paddingHorizontal: 8,\n flexDirection: 'row',\n alignItems: 'center',\n gap: 2,\n },\n reactionEmoji: { fontSize: 12, paddingTop: 0 },\n reactionText: { fontSize: 12, color: colors.textColorDefaultPrimary },\n })\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { NativeStackNavigationOptions } from '@react-navigation/native-stack';
|
|
2
2
|
import React, { ReactNode } from 'react';
|
|
3
|
-
import { type AccessibilityRole } from 'react-native';
|
|
3
|
+
import { type AccessibilityRole, type StyleProp, type ViewStyle } from 'react-native';
|
|
4
4
|
import { IconString } from '../display';
|
|
5
5
|
/**
|
|
6
6
|
* Screen options for the formsheet's NativeStackNavigation route
|
|
@@ -20,8 +20,10 @@ export default _default;
|
|
|
20
20
|
export type { FormSheetRootProps, FormSheetActionProps, FormSheetHeaderProps };
|
|
21
21
|
interface FormSheetRootProps {
|
|
22
22
|
children: ReactNode;
|
|
23
|
+
style?: StyleProp<ViewStyle>;
|
|
24
|
+
contentStyle?: StyleProp<ViewStyle>;
|
|
23
25
|
}
|
|
24
|
-
export declare function FormSheetRoot({ children }: FormSheetRootProps): React.JSX.Element;
|
|
26
|
+
export declare function FormSheetRoot({ children, style, contentStyle }: FormSheetRootProps): React.JSX.Element;
|
|
25
27
|
export declare namespace FormSheetRoot {
|
|
26
28
|
var displayName: string;
|
|
27
29
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"form_sheet.d.ts","sourceRoot":"","sources":["../../../src/components/primitive/form_sheet.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAA;AAC7E,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACxC,OAAO,EAKL,KAAK,iBAAiB,
|
|
1
|
+
{"version":3,"file":"form_sheet.d.ts","sourceRoot":"","sources":["../../../src/components/primitive/form_sheet.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAA;AAC7E,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACxC,OAAO,EAKL,KAAK,iBAA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AAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,iBAAiB,CAAC,EAAE,iBAAiB,CAAA;IACrC,UAAU,CAAC,EAAE,8BAA8B,CAAA;IAC3C,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB"}
|
|
@@ -29,11 +29,11 @@ const FormSheet = {
|
|
|
29
29
|
Header: FormSheetHeader,
|
|
30
30
|
};
|
|
31
31
|
export default FormSheet;
|
|
32
|
-
export function FormSheetRoot({ children }) {
|
|
32
|
+
export function FormSheetRoot({ children, style, contentStyle }) {
|
|
33
33
|
const styles = useStyles();
|
|
34
|
-
return (<View style={styles.container} collapsable={false}>
|
|
34
|
+
return (<View style={[styles.container, style]} collapsable={false}>
|
|
35
35
|
<AndroidSheetGrabber />
|
|
36
|
-
<View style={styles.content}>{children}</View>
|
|
36
|
+
<View style={[styles.content, contentStyle]}>{children}</View>
|
|
37
37
|
</View>);
|
|
38
38
|
}
|
|
39
39
|
FormSheetRoot.displayName = 'FormSheet.Root';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"form_sheet.js","sourceRoot":"","sources":["../../../src/components/primitive/form_sheet.tsx"],"names":[],"mappings":"AACA,OAAO,KAAoB,MAAM,OAAO,CAAA;AACxC,OAAO,EACL,QAAQ,EACR,UAAU,EACV,IAAI,EACJ,mBAAmB,GAEpB,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAA;AAClE,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AACtC,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAC/E,OAAO,EAAE,OAAO,EAAE,IAAI,EAAc,IAAI,EAAE,MAAM,YAAY,CAAA;AAE5D,oCAAoC;AACpC,oCAAoC;AACpC,oCAAoC;AAEpC;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,EACxC,WAAW,EACX,mBAAmB,GAAG,CAAC,I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Ae;SACxB;QACD,mBAAmB,EAAE;YACnB,SAAS,EAAE,CAAC;YACZ,KAAK,EAAE,EAAE;YACT,MAAM,EAAE,CAAC;YACT,eAAe,EAAE,MAAM,CAAC,mBAAmB;YAC3C,YAAY,EAAE,GAAG;YACjB,SAAS,EAAE,QAAQ;SACpB;QACD,OAAO,EAAE;YACP,UAAU,EAAE,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC;SACtD;QACD,MAAM,EAAE;YACN,eAAe,EAAE,MAAM,CAAC,2BAA2B;YACnD,iBAAiB,EAAE,EAAE;YACrB,aAAa,EAAE,EAAE;YACjB,GAAG,EAAE,EAAE;YACP,iBAAiB,EAAE,CAAC;YACpB,iBAAiB,EAAE,MAAM,CAAC,sBAAsB;YAChD,aAAa,EAAE,KAAK;YACpB,UAAU,EAAE,QAAQ;YACpB,cAAc,EAAE,eAAe;SAChC;QACD,WAAW,EAAE;YACX,SAAS,EAAE,MAAM;SAClB;QACD,aAAa,EAAE;YACb,aAAa,EAAE,KAAK;YACpB,UAAU,EAAE,QAAQ;YACpB,GAAG,EAAE,EAAE;SACR;QACD,eAAe,EAAE;YACf,aAAa,EAAE,KAAK;YACpB,UAAU,EAAE,QAAQ;YACpB,eAAe,EAAE,EAAE;YACnB,iBAAiB,EAAE,EAAE;YACrB,GAAG,EAAE,CAAC;SACP;QACD,UAAU,EAAE;YACV,KAAK,EAAE,mBAAmB,CAAC,UAAU,CAAC,CAAC,SAAS;SACjD;QACD,WAAW,EAAE;YACX,KAAK,EAAE,mBAAmB,CAAC,UAAU,CAAC,CAAC,SAAS;SACjD;KACF,CAAC,CAAA;AACJ,CAAC,CAAA","sourcesContent":["import { NativeStackNavigationOptions } from '@react-navigation/native-stack'\nimport React, { ReactNode } from 'react'\nimport {\n Platform,\n StyleSheet,\n View,\n useWindowDimensions,\n type AccessibilityRole,\n} from 'react-native'\nimport { useSafeAreaInsets } from 'react-native-safe-area-context'\nimport { useTheme } from '../../hooks'\nimport { PlatformPressable, useHeaderHeight } from '@react-navigation/elements'\nimport { Heading, Icon, IconString, Text } from '../display'\n\n// =================================\n// ====== Exports ==================\n// =================================\n\n/**\n * Screen options for the formsheet's NativeStackNavigation route\n * @param {string} options.headerTitle - Doesn't show in UI but good to have for semantic reasons.\n * @param {number[]} [options.sheetAllowedDetents] - Controls the height increments the sheet grows to. To prevent bugs in Android, do not specify more then two values and use [0.94] instead of [1] to go full screen.\n * @param {NativeStackNavigationOptions} [options.rest] - Adds or overrides any valid NativeStackNavigationOptions\n * @returns {NativeStackNavigationOptions} Merged NativeStackNavigationOptions\n */\nexport const getFormSheetScreenOptions = ({\n headerTitle,\n sheetAllowedDetents = [0.25],\n ...rest\n}: NativeStackNavigationOptions = {}): NativeStackNavigationOptions => ({\n presentation: 'formSheet',\n headerShown: false,\n sheetAllowedDetents,\n sheetCornerRadius: 16,\n sheetGrabberVisible: true,\n headerTitle,\n ...rest,\n})\n\nconst FormSheet = {\n Root: FormSheetRoot,\n Action: FormSheetAction,\n Header: FormSheetHeader,\n} as const\n\ntype FormSheetComponents = {\n Root: React.FC<FormSheetRootProps>\n Action: React.FC<FormSheetActionProps>\n Header: React.FC<FormSheetHeaderProps>\n}\n\nexport default FormSheet as FormSheetComponents\nexport type { FormSheetRootProps, FormSheetActionProps, FormSheetHeaderProps }\n\n// ====================================\n// ====== ActionsFormSheetRoot ========\n// ====================================\n\ninterface FormSheetRootProps {\n children: ReactNode\n}\n\nexport function FormSheetRoot({ children }: FormSheetRootProps) {\n const styles = useStyles()\n\n return (\n <View style={styles.container} collapsable={false}>\n <AndroidSheetGrabber />\n <View style={styles.content}>{children}</View>\n </View>\n )\n}\n\nFormSheetRoot.displayName = 'FormSheet.Root'\n\n// ====================================\n// ====== AndroidSheetGrabber =========\n// ====================================\n\nfunction AndroidSheetGrabber() {\n const styles = useStyles()\n\n return Platform.select({\n android: <View style={styles.androidSheetGrabber} />,\n ios: null,\n })\n}\n\n// ====================================\n// ====== FormSheetHeader =============\n// ====================================\n\ninterface FormSheetHeaderProps {\n title: string\n secondaryButton?: ReactNode\n primaryButton?: ReactNode\n}\nfunction FormSheetHeader({ title, secondaryButton, primaryButton }: FormSheetHeaderProps) {\n const styles = useStyles()\n const hasActions = Boolean(secondaryButton) || Boolean(primaryButton)\n\n return (\n <View style={styles.header}>\n <Heading variant=\"h3\" style={styles.headerTitle}>\n {title}\n </Heading>\n {hasActions && (\n <View style={styles.headerActions}>\n {secondaryButton}\n {primaryButton}\n </View>\n )}\n </View>\n )\n}\n\nFormSheetHeader.displayName = 'FormSheet.Header'\n\n// ====================================\n// ====== ActionsFormSheetAction ======\n// ====================================\n\nconst FORM_SHEET_ACTION_APPEARANCES = {\n neutral: 'neutral',\n danger: 'danger',\n} as const\n\ntype FormSheetActionAppearanceUnion =\n (typeof FORM_SHEET_ACTION_APPEARANCES)[keyof typeof FORM_SHEET_ACTION_APPEARANCES]\n\ninterface FormSheetActionProps {\n title: string\n iconName: IconString\n onPress: () => void\n accessibilityLabel?: string\n accessibilityHint?: string\n accessibilityRole?: AccessibilityRole\n appearance?: FormSheetActionAppearanceUnion\n disabled?: boolean\n}\n\nfunction FormSheetAction({\n title,\n iconName,\n onPress,\n accessibilityLabel,\n accessibilityHint,\n accessibilityRole = 'button',\n appearance = 'neutral',\n disabled = false,\n}: FormSheetActionProps) {\n const styles = useStyles({ appearance })\n\n return (\n <PlatformPressable\n onPress={onPress}\n accessibilityLabel={accessibilityLabel}\n accessibilityHint={accessibilityHint}\n accessibilityRole={accessibilityRole}\n style={styles.actionPressable}\n disabled={disabled}\n >\n <Icon name={iconName} size={16} accessibilityElementsHidden style={styles.actionIcon} />\n <Text style={styles.actionTitle}>{title}</Text>\n </PlatformPressable>\n )\n}\n\nFormSheetAction.displayName = 'FormSheet.Action'\n\n// ==================================\n// ====== Styles ====================\n// ==================================\n\ninterface Styles {\n appearance?: FormSheetActionAppearanceUnion\n}\n\nconst useStyles = ({ appearance = 'neutral' }: Styles = {}) => {\n const { colors } = useTheme()\n const { height } = useWindowDimensions()\n const { bottom, top } = useSafeAreaInsets()\n const headerHeight = useHeaderHeight()\n\n const containerHeight = Platform.select({\n ios: height - top - headerHeight,\n default: null,\n })\n\n const appearanceColorsMap = {\n neutral: {\n iconColor: colors.iconColorDefaultPrimary,\n textColor: colors.textColorDefaultPrimary,\n },\n danger: {\n iconColor: colors.fillColorStatusErrorMedium,\n textColor: colors.fillColorStatusErrorMedium,\n },\n }\n\n return StyleSheet.create({\n container: {\n flex: 1,\n justifyContent: 'flex-start',\n paddingBottom: bottom,\n width: '100%',\n backgroundColor: colors.fillColorNeutral100Inverted,\n height: containerHeight,\n },\n androidSheetGrabber: {\n marginTop: 5,\n width: 34,\n height: 5,\n backgroundColor: colors.fillColorNeutral040,\n borderRadius: 100,\n alignSelf: 'center',\n },\n content: {\n paddingTop: Platform.select({ android: 16, ios: 20 }),\n },\n header: {\n backgroundColor: colors.fillColorNeutral100Inverted,\n paddingHorizontal: 16,\n paddingBottom: 16,\n gap: 16,\n borderBottomWidth: 1,\n borderBottomColor: colors.borderColorDefaultBase,\n flexDirection: 'row',\n alignItems: 'center',\n justifyContent: 'space-between',\n },\n headerTitle: {\n textAlign: 'left',\n },\n headerActions: {\n flexDirection: 'row',\n alignItems: 'center',\n gap: 16,\n },\n actionPressable: {\n flexDirection: 'row',\n alignItems: 'center',\n paddingVertical: 12,\n paddingHorizontal: 16,\n gap: 8,\n },\n actionIcon: {\n color: appearanceColorsMap[appearance].iconColor,\n },\n actionTitle: {\n color: appearanceColorsMap[appearance].textColor,\n },\n })\n}\n"]}
|
|
1
|
+
{"version":3,"file":"form_sheet.js","sourceRoot":"","sources":["../../../src/components/primitive/form_sheet.tsx"],"names":[],"mappings":"AACA,OAAO,KAAoB,MAAM,OAAO,CAAA;AACxC,OAAO,EACL,QAAQ,EACR,UAAU,EACV,IAAI,EACJ,mBAAmB,GAIpB,MAAM,cAAc,CAAA;AACrB,OAA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EAAE,QAAQ;YACpB,eAAe,EAAE,EAAE;YACnB,iBAAiB,EAAE,EAAE;YACrB,GAAG,EAAE,CAAC;SACP;QACD,UAAU,EAAE;YACV,KAAK,EAAE,mBAAmB,CAAC,UAAU,CAAC,CAAC,SAAS;SACjD;QACD,WAAW,EAAE;YACX,KAAK,EAAE,mBAAmB,CAAC,UAAU,CAAC,CAAC,SAAS;SACjD;KACF,CAAC,CAAA;AACJ,CAAC,CAAA","sourcesContent":["import { NativeStackNavigationOptions } from '@react-navigation/native-stack'\nimport React, { ReactNode } from 'react'\nimport {\n Platform,\n StyleSheet,\n View,\n useWindowDimensions,\n type AccessibilityRole,\n type StyleProp,\n type ViewStyle,\n} from 'react-native'\nimport { useSafeAreaInsets } from 'react-native-safe-area-context'\nimport { useTheme } from '../../hooks'\nimport { PlatformPressable, useHeaderHeight } from '@react-navigation/elements'\nimport { Heading, Icon, IconString, Text } from '../display'\n\n// =================================\n// ====== Exports ==================\n// =================================\n\n/**\n * Screen options for the formsheet's NativeStackNavigation route\n * @param {string} options.headerTitle - Doesn't show in UI but good to have for semantic reasons.\n * @param {number[]} [options.sheetAllowedDetents] - Controls the height increments the sheet grows to. To prevent bugs in Android, do not specify more then two values and use [0.94] instead of [1] to go full screen.\n * @param {NativeStackNavigationOptions} [options.rest] - Adds or overrides any valid NativeStackNavigationOptions\n * @returns {NativeStackNavigationOptions} Merged NativeStackNavigationOptions\n */\nexport const getFormSheetScreenOptions = ({\n headerTitle,\n sheetAllowedDetents = [0.25],\n ...rest\n}: NativeStackNavigationOptions = {}): NativeStackNavigationOptions => ({\n presentation: 'formSheet',\n headerShown: false,\n sheetAllowedDetents,\n sheetCornerRadius: 16,\n sheetGrabberVisible: true,\n headerTitle,\n ...rest,\n})\n\nconst FormSheet = {\n Root: FormSheetRoot,\n Action: FormSheetAction,\n Header: FormSheetHeader,\n} as const\n\ntype FormSheetComponents = {\n Root: React.FC<FormSheetRootProps>\n Action: React.FC<FormSheetActionProps>\n Header: React.FC<FormSheetHeaderProps>\n}\n\nexport default FormSheet as FormSheetComponents\nexport type { FormSheetRootProps, FormSheetActionProps, FormSheetHeaderProps }\n\n// ====================================\n// ====== ActionsFormSheetRoot ========\n// ====================================\n\ninterface FormSheetRootProps {\n children: ReactNode\n style?: StyleProp<ViewStyle>\n contentStyle?: StyleProp<ViewStyle>\n}\n\nexport function FormSheetRoot({ children, style, contentStyle }: FormSheetRootProps) {\n const styles = useStyles()\n\n return (\n <View style={[styles.container, style]} collapsable={false}>\n <AndroidSheetGrabber />\n <View style={[styles.content, contentStyle]}>{children}</View>\n </View>\n )\n}\n\nFormSheetRoot.displayName = 'FormSheet.Root'\n\n// ====================================\n// ====== AndroidSheetGrabber =========\n// ====================================\n\nfunction AndroidSheetGrabber() {\n const styles = useStyles()\n\n return Platform.select({\n android: <View style={styles.androidSheetGrabber} />,\n ios: null,\n })\n}\n\n// ====================================\n// ====== FormSheetHeader =============\n// ====================================\n\ninterface FormSheetHeaderProps {\n title: string\n secondaryButton?: ReactNode\n primaryButton?: ReactNode\n}\nfunction FormSheetHeader({ title, secondaryButton, primaryButton }: FormSheetHeaderProps) {\n const styles = useStyles()\n const hasActions = Boolean(secondaryButton) || Boolean(primaryButton)\n\n return (\n <View style={styles.header}>\n <Heading variant=\"h3\" style={styles.headerTitle}>\n {title}\n </Heading>\n {hasActions && (\n <View style={styles.headerActions}>\n {secondaryButton}\n {primaryButton}\n </View>\n )}\n </View>\n )\n}\n\nFormSheetHeader.displayName = 'FormSheet.Header'\n\n// ====================================\n// ====== ActionsFormSheetAction ======\n// ====================================\n\nconst FORM_SHEET_ACTION_APPEARANCES = {\n neutral: 'neutral',\n danger: 'danger',\n} as const\n\ntype FormSheetActionAppearanceUnion =\n (typeof FORM_SHEET_ACTION_APPEARANCES)[keyof typeof FORM_SHEET_ACTION_APPEARANCES]\n\ninterface FormSheetActionProps {\n title: string\n iconName: IconString\n onPress: () => void\n accessibilityLabel?: string\n accessibilityHint?: string\n accessibilityRole?: AccessibilityRole\n appearance?: FormSheetActionAppearanceUnion\n disabled?: boolean\n}\n\nfunction FormSheetAction({\n title,\n iconName,\n onPress,\n accessibilityLabel,\n accessibilityHint,\n accessibilityRole = 'button',\n appearance = 'neutral',\n disabled = false,\n}: FormSheetActionProps) {\n const styles = useStyles({ appearance })\n\n return (\n <PlatformPressable\n onPress={onPress}\n accessibilityLabel={accessibilityLabel}\n accessibilityHint={accessibilityHint}\n accessibilityRole={accessibilityRole}\n style={styles.actionPressable}\n disabled={disabled}\n >\n <Icon name={iconName} size={16} accessibilityElementsHidden style={styles.actionIcon} />\n <Text style={styles.actionTitle}>{title}</Text>\n </PlatformPressable>\n )\n}\n\nFormSheetAction.displayName = 'FormSheet.Action'\n\n// ==================================\n// ====== Styles ====================\n// ==================================\n\ninterface Styles {\n appearance?: FormSheetActionAppearanceUnion\n}\n\nconst useStyles = ({ appearance = 'neutral' }: Styles = {}) => {\n const { colors } = useTheme()\n const { height } = useWindowDimensions()\n const { bottom, top } = useSafeAreaInsets()\n const headerHeight = useHeaderHeight()\n\n const containerHeight = Platform.select({\n ios: height - top - headerHeight,\n default: null,\n })\n\n const appearanceColorsMap = {\n neutral: {\n iconColor: colors.iconColorDefaultPrimary,\n textColor: colors.textColorDefaultPrimary,\n },\n danger: {\n iconColor: colors.fillColorStatusErrorMedium,\n textColor: colors.fillColorStatusErrorMedium,\n },\n }\n\n return StyleSheet.create({\n container: {\n flex: 1,\n justifyContent: 'flex-start',\n paddingBottom: bottom,\n width: '100%',\n backgroundColor: colors.fillColorNeutral100Inverted,\n height: containerHeight,\n },\n androidSheetGrabber: {\n marginTop: 5,\n width: 34,\n height: 5,\n backgroundColor: colors.fillColorNeutral040,\n borderRadius: 100,\n alignSelf: 'center',\n },\n content: {\n paddingTop: Platform.select({ android: 16, ios: 20 }),\n },\n header: {\n backgroundColor: colors.fillColorNeutral100Inverted,\n paddingHorizontal: 16,\n paddingBottom: 16,\n gap: 16,\n borderBottomWidth: 1,\n borderBottomColor: colors.borderColorDefaultBase,\n flexDirection: 'row',\n alignItems: 'center',\n justifyContent: 'space-between',\n },\n headerTitle: {\n textAlign: 'left',\n },\n headerActions: {\n flexDirection: 'row',\n alignItems: 'center',\n gap: 16,\n },\n actionPressable: {\n flexDirection: 'row',\n alignItems: 'center',\n paddingVertical: 12,\n paddingHorizontal: 16,\n gap: 8,\n },\n actionIcon: {\n color: appearanceColorsMap[appearance].iconColor,\n },\n actionTitle: {\n color: appearanceColorsMap[appearance].textColor,\n },\n })\n}\n"]}
|
|
@@ -5,7 +5,7 @@ import React, { useCallback } from 'react';
|
|
|
5
5
|
import { Alert, Platform, StyleSheet, View } from 'react-native';
|
|
6
6
|
import { Text } from '../components';
|
|
7
7
|
import { REACTION_EMOJIS, useReactionStyles } from '../components/conversation/message_reaction';
|
|
8
|
-
import { useTheme } from '../hooks';
|
|
8
|
+
import { useCreateAndroidRippleColor, useFontScale, useTheme } from '../hooks';
|
|
9
9
|
import { useApiClient } from '../hooks/use_api_client';
|
|
10
10
|
import { useConversationMessages } from '../hooks/use_conversation_messages';
|
|
11
11
|
import { useMessageReactionToggle } from '../hooks/use_message_reaction_toggle';
|
|
@@ -105,14 +105,18 @@ export function MessageActionsScreen({ route }) {
|
|
|
105
105
|
const Reaction = ({ reaction, onPress, }) => {
|
|
106
106
|
const styles = useStyles();
|
|
107
107
|
const reactionStyles = useReactionStyles({ mine: reaction.mine ? 1 : 0 });
|
|
108
|
-
|
|
108
|
+
const { colors } = useTheme();
|
|
109
|
+
const baseRippleColor = reaction.mine ? colors.interaction : colors.fillColorNeutral060;
|
|
110
|
+
const androidRippleColor = useCreateAndroidRippleColor({ color: baseRippleColor });
|
|
111
|
+
return (<PlatformPressable key={reaction.value} style={[reactionStyles.reaction, styles.reaction]} android_ripple={{ color: androidRippleColor, borderless: false, foreground: true }} onPress={onPress}>
|
|
109
112
|
<Text style={styles.reactionEmoji}>{REACTION_EMOJIS[reaction.value]}</Text>
|
|
110
113
|
</PlatformPressable>);
|
|
111
114
|
};
|
|
112
115
|
const useStyles = () => {
|
|
113
116
|
const { colors } = useTheme();
|
|
117
|
+
const fontScale = useFontScale({ maxFontSizeMultiplier: 1.3 });
|
|
114
118
|
const btnBorderWidth = 1;
|
|
115
|
-
const baseSize = 44;
|
|
119
|
+
const baseSize = 44 * fontScale;
|
|
116
120
|
const reactionBtnSize = Platform.select({
|
|
117
121
|
ios: baseSize,
|
|
118
122
|
android: baseSize + btnBorderWidth * 2,
|
|
@@ -134,6 +138,7 @@ const useStyles = () => {
|
|
|
134
138
|
borderWidth: btnBorderWidth,
|
|
135
139
|
borderRadius: 32,
|
|
136
140
|
justifyContent: 'center',
|
|
141
|
+
overflow: 'hidden',
|
|
137
142
|
},
|
|
138
143
|
reactionEmoji: {
|
|
139
144
|
fontSize: 24,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message_actions_screen.js","sourceRoot":"","sources":["../../src/screens/message_actions_screen.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAA;AAC9D,OAAO,EAAE,YAAY,EAAqB,aAAa,EAAE,MAAM,0BAA0B,CAAA;AACzF,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AACnD,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,MAAM,OAAO,CAAA;AAC1C,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AAChE,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAA;AACpC,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,6CAA6C,CAAA;AAChG,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AACnC,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AACtD,OAAO,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAA;AAC5E,OAAO,EAAE,wBAAwB,EAAE,MAAM,sCAAs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e,GAAG,QAAQ,CAAC,MAAM,CAAC;QACtC,GAAG,EAAE,QAAQ;QACb,OAAO,EAAE,QAAQ,GAAG,cAAc,GAAG,CAAC;KACvC,CAAC,CAAA;IAEF,OAAO,UAAU,CAAC,MAAM,CAAC;QACvB,YAAY,EAAE;YACZ,aAAa,EAAE,KAAK;YACpB,cAAc,EAAE,QAAQ;YACxB,UAAU,EAAE,QAAQ;YACpB,GAAG,EAAE,EAAE;YACP,UAAU,EAAE,CAAC;YACb,aAAa,EAAE,EAAE;YACjB,iBAAiB,EAAE,MAAM,CAAC,sBAAsB;YAChD,iBAAiB,EAAE,CAAC;SACrB;QACD,QAAQ,EAAE;YACR,MAAM,EAAE,eAAe;YACvB,KAAK,EAAE,eAAe;YACtB,WAAW,EAAE,cAAc;YAC3B,YAAY,EAAE,EAAE;YAChB,cAAc,EAAE,QAAQ;SACzB;QACD,aAAa,EAAE;YACb,QAAQ,EAAE,EAAE;SACb;QACD,OAAO,EAAE;YACP,UAAU,EAAE,CAAC;SACd;KACF,CAAC,CAAA;AACJ,CAAC,CAAA","sourcesContent":["import { PlatformPressable } from '@react-navigation/elements'\nimport { StackActions, StaticScreenProps, useNavigation } from '@react-navigation/native'\nimport { useMutation } from '@tanstack/react-query'\nimport React, { useCallback } from 'react'\nimport { Alert, Platform, StyleSheet, View } from 'react-native'\nimport { Text } from '../components'\nimport { REACTION_EMOJIS, useReactionStyles } from '../components/conversation/message_reaction'\nimport { useTheme } from '../hooks'\nimport { useApiClient } from '../hooks/use_api_client'\nimport { useConversationMessages } from '../hooks/use_conversation_messages'\nimport { useMessageReactionToggle } from '../hooks/use_message_reaction_toggle'\nimport { ReactionCountResource } from '../types/resources/reaction'\nimport { Clipboard } from '../utils/native_adapters'\nimport { isNil, omitBy } from 'lodash'\nimport FormSheet, { getFormSheetScreenOptions } from '../components/primitive/form_sheet'\n\nexport const MessageActionsScreenOptions = getFormSheetScreenOptions({\n sheetAllowedDetents: [0.5],\n headerTitle: 'Message actions',\n})\n\nexport type MessageActionsScreenProps = StaticScreenProps<{\n message_id: string\n conversation_id: number\n canDeleteNonAuthoredMessages?: boolean\n}>\n\nexport function MessageActionsScreen({ route }: MessageActionsScreenProps) {\n const navigation = useNavigation()\n const { conversation_id, message_id, canDeleteNonAuthoredMessages } = route.params\n\n const apiClient = useApiClient()\n const styles = useStyles()\n\n const { messages, refetch } = useConversationMessages(\n { conversation_id },\n { refetchOnMount: false }\n )\n const message = messages.find(m => m.id === message_id)\n\n if (!message) fail('Message not found')\n\n const myReactions = message?.reactionCounts\n .filter(reaction => reaction.mine)\n .map(reaction => reaction.value)\n\n const availableReactions = Object.entries(REACTION_EMOJIS).map(([value, emoji]) => {\n return {\n value: value as ReactionCountResource['value'],\n emoji,\n mine: myReactions?.includes(value as ReactionCountResource['value']),\n }\n })\n\n const attachmentForCopy = (): string => {\n const giphyTitleLink = message?.attachments.find(\n attachment => attachment.type === 'giphy'\n )?.titleLink\n\n if (giphyTitleLink) return giphyTitleLink\n return ''\n }\n\n const handleCopyPress = () => {\n Clipboard.setStringAsync(message?.text || attachmentForCopy() || '')\n navigation.goBack()\n }\n\n const { handleReactionToggle, isPending } = useMessageReactionToggle({\n conversation_id,\n message,\n onSuccess: () => navigation.goBack(),\n })\n\n const deleteMessage = useCallback(() => {\n const url = `/me/conversations/${conversation_id}/messages/${message_id}/`\n\n return apiClient.chat.delete({ url })\n }, [apiClient, conversation_id, message_id])\n\n const { mutate: handleDeleteMessage } = useMutation({\n mutationFn: deleteMessage,\n onSuccess: () => {\n refetch()\n navigation.goBack()\n },\n onError: () => {\n Alert.alert('Oops', 'We were unable to delete this message. Please try again.')\n },\n })\n\n const handleDeleteConfirm = useCallback(() => {\n Alert.alert('Delete message', 'Are you sure you want to permanently delete this message?', [\n { text: 'Cancel', style: 'cancel' },\n { text: 'Delete', style: 'destructive', onPress: () => handleDeleteMessage() },\n ])\n }, [handleDeleteMessage])\n\n const handleEditPress = useCallback(() => {\n const state = navigation.getState?.()\n const targetRoute = state?.routes?.find(r => r.name === 'Conversation')\n const params = omitBy(\n {\n ...(targetRoute?.params || {}),\n conversation_id,\n editing_message_id: message_id,\n },\n isNil\n )\n navigation.dispatch(StackActions.popTo('Conversation', params))\n }, [navigation, conversation_id, message_id])\n\n const handleViewReadReceiptsPress = useCallback(() => {\n const params = omitBy(\n {\n conversation_id,\n message_id,\n },\n isNil\n )\n navigation.dispatch(StackActions.popTo('MessageReadReceipts', params))\n }, [navigation, conversation_id, message_id])\n\n return (\n <FormSheet.Root>\n <View style={styles.reactionList}>\n {availableReactions.map((reaction, index) => (\n <Reaction\n key={index}\n reaction={reaction}\n onPress={() =>\n handleReactionToggle({\n value: reaction.value,\n mine: reaction.mine,\n })\n }\n />\n ))}\n </View>\n <View style={styles.actions}>\n <FormSheet.Action\n onPress={handleCopyPress}\n title=\"Copy text\"\n iconName=\"services.fileCopy\"\n accessibilityHint=\"Copies text and links to clipboard\"\n />\n {message?.mine && (\n <FormSheet.Action\n onPress={() => handleEditPress()}\n title=\"Edit message\"\n iconName=\"accounts.editor\"\n accessibilityHint=\"Opens existing text in the message form input.\"\n />\n )}\n {message?.mine && (\n <FormSheet.Action\n onPress={() => handleViewReadReceiptsPress()}\n title=\"View read receipts\"\n iconName=\"general.checkPerson\"\n accessibilityHint=\"Opens a modal with a list of people who read your message.\"\n />\n )}\n {(message?.mine || canDeleteNonAuthoredMessages) && (\n <FormSheet.Action\n onPress={() => handleDeleteConfirm()}\n title=\"Delete message\"\n iconName=\"publishing.trash\"\n appearance=\"danger\"\n disabled={isPending}\n accessibilityHint=\"Opens a confirmation alert to delete this message permanently.\"\n />\n )}\n </View>\n </FormSheet.Root>\n )\n}\n\nconst Reaction = ({\n reaction,\n onPress,\n}: {\n reaction: { value: ReactionCountResource['value']; emoji: string; mine: boolean | undefined }\n onPress: () => void\n}) => {\n const styles = useStyles()\n const reactionStyles = useReactionStyles({ mine: reaction.mine ? 1 : 0 })\n\n return (\n <PlatformPressable\n key={reaction.value}\n style={[reactionStyles.reaction, styles.reaction]}\n onPress={onPress}\n >\n <Text style={styles.reactionEmoji}>{REACTION_EMOJIS[reaction.value]}</Text>\n </PlatformPressable>\n )\n}\n\nconst useStyles = () => {\n const { colors } = useTheme()\n\n const btnBorderWidth = 1\n const baseSize = 44\n const reactionBtnSize = Platform.select({\n ios: baseSize,\n android: baseSize + btnBorderWidth * 2,\n })\n\n return StyleSheet.create({\n reactionList: {\n flexDirection: 'row',\n justifyContent: 'center',\n alignItems: 'center',\n gap: 16,\n paddingTop: 8,\n paddingBottom: 16,\n borderBottomColor: colors.borderColorDefaultBase,\n borderBottomWidth: 1,\n },\n reaction: {\n height: reactionBtnSize,\n width: reactionBtnSize,\n borderWidth: btnBorderWidth,\n borderRadius: 32,\n justifyContent: 'center',\n },\n reactionEmoji: {\n fontSize: 24,\n },\n actions: {\n paddingTop: 4,\n },\n })\n}\n"]}
|
|
1
|
+
{"version":3,"file":"message_actions_screen.js","sourceRoot":"","sources":["../../src/screens/message_actions_screen.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAA;AAC9D,OAAO,EAAE,YAAY,EAAqB,aAAa,EAAE,MAAM,0BAA0B,CAAA;AACzF,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AACnD,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,MAAM,OAAO,CAAA;AAC1C,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AAChE,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAA;AACpC,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,6CAA6C,CAAA;AAChG,OAAO,EAAE,2BAA2B,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAC9E,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AACtD,OAAO,EAAE,uBAAuB,EAAE,MAAM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":["import { PlatformPressable } from '@react-navigation/elements'\nimport { StackActions, StaticScreenProps, useNavigation } from '@react-navigation/native'\nimport { useMutation } from '@tanstack/react-query'\nimport React, { useCallback } from 'react'\nimport { Alert, Platform, StyleSheet, View } from 'react-native'\nimport { Text } from '../components'\nimport { REACTION_EMOJIS, useReactionStyles } from '../components/conversation/message_reaction'\nimport { useCreateAndroidRippleColor, useFontScale, useTheme } from '../hooks'\nimport { useApiClient } from '../hooks/use_api_client'\nimport { useConversationMessages } from '../hooks/use_conversation_messages'\nimport { useMessageReactionToggle } from '../hooks/use_message_reaction_toggle'\nimport { ReactionCountResource } from '../types/resources/reaction'\nimport { Clipboard } from '../utils/native_adapters'\nimport { isNil, omitBy } from 'lodash'\nimport FormSheet, { getFormSheetScreenOptions } from '../components/primitive/form_sheet'\n\nexport const MessageActionsScreenOptions = getFormSheetScreenOptions({\n sheetAllowedDetents: [0.5],\n headerTitle: 'Message actions',\n})\n\nexport type MessageActionsScreenProps = StaticScreenProps<{\n message_id: string\n conversation_id: number\n canDeleteNonAuthoredMessages?: boolean\n}>\n\nexport function MessageActionsScreen({ route }: MessageActionsScreenProps) {\n const navigation = useNavigation()\n const { conversation_id, message_id, canDeleteNonAuthoredMessages } = route.params\n\n const apiClient = useApiClient()\n const styles = useStyles()\n\n const { messages, refetch } = useConversationMessages(\n { conversation_id },\n { refetchOnMount: false }\n )\n const message = messages.find(m => m.id === message_id)\n\n if (!message) fail('Message not found')\n\n const myReactions = message?.reactionCounts\n .filter(reaction => reaction.mine)\n .map(reaction => reaction.value)\n\n const availableReactions = Object.entries(REACTION_EMOJIS).map(([value, emoji]) => {\n return {\n value: value as ReactionCountResource['value'],\n emoji,\n mine: myReactions?.includes(value as ReactionCountResource['value']),\n }\n })\n\n const attachmentForCopy = (): string => {\n const giphyTitleLink = message?.attachments.find(\n attachment => attachment.type === 'giphy'\n )?.titleLink\n\n if (giphyTitleLink) return giphyTitleLink\n return ''\n }\n\n const handleCopyPress = () => {\n Clipboard.setStringAsync(message?.text || attachmentForCopy() || '')\n navigation.goBack()\n }\n\n const { handleReactionToggle, isPending } = useMessageReactionToggle({\n conversation_id,\n message,\n onSuccess: () => navigation.goBack(),\n })\n\n const deleteMessage = useCallback(() => {\n const url = `/me/conversations/${conversation_id}/messages/${message_id}/`\n\n return apiClient.chat.delete({ url })\n }, [apiClient, conversation_id, message_id])\n\n const { mutate: handleDeleteMessage } = useMutation({\n mutationFn: deleteMessage,\n onSuccess: () => {\n refetch()\n navigation.goBack()\n },\n onError: () => {\n Alert.alert('Oops', 'We were unable to delete this message. Please try again.')\n },\n })\n\n const handleDeleteConfirm = useCallback(() => {\n Alert.alert('Delete message', 'Are you sure you want to permanently delete this message?', [\n { text: 'Cancel', style: 'cancel' },\n { text: 'Delete', style: 'destructive', onPress: () => handleDeleteMessage() },\n ])\n }, [handleDeleteMessage])\n\n const handleEditPress = useCallback(() => {\n const state = navigation.getState?.()\n const targetRoute = state?.routes?.find(r => r.name === 'Conversation')\n const params = omitBy(\n {\n ...(targetRoute?.params || {}),\n conversation_id,\n editing_message_id: message_id,\n },\n isNil\n )\n navigation.dispatch(StackActions.popTo('Conversation', params))\n }, [navigation, conversation_id, message_id])\n\n const handleViewReadReceiptsPress = useCallback(() => {\n const params = omitBy(\n {\n conversation_id,\n message_id,\n },\n isNil\n )\n navigation.dispatch(StackActions.popTo('MessageReadReceipts', params))\n }, [navigation, conversation_id, message_id])\n\n return (\n <FormSheet.Root>\n <View style={styles.reactionList}>\n {availableReactions.map((reaction, index) => (\n <Reaction\n key={index}\n reaction={reaction}\n onPress={() =>\n handleReactionToggle({\n value: reaction.value,\n mine: reaction.mine,\n })\n }\n />\n ))}\n </View>\n <View style={styles.actions}>\n <FormSheet.Action\n onPress={handleCopyPress}\n title=\"Copy text\"\n iconName=\"services.fileCopy\"\n accessibilityHint=\"Copies text and links to clipboard\"\n />\n {message?.mine && (\n <FormSheet.Action\n onPress={() => handleEditPress()}\n title=\"Edit message\"\n iconName=\"accounts.editor\"\n accessibilityHint=\"Opens existing text in the message form input.\"\n />\n )}\n {message?.mine && (\n <FormSheet.Action\n onPress={() => handleViewReadReceiptsPress()}\n title=\"View read receipts\"\n iconName=\"general.checkPerson\"\n accessibilityHint=\"Opens a modal with a list of people who read your message.\"\n />\n )}\n {(message?.mine || canDeleteNonAuthoredMessages) && (\n <FormSheet.Action\n onPress={() => handleDeleteConfirm()}\n title=\"Delete message\"\n iconName=\"publishing.trash\"\n appearance=\"danger\"\n disabled={isPending}\n accessibilityHint=\"Opens a confirmation alert to delete this message permanently.\"\n />\n )}\n </View>\n </FormSheet.Root>\n )\n}\n\nconst Reaction = ({\n reaction,\n onPress,\n}: {\n reaction: { value: ReactionCountResource['value']; emoji: string; mine: boolean | undefined }\n onPress: () => void\n}) => {\n const styles = useStyles()\n const reactionStyles = useReactionStyles({ mine: reaction.mine ? 1 : 0 })\n\n const { colors } = useTheme()\n const baseRippleColor = reaction.mine ? colors.interaction : colors.fillColorNeutral060\n const androidRippleColor = useCreateAndroidRippleColor({ color: baseRippleColor })\n\n return (\n <PlatformPressable\n key={reaction.value}\n style={[reactionStyles.reaction, styles.reaction]}\n android_ripple={{ color: androidRippleColor, borderless: false, foreground: true }}\n onPress={onPress}\n >\n <Text style={styles.reactionEmoji}>{REACTION_EMOJIS[reaction.value]}</Text>\n </PlatformPressable>\n )\n}\n\nconst useStyles = () => {\n const { colors } = useTheme()\n const fontScale = useFontScale({ maxFontSizeMultiplier: 1.3 })\n\n const btnBorderWidth = 1\n const baseSize = 44 * fontScale\n const reactionBtnSize = Platform.select({\n ios: baseSize,\n android: baseSize + btnBorderWidth * 2,\n })\n\n return StyleSheet.create({\n reactionList: {\n flexDirection: 'row',\n justifyContent: 'center',\n alignItems: 'center',\n gap: 16,\n paddingTop: 8,\n paddingBottom: 16,\n borderBottomColor: colors.borderColorDefaultBase,\n borderBottomWidth: 1,\n },\n reaction: {\n height: reactionBtnSize,\n width: reactionBtnSize,\n borderWidth: btnBorderWidth,\n borderRadius: 32,\n justifyContent: 'center',\n overflow: 'hidden',\n },\n reactionEmoji: {\n fontSize: 24,\n },\n actions: {\n paddingTop: 4,\n },\n })\n}\n"]}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { StaticScreenProps } from '@react-navigation/native';
|
|
2
|
-
import { NativeStackNavigationOptions } from '@react-navigation/native-stack';
|
|
3
2
|
import React from 'react';
|
|
4
|
-
export declare const ReactionsScreenOptions: NativeStackNavigationOptions;
|
|
3
|
+
export declare const ReactionsScreenOptions: import("@react-navigation/native-stack").NativeStackNavigationOptions;
|
|
5
4
|
export type ReactionScreenProps = StaticScreenProps<{
|
|
6
5
|
message_id: string;
|
|
7
6
|
conversation_id: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reactions_screen.d.ts","sourceRoot":"","sources":["../../src/screens/reactions_screen.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAA;AAC5D,OAAO,
|
|
1
|
+
{"version":3,"file":"reactions_screen.d.ts","sourceRoot":"","sources":["../../src/screens/reactions_screen.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAA;AAC5D,OAAO,KAAe,MAAM,OAAO,CAAA;AAenC,eAAO,MAAM,sBAAsB,uEAMjC,CAAA;AAEF,MAAM,MAAM,mBAAmB,GAAG,iBAAiB,CAAC;IAClD,UAAU,EAAE,MAAM,CAAA;IAClB,eAAe,EAAE,MAAM,CAAA;IACvB,cAAc,CAAC,EAAE,MAAM,CAAA;CACxB,CAAC,CAAA;AAEF,wBAAgB,eAAe,CAAC,EAAE,KAAK,EAAE,EAAE,mBAAmB,qBA0D7D"}
|
|
@@ -1,19 +1,22 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import {
|
|
1
|
+
import React, { memo } from 'react';
|
|
2
|
+
import { Platform, StyleSheet, View } from 'react-native';
|
|
3
|
+
import { FlatList } from 'react-native-gesture-handler';
|
|
3
4
|
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
|
4
5
|
import { Avatar, Text } from '../components';
|
|
5
|
-
import { REACTION_EMOJIS
|
|
6
|
+
import { REACTION_EMOJIS } from '../components/conversation/message_reaction';
|
|
6
7
|
import { Tabs } from '../components/display/tabs';
|
|
7
8
|
import { useSuspenseGet, useTheme } from '../hooks';
|
|
8
9
|
import { useConversationMessages } from '../hooks/use_conversation_messages';
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
sheetAllowedDetents:
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
10
|
+
import FormSheet, { getFormSheetScreenOptions } from '../components/primitive/form_sheet';
|
|
11
|
+
import { platformFontWeightMedium } from '../utils';
|
|
12
|
+
import { useFontScale } from '../hooks/use_font_scale';
|
|
13
|
+
export const ReactionsScreenOptions = getFormSheetScreenOptions({
|
|
14
|
+
sheetAllowedDetents: Platform.select({
|
|
15
|
+
android: [0.5, 0.94], // Going straight to full 0.94 preserves height of screen on Android
|
|
16
|
+
default: [0.5, 1],
|
|
17
|
+
}),
|
|
18
|
+
headerTitle: 'Reactions',
|
|
19
|
+
});
|
|
17
20
|
export function ReactionsScreen({ route }) {
|
|
18
21
|
const { conversation_id, message_id, reaction_value } = route.params;
|
|
19
22
|
const styles = useStyles();
|
|
@@ -38,54 +41,65 @@ export function ReactionsScreen({ route }) {
|
|
|
38
41
|
}
|
|
39
42
|
const authorIds = reactionCount.authorIds;
|
|
40
43
|
const authors = members.filter(member => authorIds.includes(member.id));
|
|
41
|
-
return (<
|
|
44
|
+
return (<FormSheet.Root contentStyle={styles.formSheetContent}>
|
|
42
45
|
<Tabs data={reactionCounts} activeTab={reactionCount} onTabPress={item => {
|
|
43
46
|
setReactionCountValue(item.value);
|
|
44
47
|
}} renderItem={({ item }) => (<Reaction active={reactionCount.id === item.id} reaction={item} onPress={() => setReactionCountValue(item.value)}/>)} style={styles.actions}/>
|
|
45
|
-
<
|
|
46
|
-
|
|
47
|
-
<Text key={author.id}>{author.name}</Text>
|
|
48
|
-
</View>)}/>
|
|
49
|
-
</View>);
|
|
48
|
+
<FlatList data={authors} contentContainerStyle={styles.contentContainer} keyExtractor={item => item.id.toString()} renderItem={({ item: author }) => <Author author={author} key={author.id}/>}/>
|
|
49
|
+
</FormSheet.Root>);
|
|
50
50
|
}
|
|
51
51
|
const Reaction = ({ reaction, }) => {
|
|
52
52
|
const styles = useStyles();
|
|
53
|
-
const reactionStyles = useReactionStyles({ mine: reaction.mine ? 1 : 0 });
|
|
54
53
|
return (<View key={reaction.value} style={styles.reaction}>
|
|
55
|
-
<Text style={
|
|
56
|
-
<Text style={
|
|
54
|
+
<Text style={styles.reactionContent}>{REACTION_EMOJIS[reaction.value]}</Text>
|
|
55
|
+
<Text style={styles.reactionContent}>{reaction.count}</Text>
|
|
57
56
|
</View>);
|
|
58
57
|
};
|
|
58
|
+
const Author = memo(({ author }) => {
|
|
59
|
+
const styles = useStyles();
|
|
60
|
+
return (<View style={styles.authorRow}>
|
|
61
|
+
<Avatar sourceUri={author.avatar} size="sm"/>
|
|
62
|
+
<Text variant="tertiary" numberOfLines={2} style={styles.authorName}>
|
|
63
|
+
{author.name}
|
|
64
|
+
</Text>
|
|
65
|
+
</View>);
|
|
66
|
+
});
|
|
59
67
|
const useStyles = () => {
|
|
60
|
-
const
|
|
61
|
-
const { height } = useWindowDimensions();
|
|
68
|
+
const { colors } = useTheme();
|
|
62
69
|
const { bottom } = useSafeAreaInsets();
|
|
70
|
+
const fontScale = useFontScale({ maxFontSizeMultiplier: 1.3 });
|
|
63
71
|
return StyleSheet.create({
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
paddingTop: 12,
|
|
67
|
-
paddingBottom: bottom,
|
|
68
|
-
width: '100%',
|
|
69
|
-
backgroundColor: theme.colors.fillColorNeutral100Inverted,
|
|
70
|
-
height,
|
|
71
|
-
gap: 8,
|
|
72
|
+
formSheetContent: {
|
|
73
|
+
paddingTop: Platform.select({ android: 4, default: 16 }),
|
|
72
74
|
},
|
|
73
|
-
|
|
75
|
+
contentContainer: {
|
|
76
|
+
paddingTop: 8,
|
|
77
|
+
paddingBottom: bottom + Platform.select({ android: 24, default: 16 }),
|
|
78
|
+
},
|
|
79
|
+
authorRow: {
|
|
74
80
|
flexDirection: 'row',
|
|
75
81
|
alignItems: 'center',
|
|
76
82
|
gap: 8,
|
|
77
|
-
|
|
78
|
-
|
|
83
|
+
paddingVertical: 8,
|
|
84
|
+
paddingHorizontal: 16,
|
|
85
|
+
flex: 1,
|
|
86
|
+
},
|
|
87
|
+
authorName: {
|
|
88
|
+
flex: 1,
|
|
79
89
|
},
|
|
80
90
|
reaction: {
|
|
81
|
-
|
|
82
|
-
|
|
91
|
+
paddingHorizontal: 8,
|
|
92
|
+
paddingVertical: 16,
|
|
83
93
|
flexDirection: 'row',
|
|
84
94
|
gap: 4,
|
|
85
95
|
},
|
|
96
|
+
reactionContent: {
|
|
97
|
+
fontSize: 18,
|
|
98
|
+
fontWeight: platformFontWeightMedium,
|
|
99
|
+
},
|
|
86
100
|
actions: {
|
|
87
|
-
minHeight:
|
|
88
|
-
borderBottomColor:
|
|
101
|
+
minHeight: 68 * fontScale,
|
|
102
|
+
borderBottomColor: colors.borderColorDefaultBase,
|
|
89
103
|
borderBottomWidth: 1,
|
|
90
104
|
},
|
|
91
105
|
errorContainer: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reactions_screen.js","sourceRoot":"","sources":["../../src/screens/reactions_screen.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,UAAU,EAAE,mBAAmB,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AACpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAA;AAClE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,eAAe,CAAA;AAC5C,OAAO,EAAE,eA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igation/native'\nimport { NativeStackNavigationOptions } from '@react-navigation/native-stack'\nimport React from 'react'\nimport { StyleSheet, useWindowDimensions, View } from 'react-native'\nimport { useSafeAreaInsets } from 'react-native-safe-area-context'\nimport { Avatar, Text } from '../components'\nimport { REACTION_EMOJIS, useReactionStyles } from '../components/conversation/message_reaction'\nimport { Tabs } from '../components/display/tabs'\nimport { useSuspenseGet, useTheme } from '../hooks'\nimport { useConversationMessages } from '../hooks/use_conversation_messages'\nimport { MemberResource } from '../types'\nimport { ReactionCountResource } from '../types/resources/reaction'\nimport { FlashList } from '@shopify/flash-list'\n\nexport const ReactionsScreenOptions: NativeStackNavigationOptions = {\n presentation: 'formSheet',\n headerShown: false,\n sheetAllowedDetents: [0.5],\n sheetGrabberVisible: true,\n sheetCornerRadius: 16,\n}\n\nexport type ReactionScreenProps = StaticScreenProps<{\n message_id: string\n conversation_id: number\n reaction_value?: string\n}>\n\nexport function ReactionsScreen({ route }: ReactionScreenProps) {\n const { conversation_id, message_id, reaction_value } = route.params\n const styles = useStyles()\n\n const { messages } = useConversationMessages({ conversation_id }, { refetchOnMount: false })\n const { data: members } = useSuspenseGet<MemberResource[]>({\n url: `/me/conversations/${conversation_id}/members`,\n data: {\n fields: {\n Member: ['id', 'name', 'avatar', 'badges', 'child', 'role'],\n },\n },\n })\n const message = messages.find(m => m.id === message_id)\n const reactionCounts = message?.reactionCounts || []\n const initialReactionCount =\n reactionCounts.find(r => r.value === reaction_value) || reactionCounts[0]\n const [reactionCountValue, setReactionCountValue] = React.useState<\n ReactionCountResource['value']\n >(initialReactionCount.value)\n const reactionCount = reactionCounts.find(r => r.value === reactionCountValue)\n\n if (!reactionCount) {\n return (\n <View style={styles.errorContainer}>\n <Text>No reactions found for this message.</Text>\n </View>\n )\n }\n\n const authorIds = reactionCount.authorIds\n const authors = members.filter(member => authorIds.includes(member.id))\n\n return (\n <View style={styles.container}>\n <Tabs\n data={reactionCounts}\n activeTab={reactionCount}\n onTabPress={item => {\n setReactionCountValue(item.value)\n }}\n renderItem={({ item }) => (\n <Reaction\n active={reactionCount.id === item.id}\n reaction={item}\n onPress={() => setReactionCountValue(item.value)}\n />\n )}\n style={styles.actions}\n />\n <FlashList\n data={authors}\n keyExtractor={item => item.id.toString()}\n renderItem={({ item: author }) => (\n <View style={styles.authorList}>\n <Avatar size={'md'} sourceUri={author.avatar} />\n <Text key={author.id}>{author.name}</Text>\n </View>\n )}\n />\n </View>\n )\n}\n\nconst Reaction = ({\n reaction,\n}: {\n active: boolean\n reaction: ReactionCountResource\n onPress: () => void\n}) => {\n const styles = useStyles()\n const reactionStyles = useReactionStyles({ mine: reaction.mine ? 1 : 0 })\n\n return (\n <View key={reaction.value} style={styles.reaction}>\n <Text style={reactionStyles.reactionEmoji}>{REACTION_EMOJIS[reaction.value]}</Text>\n <Text style={reactionStyles.reactionEmoji}>{reaction.count}</Text>\n </View>\n )\n}\n\nconst useStyles = () => {\n const theme = useTheme()\n const { height } = useWindowDimensions()\n const { bottom } = useSafeAreaInsets()\n\n return StyleSheet.create({\n container: {\n justifyContent: 'flex-start',\n paddingTop: 12,\n paddingBottom: bottom,\n width: '100%',\n backgroundColor: theme.colors.fillColorNeutral100Inverted,\n height,\n gap: 8,\n },\n authorList: {\n flexDirection: 'row',\n alignItems: 'center',\n gap: 8,\n paddingHorizontal: 12,\n paddingVertical: 12,\n },\n reaction: {\n paddingVertical: 12,\n paddingHorizontal: 12,\n flexDirection: 'row',\n gap: 4,\n },\n actions: {\n minHeight: 48,\n borderBottomColor: theme.colors.fillColorNeutral040,\n borderBottomWidth: 1,\n },\n errorContainer: {\n flex: 1,\n justifyContent: 'center',\n alignItems: 'center',\n padding: 16,\n marginTop: 30,\n },\n })\n}\n"]}
|
|
1
|
+
{"version":3,"file":"reactions_screen.js","sourceRoot":"","sources":["../../src/screens/reactions_screen.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,IAAI,EAAE,MAAM,OAAO,CAAA;AACnC,OAAO,EAAE,QAAQ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AAE,OAAO,EAAE,EAAE,EAAE,CAAC;SACzD;QACD,gBAAgB,EAAE;YAChB,UAAU,EAAE,CAAC;YACb,aAAa,EAAE,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;SACtE;QACD,SAAS,EAAE;YACT,aAAa,EAAE,KAAK;YACpB,UAAU,EAAE,QAAQ;YACpB,GAAG,EAAE,CAAC;YACN,eAAe,EAAE,CAAC;YAClB,iBAAiB,EAAE,EAAE;YACrB,IAAI,EAAE,CAAC;SACR;QACD,UAAU,EAAE;YACV,IAAI,EAAE,CAAC;SACR;QACD,QAAQ,EAAE;YACR,iBAAiB,EAAE,CAAC;YACpB,eAAe,EAAE,EAAE;YACnB,aAAa,EAAE,KAAK;YACpB,GAAG,EAAE,CAAC;SACP;QACD,eAAe,EAAE;YACf,QAAQ,EAAE,EAAE;YACZ,UAAU,EAAE,wBAAwB;SACrC;QACD,OAAO,EAAE;YACP,SAAS,EAAE,EAAE,GAAG,SAAS;YACzB,iBAAiB,EAAE,MAAM,CAAC,sBAAsB;YAChD,iBAAiB,EAAE,CAAC;SACrB;QACD,cAAc,EAAE;YACd,IAAI,EAAE,CAAC;YACP,cAAc,EAAE,QAAQ;YACxB,UAAU,EAAE,QAAQ;YACpB,OAAO,EAAE,EAAE;YACX,SAAS,EAAE,EAAE;SACd;KACF,CAAC,CAAA;AACJ,CAAC,CAAA","sourcesContent":["import { StaticScreenProps } from '@react-navigation/native'\nimport React, { memo } from 'react'\nimport { Platform, StyleSheet, View } from 'react-native'\nimport { FlatList } from 'react-native-gesture-handler'\nimport { useSafeAreaInsets } from 'react-native-safe-area-context'\nimport { Avatar, Text } from '../components'\nimport { REACTION_EMOJIS } from '../components/conversation/message_reaction'\nimport { Tabs } from '../components/display/tabs'\nimport { useSuspenseGet, useTheme } from '../hooks'\nimport { useConversationMessages } from '../hooks/use_conversation_messages'\nimport { MemberResource } from '../types'\nimport { ReactionCountResource } from '../types/resources/reaction'\nimport FormSheet, { getFormSheetScreenOptions } from '../components/primitive/form_sheet'\nimport { platformFontWeightMedium } from '../utils'\nimport { useFontScale } from '../hooks/use_font_scale'\n\nexport const ReactionsScreenOptions = getFormSheetScreenOptions({\n sheetAllowedDetents: Platform.select({\n android: [0.5, 0.94], // Going straight to full 0.94 preserves height of screen on Android\n default: [0.5, 1],\n }),\n headerTitle: 'Reactions',\n})\n\nexport type ReactionScreenProps = StaticScreenProps<{\n message_id: string\n conversation_id: number\n reaction_value?: string\n}>\n\nexport function ReactionsScreen({ route }: ReactionScreenProps) {\n const { conversation_id, message_id, reaction_value } = route.params\n const styles = useStyles()\n\n const { messages } = useConversationMessages({ conversation_id }, { refetchOnMount: false })\n const { data: members } = useSuspenseGet<MemberResource[]>({\n url: `/me/conversations/${conversation_id}/members`,\n data: {\n fields: {\n Member: ['id', 'name', 'avatar', 'badges', 'child', 'role'],\n },\n },\n })\n const message = messages.find(m => m.id === message_id)\n const reactionCounts = message?.reactionCounts || []\n const initialReactionCount =\n reactionCounts.find(r => r.value === reaction_value) || reactionCounts[0]\n const [reactionCountValue, setReactionCountValue] = React.useState<\n ReactionCountResource['value']\n >(initialReactionCount.value)\n const reactionCount = reactionCounts.find(r => r.value === reactionCountValue)\n\n if (!reactionCount) {\n return (\n <View style={styles.errorContainer}>\n <Text>No reactions found for this message.</Text>\n </View>\n )\n }\n\n const authorIds = reactionCount.authorIds\n const authors = members.filter(member => authorIds.includes(member.id))\n\n return (\n <FormSheet.Root contentStyle={styles.formSheetContent}>\n <Tabs\n data={reactionCounts}\n activeTab={reactionCount}\n onTabPress={item => {\n setReactionCountValue(item.value)\n }}\n renderItem={({ item }) => (\n <Reaction\n active={reactionCount.id === item.id}\n reaction={item}\n onPress={() => setReactionCountValue(item.value)}\n />\n )}\n style={styles.actions}\n />\n <FlatList\n data={authors}\n contentContainerStyle={styles.contentContainer}\n keyExtractor={item => item.id.toString()}\n renderItem={({ item: author }) => <Author author={author} key={author.id} />}\n />\n </FormSheet.Root>\n )\n}\n\nconst Reaction = ({\n reaction,\n}: {\n active: boolean\n reaction: ReactionCountResource\n onPress: () => void\n}) => {\n const styles = useStyles()\n\n return (\n <View key={reaction.value} style={styles.reaction}>\n <Text style={styles.reactionContent}>{REACTION_EMOJIS[reaction.value]}</Text>\n <Text style={styles.reactionContent}>{reaction.count}</Text>\n </View>\n )\n}\n\ntype AuthorProps = Pick<MemberResource, 'id' | 'name' | 'avatar'>\n\nconst Author = memo(({ author }: { author: AuthorProps }) => {\n const styles = useStyles()\n\n return (\n <View style={styles.authorRow}>\n <Avatar sourceUri={author.avatar} size=\"sm\" />\n <Text variant=\"tertiary\" numberOfLines={2} style={styles.authorName}>\n {author.name}\n </Text>\n </View>\n )\n})\n\nconst useStyles = () => {\n const { colors } = useTheme()\n const { bottom } = useSafeAreaInsets()\n const fontScale = useFontScale({ maxFontSizeMultiplier: 1.3 })\n\n return StyleSheet.create({\n formSheetContent: {\n paddingTop: Platform.select({ android: 4, default: 16 }),\n },\n contentContainer: {\n paddingTop: 8,\n paddingBottom: bottom + Platform.select({ android: 24, default: 16 }),\n },\n authorRow: {\n flexDirection: 'row',\n alignItems: 'center',\n gap: 8,\n paddingVertical: 8,\n paddingHorizontal: 16,\n flex: 1,\n },\n authorName: {\n flex: 1,\n },\n reaction: {\n paddingHorizontal: 8,\n paddingVertical: 16,\n flexDirection: 'row',\n gap: 4,\n },\n reactionContent: {\n fontSize: 18,\n fontWeight: platformFontWeightMedium,\n },\n actions: {\n minHeight: 68 * fontScale,\n borderBottomColor: colors.borderColorDefaultBase,\n borderBottomWidth: 1,\n },\n errorContainer: {\n flex: 1,\n justifyContent: 'center',\n alignItems: 'center',\n padding: 16,\n marginTop: 30,\n },\n })\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@planningcenter/chat-react-native",
|
|
3
|
-
"version": "3.7.
|
|
3
|
+
"version": "3.7.1-rc.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -55,5 +55,5 @@
|
|
|
55
55
|
"prettier": "^3.4.2",
|
|
56
56
|
"typescript": "<5.6.0"
|
|
57
57
|
},
|
|
58
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "7d11e45c6ec9d85c3526bba6254771776f8599d7"
|
|
59
59
|
}
|
|
@@ -7,6 +7,7 @@ import { useTheme } from '../../hooks'
|
|
|
7
7
|
import { useMessageReactionToggle } from '../../hooks/use_message_reaction_toggle'
|
|
8
8
|
import { ReactionCountResource } from '../../types/resources/reaction'
|
|
9
9
|
import { MessageResource } from '../../types'
|
|
10
|
+
import { useCreateAndroidRippleColor } from '../../hooks/use_create_android_ripple_color'
|
|
10
11
|
|
|
11
12
|
export const REACTION_EMOJIS: Record<ReactionCountResource['value'], string> = {
|
|
12
13
|
thumbs_up: '👍',
|
|
@@ -33,6 +34,10 @@ export function MessageReaction({
|
|
|
33
34
|
message,
|
|
34
35
|
})
|
|
35
36
|
|
|
37
|
+
const { colors } = useTheme()
|
|
38
|
+
const baseRippleColor = reaction.mine ? colors.interaction : colors.fillColorNeutral060
|
|
39
|
+
const androidRippleColor = useCreateAndroidRippleColor({ color: baseRippleColor })
|
|
40
|
+
|
|
36
41
|
if (!reaction.count) return null
|
|
37
42
|
if (!REACTION_EMOJIS[reaction.value]) return null
|
|
38
43
|
|
|
@@ -46,6 +51,7 @@ export function MessageReaction({
|
|
|
46
51
|
style={styles.reaction}
|
|
47
52
|
onLongPress={() => onLongPress(reaction)}
|
|
48
53
|
onPress={handlePress}
|
|
54
|
+
android_ripple={{ color: androidRippleColor, borderless: false, foreground: true }}
|
|
49
55
|
>
|
|
50
56
|
<Text style={styles.reactionEmoji}>{REACTION_EMOJIS[reaction.value]}</Text>
|
|
51
57
|
<Text style={styles.reactionText}>{reaction.count}</Text>
|
|
@@ -74,6 +80,7 @@ export const useReactionStyles = ({ mine }: { mine: number }) => {
|
|
|
74
80
|
borderColor: mine ? activeBorderColor : 'transparent',
|
|
75
81
|
backgroundColor: mine ? activeBackgroundColor : colors.fillColorNeutral060,
|
|
76
82
|
borderRadius: 16,
|
|
83
|
+
overflow: 'hidden',
|
|
77
84
|
paddingVertical: 4,
|
|
78
85
|
paddingHorizontal: 8,
|
|
79
86
|
flexDirection: 'row',
|
|
@@ -6,6 +6,8 @@ import {
|
|
|
6
6
|
View,
|
|
7
7
|
useWindowDimensions,
|
|
8
8
|
type AccessibilityRole,
|
|
9
|
+
type StyleProp,
|
|
10
|
+
type ViewStyle,
|
|
9
11
|
} from 'react-native'
|
|
10
12
|
import { useSafeAreaInsets } from 'react-native-safe-area-context'
|
|
11
13
|
import { useTheme } from '../../hooks'
|
|
@@ -58,15 +60,17 @@ export type { FormSheetRootProps, FormSheetActionProps, FormSheetHeaderProps }
|
|
|
58
60
|
|
|
59
61
|
interface FormSheetRootProps {
|
|
60
62
|
children: ReactNode
|
|
63
|
+
style?: StyleProp<ViewStyle>
|
|
64
|
+
contentStyle?: StyleProp<ViewStyle>
|
|
61
65
|
}
|
|
62
66
|
|
|
63
|
-
export function FormSheetRoot({ children }: FormSheetRootProps) {
|
|
67
|
+
export function FormSheetRoot({ children, style, contentStyle }: FormSheetRootProps) {
|
|
64
68
|
const styles = useStyles()
|
|
65
69
|
|
|
66
70
|
return (
|
|
67
|
-
<View style={styles.container} collapsable={false}>
|
|
71
|
+
<View style={[styles.container, style]} collapsable={false}>
|
|
68
72
|
<AndroidSheetGrabber />
|
|
69
|
-
<View style={styles.content}>{children}</View>
|
|
73
|
+
<View style={[styles.content, contentStyle]}>{children}</View>
|
|
70
74
|
</View>
|
|
71
75
|
)
|
|
72
76
|
}
|
|
@@ -5,7 +5,7 @@ import React, { useCallback } from 'react'
|
|
|
5
5
|
import { Alert, Platform, StyleSheet, View } from 'react-native'
|
|
6
6
|
import { Text } from '../components'
|
|
7
7
|
import { REACTION_EMOJIS, useReactionStyles } from '../components/conversation/message_reaction'
|
|
8
|
-
import { useTheme } from '../hooks'
|
|
8
|
+
import { useCreateAndroidRippleColor, useFontScale, useTheme } from '../hooks'
|
|
9
9
|
import { useApiClient } from '../hooks/use_api_client'
|
|
10
10
|
import { useConversationMessages } from '../hooks/use_conversation_messages'
|
|
11
11
|
import { useMessageReactionToggle } from '../hooks/use_message_reaction_toggle'
|
|
@@ -185,10 +185,15 @@ const Reaction = ({
|
|
|
185
185
|
const styles = useStyles()
|
|
186
186
|
const reactionStyles = useReactionStyles({ mine: reaction.mine ? 1 : 0 })
|
|
187
187
|
|
|
188
|
+
const { colors } = useTheme()
|
|
189
|
+
const baseRippleColor = reaction.mine ? colors.interaction : colors.fillColorNeutral060
|
|
190
|
+
const androidRippleColor = useCreateAndroidRippleColor({ color: baseRippleColor })
|
|
191
|
+
|
|
188
192
|
return (
|
|
189
193
|
<PlatformPressable
|
|
190
194
|
key={reaction.value}
|
|
191
195
|
style={[reactionStyles.reaction, styles.reaction]}
|
|
196
|
+
android_ripple={{ color: androidRippleColor, borderless: false, foreground: true }}
|
|
192
197
|
onPress={onPress}
|
|
193
198
|
>
|
|
194
199
|
<Text style={styles.reactionEmoji}>{REACTION_EMOJIS[reaction.value]}</Text>
|
|
@@ -198,9 +203,10 @@ const Reaction = ({
|
|
|
198
203
|
|
|
199
204
|
const useStyles = () => {
|
|
200
205
|
const { colors } = useTheme()
|
|
206
|
+
const fontScale = useFontScale({ maxFontSizeMultiplier: 1.3 })
|
|
201
207
|
|
|
202
208
|
const btnBorderWidth = 1
|
|
203
|
-
const baseSize = 44
|
|
209
|
+
const baseSize = 44 * fontScale
|
|
204
210
|
const reactionBtnSize = Platform.select({
|
|
205
211
|
ios: baseSize,
|
|
206
212
|
android: baseSize + btnBorderWidth * 2,
|
|
@@ -223,6 +229,7 @@ const useStyles = () => {
|
|
|
223
229
|
borderWidth: btnBorderWidth,
|
|
224
230
|
borderRadius: 32,
|
|
225
231
|
justifyContent: 'center',
|
|
232
|
+
overflow: 'hidden',
|
|
226
233
|
},
|
|
227
234
|
reactionEmoji: {
|
|
228
235
|
fontSize: 24,
|
|
@@ -1,24 +1,26 @@
|
|
|
1
1
|
import { StaticScreenProps } from '@react-navigation/native'
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
2
|
+
import React, { memo } from 'react'
|
|
3
|
+
import { Platform, StyleSheet, View } from 'react-native'
|
|
4
|
+
import { FlatList } from 'react-native-gesture-handler'
|
|
5
5
|
import { useSafeAreaInsets } from 'react-native-safe-area-context'
|
|
6
6
|
import { Avatar, Text } from '../components'
|
|
7
|
-
import { REACTION_EMOJIS
|
|
7
|
+
import { REACTION_EMOJIS } from '../components/conversation/message_reaction'
|
|
8
8
|
import { Tabs } from '../components/display/tabs'
|
|
9
9
|
import { useSuspenseGet, useTheme } from '../hooks'
|
|
10
10
|
import { useConversationMessages } from '../hooks/use_conversation_messages'
|
|
11
11
|
import { MemberResource } from '../types'
|
|
12
12
|
import { ReactionCountResource } from '../types/resources/reaction'
|
|
13
|
-
import {
|
|
13
|
+
import FormSheet, { getFormSheetScreenOptions } from '../components/primitive/form_sheet'
|
|
14
|
+
import { platformFontWeightMedium } from '../utils'
|
|
15
|
+
import { useFontScale } from '../hooks/use_font_scale'
|
|
14
16
|
|
|
15
|
-
export const ReactionsScreenOptions
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
17
|
+
export const ReactionsScreenOptions = getFormSheetScreenOptions({
|
|
18
|
+
sheetAllowedDetents: Platform.select({
|
|
19
|
+
android: [0.5, 0.94], // Going straight to full 0.94 preserves height of screen on Android
|
|
20
|
+
default: [0.5, 1],
|
|
21
|
+
}),
|
|
22
|
+
headerTitle: 'Reactions',
|
|
23
|
+
})
|
|
22
24
|
|
|
23
25
|
export type ReactionScreenProps = StaticScreenProps<{
|
|
24
26
|
message_id: string
|
|
@@ -60,7 +62,7 @@ export function ReactionsScreen({ route }: ReactionScreenProps) {
|
|
|
60
62
|
const authors = members.filter(member => authorIds.includes(member.id))
|
|
61
63
|
|
|
62
64
|
return (
|
|
63
|
-
<
|
|
65
|
+
<FormSheet.Root contentStyle={styles.formSheetContent}>
|
|
64
66
|
<Tabs
|
|
65
67
|
data={reactionCounts}
|
|
66
68
|
activeTab={reactionCount}
|
|
@@ -76,17 +78,13 @@ export function ReactionsScreen({ route }: ReactionScreenProps) {
|
|
|
76
78
|
)}
|
|
77
79
|
style={styles.actions}
|
|
78
80
|
/>
|
|
79
|
-
<
|
|
81
|
+
<FlatList
|
|
80
82
|
data={authors}
|
|
83
|
+
contentContainerStyle={styles.contentContainer}
|
|
81
84
|
keyExtractor={item => item.id.toString()}
|
|
82
|
-
renderItem={({ item: author }) =>
|
|
83
|
-
<View style={styles.authorList}>
|
|
84
|
-
<Avatar size={'md'} sourceUri={author.avatar} />
|
|
85
|
-
<Text key={author.id}>{author.name}</Text>
|
|
86
|
-
</View>
|
|
87
|
-
)}
|
|
85
|
+
renderItem={({ item: author }) => <Author author={author} key={author.id} />}
|
|
88
86
|
/>
|
|
89
|
-
</
|
|
87
|
+
</FormSheet.Root>
|
|
90
88
|
)
|
|
91
89
|
}
|
|
92
90
|
|
|
@@ -98,47 +96,67 @@ const Reaction = ({
|
|
|
98
96
|
onPress: () => void
|
|
99
97
|
}) => {
|
|
100
98
|
const styles = useStyles()
|
|
101
|
-
const reactionStyles = useReactionStyles({ mine: reaction.mine ? 1 : 0 })
|
|
102
99
|
|
|
103
100
|
return (
|
|
104
101
|
<View key={reaction.value} style={styles.reaction}>
|
|
105
|
-
<Text style={
|
|
106
|
-
<Text style={
|
|
102
|
+
<Text style={styles.reactionContent}>{REACTION_EMOJIS[reaction.value]}</Text>
|
|
103
|
+
<Text style={styles.reactionContent}>{reaction.count}</Text>
|
|
107
104
|
</View>
|
|
108
105
|
)
|
|
109
106
|
}
|
|
110
107
|
|
|
108
|
+
type AuthorProps = Pick<MemberResource, 'id' | 'name' | 'avatar'>
|
|
109
|
+
|
|
110
|
+
const Author = memo(({ author }: { author: AuthorProps }) => {
|
|
111
|
+
const styles = useStyles()
|
|
112
|
+
|
|
113
|
+
return (
|
|
114
|
+
<View style={styles.authorRow}>
|
|
115
|
+
<Avatar sourceUri={author.avatar} size="sm" />
|
|
116
|
+
<Text variant="tertiary" numberOfLines={2} style={styles.authorName}>
|
|
117
|
+
{author.name}
|
|
118
|
+
</Text>
|
|
119
|
+
</View>
|
|
120
|
+
)
|
|
121
|
+
})
|
|
122
|
+
|
|
111
123
|
const useStyles = () => {
|
|
112
|
-
const
|
|
113
|
-
const { height } = useWindowDimensions()
|
|
124
|
+
const { colors } = useTheme()
|
|
114
125
|
const { bottom } = useSafeAreaInsets()
|
|
126
|
+
const fontScale = useFontScale({ maxFontSizeMultiplier: 1.3 })
|
|
115
127
|
|
|
116
128
|
return StyleSheet.create({
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
height,
|
|
124
|
-
gap: 8,
|
|
129
|
+
formSheetContent: {
|
|
130
|
+
paddingTop: Platform.select({ android: 4, default: 16 }),
|
|
131
|
+
},
|
|
132
|
+
contentContainer: {
|
|
133
|
+
paddingTop: 8,
|
|
134
|
+
paddingBottom: bottom + Platform.select({ android: 24, default: 16 }),
|
|
125
135
|
},
|
|
126
|
-
|
|
136
|
+
authorRow: {
|
|
127
137
|
flexDirection: 'row',
|
|
128
138
|
alignItems: 'center',
|
|
129
139
|
gap: 8,
|
|
130
|
-
|
|
131
|
-
|
|
140
|
+
paddingVertical: 8,
|
|
141
|
+
paddingHorizontal: 16,
|
|
142
|
+
flex: 1,
|
|
143
|
+
},
|
|
144
|
+
authorName: {
|
|
145
|
+
flex: 1,
|
|
132
146
|
},
|
|
133
147
|
reaction: {
|
|
134
|
-
|
|
135
|
-
|
|
148
|
+
paddingHorizontal: 8,
|
|
149
|
+
paddingVertical: 16,
|
|
136
150
|
flexDirection: 'row',
|
|
137
151
|
gap: 4,
|
|
138
152
|
},
|
|
153
|
+
reactionContent: {
|
|
154
|
+
fontSize: 18,
|
|
155
|
+
fontWeight: platformFontWeightMedium,
|
|
156
|
+
},
|
|
139
157
|
actions: {
|
|
140
|
-
minHeight:
|
|
141
|
-
borderBottomColor:
|
|
158
|
+
minHeight: 68 * fontScale,
|
|
159
|
+
borderBottomColor: colors.borderColorDefaultBase,
|
|
142
160
|
borderBottomWidth: 1,
|
|
143
161
|
},
|
|
144
162
|
errorContainer: {
|