Skip to content

Commit

Permalink
fix: disable scrim when fraction 0f
Browse files Browse the repository at this point in the history
  • Loading branch information
ch4rl3x committed Jun 10, 2024
1 parent 4f3adc4 commit 0692c2f
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 12 deletions.
2 changes: 1 addition & 1 deletion bottom-drawer-scaffold/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ apply from: '../buildCompose.gradle'

ext {
PUBLISH_GROUP_ID = 'de.charlex.compose'
PUBLISH_VERSION = '2.0.0-rc01'
PUBLISH_VERSION = '2.0.0-rc02'
PUBLISH_ARTIFACT_ID = 'bottom-drawer-scaffold'
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,11 @@ fun BottomDrawerScaffold(
}
},
fraction = {
calculateFraction(initialOffset, 0f, bottomSheetScaffoldState.bottomSheetState.requireOffset())
try {
calculateFraction(initialOffset, 0f, bottomSheetScaffoldState.bottomSheetState.requireOffset())
} catch (exception: IllegalStateException) {
0f
}
},
color = drawerScrimColor
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import androidx.compose.foundation.gestures.detectTapGestures
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.alpha
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.input.pointer.pointerInput
import androidx.compose.ui.semantics.contentDescription
Expand All @@ -29,11 +30,15 @@ fun Scrim(
Modifier
}

Canvas(
Modifier
.fillMaxSize()
.then(dismissDrawer)
) {
drawRect(color, alpha = fraction())
val fraction = fraction()

if(fraction > 0f) {
Canvas(
Modifier
.fillMaxSize()
.then(dismissDrawer)
) {
drawRect(color, alpha = fraction())
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package de.charlex.compose.bottomdrawerscaffold.sample

import android.os.Bundle
import android.util.Log
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
Expand Down Expand Up @@ -36,6 +37,7 @@ import androidx.compose.material.icons.filled.Refresh
import androidx.compose.material.icons.filled.Send
import androidx.compose.material.icons.filled.ShoppingCart
import androidx.compose.material3.BottomAppBar
import androidx.compose.material3.Button
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.FloatingActionButton
import androidx.compose.material3.Icon
Expand Down Expand Up @@ -211,11 +213,19 @@ fun Content() {
.height(10.dp)
.background(color = MaterialTheme.colorScheme.primary)
)
Text(

Button(
modifier = Modifier.align(Alignment.Center),
text = "Content",
style = MaterialTheme.typography.bodyMedium
)
onClick = {
Log.d("TEST", "click")
}
) {
Text(
text = "Content",
style = MaterialTheme.typography.bodyMedium
)
}

Box(
modifier = Modifier
.fillMaxWidth()
Expand Down

0 comments on commit 0692c2f

Please sign in to comment.