Skip to content

Commit d9e6590

Browse files
authored
feat(android): take whole screen, refactor measurements (#236)
* feat: take whole screen, refactor measurements * feat: use ViewPager * fix: remove custom shadow nodes measurements * feat: add changesets * fix: use optional chaining for 0.77 RC * fix: use TabViewImpl to share code across architectures * fix: remove TabViewAdapter as its no longer needed * feat: use LinearLayout, make measurements better * feat: migrate off viewpager to frame layout (WIP)
1 parent f210909 commit d9e6590

30 files changed

+452
-634
lines changed

.changeset/smart-tomatoes-serve.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'react-native-bottom-tabs': minor
3+
---
4+
5+
feat: refactor android, change views on the native side, add page animations

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;

apps/example/src/Examples/ThreeTabs.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { Albums } from '../Screens/Albums';
55
import { Contacts } from '../Screens/Contacts';
66

77
export default function ThreeTabs() {
8-
const [index, setIndex] = useState(0);
8+
const [index, setIndex] = useState(1);
99
const [routes] = useState([
1010
{
1111
key: 'article',

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
}

0 commit comments

Comments
 (0)