opt: move MMRL inset from js to css

This commit is contained in:
KOWX712
2025-03-25 13:31:53 +08:00
parent 1c93287b69
commit 6a26150e50
5 changed files with 16 additions and 24 deletions

View File

@@ -5,7 +5,6 @@
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>TrickyAddon</title> <title>TrickyAddon</title>
<link rel="stylesheet" type="text/css" href="/mmrl/insets.css" />
<link rel="stylesheet" href="styles/global.css" type="text/css"> <link rel="stylesheet" href="styles/global.css" type="text/css">
<link rel="stylesheet" href="styles/about.css" type="text/css"> <link rel="stylesheet" href="styles/about.css" type="text/css">
<link rel="stylesheet" href="styles/applist.css" type="text/css"> <link rel="stylesheet" href="styles/applist.css" type="text/css">

View File

@@ -124,11 +124,7 @@ export function showPrompt(key, isSuccess = true, duration = 3000) {
clearTimeout(window.promptTimeout); clearTimeout(window.promptTimeout);
} }
setTimeout(() => { setTimeout(() => {
if (typeof ksu !== 'undefined' && ksu.mmrl) { prompt.style.transform = 'translateY(calc((var(--window-inset-bottom, 0px) + 60%) * -1))';
prompt.style.transform = 'translateY(calc((var(--window-inset-bottom) + 60%) * -1))';
} else {
prompt.style.transform = 'translateY(-60%)';
}
window.promptTimeout = setTimeout(() => { window.promptTimeout = setTimeout(() => {
prompt.style.transform = 'translateY(100%)'; prompt.style.transform = 'translateY(100%)';
}, duration); }, duration);
@@ -227,12 +223,7 @@ async function uninstallWebUI() {
async function checkMMRL() { async function checkMMRL() {
if (typeof ksu !== 'undefined' && ksu.mmrl) { if (typeof ksu !== 'undefined' && ksu.mmrl) {
// Adjust elements position for MMRL // Adjust elements position for MMRL
title.style.top = 'var(--window-inset-top)';
const insetTop = getComputedStyle(document.documentElement).getPropertyValue('--window-inset-top');
const insetTopValue = parseInt(insetTop, 10);
searchMenuContainer.style.top = `${insetTopValue + 40}px`;
headerBlock.style.display = 'block'; headerBlock.style.display = 'block';
floatingCard.style.bottom = 'calc(var(--window-inset-bottom) + 50px)';
// Set status bars theme based on device theme // Set status bars theme based on device theme
try { try {
@@ -262,13 +253,8 @@ async function checkMMRL() {
// Funtion to adapt floating button hide in MMRL // Funtion to adapt floating button hide in MMRL
export function hideFloatingBtn(hide = true) { export function hideFloatingBtn(hide = true) {
if (!hide) { if (!hide) floatingCard.style.transform = 'translateY(0)';
floatingCard.style.transform = 'translateY(0)'; else floatingCard.style.transform = 'translateY(calc(var(--window-inset-bottom, 0px) + 120px))';
} else if (typeof ksu !== 'undefined' && ksu.mmrl) {
floatingCard.style.transform = 'translateY(calc(var(--window-inset-bottom) + 120px))';
} else {
floatingCard.style.transform = 'translateY(120px)';
}
} }
// Function to apply ripple effect // Function to apply ripple effect

View File

@@ -1,7 +1,14 @@
@import url('https://mui.kernelsu.org/mmrl/insets.css');
:root {
--top-inset: var(--window-inset-top, 0px);
--bottom-inset: var(--window-inset-bottom, 0px);
}
body { body {
background-color: #F5F5F5; background-color: #F5F5F5;
padding-top: var(--window-inset-top); padding-top: var(--top-inset);
padding-bottom: var(--window-inset-bottom); padding-bottom: var(--bottom-inset);
margin: 0; margin: 0;
} }
@@ -14,7 +21,7 @@ body {
justify-content: center; justify-content: center;
position: fixed; position: fixed;
width: 100%; width: 100%;
bottom: 50px; bottom: calc(var(--bottom-inset) + 50px);
transition: transform 0.4s ease; transition: transform 0.4s ease;
pointer-events: none; pointer-events: none;
z-index: 2; z-index: 2;

View File

@@ -3,7 +3,7 @@
align-items: center; align-items: center;
justify-content: space-between; justify-content: space-between;
position: fixed; position: fixed;
top: 0; top: var(--top-inset);
height: 40px; height: 40px;
width: calc(100% - 10px); width: calc(100% - 10px);
max-width: 1100px; max-width: 1100px;
@@ -26,7 +26,7 @@
width: 100%; width: 100%;
z-index: 1100; z-index: 1100;
transition: transform 0.4s ease; transition: transform 0.4s ease;
height: var(--window-inset-top); height: var(--top-inset);
} }
#module-version, #module-version,

View File

@@ -1,7 +1,7 @@
.search-menu-container { .search-menu-container {
display: flex; display: flex;
position: fixed; position: fixed;
top: 40px; top: calc(var(--top-inset) + 40px);
height: 50px; height: 50px;
width: calc(100% - 20px); width: calc(100% - 20px);
max-width: 1100px; max-width: 1100px;