#how does the alignment and aling_items work in iced

2 messages · Page 1 of 1 (latest)

austere trout
#

use iced::{
    alignment, element, sandbox, settings,
};

use iced::widget::{
    button, column, container, row
};

use iced::theme::theme;

pub fn main() -> iced::result {
    styling::run(settings::default())
}

#[derive(default)]
struct styling {
    theme: theme,
    is_dark: bool,
}

#[derive(debug, clone)]
enum message {
    buttonpressed,
}

impl sandbox for styling {
    type message = message;

    fn new() -> self {
        styling {
            theme: theme::dark,
            is_dark: true,
        }
    }

    fn title(&self) -> string {
        string::from("iced mp4->mp3 converter")
    }

    fn update(&mut self, message: message) {
        match message {
            message::buttonpressed => {
                self.is_dark = !self.is_dark;
                self.theme = if self.is_dark {
                    theme::dark
                } else {
                    theme::light
                };
            }
        }
    }

    fn view(&self) -> element<message> {
        let button = button::button::new("toggle theme")
            .padding(10)
            .on_press(message::buttonpressed);

        let content = column![row![button].align_items(alignment::center)];

        container(content).into()
    }

    fn theme(&self) -> theme {
        self.theme.clone()
    }
}


I am creating a hello world in iced where I want to move to the other corner of the screen my button, also how do I make this button appear in windowed as well as full screen, right now only is being seen in fullscreen

also Another question is how do I add a text_input ? I know iced has multiple examples of how to do this but im still confused about this