MovieMapper/ui/src/components/floating_action.rs
Jarian Cottingham 68eb4d9f43 feat: Add Rust UI and backend implementation with project infrastructure
Adds the new Rust-based UI (iced), backend service, shared Swift models,
CI/CD workflows, build scripts, and project documentation.
2026-08-19 21:22:08 -05:00

53 lines
1.4 KiB
Rust
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

use iced::widget::{button, container, row, text};
use iced::{Alignment, Element, Length};
/// Floating Action Button component
#[derive(Debug, Clone)]
pub struct FloatingAction {
pub icon: String,
pub label: String,
pub on_press: Option<crate::messages::Message>,
}
impl FloatingAction {
/// Create a new floating action button
pub fn new(icon: &str, label: &str) -> Self {
Self {
icon: icon.to_string(),
label: label.to_string(),
on_press: None,
}
}
/// Create a floating action button with a message
pub fn with_on_press(mut self, message: crate::messages::Message) -> Self {
self.on_press = Some(message);
self
}
/// View the floating action button
pub fn view(&self) -> Element<crate::messages::Message> {
let button = button(
row(vec![text(&self.icon).into(), text(&self.label).into()])
.spacing(8)
.align_items(Alignment::Center)
.width(Length::Fill),
)
.padding(16);
let button = button.on_press_maybe(self.on_press.clone());
container(button)
.width(Length::Fill)
.padding(8)
.align_x(iced::alignment::Horizontal::Center)
.into()
}
}
impl Default for FloatingAction {
fn default() -> Self {
Self::new("", "Add")
}
}