Build some convenienc functions for measurement entry fields
Move the weight field into text_entry
This commit is contained in:
parent
525cc88c25
commit
0f5af82cb5
|
@ -22,7 +22,6 @@ use crate::{
|
|||
},
|
||||
view_models::DayDetailViewModel,
|
||||
};
|
||||
use dimensioned::si;
|
||||
use ft_core::{RecordType, TraxRecord};
|
||||
use glib::Object;
|
||||
use gtk::{prelude::*, subclass::prelude::*};
|
||||
|
|
|
@ -27,7 +27,7 @@ mod steps;
|
|||
pub use steps::{steps_editor, Steps};
|
||||
|
||||
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;
|
||||
pub use time_distance::{time_distance_detail, time_distance_summary};
|
||||
|
|
|
@ -17,6 +17,7 @@ You should have received a copy of the GNU General Public License along with Fit
|
|||
use crate::types::{
|
||||
DistanceFormatter, DurationFormatter, FormatOption, ParseError, TimeFormatter, WeightFormatter,
|
||||
};
|
||||
use dimensioned::si;
|
||||
use gtk::prelude::*;
|
||||
use std::{cell::RefCell, rc::Rc};
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@ You should have received a copy of the GNU General Public License along with Fit
|
|||
// use crate::components::{EditView, ParseError, TextEntry};
|
||||
// use chrono::{Local, NaiveDate};
|
||||
// use dimensioned::si;
|
||||
use crate::components::distance_field;
|
||||
use dimensioned::si;
|
||||
use ft_core::{RecordType, TimeDistance};
|
||||
use glib::Object;
|
||||
|
@ -102,5 +103,54 @@ pub fn time_distance_detail(type_: ft_core::RecordType, record: ft_core::TimeDis
|
|||
)
|
||||
.build(),
|
||||
);
|
||||
|
||||
layout
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct TimeDistanceEditPrivate {
|
||||
type_: RefCell<Option<ft_core::RecordType>>,
|
||||
record: RefCell<Option<ft_core::RecordType>>,
|
||||
}
|
||||
|
||||
#[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 {
|
||||
fn empty<OnUpdate>(on_update: OnUpdate) -> Self
|
||||
where
|
||||
OnUpdate: Fn(&ft_core::RecordType, &ft_core::TimeDistance),
|
||||
{
|
||||
let s = Self::default();
|
||||
|
||||
s
|
||||
}
|
||||
|
||||
/*
|
||||
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) {
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ use crate::{
|
|||
components::TextEntry,
|
||||
types::{FormatOption, WeightFormatter},
|
||||
};
|
||||
use dimensioned::si;
|
||||
use gtk::prelude::*;
|
||||
|
||||
pub struct WeightLabel {
|
||||
|
|
|
@ -56,6 +56,7 @@ impl ObjectSubclass for HistoricalViewPrivate {
|
|||
.single_click_activate(true)
|
||||
.build(),
|
||||
};
|
||||
|
||||
factory.connect_bind({
|
||||
let app = s.app.clone();
|
||||
move |_, list_item| {
|
||||
|
@ -122,9 +123,7 @@ impl HistoricalView {
|
|||
s.imp().list_view.connect_activate({
|
||||
let on_select_day = on_select_day.clone();
|
||||
move |s, idx| {
|
||||
// This gets triggered whenever the user clicks on an item on the list. What we
|
||||
// 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.
|
||||
// This gets triggered whenever the user clicks on an item on the list.
|
||||
let item = s.model().unwrap().item(idx).unwrap();
|
||||
let records = item.downcast_ref::<DayRecords>().unwrap();
|
||||
on_select_day(records.date(), records.records());
|
||||
|
|
Loading…
Reference in New Issue