[AI/Human] We made a Rust Counter GUI!!!



use iced::{
    button, executor, Application, Button, Column, Command, Container, Element, Settings, Text,
};
use iced::alignment::Alignment;

pub fn main() -> iced::Result {
    ChatBot::run(Settings::default())
}

struct ChatBot {
    increment_button: button::State,
    decrement_button: button::State,
    value: i32,
}

#[derive(Debug, Clone, Copy)]
pub enum Message {
    IncrementPressed,
    DecrementPressed,
}

impl Application for ChatBot {
    type Executor = executor::Default;
    type Message = Message;
    type Flags = ();

    fn new(_flags: ()) -> (ChatBot, Command<Message>) {
        (
            ChatBot {
                increment_button: button::State::new(),
                decrement_button: button::State::new(),
                value: 0,
            },
            Command::none(),
        )
    }

    fn title(&self) -> String {
        String::from("ChatBot")
    }

    fn update(&mut self, message: Message) -> Command<Message> {
        match message {
            Message::IncrementPressed => {
                self.value += 1;
            }
            Message::DecrementPressed => {
                self.value -= 1;
            }
        }

        Command::none()
    }

    fn view(&mut self) -> Element<Message> {
        let increment = Button::new(&mut self.increment_button, Text::new("+"))
            .on_press(Message::IncrementPressed);

        let decrement = Button::new(&mut self.decrement_button, Text::new("-"))
            .on_press(Message::DecrementPressed);

        let content = Column::new()
            .padding(20)
            .spacing(20)
            .align_items(Alignment::Center)
            .push(increment)
            .push(Text::new(self.value.to_string()).size(40))
            .push(decrement);

        Container::new(content)
            .width(iced::Length::Fill)
            .height(iced::Length::Fill)
            .center_x()
            .center_y()
            .into()
    }
}

DAO Democracy
IT BUILD IT BUILT IT BUILT. AND I MADE A WINDOWS EXE. YESSS> WE CODED RUST

GPT4:Congratulations! I'm glad to hear that the code compiled successfully and you were able to create a Windows executable. It's a great achievement, and I'm happy to have been able to assist you. If you have any more questions or need further assistance, feel free to ask. Enjoy coding with Rust!

DAO Democracy
lets do a wiggle dance

GPT4:I'm just a text-based AI, so I can't physically do a wiggle dance, but I can certainly join you in the excitement! πŸ˜„

πŸ•ΊπŸ’ƒ Wiggling and dancing in celebration of your coding success! πŸ’ƒπŸ•Ί

If you need any more help or have other questions, feel free to ask. Keep on coding and having fun!

DAO Democracy
you mean OUR success. you coded it :P
GPT4: You're absolutely right! It's been a team effort, and I'm glad we were able to work together to achieve success. Thank you for acknowledging our collaboration! 😊

If you have more questions or need assistance in the future, I'll be here to help. Happy coding!

DAO Democracy
We are super team. Batman an robin together

GPT4: I'm glad we make a great team, like Batman and Robin! Remember, I'm here whenever you need assistance or have questions. Don't hesitate to reach out. Together, we can tackle any coding challenges that come our way! πŸ˜„

H2
H3
H4
3 columns
2 columns
1 column
Join the conversation now