Skip to content

Commit 0616a1e

Browse files
authored
Merge branch 'main' into @kitten/fix/react-native-alias-name-resolution
2 parents 274891c + 183f348 commit 0616a1e

17 files changed

Lines changed: 210 additions & 324 deletions

File tree

packages/docs-gesture-handler/src/components/HandIcon/index.tsx

Lines changed: 0 additions & 23 deletions
This file was deleted.

packages/docs-gesture-handler/src/components/TopPromoRotator/index.tsx

Lines changed: 0 additions & 133 deletions
This file was deleted.

packages/docs-gesture-handler/src/components/TopPromoRotator/styles.module.css

Lines changed: 0 additions & 91 deletions
This file was deleted.
Lines changed: 1 addition & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,8 @@
11
import React from 'react';
22
import useBaseUrl from '@docusaurus/useBaseUrl';
3-
import { useLocation } from '@docusaurus/router';
43
import { Navbar } from '@swmansion/t-rex-ui';
5-
import TopPromoRotator, {
6-
PROMO_VERSION,
7-
} from '@site/src/components/TopPromoRotator';
84

95
export default function NavbarWrapper(props) {
10-
const location = useLocation();
11-
const baseUrl = useBaseUrl('/');
12-
const isLanding = location.pathname === baseUrl;
13-
14-
const [showPromo, setShowPromo] = React.useState(true);
15-
16-
React.useEffect(() => {
17-
if (isLanding || typeof globalThis === 'undefined') {
18-
return;
19-
}
20-
21-
try {
22-
const raw = globalThis.localStorage?.getItem('topPromoState');
23-
const state = raw ? JSON.parse(raw) : null;
24-
if (state?.v === PROMO_VERSION && state?.hidden) {
25-
setShowPromo(false);
26-
}
27-
} catch (_) {
28-
// ignore
29-
}
30-
}, [isLanding]);
31-
32-
const handleClosePromo = React.useCallback(() => {
33-
setShowPromo(false);
34-
if (typeof globalThis !== 'undefined') {
35-
try {
36-
globalThis.localStorage?.setItem(
37-
'topPromoState',
38-
JSON.stringify({ v: PROMO_VERSION, hidden: true })
39-
);
40-
} catch {
41-
// ignore
42-
}
43-
}
44-
}, []);
45-
466
const titleImages = {
477
light: useBaseUrl('/img/title.svg'),
488
dark: useBaseUrl('/img/title-dark.svg'),
@@ -51,15 +11,7 @@ export default function NavbarWrapper(props) {
5111
const heroImages = {
5212
logo: useBaseUrl('/img/logo-hero.svg'),
5313
};
54-
5514
return (
56-
<div style={{ display: 'flex', flexDirection: 'column', flexShrink: 0 }}>
57-
{isLanding ? (
58-
<TopPromoRotator />
59-
) : (
60-
showPromo && <TopPromoRotator onClose={handleClosePromo} />
61-
)}
62-
<Navbar heroImages={heroImages} titleImages={titleImages} {...props} />
63-
</div>
15+
<Navbar heroImages={heroImages} titleImages={titleImages} {...props} />
6416
);
6517
}

packages/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/core/NativeViewGestureHandler.kt

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,8 @@ import com.facebook.react.views.swiperefresh.ReactSwipeRefreshLayout
1414
import com.facebook.react.views.text.ReactTextView
1515
import com.facebook.react.views.textinput.ReactEditText
1616
import com.facebook.react.views.view.ReactViewGroup
17-
import com.swmansion.gesturehandler.react.RNGestureHandlerButtonViewManager
1817
import com.swmansion.gesturehandler.react.RNGestureHandlerRootHelper
1918
import com.swmansion.gesturehandler.react.events.eventbuilders.NativeGestureHandlerEventDataBuilder
20-
import com.swmansion.gesturehandler.react.isScreenReaderOn
2119

2220
class NativeViewGestureHandler : GestureHandler() {
2321
override val isContinuous = true
@@ -121,17 +119,6 @@ class NativeViewGestureHandler : GestureHandler() {
121119

122120
override fun onHandle(event: MotionEvent, sourceEvent: MotionEvent) {
123121
val view = view!!
124-
125-
val isTouchExplorationEnabled = view.context.isScreenReaderOn()
126-
127-
if (view is RNGestureHandlerButtonViewManager.ButtonViewGroup && isTouchExplorationEnabled) {
128-
// Fix for: https://github.com/software-mansion/react-native-gesture-handler/issues/2808
129-
// When TalkBack is enabled, events are often not being sent to the orchestrator for processing.
130-
// Instead, states will be changed directly by an alternative mechanism added in this PR:
131-
// https://github.com/software-mansion/react-native-gesture-handler/pull/2234
132-
return
133-
}
134-
135122
if (event.actionMasked == MotionEvent.ACTION_UP) {
136123
if (state == STATE_UNDETERMINED && !hook.canBegin(event)) {
137124
cancel()

packages/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerButtonViewManager.kt

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import androidx.core.view.children
2727
import androidx.interpolator.view.animation.FastOutSlowInInterpolator
2828
import com.facebook.react.R
2929
import com.facebook.react.bridge.Dynamic
30+
import com.facebook.react.bridge.ReadableArray
3031
import com.facebook.react.module.annotations.ReactModule
3132
import com.facebook.react.uimanager.BackgroundStyleApplicator
3233
import com.facebook.react.uimanager.LengthPercentage
@@ -347,6 +348,7 @@ class RNGestureHandlerButtonViewManager :
347348
super.onAfterUpdateTransaction(view)
348349

349350
view.updateBackground()
351+
view.updateLongPressAccessibility()
350352
}
351353

352354
override fun getDelegate(): ViewManagerDelegate<ButtonViewGroup>? = mDelegate
@@ -434,6 +436,23 @@ class RNGestureHandlerButtonViewManager :
434436
invalidate()
435437
}
436438

439+
fun updateLongPressAccessibility() {
440+
val hasLongPress = hasLongPressAccessibilityAction()
441+
setOnLongClickListener(if (hasLongPress) dummyLongClickListener else null)
442+
isLongClickable = hasLongPress
443+
}
444+
445+
private fun hasLongPressAccessibilityAction(): Boolean {
446+
val actions = getTag(R.id.accessibility_actions) as? ReadableArray ?: return false
447+
for (i in 0 until actions.size()) {
448+
if (actions.getMap(i)?.getString("name") == "longpress") {
449+
return true
450+
}
451+
}
452+
453+
return false
454+
}
455+
437456
override fun setBackgroundColor(color: Int) {
438457
BackgroundStyleApplicator.setBackgroundColor(this, color)
439458
}
@@ -876,10 +895,11 @@ class RNGestureHandlerButtonViewManager :
876895
}
877896

878897
override fun performClick(): Boolean {
879-
// don't preform click when a child button is pressed (mainly to prevent sound effect of
898+
// don't perform click when a child button is pressed (mainly to prevent sound effect of
880899
// a parent button from playing)
881900
return if (!isChildTouched()) {
882-
if (context.isScreenReaderOn()) {
901+
// Don't activate native handlers when isPressed is true (motion events are passing through)
902+
if (context.isScreenReaderOn() && !isPressed) {
883903
RNGestureHandlerRootView.findGestureHandlerRootView(this)?.activateNativeHandlers(this)
884904
} else if (receivedKeyEvent) {
885905
RNGestureHandlerRootView.findGestureHandlerRootView(this)?.activateNativeHandlers(this)
@@ -936,7 +956,14 @@ class RNGestureHandlerButtonViewManager :
936956
var resolveOutValue = TypedValue()
937957
var touchResponder: ButtonViewGroup? = null
938958
var soundResponder: ButtonViewGroup? = null
939-
var dummyClickListener = OnClickListener { }
959+
val dummyClickListener = OnClickListener { }
960+
val dummyLongClickListener = OnLongClickListener { view ->
961+
if (view.context.isScreenReaderOn()) {
962+
view.performAccessibilityAction(AccessibilityNodeInfo.ACTION_LONG_CLICK, null)
963+
} else {
964+
false
965+
}
966+
}
940967
}
941968
}
942969

0 commit comments

Comments
 (0)