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
type MyApp(?key: Key) = | |
inherit StatelessWidget(?key = key) | |
override _.build(context) = | |
MaterialApp(title = "Hello from F#!", home = ElmishWidget.From(init, update, view)) | |
let main () = MyApp() |> runApp |
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
let update msg model = | |
match msg with | |
| Increment -> { model with count = model.count + 1 }, Cmd.none | |
| Decrement -> { model with count = model.count - 1 }, Cmd.none |
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
let buttons dispatch : Widget = | |
Row( | |
mainAxisAlignment = MainAxisAlignment.center, | |
children = | |
[| MaterialButton(child = Text("Increment"), onPressed = fun () -> Increment |> dispatch) | |
MaterialButton(child = Text("Decrement"), onPressed = fun () -> Decrement |> dispatch) | |
SizedBox(width = 8) |] | |
) | |
let view model dispatch context : Widget = |
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 androidx.compose.material.Text | |
import androidx.compose.ui.window.Application | |
import kotlinx.cinterop.ObjCObjectBase | |
import kotlinx.cinterop.autoreleasepool | |
import kotlinx.cinterop.cstr | |
import kotlinx.cinterop.memScoped | |
import kotlinx.cinterop.toCValues | |
import platform.Foundation.NSStringFromClass | |
import platform.UIKit.UIApplication | |
import platform.UIKit.UIApplicationDelegateProtocol |
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
pluginManagement { | |
repositories { | |
google() | |
gradlePluginPortal() | |
mavenCentral() | |
maven("https://maven.pkg.jetbrains.space/public/p/compose/dev") | |
} | |
} | |
buildscript { |
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 org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget | |
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile | |
import org.jetbrains.compose.experimental.dsl.IOSDevices | |
plugins { | |
kotlin("multiplatform") | |
id("org.jetbrains.compose") version "1.3.0-rc01" | |
} | |
version = "1.0" |
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
data class Request(val endpoint: String) | |
data class Response(val body: String) | |
fun interface Processor : (Request) -> Response | |
val LoggingProcessor = { processor: Processor -> | |
Processor { request: Request -> processor(request).also(::println) } | |
} | |
private val cache = mutableMapOf<Request, Response>() |
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
data class Topping( | |
val id: String, | |
val name: String, | |
) | |
data class Article( | |
val id: String, | |
val name: String, | |
val toppings: MutableList<Topping> = mutableListOf(), | |
) { |
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 android.content.Context | |
import android.graphics.Bitmap | |
import android.graphics.drawable.Drawable | |
import android.os.Bundle | |
import androidx.activity.ComponentActivity | |
import androidx.activity.compose.setContent | |
import androidx.compose.foundation.* | |
import androidx.compose.foundation.layout.* | |
import androidx.compose.material.Button | |
import androidx.compose.material.MaterialTheme |
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 androidx.compose.foundation.Image | |
import androidx.compose.foundation.ScrollState | |
import androidx.compose.foundation.background | |
import androidx.compose.foundation.layout.fillMaxWidth | |
import androidx.compose.foundation.layout.height | |
import androidx.compose.runtime.* | |
import androidx.compose.ui.Modifier | |
import androidx.compose.ui.graphics.Color | |
import androidx.compose.ui.graphics.ImageBitmap | |
import androidx.compose.ui.graphics.asImageBitmap |
NewerOlder