mirror of
https://github.com/AdrianKuta/android-challange-adrian-kuta.git
synced 2025-07-02 02:27:59 +02:00
Refactor: Update package structure and implement bottom navigation
This commit refactors the package structure for Gradle convention plugins and introduces bottom navigation to the application. Key changes: - Moved Gradle convention plugin files from `dev.adriankuta.partymania` to `dev.adriankuta.flights`. - Added `TopLevelDestination.kt` to define top-level navigation destinations with icons, titles, and routes. - Implemented `FlightsBottomBar` Composable in `FlightsApp.kt` to display a `NavigationBar` with items for each `TopLevelDestination`. - Updated `FlightsNavGraph.kt`: - Renamed from `FlightsNavGraph.kt` to `navigation/FlightsNavGraph.kt`. - Added `navigateToTopLevelDestination` extension function for `NavController` to handle navigation to top-level destinations with appropriate `NavOptions`. - Updated `HomeNavigation.kt`: - Added `navigateToHome` extension function for `NavController`. - Added `strings.xml` for `ui:home` module with `home_screen_title`. - Ensured Kotlin serialization plugin is correctly applied in `app/build.gradle.kts`.
This commit is contained in:
@ -0,0 +1,83 @@
|
||||
package dev.adriankuta.flights
|
||||
|
||||
import io.gitlab.arturbosch.detekt.extensions.DetektExtension
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.artifacts.VersionCatalogsExtension
|
||||
import org.gradle.kotlin.dsl.configure
|
||||
import org.gradle.kotlin.dsl.dependencies
|
||||
import org.gradle.kotlin.dsl.getByType
|
||||
import java.io.FileWriter
|
||||
|
||||
internal fun Project.configureDetektDependencies() {
|
||||
val libs = extensions.getByType<VersionCatalogsExtension>().named("libs")
|
||||
|
||||
dependencies {
|
||||
"detektPlugins"(libs.findLibrary("detekt.ktlint").get())
|
||||
"detektPlugins"(libs.findLibrary("detekt.compose").get())
|
||||
}
|
||||
}
|
||||
|
||||
internal fun Project.configureDetektForNonUiModule() =
|
||||
createDetektConfigFile(NonDefault.trimIndent())
|
||||
|
||||
internal fun Project.configureDetektForComposeModuleExceptions() =
|
||||
createDetektConfigFile(ComposeExceptions.trimIndent())
|
||||
|
||||
internal fun Project.createDetektConfigFile(deviationsFromDefaultConfig: String) {
|
||||
val libs = extensions.getByType<VersionCatalogsExtension>().named("libs")
|
||||
|
||||
if (!file(DetektConfigPath).exists()) {
|
||||
val detektConfigFile = project.file(DetektConfigPath)
|
||||
detektConfigFile.parentFile.mkdirs()
|
||||
detektConfigFile.createNewFile()
|
||||
val writer = FileWriter(detektConfigFile)
|
||||
writer.write(deviationsFromDefaultConfig)
|
||||
writer.close()
|
||||
}
|
||||
|
||||
configure<DetektExtension> {
|
||||
toolVersion = libs.findVersion("detekt").get().toString()
|
||||
config.setFrom(files(DetektConfigPath))
|
||||
buildUponDefaultConfig = true
|
||||
}
|
||||
}
|
||||
|
||||
private const val DetektConfigPath = "config/detekt/detekt.yml"
|
||||
|
||||
private val NonDefault = """
|
||||
# Deviations from defaults
|
||||
formatting:
|
||||
TrailingCommaOnCallSite:
|
||||
active: true
|
||||
autoCorrect: true
|
||||
useTrailingCommaOnCallSite: true
|
||||
TrailingCommaOnDeclarationSite:
|
||||
active: true
|
||||
autoCorrect: true
|
||||
useTrailingCommaOnDeclarationSite: true
|
||||
"""
|
||||
|
||||
private val ComposeExceptions = """
|
||||
# Exceptions for compose. See https://detekt.dev/docs/introduction/compose
|
||||
naming:
|
||||
FunctionNaming:
|
||||
functionPattern: '[a-zA-Z][a-zA-Z0-9]*'
|
||||
|
||||
TopLevelPropertyNaming:
|
||||
constantPattern: '[A-Z][A-Za-z0-9]*'
|
||||
|
||||
complexity:
|
||||
LongParameterList:
|
||||
ignoreAnnotated: ['Composable']
|
||||
TooManyFunctions:
|
||||
ignoreAnnotatedFunctions: ['Preview']
|
||||
|
||||
style:
|
||||
MagicNumber:
|
||||
ignorePropertyDeclaration: true
|
||||
ignoreCompanionObjectPropertyDeclaration: true
|
||||
ignoreAnnotated: ['Composable']
|
||||
|
||||
UnusedPrivateMember:
|
||||
ignoreAnnotated: ['Composable']
|
||||
""" + NonDefault
|
Reference in New Issue
Block a user