#[path = "support/mod.rs"]
mod support;
use embedded_graphics::{
image::{ImageRaw, ImageRawBE},
pixelcolor::Rgb565,
prelude::{Point, RgbColor, Size},
primitives::Rectangle,
};
use faststep::{
EdgeInsets, ImageAlignment, ImageView, ImageViewStyle, RichTextView, TextAlignment,
TextRunStyle, TextSpan, TextVerticalAlignment, TextView, TextViewStyle, TextWrap,
};
fn main() {
let mut canvas = support::NullCanvas::new(Size::new(320, 240));
let image_data = [
0xF8, 0x00, 0x07, 0xE0, 0x07, 0xE0, 0xF8, 0x00, ];
let image: ImageRawBE<Rgb565> = ImageRaw::new(&image_data, 2);
ImageView::new(
Rectangle::new(Point::new(16, 16), Size::new(72, 72)),
&image,
)
.with_style(
ImageViewStyle::new()
.with_alignment(ImageAlignment::Center)
.with_insets(EdgeInsets::all(8))
.with_background(Rgb565::new(28, 58, 28))
.with_border(Rgb565::new(20, 44, 20), 2)
.with_corner_radius(12),
)
.draw(&mut canvas);
TextView::new(
Rectangle::new(Point::new(104, 18), Size::new(192, 28)),
"Faststep",
TextRunStyle::title(Rgb565::BLACK),
)
.with_view_style(
TextViewStyle::new()
.with_alignment(TextAlignment::Leading)
.with_vertical_alignment(TextVerticalAlignment::Center),
)
.draw(&mut canvas);
let spans = [
TextSpan::new("UIKit-like ", TextRunStyle::body(Rgb565::BLACK)),
TextSpan::new("embedded UI", TextRunStyle::body_strong(Rgb565::BLUE)),
TextSpan::new(
"\nfor devices and simulators",
TextRunStyle::caption(Rgb565::GREEN),
),
];
RichTextView::new(
Rectangle::new(Point::new(104, 58), Size::new(192, 72)),
&spans,
)
.with_view_style(
TextViewStyle::new()
.with_wrap(TextWrap::Multiline)
.with_insets(EdgeInsets::all(4)),
)
.draw(&mut canvas);
}