react-native-ui-lib 7.42.0-snapshot.7014 → 7.42.0-snapshot.7019

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-ui-lib",
3
- "version": "7.42.0-snapshot.7014",
3
+ "version": "7.42.0-snapshot.7019",
4
4
  "main": "src/index.js",
5
5
  "types": "src/index.d.ts",
6
6
  "author": "Ethan Sharabi <ethan.shar@gmail.com>",
@@ -1,5 +1,5 @@
1
- import React, { useCallback, useContext, useState, useMemo } from 'react';
2
- import { StyleSheet } from 'react-native';
1
+ import React, { useCallback, useContext, useState, useMemo, useRef, useEffect } from 'react';
2
+ import { StyleSheet, findNodeHandle, AccessibilityInfo } from 'react-native';
3
3
  import Reanimated, { useAnimatedStyle, useAnimatedReaction, runOnJS } from 'react-native-reanimated';
4
4
  // import {Freeze} from 'react-freeze';
5
5
  import TabBarContext from "./TabBarContext";
@@ -23,6 +23,8 @@ export default function TabPage({
23
23
  containerWidth
24
24
  } = useContext(TabBarContext);
25
25
  const [shouldLoad, setLoaded] = useState(!lazy);
26
+ const [isActive, setIsActive] = useState(false);
27
+ const pageRef = useRef(null);
26
28
  // const [focused, setFocused] = useState(false);
27
29
 
28
30
  const lazyLoad = useCallback(() => {
@@ -35,13 +37,11 @@ export default function TabPage({
35
37
  useAnimatedReaction(() => {
36
38
  return currentPage.value;
37
39
  }, (currentPage /* , previousPage */) => {
38
- const isActive = currentPage === index;
39
- // const wasActive = previousPage === index;
40
- // const nearActive = asCarousel && (currentPage - 1 === index || currentPage + 1 === index);
41
- // const wasNearActive =
42
- // asCarousel && previousPage !== null && (previousPage - 1 === index || previousPage + 1 === index);
43
-
44
- if (isActive) {
40
+ const newIsActive = currentPage === index;
41
+ if (newIsActive !== isActive) {
42
+ runOnJS(setIsActive)(newIsActive);
43
+ }
44
+ if (newIsActive) {
45
45
  runOnJS(lazyLoad)();
46
46
  }
47
47
 
@@ -50,7 +50,23 @@ export default function TabPage({
50
50
  // } else if (wasActive || wasNearActive) {
51
51
  // runOnJS(setFocused)(false);
52
52
  // }
53
- }, [currentPage, lazyLoad]);
53
+ }, [currentPage, lazyLoad, isActive]);
54
+ useEffect(() => {
55
+ let timeoutId;
56
+ if (isActive && pageRef.current && shouldLoad) {
57
+ timeoutId = setTimeout(() => {
58
+ const node = findNodeHandle(pageRef.current);
59
+ if (node) {
60
+ AccessibilityInfo.setAccessibilityFocus(node);
61
+ }
62
+ }, 100);
63
+ }
64
+ return () => {
65
+ if (timeoutId) {
66
+ clearTimeout(timeoutId);
67
+ }
68
+ };
69
+ }, [isActive, shouldLoad]);
54
70
  const animatedPageStyle = useAnimatedStyle(() => {
55
71
  const isActive = Math.round(currentPage.value) === index;
56
72
 
@@ -69,7 +85,7 @@ export default function TabPage({
69
85
  width: asCarousel ? containerWidth : undefined
70
86
  }, style];
71
87
  }, [asCarousel, animatedPageStyle, containerWidth, style]);
72
- return <Reanimated.View style={_style} testID={testID}>
88
+ return <Reanimated.View ref={pageRef} style={_style} testID={testID} accessible={false}>
73
89
  {!shouldLoad && renderLoading?.()}
74
90
  {shouldLoad && props.children}
75
91
  {/* <Freeze freeze={!shouldLoad || !focused}>{props.children}</Freeze> */}