Completely switch daydetail to navigation and remove the modal

This commit is contained in:
Savanni D'Gerinel 2023-12-25 01:09:31 -05:00
parent 84fe6fbd8f
commit 5b8b612758
4 changed files with 29 additions and 60 deletions

View File

@ -14,30 +14,6 @@
.welcome__footer { .welcome__footer {
} }
.modal {
background-color: @dialog_bg_color;
border-radius: 8px;
margin: 64px;
}
.modal__header {
}
.modal__title {
font-size: larger;
padding: 8px;
}
.modal__content {
background-color: @view_bg_color;
margin: 16px;
}
.modal__row {
margin: 8px 0px 8px 0px;
padding: 8px;
}
.historical { .historical {
margin: 32px; margin: 32px;
border-radius: 8px; border-radius: 8px;

View File

@ -16,7 +16,7 @@ You should have received a copy of the GNU General Public License along with Fit
use crate::{ use crate::{
app::{AppInvocation, AppResponse}, app::{AppInvocation, AppResponse},
components::day_detail, components::DayDetail,
views::{HistoricalView, PlaceholderView, View, ViewName, WelcomeView}, views::{HistoricalView, PlaceholderView, View, ViewName, WelcomeView},
}; };
use adw::prelude::*; use adw::prelude::*;
@ -85,7 +85,6 @@ impl AppWindow {
let initial_view = View::Placeholder(PlaceholderView::new().upcast()); let initial_view = View::Placeholder(PlaceholderView::new().upcast());
// layout.append(&header);
layout.append(&initial_view.widget()); layout.append(&initial_view.widget());
let nav_layout = gtk::Box::new(gtk::Orientation::Vertical, 0); let nav_layout = gtk::Box::new(gtk::Orientation::Vertical, 0);
@ -202,7 +201,7 @@ impl AppWindow {
Rc::new(move |date, records| { Rc::new(move |date, records| {
let layout = gtk::Box::new(gtk::Orientation::Vertical, 0); let layout = gtk::Box::new(gtk::Orientation::Vertical, 0);
layout.append(&adw::HeaderBar::new()); layout.append(&adw::HeaderBar::new());
layout.append(&day_detail(date, records)); layout.append(&DayDetail::new(date, records));
let page = &adw::NavigationPage::builder() let page = &adw::NavigationPage::builder()
.title(date.format("%Y-%m-%d").to_string()) .title(date.format("%Y-%m-%d").to_string())
.child(&layout) .child(&layout)

View File

@ -85,10 +85,16 @@ impl DaySummary {
self.append(&label); self.append(&label);
*self.imp().weight.borrow_mut() = Some(label); *self.imp().weight.borrow_mut() = Some(label);
} }
self.append(
&gtk::Label::builder()
.halign(gtk::Align::Start)
.label("15km of biking in 60 minutes")
.build(),
);
} }
} }
/*
pub struct DayDetailPrivate { pub struct DayDetailPrivate {
date: gtk::Label, date: gtk::Label,
weight: RefCell<Option<gtk::Label>>, weight: RefCell<Option<gtk::Label>>,
@ -121,22 +127,9 @@ glib::wrapper! {
} }
impl DayDetail { impl DayDetail {
pub fn new() -> Self { pub fn new(date: chrono::NaiveDate, records: Vec<TraxRecord>) -> Self {
let s: Self = Object::builder().build(); let s: Self = Object::builder().build();
s.set_orientation(gtk::Orientation::Vertical); s.set_orientation(gtk::Orientation::Vertical);
s.set_css_classes(&["modal"]);
s.append(&gtk::Label::new(Some("abcdefg")));
s
}
}
*/
pub fn day_detail(date: chrono::NaiveDate, records: Vec<TraxRecord>) -> gtk::Widget {
let content = gtk::Box::builder()
.orientation(gtk::Orientation::Vertical)
.build();
records.into_iter().for_each(|record| { records.into_iter().for_each(|record| {
let record_view = match record { let record_view = match record {
@ -152,8 +145,9 @@ pub fn day_detail(date: chrono::NaiveDate, records: Vec<TraxRecord>) -> gtk::Wid
record_view.add_css_class("day-detail"); record_view.add_css_class("day-detail");
record_view.set_halign(gtk::Align::Start); record_view.set_halign(gtk::Align::Start);
content.append(&record_view); s.append(&record_view);
}); });
content.upcast() s
}
} }

View File

@ -14,13 +14,13 @@ General Public License for more details.
You should have received a copy of the GNU General Public License along with FitnessTrax. If not, see <https://www.gnu.org/licenses/>. You should have received a copy of the GNU General Public License along with FitnessTrax. If not, see <https://www.gnu.org/licenses/>.
*/ */
mod day;
pub use day::{DayDetail, DaySummary};
use glib::Object; use glib::Object;
use gtk::{prelude::*, subclass::prelude::*}; use gtk::{prelude::*, subclass::prelude::*};
use std::{cell::RefCell, path::PathBuf, rc::Rc}; use std::{cell::RefCell, path::PathBuf, rc::Rc};
mod day;
pub use day::{day_detail, DaySummary};
pub struct FileChooserRowPrivate { pub struct FileChooserRowPrivate {
path: RefCell<Option<PathBuf>>, path: RefCell<Option<PathBuf>>,
label: gtk::Label, label: gtk::Label,