mirror of
https://github.com/hariroshan/elm-native-library.git
synced 2024-11-28 01:33:43 +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/core.css';
|
||||||
@import '@nativescript/theme/css/default.css';
|
@import '@nativescript/theme/css/default.css';
|
||||||
|
|
||||||
/* Label {
|
|
||||||
font-size: 23;
|
/* Place any CSS rules you want to apply on both iOS and Android here.
|
||||||
color: red;
|
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 |
345
app/src/Main.elm
345
app/src/Main.elm
File diff suppressed because one or more lines are too long
@ -144,6 +144,7 @@ let textBase: array<string> =
|
|||||||
paddings,
|
paddings,
|
||||||
[
|
[
|
||||||
"fontSize",
|
"fontSize",
|
||||||
|
"fontWeight",
|
||||||
"formattedText",
|
"formattedText",
|
||||||
"letterSpacing",
|
"letterSpacing",
|
||||||
"lineHeight",
|
"lineHeight",
|
||||||
@ -314,6 +315,7 @@ let commonTextBase =
|
|||||||
"autofillType",
|
"autofillType",
|
||||||
"editable",
|
"editable",
|
||||||
"fontSize",
|
"fontSize",
|
||||||
|
"fontWeight",
|
||||||
"formattedText",
|
"formattedText",
|
||||||
"hint",
|
"hint",
|
||||||
"keyboardType",
|
"keyboardType",
|
||||||
@ -376,7 +378,12 @@ let actionItem =
|
|||||||
let listView =
|
let listView =
|
||||||
[
|
[
|
||||||
view,
|
view,
|
||||||
["itemTemplateSelector", "iosEstimatedRowHeight", "rowHeight", "separatorColor"]->Belt.Array.map(dashed),
|
[
|
||||||
|
"itemTemplateSelector",
|
||||||
|
"iosEstimatedRowHeight",
|
||||||
|
"rowHeight",
|
||||||
|
"separatorColor",
|
||||||
|
]->Belt.Array.map(dashed),
|
||||||
]->Belt.Array.concatMany
|
]->Belt.Array.concatMany
|
||||||
|
|
||||||
// Js.log("****************************")
|
// Js.log("****************************")
|
||||||
|
@ -9,6 +9,11 @@ fontSize : String -> Attribute msg
|
|||||||
fontSize =
|
fontSize =
|
||||||
attribute "font-size"
|
attribute "font-size"
|
||||||
|
|
||||||
|
fontWeight : String -> Attribute msg
|
||||||
|
fontWeight =
|
||||||
|
attribute "font-weight"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
fontStyle : String -> Attribute msg
|
fontStyle : String -> Attribute msg
|
||||||
fontStyle =
|
fontStyle =
|
||||||
@ -1153,3 +1158,5 @@ separatorColor =
|
|||||||
itemTemplateSelector : String -> Attribute msg
|
itemTemplateSelector : String -> Attribute msg
|
||||||
itemTemplateSelector =
|
itemTemplateSelector =
|
||||||
attribute "item-template-selector"
|
attribute "item-template-selector"
|
||||||
|
|
||||||
|
|
||||||
|
@ -94,6 +94,6 @@ onSelectedIndexChange msg =
|
|||||||
on "selectedIndexChange" (D.field "value" D.int |> D.map msg)
|
on "selectedIndexChange" (D.field "value" D.int |> D.map msg)
|
||||||
|
|
||||||
|
|
||||||
onItemTap : D.Decoder msg -> Attribute msg
|
onItemTap : (Int -> msg) -> Attribute msg
|
||||||
onItemTap itemDecoder =
|
onItemTap msg =
|
||||||
on "itemTap" (D.field "item" itemDecoder)
|
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)
|
import Html exposing (Attribute, Html)
|
||||||
|
|
||||||
|
|
||||||
type alias Model a page =
|
type alias Model page =
|
||||||
{ a | current : page, next : Maybe page, history : List page }
|
{ current : page, history : List page }
|
||||||
|
|
||||||
|
|
||||||
cons : List a -> a -> List a
|
cons : List a -> a -> List a
|
||||||
@ -12,12 +12,12 @@ cons acc x =
|
|||||||
x :: acc
|
x :: acc
|
||||||
|
|
||||||
|
|
||||||
frame : Model a page -> List ( page, Model a page -> Html msg ) -> List (Attribute msg) -> Html msg
|
frame : Model page -> model -> List ( page, model -> Html msg ) -> List (Attribute msg) -> Html msg
|
||||||
frame model pages attrs =
|
frame model appModel pages attrs =
|
||||||
let
|
let
|
||||||
children =
|
children =
|
||||||
pages
|
pages
|
||||||
|> getPage model.current model
|
|> getPage model.current appModel
|
||||||
|> Maybe.map List.singleton
|
|> Maybe.map List.singleton
|
||||||
|> Maybe.withDefault []
|
|> Maybe.withDefault []
|
||||||
|
|
||||||
@ -26,24 +26,23 @@ frame model pages attrs =
|
|||||||
|> List.foldl
|
|> List.foldl
|
||||||
(\old acc ->
|
(\old acc ->
|
||||||
pages
|
pages
|
||||||
|> getPage old model
|
|> getPage old appModel
|
||||||
|> Maybe.map (cons acc)
|
|> Maybe.map (cons acc)
|
||||||
|> Maybe.withDefault acc
|
|> Maybe.withDefault acc
|
||||||
)
|
)
|
||||||
children
|
children
|
||||||
|
|
||||||
_ =
|
-- _ =
|
||||||
Debug.log "Childenr" (List.length history)
|
-- Debug.log "Childenr" (List.length history)
|
||||||
in
|
in
|
||||||
(Html.node "ns-frame"
|
(Html.node "ns-frame"
|
||||||
attrs
|
attrs
|
||||||
(history
|
history
|
||||||
-- model.history
|
-- model.history
|
||||||
-- |> List.foldl
|
-- |> List.foldl
|
||||||
-- (\next acc ->
|
-- (\next acc ->
|
||||||
-- )
|
-- )
|
||||||
-- []
|
-- []
|
||||||
)
|
|
||||||
-- ([ pages
|
-- ([ pages
|
||||||
-- |> getPage model.current model
|
-- |> getPage model.current model
|
||||||
-- , model.next
|
-- , model.next
|
||||||
@ -92,10 +91,33 @@ findInList target toItem acc ls =
|
|||||||
findInList target toItem acc r
|
findInList target toItem acc r
|
||||||
|
|
||||||
|
|
||||||
|
init : page -> Model page
|
||||||
|
init currentPage =
|
||||||
|
{ current = currentPage
|
||||||
|
, history = []
|
||||||
|
}
|
||||||
|
|
||||||
-- root : Frame msg -> Html msg
|
|
||||||
-- root (Frame e) =
|
back : Bool -> Model page -> Model page
|
||||||
-- e
|
back bool model =
|
||||||
-- asElement : Frame msg -> Html msg
|
if not bool then
|
||||||
-- asElement =
|
model
|
||||||
-- root
|
|
||||||
|
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