Add Store support and unsigned app releases
This commit is contained in:
60
templates/rust-app/src/main.rs
Normal file
60
templates/rust-app/src/main.rs
Normal file
@@ -0,0 +1,60 @@
|
||||
//! A Fennec OS store app in Rust: full screen, driven by the remote.
|
||||
//!
|
||||
//! The Siri Remote arrives as keys: arrows, Enter (click), Escape (Back).
|
||||
//! Home is handled by the TV itself (the app is paused in the background).
|
||||
//! Files: $HOME is the app's own data folder and the only writable place
|
||||
//! that lasts; the app's own files are read-only in $SMARTFOX_APP_DIR (/app).
|
||||
|
||||
slint::slint! {
|
||||
export component Main inherits Window {
|
||||
in-out property <int> selected: 0;
|
||||
in-out property <int> clicks: 0;
|
||||
callback quit();
|
||||
property <[string]> items: ["Hello", "Fennec OS", "Rust"];
|
||||
background: #0b0d12;
|
||||
default-font-size: 40px;
|
||||
|
||||
FocusScope {
|
||||
key-pressed(event) => {
|
||||
if event.text == Key.LeftArrow { root.selected = max(0, root.selected - 1); return accept; }
|
||||
if event.text == Key.RightArrow { root.selected = min(root.items.length - 1, root.selected + 1); return accept; }
|
||||
if event.text == Key.Return { root.clicks += 1; return accept; }
|
||||
if event.text == Key.Escape { root.quit(); return accept; }
|
||||
reject
|
||||
}
|
||||
HorizontalLayout {
|
||||
alignment: center;
|
||||
spacing: 40px;
|
||||
for item[i] in root.items: Rectangle {
|
||||
width: 360px;
|
||||
height: 220px;
|
||||
y: (root.height - self.height) / 2;
|
||||
border-radius: 32px;
|
||||
background: i == root.selected ? #ffffff : #ffffff18;
|
||||
animate background { duration: 150ms; }
|
||||
Text {
|
||||
text: item;
|
||||
color: i == root.selected ? #121317 : #ffffff;
|
||||
font-weight: 700;
|
||||
}
|
||||
}
|
||||
}
|
||||
Text {
|
||||
y: root.height - 140px;
|
||||
text: "Enter: " + root.clicks + " · Back: exit";
|
||||
color: #ffffff99;
|
||||
font-size: 28px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() -> Result<(), slint::PlatformError> {
|
||||
let ui = Main::new()?;
|
||||
ui.window().set_fullscreen(true);
|
||||
// Back on the remote = Escape: leave the app (the launcher comes back).
|
||||
ui.on_quit(|| {
|
||||
let _ = slint::quit_event_loop();
|
||||
});
|
||||
ui.run()
|
||||
}
|
||||
Reference in New Issue
Block a user