Render and be able to edit bike rides (and sorta other time distance workouts) #169

Merged
savanni merged 13 commits from fitnesstrax/time-distance-workout into main 2024-02-09 00:05:26 +00:00
4 changed files with 55 additions and 8 deletions
Showing only changes of commit af1422d523 - Show all commits

View File

@ -27,7 +27,7 @@ mod steps;
pub use steps::{steps_editor, Steps}; pub use steps::{steps_editor, Steps};
mod text_entry; mod text_entry;
pub use text_entry::{weight_field, TextEntry}; pub use text_entry::{distance_field, duration_field, time_field, weight_field, TextEntry};
mod time_distance; mod time_distance;
pub use time_distance::{time_distance_detail, time_distance_summary}; pub use time_distance::{time_distance_detail, time_distance_summary};

View File

@ -18,7 +18,9 @@ You should have received a copy of the GNU General Public License along with Fit
// use chrono::{Local, NaiveDate}; // use chrono::{Local, NaiveDate};
// use dimensioned::si; // use dimensioned::si;
use dimensioned::si; use dimensioned::si;
use gtk::prelude::*; use glib::Object;
use gtk::{prelude::*, subclass::prelude::*};
use std::cell::RefCell;
pub fn time_distance_summary( pub fn time_distance_summary(
distance: si::Meter<f64>, distance: si::Meter<f64>,
@ -99,5 +101,53 @@ pub fn time_distance_detail(record: ft_core::TimeDistance) -> gtk::Box {
) )
.build(), .build(),
); );
layout layout
} }
#[derive(Default)]
pub struct TimeDistanceEditPrivate {
#[allow(unused)]
record: RefCell<Option<ft_core::TimeDistance>>,
}
#[glib::object_subclass]
impl ObjectSubclass for TimeDistanceEditPrivate {
const NAME: &'static str = "TimeDistanceEdit";
type Type = TimeDistanceEdit;
type ParentType = gtk::Box;
}
impl ObjectImpl for TimeDistanceEditPrivate {}
impl WidgetImpl for TimeDistanceEditPrivate {}
impl BoxImpl for TimeDistanceEditPrivate {}
glib::wrapper! {
pub struct TimeDistanceEdit(ObjectSubclass<TimeDistanceEditPrivate>) @extends gtk::Box, gtk::Widget, @implements gtk::Orientable;
}
impl Default for TimeDistanceEdit {
fn default() -> Self {
let s: Self = Object::builder().build();
s.set_orientation(gtk::Orientation::Horizontal);
s.set_css_classes(&["time-distance-edit"]);
s
}
}
impl TimeDistanceEdit {
#[allow(unused)]
fn empty<OnUpdate>(_on_update: OnUpdate) -> Self
where
OnUpdate: Fn(&ft_core::TimeDistance),
{
Self::default()
}
/*
fn with_record<OnUpdate>(type_: ft_core::RecordType, record: ft_core::TimeDistance, on_update: OnUpdate) -> Self
where OnUpdate: Fn(&ft_core::RecordType, &ft_core::TimeDistance) {
}
*/
}

View File

@ -14,9 +14,7 @@ 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/>.
*/ */
use crate::{ use crate::types::{FormatOption, WeightFormatter};
types::{FormatOption, WeightFormatter},
};
use gtk::prelude::*; use gtk::prelude::*;
pub struct WeightLabel { pub struct WeightLabel {

View File

@ -56,6 +56,7 @@ impl ObjectSubclass for HistoricalViewPrivate {
.single_click_activate(true) .single_click_activate(true)
.build(), .build(),
}; };
factory.connect_bind({ factory.connect_bind({
let app = s.app.clone(); let app = s.app.clone();
move |_, list_item| { move |_, list_item| {
@ -119,9 +120,7 @@ impl HistoricalView {
s.imp().list_view.connect_activate({ s.imp().list_view.connect_activate({
let on_select_day = on_select_day.clone(); let on_select_day = on_select_day.clone();
move |s, idx| { move |s, idx| {
// This gets triggered whenever the user clicks on an item on the list. What we // This gets triggered whenever the user clicks on an item on the list.
// actually want to do here is to open a modal dialog that shows all of the details of
// the day and which allows the user to edit items within that dialog.
let item = s.model().unwrap().item(idx).unwrap(); let item = s.model().unwrap().item(idx).unwrap();
let date = item.downcast_ref::<Date>().unwrap(); let date = item.downcast_ref::<Date>().unwrap();
on_select_day(date.date()); on_select_day(date.date());