diff --git a/.idea/artifacts/lib_jvm.xml b/.idea/artifacts/lib_jvm.xml
new file mode 100644
index 0000000..dbaabc5
--- /dev/null
+++ b/.idea/artifacts/lib_jvm.xml
@@ -0,0 +1,8 @@
+
+
+ $PROJECT_DIR$/lib/build/libs
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml
new file mode 100644
index 0000000..fdf8d99
--- /dev/null
+++ b/.idea/kotlinc.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/build.gradle b/app/build.gradle
index 730b1b9..0fad91b 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -4,8 +4,10 @@ plugins {
}
android {
- compileSdkVersion 33
- buildToolsVersion "30.0.3"
+ compileSdk = 33
+ buildToolsVersion = "30.0.3"
+
+ namespace = "me.onebone.toolbar"
defaultConfig {
applicationId "me.onebone.toolbar"
@@ -30,15 +32,9 @@ android {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
- kotlinOptions {
- jvmTarget = '1.8'
- }
buildFeatures {
compose true
}
- composeOptions {
- kotlinCompilerExtensionVersion compose_compiler_version
- }
}
dependencies {
diff --git a/build.gradle b/build.gradle.kts
similarity index 56%
rename from build.gradle
rename to build.gradle.kts
index b33f02f..38a3158 100644
--- a/build.gradle
+++ b/build.gradle.kts
@@ -1,19 +1,18 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
-buildscript {
- ext {
- library_version = '2.3.5'
-
- kotlin_version = '1.7.20'
- compose_compiler_version = '1.3.2'
- }
+plugins {
+ kotlin("multiplatform") version "1.9.0" apply false
+ kotlin("android") version "1.9.0" apply false
+ id("org.jetbrains.compose") version "1.4.3" apply false
+}
+buildscript {
repositories {
google()
mavenCentral()
+ gradlePluginPortal()
}
dependencies {
- classpath 'com.android.tools.build:gradle:7.3.1'
- classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
+ classpath("com.android.tools.build:gradle:8.0.2")
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
@@ -26,7 +25,3 @@ allprojects {
mavenCentral()
}
}
-
-task clean(type: Delete) {
- delete rootProject.buildDir
-}
diff --git a/gradle/publish.gradle b/gradle/publish.gradle
index e16a310..9d22d98 100644
--- a/gradle/publish.gradle
+++ b/gradle/publish.gradle
@@ -26,7 +26,7 @@ afterEvaluate {
release(MavenPublication) {
groupId = 'me.onebone'
artifactId = 'toolbar-compose'
- version = rootProject.ext.library_version
+ version = "2.3.5"
from components.release
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index 404484b..8ff7746 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip
diff --git a/lib/build.gradle b/lib/build.gradle
deleted file mode 100644
index c5a3a24..0000000
--- a/lib/build.gradle
+++ /dev/null
@@ -1,61 +0,0 @@
-plugins {
- id 'com.android.library'
- id 'kotlin-android'
-}
-
-android {
- namespace 'me.onebone.toolbar'
-
- compileSdkVersion 33
- buildToolsVersion "30.0.3"
-
- defaultConfig {
- minSdkVersion 21
- targetSdkVersion 33
-
- testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
- consumerProguardFiles "consumer-rules.pro"
- }
-
- buildTypes {
- release {
- minifyEnabled false
- proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
- }
- }
- compileOptions {
- sourceCompatibility JavaVersion.VERSION_1_8
- targetCompatibility JavaVersion.VERSION_1_8
- }
- kotlinOptions {
- jvmTarget = '1.8'
- }
-
- buildFeatures {
- compose = true
- }
-
- composeOptions {
- kotlinCompilerExtensionVersion "$compose_compiler_version"
- }
-
- packagingOptions {
- exclude "META-INF/AL2.0"
- exclude "META-INF/LGPL2.1"
- }
-}
-
-dependencies {
- testImplementation 'junit:junit:4.13.2'
- androidTestImplementation 'androidx.test.ext:junit:1.1.5'
- androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
-
- implementation platform('androidx.compose:compose-bom:2023.01.00')
-
- implementation "androidx.compose.ui:ui"
- implementation "androidx.compose.foundation:foundation"
- implementation "androidx.compose.ui:ui-tooling"
- androidTestImplementation "androidx.compose.ui:ui-test-junit4"
-}
-
-apply from: rootProject.file('gradle/publish.gradle')
diff --git a/lib/build.gradle.kts b/lib/build.gradle.kts
new file mode 100644
index 0000000..bfa6971
--- /dev/null
+++ b/lib/build.gradle.kts
@@ -0,0 +1,49 @@
+plugins {
+ kotlin("multiplatform")
+ id("com.android.library")
+ id("org.jetbrains.compose")
+}
+
+kotlin {
+ androidTarget("android")
+ jvm()
+
+ sourceSets {
+ val commonMain by getting {
+ dependencies {
+ implementation(compose.runtime)
+ implementation(compose.foundation)
+ }
+ }
+
+ val androidMain by getting {
+ dependsOn(commonMain)
+ }
+
+ val jvmMain by getting {
+ dependsOn(commonMain)
+ }
+ }
+}
+
+android {
+ namespace = "me.onebone.toolbar"
+
+ compileSdk = 33
+
+ defaultConfig {
+ minSdkVersion(21)
+
+ testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
+ }
+ compileOptions {
+ sourceCompatibility = JavaVersion.VERSION_1_8
+ targetCompatibility = JavaVersion.VERSION_1_8
+ }
+
+ packagingOptions {
+ exclude("META-INF/AL2.0")
+ exclude("META-INF/LGPL2.1")
+ }
+}
+
diff --git a/lib/proguard-rules.pro b/lib/proguard-rules.pro
index f1b4245..2f9dc5a 100644
--- a/lib/proguard-rules.pro
+++ b/lib/proguard-rules.pro
@@ -1,6 +1,6 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
-# proguardFiles setting in build.gradle.
+# proguardFiles setting in build.gradle.kts.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
diff --git a/lib/src/main/AndroidManifest.xml b/lib/src/androidMain/AndroidManifest.xml
similarity index 100%
rename from lib/src/main/AndroidManifest.xml
rename to lib/src/androidMain/AndroidManifest.xml
diff --git a/lib/src/androidTest/java/me/onebone/toolbar/CollapsingToolbarTest.kt b/lib/src/androidTest/java/me/onebone/toolbar/CollapsingToolbarTest.kt
deleted file mode 100644
index 52e8f6c..0000000
--- a/lib/src/androidTest/java/me/onebone/toolbar/CollapsingToolbarTest.kt
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Copyright (c) 2021 onebone
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
- * OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-package me.onebone.toolbar
-
-import androidx.compose.foundation.layout.Box
-import androidx.compose.foundation.layout.fillMaxSize
-import androidx.compose.foundation.layout.fillMaxWidth
-import androidx.compose.foundation.layout.height
-import androidx.compose.foundation.lazy.LazyColumn
-import androidx.compose.foundation.lazy.items
-import androidx.compose.material.Text
-import androidx.compose.ui.Modifier
-import androidx.compose.ui.semantics.semantics
-import androidx.compose.ui.semantics.testTag
-import androidx.compose.ui.test.assertHeightIsEqualTo
-import androidx.compose.ui.test.hasTestTag
-import androidx.compose.ui.test.junit4.createComposeRule
-import androidx.compose.ui.test.performTouchInput
-import androidx.compose.ui.test.swipeUp
-import androidx.compose.ui.unit.dp
-import androidx.test.ext.junit.runners.AndroidJUnit4
-import kotlin.math.abs
-import org.junit.Rule
-import org.junit.Test
-import org.junit.runner.RunWith
-
-@RunWith(AndroidJUnit4::class)
-class CollapsingToolbarTest {
- @get:Rule
- val rule = createComposeRule()
-
- @Test
- fun testCollapse() {
- val state = CollapsingToolbarScaffoldState(
- CollapsingToolbarState()
- )
-
- rule.setContent {
- CollapsingToolbarScaffold(
- modifier = Modifier
- .fillMaxSize(),
- state = state,
- scrollStrategy = ScrollStrategy.ExitUntilCollapsed,
- toolbarModifier = Modifier
- .semantics {
- testTag = "toolbar"
- },
- toolbar = {
- Box(modifier = Modifier
- .fillMaxWidth()
- .height(300.dp))
- Box(modifier = Modifier
- .fillMaxWidth()
- .height(50.dp))
- }
- ) {
- LazyColumn(modifier = Modifier
- .fillMaxSize()
- .semantics {
- testTag = "contentList"
- }
- ) {
- items(List(100) { "Hello $it" }) {
- Text(text = it)
- }
- }
- }
- }
-
- assert(state.toolbarState.progress == 1f)
-
- rule.onNode(hasTestTag("toolbar"))
- .assertHeightIsEqualTo(300.dp)
-
- rule.onNode(hasTestTag("contentList"))
- .performTouchInput {
- swipeUp()
- }
-
- rule.onNode(hasTestTag("toolbar"))
- .assertHeightIsEqualTo(50.dp)
-
- assert(abs(state.toolbarState.progress) < 0.01f)
- }
-}
diff --git a/lib/src/androidTest/java/me/onebone/toolbar/ExampleInstrumentedTest.kt b/lib/src/androidTest/java/me/onebone/toolbar/ExampleInstrumentedTest.kt
deleted file mode 100644
index 03ac7f1..0000000
--- a/lib/src/androidTest/java/me/onebone/toolbar/ExampleInstrumentedTest.kt
+++ /dev/null
@@ -1,24 +0,0 @@
-package me.onebone.toolbar
-
-import androidx.test.platform.app.InstrumentationRegistry
-import androidx.test.ext.junit.runners.AndroidJUnit4
-
-import org.junit.Test
-import org.junit.runner.RunWith
-
-import org.junit.Assert.*
-
-/**
- * Instrumented test, which will execute on an Android device.
- *
- * See [testing documentation](http://d.android.com/tools/testing).
- */
-@RunWith(AndroidJUnit4::class)
-class ExampleInstrumentedTest {
- @Test
- fun useAppContext() {
- // Context of the app under test.
- val appContext = InstrumentationRegistry.getInstrumentation().targetContext
- assertEquals("me.onebone.toolbar.test", appContext.packageName)
- }
-}
diff --git a/lib/src/main/java/me/onebone/toolbar/Annotations.kt b/lib/src/commonMain/kotlin/me/onebone/toolbar/Annotations.kt
similarity index 100%
rename from lib/src/main/java/me/onebone/toolbar/Annotations.kt
rename to lib/src/commonMain/kotlin/me/onebone/toolbar/Annotations.kt
diff --git a/lib/src/main/java/me/onebone/toolbar/AppBarContainer.kt b/lib/src/commonMain/kotlin/me/onebone/toolbar/AppBarContainer.kt
similarity index 100%
rename from lib/src/main/java/me/onebone/toolbar/AppBarContainer.kt
rename to lib/src/commonMain/kotlin/me/onebone/toolbar/AppBarContainer.kt
diff --git a/lib/src/main/java/me/onebone/toolbar/CollapsingToolbar.kt b/lib/src/commonMain/kotlin/me/onebone/toolbar/CollapsingToolbar.kt
similarity index 99%
rename from lib/src/main/java/me/onebone/toolbar/CollapsingToolbar.kt
rename to lib/src/commonMain/kotlin/me/onebone/toolbar/CollapsingToolbar.kt
index d11ddf3..b24acdb 100644
--- a/lib/src/main/java/me/onebone/toolbar/CollapsingToolbar.kt
+++ b/lib/src/commonMain/kotlin/me/onebone/toolbar/CollapsingToolbar.kt
@@ -22,7 +22,6 @@
package me.onebone.toolbar
-import androidx.annotation.FloatRange
import androidx.compose.animation.core.AnimationState
import androidx.compose.animation.core.animateTo
import androidx.compose.animation.core.tween
@@ -97,7 +96,6 @@ class CollapsingToolbarState(
private var minHeightState by mutableStateOf(0)
val progress: Float
- @FloatRange(from = 0.0, to = 1.0)
get() =
if(minHeight == maxHeight) {
0f
diff --git a/lib/src/main/java/me/onebone/toolbar/CollapsingToolbarScaffold.kt b/lib/src/commonMain/kotlin/me/onebone/toolbar/CollapsingToolbarScaffold.kt
similarity index 100%
rename from lib/src/main/java/me/onebone/toolbar/CollapsingToolbarScaffold.kt
rename to lib/src/commonMain/kotlin/me/onebone/toolbar/CollapsingToolbarScaffold.kt
diff --git a/lib/src/main/java/me/onebone/toolbar/FabPlacement.kt b/lib/src/commonMain/kotlin/me/onebone/toolbar/FabPlacement.kt
similarity index 100%
rename from lib/src/main/java/me/onebone/toolbar/FabPlacement.kt
rename to lib/src/commonMain/kotlin/me/onebone/toolbar/FabPlacement.kt
diff --git a/lib/src/main/java/me/onebone/toolbar/FabPosition.kt b/lib/src/commonMain/kotlin/me/onebone/toolbar/FabPosition.kt
similarity index 100%
rename from lib/src/main/java/me/onebone/toolbar/FabPosition.kt
rename to lib/src/commonMain/kotlin/me/onebone/toolbar/FabPosition.kt
diff --git a/lib/src/main/java/me/onebone/toolbar/ScrollStrategy.kt b/lib/src/commonMain/kotlin/me/onebone/toolbar/ScrollStrategy.kt
similarity index 100%
rename from lib/src/main/java/me/onebone/toolbar/ScrollStrategy.kt
rename to lib/src/commonMain/kotlin/me/onebone/toolbar/ScrollStrategy.kt
diff --git a/lib/src/main/java/me/onebone/toolbar/ToolbarWithFabScaffold.kt b/lib/src/commonMain/kotlin/me/onebone/toolbar/ToolbarWithFabScaffold.kt
similarity index 100%
rename from lib/src/main/java/me/onebone/toolbar/ToolbarWithFabScaffold.kt
rename to lib/src/commonMain/kotlin/me/onebone/toolbar/ToolbarWithFabScaffold.kt
diff --git a/lib/src/test/java/me/onebone/toolbar/ExampleUnitTest.kt b/lib/src/test/java/me/onebone/toolbar/ExampleUnitTest.kt
deleted file mode 100644
index 314ec8d..0000000
--- a/lib/src/test/java/me/onebone/toolbar/ExampleUnitTest.kt
+++ /dev/null
@@ -1,17 +0,0 @@
-package me.onebone.toolbar
-
-import org.junit.Test
-
-import org.junit.Assert.*
-
-/**
- * Example local unit test, which will execute on the development machine (host).
- *
- * See [testing documentation](http://d.android.com/tools/testing).
- */
-class ExampleUnitTest {
- @Test
- fun addition_isCorrect() {
- assertEquals(4, 2 + 2)
- }
-}
diff --git a/settings.gradle b/settings.gradle.kts
similarity index 55%
rename from settings.gradle
rename to settings.gradle.kts
index b1c743a..8f6a7c8 100644
--- a/settings.gradle
+++ b/settings.gradle.kts
@@ -1,3 +1,3 @@
-include ':lib'
-include ':app'
+include(":lib")
+include(":app")
rootProject.name = "Collapsing Toolbar"