|
1 | 1 | import type { FC } from 'react'; |
2 | | -import type { SurfaceProps } from 'react-native-paper'; |
3 | | -import { Surface } from 'react-native-paper'; |
| 2 | +import type { ViewProps } from 'react-native'; |
| 3 | +import { useTheme } from 'react-native-paper'; |
4 | 4 | import type { ThemeProp } from 'react-native-paper/lib/typescript/types'; |
5 | 5 |
|
6 | | -import styled from 'styled-components'; |
| 6 | +import { View } from 'react-native'; |
7 | 7 |
|
8 | | -const InternalStyledSurface = styled(Surface)<ExtraProps>` |
9 | | - border-radius: ${({ theme, roundness }) => |
10 | | - theme.roundness! * (roundness ?? 4)}px; |
11 | | - flex: 1; |
12 | | - box-shadow: ${({ theme, disableShadow }) => |
13 | | - disableShadow ? 'none' : theme.shadow}; |
14 | | -`; |
15 | | - |
16 | | -interface ExtraProps { |
| 8 | +export type StyledSurfaceProps = ViewProps & { |
| 9 | + theme: ThemeProp; |
17 | 10 | roundness?: number; |
18 | | - disableShadow?: boolean; |
19 | | -} |
| 11 | +}; |
20 | 12 |
|
21 | | -export type StyledSurfaceProps = SurfaceProps & { |
22 | | - theme: ThemeProp; |
23 | | -} & ExtraProps; |
| 13 | +const StyledSurface: FC<StyledSurfaceProps> = ({ children, ...props }) => { |
| 14 | + const theme = useTheme(); |
24 | 15 |
|
25 | | -const StyledSurface: FC<StyledSurfaceProps> = ({ children, ...props }) => ( |
26 | | - <InternalStyledSurface elevation={5} mode="flat" disableShadow {...props}> |
27 | | - {children} |
28 | | - </InternalStyledSurface> |
29 | | -); |
| 16 | + return ( |
| 17 | + <View |
| 18 | + {...props} |
| 19 | + style={{ |
| 20 | + //@ts-expect-error: 2698 because idk |
| 21 | + ...(props?.style ?? {}), |
| 22 | + borderRadius: theme.roundness! * (props.roundness ?? 4), |
| 23 | + backgroundColor: theme.colors.elevation.level5, |
| 24 | + flex: 1, |
| 25 | + }} |
| 26 | + > |
| 27 | + {children} |
| 28 | + </View> |
| 29 | + ); |
| 30 | +}; |
30 | 31 |
|
31 | 32 | export default StyledSurface; |
0 commit comments