feat(ui): reworked entry rows in the settings

Removed huge pill buttons, added small "+" icons
This commit is contained in:
Observer KRypt0n_ 2023-05-05 11:26:36 +02:00
parent bdd45471ca
commit 3d036e6a97
No known key found for this signature in database
GPG key ID: 844DA47BA25FE1E2
3 changed files with 78 additions and 56 deletions

View file

@ -110,6 +110,20 @@ impl SimpleAsyncComponent for EnvironmentApp {
add = &adw::PreferencesGroup { add = &adw::PreferencesGroup {
set_title: &tr("new-variable"), set_title: &tr("new-variable"),
#[wrap(Some)]
set_header_suffix = &gtk::Button {
add_css_class: "flat",
set_valign: gtk::Align::Center,
adw::ButtonContent {
set_icon_name: "list-add-symbolic",
set_label: &tr("add")
},
connect_clicked => EnvironmentAppMsg::Add
},
#[local_ref] #[local_ref]
name_entry -> adw::EntryRow { name_entry -> adw::EntryRow {
set_title: &tr("name") set_title: &tr("name")
@ -118,16 +132,6 @@ impl SimpleAsyncComponent for EnvironmentApp {
#[local_ref] #[local_ref]
value_entry -> adw::EntryRow { value_entry -> adw::EntryRow {
set_title: &tr("value") set_title: &tr("value")
},
gtk::Button {
set_label: &tr("add"),
add_css_class: "pill",
set_margin_top: 8,
set_halign: gtk::Align::Start,
connect_clicked => EnvironmentAppMsg::Add
} }
}, },

View file

@ -64,6 +64,7 @@ impl AsyncFactoryComponent for GameSession {
pub struct GameApp { pub struct GameApp {
sessions: AsyncFactoryVecDeque<GameSession>, sessions: AsyncFactoryVecDeque<GameSession>,
active_sessions: gtk::StringList,
session_name_entry: adw::EntryRow session_name_entry: adw::EntryRow
} }
@ -82,25 +83,33 @@ impl SimpleAsyncComponent for GameApp {
view! { view! {
adw::PreferencesPage { adw::PreferencesPage {
set_title: "Game", set_title: "Game",
set_icon_name: Some("document-properties-symbolic"), set_icon_name: Some("applications-games-symbolic"),
add = &adw::PreferencesGroup { add = &adw::PreferencesGroup {
set_title: "Saved sessions", set_title: "Game sessions",
#[local_ref] adw::ComboRow {
session_name_entry -> adw::EntryRow { set_title: "Active session",
set_title: &tr("name") set_subtitle: "Currently selected game session",
set_model = Some(&model.active_sessions),
}
}, },
gtk::Button { add = &adw::PreferencesGroup {
set_label: &tr("add"), #[local_ref]
add_css_class: "pill", session_name_entry -> adw::EntryRow {
set_title: &tr("name"),
set_margin_top: 8, add_suffix = &gtk::Button {
set_halign: gtk::Align::Start, set_icon_name: "list-add-symbolic",
add_css_class: "flat",
set_valign: gtk::Align::Center,
connect_clicked => GameAppMsg::AddSession connect_clicked => GameAppMsg::AddSession
} }
}
}, },
#[local_ref] #[local_ref]
@ -113,11 +122,12 @@ impl SimpleAsyncComponent for GameApp {
root: Self::Root, root: Self::Root,
sender: AsyncComponentSender<Self>, sender: AsyncComponentSender<Self>,
) -> AsyncComponentParts<Self> { ) -> AsyncComponentParts<Self> {
tracing::info!("Initializing environment settings"); tracing::info!("Initializing game settings");
let mut model = Self { let mut model = Self {
sessions: AsyncFactoryVecDeque::new(adw::PreferencesGroup::new(), sender.input_sender()), sessions: AsyncFactoryVecDeque::new(adw::PreferencesGroup::new(), sender.input_sender()),
active_sessions: gtk::StringList::new(&[]),
session_name_entry: adw::EntryRow::new() session_name_entry: adw::EntryRow::new()
}; };
@ -142,6 +152,8 @@ impl SimpleAsyncComponent for GameApp {
if !name.is_empty() { if !name.is_empty() {
self.session_name_entry.set_text(""); self.session_name_entry.set_text("");
self.active_sessions.append(&name);
self.sessions.guard().push_back(GameSession { self.sessions.guard().push_back(GameSession {
title: name, title: name,
description: None, description: None,
@ -151,10 +163,7 @@ impl SimpleAsyncComponent for GameApp {
} }
GameAppMsg::RemoveSession(index) => { GameAppMsg::RemoveSession(index) => {
if let Some(var) = self.sessions.guard().get(index.current_index()) { self.active_sessions.remove(index.current_index() as u32);
// ..
}
self.sessions.guard().remove(index.current_index()); self.sessions.guard().remove(index.current_index());
} }
} }

View file

@ -197,8 +197,10 @@ impl SimpleAsyncComponent for SandboxApp {
}, },
add_suffix = &gtk::Button { add_suffix = &gtk::Button {
set_valign: gtk::Align::Center,
set_icon_name: "dialog-information-symbolic", set_icon_name: "dialog-information-symbolic",
add_css_class: "flat",
set_valign: gtk::Align::Center,
connect_clicked[sender] => move |_| { connect_clicked[sender] => move |_| {
if let Err(err) = open::that("https://man.archlinux.org/man/bwrap.1") { if let Err(err) = open::that("https://man.archlinux.org/man/bwrap.1") {
@ -218,18 +220,17 @@ impl SimpleAsyncComponent for SandboxApp {
#[local_ref] #[local_ref]
private_path_entry -> adw::EntryRow { private_path_entry -> adw::EntryRow {
set_title: &tr("path") set_title: &tr("path"),
},
gtk::Button { add_suffix = &gtk::Button {
set_label: &tr("add"), set_icon_name: "list-add-symbolic",
add_css_class: "pill", add_css_class: "flat",
set_margin_top: 8, set_valign: gtk::Align::Center,
set_halign: gtk::Align::Start,
connect_clicked => SandboxAppMsg::AddPrivate connect_clicked => SandboxAppMsg::AddPrivate
} }
}
}, },
#[local_ref] #[local_ref]
@ -239,6 +240,20 @@ impl SimpleAsyncComponent for SandboxApp {
set_title: &tr("shared-directories"), set_title: &tr("shared-directories"),
set_description: Some(&tr("shared-directories-description")), set_description: Some(&tr("shared-directories-description")),
#[wrap(Some)]
set_header_suffix = &gtk::Button {
add_css_class: "flat",
set_valign: gtk::Align::Center,
adw::ButtonContent {
set_icon_name: "list-add-symbolic",
set_label: &tr("add")
},
connect_clicked => SandboxAppMsg::AddShared
},
#[local_ref] #[local_ref]
shared_path_from_entry -> adw::EntryRow { shared_path_from_entry -> adw::EntryRow {
set_title: &tr("original-path") set_title: &tr("original-path")
@ -257,16 +272,6 @@ impl SimpleAsyncComponent for SandboxApp {
add_suffix = read_only_switch -> gtk::Switch { add_suffix = read_only_switch -> gtk::Switch {
set_valign: gtk::Align::Center set_valign: gtk::Align::Center
} }
},
gtk::Button {
set_label: &tr("add"),
add_css_class: "pill",
set_margin_top: 8,
set_halign: gtk::Align::Start,
connect_clicked => SandboxAppMsg::AddShared
} }
}, },
@ -277,6 +282,20 @@ impl SimpleAsyncComponent for SandboxApp {
set_title: &tr("symlinks"), set_title: &tr("symlinks"),
set_description: Some(&tr("symlinks-description")), set_description: Some(&tr("symlinks-description")),
#[wrap(Some)]
set_header_suffix = &gtk::Button {
add_css_class: "flat",
set_valign: gtk::Align::Center,
adw::ButtonContent {
set_icon_name: "list-add-symbolic",
set_label: &tr("add")
},
connect_clicked => SandboxAppMsg::AddSymlink
},
#[local_ref] #[local_ref]
symlink_path_from_entry -> adw::EntryRow { symlink_path_from_entry -> adw::EntryRow {
set_title: &tr("original-path") set_title: &tr("original-path")
@ -285,16 +304,6 @@ impl SimpleAsyncComponent for SandboxApp {
#[local_ref] #[local_ref]
symlink_path_to_entry -> adw::EntryRow { symlink_path_to_entry -> adw::EntryRow {
set_title: &tr("new-path") set_title: &tr("new-path")
},
gtk::Button {
set_label: &tr("add"),
add_css_class: "pill",
set_margin_top: 8,
set_halign: gtk::Align::Start,
connect_clicked => SandboxAppMsg::AddSymlink
} }
}, },