diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 2bc0c80..268ee9f 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -4,6 +4,7 @@ import org.jetbrains.kotlin.gradle.dsl.JvmTarget plugins { alias(libs.plugins.kotlinMultiplatform) + alias(libs.plugins.kotlinxSerialization) alias(libs.plugins.androidApplication) alias(libs.plugins.jetbrainsCompose) alias(libs.plugins.compose.compiler) @@ -41,7 +42,6 @@ kotlin { implementation(libs.androidx.activity.compose) implementation(libs.common.koin.android) implementation(libs.androidx.datastore) - implementation(libs.androidx.compose.windowsizeclass) } desktopMain.dependencies { @@ -71,9 +71,15 @@ kotlin { implementation(compose.components.resources) implementation(compose.components.uiToolingPreview) + // Material3 +// implementation(libs.composematerial3.adaptive) +// implementation(libs.composematerial3.adaptive.layout) +// implementation(libs.composematerial3.adaptive.navigation) + // Common implementation(libs.common.koin) implementation(libs.util.constraintlayout) + implementation(libs.kotlin.serialization.json) } commonTest.dependencies { diff --git a/app/src/androidMain/kotlin/id/gdg/app/MainActivity.kt b/app/src/androidMain/kotlin/id/gdg/app/MainActivity.kt index f0ab704..07f137e 100644 --- a/app/src/androidMain/kotlin/id/gdg/app/MainActivity.kt +++ b/app/src/androidMain/kotlin/id/gdg/app/MainActivity.kt @@ -1,3 +1,5 @@ +@file:OptIn(ExperimentalMaterial3WindowSizeClassApi::class) + package id.gdg.app import android.os.Bundle @@ -7,13 +9,13 @@ import androidx.compose.foundation.isSystemInDarkTheme import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Surface +import androidx.compose.material3.windowsizeclass.ExperimentalMaterial3WindowSizeClassApi +import androidx.compose.material3.windowsizeclass.calculateWindowSizeClass import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.ui.Modifier import id.gdg.ui.DarkColorPalette import id.gdg.ui.LightColorPalette -import id.gdg.ui.androidx.compose.material3.windowsizeclass.CommonWindowSizeClass -import id.gdg.ui.androidx.compose.material3.windowsizeclass.LocalWindowSizeClass -import id.gdg.ui.androidx.compose.material3.windowsizeclass.calculateWindowSizeClass +import id.gdg.ui.LocalWindowSizeClass class MainActivity : ComponentActivity() { override fun onCreate(savedInstanceState: Bundle?) { @@ -21,7 +23,7 @@ class MainActivity : ComponentActivity() { setContent { val colors = if (isSystemInDarkTheme()) DarkColorPalette else LightColorPalette - val windowSizeClass: CommonWindowSizeClass = calculateWindowSizeClass(this) + val windowSizeClass = calculateWindowSizeClass(this) CompositionLocalProvider(LocalWindowSizeClass provides windowSizeClass) { MaterialTheme( diff --git a/app/src/commonMain/kotlin/id/gdg/app/App.kt b/app/src/commonMain/kotlin/id/gdg/app/App.kt index 94dd994..38753eb 100644 --- a/app/src/commonMain/kotlin/id/gdg/app/App.kt +++ b/app/src/commonMain/kotlin/id/gdg/app/App.kt @@ -6,15 +6,17 @@ import androidx.compose.material3.Scaffold import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.navigation.NavHostController -import androidx.navigation.NavType import androidx.navigation.compose.NavHost import androidx.navigation.compose.composable import androidx.navigation.compose.rememberNavController -import androidx.navigation.navArgument +import androidx.navigation.toRoute import id.gdg.app.di.ViewModelFactory import id.gdg.app.ui.AppEvent -import id.gdg.app.ui.AppRouter +import id.gdg.app.ui.EventDetailRouter +import id.gdg.app.ui.HomeRouter +import id.gdg.app.ui.OnboardingRouter import id.gdg.app.ui.ScreenScaffold +import id.gdg.app.ui.SplashScreenRouter import id.gdg.app.ui.screen.EventDetailScreen import id.gdg.app.ui.screen.MainScreen import id.gdg.app.ui.screen.OnboardingScreen @@ -28,36 +30,38 @@ fun AppContent( Scaffold { innerPadding -> NavHost( navController = navController, - startDestination = AppRouter.Onboarding.toString(), //defaultRoute(state.activeChapterId), + startDestination = SplashScreenRouter, modifier = Modifier .fillMaxSize() .padding(innerPadding) ) { - composable(route = AppRouter.Splash.toString()) { + composable { SplashScreen { - navController.navigateTo( - from = AppRouter.Splash, - to = AppRouter.Onboarding - ) + navController.navigate(OnboardingRouter) { + popUpTo(SplashScreenRouter) { + inclusive = true + } + } } } - composable(route = AppRouter.Onboarding.toString()) { + composable { OnboardingScreen( chapterList = viewModel.chapterList, onChapterSelected = { chapterId -> viewModel.sendEvent(AppEvent.ChangeChapterId(chapterId)) }, navigateToMainScreen = { - navController.navigateTo( - from = AppRouter.Onboarding, - to = AppRouter.Home - ) + navController.navigate(HomeRouter) { + popUpTo(OnboardingRouter) { + inclusive = true + } + } } ) } - composable(route = AppRouter.Home.toString()) { + composable { ScreenScaffold( viewModel = viewModel, mainScreen = { viewModel, onEventDetailClicked -> @@ -81,37 +85,19 @@ fun AppContent( ) }, navigateToDetailScreen = { eventId -> - navController.navigate( - AppRouter.EventDetail.route.param(eventId) - ) + navController.navigate(EventDetailRouter(eventId)) } ) } - composable( - route = AppRouter.EventDetail.toString(), - arguments = listOf(navArgument(AppRouter.ARG_EVENT_ID) { type = NavType.StringType }) - ) { backStackEntry -> - val eventId = backStackEntry.arguments?.getString(AppRouter.ARG_EVENT_ID).orEmpty() + composable { + val eventDetail = it.toRoute() EventDetailScreen( viewModel = viewModel, - eventId = eventId + eventId = eventDetail.eventId ) } } } } - -private fun NavHostController.navigateTo(from: AppRouter? = null, to: AppRouter) { - navigate(to.route.toString()) { - if (from != null) { -// popUpTo(from.route) { -// inclusive = true -// } - } - } -} - -private fun defaultRoute(chapterId: Int) = - if (chapterId > 0) AppRouter.Home.route else AppRouter.Splash.route \ No newline at end of file diff --git a/app/src/commonMain/kotlin/id/gdg/app/ui/AppRouter.kt b/app/src/commonMain/kotlin/id/gdg/app/ui/AppRouter.kt deleted file mode 100644 index a5c675e..0000000 --- a/app/src/commonMain/kotlin/id/gdg/app/ui/AppRouter.kt +++ /dev/null @@ -1,44 +0,0 @@ -@file:Suppress("MemberVisibilityCanBePrivate") - -package id.gdg.app.ui - -import kotlin.jvm.JvmInline - -sealed class AppRouter(val route: Path) { - - data object Splash : AppRouter(Path("splash")) - data object Onboarding : AppRouter(Path("onboarding")) - data object Home : AppRouter(Path("home")) - data object EventDetail : AppRouter(Path("detail/{${ARG_EVENT_ID}}")) - - override fun toString(): String { - return "gdg://$route" - } - - companion object { - const val ARG_EVENT_ID = "eventId" - } -} - -@JvmInline -value class Path(private val value: String) { - - fun param(param: String): String { - return param(arrayOf(param)) - } - - fun param(args: Array): String { - var result = value - val regex = Regex("\\{([^}]+)\\}") - val matches = regex.findAll(value) - if (matches.any()) { - matches.forEachIndexed { index, match -> - result = result.replace(match.value, args[index]) - } - } - - return result - } - - override fun toString() = value -} \ No newline at end of file diff --git a/app/src/commonMain/kotlin/id/gdg/app/ui/Router.kt b/app/src/commonMain/kotlin/id/gdg/app/ui/Router.kt new file mode 100644 index 0000000..8642e21 --- /dev/null +++ b/app/src/commonMain/kotlin/id/gdg/app/ui/Router.kt @@ -0,0 +1,17 @@ +package id.gdg.app.ui + +import kotlinx.serialization.Serializable + +sealed interface Router + +@Serializable +data object SplashScreenRouter : Router + +@Serializable +data object OnboardingRouter : Router + +@Serializable +data object HomeRouter : Router + +@Serializable +data class EventDetailRouter(val eventId: String) : Router \ No newline at end of file diff --git a/app/src/commonMain/kotlin/id/gdg/app/ui/ScreenScaffold.kt b/app/src/commonMain/kotlin/id/gdg/app/ui/ScreenScaffold.kt index 2f44e77..9269b81 100644 --- a/app/src/commonMain/kotlin/id/gdg/app/ui/ScreenScaffold.kt +++ b/app/src/commonMain/kotlin/id/gdg/app/ui/ScreenScaffold.kt @@ -1,6 +1,7 @@ package id.gdg.app.ui import androidx.compose.material3.Surface +import androidx.compose.material3.windowsizeclass.WindowWidthSizeClass import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue @@ -9,11 +10,9 @@ import androidx.compose.runtime.saveable.rememberSaveable import androidx.compose.runtime.setValue import androidx.compose.ui.unit.dp import id.gdg.app.AppViewModel +import id.gdg.ui.LocalWindowSizeClass import id.gdg.ui.TwoPanelScaffold import id.gdg.ui.TwoPanelScaffoldAnimationSpec -import id.gdg.ui.androidx.compose.material3.windowsizeclass.CommonWindowSizeClass -import id.gdg.ui.androidx.compose.material3.windowsizeclass.CommonWindowWidthSizeClass -import id.gdg.ui.androidx.compose.material3.windowsizeclass.LocalWindowSizeClass @Composable fun ScreenScaffold( @@ -24,13 +23,13 @@ fun ScreenScaffold( ) { var selectedEventId by rememberSaveable { mutableStateOf("") } - val windowSizeClazz: CommonWindowSizeClass = LocalWindowSizeClass.current + val windowSizeClazz = LocalWindowSizeClass.current var shouldPanelOpened: Boolean? by rememberSaveable { mutableStateOf(null) } var panelVisibility by rememberSaveable { mutableStateOf(shouldPanelOpened != null) } LaunchedEffect(windowSizeClazz) { shouldPanelOpened = shouldPanelOpened.takeIf { - windowSizeClazz.widthSizeClass != CommonWindowWidthSizeClass.Compact + windowSizeClazz.widthSizeClass != WindowWidthSizeClass.Compact } panelVisibility = shouldPanelOpened != null @@ -45,7 +44,7 @@ fun ScreenScaffold( mainScreen(viewModel) { // If the screen size is compact (or mobile device screen size), then // navigate to detail page with router. Otherwise, render the [panel]. - if (windowSizeClazz.widthSizeClass == CommonWindowWidthSizeClass.Compact) { + if (windowSizeClazz.widthSizeClass == WindowWidthSizeClass.Compact) { navigateToDetailScreen(it) return@mainScreen } diff --git a/app/src/desktopMain/kotlin/id/gdg/app/main.kt b/app/src/desktopMain/kotlin/id/gdg/app/main.kt index 69b0c77..295302b 100644 --- a/app/src/desktopMain/kotlin/id/gdg/app/main.kt +++ b/app/src/desktopMain/kotlin/id/gdg/app/main.kt @@ -1,3 +1,5 @@ +@file:OptIn(ExperimentalMaterial3WindowSizeClassApi::class) + package id.gdg.app import androidx.compose.foundation.background @@ -7,6 +9,8 @@ import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.window.WindowDraggableArea import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.windowsizeclass.ExperimentalMaterial3WindowSizeClassApi +import androidx.compose.material3.windowsizeclass.calculateWindowSizeClass import androidx.compose.runtime.Composable import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.ui.Modifier @@ -23,8 +27,7 @@ import id.gdg.app.di.appModule import id.gdg.chapter.data.dataStore import id.gdg.ui.DarkColorPalette import id.gdg.ui.LightColorPalette -import id.gdg.ui.androidx.compose.material3.windowsizeclass.CommonWindowSizeClass -import id.gdg.ui.androidx.compose.material3.windowsizeclass.LocalWindowSizeClass +import id.gdg.ui.LocalWindowSizeClass import org.koin.core.context.startKoin import org.koin.dsl.module @@ -42,7 +45,7 @@ fun main() = application { val colors = if (isSystemInDarkTheme()) DarkColorPalette else LightColorPalette CompositionLocalProvider( - LocalWindowSizeClass provides CommonWindowSizeClass.calculateFromSize(windowState.size) + LocalWindowSizeClass provides calculateWindowSizeClass() ) { MaterialTheme(colorScheme = colors) { AppContent() diff --git a/app/src/iosMain/kotlin/id/gdg/app/MainViewController.kt b/app/src/iosMain/kotlin/id/gdg/app/MainViewController.kt index 2027b69..b639846 100644 --- a/app/src/iosMain/kotlin/id/gdg/app/MainViewController.kt +++ b/app/src/iosMain/kotlin/id/gdg/app/MainViewController.kt @@ -1,4 +1,5 @@ @file:Suppress("FunctionName") +@file:OptIn(ExperimentalMaterial3WindowSizeClassApi::class) package id.gdg.app @@ -7,20 +8,19 @@ import androidx.compose.foundation.layout.BoxWithConstraints import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Surface +import androidx.compose.material3.windowsizeclass.ExperimentalMaterial3WindowSizeClassApi +import androidx.compose.material3.windowsizeclass.calculateWindowSizeClass import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.ui.Modifier -import androidx.compose.ui.unit.DpSize import androidx.compose.ui.window.ComposeUIViewController import id.gdg.ui.DarkColorPalette import id.gdg.ui.LightColorPalette -import id.gdg.ui.androidx.compose.material3.windowsizeclass.LocalWindowSizeClass -import id.gdg.ui.androidx.compose.material3.windowsizeclass.CommonWindowSizeClass -import id.gdg.ui.androidx.compose.material3.windowsizeclass.calculateWindowSizeClass +import id.gdg.ui.LocalWindowSizeClass fun MainViewController() = ComposeUIViewController { BoxWithConstraints { val colors = if (isSystemInDarkTheme()) DarkColorPalette else LightColorPalette - val windowSizeClass: CommonWindowSizeClass = calculateWindowSizeClass(DpSize(maxWidth, maxHeight)) + val windowSizeClass = calculateWindowSizeClass() CompositionLocalProvider(LocalWindowSizeClass provides windowSizeClass) { MaterialTheme(colorScheme = colors) { diff --git a/gdg-ui/build.gradle.kts b/gdg-ui/build.gradle.kts index 45e35b7..d57a1bd 100644 --- a/gdg-ui/build.gradle.kts +++ b/gdg-ui/build.gradle.kts @@ -25,10 +25,9 @@ kotlin { } sourceSets { - androidMain.dependencies { - implementation(libs.androidx.compose.windowsizeclass) - } commonMain.dependencies { + api(libs.composematerial3.window.size.clazz) + api(libs.util.qdsfdhvh.image.loader) api(libs.util.shimmer) @@ -43,7 +42,6 @@ kotlin { android { namespace = "id.gdg.ui" compileSdk = libs.versions.android.compileSdk.get().toInt() - sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml") defaultConfig { minSdk = libs.versions.android.minSdk.get().toInt() diff --git a/gdg-ui/src/androidMain/AndroidManifest.xml b/gdg-ui/src/androidMain/AndroidManifest.xml deleted file mode 100644 index 568741e..0000000 --- a/gdg-ui/src/androidMain/AndroidManifest.xml +++ /dev/null @@ -1,2 +0,0 @@ - - \ No newline at end of file diff --git a/gdg-ui/src/androidMain/kotlin/id/gdg/ui/androidx/compose/material3/windowsizeclass/calculateWindowSizeClass.kt b/gdg-ui/src/androidMain/kotlin/id/gdg/ui/androidx/compose/material3/windowsizeclass/calculateWindowSizeClass.kt deleted file mode 100644 index 1b10ae6..0000000 --- a/gdg-ui/src/androidMain/kotlin/id/gdg/ui/androidx/compose/material3/windowsizeclass/calculateWindowSizeClass.kt +++ /dev/null @@ -1,37 +0,0 @@ -package id.gdg.ui.androidx.compose.material3.windowsizeclass - -import android.app.Activity -import androidx.compose.material3.windowsizeclass.ExperimentalMaterial3WindowSizeClassApi -import androidx.compose.material3.windowsizeclass.WindowHeightSizeClass -import androidx.compose.material3.windowsizeclass.WindowSizeClass -import androidx.compose.material3.windowsizeclass.WindowWidthSizeClass -import androidx.compose.runtime.Composable -import androidx.compose.material3.windowsizeclass.calculateWindowSizeClass - -@OptIn(ExperimentalMaterial3WindowSizeClassApi::class) -@Composable -fun calculateWindowSizeClass(activity: Activity): CommonWindowSizeClass = - calculateWindowSizeClass(activity).map() - -fun WindowSizeClass.map(): CommonWindowSizeClass { - return CommonWindowSizeClass( - widthSizeClass = widthSizeClass.trasnform(), - heightSizeClass = heightSizeClass.trasnform() - ) -} - -fun WindowWidthSizeClass.trasnform(): CommonWindowWidthSizeClass { - return when { - this == WindowWidthSizeClass.Compact -> CommonWindowWidthSizeClass.Compact - this == WindowWidthSizeClass.Medium -> CommonWindowWidthSizeClass.Medium - else -> CommonWindowWidthSizeClass.Expanded - } -} - -fun WindowHeightSizeClass.trasnform(): CommonWindowHeightSizeClass { - return when { - this == WindowHeightSizeClass.Compact -> CommonWindowHeightSizeClass.Compact - this == WindowHeightSizeClass.Medium -> CommonWindowHeightSizeClass.Medium - else -> CommonWindowHeightSizeClass.Expanded - } -} \ No newline at end of file diff --git a/gdg-ui/src/commonMain/kotlin/id/gdg/ui/androidx.compose.material3.windowsizeclass/LocalWindowSizeClass.kt b/gdg-ui/src/commonMain/kotlin/id/gdg/ui/LocalWindowSizeClass.kt similarity index 54% rename from gdg-ui/src/commonMain/kotlin/id/gdg/ui/androidx.compose.material3.windowsizeclass/LocalWindowSizeClass.kt rename to gdg-ui/src/commonMain/kotlin/id/gdg/ui/LocalWindowSizeClass.kt index addd59c..2bd8e64 100644 --- a/gdg-ui/src/commonMain/kotlin/id/gdg/ui/androidx.compose.material3.windowsizeclass/LocalWindowSizeClass.kt +++ b/gdg-ui/src/commonMain/kotlin/id/gdg/ui/LocalWindowSizeClass.kt @@ -1,7 +1,8 @@ -package id.gdg.ui.androidx.compose.material3.windowsizeclass +package id.gdg.ui +import androidx.compose.material3.windowsizeclass.WindowSizeClass import androidx.compose.runtime.ProvidableCompositionLocal import androidx.compose.runtime.staticCompositionLocalOf -val LocalWindowSizeClass: ProvidableCompositionLocal = +val LocalWindowSizeClass: ProvidableCompositionLocal = staticCompositionLocalOf { error("No window size class provided") } \ No newline at end of file diff --git a/gdg-ui/src/commonMain/kotlin/id/gdg/ui/androidx.compose.material3.windowsizeclass/CommonWindowSizeClass.kt b/gdg-ui/src/commonMain/kotlin/id/gdg/ui/androidx.compose.material3.windowsizeclass/CommonWindowSizeClass.kt deleted file mode 100644 index 58858ef..0000000 --- a/gdg-ui/src/commonMain/kotlin/id/gdg/ui/androidx.compose.material3.windowsizeclass/CommonWindowSizeClass.kt +++ /dev/null @@ -1,101 +0,0 @@ -package id.gdg.ui.androidx.compose.material3.windowsizeclass - -import androidx.compose.runtime.Immutable -import androidx.compose.ui.unit.Dp -import androidx.compose.ui.unit.DpSize -import androidx.compose.ui.unit.dp -import kotlin.jvm.JvmInline - -@Immutable -class CommonWindowSizeClass( - val widthSizeClass: CommonWindowWidthSizeClass, - val heightSizeClass: CommonWindowHeightSizeClass -) { - companion object { - fun calculateFromSize(size: DpSize): CommonWindowSizeClass { - val windowWidthSizeClass = CommonWindowWidthSizeClass.fromWidth(size.width) - val windowHeightSizeClass = CommonWindowHeightSizeClass.fromHeight(size.height) - return CommonWindowSizeClass(windowWidthSizeClass, windowHeightSizeClass) - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) return true - if (other == null || this::class != other::class) return false - - other as CommonWindowSizeClass - - if (widthSizeClass != other.widthSizeClass) return false - if (heightSizeClass != other.heightSizeClass) return false - - return true - } - - override fun hashCode(): Int { - var result = widthSizeClass.hashCode() - result = 31 * result + heightSizeClass.hashCode() - return result - } - - override fun toString() = "WindowSizeClass($widthSizeClass, $heightSizeClass)" -} - -@JvmInline -value class CommonWindowWidthSizeClass private constructor(private val value: Int) : - Comparable { - override operator fun compareTo(other: CommonWindowWidthSizeClass) = value.compareTo(other.value) - - override fun toString(): String { - return "WindowWidthSizeClass." + when (this) { - Compact -> "Compact" - Medium -> "Medium" - Expanded -> "Expanded" - else -> "" - } - } - - companion object { - val Compact = CommonWindowWidthSizeClass(0) - val Medium = CommonWindowWidthSizeClass(1) - val Expanded = CommonWindowWidthSizeClass(2) - - internal fun fromWidth(width: Dp): CommonWindowWidthSizeClass { - require(width >= 0.dp) { "Width must not be negative" } - return when { - width < 600.dp -> Compact - width < 840.dp -> Medium - else -> Expanded - } - } - } -} - -@JvmInline -value class CommonWindowHeightSizeClass private constructor(private val value: Int) : - Comparable { - override operator fun compareTo(other: CommonWindowHeightSizeClass) = value.compareTo(other.value) - - override fun toString(): String { - return "WindowHeightSizeClass." + when (this) { - Compact -> "Compact" - Medium -> "Medium" - Expanded -> "Expanded" - else -> "" - } - } - - companion object { - val Compact = CommonWindowHeightSizeClass(0) - val Medium = CommonWindowHeightSizeClass(1) - val Expanded = CommonWindowHeightSizeClass(2) - - internal fun fromHeight(height: Dp): CommonWindowHeightSizeClass { - require(height >= 0.dp) { "Height must not be negative" } - return when { - height < 480.dp -> Compact - height < 900.dp -> Medium - else -> Expanded - } - } - } -} \ No newline at end of file diff --git a/gdg-ui/src/iosMain/kotlin/id/gdg/ui/androidx/compose/material3/windowsizeclass/calculateWindowSizeClass.kt b/gdg-ui/src/iosMain/kotlin/id/gdg/ui/androidx/compose/material3/windowsizeclass/calculateWindowSizeClass.kt deleted file mode 100644 index 876ea67..0000000 --- a/gdg-ui/src/iosMain/kotlin/id/gdg/ui/androidx/compose/material3/windowsizeclass/calculateWindowSizeClass.kt +++ /dev/null @@ -1,35 +0,0 @@ -package id.gdg.ui.androidx.compose.material3.windowsizeclass - -import androidx.compose.runtime.Composable -import androidx.compose.ui.geometry.Rect -import androidx.compose.ui.platform.LocalDensity -import androidx.compose.ui.unit.DpSize -import kotlinx.cinterop.ExperimentalForeignApi -import kotlinx.cinterop.useContents -import platform.UIKit.UIViewController - -@OptIn(ExperimentalForeignApi::class) -@Composable -fun calculateWindowSizeClass(controller: UIViewController): CommonWindowSizeClass { - val density = LocalDensity.current - - val rect: Rect = controller.view.bounds.useContents { - val x = origin.x.toFloat() - val y = origin.y.toFloat() - val width = size.width.toFloat() / 2 - val height = size.height.toFloat() / 2 - Rect( - left = x - width, - top = y - height, - right = x + width, - bottom = y + height, - ) - } - - val size = with(density) { rect.size.toDpSize() } - return CommonWindowSizeClass.calculateFromSize(size) -} - -@Composable -fun calculateWindowSizeClass(size: DpSize): CommonWindowSizeClass = - CommonWindowSizeClass.calculateFromSize(size) \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 5cd0895..f1c9806 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,5 +1,5 @@ [versions] -agp = "8.2.2" +agp = "8.1.4" android-compileSdk = "34" android-minSdk = "24" android-targetSdk = "34" @@ -8,17 +8,15 @@ androidx-appcompat = "1.7.0" androidx-constraintlayout = "2.1.4" androidx-datastore = "1.1.0" androidx-core-ktx = "1.13.1" -androidx-compose-material3 = "1.2.1" androidx-espresso-core = "3.6.1" -androidx-lifecycle = "2.8.0" +androidx-lifecycle = "2.8.1" androidx-material = "1.12.0" -androidx-navigation-compose = "2.7.0-alpha03" +androidx-navigation-compose = "2.8.0-alpha09" androidx-test-junit = "1.2.1" constraint-layout = "0.4.0" common-datetime = "0.5.0" common-essenty = "1.2.0" -compose-plugin = "1.6.11" -jetbrainsKotlinJvm = "1.9.0" +compose-plugin = "1.7.0-beta01" junit = "4.13.2" koin = "3.2.0" kotlin = "2.0.0" @@ -29,6 +27,8 @@ kover = "0.8.3" ksp = "2.0.0-1.0.24" ktor = "2.3.10" ktorfit = "2.0.0-beta1" +material3-adaptive = "1.0.0-rc01" +material3-wzc = "1.7.0-beta01" test-coroutines = "1.6.4" test-mockk = "1.13.12" test-turbine = "0.12.1" @@ -39,7 +39,6 @@ shimmer = "1.3.1" kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotlin" } kotlin-test-junit = { module = "org.jetbrains.kotlin:kotlin-test-junit", version.ref = "kotlin" } junit = { group = "junit", name = "junit", version.ref = "junit" } -androidx-compose-windowsizeclass = { module = "androidx.compose.material3:material3-window-size-class", version.ref = "androidx-compose-material3" } androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "androidx-core-ktx" } androidx-test-junit = { group = "androidx.test.ext", name = "junit", version.ref = "androidx-test-junit" } androidx-espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "androidx-espresso-core" } @@ -53,6 +52,11 @@ androidx-lifecycle-viewmodel = { group = "org.jetbrains.androidx.lifecycle", nam androidx-lifecycle-runtime-compose = { group = "org.jetbrains.androidx.lifecycle", name = "lifecycle-runtime-compose", version.ref = "androidx-lifecycle" } androidx-lifecycle-viewmodel-compose = { module = "org.jetbrains.androidx.lifecycle:lifecycle-viewmodel-compose", version.ref = "androidx-lifecycle" } +composematerial3-adaptive = { module = "org.jetbrains.compose.material3.adaptive:adaptive", version.ref = "material3-adaptive" } +composematerial3-adaptive-layout = { module = "org.jetbrains.compose.material3.adaptive:adaptive-layout", version.ref = "material3-adaptive" } +composematerial3-adaptive-navigation = { module = "org.jetbrains.compose.material3.adaptive:adaptive-navigation", version.ref = "material3-adaptive" } +composematerial3-window-size-clazz = { module = "org.jetbrains.compose.material3:material3-window-size-class", version.ref = "material3-wzc" } + ktorfit = { module = "de.jensklingenberg.ktorfit:ktorfit-lib", version.ref = "ktorfit" } ktorfit-converters-response = { module = "de.jensklingenberg.ktorfit:ktorfit-converters-response", version.ref = "ktorfit" } ktorfit-converters-call = { module = "de.jensklingenberg.ktorfit:ktorfit-converters-call", version.ref = "ktorfit" }