mirror of
https://github.com/hariroshan/elm-native-library.git
synced 2024-12-01 00:19:34 +03:00
moved files to app folder
This commit is contained in:
parent
bfb857f3c1
commit
33f7bd51ff
@ -215,6 +215,21 @@ counter model =
|
||||
, NA.selectedIndex "1"
|
||||
]
|
||||
[]
|
||||
|
||||
Native.listView
|
||||
[ E.list E.int [ 2022, 2021, 2020, 2019, 2018, 2017 ] |> NA.items
|
||||
, NA.itemTemplateSelector "{{ $value % 2 == 0 ? 'even' : 'odd' }}"
|
||||
]
|
||||
[ Layout.asElement <|
|
||||
Layout.stackLayout
|
||||
[ NA.key "even" ]
|
||||
[ Native.label [ NA.text "{{ $value.toString() }}", NA.color "green" ] []
|
||||
]
|
||||
, Layout.asElement <|
|
||||
Layout.stackLayout
|
||||
[ NA.key "odd" ]
|
||||
[ Native.label [ NA.text "{{ $value.toString() }}", NA.color "red" ] [] ]
|
||||
]
|
||||
-}
|
||||
|
||||
|
||||
@ -226,10 +241,13 @@ detailsPage model =
|
||||
[ Native.listView
|
||||
[ E.list E.int [ 2022, 2021, 2020, 2019, 2018, 2017 ] |> NA.items
|
||||
, NA.itemTemplateSelector "{{ $value % 2 == 0 ? 'even' : 'odd' }}"
|
||||
, NA.separatorColor "#dedede"
|
||||
]
|
||||
[ Layout.asElement <|
|
||||
Layout.stackLayout
|
||||
[ NA.key "even" ]
|
||||
[ NA.key "even"
|
||||
, NA.padding "20, 20"
|
||||
]
|
||||
[ Native.label [ NA.text "{{ $value.toString() }}", NA.color "green" ] []
|
||||
]
|
||||
, Layout.asElement <|
|
@ -1,2 +0,0 @@
|
||||
<Frame defaultPage="main-page">
|
||||
</Frame>
|
@ -1,6 +1,7 @@
|
||||
@import '@nativescript/theme/css/core.css';
|
||||
@import '@nativescript/theme/css/default.css';
|
||||
|
||||
Button.-primary {
|
||||
font-size: 18;
|
||||
}
|
||||
/* Label {
|
||||
font-size: 23;
|
||||
color: red;
|
||||
} */
|
||||
|
@ -2,8 +2,6 @@ import Elm from "./Main.elm";
|
||||
import { start } from "../elm-native-js/App.bs"
|
||||
import { Application } from "@nativescript/core";
|
||||
|
||||
Application.setCssFileName('style.css')
|
||||
|
||||
start(
|
||||
{
|
||||
elmModule: Elm,
|
14
app/app.ts
14
app/app.ts
@ -1,14 +0,0 @@
|
||||
/*
|
||||
In NativeScript, the app.ts file is the entry point to your application.
|
||||
You can use this file to perform app-level initialization, but the primary
|
||||
purpose of the file is to pass control to the app’s first module.
|
||||
*/
|
||||
|
||||
import { Application } from '@nativescript/core'
|
||||
|
||||
Application.run({ moduleName: 'app-root' })
|
||||
|
||||
/*
|
||||
Do not place any code after the application has been started as it will not
|
||||
be executed on iOS.
|
||||
*/
|
0
src/elm.d.ts → app/elm.d.ts
vendored
0
src/elm.d.ts → app/elm.d.ts
vendored
@ -1,7 +0,0 @@
|
||||
import { EventData, Page } from '@nativescript/core'
|
||||
import { HelloWorldModel } from './main-view-model'
|
||||
|
||||
export function navigatingTo(args: EventData) {
|
||||
const page = <Page>args.object
|
||||
page.bindingContext = new HelloWorldModel()
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
<Page xmlns="http://schemas.nativescript.org/tns.xsd" navigatingTo="navigatingTo">
|
||||
<ActionBar title="My App" icon="" />
|
||||
|
||||
<StackLayout class="p-20">
|
||||
<Label text="Tap the button" class="h1 text-center" />
|
||||
<Button text="TAP" tap="{{ onTap }}" class="-primary" />
|
||||
<Label text="{{ message }}" class="h2 text-center" textWrap="true" />
|
||||
</StackLayout>
|
||||
</Page>
|
@ -1,38 +0,0 @@
|
||||
import { Observable } from '@nativescript/core'
|
||||
|
||||
export class HelloWorldModel extends Observable {
|
||||
private _counter: number
|
||||
private _message: string
|
||||
|
||||
constructor() {
|
||||
super()
|
||||
|
||||
// Initialize default values.
|
||||
this._counter = 42
|
||||
this.updateMessage()
|
||||
}
|
||||
|
||||
get message(): string {
|
||||
return this._message
|
||||
}
|
||||
|
||||
set message(value: string) {
|
||||
if (this._message !== value) {
|
||||
this._message = value
|
||||
this.notifyPropertyChange('message', value)
|
||||
}
|
||||
}
|
||||
|
||||
onTap() {
|
||||
this._counter--
|
||||
this.updateMessage()
|
||||
}
|
||||
|
||||
private updateMessage() {
|
||||
if (this._counter <= 0) {
|
||||
this.message = 'Hoorraaay! You unlocked the NativeScript clicker achievement!'
|
||||
} else {
|
||||
this.message = `${this._counter} taps left`
|
||||
}
|
||||
}
|
||||
}
|
@ -86,7 +86,7 @@ let addView: (. Types.htmlElement, Types.htmlElement) => unit = %raw(`
|
||||
const expression =
|
||||
getExpression(parentElement.getAttribute("item-template-selector"))
|
||||
|
||||
parentElement.data.itemTemplateSelector = ($value, $index, $items) => {
|
||||
parentElement.data.itemTemplateSelector = ($value, $index, _) => {
|
||||
return eval(expression)
|
||||
}
|
||||
parentElement.data.itemTemplates = keyedTemplates
|
||||
|
2
elm.json
2
elm.json
@ -1,7 +1,7 @@
|
||||
{
|
||||
"type": "application",
|
||||
"source-directories": [
|
||||
"src",
|
||||
"app",
|
||||
"elm-native/src"
|
||||
],
|
||||
"elm-version": "0.19.1",
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "elm-native",
|
||||
"main": "src/app.js",
|
||||
"main": "app/app.js",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
|
@ -1,7 +0,0 @@
|
||||
@import '@nativescript/theme/css/core.css';
|
||||
@import '@nativescript/theme/css/default.css';
|
||||
|
||||
/* Label {
|
||||
font-size: 23;
|
||||
color: red;
|
||||
} */
|
Loading…
Reference in New Issue
Block a user