Skip to content

Commit

Permalink
make aspect ratio not be out of place in embedded view
Browse files Browse the repository at this point in the history
  • Loading branch information
theScrabi committed Nov 1, 2024
1 parent c5ae059 commit 127ae66
Showing 1 changed file with 28 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,33 +75,39 @@ internal fun PlaySurface(

// actual calculation of the aspect ratio

if (uiState.uiMode.fullscreen && fitMode == ContentScale.STRETCHED)
ActualView(modifier.fillMaxSize(), player)
else {
val modifier = modifier.aspectRatio(contentRatio)
if (fitMode == ContentScale.FIT_INSIDE) {
if(!uiState.uiMode.fullscreen) {
ActualView(modifier.fillMaxHeight().aspectRatio(contentRatio), player)
} else {
if (fitMode == ContentScale.STRETCHED) {
ActualView(modifier.fillMaxSize(), player)
} else { /* if(fitMode == ContentScale.CROP) */
if (uiRatio <= contentRatio) {
Box(
modifier = Modifier
.fillMaxSize()
.wrapContentWidth(unbounded = true, align = Alignment.CenterHorizontally)
) {
ActualView(modifier.fillMaxHeight(), player)
}
} else {
Box(
modifier = Modifier
.fillMaxSize()
.wrapContentHeight(unbounded = true, align = Alignment.CenterVertically)
) {
ActualView(modifier.fillMaxWidth(), player)
} else {
val modifier = modifier.aspectRatio(contentRatio)
if (fitMode == ContentScale.FIT_INSIDE) {
ActualView(modifier.fillMaxSize(), player)
} else { /* if(fitMode == ContentScale.CROP) */
if (uiRatio <= contentRatio) {
Box(
modifier = Modifier
.fillMaxSize()
.wrapContentWidth(
unbounded = true,
align = Alignment.CenterHorizontally
)
) {
ActualView(modifier.fillMaxHeight(), player)
}
} else {
Box(
modifier = Modifier
.fillMaxSize()
.wrapContentHeight(unbounded = true, align = Alignment.CenterVertically)
) {
ActualView(modifier.fillMaxWidth(), player)
}
}
}
}
}

}

@Composable
Expand Down

0 comments on commit 127ae66

Please sign in to comment.