Skip to content

Commit

Permalink
Add reproduction
Browse files Browse the repository at this point in the history
  • Loading branch information
zoontek committed Oct 30, 2024
1 parent d0e9d05 commit c97fcd2
Show file tree
Hide file tree
Showing 6 changed files with 156 additions and 118 deletions.
169 changes: 55 additions & 114 deletions App.tsx
Original file line number Diff line number Diff line change
@@ -1,118 +1,59 @@
/**
* Sample React Native App
* https://github.com/facebook/react-native
*
* @format
*/
import React, {useState} from 'react';
import {Text, View} from 'react-native';
import TabView, {SceneMap} from 'react-native-bottom-tabs';

const ScreenA = () => (
<View>
<Text>Screen A</Text>
</View>
);

const ScreenB = () => (
<View>
<Text>Screen B</Text>
</View>
);

const ScreenC = () => (
<View>
<Text>Screen C</Text>
</View>
);

export default function App(): React.JSX.Element {
const [index, setIndex] = useState(0);

const [routes] = useState([
{
key: 'article',
title: 'Article',
focusedIcon: require('./icon.png'),
badge: '!',
},
{
key: 'albums',
title: 'Albums',
focusedIcon: require('./icon.png'),
badge: '5',
},
{
key: 'contacts',
title: 'Contacts',
focusedIcon: require('./icon.png'),
},
]);

const renderScene = SceneMap({
article: ScreenA,
albums: ScreenB,
contacts: ScreenC,
});

import React from 'react';
import type {PropsWithChildren} from 'react';
import {
SafeAreaView,
ScrollView,
StatusBar,
StyleSheet,
Text,
useColorScheme,
View,
} from 'react-native';

import {
Colors,
DebugInstructions,
Header,
LearnMoreLinks,
ReloadInstructions,
} from 'react-native/Libraries/NewAppScreen';

type SectionProps = PropsWithChildren<{
title: string;
}>;

function Section({children, title}: SectionProps): React.JSX.Element {
const isDarkMode = useColorScheme() === 'dark';
return (
<View style={styles.sectionContainer}>
<Text
style={[
styles.sectionTitle,
{
color: isDarkMode ? Colors.white : Colors.black,
},
]}>
{title}
</Text>
<Text
style={[
styles.sectionDescription,
{
color: isDarkMode ? Colors.light : Colors.dark,
},
]}>
{children}
</Text>
</View>
<TabView
navigationState={{index, routes}}
onIndexChange={setIndex}
renderScene={renderScene}
/>
);
}

function App(): React.JSX.Element {
const isDarkMode = useColorScheme() === 'dark';

const backgroundStyle = {
backgroundColor: isDarkMode ? Colors.darker : Colors.lighter,
};

return (
<SafeAreaView style={backgroundStyle}>
<StatusBar
barStyle={isDarkMode ? 'light-content' : 'dark-content'}
backgroundColor={backgroundStyle.backgroundColor}
/>
<ScrollView
contentInsetAdjustmentBehavior="automatic"
style={backgroundStyle}>
<Header />
<View
style={{
backgroundColor: isDarkMode ? Colors.black : Colors.white,
}}>
<Section title="Step One">
Edit <Text style={styles.highlight}>App.tsx</Text> to change this
screen and then come back to see your edits.
</Section>
<Section title="See Your Changes">
<ReloadInstructions />
</Section>
<Section title="Debug">
<DebugInstructions />
</Section>
<Section title="Learn More">
Read the docs to discover what to do next:
</Section>
<LearnMoreLinks />
</View>
</ScrollView>
</SafeAreaView>
);
}

const styles = StyleSheet.create({
sectionContainer: {
marginTop: 32,
paddingHorizontal: 24,
},
sectionTitle: {
fontSize: 24,
fontWeight: '600',
},
sectionDescription: {
marginTop: 8,
fontSize: 18,
fontWeight: '400',
},
highlight: {
fontWeight: '700',
},
});

export default App;
14 changes: 14 additions & 0 deletions android/app/src/main/java/com/bottomtabsissue/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package com.bottomtabsissue

import android.graphics.Color
import android.os.Bundle
import androidx.core.view.WindowCompat
import com.facebook.react.ReactActivity
import com.facebook.react.ReactActivityDelegate
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.fabricEnabled
Expand All @@ -19,4 +22,15 @@ class MainActivity : ReactActivity() {
*/
override fun createReactActivityDelegate(): ReactActivityDelegate =
DefaultReactActivityDelegate(this, mainComponentName, fabricEnabled)

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

// This breaks react-native-bottom-tabs 👇
WindowCompat.setDecorFitsSystemWindows(window, false)

// These lines are not responsible, it's just to see better
window.statusBarColor = Color.TRANSPARENT
window.navigationBarColor = Color.TRANSPARENT
}
}
2 changes: 1 addition & 1 deletion android/app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<resources>

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.DayNight.NoActionBar">
<style name="AppTheme" parent="Theme.Material3.DayNight.NoActionBar">
<!-- Customize your theme here. -->
<item name="android:editTextBackground">@drawable/rn_edit_text_material</item>
</style>
Expand Down
Binary file added icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
84 changes: 83 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
},
"dependencies": {
"react": "18.3.1",
"react-native": "0.76.1"
"react-native": "0.76.1",
"react-native-bottom-tabs": "^0.2.0"
},
"devDependencies": {
"@babel/core": "^7.25.2",
Expand All @@ -36,4 +37,4 @@
"engines": {
"node": ">=18"
}
}
}

0 comments on commit c97fcd2

Please sign in to comment.