152 lines
4.2 KiB
Rust
152 lines
4.2 KiB
Rust
use super::{
|
|
settings_page::{
|
|
MatchData, PageType, SettingsPageEvent, SettingsPageMeta, SettingsPageViewHandle,
|
|
SettingsWidget,
|
|
},
|
|
SettingsSection,
|
|
};
|
|
use crate::{appearance::Appearance, channel::ChannelState, workspace::WorkspaceAction};
|
|
use galaxyui::{
|
|
assets::asset_cache::AssetSource,
|
|
elements::{
|
|
Align, CacheOption, ConstrainedBox, Container, CrossAxisAlignment, Element, Flex, Image,
|
|
MainAxisAlignment, MouseStateHandle, ParentElement, Wrap,
|
|
},
|
|
ui_components::components::UiComponent,
|
|
AppContext, Entity, View, ViewContext, ViewHandle,
|
|
};
|
|
|
|
pub struct AboutPageView {
|
|
page: PageType<Self>,
|
|
}
|
|
|
|
impl AboutPageView {
|
|
pub fn new(_ctx: &mut ViewContext<AboutPageView>) -> Self {
|
|
AboutPageView {
|
|
page: PageType::new_monolith(AboutPageWidget::default(), None, false),
|
|
}
|
|
}
|
|
}
|
|
|
|
impl Entity for AboutPageView {
|
|
type Event = SettingsPageEvent;
|
|
}
|
|
|
|
impl View for AboutPageView {
|
|
fn ui_name() -> &'static str {
|
|
"AboutPage"
|
|
}
|
|
|
|
fn render(&self, app: &AppContext) -> Box<dyn Element> {
|
|
self.page.render(self, app)
|
|
}
|
|
}
|
|
|
|
#[derive(Default)]
|
|
struct AboutPageWidget {
|
|
copy_version_button_mouse_state: MouseStateHandle,
|
|
}
|
|
|
|
impl SettingsWidget for AboutPageWidget {
|
|
type View = AboutPageView;
|
|
|
|
fn search_terms(&self) -> &str {
|
|
"about galaxy ai version"
|
|
}
|
|
|
|
fn render(
|
|
&self,
|
|
_view: &AboutPageView,
|
|
appearance: &Appearance,
|
|
_app: &AppContext,
|
|
) -> Box<dyn Element> {
|
|
let ui_builder = appearance.ui_builder();
|
|
|
|
let image_path = "bundled/svg/galaxy-logo.svg";
|
|
|
|
let version =
|
|
ChannelState::app_version().unwrap_or(concat!("v", env!("CARGO_PKG_VERSION")));
|
|
|
|
let version_text = ui_builder
|
|
.span(version.to_string())
|
|
.with_soft_wrap()
|
|
.build()
|
|
.with_margin_top(16.)
|
|
.finish();
|
|
|
|
let copy_version_icon = appearance
|
|
.ui_builder()
|
|
.copy_button(16., self.copy_version_button_mouse_state.clone())
|
|
.build()
|
|
.on_click(move |ctx, _, _| {
|
|
ctx.dispatch_typed_action(WorkspaceAction::CopyVersion(version));
|
|
})
|
|
.finish();
|
|
|
|
let version_row = Wrap::row()
|
|
.with_main_axis_alignment(MainAxisAlignment::Center)
|
|
.with_children([
|
|
version_text,
|
|
Container::new(copy_version_icon)
|
|
.with_margin_top(16.)
|
|
.with_padding_left(6.)
|
|
.finish(),
|
|
]);
|
|
|
|
Align::new(
|
|
Flex::column()
|
|
.with_cross_axis_alignment(CrossAxisAlignment::Center)
|
|
.with_child(
|
|
ConstrainedBox::new(
|
|
Image::new(
|
|
AssetSource::Bundled { path: image_path },
|
|
CacheOption::BySize,
|
|
)
|
|
.finish(),
|
|
)
|
|
.with_max_height(100.)
|
|
.with_max_width(350.)
|
|
.finish(),
|
|
)
|
|
.with_child(version_row.finish())
|
|
.with_child(
|
|
ui_builder
|
|
.span("Copyright 2026 Samsung Electronics Co., Ltd.")
|
|
.build()
|
|
.with_margin_top(16.)
|
|
.finish(),
|
|
)
|
|
.finish(),
|
|
)
|
|
.finish()
|
|
}
|
|
}
|
|
|
|
impl SettingsPageMeta for AboutPageView {
|
|
fn section() -> SettingsSection {
|
|
SettingsSection::About
|
|
}
|
|
|
|
fn should_render(&self, _ctx: &AppContext) -> bool {
|
|
true
|
|
}
|
|
|
|
fn update_filter(&mut self, query: &str, ctx: &mut ViewContext<Self>) -> MatchData {
|
|
self.page.update_filter(query, ctx)
|
|
}
|
|
|
|
fn scroll_to_widget(&mut self, widget_id: &'static str) {
|
|
self.page.scroll_to_widget(widget_id)
|
|
}
|
|
|
|
fn clear_highlighted_widget(&mut self) {
|
|
self.page.clear_highlighted_widget();
|
|
}
|
|
}
|
|
|
|
impl From<ViewHandle<AboutPageView>> for SettingsPageViewHandle {
|
|
fn from(view_handle: ViewHandle<AboutPageView>) -> Self {
|
|
SettingsPageViewHandle::About(view_handle)
|
|
}
|
|
}
|