Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Android): take whole screen, refactor measurements #236

Merged
merged 9 commits into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/smart-tomatoes-serve.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'react-native-bottom-tabs': minor
---

feat: refactor android, change views on the native side, add page animations
2 changes: 1 addition & 1 deletion apps/example/android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ reactNativeArchitectures=armeabi-v7a,arm64-v8a,x86,x86_64
# to write custom TurboModules/Fabric components OR use libraries that
# are providing them.
# Note that this is incompatible with web debugging.
newArchEnabled=false
newArchEnabled=true
#bridgelessEnabled=true

# Uncomment the line below to build React Native from source.
Expand Down
6 changes: 5 additions & 1 deletion apps/example/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import TintColorsExample from './Examples/TintColors';
import NativeBottomTabsEmbeddedStacks from './Examples/NativeBottomTabsEmbeddedStacks';
import NativeBottomTabsSVGs from './Examples/NativeBottomTabsSVGs';
import NativeBottomTabsRemoteIcons from './Examples/NativeBottomTabsRemoteIcons';
import NativeBottomTabsUnmounting from './Examples/NativeBottomTabsUnmounting';

const FourTabsIgnoreSafeArea = () => {
return <FourTabs ignoresTopSafeArea />;
Expand Down Expand Up @@ -95,7 +96,6 @@ const examples = [
{
component: FourTabsNoAnimations,
name: 'Four Tabs - no animations',
platform: 'ios',
},
{
component: FourTabsTransparentScrollEdgeAppearance,
Expand Down Expand Up @@ -128,6 +128,10 @@ const examples = [
component: NativeBottomTabsSVGs,
name: 'Native Bottom Tabs with SVG Icons',
},
{
component: NativeBottomTabsUnmounting,
name: 'Native Bottom Tabs unmounting',
},
{
component: NativeBottomTabsRemoteIcons,
name: 'Native Bottom Tabs with SVG Remote Icons',
Expand Down
63 changes: 63 additions & 0 deletions apps/example/src/Examples/NativeBottomTabsUnmounting.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import { Article } from '../Screens/Article';
import { Albums } from '../Screens/Albums';
import { Contacts } from '../Screens/Contacts';
import { Chat } from '../Screens/Chat';
import { createNativeBottomTabNavigator } from '@bottom-tabs/react-navigation';
import React from 'react';
import { Alert } from 'react-native';

const Tab = createNativeBottomTabNavigator();

function NativeBottomTabsUnmounting() {
const [isTabMounted, setIsTabMounted] = React.useState(true);

React.useEffect(() => {
const id = setTimeout(() => {
setIsTabMounted(false);
Alert.alert('Tab is unmounted');
}, 1000);

return () => clearTimeout(id);
}, []);
return (
<Tab.Navigator initialRouteName="Chat" labeled={true}>
<Tab.Screen
name="Article"
component={Article}
options={{
tabBarButtonTestID: 'articleTestID',
tabBarBadge: '10',
tabBarIcon: ({ focused }) =>
focused
? require('../../assets/icons/person_dark.png')
: require('../../assets/icons/article_dark.png'),
}}
/>
<Tab.Screen
name="Albums"
component={Albums}
options={{
tabBarIcon: () => require('../../assets/icons/grid_dark.png'),
}}
/>
<Tab.Screen
name="Contacts"
component={Contacts}
options={{
tabBarIcon: () => require('../../assets/icons/person_dark.png'),
}}
/>
{isTabMounted && (
<Tab.Screen
name="Chat"
component={Chat}
options={{
tabBarIcon: () => require('../../assets/icons/chat_dark.png'),
}}
/>
)}
</Tab.Navigator>
);
}

export default NativeBottomTabsUnmounting;
2 changes: 1 addition & 1 deletion apps/example/src/Examples/ThreeTabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Albums } from '../Screens/Albums';
import { Contacts } from '../Screens/Contacts';

export default function ThreeTabs() {
const [index, setIndex] = useState(0);
const [index, setIndex] = useState(1);
const [routes] = useState([
{
key: 'article',
Expand Down
5 changes: 0 additions & 5 deletions packages/react-native-bottom-tabs/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@ buildscript {
}
}

def reactNativeArchitectures() {
def value = rootProject.getProperties().get("reactNativeArchitectures")
return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
}

def isNewArchitectureEnabled() {
return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
}
Expand Down
Loading
Loading