mirror of
https://github.com/wger-project/flutter.git
synced 2026-02-18 00:17:48 +01:00
Move milliseconds factor to a constant
This makes it less likely to run into weird bugs if we need to tweak the value in the future.
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
import 'consts.dart';
|
||||
|
||||
double chartGetInterval(DateTime first, DateTime last, {divider = 3}) {
|
||||
final dayDiff = last.difference(first);
|
||||
|
||||
return dayDiff.inMilliseconds == 0 ? 1000000 : dayDiff.inMilliseconds.abs() / divider;
|
||||
return dayDiff.inMilliseconds == 0
|
||||
? CHART_MILLISECOND_FACTOR
|
||||
: dayDiff.inMilliseconds.abs() / divider;
|
||||
}
|
||||
|
||||
@@ -112,3 +112,9 @@ const COLOR_SECONDARY_MUSCLES = Colors.orange;
|
||||
// Min account age to contribute exercises. Needs to be kept in sync with
|
||||
// the value on the backend
|
||||
const MIN_ACCOUNT_AGE = 14;
|
||||
|
||||
/// Factor to multiply / divide in the charts when converting dates to milliseconds
|
||||
/// from epoch since fl_charts does not support real time series charts and using
|
||||
/// the milliseconds themselves can cause the application to crash since it runs
|
||||
/// out of memory...
|
||||
const double CHART_MILLISECOND_FACTOR = 100000.0;
|
||||
|
||||
@@ -20,6 +20,7 @@ import 'package:fl_chart/fl_chart.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:wger/helpers/charts.dart';
|
||||
import 'package:wger/helpers/consts.dart';
|
||||
import 'package:wger/l10n/generated/app_localizations.dart';
|
||||
|
||||
class MeasurementOverallChangeWidget extends StatelessWidget {
|
||||
@@ -142,7 +143,7 @@ class _MeasurementChartWidgetFlState extends State<MeasurementChartWidgetFl> {
|
||||
widget._entries.last.date,
|
||||
widget._entries.first.date,
|
||||
)
|
||||
: 1000000,
|
||||
: CHART_MILLISECOND_FACTOR,
|
||||
),
|
||||
),
|
||||
leftTitles: AxisTitles(
|
||||
|
||||
@@ -78,13 +78,15 @@ List<Widget> getOverviewWidgetsSeries(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Indicator(
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
text: AppLocalizations.of(context).indicatorRaw,
|
||||
isSquare: true),
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
text: AppLocalizations.of(context).indicatorRaw,
|
||||
isSquare: true,
|
||||
),
|
||||
Indicator(
|
||||
color: Theme.of(context).colorScheme.tertiary,
|
||||
text: AppLocalizations.of(context).indicatorAvg,
|
||||
isSquare: true),
|
||||
color: Theme.of(context).colorScheme.tertiary,
|
||||
text: AppLocalizations.of(context).indicatorAvg,
|
||||
isSquare: true,
|
||||
),
|
||||
],
|
||||
),
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user