Skip to content

Commit

Permalink
feat(parkings): replace decimal numbers with integers & make sure tha…
Browse files Browse the repository at this point in the history
…t free slots are always >= 0 #230  (#231)

* #230 - replace decimal numbers with integers at parking's page

* #230 - replace decimal numbers with integers at parking's page - code cleanup

* #230 - replace decimal numbers with integers at parking's page - make sure that free parking's slots're always => 0

* #230 - replace decimal numbers with integers at parking's page - make sure that free parking's slots're always => 0 - code cleanup
  • Loading branch information
mikolaj-jalocha authored Sep 25, 2024
1 parent 7663bf9 commit d824cd7
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
18 changes: 18 additions & 0 deletions lib/features/parking_chart/widgets/chart_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import "package:fast_immutable_collections/fast_immutable_collections.dart";
import "package:fl_chart/fl_chart.dart";
import "package:flutter/material.dart";

import "../../../theme/app_theme.dart";
import "../../parkings_view/models/parking.dart";
import "../chart_elements/chart_border.dart";
import "../chart_elements/chart_grid.dart";
Expand Down Expand Up @@ -39,6 +40,23 @@ class ChartWidget extends StatelessWidget {
maxX: chartData.maxX,
maxY: chartData.maxY(parking),
minY: 0,
lineTouchData: LineTouchData(
touchTooltipData: LineTouchTooltipData(
getTooltipItems: (touchedSpots) {
return touchedSpots.map((touchedSpot) {
final value =
touchedSpot.y.toInt(); // Convert double to int
return LineTooltipItem(
value.toString(),
TextStyle(
color: context.colorTheme.whiteSoap,
fontWeight: FontWeight.bold,
),
);
}).toList();
},
),
),
),
),
),
Expand Down
3 changes: 3 additions & 0 deletions lib/features/parkings_view/models/parking.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ class Parking with _$Parking implements GoogleNavigable {
return ParkingsConfig.rootUrl + photo.trim();
}

String get parsedNumberOfPlaces =>
numberOfPlaces.startsWith("-") ? "0" : numberOfPlaces;

double get latitude => double.tryParse(geoLat) ?? 0;
double get longitude => double.tryParse(geoLan) ?? 0;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ class _RightColumn extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.end,
children: [
Text(
parking.numberOfPlaces,
parking.parsedNumberOfPlaces,
style: isActive
? context.iParkingTheme.title.withoutShadows
: context.iParkingTheme.title,
Expand Down

0 comments on commit d824cd7

Please # to comment.