From 5cd0e822c6e4b3252fc08f6b06fd945b8f488169 Mon Sep 17 00:00:00 2001 From: Savanni D'Gerinel Date: Mon, 25 Dec 2023 01:09:31 -0500 Subject: [PATCH] Update to adwaita 1.4, and add a navigation page stack --- fitnesstrax/app/Cargo.toml | 2 +- fitnesstrax/app/src/app_window.rs | 21 ++++++++++++++++----- flake.lock | 8 ++++---- flake.nix | 2 +- 4 files changed, 22 insertions(+), 11 deletions(-) diff --git a/fitnesstrax/app/Cargo.toml b/fitnesstrax/app/Cargo.toml index bfb1eca..9680e26 100644 --- a/fitnesstrax/app/Cargo.toml +++ b/fitnesstrax/app/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -adw = { version = "0.5", package = "libadwaita", features = [ "v1_2" ] } +adw = { version = "0.5", package = "libadwaita", features = [ "v1_4" ] } async-channel = { version = "2.1" } chrono = { version = "0.4" } chrono-tz = { version = "0.8" } diff --git a/fitnesstrax/app/src/app_window.rs b/fitnesstrax/app/src/app_window.rs index 2d8722e..dba2366 100644 --- a/fitnesstrax/app/src/app_window.rs +++ b/fitnesstrax/app/src/app_window.rs @@ -37,6 +37,7 @@ pub struct AppWindow { layout: gtk::Box, current_view: Rc>, settings: gio::Settings, + navigation: adw::NavigationView, } impl AppWindow { @@ -76,9 +77,7 @@ impl AppWindow { #[allow(deprecated)] context.add_provider(&provider, STYLE_PROVIDER_PRIORITY_USER); - let header = adw::HeaderBar::builder() - .title_widget(>k::Label::new(Some("FitnessTrax"))) - .build(); + let navigation = adw::NavigationView::new(); let layout = gtk::Box::builder() .orientation(gtk::Orientation::Vertical) @@ -86,10 +85,21 @@ impl AppWindow { let initial_view = View::Placeholder(PlaceholderView::new().upcast()); - layout.append(&header); + // layout.append(&header); layout.append(&initial_view.widget()); - window.set_content(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(&navigation)); window.present(); let s = Self { @@ -97,6 +107,7 @@ impl AppWindow { layout, current_view: Rc::new(RefCell::new(initial_view)), settings: gio::Settings::new(app_id), + navigation, }; s diff --git a/flake.lock b/flake.lock index ca25ad3..6edcaf2 100644 --- a/flake.lock +++ b/flake.lock @@ -51,16 +51,16 @@ }, "nixpkgs": { "locked": { - "lastModified": 1691421349, - "narHash": "sha256-RRJyX0CUrs4uW4gMhd/X4rcDG8PTgaaCQM5rXEJOx6g=", + "lastModified": 1703200384, + "narHash": "sha256-q5j06XOsy0qHOarsYPfZYJPWbTbc8sryRxianlEPJN0=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "011567f35433879aae5024fc6ec53f2a0568a6c4", + "rev": "0b3d618173114c64ab666f557504d6982665d328", "type": "github" }, "original": { "id": "nixpkgs", - "ref": "nixos-23.05", + "ref": "nixos-23.11", "type": "indirect" } }, diff --git a/flake.nix b/flake.nix index 387310c..0854e20 100644 --- a/flake.nix +++ b/flake.nix @@ -2,7 +2,7 @@ description = "Lumenescent Dreams Tools"; inputs = { - nixpkgs.url = "nixpkgs/nixos-23.05"; + nixpkgs.url = "nixpkgs/nixos-23.11"; unstable.url = "nixpkgs/nixos-unstable"; pkgs-cargo2nix.url = "github:cargo2nix/cargo2nix"; typeshare.url = "github:1Password/typeshare";