Skip to content

Commit 78e33f3

Browse files
committed
refacto: centralize TAB_BAR_HEIGHT in TabNavigator
1 parent 5fae819 commit 78e33f3

23 files changed

Lines changed: 42 additions & 88 deletions

src/components/Lists/EventList.tsx

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ import { useTheme } from 'react-native-paper';
3030
import { dateToDateStringHuman, PlanningEventType } from '../../utils/Planning';
3131
import GENERAL_STYLES from '../../constants/Styles';
3232
import i18n from 'i18n-js';
33-
import { TAB_BAR_HEIGHT } from '../Tabbar/CustomTabBar';
3433

3534
type EventListProps = {
3635
eventsByDate: { [key: string]: Array<PlanningEventType> };
@@ -179,16 +178,12 @@ function EventList(props: EventListProps) {
179178
) : undefined
180179
}
181180
stickySectionHeadersEnabled={true}
182-
contentContainerStyle={styles.contentContainer}
183181
/>
184182
</View>
185183
);
186184
}
187185

188186
const styles = StyleSheet.create({
189-
contentContainer: {
190-
paddingBottom: TAB_BAR_HEIGHT,
191-
},
192187
sectionHeader: {
193188
padding: 15,
194189
borderBottomWidth: 1,

src/components/Overrides/CustomModal.tsx

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import React, { Ref } from 'react';
2121
import { useTheme } from 'react-native-paper';
2222
import { Modalize } from 'react-native-modalize';
2323
import { View } from 'react-native-animatable';
24-
import { TAB_BAR_HEIGHT } from '../Tabbar/CustomTabBar';
2524

2625
type Props = {
2726
children?: React.ReactChild | null;
@@ -44,13 +43,7 @@ function CustomModal(props: Props, ref?: Ref<Modalize>) {
4443
modalStyle={{ backgroundColor: theme.colors.card }}
4544
handleStyle={{ backgroundColor: theme.colors.primary }}
4645
>
47-
<View
48-
style={{
49-
paddingBottom: TAB_BAR_HEIGHT,
50-
}}
51-
>
52-
{children}
53-
</View>
46+
<View style={{}}>{children}</View>
5447
</Modalize>
5548
);
5649
}

src/navigation/TabNavigator.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ import HomeScreen from '../screens/Home/HomeScreen';
2828
import PlanningScreen from '../screens/Planning/PlanningScreen';
2929
import ProxiwashScreen from '../screens/Proxiwash/ProxiwashScreen';
3030
import PlanexScreen from '../screens/Planex/PlanexScreen';
31-
import CustomTabBar from '../components/Tabbar/CustomTabBar';
31+
import CustomTabBar, {
32+
TAB_BAR_HEIGHT,
33+
} from '../components/Tabbar/CustomTabBar';
3234
import WebsitesHomeScreen from '../screens/Services/ServicesScreen';
3335
import Mascot, { MASCOT_STYLE } from '../components/Mascot/Mascot';
3436
import { usePreferences } from '../context/preferencesContext';
@@ -129,6 +131,11 @@ function TabNavigator(props: PropsType) {
129131
<CustomTabBar {...tabProps} labels={LABELS} icons={ICONS} />
130132
)}
131133
backBehavior={'initialRoute'}
134+
screenOptions={{
135+
sceneStyle: {
136+
paddingBottom: TAB_BAR_HEIGHT,
137+
},
138+
}}
132139
>
133140
<Tab.Screen
134141
name={TabRoutes.Services}

src/screens/About/AboutDependenciesScreen.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import * as React from 'react';
2121
import { List } from 'react-native-paper';
2222
import { View } from 'react-native-animatable';
2323
import { FlatList } from 'react-native';
24-
import { TAB_BAR_HEIGHT } from '../../components/Tabbar/CustomTabBar';
24+
2525
import packageJson from '../../../package.json';
2626

2727
type ListItemType = {
@@ -80,7 +80,6 @@ export default function AboutDependenciesScreen() {
8080
// Performance props, see https://reactnative.dev/docs/optimizing-flatlist-configuration
8181
removeClippedSubviews
8282
getItemLayout={getItemLayout}
83-
contentContainerStyle={{ paddingBottom: TAB_BAR_HEIGHT }}
8483
/>
8584
</View>
8685
);

src/screens/About/AboutScreen.tsx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import i18n from 'i18n-js';
2323
import { StackNavigationProp } from '@react-navigation/stack';
2424
import packageJson from '../../../package.json';
2525
import { FlatList } from 'react-native';
26-
import { TAB_BAR_HEIGHT } from '../../components/Tabbar/CustomTabBar';
26+
2727
import OptionsDialog from '../../components/Dialogs/OptionsDialog';
2828
import type { OptionsDialogButtonType } from '../../components/Dialogs/OptionsDialog';
2929
import GENERAL_STYLES from '../../constants/Styles';
@@ -182,12 +182,7 @@ function AboutScreen() {
182182

183183
return (
184184
<View style={GENERAL_STYLES.flex}>
185-
<FlatList
186-
style={styles.list}
187-
data={DATA_ORDER}
188-
renderItem={renderItem}
189-
contentContainerStyle={{ paddingBottom: TAB_BAR_HEIGHT }}
190-
/>
185+
<FlatList style={styles.list} data={DATA_ORDER} renderItem={renderItem} />
191186
{dialog != null ? (
192187
<OptionsDialog
193188
visible={dialog != null}

src/screens/About/DebugScreen.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import {
3030
import { Modalize } from 'react-native-modalize';
3131
import CustomModal from '../../components/Overrides/CustomModal';
3232
import { FlatList } from 'react-native';
33-
import { TAB_BAR_HEIGHT } from '../../components/Tabbar/CustomTabBar';
33+
3434
import { usePreferences } from '../../context/preferencesContext';
3535
import {
3636
defaultPreferences,
@@ -155,7 +155,6 @@ function DebugScreen() {
155155
data={currentPreferences}
156156
extraData={currentPreferences}
157157
renderItem={getRenderItem}
158-
contentContainerStyle={{ paddingBottom: TAB_BAR_HEIGHT }}
159158
/>
160159
</View>
161160
);

src/screens/Amicale/AmicaleContactScreen.tsx

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import * as React from 'react';
2121
import { FlatList, Image, Linking, StyleSheet, View } from 'react-native';
2222
import { Avatar, Card, List, Text } from 'react-native-paper';
2323
import i18n from 'i18n-js';
24-
import { TAB_BAR_HEIGHT } from '../../components/Tabbar/CustomTabBar';
2524

2625
const AMICALE_LOGO = require('../../../assets/amicale.png');
2726

@@ -171,13 +170,7 @@ function AmicaleContactScreen() {
171170
};
172171

173172
// We cannot wrap flatlists inside scrollviews
174-
return (
175-
<FlatList
176-
data={[{ key: '1' }]}
177-
renderItem={renderItem}
178-
contentContainerStyle={{ paddingBottom: TAB_BAR_HEIGHT }}
179-
/>
180-
);
173+
return <FlatList data={[{ key: '1' }]} renderItem={renderItem} />;
181174
}
182175

183176
export default AmicaleContactScreen;

src/screens/Amicale/Clubs/ClubAboutScreen.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import { Card, Avatar, Text } from 'react-native-paper';
2323
import i18n from 'i18n-js';
2424
import Autolink from 'react-native-autolink';
2525
import { ScrollView } from 'react-native';
26-
import { TAB_BAR_HEIGHT } from '../../../components/Tabbar/CustomTabBar';
26+
2727
const AMICALE_ICON = require('../../../../assets/amicale.png');
2828

2929
const CONTACT_LINK = 'clubs@amicale-insat.fr';
@@ -51,10 +51,7 @@ const styles = StyleSheet.create({
5151

5252
function ClubAboutScreen() {
5353
return (
54-
<ScrollView
55-
style={styles.container}
56-
contentContainerStyle={{ paddingBottom: TAB_BAR_HEIGHT }}
57-
>
54+
<ScrollView style={styles.container}>
5855
<View style={styles.imageContainer}>
5956
<Image
6057
source={AMICALE_ICON}

src/screens/Amicale/Clubs/ClubDisplayScreen.tsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import {
2929
} from 'react-native-paper';
3030
import i18n from 'i18n-js';
3131
import CustomHTML from '../../../components/Overrides/CustomHTML';
32-
import { TAB_BAR_HEIGHT } from '../../../components/Tabbar/CustomTabBar';
32+
3333
import type { Club, ClubRespo } from './ClubListScreen';
3434
import { ScrollView } from 'react-native';
3535
import ImageGalleryButton from '../../../components/Media/ImageGalleryButton';
@@ -155,7 +155,7 @@ function ClubDisplayScreen(props: Props) {
155155
return (
156156
<Card
157157
style={{
158-
marginBottom: TAB_BAR_HEIGHT + 20,
158+
marginBottom: 20,
159159
...styles.card,
160160
}}
161161
>
@@ -219,10 +219,7 @@ function ClubDisplayScreen(props: Props) {
219219
if (club) {
220220
console.log(club);
221221
return (
222-
<ScrollView
223-
style={styles.scroll}
224-
contentContainerStyle={{ paddingBottom: TAB_BAR_HEIGHT }}
225-
>
222+
<ScrollView style={styles.scroll}>
226223
{getCategoriesRender(club.categories)}
227224
{club.logo !== null ? (
228225
<ImageGalleryButton

src/screens/Amicale/Equipment/EquipmentConfirmScreen.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import { StyleSheet, View } from 'react-native';
3030
import i18n from 'i18n-js';
3131
import { getRelativeDateString } from '../../../utils/EquipmentBooking';
3232
import { ScrollView } from 'react-native';
33-
import { TAB_BAR_HEIGHT } from '../../../components/Tabbar/CustomTabBar';
33+
3434
import { StackScreenProps } from '@react-navigation/stack';
3535
import {
3636
MainRoutes,
@@ -93,7 +93,7 @@ function EquipmentConfirmScreen(props: Props) {
9393
});
9494
}
9595
return (
96-
<ScrollView contentContainerStyle={{ paddingBottom: TAB_BAR_HEIGHT }}>
96+
<ScrollView>
9797
<Card style={styles.card}>
9898
<Card.Content>
9999
<View style={GENERAL_STYLES.flex}>

0 commit comments

Comments
 (0)