/Foody

Android application demonstrating the use of JetPack Compose with Koin, Ktor, SqlDelight, Navigation Component and MVVM architecture.

Primary LanguageKotlin

Foody

Kotlin Jetpack Compose Android Release

Real world Android application demonstrating the use of JetPack Compose with Koin, Ktor,SqlDelight, Navigation Component and MVVM architecture.

Foody supports almost all screen sizes from phones in portrait and landscape to foldable phones and tablets. It also supports light and dark theme.

Screenshots

Portrait

Landscape

Foldable / Tablet

Api

This project is using the API provided by themealdb.com

Compose Previews

FontScalePreviews, ThemePreviews and ScreenPreviews annotations are added for better previews.

@Preview(name = "Default Font Size", fontScale = 1f)
@Preview(name = "Medium Font Size", fontScale = 1.5f)
@Preview(name = "Large Font Size", fontScale = 2f)
annotation class FontScalePreviews
@Preview(name = "Light Theme")
@Preview(name = "Dark Theme", uiMode = Configuration.UI_MODE_NIGHT_YES, backgroundColor = 0xFF000000)
annotation class ThemePreviews
@Preview(showSystemUi = true, device = "spec:width=411dp,height=891dp")
@Preview(showSystemUi = true, device = "spec:width=673.5dp,height=841dp,dpi=480,orientation=landscape")
@Preview(showSystemUi = true, device = "spec:width=1280dp,height=800dp,dpi=480")
@Preview(showSystemUi = true, device = "spec:width=1920dp,height=1080dp,dpi=480")
annotation class ScreenPreviews

PreBuild

The preBuild depends on 2 tasks: ktlint and Detekt. You can manually run the tasks with ./gradlew ktlintFormat and ./gradlew detekt

Koin

Verify Koin configuration

@Test
fun checkKoinModule() {
  appModule.verify(
    extraTypes = listOf(
      io.ktor.client.engine.HttpClientEngine::class,
      io.ktor.client.HttpClientConfig::class
    )
  )
}

Koin Compile time check

ksp {
    arg("KOIN_CONFIG_CHECK","true")
}

Coil - Image loader cache policy

ImageLoader(this).newBuilder()
            .memoryCachePolicy(CachePolicy.ENABLED)
            .memoryCache {
                MemoryCache.Builder(this)
                    .maxSizePercent(percent = 0.1)
                    .strongReferencesEnabled(true)
                    .build()
            }
            .diskCachePolicy(CachePolicy.ENABLED)
            .diskCache {
                DiskCache.Builder()
                    .maxSizePercent(percent = 0.03)
                    .directory(cacheDir)
                    .build()
            }
            .logger(DebugLogger())
            .build()

Build With

  • Kotlin - First class and official programming language for Android development.
  • Jetpack Compose - Android’s modern toolkit for building native UI.
  • Coroutines and Flow - Official Kotlin's tooling for performing asynchronous work.
  • Android Jetpack - Jetpack is a suite of libraries to help developers build state-of-the-art applications.
  • Navigation Compose - Navigation Compose is a framework for navigating between composables while taking advantage of the Navigation component’s infrastructure and features.
  • Window size - Window size classes helps you design, responsive layouts.
  • ViewModel - The ViewModel is designed to store and manage UI-related data in a lifecycle conscious way.
  • StateFlow - StateFlow is a state-holder observable flow that emits the current and new state updates to its collectors.
  • Koin - A pragmatic lightweight dependency injection framework.
  • SqlDelight - Generates typesafe Kotlin APIs from your SQL statements.
  • Ktor - An asynchronous framework for creating microservices, web applications and more.
  • Coil - An image loading library for Android backed by Kotlin Coroutines.
  • Kotlinx Serialization - Provides an easy-to-use API and supports a wide range of formats for reflection-less serialization.
  • Material 3 - The latest version of Google’s open-source design system.
  • Android Architecture Components - Collection of libraries that help you design robust, testable, and maintainable apps.
  • Material Components for Android - Modular and customizable Material Design UI components for Android.
  • Gradle Version Catalog - Maintain dependencies and plugins in a scalable way.

Static Code Analysis

  • Ktlint - A library for formatting Kotlin code according to official guidelines.
  • Detekt - A static code analysis library for Kotlin.

Testing

  • MockEngine - HttpClientEngine for writing tests without network.