Skip to content

Repository files navigation

Multi-Unit Converter

A clean, modern unit conversion application built with Jetpack Compose and Material 3. This project demonstrates a generic, scalable architecture for handling various measurement types including Length, Mass, Area, Data, Speed, Time, and Temperature.


✨ Features

  • Generic Conversion Logic
    Uses a shared interface for all units, making it easy to add new categories without duplicating UI code.

  • Real-time Calculation
    Inputs are processed instantly using derivedStateOf for a seamless user experience.

  • Material 3 UI
    Features a modern interface with scrollable category chips and integrated dropdowns within input fields.

  • Precision Handling
    Automatically formats results and trims unnecessary trailing zeros for a clean display.

  • Swap Functionality
    Quickly switch between From and To units with a single tap.


🛠️ Architecture

The app follows a Zero-Repetition Architecture.

Instead of writing separate UI logic for every measurement category, a single reusable composable named ConverterContent handles all conversion operations by accepting any class implementing the ConversionUnit interface.


📦 Supported Categories

📏 Length

Meters, Kilometers, Inches, Feet, Miles, Centimeters, and more.

⚖️ Mass

Grams, Kilograms, Pounds, Ounces, Tons.

📐 Area

Square Meters, Acres, Hectares, Square Feet.

💾 Data

Bytes, KB, MB, GB, TB.

🚗 Speed

Meters per Second, Kilometers per Hour, Miles per Hour.

⏱️ Time

Seconds, Minutes, Hours, Days.

🌡️ Temperature

Celsius, Fahrenheit, Kelvin with custom offset-based conversion handling.


🚀 Getting Started

Prerequisites

  • Android Studio Ladybug or newer
  • Kotlin 1.9.0+
  • Minimum SDK 24+

📥 Installation

  1. Clone the repository
git clone https://github.com/yourusername/unit-converter.git
  1. Open the project in Android Studio

  2. Sync Gradle files

  3. Run the app on an emulator or physical device


📖 Code Highlights

🔹 The Conversion Interface

This shared interface allows all measurement categories to use the same UI and conversion engine.

interface ConversionUnit {
    val symbol: String
    val theRatio: Double
    val offset: Double
        get() = 0.0
}

📱 Screenshots

App Screenshot

🔹 Generic Conversion Formula

The app uses a base-unit normalization strategy for accurate conversion across different scales.

$$Result = \frac{(Input - SourceOffset)}{SourceRatio} \times TargetRatio + TargetOffset$$


🎨 Tech Stack

  • Kotlin
  • Jetpack Compose
  • Material 3
  • State Management with Compose APIs
  • derivedStateOf for optimized recomposition

📌 Future Improvements

  • Currency conversion with live exchange rates
  • Scientific notation support
  • History and favorites
  • Tablet and foldable optimization
  • Unit search functionality

👤 Author

Manish Kumar Shrestha
Mobile and Game Developer

Built with ❤️ in Kathmandu, Nepal.

About

Made in pure Kotlin, with basic calculations and Jetpack Compose Composables.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages