-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathApp.fs
59 lines (47 loc) · 1.36 KB
/
App.fs
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
module App
open Elmish
open Elmish.React
open Elmish.ReactNative
open Fable.ReactNative
type Model = {
Counter : int
}
type Message =
| Increment
let init () = {Counter = 0}, Cmd.none
let update msg model =
match msg with
| Increment ->
{model with Counter = model.Counter + 1}, Cmd.none
module R = Fable.ReactNative.Helpers
module P = Fable.ReactNative.Props
open Fable.ReactNative.Props
let view model dispatch =
R.view [
P.ViewProperties.Style [
P.FlexStyle.Flex 1.0
P.FlexStyle.JustifyContent JustifyContent.Center
P.BackgroundColor "#131313" ]
] [
R.text [
P.TextProperties.Style [ P.Color "#ffffff" ]
] "Press me"
|> R.touchableHighlightWithChild [
P.TouchableHighlightProperties.Style [
P.FlexStyle.Padding (R.dip 10.)
]
P.TouchableHighlightProperties.UnderlayColor "#f6f6f6"
OnPress (fun _ -> dispatch Increment)
]
R.text [
P.TextProperties.Style [
P.Color "#ffffff"
P.FontSize 30.
P.TextAlign P.TextAlignment.Center
]
] (string model.Counter)
]
Program.mkProgram init update view
|> Program.withConsoleTrace
|> Program.withReactNative "Your project name"
|> Program.run