From c70be391b402af73123beb3869fe79a7c0bdc211 Mon Sep 17 00:00:00 2001 From: Syer10 Date: Sun, 12 Feb 2023 23:05:39 +0000 Subject: [PATCH] Automatic Lint --- .../ca/gosyer/jui/domain/manga/model/Manga.kt | 2 +- .../domain/updates/interactor/UpdatesPager.kt | 10 +++--- .../ca/gosyer/jui/ui/reader/ReaderMenu.kt | 2 +- .../jui/ui/reader/ReaderMenuViewModel.kt | 15 ++++---- .../ca/gosyer/jui/uicore/pager/Pager.kt | 36 +++++++++---------- 5 files changed, 31 insertions(+), 34 deletions(-) diff --git a/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/manga/model/Manga.kt b/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/manga/model/Manga.kt index 0e044707..86816b1b 100644 --- a/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/manga/model/Manga.kt +++ b/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/manga/model/Manga.kt @@ -74,4 +74,4 @@ enum class MangaStatus(@Transient val res: StringResource) { enum class UpdateStrategy { ALWAYS_UPDATE, ONLY_FETCH_ONCE -} \ No newline at end of file +} diff --git a/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/updates/interactor/UpdatesPager.kt b/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/updates/interactor/UpdatesPager.kt index c7ef76fa..99e6d8e5 100644 --- a/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/updates/interactor/UpdatesPager.kt +++ b/domain/src/commonMain/kotlin/ca/gosyer/jui/domain/updates/interactor/UpdatesPager.kt @@ -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>() @@ -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().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 } -} \ No newline at end of file +} diff --git a/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/reader/ReaderMenu.kt b/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/reader/ReaderMenu.kt index 8e32a622..6125d7a3 100644 --- a/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/reader/ReaderMenu.kt +++ b/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/reader/ReaderMenu.kt @@ -437,7 +437,7 @@ fun ThinReaderMenu( sheetState.show() } } - ), + ) ).toImmutableList() } ) diff --git a/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/reader/ReaderMenuViewModel.kt b/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/reader/ReaderMenuViewModel.kt index 639ba9dc..486df22c 100644 --- a/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/reader/ReaderMenuViewModel.kt +++ b/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/reader/ReaderMenuViewModel.kt @@ -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()) diff --git a/ui-core/src/commonMain/kotlin/ca/gosyer/jui/uicore/pager/Pager.kt b/ui-core/src/commonMain/kotlin/ca/gosyer/jui/uicore/pager/Pager.kt index e15beb37..8d85a6a6 100644 --- a/ui-core/src/commonMain/kotlin/ca/gosyer/jui/uicore/pager/Pager.kt +++ b/ui-core/src/commonMain/kotlin/ca/gosyer/jui/uicore/pager/Pager.kt @@ -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 = 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 }