Skip to content

Commit

Permalink
Release 1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
kevingermainbusiness committed Jul 31, 2022
1 parent e212648 commit c2f792a
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 7 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-rc06"
implementation "com.github.germainkevinbusiness:CollapsingTopBarCompose:1.0.0"
}
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ 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
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
buildscript {
ext {
compose_version = '1.3.0-alpha01'
compose_version = '1.2.0'
coreKtx = '1.8.0'
libraryVersion ='1.0.0-rc06'
material3Version ='1.0.0-alpha14'
libraryVersion ='1.0.0'
material3Version ='1.0.0-alpha15'
timberVersion ='5.0.1'
}
}// Top-level build file where you can add configuration options common to all sub-projects/modules.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ fun CollapsingTopBar(
subtitle = subtitle,
navigationIcon = navigationIcon,
actions = actions,
centeredTitleWhenCollapsed = centeredTitleWhenCollapsed,
centeredTitleAndSubtitle = centeredTitleAndSubtitle,
contentPadding = contentPadding,
expandedColumnAlphaValue = expandedColumnAlphaValue.invoke().value,
Expand All @@ -77,6 +78,8 @@ fun CollapsingTopBar(
* @param contentPadding The padding of the content inside the [CollapsingTopBar]
* @param elevation The size of the shadow below the [Surface]
* @param currentTopBarHeight The current height of the [CollapsingTopBar]
* @param centeredTitleWhenCollapsed Whether the [title] should be centered when the
* [CollapsingTopBar] is collapsed
* @param elevation The size of the shadow below the [Surface]
* */
@Composable
Expand All @@ -86,6 +89,7 @@ private fun CollapsingTopBarLayout(
subtitle: @Composable () -> Unit,
navigationIcon: @Composable (() -> Unit)?,
actions: @Composable RowScope.() -> Unit,
centeredTitleWhenCollapsed: Boolean,
centeredTitleAndSubtitle: Boolean,
contentPadding: PaddingValues,
currentBackgroundColor: Color,
Expand Down Expand Up @@ -152,6 +156,8 @@ private fun CollapsingTopBarLayout(
.fillMaxHeight()
.weight(1f),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement =
if (centeredTitleWhenCollapsed) Arrangement.Center else Arrangement.Start,
content = {
collapsedTitle(
centeredTitleAndSubtitle,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,16 @@ object CollapsingTopBarDefaults {
* the default value is [defaultMaximumTopBarHeight]
* */
fun scrollBehavior(
isAlwaysCollapsed: Boolean = false,
isExpandedWhenFirstDisplayed: Boolean = true,
centeredTitleAndSubtitle: Boolean = true,
isAlwaysCollapsed: Boolean,
isExpandedWhenFirstDisplayed: Boolean,
centeredTitleWhenCollapsed: Boolean,
centeredTitleAndSubtitle: Boolean,
collapsedTopBarHeight: Dp = defaultMinimumTopBarHeight,
expandedTopBarMaxHeight: Dp = defaultMaximumTopBarHeight,
): CollapsingTopBarScrollBehavior = DefaultBehaviorOnScroll(
isAlwaysCollapsed = isAlwaysCollapsed,
isExpandedWhenFirstDisplayed = isExpandedWhenFirstDisplayed,
centeredTitleWhenCollapsed = centeredTitleWhenCollapsed,
centeredTitleAndSubtitle = centeredTitleAndSubtitle,
collapsedTopBarHeight = collapsedTopBarHeight,
expandedTopBarMaxHeight = expandedTopBarMaxHeight
Expand Down Expand Up @@ -100,6 +102,8 @@ class CollapsingTopBarColors(
* @param isExpandedWhenFirstDisplayed When true, Sets the [CollapsingTopBar] to an expanded
* state when first displayed on the UI by setting the [CollapsingTopBar]'s height to
* [expandedTopBarMaxHeight]
* @param centeredTitleWhenCollapsed Should the title be centered when it's the [CollapsingTopBar]
* is collapsed
* @param centeredTitleAndSubtitle Whether the title and subtitle should be centered when Expanded
* @param collapsedTopBarHeight The height of the [CollapsingTopBar] when it's collapsed, the
* default value is [defaultMinimumTopBarHeight]
Expand All @@ -110,13 +114,15 @@ class CollapsingTopBarColors(
fun rememberCollapsingTopBarScrollBehavior(
isAlwaysCollapsed: Boolean = false,
isExpandedWhenFirstDisplayed: Boolean = true,
centeredTitleWhenCollapsed: Boolean = false,
centeredTitleAndSubtitle: Boolean = true,
collapsedTopBarHeight: Dp = defaultMinimumTopBarHeight,
expandedTopBarMaxHeight: Dp = defaultMaximumTopBarHeight,
): CollapsingTopBarScrollBehavior {
return remember(
isAlwaysCollapsed,
isExpandedWhenFirstDisplayed,
centeredTitleWhenCollapsed,
centeredTitleAndSubtitle,
collapsedTopBarHeight,
collapsedTopBarHeight,
Expand All @@ -125,6 +131,7 @@ fun rememberCollapsingTopBarScrollBehavior(
CollapsingTopBarDefaults.scrollBehavior(
isAlwaysCollapsed = isAlwaysCollapsed,
isExpandedWhenFirstDisplayed = isExpandedWhenFirstDisplayed,
centeredTitleWhenCollapsed = centeredTitleWhenCollapsed,
centeredTitleAndSubtitle = centeredTitleAndSubtitle,
collapsedTopBarHeight = collapsedTopBarHeight,
expandedTopBarMaxHeight = expandedTopBarMaxHeight
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ interface CollapsingTopBarScrollBehavior {
* */
var isExpandedWhenFirstDisplayed: Boolean

/**
* Should the title be centered when the [CollapsingTopBar] is collapsed
* */
var centeredTitleWhenCollapsed: Boolean

/**
* Whether the title and subtitle should be centered when Expanded
* */
Expand Down Expand Up @@ -95,6 +100,7 @@ interface CollapsingTopBarScrollBehavior {
class DefaultBehaviorOnScroll(
override var isAlwaysCollapsed: Boolean,
override var isExpandedWhenFirstDisplayed: Boolean,
override var centeredTitleWhenCollapsed: Boolean,
override var centeredTitleAndSubtitle: Boolean,
override var collapsedTopBarHeight: Dp,
override var expandedTopBarMaxHeight: Dp,
Expand Down

0 comments on commit c2f792a

Please sign in to comment.