Render and be able to edit bike rides (and sorta other time distance workouts) #169
|
@ -28,6 +28,8 @@ use glib::Object;
|
||||||
use gtk::{prelude::*, subclass::prelude::*};
|
use gtk::{prelude::*, subclass::prelude::*};
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
|
|
||||||
|
use super::time_distance_detail;
|
||||||
|
|
||||||
pub struct DaySummaryPrivate {
|
pub struct DaySummaryPrivate {
|
||||||
date: gtk::Label,
|
date: gtk::Label,
|
||||||
}
|
}
|
||||||
|
@ -178,51 +180,10 @@ impl DayDetail {
|
||||||
|
|
||||||
s.append(&top_row);
|
s.append(&top_row);
|
||||||
|
|
||||||
/*
|
let records = view_model.time_distance_records();
|
||||||
records.into_iter().for_each(|record| {
|
for emseries::Record { data, .. } in records {
|
||||||
let record_view = match record {
|
s.append(&time_distance_detail(data));
|
||||||
Record {
|
|
||||||
data: ft_core::TraxRecord::BikeRide(record),
|
|
||||||
..
|
|
||||||
} => Some(
|
|
||||||
TimeDistanceView::new(ft_core::RecordType::BikeRide, record)
|
|
||||||
.upcast::<gtk::Widget>(),
|
|
||||||
),
|
|
||||||
Record {
|
|
||||||
data: ft_core::TraxRecord::Row(record),
|
|
||||||
..
|
|
||||||
} => Some(
|
|
||||||
TimeDistanceView::new(ft_core::RecordType::Row, record).upcast::<gtk::Widget>(),
|
|
||||||
),
|
|
||||||
Record {
|
|
||||||
data: ft_core::TraxRecord::Run(record),
|
|
||||||
..
|
|
||||||
} => Some(
|
|
||||||
TimeDistanceView::new(ft_core::RecordType::Row, record).upcast::<gtk::Widget>(),
|
|
||||||
),
|
|
||||||
Record {
|
|
||||||
data: ft_core::TraxRecord::Swim(record),
|
|
||||||
..
|
|
||||||
} => Some(
|
|
||||||
TimeDistanceView::new(ft_core::RecordType::Row, record).upcast::<gtk::Widget>(),
|
|
||||||
),
|
|
||||||
Record {
|
|
||||||
data: ft_core::TraxRecord::Walk(record),
|
|
||||||
..
|
|
||||||
} => Some(
|
|
||||||
TimeDistanceView::new(ft_core::RecordType::Row, record).upcast::<gtk::Widget>(),
|
|
||||||
),
|
|
||||||
_ => None,
|
|
||||||
};
|
|
||||||
|
|
||||||
if let Some(record_view) = record_view {
|
|
||||||
record_view.add_css_class("day-detail");
|
|
||||||
record_view.set_halign(gtk::Align::Start);
|
|
||||||
|
|
||||||
s.append(&record_view);
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
*/
|
|
||||||
|
|
||||||
s
|
s
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ mod text_entry;
|
||||||
pub use text_entry::{weight_field, TextEntry};
|
pub use text_entry::{weight_field, TextEntry};
|
||||||
|
|
||||||
mod time_distance;
|
mod time_distance;
|
||||||
pub use time_distance::{time_distance_summary, TimeDistanceView};
|
pub use time_distance::{time_distance_detail, time_distance_summary};
|
||||||
|
|
||||||
mod weight;
|
mod weight;
|
||||||
pub use weight::WeightLabel;
|
pub use weight::WeightLabel;
|
||||||
|
|
|
@ -18,10 +18,7 @@ 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 ft_core::TimeDistance;
|
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>,
|
||||||
|
@ -44,33 +41,11 @@ pub fn time_distance_summary(
|
||||||
text.map(|text| gtk::Label::new(Some(&text)))
|
text.map(|text| gtk::Label::new(Some(&text)))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default)]
|
pub fn time_distance_detail(record: ft_core::TimeDistance) -> gtk::Box {
|
||||||
pub struct TimeDistanceViewPrivate {
|
let layout = gtk::Box::builder()
|
||||||
#[allow(unused)]
|
.orientation(gtk::Orientation::Vertical)
|
||||||
record: RefCell<Option<TimeDistance>>,
|
.hexpand(true)
|
||||||
}
|
.build();
|
||||||
|
|
||||||
#[glib::object_subclass]
|
|
||||||
impl ObjectSubclass for TimeDistanceViewPrivate {
|
|
||||||
const NAME: &'static str = "TimeDistanceView";
|
|
||||||
type Type = TimeDistanceView;
|
|
||||||
type ParentType = gtk::Box;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ObjectImpl for TimeDistanceViewPrivate {}
|
|
||||||
impl WidgetImpl for TimeDistanceViewPrivate {}
|
|
||||||
impl BoxImpl for TimeDistanceViewPrivate {}
|
|
||||||
|
|
||||||
glib::wrapper! {
|
|
||||||
pub struct TimeDistanceView(ObjectSubclass<TimeDistanceViewPrivate>) @extends gtk::Box, gtk::Widget, @implements gtk::Orientable;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl TimeDistanceView {
|
|
||||||
pub fn new(record: TimeDistance) -> Self {
|
|
||||||
let s: Self = Object::builder().build();
|
|
||||||
s.set_orientation(gtk::Orientation::Vertical);
|
|
||||||
s.set_hexpand(true);
|
|
||||||
|
|
||||||
let first_row = gtk::Box::builder().homogeneous(true).build();
|
let first_row = gtk::Box::builder().homogeneous(true).build();
|
||||||
|
|
||||||
first_row.append(
|
first_row.append(
|
||||||
|
@ -80,14 +55,12 @@ impl TimeDistanceView {
|
||||||
.build(),
|
.build(),
|
||||||
);
|
);
|
||||||
|
|
||||||
/*
|
|
||||||
first_row.append(
|
first_row.append(
|
||||||
>k::Label::builder()
|
>k::Label::builder()
|
||||||
.halign(gtk::Align::Start)
|
.halign(gtk::Align::Start)
|
||||||
.label(format!("{:?}", type_))
|
.label(format!("{:?}", record.activity))
|
||||||
.build(),
|
.build(),
|
||||||
);
|
);
|
||||||
*/
|
|
||||||
|
|
||||||
first_row.append(
|
first_row.append(
|
||||||
>k::Label::builder()
|
>k::Label::builder()
|
||||||
|
@ -113,9 +86,9 @@ impl TimeDistanceView {
|
||||||
.build(),
|
.build(),
|
||||||
);
|
);
|
||||||
|
|
||||||
s.append(&first_row);
|
layout.append(&first_row);
|
||||||
|
|
||||||
s.append(
|
layout.append(
|
||||||
>k::Label::builder()
|
>k::Label::builder()
|
||||||
.halign(gtk::Align::Start)
|
.halign(gtk::Align::Start)
|
||||||
.label(
|
.label(
|
||||||
|
@ -126,7 +99,5 @@ impl TimeDistanceView {
|
||||||
)
|
)
|
||||||
.build(),
|
.build(),
|
||||||
);
|
);
|
||||||
|
layout
|
||||||
s
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue