Last active
December 19, 2022 18:43
-
-
Save ClassicOldSong/6db5fb2ff331130a26504fec05ceabc6 to your computer and use it in GitHub Desktop.
Solidjs + NativeScript + SwiftUI
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Application } from "@nativescript/core" | |
import { render } from "@dominative/solid" | |
import { createSignal } from "solid-js" | |
import { registerElement } from 'dominative' | |
import { SwiftUI, registerSwiftUI, UIDataDriver } from '@nativescript/swift-ui' | |
registerElement('swiftui', SwiftUI) | |
registerSwiftUI("sampleView", (view) => | |
new UIDataDriver(SampleViewProvider.alloc().init(), view) | |
) | |
const App = () => { | |
const [count, setCount] = createSignal(0) | |
return <> | |
<actionbar title="Hello, SolidJS!"></actionbar> | |
<stacklayout> | |
<swiftui swiftId="sampleView" height="200" data={{count: count()}} on:swiftUIEvent={(evt) => setCount(evt.data.count)}/> | |
<label>You have taapped {count()} time{count() === 1 ? '' : 's'}</label> | |
{ | |
// use 'on:___' instead of 'on___' for event handlers | |
// See https://github.com/SudoMaker/dominative-solid#event-handling for detail | |
} | |
<button class="-primary" on:tap={() => setCount(c => c + 1)}>Tap me!</button> | |
</stacklayout> | |
</> | |
} | |
const create = () => { | |
document.body.actionBarHidden = false | |
render(App, document.body) | |
return document | |
} | |
Application.run({ create }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment