Skip to content

Commit

Permalink
Update project
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelbel committed Dec 18, 2024
1 parent 308862e commit a5e192e
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 5 deletions.
Binary file modified .github/pics/foldable.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ dependencies {
api(libs.androidx.lifecycle.viewmodel.compose)
api(libs.androidx.navigation.compose)
api(libs.androidx.paging.compose)
api(libs.androidx.window)
api(libs.koin.androidx.compose)
api(libs.ktor.client.okhttp)
api(libs.ktor.serialization.kotlinx.json)
Expand Down
20 changes: 17 additions & 3 deletions core/src/main/kotlin/org/michaelbel/core/ktx/ConfigurationKtx.kt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@file:Suppress("unused", "ObsoleteSdkInt")
@file:Suppress("unused", "ObsoleteSdkInt", "RestrictedApi")

package org.michaelbel.core.ktx

Expand All @@ -13,10 +13,16 @@ import android.view.WindowInsets
import android.view.WindowManager
import android.view.WindowMetrics
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.remember
import androidx.compose.ui.platform.LocalConfiguration
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import androidx.core.content.ContextCompat
import androidx.window.layout.FoldingFeature
import androidx.window.layout.WindowInfoTracker
import androidx.window.layout.WindowLayoutInfo

inline val Context.deviceWidth: Int
get() {
Expand Down Expand Up @@ -111,7 +117,15 @@ inline val isLandscape: Boolean
@Composable get() = LocalConfiguration.current.orientation == Configuration.ORIENTATION_LANDSCAPE

inline val isTabletPortrait: Boolean
@Composable get() = isPortrait && screenWidth >= 600
@Composable get() = !isFoldable() && isPortrait && screenWidth >= 600

inline val isTabletLandscape: Boolean
@Composable get() = isLandscape && screenWidth >= 1200
@Composable get() = !isFoldable() && isLandscape && screenWidth >= 1200

@Composable
fun isFoldable(): Boolean {
val context = LocalContext.current
val windowLayoutInfo = remember { WindowInfoTracker.getOrCreate(context).windowLayoutInfo(context) }
val foldableState = windowLayoutInfo.collectAsState(initial = WindowLayoutInfo(emptyList()))
return foldableState.value.displayFeatures.any { it is FoldingFeature }
}
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ google-gms-play-services-wallet = "19.4.0"
google-gms-play-services-wearable = "19.0.0"

google-play-app-update = "2.1.0"
google-play-asset-delivery = "2.2.2"
google-play-asset-delivery = "2.3.0"
google-play-feature-delivery = "2.1.0"
google-play-review = "2.0.2"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ fun ListScreen(
TopAppBar(
title = {
Text(
text = "Phone Template"
text = "Foldable Template"
)
}
)
Expand Down

0 comments on commit a5e192e

Please sign in to comment.