Skip to content
Merged
Show file tree
Hide file tree
Changes from 19 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
7 changes: 6 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,9 @@ root = true
charset = utf-8
insert_final_newline = true
max_line_length = 120
end_of_line = crlf
end_of_line = crlf

[*.{kt,kts}]
ktlint_code_style = intellij_idea
ktlint_function_naming_ignore_when_annotated_with = Composable
ktlint_standard_filename = disabled
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,5 @@ google-services.json
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
replay_pid*

*.DS_Store
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@ configure<KtlintExtension> {
val libs = extensions.getByType<VersionCatalogsExtension>().named("libs")

version = libs.findVersion("ktlint").get().toString()
disabledRules = setOf("filename")
}
1 change: 0 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ android.library.defaults.buildfeatures.androidresources=false

# Kotlin
kotlin.code.style=official
kotlin.native.useEmbeddableCompilerJar=true
kotlin.native.ignoreDisabledTargets=true
kotlin.mpp.stability.nowarn=true

Expand Down
31 changes: 17 additions & 14 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
[versions]
agp = "8.11.0"
kotlin = "2.2.0"
agp = "8.12.2"
kotlin = "2.2.21"
mavenPublish = "0.33.0"
composeMultiplatform = "1.8.2"
binaryCompatibilityValidator = "0.18.0"
composeMultiplatform = "1.10.3"
binaryCompatibilityValidator = "0.18.1"
atomicfu = "0.29.0"
ktlint = "0.47.1"
ktlintPlugin = "12.3.0"
ktlint = "1.0.1"
ktlintPlugin = "13.0.0"

coroutines = "1.10.2"
kodein = "7.21.2"
koin-compose = "4.1.0"
kodein = "7.29.0"
koin-compose = "4.1.1"
hilt = "2.56.2"
lifecycle = "2.9.1"
activityCompose = "1.10.1"
rxjava = "3.1.10"
lifecycle = "2.10.0"
activityCompose = "1.12.0"
rxjava = "3.1.12"

androidxKmp-bundle = "1.0.1"
androidxKmp-lifecycle = "2.9.1"
androidxKmp-lifecycle = "2.10.0"

junit = "5.13.2"

