Show summaries of all time-distance workouts
This commit is contained in:
parent
b5c42e3ac3
commit
291dc32fe5
|
@ -24,7 +24,7 @@ use crate::{
|
||||||
view_models::DayDetailViewModel,
|
view_models::DayDetailViewModel,
|
||||||
};
|
};
|
||||||
use emseries::{Record, RecordId};
|
use emseries::{Record, RecordId};
|
||||||
use ft_core::{TimeDistanceActivity, TraxRecord};
|
use ft_core::{TimeDistanceActivity, TraxRecord, TIME_DISTANCE_ACTIVITIES};
|
||||||
use glib::Object;
|
use glib::Object;
|
||||||
use gtk::{prelude::*, subclass::prelude::*};
|
use gtk::{prelude::*, subclass::prelude::*};
|
||||||
use std::{cell::RefCell, rc::Rc};
|
use std::{cell::RefCell, rc::Rc};
|
||||||
|
@ -105,15 +105,18 @@ impl DaySummary {
|
||||||
row.append(&label);
|
row.append(&label);
|
||||||
self.append(&row);
|
self.append(&row);
|
||||||
|
|
||||||
let biking_summary = view_model.time_distance_summary(TimeDistanceActivity::BikeRide);
|
for activity in TIME_DISTANCE_ACTIVITIES {
|
||||||
|
let summary = view_model.time_distance_summary(activity);
|
||||||
if let Some(label) = time_distance_summary(
|
if let Some(label) = time_distance_summary(
|
||||||
DistanceFormatter::from(biking_summary.0),
|
activity,
|
||||||
DurationFormatter::from(biking_summary.1),
|
DistanceFormatter::from(summary.0),
|
||||||
|
DurationFormatter::from(summary.1),
|
||||||
) {
|
) {
|
||||||
self.append(&label);
|
self.append(&label);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct DayDetailPrivate {}
|
pub struct DayDetailPrivate {}
|
||||||
|
|
|
@ -25,17 +25,27 @@ use gtk::{prelude::*, subclass::prelude::*};
|
||||||
use std::{cell::RefCell, rc::Rc};
|
use std::{cell::RefCell, rc::Rc};
|
||||||
|
|
||||||
pub fn time_distance_summary(
|
pub fn time_distance_summary(
|
||||||
|
activity: TimeDistanceActivity,
|
||||||
distance: DistanceFormatter,
|
distance: DistanceFormatter,
|
||||||
duration: DurationFormatter,
|
duration: DurationFormatter,
|
||||||
) -> Option<gtk::Label> {
|
) -> Option<gtk::Label> {
|
||||||
let text = match (*distance > si::M, *duration > si::S) {
|
let text = match (*distance > si::M, *duration > si::S) {
|
||||||
(true, true) => Some(format!(
|
(true, true) => Some(format!(
|
||||||
"{} of biking in {}",
|
"{} of {:?} in {}",
|
||||||
distance.format(FormatOption::Full),
|
distance.format(FormatOption::Full),
|
||||||
|
activity,
|
||||||
duration.format(FormatOption::Full)
|
duration.format(FormatOption::Full)
|
||||||
)),
|
)),
|
||||||
(true, false) => Some(format!("{} of biking", distance.format(FormatOption::Full))),
|
(true, false) => Some(format!(
|
||||||
(false, true) => Some(format!("{} of biking", duration.format(FormatOption::Full))),
|
"{} of {:?}",
|
||||||
|
distance.format(FormatOption::Full),
|
||||||
|
activity
|
||||||
|
)),
|
||||||
|
(false, true) => Some(format!(
|
||||||
|
"{} of {:?}",
|
||||||
|
duration.format(FormatOption::Full),
|
||||||
|
activity
|
||||||
|
)),
|
||||||
(false, false) => None,
|
(false, false) => None,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue