Skip to content

Commit

Permalink
Fix the ktlint integration (and update ktlint compose) (#1875)
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulWoitaschek authored May 13, 2023
1 parent 08ddf39 commit d706e0b
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 15 deletions.
3 changes: 1 addition & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@ indent_size = 2
continuation_indent_size = 2
trim_trailing_whitespace = true
max_line_length = 140
ktlint_disabled_rules = filename
ktlint_standard_filename = disabled
ij_java_class_count_to_use_import_on_demand = 999
ij_kotlin_allow_trailing_comma = true
ij_kotlin_allow_trailing_comma_on_call_site = true
ij_kotlin_line_break_after_multiline_when_entry = false
ij_kotlin_name_count_to_use_star_import = 999
ij_kotlin_name_count_to_use_star_import_for_members = 999

Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ enum class BookOverviewCategory(
nameRes = StringsR.string.book_header_completed,
comparator = BookComparator.ByLastPlayed,
),
;
}

val Book.category: BookOverviewCategory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,9 @@ internal fun BookOverview(
onBookMigrationClick: () -> Unit,
onBoomMigrationHelperConfirmClick: () -> Unit,
onSearchActiveChange: (Boolean) -> Unit,
modifier: Modifier = Modifier,
onSearchQueryChange: (String) -> Unit,
onSearchBookClick: (BookId) -> Unit,
modifier: Modifier = Modifier,
) {
val scrollBehavior = TopAppBarDefaults.pinnedScrollBehavior()
Scaffold(
Expand All @@ -172,7 +172,9 @@ internal fun BookOverview(
if (viewState.playButtonState != null) {
PlayButton(
playing = viewState.playButtonState == BookOverviewViewState.PlayButtonState.Playing,
fabSize = 56.dp, iconSize = 24.dp, onPlayClick = onPlayButtonClick,
fabSize = 56.dp,
iconSize = 24.dp,
onPlayClick = onPlayButtonClick,
)
}
},
Expand Down Expand Up @@ -214,7 +216,7 @@ internal fun BookOverview(

@Preview // ktlint-disable twitter-compose:preview-public-check
@Composable
fun BookOverviewPreview(
private fun BookOverviewPreview(
@PreviewParameter(BookOverviewPreviewParameterProvider::class)
viewState: BookOverviewViewState,
) {
Expand Down Expand Up @@ -267,7 +269,7 @@ internal class BookOverviewPreviewParameterProvider : PreviewParameterProvider<B
recentQueries = emptyList(),
query = "",

),
),
),
)
}
7 changes: 5 additions & 2 deletions common/src/main/kotlin/voice/common/compose/PlayButton.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@ fun PlayButton(
fabSize: Dp,
iconSize: Dp,
onPlayClick: () -> Unit,
modifier: Modifier = Modifier,
) {
val cornerSize by animateDpAsState(if (playing) 16.dp else fabSize / 2)
FloatingActionButton(
modifier = Modifier.size(fabSize),
modifier = modifier.size(fabSize),
onClick = onPlayClick,
shape = RoundedCornerShape(cornerSize),
) {
Expand All @@ -37,7 +38,9 @@ fun PlayButton(
contentDescription = stringResource(
id = if (playing) {
StringsR.string.pause
} else StringsR.string.play,
} else {
StringsR.string.play
},
),
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import javax.inject.Named
interface SharedComponent {

@get:[
Named(PrefKeys.DARK_THEME)
Named(PrefKeys.DARK_THEME)
]
val useDarkTheme: Pref<Boolean>
}
3 changes: 2 additions & 1 deletion cover/src/main/kotlin/voice/cover/SelectCoverFromInternet.kt
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ private fun SelectCoverFromInternet(
}
.fillMaxWidth()
.aspectRatio(item.width.toFloat() / item.height),
painter = rememberAsyncImagePainter(model = item.thumbnail), contentDescription = null,
painter = rememberAsyncImagePainter(model = item.thumbnail),
contentDescription = null,
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ internal class ImageSearchPagingSource(
override suspend fun load(params: LoadParams<ImageSearchParams>): LoadResult<ImageSearchParams, SearchResponse.ImageResult> {
return try {
val searchParams = params.key ?: freshSearchParams()
?: return LoadResult.Error(IOException("No params"))
?: return LoadResult.Error(IOException("No params"))

val response = api.search(
query = query,
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ compose-navigation = "dev.olshevski.navigation:reimagined:1.4.0"
# For these dependencies we only use the version but declare full artifacts so renovate can update the version
compose-compiler = { module = "androidx.compose.compiler:compiler", version.ref = "compose-compiler" }
ktlint = { module = "com.pinterest.ktlint:ktlint-core", version.ref = "ktlint" }
compose-ktlint = "com.twitter.compose.rules:ktlint:0.0.26"
compose-ktlint = "io.nlopez.compose.rules:ktlint:0.1.5"

[bundles]
compose = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,3 @@ class ImageFileProvider
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,9 @@ private fun havePosition(currentMediaItemIndex: Int, currentPosition: Long) = ob
val actualCurrentPosition = value.currentPosition
return MatcherResult(
passed = actualCurrentMediaItemIndex == currentMediaItemIndex && actualCurrentPosition == currentPosition,
failureMessageFn = { "position was ($actualCurrentMediaItemIndex,$actualCurrentPosition) but we expected ($currentMediaItemIndex,$currentPosition)" },
failureMessageFn = {
"position was ($actualCurrentMediaItemIndex,$actualCurrentPosition) but we expected ($currentMediaItemIndex,$currentPosition)"
},
negatedFailureMessageFn = { "position should not be ($actualCurrentMediaItemIndex,$actualCurrentPosition)" },
)
}
Expand Down

0 comments on commit d706e0b

Please sign in to comment.