Skip to content

Commit 76458fa

Browse files
committed
fix: remove custom shadow nodes measurements
1 parent 8dd3a80 commit 76458fa

File tree

20 files changed

+139
-437
lines changed

20 files changed

+139
-437
lines changed

apps/example/android/gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ reactNativeArchitectures=armeabi-v7a,arm64-v8a,x86,x86_64
4040
# to write custom TurboModules/Fabric components OR use libraries that
4141
# are providing them.
4242
# Note that this is incompatible with web debugging.
43-
newArchEnabled=false
43+
newArchEnabled=true
4444
#bridgelessEnabled=true
4545

4646
# Uncomment the line below to build React Native from source.

apps/example/src/App.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import TintColorsExample from './Examples/TintColors';
2727
import NativeBottomTabsEmbeddedStacks from './Examples/NativeBottomTabsEmbeddedStacks';
2828
import NativeBottomTabsSVGs from './Examples/NativeBottomTabsSVGs';
2929
import NativeBottomTabsRemoteIcons from './Examples/NativeBottomTabsRemoteIcons';
30+
import NativeBottomTabsUnmounting from './Examples/NativeBottomTabsUnmounting';
3031

3132
const FourTabsIgnoreSafeArea = () => {
3233
return <FourTabs ignoresTopSafeArea />;
@@ -95,7 +96,6 @@ const examples = [
9596
{
9697
component: FourTabsNoAnimations,
9798
name: 'Four Tabs - no animations',
98-
platform: 'ios',
9999
},
100100
{
101101
component: FourTabsTransparentScrollEdgeAppearance,
@@ -128,6 +128,10 @@ const examples = [
128128
component: NativeBottomTabsSVGs,
129129
name: 'Native Bottom Tabs with SVG Icons',
130130
},
131+
{
132+
component: NativeBottomTabsUnmounting,
133+
name: 'Native Bottom Tabs unmounting',
134+
},
131135
{
132136
component: NativeBottomTabsRemoteIcons,
133137
name: 'Native Bottom Tabs with SVG Remote Icons',
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
import { Article } from '../Screens/Article';
2+
import { Albums } from '../Screens/Albums';
3+
import { Contacts } from '../Screens/Contacts';
4+
import { Chat } from '../Screens/Chat';
5+
import { createNativeBottomTabNavigator } from '@bottom-tabs/react-navigation';
6+
import React from 'react';
7+
import { Alert } from 'react-native';
8+
9+
const Tab = createNativeBottomTabNavigator();
10+
11+
function NativeBottomTabsUnmounting() {
12+
const [isTabMounted, setIsTabMounted] = React.useState(true);
13+
14+
React.useEffect(() => {
15+
const id = setTimeout(() => {
16+
setIsTabMounted(false);
17+
Alert.alert('Tab is unmounted');
18+
}, 1000);
19+
20+
return () => clearTimeout(id);
21+
}, []);
22+
return (
23+
<Tab.Navigator initialRouteName="Chat" labeled={true}>
24+
<Tab.Screen
25+
name="Article"
26+
component={Article}
27+
options={{
28+
tabBarButtonTestID: 'articleTestID',
29+
tabBarBadge: '10',
30+
tabBarIcon: ({ focused }) =>
31+
focused
32+
? require('../../assets/icons/person_dark.png')
33+
: require('../../assets/icons/article_dark.png'),
34+
}}
35+
/>
36+
<Tab.Screen
37+
name="Albums"
38+
component={Albums}
39+
options={{
40+
tabBarIcon: () => require('../../assets/icons/grid_dark.png'),
41+
}}
42+
/>
43+
<Tab.Screen
44+
name="Contacts"
45+
component={Contacts}
46+
options={{
47+
tabBarIcon: () => require('../../assets/icons/person_dark.png'),
48+
}}
49+
/>
50+
{isTabMounted && (
51+
<Tab.Screen
52+
name="Chat"
53+
component={Chat}
54+
options={{
55+
tabBarIcon: () => require('../../assets/icons/chat_dark.png'),
56+
}}
57+
/>
58+
)}
59+
</Tab.Navigator>
60+
);
61+
}
62+
63+
export default NativeBottomTabsUnmounting;

packages/react-native-bottom-tabs/android/build.gradle

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,6 @@ buildscript {
1414
}
1515
}
1616

17-
def reactNativeArchitectures() {
18-
def value = rootProject.getProperties().get("reactNativeArchitectures")
19-
return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
20-
}
21-
2217
def isNewArchitectureEnabled() {
2318
return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
2419
}

packages/react-native-bottom-tabs/android/src/main/java/com/rcttabview/RCTTabView.kt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ class ReactBottomNavigationView(context: ReactContext) : FrameLayout(context) {
174174

175175
fun updateItems(items: MutableList<TabInfo>) {
176176
this.items = items
177+
bottomNavigation.menu.clear()
177178
items.forEachIndexed { index, item ->
178179
val menuItem = getOrCreateItem(index, item.title)
179180
menuItem.isVisible = !item.hidden
@@ -291,7 +292,9 @@ class ReactBottomNavigationView(context: ReactContext) : FrameLayout(context) {
291292
bottomNavigation.itemBackground = colorDrawable
292293
backgroundTintList = ColorStateList.valueOf(backgroundColor)
293294
// Set navigationBarColor for edge-to-edge.
294-
reactContext.currentActivity?.window?.navigationBarColor = backgroundColor
295+
if (Utils.isEdgeToEdge()) {
296+
reactContext.currentActivity?.window?.navigationBarColor = backgroundColor
297+
}
295298
}
296299

297300
fun setActiveTintColor(color: Int?) {
@@ -380,6 +383,8 @@ class ReactBottomNavigationView(context: ReactContext) : FrameLayout(context) {
380383

381384
override fun onDetachedFromWindow() {
382385
super.onDetachedFromWindow()
383-
reactContext.currentActivity?.window?.navigationBarColor = Color.TRANSPARENT
386+
if (Utils.isEdgeToEdge()) {
387+
reactContext.currentActivity?.window?.navigationBarColor = Color.TRANSPARENT
388+
}
384389
}
385390
}

packages/react-native-bottom-tabs/android/src/main/java/com/rcttabview/RCTTabViewImpl.kt

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,27 +24,24 @@ class RCTTabViewImpl {
2424
fun setItems(view: ReactBottomNavigationView, items: ReadableArray) {
2525
val itemsArray = mutableListOf<TabInfo>()
2626
for (i in 0 until items.size()) {
27-
items.getMap(i).let { item ->
28-
itemsArray.add(
29-
TabInfo(
30-
key = item.getString("key") ?: "",
31-
title = item.getString("title") ?: "",
32-
badge = item.getString("badge") ?: "",
33-
activeTintColor = if (item.hasKey("activeTintColor")) item.getInt("activeTintColor") else null,
34-
hidden = if (item.hasKey("hidden")) item.getBoolean("hidden") else false,
35-
testID = item.getString("testID")
27+
items.getMap(i)?.let { item ->
28+
itemsArray.add(
29+
TabInfo(
30+
key = item.getString("key") ?: "",
31+
title = item.getString("title") ?: "",
32+
badge = item.getString("badge") ?: "",
33+
activeTintColor = if (item.hasKey("activeTintColor")) item.getInt("activeTintColor") else null,
34+
hidden = if (item.hasKey("hidden")) item.getBoolean("hidden") else false,
35+
testID = item.getString("testID")
36+
)
3637
)
37-
)
3838
}
3939
}
4040
view.updateItems(itemsArray)
4141
}
4242

4343
fun setSelectedPage(view: ReactBottomNavigationView, key: String) {
4444
view.setSelectedItem(key)
45-
// view.items?.indexOfFirst { it.key == key }?.let {
46-
// view.setSelectedItemId(it)
47-
// }
4845
}
4946

5047
fun setLabeled(view: ReactBottomNavigationView, flag: Boolean?) {

packages/react-native-bottom-tabs/android/src/main/java/com/rcttabview/Utils.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,13 @@ class Utils {
2727
)
2828
return baseColor.defaultColor
2929
}
30+
31+
// Detect `react-native-edge-to-edge` (https://github.com/zoontek/react-native-edge-to-edge)
32+
fun isEdgeToEdge() = try {
33+
Class.forName("com.zoontek.rnedgetoedge.EdgeToEdgePackage")
34+
true
35+
} catch (exception: ClassNotFoundException) {
36+
false
37+
}
3038
}
3139
}

packages/react-native-bottom-tabs/android/src/main/jni/CMakeLists.txt

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

packages/react-native-bottom-tabs/android/src/main/jni/RNCTabView.h

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

0 commit comments

Comments
 (0)