Skip to content

Instantly share code, notes, and snippets.

@artsmvch
Created April 25, 2024 16:28
Show Gist options
  • Save artsmvch/e0a3c2b25714f48de2e938b653b6eb42 to your computer and use it in GitHub Desktop.
Save artsmvch/e0a3c2b25714f48de2e938b653b6eb42 to your computer and use it in GitHub Desktop.
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.wrapContentHeight
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.material.BottomNavigationItem
import androidx.compose.material.Icon
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Scaffold
import androidx.compose.material.Text
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.AccountBox
import androidx.compose.material.icons.filled.AddCircle
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.NavigationBar
import androidx.compose.material3.TopAppBar
import androidx.compose.material3.TopAppBarDefaults
import androidx.compose.material3.rememberTopAppBarState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.drawWithCache
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.input.nestedscroll.nestedScroll
import androidx.compose.ui.unit.dp
import dev.chrisbanes.haze.HazeState
import dev.chrisbanes.haze.haze
import dev.chrisbanes.haze.hazeChild
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun HazeBugScene() {
val hazeState = remember { HazeState() }
val scrollBehavior = TopAppBarDefaults.exitUntilCollapsedScrollBehavior(rememberTopAppBarState())
Scaffold(
topBar = {
TopAppBar(
// Need to make app bar transparent to see the content behind
colors = TopAppBarDefaults.largeTopAppBarColors(Color.Transparent),
modifier = Modifier
.hazeChild(state = hazeState)
.fillMaxWidth(),
title = { Text("Test") },
scrollBehavior = scrollBehavior
)
},
bottomBar = {
NavigationBar(
containerColor = Color.Transparent,
modifier = Modifier
.hazeChild(state = hazeState)
.fillMaxWidth()
.drawWithCache {
onDrawWithContent {
drawContent()
drawLine(
color = Color.White,
start = Offset(0f, 0f),
end = Offset(size.width, 0f),
strokeWidth = 5f
)
}
},
) {
BottomNavigationItem(
selected = false,
onClick = {},
icon = {
Icon(imageVector = Icons.Default.AddCircle, contentDescription = null)
}
)
BottomNavigationItem(
selected = false,
onClick = {},
icon = {
Icon(imageVector = Icons.Default.AccountBox, contentDescription = null)
}
)
}
},
) {
LazyColumn(
modifier = Modifier
.nestedScroll(scrollBehavior.nestedScrollConnection)
.haze(
state = hazeState,
backgroundColor = MaterialTheme.colors.surface,
),
) {
repeat(100) { index ->
item {
Text(
modifier = Modifier
.fillMaxWidth()
.wrapContentHeight()
.padding(8.dp),
text = "Text Text Text Text Text $index"
)
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment