From 83805d5b2d57444ff9d8eb392d2e054d461d8f28 Mon Sep 17 00:00:00 2001 From: germainkevinbusiness <67168053+kevingermainbusiness@users.noreply.github.com> Date: Tue, 31 May 2022 13:53:23 -0400 Subject: [PATCH] 1.0.0-alpha08 release version with good integration with Material 3 --- README.md | 2 +- app/build.gradle | 2 +- .../germainkevin/collapsingtopbarcompose/MainActivity.kt | 2 +- collapsingtopbar/build.gradle | 2 +- .../com/germainkevin/collapsingtopbar/CollapsingTopBar.kt | 6 +++--- .../germainkevin/collapsingtopbar/TopBarScrollBehavior.kt | 5 +++-- 6 files changed, 10 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 7b6ea8b..1050aa2 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ repositories { ```groovy dependencies { - implementation 'com.github.germainkevinbusiness:CollapsingTopBarCompose:1.0.0-alpha07' + implementation 'com.github.germainkevinbusiness:CollapsingTopBarCompose:1.0.0-alpha08' } ``` diff --git a/app/build.gradle b/app/build.gradle index 715a918..59e67eb 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -11,7 +11,7 @@ android { minSdk 21 targetSdk 32 versionCode 1 - versionName "1.0.0-alpha07" + versionName "1.0.0-alpha08" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" vectorDrawables { diff --git a/app/src/main/java/com/germainkevin/collapsingtopbarcompose/MainActivity.kt b/app/src/main/java/com/germainkevin/collapsingtopbarcompose/MainActivity.kt index dd18b9c..cadae28 100644 --- a/app/src/main/java/com/germainkevin/collapsingtopbarcompose/MainActivity.kt +++ b/app/src/main/java/com/germainkevin/collapsingtopbarcompose/MainActivity.kt @@ -71,7 +71,7 @@ class MainActivity : ComponentActivity() { val scrollBehavior = remember { CollapsingTopBarDefaults.scrollBehavior( isAlwaysCollapsed = false, - isExpandedWhenFirstDisplayed = false, + isExpandedWhenFirstDisplayed = true, expandedTopBarMaxHeight = 256.dp, ) } diff --git a/collapsingtopbar/build.gradle b/collapsingtopbar/build.gradle index a79dfff..8e6638b 100644 --- a/collapsingtopbar/build.gradle +++ b/collapsingtopbar/build.gradle @@ -24,7 +24,7 @@ afterEvaluate { // You can then customize attributes of the publication as shown below. groupId = 'com.germainkevin.collapsingtopbarcompose' artifactId = 'collapsingtopbarcompose' - version = '1.0.0-alpha07' + version = '1.0.0-alpha08' } } } diff --git a/collapsingtopbar/src/main/java/com/germainkevin/collapsingtopbar/CollapsingTopBar.kt b/collapsingtopbar/src/main/java/com/germainkevin/collapsingtopbar/CollapsingTopBar.kt index 7403b85..a1c07f1 100644 --- a/collapsingtopbar/src/main/java/com/germainkevin/collapsingtopbar/CollapsingTopBar.kt +++ b/collapsingtopbar/src/main/java/com/germainkevin/collapsingtopbar/CollapsingTopBar.kt @@ -29,7 +29,7 @@ import androidx.compose.ui.unit.dp * @param centeredTitleAndSubtitle Whether the [title] and [subtitle] section should be centered or * at the start of the [CollapsingTopBar] * @param colors [CollapsingTopBarColors] that will be used to resolve the colors used for this - * [CollapsingTopBar] in different states. See [CollapsingTopBarDefaults.collapsingTopBarColors]. + * [CollapsingTopBar] in different states. See [CollapsingTopBarDefaults.colors]. * @param contentPadding The padding of the content inside the [CollapsingTopBar] * @param elevation The size of the shadow below the [Surface] * @param scrollBehavior [TopBarScrollBehavior] which holds certain values that will be applied by @@ -56,7 +56,7 @@ fun CollapsingTopBar( // Make sure the trackOffSetIsZero variable does not exceed the number 10 if (trackOffSetIsZero > 10) trackOffSetIsZero = 3 currentTopBarHeight = expandedTopBarMaxHeight + topBarOffset.dp - } else if (isExpandedWhenFirstDisplayed) { + } else if (isExpandedWhenFirstDisplayed && !isAlwaysCollapsed) { currentTopBarHeight = expandedTopBarMaxHeight + topBarOffset.dp } @@ -118,7 +118,7 @@ fun CollapsingTopBar( * @param actions the actions displayed at the end of the [CollapsingTopBar]. This should typically * be [IconButton]s. The default layout here is a [Row], so icons inside will be placed horizontally. * @param colors [CollapsingTopBarColors] that will be used to resolve the colors used for this - * [CollapsingTopBar] in different states. See [CollapsingTopBarDefaults.collapsingTopBarColors]. + * [CollapsingTopBar] in different states. See [CollapsingTopBarDefaults.colors]. * @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] diff --git a/collapsingtopbar/src/main/java/com/germainkevin/collapsingtopbar/TopBarScrollBehavior.kt b/collapsingtopbar/src/main/java/com/germainkevin/collapsingtopbar/TopBarScrollBehavior.kt index 5b04eb5..44de748 100644 --- a/collapsingtopbar/src/main/java/com/germainkevin/collapsingtopbar/TopBarScrollBehavior.kt +++ b/collapsingtopbar/src/main/java/com/germainkevin/collapsingtopbar/TopBarScrollBehavior.kt @@ -91,8 +91,9 @@ class DefaultBehaviorOnScroll( override var trackOffSetIsZero: Int by mutableStateOf(0) override var currentTopBarHeight: Dp by mutableStateOf( - if (isAlwaysCollapsed) collapsedTopBarHeight - else if (!isExpandedWhenFirstDisplayed) collapsedTopBarHeight + if (isAlwaysCollapsed && isExpandedWhenFirstDisplayed) collapsedTopBarHeight + else if (isAlwaysCollapsed && !isExpandedWhenFirstDisplayed) collapsedTopBarHeight + else if (!isAlwaysCollapsed && !isExpandedWhenFirstDisplayed) collapsedTopBarHeight else if (!isAlwaysCollapsed && isExpandedWhenFirstDisplayed) expandedTopBarMaxHeight else expandedTopBarMaxHeight )