Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import com.guru.composecookbook.build.configurations.ProjectConfigs
import org.jetbrains.kotlin.gradle.dsl.JvmTarget

plugins {
id("com.android.application")
id("kotlin-android")
id("com.google.devtools.ksp")
id("org.jetbrains.kotlin.plugin.compose")
}
Expand Down Expand Up @@ -31,16 +31,15 @@ android {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = "1.8"
// useIR = true
freeCompilerArgs = freeCompilerArgs + "-opt-in=kotlin.RequiresOptIn"
}
buildFeatures { compose = true }
lint { abortOnError = false }
testOptions { unitTests.all { it.useJUnitPlatform() } }
}

// AGP 9.0 ships built-in Kotlin (replacing the kotlin-android plugin), so the
// JVM target is configured through the Kotlin compiler options.
kotlin { compilerOptions { jvmTarget.set(JvmTarget.JVM_1_8) } }

dependencies {
implementation(project(":data"))
implementation(project(":theme"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,9 @@ fun DraggableCardWithAnimatable() {
Material3Card(
backgroundColor = green200,
modifier =
modifier.size(100.dp).offset(x = pointerAnimatableX.value.dp, y = pointerAnimatableX.value.dp),
modifier
.size(100.dp)
.offset(x = pointerAnimatableX.value.dp, y = pointerAnimatableX.value.dp),
) {}
Spacer(modifier = Modifier.height(100.dp))
}
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,8 @@ fun SimpleAnimateCustomStateClass() {

Button(
onClick = { enabled = !enabled },
modifier = Modifier.padding(16.dp).width(animatedUiState.width).rotate(animatedUiState.rotation),
modifier =
Modifier.padding(16.dp).width(animatedUiState.width).rotate(animatedUiState.rotation),
) {
Text("Custom State Animation")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,10 @@ fun ContrastThemeDemo(dark: Boolean) {
selected = level == value,
onClick = { level = value },
shape =
SegmentedButtonDefaults.itemShape(index = index, count = ContrastLevel.entries.size),
SegmentedButtonDefaults.itemShape(
index = index,
count = ContrastLevel.entries.size,
),
) {
Text(value.label)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ fun TypesOfRows() {
)
Row(
horizontalArrangement = Arrangement.SpaceAround,
modifier = Modifier.padding(8.dp).fillMaxWidth().testTag(TestTags.HOME_LAYOUTS_ROW_SPACE_AROUND),
modifier =
Modifier.padding(8.dp).fillMaxWidth().testTag(TestTags.HOME_LAYOUTS_ROW_SPACE_AROUND),
) {
MultipleTexts()
}
Expand All @@ -93,7 +94,8 @@ fun TypesOfRows() {
)
Row(
horizontalArrangement = Arrangement.SpaceEvenly,
modifier = Modifier.padding(8.dp).fillMaxWidth().testTag(TestTags.HOME_LAYOUTS_ROW_SPACE_EVENLY),
modifier =
Modifier.padding(8.dp).fillMaxWidth().testTag(TestTags.HOME_LAYOUTS_ROW_SPACE_EVENLY),
) {
MultipleTexts()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ fun SegmentedButtons() {
selected = selected == option,
onClick = { selected = option },
shape =
SegmentedButtonDefaults.itemShape(index = options.indexOf(option), count = options.size),
SegmentedButtonDefaults.itemShape(
index = options.indexOf(option),
count = options.size,
),
) {
Text(option)
}
Expand Down
26 changes: 13 additions & 13 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@
// build classpath through buildSrc's dependencies (also catalog-driven), so
// only ktfmt needs to be declared here.
plugins {
alias(libs.plugins.ktfmt) apply false
alias(libs.plugins.roborazzi) apply false
alias(libs.plugins.ktfmt) apply false
alias(libs.plugins.roborazzi) apply false
}

allprojects {
repositories {
mavenCentral()
google()
maven(url = "https://jitpack.io")
}
repositories {
mavenCentral()
google()
maven(url = "https://jitpack.io")
}

// Apply ktfmt to all projects
apply(plugin = "com.ncorti.ktfmt.gradle")
// Apply ktfmt to all projects
apply(plugin = "com.ncorti.ktfmt.gradle")

configure<com.ncorti.ktfmt.gradle.KtfmtExtension> {
googleStyle()
maxWidth.set(100)
}
configure<com.ncorti.ktfmt.gradle.KtfmtExtension> {
googleStyle()
maxWidth.set(100)
}
}
4 changes: 2 additions & 2 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ repositories {
}

dependencies {
// in order to be able to use "kotlin-android" in the common script
// for the Kotlin Gradle plugin DSL (kotlin { compilerOptions }, JvmTarget) in the common scripts
implementation(libs.kotlin.gradle.plugin)

// in order to be able to apply "org.jetbrains.kotlin.plugin.compose" in the common scripts
Expand All @@ -27,7 +27,7 @@ dependencies {
implementation(libs.kotlin.serialization.plugin)

// in order to be able to apply "com.google.devtools.ksp" in the common scripts
// (the KSP version in the catalog must match the Kotlin version)
// (KSP 2.3.x is versioned independently of Kotlin since Kotlin 2.2)
implementation(libs.ksp.gradle.plugin)

// in order to recognize the "plugins" block in the common script
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import com.guru.composecookbook.build.configurations.ProjectConfigs
import org.jetbrains.kotlin.gradle.dsl.JvmTarget

plugins {
id("com.android.library")
id("kotlin-android")
id("org.jetbrains.kotlin.plugin.compose")
}

Expand All @@ -11,21 +11,24 @@ android {

defaultConfig {
minSdk = ProjectConfigs.minSdkVersion
targetSdk = ProjectConfigs.targetSdkVersion
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}

compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = "17"
freeCompilerArgs = freeCompilerArgs + "-opt-in=kotlin.RequiresOptIn"
}
buildFeatures {
compose = true
}
}

// AGP 9.0 ships built-in Kotlin (replacing the kotlin-android plugin), so the
// JVM target is configured through the Kotlin compiler options.
kotlin {
compilerOptions {
jvmTarget.set(JvmTarget.JVM_17)
}
}

// Namespace will be set by individual module
Original file line number Diff line number Diff line change
@@ -1,31 +1,35 @@
import com.guru.composecookbook.build.configurations.ProjectConfigs
import org.jetbrains.kotlin.gradle.dsl.JvmTarget

plugins {
id("com.android.library")
id("kotlin-android")
id("com.google.devtools.ksp")
id("org.jetbrains.kotlin.plugin.compose")
}

android {
compileSdk = ProjectConfigs.compileSdkVersion

defaultConfig {
minSdk = ProjectConfigs.minSdkVersion
targetSdk = ProjectConfigs.targetSdkVersion
}

compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = "17"
}


buildFeatures {
compose = true
}
}

// AGP 9.0 ships built-in Kotlin (replacing the kotlin-android plugin), so the
// JVM target is configured through the Kotlin compiler options.
kotlin {
compilerOptions {
jvmTarget.set(JvmTarget.JVM_17)
}
}

// Namespace will be set by individual module
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,13 @@ fun StaggeredVerticalGrid(
val columnWidth = constraints.maxWidth / columns
val itemConstraints = constraints.copy(maxWidth = columnWidth)
val colHeights = IntArray(columns) { 0 } // track each column's height
val placeables =
measurables.map { measurable ->
val column = shortestColumn(colHeights)
val placeable = measurable.measure(itemConstraints)
placeableXY[placeable] = Pair(columnWidth * column, colHeights[column])
colHeights[column] += placeable.height
placeable
}
val placeables = measurables.map { measurable ->
val column = shortestColumn(colHeights)
val placeable = measurable.measure(itemConstraints)
placeableXY[placeable] = Pair(columnWidth * column, colHeights[column])
colHeights[column] += placeable.height
placeable
}

val height =
colHeights.maxOrNull()?.coerceIn(constraints.minHeight, constraints.maxHeight)
Expand Down
1 change: 0 additions & 1 deletion demos/cryptoapp/app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
plugins {
/** See [common-compose-module-configs-script-plugin.gradle.kts] file */
id("common-compose-module-configs-script-plugin")
id("org.jetbrains.kotlin.android")
}

android { namespace = "com.guru.composecookbook.cryptoapp" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ class CryptoRepositoryImpl(
val response = cryptoApi.getAllCrypto(page)
return if (response.isSuccessful && !response.body().isNullOrEmpty()) {
val cryptoApiResponseList = response.body()
val cryptoList =
cryptoApiResponseList?.map { cryptoApiResponse -> cryptoApiMapper.map(cryptoApiResponse) }
val cryptoList = cryptoApiResponseList?.map { cryptoApiResponse ->
cryptoApiMapper.map(cryptoApiResponse)
}
cryptoList ?: emptyList()
} else {
emptyList()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,7 @@ fun DatingHomeScreen() {
.alpha(animateFloatAsState(if (listEmpty.value) 0f else 1f).value),
) {
IconButton(
onClick = {
/* TODO Hook to swipe event */
},
onClick = { /* TODO Hook to swipe event */ },
modifier =
Modifier.padding(horizontal = 16.dp)
.size(60.dp)
Expand All @@ -109,9 +107,7 @@ fun DatingHomeScreen() {
)
}
IconButton(
onClick = {
/* TODO Hook to swipe event */
},
onClick = { /* TODO Hook to swipe event */ },
modifier =
Modifier.padding(horizontal = 16.dp)
.size(60.dp)
Expand Down
Loading
Loading