# ๐๏ธ BMI Calculator
[](https://kotlinlang.org)
[](https://developer.android.com/jetpack/compose)
[](https://m3.material.io/)
[](LICENSE)
Modern Android aplikasi untuk menghitung Body Mass Index (BMI) dengan antarmuka yang clean dan intuitif menggunakan Jetpack Compose dan Material Design 3.

---
## ๐ Daftar Isi
- [Fitur](#-fitur)
- [Screenshots](#-screenshots)
- [Teknologi](#-teknologi)
- [Arsitektur](#-arsitektur)
- [Instalasi](#-instalasi)
- [Cara Menggunakan](#-cara-menggunakan)
- [Testing](#-testing)
- [Struktur Project](#-struktur-project)
- [Kategori BMI](#-kategori-bmi)
- [Formula Perhitungan](#-formula-perhitungan)
- [Kontribusi](#-kontribusi)
- [Lisensi](#-lisensi)
- [Kontak](#-kontak)
---
## โจ Fitur
### ๐ฏ Core Features
- โ
**Perhitungan BMI Akurat** - Formula standar WHO untuk Metric dan Imperial
- โ
**Dual Unit System** - Support Metric (kg, cm) dan Imperial (lb, in)
- โ
**Kategori BMI** - Underweight, Normal, Overweight, Obese dengan color coding
- โ
**Healthy Weight Range** - Menampilkan rentang berat ideal berdasarkan tinggi
- โ
**Input Validation** - Validasi real-time untuk input yang valid
- โ
**Error Handling** - Error messages yang jelas dan helpful
### ๐จ UI/UX Features
- โ
**Modern UI** - Jetpack Compose dengan Material Design 3
- โ
**Smooth Animations** - Spring animations untuk hasil BMI
- โ
**Clean Design** - Minimalist interface dengan visual hierarchy yang jelas
- โ
**Material Icons** - Icon yang meaningful untuk setiap elemen
- โ
**Welcome Screen** - Onboarding screen dengan ilustrasi
- โ
**Responsive Layout** - Adaptive untuk berbagai ukuran layar
- โ
**Color-coded Results** - Visual feedback berdasarkan kategori BMI
### ๐ง Technical Features
- โ
**Jetpack Compose** - 100% Compose UI (no XML layouts)
- โ
**Material Design 3** - Latest design system
- โ
**Type Safety** - Kotlin with strong typing
- โ
**Unit Tested** - 93+ test cases dengan coverage >90%
- โ
**Edge-to-Edge** - Modern Android edge-to-edge support
- โ
**No Dependencies** - Pure Android SDK (no third-party libraries)
---
## ๐ฑ Screenshots
### Welcome Screen
### Main Calculator
### Result Display
---
## ๐ Teknologi
### Core Technologies
| Technology | Version | Purpose |
|------------|---------|---------|
| **Kotlin** | 1.9+ | Programming language |
| **Jetpack Compose** | 2025.11 | Modern UI toolkit |
| **Material Design 3** | Latest | Design system |
| **Android SDK** | Min 24, Target 36 | Android platform |
| **JUnit 4** | 4.13.2 | Unit testing |
### Key Libraries
```kotlin
// Compose BOM
implementation(platform("androidx.compose:compose-bom:2025.11.00"))
// Compose Core
implementation("androidx.compose.ui:ui")
implementation("androidx.compose.material3:material3")
implementation("androidx.compose.material:material-icons-extended")
// Activity Compose
implementation("androidx.activity:activity-compose:1.11.0")
// Core
implementation("androidx.core:core-ktx:1.17.0")
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.9.4")
```
### Development Tools
- **Gradle** 8.x - Build system
- **Android Studio** Koala+ - IDE
- **Git** - Version control
---
## ๐ Arsitektur
### Project Structure
```
app/
โโโ src/
โ โโโ main/
โ โ โโโ java/com/example/tiptime/
โ โ โ โโโ MainActivity.kt # Main entry point
โ โ โ โโโ WelcomeActivity.kt # Welcome screen
โ โ โ โโโ model/
โ โ โ โ โโโ BmiData.kt # BMI data class
โ โ โ โ โโโ BmiCategory.kt # BMI categories enum
โ โ โ โ โโโ UnitSystem.kt # Metric/Imperial enum
โ โ โ โโโ ui/
โ โ โ โ โโโ BmiCalculatorScreen.kt # Main calculator UI
โ โ โ โ โโโ theme/
โ โ โ โ โโโ Color.kt # Color definitions
โ โ โ โ โโโ Theme.kt # App theme
โ โ โ โ โโโ Type.kt # Typography
โ โ โ โโโ utils/
โ โ โ โโโ BmiCalculator.kt # BMI calculation logic
โ โ โโโ res/
โ โ โโโ drawable/
โ โ โ โโโ image_bmi.png # Welcome illustration
โ โ โโโ values/
โ โ โโโ strings.xml # String resources
โ โโโ test/
โ โโโ java/com/example/tiptime/
โ โโโ utils/
โ โ โโโ BmiCalculatorTest.kt # 43 unit tests
โ โโโ model/
โ โโโ BmiCategoryTest.kt # 30+ unit tests
โ โโโ BmiDataTest.kt # 10 unit tests
โ โโโ UnitSystemTest.kt # 10 unit tests
```
### Design Pattern
- **MVVM-like Structure** - Separation of UI and business logic
- **Single Activity** - Modern Android navigation
- **Stateless Composables** - Unidirectional data flow
- **Utility Classes** - Pure functions for calculations
- **Material Design** - Following Material 3 guidelines
---
## ๐ฟ Instalasi
### Prerequisites
- **Android Studio** Koala (2024.1.1) atau lebih baru
- **JDK** 17 atau lebih baru
- **Android SDK** API 24+ (Android 7.0)
- **Git** untuk clone repository
### Clone & Build
```bash
# 1. Clone repository
git clone https://github.com/username/bmi-calculator.git
cd bmi-calculator
# 2. Open di Android Studio
# File โ Open โ Pilih folder project
# 3. Sync Gradle
# Android Studio akan otomatis sync dependencies
# 4. Build project
./gradlew build
# Windows:
gradlew.bat build
# 5. Run aplikasi
# Pilih device/emulator โ Click Run (โถ๏ธ)
```
### Install APK
```bash
# Build debug APK
./gradlew assembleDebug
# APK tersedia di:
# app/build/outputs/apk/debug/app-debug.apk
# Install ke device
./gradlew installDebug
```
---
## ๐ Cara Menggunakan
### Langkah Penggunaan
1. **Buka Aplikasi**
- Lihat welcome screen
- Tap "Get Started"
2. **Pilih Unit System**
- **Metric**: kg & cm
- **Imperial**: lb & in
3. **Input Data**
- Masukkan **Weight** (berat badan)
- Masukkan **Height** (tinggi badan)
4. **Hitung BMI**
- Tap tombol **"Calculate BMI"**
- Hasil akan muncul dengan animasi
5. **Lihat Hasil**
- **BMI Value** - Nilai BMI Anda
- **Category** - Underweight/Normal/Overweight/Obese
- **Healthy Range** - Rentang berat ideal Anda
- **BMI Categories** - Info kategori BMI
### Input Validation
| System | Weight Range | Height Range |
|----------|--------------|--------------|
| Metric | 1-500 kg | 50-300 cm |
| Imperial | 2-1100 lb | 20-120 in |
---
## ๐งช Testing
### Unit Tests
Project ini memiliki **93+ unit tests** dengan coverage >90%.
#### Jalankan Test
```bash
# Command Line
./gradlew test
# Windows
gradlew.bat test
# Lihat HTML Report
# app/build/reports/tests/test/index.html
```
#### Test Coverage
| File | Tests | Coverage |
|------|-------|----------|
| `BmiCalculatorTest.kt` | 43 | Perhitungan, validasi, boundary |
| `BmiCategoryTest.kt` | 30+ | Kategori, warna, display |
| `BmiDataTest.kt` | 10 | Data class, equality |
| `UnitSystemTest.kt` | 10 | Enum values |
#### Contoh Test Cases
```kotlin
// Test perhitungan BMI
@Test
fun calculateBmi_metric_normal_returnsCorrectBmi() {
// 70 kg, 175 cm -> BMI = 22.86 (Normal)
val result = BmiCalculator.calculateBmi(70.0, 175.0, UnitSystem.METRIC)
assertEquals(22.86, result.bmi, 0.01)
assertEquals(BmiCategory.NORMAL, result.category)
}
// Test boundary values
@Test
fun fromBmi_exactNormalLowerBoundary_returnsNormal() {
// BMI 18.5 (tepat batas bawah normal)
assertEquals(BmiCategory.NORMAL, BmiCategory.fromBmi(18.5))
}
```
Untuk panduan lengkap, baca: **[TESTING_GUIDE.md](TESTING_GUIDE.md)**
---
## ๐ Kategori BMI
Berdasarkan standar **WHO (World Health Organization)**:
| Kategori | BMI Range | Color | Status |
|----------|-----------|-------|--------|
| **Underweight** | < 18.5 | ๐ต Blue | Berat badan kurang |
| **Normal** | 18.5 - 24.9 | ๐ข Green | Berat badan ideal |
| **Overweight** | 25.0 - 29.9 | ๐ Orange | Kelebihan berat badan |
| **Obese** | โฅ 30.0 | ๐ด Red | Obesitas |
### Visual Color Coding
```kotlin
val UnderweightColor = Color(0xFF3B82F6) // Blue
val NormalColor = Color(0xFF10B981) // Green
val OverweightColor = Color(0xFFF59E0B) // Orange
val ObeseColor = Color(0xFFEF4444) // Red
```
---
## ๐ฌ Formula Perhitungan
### Metric System (kg, cm)
```
BMI = weight (kg) / (height (m))ยฒ
```
**Contoh:**
- Weight: 70 kg
- Height: 175 cm = 1.75 m
- BMI = 70 / (1.75)ยฒ = 22.86
### Imperial System (lb, in)
```
BMI = (weight (lb) / (height (in))ยฒ) ร 703
```
**Contoh:**
- Weight: 150 lb
- Height: 67 in
- BMI = (150 / (67)ยฒ) ร 703 = 23.49
### Healthy Weight Range
```kotlin
// Untuk BMI 18.5 - 24.9
minWeight = 18.5 ร (height)ยฒ
maxWeight = 24.9 ร (height)ยฒ
```
---
## ๐จ Theme & Colors
### Color Palette
```kotlin
// Primary Colors
val PrimaryBlue = Color(0xFF2563EB)
val PrimaryBlueDark = Color(0xFF1E40AF)
val BackgroundLight = Color(0xFFF8FAFC)
// Text Colors
val TextPrimary = Color(0xFF1E293B)
val TextSecondary = Color(0xFF64748B)
// BMI Category Colors
val UnderweightColor = Color(0xFF3B82F6) // Blue
val NormalColor = Color(0xFF10B981) // Green
val OverweightColor = Color(0xFFF59E0B) // Orange
val ObeseColor = Color(0xFFEF4444) // Red
```
### Material Icons
- **FitnessCenter** - App header icon
- **MonitorWeight** - Weight input icon
- **Height** - Height input icon
- **Calculate** - Calculate button icon
---
## ๐ง Configuration
### Build Configuration
```kotlin
android {
compileSdk = 36
defaultConfig {
applicationId = "com.example.tiptime"
minSdk = 24
targetSdk = 36
versionCode = 1
versionName = "1.0"
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = "17"
}
}
```
### Gradle Version
- **Gradle**: 8.9
- **AGP**: 8.7.3
- **Kotlin**: 2.0.21
---
## ๐ค Kontribusi
Kontribusi sangat diterima! Berikut cara berkontribusi:
### Steps
1. **Fork** repository ini
2. **Create** feature branch (`git checkout -b feature/AmazingFeature`)
3. **Commit** changes (`git commit -m 'Add some AmazingFeature'`)
4. **Push** to branch (`git push origin feature/AmazingFeature`)
5. **Open** Pull Request
### Guidelines
- โ
Ikuti Kotlin coding conventions
- โ
Tulis unit tests untuk fitur baru
- โ
Update dokumentasi jika perlu
- โ
Pastikan semua tests pass
- โ
Gunakan commit messages yang jelas
### Bug Reports
Jika menemukan bug, silakan buat issue dengan detail:
- Deskripsi bug
- Steps to reproduce
- Expected vs actual behavior
- Screenshots (jika ada)
- Device & Android version
---
## ๐ Changelog
### Version 1.0.0 (November 2025)
**Initial Release**
โจ **Features:**
- BMI calculation (Metric & Imperial)
- Welcome screen dengan ilustrasi
- Modern Material Design 3 UI
- Input validation
- Healthy weight range
- Animated results
- BMI categories info card
๐งช **Tests:**
- 93+ unit tests
- >90% code coverage
- Boundary value testing
- Edge case handling
๐จ **UI/UX:**
- Clean, modern interface
- Color-coded categories
- Material icons
- Smooth animations
- Responsive layout
---
## ๐ Lisensi
```
Copyright (C) 2025 BMI Calculator Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
```
Project ini menggunakan **Apache License 2.0**. Lihat file [LICENSE](LICENSE) untuk detail lengkap.
---
## ๐ฅ Authors
**[NPM: ISI NPM ANDA]**
**[Nama: ISI NAMA ANDA]**
---
## ๐ Kontak
- **Email**: your.email@example.com
- **GitHub**: [@yourusername](https://github.com/yourusername)
- **LinkedIn**: [Your Name](https://linkedin.com/in/yourprofile)
---
## ๐ Acknowledgments
- **Android Team** - Jetpack Compose & Material Design 3
- **WHO** - BMI classification standards
- **Material Design** - Design guidelines & icons
- **Kotlin Team** - Amazing programming language
- **Open Source Community** - Inspiration & support
---
## ๐ Resources
### Documentation
- [Jetpack Compose](https://developer.android.com/jetpack/compose)
- [Material Design 3](https://m3.material.io/)
- [Kotlin Language](https://kotlinlang.org/docs/home.html)
### Related Projects
- [Android Compose Samples](https://github.com/android/compose-samples)
- [Material 3 Catalog](https://github.com/material-components/material-components-android)
### Learning Resources
- [Android Basics with Compose](https://developer.android.com/courses/android-basics-compose/course)
- [Kotlin Bootcamp](https://developer.android.com/courses/kotlin-bootcamp/overview)
---
## โญ Star History
Jika project ini membantu Anda, berikan โญ di GitHub!
[](https://star-history.com/#username/bmi-calculator&Date)
---
## ๐ Future Enhancements
Rencana pengembangan untuk versi mendatang:
- [ ] Dark mode support
- [ ] BMI history tracking
- [ ] Export hasil ke PDF
- [ ] Grafik BMI over time
- [ ] Multi-language support (Indonesian, English)
- [ ] Widget untuk home screen
- [ ] Apple Health / Google Fit integration
- [ ] BMI trends & analytics
- [ ] Recommendations berdasarkan BMI
- [ ] Share hasil ke social media
---