Skip to content

Commit 6b74728

Browse files
authored
Merge pull request #318 from ZeroGachis/fix/remove-hard-lib
remove hardware on a design library
2 parents 156a674 + 00d7781 commit 6b74728

File tree

10 files changed

+19
-51
lines changed

10 files changed

+19
-51
lines changed

Storybook/package-lock.json

Lines changed: 0 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Storybook/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
"react-dom": "^18.2.0",
2929
"react-native": "0.72.4",
3030
"react-native-code-push": "^8.1.0",
31-
"react-native-device-info": "^10.12.0",
3231
"react-native-drop-shadow": "^0.0.6",
3332
"react-native-gesture-handler": "^2.12.0",
3433
"react-native-icomoon": "^0.1.1",

jest.setup.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1 @@
11
import '@testing-library/react-native/extend-expect';
2-
//This 2 following lines are mandatory since we add and use react-native-device-info
3-
import mockRNDeviceInfo from 'react-native-device-info/jest/react-native-device-info-mock';
4-
// eslint-disable-next-line no-undef
5-
jest.mock('react-native-device-info', () => mockRNDeviceInfo);

modules.d.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.

package-lock.json

Lines changed: 0 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@
7575
"@gorhom/bottom-sheet": "*",
7676
"react": "*",
7777
"react-native": "*",
78-
"react-native-device-info": "*",
7978
"react-native-drop-shadow": "*",
8079
"react-native-gesture-handler": "*",
8180
"react-native-icomoon": "*",

src/components/Screen.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@ import React from 'react';
22
import { SafeAreaView, ViewStyle, StatusBar, StyleSheet } from 'react-native';
33
import { useSafeAreaInsets } from 'react-native-safe-area-context';
44
import { useTheme } from '../styles/themes';
5-
import DeviceInfo from 'react-native-device-info';
65
import type { WithTestID } from 'src/shared/type';
76

87
type Props = WithTestID<{
98
children?: React.ReactNode;
109
style?: ViewStyle;
1110
statusBarColor?: string;
11+
isTablet?: boolean;
1212
}>;
1313

