added html view

This commit is contained in:
hariroshan 2023-01-09 13:50:00 +05:30
parent 8f95fb5b24
commit 8411e7c60c
5 changed files with 53 additions and 2 deletions

View File

@ -1,4 +1,4 @@
module Native exposing (activityIndicator, button, formattedString, label, span, datePicker)
module Native exposing (activityIndicator, button, datePicker, formattedString, htmlView, label, span)
import Html exposing (Attribute, Html)
@ -32,6 +32,12 @@ span : List (Attribute msg) -> List (Html msg) -> Html msg
span =
buildElement "ns-span"
datePicker : List (Attribute msg) -> List (Html msg) -> Html msg
datePicker =
buildElement "ns-datepicker"
htmlView : List (Attribute msg) -> List (Html msg) -> Html msg
htmlView =
buildElement "ns-html-view"

View File

@ -802,3 +802,8 @@ month =
year : String -> Attribute msg
year =
attribute "year"
html : String -> Attribute msg
html =
attribute "html"

View File

@ -214,7 +214,21 @@ let formattedString =
let span = [formattedString, ["text"]->Belt.Array.map(dashed)]->Belt.Array.concatMany
let datePicker = [view, ["date", "day", "iosPreferredDatePickerStyle", "maxDate", "minDate", "month", "year"]->Belt.Array.map(dashed)]->Belt.Array.concatMany
let datePicker =
[
view,
[
"date",
"day",
"iosPreferredDatePickerStyle",
"maxDate",
"minDate",
"month",
"year",
]->Belt.Array.map(dashed),
]->Belt.Array.concatMany
let htmlView = [view, ["html"]->Belt.Array.map(dashed)]->Belt.Array.concatMany
// Js.log("****************************")
// ["date", "day", "iosPreferredDatePickerStyle", "maxDate", "minDate", "month", "year"]

View File

@ -74,6 +74,15 @@ module DatePicker = {
let handler: Types.handler = buildHandler(new, Constants.datePicker, Helper.addView)
}
module HtmlView = {
%%private(
@module("@nativescript/core") @new
external new: unit => Types.nativeObject = "HtmlView"
)
let tagName = "ns-html-view"
let handler: Types.handler = buildHandler(new, Constants.htmlView, Helper.addView)
}
let all: array<Types.customElement> = [
{
@ -100,4 +109,8 @@ let all: array<Types.customElement> = [
tagName: DatePicker.tagName,
handler: DatePicker.handler,
},
{
tagName: HtmlView.tagName,
handler: HtmlView.handler,
},
]

View File

@ -148,6 +148,19 @@ detailsPage model =
, NA.minDate "1980-02-01"
]
[]
, Native.htmlView
[ NA.html """
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<span style="color: green">Hello World</span>
</body>
</html>
"""
]
[]
]
]
)