by Klonoar · 1w ago · 0 comments
use iced::widget::{column, *};
use iced::{Center, Color, Fill, Theme, border, color};
fn main() -> iced::Result {
iced::application(new, update, view)
.window_size((500, 500))
.run()
}
// fill in your state and message types as needed
pub type State = ();
pub type Message = ();
fn new() -> State {}
fn update(state: &mut State, message: Message) {}
fn view(state: &State) -> impl Widget<Message> {
let swatch = |c: Color| {
container("")
.width(32)
.height(32)
.style(move |theme| container::background(c))
};
let colors = [
color!(0xff0000),
color!(0x00ff00),
color!(0x0000ff),
color!(0xffff00),
Color::BLACK,
Color::WHITE,
];
container(
column![
text("Hello, World!").size(20).color(Color::WHITE),
row(colors.map(swatch)).spacing(8),
]
.spacing(12)
.align_x(Center),
)
.center(Fill)
.style(panel)
}
fn panel(theme: &Theme) -> container::Style {
container::background(color!(0x505050)).border(border::color(color!(0x0000ff)).width(1))
}
but you'll get warnings for unused variables