dash-frontend: tab titles, home screen username
This commit is contained in:
@@ -27,7 +27,13 @@
|
||||
<!-- left/right separator (menu and rest) -->
|
||||
<div flex_direction="row" gap="8" width="100%" height="100%">
|
||||
<!-- LEFT MENU -->
|
||||
<div id="menu" width="~size_size" min_width="~side_size" max_width="~side_size" height="100%" align_items="center" justify_content="center">
|
||||
<div id="menu"
|
||||
width="~size_size"
|
||||
min_width="~side_size"
|
||||
max_width="~side_size"
|
||||
height="100%"
|
||||
align_items="center"
|
||||
justify_content="center">
|
||||
<rectangle
|
||||
width="100%"
|
||||
round="100%"
|
||||
@@ -48,21 +54,34 @@
|
||||
</div>
|
||||
<!-- REST -->
|
||||
<!-- content/bottom panel separator -->
|
||||
<div flex_direction="column" gap="8" flex_grow="1">
|
||||
<div
|
||||
flex_direction="column"
|
||||
gap="8"
|
||||
width="100%"
|
||||
height="100%"
|
||||
overflow_x="scroll">
|
||||
<!-- CONTENT -->
|
||||
<rectangle
|
||||
color2="#0d131acc" color="#244179aa" gradient="vertical" round="8" overflow_y="hidden"
|
||||
justify_content="center"
|
||||
color2="#0d131acc"
|
||||
color="#244179aa"
|
||||
gradient="vertical"
|
||||
round="8"
|
||||
flex_grow="1"
|
||||
width="100%"
|
||||
overflow_y="scroll"
|
||||
>
|
||||
<div
|
||||
id="content"
|
||||
overflow_x="scroll"
|
||||
overflow_y="scroll"
|
||||
align_items="center"
|
||||
justify_content="center"
|
||||
flex_direction="column"
|
||||
gap="24"
|
||||
padding_top="8"
|
||||
padding_bottom="8"
|
||||
padding_left="16"
|
||||
padding_right="16"
|
||||
gap="8"
|
||||
width="100%"
|
||||
min_height="100%"
|
||||
>
|
||||
<!-- filled-in at runtime -->
|
||||
</div>
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
justify_content="center"
|
||||
flex_direction="column">
|
||||
<sprite src="${icon}" width="32" height="32" />
|
||||
<label weight="bold" size="18" text="${text}" />
|
||||
<label weight="bold" size="18" text="${text}" translation="${translation}" />
|
||||
</div>
|
||||
</Button>
|
||||
</template>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<layout>
|
||||
<include src="t_tab_title.xml" />
|
||||
|
||||
<elements>
|
||||
<label text="Apps" size="64" weight="bold" />
|
||||
<label text="bottom text" size="16" weight="bold" color="#FFFFFF88" />
|
||||
<TabTitle translation="APPLICATIONS" icon="dashboard/apps.svg" />
|
||||
</elements>
|
||||
</layout>
|
||||
@@ -1,5 +1,7 @@
|
||||
<layout>
|
||||
<include src="t_tab_title.xml" />
|
||||
|
||||
<elements>
|
||||
<label text="Games" size="32" weight="bold" />
|
||||
<TabTitle translation="GAMES" icon="dashboard/games.svg" />
|
||||
</elements>
|
||||
</layout>
|
||||
@@ -2,17 +2,23 @@
|
||||
<include src="../t_menu_button.xml" />
|
||||
|
||||
<elements>
|
||||
<sprite src="dashboard/wayvr_dashboard.svg" min_width="96" min_height="96" />
|
||||
<label text="Hello, user!" size="32" weight="bold" />
|
||||
<label text="Connected to wlx-overlay-s" size="16" weight="bold" color="#bbffbb" />
|
||||
<div
|
||||
flex_direction="column"
|
||||
justify_content="center"
|
||||
align_items="center"
|
||||
flex_grow="1"
|
||||
gap="24">
|
||||
<sprite src="dashboard/wayvr_dashboard.svg" width="96" height="96" />
|
||||
<label id="label_hello" size="32" weight="bold" />
|
||||
|
||||
<!-- main button list -->
|
||||
<div flex_direction="row" gap="8" margin_top="32">
|
||||
<MenuButton id="btn_apps" icon="dashboard/apps.svg" text="Apps" />
|
||||
<MenuButton id="btn_games" icon="dashboard/games.svg" text="Games" />
|
||||
<MenuButton id="btn_monado" icon="dashboard/monado.svg" text="Monado" />
|
||||
<MenuButton id="btn_processes" icon="dashboard/window.svg" text="Processes" />
|
||||
<MenuButton id="btn_settings" icon="dashboard/settings.svg" text="Settings" />
|
||||
<!-- main button list -->
|
||||
<div flex_direction="row" gap="8">
|
||||
<MenuButton id="btn_apps" icon="dashboard/apps.svg" translation="APPLICATIONS" />
|
||||
<MenuButton id="btn_games" icon="dashboard/games.svg" translation="GAMES" />
|
||||
<MenuButton id="btn_monado" icon="dashboard/monado.svg" text="Monado" />
|
||||
<MenuButton id="btn_processes" icon="dashboard/window.svg" translation="PROCESSES" />
|
||||
<MenuButton id="btn_settings" icon="dashboard/settings.svg" translation="SETTINGS" />
|
||||
</div>
|
||||
</div>
|
||||
</elements>
|
||||
</layout>
|
||||
@@ -1,5 +1,7 @@
|
||||
<layout>
|
||||
<include src="t_tab_title.xml" />
|
||||
|
||||
<elements>
|
||||
<label text="Monado" size="32" weight="bold" />
|
||||
<TabTitle translation="MONADO_RUNTIME" icon="dashboard/monado.svg" />
|
||||
</elements>
|
||||
</layout>
|
||||
@@ -1,5 +1,7 @@
|
||||
<layout>
|
||||
<include src="t_tab_title.xml" />
|
||||
|
||||
<elements>
|
||||
<label text="Processes" size="32" weight="bold" />
|
||||
<TabTitle translation="PROCESSES" icon="dashboard/window.svg" />
|
||||
</elements>
|
||||
</layout>
|
||||
@@ -1,5 +1,7 @@
|
||||
<layout>
|
||||
<include src="t_tab_title.xml" />
|
||||
|
||||
<elements>
|
||||
<label text="Settings" size="32" weight="bold" />
|
||||
<TabTitle translation="SETTINGS" icon="dashboard/settings.svg" />
|
||||
</elements>
|
||||
</layout>
|
||||
9
dash-frontend/assets/gui/tab/t_tab_title.xml
Normal file
9
dash-frontend/assets/gui/tab/t_tab_title.xml
Normal file
@@ -0,0 +1,9 @@
|
||||
<layout>
|
||||
<!-- translation, icon -->
|
||||
<template name="TabTitle">
|
||||
<div gap="8" align_items="center">
|
||||
<sprite src="${icon}" width="24" height="24" />
|
||||
<label translation="${translation}" size="18" weight="bold" />
|
||||
</div>
|
||||
</template>
|
||||
</layout>
|
||||
9
dash-frontend/assets/lang/de.json
Normal file
9
dash-frontend/assets/lang/de.json
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"HOME_SCREEN": "Startbildschirm",
|
||||
"MONADO_RUNTIME": "„Monado”-Laufzeitumgebung",
|
||||
"APPLICATIONS": "Anwendungen",
|
||||
"GAMES": "Spiele",
|
||||
"SETTINGS": "Einstellungen",
|
||||
"PROCESSES": "Prozesse",
|
||||
"HELLO_USER": "Hallo, {USER}!"
|
||||
}
|
||||
@@ -1 +1,9 @@
|
||||
{}
|
||||
{
|
||||
"HOME_SCREEN": "Home",
|
||||
"MONADO_RUNTIME": "„Monado” runtime",
|
||||
"APPLICATIONS": "Applications",
|
||||
"GAMES": "Games",
|
||||
"SETTINGS": "Settings",
|
||||
"PROCESSES": "Processes",
|
||||
"HELLO_USER": "Hello, {USER}!"
|
||||
}
|
||||
|
||||
9
dash-frontend/assets/lang/es.json
Normal file
9
dash-frontend/assets/lang/es.json
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"HOME_SCREEN": "Inicio",
|
||||
"MONADO_RUNTIME": "„Monado” tiempo de ejecución",
|
||||
"APPLICATIONS": "Aplicaciones",
|
||||
"GAMES": "Juegos",
|
||||
"SETTINGS": "Ajustes",
|
||||
"PROCESSES": "Procesos",
|
||||
"HELLO_USER": "¡Hola, {USER}!"
|
||||
}
|
||||
9
dash-frontend/assets/lang/ja.json
Normal file
9
dash-frontend/assets/lang/ja.json
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"HOME_SCREEN": "ホーム",
|
||||
"MONADO_RUNTIME": "「Monado」ランタイム",
|
||||
"APPLICATIONS": "アプリケーション",
|
||||
"GAMES": "ゲーム",
|
||||
"SETTINGS": "設定",
|
||||
"PROCESSES": "プロセス",
|
||||
"HELLO_USER": "こんにちは、{USER}!"
|
||||
}
|
||||
9
dash-frontend/assets/lang/pl.json
Normal file
9
dash-frontend/assets/lang/pl.json
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"HOME_SCREEN": "Ekran główny",
|
||||
"MONADO_RUNTIME": "„Monado” środowisko uruchomieniowe",
|
||||
"APPLICATIONS": "Aplikacje",
|
||||
"GAMES": "Gry",
|
||||
"SETTINGS": "Ustawienia",
|
||||
"PROCESSES": "Procesy",
|
||||
"HELLO_USER": "Witaj, {USER}!"
|
||||
}
|
||||
@@ -20,6 +20,7 @@ use crate::tab::{
|
||||
|
||||
mod assets;
|
||||
mod tab;
|
||||
mod various;
|
||||
|
||||
pub struct Frontend {
|
||||
pub layout: RcLayout,
|
||||
|
||||
@@ -1,9 +1,14 @@
|
||||
use wgui::{
|
||||
components::button::ComponentButton,
|
||||
i18n::Translation,
|
||||
parser::{ParseDocumentParams, ParserState},
|
||||
widget::label::WidgetLabel,
|
||||
};
|
||||
|
||||
use crate::tab::{Tab, TabParams, TabType};
|
||||
use crate::{
|
||||
tab::{Tab, TabParams, TabType},
|
||||
various,
|
||||
};
|
||||
|
||||
pub struct TabHome {
|
||||
#[allow(dead_code)]
|
||||
@@ -16,6 +21,18 @@ impl Tab for TabHome {
|
||||
}
|
||||
}
|
||||
|
||||
fn configure_label_hello(label_hello: &mut WidgetLabel, i18n: &mut wgui::i18n::I18n) {
|
||||
let mut username = various::get_username();
|
||||
// first character as uppercase
|
||||
if let Some(first) = username.chars().next() {
|
||||
let first = first.to_uppercase().to_string();
|
||||
username.replace_range(0..1, &first);
|
||||
}
|
||||
|
||||
let translated = i18n.translate_and_replace("HELLO_USER", ("{USER}", &username));
|
||||
label_hello.set_text_simple(i18n, Translation::from_raw_text(&translated));
|
||||
}
|
||||
|
||||
impl TabHome {
|
||||
pub fn new(params: TabParams) -> anyhow::Result<Self> {
|
||||
let state = wgui::parser::parse_from_assets(
|
||||
@@ -29,6 +46,9 @@ impl TabHome {
|
||||
params.parent_id,
|
||||
)?;
|
||||
|
||||
let mut label_hello = state.fetch_widget_as::<WidgetLabel>(¶ms.layout.state, "label_hello")?;
|
||||
configure_label_hello(&mut label_hello, &mut params.globals.i18n());
|
||||
|
||||
let btn_apps = state.fetch_component_as::<ComponentButton>("btn_apps")?;
|
||||
let btn_games = state.fetch_component_as::<ComponentButton>("btn_games")?;
|
||||
let btn_monado = state.fetch_component_as::<ComponentButton>("btn_monado")?;
|
||||
|
||||
6
dash-frontend/src/various.rs
Normal file
6
dash-frontend/src/various.rs
Normal file
@@ -0,0 +1,6 @@
|
||||
pub fn get_username() -> String {
|
||||
match std::env::var("USER") {
|
||||
Ok(user) => user,
|
||||
Err(_) => String::from("anonymous"),
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user