Skip to content

Instantly share code, notes, and snippets.

View manuel-martos's full-sized avatar

Manuel Martos manuel-martos

View GitHub Profile
@manuel-martos
manuel-martos / vignetteShader.kt
Created August 14, 2024 10:54
AGSL - CMP - vignetteShader
fun Modifier.vignetteShader(
intensity: Float,
decayFactor: Float,
) = this then runtimeShader(shader) {
uniform("intensity", intensity)
uniform("decayFactor", decayFactor)
}
- name: Commit and push
run: |
git config user.email "mmartos@degirona.info"
git config user.name "Manuel Martos Roldán"
git checkout --orphan gh-pages
git reset --hard
git --work-tree=composeApp/build/dist/wasmJs/productionExecutable add .
git commit -m "Upload gh-pages"
git push origin gh-pages --force
- uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '17'
- uses: gradle/wrapper-validation-action@v1
- uses: gradle/gradle-build-action@v2
with:
cache-read-only: ${{ env.MAIN_BRANCH != 'true' }}
- name: Build
run: >
steps:
- uses: actions/checkout@v3
with:
token: ${{ secrets.LOTTIE_VIEWER_TOKEN }}
jobs:
deploy:
name: Deploy
runs-on: ubuntu-latest
name: Deploy Kotlin/wasm to GitHub Pages
on:
push:
branches:
- main
actual fun createFileStore(): FileStore = FileStore { fileDesc ->
flow {
(fileDesc as? JsFileDesc)?.run {
suspendCoroutine { continuation ->
val reader = FileReader()
reader.onload = {
continuation.resume(reader.result.toString())
}
reader.readAsText(fileDesc.file)
}.run { emit(this) }
fun interface FileStore {
suspend fun readFileContent(fileDesc: FileDesc): Flow<String>
}
expect fun createFileStore(): FileStore
@Composable
actual fun Modifier.onDragAndDrop(
onDragStart: () -> Unit,
onDragExit: () -> Unit,
onSingleFileDropped: (FileDesc) -> Unit,
): Modifier = composed {
DisposableEffect(LocalWindowInfo.current) {
registerDragAndDropListener(
onDragOver = { onDragStart() },
onDragLeave = { onDragExit() },
external fun registerDragAndDropListener(
onDragOver: () -> Unit,
onDragLeave: () -> Unit,
onDrop: (JsAny) -> Unit,
)
external fun unregisterDragAndDropListener()