Skip to content

Commit

Permalink
Updated dependencies and migrated to version catalogs (TOML) (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
brianwernick authored Dec 22, 2024
1 parent 0e98467 commit 0189f70
Show file tree
Hide file tree
Showing 14 changed files with 275 additions and 164 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
bin/
gen/
.idea/
.kotlin/
*.iml
*.ipr
*.iws
Expand Down
11 changes: 7 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
buildscript {
ext.kotlinVersion = '1.8.21'
repositories {
mavenCentral()
google()
}

dependencies {
classpath 'com.android.tools.build:gradle:8.0.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
classpath libs.android.gradle
classpath libs.kotlin.gradle
}
}

plugins {
id "io.github.gradle-nexus.publish-plugin" version "1.1.0"
alias libs.plugins.android.application apply false
alias libs.plugins.android.library apply false
alias libs.plugins.compose.compiler apply false
alias libs.plugins.kotlin.android apply false
alias libs.plugins.nexus.publish
}

apply from: './gradle/util/testOutput.gradle'
Expand Down
44 changes: 19 additions & 25 deletions demo/build.gradle
Original file line number Diff line number Diff line change
@@ -1,36 +1,34 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'

ext {
composeVersion = "1.4.3"
composeCompilerVersion = "1.4.7"
plugins {
alias libs.plugins.android.application
alias libs.plugins.kotlin.android
alias libs.plugins.compose.compiler
}

dependencies {
implementation project(':library')

// Misc
implementation 'androidx.core:core-ktx:1.10.1'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation libs.core.ktx
implementation libs.appcompat

// Jetpack Compose UI
implementation "androidx.compose.ui:ui:$composeVersion"
implementation "androidx.compose.ui:ui-tooling:$composeVersion"
implementation "androidx.compose.ui:ui-tooling-preview:$composeVersion"
implementation "androidx.compose.material:material:$composeVersion"
implementation 'androidx.activity:activity-compose:1.7.2'
implementation "androidx.navigation:navigation-compose:2.6.0"
implementation "com.google.accompanist:accompanist-navigation-animation:0.30.1"
implementation libs.ui
implementation libs.ui.tooling
implementation libs.ui.tooling.preview
implementation libs.material
implementation libs.material.icons.core
implementation libs.activity.compose
implementation libs.navigation.compose
}

android {
namespace 'com.devbrackets.android.datastoredemo'
compileSdkVersion 33
compileSdk 35

defaultConfig {
applicationId "com.devbrackets.android.datastoredemo"
minSdkVersion 23
targetSdkVersion 33
targetSdkVersion 35
versionCode 1
versionName "1.0.0"
}
Expand All @@ -39,22 +37,18 @@ android {
main.java.srcDirs += "src/main/kotlin"
}

kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8
}

buildFeatures {
compose true
viewBinding true
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}

composeOptions {
kotlinCompilerExtensionVersion composeCompilerVersion
kotlinOptions {
jvmTarget = JavaVersion.VERSION_11
}

lint {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.navigation.compose.composable
import androidx.navigation.compose.rememberNavController
import com.devbrackets.android.datastoredemo.common.DemoTheme
import com.devbrackets.android.datastoredemo.data.Preferences
import com.devbrackets.android.datastoredemo.navigation.DemoNavHost
import com.devbrackets.android.datastoredemo.playground.PreferencePlaygroundScreen
import com.devbrackets.android.datastoredemo.playground.PreferencePlaygroundViewModel
import com.google.accompanist.navigation.animation.composable
import com.google.accompanist.navigation.animation.rememberAnimatedNavController

@ExperimentalAnimationApi
class MainActivity : AppCompatActivity() {
Expand All @@ -31,7 +31,7 @@ class MainActivity : AppCompatActivity() {

@Composable
fun Content() {
val navController = rememberAnimatedNavController()
val navController = rememberNavController()

DemoNavHost(
navController = navController,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.devbrackets.android.datastoredemo.navigation

import androidx.compose.animation.ExperimentalAnimationApi
import androidx.compose.animation.core.FastOutSlowInEasing
import androidx.compose.animation.core.tween
import androidx.compose.animation.slideInHorizontally
Expand All @@ -9,7 +8,7 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.navigation.NavGraphBuilder
import androidx.navigation.NavHostController
import com.google.accompanist.navigation.animation.AnimatedNavHost
import androidx.navigation.compose.NavHost

private const val ANIMATION_DURATION = 300

Expand Down Expand Up @@ -46,15 +45,14 @@ private val popExitTransition = slideOutHorizontally(
)

@Composable
@OptIn(ExperimentalAnimationApi::class)
fun DemoNavHost(
navController: NavHostController,
startDestination: String,
modifier: Modifier = Modifier,
route: String? = null,
builder: NavGraphBuilder.() -> Unit
) {
AnimatedNavHost(
NavHost(
navController = navController,
startDestination = startDestination,
modifier = modifier,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.ime
import androidx.compose.foundation.layout.navigationBars
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.statusBars
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.OutlinedTextField
Expand Down Expand Up @@ -135,7 +136,8 @@ private fun ScreenScaffold(
TopAppBar(
title = {
Text(text = "DataStore Delegates Demo")
}
},
windowInsets = WindowInsets.statusBars
)
},
content = content
Expand Down Expand Up @@ -166,7 +168,7 @@ private fun MonthSelector(
onMonthSelected: (Month) -> Unit,
modifier: Modifier = Modifier
) {
val availableMonths = remember { Month.values().toList() }
val availableMonths = remember { Month.entries }
val selectedMonth = remember { mutableStateOf(month.value) }
LaunchedEffect(month.value) {
selectedMonth.value = month.value
Expand Down
1 change: 0 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
android.defaults.buildfeatures.buildconfig=true
android.enableJetifier=true
android.nonFinalResIds=false
android.nonTransitiveRClass=false
Expand Down
38 changes: 38 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
[versions]
activityCompose = "1.9.3"
androidGradlePlugin = "8.7.3"
appcompat = "1.7.0"
coreKtx = "1.15.0"
datastorePreferences = "1.1.1"
junit = "4.13.2"
kotlin = "2.0.20"
material = "1.7.6"
navigationCompose = "2.8.5"
nexusPublish = "1.1.0"
robolectric = "4.13"
composeUi = "1.7.6"

[libraries]
activity-compose = { module = "androidx.activity:activity-compose", version.ref = "activityCompose" }
android-gradle = { module = "com.android.tools.build:gradle", version.ref = "androidGradlePlugin" }
appcompat = { module = "androidx.appcompat:appcompat", version.ref = "appcompat" }
core-ktx = { module = "androidx.core:core-ktx", version.ref = "coreKtx" }
datastore-preferences = { module = "androidx.datastore:datastore-preferences", version.ref = "datastorePreferences" }
junit = { module = "junit:junit", version.ref = "junit" }
kotlin-gradle = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" }
kotlin-stdlib-jdk7 = { module = "org.jetbrains.kotlin:kotlin-stdlib-jdk7", version.ref = "kotlin" }
material = { module = "androidx.compose.material:material", version.ref = "material" }
material-icons-core = { module = "androidx.compose.material:material-icons-core", version.ref = "material" }
navigation-compose = { module = "androidx.navigation:navigation-compose", version.ref = "navigationCompose" }
robolectric = { module = "org.robolectric:robolectric", version.ref = "robolectric" }
ui = { module = "androidx.compose.ui:ui", version.ref = "composeUi" }
ui-tooling = { module = "androidx.compose.ui:ui-tooling", version.ref = "composeUi" }
ui-tooling-preview = { module = "androidx.compose.ui:ui-tooling-preview", version.ref = "composeUi" }

[plugins]
android-application = { id = "com.android.application", version.ref = "androidGradlePlugin" }
android-library = { id = "com.android.library", version.ref = "androidGradlePlugin" }
compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
nexus-publish = { id = "io.github.gradle-nexus.publish-plugin", version.ref = "nexusPublish" }

Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 2 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit 0189f70

Please sign in to comment.