Skip to content

Commit

Permalink
make content crop possible
Browse files Browse the repository at this point in the history
  • Loading branch information
theScrabi committed Nov 1, 2024
1 parent 9d68cad commit e15f1d9
Showing 1 changed file with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,16 @@ import androidx.compose.foundation.layout.aspectRatio
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.wrapContentHeight
import androidx.compose.foundation.layout.wrapContentWidth
import androidx.compose.material3.Surface
import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
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.platform.LocalContext
Expand Down Expand Up @@ -83,9 +86,21 @@ internal fun PlaySurface(
ActualView(modifier.fillMaxSize(), player)
} else { /* if(fitMode == ContentScale.CROP) */
if (uiRatio <= contentRatio) {
ActualView(modifier.fillMaxHeight(), player)
Box(
modifier = Modifier
.fillMaxSize()
.wrapContentWidth(unbounded = true, align = Alignment.CenterHorizontally)
) {
ActualView(modifier.fillMaxHeight(), player)
}
} else {
ActualView(modifier.fillMaxWidth(), player)
Box(
modifier = Modifier
.fillMaxSize()
.wrapContentHeight(unbounded = true, align = Alignment.CenterVertically)
) {
ActualView(modifier.fillMaxWidth(), player)
}
}
}
}
Expand Down

0 comments on commit e15f1d9

Please sign in to comment.