react-native-ui-lib 7.37.2-snapshot.6208 → 7.37.2-snapshot.6211

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.37.2-snapshot.6208",
3
+ "version": "7.37.2-snapshot.6211",
4
4
  "main": "src/index.js",
5
5
  "types": "src/index.d.ts",
6
6
  "author": "Ethan Sharabi <ethan.shar@gmail.com>",
@@ -149,7 +149,7 @@ const TabBar = props => {
149
149
  }, [labelColor, selectedLabelColor]);
150
150
  return <View style={_containerStyle} key={key} bg-$backgroundElevated>
151
151
  <FadedScrollView ref={tabBar} horizontal showsHorizontalScrollIndicator={false} showStartFader startFaderProps={faderProps} showEndFader endFaderProps={faderProps} contentContainerStyle={scrollViewContainerStyle} testID={testID} onContentSizeChange={onContentSizeChange} onLayout={onLayout}>
152
- <View style={tabBarContainerStyle}>{tabBarItems}</View>
152
+ <View style={tabBarContainerStyle} accessibilityRole={Constants.isIOS ? 'tabbar' : 'tablist'}>{tabBarItems}</View>
153
153
  {itemsCount > 1 && <Reanimated.View style={[styles.selectedIndicator, indicatorStyle, _indicatorTransitionStyle]} />}
154
154
  </FadedScrollView>
155
155
  </View>;
@@ -3,9 +3,9 @@ import _isEmpty from "lodash/isEmpty";
3
3
  import _isUndefined from "lodash/isUndefined";
4
4
  import _cloneDeep from "lodash/cloneDeep";
5
5
  // TODO: support commented props
6
- import React, { useCallback, useContext, useEffect, useRef, useMemo } from 'react';
6
+ import React, { useCallback, useContext, useEffect, useRef, useMemo, useState } from 'react';
7
7
  import { StyleSheet } from 'react-native';
8
- import Reanimated, { runOnJS, useAnimatedStyle, useSharedValue } from 'react-native-reanimated';
8
+ import Reanimated, { runOnJS, useAnimatedReaction, useAnimatedStyle, useSharedValue } from 'react-native-reanimated';
9
9
  import { Gesture, GestureDetector } from 'react-native-gesture-handler';
10
10
  import { Colors, Typography, Spacings } from "../../style";
11
11
  import Badge from "../badge";
@@ -52,6 +52,7 @@ export default function TabBarItem({
52
52
  // JSON.parse(JSON.stringify is due to an issue with reanimated
53
53
  const sharedLabelStyle = useSharedValue(JSON.parse(JSON.stringify(StyleSheet.flatten(labelStyle))));
54
54
  const sharedSelectedLabelStyle = useSharedValue(JSON.parse(JSON.stringify(StyleSheet.flatten(selectedLabelStyle))));
55
+ const [isSelected, setIsSelected] = useState(currentPage.value === index);
55
56
 
56
57
  // NOTE: We clone these color values in refs because they might contain a PlatformColor value
57
58
  // which throws an error (see https://github.com/software-mansion/react-native-reanimated/issues/3164)
@@ -71,6 +72,11 @@ export default function TabBarItem({
71
72
  }, index);
72
73
  }
73
74
  }, []);
75
+ useAnimatedReaction(() => currentPage.value === index, (isSelected, prevIsSelected) => {
76
+ if (isSelected !== prevIsSelected) {
77
+ runOnJS(setIsSelected)(isSelected);
78
+ }
79
+ });
74
80
  const onLayout = useCallback(event => {
75
81
  const {
76
82
  width
@@ -120,6 +126,9 @@ export default function TabBarItem({
120
126
  flex
121
127
  }, style, constantWidthStyle, pressStyle];
122
128
  }, [style, spreadItems]);
129
+ const accessibilityState = useMemo(() => ({
130
+ selected: isSelected
131
+ }), [isSelected]);
123
132
  const gesture = Gesture.Tap().maxDuration(60000).onEnd(() => {
124
133
  if (!ignore) {
125
134
  setCurrentIndex(index);
@@ -133,7 +142,7 @@ export default function TabBarItem({
133
142
  return <GestureDetector gesture={gesture}>
134
143
  <View reanimated
135
144
  // @ts-expect-error
136
- ref={itemRef} style={_style} onLayout={onLayout} testID={testID}>
145
+ ref={itemRef} style={_style} onLayout={onLayout} testID={testID} accessible accessibilityRole="tab" accessibilityState={accessibilityState}>
137
146
  {leadingAccessory}
138
147
  {icon && <Reanimated.Image source={icon} style={[!_isUndefined(label) && styles.tabItemIconWithLabel, animatedIconStyle]} />}
139
148
  {!_isEmpty(label) && <Reanimated.Text {...labelProps} fsTagName={'unmask'} style={[styles.tabItemLabel, labelStyle, animatedLabelStyle, animatedLabelColorStyle]}>