Skip to content

fix harcoded altitude units#196

Merged
vide merged 2 commits intomainfrom
fix/harcoded-altitude-units
Mar 20, 2026
Merged

fix harcoded altitude units#196
vide merged 2 commits intomainfrom
fix/harcoded-altitude-units

Conversation

@MARMdeveloper
Copy link
Collaborator

Summary

Closes #195

Adds elevation unit conversion (meters ↔ feet) following the same logic as other units: if unit_of_length is mile, elevation is displayed in feet. Since TeslamateAPI does not convert elevation values, the conversion is implemented in UnitFormatter.

Changes

UnitFormatter

  • Added formatElevation(value: Int?, units: Units?) — formats and converts meters to feet when imperial
  • Added convertElevation(value: Float, units: Units?) — returns the numeric converted value for chart use
  • Added getElevationUnit(units: Units?) — returns "ft" or "m" for chart axis label

DriveDetailScreen

  • Replaced hardcoded "%,d m" in elevation stats (max, min, gain, loss) with UnitFormatter.formatElevation()
  • Updated ElevationChartCard to use UnitFormatter.getElevationUnit() and UnitFormatter.convertElevation() via convertValue lambda

StatsScreen

  • Replaced hardcoded "%,d m" in Records section (highest point, most climbing) with UnitFormatter.formatElevation()

DashboardScreen

  • Replaced harcoded function with UnitFormatter.formatElevation()
  • Fixed icon color to match accent color

MARMdeveloper and others added 2 commits March 14, 2026 20:38
… climbing record

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@vide vide force-pushed the fix/harcoded-altitude-units branch from 6b3e879 to c755ef3 Compare March 15, 2026 10:24
@vide
Copy link
Owner

vide commented Mar 15, 2026

Rebased onto latest main and fixed two bugs:

  • DriveDetailScreen: "Minimum" elevation stat was showing elevationMax instead of elevationMin (copy-paste error)
  • StatsScreen: "Most Climbing" record lost its + prefix when switching to UnitFormatter.formatElevation()

@vide vide merged commit 6d85207 into main Mar 20, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Altitude units not converted to feet

2 participants