Yahor
04/05/2024, 2:58 PMChris Athanas
04/05/2024, 10:18 PMYahor
04/06/2024, 5:08 AMChris Athanas
04/06/2024, 5:45 AMYahor
04/06/2024, 5:55 AMI've even been able to create a simple fix for the screen orientation changes and pixel ratios. It's in my github.
Could you please share the link for fix?Chris Athanas
04/06/2024, 3:07 PM<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8"> <!-- note: no meta viewport tag here -->
<title>Compose App</title>
<script>
// Sets the viewport to the correct size for mobile devices
window.addEventListener("load", function(){ onLoad() } );
function onLoad() {
window.setTimeout(function() {
const meta = document.createElement('meta');
meta.name = "viewport";
meta.content = "width=" + (window.screen.width * window.devicePixelRatio) / 2 + ", initial-scale=1";
document.head.appendChild(meta);
}, 0);
}
</script>
...
from here: https://github.com/realityexpander/KMPMensAdventure/blob/5172de6c9d9db36517aae70516cdcdb5f071d8f7/composeApp/src/wasmJsMain/resources/index.html#L63
Note: this is a test application, this is a simple app to try out the compose-web alpha features.katz
04/06/2024, 7:06 PMYahor
04/07/2024, 6:57 PMChris Athanas
04/07/2024, 9:08 PMYahor
04/08/2024, 8:21 AMChris Athanas
04/11/2024, 9:11 PM<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script>
window.addEventListener("load", function(){ onLoad() } );
// Sets the viewport to the correct size for mobile devices
function onLoad() {
window.setTimeout(function() {
// Replace the default viewport for mobile with one that uses the devicePixelRatio
let meta = document.querySelector('meta[name="viewport"]')
meta.content = calcMetaViewportContent(innerWidth);
document.head.appendChild(meta);
}, 5);
}
screen.orientation.addEventListener("change", (event) => {
const type = event.target.type;
const angle = event.target.angle;
var calcWidth;
// Reset to default viewport for mobile
let meta = document.querySelector('meta[name="viewport"]')
meta.content = "width=device-width, initial-scale=1";
// Adjust the viewport for mobile after orientation change.
setTimeout(() => {
meta.content = calcMetaViewportContent();
}, 50);
});
function calcMetaViewportContent(actualWidth) {
var calcWidth;
if(actualWidth != undefined) {
calcWidth = actualWidth;
} else {
if (screen.orientation.type.includes("landscape")) {
calcWidth = screen.height;
} else {
calcWidth = screen.width;
}
}
return "width=" + ((calcWidth * window.devicePixelRatio)/2) + ", initial-scale=1.0";
}
</script>
<!-- Rest of your html -->
alorma
05/15/2024, 4:40 AMalorma
05/15/2024, 4:40 AMHayk Kerobyan
05/21/2024, 11:56 PMwindow.devicePixelRatio
, but even after replacing it with this function it still didn't work.
The website is: https://passaporteaupair.com/Alex Styl
05/22/2024, 5:45 AMHayk Kerobyan
05/22/2024, 5:54 PM2.0.0
• Added plugin org.jetbrains.kotlin.plugin.compose
• updated org.jetbrains.compose
to 1.6.10
• updated androidx.compose.ui:ui-tooling
to 1.6.7
Wrapped the UI into ComposeViewport
The results are as follows:
• Web browsers look good, as previously
• Android Emulator Chrome cuts the top and gets zoomed view of Web mode(However should show Mobile view)
• iOS phone shows Web mode but the bounds are correct
Given that I've got a check like this, it already doesn't make sense for me at all what can be the reason. Any ideas?
val screenWidth = with(LocalDensity.current) {
LocalWindowInfo.current.containerSize.width.toDp()
}
if(screenWidth< 840.dp){
LandingMobileMode(component)
}else{
LandingWebMode(component)
}
Source code: https://github.com/hayk-kerobyan/srcpassaporteaupairChris Athanas
05/24/2024, 2:29 AMwasm
target at some point.
I switched to the js
target, and it doesn’t have the same viewport sizing problem (as far as I can tell) and it also works on Safari browsers for desktop and iOS.