feat: ui optimize

This commit is contained in:
zhoubinjia committed 2026-07-28 14:09:04 +08:00
1 parent b6b4ddb323
commit 4329750ce3
5 files changed
+44 -21

No files matched your search

@@ -3,6 +3,7 @@ package com.hinnka.mycamera.ui.camera
import android.hardware.camera2.CameraMetadata
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
@@ -31,7 +32,7 @@ fun CameraParameterBar(
Row(
modifier = modifier
.fillMaxWidth()
.padding(start = 16.dp, top = 4.dp, end = 16.dp),
.padding(start = 16.dp, top = 12.dp, end = 16.dp),
horizontalArrangement = Arrangement.SpaceBetween,
verticalAlignment = Alignment.CenterVertically
) {
@@ -79,11 +80,11 @@ fun ParameterItem(
) {
PhysicalButton(
modifier = modifier
.width(if (vertical) 40.dp else 60.dp)
.height(if (vertical) 60.dp else 40.dp),
.width(if (vertical) 32.dp else 56.dp)
.height(if (vertical) 56.dp else 32.dp),
onClick = onClick,
enabled = isEnabled,
shape = RoundedCornerShape(18.dp)
shape = RoundedCornerShape(8.dp)
) {
Box(
modifier = Modifier.fillMaxSize(),
@@ -139,12 +140,12 @@ fun CameraParameterValuesOverlay(
Row(
modifier = Modifier.fillMaxSize(),
horizontalArrangement = Arrangement.SpaceEvenly,
verticalAlignment = Alignment.CenterVertically
) {
values.forEach { item ->
Row(
modifier = Modifier.weight(1f),
horizontalArrangement = Arrangement.Center,
horizontalArrangement = Arrangement.Start,
verticalAlignment = Alignment.CenterVertically
) {
if (showLabels) {
@@ -5,6 +5,7 @@ import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.icons.Icons
@@ -23,6 +24,7 @@ import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.hinnka.mycamera.R
import com.hinnka.mycamera.ui.components.PhysicalButton
import com.hinnka.mycamera.video.CaptureMode
import com.hinnka.mycamera.video.QuickShotCapabilities
import com.hinnka.mycamera.video.QuickShotConfig
@@ -95,11 +97,14 @@ fun CameraTopBar(
Row(
modifier = modifier
.fillMaxWidth()
.padding(top = 32.dp),
horizontalArrangement = Arrangement.SpaceBetween,
.padding(top = 32.dp, bottom = 8.dp),
horizontalArrangement = Arrangement.SpaceEvenly,
verticalAlignment = Alignment.CenterVertically
) {
IconButton(onClick = onFlashToggle) {
PhysicalButton(
modifier = Modifier.size(36.dp),
onClick = onFlashToggle
) {
Icon(
imageVector = when (flashMode) {
0 -> AppIcons.FlashOff
@@ -113,7 +118,10 @@ fun CameraTopBar(
)
}
IconButton(onClick = onTimerToggle) {
PhysicalButton(
modifier = Modifier.size(36.dp),
onClick = onTimerToggle
) {
if (timerSeconds > 0) {
Text(
text = "${timerSeconds}s",
@@ -132,7 +140,10 @@ fun CameraTopBar(
}
}
IconButton(onClick = onLivePhotoToggle) {
PhysicalButton(
modifier = Modifier.size(36.dp),
onClick = onLivePhotoToggle
) {
Icon(
painterResource(R.drawable.ic_live_photo),
contentDescription = stringResource(R.string.settings_use_live_photo),
@@ -141,7 +152,10 @@ fun CameraTopBar(
)
}
IconButton(onClick = onHistogramToggle) {
PhysicalButton(
modifier = Modifier.size(36.dp),
onClick = onHistogramToggle
) {
Icon(
imageVector = AppIcons.BarChart,
contentDescription = stringResource(R.string.histogram),
@@ -150,7 +164,10 @@ fun CameraTopBar(
)
}
IconButton(onClick = onSettingsClick) {
PhysicalButton(
modifier = Modifier.size(36.dp),
onClick = onSettingsClick
) {
Icon(
imageVector = Icons.Default.Settings,
contentDescription = stringResource(R.string.settings),
@@ -34,12 +34,15 @@ fun GalleryThumbnail(
) {
val context = LocalContext.current
val refreshKey = latestPhoto?.id?.let { viewModel.getPreparedPhotoThumbnailRefreshKey(it) } ?: 0L
val buttonShape = RoundedCornerShape(10.dp)
val thumbnailShape = RoundedCornerShape(7.dp)
PhysicalButton(
modifier = modifier
.size(48.dp),
onClick = onClick,
shape = RoundedCornerShape(10.dp)
shape = buttonShape,
contentShape = thumbnailShape
) {
if (latestPhoto != null) {
AsyncImage(
@@ -11,6 +11,7 @@ import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.BoxScope
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
@@ -119,7 +120,7 @@ object PhysicalButtonDefaults {
*/
@Composable
fun PhysicalButton(
modifier: Modifier = Modifier,
modifier: Modifier = Modifier.size(48.dp),
onClick: (() -> Unit)? = null,
enabled: Boolean = true,
shape: Shape = CircleShape,
@@ -127,6 +128,7 @@ fun PhysicalButton(
highlightBorderWidth: Dp = 1.dp,
backgroundBrush: Brush = PhysicalButtonDefaults.backgroundBrush(enabled),
contentAlignment: Alignment = Alignment.Center,
contentShape: Shape = shape,
content: @Composable BoxScope.() -> Unit
) {
val orientationDegrees = OrientationObserver.continuousOrientationDegrees
@@ -177,7 +179,7 @@ fun PhysicalButton(
modifier = Modifier
.fillMaxSize()
.padding(outerBorderWidth + highlightBorderWidth)
.clip(shape),
.clip(contentShape),
contentAlignment = contentAlignment,
content = content
)
@@ -133,8 +133,8 @@ fun CropEditPanel(
modifier = Modifier.weight(1f),
contentPadding = PaddingValues(horizontal = 8.dp),
colors = ButtonDefaults.filledTonalButtonColors(
containerColor = Color.White.copy(alpha = 0.08f),
contentColor = Color.White
containerColor = Color.White.copy(alpha = 0.05f),
contentColor = Color.White.copy(alpha = 0.6f)
)
) {
Icon(
@@ -153,9 +153,9 @@ fun CropEditPanel(
containerColor = if (isHorizontallyMirrored) {
AccentOrange.copy(alpha = 0.18f)
} else {
Color.White.copy(alpha = 0.08f)
Color.White.copy(alpha = 0.05f)
},
contentColor = if (isHorizontallyMirrored) AccentOrange else Color.White
contentColor = if (isHorizontallyMirrored) AccentOrange else Color.White.copy(0.6f)
)
) {
Icon(