@@ -42,6 +42,7 @@ import androidx.compose.material3.rememberBottomSheetScaffoldState
4242import androidx.compose.runtime.Composable
4343import androidx.compose.runtime.collectAsState
4444import androidx.compose.runtime.getValue
45+ import androidx.compose.runtime.remember
4546import androidx.compose.ui.Alignment
4647import androidx.compose.ui.Modifier
4748import androidx.compose.ui.draw.clipToBounds
@@ -65,6 +66,12 @@ fun AppScreen(modifier: Modifier = Modifier) {
6566 val graphState by viewModel.graphState.collectAsState()
6667 val functionsState by viewModel.functionsState.collectAsState()
6768
69+ val expandSheet = remember(functionsState.function) {
70+ functionsState.function.matches(
71+ " \\ s*r\\ s*=\\ s*\\ S+\\ s*|\\ s*\\ (\\ s*\\ S+\\ s*,\\ s*\\ S+\\ s*\\ )\\ s*" .toRegex()
72+ )
73+ }
74+
6875 val colorScheme = colorScheme
6976 val transformableState = rememberTransformableState { _, offsetChange, _ ->
7077 viewModel.updateOffset(offsetChange)
@@ -79,14 +86,14 @@ fun AppScreen(modifier: Modifier = Modifier) {
7986 val bottomSpacing by animateDpAsState(
8087 if (
8188 scaffoldState.bottomSheetState.targetValue == SheetValue .PartiallyExpanded &&
82- ! functionsState.function.contains( " r \\ s*=|, " .toRegex())
89+ ! expandSheet
8390 )
8491 WindowInsets .systemBars.asPaddingValues().calculateBottomPadding() + 16 .dp
8592 else 16 .dp,
8693 animationSpec = motionScheme.defaultSpatialSpec()
8794 )
8895 val sheetPeekHeight by animateDpAsState(
89- if (functionsState.function.contains( " r \\ s*=|, " .toRegex()) ) 164 .dp
96+ if (expandSheet ) 164 .dp
9097 else 64 .dp,
9198 animationSpec = motionScheme.defaultSpatialSpec()
9299 )
@@ -109,7 +116,7 @@ fun AppScreen(modifier: Modifier = Modifier) {
109116 shape = shapes.large,
110117 modifier = Modifier .fillMaxWidth()
111118 )
112- AnimatedVisibility (functionsState.function.contains( " r \\ s*=|, " .toRegex()) ) {
119+ AnimatedVisibility (expandSheet ) {
113120 AnimatedContent (functionsState.function.contains(' ,' )) {
114121 when (it) {
115122 true -> {
0 commit comments