basic text

This commit is contained in:
Chris Cochrun 2025-08-11 05:57:33 -05:00
parent 79ae0dac0f
commit fd94f1dfa6

View file

@ -561,74 +561,66 @@ pub(crate) fn slide_view(
// text widget based // text widget based
let lines = slide_text.lines(); let lines = slide_text.lines();
let chars = lines
.map(|t| t.chars().map(|c| format!("{}\n", c)))
.collect();
let mut spans = vec![];
for c in chars {
spans.push(
span(format!("{}\n", c))
.size(font_size)
.font(font)
.background(
Background::Color(Color::BLACK)
.scale_alpha(0.4),
)
.border(border::rounded(10))
.padding(10),
)
}
let text: Vec<Element<Message>> = lines let text: Vec<Element<Message>> = lines
.map(|t| { .map(|t| {
let chars = t rich_text([span(format!("{}\n", t))
.chars()
.map(|c| {
span(format!("{}\n", c))
.size(font_size)
.font(font)
.background( .background(
Background::Color(Color::BLACK) Background::Color(Color::BLACK)
.scale_alpha(0.4), .scale_alpha(0.4),
) )
.border(border::rounded(10)) .border(border::rounded(10))
.padding(10) .padding(10)])
}) .size(font_size)
.collect(); .font(font)
rich_text(chars).center().into() .center()
.into()
// let chars: Vec<Span> = t
// .chars()
// .map(|c| -> Span {
// let character: String = format!("{}/n", c);
// span(character)
// .size(font_size)
// .font(font)
// .background(
// Background::Color(Color::BLACK)
// .scale_alpha(0.4),
// )
// .border(border::rounded(10))
// .padding(10)
}) })
.collect(); .collect();
let text = Column::with_children(text).spacing(26); let text = Column::with_children(text).spacing(26);
let lines = slide_text.lines(); // let lines = slide_text.lines();
let stroke_text: Vec<Element<Message>> = lines // let stroke_text: Vec<Element<Message>> = lines
.map(|t| { // .map(|t| {
let mut stroke_font = font.clone(); // let mut stroke_font = font.clone();
stroke_font.stretch = Stretch::Condensed; // stroke_font.stretch = Stretch::Condensed;
stroke_font.weight = Weight::Bold; // stroke_font.weight = Weight::Bold;
rich_text([span(format!("{}\n", t)) // rich_text([span(format!("{}\n", t))
.size(font_size + 0.3) // .size(font_size + 0.3)
.font(stroke_font) // .font(stroke_font)
.color(Color::BLACK) // .color(Color::BLACK)
.border(border::rounded(10)) // .border(border::rounded(10))
.padding(10)]) // .padding(10)])
.center() // .center()
.into() // .into()
}) // })
.collect(); // .collect();
let stroke_text = // let stroke_text =
Column::with_children(stroke_text).spacing(26); // Column::with_children(stroke_text).spacing(26);
//Next //Next
let text_container = Container::new(text) let text_container = Container::new(text)
.center(Length::Fill) .center(Length::Fill)
.align_x(Horizontal::Left); .align_x(Horizontal::Left);
let stroke_text_container = Container::new(stroke_text) // let stroke_text_container = Container::new(stroke_text)
.center(Length::Fill) // .center(Length::Fill)
.align_x(Horizontal::Left); // .align_x(Horizontal::Left);
let text_stack = // let text_stack =
stack!(stroke_text_container, text_container); // stack!(stroke_text_container, text_container);
let black = Container::new(Space::new(0, 0)) let black = Container::new(Space::new(0, 0))
.style(|_| { .style(|_| {
container::background(Background::Color(Color::BLACK)) container::background(Background::Color(Color::BLACK))
@ -685,8 +677,11 @@ pub(crate) fn slide_view(
} }
} }
}; };
let stack = let stack = stack!(
stack!(black, container.center(Length::Fill), text_stack); black,
container.center(Length::Fill),
text_container
);
Container::new(stack).center(Length::Fill).into() Container::new(stack).center(Length::Fill).into()
}) })
.into() .into()