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