Show custom touch layout's author name in toast message

This commit is contained in:
redphx
2024-05-08 17:04:14 +07:00
parent d8fada8f5d
commit 26bf14eda6
8 changed files with 65 additions and 18 deletions

View File

@@ -393,7 +393,7 @@ export class MkbHandler {
}),
CE('div', {},
CE('p', {}, t('mkb-click-to-activate')),
CE('p', {}, t<any>('press-key-to-toggle-mkb')({key: 'F8'})),
CE('p', {}, t('press-key-to-toggle-mkb', {key: 'F8'})),
),
);

View File

@@ -1,5 +1,5 @@
import { STATES } from "@utils/global";
import { CE } from "@utils/html";
import { CE, escapeHtml } from "@utils/html";
import { Toast } from "@utils/toast";
import { BxEvent } from "@utils/bx-event";
import { BX_FLAGS } from "@utils/bx-flags";
@@ -168,7 +168,17 @@ export class TouchController {
}
// Show a toast with layout's name
layoutChanged && Toast.show(t('touch-control-layout'), layout.name);
let msg: string;
let html = false;
if (layout.author) {
const author = `<b>${escapeHtml(layout.author)}</b>`;
msg = t('touch-control-layout-by', {name: author});
html = true;
} else {
msg = t('touch-control-layout');
}
layoutChanged && Toast.show(msg, layout.name, {html: html});
window.setTimeout(() => {
window.BX_EXPOSED.touch_layout_manager.changeLayoutForScope({

View File

@@ -217,7 +217,14 @@ function setupQuickSettingsBar() {
for (const key in data.layouts) {
const layout = data.layouts[key];
const $option = CE('option', {value: key}, layout.name);
let name;
if (layout.author) {
name = `${layout.name} (${layout.author})`;
} else {
name = layout.name;
}
const $option = CE('option', {value: key}, name);
$fragment.appendChild($option);
}