@planningcenter/chat-react-native 4.8.0-rc.11 → 4.8.0-rc.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,17 +1,20 @@
1
1
  import { c as _c } from "react/compiler-runtime";
2
2
  import React from 'react';
3
- import { StyleSheet } from 'react-native';
3
+ import { StyleSheet, View } from 'react-native';
4
4
  import { Pressable } from 'react-native-gesture-handler';
5
+ import Animated, { Extrapolation, interpolate, useAnimatedStyle } from 'react-native-reanimated';
5
6
  import { useCreateAndroidRippleColor, useTheme } from '../../hooks';
6
7
  import { Haptic } from '../../utils/native_adapters/configuration';
7
8
  import { MAX_FONT_SIZE_MULTIPLIER, platformFontWeightMedium, platformPressedOpacityStyle } from '../../utils/styles';
8
9
  import { tokens } from '../../vendor/tapestry/tokens';
9
10
  import { Icon, Spinner, Text } from '../display';
10
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
11
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
12
+ export const SWIPEABLE_TOGGLE_BUTTON_WIDTH = 120;
11
13
  export function SwipeableToggleButton(t0) {
12
- const $ = _c(35);
14
+ const $ = _c(39);
13
15
  let backgroundColor;
14
16
  let onPress;
17
+ let progress;
15
18
  let props;
16
19
  let t1;
17
20
  let t2;
@@ -21,6 +24,7 @@ export function SwipeableToggleButton(t0) {
21
24
  ({
22
25
  backgroundColor,
23
26
  onPress,
27
+ progress,
24
28
  toggleContent,
25
29
  disabled: t1,
26
30
  toggled,
@@ -30,124 +34,144 @@ export function SwipeableToggleButton(t0) {
30
34
  $[0] = t0;
31
35
  $[1] = backgroundColor;
32
36
  $[2] = onPress;
33
- $[3] = props;
34
- $[4] = t1;
35
- $[5] = t2;
36
- $[6] = toggleContent;
37
- $[7] = toggled;
37
+ $[3] = progress;
38
+ $[4] = props;
39
+ $[5] = t1;
40
+ $[6] = t2;
41
+ $[7] = toggleContent;
42
+ $[8] = toggled;
38
43
  } else {
39
44
  backgroundColor = $[1];
40
45
  onPress = $[2];
41
- props = $[3];
42
- t1 = $[4];
43
- t2 = $[5];
44
- toggleContent = $[6];
45
- toggled = $[7];
46
+ progress = $[3];
47
+ props = $[4];
48
+ t1 = $[5];
49
+ t2 = $[6];
50
+ toggleContent = $[7];
51
+ toggled = $[8];
46
52
  }
47
53
  const disabled = t1 === undefined ? false : t1;
48
54
  const loading = t2 === undefined ? false : t2;
49
55
  let t3;
50
- if ($[8] !== backgroundColor || $[9] !== disabled) {
56
+ if ($[9] !== backgroundColor || $[10] !== disabled) {
51
57
  t3 = {
52
58
  backgroundColor,
53
59
  disabled
54
60
  };
55
- $[8] = backgroundColor;
56
- $[9] = disabled;
57
- $[10] = t3;
61
+ $[9] = backgroundColor;
62
+ $[10] = disabled;
63
+ $[11] = t3;
58
64
  } else {
59
- t3 = $[10];
65
+ t3 = $[11];
60
66
  }
61
67
  const styles = useStyles(t3);
62
68
  let t4;
63
- if ($[11] !== backgroundColor) {
69
+ if ($[12] !== backgroundColor) {
64
70
  t4 = {
65
71
  color: backgroundColor
66
72
  };
67
- $[11] = backgroundColor;
68
- $[12] = t4;
73
+ $[12] = backgroundColor;
74
+ $[13] = t4;
69
75
  } else {
70
- t4 = $[12];
76
+ t4 = $[13];
71
77
  }
72
78
  const androidRippleColor = useCreateAndroidRippleColor(t4);
73
79
  const {
74
80
  iconName,
75
81
  label
76
82
  } = toggleContent[toggled ? "true" : "false"];
83
+ const iconStyle = useAnimatedStyle(() => ({
84
+ transform: [{
85
+ scale: interpolate(progress.value, [0, 1], [0.7, 1], Extrapolation.CLAMP)
86
+ }]
87
+ }));
88
+ const labelStyle = useAnimatedStyle(() => ({
89
+ opacity: interpolate(progress.value, [0.5, 1], [0, 1], Extrapolation.CLAMP)
90
+ }));
77
91
  let t5;
78
- if ($[13] !== onPress) {
92
+ if ($[14] !== onPress) {
79
93
  t5 = event => {
80
94
  Haptic.impactLight();
81
95
  onPress?.(event);
82
96
  };
83
- $[13] = onPress;
84
- $[14] = t5;
97
+ $[14] = onPress;
98
+ $[15] = t5;
85
99
  } else {
86
- t5 = $[14];
100
+ t5 = $[15];
87
101
  }
88
102
  let t6;
89
- if ($[15] !== styles.button) {
103
+ if ($[16] !== styles.button) {
90
104
  t6 = t7 => {
91
105
  const {
92
106
  pressed
93
107
  } = t7;
94
108
  return [styles.button, pressed && platformPressedOpacityStyle];
95
109
  };
96
- $[15] = styles.button;
97
- $[16] = t6;
110
+ $[16] = styles.button;
111
+ $[17] = t6;
98
112
  } else {
99
- t6 = $[16];
113
+ t6 = $[17];
100
114
  }
101
115
  let t7;
102
- if ($[17] !== androidRippleColor) {
116
+ if ($[18] !== androidRippleColor) {
103
117
  t7 = {
104
118
  color: androidRippleColor,
105
119
  borderless: false,
106
120
  foreground: true
107
121
  };
108
- $[17] = androidRippleColor;
109
- $[18] = t7;
122
+ $[18] = androidRippleColor;
123
+ $[19] = t7;
110
124
  } else {
111
- t7 = $[18];
125
+ t7 = $[19];
112
126
  }
113
127
  const t8 = disabled || loading;
114
128
  let t9;
115
- if ($[19] !== toggled) {
129
+ if ($[20] !== toggled) {
116
130
  t9 = {
117
131
  checked: toggled
118
132
  };
119
- $[19] = toggled;
120
- $[20] = t9;
133
+ $[20] = toggled;
134
+ $[21] = t9;
121
135
  } else {
122
- t9 = $[20];
136
+ t9 = $[21];
123
137
  }
124
138
  let t10;
125
- if ($[21] !== iconName || $[22] !== label || $[23] !== loading || $[24] !== styles.icon || $[25] !== styles.text) {
139
+ if ($[22] !== iconName || $[23] !== iconStyle || $[24] !== label || $[25] !== labelStyle || $[26] !== loading || $[27] !== styles.content || $[28] !== styles.icon || $[29] !== styles.text) {
126
140
  t10 = loading ? /*#__PURE__*/_jsx(Spinner, {
127
141
  size: 20
128
- }) : /*#__PURE__*/_jsxs(_Fragment, {
129
- children: [/*#__PURE__*/_jsx(Icon, {
130
- name: iconName,
131
- style: styles.icon,
132
- maxFontSizeMultiplier: MAX_FONT_SIZE_MULTIPLIER
133
- }), /*#__PURE__*/_jsx(Text, {
134
- variant: "footnote",
135
- style: styles.text,
136
- maxFontSizeMultiplier: MAX_FONT_SIZE_MULTIPLIER,
137
- children: label
142
+ }) : /*#__PURE__*/_jsxs(View, {
143
+ style: styles.content,
144
+ children: [/*#__PURE__*/_jsx(Animated.View, {
145
+ style: iconStyle,
146
+ children: /*#__PURE__*/_jsx(Icon, {
147
+ name: iconName,
148
+ style: styles.icon,
149
+ maxFontSizeMultiplier: MAX_FONT_SIZE_MULTIPLIER
150
+ })
151
+ }), /*#__PURE__*/_jsx(Animated.View, {
152
+ style: labelStyle,
153
+ children: /*#__PURE__*/_jsx(Text, {
154
+ variant: "footnote",
155
+ style: styles.text,
156
+ maxFontSizeMultiplier: MAX_FONT_SIZE_MULTIPLIER,
157
+ children: label
158
+ })
138
159
  })]
139
160
  });
140
- $[21] = iconName;
141
- $[22] = label;
142
- $[23] = loading;
143
- $[24] = styles.icon;
144
- $[25] = styles.text;
145
- $[26] = t10;
161
+ $[22] = iconName;
162
+ $[23] = iconStyle;
163
+ $[24] = label;
164
+ $[25] = labelStyle;
165
+ $[26] = loading;
166
+ $[27] = styles.content;
167
+ $[28] = styles.icon;
168
+ $[29] = styles.text;
169
+ $[30] = t10;
146
170
  } else {
147
- t10 = $[26];
171
+ t10 = $[30];
148
172
  }
149
173
  let t11;
150
- if ($[27] !== props || $[28] !== t10 || $[29] !== t5 || $[30] !== t6 || $[31] !== t7 || $[32] !== t8 || $[33] !== t9) {
174
+ if ($[31] !== props || $[32] !== t10 || $[33] !== t5 || $[34] !== t6 || $[35] !== t7 || $[36] !== t8 || $[37] !== t9) {
151
175
  t11 = /*#__PURE__*/_jsx(Pressable, {
152
176
  onPress: t5,
153
177
  style: t6,
@@ -158,16 +182,16 @@ export function SwipeableToggleButton(t0) {
158
182
  ...props,
159
183
  children: t10
160
184
  });
161
- $[27] = props;
162
- $[28] = t10;
163
- $[29] = t5;
164
- $[30] = t6;
165
- $[31] = t7;
166
- $[32] = t8;
167
- $[33] = t9;
168
- $[34] = t11;
185
+ $[31] = props;
186
+ $[32] = t10;
187
+ $[33] = t5;
188
+ $[34] = t6;
189
+ $[35] = t7;
190
+ $[36] = t8;
191
+ $[37] = t9;
192
+ $[38] = t11;
169
193
  } else {
170
- t11 = $[34];
194
+ t11 = $[38];
171
195
  }
172
196
  return t11;
173
197
  }
@@ -190,10 +214,15 @@ const useStyles = t0 => {
190
214
  flexDirection: "column",
191
215
  alignItems: "center",
192
216
  justifyContent: "center",
193
- gap: 4,
194
217
  height: "100%",
218
+ overflow: "hidden",
195
219
  backgroundColor: buttonBackgroundColor
196
220
  },
221
+ content: {
222
+ width: SWIPEABLE_TOGGLE_BUTTON_WIDTH,
223
+ alignItems: "center",
224
+ gap: 4
225
+ },
197
226
  icon: {
198
227
  fontSize: 20,
199
228
  color: fillColor,
@@ -1 +1 @@
1
- {"version":3,"file":"swipeable_toggle_button.js","names":["React","StyleSheet","Pressable","useCreateAndroidRippleColor","useTheme","Haptic","MAX_FONT_SIZE_MULTIPLIER","platformFontWeightMedium","platformPressedOpacityStyle","tokens","Icon","Spinner","Text","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","SwipeableToggleButton","t0","$","_c","backgroundColor","onPress","props","t1","t2","toggleContent","toggled","disabled","loading","undefined","t3","styles","useStyles","t4","color","androidRippleColor","iconName","label","t5","event","impactLight","t6","button","t7","pressed","borderless","foreground","t8","t9","checked","t10","icon","text","size","children","style","variant","t11","android_ripple","accessibilityRole","accessibilityState","colors","fillColor","textColorDefaultDisabled","colorNeutral100White","buttonBackgroundColor","fillColorButtonNeutralSolidDisabled","create","flex","flexDirection","alignItems","justifyContent","gap","height","fontSize","marginTop","fontWeight","textAlign","paddingHorizontal"],"sources":["../../../src/components/conversations/swipeable_toggle_button.tsx"],"sourcesContent":["import React from 'react'\nimport { StyleSheet } from 'react-native'\nimport { Pressable, type PressableProps } from 'react-native-gesture-handler'\nimport { useCreateAndroidRippleColor, useTheme } from '../../hooks'\nimport { Haptic } from '../../utils/native_adapters/configuration'\nimport {\n MAX_FONT_SIZE_MULTIPLIER,\n platformFontWeightMedium,\n platformPressedOpacityStyle,\n} from '../../utils/styles'\nimport { tokens } from '../../vendor/tapestry/tokens'\nimport { Icon, IconString, Spinner, Text } from '../display'\n\ninterface SwipeableToggleButtonProps extends PressableProps {\n backgroundColor: string\n toggled: boolean\n toggleContent: {\n true: { iconName: IconString; label: string }\n false: { iconName: IconString; label: string }\n }\n loading?: boolean\n}\n\nexport function SwipeableToggleButton({\n backgroundColor,\n onPress,\n toggleContent,\n disabled = false,\n toggled,\n loading = false,\n ...props\n}: SwipeableToggleButtonProps) {\n const styles = useStyles({ backgroundColor, disabled })\n const androidRippleColor = useCreateAndroidRippleColor({\n color: backgroundColor,\n })\n\n const { iconName, label } = toggleContent[toggled ? 'true' : 'false']\n\n return (\n <Pressable\n onPress={event => {\n Haptic.impactLight()\n onPress?.(event)\n }}\n style={({ pressed }) => [styles.button, pressed && platformPressedOpacityStyle]}\n android_ripple={{ color: androidRippleColor, borderless: false, foreground: true }}\n disabled={disabled || loading}\n accessibilityRole=\"togglebutton\"\n accessibilityState={{ checked: toggled }}\n {...props}\n >\n {loading ? (\n <Spinner size={20} />\n ) : (\n <>\n <Icon\n name={iconName}\n style={styles.icon}\n maxFontSizeMultiplier={MAX_FONT_SIZE_MULTIPLIER}\n />\n <Text\n variant=\"footnote\"\n style={styles.text}\n maxFontSizeMultiplier={MAX_FONT_SIZE_MULTIPLIER}\n >\n {label}\n </Text>\n </>\n )}\n </Pressable>\n )\n}\n\nconst useStyles = ({ backgroundColor, disabled }: Partial<SwipeableToggleButtonProps>) => {\n const { colors } = useTheme()\n const fillColor = disabled ? colors.textColorDefaultDisabled : tokens.colorNeutral100White\n const buttonBackgroundColor = disabled\n ? colors.fillColorButtonNeutralSolidDisabled\n : backgroundColor\n\n return StyleSheet.create({\n button: {\n flex: 1,\n flexDirection: 'column',\n alignItems: 'center',\n justifyContent: 'center',\n gap: 4,\n height: '100%',\n backgroundColor: buttonBackgroundColor,\n },\n icon: {\n fontSize: 20,\n color: fillColor,\n marginTop: 4,\n },\n text: {\n color: fillColor,\n fontWeight: platformFontWeightMedium,\n textAlign: 'center',\n paddingHorizontal: 8,\n },\n })\n}\n"],"mappings":";AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,UAAU,QAAQ,cAAc;AACzC,SAASC,SAAS,QAA6B,8BAA8B;AAC7E,SAASC,2BAA2B,EAAEC,QAAQ,QAAQ,aAAa;AACnE,SAASC,MAAM,QAAQ,2CAA2C;AAClE,SACEC,wBAAwB,EACxBC,wBAAwB,EACxBC,2BAA2B,QACtB,oBAAoB;AAC3B,SAASC,MAAM,QAAQ,8BAA8B;AACrD,SAASC,IAAI,EAAcC,OAAO,EAAEC,IAAI,QAAQ,YAAY;AAAA,SAAAC,GAAA,IAAAC,IAAA,EAAAC,QAAA,IAAAC,SAAA,EAAAC,IAAA,IAAAC,KAAA;AAY5D,OAAO,SAAAC,sBAAAC,EAAA;EAAA,MAAAC,CAAA,GAAAC,EAAA;EAAA,IAAAC,eAAA;EAAA,IAAAC,OAAA;EAAA,IAAAC,KAAA;EAAA,IAAAC,EAAA;EAAA,IAAAC,EAAA;EAAA,IAAAC,aAAA;EAAA,IAAAC,OAAA;EAAA,IAAAR,CAAA,QAAAD,EAAA;IAA+B;MAAAG,eAAA;MAAAC,OAAA;MAAAI,aAAA;MAAAE,QAAA,EAAAJ,EAAA;MAAAG,OAAA;MAAAE,OAAA,EAAAJ,EAAA;MAAA,GAAAF;IAAA,IAAAL,EAQT;IAAAC,CAAA,MAAAD,EAAA;IAAAC,CAAA,MAAAE,eAAA;IAAAF,CAAA,MAAAG,OAAA;IAAAH,CAAA,MAAAI,KAAA;IAAAJ,CAAA,MAAAK,EAAA;IAAAL,CAAA,MAAAM,EAAA;IAAAN,CAAA,MAAAO,aAAA;IAAAP,CAAA,MAAAQ,OAAA;EAAA;IAAAN,e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apolation","interpolate","useAnimatedStyle","useCreateAndroidRippleColor","useTheme","Haptic","MAX_FONT_SIZE_MULTIPLIER","platformFontWeightMedium","platformPressedOpacityStyle","tokens","Icon","Spinner","Text","jsx","_jsx","jsxs","_jsxs","SWIPEABLE_TOGGLE_BUTTON_WIDTH","SwipeableToggleButton","t0","$","_c","backgroundColor","onPress","progress","props","t1","t2","toggleContent","toggled","disabled","loading","undefined","t3","styles","useStyles","t4","color","androidRippleColor","iconName","label","iconStyle","transform","scale","value","CLAMP","labelStyle","opacity","t5","event","impactLight","t6","button","t7","pressed","borderless","foreground","t8","t9","checked","t10","content","icon","text","size","style","children","variant","t11","android_ripple","accessibilityRole","accessibilityState","colors","fillColor","textColorDefaultDisabled","colorNeutral100White","buttonBackgroundColor","fillColorButtonNeutralSolidDisabled","create","flex","flexDirection","alignItems","justifyContent","height","overflow","width","gap","fontSize","marginTop","fontWeight","textAlign","paddingHorizontal"],"sources":["../../../src/components/conversations/swipeable_toggle_button.tsx"],"sourcesContent":["import React from 'react'\nimport { StyleSheet, View } from 'react-native'\nimport { Pressable, type PressableProps } from 'react-native-gesture-handler'\nimport Animated, {\n Extrapolation,\n SharedValue,\n interpolate,\n useAnimatedStyle,\n} from 'react-native-reanimated'\nimport { useCreateAndroidRippleColor, useTheme } from '../../hooks'\nimport { Haptic } from '../../utils/native_adapters/configuration'\nimport {\n MAX_FONT_SIZE_MULTIPLIER,\n platformFontWeightMedium,\n platformPressedOpacityStyle,\n} from '../../utils/styles'\nimport { tokens } from '../../vendor/tapestry/tokens'\nimport { Icon, IconString, Spinner, Text } from '../display'\n\nexport const SWIPEABLE_TOGGLE_BUTTON_WIDTH = 120\n\ninterface SwipeableToggleButtonProps extends PressableProps {\n backgroundColor: string\n /** How far the swipe is open, 0 (closed) to 1 (fully open). */\n progress: SharedValue<number>\n toggled: boolean\n toggleContent: {\n true: { iconName: IconString; label: string }\n false: { iconName: IconString; label: string }\n }\n loading?: boolean\n}\n\nexport function SwipeableToggleButton({\n backgroundColor,\n onPress,\n progress,\n toggleContent,\n disabled = false,\n toggled,\n loading = false,\n ...props\n}: SwipeableToggleButtonProps) {\n const styles = useStyles({ backgroundColor, disabled })\n const androidRippleColor = useCreateAndroidRippleColor({\n color: backgroundColor,\n })\n\n const { iconName, label } = toggleContent[toggled ? 'true' : 'false']\n\n const iconStyle = useAnimatedStyle(() => ({\n transform: [{ scale: interpolate(progress.value, [0, 1], [0.7, 1], Extrapolation.CLAMP) }],\n }))\n const labelStyle = useAnimatedStyle(() => ({\n opacity: interpolate(progress.value, [0.5, 1], [0, 1], Extrapolation.CLAMP),\n }))\n\n return (\n <Pressable\n onPress={event => {\n Haptic.impactLight()\n onPress?.(event)\n }}\n style={({ pressed }) => [styles.button, pressed && platformPressedOpacityStyle]}\n android_ripple={{ color: androidRippleColor, borderless: false, foreground: true }}\n disabled={disabled || loading}\n accessibilityRole=\"togglebutton\"\n accessibilityState={{ checked: toggled }}\n {...props}\n >\n {loading ? (\n <Spinner size={20} />\n ) : (\n <View style={styles.content}>\n <Animated.View style={iconStyle}>\n <Icon\n name={iconName}\n style={styles.icon}\n maxFontSizeMultiplier={MAX_FONT_SIZE_MULTIPLIER}\n />\n </Animated.View>\n <Animated.View style={labelStyle}>\n <Text\n variant=\"footnote\"\n style={styles.text}\n maxFontSizeMultiplier={MAX_FONT_SIZE_MULTIPLIER}\n >\n {label}\n </Text>\n </Animated.View>\n </View>\n )}\n </Pressable>\n )\n}\n\nconst useStyles = ({ backgroundColor, disabled }: Partial<SwipeableToggleButtonProps>) => {\n const { colors } = useTheme()\n const fillColor = disabled ? colors.textColorDefaultDisabled : tokens.colorNeutral100White\n const buttonBackgroundColor = disabled\n ? colors.fillColorButtonNeutralSolidDisabled\n : backgroundColor\n\n return StyleSheet.create({\n button: {\n flex: 1,\n flexDirection: 'column',\n alignItems: 'center',\n justifyContent: 'center',\n height: '100%',\n overflow: 'hidden',\n backgroundColor: buttonBackgroundColor,\n },\n // Laid out at the fully open width and clipped by the button, so the icon and label stay\n // centered and never reflow while the button is narrower than that.\n content: {\n width: SWIPEABLE_TOGGLE_BUTTON_WIDTH,\n alignItems: 'center',\n gap: 4,\n },\n icon: {\n fontSize: 20,\n color: fillColor,\n marginTop: 4,\n },\n text: {\n color: fillColor,\n fontWeight: platformFontWeightMedium,\n textAlign: 'center',\n paddingHorizontal: 8,\n },\n })\n}\n"],"mappings":";AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,UAAU,EAAEC,IAAI,QAAQ,cAAc;AAC/C,SAASC,SAAS,QAA6B,8BAA8B;AAC7E,OAAOC,QAAQ,IACbC,aAAa,EAEbC,WAAW,EACXC,gBAAgB,QACX,yBAAyB;AAChC,SAASC,2BAA2B,EAAEC,QAAQ,QAAQ,aAAa;AACnE,SAASC,MAAM,QAAQ,2CAA2C;AAClE,SACEC,wBAAwB,EACxBC,wBAAwB,EACxBC,2BAA2B,QACtB,oBAAoB;AAC3B,SAASC,MAAM,QAAQ,8BAA8B;AACrD,SAASC,IAAI,EAAcC,OAAO,EAAEC,IAAI,QAAQ,YAAY;AAAA,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAE5D,OAAO,MAAMC,6BAA6B,GAAG,GAAG;AAchD,OAAO,SAAAC,sBAAAC,EAAA;EAAA,MAAAC,CAAA,GAAAC,EAAA;EAAA,IAAAC,eAAA;EAAA,IAAAC,OAAA;EAAA,IAAAC,QAAA;EAAA,IAAAC,KAAA;EAAA,IAAAC,EAAA;EAAA,IAAAC,EAAA;EAAA,IAAAC,aAAA;EAAA,IAAAC,OAAA;EAAA,IAAAT,CAAA,QAAAD,EAAA;IAA+B;MAAAG,eAAA;MAAAC,OAAA;MAAAC,QAAA;MAAAI,aAAA;MAAAE,QAAA,EAAAJ,EAAA;MAAAG,OAAA;MAAAE,OAAA,EAAAJ,EAAA;MAAA,GAAAF;IAAA,IAAAN,EAST;IAAAC,CAAA,MAAAD,EAAA;IAAAC,CAAA,MAAAE,eA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ED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@planningcenter/chat-react-native",
3
- "version": "4.8.0-rc.11",
3
+ "version": "4.8.0-rc.13",
4
4
  "description": "",
5
5
  "repository": {
6
6
  "type": "git",
@@ -84,5 +84,5 @@
84
84
  "sf-symbols-typescript": "^2.2.0",
85
85
  "typescript": "~6.0.3"
86
86
  },
87
- "gitHead": "de07677a557e9387ac63a96fed82e54bf2b9f6c9"
87
+ "gitHead": "c38690ba884c1b6838c33e0629a7d5fee96c9616"
88
88
  }
@@ -2,6 +2,7 @@ import { DefaultTheme, ThemeProvider } from '@react-navigation/native'
2
2
  import { QueryClientProvider, notifyManager } from '@tanstack/react-query'
3
3
  import { act, fireEvent, render, screen } from '@testing-library/react-native'
4
4
  import React from 'react'
5
+ import { TextInput } from 'react-native'
5
6
  import { chatQueryClient } from '../../../contexts/api_provider'
6
7
  import type { ConversationResource } from '../../../types'
7
8
  import { MessageForm } from '../message_form'
@@ -60,7 +61,7 @@ describe('MessageForm', () => {
60
61
  await act(async () => finishSend({ data: { type: 'Message', id: 'sent', mine: true } }))
61
62
  })
62
63
 
63
- it('keeps the input editable while a sent message is in flight', async () => {
64
+ function renderForm() {
64
65
  render(
65
66
  <QueryClientProvider client={chatQueryClient}>
66
67
  <ThemeProvider value={DefaultTheme}>
@@ -71,13 +72,29 @@ describe('MessageForm', () => {
71
72
  </ThemeProvider>
72
73
  </QueryClientProvider>
73
74
  )
75
+ }
74
76
 
75
- fireEvent.changeText(screen.getByTestId('message-composer-input'), 'hello')
77
+ async function sendMessage(text: string) {
78
+ fireEvent.changeText(screen.getByTestId('message-composer-input'), text)
76
79
  await act(async () => {
77
80
  fireEvent.press(screen.getByLabelText('Send message'))
78
81
  })
82
+ }
83
+
84
+ it('keeps the input editable while a sent message is in flight', async () => {
85
+ renderForm()
86
+ await sendMessage('hello')
79
87
 
80
88
  expect(mockPost).toHaveBeenCalled()
81
89
  expect(screen.getByTestId('message-composer-input').props.editable).toBe(true)
82
90
  })
91
+
92
+ it('clears the native input after sending so iOS resizes the composer', async () => {
93
+ const clear = jest.spyOn(TextInput.prototype, 'clear')
94
+ renderForm()
95
+ await sendMessage('a message long enough to wrap onto more than one line in the composer')
96
+
97
+ expect(clear).toHaveBeenCalled()
98
+ expect(screen.getByTestId('message-composer-input').props.value).toBe('')
99
+ })
83
100
  })
@@ -89,6 +89,7 @@ const MessageFormContext = React.createContext<{
89
89
  reset: () => void
90
90
  replyRootId?: string | null
91
91
  replyRootAuthorFirstName?: string | null
92
+ inputRef?: React.RefObject<TextInput | null>
92
93
  }>({
93
94
  text: '',
94
95
  setText: (_text: string) => {},
@@ -144,10 +145,12 @@ function MessageFormRoot({
144
145
  onFlaggedInMessageForm,
145
146
  })
146
147
  const resetAttachmentUploader = attachmentUploader.reset
148
+ const inputRef = useRef<TextInput>(null)
147
149
 
148
150
  const reset = useCallback(() => {
149
151
  resetAttachmentUploader()
150
152
  resetMutation()
153
+ inputRef.current?.clear()
151
154
  setText('')
152
155
  setUsingGiphy(false)
153
156
  if (!currentlyEditingMessage) {
@@ -306,6 +309,7 @@ function MessageFormRoot({
306
309
  reset,
307
310
  replyRootId,
308
311
  replyRootAuthorFirstName,
312
+ inputRef,
309
313
  }}
310
314
  >
311
315
  <View style={styles.container}>
@@ -457,8 +461,16 @@ function MessageFormInput() {
457
461
  const styles = useMessageFormStyles()
458
462
  const theme = useTheme()
459
463
  const fontScale = useFontScale()
460
- const { text, setText, onSubmit, inputEditable, usingGiphy, attachmentUploader, replyRootId } =
461
- React.useContext(MessageFormContext)
464
+ const {
465
+ text,
466
+ setText,
467
+ onSubmit,
468
+ inputEditable,
469
+ usingGiphy,
470
+ attachmentUploader,
471
+ replyRootId,
472
+ inputRef,
473
+ } = React.useContext(MessageFormContext)
462
474
  const attachmentError = attachmentUploader?.errorMessage
463
475
 
464
476
  const broadcastTypingStatus = useBroadcastTypingStatus()
@@ -495,6 +507,7 @@ function MessageFormInput() {
495
507
  ) : null}
496
508
 
497
509
  <TextInput
510
+ ref={inputRef}
498
511
  testID="message-composer-input"
499
512
  style={[styles.textInput, usingGiphy && styles.textInputWithGiphy]}
500
513
  multiline={true}
@@ -13,10 +13,13 @@ jest.mock('react-native-gesture-handler/ReanimatedSwipeable', () => {
13
13
  renderLeftActions,
14
14
  }: {
15
15
  children: React.ReactNode
16
- renderLeftActions: () => React.ReactNode
16
+ renderLeftActions: (
17
+ progress: { value: number },
18
+ translation: { value: number }
19
+ ) => React.ReactNode
17
20
  }) => (
18
21
  <MockView>
19
- {renderLeftActions()}
22
+ {renderLeftActions({ value: 1 }, { value: 360 })}
20
23
  {children}
21
24
  </MockView>
22
25
  ),
@@ -12,6 +12,7 @@ import {
12
12
  import ReanimatedSwipeable, {
13
13
  SwipeableMethods,
14
14
  } from 'react-native-gesture-handler/ReanimatedSwipeable'
15
+ import Animated, { SharedValue, useAnimatedStyle } from 'react-native-reanimated'
15
16
  import { useConversationsContext } from '../../contexts/conversations_context'
16
17
  import { useTheme, useCreateAndroidRippleColor } from '../../hooks'
17
18
  import {
@@ -24,7 +25,7 @@ import { ConversationResource } from '../../types'
24
25
  import { isArchivedConversation, platformPressedOpacityStyle } from '../../utils'
25
26
  import { Haptic } from '../../utils/native_adapters'
26
27
  import { tokens } from '../../vendor/tapestry/tokens'
27
- import { SwipeableToggleButton } from './swipeable_toggle_button'
28
+ import { SWIPEABLE_TOGGLE_BUTTON_WIDTH, SwipeableToggleButton } from './swipeable_toggle_button'
28
29
 
29
30
  export function ConversationActions({
30
31
  children,
@@ -186,8 +187,10 @@ export function ConversationActions({
186
187
  onSwipeableOpenStartDrag={handleSwipeableOpen}
187
188
  onSwipeableClose={() => setDisabled(false)}
188
189
  renderRightActions={() => <></>}
189
- renderLeftActions={() => (
190
+ renderLeftActions={(progress, translation) => (
190
191
  <LeftActions
192
+ progress={progress}
193
+ translation={translation}
191
194
  isConversationEmpty={isConversationEmpty}
192
195
  canMute={canMute}
193
196
  canHide={canHide}
@@ -222,6 +225,8 @@ export function ConversationActions({
222
225
  }
223
226
 
224
227
  interface LeftActionsProps {
228
+ progress: SharedValue<number>
229
+ translation: SharedValue<number>
225
230
  isConversationEmpty: boolean
226
231
  canMute: boolean
227
232
  canHide: boolean
@@ -237,6 +242,8 @@ interface LeftActionsProps {
237
242
  }
238
243
 
239
244
  function LeftActions({
245
+ progress,
246
+ translation,
240
247
  isConversationEmpty,
241
248
  canMute,
242
249
  canHide,
@@ -251,6 +258,9 @@ function LeftActions({
251
258
  isMarkReadPending,
252
259
  }: LeftActionsProps) {
253
260
  const styles = useStyles({ actionButtonCount: 1 + Number(canMute) + Number(canHide) })
261
+ // The buttons split whatever the drag has uncovered, so every action is on screen from the
262
+ // first few points and grows with the drag, instead of the last one waiting for a full open.
263
+ const revealStyle = useAnimatedStyle(() => ({ width: Math.max(translation.value, 0) }))
254
264
 
255
265
  const muteToggleContent = {
256
266
  true: { iconName: 'general.bell', label: 'Enable' },
@@ -269,38 +279,41 @@ function LeftActions({
269
279
 
270
280
  return (
271
281
  <View style={styles.actionButtonContainer}>
272
- <SwipeableToggleButton
273
- loading={isMarkReadPending}
274
- disabled={isConversationEmpty}
275
- toggled={!read}
276
- onPress={handleLatestMessageUnread}
277
- toggleContent={latestMessageUnreadToggleContent}
278
- backgroundColor={tokens.fillColorInteractionSwipeDefault}
279
- />
280
- {canMute && (
282
+ <Animated.View style={[styles.actionButtonReveal, revealStyle]}>
281
283
  <SwipeableToggleButton
282
- loading={isMutedPending}
283
- toggled={muted}
284
- onPress={handleMute}
285
- toggleContent={muteToggleContent}
286
- backgroundColor={tokens.fillColorInteractionSwipeSecondary}
284
+ progress={progress}
285
+ loading={isMarkReadPending}
286
+ disabled={isConversationEmpty}
287
+ toggled={!read}
288
+ onPress={handleLatestMessageUnread}
289
+ toggleContent={latestMessageUnreadToggleContent}
290
+ backgroundColor={tokens.fillColorInteractionSwipeDefault}
287
291
  />
288
- )}
289
- {canHide && (
290
- <SwipeableToggleButton
291
- loading={isHiddenPending}
292
- toggled={hidden}
293
- onPress={handleHide}
294
- toggleContent={hideToggleContent}
295
- backgroundColor={tokens.colorNeutral45}
296
- />
297
- )}
292
+ {canMute && (
293
+ <SwipeableToggleButton
294
+ progress={progress}
295
+ loading={isMutedPending}
296
+ toggled={muted}
297
+ onPress={handleMute}
298
+ toggleContent={muteToggleContent}
299
+ backgroundColor={tokens.fillColorInteractionSwipeSecondary}
300
+ />
301
+ )}
302
+ {canHide && (
303
+ <SwipeableToggleButton
304
+ progress={progress}
305
+ loading={isHiddenPending}
306
+ toggled={hidden}
307
+ onPress={handleHide}
308
+ toggleContent={hideToggleContent}
309
+ backgroundColor={tokens.colorNeutral45}
310
+ />
311
+ )}
312
+ </Animated.View>
298
313
  </View>
299
314
  )
300
315
  }
301
316
 
302
- const ACTION_BUTTON_WIDTH = 120
303
-
304
317
  const useStyles = ({ actionButtonCount = 2 }: { actionButtonCount?: number } = {}) => {
305
318
  const { colors } = useTheme()
306
319
  return StyleSheet.create({
@@ -308,10 +321,13 @@ const useStyles = ({ actionButtonCount = 2 }: { actionButtonCount?: number } = {
308
321
  backgroundColor: colors.conversationActionsBackground,
309
322
  },
310
323
  actionButtonContainer: {
324
+ // Fixed at the fully open width: the swipeable measures this to find its snap point.
325
+ width: SWIPEABLE_TOGGLE_BUTTON_WIDTH * actionButtonCount,
326
+ height: '100%',
327
+ },
328
+ actionButtonReveal: {
311
329
  flexDirection: 'row',
312
- alignItems: 'center',
313
- width: ACTION_BUTTON_WIDTH * actionButtonCount,
314
- alignContent: 'stretch',
330
+ height: '100%',
315
331
  },
316
332
  swipeableContainer: {
317
333
  backgroundColor: colors.surfaceColor090,