Skip to content

Commit 7206a99

Browse files
authored
Add Single Tap to Trigger Functionality (#53)
* Fix deps on fresh clone * Fixup deps * Working single tap functionality * Update name a bit * Add single tap for android * Bump version * Update documentation
1 parent 3bca7aa commit 7206a99

File tree

11 files changed

+2134
-22205
lines changed

11 files changed

+2134
-22205
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,7 @@ Optional. When the popop is opened and the user cancels.
6767
###### `previewBackgroundColor`
6868

6969
Optional. The background color of the preview. This is displayed underneath your view. Set this to transparent (or another color) if the default causes issues.
70+
71+
###### `dropdownMenuMode`
72+
73+
Optional. When set to `true`, the context menu is triggered with a single tap instead of a long press, and a preview is not show and no blur occurs. Uses the iOS 14 Menu API and a simple tap listener on android.

example/App.js

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const App = () => {
3838
disabled: true,
3939
},
4040
]} onPress={(event) => {
41-
const {index, name} = event.nativeEvent;
41+
const { index, name } = event.nativeEvent;
4242
if (index == 0) {
4343
setColor(name.toLowerCase());
4444
} else {
@@ -47,8 +47,25 @@ const App = () => {
4747
}} onCancel={() => {
4848
console.warn('CANCELLED')
4949
}} previewBackgroundColor="transparent">
50-
<View style={[styles.rectangle, {backgroundColor: color, borderRadius: circle ? 999 : 0}]} />
50+
<View style={[styles.rectangle, { backgroundColor: color, borderRadius: circle ? 999 : 0 }]} />
5151
</ContextMenu>
52+
53+
<View style={styles.spacer} />
54+
55+
<ContextMenu
56+
title={'Dropdown Menu'}
57+
actions={[
58+
{
59+
title: 'Test Item',
60+
}
61+
]}
62+
dropdownMenuMode={true}
63+
>
64+
<View style={[styles.rectangle, { backgroundColor: 'purple' }]} />
65+
</ContextMenu>
66+
67+
<View style={styles.spacer} />
68+
5269
<ContextMenu
5370
title={'Custom Preview'}
5471
actions={[
@@ -57,23 +74,25 @@ const App = () => {
5774
},
5875
]}
5976
previewBackgroundColor="transparent"
60-
preview={<View style={[styles.rectangle, {backgroundColor: 'green'}]} />}>
61-
<View style={[styles.rectangle, {backgroundColor: 'red'}]} />
77+
preview={<View style={[styles.rectangle, { backgroundColor: 'green' }]} />}>
78+
<View style={[styles.rectangle, { backgroundColor: 'red' }]} />
6279
</ContextMenu>
63-
<View style={{color: 'red', height: 100, width: 100}} />
6480
</SafeAreaView>
6581
);
6682
}
6783

6884
const styles = StyleSheet.create({
6985
container: {
7086
flex: 1,
71-
justifyContent: 'center',
87+
justifyContent: 'flex-start',
7288
alignItems: 'center'
7389
},
7490
rectangle: {
75-
width: 200,
91+
width: 200,
7692
height: 200,
93+
},
94+
spacer: {
95+
height: 16,
7796
}
7897
});
7998

example/android/app/src/main/AndroidManifest.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
android:icon="@mipmap/ic_launcher"
1010
android:roundIcon="@mipmap/ic_launcher_round"
1111
android:allowBackup="false"
12-
android:theme="@style/AppTheme">
12+
android:theme="@style/AppTheme"
13+
android:usesCleartextTraffic="true">
1314
<activity
1415
android:name=".MainActivity"
1516
android:label="@string/app_name"

0 commit comments

Comments
 (0)