mirror of
https://github.com/mihonapp/mihon.git
synced 2025-06-27 11:37:51 +02:00
@ -1,6 +1,5 @@
|
|||||||
package eu.kanade.tachiyomi.ui.home
|
package eu.kanade.tachiyomi.ui.home
|
||||||
|
|
||||||
import android.annotation.SuppressLint
|
|
||||||
import androidx.activity.compose.PredictiveBackHandler
|
import androidx.activity.compose.PredictiveBackHandler
|
||||||
import androidx.compose.animation.AnimatedContent
|
import androidx.compose.animation.AnimatedContent
|
||||||
import androidx.compose.animation.AnimatedVisibility
|
import androidx.compose.animation.AnimatedVisibility
|
||||||
@ -12,7 +11,8 @@ import androidx.compose.animation.togetherWith
|
|||||||
import androidx.compose.foundation.layout.Box
|
import androidx.compose.foundation.layout.Box
|
||||||
import androidx.compose.foundation.layout.RowScope
|
import androidx.compose.foundation.layout.RowScope
|
||||||
import androidx.compose.foundation.layout.WindowInsets
|
import androidx.compose.foundation.layout.WindowInsets
|
||||||
import androidx.compose.foundation.layout.windowInsetsPadding
|
import androidx.compose.foundation.layout.consumeWindowInsets
|
||||||
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.material3.Badge
|
import androidx.compose.material3.Badge
|
||||||
import androidx.compose.material3.BadgedBox
|
import androidx.compose.material3.BadgedBox
|
||||||
import androidx.compose.material3.Icon
|
import androidx.compose.material3.Icon
|
||||||
@ -30,15 +30,11 @@ import androidx.compose.runtime.produceState
|
|||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
import androidx.compose.runtime.rememberCoroutineScope
|
import androidx.compose.runtime.rememberCoroutineScope
|
||||||
import androidx.compose.runtime.setValue
|
import androidx.compose.runtime.setValue
|
||||||
import androidx.compose.runtime.staticCompositionLocalOf
|
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.graphics.graphicsLayer
|
import androidx.compose.ui.graphics.graphicsLayer
|
||||||
import androidx.compose.ui.semantics.contentDescription
|
import androidx.compose.ui.semantics.contentDescription
|
||||||
import androidx.compose.ui.semantics.semantics
|
import androidx.compose.ui.semantics.semantics
|
||||||
import androidx.compose.ui.text.style.TextOverflow
|
import androidx.compose.ui.text.style.TextOverflow
|
||||||
import androidx.compose.ui.unit.Density
|
|
||||||
import androidx.compose.ui.unit.LayoutDirection
|
|
||||||
import androidx.compose.ui.unit.dp
|
|
||||||
import androidx.compose.ui.util.fastForEach
|
import androidx.compose.ui.util.fastForEach
|
||||||
import androidx.compose.ui.util.lerp
|
import androidx.compose.ui.util.lerp
|
||||||
import cafe.adriel.voyager.navigator.LocalNavigator
|
import cafe.adriel.voyager.navigator.LocalNavigator
|
||||||
@ -86,9 +82,6 @@ object HomeScreen : Screen() {
|
|||||||
@Suppress("ConstPropertyName")
|
@Suppress("ConstPropertyName")
|
||||||
private const val TabNavigatorKey = "HomeTabs"
|
private const val TabNavigatorKey = "HomeTabs"
|
||||||
|
|
||||||
@SuppressLint("ComposeCompositionLocalUsage")
|
|
||||||
val LocalHomeScreenInsetsProvider = staticCompositionLocalOf { WindowInsets(0.dp) }
|
|
||||||
|
|
||||||
private val TABS = listOf(
|
private val TABS = listOf(
|
||||||
LibraryTab,
|
LibraryTab,
|
||||||
UpdatesTab,
|
UpdatesTab,
|
||||||
@ -136,50 +129,17 @@ object HomeScreen : Screen() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
contentWindowInsets = WindowInsets(0),
|
||||||
) { contentPadding ->
|
) { contentPadding ->
|
||||||
Box(
|
Box(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
|
.padding(contentPadding)
|
||||||
|
.consumeWindowInsets(contentPadding)
|
||||||
.graphicsLayer {
|
.graphicsLayer {
|
||||||
scaleX = scale
|
scaleX = scale
|
||||||
scaleY = scale
|
scaleY = scale
|
||||||
}
|
|
||||||
.windowInsetsPadding(
|
|
||||||
remember {
|
|
||||||
object : WindowInsets {
|
|
||||||
override fun getLeft(density: Density, layoutDirection: LayoutDirection): Int {
|
|
||||||
return with(density) {
|
|
||||||
contentPadding.calculateLeftPadding(layoutDirection).roundToPx()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getRight(density: Density, layoutDirection: LayoutDirection): Int {
|
|
||||||
return with(density) {
|
|
||||||
contentPadding.calculateRightPadding(layoutDirection).roundToPx()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getBottom(density: Density): Int = 0
|
|
||||||
|
|
||||||
override fun getTop(density: Density): Int = 0
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
),
|
|
||||||
) {
|
) {
|
||||||
val insets = remember {
|
|
||||||
object : WindowInsets {
|
|
||||||
override fun getBottom(density: Density): Int {
|
|
||||||
return with(density) { contentPadding.calculateBottomPadding().roundToPx() }
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getTop(density: Density): Int {
|
|
||||||
return with(density) { contentPadding.calculateTopPadding().roundToPx() }
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getLeft(density: Density, layoutDirection: LayoutDirection): Int = 0
|
|
||||||
|
|
||||||
override fun getRight(density: Density, layoutDirection: LayoutDirection): Int = 0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
AnimatedContent(
|
AnimatedContent(
|
||||||
targetState = tabNavigator.current,
|
targetState = tabNavigator.current,
|
||||||
transitionSpec = {
|
transitionSpec = {
|
||||||
@ -188,7 +148,6 @@ object HomeScreen : Screen() {
|
|||||||
},
|
},
|
||||||
label = "tabContent",
|
label = "tabContent",
|
||||||
) {
|
) {
|
||||||
CompositionLocalProvider(LocalHomeScreenInsetsProvider provides insets) {
|
|
||||||
tabNavigator.saveableState(key = "currentTab", it) {
|
tabNavigator.saveableState(key = "currentTab", it) {
|
||||||
it.Content()
|
it.Content()
|
||||||
}
|
}
|
||||||
@ -196,7 +155,6 @@ object HomeScreen : Screen() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
val goToLibraryTab = { tabNavigator.current = LibraryTab }
|
val goToLibraryTab = { tabNavigator.current = LibraryTab }
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user