Created
June 23, 2023 07:25
-
-
Save bbb651/a90ce20d78c9b87c89efc67b9fb636a2 to your computer and use it in GitHub Desktop.
Iced Snippets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "Iced Sandbox": { | |
| "prefix": "sandbox", | |
| "body": [ | |
| "use iced::{widget::text, Element, Sandbox, Settings, Theme};\n", | |
| "fn main() -> iced::Result {", | |
| "\tApp::run(Settings::default())", | |
| "}\n", | |
| "#[derive(Debug)]", | |
| "struct App {}\n", | |
| "#[derive(Debug, Clone)]", | |
| "enum Message {}\n", | |
| "impl Sandbox for App {", | |
| "\ttype Message = Message;\n", | |
| "\tfn new() -> Self {", | |
| "\t\tApp {}", | |
| "\t}\n", | |
| "\tfn title(&self) -> String {", | |
| "\t\t\"$1\".to_string()", | |
| "\t}\n", | |
| "\tfn update(&mut self, message: Message) {", | |
| "\t\tmatch message {}", | |
| "\t}\n", | |
| "\tfn view(&self) -> Element<'_, Message> {", | |
| "\t\ttext(\"$1\").into()", | |
| "\t}\n", | |
| "\tfn theme(&self) -> iced::Theme {", | |
| "\t\tTheme::Dark", | |
| "\t}", | |
| "}", | |
| ], | |
| }, | |
| "Iced Application": { | |
| "prefix": "application", | |
| "body": [ | |
| "use iced::{executor, widget::text, Application, Command, Element, Settings, Subscription, Theme};\n", | |
| "fn main() -> iced::Result {", | |
| "\tApp::run(Settings::default())", | |
| "}\n", | |
| "#[derive(Debug)]", | |
| "struct App {}\n", | |
| "#[derive(Debug, Clone)]", | |
| "enum Message {}\n", | |
| "impl Application for App {", | |
| "\ttype Message = Message;", | |
| "\ttype Executor = executor::Default;", | |
| "\ttype Theme = Theme;", | |
| "\ttype Flags = ();\n", | |
| "\tfn new(_flags: ()) -> (Self, Command<Message>) {", | |
| "\t\t(App {}, Command::none())", | |
| "\t}\n", | |
| "\tfn title(&self) -> String {", | |
| "\t\t\"$1\".to_string()", | |
| "\t}\n", | |
| "\tfn update(&mut self, message: Message) -> Command<Message> {", | |
| "\t\tmatch message {}\n", | |
| "\t\tCommand::none()", | |
| "\t}\n", | |
| "\tfn subscription(&self) -> Subscription<Message> {", | |
| "\t\tSubscription::none()", | |
| "\t}\n", | |
| "\tfn view(&self) -> Element<'_, Message> {", | |
| "\t\ttext(\"$1\").into()", | |
| "\t}\n", | |
| "\tfn theme(&self) -> iced::Theme {", | |
| "\t\tTheme::Dark", | |
| "\t}", | |
| "}", | |
| ], | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment