Skip to content

Commit

Permalink
Cleanup 2
Browse files Browse the repository at this point in the history
  • Loading branch information
AntsyLich committed Mar 28, 2024
1 parent 1b408b1 commit 3ca646f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 36 deletions.
53 changes: 17 additions & 36 deletions app/src/main/java/mihon/feature/upcoming/UpcomingScreenContent.kt
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -124,9 +114,7 @@ private fun UpcomingScreenSmallImpl(
contentPadding = paddingValues,
state = listState,
) {
item(
key = "upcoming-calendar",
) {
item(key = "upcoming-calendar") {
Calendar(
selectedYearMonth = selectedYearMonth,
events = events,
Expand All @@ -151,7 +139,6 @@ private fun UpcomingScreenSmallImpl(
onClick = { onClickUpcoming(item.manga) },
)
}

is UpcomingUIModel.Header -> {
ListGroupHeader(text = relativeDateText(item.date))
}
Expand Down Expand Up @@ -200,7 +187,6 @@ private fun UpcomingScreenLargeImpl(
onClick = { onClickUpcoming(item.manga) },
)
}

is UpcomingUIModel.Header -> {
ListGroupHeader(text = relativeDateText(item.date))
}
Expand All @@ -210,8 +196,3 @@ private fun UpcomingScreenLargeImpl(
},
)
}

sealed interface UpcomingUIModel {
data class Header(val date: LocalDate) : UpcomingUIModel
data class Item(val manga: Manga) : UpcomingUIModel
}
9 changes: 9 additions & 0 deletions app/src/main/java/mihon/feature/upcoming/UpcomingUIModel.kt
Original file line number Diff line number Diff line change
@@ -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
}

0 comments on commit 3ca646f

Please sign in to comment.