Expand All @@ -41,10 +40,14 @@ androidx-lifecycle-livedata = { module = "androidx.lifecycle:lifecycle-livedata-
androidx-activity-compose = { module = "androidx.activity:activity-compose", version.ref = "activityCompose" }
rxjava = { module = "io.reactivex.rxjava3:rxjava", version.ref = "rxjava" }

androidxKmp-core-bundle = { module = "org.jetbrains.androidx.core:core-bundle", version.ref = "androidxKmp-bundle" }
androidxKmp-animation = { module = "org.jetbrains.compose.animation:animation", version.ref = "composeMultiplatform" }
androidxKmp-lifecycle-runtimeCompose = { module = "org.jetbrains.androidx.lifecycle:lifecycle-runtime-compose", version.ref = "androidxKmp-lifecycle" }
androidxKmp-lifecycle-viewmodel = { module = "org.jetbrains.androidx.lifecycle:lifecycle-viewmodel", version.ref = "androidxKmp-lifecycle" }
androidxKmp-lifecycle-viewmodelCompose = { module = "org.jetbrains.androidx.lifecycle:lifecycle-viewmodel-compose", version.ref = "androidxKmp-lifecycle" }
androidxKmp-material = { module = "org.jetbrains.compose.material:material", version.ref = "composeMultiplatform" }
androidxKmp-runtime = { module = "org.jetbrains.compose.runtime:runtime", version.ref = "composeMultiplatform" }
androidxKmp-runtime-saveable = { module = "org.jetbrains.compose.runtime:runtime-saveable", version.ref = "composeMultiplatform" }
androidxKmp-ui = { module = "org.jetbrains.compose.ui:ui", version.ref = "composeMultiplatform" }

junit-engine = { module = "org.junit.jupiter:junit-jupiter-engine", version.ref = "junit" }
junit-api = { module = "org.junit.jupiter:junit-jupiter-api", version.ref = "junit" }
Expand Down
1 change: 1 addition & 0 deletions samples/android/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ android {
namespace = "cafe.adriel.voyager.sample"
defaultConfig {
applicationId = "cafe.adriel.voyager.sample"
minSdk = 23
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class App : Application(), DIAware {
viewModel { parameters ->
AndroidDetailsViewModel(index = parameters.get())
}
}
},
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class SampleActivity : ComponentActivity() {
verticalArrangement = Arrangement.Center,
horizontalAlignment = Alignment.CenterHorizontally,
modifier = Modifier.fillMaxSize(),
contentPadding = PaddingValues(24.dp)
contentPadding = PaddingValues(24.dp),
) {
item {
StartSampleButton<StateStackActivity>("SnapshotStateStack")
Expand Down Expand Up @@ -78,7 +78,7 @@ class SampleActivity : ComponentActivity() {

Button(
onClick = { context.startActivity(Intent(this, T::class.java)) },
modifier = Modifier.fillMaxWidth().padding(vertical = 8.dp)
modifier = Modifier.fillMaxWidth().padding(vertical = 8.dp),
) {
Text(text = text)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ val sampleItems: List<String>
fun LoadingContent() {
Box(
contentAlignment = Alignment.Center,
modifier = Modifier.fillMaxSize()
modifier = Modifier.fillMaxSize(),
) {
CircularProgressIndicator()
}
Expand All @@ -41,7 +41,7 @@ fun ListContent(items: List<String>, onClick: ((Int) -> Unit)? = null) {
itemsIndexed(items) { index, item ->
ListItem(
text = { Text(text = item) },
modifier = if (onClick == null) Modifier else Modifier.clickable { onClick(index) }
modifier = if (onClick == null) Modifier else Modifier.clickable { onClick(index) },
)
}
}
Expand All @@ -52,25 +52,25 @@ fun DetailsContent(instance: Any, item: String, onClick: () -> Unit) {
Column(
verticalArrangement = Arrangement.Center,
horizontalAlignment = Alignment.CenterHorizontally,
modifier = Modifier.fillMaxSize()
modifier = Modifier.fillMaxSize(),
) {
Text(
text = item,
style = MaterialTheme.typography.h5
style = MaterialTheme.typography.h5,
)

Spacer(modifier = Modifier.height(16.dp))

Text(
text = instance.toString().substringAfterLast('.'),
style = MaterialTheme.typography.body2
style = MaterialTheme.typography.body2,
)

Spacer(modifier = Modifier.height(16.dp))

Button(
onClick = onClick,
content = { Text(text = "Back") }
content = { Text(text = "Back") },
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,25 +30,25 @@ class LegacyScreenOne : Screen {
Column(
verticalArrangement = Arrangement.Center,
horizontalAlignment = Alignment.CenterHorizontally,
modifier = Modifier.fillMaxSize()
modifier = Modifier.fillMaxSize(),
) {
Text(
text = model.text,
style = MaterialTheme.typography.h5
style = MaterialTheme.typography.h5,
)

Spacer(modifier = Modifier.height(16.dp))

Text(
text = model.toString().substringAfterLast('.'),
style = MaterialTheme.typography.body2
style = MaterialTheme.typography.body2,
)

Spacer(modifier = Modifier.height(16.dp))

Button(
onClick = { navigator.push(LegacyScreenTwo()) },
content = { Text(text = "Go to Two") }
content = { Text(text = "Go to Two") },
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,25 +30,25 @@ class LegacyScreenTwo : Screen {
Column(
verticalArrangement = Arrangement.Center,
horizontalAlignment = Alignment.CenterHorizontally,
modifier = Modifier.fillMaxSize()
modifier = Modifier.fillMaxSize(),
) {
Text(
text = model.text,
style = MaterialTheme.typography.h5
style = MaterialTheme.typography.h5,
)

Spacer(modifier = Modifier.height(16.dp))

Text(
text = model.toString().substringAfterLast('.'),
style = MaterialTheme.typography.body2
style = MaterialTheme.typography.body2,
)

Spacer(modifier = Modifier.height(16.dp))

Button(
onClick = navigator::pop,
content = { Text(text = "Go to One") }
content = { Text(text = "Go to One") },
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import org.koin.androidx.compose.koinViewModel
import org.koin.core.parameter.parametersOf

data class AndroidDetailsScreen(
val index: Int
val index: Int,
) : Screen {
override val key: ScreenKey = uniqueScreenKey

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package cafe.adriel.voyager.sample.androidViewModel
import androidx.lifecycle.ViewModel

class AndroidDetailsViewModel(
val index: Int
val index: Int,
) : ViewModel() {

override fun onCleared() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class BasicNavigationActivity : ComponentActivity() {
onBackPressed = { currentScreen ->
Log.d("Navigator", "Pop screen #${(currentScreen as BasicNavigationScreen).index}")
true
}
},
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import cafe.adriel.voyager.navigator.currentOrThrow

data class BasicNavigationScreen(
val index: Int,
val wrapContent: Boolean = false
val wrapContent: Boolean = false,
) : Screen {

override val key = uniqueScreenKey
Expand Down Expand Up @@ -57,22 +57,22 @@ data class BasicNavigationScreen(
} else {
fillMaxSize()
}
}
},
) {
Text(
text = "Screen #$index",
style = MaterialTheme.typography.h5
style = MaterialTheme.typography.h5,
)

Spacer(modifier = Modifier.height(24.dp))

Row(
modifier = Modifier.padding(16.dp)
modifier = Modifier.padding(16.dp),
) {
Button(
enabled = navigator.canPop,
onClick = navigator::pop,
modifier = Modifier.weight(.5f)
modifier = Modifier.weight(.5f),
) {
Text(text = "Pop")
}
Expand All @@ -81,7 +81,7 @@ data class BasicNavigationScreen(

Button(
onClick = { navigator.push(BasicNavigationScreen(index.inc(), wrapContent)) },
modifier = Modifier.weight(.5f)
modifier = Modifier.weight(.5f),
) {
Text(text = "Push")
}
Expand All @@ -90,14 +90,14 @@ data class BasicNavigationScreen(

Button(
onClick = { navigator.replace(BasicNavigationScreen(index.inc(), wrapContent)) },
modifier = Modifier.weight(.5f)
modifier = Modifier.weight(.5f),
) {
Text(text = "Replace")
}
}

LazyColumn(
modifier = Modifier.height(100.dp)
modifier = Modifier.height(100.dp),
) {
items(100) {
Text("Item #$it")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ class BackScreen : Screen {

Box(
contentAlignment = Alignment.Center,
modifier = Modifier.fillMaxSize()
modifier = Modifier.fillMaxSize(),
) {
Button(
onClick = { bottomSheetNavigator.show(BasicNavigationScreen(index = 0, wrapContent = true)) }
onClick = { bottomSheetNavigator.show(BasicNavigationScreen(index = 0, wrapContent = true)) },
) {
Text(text = "Show BottomSheet")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import cafe.adriel.voyager.navigator.currentOrThrow
import cafe.adriel.voyager.sample.DetailsContent

data class HiltDetailsScreen(
val index: Int
val index: Int,
) : Screen {
override val key: ScreenKey = uniqueScreenKey

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import dagger.assisted.AssistedInject

// Working with Assisted Injection here to simulate a custom param in the constructor
class HiltDetailsScreenModel @AssistedInject constructor(
@Assisted val index: Int
@Assisted val index: Int,
) : ScreenModel {

@AssistedFactory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import dagger.hilt.android.lifecycle.HiltViewModel

@HiltViewModel(assistedFactory = HiltDetailsViewModel.Factory::class)
class HiltDetailsViewModel @AssistedInject constructor(
@Assisted val index: Int
@Assisted val index: Int,
) : ViewModel() {

@AssistedFactory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import javax.inject.Inject

@HiltViewModel
class HiltListViewModel @Inject constructor(
private val handle: SavedStateHandle
private val handle: SavedStateHandle,
) : ViewModel() {

init {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ abstract class HiltModule {
@IntoMap
@ScreenModelFactoryKey(HiltDetailsScreenModel.Factory::class)
abstract fun bindHiltDetailsScreenModelFactory(
hiltDetailsScreenModelFactory: HiltDetailsScreenModel.Factory
hiltDetailsScreenModelFactory: HiltDetailsScreenModel.Factory,
): ScreenModelFactory
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package cafe.adriel.voyager.sample.kodeinIntegration
import org.kodein.di.bindings.ScopeCloseable

data class KodeinScopedDependencySample(
val screenKey: String
val screenKey: String,
) : ScopeCloseable {
override fun close() {
println("Being disposed")
Expand Down
Loading
Loading