Skip to content

Commit

Permalink
Reformat code using new refmt (facebook#263)
Browse files Browse the repository at this point in the history
  • Loading branch information
czystyl authored and wokalski committed Oct 1, 2018
1 parent 997da7e commit 2eb2f3a
Show file tree
Hide file tree
Showing 187 changed files with 1,616 additions and 1,681 deletions.
2 changes: 1 addition & 1 deletion example/App.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export {reactClass as default} from './lib/js/src/RNTesterApp.js';
export { reactClass as default } from './lib/js/src/RNTesterApp.js';
2 changes: 1 addition & 1 deletion example/src/ExampleList.re
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,4 @@ let components: array(item) = [|
Settings.item("SettingsExample"),
ImageStore.item("ImageStoreExample"),
ActivityIndicator.item("ActivityIndicatorExample"),
|];
|];
107 changes: 55 additions & 52 deletions example/src/RNTesterApp.re
Original file line number Diff line number Diff line change
Expand Up @@ -2,59 +2,57 @@ open BsReactNative;

let styles =
StyleSheet.create(
Style.(
{
"header":
style([
height(Pt(60.)),
borderBottomWidth(StyleSheet.hairlineWidth),
borderBottomColor(String("#96969A")),
backgroundColor(String("#F5F5F6")),
alignItems(Center),
justifyContent(Center),
flexDirection(Row),
]),
"headerLeft":
style([
position(Absolute),
top(Pt(0.)),
left(Pt(10.)),
bottom(Pt(0.)),
alignItems(Center),
justifyContent(Center),
]),
"headerCenter": style([flex(1.0)]),
"title":
style([
fontSize(Float(19.)),
fontWeight(`_600),
textAlign(Center),
]),
"exampleContainer": style([flex(1.0)]),
"appContainer":
style([
flex(1.0),
backgroundColor(String("#F5F5F6")),
marginTop(Pt(Platform.os() == Platform.Android ? 20.0 : 0.0))
]),
}
),
Style.{
"header":
style([
height(Pt(60.)),
borderBottomWidth(StyleSheet.hairlineWidth),
borderBottomColor(String("#96969A")),
backgroundColor(String("#F5F5F6")),
alignItems(Center),
justifyContent(Center),
flexDirection(Row),
]),
"headerLeft":
style([
position(Absolute),
top(Pt(0.)),
left(Pt(10.)),
bottom(Pt(0.)),
alignItems(Center),
justifyContent(Center),
]),
"headerCenter": style([flex(1.0)]),
"title":
style([
fontSize(Float(19.)),
fontWeight(`_600),
textAlign(Center),
]),
"exampleContainer": style([flex(1.0)]),
"appContainer":
style([
flex(1.0),
backgroundColor(String("#F5F5F6")),
marginTop(Pt(Platform.os() == Platform.Android ? 20.0 : 0.0)),
]),
},
);

let header = (~onBack=?, ~title, ()) =>
<View style=styles##header>
<View style=styles##headerCenter>
<Text style=styles##title> (ReasonReact.string(title)) </Text>
<Text style=styles##title> {ReasonReact.string(title)} </Text>
</View>
(
{
switch (onBack) {
| None => ReasonReact.null
| Some(onBack) =>
<View style=styles##headerLeft>
<Button title="Back" onPress=onBack />
</View>
}
)
}
</View>;

type action =
Expand All @@ -71,26 +69,31 @@ let make = _children => {
switch (action) {
| ChangeCurrentExample(example) => Update({currentExample: example})
},
didMount: (self) => {
didMount: self => {
let handler = () => {
let didHandleBackButton = ref(false);
self.handle((_, self) => {
self.send(ChangeCurrentExample(None));
didHandleBackButton := Js.Option.isSome(self.state.currentExample);
})(());
self.handle(
(_, self) => {
self.send(ChangeCurrentExample(None));
didHandleBackButton := Js.Option.isSome(self.state.currentExample);
},
(),
);
didHandleBackButton^;
};
BackHandler.addEventListener("hardwareBackPress", handler);
self.onUnmount(() => BackHandler.removeEventListener("hardwareBackPress", handler));
self.onUnmount(() =>
BackHandler.removeEventListener("hardwareBackPress", handler)
);
},
render: ({state, send}) => {
let components = ExampleList.components;
<SafeAreaView style=styles##appContainer>
(
{
switch (state.currentExample) {
| None =>
<View style=styles##exampleContainer>
(header(~title="ReasonRNTester", ()))
{header(~title="ReasonRNTester", ())}
<RNTesterExampleList
components
onPress=(
Expand All @@ -106,20 +109,20 @@ let make = _children => {
example.examples[0].render()
| Some(example) =>
<View style=styles##exampleContainer>
(
{
header(
~title=example.title,
~onBack=_event => send(ChangeCurrentExample(None)),
(),
)
)
}
<RNTesterExampleContainer example />
</View>
}
)
}
</SafeAreaView>;
},
};

let reactClass =
ReasonReact.wrapReasonForJs(~component, _jsProps => make([||]));
ReasonReact.wrapReasonForJs(~component, _jsProps => make([||]));
80 changes: 39 additions & 41 deletions example/src/RNTesterBlock.re
Original file line number Diff line number Diff line change
Expand Up @@ -2,41 +2,39 @@ open BsReactNative;

let styles =
StyleSheet.create(
Style.(
{
"container":
style([
borderRadius(3.),
borderWidth(1.),
borderColor(String("#d6d7da")),
backgroundColor(String("#ffffff")),
margin(Pt(10.)),
marginVertical(Pt(5.)),
overflow(Hidden),
]),
"titleContainer":
style([
borderBottomWidth(1.),
borderTopLeftRadius(3.),
borderTopRightRadius(3.),
borderBottomColor(String("#d6d7da")),
backgroundColor(String("#f6f7f8")),
paddingHorizontal(Pt(10.)),
paddingVertical(Pt(5.)),
]),
"titleText": style([fontSize(Float(14.)), fontWeight(`_500)]),
"descriptionText": style([fontSize(Float(14.))]),
"disclosure":
style([
position(Absolute),
top(Pt(0.)),
right(Pt(0.)),
padding(Pt(10.)),
]),
"disclosureIcon": style([width(Pt(12.)), height(Pt(8.))]),
"children": style([margin(Pt(10.))]),
}
),
Style.{
"container":
style([
borderRadius(3.),
borderWidth(1.),
borderColor(String("#d6d7da")),
backgroundColor(String("#ffffff")),
margin(Pt(10.)),
marginVertical(Pt(5.)),
overflow(Hidden),
]),
"titleContainer":
style([
borderBottomWidth(1.),
borderTopLeftRadius(3.),
borderTopRightRadius(3.),
borderBottomColor(String("#d6d7da")),
backgroundColor(String("#f6f7f8")),
paddingHorizontal(Pt(10.)),
paddingVertical(Pt(5.)),
]),
"titleText": style([fontSize(Float(14.)), fontWeight(`_500)]),
"descriptionText": style([fontSize(Float(14.))]),
"disclosure":
style([
position(Absolute),
top(Pt(0.)),
right(Pt(0.)),
padding(Pt(10.)),
]),
"disclosureIcon": style([width(Pt(12.)), height(Pt(8.))]),
"children": style([margin(Pt(10.))]),
},
);

let comp = ReasonReact.statelessComponent("RNTesterBlock");
Expand All @@ -46,17 +44,17 @@ let make = (~description, ~title, children) => {
render: _self =>
<View style=styles##container>
<View style=styles##titleContainer>
<Text style=styles##titleText> (ReasonReact.string(title)) </Text>
(
<Text style=styles##titleText> {ReasonReact.string(title)} </Text>
{
switch (description) {
| Some(description) =>
<Text style=styles##descriptionText>
(ReasonReact.string(description))
{ReasonReact.string(description)}
</Text>
| None => ReasonReact.null
}
)
}
</View>
(View.make(~style=styles##children, children) |> ReasonReact.element)
{View.make(~style=styles##children, children) |> ReasonReact.element}
</View>,
};
};
10 changes: 5 additions & 5 deletions example/src/RNTesterExampleContainer.re
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
let renderExample = (i, {title, description, render}: Example.t) =>
<RNTesterBlock key=(string_of_int(i)) title description>
(render())
<RNTesterBlock key={string_of_int(i)} title description>
{render()}
</RNTesterBlock>;

let component = ReasonReact.statelessComponent("RNTesterExampleContainer");

let make = (~example: ExampleList.item, _children) => {
...component,
render: _self =>
<RNTesterPage title=example.title>
(ReasonReact.array(Array.mapi(renderExample, example.examples)))
<RNTesterPage title={example.title}>
{ReasonReact.array(Array.mapi(renderExample, example.examples))}
</RNTesterPage>,
};
};
72 changes: 35 additions & 37 deletions example/src/RNTesterExampleList.re
Original file line number Diff line number Diff line change
Expand Up @@ -2,49 +2,47 @@ open BsReactNative;

let styles =
StyleSheet.create(
Style.(
{
"listContainer": style([flex(1.0)]),
"row":
style([
backgroundColor(String("white")),
justifyContent(Center),
paddingHorizontal(Pt(15.)),
paddingVertical(Pt(8.)),
]),
"rowTitleText": style([fontSize(Float(17.)), fontWeight(`_500)]),
"rowDetailText":
style([
fontSize(Float(15.)),
color(String("#888888")),
lineHeight(20.),
]),
"separator":
style([
height(Pt(StyleSheet.hairlineWidth)),
backgroundColor(String("#bbbbbb")),
marginLeft(Pt(15.)),
]),
"separatorHighlighted":
style([
height(Pt(StyleSheet.hairlineWidth)),
backgroundColor(String("rgb(217, 217, 217)")),
]),
}
),
Style.{
"listContainer": style([flex(1.0)]),
"row":
style([
backgroundColor(String("white")),
justifyContent(Center),
paddingHorizontal(Pt(15.)),
paddingVertical(Pt(8.)),
]),
"rowTitleText": style([fontSize(Float(17.)), fontWeight(`_500)]),
"rowDetailText":
style([
fontSize(Float(15.)),
color(String("#888888")),
lineHeight(20.),
]),
"separator":
style([
height(Pt(StyleSheet.hairlineWidth)),
backgroundColor(String("#bbbbbb")),
marginLeft(Pt(15.)),
]),
"separatorHighlighted":
style([
height(Pt(StyleSheet.hairlineWidth)),
backgroundColor(String("rgb(217, 217, 217)")),
]),
},
);

let component = ReasonReact.statelessComponent("RNTesterExampleList");

let renderItem = onPress =>
SectionList.renderItem(({item}) =>
<TouchableHighlight onPress=(() => onPress(item))>
<TouchableHighlight onPress={() => onPress(item)}>
<View style=styles##row>
<Text style=styles##rowTitleText>
(ReasonReact.string(item.ExampleList.title))
{ReasonReact.string(item.ExampleList.title)}
</Text>
<Text style=styles##rowDetailText>
(ReasonReact.string(item.description))
{ReasonReact.string(item.description)}
</Text>
</View>
</TouchableHighlight>
Expand All @@ -53,7 +51,7 @@ let renderItem = onPress =>
let itemSeparatorComponent =
SectionList.separatorComponent(({highlighted}) =>
<View
style=(highlighted ? styles##separatorHighlighted : styles##separator)
style={highlighted ? styles##separatorHighlighted : styles##separator}
/>
);

Expand All @@ -68,10 +66,10 @@ let make = (~components, ~onPress, _children) => {
<View style=styles##listContainer>
<SectionList
sections
renderItem=(renderItem(onPress))
keyExtractor=((item, _) => item.key)
renderItem={renderItem(onPress)}
keyExtractor={(item, _) => item.key}
itemSeparatorComponent
/>
</View>,
};
};
};
Loading

0 comments on commit 2eb2f3a

Please sign in to comment.