From 3ca646fc13b2d5ccab59637429712547fa7d147c Mon Sep 17 00:00:00 2001 From: AntsyLich <59261191+AntsyLich@users.noreply.github.com> Date: Fri, 29 Mar 2024 00:46:52 +0600 Subject: [PATCH] Cleanup 2 --- .../feature/upcoming/UpcomingScreenContent.kt | 53 ++++++------------- .../mihon/feature/upcoming/UpcomingUIModel.kt | 9 ++++ 2 files changed, 26 insertions(+), 36 deletions(-) create mode 100644 app/src/main/java/mihon/feature/upcoming/UpcomingUIModel.kt diff --git a/app/src/main/java/mihon/feature/upcoming/UpcomingScreenContent.kt b/app/src/main/java/mihon/feature/upcoming/UpcomingScreenContent.kt index 42c56d2db1..0baa1c8ee1 100644 --- a/app/src/main/java/mihon/feature/upcoming/UpcomingScreenContent.kt +++ b/app/src/main/java/mihon/feature/upcoming/UpcomingScreenContent.kt @@ -1,6 +1,5 @@ package mihon.feature.upcoming -import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.padding import androidx.compose.foundation.lazy.LazyListState @@ -10,15 +9,13 @@ import androidx.compose.material.icons.Icons import androidx.compose.material.icons.automirrored.outlined.HelpOutline import androidx.compose.material3.Icon import androidx.compose.material3.IconButton -import androidx.compose.material3.TopAppBar import androidx.compose.runtime.Composable import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalUriHandler import cafe.adriel.voyager.navigator.LocalNavigator import cafe.adriel.voyager.navigator.currentOrThrow -import eu.kanade.presentation.components.AppBarTitle -import eu.kanade.presentation.components.UpIcon +import eu.kanade.presentation.components.AppBar import eu.kanade.presentation.components.relativeDateText import eu.kanade.presentation.util.isTabletUi import kotlinx.collections.immutable.ImmutableList @@ -84,29 +81,22 @@ fun UpcomingScreenContent( } @Composable -private fun UpcomingToolbar( - modifier: Modifier = Modifier, -) { +private fun UpcomingToolbar() { val navigator = LocalNavigator.currentOrThrow - Column(modifier = modifier) { - TopAppBar( - actions = { - val uriHandler = LocalUriHandler.current - IconButton(onClick = { uriHandler.openUri(Constants.URL_HELP_UPCOMING) }) { - Icon( - imageVector = Icons.AutoMirrored.Outlined.HelpOutline, - contentDescription = stringResource(MR.strings.upcoming_guide), - ) - } - }, - navigationIcon = { - IconButton(onClick = navigator::pop) { - UpIcon() - } - }, - title = { AppBarTitle(stringResource(MR.strings.label_upcoming)) }, - ) - } + val uriHandler = LocalUriHandler.current + + AppBar( + title = stringResource(MR.strings.label_upcoming), + navigateUp = navigator::pop, + actions = { + IconButton(onClick = { uriHandler.openUri(Constants.URL_HELP_UPCOMING) }) { + Icon( + imageVector = Icons.AutoMirrored.Outlined.HelpOutline, + contentDescription = stringResource(MR.strings.upcoming_guide), + ) + } + }, + ) } @Composable @@ -124,9 +114,7 @@ private fun UpcomingScreenSmallImpl( contentPadding = paddingValues, state = listState, ) { - item( - key = "upcoming-calendar", - ) { + item(key = "upcoming-calendar") { Calendar( selectedYearMonth = selectedYearMonth, events = events, @@ -151,7 +139,6 @@ private fun UpcomingScreenSmallImpl( onClick = { onClickUpcoming(item.manga) }, ) } - is UpcomingUIModel.Header -> { ListGroupHeader(text = relativeDateText(item.date)) } @@ -200,7 +187,6 @@ private fun UpcomingScreenLargeImpl( onClick = { onClickUpcoming(item.manga) }, ) } - is UpcomingUIModel.Header -> { ListGroupHeader(text = relativeDateText(item.date)) } @@ -210,8 +196,3 @@ private fun UpcomingScreenLargeImpl( }, ) } - -sealed interface UpcomingUIModel { - data class Header(val date: LocalDate) : UpcomingUIModel - data class Item(val manga: Manga) : UpcomingUIModel -} diff --git a/app/src/main/java/mihon/feature/upcoming/UpcomingUIModel.kt b/app/src/main/java/mihon/feature/upcoming/UpcomingUIModel.kt new file mode 100644 index 0000000000..c394f45f6f --- /dev/null +++ b/app/src/main/java/mihon/feature/upcoming/UpcomingUIModel.kt @@ -0,0 +1,9 @@ +package mihon.feature.upcoming + +import tachiyomi.domain.manga.model.Manga +import java.time.LocalDate + +sealed interface UpcomingUIModel { + data class Header(val date: LocalDate) : UpcomingUIModel + data class Item(val manga: Manga) : UpcomingUIModel +}