Moved ReaderScreen top and bottom bars color to Theme.kt → Colors.readerSystemBarsColor + Longer delay for progress to update(may result in a little performance improvement). (v1.0.1)
This commit is contained in:
parent
e033294df0
commit
2a20ab29fa
5 changed files with 15 additions and 16 deletions
|
|
@ -165,7 +165,6 @@ private fun ReaderScreen(
|
|||
) {
|
||||
val context = LocalContext.current as ComponentActivity
|
||||
val density = LocalDensity.current
|
||||
val systemBarsColor = MaterialTheme.colorScheme.surfaceContainerHighest.copy(0.94f)
|
||||
|
||||
val nestedScrollConnection = remember(state) {
|
||||
object : NestedScrollConnection {
|
||||
|
|
@ -284,8 +283,7 @@ private fun ReaderScreen(
|
|||
state = state,
|
||||
onEvent = onEvent,
|
||||
onLibraryUpdateEvent = onLibraryEvent,
|
||||
onHistoryUpdateEvent = onHistoryEvent,
|
||||
containerColor = systemBarsColor
|
||||
onHistoryUpdateEvent = onHistoryEvent
|
||||
)
|
||||
}
|
||||
},
|
||||
|
|
@ -300,8 +298,7 @@ private fun ReaderScreen(
|
|||
state = state,
|
||||
onEvent = onEvent,
|
||||
onLibraryUpdateEvent = onLibraryEvent,
|
||||
onHistoryUpdateEvent = onHistoryEvent,
|
||||
containerColor = systemBarsColor
|
||||
onHistoryUpdateEvent = onHistoryEvent
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ import androidx.compose.runtime.getValue
|
|||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.unit.dp
|
||||
import ua.acclorite.book_story.presentation.data.LocalNavigator
|
||||
import ua.acclorite.book_story.presentation.data.removeDigits
|
||||
|
|
@ -29,6 +28,7 @@ import ua.acclorite.book_story.presentation.screens.history.data.HistoryEvent
|
|||
import ua.acclorite.book_story.presentation.screens.library.data.LibraryEvent
|
||||
import ua.acclorite.book_story.presentation.screens.reader.data.ReaderEvent
|
||||
import ua.acclorite.book_story.presentation.screens.reader.data.ReaderState
|
||||
import ua.acclorite.book_story.presentation.ui.Colors
|
||||
|
||||
/**
|
||||
* Reader bottom bar. Has a slider to change progress.
|
||||
|
|
@ -37,15 +37,13 @@ import ua.acclorite.book_story.presentation.screens.reader.data.ReaderState
|
|||
* @param onEvent [ReaderEvent] callback.
|
||||
* @param onLibraryUpdateEvent [LibraryEvent] callback.
|
||||
* @param onHistoryUpdateEvent [HistoryEvent] callback.
|
||||
* @param containerColor Container color.
|
||||
*/
|
||||
@Composable
|
||||
fun ReaderBottomBar(
|
||||
state: State<ReaderState>,
|
||||
onEvent: (ReaderEvent) -> Unit,
|
||||
onLibraryUpdateEvent: (LibraryEvent.OnUpdateBook) -> Unit,
|
||||
onHistoryUpdateEvent: (HistoryEvent.OnUpdateBook) -> Unit,
|
||||
containerColor: Color
|
||||
onHistoryUpdateEvent: (HistoryEvent.OnUpdateBook) -> Unit
|
||||
) {
|
||||
val navigator = LocalNavigator.current
|
||||
val progress by remember(state.value.book.progress) {
|
||||
|
|
@ -61,7 +59,7 @@ fun ReaderBottomBar(
|
|||
Column(
|
||||
Modifier
|
||||
.fillMaxWidth()
|
||||
.background(containerColor)
|
||||
.background(Colors.readerSystemBarsColor)
|
||||
.clickable(
|
||||
interactionSource = null,
|
||||
indication = null,
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ import androidx.compose.runtime.derivedStateOf
|
|||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.font.FontFamily
|
||||
|
|
@ -37,6 +36,7 @@ import ua.acclorite.book_story.presentation.screens.history.data.HistoryEvent
|
|||
import ua.acclorite.book_story.presentation.screens.library.data.LibraryEvent
|
||||
import ua.acclorite.book_story.presentation.screens.reader.data.ReaderEvent
|
||||
import ua.acclorite.book_story.presentation.screens.reader.data.ReaderState
|
||||
import ua.acclorite.book_story.presentation.ui.Colors
|
||||
|
||||
/**
|
||||
* Reader top bar. Displays title of the book.
|
||||
|
|
@ -45,7 +45,6 @@ import ua.acclorite.book_story.presentation.screens.reader.data.ReaderState
|
|||
* @param onEvent [ReaderEvent] callback.
|
||||
* @param onLibraryUpdateEvent [LibraryEvent] callback.
|
||||
* @param onHistoryUpdateEvent [HistoryEvent] callback.
|
||||
* @param containerColor Container color.
|
||||
*/
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
|
|
@ -53,8 +52,7 @@ fun ReaderTopBar(
|
|||
state: State<ReaderState>,
|
||||
onEvent: (ReaderEvent) -> Unit,
|
||||
onLibraryUpdateEvent: (LibraryEvent.OnUpdateBook) -> Unit,
|
||||
onHistoryUpdateEvent: (HistoryEvent.OnUpdateBook) -> Unit,
|
||||
containerColor: Color
|
||||
onHistoryUpdateEvent: (HistoryEvent.OnUpdateBook) -> Unit
|
||||
) {
|
||||
val navigator = LocalNavigator.current
|
||||
val context = LocalContext.current as ComponentActivity
|
||||
|
|
@ -161,7 +159,7 @@ fun ReaderTopBar(
|
|||
}
|
||||
},
|
||||
colors = TopAppBarDefaults.topAppBarColors(
|
||||
containerColor = containerColor
|
||||
containerColor = Colors.readerSystemBarsColor
|
||||
)
|
||||
)
|
||||
}
|
||||
|
|
@ -1279,7 +1279,7 @@ class ReaderViewModel @Inject constructor(
|
|||
snapshotFlow {
|
||||
firstVisibleItemIndex to firstVisibleItemOffset
|
||||
}
|
||||
.debounce(200)
|
||||
.debounce(300)
|
||||
.collectLatest { items ->
|
||||
val listState = _state.value.listState
|
||||
if (
|
||||
|
|
|
|||
|
|
@ -115,6 +115,12 @@ fun BookStoryTheme(
|
|||
)
|
||||
}
|
||||
|
||||
object Colors {
|
||||
val readerSystemBarsColor: Color
|
||||
@Composable
|
||||
get() = MaterialTheme.colorScheme.surfaceContainerHighest.copy(0.94f)
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun animateColor(targetColor: Color): Color {
|
||||
return animateColorAsState(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue