Skip to content

Commit

Permalink
adds unit to Watt
Browse files Browse the repository at this point in the history
  • Loading branch information
just-seba committed Oct 2, 2024
1 parent 0f7e3ae commit fb8c777
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion app/lib/application/backend_api/models.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
extension type const Watt(num value) implements num {
static const Watt zero = Watt(0);
static const unit = "W";
static const zero = Watt(0);

// Json serialization
factory Watt.fromJson(num json) => Watt(json);
Expand Down
6 changes: 3 additions & 3 deletions app/lib/ui/shared/unit_text.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ class UnitText extends StatelessWidget {
: value = wattHours,
unit = "Wh";

UnitText.power(Watt watts, {this.color, super.key})
: value = watts.value,
unit = "W";
const UnitText.power(Watt watts, {this.color, super.key})
: value = watts,
unit = Watt.unit;

UnitText.percentage(num percentage, {this.color, super.key})
: value = (percentage * 100).roundToDouble(),
Expand Down

0 comments on commit fb8c777

Please sign in to comment.