hey I have a very specific use case for a `LazyRow` - we want all our items to have the same visible...
a

agrosner

almost 3 years ago
hey I have a very specific use case for a
LazyRow
- we want all our items to have the same visible height on screen. (i.e. the smallest visible item grow to fit the other tallest visible item). We cannot have a
Row
as that requires measuring all items including offscreen items, and we may have more than 5-10 ui elements. We also dont want to measure offscreen items until they reach visible, then reset the height modifiers on only visible ones if the height is
>
the previous value We currently use an
onGloballyPositioned
modifier like so:
onGloballyPositioned {
                    if (props.rowHeight is RowHeight.MaxHeight) {
                        minHeightOnMaxHeightChange(with(density) { it.size.height.toDp() })
                    }
                }
we buffer the emission of each item so it only updates in smaller intervals if many are drawn on screen at once. It works in most cases and seems to be as performant as it can be. we then use a
CompositionLocal
to send the value to each item:
val minHeightOnMaxHeight = LocalMaxHeightValue.current
carouselIntervalContent.item.invoke(
    this,
    info.index,
    Modifier.thenIf(props.rowHeight is RowHeight.MaxHeight) {
        minHeightOnMaxHeight.takeIf { it > 0.0.dp }?.let {
            heightIn(min = it)
        } ?: rowHeightModifier
    }
)
However, we discover that some kinds of content (depending on their internals) continuously grow until they reach a too large height and crash. Is there a better way to do this?
I’m having this error `KotlinSourceSet with name 'androidUnitTest' not found.` Here is my config...
o

Oluwafemi Ogundipe

over 2 years ago
I’m having this error
KotlinSourceSet with name 'androidUnitTest' not found.
Here is my configuration, please what am I missing?
plugins {
    kotlin(Plugins.multiplatform)
    kotlin(Plugins.nativeCocoapods)
    id(Plugins.androidLibrary) version Versions.androidGradlePlugin
    id(Plugins.ktlint) version Versions.ktlintVersion
    id(Plugins.kotlinx_serialization)
    id("io.kotest.multiplatform") version "5.0.2"
}

kotlin {
    android {
        compilations.all {
            kotlinOptions {
                jvmTarget = "1.8"
            }
        }
    }
    targets {
        jvm {
            compilations.all {
                kotlinOptions {
                    jvmTarget = "1.8"
                }
            }
        }
        android {
            compilations.all {
                kotlinOptions {
                    jvmTarget = "1.8"
                }
            }
        }
        iosX64()
    }
    android()
    iosX64()
    iosArm64()
    iosSimulatorArm64()

    cocoapods {
        summary = "Some description for the Shared Module"
        homepage = "Link to the Shared Module homepage"
        version = "1.0"
        ios.deploymentTarget = "14.1"
        framework {
            baseName = "magicsdk"
        }
    }

    sourceSets {
        val commonMain by getting {
            dependencies {
                implementation(Google.gson)
                // ktor
                implementation(Ktor.clientSerialization)
                implementation(Ktor.serialization_kotlinx)
                implementation(Ktor.ktor_json_serialization)
                implementation(Ktor.content_negotiation)
                implementation(Ktor.core)
                implementation(Ktor.kmmLogging)
            }
        }
        val commonTest by getting {
            dependencies {
                implementation(kotlin("test"))
                implementation(kotlin("test-common"))
                implementation(kotlin("test-annotations-common"))
                implementation("io.kotest:kotest-framework-engine:5.0.2")
//                implementation("io.kotest:kotest-assertions-core:5.0.2")
            }
        }
        val androidMain by getting {
            dependencies {
                implementation(Ktor.android)
                implementation(Ktor.ktor_client_android_okhttp)
                implementation(SQLDelight.androidDriver)
                implementation(Ktor.logging)
            }
        }
        val androidUnitTest by getting {
            dependencies {
                implementation(kotlin("test-junit"))
                implementation("junit:junit:4.13.2")
            }
        }
        val iosX64Main by getting
        val iosArm64Main by getting
        val iosSimulatorArm64Main by getting
        val iosMain by creating {
            dependsOn(commonMain)
            iosX64Main.dependsOn(this)
            iosArm64Main.dependsOn(this)
            iosSimulatorArm64Main.dependsOn(this)
            dependencies {
                implementation(Ktor.ktor_darwin)
                implementation(Ktor.ios)
                implementation(SQLDelight.nativeDriver)
            }
        }
        val iosX64Test by getting
        val iosArm64Test by getting
        val iosSimulatorArm64Test by getting
        val iosTest by creating {
            dependsOn(commonTest)
            iosX64Test.dependsOn(this)
            iosArm64Test.dependsOn(this)
            iosSimulatorArm64Test.dependsOn(this)
        }
    }
}

android {
    namespace = "com.tilbury.magic"
    compileSdk = Application.compileSdk
    defaultConfig {
        minSdk = Application.minSdk
        targetSdk = Application.targetSdk
    }
}
🧵 2