Skip to content

Commit

Permalink
💄 Screen - apply different padding if it's tablet or not
Browse files Browse the repository at this point in the history
  • Loading branch information
clementdejoie committed Dec 6, 2023
1 parent 8ac544d commit e74718a
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 7 deletions.
9 changes: 9 additions & 0 deletions Storybook/package-lock.json

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

1 change: 1 addition & 0 deletions Storybook/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"react-dom": "^18.2.0",
"react-native": "0.72.4",
"react-native-code-push": "^8.1.0",
"react-native-device-info": "^10.12.0",
"react-native-drop-shadow": "^0.0.6",
"react-native-gesture-handler": "^2.12.0",
"react-native-icomoon": "^0.1.1",
Expand Down
1 change: 1 addition & 0 deletions jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const jestConfig: JestConfigWithTsJest = {
],
moduleDirectories: ['node_modules', 'src'],
setupFiles: [
'./jest.setup.js',
'./node_modules/react-native-gesture-handler/jestSetup.js',
'./node_modules/react-native/jest/setup.js',
],
Expand Down
3 changes: 3 additions & 0 deletions jest.setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// This 2 following lines are mandatory since we add and use react-native-device-info
import mockRNDeviceInfo from 'react-native-device-info/jest/react-native-device-info-mock';
jest.mock('react-native-device-info', () => mockRNDeviceInfo);
17 changes: 17 additions & 0 deletions package-lock.json

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

10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,15 @@
"@gorhom/bottom-sheet": "*",
"react": "*",
"react-native": "*",
"react-native-device-info": "*",
"react-native-drop-shadow": "*",
"react-native-gesture-handler": "*",
"react-native-icomoon": "*",
"react-native-linear-gradient": "*",
"react-native-paper": "*",
"react-native-reanimated": "*",
"react-native-safe-area-context": "*",
"react-native-svg": "*",
"react-native-vector-icons": "*",
"react-native-drop-shadow": "*",
"react-native-linear-gradient": "*"
},
"dependencies": {}
"react-native-vector-icons": "*"
}
}
6 changes: 4 additions & 2 deletions src/components/Screen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from 'react';
import { SafeAreaView, ViewStyle, StatusBar, StyleSheet } from 'react-native';
import { useSafeAreaInsets } from 'react-native-safe-area-context';
import { useTheme } from '../styles/themes';
import DeviceInfo from 'react-native-device-info';
import type { WithTestID } from 'src/shared/type';

type Props = WithTestID<{
Expand All @@ -13,14 +14,15 @@ type Props = WithTestID<{
export const Screen = ({ children, style, testID, statusBarColor }: Props) => {
const theme = useTheme();
const insets = useSafeAreaInsets();
const isTablet = DeviceInfo.isTablet();

const styles = StyleSheet.create({
screen: {
flex: 1,
backgroundColor: theme.sw.colors.neutral[50],
marginTop: insets.top,
paddingLeft: theme.sw.spacing.m,
paddingRight: theme.sw.spacing.m,
paddingLeft: isTablet ? theme.sw.spacing.m : 0,
paddingRight: isTablet ? theme.sw.spacing.m : 0,
...style,
},
});
Expand Down

0 comments on commit e74718a

Please sign in to comment.