feat: reorganize filter and camera switch buttons
This commit is contained in:
1 parent
b3022908b2
commit
32dd9acfde
4 files changed
+126
-111
No files matched your search
@@ -303,7 +303,6 @@ 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) }
|
||||
@@ -984,12 +983,7 @@ fun CameraScreen(
|
||||
onZoomChange = { setZoomWithPreviewTransition(it) },
|
||||
onZoomStopClick = { animateZoomStopWithPreviewTransition(it) },
|
||||
onLensSwitch = { lensId -> switchToLensWithPreviewTransition(lensId) },
|
||||
onFilterClick = {
|
||||
activePanel = if (activePanel == ActivePanel.FILTERS) ActivePanel.NONE else ActivePanel.FILTERS
|
||||
},
|
||||
onFilterButtonBoundsChanged = { bounds ->
|
||||
filterButtonBounds = bounds
|
||||
},
|
||||
onSwitchCameraClick = ::switchCameraWithPreviewTransition,
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.onGloballyPositioned { coordinates ->
|
||||
@@ -1578,17 +1572,11 @@ fun CameraScreen(
|
||||
onZoomChange = { setZoomWithPreviewTransition(it) },
|
||||
onZoomStopClick = { animateZoomStopWithPreviewTransition(it) },
|
||||
onLensSwitch = { lensId -> switchToLensWithPreviewTransition(lensId) },
|
||||
onFilterClick = {
|
||||
activePanel =
|
||||
if (activePanel == ActivePanel.FILTERS) ActivePanel.NONE else ActivePanel.FILTERS
|
||||
},
|
||||
onFilterButtonBoundsChanged = { bounds ->
|
||||
filterButtonBounds = bounds
|
||||
},
|
||||
onSwitchCameraClick = ::switchCameraWithPreviewTransition,
|
||||
)
|
||||
}
|
||||
Box(
|
||||
modifier = Modifier
|
||||
modifier = Modifier
|
||||
.align(Alignment.CenterEnd)
|
||||
.width(xpanSideWidth),
|
||||
contentAlignment = Alignment.Center
|
||||
@@ -1620,7 +1608,10 @@ fun CameraScreen(
|
||||
onCaptureButtonBoundsChanged = { bounds ->
|
||||
captureButtonBounds = bounds
|
||||
},
|
||||
onSwitchCameraClick = ::switchCameraWithPreviewTransition,
|
||||
onFilterClick = {
|
||||
activePanel = if (activePanel == ActivePanel.FILTERS) ActivePanel.NONE else ActivePanel.FILTERS
|
||||
},
|
||||
isFilterPanelOpen = activePanel == ActivePanel.FILTERS,
|
||||
onCaptureModeSelected = ::setShootingModeWithPreviewTransition,
|
||||
modeSwitchEnabled = !previewTransitionActive && !lensSwitchTransition.isActive,
|
||||
onCaptureTap = {
|
||||
@@ -1846,11 +1837,9 @@ fun CameraScreen(
|
||||
isVideoMode -> maxHeight - 170.dp
|
||||
else -> topBarHeight + cardHeight - 48.dp
|
||||
}
|
||||
val filterPanelAnchorY = if (isXpan) {
|
||||
captureButtonBounds?.top
|
||||
} else {
|
||||
filterButtonBounds?.bottom
|
||||
}
|
||||
// The filter entry now sits beside the shutter. Keep the panel above
|
||||
// the entire capture row so both the shutter and panel toggle stay accessible.
|
||||
val filterPanelAnchorY = captureButtonBounds?.top
|
||||
val requestedFilterPanelBottom = filterPanelAnchorY?.let { anchorY ->
|
||||
val parentTop = cameraScreenBounds?.top ?: 0f
|
||||
with(density) { (anchorY - parentTop).toDp() - 8.dp }
|
||||
@@ -2070,7 +2059,8 @@ private fun Controls(
|
||||
multipleExposureState: com.hinnka.mycamera.viewmodel.MultipleExposureSessionState,
|
||||
onGalleryThumbnailBoundsChanged: (Rect) -> Unit,
|
||||
onCaptureButtonBoundsChanged: (Rect) -> Unit,
|
||||
onSwitchCameraClick: () -> Unit,
|
||||
onFilterClick: () -> Unit,
|
||||
isFilterPanelOpen: Boolean,
|
||||
onCaptureModeSelected: (CameraShootingMode) -> Unit,
|
||||
modeSwitchEnabled: Boolean,
|
||||
onCaptureTap: () -> Unit,
|
||||
@@ -2155,67 +2145,69 @@ private fun Controls(
|
||||
)
|
||||
|
||||
if (state.videoRecordingState.isRecording) {
|
||||
IconButton(
|
||||
onClick = { viewModel.captureVideoFrame() },
|
||||
modifier = Modifier
|
||||
.align(Alignment.CenterEnd)
|
||||
.padding(end = sideControlInset ?: 40.dp)
|
||||
.size(CameraControlsLayoutDefaults.SideButtonSize)
|
||||
.autoRotate()
|
||||
// Both recording actions share the shutter's center and spacing.
|
||||
Row(
|
||||
modifier = Modifier.align(Alignment.Center),
|
||||
horizontalArrangement = Arrangement.spacedBy(8.dp),
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
Icon(
|
||||
imageVector = AppIcons.CameraAlt,
|
||||
contentDescription = stringResource(R.string.take_photo),
|
||||
tint = Color.White,
|
||||
modifier = Modifier.size(32.dp)
|
||||
)
|
||||
}
|
||||
IconButton(
|
||||
onClick = {
|
||||
if (state.videoRecordingState.isPaused) {
|
||||
viewModel.resumeVideoRecording()
|
||||
} else {
|
||||
viewModel.pauseVideoRecording()
|
||||
}
|
||||
},
|
||||
modifier = Modifier
|
||||
.size(32.dp)
|
||||
.autoRotate()
|
||||
) {
|
||||
Icon(
|
||||
imageVector = if (state.videoRecordingState.isPaused) Icons.Default.PlayArrow else AppIcons.Pause,
|
||||
contentDescription = null,
|
||||
tint = Color.White,
|
||||
modifier = Modifier.size(20.dp)
|
||||
)
|
||||
}
|
||||
|
||||
IconButton(
|
||||
onClick = {
|
||||
if (state.videoRecordingState.isPaused) {
|
||||
viewModel.resumeVideoRecording()
|
||||
} else {
|
||||
viewModel.pauseVideoRecording()
|
||||
}
|
||||
},
|
||||
modifier = Modifier
|
||||
.align(Alignment.CenterStart)
|
||||
.padding(start = 100.dp)
|
||||
.size(48.dp)
|
||||
.autoRotate()
|
||||
) {
|
||||
Icon(
|
||||
imageVector = if (state.videoRecordingState.isPaused) Icons.Default.PlayArrow else AppIcons.Pause,
|
||||
contentDescription = null,
|
||||
tint = Color.White,
|
||||
modifier = Modifier.size(32.dp)
|
||||
)
|
||||
}
|
||||
} else {
|
||||
PhysicalButton(
|
||||
onClick = {
|
||||
if (!state.videoRecordingState.isProcessing) {
|
||||
onSwitchCameraClick()
|
||||
}
|
||||
},
|
||||
modifier = Modifier
|
||||
.align(Alignment.CenterEnd)
|
||||
.padding(end = sideControlInset ?: 40.dp)
|
||||
.size(CameraControlsLayoutDefaults.SideButtonSize)
|
||||
.autoRotate(),
|
||||
shape = CircleShape
|
||||
) {
|
||||
Icon(
|
||||
imageVector = AppIcons.Cameraswitch,
|
||||
contentDescription = stringResource(R.string.switch_camera),
|
||||
tint = Color.White.copy(
|
||||
alpha = if (state.videoRecordingState.isProcessing) 0.35f else 1f
|
||||
),
|
||||
modifier = Modifier.size(24.dp)
|
||||
)
|
||||
Spacer(modifier = Modifier.width(CameraControlsLayoutDefaults.CaptureButtonSize))
|
||||
|
||||
IconButton(
|
||||
onClick = { viewModel.captureVideoFrame() },
|
||||
modifier = Modifier
|
||||
.size(32.dp)
|
||||
.autoRotate()
|
||||
) {
|
||||
Icon(
|
||||
imageVector = AppIcons.CameraAlt,
|
||||
contentDescription = stringResource(R.string.take_photo),
|
||||
tint = Color.White,
|
||||
modifier = Modifier.size(20.dp)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PhysicalButton(
|
||||
onClick = onFilterClick,
|
||||
enabled = !state.videoRecordingState.isProcessing,
|
||||
modifier = Modifier
|
||||
.align(Alignment.CenterEnd)
|
||||
.padding(end = sideControlInset ?: 40.dp)
|
||||
.size(CameraControlsLayoutDefaults.SideButtonSize)
|
||||
.autoRotate(),
|
||||
shape = CircleShape
|
||||
) {
|
||||
Icon(
|
||||
imageVector = AppIcons.ColorFilters,
|
||||
contentDescription = stringResource(R.string.filters_panel),
|
||||
tint = (if (isFilterPanelOpen) AccentColor else Color.White).copy(
|
||||
alpha = if (state.videoRecordingState.isProcessing) 0.35f else 1f
|
||||
),
|
||||
modifier = Modifier.size(28.dp)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Spacer(modifier = Modifier.height(CameraControlsLayoutDefaults.ModeSwitcherSpacing))
|
||||
|
||||
@@ -17,13 +17,10 @@ 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
|
||||
@@ -74,8 +71,7 @@ fun ZoomControlBar(
|
||||
onZoomChange: (Float) -> Unit,
|
||||
onZoomStopClick: (Float) -> Unit,
|
||||
onLensSwitch: (String) -> Unit,
|
||||
onFilterClick: () -> Unit,
|
||||
onFilterButtonBoundsChanged: (Rect) -> Unit = {},
|
||||
onSwitchCameraClick: () -> Unit,
|
||||
modifier: Modifier = Modifier
|
||||
) {
|
||||
val displayMode by viewModel.zoomDisplayMode.collectAsState()
|
||||
@@ -255,22 +251,24 @@ fun ZoomControlBar(
|
||||
exit = fadeOut() + shrinkHorizontally(),
|
||||
modifier = Modifier.align(Alignment.CenterEnd)
|
||||
) {
|
||||
// 右侧滤镜按钮
|
||||
// 右侧前后摄像头切换按钮
|
||||
IconButton(
|
||||
onClick = onFilterClick,
|
||||
modifier = Modifier
|
||||
.size(32.dp)
|
||||
.onGloballyPositioned { coordinates ->
|
||||
onFilterButtonBoundsChanged(coordinates.boundsInRoot())
|
||||
}
|
||||
onClick = onSwitchCameraClick,
|
||||
enabled = !cameraState.videoRecordingState.isRecording &&
|
||||
!cameraState.videoRecordingState.isProcessing,
|
||||
modifier = Modifier.size(32.dp)
|
||||
) {
|
||||
Icon(
|
||||
imageVector = AppIcons.AutoAwesome,
|
||||
contentDescription = stringResource(R.string.filters_panel),
|
||||
imageVector = AppIcons.Cameraswitch,
|
||||
contentDescription = stringResource(R.string.switch_camera),
|
||||
modifier = Modifier
|
||||
.size(32.dp)
|
||||
.padding(8.dp),
|
||||
tint = AccentColor
|
||||
.padding(8.dp)
|
||||
.autoRotate(),
|
||||
tint = Color.White.copy(
|
||||
alpha = if (cameraState.videoRecordingState.isRecording ||
|
||||
cameraState.videoRecordingState.isProcessing) 0.35f else 1f
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,12 +18,9 @@ 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
|
||||
@@ -57,8 +54,7 @@ fun ZoomControlBarVerticel(
|
||||
onZoomChange: (Float) -> Unit,
|
||||
onZoomStopClick: (Float) -> Unit,
|
||||
onLensSwitch: (String) -> Unit,
|
||||
onFilterClick: () -> Unit,
|
||||
onFilterButtonBoundsChanged: (Rect) -> Unit = {},
|
||||
onSwitchCameraClick: () -> Unit,
|
||||
modifier: Modifier = Modifier
|
||||
) {
|
||||
val displayMode by viewModel.zoomDisplayMode.collectAsState()
|
||||
@@ -236,22 +232,24 @@ fun ZoomControlBarVerticel(
|
||||
exit = fadeOut() + shrinkVertically(),
|
||||
modifier = Modifier.align(Alignment.BottomCenter)
|
||||
) {
|
||||
// 底部滤镜按钮
|
||||
// 底部前后摄像头切换按钮
|
||||
IconButton(
|
||||
onClick = onFilterClick,
|
||||
modifier = Modifier
|
||||
.size(32.dp)
|
||||
.onGloballyPositioned { coordinates ->
|
||||
onFilterButtonBoundsChanged(coordinates.boundsInRoot())
|
||||
}
|
||||
onClick = onSwitchCameraClick,
|
||||
enabled = !cameraState.videoRecordingState.isRecording &&
|
||||
!cameraState.videoRecordingState.isProcessing,
|
||||
modifier = Modifier.size(32.dp)
|
||||
) {
|
||||
Icon(
|
||||
imageVector = AppIcons.AutoAwesome,
|
||||
contentDescription = stringResource(R.string.filters_panel),
|
||||
imageVector = AppIcons.Cameraswitch,
|
||||
contentDescription = stringResource(R.string.switch_camera),
|
||||
modifier = Modifier.size(32.dp)
|
||||
.background(Color.Black.copy(alpha = 0.3f), CircleShape)
|
||||
.padding(8.dp),
|
||||
tint = AccentColor
|
||||
.padding(8.dp)
|
||||
.autoRotate(),
|
||||
tint = Color.White.copy(
|
||||
alpha = if (cameraState.videoRecordingState.isRecording ||
|
||||
cameraState.videoRecordingState.isProcessing) 0.35f else 1f
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -601,6 +601,32 @@ object AppIcons {
|
||||
}
|
||||
}
|
||||
|
||||
/** Three overlapping optical filters, drawn on the standard 24 dp icon grid. */
|
||||
val ColorFilters: ImageVector
|
||||
get() {
|
||||
_colorFilters?.let { return it }
|
||||
return ImageVector.Builder(
|
||||
name = "AppIcons.ColorFilters",
|
||||
defaultWidth = 24f.dp,
|
||||
defaultHeight = 24f.dp,
|
||||
viewportWidth = 24f,
|
||||
viewportHeight = 24f,
|
||||
).apply {
|
||||
addPath(
|
||||
pathData = addPathNodes(
|
||||
"M16.8,7.8a4.8,4.8 0,1 1,-9.6,0a4.8,4.8 0,1 1,9.6,0Z " +
|
||||
"M12.8,14.8a4.8,4.8 0,1 1,-9.6,0a4.8,4.8 0,1 1,9.6,0Z " +
|
||||
"M20.8,14.8a4.8,4.8 0,1 1,-9.6,0a4.8,4.8 0,1 1,9.6,0Z"
|
||||
),
|
||||
fill = null,
|
||||
stroke = SolidColor(Color.Black),
|
||||
strokeLineWidth = 1.8f,
|
||||
)
|
||||
}.build().also {
|
||||
_colorFilters = it
|
||||
}
|
||||
}
|
||||
|
||||
val FilterFrames: ImageVector
|
||||
get() {
|
||||
_filterFrames?.let { return it }
|
||||
@@ -1568,6 +1594,7 @@ private var _download: ImageVector? = null
|
||||
private var _dragHandle: ImageVector? = null
|
||||
private var _expandLess: ImageVector? = null
|
||||
private var _expandMore: ImageVector? = null
|
||||
private var _colorFilters: ImageVector? = null
|
||||
private var _filterFrames: ImageVector? = null
|
||||
private var _filterNone: ImageVector? = null
|
||||
private var _filterVintage: ImageVector? = null
|
||||
|
||||
Reference in new issue
Block a user