Update to adwaita 1.4, and switch to the navigation page stack
This commit is contained in:
parent
cb71b0f2ac
commit
ad9312df4c
|
@ -6,7 +6,7 @@ edition = "2021"
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
adw = { version = "0.5", package = "libadwaita", features = [ "v1_2" ] }
|
adw = { version = "0.5", package = "libadwaita", features = [ "v1_4" ] }
|
||||||
async-channel = { version = "2.1" }
|
async-channel = { version = "2.1" }
|
||||||
chrono = { version = "0.4" }
|
chrono = { version = "0.4" }
|
||||||
chrono-tz = { version = "0.8" }
|
chrono-tz = { version = "0.8" }
|
||||||
|
|
|
@ -39,8 +39,7 @@ pub struct AppWindow {
|
||||||
layout: gtk::Box,
|
layout: gtk::Box,
|
||||||
current_view: Rc<RefCell<View>>,
|
current_view: Rc<RefCell<View>>,
|
||||||
settings: gio::Settings,
|
settings: gio::Settings,
|
||||||
overlay: gtk::Overlay,
|
navigation: adw::NavigationView,
|
||||||
modal: RefCell<Option<gtk::Widget>>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AppWindow {
|
impl AppWindow {
|
||||||
|
@ -80,11 +79,13 @@ impl AppWindow {
|
||||||
#[allow(deprecated)]
|
#[allow(deprecated)]
|
||||||
context.add_provider(&provider, STYLE_PROVIDER_PRIORITY_USER);
|
context.add_provider(&provider, STYLE_PROVIDER_PRIORITY_USER);
|
||||||
|
|
||||||
let overlay = gtk::Overlay::new();
|
let navigation = adw::NavigationView::new();
|
||||||
|
|
||||||
|
/*
|
||||||
let header = adw::HeaderBar::builder()
|
let header = adw::HeaderBar::builder()
|
||||||
.title_widget(>k::Label::new(Some("FitnessTrax")))
|
.title_widget(>k::Label::new(Some("FitnessTrax")))
|
||||||
.build();
|
.build();
|
||||||
|
*/
|
||||||
|
|
||||||
let layout = gtk::Box::builder()
|
let layout = gtk::Box::builder()
|
||||||
.orientation(gtk::Orientation::Vertical)
|
.orientation(gtk::Orientation::Vertical)
|
||||||
|
@ -92,12 +93,21 @@ impl AppWindow {
|
||||||
|
|
||||||
let initial_view = View::Placeholder(PlaceholderView::new().upcast());
|
let initial_view = View::Placeholder(PlaceholderView::new().upcast());
|
||||||
|
|
||||||
layout.append(&header);
|
// layout.append(&header);
|
||||||
layout.append(initial_view.widget());
|
layout.append(initial_view.widget());
|
||||||
|
|
||||||
overlay.set_child(Some(&layout));
|
let nav_layout = gtk::Box::new(gtk::Orientation::Vertical, 0);
|
||||||
|
nav_layout.append(&adw::HeaderBar::new());
|
||||||
|
nav_layout.append(&layout);
|
||||||
|
navigation.push(
|
||||||
|
&adw::NavigationPage::builder()
|
||||||
|
.can_pop(false)
|
||||||
|
.title("FitnessTrax")
|
||||||
|
.child(&nav_layout)
|
||||||
|
.build(),
|
||||||
|
);
|
||||||
|
|
||||||
window.set_content(Some(&overlay));
|
window.set_content(Some(&navigation));
|
||||||
window.present();
|
window.present();
|
||||||
|
|
||||||
let gesture = gtk::GestureClick::new();
|
let gesture = gtk::GestureClick::new();
|
||||||
|
@ -109,8 +119,7 @@ impl AppWindow {
|
||||||
layout,
|
layout,
|
||||||
current_view: Rc::new(RefCell::new(initial_view)),
|
current_view: Rc::new(RefCell::new(initial_view)),
|
||||||
settings: gio::Settings::new(app_id),
|
settings: gio::Settings::new(app_id),
|
||||||
overlay,
|
navigation,
|
||||||
modal: RefCell::new(None),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
s
|
s
|
||||||
|
@ -120,21 +129,6 @@ impl AppWindow {
|
||||||
self.swap_main(self.construct_view(view));
|
self.swap_main(self.construct_view(view));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn open_modal(&self, modal: gtk::Widget) {
|
|
||||||
self.close_modal();
|
|
||||||
|
|
||||||
self.overlay.add_overlay(&modal);
|
|
||||||
*self.modal.borrow_mut() = Some(modal);
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn close_modal(&self) {
|
|
||||||
match *self.modal.borrow() {
|
|
||||||
Some(ref widget) => self.overlay.remove_overlay(widget),
|
|
||||||
None => {}
|
|
||||||
}
|
|
||||||
*self.modal.borrow_mut() = None;
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn process_response(&self, response: AppResponse) {
|
pub fn process_response(&self, response: AppResponse) {
|
||||||
match response {
|
match response {
|
||||||
AppResponse::DatabaseChanged(db_path) => {
|
AppResponse::DatabaseChanged(db_path) => {
|
||||||
|
@ -211,7 +205,16 @@ impl AppWindow {
|
||||||
],
|
],
|
||||||
{
|
{
|
||||||
let s = self.clone();
|
let s = self.clone();
|
||||||
Rc::new(move |date, records| s.open_modal(day_detail(date, records)))
|
Rc::new(move |date: chrono::NaiveDate, records| {
|
||||||
|
let layout = gtk::Box::new(gtk::Orientation::Vertical, 0);
|
||||||
|
layout.append(&adw::HeaderBar::new());
|
||||||
|
layout.append(&day_detail(date, records));
|
||||||
|
let page = &adw::NavigationPage::builder()
|
||||||
|
.title(date.format("%Y-%m-%d").to_string())
|
||||||
|
.child(&layout)
|
||||||
|
.build();
|
||||||
|
s.navigation.push(page);
|
||||||
|
})
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
.upcast(),
|
.upcast(),
|
||||||
|
|
|
@ -51,16 +51,16 @@
|
||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1691421349,
|
"lastModified": 1703200384,
|
||||||
"narHash": "sha256-RRJyX0CUrs4uW4gMhd/X4rcDG8PTgaaCQM5rXEJOx6g=",
|
"narHash": "sha256-q5j06XOsy0qHOarsYPfZYJPWbTbc8sryRxianlEPJN0=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "011567f35433879aae5024fc6ec53f2a0568a6c4",
|
"rev": "0b3d618173114c64ab666f557504d6982665d328",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"id": "nixpkgs",
|
"id": "nixpkgs",
|
||||||
"ref": "nixos-23.05",
|
"ref": "nixos-23.11",
|
||||||
"type": "indirect"
|
"type": "indirect"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
description = "Lumenescent Dreams Tools";
|
description = "Lumenescent Dreams Tools";
|
||||||
|
|
||||||
inputs = {
|
inputs = {
|
||||||
nixpkgs.url = "nixpkgs/nixos-23.05";
|
nixpkgs.url = "nixpkgs/nixos-23.11";
|
||||||
unstable.url = "nixpkgs/nixos-unstable";
|
unstable.url = "nixpkgs/nixos-unstable";
|
||||||
pkgs-cargo2nix.url = "github:cargo2nix/cargo2nix";
|
pkgs-cargo2nix.url = "github:cargo2nix/cargo2nix";
|
||||||
typeshare.url = "github:1Password/typeshare";
|
typeshare.url = "github:1Password/typeshare";
|
||||||
|
|
Loading…
Reference in New Issue