Skip to content

Commit

Permalink
Release 1.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
kevingermainbusiness committed Aug 2, 2022
1 parent d606485 commit 16adf4f
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 21 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ repositories {

```groovy
dependencies {
implementation "com.github.germainkevinbusiness:CollapsingTopBarCompose:1.0.0"
implementation "com.github.germainkevinbusiness:CollapsingTopBarCompose:1.0.1"
}
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import androidx.compose.material3.Surface
import androidx.compose.runtime.Composable
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.toArgb
import androidx.compose.ui.input.nestedscroll.nestedScroll
import androidx.compose.ui.platform.LocalContext
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ buildscript {
ext {
compose_version = '1.2.0'
coreKtx = '1.8.0'
libraryVersion ='1.0.0'
libraryVersion ='1.0.1'
material3Version ='1.0.0-alpha15'
timberVersion ='5.0.1'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ private fun CollapsingTopBarLayout(
horizontalArrangement = Arrangement.Start,
verticalAlignment = Alignment.Bottom,
content = {
navigationIconRow(navigationIcon)
navigationIconRow(navigationIcon, contentPadding, centeredTitleWhenCollapsed)

/**
* Title section, shown when the [CollapsingTopBar] is collapsed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import androidx.compose.runtime.State
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalLayoutDirection
import androidx.compose.ui.unit.LayoutDirection
import androidx.compose.ui.unit.dp

/**
Expand All @@ -21,12 +23,6 @@ internal val defaultMaximumTopBarHeight = 156.dp

internal val topBarHorizontalPadding = 4.dp

/**
* [Modifier] when there isn't a navigation icon provided. Start inset for the title slot inside
* the [CollapsingTopBar]
* */
private val noNavIconSpacerModifier = Modifier.width(16.dp - topBarHorizontalPadding)

/**
* [Modifier] when there is a navigation icon provided
* */
Expand All @@ -35,17 +31,28 @@ private val navigationIconModifier = Modifier
.width(56.dp - topBarHorizontalPadding)


internal val navigationIconRow: @Composable (@Composable (() -> Unit)?) -> Unit =
{ navigationIcon ->
if (navigationIcon == null) Spacer(modifier = noNavIconSpacerModifier)
else {
Row(
modifier = navigationIconModifier,
verticalAlignment = Alignment.Bottom,
content = { navigationIcon() }
)
}
}
internal val navigationIconRow: @Composable (
@Composable (() -> Unit)?, PaddingValues, Boolean
) -> Unit = { navigationIcon, contentPadding, centeredTitleWhenCollapsed ->

val noIconModifier = Modifier.width(
16.dp - contentPadding.calculateStartPadding(
if (LocalLayoutDirection.current == LayoutDirection.Ltr) LayoutDirection.Ltr
else LayoutDirection.Rtl
)
)
if (navigationIcon == null) Spacer(modifier = noIconModifier)
else if (centeredTitleWhenCollapsed) Row(
modifier = Modifier.wrapContentWidth(),
verticalAlignment = Alignment.Bottom,
content = { navigationIcon() }
)
else Row(
modifier = navigationIconModifier,
verticalAlignment = Alignment.Bottom,
content = { navigationIcon() }
)
}

internal val collapsedTitle: @Composable (Boolean, Float, @Composable () -> Unit) -> Unit =
{ centeredTitleAndSubtitle, collapsedTitleAlpha, title ->
Expand Down

0 comments on commit 16adf4f

Please sign in to comment.