Full Compose settings (#8201)

* Uses Voyager for navigation.
* Replaces every screen inside settings except category editor screen since it's
called from several places.
This commit is contained in:
Ivan Iskandar
2022-10-15 22:38:01 +07:00
committed by GitHub
parent 3fdcd636d7
commit 890f1a3c7b
42 changed files with 4904 additions and 80 deletions

View File

@@ -8,6 +8,16 @@ import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
@Composable
fun LazyListState.isScrolledToStart(): Boolean {
return remember {
derivedStateOf {
val firstItem = layoutInfo.visibleItemsInfo.firstOrNull()
firstItem == null || firstItem.offset == layoutInfo.viewportStartOffset
}
}.value
}
@Composable
fun LazyListState.isScrolledToEnd(): Boolean {
return remember {

View File

@@ -0,0 +1,15 @@
package eu.kanade.presentation.util
import androidx.compose.runtime.ProvidableCompositionLocal
import androidx.compose.runtime.staticCompositionLocalOf
import com.bluelinelabs.conductor.Router
/**
* For interop with Conductor
*/
val LocalRouter: ProvidableCompositionLocal<Router?> = staticCompositionLocalOf { null }
/**
* For invoking back press to the parent activity
*/
val LocalBackPress: ProvidableCompositionLocal<(() -> Unit)?> = staticCompositionLocalOf { null }

View File

@@ -0,0 +1,13 @@
package eu.kanade.presentation.util
import androidx.compose.runtime.Composable
import androidx.compose.runtime.State
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.remember
import eu.kanade.tachiyomi.core.preference.Preference
@Composable
fun <T> Preference<T>.collectAsState(): State<T> {
val flow = remember(this) { changes() }
return flow.collectAsState(initial = get())
}