├── demo ├── demo2.gif ├── output.gif └── output4.gif ├── gradle ├── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties └── libs.versions.toml ├── iosApp ├── Configuration │ └── Config.xcconfig ├── iosApp │ ├── Assets.xcassets │ │ ├── Contents.json │ │ ├── AppIcon.appiconset │ │ │ ├── app-icon-1024.png │ │ │ └── Contents.json │ │ └── AccentColor.colorset │ │ │ └── Contents.json │ ├── Preview Content │ │ └── Preview Assets.xcassets │ │ │ └── Contents.json │ ├── iOSApp.swift │ ├── ContentView.swift │ └── Info.plist └── iosApp.xcodeproj │ └── project.pbxproj ├── composeApp ├── src │ ├── androidMain │ │ ├── res │ │ │ ├── values │ │ │ │ └── strings.xml │ │ │ ├── mipmap-hdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-mdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-anydpi-v26 │ │ │ │ ├── ic_launcher.xml │ │ │ │ └── ic_launcher_round.xml │ │ │ ├── drawable-v24 │ │ │ │ └── ic_launcher_foreground.xml │ │ │ └── drawable │ │ │ │ └── ic_launcher_background.xml │ │ ├── kotlin │ │ │ └── org │ │ │ │ └── example │ │ │ │ └── project │ │ │ │ ├── Platform.android.kt │ │ │ │ └── MainActivity.kt │ │ └── AndroidManifest.xml │ ├── wasmJsMain │ │ ├── resources │ │ │ ├── styles.css │ │ │ └── index.html │ │ └── kotlin │ │ │ └── org │ │ │ └── example │ │ │ └── project │ │ │ ├── Platform.wasmJs.kt │ │ │ └── main.kt │ ├── commonMain │ │ ├── composeResources │ │ │ └── drawable │ │ │ │ ├── blush.png │ │ │ │ ├── insta.webp │ │ │ │ ├── cold_sweat.png │ │ │ │ ├── heart_eyes.png │ │ │ │ ├── neutral_face.png │ │ │ │ ├── disappointed_relieved.png │ │ │ │ ├── emoji.xml │ │ │ │ └── compose-multiplatform.xml │ │ └── kotlin │ │ │ └── org │ │ │ └── example │ │ │ └── project │ │ │ ├── Platform.kt │ │ │ ├── Greeting.kt │ │ │ └── App.kt │ ├── iosMain │ │ └── kotlin │ │ │ └── org │ │ │ └── example │ │ │ └── project │ │ │ ├── MainViewController.kt │ │ │ └── Platform.ios.kt │ └── desktopMain │ │ └── kotlin │ │ └── org │ │ └── example │ │ └── project │ │ ├── Platform.jvm.kt │ │ └── main.kt └── build.gradle.kts ├── liquidSlider ├── src │ ├── androidMain │ │ ├── res │ │ │ ├── values │ │ │ │ └── strings.xml │ │ │ ├── mipmap-hdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-mdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-anydpi-v26 │ │ │ │ ├── ic_launcher.xml │ │ │ │ └── ic_launcher_round.xml │ │ │ ├── drawable-v24 │ │ │ │ └── ic_launcher_foreground.xml │ │ │ └── drawable │ │ │ │ └── ic_launcher_background.xml │ │ ├── kotlin │ │ │ └── org │ │ │ │ └── example │ │ │ │ └── project │ │ │ │ └── Platform.android.kt │ │ └── AndroidManifest.xml │ ├── commonMain │ │ ├── kotlin │ │ │ └── org │ │ │ │ └── example │ │ │ │ └── slider │ │ │ │ ├── Platform.kt │ │ │ │ └── library │ │ │ │ ├── LiquidSliderSize.kt │ │ │ │ ├── Rect.kt │ │ │ │ ├── CanvasState.kt │ │ │ │ ├── LiquidSliderConstants.kt │ │ │ │ ├── LiquidSliderConfig.kt │ │ │ │ ├── LiquidSlider.kt │ │ │ │ ├── LiquidBall.kt │ │ │ │ └── LiquidSliderCanvas.kt │ │ └── composeResources │ │ │ └── drawable │ │ │ ├── emoji.xml │ │ │ └── compose-multiplatform.xml │ ├── wasmJsMain │ │ ├── resources │ │ │ ├── styles.css │ │ │ └── index.html │ │ └── kotlin │ │ │ └── org │ │ │ └── example │ │ │ └── project │ │ │ └── main.kt │ ├── iosMain │ │ └── kotlin │ │ │ └── org │ │ │ └── example │ │ │ └── project │ │ │ ├── MainViewController.kt │ │ │ └── Platform.ios.kt │ └── desktopMain │ │ └── kotlin │ │ └── org │ │ └── example │ │ └── project │ │ ├── Platform.jvm.kt │ │ └── main.kt └── build.gradle.kts ├── .gitignore ├── gradle.properties ├── .fleet └── receipt.json ├── settings.gradle.kts ├── .github └── workflows │ ├── deploy_web.yml │ └── publish.yml ├── gradlew.bat ├── README.md └── gradlew /demo/demo2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mejdi14/KMP-Liquid-Slider/HEAD/demo/demo2.gif -------------------------------------------------------------------------------- /demo/output.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mejdi14/KMP-Liquid-Slider/HEAD/demo/output.gif -------------------------------------------------------------------------------- /demo/output4.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mejdi14/KMP-Liquid-Slider/HEAD/demo/output4.gif -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mejdi14/KMP-Liquid-Slider/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /iosApp/Configuration/Config.xcconfig: -------------------------------------------------------------------------------- 1 | TEAM_ID= 2 | BUNDLE_ID=org.example.project.KMP-Liquid-Slider 3 | APP_NAME=KMP-Liquid-Slider -------------------------------------------------------------------------------- /iosApp/iosApp/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | } 6 | } -------------------------------------------------------------------------------- /composeApp/src/androidMain/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | KMP-Liquid-Slider 3 | -------------------------------------------------------------------------------- /liquidSlider/src/androidMain/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | KMP-Liquid-Slider 3 | -------------------------------------------------------------------------------- /iosApp/iosApp/Preview Content/Preview Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | } 6 | } -------------------------------------------------------------------------------- /liquidSlider/src/commonMain/kotlin/org/example/slider/Platform.kt: -------------------------------------------------------------------------------- 1 | package org.example.project 2 | 3 | interface Platform { 4 | val name: String 5 | } 6 | 7 | -------------------------------------------------------------------------------- /composeApp/src/wasmJsMain/resources/styles.css: -------------------------------------------------------------------------------- 1 | html, body { 2 | width: 100%; 3 | height: 100%; 4 | margin: 0; 5 | padding: 0; 6 | overflow: hidden; 7 | } -------------------------------------------------------------------------------- /composeApp/src/androidMain/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mejdi14/KMP-Liquid-Slider/HEAD/composeApp/src/androidMain/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /composeApp/src/androidMain/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mejdi14/KMP-Liquid-Slider/HEAD/composeApp/src/androidMain/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /liquidSlider/src/wasmJsMain/resources/styles.css: -------------------------------------------------------------------------------- 1 | html, body { 2 | width: 100%; 3 | height: 100%; 4 | margin: 0; 5 | padding: 0; 6 | overflow: hidden; 7 | } -------------------------------------------------------------------------------- /composeApp/src/androidMain/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mejdi14/KMP-Liquid-Slider/HEAD/composeApp/src/androidMain/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /composeApp/src/androidMain/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mejdi14/KMP-Liquid-Slider/HEAD/composeApp/src/androidMain/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /composeApp/src/androidMain/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mejdi14/KMP-Liquid-Slider/HEAD/composeApp/src/androidMain/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /composeApp/src/commonMain/composeResources/drawable/blush.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mejdi14/KMP-Liquid-Slider/HEAD/composeApp/src/commonMain/composeResources/drawable/blush.png -------------------------------------------------------------------------------- /liquidSlider/src/androidMain/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mejdi14/KMP-Liquid-Slider/HEAD/liquidSlider/src/androidMain/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /liquidSlider/src/androidMain/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mejdi14/KMP-Liquid-Slider/HEAD/liquidSlider/src/androidMain/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /liquidSlider/src/androidMain/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mejdi14/KMP-Liquid-Slider/HEAD/liquidSlider/src/androidMain/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /composeApp/src/commonMain/composeResources/drawable/insta.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mejdi14/KMP-Liquid-Slider/HEAD/composeApp/src/commonMain/composeResources/drawable/insta.webp -------------------------------------------------------------------------------- /liquidSlider/src/androidMain/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mejdi14/KMP-Liquid-Slider/HEAD/liquidSlider/src/androidMain/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /liquidSlider/src/androidMain/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mejdi14/KMP-Liquid-Slider/HEAD/liquidSlider/src/androidMain/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /composeApp/src/androidMain/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mejdi14/KMP-Liquid-Slider/HEAD/composeApp/src/androidMain/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /composeApp/src/androidMain/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mejdi14/KMP-Liquid-Slider/HEAD/composeApp/src/androidMain/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /composeApp/src/androidMain/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mejdi14/KMP-Liquid-Slider/HEAD/composeApp/src/androidMain/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /composeApp/src/androidMain/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mejdi14/KMP-Liquid-Slider/HEAD/composeApp/src/androidMain/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /composeApp/src/commonMain/composeResources/drawable/cold_sweat.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mejdi14/KMP-Liquid-Slider/HEAD/composeApp/src/commonMain/composeResources/drawable/cold_sweat.png -------------------------------------------------------------------------------- /composeApp/src/commonMain/composeResources/drawable/heart_eyes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mejdi14/KMP-Liquid-Slider/HEAD/composeApp/src/commonMain/composeResources/drawable/heart_eyes.png -------------------------------------------------------------------------------- /iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/app-icon-1024.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mejdi14/KMP-Liquid-Slider/HEAD/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/app-icon-1024.png -------------------------------------------------------------------------------- /liquidSlider/src/androidMain/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mejdi14/KMP-Liquid-Slider/HEAD/liquidSlider/src/androidMain/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /liquidSlider/src/androidMain/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mejdi14/KMP-Liquid-Slider/HEAD/liquidSlider/src/androidMain/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /composeApp/src/androidMain/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mejdi14/KMP-Liquid-Slider/HEAD/composeApp/src/androidMain/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /composeApp/src/commonMain/composeResources/drawable/neutral_face.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mejdi14/KMP-Liquid-Slider/HEAD/composeApp/src/commonMain/composeResources/drawable/neutral_face.png -------------------------------------------------------------------------------- /composeApp/src/commonMain/kotlin/org/example/project/Platform.kt: -------------------------------------------------------------------------------- 1 | package org.example.project 2 | 3 | interface Platform { 4 | val name: String 5 | } 6 | 7 | expect fun getPlatform(): Platform -------------------------------------------------------------------------------- /liquidSlider/src/androidMain/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mejdi14/KMP-Liquid-Slider/HEAD/liquidSlider/src/androidMain/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /liquidSlider/src/androidMain/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mejdi14/KMP-Liquid-Slider/HEAD/liquidSlider/src/androidMain/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /liquidSlider/src/androidMain/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mejdi14/KMP-Liquid-Slider/HEAD/liquidSlider/src/androidMain/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /liquidSlider/src/commonMain/kotlin/org/example/slider/library/LiquidSliderSize.kt: -------------------------------------------------------------------------------- 1 | package org.example.project.library 2 | 3 | data class LiquidSliderSize(val height: Int = 60, val width: Int = 300) 4 | -------------------------------------------------------------------------------- /iosApp/iosApp/iOSApp.swift: -------------------------------------------------------------------------------- 1 | import SwiftUI 2 | 3 | @main 4 | struct iOSApp: App { 5 | var body: some Scene { 6 | WindowGroup { 7 | ContentView() 8 | } 9 | } 10 | } -------------------------------------------------------------------------------- /composeApp/src/commonMain/composeResources/drawable/disappointed_relieved.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mejdi14/KMP-Liquid-Slider/HEAD/composeApp/src/commonMain/composeResources/drawable/disappointed_relieved.png -------------------------------------------------------------------------------- /liquidSlider/src/iosMain/kotlin/org/example/project/MainViewController.kt: -------------------------------------------------------------------------------- 1 | package org.example.project 2 | 3 | import androidx.compose.ui.window.ComposeUIViewController 4 | 5 | fun MainViewController() = ComposeUIViewController { } -------------------------------------------------------------------------------- /composeApp/src/iosMain/kotlin/org/example/project/MainViewController.kt: -------------------------------------------------------------------------------- 1 | package org.example.project 2 | 3 | import androidx.compose.ui.window.ComposeUIViewController 4 | 5 | fun MainViewController() = ComposeUIViewController { App() } -------------------------------------------------------------------------------- /iosApp/iosApp/Assets.xcassets/AccentColor.colorset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "colors" : [ 3 | { 4 | "idiom" : "universal" 5 | } 6 | ], 7 | "info" : { 8 | "author" : "xcode", 9 | "version" : 1 10 | } 11 | } -------------------------------------------------------------------------------- /liquidSlider/src/desktopMain/kotlin/org/example/project/Platform.jvm.kt: -------------------------------------------------------------------------------- 1 | package org.example.project 2 | 3 | class JVMPlatform: Platform { 4 | override val name: String = "Java ${System.getProperty("java.version")}" 5 | } 6 | 7 | -------------------------------------------------------------------------------- /composeApp/src/commonMain/kotlin/org/example/project/Greeting.kt: -------------------------------------------------------------------------------- 1 | package org.example.project 2 | 3 | class Greeting { 4 | private val platform = getPlatform() 5 | 6 | fun greet(): String { 7 | return "Hello, ${platform.name}!" 8 | } 9 | } -------------------------------------------------------------------------------- /composeApp/src/wasmJsMain/kotlin/org/example/project/Platform.wasmJs.kt: -------------------------------------------------------------------------------- 1 | package org.example.project 2 | 3 | class WasmPlatform: Platform { 4 | override val name: String = "Web with Kotlin/Wasm" 5 | } 6 | 7 | actual fun getPlatform(): Platform = WasmPlatform() -------------------------------------------------------------------------------- /liquidSlider/src/androidMain/kotlin/org/example/project/Platform.android.kt: -------------------------------------------------------------------------------- 1 | package org.example.project 2 | 3 | import android.os.Build 4 | 5 | class AndroidPlatform : Platform { 6 | override val name: String = "Android ${Build.VERSION.SDK_INT}" 7 | } 8 | 9 | -------------------------------------------------------------------------------- /composeApp/src/desktopMain/kotlin/org/example/project/Platform.jvm.kt: -------------------------------------------------------------------------------- 1 | package org.example.project 2 | 3 | class JVMPlatform: Platform { 4 | override val name: String = "Java ${System.getProperty("java.version")}" 5 | } 6 | 7 | actual fun getPlatform(): Platform = JVMPlatform() -------------------------------------------------------------------------------- /liquidSlider/src/iosMain/kotlin/org/example/project/Platform.ios.kt: -------------------------------------------------------------------------------- 1 | package org.example.project 2 | 3 | import platform.UIKit.UIDevice 4 | 5 | class IOSPlatform: Platform { 6 | override val name: String = UIDevice.currentDevice.systemName() + " " + UIDevice.currentDevice.systemVersion 7 | } 8 | -------------------------------------------------------------------------------- /composeApp/src/androidMain/kotlin/org/example/project/Platform.android.kt: -------------------------------------------------------------------------------- 1 | package org.example.project 2 | 3 | import android.os.Build 4 | 5 | class AndroidPlatform : Platform { 6 | override val name: String = "Android ${Build.VERSION.SDK_INT}" 7 | } 8 | 9 | actual fun getPlatform(): Platform = AndroidPlatform() -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip 4 | networkTimeout=10000 5 | validateDistributionUrl=true 6 | zipStoreBase=GRADLE_USER_HOME 7 | zipStorePath=wrapper/dists 8 | -------------------------------------------------------------------------------- /composeApp/src/androidMain/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "filename" : "app-icon-1024.png", 5 | "idiom" : "universal", 6 | "platform" : "ios", 7 | "size" : "1024x1024" 8 | } 9 | ], 10 | "info" : { 11 | "author" : "xcode", 12 | "version" : 1 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /composeApp/src/androidMain/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /composeApp/src/iosMain/kotlin/org/example/project/Platform.ios.kt: -------------------------------------------------------------------------------- 1 | package org.example.project 2 | 3 | import platform.UIKit.UIDevice 4 | 5 | class IOSPlatform: Platform { 6 | override val name: String = UIDevice.currentDevice.systemName() + " " + UIDevice.currentDevice.systemVersion 7 | } 8 | 9 | actual fun getPlatform(): Platform = IOSPlatform() -------------------------------------------------------------------------------- /liquidSlider/src/androidMain/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /liquidSlider/src/androidMain/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /liquidSlider/src/desktopMain/kotlin/org/example/project/main.kt: -------------------------------------------------------------------------------- 1 | package org.example.project 2 | 3 | import androidx.compose.ui.window.Window 4 | import androidx.compose.ui.window.application 5 | 6 | fun main() = application { 7 | Window( 8 | onCloseRequest = ::exitApplication, 9 | title = "KMP-Liquid-Slider", 10 | ) { 11 | } 12 | } -------------------------------------------------------------------------------- /liquidSlider/src/wasmJsMain/kotlin/org/example/project/main.kt: -------------------------------------------------------------------------------- 1 | package org.example.project 2 | 3 | import androidx.compose.ui.ExperimentalComposeUiApi 4 | import androidx.compose.ui.window.ComposeViewport 5 | import kotlinx.browser.document 6 | 7 | @OptIn(ExperimentalComposeUiApi::class) 8 | fun main() { 9 | ComposeViewport(document.body!!) { 10 | } 11 | } -------------------------------------------------------------------------------- /composeApp/src/desktopMain/kotlin/org/example/project/main.kt: -------------------------------------------------------------------------------- 1 | package org.example.project 2 | 3 | import androidx.compose.ui.window.Window 4 | import androidx.compose.ui.window.application 5 | 6 | fun main() = application { 7 | Window( 8 | onCloseRequest = ::exitApplication, 9 | title = "KMP-Liquid-Slider", 10 | ) { 11 | App() 12 | } 13 | } -------------------------------------------------------------------------------- /composeApp/src/wasmJsMain/kotlin/org/example/project/main.kt: -------------------------------------------------------------------------------- 1 | package org.example.project 2 | 3 | import androidx.compose.ui.ExperimentalComposeUiApi 4 | import androidx.compose.ui.window.ComposeViewport 5 | import kotlinx.browser.document 6 | 7 | @OptIn(ExperimentalComposeUiApi::class) 8 | fun main() { 9 | ComposeViewport(document.body!!) { 10 | App() 11 | } 12 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .kotlin 3 | .gradle 4 | **/build/ 5 | xcuserdata 6 | !src/**/build/ 7 | local.properties 8 | .idea 9 | .DS_Store 10 | captures 11 | .externalNativeBuild 12 | .cxx 13 | *.xcodeproj/* 14 | !*.xcodeproj/project.pbxproj 15 | !*.xcodeproj/xcshareddata/ 16 | !*.xcodeproj/project.xcworkspace/ 17 | !*.xcworkspace/contents.xcworkspacedata 18 | **/xcshareddata/WorkspaceSettings.xcsettings 19 | -------------------------------------------------------------------------------- /composeApp/src/wasmJsMain/resources/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | KMP-Liquid-Slider 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /liquidSlider/src/wasmJsMain/resources/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | KMP-Liquid-Slider 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | #Kotlin 2 | kotlin.code.style=official 3 | kotlin.daemon.jvmargs=-Xmx8048M 4 | 5 | #Gradle 6 | org.gradle.jvmargs=-Xmx8048M -Dfile.encoding=UTF-8 7 | 8 | #Android 9 | android.nonTransitiveRClass=true 10 | android.useAndroidX=true 11 | SONATYPE_HOST=CENTRAL_PORTAL 12 | RELEASE_SIGNING_ENABLED=true 13 | mavenCentralUsername=zgNDKkyt 14 | mavenCentralPassword=b1GmPORIcOfyL147yIhsTJH/daNVnPCZg2FrOaaGSuzE 15 | 16 | 17 | signing.keyId=84DC98B3 -------------------------------------------------------------------------------- /iosApp/iosApp/ContentView.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | import SwiftUI 3 | import ComposeApp 4 | 5 | struct ComposeView: UIViewControllerRepresentable { 6 | func makeUIViewController(context: Context) -> UIViewController { 7 | MainViewControllerKt.MainViewController() 8 | } 9 | 10 | func updateUIViewController(_ uiViewController: UIViewController, context: Context) {} 11 | } 12 | 13 | struct ContentView: View { 14 | var body: some View { 15 | ComposeView() 16 | .ignoresSafeArea(.keyboard) // Compose has own keyboard handler 17 | } 18 | } 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /liquidSlider/src/commonMain/kotlin/org/example/slider/library/Rect.kt: -------------------------------------------------------------------------------- 1 | package org.example.project.library 2 | 3 | internal data class Rect( 4 | var left: Float, 5 | var top: Float, 6 | var right: Float, 7 | var bottom: Float 8 | ) { 9 | val width: Float get() = right - left 10 | val height: Float get() = bottom - top 11 | 12 | val centerX: Float get() = left + width / 2f 13 | val centerY: Float get() = top + height / 2f 14 | 15 | fun translate(dx: Float, dy: Float) { 16 | left += dx 17 | right += dx 18 | top += dy 19 | bottom += dy 20 | } 21 | } -------------------------------------------------------------------------------- /composeApp/src/androidMain/kotlin/org/example/project/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package org.example.project 2 | 3 | import android.os.Bundle 4 | import androidx.activity.ComponentActivity 5 | import androidx.activity.compose.setContent 6 | import androidx.compose.runtime.Composable 7 | import androidx.compose.ui.tooling.preview.Preview 8 | 9 | class MainActivity : ComponentActivity() { 10 | override fun onCreate(savedInstanceState: Bundle?) { 11 | super.onCreate(savedInstanceState) 12 | 13 | setContent { 14 | App() 15 | } 16 | } 17 | } 18 | 19 | @Preview 20 | @Composable 21 | fun AppAndroidPreview() { 22 | App() 23 | } -------------------------------------------------------------------------------- /.fleet/receipt.json: -------------------------------------------------------------------------------- 1 | // Project generated by Kotlin Multiplatform Wizard 2 | { 3 | "spec": { 4 | "template_id": "kmt", 5 | "targets": { 6 | "android": { 7 | "ui": [ 8 | "compose" 9 | ] 10 | }, 11 | "ios": { 12 | "ui": [ 13 | "compose" 14 | ] 15 | }, 16 | "desktop": { 17 | "ui": [ 18 | "compose" 19 | ] 20 | }, 21 | "web": { 22 | "ui": [ 23 | "compose" 24 | ] 25 | } 26 | } 27 | }, 28 | "timestamp": "2025-01-22T13:09:12.471062340Z" 29 | } -------------------------------------------------------------------------------- /liquidSlider/src/commonMain/kotlin/org/example/slider/library/CanvasState.kt: -------------------------------------------------------------------------------- 1 | package org.example.project.library 2 | 3 | import kotlin.math.cos 4 | import kotlin.math.sin 5 | import kotlin.math.sqrt 6 | 7 | internal fun getVector(radians: Float, length: Float): Pair { 8 | val x = cos(radians) * length 9 | val y = sin(radians) * length 10 | return x to y 11 | } 12 | 13 | internal fun getVectorLength(x1: Float, y1: Float, x2: Float, y2: Float): Float { 14 | val dx = x1 - x2 15 | val dy = y1 - y2 16 | return sqrt(dx * dx + dy * dy) 17 | } 18 | 19 | internal fun offsetRectToPosition(centerX: Float, vararg rects: Rect) { 20 | rects.forEach { r -> 21 | val dx = centerX - (r.left + r.width / 2) 22 | r.translate(dx = dx, dy = 0f) 23 | } 24 | } -------------------------------------------------------------------------------- /settings.gradle.kts: -------------------------------------------------------------------------------- 1 | rootProject.name = "KMP-Liquid-Slider" 2 | enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS") 3 | 4 | pluginManagement { 5 | repositories { 6 | google { 7 | mavenContent { 8 | includeGroupAndSubgroups("androidx") 9 | includeGroupAndSubgroups("com.android") 10 | includeGroupAndSubgroups("com.google") 11 | } 12 | } 13 | mavenCentral() 14 | gradlePluginPortal() 15 | } 16 | } 17 | 18 | dependencyResolutionManagement { 19 | repositories { 20 | google { 21 | mavenContent { 22 | includeGroupAndSubgroups("androidx") 23 | includeGroupAndSubgroups("com.android") 24 | includeGroupAndSubgroups("com.google") 25 | } 26 | } 27 | mavenCentral() 28 | } 29 | } 30 | 31 | include(":composeApp") 32 | include(":liquidSlider") -------------------------------------------------------------------------------- /.github/workflows/deploy_web.yml: -------------------------------------------------------------------------------- 1 | name: Deploy to GitHub Pages 2 | 3 | on: 4 | push: 5 | tags: 6 | - 'v*' 7 | 8 | jobs: 9 | deploy: 10 | runs-on: ubuntu-latest 11 | steps: 12 | - name: Checkout code 13 | uses: actions/checkout@v4 14 | 15 | - name: Setup Java 16 | uses: actions/setup-java@v4 17 | with: 18 | distribution: 'temurin' 19 | java-version: '17' 20 | 21 | - name: Setup Node.js (for Kotlin/JS) 22 | uses: actions/setup-node@v4 23 | with: 24 | node-version: '20' 25 | 26 | - name: Grant execute permission for gradlew 27 | run: chmod +x gradlew 28 | 29 | - name: Build WASM app 30 | run: ./gradlew :composeApp:wasmJsBrowserDistribution 31 | 32 | - name: Deploy to GitHub Pages 33 | uses: peaceiris/actions-gh-pages@v3 34 | with: 35 | github_token: ${{ secrets.GITHUB_TOKEN }} 36 | publish_dir: composeApp/build/dist/wasmJs/productionExecutable 37 | keep_files: true -------------------------------------------------------------------------------- /composeApp/src/androidMain/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /liquidSlider/src/androidMain/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /liquidSlider/src/commonMain/kotlin/org/example/slider/library/LiquidSliderConstants.kt: -------------------------------------------------------------------------------- 1 | package org.example.slider.library 2 | 3 | object SliderConstants { 4 | const val BAR_CORNER_RADIUS = 4 5 | const val BAR_VERTICAL_OFFSET = 1.2f 6 | const val PROGRESS_COUNT = 20 7 | const val BAR_INNER_HORIZONTAL_OFFSET = 0f 8 | const val SLIDER_WIDTH = 4 9 | const val SLIDER_HEIGHT = 1 + BAR_VERTICAL_OFFSET 10 | const val TOP_CIRCLE_DIAMETER = 0.8f 11 | const val BOTTOM_CIRCLE_DIAMETER = 25f 12 | const val TOUCH_CIRCLE_DIAMETER = 1f 13 | const val LABEL_CIRCLE_DIAMETER = 1f 14 | const val ANIMATION_DURATION = 400 15 | const val TOP_SPREAD_FACTOR = 0.4f 16 | const val BOTTOM_START_SPREAD_FACTOR = 0.25f 17 | const val BOTTOM_END_SPREAD_FACTOR = 0.1f 18 | const val LIQUID_BALL_HANDLER_FACTOR = 1.4f 19 | const val LIQUID_BALL_MAX_DISTANCE = 15f 20 | const val LIQUID_BALL_RISE_DISTANCE = 1.2f 21 | const val TEXT_SIZE = 12f 22 | const val TEXT_OFFSET = 8 23 | const val TEXT_START = "0" 24 | const val TEXT_END = "20" 25 | const val INITIAL_POSITION = 0.5f 26 | const val LIQUID_BALL_TEXT_BACKGROUND_FACTOR = 0.8f 27 | } 28 | -------------------------------------------------------------------------------- /iosApp/iosApp/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | $(PRODUCT_BUNDLE_PACKAGE_TYPE) 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | CADisableMinimumFrameDurationOnPhone 24 | 25 | UIApplicationSceneManifest 26 | 27 | UIApplicationSupportsMultipleScenes 28 | 29 | 30 | UILaunchScreen 31 | 32 | UIRequiredDeviceCapabilities 33 | 34 | armv7 35 | 36 | UISupportedInterfaceOrientations 37 | 38 | UIInterfaceOrientationPortrait 39 | UIInterfaceOrientationLandscapeLeft 40 | UIInterfaceOrientationLandscapeRight 41 | 42 | UISupportedInterfaceOrientations~ipad 43 | 44 | UIInterfaceOrientationPortrait 45 | UIInterfaceOrientationPortraitUpsideDown 46 | UIInterfaceOrientationLandscapeLeft 47 | UIInterfaceOrientationLandscapeRight 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /composeApp/src/androidMain/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | 15 | 18 | 21 | 22 | 23 | 24 | 30 | -------------------------------------------------------------------------------- /liquidSlider/src/androidMain/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | 15 | 18 | 21 | 22 | 23 | 24 | 30 | -------------------------------------------------------------------------------- /composeApp/src/commonMain/composeResources/drawable/emoji.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 11 | 14 | 17 | 20 | 23 | 26 | 29 | -------------------------------------------------------------------------------- /liquidSlider/src/commonMain/composeResources/drawable/emoji.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 11 | 14 | 17 | 20 | 23 | 26 | 29 | -------------------------------------------------------------------------------- /liquidSlider/src/commonMain/kotlin/org/example/slider/library/LiquidSliderConfig.kt: -------------------------------------------------------------------------------- 1 | package org.example.slider.library 2 | 3 | import androidx.compose.ui.graphics.Color 4 | import androidx.compose.ui.graphics.ImageBitmap 5 | import org.example.slider.library.SliderConstants.LIQUID_BALL_TEXT_BACKGROUND_FACTOR 6 | 7 | 8 | data class LiquidSliderConfig( 9 | val barColor: Color = Color(0xFF6168E7), 10 | val bubbleColor: Color = Color(0xFF6168E7), 11 | val textColor: Color = Color.Black, 12 | val barTextColor: Color = Color.White, 13 | val imageList: List = emptyList(), 14 | val bubbleImageSizeFactor: Float = 0.8f, 15 | val startText: String = SliderConstants.TEXT_START, 16 | val endText: String = SliderConstants.TEXT_END, 17 | val textSize: Float = SliderConstants.TEXT_SIZE, 18 | val bubbleText: String? = null, 19 | val showBubbleTextBackground: Boolean = true, 20 | val bubbleTextBackground: Color = Color.White, 21 | val bubbleTextBackgroundSizeFactor: Float = LIQUID_BALL_TEXT_BACKGROUND_FACTOR, 22 | val progressCount: Int = SliderConstants.PROGRESS_COUNT, 23 | val barCornerRadius: Float = SliderConstants.BAR_CORNER_RADIUS.toFloat(), 24 | val barVerticalOffset: Float = SliderConstants.BAR_VERTICAL_OFFSET, 25 | val barInnerHorizontalOffset: Float = SliderConstants.BAR_INNER_HORIZONTAL_OFFSET, 26 | val sliderWidth: Float = SliderConstants.SLIDER_WIDTH.toFloat(), 27 | val sliderHeight: Float = SliderConstants.SLIDER_HEIGHT, 28 | val topCircleDiameter: Float = SliderConstants.TOP_CIRCLE_DIAMETER, 29 | val bottomCircleDiameter: Float = SliderConstants.BOTTOM_CIRCLE_DIAMETER, 30 | val touchCircleDiameter: Float = SliderConstants.TOUCH_CIRCLE_DIAMETER, 31 | val labelCircleDiameter: Float = SliderConstants.LABEL_CIRCLE_DIAMETER, 32 | val animationDuration: Int = SliderConstants.ANIMATION_DURATION, 33 | val topSpreadFactor: Float = SliderConstants.TOP_SPREAD_FACTOR, 34 | val bottomStartSpreadFactor: Float = SliderConstants.BOTTOM_START_SPREAD_FACTOR, 35 | val bottomEndSpreadFactor: Float = SliderConstants.BOTTOM_END_SPREAD_FACTOR, 36 | val liquidBalHandlerFactor: Float = SliderConstants.LIQUID_BALL_HANDLER_FACTOR, 37 | val liquidBalMaxDistance: Float = SliderConstants.LIQUID_BALL_MAX_DISTANCE, 38 | val liquidBalRiseDistance: Float = SliderConstants.LIQUID_BALL_RISE_DISTANCE, 39 | val textOffset: Float = SliderConstants.TEXT_OFFSET.toFloat(), 40 | val initialPosition: Float = SliderConstants.INITIAL_POSITION 41 | ) -------------------------------------------------------------------------------- /gradle/libs.versions.toml: -------------------------------------------------------------------------------- 1 | [versions] 2 | agp = "8.5.2" 3 | android-compileSdk = "34" 4 | android-minSdk = "24" 5 | android-targetSdk = "34" 6 | androidx-activityCompose = "1.9.3" 7 | androidx-appcompat = "1.7.0" 8 | androidx-constraintlayout = "2.2.0" 9 | androidx-core-ktx = "1.15.0" 10 | androidx-espresso-core = "3.6.1" 11 | androidx-lifecycle = "2.8.4" 12 | androidx-material = "1.12.0" 13 | androidx-test-junit = "1.2.1" 14 | compose-multiplatform = "1.7.0" 15 | junit = "4.13.2" 16 | kotlin = "2.1.0" 17 | kotlinx-coroutines = "1.10.1" 18 | 19 | [libraries] 20 | kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotlin" } 21 | kotlin-test-junit = { module = "org.jetbrains.kotlin:kotlin-test-junit", version.ref = "kotlin" } 22 | junit = { group = "junit", name = "junit", version.ref = "junit" } 23 | androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "androidx-core-ktx" } 24 | androidx-test-junit = { group = "androidx.test.ext", name = "junit", version.ref = "androidx-test-junit" } 25 | androidx-espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "androidx-espresso-core" } 26 | androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "androidx-appcompat" } 27 | androidx-material = { group = "com.google.android.material", name = "material", version.ref = "androidx-material" } 28 | androidx-constraintlayout = { group = "androidx.constraintlayout", name = "constraintlayout", version.ref = "androidx-constraintlayout" } 29 | androidx-activity-compose = { module = "androidx.activity:activity-compose", version.ref = "androidx-activityCompose" } 30 | androidx-lifecycle-viewmodel = { group = "org.jetbrains.androidx.lifecycle", name = "lifecycle-viewmodel", version.ref = "androidx-lifecycle" } 31 | androidx-lifecycle-runtime-compose = { group = "org.jetbrains.androidx.lifecycle", name = "lifecycle-runtime-compose", version.ref = "androidx-lifecycle" } 32 | kotlinx-coroutines-swing = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-swing", version.ref = "kotlinx-coroutines" } 33 | 34 | [plugins] 35 | androidApplication = { id = "com.android.application", version.ref = "agp" } 36 | androidLibrary = { id = "com.android.library", version.ref = "agp" } 37 | composeMultiplatform = { id = "org.jetbrains.compose", version.ref = "compose-multiplatform" } 38 | composeCompiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" } 39 | kotlinMultiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" } -------------------------------------------------------------------------------- /liquidSlider/src/commonMain/kotlin/org/example/slider/library/LiquidSlider.kt: -------------------------------------------------------------------------------- 1 | package org.example.project.library 2 | 3 | import androidx.compose.animation.core.Spring 4 | import androidx.compose.animation.core.animateFloatAsState 5 | import androidx.compose.animation.core.spring 6 | import androidx.compose.foundation.layout.Box 7 | import androidx.compose.foundation.layout.height 8 | import androidx.compose.foundation.layout.width 9 | import androidx.compose.runtime.Composable 10 | import androidx.compose.runtime.LaunchedEffect 11 | import androidx.compose.runtime.mutableStateOf 12 | import androidx.compose.runtime.remember 13 | import androidx.compose.ui.Modifier 14 | import androidx.compose.ui.draw.clip 15 | import androidx.compose.ui.graphics.RectangleShape 16 | import androidx.compose.ui.platform.LocalDensity 17 | import androidx.compose.ui.text.rememberTextMeasurer 18 | import androidx.compose.ui.unit.dp 19 | import org.example.slider.library.LiquidSliderConfig 20 | import org.example.slider.library.SliderConstants.SLIDER_HEIGHT 21 | 22 | @Composable 23 | fun LiquidSlider( 24 | modifier: Modifier = Modifier, 25 | size: LiquidSliderSize = LiquidSliderSize(), 26 | liquidSliderConfig: LiquidSliderConfig = LiquidSliderConfig(), 27 | 28 | onValueChange: (Float) -> Unit, 29 | onBeginTracking: () -> Unit = {}, 30 | onEndTracking: () -> Unit = {}, 31 | 32 | ) { 33 | val density = LocalDensity.current 34 | val barHeightPx = with(density) { size.height.dp.toPx() } 35 | 36 | val desiredWidthPx = with(density) { size.width.dp.toPx() } 37 | val desiredHeightPx = (barHeightPx * SLIDER_HEIGHT) 38 | 39 | var sliderPosition = remember { mutableStateOf(liquidSliderConfig.initialPosition.coerceIn(0f, 1f)) } 40 | 41 | var isDragging = remember { mutableStateOf(false) } 42 | val topCircleAnimOffset = animateFloatAsState( 43 | targetValue = if (isDragging.value) -(liquidSliderConfig.liquidBalRiseDistance) else 0f, 44 | animationSpec = spring( 45 | dampingRatio = 0.6f, 46 | stiffness = Spring.StiffnessLow 47 | ), 48 | label = "topCircleY" 49 | ) 50 | 51 | val textMeasurer = rememberTextMeasurer() 52 | 53 | Box( 54 | modifier = modifier 55 | .width(with(density) { desiredWidthPx.toDp() }) 56 | .height(with(density) { (desiredHeightPx * 1.4f).toDp() }) 57 | .clip(RectangleShape) 58 | ) { 59 | LiquidSliderCanvas( 60 | density, 61 | desiredHeightPx, 62 | isDragging, 63 | onBeginTracking, 64 | onEndTracking, 65 | size, 66 | desiredWidthPx, 67 | barHeightPx, 68 | sliderPosition, 69 | onValueChange, 70 | topCircleAnimOffset, 71 | textMeasurer, 72 | liquidSliderConfig 73 | ) 74 | } 75 | 76 | LaunchedEffect(liquidSliderConfig.initialPosition) { 77 | sliderPosition.value = liquidSliderConfig.initialPosition.coerceIn(0f, 1f) 78 | } 79 | } 80 | 81 | 82 | -------------------------------------------------------------------------------- /.github/workflows/publish.yml: -------------------------------------------------------------------------------- 1 | name: Publish to Maven Central 2 | 3 | on: 4 | push: 5 | tags: 6 | - 'v*' 7 | 8 | jobs: 9 | publish: 10 | runs-on: macos-latest 11 | steps: 12 | - name: Checkout repository 13 | uses: actions/checkout@v3 14 | 15 | - name: Set up JDK 17 16 | uses: actions/setup-java@v3 17 | with: 18 | distribution: temurin 19 | java-version: '17' 20 | 21 | - name: Grant execute permission to gradlew 22 | run: chmod +x gradlew 23 | 24 | - name: Import GPG Key 25 | run: | 26 | # Import the passphrase-free GPG private key into the keyring. 27 | echo "$GPG_PRIVATE_KEY" | gpg --batch --import 28 | # (Optional) List imported keys for debugging. 29 | gpg --list-secret-keys --keyid-format LONG 30 | env: 31 | GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }} 32 | 33 | - name: Build and Publish to Maven Central 34 | env: 35 | # Non-sensitive properties 36 | android.nonTransitiveRClass: true 37 | SONATYPE_HOST: CENTRAL_PORTAL 38 | RELEASE_SIGNING_ENABLED: true 39 | GROUP: io.github.mejdi14 40 | POM_ARTIFACT_ID: KMP-Liquid-Slider 41 | POM_NAME: KMP-Liquid-Slider 42 | POM_DESCRIPTION: "This library provides ...." 43 | POM_URL: https://github.com/mejdi14/KMP-Liquid-Slider 44 | POM_LICENSE_NAME: "The Apache Software License, Version 2.0" 45 | POM_LICENSE_URL: https://www.apache.org/licenses/LICENSE-2.0.txt 46 | POM_LICENSE_DIST: repo 47 | POM_SCM_URL: https://github.com/mejdi14/KMP-Liquid-Slider 48 | POM_SCM_CONNECTION: scm:git:git://github.com/mejdi14/KMP-Liquid-Slider.git 49 | POM_SCM_DEV_CONNECTION: scm:git:ssh://git@github.com/mejdi14/KMP-Liquid-Slider.git 50 | POM_DEVELOPER_ID: mejdi14 51 | POM_DEVELOPER_NAME: "mejdi hafiene" 52 | POM_DEVELOPER_URL: https://github.com/mejdi14/ 53 | POM_DEVELOPER_EMAIL: mejdihafiane@gmail.com 54 | 55 | run: | 56 | VERSION_NAME=${GITHUB_REF#refs/tags/v} 57 | echo "Publishing version: $VERSION_NAME" 58 | 59 | ./gradlew publish \ 60 | -PVERSION_NAME="$VERSION_NAME" \ 61 | -PGROUP="$GROUP" \ 62 | -PPOM_ARTIFACT_ID="$POM_ARTIFACT_ID" \ 63 | -PPOM_NAME="$POM_NAME" \ 64 | -PPOM_DESCRIPTION="$POM_DESCRIPTION" \ 65 | -PPOM_URL="$POM_URL" \ 66 | -PPOM_LICENSE_NAME="$POM_LICENSE_NAME" \ 67 | -PPOM_LICENSE_URL="$POM_LICENSE_URL" \ 68 | -PPOM_LICENSE_DIST="$POM_LICENSE_DIST" \ 69 | -PPOM_SCM_URL="$POM_SCM_URL" \ 70 | -PPOM_SCM_CONNECTION="$POM_SCM_CONNECTION" \ 71 | -PPOM_SCM_DEV_CONNECTION="$POM_SCM_DEV_CONNECTION" \ 72 | -PPOM_DEVELOPER_ID="$POM_DEVELOPER_ID" \ 73 | -PPOM_DEVELOPER_NAME="$POM_DEVELOPER_NAME" \ 74 | -PPOM_DEVELOPER_URL="$POM_DEVELOPER_URL" \ 75 | -PPOM_DEVELOPER_EMAIL="$POM_DEVELOPER_EMAIL" \ 76 | -Dorg.gradle.internal.publish.checksums.insecure=true \ 77 | -Dorg.gradle.internal.publish.signing.insecure=true -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | @rem SPDX-License-Identifier: Apache-2.0 17 | @rem 18 | 19 | @if "%DEBUG%"=="" @echo off 20 | @rem ########################################################################## 21 | @rem 22 | @rem Gradle startup script for Windows 23 | @rem 24 | @rem ########################################################################## 25 | 26 | @rem Set local scope for the variables with windows NT shell 27 | if "%OS%"=="Windows_NT" setlocal 28 | 29 | set DIRNAME=%~dp0 30 | if "%DIRNAME%"=="" set DIRNAME=. 31 | @rem This is normally unused 32 | set APP_BASE_NAME=%~n0 33 | set APP_HOME=%DIRNAME% 34 | 35 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 36 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 37 | 38 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 39 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 40 | 41 | @rem Find java.exe 42 | if defined JAVA_HOME goto findJavaFromJavaHome 43 | 44 | set JAVA_EXE=java.exe 45 | %JAVA_EXE% -version >NUL 2>&1 46 | if %ERRORLEVEL% equ 0 goto execute 47 | 48 | echo. 1>&2 49 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 50 | echo. 1>&2 51 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2 52 | echo location of your Java installation. 1>&2 53 | 54 | goto fail 55 | 56 | :findJavaFromJavaHome 57 | set JAVA_HOME=%JAVA_HOME:"=% 58 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 59 | 60 | if exist "%JAVA_EXE%" goto execute 61 | 62 | echo. 1>&2 63 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 64 | echo. 1>&2 65 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2 66 | echo location of your Java installation. 1>&2 67 | 68 | goto fail 69 | 70 | :execute 71 | @rem Setup the command line 72 | 73 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 74 | 75 | 76 | @rem Execute Gradle 77 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 78 | 79 | :end 80 | @rem End local scope for the variables with windows NT shell 81 | if %ERRORLEVEL% equ 0 goto mainEnd 82 | 83 | :fail 84 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 85 | rem the _cmd.exe /c_ return code! 86 | set EXIT_CODE=%ERRORLEVEL% 87 | if %EXIT_CODE% equ 0 set EXIT_CODE=1 88 | if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% 89 | exit /b %EXIT_CODE% 90 | 91 | :mainEnd 92 | if "%OS%"=="Windows_NT" endlocal 93 | 94 | :omega 95 | -------------------------------------------------------------------------------- /composeApp/src/commonMain/kotlin/org/example/project/App.kt: -------------------------------------------------------------------------------- 1 | package org.example.project 2 | 3 | import androidx.compose.foundation.layout.Box 4 | import androidx.compose.foundation.layout.Column 5 | import androidx.compose.foundation.layout.Spacer 6 | import androidx.compose.foundation.layout.fillMaxWidth 7 | import androidx.compose.foundation.layout.height 8 | import androidx.compose.material.MaterialTheme 9 | import androidx.compose.runtime.* 10 | import androidx.compose.ui.Alignment 11 | import androidx.compose.ui.Modifier 12 | import androidx.compose.ui.graphics.Color 13 | import androidx.compose.ui.graphics.ImageBitmap 14 | import androidx.compose.ui.unit.dp 15 | import kmp_liquid_slider.composeapp.generated.resources.Res 16 | import kmp_liquid_slider.composeapp.generated.resources.blush 17 | import kmp_liquid_slider.composeapp.generated.resources.cold_sweat 18 | import kmp_liquid_slider.composeapp.generated.resources.disappointed_relieved 19 | import kmp_liquid_slider.composeapp.generated.resources.heart_eyes 20 | import kmp_liquid_slider.composeapp.generated.resources.neutral_face 21 | import org.example.project.library.LiquidSlider 22 | import org.example.slider.library.LiquidSliderConfig 23 | import org.jetbrains.compose.resources.imageResource 24 | import org.jetbrains.compose.ui.tooling.preview.Preview 25 | 26 | @Composable 27 | @Preview 28 | fun App() { 29 | MaterialTheme { 30 | Column { 31 | Spacer(Modifier.height(100.dp)) 32 | Box( 33 | Modifier.fillMaxWidth() 34 | ) { 35 | val imageList = listOf( 36 | imageResource(Res.drawable.cold_sweat), 37 | imageResource(Res.drawable.disappointed_relieved), 38 | imageResource(Res.drawable.neutral_face), 39 | imageResource(Res.drawable.blush), 40 | imageResource(Res.drawable.heart_eyes), 41 | 42 | ) 43 | LiquidSlider( 44 | modifier = Modifier.align(Alignment.Center), 45 | liquidSliderConfig = LiquidSliderConfig( 46 | imageList = imageList, 47 | barColor = Color(0xFF5CB338), 48 | bubbleColor = Color(0xFF5CB338) 49 | ), 50 | onValueChange = { newValue -> 51 | }, 52 | ) 53 | } 54 | 55 | Spacer(Modifier.height(100.dp)) 56 | data class People( 57 | val name: String, 58 | val job: String 59 | ) 60 | 61 | val people = listOf( 62 | People("Arij", "Software engineer"), 63 | People("Mejdi", "Software engineer"), 64 | People("Sami", "Designer"), 65 | People("Rami", "Product Manager"), 66 | People("Balqees", "QA Tester"), 67 | ) 68 | Box( 69 | Modifier.fillMaxWidth() 70 | ) { 71 | LiquidSlider( 72 | modifier = Modifier.align(Alignment.Center), 73 | 74 | onValueChange = { newValue -> 75 | }, 76 | ) 77 | 78 | } 79 | } 80 | } 81 | } 82 | 83 | -------------------------------------------------------------------------------- /liquidSlider/build.gradle.kts: -------------------------------------------------------------------------------- 1 | import org.jetbrains.compose.desktop.application.dsl.TargetFormat 2 | import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi 3 | import org.jetbrains.kotlin.gradle.ExperimentalWasmDsl 4 | import org.jetbrains.kotlin.gradle.dsl.JvmTarget 5 | import org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpackConfig 6 | 7 | plugins { 8 | alias(libs.plugins.kotlinMultiplatform) 9 | alias(libs.plugins.androidLibrary) 10 | alias(libs.plugins.composeMultiplatform) 11 | alias(libs.plugins.composeCompiler) 12 | id("com.vanniktech.maven.publish") version "0.30.0" 13 | signing 14 | } 15 | 16 | kotlin { 17 | androidTarget { 18 | @OptIn(ExperimentalKotlinGradlePluginApi::class) 19 | compilerOptions { 20 | jvmTarget.set(JvmTarget.JVM_11) 21 | } 22 | } 23 | 24 | iosX64() 25 | iosArm64() 26 | iosSimulatorArm64() 27 | 28 | jvm("desktop") 29 | 30 | @OptIn(ExperimentalWasmDsl::class) 31 | wasmJs { 32 | moduleName = "liquidSlider" 33 | browser { 34 | val rootDirPath = project.rootDir.path 35 | val projectDirPath = project.projectDir.path 36 | commonWebpackConfig { 37 | outputFileName = "composeApp.js" 38 | devServer = (devServer ?: KotlinWebpackConfig.DevServer()).apply { 39 | static = (static ?: mutableListOf()).apply { 40 | // Serve sources to debug inside browser 41 | add(rootDirPath) 42 | add(projectDirPath) 43 | } 44 | } 45 | } 46 | } 47 | binaries.executable() 48 | } 49 | 50 | sourceSets { 51 | val desktopMain by getting 52 | 53 | androidMain.dependencies { 54 | implementation(compose.preview) 55 | implementation(libs.androidx.activity.compose) 56 | } 57 | commonMain.dependencies { 58 | implementation(compose.runtime) 59 | implementation(compose.foundation) 60 | implementation(compose.material) 61 | implementation(compose.ui) 62 | implementation(compose.components.resources) 63 | implementation(compose.components.uiToolingPreview) 64 | implementation(libs.androidx.lifecycle.viewmodel) 65 | implementation(libs.androidx.lifecycle.runtime.compose) 66 | implementation("co.touchlab:kermit:2.0.4") 67 | } 68 | desktopMain.dependencies { 69 | implementation(compose.desktop.currentOs) 70 | implementation(libs.kotlinx.coroutines.swing) 71 | } 72 | } 73 | } 74 | 75 | android { 76 | namespace = "org.example.slider" 77 | compileSdk = libs.versions.android.compileSdk.get().toInt() 78 | 79 | defaultConfig { 80 | minSdk = libs.versions.android.minSdk.get().toInt() 81 | } 82 | packaging { 83 | resources { 84 | excludes += "/META-INF/{AL2.0,LGPL2.1}" 85 | } 86 | } 87 | buildTypes { 88 | getByName("release") { 89 | isMinifyEnabled = false 90 | } 91 | } 92 | compileOptions { 93 | sourceCompatibility = JavaVersion.VERSION_11 94 | targetCompatibility = JavaVersion.VERSION_11 95 | } 96 | } 97 | 98 | dependencies { 99 | debugImplementation(compose.uiTooling) 100 | } 101 | 102 | compose.desktop { 103 | application { 104 | mainClass = "org.example.slider.MainKt" 105 | 106 | nativeDistributions { 107 | targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb) 108 | packageName = "org.example.slider" 109 | packageVersion = "1.0.0" 110 | } 111 | } 112 | } 113 | 114 | if ((project.findProperty("RELEASE_SIGNING_ENABLED")?.toString() ?: "false").toBoolean()) { 115 | signing { 116 | useGpgCmd() 117 | sign(publishing.publications) 118 | } 119 | } 120 | -------------------------------------------------------------------------------- /composeApp/build.gradle.kts: -------------------------------------------------------------------------------- 1 | @file:OptIn(ExperimentalDistributionDsl::class) 2 | 3 | import org.jetbrains.compose.desktop.application.dsl.TargetFormat 4 | import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi 5 | import org.jetbrains.kotlin.gradle.ExperimentalWasmDsl 6 | import org.jetbrains.kotlin.gradle.dsl.JvmTarget 7 | import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalDistributionDsl 8 | import org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpackConfig 9 | 10 | plugins { 11 | alias(libs.plugins.kotlinMultiplatform) 12 | alias(libs.plugins.androidApplication) 13 | alias(libs.plugins.composeMultiplatform) 14 | alias(libs.plugins.composeCompiler) 15 | } 16 | 17 | kotlin { 18 | androidTarget { 19 | @OptIn(ExperimentalKotlinGradlePluginApi::class) 20 | compilerOptions { 21 | jvmTarget.set(JvmTarget.JVM_11) 22 | } 23 | } 24 | 25 | listOf( 26 | iosX64(), 27 | iosArm64(), 28 | iosSimulatorArm64() 29 | ).forEach { iosTarget -> 30 | iosTarget.binaries.framework { 31 | baseName = "ComposeApp" 32 | isStatic = true 33 | } 34 | } 35 | 36 | jvm("desktop") 37 | 38 | @OptIn(ExperimentalWasmDsl::class) 39 | wasmJs { 40 | moduleName = "composeApp" 41 | browser { 42 | val rootDirPath = project.rootDir.path 43 | val projectDirPath = project.projectDir.path 44 | commonWebpackConfig { 45 | outputFileName = "composeApp.js" 46 | devServer = (devServer ?: KotlinWebpackConfig.DevServer()).apply { 47 | static = (static ?: mutableListOf()).apply { 48 | // Serve sources to debug inside browser 49 | add(rootDirPath) 50 | add(projectDirPath) 51 | } 52 | } 53 | } 54 | distribution { 55 | directory = File("$projectDir/build/dist/wasmJs/productionExecutable") 56 | } 57 | } 58 | binaries.executable() 59 | } 60 | 61 | sourceSets { 62 | val desktopMain by getting 63 | 64 | androidMain.dependencies { 65 | implementation(compose.preview) 66 | implementation(libs.androidx.activity.compose) 67 | } 68 | commonMain.dependencies { 69 | implementation(compose.runtime) 70 | implementation(compose.foundation) 71 | implementation(compose.material) 72 | implementation(compose.ui) 73 | implementation(compose.components.resources) 74 | implementation(compose.components.uiToolingPreview) 75 | implementation(libs.androidx.lifecycle.viewmodel) 76 | implementation(libs.androidx.lifecycle.runtime.compose) 77 | implementation(project(":liquidSlider")) 78 | } 79 | desktopMain.dependencies { 80 | implementation(compose.desktop.currentOs) 81 | implementation(libs.kotlinx.coroutines.swing) 82 | } 83 | } 84 | } 85 | 86 | android { 87 | namespace = "org.example.project" 88 | compileSdk = libs.versions.android.compileSdk.get().toInt() 89 | 90 | defaultConfig { 91 | applicationId = "org.example.project" 92 | minSdk = libs.versions.android.minSdk.get().toInt() 93 | targetSdk = libs.versions.android.targetSdk.get().toInt() 94 | versionCode = 1 95 | versionName = "1.0" 96 | } 97 | packaging { 98 | resources { 99 | excludes += "/META-INF/{AL2.0,LGPL2.1}" 100 | } 101 | } 102 | buildTypes { 103 | getByName("release") { 104 | isMinifyEnabled = false 105 | } 106 | } 107 | compileOptions { 108 | sourceCompatibility = JavaVersion.VERSION_11 109 | targetCompatibility = JavaVersion.VERSION_11 110 | } 111 | } 112 | 113 | dependencies { 114 | debugImplementation(compose.uiTooling) 115 | } 116 | 117 | compose.desktop { 118 | application { 119 | mainClass = "org.example.project.MainKt" 120 | 121 | nativeDistributions { 122 | targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb) 123 | packageName = "org.example.project" 124 | packageVersion = "1.0.0" 125 | } 126 | } 127 | } 128 | -------------------------------------------------------------------------------- /composeApp/src/commonMain/composeResources/drawable/compose-multiplatform.xml: -------------------------------------------------------------------------------- 1 | 6 | 10 | 14 | 18 | 24 | 30 | 36 | -------------------------------------------------------------------------------- /liquidSlider/src/commonMain/composeResources/drawable/compose-multiplatform.xml: -------------------------------------------------------------------------------- 1 | 6 | 10 | 14 | 18 | 24 | 30 | 36 | -------------------------------------------------------------------------------- /composeApp/src/androidMain/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 10 | 15 | 20 | 25 | 30 | 35 | 40 | 45 | 50 | 55 | 60 | 65 | 70 | 75 | 80 | 85 | 90 | 95 | 100 | 105 | 110 | 115 | 120 | 125 | 130 | 135 | 140 | 145 | 150 | 155 | 160 | 165 | 170 | -------------------------------------------------------------------------------- /liquidSlider/src/androidMain/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 10 | 15 | 20 | 25 | 30 | 35 | 40 | 45 | 50 | 55 | 60 | 65 | 70 | 75 | 80 | 85 | 90 | 95 | 100 | 105 | 110 | 115 | 120 | 125 | 130 | 135 | 140 | 145 | 150 | 155 | 160 | 165 | 170 | -------------------------------------------------------------------------------- /liquidSlider/src/commonMain/kotlin/org/example/slider/library/LiquidBall.kt: -------------------------------------------------------------------------------- 1 | package org.example.project.library 2 | 3 | import androidx.compose.ui.geometry.Offset 4 | import androidx.compose.ui.geometry.Size 5 | import androidx.compose.ui.graphics.Color 6 | import androidx.compose.ui.graphics.Path 7 | import androidx.compose.ui.graphics.drawscope.DrawScope 8 | import kotlin.math.PI 9 | import kotlin.math.abs 10 | import kotlin.math.acos 11 | import kotlin.math.atan2 12 | import kotlin.math.max 13 | import kotlin.math.min 14 | 15 | internal fun DrawScope.drawLiquidBall( 16 | liquidBallPath: Path, 17 | bottomCircle: Rect, 18 | topCircle: Rect, 19 | barTopBoundary: Float, 20 | liquidBallRiseLimit: Float, 21 | maxDistanceBetweenCircles: Float, 22 | cornerRadiusPx: Float, 23 | topCircleSpreadFactor: Float, 24 | bottomCircleStartSpreadFactor: Float, 25 | bottomCircleEndSpreadFactor: Float, 26 | handleRate: Float, 27 | liquidBallColor: Color 28 | ) { 29 | val bottomCircleRadius = bottomCircle.width / 2f 30 | val topCircleRadius = topCircle.width / 2f 31 | 32 | if (bottomCircleRadius == 0f || topCircleRadius == 0f) return 33 | 34 | val centerDistance = getVectorLength( 35 | bottomCircle.centerX, bottomCircle.centerY, 36 | topCircle.centerX, topCircle.centerY 37 | ) 38 | 39 | if (centerDistance > maxDistanceBetweenCircles || centerDistance <= abs(bottomCircleRadius - topCircleRadius)) { 40 | return 41 | } 42 | 43 | val riseRatio = min(1f, max(0f, barTopBoundary - topCircle.top) / liquidBallRiseLimit) 44 | 45 | val angleOffset1: Float 46 | val angleOffset2: Float 47 | 48 | if (centerDistance < bottomCircleRadius + topCircleRadius) { 49 | angleOffset1 = acos( 50 | (bottomCircleRadius * bottomCircleRadius + centerDistance * centerDistance - topCircleRadius * topCircleRadius) / 51 | (2 * bottomCircleRadius * centerDistance) 52 | ) 53 | angleOffset2 = acos( 54 | (topCircleRadius * topCircleRadius + centerDistance * centerDistance - bottomCircleRadius * bottomCircleRadius) / 55 | (2 * topCircleRadius * centerDistance) 56 | ) 57 | } else { 58 | angleOffset1 = 0f 59 | angleOffset2 = 0f 60 | } 61 | 62 | val xDistance = topCircle.centerX - bottomCircle.centerX 63 | val yDistance = topCircle.centerY - bottomCircle.centerY 64 | 65 | val bottomCircleSpreadFactorDiff = bottomCircleStartSpreadFactor - bottomCircleEndSpreadFactor 66 | val bottomCircleSpreadFactor = 67 | bottomCircleStartSpreadFactor - bottomCircleSpreadFactorDiff * riseRatio 68 | 69 | val fullPi = PI.toFloat() 70 | val baseAngle = atan2(yDistance, xDistance) 71 | val angleDifference = acos((bottomCircleRadius - topCircleRadius) / centerDistance) 72 | 73 | val bottomCircleAngle1 = 74 | baseAngle + angleOffset1 + (angleDifference - angleOffset1) * bottomCircleSpreadFactor 75 | val bottomCircleAngle2 = 76 | baseAngle - angleOffset1 - (angleDifference - angleOffset1) * bottomCircleSpreadFactor 77 | val topCircleAngle1 = 78 | baseAngle + fullPi - angleOffset2 - (fullPi - angleOffset2 - angleDifference) * topCircleSpreadFactor 79 | val topCircleAngle2 = 80 | baseAngle - fullPi + angleOffset2 + (fullPi - angleOffset2 - angleDifference) * topCircleSpreadFactor 81 | 82 | val bottomCirclePoint1 = getVector(bottomCircleAngle1, bottomCircleRadius).let { 83 | Offset(it.first + bottomCircle.centerX, it.second + bottomCircle.centerY) 84 | } 85 | val bottomCirclePoint2 = getVector(bottomCircleAngle2, bottomCircleRadius).let { 86 | Offset(it.first + bottomCircle.centerX, it.second + bottomCircle.centerY) 87 | } 88 | 89 | val topCirclePoint1 = getVector(topCircleAngle1, topCircleRadius).let { 90 | Offset(it.first + topCircle.centerX, it.second + topCircle.centerY) 91 | } 92 | val topCirclePoint2 = getVector(topCircleAngle2, topCircleRadius).let { 93 | Offset(it.first + topCircle.centerX, it.second + topCircle.centerY) 94 | } 95 | 96 | val combinedRadius = bottomCircleRadius + topCircleRadius 97 | val handleOffset = min( 98 | max(topCircleSpreadFactor, bottomCircleSpreadFactor) * handleRate, 99 | getVectorLength( 100 | bottomCirclePoint1.x, 101 | bottomCirclePoint1.y, 102 | topCirclePoint1.x, 103 | topCirclePoint1.y 104 | ) / combinedRadius 105 | ) 106 | 107 | val bottomHandleRadius = bottomCircleRadius * handleOffset 108 | val topHandleRadius = topCircleRadius * handleOffset 109 | 110 | val quarterPi = fullPi / 2 111 | val bottomHandle1 = getVector(bottomCircleAngle1 - quarterPi, bottomHandleRadius) 112 | val topHandle1 = getVector(topCircleAngle1 + quarterPi, topHandleRadius) 113 | val topHandle2 = getVector(topCircleAngle2 - quarterPi, topHandleRadius) 114 | val bottomHandle2 = getVector(bottomCircleAngle2 + quarterPi, bottomHandleRadius) 115 | 116 | val verticalOffset = abs(barTopBoundary - bottomCirclePoint1.y) * riseRatio - 1 117 | val adjustedBottomPoint1 = Offset(bottomCirclePoint1.x, bottomCirclePoint1.y - verticalOffset) 118 | val adjustedBottomPoint2 = Offset(bottomCirclePoint2.x, bottomCirclePoint2.y - verticalOffset) 119 | 120 | with(liquidBallPath) { 121 | reset() 122 | moveTo(adjustedBottomPoint1.x, adjustedBottomPoint1.y + cornerRadiusPx) 123 | lineTo(adjustedBottomPoint1.x, adjustedBottomPoint1.y) 124 | 125 | cubicTo( 126 | adjustedBottomPoint1.x + bottomHandle1.first, 127 | adjustedBottomPoint1.y + bottomHandle1.second, 128 | topCirclePoint1.x + topHandle1.first, 129 | topCirclePoint1.y + topHandle1.second, 130 | topCirclePoint1.x, 131 | topCirclePoint1.y 132 | ) 133 | 134 | lineTo(topCircle.centerX, topCircle.centerY) 135 | lineTo(topCirclePoint2.x, topCirclePoint2.y) 136 | 137 | cubicTo( 138 | topCirclePoint2.x + topHandle2.first, 139 | topCirclePoint2.y + topHandle2.second, 140 | adjustedBottomPoint2.x + bottomHandle2.first, 141 | adjustedBottomPoint2.y + bottomHandle2.second, 142 | adjustedBottomPoint2.x, 143 | adjustedBottomPoint2.y 144 | ) 145 | 146 | lineTo(adjustedBottomPoint2.x, adjustedBottomPoint2.y + cornerRadiusPx) 147 | close() 148 | } 149 | 150 | drawPath(path = liquidBallPath, color = liquidBallColor) 151 | drawOval( 152 | color = liquidBallColor, 153 | topLeft = Offset(topCircle.left, topCircle.top), 154 | size = Size(topCircle.width, topCircle.height) 155 | ) 156 | } 157 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 |

Welcome to KMP Liquid Slider 👋

4 | 5 |

6 | 7 | Minimum API Level 8 | 9 | 10 | Maven Central 11 | 12 | 13 | License: MIT 14 | 15 | 16 | Android Arsenal 17 | 18 |

19 | 20 | ## ✨ Demo 21 | 22 |
23 | 29 |
30 | 31 | ## :art: inspiration 32 | 33 | This library was inspired by Ramotion's original library which i migrated to Jetpack Compose 34 | 35 | ## Installation 36 | 37 | Add this to your module's `build.gradle` file: 38 | 39 | ```gradle 40 | dependencies { 41 | ... 42 | implementation("io.github.mejdi14:KMP-Liquid-Slider:1.0.7")} 43 | ``` 44 | 45 | ## :fire: How to Use 46 | 47 | ```kotlin 48 | LiquidSlider( 49 | modifier = Modifier.fillMaxWidth(), 50 | size = LiquidSliderSize(width = 300.dp, height = 50.dp), 51 | liquidSliderConfig = LiquidSliderConfig( 52 | barColor = Color(0xFF6168E7), 53 | bubbleColor = Color.White, 54 | textColor = Color.Black, 55 | startText = "0", 56 | endText = "20", 57 | textSize = 14f, 58 | bubbleText = "Value", 59 | initialPosition = 0.5f 60 | ), 61 | onValueChange = { value -> 62 | // Handle value change 63 | }, 64 | onBeginTracking = { 65 | // Called when the user starts interacting with the slider 66 | }, 67 | onEndTracking = { 68 | // Called when the user stops interacting with the slider 69 | } 70 | ) 71 | ``` 72 | 73 | --- 74 | 75 | ## LiquidSliderConfig Properties 76 | 77 | The `LiquidSliderConfig` class allows you to customize the appearance and behavior of the liquid slider. Below is a table of its properties: 78 | 79 | | Field | Type | Default Value | Description | 80 | |------------------------------|------------|----------------------------------------|-----------------------------------------------------------------------------| 81 | | `barColor` | `Color` | `Color(0xFF6168E7)` | The color of the slider bar. | 82 | | `bubbleColor` | `Color` | `Color(0xFF6168E7)` | The color of the bubble (thumb). | 83 | | `textColor` | `Color` | `Color.Black` | The color of the text displayed on the slider. | 84 | | `barTextColor` | `Color` | `Color.White` | The color of the text inside the bar. | 85 | | `startText` | `String` | `SliderConstants.TEXT_START` | The text displayed at the start of the slider. | 86 | | `endText` | `String` | `SliderConstants.TEXT_END` | The text displayed at the end of the slider. | 87 | | `textSize` | `Float` | `SliderConstants.TEXT_SIZE` | The size of the text displayed on the slider. | 88 | | `bubbleText` | `String?` | `null` | Optional text displayed inside the bubble. | 89 | | `progressCount` | `Int` | `SliderConstants.PROGRESS_COUNT` | The number of progress steps (if applicable). | 90 | | `barCornerRadius` | `Float` | `SliderConstants.BAR_CORNER_RADIUS` | The corner radius of the slider bar. | 91 | | `barVerticalOffset` | `Float` | `SliderConstants.BAR_VERTICAL_OFFSET` | The vertical offset of the slider bar. | 92 | | `barInnerHorizontalOffset` | `Float` | `SliderConstants.BAR_INNER_HORIZONTAL_OFFSET` | The horizontal offset inside the slider bar. | 93 | | `sliderWidth` | `Float` | `SliderConstants.SLIDER_WIDTH` | The width of the slider. | 94 | | `sliderHeight` | `Float` | `SliderConstants.SLIDER_HEIGHT` | The height of the slider. | 95 | | `topCircleDiameter` | `Float` | `SliderConstants.TOP_CIRCLE_DIAMETER` | The diameter of the top circle (bubble). | 96 | | `bottomCircleDiameter` | `Float` | `SliderConstants.BOTTOM_CIRCLE_DIAMETER` | The diameter of the bottom circle. | 97 | | `touchCircleDiameter` | `Float` | `SliderConstants.TOUCH_CIRCLE_DIAMETER` | The diameter of the touchable area. | 98 | | `labelCircleDiameter` | `Float` | `SliderConstants.LABEL_CIRCLE_DIAMETER` | The diameter of the label circle. | 99 | | `animationDuration` | `Int` | `SliderConstants.ANIMATION_DURATION` | The duration of animations in milliseconds. | 100 | | `topSpreadFactor` | `Float` | `SliderConstants.TOP_SPREAD_FACTOR` | The spread factor for the top circle animation. | 101 | | `bottomStartSpreadFactor` | `Float` | `SliderConstants.BOTTOM_START_SPREAD_FACTOR` | The spread factor for the bottom circle at the start. | 102 | | `bottomEndSpreadFactor` | `Float` | `SliderConstants.BOTTOM_END_SPREAD_FACTOR` | The spread factor for the bottom circle at the end. | 103 | | `liquidBalHandlerFactor` | `Float` | `SliderConstants.LIQUID_BALL_HANDLER_FACTOR` | The handler factor for the liquid ball animation. | 104 | | `liquidBalMaxDistance` | `Float` | `SliderConstants.LIQUID_BALL_MAX_DISTANCE` | The maximum distance for the liquid ball animation. | 105 | | `liquidBalRiseDistance` | `Float` | `SliderConstants.LIQUID_BALL_RISE_DISTANCE` | The rise distance for the liquid ball animation. | 106 | | `textOffset` | `Float` | `SliderConstants.TEXT_OFFSET` | The offset for the text displayed on the slider. | 107 | | `initialPosition` | `Float` | `SliderConstants.INITIAL_POSITION` | The initial position of the slider (between 0 and 1). | 108 | 109 | --- 110 | 111 | ## Use images instead 112 | you can make the slider switch between different images just by providing a list of images 113 | 114 |
115 | 121 |
122 | 123 | ```kotlin 124 | val myImages = listOf( 125 | imageResource(Res.drawable.cold_sweat), 126 | imageResource(Res.drawable.disappointed_relieved), 127 | imageResource(Res.drawable.neutral_face), 128 | imageResource(Res.drawable.blush), 129 | imageResource(Res.drawable.heart_eyes), 130 | 131 | ) 132 | LiquidSlider( 133 | modifier = Modifier.align(Alignment.Center), 134 | liquidSliderConfig = LiquidSliderConfig( 135 | imageList = myImages, 136 | ), 137 | onValueChange = { newValue -> 138 | }, 139 | ) 140 | 141 | ``` 142 | 143 | If you have suggestions or feature requests, feel free to open an issue or contribute to the repository. 144 | 145 | --- 146 | 147 | ## 🤝 Contributing 148 | 149 | Contributions, issues, and feature requests are welcome!
150 | Feel free to check the [issues page](https://github.com/mejdi14/KMP-Liquid-Slider/issues) if you want to contribute. 151 | 152 | --- 153 | 154 | ## Author 155 | 156 | 👤 **Mejdi Hafiane** 157 | 158 | - Profile: [@MejdiHafiane](https://twitter.com/mejdi141) 159 | 160 | --- 161 | 162 | ## Show Your Support 163 | 164 | Please ⭐️ this repository if this project helped you! 165 | 166 | --- 167 | 168 | ## 📝 License 169 | 170 | Copyright © 2023 [Mejdi Hafiane](https://github.com/mejdi14).
171 | This project is [MIT](https://github.com/mejdi14/KMP-Liquid-Slider/blob/main/LICENSE) licensed. 172 | 173 | --- 174 | 175 | This README provides a clear and structured overview of your `KMP-Liquid-Slider` library, making it easy for users to understand and integrate into their projects. 176 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # 4 | # Copyright © 2015-2021 the original authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | # SPDX-License-Identifier: Apache-2.0 19 | # 20 | 21 | ############################################################################## 22 | # 23 | # Gradle start up script for POSIX generated by Gradle. 24 | # 25 | # Important for running: 26 | # 27 | # (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is 28 | # noncompliant, but you have some other compliant shell such as ksh or 29 | # bash, then to run this script, type that shell name before the whole 30 | # command line, like: 31 | # 32 | # ksh Gradle 33 | # 34 | # Busybox and similar reduced shells will NOT work, because this script 35 | # requires all of these POSIX shell features: 36 | # * functions; 37 | # * expansions «$var», «${var}», «${var:-default}», «${var+SET}», 38 | # «${var#prefix}», «${var%suffix}», and «$( cmd )»; 39 | # * compound commands having a testable exit status, especially «case»; 40 | # * various built-in commands including «command», «set», and «ulimit». 41 | # 42 | # Important for patching: 43 | # 44 | # (2) This script targets any POSIX shell, so it avoids extensions provided 45 | # by Bash, Ksh, etc; in particular arrays are avoided. 46 | # 47 | # The "traditional" practice of packing multiple parameters into a 48 | # space-separated string is a well documented source of bugs and security 49 | # problems, so this is (mostly) avoided, by progressively accumulating 50 | # options in "$@", and eventually passing that to Java. 51 | # 52 | # Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, 53 | # and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; 54 | # see the in-line comments for details. 55 | # 56 | # There are tweaks for specific operating systems such as AIX, CygWin, 57 | # Darwin, MinGW, and NonStop. 58 | # 59 | # (3) This script is generated from the Groovy template 60 | # https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt 61 | # within the Gradle project. 62 | # 63 | # You can find Gradle at https://github.com/gradle/gradle/. 64 | # 65 | ############################################################################## 66 | 67 | # Attempt to set APP_HOME 68 | 69 | # Resolve links: $0 may be a link 70 | app_path=$0 71 | 72 | # Need this for daisy-chained symlinks. 73 | while 74 | APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path 75 | [ -h "$app_path" ] 76 | do 77 | ls=$( ls -ld "$app_path" ) 78 | link=${ls#*' -> '} 79 | case $link in #( 80 | /*) app_path=$link ;; #( 81 | *) app_path=$APP_HOME$link ;; 82 | esac 83 | done 84 | 85 | # This is normally unused 86 | # shellcheck disable=SC2034 87 | APP_BASE_NAME=${0##*/} 88 | # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) 89 | APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s 90 | ' "$PWD" ) || exit 91 | 92 | # Use the maximum available, or set MAX_FD != -1 to use that value. 93 | MAX_FD=maximum 94 | 95 | warn () { 96 | echo "$*" 97 | } >&2 98 | 99 | die () { 100 | echo 101 | echo "$*" 102 | echo 103 | exit 1 104 | } >&2 105 | 106 | # OS specific support (must be 'true' or 'false'). 107 | cygwin=false 108 | msys=false 109 | darwin=false 110 | nonstop=false 111 | case "$( uname )" in #( 112 | CYGWIN* ) cygwin=true ;; #( 113 | Darwin* ) darwin=true ;; #( 114 | MSYS* | MINGW* ) msys=true ;; #( 115 | NONSTOP* ) nonstop=true ;; 116 | esac 117 | 118 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 119 | 120 | 121 | # Determine the Java command to use to start the JVM. 122 | if [ -n "$JAVA_HOME" ] ; then 123 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 124 | # IBM's JDK on AIX uses strange locations for the executables 125 | JAVACMD=$JAVA_HOME/jre/sh/java 126 | else 127 | JAVACMD=$JAVA_HOME/bin/java 128 | fi 129 | if [ ! -x "$JAVACMD" ] ; then 130 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 131 | 132 | Please set the JAVA_HOME variable in your environment to match the 133 | location of your Java installation." 134 | fi 135 | else 136 | JAVACMD=java 137 | if ! command -v java >/dev/null 2>&1 138 | then 139 | die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 140 | 141 | Please set the JAVA_HOME variable in your environment to match the 142 | location of your Java installation." 143 | fi 144 | fi 145 | 146 | # Increase the maximum file descriptors if we can. 147 | if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then 148 | case $MAX_FD in #( 149 | max*) 150 | # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. 151 | # shellcheck disable=SC2039,SC3045 152 | MAX_FD=$( ulimit -H -n ) || 153 | warn "Could not query maximum file descriptor limit" 154 | esac 155 | case $MAX_FD in #( 156 | '' | soft) :;; #( 157 | *) 158 | # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. 159 | # shellcheck disable=SC2039,SC3045 160 | ulimit -n "$MAX_FD" || 161 | warn "Could not set maximum file descriptor limit to $MAX_FD" 162 | esac 163 | fi 164 | 165 | # Collect all arguments for the java command, stacking in reverse order: 166 | # * args from the command line 167 | # * the main class name 168 | # * -classpath 169 | # * -D...appname settings 170 | # * --module-path (only if needed) 171 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. 172 | 173 | # For Cygwin or MSYS, switch paths to Windows format before running java 174 | if "$cygwin" || "$msys" ; then 175 | APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) 176 | CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) 177 | 178 | JAVACMD=$( cygpath --unix "$JAVACMD" ) 179 | 180 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 181 | for arg do 182 | if 183 | case $arg in #( 184 | -*) false ;; # don't mess with options #( 185 | /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath 186 | [ -e "$t" ] ;; #( 187 | *) false ;; 188 | esac 189 | then 190 | arg=$( cygpath --path --ignore --mixed "$arg" ) 191 | fi 192 | # Roll the args list around exactly as many times as the number of 193 | # args, so each arg winds up back in the position where it started, but 194 | # possibly modified. 195 | # 196 | # NB: a `for` loop captures its iteration list before it begins, so 197 | # changing the positional parameters here affects neither the number of 198 | # iterations, nor the values presented in `arg`. 199 | shift # remove old arg 200 | set -- "$@" "$arg" # push replacement arg 201 | done 202 | fi 203 | 204 | 205 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 206 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 207 | 208 | # Collect all arguments for the java command: 209 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, 210 | # and any embedded shellness will be escaped. 211 | # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be 212 | # treated as '${Hostname}' itself on the command line. 213 | 214 | set -- \ 215 | "-Dorg.gradle.appname=$APP_BASE_NAME" \ 216 | -classpath "$CLASSPATH" \ 217 | org.gradle.wrapper.GradleWrapperMain \ 218 | "$@" 219 | 220 | # Stop when "xargs" is not available. 221 | if ! command -v xargs >/dev/null 2>&1 222 | then 223 | die "xargs is not available" 224 | fi 225 | 226 | # Use "xargs" to parse quoted args. 227 | # 228 | # With -n1 it outputs one arg per line, with the quotes and backslashes removed. 229 | # 230 | # In Bash we could simply go: 231 | # 232 | # readarray ARGS < <( xargs -n1 <<<"$var" ) && 233 | # set -- "${ARGS[@]}" "$@" 234 | # 235 | # but POSIX shell has neither arrays nor command substitution, so instead we 236 | # post-process each arg (as a line of input to sed) to backslash-escape any 237 | # character that might be a shell metacharacter, then use eval to reverse 238 | # that process (while maintaining the separation between arguments), and wrap 239 | # the whole thing up as a single "set" statement. 240 | # 241 | # This will of course break if any of these variables contains a newline or 242 | # an unmatched quote. 243 | # 244 | 245 | eval "set -- $( 246 | printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | 247 | xargs -n1 | 248 | sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | 249 | tr '\n' ' ' 250 | )" '"$@"' 251 | 252 | exec "$JAVACMD" "$@" 253 | -------------------------------------------------------------------------------- /liquidSlider/src/commonMain/kotlin/org/example/slider/library/LiquidSliderCanvas.kt: -------------------------------------------------------------------------------- 1 | package org.example.project.library 2 | 3 | import androidx.compose.foundation.Canvas 4 | import androidx.compose.foundation.gestures.detectDragGestures 5 | import androidx.compose.foundation.layout.BoxScope 6 | import androidx.compose.foundation.layout.offset 7 | import androidx.compose.runtime.Composable 8 | import androidx.compose.runtime.MutableState 9 | import androidx.compose.runtime.State 10 | import androidx.compose.ui.Modifier 11 | import androidx.compose.ui.geometry.CornerRadius 12 | import androidx.compose.ui.geometry.Offset 13 | import androidx.compose.ui.geometry.Size 14 | import androidx.compose.ui.graphics.Path 15 | import androidx.compose.ui.input.pointer.pointerInput 16 | import androidx.compose.ui.text.AnnotatedString 17 | import androidx.compose.ui.text.TextMeasurer 18 | import androidx.compose.ui.text.TextStyle 19 | import androidx.compose.ui.text.drawText 20 | import androidx.compose.ui.text.style.TextAlign 21 | import androidx.compose.ui.unit.Density 22 | import androidx.compose.ui.unit.IntOffset 23 | import androidx.compose.ui.unit.IntSize 24 | import androidx.compose.ui.unit.dp 25 | import androidx.compose.ui.unit.sp 26 | import org.example.slider.library.LiquidSliderConfig 27 | import kotlin.math.roundToInt 28 | 29 | @Composable 30 | internal fun BoxScope.LiquidSliderCanvas( 31 | density: Density, 32 | desiredHeightPx: Float, 33 | isDragging: MutableState, 34 | onBeginTracking: () -> Unit, 35 | onEndTracking: () -> Unit, 36 | size: LiquidSliderSize, 37 | desiredWidthPx: Float, 38 | barHeightPx: Float, 39 | sliderPosition: MutableState, 40 | onValueChange: (Float) -> Unit, 41 | topCircleAnimOffset: State, 42 | textMeasurer: TextMeasurer, 43 | liquidSliderConfig: LiquidSliderConfig, 44 | ) { 45 | Canvas( 46 | modifier = Modifier 47 | .matchParentSize() 48 | .offset(y = with(density) { (desiredHeightPx * 0.4f).toDp() }) 49 | .pointerInput(Unit) { 50 | detectDragGestures( 51 | onDragStart = { 52 | isDragging.value = true 53 | onBeginTracking() 54 | }, 55 | onDragEnd = { 56 | isDragging.value = false 57 | onEndTracking() 58 | }, 59 | onDragCancel = { 60 | isDragging.value = false 61 | onEndTracking() 62 | } 63 | ) { change, dragAmount -> 64 | change.consume() 65 | 66 | size 67 | val w = size.width.dp.toPx() 68 | val actualWidth = desiredWidthPx 69 | val touchDiameterPx = barHeightPx * liquidSliderConfig.touchCircleDiameter 70 | val maxMovement = 71 | actualWidth - touchDiameterPx - liquidSliderConfig.barInnerHorizontalOffset 72 | 73 | val newPos = 74 | (sliderPosition.value + dragAmount.x / maxMovement).coerceIn(0f, 1f) 75 | sliderPosition.value = newPos 76 | onValueChange(newPos) 77 | } 78 | } 79 | ) { 80 | val canvasWidth = size.width.dp.toPx().coerceAtLeast(desiredWidthPx) 81 | val canvasHeight = size.height.dp.toPx().coerceAtLeast(desiredHeightPx) 82 | 83 | val barVerticalOffsetPx = barHeightPx * liquidSliderConfig.barVerticalOffset 84 | val barRect = Rect( 85 | left = 0f, 86 | top = barVerticalOffsetPx, 87 | right = canvasWidth, 88 | bottom = barVerticalOffsetPx + barHeightPx 89 | ) 90 | 91 | val topCircleDiameterPx = barHeightPx * liquidSliderConfig.topCircleDiameter 92 | val bottomCircleDiameterPx = barHeightPx * liquidSliderConfig.bottomCircleDiameter 93 | val touchDiameterPx = barHeightPx * liquidSliderConfig.touchCircleDiameter 94 | val labelDiameterPx = barHeightPx * liquidSliderConfig.labelCircleDiameter 95 | 96 | val liquidBallMaxDistPx = barHeightPx * liquidSliderConfig.liquidBalMaxDistance 97 | val liquidBallRiseDistPx = barHeightPx * liquidSliderConfig.liquidBalRiseDistance 98 | val cornerRadiusPx = liquidSliderConfig.barCornerRadius * density.density 99 | 100 | val rectBottomCircle = Rect( 101 | left = 0f, 102 | top = barVerticalOffsetPx, 103 | right = bottomCircleDiameterPx, 104 | bottom = barVerticalOffsetPx + bottomCircleDiameterPx 105 | ) 106 | 107 | val topRising = 108 | topCircleAnimOffset.value * barHeightPx 109 | val rectTopCircle = Rect( 110 | left = 0f, 111 | top = barVerticalOffsetPx + topRising, 112 | right = topCircleDiameterPx, 113 | bottom = barVerticalOffsetPx + topCircleDiameterPx + topRising 114 | ) 115 | 116 | val rectTouch = Rect( 117 | left = 0f, 118 | top = barVerticalOffsetPx, 119 | right = touchDiameterPx, 120 | bottom = barVerticalOffsetPx + touchDiameterPx 121 | ) 122 | 123 | val maxMovement = 124 | canvasWidth - touchDiameterPx - liquidSliderConfig.barInnerHorizontalOffset * 2 125 | val xPos = 126 | liquidSliderConfig.barInnerHorizontalOffset + (touchDiameterPx / 2) + maxMovement * sliderPosition.value 127 | val labelOffsetY = 128 | barVerticalOffsetPx + (topCircleDiameterPx - labelDiameterPx) / 2f + topRising 129 | val rectLabel = Rect( 130 | left = xPos - labelDiameterPx / 2f, 131 | top = labelOffsetY, 132 | right = xPos + labelDiameterPx / 2f, 133 | bottom = labelOffsetY + labelDiameterPx 134 | ) 135 | 136 | 137 | offsetRectToPosition(xPos, rectTouch, rectTopCircle, rectBottomCircle, rectLabel) 138 | 139 | drawRoundRect( 140 | color = liquidSliderConfig.barColor, 141 | topLeft = Offset(barRect.left, barRect.top), 142 | size = Size(barRect.width, barRect.height), 143 | cornerRadius = CornerRadius(cornerRadiusPx, cornerRadiusPx) 144 | ) 145 | 146 | val textStyleBar = TextStyle( 147 | color = liquidSliderConfig.barTextColor, 148 | fontSize = ((liquidSliderConfig.textSize)).sp, 149 | textAlign = TextAlign.Center 150 | ) 151 | val startTextLayout = 152 | textMeasurer.measure( 153 | AnnotatedString(liquidSliderConfig.startText), 154 | style = textStyleBar 155 | ) 156 | if (liquidSliderConfig.imageList.isEmpty()) { 157 | drawText( 158 | textMeasurer, 159 | liquidSliderConfig.startText, 160 | topLeft = Offset( 161 | x = liquidSliderConfig.textOffset * density.density, 162 | y = barRect.top + (barRect.height - startTextLayout.size.height) / 2 163 | ), 164 | style = textStyleBar 165 | ) 166 | val endTextLayout = 167 | textMeasurer.measure( 168 | AnnotatedString(liquidSliderConfig.endText), 169 | style = textStyleBar 170 | ) 171 | drawText( 172 | textMeasurer, 173 | liquidSliderConfig.endText, 174 | topLeft = Offset( 175 | x = barRect.right - endTextLayout.size.width - liquidSliderConfig.textOffset * density.density, 176 | y = barRect.top + (barRect.height - endTextLayout.size.height) / 2 177 | ), 178 | style = textStyleBar 179 | ) 180 | } 181 | 182 | 183 | val path = Path() 184 | drawLiquidBall( 185 | liquidBallPath = path, 186 | bottomCircle = rectBottomCircle, 187 | topCircle = rectTopCircle, 188 | barTopBoundary = barRect.top, 189 | liquidBallRiseLimit = liquidBallRiseDistPx, 190 | maxDistanceBetweenCircles = liquidBallMaxDistPx, 191 | cornerRadiusPx = cornerRadiusPx, 192 | topCircleSpreadFactor = liquidSliderConfig.topSpreadFactor, 193 | bottomCircleStartSpreadFactor = liquidSliderConfig.bottomStartSpreadFactor, 194 | bottomCircleEndSpreadFactor = liquidSliderConfig.bottomEndSpreadFactor, 195 | handleRate = liquidSliderConfig.liquidBalHandlerFactor, 196 | liquidBallColor = liquidSliderConfig.barColor 197 | ) 198 | 199 | drawCircle( 200 | color = liquidSliderConfig.bubbleColor, 201 | radius = labelDiameterPx / 2f, 202 | center = Offset(rectLabel.centerX, rectLabel.centerY) 203 | ) 204 | 205 | if (liquidSliderConfig.imageList.isNotEmpty()) { 206 | val index = (sliderPosition.value * (liquidSliderConfig.imageList.size - 1)) 207 | .roundToInt() 208 | .coerceIn(0, liquidSliderConfig.imageList.lastIndex) 209 | val imagePainter = liquidSliderConfig.imageList[index] 210 | val imageSize = labelDiameterPx * liquidSliderConfig.bubbleImageSizeFactor 211 | 212 | // Calculate the offset for the image 213 | val imageOffsetX = rectLabel.centerX - imageSize / 2 214 | val imageOffsetY = rectLabel.centerY - imageSize / 2 215 | 216 | // Use withTransform to position the image 217 | drawImage( 218 | image = imagePainter, 219 | dstSize = IntSize(imageSize.toInt(), imageSize.toInt()), 220 | dstOffset = IntOffset( 221 | imageOffsetX.toInt(), 222 | imageOffsetY.toInt() 223 | ), // Positioning the image 224 | ) 225 | } else { 226 | val labelString = liquidSliderConfig.bubbleText 227 | ?: ((sliderPosition.value * liquidSliderConfig.progressCount).toInt()).toString() 228 | val textLayoutLabel = textMeasurer.measure( 229 | AnnotatedString(labelString), 230 | style = textStyleBar.copy(color = liquidSliderConfig.textColor) 231 | ) 232 | 233 | val backgroundDiameter = 234 | labelDiameterPx * liquidSliderConfig.bubbleTextBackgroundSizeFactor 235 | val backgroundRadius = backgroundDiameter / 2f 236 | 237 | if (liquidSliderConfig.showBubbleTextBackground) 238 | drawCircle( 239 | color = liquidSliderConfig.bubbleTextBackground, 240 | radius = backgroundRadius, 241 | center = Offset(rectLabel.centerX, rectLabel.centerY) 242 | ) 243 | 244 | drawText( 245 | textMeasurer, 246 | labelString, 247 | topLeft = Offset( 248 | x = rectLabel.centerX - textLayoutLabel.size.width / 2, 249 | y = rectLabel.centerY - textLayoutLabel.size.height / 2 250 | ), 251 | style = textStyleBar.copy(color = liquidSliderConfig.textColor) 252 | ) 253 | } 254 | } 255 | 256 | } -------------------------------------------------------------------------------- /iosApp/iosApp.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 56; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 058557BB273AAA24004C7B11 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 058557BA273AAA24004C7B11 /* Assets.xcassets */; }; 11 | 058557D9273AAEEB004C7B11 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 058557D8273AAEEB004C7B11 /* Preview Assets.xcassets */; }; 12 | 2152FB042600AC8F00CF470E /* iOSApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2152FB032600AC8F00CF470E /* iOSApp.swift */; }; 13 | 7555FF83242A565900829871 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7555FF82242A565900829871 /* ContentView.swift */; }; 14 | /* End PBXBuildFile section */ 15 | 16 | /* Begin PBXFileReference section */ 17 | 058557BA273AAA24004C7B11 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 18 | 058557D8273AAEEB004C7B11 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = ""; }; 19 | 2152FB032600AC8F00CF470E /* iOSApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = iOSApp.swift; sourceTree = ""; }; 20 | 7555FF7B242A565900829871 /* KMP-Liquid-Slider.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = KMP-Liquid-Slider.app; sourceTree = BUILT_PRODUCTS_DIR; }; 21 | 7555FF82242A565900829871 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = ""; }; 22 | 7555FF8C242A565B00829871 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 23 | AB3632DC29227652001CCB65 /* Config.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Config.xcconfig; sourceTree = ""; }; 24 | /* End PBXFileReference section */ 25 | 26 | /* Begin PBXFrameworksBuildPhase section */ 27 | B92378962B6B1156000C7307 /* Frameworks */ = { 28 | isa = PBXFrameworksBuildPhase; 29 | buildActionMask = 2147483647; 30 | files = ( 31 | ); 32 | runOnlyForDeploymentPostprocessing = 0; 33 | }; 34 | /* End PBXFrameworksBuildPhase section */ 35 | 36 | /* Begin PBXGroup section */ 37 | 058557D7273AAEEB004C7B11 /* Preview Content */ = { 38 | isa = PBXGroup; 39 | children = ( 40 | 058557D8273AAEEB004C7B11 /* Preview Assets.xcassets */, 41 | ); 42 | path = "Preview Content"; 43 | sourceTree = ""; 44 | }; 45 | 42799AB246E5F90AF97AA0EF /* Frameworks */ = { 46 | isa = PBXGroup; 47 | children = ( 48 | ); 49 | name = Frameworks; 50 | sourceTree = ""; 51 | }; 52 | 7555FF72242A565900829871 = { 53 | isa = PBXGroup; 54 | children = ( 55 | AB1DB47929225F7C00F7AF9C /* Configuration */, 56 | 7555FF7D242A565900829871 /* iosApp */, 57 | 7555FF7C242A565900829871 /* Products */, 58 | 42799AB246E5F90AF97AA0EF /* Frameworks */, 59 | ); 60 | sourceTree = ""; 61 | }; 62 | 7555FF7C242A565900829871 /* Products */ = { 63 | isa = PBXGroup; 64 | children = ( 65 | 7555FF7B242A565900829871 /* KMP-Liquid-Slider.app */, 66 | ); 67 | name = Products; 68 | sourceTree = ""; 69 | }; 70 | 7555FF7D242A565900829871 /* iosApp */ = { 71 | isa = PBXGroup; 72 | children = ( 73 | 058557BA273AAA24004C7B11 /* Assets.xcassets */, 74 | 7555FF82242A565900829871 /* ContentView.swift */, 75 | 7555FF8C242A565B00829871 /* Info.plist */, 76 | 2152FB032600AC8F00CF470E /* iOSApp.swift */, 77 | 058557D7273AAEEB004C7B11 /* Preview Content */, 78 | ); 79 | path = iosApp; 80 | sourceTree = ""; 81 | }; 82 | AB1DB47929225F7C00F7AF9C /* Configuration */ = { 83 | isa = PBXGroup; 84 | children = ( 85 | AB3632DC29227652001CCB65 /* Config.xcconfig */, 86 | ); 87 | path = Configuration; 88 | sourceTree = ""; 89 | }; 90 | /* End PBXGroup section */ 91 | 92 | /* Begin PBXNativeTarget section */ 93 | 7555FF7A242A565900829871 /* iosApp */ = { 94 | isa = PBXNativeTarget; 95 | buildConfigurationList = 7555FFA5242A565B00829871 /* Build configuration list for PBXNativeTarget "iosApp" */; 96 | buildPhases = ( 97 | F36B1CEB2AD83DDC00CB74D5 /* Compile Kotlin Framework */, 98 | 7555FF77242A565900829871 /* Sources */, 99 | B92378962B6B1156000C7307 /* Frameworks */, 100 | 7555FF79242A565900829871 /* Resources */, 101 | ); 102 | buildRules = ( 103 | ); 104 | dependencies = ( 105 | ); 106 | name = iosApp; 107 | packageProductDependencies = ( 108 | ); 109 | productName = iosApp; 110 | productReference = 7555FF7B242A565900829871 /* KMP-Liquid-Slider.app */; 111 | productType = "com.apple.product-type.application"; 112 | }; 113 | /* End PBXNativeTarget section */ 114 | 115 | /* Begin PBXProject section */ 116 | 7555FF73242A565900829871 /* Project object */ = { 117 | isa = PBXProject; 118 | attributes = { 119 | BuildIndependentTargetsInParallel = YES; 120 | LastSwiftUpdateCheck = 1130; 121 | LastUpgradeCheck = 1540; 122 | ORGANIZATIONNAME = orgName; 123 | TargetAttributes = { 124 | 7555FF7A242A565900829871 = { 125 | CreatedOnToolsVersion = 11.3.1; 126 | }; 127 | }; 128 | }; 129 | buildConfigurationList = 7555FF76242A565900829871 /* Build configuration list for PBXProject "iosApp" */; 130 | compatibilityVersion = "Xcode 14.0"; 131 | developmentRegion = en; 132 | hasScannedForEncodings = 0; 133 | knownRegions = ( 134 | en, 135 | Base, 136 | ); 137 | mainGroup = 7555FF72242A565900829871; 138 | packageReferences = ( 139 | ); 140 | productRefGroup = 7555FF7C242A565900829871 /* Products */; 141 | projectDirPath = ""; 142 | projectRoot = ""; 143 | targets = ( 144 | 7555FF7A242A565900829871 /* iosApp */, 145 | ); 146 | }; 147 | /* End PBXProject section */ 148 | 149 | /* Begin PBXResourcesBuildPhase section */ 150 | 7555FF79242A565900829871 /* Resources */ = { 151 | isa = PBXResourcesBuildPhase; 152 | buildActionMask = 2147483647; 153 | files = ( 154 | 058557D9273AAEEB004C7B11 /* Preview Assets.xcassets in Resources */, 155 | 058557BB273AAA24004C7B11 /* Assets.xcassets in Resources */, 156 | ); 157 | runOnlyForDeploymentPostprocessing = 0; 158 | }; 159 | /* End PBXResourcesBuildPhase section */ 160 | 161 | /* Begin PBXShellScriptBuildPhase section */ 162 | F36B1CEB2AD83DDC00CB74D5 /* Compile Kotlin Framework */ = { 163 | isa = PBXShellScriptBuildPhase; 164 | buildActionMask = 2147483647; 165 | files = ( 166 | ); 167 | inputFileListPaths = ( 168 | ); 169 | inputPaths = ( 170 | ); 171 | name = "Compile Kotlin Framework"; 172 | outputFileListPaths = ( 173 | ); 174 | outputPaths = ( 175 | ); 176 | runOnlyForDeploymentPostprocessing = 0; 177 | shellPath = /bin/sh; 178 | shellScript = "if [ \"YES\" = \"$OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED\" ]; then\n echo \"Skipping Gradle build task invocation due to OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED environment variable set to \\\"YES\\\"\"\n exit 0\nfi\ncd \"$SRCROOT/..\"\n./gradlew :composeApp:embedAndSignAppleFrameworkForXcode\n"; 179 | }; 180 | /* End PBXShellScriptBuildPhase section */ 181 | 182 | /* Begin PBXSourcesBuildPhase section */ 183 | 7555FF77242A565900829871 /* Sources */ = { 184 | isa = PBXSourcesBuildPhase; 185 | buildActionMask = 2147483647; 186 | files = ( 187 | 2152FB042600AC8F00CF470E /* iOSApp.swift in Sources */, 188 | 7555FF83242A565900829871 /* ContentView.swift in Sources */, 189 | ); 190 | runOnlyForDeploymentPostprocessing = 0; 191 | }; 192 | /* End PBXSourcesBuildPhase section */ 193 | 194 | /* Begin XCBuildConfiguration section */ 195 | 7555FFA3242A565B00829871 /* Debug */ = { 196 | isa = XCBuildConfiguration; 197 | baseConfigurationReference = AB3632DC29227652001CCB65 /* Config.xcconfig */; 198 | buildSettings = { 199 | ALWAYS_SEARCH_USER_PATHS = NO; 200 | CLANG_ANALYZER_NONNULL = YES; 201 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 202 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 203 | CLANG_CXX_LIBRARY = "libc++"; 204 | CLANG_ENABLE_MODULES = YES; 205 | CLANG_ENABLE_OBJC_ARC = YES; 206 | CLANG_ENABLE_OBJC_WEAK = YES; 207 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 208 | CLANG_WARN_BOOL_CONVERSION = YES; 209 | CLANG_WARN_COMMA = YES; 210 | CLANG_WARN_CONSTANT_CONVERSION = YES; 211 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 212 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 213 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 214 | CLANG_WARN_EMPTY_BODY = YES; 215 | CLANG_WARN_ENUM_CONVERSION = YES; 216 | CLANG_WARN_INFINITE_RECURSION = YES; 217 | CLANG_WARN_INT_CONVERSION = YES; 218 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 219 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 220 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 221 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 222 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 223 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 224 | CLANG_WARN_STRICT_PROTOTYPES = YES; 225 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 226 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 227 | CLANG_WARN_UNREACHABLE_CODE = YES; 228 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 229 | COPY_PHASE_STRIP = NO; 230 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 231 | ENABLE_STRICT_OBJC_MSGSEND = YES; 232 | ENABLE_TESTABILITY = YES; 233 | ENABLE_USER_SCRIPT_SANDBOXING = NO; 234 | GCC_C_LANGUAGE_STANDARD = gnu11; 235 | GCC_DYNAMIC_NO_PIC = NO; 236 | GCC_NO_COMMON_BLOCKS = YES; 237 | GCC_OPTIMIZATION_LEVEL = 0; 238 | GCC_PREPROCESSOR_DEFINITIONS = ( 239 | "DEBUG=1", 240 | "$(inherited)", 241 | ); 242 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 243 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 244 | GCC_WARN_UNDECLARED_SELECTOR = YES; 245 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 246 | GCC_WARN_UNUSED_FUNCTION = YES; 247 | GCC_WARN_UNUSED_VARIABLE = YES; 248 | IPHONEOS_DEPLOYMENT_TARGET = 15.3; 249 | MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; 250 | MTL_FAST_MATH = YES; 251 | ONLY_ACTIVE_ARCH = YES; 252 | SDKROOT = iphoneos; 253 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 254 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 255 | }; 256 | name = Debug; 257 | }; 258 | 7555FFA4242A565B00829871 /* Release */ = { 259 | isa = XCBuildConfiguration; 260 | baseConfigurationReference = AB3632DC29227652001CCB65 /* Config.xcconfig */; 261 | buildSettings = { 262 | ALWAYS_SEARCH_USER_PATHS = NO; 263 | CLANG_ANALYZER_NONNULL = YES; 264 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 265 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 266 | CLANG_CXX_LIBRARY = "libc++"; 267 | CLANG_ENABLE_MODULES = YES; 268 | CLANG_ENABLE_OBJC_ARC = YES; 269 | CLANG_ENABLE_OBJC_WEAK = YES; 270 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 271 | CLANG_WARN_BOOL_CONVERSION = YES; 272 | CLANG_WARN_COMMA = YES; 273 | CLANG_WARN_CONSTANT_CONVERSION = YES; 274 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 275 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 276 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 277 | CLANG_WARN_EMPTY_BODY = YES; 278 | CLANG_WARN_ENUM_CONVERSION = YES; 279 | CLANG_WARN_INFINITE_RECURSION = YES; 280 | CLANG_WARN_INT_CONVERSION = YES; 281 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 282 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 283 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 284 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 285 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 286 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 287 | CLANG_WARN_STRICT_PROTOTYPES = YES; 288 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 289 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 290 | CLANG_WARN_UNREACHABLE_CODE = YES; 291 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 292 | COPY_PHASE_STRIP = NO; 293 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 294 | ENABLE_NS_ASSERTIONS = NO; 295 | ENABLE_STRICT_OBJC_MSGSEND = YES; 296 | ENABLE_USER_SCRIPT_SANDBOXING = NO; 297 | GCC_C_LANGUAGE_STANDARD = gnu11; 298 | GCC_NO_COMMON_BLOCKS = YES; 299 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 300 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 301 | GCC_WARN_UNDECLARED_SELECTOR = YES; 302 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 303 | GCC_WARN_UNUSED_FUNCTION = YES; 304 | GCC_WARN_UNUSED_VARIABLE = YES; 305 | IPHONEOS_DEPLOYMENT_TARGET = 15.3; 306 | MTL_ENABLE_DEBUG_INFO = NO; 307 | MTL_FAST_MATH = YES; 308 | SDKROOT = iphoneos; 309 | SWIFT_COMPILATION_MODE = wholemodule; 310 | SWIFT_OPTIMIZATION_LEVEL = "-O"; 311 | VALIDATE_PRODUCT = YES; 312 | }; 313 | name = Release; 314 | }; 315 | 7555FFA6242A565B00829871 /* Debug */ = { 316 | isa = XCBuildConfiguration; 317 | buildSettings = { 318 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 319 | CODE_SIGN_IDENTITY = "Apple Development"; 320 | CODE_SIGN_STYLE = Automatic; 321 | DEVELOPMENT_ASSET_PATHS = "\"iosApp/Preview Content\""; 322 | DEVELOPMENT_TEAM = "${TEAM_ID}"; 323 | ENABLE_PREVIEWS = YES; 324 | FRAMEWORK_SEARCH_PATHS = ( 325 | "$(inherited)", 326 | "$(SRCROOT)/../shared/build/xcode-frameworks/$(CONFIGURATION)/$(SDK_NAME)\n$(SRCROOT)/../composeApp/build/xcode-frameworks/$(CONFIGURATION)/$(SDK_NAME)", 327 | ); 328 | INFOPLIST_FILE = iosApp/Info.plist; 329 | IPHONEOS_DEPLOYMENT_TARGET = 15.3; 330 | LD_RUNPATH_SEARCH_PATHS = ( 331 | "$(inherited)", 332 | "@executable_path/Frameworks", 333 | ); 334 | PRODUCT_BUNDLE_IDENTIFIER = "${BUNDLE_ID}${TEAM_ID}"; 335 | PRODUCT_NAME = "${APP_NAME}"; 336 | PROVISIONING_PROFILE_SPECIFIER = ""; 337 | SWIFT_VERSION = 5.0; 338 | TARGETED_DEVICE_FAMILY = "1,2"; 339 | }; 340 | name = Debug; 341 | }; 342 | 7555FFA7242A565B00829871 /* Release */ = { 343 | isa = XCBuildConfiguration; 344 | buildSettings = { 345 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 346 | CODE_SIGN_IDENTITY = "Apple Development"; 347 | CODE_SIGN_STYLE = Automatic; 348 | DEVELOPMENT_ASSET_PATHS = "\"iosApp/Preview Content\""; 349 | DEVELOPMENT_TEAM = "${TEAM_ID}"; 350 | ENABLE_PREVIEWS = YES; 351 | FRAMEWORK_SEARCH_PATHS = ( 352 | "$(inherited)", 353 | "$(SRCROOT)/../shared/build/xcode-frameworks/$(CONFIGURATION)/$(SDK_NAME)\n$(SRCROOT)/../composeApp/build/xcode-frameworks/$(CONFIGURATION)/$(SDK_NAME)", 354 | ); 355 | INFOPLIST_FILE = iosApp/Info.plist; 356 | IPHONEOS_DEPLOYMENT_TARGET = 15.3; 357 | LD_RUNPATH_SEARCH_PATHS = ( 358 | "$(inherited)", 359 | "@executable_path/Frameworks", 360 | ); 361 | PRODUCT_BUNDLE_IDENTIFIER = "${BUNDLE_ID}${TEAM_ID}"; 362 | PRODUCT_NAME = "${APP_NAME}"; 363 | PROVISIONING_PROFILE_SPECIFIER = ""; 364 | SWIFT_VERSION = 5.0; 365 | TARGETED_DEVICE_FAMILY = "1,2"; 366 | }; 367 | name = Release; 368 | }; 369 | /* End XCBuildConfiguration section */ 370 | 371 | /* Begin XCConfigurationList section */ 372 | 7555FF76242A565900829871 /* Build configuration list for PBXProject "iosApp" */ = { 373 | isa = XCConfigurationList; 374 | buildConfigurations = ( 375 | 7555FFA3242A565B00829871 /* Debug */, 376 | 7555FFA4242A565B00829871 /* Release */, 377 | ); 378 | defaultConfigurationIsVisible = 0; 379 | defaultConfigurationName = Release; 380 | }; 381 | 7555FFA5242A565B00829871 /* Build configuration list for PBXNativeTarget "iosApp" */ = { 382 | isa = XCConfigurationList; 383 | buildConfigurations = ( 384 | 7555FFA6242A565B00829871 /* Debug */, 385 | 7555FFA7242A565B00829871 /* Release */, 386 | ); 387 | defaultConfigurationIsVisible = 0; 388 | defaultConfigurationName = Release; 389 | }; 390 | /* End XCConfigurationList section */ 391 | }; 392 | rootObject = 7555FF73242A565900829871 /* Project object */; 393 | } --------------------------------------------------------------------------------