refactor: simplify about page
This commit is contained in:
@@ -1,10 +1,6 @@
|
|||||||
use galaxyui::ui_components::components::UiComponent;
|
|
||||||
use galaxyui::{AppContext, Entity, SingletonEntity, View, ViewContext, ViewHandle};
|
use galaxyui::{AppContext, Entity, SingletonEntity, View, ViewContext, ViewHandle};
|
||||||
use warpui::assets::asset_cache::AssetSource;
|
use warpui::assets::asset_cache::AssetSource;
|
||||||
use warpui::elements::{
|
use warpui::elements::{Align, CacheOption, ConstrainedBox, Element, Image};
|
||||||
Align, CacheOption, ConstrainedBox, Container, CrossAxisAlignment, Element, Flex, Image,
|
|
||||||
MainAxisAlignment, MouseStateHandle, ParentElement, Wrap,
|
|
||||||
};
|
|
||||||
|
|
||||||
use super::settings_page::{
|
use super::settings_page::{
|
||||||
MatchData, PageType, SettingsPageEvent, SettingsPageMeta, SettingsPageViewHandle,
|
MatchData, PageType, SettingsPageEvent, SettingsPageMeta, SettingsPageViewHandle,
|
||||||
@@ -12,10 +8,7 @@ use super::settings_page::{
|
|||||||
};
|
};
|
||||||
use super::SettingsSection;
|
use super::SettingsSection;
|
||||||
use crate::appearance::Appearance;
|
use crate::appearance::Appearance;
|
||||||
use crate::channel::ChannelState;
|
|
||||||
use crate::settings::app_icon::AppIconSettings;
|
use crate::settings::app_icon::AppIconSettings;
|
||||||
use crate::themes::theme::ColorScheme;
|
|
||||||
use crate::workspace::WorkspaceAction;
|
|
||||||
|
|
||||||
pub struct AboutPageView {
|
pub struct AboutPageView {
|
||||||
page: PageType<Self>,
|
page: PageType<Self>,
|
||||||
@@ -24,7 +17,7 @@ pub struct AboutPageView {
|
|||||||
impl AboutPageView {
|
impl AboutPageView {
|
||||||
pub fn new(_ctx: &mut ViewContext<AboutPageView>) -> Self {
|
pub fn new(_ctx: &mut ViewContext<AboutPageView>) -> Self {
|
||||||
AboutPageView {
|
AboutPageView {
|
||||||
page: PageType::new_monolith(AboutPageWidget::default(), None, false),
|
page: PageType::new_monolith(AboutPageWidget, None, false),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -43,10 +36,7 @@ impl View for AboutPageView {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default)]
|
struct AboutPageWidget;
|
||||||
struct AboutPageWidget {
|
|
||||||
copy_version_button_mouse_state: MouseStateHandle,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl SettingsWidget for AboutPageWidget {
|
impl SettingsWidget for AboutPageWidget {
|
||||||
type View = AboutPageView;
|
type View = AboutPageView;
|
||||||
@@ -58,11 +48,9 @@ impl SettingsWidget for AboutPageWidget {
|
|||||||
fn render(
|
fn render(
|
||||||
&self,
|
&self,
|
||||||
_view: &AboutPageView,
|
_view: &AboutPageView,
|
||||||
appearance: &Appearance,
|
_appearance: &Appearance,
|
||||||
app: &AppContext,
|
app: &AppContext,
|
||||||
) -> Box<dyn Element> {
|
) -> Box<dyn Element> {
|
||||||
let ui_builder = appearance.ui_builder();
|
|
||||||
|
|
||||||
let icon_file =
|
let icon_file =
|
||||||
AppIconSettings::get_base_icon_file_name(*AppIconSettings::as_ref(app).app_icon);
|
AppIconSettings::get_base_icon_file_name(*AppIconSettings::as_ref(app).app_icon);
|
||||||
let image_path = match icon_file {
|
let image_path = match icon_file {
|
||||||
@@ -74,39 +62,7 @@ impl SettingsWidget for AboutPageWidget {
|
|||||||
_ => "bundled/png/galaxy.png",
|
_ => "bundled/png/galaxy.png",
|
||||||
};
|
};
|
||||||
|
|
||||||
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(
|
Align::new(
|
||||||
Flex::column()
|
|
||||||
.with_cross_axis_alignment(CrossAxisAlignment::Center)
|
|
||||||
.with_child(
|
|
||||||
ConstrainedBox::new(
|
ConstrainedBox::new(
|
||||||
Image::new(
|
Image::new(
|
||||||
AssetSource::Bundled { path: image_path },
|
AssetSource::Bundled { path: image_path },
|
||||||
@@ -114,34 +70,8 @@ impl SettingsWidget for AboutPageWidget {
|
|||||||
)
|
)
|
||||||
.finish(),
|
.finish(),
|
||||||
)
|
)
|
||||||
.with_max_height(100.)
|
.with_max_height(144.)
|
||||||
.with_max_width(350.)
|
.with_max_width(144.)
|
||||||
.finish(),
|
|
||||||
)
|
|
||||||
.with_child(version_row.finish())
|
|
||||||
.with_child(
|
|
||||||
ui_builder
|
|
||||||
.span("Galaxy is a local-first, open-source developer terminal built around your workflow, your data, and the model providers you choose.")
|
|
||||||
.build()
|
|
||||||
.with_margin_top(16.)
|
|
||||||
.finish(),
|
|
||||||
)
|
|
||||||
.with_child(
|
|
||||||
ui_builder
|
|
||||||
.span("Conversations, settings, and Galaxy Drive content are stored locally by default. Network access is limited to providers and tools that you explicitly configure.")
|
|
||||||
.with_soft_wrap()
|
|
||||||
.build()
|
|
||||||
.with_margin_top(8.)
|
|
||||||
.finish(),
|
|
||||||
)
|
|
||||||
.with_child(
|
|
||||||
ui_builder
|
|
||||||
.span("The application and most workspace crates are licensed under AGPL-3.0-only. GalaxyUI crates are licensed under the MIT License. See LICENSE-AGPL and LICENSE-MIT in the source repository for the full terms.")
|
|
||||||
.with_soft_wrap()
|
|
||||||
.build()
|
|
||||||
.with_margin_top(8.)
|
|
||||||
.finish(),
|
|
||||||
)
|
|
||||||
.finish(),
|
.finish(),
|
||||||
)
|
)
|
||||||
.finish()
|
.finish()
|
||||||
|
|||||||
Reference in New Issue
Block a user