mirror of
https://github.com/Suwayomi/TachideskJUI.git
synced 2025-12-10 06:42:05 +01:00
Automatic Lint
This commit is contained in:
@@ -74,4 +74,4 @@ enum class MangaStatus(@Transient val res: StringResource) {
|
||||
enum class UpdateStrategy {
|
||||
ALWAYS_UPDATE,
|
||||
ONLY_FETCH_ONCE
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,8 +41,8 @@ class UpdatesPager @Inject constructor(
|
||||
private val getRecentUpdates: GetRecentUpdates,
|
||||
private val getManga: GetManga,
|
||||
private val getChapter: GetChapter,
|
||||
private val serverListeners: ServerListeners,
|
||||
) : CoroutineScope by CoroutineScope(Dispatchers.Default + SupervisorJob()){
|
||||
private val serverListeners: ServerListeners
|
||||
) : CoroutineScope by CoroutineScope(Dispatchers.Default + SupervisorJob()) {
|
||||
private val updatesMutex = Mutex()
|
||||
|
||||
private val fetchedUpdates = MutableSharedFlow<List<MangaAndChapter>>()
|
||||
@@ -96,7 +96,7 @@ class UpdatesPager @Inject constructor(
|
||||
|
||||
init {
|
||||
serverListeners.chapterIndexesListener
|
||||
.onEach {(mangaId, chapterIndexes) ->
|
||||
.onEach { (mangaId, chapterIndexes) ->
|
||||
if (chapterIndexes == null) {
|
||||
val chapters = coroutineScope {
|
||||
foldedUpdates.value.filterIsInstance<Updates.Update>().filter { it.manga.id == mangaId }.map {
|
||||
@@ -133,7 +133,6 @@ class UpdatesPager @Inject constructor(
|
||||
.launchIn(this)
|
||||
}
|
||||
|
||||
|
||||
val updates = combine(
|
||||
foldedUpdates,
|
||||
changedManga,
|
||||
@@ -157,6 +156,7 @@ class UpdatesPager @Inject constructor(
|
||||
sealed class Updates {
|
||||
@Immutable
|
||||
data class Update(val manga: Manga, val chapter: Chapter) : Updates()
|
||||
|
||||
@Immutable
|
||||
data class Date(val date: String) : Updates() {
|
||||
constructor(date: LocalDate) : this(date.toString())
|
||||
@@ -185,4 +185,4 @@ class UpdatesPager @Inject constructor(
|
||||
fetchedUpdates.emit(updates.page)
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -437,7 +437,7 @@ fun ThinReaderMenu(
|
||||
sheetState.show()
|
||||
}
|
||||
}
|
||||
),
|
||||
)
|
||||
).toImmutableList()
|
||||
}
|
||||
)
|
||||
|
||||
@@ -107,14 +107,13 @@ class ReaderMenuViewModel @Inject constructor(
|
||||
?.map { (it as? PagesState.Success)?.pages }
|
||||
?: flowOf(null)
|
||||
combine(previousChapterPages, chapterPages, nextChapterPages) { prev, cur, next ->
|
||||
(
|
||||
prev.orEmpty() +
|
||||
ReaderPageSeparator(viewerChapters.prevChapter, viewerChapters.currChapter) +
|
||||
cur.orEmpty() +
|
||||
ReaderPageSeparator(viewerChapters.currChapter, viewerChapters.nextChapter) +
|
||||
next.orEmpty()
|
||||
).toImmutableList()
|
||||
|
||||
(
|
||||
prev.orEmpty() +
|
||||
ReaderPageSeparator(viewerChapters.prevChapter, viewerChapters.currChapter) +
|
||||
cur.orEmpty() +
|
||||
ReaderPageSeparator(viewerChapters.currChapter, viewerChapters.nextChapter) +
|
||||
next.orEmpty()
|
||||
).toImmutableList()
|
||||
}
|
||||
}.stateIn(scope, SharingStarted.Eagerly, persistentListOf())
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ fun VerticalPager(
|
||||
horizontalAlignment: Alignment.Horizontal = Alignment.CenterHorizontally,
|
||||
userScrollEnabled: Boolean = true,
|
||||
reverseLayout: Boolean = false,
|
||||
content: @Composable BoxScope.(page: Int) -> Unit,
|
||||
content: @Composable BoxScope.(page: Int) -> Unit
|
||||
) {
|
||||
Pager(
|
||||
count = count,
|
||||
@@ -61,11 +61,10 @@ fun VerticalPager(
|
||||
horizontalAlignment = horizontalAlignment,
|
||||
userScrollEnabled = userScrollEnabled,
|
||||
reverseLayout = reverseLayout,
|
||||
content = content,
|
||||
content = content
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@Composable
|
||||
fun HorizontalPager(
|
||||
count: Int,
|
||||
@@ -76,7 +75,7 @@ fun HorizontalPager(
|
||||
verticalAlignment: Alignment.Vertical = Alignment.CenterVertically,
|
||||
userScrollEnabled: Boolean = true,
|
||||
reverseLayout: Boolean = false,
|
||||
content: @Composable BoxScope.(page: Int) -> Unit,
|
||||
content: @Composable BoxScope.(page: Int) -> Unit
|
||||
) {
|
||||
Pager(
|
||||
count = count,
|
||||
@@ -88,7 +87,7 @@ fun HorizontalPager(
|
||||
verticalAlignment = verticalAlignment,
|
||||
userScrollEnabled = userScrollEnabled,
|
||||
reverseLayout = reverseLayout,
|
||||
content = content,
|
||||
content = content
|
||||
)
|
||||
}
|
||||
|
||||
@@ -104,7 +103,7 @@ private fun Pager(
|
||||
reverseLayout: Boolean,
|
||||
verticalAlignment: Alignment.Vertical = Alignment.CenterVertically,
|
||||
horizontalAlignment: Alignment.Horizontal = Alignment.CenterHorizontally,
|
||||
content: @Composable BoxScope.(page: Int) -> Unit,
|
||||
content: @Composable BoxScope.(page: Int) -> Unit
|
||||
) {
|
||||
LaunchedEffect(count) {
|
||||
state.updateCurrentPageBasedOnLazyListState()
|
||||
@@ -125,16 +124,16 @@ private fun Pager(
|
||||
verticalArrangement = Arrangement.aligned(verticalAlignment),
|
||||
userScrollEnabled = userScrollEnabled,
|
||||
reverseLayout = reverseLayout,
|
||||
flingBehavior = rememberLazyListSnapFlingBehavior(lazyListState = state.lazyListState),
|
||||
flingBehavior = rememberLazyListSnapFlingBehavior(lazyListState = state.lazyListState)
|
||||
) {
|
||||
items(
|
||||
count = count,
|
||||
key = key,
|
||||
key = key
|
||||
) { page ->
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.fillParentMaxHeight()
|
||||
.wrapContentSize(),
|
||||
.wrapContentSize()
|
||||
) {
|
||||
content(this, page)
|
||||
}
|
||||
@@ -149,16 +148,16 @@ private fun Pager(
|
||||
horizontalArrangement = Arrangement.aligned(horizontalAlignment),
|
||||
userScrollEnabled = userScrollEnabled,
|
||||
reverseLayout = reverseLayout,
|
||||
flingBehavior = rememberLazyListSnapFlingBehavior(lazyListState = state.lazyListState),
|
||||
flingBehavior = rememberLazyListSnapFlingBehavior(lazyListState = state.lazyListState)
|
||||
) {
|
||||
items(
|
||||
count = count,
|
||||
key = key,
|
||||
key = key
|
||||
) { page ->
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.fillParentMaxWidth()
|
||||
.wrapContentSize(),
|
||||
.wrapContentSize()
|
||||
) {
|
||||
content(this, page)
|
||||
}
|
||||
@@ -169,14 +168,14 @@ private fun Pager(
|
||||
|
||||
@Composable
|
||||
fun rememberPagerState(
|
||||
initialPage: Int = 0,
|
||||
initialPage: Int = 0
|
||||
) = rememberSaveable(saver = PagerState.Saver) {
|
||||
PagerState(currentPage = initialPage)
|
||||
}
|
||||
|
||||
@Stable
|
||||
class PagerState(
|
||||
currentPage: Int = 0,
|
||||
currentPage: Int = 0
|
||||
) {
|
||||
init { check(currentPage >= 0) { "currentPage cannot be less than zero" } }
|
||||
|
||||
@@ -199,7 +198,7 @@ class PagerState(
|
||||
val start = maxOf(it.offset, 0)
|
||||
val end = minOf(
|
||||
it.offset + it.size,
|
||||
layoutInfo.viewportEndOffset - layoutInfo.afterContentPadding,
|
||||
layoutInfo.viewportEndOffset - layoutInfo.afterContentPadding
|
||||
)
|
||||
end - start
|
||||
}
|
||||
@@ -223,7 +222,7 @@ class PagerState(
|
||||
companion object {
|
||||
val Saver: Saver<PagerState, *> = listSaver(
|
||||
save = { listOf(it.currentPage) },
|
||||
restore = { PagerState(it[0]) },
|
||||
restore = { PagerState(it[0]) }
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -233,7 +232,7 @@ private fun lazyListSnapLayoutInfoProvider(
|
||||
lazyListState: LazyListState,
|
||||
positionInLayout: (layoutSize: Float, itemSize: Float) -> Float = { layoutSize, itemSize ->
|
||||
layoutSize / 2f - itemSize / 2f
|
||||
},
|
||||
}
|
||||
) = object : SnapLayoutInfoProvider {
|
||||
|
||||
private val layoutInfo: LazyListLayoutInfo
|
||||
@@ -271,7 +270,6 @@ private fun lazyListSnapLayoutInfoProvider(
|
||||
0f
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Composable
|
||||
@@ -283,7 +281,7 @@ private fun rememberLazyListSnapFlingBehavior(lazyListState: LazyListState): Fli
|
||||
private fun calculateDistanceToDesiredSnapPosition(
|
||||
layoutInfo: LazyListLayoutInfo,
|
||||
item: LazyListItemInfo,
|
||||
positionInLayout: (layoutSize: Float, itemSize: Float) -> Float,
|
||||
positionInLayout: (layoutSize: Float, itemSize: Float) -> Float
|
||||
): Float {
|
||||
val containerSize =
|
||||
with(layoutInfo) { singleAxisViewportSize - beforeContentPadding - afterContentPadding }
|
||||
|
||||
Reference in New Issue
Block a user