Skip to content

Commit 9c5d7ef

Browse files
committed
Paper.re and Paper to UnstatedDemo
1 parent e561333 commit 9c5d7ef

File tree

4 files changed

+54
-24
lines changed

4 files changed

+54
-24
lines changed

src/Demos/UnstatedDemo.re

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ open ReactNative;
22
let styles =
33
Style.(
44
StyleSheet.create({
5-
"buttons": style(~flexDirection=`row, ~padding=8.->dp, ()),
5+
"buttons": style(~flexDirection=`column, ~padding=8.->dp, ()),
66
"button": style(~margin=8.->dp, ()),
77
})
88
);
@@ -31,33 +31,39 @@ module Counter =
3131
type value = counter;
3232
let useHook = useCounter;
3333
});
34+
3435
module CounterDisplay = {
3536
[@react.component]
3637
let make = () => {
3738
let counter = Counter.useContainer();
38-
<View
39-
style=Style.(
39+
// <View style=styles##buttons>
40+
<View style=Style.(
4041
style(~flex=1., ~alignItems=`center, ~justifyContent=`center, ())
4142
)>
42-
<View style=Style.(style(~width=100.->dp, ~height=50.->dp, ()))>
43-
<Button title="-" onPress={_ => counter.decrement()} />
44-
</View>
43+
<Paper.IconButton
44+
mode=`contained
45+
onPress={_ => counter.decrement()}
46+
style=styles##button
47+
icon="remove"
48+
/>
4549
<Text style=Style.(style(~fontSize=50., ()))>
4650
{React.string(string_of_int(counter.count))}
4751
</Text>
48-
<View style=Style.(style(~width=100.->dp, ~height=50.->dp, ()))>
49-
<Button title="+" onPress={_ => counter.increment()} />
50-
</View>
51-
<PaperButton
52+
<Paper.IconButton
5253
mode=`contained
53-
onPress={_ => counter.reset()}
54+
onPress={_ => counter.increment()}
5455
style=styles##button
55-
>"Reset"->React.string</PaperButton>
56+
icon="add"
57+
/>
58+
<Paper.Button
59+
mode=`contained onPress={_ => counter.reset()} style=styles##button>
60+
"Reset"->React.string
61+
</Paper.Button>
5662
</View>;
5763
};
5864
};
5965

60-
module HomeScreen = {
66+
module App = {
6167
[@react.component]
6268
let make = () =>
6369
<Counter.Provider>
@@ -67,4 +73,4 @@ module HomeScreen = {
6773
};
6874

6975
[@react.component]
70-
let make = () => <HomeScreen />;
76+
let make = () => <App />;

src/SimpleStacks.re

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
open ReactNavigation;
22

33
open ReactNative;
4-
module Button = PaperButton;
4+
module Button = Paper.Button;
55
let styles =
66
Style.(
77
StyleSheet.create({

src/components/Paper.re

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
module Button = {
2+
[@bs.module ("react-native-paper", "Button")] [@react.component]
3+
external make:
4+
(
5+
~mode: [@bs.string] [ | `text | `outlined | `contained],
6+
~onPress: unit => unit,
7+
~color: string=?,
8+
~icon: string=?,
9+
~style: ReactNative.Style.t,
10+
~children:'b
11+
) =>
12+
// ~children:'b
13+
React.element =
14+
"Button";
15+
};
16+
17+
module IconButton = {
18+
[@bs.module ("react-native-paper", "IconButton")] [@react.component]
19+
external make:
20+
(
21+
~icon: string,
22+
~color: string=?,
23+
~size: float=?,
24+
~accessibilityLabel: string=?,
25+
~onPress: unit => unit,
26+
~style: ReactNative.Style.t=?,
27+
~theme: 'a=?,
28+
// ~children:'b,
29+
~mode: [@bs.string] [ | `text | `outlined | `contained]
30+
) =>
31+
React.element =
32+
"IconButton";
33+
};

src/components/PaperButton.re

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)