Skip to content

Commit 164e3b6

Browse files
committed
💫 Update: Ex - Test03Screen
1 parent 2148506 commit 164e3b6

File tree

3 files changed

+66
-20
lines changed

3 files changed

+66
-20
lines changed

example/src/constants/ExampleCardItems.ts

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ export type ExampleListItem = {
9898

9999
export const EXAMPLE_ITEMS: Array<ExampleItem> = (() => {
100100

101-
const screenItems: Array<ExampleItemRoute> = [
101+
const screenItemsPre: Array<ExampleItemRoute> = [
102102
{
103103
type: 'screen',
104104
...ROUTE_MAP.contextMenuTest01,
@@ -361,6 +361,36 @@ export const EXAMPLE_ITEMS: Array<ExampleItem> = (() => {
361361
},
362362
];
363363

364+
const screenItemsPost: Array<ExampleItemRoute> = [
365+
{
366+
type: 'screen',
367+
...ROUTE_MAP.test01Screen,
368+
},
369+
{
370+
type: 'screen',
371+
...ROUTE_MAP.test02Screen,
372+
},{
373+
type: 'screen',
374+
...ROUTE_MAP.test03Screen,
375+
},
376+
{
377+
type: 'screen',
378+
...ROUTE_MAP.test04Screen,
379+
},
380+
{
381+
type: 'screen',
382+
...ROUTE_MAP.test05Screen,
383+
},
384+
{
385+
type: 'screen',
386+
...ROUTE_MAP.test06Screen,
387+
},
388+
{
389+
type: 'screen',
390+
...ROUTE_MAP.test07Screen,
391+
},
392+
];
393+
364394
// if (SHARED_ENV.enableReactNavigation) {
365395
// items.splice(0, 0, ...[DebugControls]);
366396
// }
@@ -370,7 +400,8 @@ export const EXAMPLE_ITEMS: Array<ExampleItem> = (() => {
370400
type: 'card',
371401
component: AppMetadataCard,
372402
},
373-
...screenItems,
374-
...cardItems
403+
...screenItemsPre,
404+
...cardItems,
405+
...screenItemsPost,
375406
];
376407
})();

example/src/screens/Test03Screen.tsx

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { type AuxiliaryPreviewConfig, ContextMenuView, type MenuElementConfig, t
77

88

99
const SHOULD_USE_NEW_CONFIG = true;
10+
const MESSAGE_BUBBLE_BORDER_RADIUS = 10;
1011

1112
// Repro for issue:
1213
// https://github.com/dominicstop/react-native-ios-context-menu/issues/47
@@ -283,7 +284,7 @@ const MessageBubble = (props: {
283284

284285
const hasReaction = (currentReaction != null);
285286

286-
const menuRef = React.useRef<ContextMenuView | undefined>();
287+
const menuRef = React.useRef<ContextMenuView | null>();
287288

288289
const animatedReactionOpacity =
289290
React.useRef(new Animated.Value(0)).current;
@@ -315,7 +316,6 @@ const MessageBubble = (props: {
315316
};
316317

317318
const startCollapse = () => {
318-
319319
return Promise.all([
320320
new Promise(resolve => {
321321
Animated.timing(animatedMessageContainerMarginTop, {
@@ -347,7 +347,7 @@ const MessageBubble = (props: {
347347
</Animated.View>
348348
);
349349

350-
const AuxPreviewConfig: AuxiliaryPreviewConfigBackwardsCompatible = (SHOULD_USE_NEW_CONFIG ? {
350+
const auxPreviewConfig: AuxiliaryPreviewConfigBackwardsCompatible = (SHOULD_USE_NEW_CONFIG ? {
351351
verticalAnchorPosition: 'automatic',
352352
horizontalAlignment: (props.message.isSender
353353
? 'targetTrailing'
@@ -386,13 +386,10 @@ const MessageBubble = (props: {
386386
}]}>
387387
{(hasReaction && props.message.isSender) && reactionIndicator}
388388
<ContextMenuView
389-
ref={menuRef}
390-
style={[styles.messageBubbleContainer, {
391-
backgroundColor: (props.message.isSender
392-
? Colors.PURPLE[100]
393-
: Colors.ORANGE[100]
394-
),
395-
}]}
389+
ref={ref => menuRef.current = ref}
390+
style={[
391+
styles.messageBubbleContainer
392+
]}
396393
lazyPreview={true}
397394
menuConfig={{
398395
menuTitle: '',
@@ -403,7 +400,10 @@ const MessageBubble = (props: {
403400
MENU_CONFIGS.delete,
404401
],
405402
}}
406-
auxiliaryPreviewConfig={AuxPreviewConfig}
403+
previewConfig={{
404+
borderRadius: MESSAGE_BUBBLE_BORDER_RADIUS,
405+
}}
406+
auxiliaryPreviewConfig={auxPreviewConfig}
407407
renderAuxiliaryPreview={() => (
408408
<View style={styles.auxRootContainer}>
409409
{REACTIONS_KEYS.map((reactionKey, index) => (
@@ -467,9 +467,19 @@ const MessageBubble = (props: {
467467
(currentReaction != null) && await startFadeIn();
468468
}}
469469
>
470-
<Text style={styles.messageTextLabel}>
471-
{props.message.messageText}
472-
</Text>
470+
<View style={[
471+
styles.messageBubbleContent,
472+
{
473+
backgroundColor: (props.message.isSender
474+
? Colors.PURPLE[100]
475+
: Colors.ORANGE[100]
476+
),
477+
}
478+
]}>
479+
<Text style={styles.messageTextLabel}>
480+
{props.message.messageText}
481+
</Text>
482+
</View>
473483
</ContextMenuView>
474484
{(hasReaction && !props.message.isSender) && reactionIndicator}
475485
</Animated.View>
@@ -605,10 +615,13 @@ const styles = StyleSheet.create({
605615
marginBottom: 10,
606616
},
607617
messageBubbleContainer: {
618+
maxWidth: '90%',
619+
},
620+
messageBubbleContent: {
621+
flex: 1,
608622
paddingHorizontal: 12,
609623
paddingVertical: 8,
610-
borderRadius: 10,
611-
maxWidth: '90%',
624+
borderRadius: MESSAGE_BUBBLE_BORDER_RADIUS,
612625
},
613626
messageTextLabel: {
614627
},

src/components/ContextMenuView/ContextMenuView.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,9 @@ export class ContextMenuView extends
391391
</React.Fragment>
392392
</RNIDetachedView>
393393
)}
394-
{props.viewProps.children}
394+
<View>
395+
{props.viewProps.children}
396+
</View>
395397
</RNIContextMenuView>
396398
):(
397399
// B - Use Regular View

0 commit comments

Comments
 (0)