forked from 1b-agent/opencadstudio-upstream
feat(ui): refine about dialog
Use intrinsic modal sizing and present platform details in a balanced layout.\n\nRefs #450
This commit is contained in:
1 parent
2f86bfde8e
commit
429d2eb06b
3 files changed
+128
-77
No files matched your search
@@ -5006,8 +5006,8 @@ impl OpenCADStudio {
|
|||||||
let info = format!(
|
let info = format!(
|
||||||
"Open CAD Studio v{}\nOS: {}\nArch: {}",
|
"Open CAD Studio v{}\nOS: {}\nArch: {}",
|
||||||
env!("CARGO_PKG_VERSION"),
|
env!("CARGO_PKG_VERSION"),
|
||||||
std::env::consts::OS,
|
crate::ui::window::about::platform_name(),
|
||||||
std::env::consts::ARCH,
|
crate::ui::window::about::architecture_name(),
|
||||||
);
|
);
|
||||||
iced::clipboard::write(info).discard()
|
iced::clipboard::write(info).discard()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,12 +54,9 @@ impl OpenCADStudio {
|
|||||||
pub(super) fn modal_content<'s>(&'s self) -> Option<Element<'s, Message>> {
|
pub(super) fn modal_content<'s>(&'s self) -> Option<Element<'s, Message>> {
|
||||||
let ex = self.modal_resize;
|
let ex = self.modal_resize;
|
||||||
Some(match self.active_modal? {
|
Some(match self.active_modal? {
|
||||||
super::super::ModalKind::About => automatic_flow(ex, |flow| {
|
super::super::ModalKind::About => {
|
||||||
container(crate::ui::window::about::view_window())
|
automatic_flow(ex, crate::ui::window::about::view_window)
|
||||||
.width(flow.width)
|
}
|
||||||
.height(flow.height)
|
|
||||||
.into()
|
|
||||||
}),
|
|
||||||
super::super::ModalKind::Shortcuts => {
|
super::super::ModalKind::Shortcuts => {
|
||||||
sized_flow(
|
sized_flow(
|
||||||
ex,
|
ex,
|
||||||
|
|||||||
+123
-69
@@ -1,91 +1,145 @@
|
|||||||
use crate::app::Message;
|
use crate::app::Message;
|
||||||
use iced::widget::{button, column, container, row, text};
|
|
||||||
use iced::{Background, Element, Theme};
|
|
||||||
use crate::t;
|
use crate::t;
|
||||||
|
use iced::widget::{button, column, container, row, svg, text, Space};
|
||||||
|
use iced::{Background, Border, Element, Fill, Length, Shrink, Theme};
|
||||||
|
|
||||||
fn info_row<'a>(
|
fn muted_style(theme: &Theme) -> iced::widget::text::Style {
|
||||||
|
iced::widget::text::Style {
|
||||||
|
color: Some(theme.palette().background.base.text.scale_alpha(0.68)),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn primary_style(theme: &Theme) -> iced::widget::text::Style {
|
||||||
|
iced::widget::text::Style {
|
||||||
|
color: Some(theme.palette().primary.base.color),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn surface_style(theme: &Theme) -> container::Style {
|
||||||
|
container::Style {
|
||||||
|
background: Some(Background::Color(
|
||||||
|
theme.palette().background.weakest.color,
|
||||||
|
)),
|
||||||
|
border: Border {
|
||||||
|
color: theme.palette().background.neutral.color,
|
||||||
|
width: 1.0,
|
||||||
|
radius: 8.0.into(),
|
||||||
|
},
|
||||||
|
..Default::default()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn info_card<'a>(
|
||||||
label: std::borrow::Cow<'static, str>,
|
label: std::borrow::Cow<'static, str>,
|
||||||
value: String,
|
value: impl iced::widget::text::IntoFragment<'a>,
|
||||||
|
width: Length,
|
||||||
) -> Element<'a, Message> {
|
) -> Element<'a, Message> {
|
||||||
row![
|
container(
|
||||||
text(label)
|
column![
|
||||||
.size(11)
|
text(label).size(10).style(muted_style),
|
||||||
.style(|theme: &Theme| iced::widget::text::Style {
|
text(value).size(14),
|
||||||
color: Some(theme.palette().background.base.text.scale_alpha(0.68)),
|
]
|
||||||
})
|
.spacing(5),
|
||||||
.width(100),
|
)
|
||||||
text(value).size(11),
|
.padding([10, 12])
|
||||||
]
|
.width(width)
|
||||||
.spacing(8)
|
.height(Length::Fixed(62.0))
|
||||||
.align_y(iced::Center)
|
.style(surface_style)
|
||||||
.padding([3, 0])
|
|
||||||
.into()
|
.into()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn view_window<'a>() -> Element<'a, Message> {
|
pub(crate) fn platform_name() -> &'static str {
|
||||||
let version = env!("CARGO_PKG_VERSION");
|
#[cfg(target_arch = "wasm32")]
|
||||||
let os = std::env::consts::OS;
|
{
|
||||||
let arch = std::env::consts::ARCH;
|
"Web"
|
||||||
|
}
|
||||||
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
|
{
|
||||||
|
match std::env::consts::OS {
|
||||||
|
"linux" => "Linux",
|
||||||
|
"windows" => "Windows",
|
||||||
|
"macos" => "macOS",
|
||||||
|
other => other,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let logo = container(
|
pub(crate) fn architecture_name() -> &'static str {
|
||||||
column![
|
match std::env::consts::ARCH {
|
||||||
text("Open CAD Studio")
|
"x86_64" => "x86-64",
|
||||||
.size(32)
|
"aarch64" => "ARM64",
|
||||||
.style(|theme: &Theme| iced::widget::text::Style {
|
"wasm32" => "WebAssembly 32-bit",
|
||||||
color: Some(theme.palette().primary.base.color),
|
other => other,
|
||||||
}),
|
}
|
||||||
text(t!("CAD application for Architecture & Engineering"))
|
}
|
||||||
.size(11)
|
|
||||||
.style(|theme: &Theme| iced::widget::text::Style {
|
pub fn view_window(
|
||||||
color: Some(theme.palette().background.base.text.scale_alpha(0.68)),
|
sizing: crate::ui::modal::ModalSizing,
|
||||||
}),
|
) -> Element<'static, Message> {
|
||||||
|
let version = format!("v{}", env!("CARGO_PKG_VERSION"));
|
||||||
|
let content_width = if matches!(sizing.width, Length::Fill) {
|
||||||
|
Fill
|
||||||
|
} else {
|
||||||
|
Shrink
|
||||||
|
};
|
||||||
|
let card_width = if matches!(sizing.width, Length::Fill) {
|
||||||
|
Length::FillPortion(1)
|
||||||
|
} else {
|
||||||
|
Length::Fixed(148.0)
|
||||||
|
};
|
||||||
|
let logo = svg(svg::Handle::from_memory(include_bytes!(
|
||||||
|
"../../../assets/logo.svg"
|
||||||
|
)))
|
||||||
|
.width(Length::Fixed(72.0))
|
||||||
|
.height(Length::Fixed(72.0));
|
||||||
|
|
||||||
|
let hero = container(
|
||||||
|
row![
|
||||||
|
logo,
|
||||||
|
column![
|
||||||
|
text("Open CAD Studio").size(28).style(primary_style),
|
||||||
|
text(t!("CAD application for Architecture & Engineering"))
|
||||||
|
.size(11)
|
||||||
|
.style(muted_style),
|
||||||
|
text(version.clone()).size(13),
|
||||||
|
]
|
||||||
|
.spacing(5),
|
||||||
]
|
]
|
||||||
.spacing(4)
|
.spacing(18)
|
||||||
.align_x(iced::Center),
|
.align_y(iced::Center),
|
||||||
)
|
)
|
||||||
.padding(iced::Padding {
|
.padding([14, 16])
|
||||||
top: 20.0,
|
.width(content_width)
|
||||||
right: 0.0,
|
.style(surface_style);
|
||||||
bottom: 16.0,
|
|
||||||
left: 0.0,
|
|
||||||
})
|
|
||||||
.align_x(iced::Center);
|
|
||||||
|
|
||||||
let info_block = container(
|
let metadata = row![
|
||||||
column![
|
info_card(t!("Version"), version, card_width),
|
||||||
info_row(t!("Version"), format!("v{}", version)),
|
info_card(t!("Platform"), platform_name(), card_width),
|
||||||
info_row(t!("Platform"), os.to_string()),
|
info_card(t!("Arch"), architecture_name(), card_width),
|
||||||
info_row(t!("Arch"), arch.to_string()),
|
]
|
||||||
]
|
.spacing(8)
|
||||||
.spacing(2)
|
.width(content_width);
|
||||||
.padding([12, 16]),
|
|
||||||
)
|
|
||||||
.style(container::bordered_box);
|
|
||||||
|
|
||||||
let copy_btn = button(text(t!("Copy Info")).size(11))
|
let copy = button(text(t!("Copy Info")).size(11))
|
||||||
.on_press(Message::AboutCopyInfo)
|
.on_press(Message::AboutCopyInfo)
|
||||||
.style(button::primary)
|
.style(button::primary)
|
||||||
.padding([6, 16]);
|
.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(
|
container(
|
||||||
column![logo, info_block, footer]
|
column![
|
||||||
.spacing(0)
|
hero,
|
||||||
.padding(iced::Padding {
|
metadata,
|
||||||
top: 0.0,
|
row![Space::new().width(content_width), copy]
|
||||||
right: 20.0,
|
.width(sizing.width)
|
||||||
bottom: 20.0,
|
.align_y(iced::Center),
|
||||||
left: 20.0,
|
]
|
||||||
}),
|
.spacing(12)
|
||||||
|
.padding(16)
|
||||||
|
.width(sizing.width)
|
||||||
|
.height(sizing.height),
|
||||||
)
|
)
|
||||||
|
.width(sizing.width)
|
||||||
|
.height(sizing.height)
|
||||||
.style(|theme: &Theme| container::Style {
|
.style(|theme: &Theme| container::Style {
|
||||||
background: Some(Background::Color(
|
background: Some(Background::Color(
|
||||||
theme.palette().background.base.color,
|
theme.palette().background.base.color,
|
||||||
|
|||||||
Reference in new issue
Block a user