Skip to content

Commit

Permalink
WTA #71: Fixed detekt config and code issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacob3075 committed Sep 9, 2023
1 parent cb970ff commit c074777
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import com.jacob.wakatimeapp.details.ui.components.TabBar
import com.jacob.wakatimeapp.details.ui.components.Tabs
import com.jacob.wakatimeapp.details.ui.components.TimeTab
import com.ramcosta.composedestinations.annotation.Destination
import kotlinx.collections.immutable.toImmutableList
import kotlinx.coroutines.launch

@Composable
Expand Down Expand Up @@ -91,7 +92,7 @@ private fun DetailsPageLoaded(viewState: DetailsPageViewState.Loaded) {
Tabs.Languages,
Tabs.Editors,
Tabs.OperatingSystems,
)
).toImmutableList()

Column {
Spacer(modifier = Modifier.height(MaterialTheme.spacing.small))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,6 @@ private fun DetailsPageHeaderPreview(
private class DetailPageHeaderPreviewProvider : CollectionPreviewParameterProvider<String>(
listOf(
"Project Name",
"Some very long project name"
"Some very long project name",
),
)
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,29 @@ import androidx.compose.ui.unit.dp
import com.google.accompanist.pager.ExperimentalPagerApi
import com.google.accompanist.pager.PagerState
import com.jacob.wakatimeapp.core.ui.theme.spacing
import kotlinx.collections.immutable.ImmutableList
import kotlinx.coroutines.launch

@OptIn(ExperimentalPagerApi::class)
@Composable
fun TabBar(pagerState: PagerState, pages: List<Tabs>) {
internal fun TabBar(
pagerState: PagerState,
pages: ImmutableList<Tabs>,
modifier: Modifier = Modifier,
) {
val scope = rememberCoroutineScope()
ScrollableTabRow(
selectedTabIndex = pagerState.currentPage,
contentColor = MaterialTheme.colorScheme.onSurface,
divider = { },
edgePadding = 0.dp,
modifier = Modifier.fillMaxWidth(),
modifier = modifier.fillMaxWidth(),
) {
pages.forEachIndexed { index, tab ->
val isSelected = pagerState.currentPage == index
Tab(
selected = isSelected,
onClick = { scope.launch { pagerState.animateScrollToPage(index) } }
onClick = { scope.launch { pagerState.animateScrollToPage(index) } },
) {
Text(
text = tab.title,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ fun Modifier.pagerTabIndicatorOffset(
fraction > 0 && nextTab != null -> lerp(
currentTab.width,
nextTab.width,
fraction
fraction,
).roundToPx()

fraction < 0 && previousTab != null -> lerp(
currentTab.width,
previousTab.width,
-fraction
-fraction,
).roundToPx()

else -> currentTab.width.roundToPx()
Expand All @@ -46,13 +46,13 @@ fun Modifier.pagerTabIndicatorOffset(
fraction > 0 && nextTab != null -> lerp(
currentTab.left,
nextTab.left,
fraction
fraction,
).roundToPx()

fraction < 0 && previousTab != null -> lerp(
currentTab.left,
previousTab.left,
-fraction
-fraction,
).roundToPx()

else -> currentTab.left.roundToPx()
Expand All @@ -63,14 +63,14 @@ fun Modifier.pagerTabIndicatorOffset(
minWidth = indicatorWidth,
maxWidth = indicatorWidth,
minHeight = 0,
maxHeight = constraints.maxHeight
)
maxHeight = constraints.maxHeight,
),
)

return@layout layout(constraints.maxWidth, maxOf(placeable.height, constraints.minHeight)) {
placeable.placeRelative(
indicatorOffset,
maxOf(constraints.minHeight - placeable.height, 0)
maxOf(constraints.minHeight - placeable.height, 0),
)
}
}
4 changes: 2 additions & 2 deletions tools/detekt-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ style:
ignoreConstantDeclaration: true
ignoreCompanionObjectPropertyDeclaration: true
ignoreAnnotation: true
ignoreAnnotated: [ 'Preview', 'WtaPreviews'. 'WtaComponentPreviews', 'WtaDevicePreviews' ]
ignoreAnnotated: [ 'Preview', 'WtaPreviews', 'WtaComponentPreviews', 'WtaDevicePreviews' ]
ignoreNamedArgument: true
ignoreEnums: true
ignoreRanges: false
Expand Down Expand Up @@ -712,7 +712,7 @@ style:
UnusedPrivateMember:
active: true
allowedNames: '(_|ignored|expected|serialVersionUID|preview)'
ignoreAnnotated: [ 'Preview', 'WtaPreviews' ]
ignoreAnnotated: [ 'Preview', 'WtaPreviews', 'WtaComponentPreviews', 'WtaDevicePreviews' ]
UseAnyOrNoneInsteadOfFind:
active: true
UseArrayLiteralsInAnnotations:
Expand Down

0 comments on commit c074777

Please sign in to comment.