-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathBorderStyleDemo.scala
73 lines (63 loc) · 1.98 KB
/
BorderStyleDemo.scala
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
package showcase.app.style
import scommons.react._
import scommons.reactnative._
import scala.scalajs.js
object BorderStyleDemo extends FunctionComponent[Unit] {
private[style] val Example = new FunctionComponent[Unit] {
protected def render(props: Props): ReactElement = {
<.View(^.rnStyle := js.Array(
styles.example,
props.native.style.asInstanceOf[Style]
))(
props.children
)
}
}
private[style] var exampleComp: UiComponent[Unit] = Example
protected def render(props: Props): ReactElement = {
import Style._
<.View(^.rnStyle := styles.container)(
<(exampleComp())(^.rnStyle := new Style {
override val borderWidth = 1
})(
<.Text()("borderWidth: 1")
),
<(exampleComp())(^.rnStyle := new Style {
override val borderWidth = 3
override val borderLeftWidth = 0
})(
<.Text()("borderWidth: 3, borderLeftWidth: 0")
),
<(exampleComp())(^.rnStyle := new Style {
override val borderWidth = 3
override val borderLeftColor = Color.red
})(
<.Text()("borderWidth: 3, borderLeftColor: 'red'")
),
<(exampleComp())(^.rnStyle := new Style {
override val borderLeftWidth = 3
})(
<.Text()("borderLeftWidth: 3")
),
<(exampleComp())(^.rnStyle := new Style {
override val borderWidth = 1
override val borderStyle = BorderStyle.dashed
})(
<.Text()("borderWidth: 1, borderStyle: 'dashed'")
)
)
}
private[style] lazy val styles = StyleSheet.create(new Styles)
private[style] class Styles extends js.Object {
import ViewStyle._
val container: Style = new ViewStyle {
override val flex = 1
override val justifyContent = JustifyContent.center
override val alignItems = AlignItems.center
override val backgroundColor = Style.Color.white
}
val example: Style = new ViewStyle {
override val marginBottom = 15
}
}
}