Skip to content

Commit 85549b4

Browse files
Jashan32marcnause
authored andcommitted
update Y-axis label when temperature unit changes
1 parent 995adbf commit 85549b4

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

lib/view/thermometer_screen.dart

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,7 @@ class _ThermometerScreenState extends State<ThermometerScreen> {
339339
Widget _buildChartSection() {
340340
return Consumer<ThermometerStateProvider>(
341341
builder: (context, provider, child) {
342+
final unit = context.watch<ThermometerConfigProvider>().config.unit;
342343
final screenWidth = MediaQuery.of(context).size.width;
343344
final cardMargin = screenWidth < 400 ? 8.0 : 12.0;
344345
final cardPadding = screenWidth < 400 ? 2.0 : 5.0;
@@ -353,8 +354,8 @@ class _ThermometerScreenState extends State<ThermometerScreen> {
353354
color: chartBackgroundColor,
354355
borderRadius: BorderRadius.zero,
355356
),
356-
child:
357-
_buildChart(screenWidth, maxTime, minTime, timeInterval, spots),
357+
child: _buildChart(
358+
screenWidth, maxTime, minTime, timeInterval, spots, unit),
358359
);
359360
},
360361
);
@@ -394,7 +395,7 @@ class _ThermometerScreenState extends State<ThermometerScreen> {
394395
}
395396

396397
Widget _buildChart(double screenWidth, double maxTime, double minTime,
397-
double timeInterval, List<FlSpot> spots) {
398+
double timeInterval, List<FlSpot> spots, String unit) {
398399
final chartFontSize = screenWidth < 400
399400
? 8.0
400401
: screenWidth < 600
@@ -441,7 +442,9 @@ class _ThermometerScreenState extends State<ThermometerScreen> {
441442
),
442443
leftTitles: AxisTitles(
443444
axisNameWidget: Text(
444-
appLocalizations.celsius,
445+
unit == "Fahrenheit"
446+
? appLocalizations.fahrenheitUnit
447+
: appLocalizations.celsius,
445448
style: TextStyle(
446449
fontSize: axisNameFontSize,
447450
color: chartTextColor,

0 commit comments

Comments
 (0)