StretchKt - a Kotlin port of stretch2

Overview

StretchKt

StretchKt is a Kotlin port of stretch2, which is an implementation of Flexbox originally written in Rust.

The current tracked commit of the port is 42190498ca906df8a7345826078ca33e620edb63.

Goals

This project serves as a pure Kotlin port of the original Rust implementation.

Usage (not ready yet)

StretchKt is built in Kotlin and can be used by any JVM languages.

Kotlin

  1. Add the repository to your Gradle project
repositories {
    maven("https://raw.githubusercontent.com/OrionCraftMC/OrionMaven/main/")
}
  1. Add the dependency to your project
dependencies {
    implementation("io.github.orioncraftmc:StretchKt:1.0.0-SNAPSHOT")
}
  1. You're ready to go!
// main.kt
import io.github.orioncraftmc.stretchkt.geometry.Size
import io.github.orioncraftmc.stretchkt.node.Node
import io.github.orioncraftmc.stretchkt.node.Stretch
import io.github.orioncraftmc.stretchkt.style.Style
import io.github.orioncraftmc.stretchkt.style.enums.StretchDimension

fun main() {
    // You can use the `Node` class to create a new node.
    val child = Node(
        Style(
            size = Size(StretchDimension.Percent(0.5f), StretchDimension.Auto),
        ),
        emptyList()
    )

    // Or if you prefer, you can use the `Stretch` class to also create new nodes.
    val node = Stretch.newNode(
        Style(
            size = Size(StretchDimension.Points(100f), StretchDimension.Points(100f)),
        ),
        listOf(child)
    )

    val layout = Stretch.computeLayout(node, Size.undefinedNumber())

    println(layout)
}

Testing (not ready yet)

Stretch2 is tested by validating that layouts written in StretchKt perform the same as in Chrome. This is done by rendering an equivalent layout in HTML and then generating a Kotlin test case which asserts that the resulting layout is the same when run through Stretch.

You can run these tests without setting up a webdriver environment but if you are looking to add any test case you will need to install chromedriver.

Once you have chromedriver installed and available in PATH you can re-generate all tests by running gradle :gentest:run.

To add a new test case add another HTML file to /test_fixtures following the current tests as a template for new tests.

Relationship to Yoga

If you're in the mood for some Yoga but can't depend on native libraries, also check out our pure Java port of Yoga called meditate-layout.

Yoga is a cross-platform implementation of Flexbox written in C. Yoga is a fantastic project but has some fundamental issues which the upstream project hopes to resolve. Compared to Yoga they aim to have a stronger adherence to web standards, a flexible architecture eventually supporting multiple layout algorithms, and future performance improvements including multi-threaded layout. In addition to this they aim to use a safer language with a more modern codebase.

You might also like...
Saga pattern implementation in Kotlin build in top of Kotlin's Coroutines.

