feat: camera screen ui (2)
This commit is contained in:
1 parent
215f848b4e
commit
313c4a6073
4 files changed
+55
-17
No files matched your search
@@ -31,7 +31,7 @@ fun CameraParameterBar(
|
||||
Row(
|
||||
modifier = modifier
|
||||
.fillMaxWidth()
|
||||
.padding(start = 16.dp, top = 12.dp, end = 16.dp),
|
||||
.padding(start = 16.dp, top = 8.dp, end = 16.dp),
|
||||
horizontalArrangement = Arrangement.SpaceBetween,
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
|
||||
@@ -274,6 +274,8 @@ fun CameraScreen(
|
||||
var previewBounds by remember { mutableStateOf<Rect?>(null) }
|
||||
var viewfinderAreaBounds by remember { mutableStateOf<Rect?>(null) }
|
||||
var zoomBarBounds by remember { mutableStateOf<Rect?>(null) }
|
||||
var filterButtonBounds by remember { mutableStateOf<Rect?>(null) }
|
||||
var captureButtonBounds by remember { mutableStateOf<Rect?>(null) }
|
||||
var parameterRulerBounds by remember { mutableStateOf<Rect?>(null) }
|
||||
var galleryThumbnailBounds by remember { mutableStateOf<Rect?>(null) }
|
||||
var captureAnimationSnapshot by remember { mutableStateOf<CaptureAnimationSnapshot?>(null) }
|
||||
@@ -918,6 +920,9 @@ fun CameraScreen(
|
||||
onFilterClick = {
|
||||
activePanel = if (activePanel == ActivePanel.FILTERS) ActivePanel.NONE else ActivePanel.FILTERS
|
||||
},
|
||||
onFilterButtonBoundsChanged = { bounds ->
|
||||
filterButtonBounds = bounds
|
||||
},
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.onGloballyPositioned { coordinates ->
|
||||
@@ -1431,7 +1436,10 @@ fun CameraScreen(
|
||||
onFilterClick = {
|
||||
activePanel =
|
||||
if (activePanel == ActivePanel.FILTERS) ActivePanel.NONE else ActivePanel.FILTERS
|
||||
}
|
||||
},
|
||||
onFilterButtonBoundsChanged = { bounds ->
|
||||
filterButtonBounds = bounds
|
||||
},
|
||||
)
|
||||
}
|
||||
Box(
|
||||
@@ -1464,6 +1472,9 @@ fun CameraScreen(
|
||||
onGalleryThumbnailBoundsChanged = { bounds ->
|
||||
galleryThumbnailBounds = bounds
|
||||
},
|
||||
onCaptureButtonBoundsChanged = { bounds ->
|
||||
captureButtonBounds = bounds
|
||||
},
|
||||
onSwitchCameraClick = ::switchCameraWithPreviewTransition,
|
||||
onCaptureModeSelected = ::setShootingModeWithPreviewTransition,
|
||||
modeSwitchEnabled = !previewTransitionActive,
|
||||
@@ -1674,6 +1685,22 @@ fun CameraScreen(
|
||||
contentTopPadding = CameraTopBarBaseTopPadding + topSafePadding
|
||||
)
|
||||
|
||||
val filterPanelTop = if (!isXpan && !isVideoMode) topBarHeight else 0.dp
|
||||
val fallbackFilterPanelBottom = when {
|
||||
isXpan -> maxHeight - 48.dp
|
||||
isVideoMode -> maxHeight - 170.dp
|
||||
else -> topBarHeight + cardHeight - 48.dp
|
||||
}
|
||||
val filterPanelAnchorY = if (isXpan) {
|
||||
captureButtonBounds?.top
|
||||
} else {
|
||||
filterButtonBounds?.bottom
|
||||
}
|
||||
val filterPanelBottom = filterPanelAnchorY?.let { anchorY ->
|
||||
val parentTop = cameraScreenBounds?.top ?: 0f
|
||||
with(density) { (anchorY - parentTop).toDp() }
|
||||
}?.coerceIn(filterPanelTop, maxHeight) ?: fallbackFilterPanelBottom
|
||||
|
||||
AnimatedVisibility(
|
||||
activePanel == ActivePanel.FILTERS,
|
||||
enter = if (isXpan) {slideInVertically(initialOffsetY = { it })} else fadeIn(),
|
||||
@@ -1682,17 +1709,8 @@ fun CameraScreen(
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.then(
|
||||
if (isXpan) {
|
||||
Modifier.fillMaxHeight().padding(bottom = 48.dp)
|
||||
} else if (isVideoMode) {
|
||||
Modifier.height(maxHeight - 170.dp)
|
||||
} else {
|
||||
Modifier
|
||||
.padding(top = topBarHeight)
|
||||
.height(cardHeight - 48.dp)
|
||||
}
|
||||
),
|
||||
.height(filterPanelBottom)
|
||||
.padding(top = filterPanelTop),
|
||||
contentAlignment = Alignment.BottomCenter
|
||||
) {
|
||||
val allPresets by viewModel.allPresets.collectAsState()
|
||||
@@ -1750,7 +1768,7 @@ fun CameraScreen(
|
||||
categoryOrder = categoryOrder,
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(horizontal = 6.dp, vertical = 10.dp)
|
||||
.padding(start = 6.dp, top = 10.dp, end = 6.dp)
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -1884,6 +1902,7 @@ private fun Controls(
|
||||
useMultipleExposure: Boolean,
|
||||
multipleExposureState: com.hinnka.mycamera.viewmodel.MultipleExposureSessionState,
|
||||
onGalleryThumbnailBoundsChanged: (Rect) -> Unit,
|
||||
onCaptureButtonBoundsChanged: (Rect) -> Unit,
|
||||
onSwitchCameraClick: () -> Unit,
|
||||
onCaptureModeSelected: (CameraShootingMode) -> Unit,
|
||||
modeSwitchEnabled: Boolean,
|
||||
@@ -1943,7 +1962,10 @@ private fun Controls(
|
||||
customImagePath = captureButtonImagePath,
|
||||
onTap = onCaptureTap,
|
||||
onLongPressStart = { viewModel.startContinuousCapture() },
|
||||
onLongPressEnd = { viewModel.stopContinuousCapture() }
|
||||
onLongPressEnd = { viewModel.stopContinuousCapture() },
|
||||
modifier = Modifier.onGloballyPositioned { coordinates ->
|
||||
onCaptureButtonBoundsChanged(coordinates.boundsInRoot())
|
||||
},
|
||||
)
|
||||
|
||||
if (state.videoRecordingState.isRecording) {
|
||||
|
||||
@@ -16,10 +16,13 @@ import androidx.compose.runtime.*
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.geometry.Offset
|
||||
import androidx.compose.ui.geometry.Rect
|
||||
import androidx.compose.ui.geometry.Size
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.graphics.Path
|
||||
import androidx.compose.ui.input.pointer.pointerInput
|
||||
import androidx.compose.ui.layout.boundsInRoot
|
||||
import androidx.compose.ui.layout.onGloballyPositioned
|
||||
import androidx.compose.ui.text.TextStyle
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.text.style.TextDecoration
|
||||
@@ -70,6 +73,7 @@ fun ZoomControlBar(
|
||||
onZoomStopClick: (Float) -> Unit,
|
||||
onLensSwitch: (String) -> Unit,
|
||||
onFilterClick: () -> Unit,
|
||||
onFilterButtonBoundsChanged: (Rect) -> Unit = {},
|
||||
modifier: Modifier = Modifier
|
||||
) {
|
||||
val displayMode by viewModel.zoomDisplayMode.collectAsState()
|
||||
@@ -252,7 +256,11 @@ fun ZoomControlBar(
|
||||
// 右侧滤镜按钮
|
||||
IconButton(
|
||||
onClick = onFilterClick,
|
||||
modifier = Modifier.size(32.dp)
|
||||
modifier = Modifier
|
||||
.size(32.dp)
|
||||
.onGloballyPositioned { coordinates ->
|
||||
onFilterButtonBoundsChanged(coordinates.boundsInRoot())
|
||||
}
|
||||
) {
|
||||
Icon(
|
||||
imageVector = AppIcons.AutoAwesome,
|
||||
|
||||
@@ -17,9 +17,12 @@ import androidx.compose.runtime.*
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.geometry.Offset
|
||||
import androidx.compose.ui.geometry.Rect
|
||||
import androidx.compose.ui.geometry.Size
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.input.pointer.pointerInput
|
||||
import androidx.compose.ui.layout.boundsInRoot
|
||||
import androidx.compose.ui.layout.onGloballyPositioned
|
||||
import androidx.compose.ui.text.TextStyle
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.text.style.TextDecoration
|
||||
@@ -53,6 +56,7 @@ fun ZoomControlBarVerticel(
|
||||
onZoomStopClick: (Float) -> Unit,
|
||||
onLensSwitch: (String) -> Unit,
|
||||
onFilterClick: () -> Unit,
|
||||
onFilterButtonBoundsChanged: (Rect) -> Unit = {},
|
||||
modifier: Modifier = Modifier
|
||||
) {
|
||||
val displayMode by viewModel.zoomDisplayMode.collectAsState()
|
||||
@@ -233,7 +237,11 @@ fun ZoomControlBarVerticel(
|
||||
// 底部滤镜按钮
|
||||
IconButton(
|
||||
onClick = onFilterClick,
|
||||
modifier = Modifier.size(32.dp)
|
||||
modifier = Modifier
|
||||
.size(32.dp)
|
||||
.onGloballyPositioned { coordinates ->
|
||||
onFilterButtonBoundsChanged(coordinates.boundsInRoot())
|
||||
}
|
||||
) {
|
||||
Icon(
|
||||
imageVector = AppIcons.AutoAwesome,
|
||||
|
||||
Reference in new issue
Block a user