-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathModuleStatic.tsx
59 lines (52 loc) · 1.31 KB
/
ModuleStatic.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
import * as React from "react";
import { PressableProps, View } from "react-native";
import { IOColors, IOModuleStyles, useIOTheme } from "../../core";
import { HStack } from "../stack";
type ModuleStaticProps =
| ModuleStaticSingleBlockProps
| ModuleStaticMultipleBlockProps;
type ModuleStaticMultipleBlockProps = {
startBlock: React.ReactNode;
endBlock?: React.ReactNode;
children?: never;
disabled?: PressableProps["disabled"];
};
type ModuleStaticSingleBlockProps = {
startBlock?: never;
endBlock?: never;
children: React.ReactNode;
disabled?: PressableProps["disabled"];
};
const DISABLED_OPACITY = 0.5;
export const ModuleStatic = ({
disabled = false,
startBlock,
endBlock,
children
}: ModuleStaticProps) => {
const theme = useIOTheme();
return (
<View
style={[
IOModuleStyles.button,
{
borderColor: IOColors[theme["cardBorder-default"]],
opacity: disabled ? DISABLED_OPACITY : 1
}
]}
accessible={false}
>
{startBlock && (
<HStack space={8} style={{ alignItems: "center" }}>
<View
style={{ flexDirection: "row", alignItems: "center", flexGrow: 1 }}
>
{startBlock}
</View>
{endBlock}
</HStack>
)}
{children}
</View>
);
};