@react-native-menu/menu 0.7.2 → 0.8.0
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.
|
@@ -25,14 +25,14 @@ class MenuView(private val mContext: ReactContext): ReactViewGroup(mContext) {
|
|
|
25
25
|
|
|
26
26
|
init {
|
|
27
27
|
mGestureDetector = GestureDetector(mContext, object : GestureDetector.SimpleOnGestureListener() {
|
|
28
|
-
override fun onLongPress(e: MotionEvent
|
|
28
|
+
override fun onLongPress(e: MotionEvent) {
|
|
29
29
|
if (!mIsOnLongPress) {
|
|
30
30
|
return
|
|
31
31
|
}
|
|
32
32
|
prepareMenu()
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
override fun
|
|
35
|
+
override fun onSingleTapUp(e: MotionEvent): Boolean {
|
|
36
36
|
if (!mIsOnLongPress) {
|
|
37
37
|
prepareMenu()
|
|
38
38
|
}
|
|
@@ -45,7 +45,7 @@ class MenuView(private val mContext: ReactContext): ReactViewGroup(mContext) {
|
|
|
45
45
|
return true
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
override fun onTouchEvent(ev: MotionEvent
|
|
48
|
+
override fun onTouchEvent(ev: MotionEvent): Boolean {
|
|
49
49
|
mGestureDetector.onTouchEvent(ev)
|
|
50
50
|
return true
|
|
51
51
|
}
|
|
@@ -124,7 +124,7 @@ class MenuView(private val mContext: ReactContext): ReactViewGroup(mContext) {
|
|
|
124
124
|
menuItem.title = getMenuItemTextWithColor(menuItem.title.toString(), disabledColor)
|
|
125
125
|
if (imageName != null) {
|
|
126
126
|
val icon = menuItem.icon
|
|
127
|
-
icon
|
|
127
|
+
icon?.setTintList(ColorStateList.valueOf(disabledColor))
|
|
128
128
|
menuItem.icon = icon
|
|
129
129
|
}
|
|
130
130
|
}
|
|
@@ -145,7 +145,7 @@ class MenuView(private val mContext: ReactContext): ReactViewGroup(mContext) {
|
|
|
145
145
|
menuItem.title = getMenuItemTextWithColor(menuItem.title.toString(), Color.RED)
|
|
146
146
|
if (imageName != null) {
|
|
147
147
|
val icon = menuItem.icon
|
|
148
|
-
icon
|
|
148
|
+
icon?.setTintList(ColorStateList.valueOf(Color.RED))
|
|
149
149
|
menuItem.icon = icon
|
|
150
150
|
}
|
|
151
151
|
}
|
|
@@ -159,23 +159,25 @@ class MenuView(private val mContext: ReactContext): ReactViewGroup(mContext) {
|
|
|
159
159
|
while (i < subactionsCount) {
|
|
160
160
|
if (!subactions.isNull(i)) {
|
|
161
161
|
val subMenuConfig = subactions.getMap(i)
|
|
162
|
-
val subMenuItem = menuItem.subMenu
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
162
|
+
val subMenuItem = menuItem.subMenu?.add(Menu.NONE, Menu.NONE, i, subMenuConfig?.getString("title"))
|
|
163
|
+
if (subMenuItem != null) {
|
|
164
|
+
prepareMenuItem(subMenuItem, subMenuConfig)
|
|
165
|
+
subMenuItem.setOnMenuItemClickListener {
|
|
166
|
+
if (!it.hasSubMenu()) {
|
|
167
|
+
mIsMenuDisplayed = false
|
|
168
|
+
val args: WritableMap = Arguments.createMap()
|
|
169
|
+
if (!subactions.isNull(it.order)) {
|
|
170
|
+
val selectedItem = subactions.getMap(it.order)
|
|
171
|
+
args.putString("event", selectedItem?.getString("id"))
|
|
172
|
+
args.putString("target", "$id")
|
|
173
|
+
mContext
|
|
174
|
+
.getJSModule(RCTEventEmitter::class.java)
|
|
175
|
+
.receiveEvent(id, "onPressAction", args)
|
|
176
|
+
}
|
|
177
|
+
true
|
|
178
|
+
} else {
|
|
179
|
+
false
|
|
175
180
|
}
|
|
176
|
-
true
|
|
177
|
-
} else {
|
|
178
|
-
false
|
|
179
181
|
}
|
|
180
182
|
}
|
|
181
183
|
}
|