Skip to content

Commit 1aee3d0

Browse files
committed
Remove useless code
1 parent 73b88b2 commit 1aee3d0

File tree

6 files changed

+2
-115
lines changed

6 files changed

+2
-115
lines changed

build.gradle.kts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
plugins {
2-
// this is necessary to avoid the plugins to be loaded multiple times
3-
// in each subproject's classloader
42
alias(libs.plugins.androidApplication) apply false
5-
alias(libs.plugins.androidLibrary) apply false
63
alias(libs.plugins.jetbrainsCompose) apply false
74
alias(libs.plugins.compose.compiler) apply false
85
alias(libs.plugins.kotlinMultiplatform) apply false
9-
kotlin("plugin.serialization") version "1.5.30"
106
}

composeApp/build.gradle.kts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ plugins {
66
alias(libs.plugins.androidApplication)
77
alias(libs.plugins.jetbrainsCompose)
88
alias(libs.plugins.compose.compiler)
9-
kotlin("plugin.serialization") version "1.5.30"
109
}
1110

1211
kotlin {
@@ -46,14 +45,6 @@ kotlin {
4645
implementation(libs.navigator.koin)
4746
implementation(libs.navigator.screen.model)
4847

49-
// Ktor for networking
50-
implementation(libs.ktor.client.core)
51-
implementation(libs.ktor.client.cio) // or another engine
52-
implementation(libs.ktor.client.content.negotiation)
53-
implementation(libs.ktor.serialization.kotlinx.json)
54-
implementation(libs.kotlinx.serialization.json)
55-
implementation(libs.ktor.serialization.kotlinx.json)
56-
5748
val voyagerVersion = "1.1.0-beta02"
5849

5950
implementation("cafe.adriel.voyager:voyager-screenmodel:$voyagerVersion")

composeApp/src/commonMain/kotlin/org/example/project/StateControl.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import kotlinx.coroutines.Job
44
import ru.nsk.kstatemachine.event.Event
55
import ru.nsk.kstatemachine.state.DefaultState
66

7-
87
sealed interface ControlEvent : Event {
98
object JumpPressEvent : ControlEvent
109
object JumpCompleteEvent : ControlEvent

composeApp/src/commonMain/kotlin/org/example/project/StickManGameScreen.kt

Lines changed: 1 addition & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,27 @@
11
package org.example.project
22

3-
import androidx.compose.animation.AnimatedVisibility
43
import androidx.compose.foundation.Image
5-
import androidx.compose.foundation.clickable
64
import androidx.compose.foundation.interaction.MutableInteractionSource
75
import androidx.compose.foundation.interaction.collectIsPressedAsState
86
import androidx.compose.foundation.layout.*
97
import androidx.compose.material.Button
10-
import androidx.compose.material.CircularProgressIndicator
118
import androidx.compose.material.Text
129
import androidx.compose.runtime.*
1310
import androidx.compose.ui.Alignment
1411
import androidx.compose.ui.Modifier
15-
import androidx.compose.ui.layout.ContentScale
16-
import androidx.compose.ui.platform.LocalLifecycleOwner
1712
import androidx.compose.ui.unit.dp
1813
import androidx.compose.ui.unit.sp
14+
import androidx.lifecycle.compose.LocalLifecycleOwner
1915
import cafe.adriel.voyager.core.screen.Screen
2016
import kotlinx.coroutines.launch
2117
import org.example.project.ControlEvent.*
2218
import org.example.project.HeroState.*
2319
import cafe.adriel.voyager.koin.getScreenModel
2420
import co.touchlab.kermit.Logger
25-
import com.skydoves.landscapist.ImageOptions
26-
import com.skydoves.landscapist.coil3.CoilImage
2721
import kotlinx.coroutines.flow.collectLatest
2822
import kstatemachine_compose_sample.composeapp.generated.resources.Res
2923
import kstatemachine_compose_sample.composeapp.generated.resources.airattacking
3024
import kstatemachine_compose_sample.composeapp.generated.resources.airattacking_shooting
31-
import kstatemachine_compose_sample.composeapp.generated.resources.compose_multiplatform
3225
import kstatemachine_compose_sample.composeapp.generated.resources.ducking
3326
import kstatemachine_compose_sample.composeapp.generated.resources.ducking_shooting
3427
import kstatemachine_compose_sample.composeapp.generated.resources.jumping
@@ -38,7 +31,6 @@ import kstatemachine_compose_sample.composeapp.generated.resources.standing_shoo
3831
import org.jetbrains.compose.resources.DrawableResource
3932
import org.jetbrains.compose.resources.painterResource
4033

41-
4234
class StickManGameScreen : Screen {
4335
@Composable
4436
override fun Content() {
@@ -81,12 +73,9 @@ private fun onEffect(effect: ModelEffect) {
8173

8274
@Composable
8375
fun StickManGameScreenContent(viewModel: StickManGameScreenModel) {
84-
val xkcdClient = remember { XkcdClient() }
8576
val coroutineScope = rememberCoroutineScope()
86-
var imageUrl by remember { mutableStateOf<String?>(null) }
8777
// Observe the state from the ViewModel
8878
val uiState by viewModel.model.stateFlow.collectAsState()
89-
var showContent by remember { mutableStateOf(false) }
9079

9180
// State variables for drawable and ammo count
9281
var heroDrawableRes by remember { mutableStateOf(Res.drawable.standing) }
@@ -103,7 +92,6 @@ fun StickManGameScreenContent(viewModel: StickManGameScreenModel) {
10392

10493
LaunchedEffect(Unit) {
10594
coroutineScope.launch {
106-
imageUrl = xkcdClient.getCurrentXkcdImageUrl()
10795
viewModel.observe(
10896
lifecycleOwner,
10997
{ state ->
@@ -165,29 +153,6 @@ fun StickManGameScreenContent(viewModel: StickManGameScreenModel) {
165153
verticalArrangement = Arrangement.spacedBy(16.dp),
166154
horizontalAlignment = Alignment.CenterHorizontally
167155
) {
168-
AnimatedVisibility(showContent) {
169-
Column(
170-
Modifier.fillMaxWidth().weight(1f),
171-
horizontalAlignment = Alignment.CenterHorizontally
172-
) {
173-
imageUrl?.let { url ->
174-
CoilImage(
175-
modifier = Modifier.fillMaxWidth()
176-
,
177-
imageModel = { imageUrl },
178-
imageOptions = ImageOptions(
179-
contentScale = ContentScale.Crop,
180-
alignment = Alignment.Center
181-
)
182-
)
183-
} ?: CircularProgressIndicator()
184-
Image(
185-
painterResource(Res.drawable.compose_multiplatform),
186-
null,
187-
modifier = Modifier.size(100.dp)
188-
)
189-
}
190-
}
191156
Text(
192157
text = "Ammo: ${uiState.ammoLeft}",
193158
fontSize = 20.sp,
@@ -225,14 +190,5 @@ fun StickManGameScreenContent(viewModel: StickManGameScreenModel) {
225190
}
226191
}
227192
}
228-
Image(
229-
painter = painterResource(Res.drawable.compose_multiplatform),
230-
contentDescription = null,
231-
modifier = Modifier
232-
.size(100.dp)
233-
.align(Alignment.TopEnd)
234-
.padding(8.dp)
235-
.clickable { showContent = !showContent }
236-
)
237193
}
238194
}

composeApp/src/commonMain/kotlin/org/example/project/XkcdClient.kt

Lines changed: 0 additions & 46 deletions
This file was deleted.

gradle/libs.versions.toml

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,18 @@ androidx-lifecycle = "2.9.1"
88
compose-plugin = "1.8.2"
99
kermit = "2.0.6"
1010
kotlin = "2.2.0"
11-
kotlinxSerializationJson = "1.9.0"
1211
kstatemachine = "0.34.1"
1312
koin = "4.1.0"
14-
koinComposeMultiplatform = "4.1.0"
15-
ktorSerializationKotlinxJson = "3.2.3"
1613
landscapistCoil3 = "2.5.1"
1714
startupRuntime = "1.2.0"
1815
voyager = "1.0.1"
1916

2017
[libraries]
2118
kermit = { module = "co.touchlab:kermit", version.ref = "kermit" }
22-
kotlinx-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "kotlinxSerializationJson" }
2319
kstatemachine = { module = "io.github.nsk90:kstatemachine", version.ref = "kstatemachine" }
2420
kstatemachine-coroutines = { module = "io.github.nsk90:kstatemachine-coroutines", version.ref = "kstatemachine" }
2521
koin-core = { module = "io.insert-koin:koin-core", version.ref = "koin" }
26-
koin-compose = { module = "io.insert-koin:koin-compose", version.ref = "koinComposeMultiplatform" }
22+
koin-compose = { module = "io.insert-koin:koin-compose", version.ref = "koin" }
2723
navigator-screen-model = { module = "cafe.adriel.voyager:voyager-screenmodel", version.ref = "voyager" }
2824
navigator-koin = { module = "cafe.adriel.voyager:voyager-koin", version.ref = "voyager" }
2925
koin-android = { module = "io.insert-koin:koin-android", version.ref = "koin" }
@@ -32,16 +28,11 @@ koin-androidx-compose = { module = "io.insert-koin:koin-androidx-compose", versi
3228
androidx-activity-compose = { module = "androidx.activity:activity-compose", version.ref = "androidx-activityCompose" }
3329
androidx-lifecycle-viewmodel = { group = "org.jetbrains.androidx.lifecycle", name = "lifecycle-viewmodel", version.ref = "androidx-lifecycle" }
3430
androidx-lifecycle-runtime-compose = { group = "org.jetbrains.androidx.lifecycle", name = "lifecycle-runtime-compose", version.ref = "androidx-lifecycle" }
35-
ktor-client-cio = { module = "io.ktor:ktor-client-cio", version.ref = "ktorSerializationKotlinxJson" }
36-
ktor-client-content-negotiation = { module = "io.ktor:ktor-client-content-negotiation", version.ref = "ktorSerializationKotlinxJson" }
37-
ktor-client-core = { module = "io.ktor:ktor-client-core", version.ref = "ktorSerializationKotlinxJson" }
38-
ktor-serialization-kotlinx-json = { module = "io.ktor:ktor-serialization-kotlinx-json", version.ref = "ktorSerializationKotlinxJson" }
3931
landscapist-coil3 = { module = "com.github.skydoves:landscapist-coil3", version.ref = "landscapistCoil3" }
4032
androidx-startup-runtime = { group = "androidx.startup", name = "startup-runtime", version.ref = "startupRuntime" }
4133

4234
[plugins]
4335
androidApplication = { id = "com.android.application", version.ref = "agp" }
44-
androidLibrary = { id = "com.android.library", version.ref = "agp" }
4536
jetbrainsCompose = { id = "org.jetbrains.compose", version.ref = "compose-plugin" }
4637
compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
4738
kotlinMultiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }

0 commit comments

Comments
 (0)