use portaki_sdk::prelude::*;
use portaki_sdk::sdui::primitives::{Card, Field, FieldHint, Form, Page, Stack, TextInput};
use crate::config::ModuleConfig;
use crate::ids::HOST_MAIN;
#[portaki_sdk::surface(
host,
id = "main",
placement = HostPlacement::PropertyModuleSheet,
label_key = "nav.main",
icon = IconName::Grid
)]
pub fn render_host_main(ctx: HostContext) -> Result<Surface> {
let config = ModuleConfig::load(&ctx)?;
let children: Vec<Component> = vec![
Card::new()
.title("i18n:host.section.greeting")
.subtitle("i18n:host.section.greeting.help")
.children(vec![
Field::new()
.name("greeting")
.label("i18n:host.greeting.label")
.child(
TextInput::new()
.name("greeting")
.value(config.greeting)
.placeholder("i18n:host.greeting.placeholder"),
)
.into(),
FieldHint::new().text("i18n:host.greeting.hint").into(),
])
.into(),
];
Ok(Surface::new(
Page::new().child(Form::new().child(Stack::new().gap(16.0).children(children))),
)
.with_id(HOST_MAIN))
}