14-
export const Screen = ({ children, style, testID, statusBarColor }: Props) => {
14+
export const Screen = ({ children, style, testID, statusBarColor, isTablet = true }: Props) => {
1515
const theme = useTheme();
1616
const insets = useSafeAreaInsets();
17-
const isTablet = DeviceInfo.isTablet();
17+
1818

1919
const styles = StyleSheet.create({
2020
screen: {

src/components/modals/Modal.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { Button } from '../buttons/Button';
55
import { Headline } from '../typography/Headline';
66
import { DialogIcon, DialogIconProps } from './ModalIcon';
77
import { useTheme } from '../../styles/themes';
8-
import DeviceInfo from 'react-native-device-info';
98

109
interface Action {
1110
label: string;
@@ -33,10 +32,11 @@ export interface ModalProps extends PropsWithChildren {
3332
dismissable?: boolean;
3433
onDismiss?: () => void;
3534
actions: ModalActions;
35+
isTablet?: boolean;
3636
}
3737

3838
export const Modal = (props: ModalProps) => {
39-
const { style, actionsStyle, leftActionsStyle, rightActionsStyle, actions, variant } = props;
39+
const { style, actionsStyle, leftActionsStyle, rightActionsStyle, actions, variant, isTablet = true } = props;
4040

4141
const styles = useStyles({
4242
style,
@@ -45,6 +45,7 @@ export const Modal = (props: ModalProps) => {
4545
rightActionsStyle,
4646
cancel: actions.cancel,
4747
variant,
48+
isTablet,
4849
});
4950

5051
return (
@@ -113,7 +114,7 @@ export const Modal = (props: ModalProps) => {
113114

114115
type UseStylesProps = Pick<
115116
ModalProps,
116-
'style' | 'actionsStyle' | 'leftActionsStyle' | 'rightActionsStyle' | 'variant'
117+
'style' | 'actionsStyle' | 'leftActionsStyle' | 'rightActionsStyle' | 'variant' | 'isTablet'
117118
> & {
118119
cancel: ModalProps['actions']['cancel'];
119120
};
@@ -125,6 +126,7 @@ function useStyles({
125126
rightActionsStyle,
126127
cancel,
127128
variant,
129+
isTablet,
128130
}: UseStylesProps) {
129131
const theme = useTheme();
130132

@@ -202,5 +204,5 @@ function useStyles({
202204
rightOption: commonStyleSheet.rightOption,
203205
});
204206

205-
return DeviceInfo.isTablet() ? createTabletStyle() : createMobileStyle();
207+
return isTablet ? createTabletStyle() : createMobileStyle();
206208
}

src/components/topAppBar/TopAppBar.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { Appbar } from 'react-native-paper';
33
import { useTheme } from '../../styles/themes';
44
import { StyleSheet, type ViewStyle } from 'react-native';
55
import { Headline } from '../typography/Headline';
6-
import DeviceInfo from 'react-native-device-info';
76
import type { WithTestID } from 'src/shared/type';
87
import TopAppBarAction from './TopAppBarAction';
98
import { TopAppBarMenu } from './Menu/TopAppBarMenu';
@@ -20,10 +19,9 @@ export type TopAppBarProps = WithTestID<{
2019
onBack?: () => void;
2120
style?: ViewStyle;
2221
action?: ReactNode;
22+
isTablet?: boolean;
2323
}>;
2424

25-
const isTablet = DeviceInfo.isTablet();
26-
2725
// eslint-disable-next-line react/function-component-definition
2826
export function TopAppBar({
2927
size = 'small',
@@ -32,8 +30,9 @@ export function TopAppBar({
3230
style,
3331
testID,
3432
action,
33+
isTablet = true,
3534
}: TopAppBarProps) {
36-
const styles = useStyles(size, style);
35+
const styles = useStyles(size, style, isTablet);
3736

3837
const headlineSize = isTablet ? 'n1' : isTitleBelowTopAppBar(size) ? 'n2' : 'n1';
3938

@@ -69,7 +68,7 @@ TopAppBar.Action = TopAppBarAction;
6968
TopAppBar.Menu = TopAppBarMenu;
7069
TopAppBar.MenuItem = TopAppBarMenuItem;
7170

72-
function useStyles(size: TopAppBarProps['size'], style: TopAppBarProps['style']) {
71+
function useStyles(size: TopAppBarProps['size'], style: TopAppBarProps['style'], isTablet: TopAppBarProps['isTablet']) {
7372
const theme = useTheme();
7473

7574
return StyleSheet.create({

src/components/topAppBar/TopAppBarAction.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
import React, { ComponentProps } from 'react';
22
import { Appbar } from 'react-native-paper';
33
import { Theme, useTheme } from '../../styles/themes';
4-
import DeviceInfo from 'react-native-device-info';
54
import { StyleSheet } from 'react-native';
65

7-
type TopAppBarActionProps = ComponentProps<typeof Appbar.Action>;
6+
type TopAppBarActionProps = ComponentProps<typeof Appbar.Action> & {
7+
isTablet?: boolean;
8+
};
89
const TopAppBarAction = (props: TopAppBarActionProps) => {
10+
const { isTablet = true } = props;
911
const theme = useTheme();
10-
const styles = useStyles(theme);
12+
const styles = useStyles(theme, isTablet);
1113

1214
return (
1315
<Appbar.Action
@@ -20,9 +22,7 @@ const TopAppBarAction = (props: TopAppBarActionProps) => {
2022
);
2123
};
2224

23-
function useStyles(theme: Theme) {
24-
const isTablet = DeviceInfo.isTablet();
25-
25+
function useStyles(theme: Theme, isTablet: boolean) {
2626
return StyleSheet.create({
2727
button: {
2828
backgroundColor: theme.sw.color.neutral[300],

0 commit comments

Comments
 (0)