Compare commits

...

2 Commits

6 changed files with 106 additions and 53 deletions

2
Cargo.lock generated
View File

@ -936,7 +936,7 @@ checksum = "8fcfdc7a0362c9f4444381a9e697c79d435fe65b52a37466fc2c1184cee9edc6"
[[package]] [[package]]
name = "fitnesstrax" name = "fitnesstrax"
version = "0.3.0" version = "0.4.0"
dependencies = [ dependencies = [
"async-channel", "async-channel",
"async-trait", "async-trait",

View File

@ -185,6 +185,16 @@ rec {
# File a bug if you depend on any for non-debug work! # File a bug if you depend on any for non-debug work!
debug = internal.debugCrate { inherit packageId; }; debug = internal.debugCrate { inherit packageId; };
}; };
"icon-test" = rec {
packageId = "icon-test";
build = internal.buildRustCrateWithFeatures {
packageId = "icon-test";
};
# Debug support which might change between releases.
# File a bug if you depend on any for non-debug work!
debug = internal.debugCrate { inherit packageId; };
};
"ifc" = rec { "ifc" = rec {
packageId = "ifc"; packageId = "ifc";
build = internal.buildRustCrateWithFeatures { build = internal.buildRustCrateWithFeatures {
@ -2979,7 +2989,7 @@ rec {
}; };
"fitnesstrax" = rec { "fitnesstrax" = rec {
crateName = "fitnesstrax"; crateName = "fitnesstrax";
version = "0.3.0"; version = "0.4.0";
edition = "2021"; edition = "2021";
crateBin = [ crateBin = [
{ {
@ -3023,6 +3033,11 @@ rec {
name = "ft-core"; name = "ft-core";
packageId = "ft-core"; packageId = "ft-core";
} }
{
name = "gdk4";
packageId = "gdk4";
rename = "gdk";
}
{ {
name = "gio"; name = "gio";
packageId = "gio"; packageId = "gio";
@ -5713,6 +5728,46 @@ rec {
} }
]; ];
};
"icon-test" = rec {
crateName = "icon-test";
version = "0.1.0";
edition = "2021";
crateBin = [
{
name = "icon-test";
path = "src/main.rs";
requiredFeatures = [ ];
}
];
# We can't filter paths with references in Nix 2.4
# See https://github.com/NixOS/nix/issues/5410
src = if ((lib.versionOlder builtins.nixVersion "2.4pre20211007") || (lib.versionOlder "2.5" builtins.nixVersion ))
then lib.cleanSourceWith { filter = sourceFilter; src = ./icon-test; }
else ./icon-test;
dependencies = [
{
name = "gio";
packageId = "gio";
}
{
name = "glib";
packageId = "glib";
}
{
name = "gtk4";
packageId = "gtk4";
rename = "gtk";
features = [ "v4_10" ];
}
{
name = "libadwaita";
packageId = "libadwaita";
rename = "adw";
features = [ "v1_4" ];
}
];
}; };
"idna 0.1.5" = rec { "idna 0.1.5" = rec {
crateName = "idna"; crateName = "idna";

View File

@ -1,6 +1,6 @@
[package] [package]
name = "fitnesstrax" name = "fitnesstrax"
version = "0.3.0" version = "0.4.0"
edition = "2021" edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View File

@ -3,15 +3,16 @@
<gresource prefix="/com/luminescent-dreams/fitnesstrax/"> <gresource prefix="/com/luminescent-dreams/fitnesstrax/">
<file>style.css</file> <file>style.css</file>
</gresource> </gresource>
<gresource prefix="/com/luminescent-dreams/fitnesstrax/icons/scalable/actions/">
<file preprocess="xml-stripblanks">walking2-symbolic.svg</file> <gresource prefix="/com/luminescent-dreams/fitnesstrax/icons/scalable/actions">
<file preprocess="xml-stripblanks">cycling-symbolic.svg</file>
</gresource> </gresource>
<gresource prefix="/com/luminescent-dreams/fitnesstrax/icons/scalable/actions"> <gresource prefix="/com/luminescent-dreams/fitnesstrax/icons/scalable/actions">
<file preprocess="xml-stripblanks">running-symbolic.svg</file> <file preprocess="xml-stripblanks">running-symbolic.svg</file>
</gresource> </gresource>
<gresource prefix="/com/luminescent-dreams/fitnesstrax/icons/scalable/actions"> <gresource prefix="/com/luminescent-dreams/fitnesstrax/icons/scalable/actions/">
<file preprocess="xml-stripblanks">cycling-symbolic.svg</file> <file preprocess="xml-stripblanks">walking-symbolic.svg</file>
</gresource> </gresource>
</gresources> </gresources>

View File

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

View File

@ -349,56 +349,53 @@ where
AddRow: Fn(Record<TraxRecord>) + 'static, AddRow: Fn(Record<TraxRecord>) + 'static,
{ {
let add_row = Rc::new(add_row); let add_row = Rc::new(add_row);
/*
let walking_button = gtk::Button::builder()
.icon_name("walking2-symbolic")
.width_request(64)
.height_request(64)
.build();
walking_button.connect_clicked({
let view_model = view_model.clone();
let add_row = add_row.clone();
move |_| {
let workout = view_model.new_time_distance(TimeDistanceActivity::Walking);
add_row(workout.map(TraxRecord::TimeDistance));
}
});
let running_button = gtk::Button::builder()
.icon_name("running-symbolic")
.width_request(64)
.height_request(64)
.build();
running_button.connect_clicked({
let view_model = view_model.clone();
move |_| {
let workout = view_model.new_time_distance(TimeDistanceActivity::Running);
add_row(workout.map(TraxRecord::TimeDistance));
}
});
*/
let biking_button = gtk::Button::builder()
.icon_name("cycling-symbolic")
.width_request(64)
.height_request(64)
.build();
biking_button.connect_clicked({
let view_model = view_model.clone();
move |_| {
let workout = view_model.new_time_distance(TimeDistanceActivity::Biking);
add_row(workout.map(TraxRecord::TimeDistance));
}
});
let layout = gtk::Box::builder() let layout = gtk::Box::builder()
.orientation(gtk::Orientation::Vertical)
.build();
let row = gtk::Box::builder()
.orientation(gtk::Orientation::Horizontal) .orientation(gtk::Orientation::Horizontal)
.build(); .build();
row.append(&biking_button);
layout.append(&row); for (activity, icon, label) in [
(
TimeDistanceActivity::Biking,
"cycling-symbolic",
"Bike Ride",
),
(TimeDistanceActivity::Rowing, "rowing-symbolic", "Rowing"),
(TimeDistanceActivity::Running, "running-symbolic", "Run"),
(TimeDistanceActivity::Swimming, "swimming-symbolic", "Swim"),
(TimeDistanceActivity::Walking, "walking-symbolic", "Walk"),
] {
let button = workout_button(activity, icon, label, view_model.clone(), {
let add_row = add_row.clone();
move |record| add_row(record)
});
layout.append(&button);
}
layout layout
} }
fn workout_button<AddRow>(
activity: TimeDistanceActivity,
_icon: &str,
label: &str,
view_model: DayDetailViewModel,
add_row: AddRow,
) -> gtk::Button
where
AddRow: Fn(Record<TraxRecord>) + 'static,
{
let button = gtk::Button::builder()
.label(label)
.width_request(64)
.height_request(64)
.build();
button.connect_clicked({
let view_model = view_model.clone();
move |_| {
let workout = view_model.new_time_distance(activity);
add_row(workout.map(TraxRecord::TimeDistance));
}
});
button
}