This repository has been archived by the owner on May 2, 2019. It is now read-only.
/
REStyled.re
57 lines (49 loc) · 1.74 KB
/
REStyled.re
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
open BsReactNative;
let get = (arg, default) =>
switch arg {
| None => default
| Some(value) => value
};
module type StyledConfig = {type styleParams; let style: option(styleParams) => Style.t;};
module View = (Config: StyledConfig) => {
let make = (~styled=?, ~style as additionalStyle=Style.(style([]))) =>
View.make(~style=Style.combine(Config.style(styled), additionalStyle));
};
module Text =
(
Config: {
type styleParams;
let defaultParams: styleParams;
let style: (~params: styleParams) => Style.t;
}
) => {
let make = (~styled=?, ~style as additionalStyle=Style.(style([]))) => {
let params = get(styled, Config.defaultParams);
Text.make(~style=Style.combine(Config.style(~params), additionalStyle))
};
};
module ScrollView = (Config: StyledConfig) => {
let make = (~styled=?, ~style as additionalStyle=Style.(style([]))) =>
ScrollView.make(~style=Style.combine(Config.style(styled), additionalStyle));
};
module TouchableOpacity = (Config: StyledConfig) => {
let make = (~styled=?, ~style as additionalStyle=Style.(style([]))) =>
TouchableOpacity.make(~style=Style.combine(Config.style(styled), additionalStyle));
};
module TextInput = (Config: StyledConfig) => {
let make = (~styled=?, ~style as additionalStyle=Style.(style([]))) =>
TextInput.make(
~style=
Style.combine(
switch styled {
| Some(params) => Config.style(params)
| None => Style.style([])
},
additionalStyle
)
);
};
module Image = (Config: StyledConfig) => {
let make = (~styled=?, ~style as additionalStyle=Style.(style([]))) =>
Image.make(~style=Style.combine(Config.style(styled), additionalStyle));
};