Skip to content

[Fix] Camera Guide Text #71

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp

@OptIn(ExperimentalMaterial3ExpressiveApi::class)
Expand All @@ -33,10 +34,10 @@ fun CameraGuideText(
modifier: Modifier = Modifier,
) {
BasicText(
stringResource(R.string.camera_guide_text_label),
style = MaterialTheme.typography.bodyMediumEmphasized,
text = stringResource(R.string.camera_guide_text_label),
style = MaterialTheme.typography.bodyMediumEmphasized.copy(textAlign = TextAlign.Center),
autoSize = TextAutoSize.StepBased(maxFontSize = MaterialTheme.typography.bodyMediumEmphasized.fontSize),
maxLines = 1,
maxLines = 2,
modifier = modifier
.background(
MaterialTheme.colorScheme.surfaceContainerHighest,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.widthIn
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.material3.Button
Expand Down Expand Up @@ -247,12 +248,18 @@ fun StatelessCameraPreviewContent(
},
guideText = { guideTextModifier ->
AnimatedVisibility(
!detectedPose,
visible = !detectedPose,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Consider using visible = detectedPose.not() for better readability and consistency with other visibility toggles in this file.

            AnimatedVisibility(
                visible = !detectedPose,

enter = fadeIn(MaterialTheme.motionScheme.slowEffectsSpec()),
exit = fadeOut(MaterialTheme.motionScheme.slowEffectsSpec()),
modifier = guideTextModifier,
) {
CameraGuideText()
CameraGuideText(
modifier = Modifier.padding(
start = 10.dp,
end = 10.dp,
bottom = 10.dp,
),
)
}
},
guide = { guideModifier ->
Expand All @@ -263,12 +270,12 @@ fun StatelessCameraPreviewContent(
)
},
rearCameraButton = (
if (shouldShowRearCameraFeature()) {
rearCameraButton
} else {
emptyComposable
}
),
if (shouldShowRearCameraFeature()) {
rearCameraButton
} else {
emptyComposable
}
),
isTabletop = isTableTopPosture(foldingFeature),
modifier = modifier.onSizeChanged { size ->
if (size.height > 0) {
Expand Down Expand Up @@ -324,7 +331,8 @@ private fun CameraPreviewContent(
onScaleZoom = { scope.launch { zoomState.scaleZoom(it) } },
modifier = viewfinderModifier.onSizeChanged { size -> // Apply modifier from slot
if (size.height > 0) {
aspectRatio = calculateCorrectAspectRatio(size.height, size.width, aspectRatio)
aspectRatio =
calculateCorrectAspectRatio(size.height, size.width, aspectRatio)
}
},
)
Expand Down