Module Saga Website can be found here Add in build.gradle.kts repositories { mavenCentral() } dependencies { implementation("io.github.nomisr

Kotlin microservices with REST, and gRPC using BFF pattern. This repository contains backend services. Everything is dockerized and ready to
Kotlin microservices with REST, and gRPC using BFF pattern. This repository contains backend services. Everything is dockerized and ready to "Go" actually "Kotlin" :-)

Microservices Kotlin gRPC Deployed in EC2, Check it out! This repo contains microservices written in Kotlin with BFF pattern for performing CRUD opera

A sample skeleton backend app built using Spring Boot kotlin, Expedia Kotlin Graphql, Reactive Web that can be deployed to Google App Engine Flexible environmennt

spring-kotlin-gql-gae This is a sample skeleton of a backend app that was built using: Spring Boot(Kotlin) Reactive Web Sprinng Data R2DBC with MYSQL

Modular Android architecture which showcase Kotlin, MVVM, Navigation, Hilt, Coroutines, Jetpack compose, Retrofit, Unit test and Kotlin Gradle DSL.

SampleCompose Modular Android architecture which showcase Kotlin, MVVM, Navigation, Hilt, Coroutines, Jetpack compose, Retrofit, Unit test and Kotlin

Learn-kotlin - Learning more about Kotlin in various content

Kotlin study roadmap https://kotlinlang.org/docs/reference/ Getting Started Basi

Mis experimentos con Kotlin para JetBrains Academy, certificación de Kotlin donde voy resolviendo proyectos de evaluación y haciendo actividades de cada tema.
Mis experimentos con Kotlin para JetBrains Academy, certificación de Kotlin donde voy resolviendo proyectos de evaluación y haciendo actividades de cada tema.

Kotlin Academy Mis experimentos con Kotlin para JetBrains donde voy resolviendo proyectos de evaluación y haciendo actividades de cada tema. Acerca de

Repositório criado para ser utilizado pelo projeto de Kotlin Collections desenvolvido em Kotlin nas aulas feitas através da plataforma Alura.

Projeto Kotlin Collections Repositório criado para ser utilizado pelo projeto de Kotlin Collections desenvolvido em Kotlin nas aulas feitas através da

Kotlin-GraphQL-Apollo - Sencillo cliente para consumir una API GraphQL con Apollo usando Kotlin
Kotlin-GraphQL-Apollo - Sencillo cliente para consumir una API GraphQL con Apollo usando Kotlin

Kotlin GraphQL Apollo Sencillo cliente para consumir una API GraphQL con Apollo

DS-for-Kotlin - Some classic data sturctures write in kotlin for fun

DS-for-Kotlin Just write some classic data structure by kotlin during my leisure

Comments
  • Generated tests are inconsistent

    Generated tests are inconsistent

    Software used

    Chrome is up to date Version 102.0.5005.63 (Official Build) (64-bit)

    A test that shows these kinds of inconsistencies is the min_height test.

    Comparison of results in min_height

    Root element

    assert_eq!(sprawl.layout(node).unwrap().size.width, 100f32);
    assert_eq!(sprawl.layout(node).unwrap().size.height, 100f32);
    assert_eq!(sprawl.layout(node).unwrap().location.x, 0f32);
    assert_eq!(sprawl.layout(node).unwrap().location.y, 0f32);
    

    Root is 100x100 on Chrome Clearly the root is 100x100 and at 0x0, this checks out.

    Root's first child (node 0)

    assert_eq!(sprawl.layout(node0).unwrap().size.width, 100f32);
    assert_eq!(sprawl.layout(node0).unwrap().size.height, 80f32);
    assert_eq!(sprawl.layout(node0).unwrap().location.x, 0f32);
    assert_eq!(sprawl.layout(node0).unwrap().location.y, 0f32);
    

    Node 0 is 100x60 and at 0x0 This is.. odd? Sprawl is giving the wrong value here, since the test passes, when compared to what Chrome returns.

    Please someone help, I've spent 3 hours yesterday trying to debug this issue.

    Originally posted by @NickAcPT in https://github.com/DioxusLabs/sprawl/discussions/46#discussioncomment-2883900

    opened by NickAcPT 0
Owner
null
A multifunctional Android RAT with GUI based Web Panel without port forwarding.

AIRAVAT A multifunctional Android RAT with GUI based Web Panel without port forwarding. Features Read all the files of Internal Storage Download Any M

The One And Only 336 Dec 27, 2022
Remote Administrator Tool [ RAT For Android ] No Port Forwarding

XHUNTER RAT for Android ?? · Telegram · ⚖️ Legal Disclaimer: For Educational Purpose Only Usage of XHUNTER for attacking targets without prior mutual

Anon 79 Dec 31, 2022
Repo: Programming problems with solutions in Kotlin to help avid Kotlin learners to get a strong hold on Kotlin programming.

Kotlin_practice_problems Repo: Programming problems with solutions in Kotlin to help avid Kotlin learners to get a strong hold on Kotlin programming.

Aman 0 Oct 14, 2021
Mocking for Kotlin/Native and Kotlin Multiplatform using the Kotlin Symbol Processing API (KSP)

Mockative Mocking for Kotlin/Native and Kotlin Multiplatform using the Kotlin Symbol Processing API (KSP). Installation Mockative uses KSP to generate

Mockative 121 Dec 26, 2022
Kotlin-oop - Repositório criado para ser utilizado pelo projeto de Kotlin OOP desenvolvido em Kotlin nas aulas feitas através da plataforma Alura.

Projeto React OOP Repositório criado para ser utilizado pelo projeto de Kotlin OOP desenvolvido em Kotlin nas aulas feitas através da plataforma Alura

Marcos Felipe 1 Jan 5, 2022
Kotlin-koans - Kotlin Koans are a series of exercises to get you familiar with the Kotlin Syntax

kotlin-koans-edu Kotlin Koans are a series of exercises to get you familiar with

null 1 Jan 11, 2022
Kotlin TodoMVC – full-stack Kotlin application demo

Kotlin full stack TodoMVC This project is an example implementation of the TodoMVC app written in Kotlin. More specifically, it's the Kotlin port of t

Gyula Voros 22 Oct 3, 2022
Integration Testing Kotlin Multiplatform Kata for Kotlin Developers. The main goal is to practice integration testing using Ktor and Ktor Client Mock

This kata is a Kotlin multiplatform version of the kata KataTODOApiClientKotlin of Karumi. We are here to practice integration testing using HTTP stub

Jorge Sánchez Fernández 29 Oct 3, 2022
Small kotlin library for persisting _single instances_ of kotlin data classes

PerSista Small library for persisting single instances of kotlin data classes. NB: PerSista uses typeOf() internally which is marked as @ExperimentalS

Eric Donovan 5 Nov 13, 2022
Kotlin Leaning Notes from Udacity Course | Kotlin Bootcamp for Programmers by Google

Kotlin Beginners Notes These are all personal notes taken from the Udacity Course (ud9011) of Kotlin Bootcamp for Programmers by Google as well as oth

Süha Tanrıverdi 34 Dec 10, 2022