Skip to content

Commit 9c57357

Browse files
committed
Revert "Remove deprecated Card Wrapper"
This reverts commit 5b5de36.
1 parent b3c7557 commit 9c57357

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import React from "react";
2+
import { withTheme } from "../theming";
3+
import Touchable from "./Touchable";
4+
import { StyleProp, ViewStyle } from "react-native";
5+
import theme from "../styles/DefaultTheme";
6+
7+
type Props = {
8+
numColumns?: number;
9+
children?: React.ReactNode;
10+
onPress?: () => void;
11+
style?: StyleProp<ViewStyle>;
12+
theme: typeof theme;
13+
};
14+
15+
const getWidth = (numColumns: number) => {
16+
switch (numColumns) {
17+
case 1:
18+
return "33%";
19+
case 2:
20+
return "50%";
21+
default:
22+
return "100%";
23+
}
24+
};
25+
26+
const Card: React.FC<React.PropsWithChildren<Props>> = ({
27+
numColumns = 3,
28+
children,
29+
onPress,
30+
style,
31+
...rest
32+
}) => {
33+
const width = getWidth(numColumns);
34+
return (
35+
<Touchable
36+
disabled={!onPress}
37+
onPress={onPress}
38+
style={[style, { width }]}
39+
{...rest}
40+
>
41+
{children}
42+
</Touchable>
43+
);
44+
};
45+
46+
export default withTheme(Card);

0 commit comments

Comments
 (0)