Skip to content

Commit 2eb37d9

Browse files
authored
Update: Dependencies (#86)
1 parent f02cfcf commit 2eb37d9

30 files changed

Lines changed: 150 additions & 96 deletions

File tree

composeApp/build.gradle.kts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,7 @@
1111
*/
1212

1313
import com.google.devtools.ksp.gradle.KspAATask
14-
import com.google.devtools.ksp.gradle.KspTask
15-
import org.gradle.configurationcache.extensions.capitalized
1614
import org.jetbrains.compose.desktop.application.dsl.TargetFormat
17-
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
1815
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
1916
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
2017
import org.jetbrains.kotlin.gradle.plugin.KotlinTarget
@@ -116,6 +113,9 @@ kotlin {
116113
implementation(libs.androidx.datastore)
117114
implementation(libs.androidx.datastore.preferences)
118115

116+
// Collections
117+
implementation(libs.kotlinx.collections.immutable)
118+
119119
// File IO
120120
implementation(libs.okio)
121121

@@ -169,6 +169,9 @@ android {
169169
}
170170

171171
buildTypes {
172+
getByName("debug") {
173+
applicationIdSuffix = ".debug"
174+
}
172175
getByName("release") {
173176
isMinifyEnabled = true
174177
proguardFiles(
@@ -178,6 +181,7 @@ android {
178181
signingConfig = signingConfigs.getByName("release")
179182
}
180183
create("development") {
184+
applicationIdSuffix = ".development"
181185
initWith(getByName("debug"))
182186
matchingFallbacks += listOf("release")
183187
isMinifyEnabled = true
@@ -283,15 +287,11 @@ abstract class GenerateVersionInfoTask @Inject constructor(
283287
}
284288
}
285289

286-
287290
val versionInfoProvider = tasks.register<GenerateVersionInfoTask>("generateVersionInfo") {
288291
buildNumber.set(abysnerBuildNumber)
289292
versionName.set(abysnerVersion)
290293
}
291294

292-
tasks.withType(KspTask::class.java).configureEach {
293-
dependsOn(versionInfoProvider)
294-
}
295295
tasks.withType(KspAATask::class.java).configureEach {
296296
dependsOn(versionInfoProvider)
297297
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<resources>
3+
<string name="app_name">Abysner Debug</string>
4+
</resources>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<resources>
3+
<string name="app_name">Abysner Development</string>
4+
</resources>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
<?xml version="1.0" encoding="utf-8"?>
12
<resources>
23
<string name="app_name">Abysner</string>
34
</resources>

composeApp/src/commonMain/kotlin/org/neotech/app/abysner/presentation/component/DropDown.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ package org.neotech.app.abysner.presentation.component
1515
import androidx.compose.foundation.layout.fillMaxWidth
1616
import androidx.compose.material3.DropdownMenuItem
1717
import androidx.compose.material3.ExperimentalMaterial3Api
18+
import androidx.compose.material3.ExposedDropdownMenuAnchorType
1819
import androidx.compose.material3.ExposedDropdownMenuDefaults
1920
import androidx.compose.material3.MaterialTheme
20-
import androidx.compose.material3.MenuAnchorType
2121
import androidx.compose.material3.OutlinedTextField
2222
import androidx.compose.material3.Text
2323
import androidx.compose.runtime.Composable
@@ -31,6 +31,7 @@ import androidx.compose.ui.text.font.FontWeight
3131
import androidx.compose.ui.text.input.TextFieldValue
3232
import androidx.compose.ui.text.input.VisualTransformation
3333
import androidx.compose.ui.text.style.TextAlign
34+
import kotlinx.collections.immutable.ImmutableList
3435

3536
/**
3637
* This is quite rudimentary still, for example even though the internal TextField is readOnly it
@@ -43,7 +44,7 @@ fun <T> DropDown(
4344
modifier: Modifier = Modifier,
4445
label: String? = null,
4546
selectedValue: T? = null,
46-
items: List<T>,
47+
items: ImmutableList<T>,
4748
selectedText: @Composable (value: T?) -> AnnotatedString,
4849
visualTransformation: VisualTransformation = VisualTransformation.None,
4950
dropdownRow: @Composable (index: Int, value: T) -> Unit,
@@ -75,7 +76,7 @@ fun <T> DropDown(
7576
}
7677
},
7778
modifier = Modifier.fillMaxWidth()
78-
.menuAnchor(type = MenuAnchorType.PrimaryNotEditable),
79+
.menuAnchor(type = ExposedDropdownMenuAnchorType.PrimaryNotEditable),
7980
readOnly = true,
8081
trailingIcon = { ExposedDropdownMenuDefaults.TrailingIcon(expanded = expanded) },
8182
)

composeApp/src/commonMain/kotlin/org/neotech/app/abysner/presentation/component/IconButton.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ import androidx.compose.ui.unit.dp
3131
import org.jetbrains.compose.ui.tooling.preview.Preview
3232
import org.neotech.app.abysner.presentation.theme.AbysnerTheme
3333

34-
3534
@Composable
3635
@Preview
3736
fun IconAndTextButtonPreview() {

composeApp/src/commonMain/kotlin/org/neotech/app/abysner/presentation/component/MultiChoiceSegmentedButtonRowComponent.kt

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,25 +21,29 @@ import androidx.compose.runtime.Stable
2121
import androidx.compose.runtime.mutableStateListOf
2222
import androidx.compose.runtime.remember
2323
import androidx.compose.runtime.snapshots.SnapshotStateList
24+
import androidx.compose.runtime.toMutableStateList
2425
import androidx.compose.ui.Modifier
26+
import kotlinx.collections.immutable.ImmutableList
27+
import kotlinx.collections.immutable.persistentListOf
28+
import kotlinx.collections.immutable.toImmutableList
2529

2630
@Stable
27-
class MultiChoiceSegmentedButtonRowState(initialCheckedItemIndexes: Array<Int>) {
28-
var checkedItemIndexes: SnapshotStateList<Int> = mutableStateListOf(*initialCheckedItemIndexes)
31+
class MultiChoiceSegmentedButtonRowState(initialCheckedItemIndexes: ImmutableList<Int>) {
32+
var checkedItemIndexes: SnapshotStateList<Int> = initialCheckedItemIndexes.toMutableStateList()
2933
}
3034

3135
@Composable
32-
fun rememberMultiChoiceSegmentedButtonRowState(initialCheckedItemIndexes: Array<Int> = emptyArray()): MultiChoiceSegmentedButtonRowState {
33-
return remember {
36+
fun rememberMultiChoiceSegmentedButtonRowState(initialCheckedItemIndexes: ImmutableList<Int> = persistentListOf()): MultiChoiceSegmentedButtonRowState {
37+
return remember(initialCheckedItemIndexes) {
3438
MultiChoiceSegmentedButtonRowState(initialCheckedItemIndexes)
3539
}
3640
}
3741

3842
@Composable
3943
fun <T> MultiChoiceSegmentedButtonRow(
4044
modifier: Modifier = Modifier,
41-
items: List<T>,
42-
multiChoiceSegmentedButtonRowState: MultiChoiceSegmentedButtonRowState = rememberMultiChoiceSegmentedButtonRowState(emptyArray()),
45+
items: ImmutableList<T>,
46+
multiChoiceSegmentedButtonRowState: MultiChoiceSegmentedButtonRowState = rememberMultiChoiceSegmentedButtonRowState(),
4347
onChecked: (item: T, index: Int, checked: Boolean) -> Unit = { _, _, _ -> },
4448
label: @Composable (item: T, index: Int) -> Unit = { item, _ ->
4549
Text(text = item.toString(), maxLines = 1)
@@ -71,7 +75,7 @@ fun <T> MultiChoiceSegmentedButtonRow(
7175
@Composable
7276
private fun MultiChoiceSegmentedButtonRowPreview() {
7377
MultiChoiceSegmentedButtonRow(
74-
items = listOf("+3min", "+3m"),
78+
items = persistentListOf("+3min", "+3m"),
7579
onChecked = { _, _, _ ->
7680

7781
}

composeApp/src/commonMain/kotlin/org/neotech/app/abysner/presentation/component/SingleChoiceSegmentedButtonRowComponent.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ import androidx.compose.runtime.mutableIntStateOf
2323
import androidx.compose.runtime.remember
2424
import androidx.compose.runtime.setValue
2525
import androidx.compose.ui.Modifier
26+
import kotlinx.collections.immutable.ImmutableList
27+
import kotlinx.collections.immutable.persistentListOf
2628

2729
@Stable
2830
class SingleChoiceSegmentedButtonRowState(initialSelectedIndex: Int) {
@@ -39,7 +41,7 @@ fun rememberSingleChoiceSegmentedButtonRowState(initialSelectedIndex: Int): Sing
3941
@Composable
4042
fun <T> SingleChoiceSegmentedButtonRow(
4143
modifier: Modifier = Modifier,
42-
items: List<T>,
44+
items: ImmutableList<T>,
4345
singleChoiceSegmentedButtonRowState: SingleChoiceSegmentedButtonRowState = rememberSingleChoiceSegmentedButtonRowState(0),
4446
onClick: (item: T, index: Int) -> Unit = { _, _ -> },
4547
label: @Composable (item: T, index: Int) -> Unit = { item, _ ->
@@ -68,7 +70,7 @@ fun <T> SingleChoiceSegmentedButtonRow(
6870
@Composable
6971
private fun SingleChoiceSegmentedButtonRowPreview() {
7072
SingleChoiceSegmentedButtonRow(
71-
items = listOf("All", "Basics"),
73+
items = persistentListOf("All", "Basics"),
7274
onClick = { _, _ ->
7375

7476
}

composeApp/src/commonMain/kotlin/org/neotech/app/abysner/presentation/component/core/ResourceExtensions.kt

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,26 +18,28 @@ import org.jetbrains.compose.resources.StringResource
1818
import org.jetbrains.compose.resources.pluralStringResource
1919
import org.jetbrains.compose.resources.stringResource
2020

21+
private data class PluralData(val resource: PluralStringResource, val quantity: Int, val value: Any)
22+
2123
interface PluralBuilder {
2224

23-
@Composable
2425
fun pluralArgument(resource: PluralStringResource, quantity: Int, value: Any)
2526

26-
@Composable
2727
fun pluralInt(resource: PluralStringResource, quantity: Int) =
2828
pluralArgument(resource, quantity, quantity)
2929
}
3030

31-
3231
@Composable
33-
fun pluralsStringBuilder(resource: StringResource, build: @Composable PluralBuilder.() -> Unit): String {
34-
val arguments = mutableListOf<String>()
35-
val builder = object: PluralBuilder {
36-
@Composable
32+
fun pluralsStringBuilder(resource: StringResource, build: PluralBuilder.() -> Unit): String {
33+
val pluralArgs = mutableListOf<PluralData>()
34+
val builder = object : PluralBuilder {
3735
override fun pluralArgument(resource: PluralStringResource, quantity: Int, value: Any) {
38-
arguments.add(pluralStringResource(resource, quantity, value))
36+
pluralArgs.add(PluralData(resource, quantity, value))
3937
}
4038
}
4139
builder.build()
40+
41+
val arguments = pluralArgs.map { (resource, quantity, value) ->
42+
pluralStringResource(resource, quantity, value)
43+
}
4244
return stringResource(resource, *arguments.toTypedArray())
4345
}

composeApp/src/commonMain/kotlin/org/neotech/app/abysner/presentation/component/graphs/BarChart.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import androidx.compose.ui.text.drawText
2727
import androidx.compose.ui.text.rememberTextMeasurer
2828
import androidx.compose.ui.unit.Constraints
2929
import androidx.compose.ui.unit.dp
30+
import kotlinx.collections.immutable.ImmutableList
3031
import kotlin.math.max
3132
import kotlin.math.min
3233

@@ -41,6 +42,9 @@ internal fun GasBarChartLayout(
4142
graph: @Composable (modifier: Modifier) -> Unit,
4243
) {
4344
// ConstraintLayout uses this internally, but is not yet available on Compose MultiPlatform
45+
// In this specific case, using the MultiMeasureLayout is actually beneficial to achieve the
46+
// desired layout in a performant way.
47+
@Suppress("DEPRECATION")
4448
MultiMeasureLayout(
4549
modifier = modifier,
4650
content = {
@@ -111,7 +115,7 @@ internal fun StackedHorizontalBar(
111115
minValue: Float = 0f,
112116
maxValue: Float = 200f,
113117
offset: Float = 0f,
114-
values: List<BarSection>,
118+
values: ImmutableList<BarSection>,
115119
valueTransformation: (Int, Float) -> String = { _, value -> value.toString() }
116120
) {
117121
// TextMeasurer for text measurement

0 commit comments

Comments
 (0)