-
Notifications
You must be signed in to change notification settings - Fork 0
/
DialogSheet.tsx
103 lines (98 loc) · 2.22 KB
/
DialogSheet.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
import React from 'react';
import { StyleProp, Text, TextStyle, View, ViewStyle } from 'react-native';
import { useThemeContext } from '../contexts/ThemeContext';
import createStyleSheet from '../styles/createStyleSheet';
import type { LocalIconName } from './Icon';
import { LocalIcon } from './Icon';
type DialogSheetProps = React.PropsWithChildren<{
style?: StyleProp<ViewStyle>;
}>;
const DialogSheet: ((props: DialogSheetProps) => JSX.Element) & {
ButtonItem: typeof ButtonSheetItem;
} = ({ style, children }) => {
const { colors } = useThemeContext();
return (
<View
style={[
styles.container,
{ backgroundColor: colors.card.background },
style,
]}
>
{children}
</View>
);
};
export type SheetItemProps = {
icon?: LocalIconName;
iconColor?: string;
title: string;
titleColor?: string;
containerStyle?: StyleProp<ViewStyle>;
titleStyle?: StyleProp<TextStyle>;
};
const ButtonSheetItem = ({
icon,
title,
iconColor,
titleColor,
containerStyle,
titleStyle,
}: SheetItemProps) => {
const { colors, fonts } = useThemeContext();
return (
<View
style={[
styles.sheetItemContainer,
{ backgroundColor: 'rgba(250, 250, 250, 1)' },
containerStyle,
]}
>
{icon && (
<LocalIcon
name={icon}
color={iconColor ?? colors.primary}
containerStyle={styles.sheetItemIcon}
/>
)}
<Text
numberOfLines={1}
style={[
styles.sheetItemText,
{ color: titleColor ?? colors.text },
fonts.sheet,
titleStyle,
]}
>
{title}
</Text>
</View>
);
};
const styles = createStyleSheet({
container: {
overflow: 'hidden',
flexDirection: 'column',
width: '100%',
borderTopLeftRadius: 8,
borderTopRightRadius: 8,
alignItems: 'center',
},
sheetItemContainer: {
marginTop: 12,
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'center',
height: 48,
minWidth: '90%',
borderRadius: 24,
},
sheetItemIcon: {
marginLeft: 16,
},
sheetItemText: {
marginHorizontal: 24,
},
});
DialogSheet.ButtonItem = ButtonSheetItem;
export default DialogSheet;