Files
OneCAD-Draft/src/ui/about.rs
T
Hakan SevenandClaude Opus 4.8 e6213eafbb feat(ui): shared in-canvas modal overlay; migrate About (Plan B)
Start Plan B — replace the daemon's pop-up OS windows with in-canvas
modal overlays so dialogs work identically on native (one main window)
and web (canvas only).

- New `ui::modal::modal(base, content, on_close)`: dims the view behind
  a backdrop that blocks clicks but does NOT dismiss, frames the content,
  and adds a top-right ✕ as the sole close affordance. Sizes to the
  content (no `Fill`), so dialogs shrink to fit.
- view_main stacks the active modal on top, so both run paths show it.
- Migrate About as the pilot: `about_open` bool + AboutOpen/AboutClose
  instead of an OS window; About's view shrinks to content.

Remaining dialogs migrate to the same pattern next. Native + 75 tests OK.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-16 18:59:13 +03:00

141 lines
3.2 KiB
Rust

use crate::app::Message;
use iced::widget::{button, column, container, row, text};
use iced::{Background, Border, Color, Element, Theme};
const BG: Color = Color {
r: 0.15,
g: 0.15,
b: 0.15,
a: 1.0,
};
const PANEL: Color = Color {
r: 0.12,
g: 0.12,
b: 0.12,
a: 1.0,
};
const BORDER: Color = Color {
r: 0.30,
g: 0.30,
b: 0.30,
a: 1.0,
};
const DIM: Color = Color {
r: 0.55,
g: 0.55,
b: 0.55,
a: 1.0,
};
const ACCENT: Color = Color {
r: 0.25,
g: 0.50,
b: 0.85,
a: 1.0,
};
const WHITE: Color = Color {
r: 0.92,
g: 0.92,
b: 0.92,
a: 1.0,
};
fn info_row<'a>(label: &'static str, value: String) -> Element<'a, Message> {
row![
text(label).size(11).color(DIM).width(100),
text(value).size(11).color(WHITE),
]
.spacing(8)
.align_y(iced::Center)
.padding([3, 0])
.into()
}
pub fn view_window<'a>() -> Element<'a, Message> {
let version = env!("CARGO_PKG_VERSION");
let os = std::env::consts::OS;
let arch = std::env::consts::ARCH;
let logo = container(
column![
text("Open CAD Studio").size(32).color(ACCENT),
text("CAD application for Architecture & Engineering")
.size(11)
.color(DIM),
]
.spacing(4)
.align_x(iced::Center),
)
.padding(iced::Padding {
top: 20.0,
right: 0.0,
bottom: 16.0,
left: 0.0,
})
.align_x(iced::Center);
let info_block = container(
column![
info_row("Version", format!("v{}", version)),
info_row("Platform", os.to_string()),
info_row("Arch", arch.to_string()),
]
.spacing(2)
.padding([12, 16]),
)
.style(|_: &Theme| container::Style {
background: Some(Background::Color(PANEL)),
border: Border {
color: BORDER,
width: 1.0,
radius: 4.0.into(),
},
..Default::default()
});
let copy_btn = button(text("Copy Info").size(11))
.on_press(Message::AboutCopyInfo)
.style(|_: &Theme, st| button::Style {
background: Some(Background::Color(match st {
button::Status::Hovered | button::Status::Pressed => Color {
r: 0.20,
g: 0.42,
b: 0.72,
a: 1.0,
},
_ => ACCENT,
})),
text_color: WHITE,
border: Border {
radius: 4.0.into(),
..Default::default()
},
..Default::default()
})
.padding([6, 16]);
let footer = row![copy_btn]
.align_y(iced::Center)
.padding(iced::Padding {
top: 12.0,
right: 0.0,
bottom: 0.0,
left: 0.0,
});
container(
column![logo, info_block, footer]
.spacing(0)
.padding(iced::Padding {
top: 0.0,
right: 20.0,
bottom: 20.0,
left: 20.0,
}),
)
.style(|_: &Theme| container::Style {
background: Some(Background::Color(BG)),
..Default::default()
})
.into()
}