Skip to content

Instantly share code, notes, and snippets.

@mtkennerly
Created July 18, 2022 15:43
Show Gist options
  • Save mtkennerly/f248f51b3f1c25622f63d5b6d94eb92d to your computer and use it in GitHub Desktop.
Save mtkennerly/f248f51b3f1c25622f63d5b6d94eb92d to your computer and use it in GitHub Desktop.
Iced 0.4.0 ignores `max_height`
[package]
name = "repro-max-height"
version = "0.1.0"
edition = "2021"
[dependencies]
iced = "0.4.0"
use iced::{Column, Container, Element, Length, Row, Sandbox, Settings, Text};
const LOREM_IPSUM: &'static str = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.";
fn lorem_ipsum() -> String {
LOREM_IPSUM.replace(" ", "\n")
}
pub fn main() -> iced::Result {
Demo::run(Settings::default())
}
struct Demo {}
#[derive(Debug, Clone)]
enum Message {}
impl Sandbox for Demo {
type Message = Message;
fn new() -> Self {
Demo {}
}
fn title(&self) -> String {
String::from("Repro - Iced")
}
fn update(&mut self, _message: Message) {}
fn view(&mut self) -> Element<Message> {
let content = Row::new()
.push(
Column::new()
.spacing(20)
.padding(20)
.push(Text::new("-height, -max"))
.push(Container::new(Text::new(lorem_ipsum())))
.push(Text::new("after")),
)
.push(
Column::new()
.spacing(20)
.padding(20)
.push(Text::new("+height, -max"))
.push(Container::new(Text::new(lorem_ipsum())).height(Length::Fill))
.push(Text::new("after")),
)
.push(
Column::new()
.spacing(20)
.padding(20)
.push(Text::new("-height, +max"))
.push(Container::new(Text::new(lorem_ipsum())).max_height(200))
.push(Text::new("after")),
)
.push(
Column::new()
.spacing(20)
.padding(20)
.push(Text::new("+height, +max"))
.push(
Container::new(Text::new(lorem_ipsum()))
.height(Length::Fill)
.max_height(200),
)
.push(Text::new("after")),
);
Container::new(content).into()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment