mirror of
https://github.com/fromchat-messenger/app.git
synced 2026-09-23 03:25:06 +03:00
Refactor the whole project structure
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
package com.pr0gramm3r101.utils
|
||||
|
||||
import androidx.compose.foundation.layout.ExperimentalLayoutApi
|
||||
import androidx.compose.foundation.layout.imeNestedScroll
|
||||
import androidx.compose.ui.Modifier
|
||||
|
||||
@OptIn(ExperimentalLayoutApi::class)
|
||||
actual fun Modifier.imeScrollWithKeyboard(): Modifier = this.imeNestedScroll()
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
package com.pr0gramm3r101.utils
|
||||
|
||||
import android.app.Activity
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.ui.platform.LocalView
|
||||
import androidx.core.view.WindowCompat
|
||||
import androidx.core.view.WindowInsetsCompat
|
||||
|
||||
@Composable
|
||||
actual fun rememberSystemBarsController(): ((Boolean) -> Unit)? {
|
||||
val view = LocalView.current
|
||||
return remember(view) {
|
||||
val activity = view.context as? Activity ?: return@remember null
|
||||
val window = activity.window ?: return@remember null
|
||||
val controller = WindowCompat.getInsetsController(window, view);
|
||||
|
||||
{ visible: Boolean ->
|
||||
if (visible) {
|
||||
controller.show(WindowInsetsCompat.Type.statusBars())
|
||||
} else {
|
||||
controller.hide(WindowInsetsCompat.Type.statusBars())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -830,4 +830,29 @@ inline fun String.decodeWindows1251() = String(
|
||||
)
|
||||
|
||||
@get:ChecksSdkIntAtLeast(api = Build.VERSION_CODES.S)
|
||||
actual val materialYouAvailable get() = Build.VERSION.SDK_INT >= 31
|
||||
actual val materialYouAvailable get() = Build.VERSION.SDK_INT >= 31
|
||||
|
||||
private fun String?.trimIfNotBlank(): String? =
|
||||
this?.trim()?.takeIf { it.isNotEmpty() }
|
||||
|
||||
actual fun currentDeviceInfo(): CurrentDeviceInfo {
|
||||
val osName = "Android"
|
||||
val osVersion = Build.VERSION.RELEASE.trimIfNotBlank() ?: Build.VERSION.SDK_INT.toString()
|
||||
val brand = Build.BRAND.trimIfNotBlank() ?: Build.MANUFACTURER.trimIfNotBlank()
|
||||
val model = Build.MODEL.trimIfNotBlank()
|
||||
|
||||
return CurrentDeviceInfo(
|
||||
osName = osName,
|
||||
osVersion = osVersion,
|
||||
deviceType = "mobile",
|
||||
deviceName = model?.let {
|
||||
if (it.contains(
|
||||
brand.orEmpty(),
|
||||
ignoreCase = true
|
||||
)
|
||||
) it else listOfNotNull(brand, it).joinToString(" ")
|
||||
},
|
||||
brand = brand,
|
||||
model = model
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user