mirror of
https://github.com/hariroshan/elm-native-library.git
synced 2024-11-24 09:04:47 +03:00
tested with example
This commit is contained in:
parent
854d589062
commit
b5e89adddc
35
app/app.css
35
app/app.css
@ -1,7 +1,34 @@
|
||||
@import '@nativescript/theme/css/core.css';
|
||||
@import '@nativescript/theme/css/default.css';
|
||||
|
||||
/* Label {
|
||||
font-size: 23;
|
||||
color: red;
|
||||
} */
|
||||
|
||||
/* Place any CSS rules you want to apply on both iOS and Android here.
|
||||
This is where the vast majority of your CSS code goes. */
|
||||
|
||||
/* applied when device is in light mode */
|
||||
.ns-light .bg-primary {
|
||||
background-color: #fdfdfd;
|
||||
}
|
||||
.ns-light .bg-secondary {
|
||||
background-color: #ffffff;
|
||||
}
|
||||
.ns-light.text-primary {
|
||||
color: #444;
|
||||
}
|
||||
.ns-light.text-secondary {
|
||||
color: #777;
|
||||
}
|
||||
|
||||
/* applied when device is in dark mode */
|
||||
.ns-dark .bg-primary {
|
||||
background-color: #212121;
|
||||
}
|
||||
.ns-dark .bg-secondary {
|
||||
background-color: #383838;
|
||||
}
|
||||
.ns-dark .text-primary {
|
||||
color: #eee;
|
||||
}
|
||||
.ns-dark .text-secondary {
|
||||
color: #ccc;
|
||||
}
|
||||
|
BIN
app/assets/anastasia.png
Normal file
BIN
app/assets/anastasia.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 134 KiB |
BIN
app/assets/beetlejuicemusical.png
Normal file
BIN
app/assets/beetlejuicemusical.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 148 KiB |
BIN
app/assets/bookofmormon.png
Normal file
BIN
app/assets/bookofmormon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 135 KiB |
511
app/src/Main.elm
511
app/src/Main.elm
File diff suppressed because one or more lines are too long
@ -144,6 +144,7 @@ let textBase: array<string> =
|
||||
paddings,
|
||||
[
|
||||
"fontSize",
|
||||
"fontWeight",
|
||||
"formattedText",
|
||||
"letterSpacing",
|
||||
"lineHeight",
|
||||
@ -314,6 +315,7 @@ let commonTextBase =
|
||||
"autofillType",
|
||||
"editable",
|
||||
"fontSize",
|
||||
"fontWeight",
|
||||
"formattedText",
|
||||
"hint",
|
||||
"keyboardType",
|
||||
@ -376,7 +378,12 @@ let actionItem =
|
||||
let listView =
|
||||
[
|
||||
view,
|
||||
["itemTemplateSelector", "iosEstimatedRowHeight", "rowHeight", "separatorColor"]->Belt.Array.map(dashed),
|
||||
[
|
||||
"itemTemplateSelector",
|
||||
"iosEstimatedRowHeight",
|
||||
"rowHeight",
|
||||
"separatorColor",
|
||||
]->Belt.Array.map(dashed),
|
||||
]->Belt.Array.concatMany
|
||||
|
||||
// Js.log("****************************")
|
||||
|
@ -9,6 +9,11 @@ fontSize : String -> Attribute msg
|
||||
fontSize =
|
||||
attribute "font-size"
|
||||
|
||||
fontWeight : String -> Attribute msg
|
||||
fontWeight =
|
||||
attribute "font-weight"
|
||||
|
||||
|
||||
|
||||
fontStyle : String -> Attribute msg
|
||||
fontStyle =
|
||||
@ -1153,3 +1158,5 @@ separatorColor =
|
||||
itemTemplateSelector : String -> Attribute msg
|
||||
itemTemplateSelector =
|
||||
attribute "item-template-selector"
|
||||
|
||||
|
||||
|
@ -26,13 +26,13 @@ on eventName =
|
||||
|
||||
{-| Method values are kept under {custom: {[methodName]: value}}
|
||||
example:
|
||||
Event.onEventWithMethodCalls "touch"
|
||||
[ "getX", "getY" ]
|
||||
(D.map2 Tuple.pair
|
||||
(D.at [ "custom", "getX"] D.float)
|
||||
(D.at [ "custom", "getY"] D.float)
|
||||
|> D.map Msg
|
||||
)
|
||||
Event.onEventWithMethodCalls "touch"
|
||||
[ "getX", "getY" ]
|
||||
(D.map2 Tuple.pair
|
||||
(D.at [ "custom", "getX"] D.float)
|
||||
(D.at [ "custom", "getY"] D.float)
|
||||
|> D.map Msg
|
||||
)
|
||||
-}
|
||||
onEventWithMethodCalls : String -> List String -> D.Decoder msg -> Attribute msg
|
||||
onEventWithMethodCalls eventName methods =
|
||||
@ -94,6 +94,6 @@ onSelectedIndexChange msg =
|
||||
on "selectedIndexChange" (D.field "value" D.int |> D.map msg)
|
||||
|
||||
|
||||
onItemTap : D.Decoder msg -> Attribute msg
|
||||
onItemTap itemDecoder =
|
||||
on "itemTap" (D.field "item" itemDecoder)
|
||||
onItemTap : (Int -> msg) -> Attribute msg
|
||||
onItemTap msg =
|
||||
on "itemTap" (D.field "index" D.int |> D.map msg)
|
||||
|
@ -1,10 +1,10 @@
|
||||
module Native.Frame exposing (Model, frame)
|
||||
module Native.Frame exposing (Model, back, frame, init, current)
|
||||
|
||||
import Html exposing (Attribute, Html)
|
||||
|
||||
|
||||
type alias Model a page =
|
||||
{ a | current : page, next : Maybe page, history : List page }
|
||||
type alias Model page =
|
||||
{ current : page, history : List page }
|
||||
|
||||
|
||||
cons : List a -> a -> List a
|
||||
@ -12,12 +12,12 @@ cons acc x =
|
||||
x :: acc
|
||||
|
||||
|
||||
frame : Model a page -> List ( page, Model a page -> Html msg ) -> List (Attribute msg) -> Html msg
|
||||
frame model pages attrs =
|
||||
frame : Model page -> model -> List ( page, model -> Html msg ) -> List (Attribute msg) -> Html msg
|
||||
frame model appModel pages attrs =
|
||||
let
|
||||
children =
|
||||
pages
|
||||
|> getPage model.current model
|
||||
|> getPage model.current appModel
|
||||
|> Maybe.map List.singleton
|
||||
|> Maybe.withDefault []
|
||||
|
||||
@ -26,24 +26,23 @@ frame model pages attrs =
|
||||
|> List.foldl
|
||||
(\old acc ->
|
||||
pages
|
||||
|> getPage old model
|
||||
|> getPage old appModel
|
||||
|> Maybe.map (cons acc)
|
||||
|> Maybe.withDefault acc
|
||||
)
|
||||
children
|
||||
|
||||
_ =
|
||||
Debug.log "Childenr" (List.length history)
|
||||
-- _ =
|
||||
-- Debug.log "Childenr" (List.length history)
|
||||
in
|
||||
(Html.node "ns-frame"
|
||||
attrs
|
||||
(history
|
||||
-- model.history
|
||||
-- |> List.foldl
|
||||
-- (\next acc ->
|
||||
-- )
|
||||
-- []
|
||||
)
|
||||
history
|
||||
-- model.history
|
||||
-- |> List.foldl
|
||||
-- (\next acc ->
|
||||
-- )
|
||||
-- []
|
||||
-- ([ pages
|
||||
-- |> getPage model.current model
|
||||
-- , model.next
|
||||
@ -92,10 +91,33 @@ findInList target toItem acc ls =
|
||||
findInList target toItem acc r
|
||||
|
||||
|
||||
init : page -> Model page
|
||||
init currentPage =
|
||||
{ current = currentPage
|
||||
, history = []
|
||||
}
|
||||
|
||||
-- root : Frame msg -> Html msg
|
||||
-- root (Frame e) =
|
||||
-- e
|
||||
-- asElement : Frame msg -> Html msg
|
||||
-- asElement =
|
||||
-- root
|
||||
|
||||
back : Bool -> Model page -> Model page
|
||||
back bool model =
|
||||
if not bool then
|
||||
model
|
||||
|
||||
else
|
||||
case model.history of
|
||||
[] ->
|
||||
model
|
||||
|
||||
cur :: [] ->
|
||||
{ model | history = [], current = cur }
|
||||
|
||||
_ :: cur :: rest ->
|
||||
{ model | history = rest, current = cur }
|
||||
|
||||
|
||||
current : page -> Model page -> Model page
|
||||
current page model =
|
||||
{ model
|
||||
| history = model.current :: model.history
|
||||
, current = page
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user