Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions app/src/main/java/com/example/cahier/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,11 @@ class MainActivity : ComponentActivity() {
androidx.compose.runtime.CompositionLocalProvider(LocalTextureStore provides textureStore) {
Surface(
modifier = Modifier
.fillMaxSize(),
color = MaterialTheme.colorScheme.background
) {
CahierApp(noteId = noteId,
.fillMaxSize(),
color = MaterialTheme.colorScheme.background
) {
CahierApp(
noteId = noteId,
noteType = noteType,
navigateToBrushGraph = navigateToBrushGraph,
onNavigateToBrushGraphHandled = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.geometry.toRect
import androidx.compose.ui.graphics.BlendMode
import androidx.compose.ui.graphics.Path
import androidx.compose.ui.graphics.nativeCanvas
import androidx.compose.ui.graphics.withSaveLayer
import androidx.compose.ui.input.pointer.pointerInput
Expand Down Expand Up @@ -65,6 +66,7 @@ fun DrawingSurface(
backgroundImageUri: String?,
onStartDrag: () -> Unit,
modifier: Modifier = Modifier,
maskPath: Path? = null,
) {
val textureStore = LocalTextureStore.current
Box(modifier = modifier) {
Expand Down Expand Up @@ -139,7 +141,8 @@ fun DrawingSurface(
defaultBrush = currentBrush,
nextBrush = onGetNextBrush,
onStrokesFinished = onStrokesFinished,
textureBitmapStore = textureStore
textureBitmapStore = textureStore,
maskPath = maskPath
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ fun BrushGraphContent(
isNodeSelected: Boolean,
isEdgeSelected: Boolean,
isErrorPaneOpen: Boolean,
isPreviewExpanded: Boolean,
previewHeight: Dp,
viewportSize: Size,
onViewportSizeChange: (Size) -> Unit,
canvasSlot: @Composable (trashPaddingBottom: Dp) -> Unit,
Expand All @@ -47,7 +47,7 @@ fun BrushGraphContent(
previewSlot: @Composable () -> Unit,
menuSlot: @Composable () -> Unit,
fabSlot: @Composable (viewportSize: Size) -> Unit,
tutorialSlot: @Composable (viewportSize: Size) -> Unit,
tutorialSlot: @Composable () -> Unit,
dialogSlot: @Composable () -> Unit,
modifier: Modifier = Modifier,
) {
Expand All @@ -61,19 +61,14 @@ fun BrushGraphContent(
targetValue = if (isSidePaneOpen) (INSPECTOR_WIDTH_LANDSCAPE + 16).dp else 16.dp,
label = "indicatorPaddingEnd",
)
val previewHeight = if (isPreviewExpanded) {
PREVIEW_HEIGHT_EXPANDED
} else {
PREVIEW_HEIGHT_COLLAPSED
}
val isAnySidePaneOpen = isNodeSelected || isEdgeSelected || isErrorPaneOpen

val trashPaddingBottom by animateDpAsState(
targetValue =
if (!isWideScreen && isAnySidePaneOpen) {
(maxOf(previewHeight, INSPECTOR_HEIGHT_PORTRAIT) + 16).dp
maxOf(previewHeight, INSPECTOR_HEIGHT_PORTRAIT.dp) + 16.dp
} else {
(previewHeight + 16).dp
previewHeight + 16.dp
},
label = "trashPaddingBottom",
)
Expand All @@ -82,11 +77,11 @@ fun BrushGraphContent(
Box(
modifier =
Modifier
.fillMaxSize()
.padding(paddingValues)
.onGloballyPositioned { coordinates ->
onViewportSizeChange(coordinates.size.toSize())
}
.fillMaxSize()
.padding(paddingValues)
.onGloballyPositioned { coordinates ->
onViewportSizeChange(coordinates.size.toSize())
}
) {
canvasSlot(trashPaddingBottom)
inspectorSlot()
Expand All @@ -95,7 +90,7 @@ fun BrushGraphContent(
previewSlot()
menuSlot()
fabSlot(viewportSize)
tutorialSlot(viewportSize)
tutorialSlot()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.platform.LocalUriHandler
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.DpOffset
import androidx.compose.ui.unit.IntSize
import androidx.compose.ui.unit.dp
Expand Down Expand Up @@ -305,26 +306,19 @@ fun PaletteMenu(
fun CreateNodeSpeedDial(
isWideScreen: Boolean,
isAnySidePaneOpen: Boolean,
isPreviewExpanded: Boolean,
viewportSize: androidx.compose.ui.geometry.Size,
previewHeight: Dp,
modifier: Modifier = Modifier,
menuContent: @Composable (onClose: () -> Unit) -> Unit,
) {
var expanded by rememberSaveable { mutableStateOf(false) }

val previewHeight = if (isPreviewExpanded) {
PREVIEW_HEIGHT_EXPANDED
} else {
PREVIEW_HEIGHT_COLLAPSED
}

val fabPaddingBottom by
animateDpAsState(
targetValue =
if (!isWideScreen && isAnySidePaneOpen) {
(maxOf(previewHeight, INSPECTOR_HEIGHT_PORTRAIT) + 16).dp
maxOf(previewHeight, INSPECTOR_HEIGHT_PORTRAIT.dp) + 16.dp
} else {
(previewHeight + 16).dp
previewHeight + 16.dp
},
label = "fabPaddingBottom",
)
Expand Down
Loading
Loading