Skip to content

Commit 1b8ad3e

Browse files
Merge pull request #120 from OpenDTU-App/113-ensure-every-view-has-some-margin-below-it
2 parents 6ee5d12 + 55a9e11 commit 1b8ad3e

24 files changed

+240
-207
lines changed

src/components/devices/DeviceList.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { FC } from 'react';
22
import { Box } from 'react-native-flex-layout';
33

4-
import { ScrollView } from 'react-native';
4+
import { ScrollView, View } from 'react-native';
55

66
import DeviceListItem from '@/components/devices/DeviceListItem';
77

@@ -22,6 +22,7 @@ const DeviceList: FC = () => {
2222
/>
2323
))}
2424
</Box>
25+
<View style={{ height: spacing * 2 }} />
2526
</ScrollView>
2627
);
2728
};

src/components/inverters/InverterList.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { FC } from 'react';
22
import { Box } from 'react-native-flex-layout';
33

4-
import { ScrollView } from 'react-native';
4+
import { ScrollView, View } from 'react-native';
55

66
import InverterListItem from '@/components/inverters/InverterListItem';
77

@@ -43,6 +43,7 @@ const InverterList: FC = () => {
4343
/>
4444
))}
4545
</Box>
46+
<View style={{ height: spacing * 2 }} />
4647
</ScrollView>
4748
);
4849
};

src/components/styled/StyledListItem.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const StyledListItem: FC<ListItemProps> = props => {
66
return (
77
<Surface
88
mode="flat"
9-
elevation={props.disabled ? 1 : 5}
9+
elevation={props.disabled ? 1 : 3}
1010
style={{
1111
borderRadius: 16,
1212
...(props.disabled && { opacity: 0.5 }),

src/style.tsx

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import { ScrollView, View } from 'react-native';
1010

1111
import styled from 'styled-components';
1212

13+
import { spacing } from '@/constants';
14+
1315
import { DarkTheme, DefaultTheme } from '@react-navigation/native';
1416

1517
export const ReactNavigationDarkTheme = {
@@ -34,20 +36,15 @@ export const ReactNavigationLightTheme = {
3436
},*/
3537
};
3638

37-
export const StyledView = styled(View)`
38-
background-color: ${props => props.theme.colors.background};
39-
color: ${props => props.theme.colors.onBackground};
40-
flex: 1;
41-
align-items: center;
42-
justify-content: center;
43-
width: 100%;
44-
`;
45-
4639
export interface StyledScrollViewProps extends ScrollViewProps {
4740
theme: MD3Theme;
41+
disableSafeBottomMargin?: boolean;
4842
}
4943

50-
export const StyledScrollView: FC<StyledScrollViewProps> = props => {
44+
export const StyledScrollView: FC<StyledScrollViewProps> = ({
45+
children,
46+
...props
47+
}) => {
5148
const rnpTheme = useTheme();
5249
const theme = props.theme ?? rnpTheme;
5350

@@ -60,21 +57,32 @@ export const StyledScrollView: FC<StyledScrollViewProps> = props => {
6057
color: theme.colors.onBackground,
6158
width: '100%',
6259
}}
63-
/>
60+
>
61+
{children}
62+
{props.disableSafeBottomMargin ? null : (
63+
<View style={{ height: spacing * 2 }} />
64+
)}
65+
</ScrollView>
6466
);
6567
};
6668

6769
export type StyledSafeAreaViewProps = {
6870
theme?: MD3Theme;
71+
enableSafeBottomMargin?: boolean;
6972
} & SafeAreaViewProps;
7073

71-
const InternalStyledSafeAreaView = styled(SafeAreaView)<{ theme: MD3Theme }>`
74+
const InternalStyledSafeAreaView = styled(SafeAreaView)<{
75+
theme: MD3Theme;
76+
enableSafeBottomMargin?: boolean;
77+
}>`
7278
height: 100%;
7379
flex: 1;
7480
align-items: center;
7581
background-color: ${props => props.theme.colors.background};
7682
display: flex;
7783
color: ${props => props.theme.colors.onBackground};
84+
padding-bottom: ${props =>
85+
props.enableSafeBottomMargin ? spacing * 2 : 0}px;
7886
`;
7987

8088
export const StyledSafeAreaView: FC<StyledSafeAreaViewProps> = props => {

src/views/navigation/screens/AboutAppScreen.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {
1616
useTheme,
1717
} from 'react-native-paper';
1818

19-
import { Linking, ScrollView, Text as RNText } from 'react-native';
19+
import { Linking, ScrollView, Text as RNText, View } from 'react-native';
2020

2121
import moment from 'moment';
2222

@@ -26,6 +26,7 @@ import GenericRefreshModal from '@/components/modals/GenericRefreshModal';
2626

2727
import useHasNewAppVersion from '@/hooks/useHasNewAppVersion';
2828

29+
import { spacing } from '@/constants';
2930
import { useFetchControl } from '@/github/FetchHandler';
3031
import { useAppDispatch, useAppSelector } from '@/store';
3132
import { StyledSafeAreaView } from '@/style';
@@ -189,6 +190,7 @@ const AboutAppScreen: FC<PropsWithNavigation> = ({ navigation }) => {
189190
/>
190191
)}
191192
/>
193+
<View style={{ height: spacing * 2 }} />
192194
</ScrollView>
193195
</Box>
194196
</StyledSafeAreaView>

src/views/navigation/screens/DebugColorsScreen.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { ScrollView, View } from 'react-native';
77

88
import styled from 'styled-components';
99

10+
import { spacing } from '@/constants';
1011
import { StyledSafeAreaView } from '@/style';
1112
import type { PropsWithNavigation } from '@/views/navigation/NavigationStack';
1213

@@ -50,7 +51,10 @@ const DebugColorsScreen: FC<PropsWithNavigation> = ({ navigation }) => {
5051
</Appbar.Header>
5152
<StyledSafeAreaView theme={theme}>
5253
<Box style={{ flex: 1, width: '100%' }}>
53-
<ScrollView>{flatColors}</ScrollView>
54+
<ScrollView>
55+
{flatColors}
56+
<View style={{ height: spacing * 2 }} />
57+
</ScrollView>
5458
</Box>
5559
</StyledSafeAreaView>
5660
</>

src/views/navigation/screens/DebugScreen.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { useTranslation } from 'react-i18next';
44
import { Box } from 'react-native-flex-layout';
55
import { Appbar, IconButton, List, useTheme } from 'react-native-paper';
66

7-
import { ScrollView } from 'react-native';
7+
import { ScrollView, View } from 'react-native';
88

99
import moment from 'moment';
1010

@@ -17,6 +17,7 @@ import { setDebugEnabled } from '@/slices/settings';
1717

1818
import { useApi } from '@/api/ApiHandler';
1919
import type { DebugInfo } from '@/api/opendtuapi';
20+
import { spacing } from '@/constants';
2021
import { useAppDispatch, useAppSelector } from '@/store';
2122
import { StyledSafeAreaView } from '@/style';
2223
import type { PropsWithNavigation } from '@/views/navigation/NavigationStack';
@@ -148,6 +149,7 @@ const DebugScreen: FC<PropsWithNavigation> = ({ navigation }) => {
148149
onPress={() => navigation.navigate('DebugColorsScreen')}
149150
/>
150151
</List.Section>
152+
<View style={{ height: spacing * 2 }} />
151153
</ScrollView>
152154
</Box>
153155
</StyledSafeAreaView>

0 commit comments

Comments
 (0)