Adding a New Feature

1. Create the feature module

feature/newfeature/
├── build.gradle.kts
└── src/main/java/com/shrivatsav/monomail/feature/newfeature/
    └── NewFeatureScreen.kt

build.gradle.kts template:

plugins {
    alias(libs.plugins.android.library)
    alias(libs.plugins.kotlin.compose)
    alias(libs.plugins.ksp)
    alias(libs.plugins.hilt)
}

android {
    namespace = "com.shrivatsav.monomail.feature.newfeature"
    compileSdk = 37

    defaultConfig {
        minSdk = 26
        consumerProguardFiles("consumer-rules.pro")
    }

    flavorDimensions += "distribution"

    productFlavors {
        create("github") { dimension = "distribution" }
        create("playstore") { dimension = "distribution" }
    }

    buildFeatures { compose = true }
}

dependencies {
    implementation(project(":core:model"))
    implementation(project(":core:designsystem"))
    implementation(project(":core:data"))

    implementation(platform(libs.androidx.compose.bom))
    implementation(libs.androidx.compose.ui)
    implementation(libs.androidx.compose.material3)
    implementation(libs.androidx.lifecycle.viewmodel.compose)
    implementation(libs.hilt.android)
    ksp(libs.hilt.compiler)
}

2. Register in settings.gradle.kts

include(":feature:newfeature")

3. Add to :app dependencies

// app/build.gradle.kts
dependencies {
    implementation(project(":feature:newfeature"))
}

4. Create the screen

Follow the standard screen pattern: sealed class state in ViewModel, @HiltViewModel with @Inject constructor, Composable function with viewModel parameter and nav callbacks.

5. Add a NavGraph route

sealed class Screen(val route: String) {
    object NewFeature : Screen("new_feature")
}

// In NavGraph composable block:
composable(Screen.NewFeature.route) {
    NewFeatureScreen(
        onBack = { navController.popBackStack() }
    )
}

6. Wire DI if needed

If the new feature needs new singleton providers, add them to the appropriate DI module in :app/di/ or create a new one.

7. Flavor-specific logic

If the feature differs between github and playstore:

8. Add a settings entry (if applicable)

Add a SettingsCard in SettingsScreen.kt that navigates to the new route.

← Build System Testing →