forked from dominicstop/react-native-ios-context-menu
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Test02Screen.tsx
85 lines (80 loc) · 2.16 KB
/
Test02Screen.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import * as React from 'react';
import { useState } from 'react';
import { View, Image, StyleSheet, Text } from 'react-native';
import { ContextMenuView } from 'react-native-ios-context-menu';
// Repro for issue #43
// https://github.com/dominicstop/react-native-ios-context-menu/issues/43
export const Test02Screen = () => {
const [isMessageLiked, setIsMessageLiked] = useState(false);
return (
<View style={styles.rootContainer}>
<View style={styles.messageContainer}>
<ContextMenuView
style={styles.messageMenuContainer}
menuConfig={{
menuTitle: '',
menuItems: [{
actionKey: 'action-like',
actionTitle: isMessageLiked? 'Unlike' : 'Like',
icon: {
type: 'IMAGE_SYSTEM',
imageValue: {
systemName: isMessageLiked ? 'heart.fill' : 'heart',
paletteColors: ['']
},
imageOptions: {
tint: 'red',
renderingMode: 'alwaysOriginal',
},
}
}],
}}
onPressMenuItem={({nativeEvent}) => {
switch(nativeEvent.actionKey) {
case "action-like":
setIsMessageLiked((value) => !value);
break;
};
}}
>
<Image
style={styles.messageImage}
source={require('../assets/macos11_wallpaper.jpg')}
resizeMode={'cover'}
/>
</ContextMenuView>
{isMessageLiked && (
<Text style={styles.labelReaction}>
{'❤️'}
</Text>
)}
</View>
</View>
);
};
const styles = StyleSheet.create({
rootContainer: {
flex: 1,
alignItems: 'flex-end',
justifyContent: 'flex-end',
paddingHorizontal: 15,
paddingVertical: 10,
paddingBottom: 20
},
messageContainer: {
},
messageMenuContainer: {
flex: 0,
backgroundColor: 'red',
borderRadius: 10,
overflow: 'hidden',
},
messageImage: {
width: 200,
height: 100,
},
labelReaction: {
alignSelf: 'flex-end',
marginTop: 5,
},
});