Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Camera update: icons rotation #26

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalLifecycleOwner
import androidx.compose.ui.unit.dp
Expand Down Expand Up @@ -209,12 +210,13 @@ fun Camera(
horizontalAlignment = Alignment.CenterHorizontally,
) {
Row(
modifier = Modifier.fillMaxWidth(),
modifier = Modifier.fillMaxWidth().height(100.dp),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.Center,
) {
CameraControls(
captureMode,
rotation,
{ setCaptureMode(CaptureMode.PHOTO) },
{ setCaptureMode(CaptureMode.VIDEO_READY) },
)
Expand Down Expand Up @@ -276,12 +278,13 @@ fun Camera(
.fillMaxWidth()
.padding(0.dp, 5.dp, 0.dp, 5.dp)
.background(Color.Black)
.height(50.dp),
.height(100.dp),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.Center,
) {
CameraControls(
captureMode,
rotation,
{ setCaptureMode(CaptureMode.PHOTO) },
{ setCaptureMode(CaptureMode.VIDEO_READY) },
)
Expand Down Expand Up @@ -316,21 +319,21 @@ fun Camera(
}

@Composable
fun CameraControls(captureMode: CaptureMode, onPhotoButtonClick: () -> Unit, onVideoButtonClick: () -> Unit) {
fun CameraControls(captureMode: CaptureMode, rotation: Int, onPhotoButtonClick: () -> Unit, onVideoButtonClick: () -> Unit) {
val activeButtonColor =
ButtonDefaults.buttonColors(containerColor = MaterialTheme.colorScheme.primary)
val inactiveButtonColor =
ButtonDefaults.buttonColors(containerColor = Color.LightGray)
if (captureMode != CaptureMode.VIDEO_RECORDING) {
Button(
modifier = Modifier.padding(5.dp),
modifier = Modifier.padding(5.dp).graphicsLayer(rotationZ = rotation.toFloat() * 90),
onClick = onPhotoButtonClick,
colors = if (captureMode == CaptureMode.PHOTO) activeButtonColor else inactiveButtonColor,
) {
Text("Photo")
}
Button(
modifier = Modifier.padding(5.dp),
modifier = Modifier.padding(5.dp).graphicsLayer(rotationZ = rotation.toFloat() * 90),
onClick = onVideoButtonClick,
colors = if (captureMode != CaptureMode.PHOTO) activeButtonColor else inactiveButtonColor,
) {
Expand Down