Open-source Android PDF and document toolkit with PDF tools, Office viewing, XLSX editing, scanning, and image editing. Built with Kotlin and Jetpack Compose.
Rust androiddocument-scannerdocximage-editorjetpack-composekotlinliquid-glassofflineopen-sourcepdfpdf-compressorpdf-editorpdf-mergerpdf-readerpdf-splitterpdf-toolspdf-viewerpptxspreadsheet-editorxlsx
before backdrop changes
Chethan616ff4b458a16e0
diff --git a/AndroidLiquidGlass-kmp/.gitignore b/AndroidLiquidGlass-kmp/.gitignorenew file mode 100644index 0000000..28a82e3--- /dev/null+++ b/AndroidLiquidGlass-kmp/.gitignore@@ -0,0 +1,16 @@+*.iml+.gradle+/local.properties+/.idea/caches+/.idea/libraries+/.idea/modules.xml+/.idea/workspace.xml+/.idea/navEditor.xml+/.idea/assetWizardSettings.xml+.DS_Store+/build+/captures+.externalNativeBuild+.cxx+local.properties+/.kotlindiff --git a/AndroidLiquidGlass-kmp/LICENSE b/AndroidLiquidGlass-kmp/LICENSEnew file mode 100644index 0000000..e29d7cc--- /dev/null+++ b/AndroidLiquidGlass-kmp/LICENSE@@ -0,0 +1,191 @@++ Apache License+ Version 2.0, January 2004+ http://www.apache.org/licenses/++ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION++ 1. Definitions.++ "License" shall mean the terms and conditions for use, reproduction,+ and distribution as defined by Sections 1 through 9 of this document.++ "Licensor" shall mean the copyright owner or entity authorized by+ the copyright owner that is granting the License.++ "Legal Entity" shall mean the union of the acting entity and all+ other entities that control, are controlled by, or are under common+ control with that entity. For the purposes of this definition,+ "control" means (i) the power, direct or indirect, to cause the+ direction or management of such entity, whether by contract or+ otherwise, or (ii) ownership of fifty percent (50%) or more of the+ outstanding shares, or (iii) beneficial ownership of such entity.++ "You" (or "Your") shall mean an individual or Legal Entity+ exercising permissions granted by this License.++ "Source" form shall mean the preferred form for making modifications,+ including but not limited to software source code, documentation+ source, and configuration files.++ "Object" form shall mean any form resulting from mechanical+ transformation or translation of a Source form, including but+ not limited to compiled object code, generated documentation,+ and conversions to other media types.++ "Work" shall mean the work of authorship, whether in Source or+ Object form, made available under the License, as indicated by a+ copyright notice that is included in or attached to the work+ (an example is provided in the Appendix below).++ "Derivative Works" shall mean any work, whether in Source or Object+ form, that is based on (or derived from) the Work and for which the+ editorial revisions, annotations, elaborations, or other modifications+ represent, as a whole, an original work of authorship. For the purposes+ of this License, Derivative Works shall not include works that remain+ separable from, or merely link (or bind by name) to the interfaces of,+ the Work and Derivative Works thereof.++ "Contribution" shall mean any work of authorship, including+ the original version of the Work and any modifications or additions+ to that Work or Derivative Works thereof, that is intentionally+ submitted to Licensor for inclusion in the Work by the copyright owner+ or by an individual or Legal Entity authorized to submit on behalf of+ the copyright owner. For the purposes of this definition, "submitted"+ means any form of electronic, verbal, or written communication sent+ to the Licensor or its representatives, including but not limited to+ communication on electronic mailing lists, source code control systems,+ and issue tracking systems that are managed by, or on behalf of, the+ Licensor for the purpose of discussing and improving the Work, but+ excluding communication that is conspicuously marked or otherwise+ designated in writing by the copyright owner as "Not a Contribution."++ "Contributor" shall mean Licensor and any individual or Legal Entity+ on behalf of whom a Contribution has been received by Licensor and+ subsequently incorporated within the Work.++ 2. Grant of Copyright License. Subject to the terms and conditions of+ this License, each Contributor hereby grants to You a perpetual,+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable+ copyright license to reproduce, prepare Derivative Works of,+ publicly display, publicly perform, sublicense, and distribute the+ Work and such Derivative Works in Source or Object form.++ 3. Grant of Patent License. Subject to the terms and conditions of+ this License, each Contributor hereby grants to You a perpetual,+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable+ (except as stated in this section) patent license to make, have made,+ use, offer to sell, sell, import, and otherwise transfer the Work,+ where such license applies only to those patent claims licensable+ by such Contributor that are necessarily infringed by their+ Contribution(s) alone or by combination of their Contribution(s)+ with the Work to which such Contribution(s) was submitted. If You+ institute patent litigation against any entity (including a+ cross-claim or counterclaim in a lawsuit) alleging that the Work+ or a Contribution incorporated within the Work constitutes direct+ or contributory patent infringement, then any patent licenses+ granted to You under this License for that Work shall terminate+ as of the date such litigation is filed.++ 4. Redistribution. You may reproduce and distribute copies of the+ Work or Derivative Works thereof in any medium, with or without+ modifications, and in Source or Object form, provided that You+ meet the following conditions:++ (a) You must give any other recipients of the Work or+ Derivative Works a copy of this License; and++ (b) You must cause any modified files to carry prominent notices+ stating that You changed the files; and++ (c) You must retain, in the Source form of any Derivative Works+ that You distribute, all copyright, patent, trademark, and+ attribution notices from the Source form of the Work,+ excluding those notices that do not pertain to any part of+ the Derivative Works; and++ (d) If the Work includes a "NOTICE" text file as part of its+ distribution, then any Derivative Works that You distribute must+ include a readable copy of the attribution notices contained+ within such NOTICE file, excluding those notices that do not+ pertain to any part of the Derivative Works, in at least one+ of the following places: within a NOTICE text file distributed+ as part of the Derivative Works; within the Source form or+ documentation, if provided along with the Derivative Works; or,+ within a display generated by the Derivative Works, if and+ wherever such third-party notices normally appear. The contents+ of the NOTICE file are for informational purposes only and+ do not modify the License. You may add Your own attribution+ notices within Derivative Works that You distribute, alongside+ or as an addendum to the NOTICE text from the Work, provided+ that such additional attribution notices cannot be construed+ as modifying the License.++ You may add Your own copyright statement to Your modifications and+ may provide additional or different license terms and conditions+ for use, reproduction, or distribution of Your modifications, or+ for any such Derivative Works as a whole, provided Your use,+ reproduction, and distribution of the Work otherwise complies with+ the conditions stated in this License.++ 5. Submission of Contributions. Unless You explicitly state otherwise,+ any Contribution intentionally submitted for inclusion in the Work+ by You to the Licensor shall be under the terms and conditions of+ this License, without any additional terms or conditions.+ Notwithstanding the above, nothing herein shall supersede or modify+ the terms of any separate license agreement you may have executed+ with Licensor regarding such Contributions.++ 6. Trademarks. This License does not grant permission to use the trade+ names, trademarks, service marks, or product names of the Licensor,+ except as required for reasonable and customary use in describing the+ origin of the Work and reproducing the content of the NOTICE file.++ 7. Disclaimer of Warranty. Unless required by applicable law or+ agreed to in writing, Licensor provides the Work (and each+ Contributor provides its Contributions) on an "AS IS" BASIS,+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or+ implied, including, without limitation, any warranties or conditions+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A+ PARTICULAR PURPOSE. You are solely responsible for determining the+ appropriateness of using or redistributing the Work and assume any+ risks associated with Your exercise of permissions under this License.++ 8. Limitation of Liability. In no event and under no legal theory,+ whether in tort (including negligence), contract, or otherwise,+ unless required by applicable law (such as deliberate and grossly+ negligent acts) or agreed to in writing, shall any Contributor be+ liable to You for damages, including any direct, indirect, special,+ incidental, or consequential damages of any character arising as a+ result of this License or out of the use or inability to use the+ Work (including but not limited to damages for loss of goodwill,+ work stoppage, computer failure or malfunction, or any and all+ other commercial damages or losses), even if such Contributor+ has been advised of the possibility of such damages.++ 9. Accepting Warranty or Additional Liability. While redistributing+ the Work or Derivative Works thereof, You may choose to offer,+ and charge a fee for, acceptance of support, warranty, indemnity,+ or other liability obligations and/or rights consistent with this+ License. However, in accepting such obligations, You may act only+ on Your own behalf and on Your sole responsibility, not on behalf+ of any other Contributor, and only if You agree to indemnify,+ defend, and hold each Contributor harmless for any liability+ incurred by, or claims asserted against, such Contributor by reason+ of your accepting any such warranty or additional liability.++ END OF TERMS AND CONDITIONS++ Copyright 2025 Kyant++ Licensed under the Apache License, Version 2.0 (the "License");+ you may not use this file except in compliance with the License.+ You may obtain a copy of the License at++ http://www.apache.org/licenses/LICENSE-2.0++ Unless required by applicable law or agreed to in writing, software+ distributed under the License is distributed on an "AS IS" BASIS,+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ See the License for the specific language governing permissions and+ limitations under the License.\ No newline at end of filediff --git a/AndroidLiquidGlass-kmp/README.md b/AndroidLiquidGlass-kmp/README.mdnew file mode 100644index 0000000..e6abf3b--- /dev/null+++ b/AndroidLiquidGlass-kmp/README.md@@ -0,0 +1,27 @@+# Liquid Glass (Backdrop)++++A customizable Liquid Glass effect library for Compose Multiplatform.++## Docs++[](https://central.sonatype.com/artifact/io.github.kyant0/backdrop)++[Documentation](https://kyant.gitbook.io/backdrop)++## Components++The library does not include any high-level components; you will need to create your own.+Below are some example components:++- [LiquidButton](/app/src/commonMain/kotlin/com/kyant/backdrop/catalog/components/LiquidButton.kt)+- [LiquidToggle](/app/src/commonMain/kotlin/com/kyant/backdrop/catalog/components/LiquidToggle.kt)+- [LiquidSlider](/app/src/commonMain/kotlin/com/kyant/backdrop/catalog/components/LiquidSlider.kt)+- [LiquidBottomTabs](/app/src/commonMain/kotlin/com/kyant/backdrop/catalog/components/LiquidBottomTabs.kt)++## Demo++- [Backdrop Catalog](./androidApp/release/androidApp-release.apk)++diff --git a/AndroidLiquidGlass-kmp/androidApp/.gitignore b/AndroidLiquidGlass-kmp/androidApp/.gitignorenew file mode 100644index 0000000..42afabf--- /dev/null+++ b/AndroidLiquidGlass-kmp/androidApp/.gitignore@@ -0,0 +1 @@+/build\ No newline at end of filediff --git a/AndroidLiquidGlass-kmp/androidApp/build.gradle.kts b/AndroidLiquidGlass-kmp/androidApp/build.gradle.ktsnew file mode 100644index 0000000..98e9dc7--- /dev/null+++ b/AndroidLiquidGlass-kmp/androidApp/build.gradle.kts@@ -0,0 +1,61 @@+plugins {+ alias(libs.plugins.android.application)+ alias(libs.plugins.kotlin.compose)+}++android {+ namespace = "com.kyant.backdrop.catalog"+ compileSdk = 37+ buildToolsVersion = "37.0.0"++ defaultConfig {+ applicationId = "com.kyant.backdrop.catalog"+ minSdk = 23+ targetSdk = 37+ versionCode = 1+ versionName = "1.0.0"+ androidResources.localeFilters += arrayOf("en")+ }++ buildTypes {+ release {+ isMinifyEnabled = true+ isShrinkResources = true+ proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")+ vcsInfo.include = false+ }+ }+ buildFeatures {+ compose = true+ }+ packaging {+ resources {+ excludes += arrayOf(+ "DebugProbesKt.bin",+ "kotlin-tooling-metadata.json",+ "kotlin/**",+ "META-INF/*.version",+ "META-INF/**/LICENSE.txt"+ )+ }+ dex {+ useLegacyPackaging = true+ }+ jniLibs {+ useLegacyPackaging = true+ }+ }+ dependenciesInfo {+ includeInApk = false+ includeInBundle = false+ }+ lint {+ checkReleaseBuilds = false+ }+}++dependencies {+ implementation(libs.androidx.core.ktx)+ implementation(libs.androidx.activity.compose)+ implementation(project(":app"))+}diff --git a/AndroidLiquidGlass-kmp/androidApp/proguard-rules.pro b/AndroidLiquidGlass-kmp/androidApp/proguard-rules.pronew file mode 100644index 0000000..481bb43--- /dev/null+++ b/AndroidLiquidGlass-kmp/androidApp/proguard-rules.pro@@ -0,0 +1,21 @@+# Add project specific ProGuard rules here.+# You can control the set of applied configuration files using the+# proguardFiles setting in build.gradle.+#+# For more details, see+# http://developer.android.com/guide/developing/tools/proguard.html++# If your project uses WebView with JS, uncomment the following+# and specify the fully qualified class name to the JavaScript interface+# class:+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {+# public *;+#}++# Uncomment this to preserve the line number information for+# debugging stack traces.+#-keepattributes SourceFile,LineNumberTable++# If you keep the line number information, uncomment this to+# hide the original source file name.+#-renamesourcefileattribute SourceFile\ No newline at end of filediff --git a/AndroidLiquidGlass-kmp/androidApp/release/baselineProfiles/0/androidApp-release.dm b/AndroidLiquidGlass-kmp/androidApp/release/baselineProfiles/0/androidApp-release.dmnew file mode 100644index 0000000..4b8a138Binary files /dev/null and b/AndroidLiquidGlass-kmp/androidApp/release/baselineProfiles/0/androidApp-release.dm differdiff --git a/AndroidLiquidGlass-kmp/androidApp/release/baselineProfiles/1/androidApp-release.dm b/AndroidLiquidGlass-kmp/androidApp/release/baselineProfiles/1/androidApp-release.dmnew file mode 100644index 0000000..22edefaBinary files /dev/null and b/AndroidLiquidGlass-kmp/androidApp/release/baselineProfiles/1/androidApp-release.dm differdiff --git a/AndroidLiquidGlass-kmp/androidApp/release/output-metadata.json b/AndroidLiquidGlass-kmp/androidApp/release/output-metadata.jsonnew file mode 100644index 0000000..0c5d425--- /dev/null+++ b/AndroidLiquidGlass-kmp/androidApp/release/output-metadata.json@@ -0,0 +1,37 @@+{+ "version": 3,+ "artifactType": {+ "type": "APK",+ "kind": "Directory"+ },+ "applicationId": "com.kyant.backdrop.catalog",+ "variantName": "release",+ "elements": [+ {+ "type": "SINGLE",+ "filters": [],+ "attributes": [],+ "versionCode": 1,+ "versionName": "1.0.0",+ "outputFile": "androidApp-release.apk"+ }+ ],+ "elementType": "File",+ "baselineProfiles": [+ {+ "minApi": 28,+ "maxApi": 30,+ "baselineProfiles": [+ "baselineProfiles/1/androidApp-release.dm"+ ]+ },+ {+ "minApi": 31,+ "maxApi": 2147483647,+ "baselineProfiles": [+ "baselineProfiles/0/androidApp-release.dm"+ ]+ }+ ],+ "minSdkVersionForDexing": 23+}\ No newline at end of filediff --git a/AndroidLiquidGlass-kmp/androidApp/src/main/AndroidManifest.xml b/AndroidLiquidGlass-kmp/androidApp/src/main/AndroidManifest.xmlnew file mode 100644index 0000000..27531c7--- /dev/null+++ b/AndroidLiquidGlass-kmp/androidApp/src/main/AndroidManifest.xml@@ -0,0 +1,25 @@+<?xml version="1.0" encoding="utf-8"?>+<manifest xmlns:android="http://schemas.android.com/apk/res/android"+ xmlns:tools="http://schemas.android.com/tools">++ <application+ android:allowBackup="true"+ android:enableOnBackInvokedCallback="true"+ android:icon="@mipmap/ic_launcher"+ android:label="@string/app_name"+ android:roundIcon="@mipmap/ic_launcher_round"+ android:supportsRtl="true"+ android:theme="@style/Theme.Catalog"+ tools:targetApi="33">+ <activity+ android:name=".MainActivity"+ android:exported="true">+ <intent-filter>+ <action android:name="android.intent.action.MAIN" />++ <category android:name="android.intent.category.LAUNCHER" />+ </intent-filter>+ </activity>+ </application>++</manifest>\ No newline at end of filediff --git a/AndroidLiquidGlass-kmp/androidApp/src/main/java/com/kyant/backdrop/catalog/MainActivity.kt b/AndroidLiquidGlass-kmp/androidApp/src/main/java/com/kyant/backdrop/catalog/MainActivity.ktnew file mode 100644index 0000000..352ce4d--- /dev/null+++ b/AndroidLiquidGlass-kmp/androidApp/src/main/java/com/kyant/backdrop/catalog/MainActivity.kt@@ -0,0 +1,18 @@+package com.kyant.backdrop.catalog++import android.os.Bundle+import androidx.activity.ComponentActivity+import androidx.activity.compose.setContent+import androidx.core.view.WindowCompat++class MainActivity : ComponentActivity() {++ override fun onCreate(savedInstanceState: Bundle?) {+ super.onCreate(savedInstanceState)+ WindowCompat.setDecorFitsSystemWindows(window, false)++ setContent {+ MainContent()+ }+ }+}diff --git a/AndroidLiquidGlass-kmp/androidApp/src/main/res/drawable-v24/ic_launcher_foreground.xml b/AndroidLiquidGlass-kmp/androidApp/src/main/res/drawable-v24/ic_launcher_foreground.xmlnew file mode 100644index 0000000..2b068d1--- /dev/null+++ b/AndroidLiquidGlass-kmp/androidApp/src/main/res/drawable-v24/ic_launcher_foreground.xml@@ -0,0 +1,30 @@+<vector xmlns:android="http://schemas.android.com/apk/res/android"+ xmlns:aapt="http://schemas.android.com/aapt"+ android:width="108dp"+ android:height="108dp"+ android:viewportWidth="108"+ android:viewportHeight="108">+ <path android:pathData="M31,63.928c0,0 6.4,-11 12.1,-13.1c7.2,-2.6 26,-1.4 26,-1.4l38.1,38.1L107,108.928l-32,-1L31,63.928z">+ <aapt:attr name="android:fillColor">+ <gradient+ android:endX="85.84757"+ android:endY="92.4963"+ android:startX="42.9492"+ android:startY="49.59793"+ android:type="linear">+ <item+ android:color="#44000000"+ android:offset="0.0" />+ <item+ android:color="#00000000"+ android:offset="1.0" />+ </gradient>+ </aapt:attr>+ </path>+ <path+ android:fillColor="#FFFFFF"+ android:fillType="nonZero"+ android:pathData="M65.3,45.828l3.8,-6.6c0.2,-0.4 0.1,-0.9 -0.3,-1.1c-0.4,-0.2 -0.9,-0.1 -1.1,0.3l-3.9,6.7c-6.3,-2.8 -13.4,-2.8 -19.7,0l-3.9,-6.7c-0.2,-0.4 -0.7,-0.5 -1.1,-0.3C38.8,38.328 38.7,38.828 38.9,39.228l3.8,6.6C36.2,49.428 31.7,56.028 31,63.928h46C76.3,56.028 71.8,49.428 65.3,45.828zM43.4,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2c-0.3,-0.7 -0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C45.3,56.528 44.5,57.328 43.4,57.328L43.4,57.328zM64.6,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2s-0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C66.5,56.528 65.6,57.328 64.6,57.328L64.6,57.328z"+ android:strokeWidth="1"+ android:strokeColor="#00000000" />+</vector>\ No newline at end of filediff --git a/AndroidLiquidGlass-kmp/androidApp/src/main/res/drawable/ic_launcher_background.xml b/AndroidLiquidGlass-kmp/androidApp/src/main/res/drawable/ic_launcher_background.xmlnew file mode 100644index 0000000..07d5da9--- /dev/null+++ b/AndroidLiquidGlass-kmp/androidApp/src/main/res/drawable/ic_launcher_background.xml@@ -0,0 +1,170 @@+<?xml version="1.0" encoding="utf-8"?>+<vector xmlns:android="http://schemas.android.com/apk/res/android"+ android:width="108dp"+ android:height="108dp"+ android:viewportWidth="108"+ android:viewportHeight="108">+ <path+ android:fillColor="#3DDC84"+ android:pathData="M0,0h108v108h-108z" />+ <path+ android:fillColor="#00000000"+ android:pathData="M9,0L9,108"+ android:strokeWidth="0.8"+ android:strokeColor="#33FFFFFF" />+ <path+ android:fillColor="#00000000"+ android:pathData="M19,0L19,108"+ android:strokeWidth="0.8"+ android:strokeColor="#33FFFFFF" />+ <path+ android:fillColor="#00000000"+ android:pathData="M29,0L29,108"+ android:strokeWidth="0.8"+ android:strokeColor="#33FFFFFF" />+ <path+ android:fillColor="#00000000"+ android:pathData="M39,0L39,108"+ android:strokeWidth="0.8"+ android:strokeColor="#33FFFFFF" />+ <path+ android:fillColor="#00000000"+ android:pathData="M49,0L49,108"+ android:strokeWidth="0.8"+ android:strokeColor="#33FFFFFF" />+ <path+ android:fillColor="#00000000"+ android:pathData="M59,0L59,108"+ android:strokeWidth="0.8"+ android:strokeColor="#33FFFFFF" />+ <path+ android:fillColor="#00000000"+ android:pathData="M69,0L69,108"+ android:strokeWidth="0.8"+ android:strokeColor="#33FFFFFF" />+ <path+ android:fillColor="#00000000"+ android:pathData="M79,0L79,108"+ android:strokeWidth="0.8"+ android:strokeColor="#33FFFFFF" />+ <path+ android:fillColor="#00000000"+ android:pathData="M89,0L89,108"+ android:strokeWidth="0.8"+ android:strokeColor="#33FFFFFF" />+ <path+ android:fillColor="#00000000"+ android:pathData="M99,0L99,108"+ android:strokeWidth="0.8"+ android:strokeColor="#33FFFFFF" />+ <path+ android:fillColor="#00000000"+ android:pathData="M0,9L108,9"+ android:strokeWidth="0.8"+ android:strokeColor="#33FFFFFF" />+ <path+ android:fillColor="#00000000"+ android:pathData="M0,19L108,19"+ android:strokeWidth="0.8"+ android:strokeColor="#33FFFFFF" />+ <path+ android:fillColor="#00000000"+ android:pathData="M0,29L108,29"+ android:strokeWidth="0.8"+ android:strokeColor="#33FFFFFF" />+ <path+ android:fillColor="#00000000"+ android:pathData="M0,39L108,39"+ android:strokeWidth="0.8"+ android:strokeColor="#33FFFFFF" />+ <path+ android:fillColor="#00000000"+ android:pathData="M0,49L108,49"+ android:strokeWidth="0.8"+ android:strokeColor="#33FFFFFF" />+ <path+ android:fillColor="#00000000"+ android:pathData="M0,59L108,59"+ android:strokeWidth="0.8"+ android:strokeColor="#33FFFFFF" />+ <path+ android:fillColor="#00000000"+ android:pathData="M0,69L108,69"+ android:strokeWidth="0.8"+ android:strokeColor="#33FFFFFF" />+ <path+ android:fillColor="#00000000"+ android:pathData="M0,79L108,79"+ android:strokeWidth="0.8"+ android:strokeColor="#33FFFFFF" />+ <path+ android:fillColor="#00000000"+ android:pathData="M0,89L108,89"+ android:strokeWidth="0.8"+ android:strokeColor="#33FFFFFF" />+ <path+ android:fillColor="#00000000"+ android:pathData="M0,99L108,99"+ android:strokeWidth="0.8"+ android:strokeColor="#33FFFFFF" />+ <path+ android:fillColor="#00000000"+ android:pathData="M19,29L89,29"+ android:strokeWidth="0.8"+ android:strokeColor="#33FFFFFF" />+ <path+ android:fillColor="#00000000"+ android:pathData="M19,39L89,39"+ android:strokeWidth="0.8"+ android:strokeColor="#33FFFFFF" />+ <path+ android:fillColor="#00000000"+ android:pathData="M19,49L89,49"+ android:strokeWidth="0.8"+ android:strokeColor="#33FFFFFF" />+ <path+ android:fillColor="#00000000"+ android:pathData="M19,59L89,59"+ android:strokeWidth="0.8"+ android:strokeColor="#33FFFFFF" />+ <path+ android:fillColor="#00000000"+ android:pathData="M19,69L89,69"+ android:strokeWidth="0.8"+ android:strokeColor="#33FFFFFF" />+ <path+ android:fillColor="#00000000"+ android:pathData="M19,79L89,79"+ android:strokeWidth="0.8"+ android:strokeColor="#33FFFFFF" />+ <path+ android:fillColor="#00000000"+ android:pathData="M29,19L29,89"+ android:strokeWidth="0.8"+ android:strokeColor="#33FFFFFF" />+ <path+ android:fillColor="#00000000"+ android:pathData="M39,19L39,89"+ android:strokeWidth="0.8"+ android:strokeColor="#33FFFFFF" />+ <path+ android:fillColor="#00000000"+ android:pathData="M49,19L49,89"+ android:strokeWidth="0.8"+ android:strokeColor="#33FFFFFF" />+ <path+ android:fillColor="#00000000"+ android:pathData="M59,19L59,89"+ android:strokeWidth="0.8"+ android:strokeColor="#33FFFFFF" />+ <path+ android:fillColor="#00000000"+ android:pathData="M69,19L69,89"+ android:strokeWidth="0.8"+ android:strokeColor="#33FFFFFF" />+ <path+ android:fillColor="#00000000"+ android:pathData="M79,19L79,89"+ android:strokeWidth="0.8"+ android:strokeColor="#33FFFFFF" />+</vector>diff --git a/AndroidLiquidGlass-kmp/androidApp/src/main/res/drawable/system_home_screen_light.webp b/AndroidLiquidGlass-kmp/androidApp/src/main/res/drawable/system_home_screen_light.webpnew file mode 100644index 0000000..e35ceb5Binary files /dev/null and b/AndroidLiquidGlass-kmp/androidApp/src/main/res/drawable/system_home_screen_light.webp differdiff --git a/AndroidLiquidGlass-kmp/androidApp/src/main/res/drawable/wallpaper_light.webp b/AndroidLiquidGlass-kmp/androidApp/src/main/res/drawable/wallpaper_light.webpnew file mode 100644index 0000000..2315231Binary files /dev/null and b/AndroidLiquidGlass-kmp/androidApp/src/main/res/drawable/wallpaper_light.webp differdiff --git a/AndroidLiquidGlass-kmp/androidApp/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/AndroidLiquidGlass-kmp/androidApp/src/main/res/mipmap-anydpi-v26/ic_launcher.xmlnew file mode 100644index 0000000..6f3b755--- /dev/null+++ b/AndroidLiquidGlass-kmp/androidApp/src/main/res/mipmap-anydpi-v26/ic_launcher.xml@@ -0,0 +1,6 @@+<?xml version="1.0" encoding="utf-8"?>+<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">+ <background android:drawable="@drawable/ic_launcher_background" />+ <foreground android:drawable="@drawable/ic_launcher_foreground" />+ <monochrome android:drawable="@drawable/ic_launcher_foreground" />+</adaptive-icon>\ No newline at end of filediff --git a/AndroidLiquidGlass-kmp/androidApp/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/AndroidLiquidGlass-kmp/androidApp/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xmlnew file mode 100644index 0000000..6f3b755--- /dev/null+++ b/AndroidLiquidGlass-kmp/androidApp/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml@@ -0,0 +1,6 @@+<?xml version="1.0" encoding="utf-8"?>+<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">+ <background android:drawable="@drawable/ic_launcher_background" />+ <foreground android:drawable="@drawable/ic_launcher_foreground" />+ <monochrome android:drawable="@drawable/ic_launcher_foreground" />+</adaptive-icon>\ No newline at end of filediff --git a/AndroidLiquidGlass-kmp/androidApp/src/main/res/mipmap-hdpi/ic_launcher.webp b/AndroidLiquidGlass-kmp/androidApp/src/main/res/mipmap-hdpi/ic_launcher.webpnew file mode 100644index 0000000..c209e78Binary files /dev/null and b/AndroidLiquidGlass-kmp/androidApp/src/main/res/mipmap-hdpi/ic_launcher.webp differdiff --git a/AndroidLiquidGlass-kmp/androidApp/src/main/res/mipmap-hdpi/ic_launcher_round.webp b/AndroidLiquidGlass-kmp/androidApp/src/main/res/mipmap-hdpi/ic_launcher_round.webpnew file mode 100644index 0000000..b2dfe3dBinary files /dev/null and b/AndroidLiquidGlass-kmp/androidApp/src/main/res/mipmap-hdpi/ic_launcher_round.webp differdiff --git a/AndroidLiquidGlass-kmp/androidApp/src/main/res/mipmap-mdpi/ic_launcher.webp b/AndroidLiquidGlass-kmp/androidApp/src/main/res/mipmap-mdpi/ic_launcher.webpnew file mode 100644index 0000000..4f0f1d6Binary files /dev/null and b/AndroidLiquidGlass-kmp/androidApp/src/main/res/mipmap-mdpi/ic_launcher.webp differdiff --git a/AndroidLiquidGlass-kmp/androidApp/src/main/res/mipmap-mdpi/ic_launcher_round.webp b/AndroidLiquidGlass-kmp/androidApp/src/main/res/mipmap-mdpi/ic_launcher_round.webpnew file mode 100644index 0000000..62b611dBinary files /dev/null and b/AndroidLiquidGlass-kmp/androidApp/src/main/res/mipmap-mdpi/ic_launcher_round.webp differdiff --git a/AndroidLiquidGlass-kmp/androidApp/src/main/res/mipmap-xhdpi/ic_launcher.webp b/AndroidLiquidGlass-kmp/androidApp/src/main/res/mipmap-xhdpi/ic_launcher.webpnew file mode 100644index 0000000..948a307Binary files /dev/null and b/AndroidLiquidGlass-kmp/androidApp/src/main/res/mipmap-xhdpi/ic_launcher.webp differdiff --git a/AndroidLiquidGlass-kmp/androidApp/src/main/res/mipmap-xhdpi/ic_launcher_round.webp b/AndroidLiquidGlass-kmp/androidApp/src/main/res/mipmap-xhdpi/ic_launcher_round.webpnew file mode 100644index 0000000..1b9a695Binary files /dev/null and b/AndroidLiquidGlass-kmp/androidApp/src/main/res/mipmap-xhdpi/ic_launcher_round.webp differdiff --git a/AndroidLiquidGlass-kmp/androidApp/src/main/res/mipmap-xxhdpi/ic_launcher.webp b/AndroidLiquidGlass-kmp/androidApp/src/main/res/mipmap-xxhdpi/ic_launcher.webpnew file mode 100644index 0000000..28d4b77Binary files /dev/null and b/AndroidLiquidGlass-kmp/androidApp/src/main/res/mipmap-xxhdpi/ic_launcher.webp differdiff --git a/AndroidLiquidGlass-kmp/androidApp/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp b/AndroidLiquidGlass-kmp/androidApp/src/main/res/mipmap-xxhdpi/ic_launcher_round.webpnew file mode 100644index 0000000..9287f50Binary files /dev/null and b/AndroidLiquidGlass-kmp/androidApp/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp differdiff --git a/AndroidLiquidGlass-kmp/androidApp/src/main/res/mipmap-xxxhdpi/ic_launcher.webp b/AndroidLiquidGlass-kmp/androidApp/src/main/res/mipmap-xxxhdpi/ic_launcher.webpnew file mode 100644index 0000000..aa7d642Binary files /dev/null and b/AndroidLiquidGlass-kmp/androidApp/src/main/res/mipmap-xxxhdpi/ic_launcher.webp differdiff --git a/AndroidLiquidGlass-kmp/androidApp/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp b/AndroidLiquidGlass-kmp/androidApp/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webpnew file mode 100644index 0000000..9126ae3Binary files /dev/null and b/AndroidLiquidGlass-kmp/androidApp/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp differdiff --git a/AndroidLiquidGlass-kmp/androidApp/src/main/res/values-night/themes.xml b/AndroidLiquidGlass-kmp/androidApp/src/main/res/values-night/themes.xmlnew file mode 100644index 0000000..982ac83--- /dev/null+++ b/AndroidLiquidGlass-kmp/androidApp/src/main/res/values-night/themes.xml@@ -0,0 +1,14 @@+<?xml version="1.0" encoding="utf-8"?>+<resources xmlns:tools="http://schemas.android.com/tools">++ <style name="Theme.Catalog" parent="android:Theme.Material.NoActionBar">+ <item name="android:windowBackground">@android:color/black</item>+ <item name="android:statusBarColor">@android:color/transparent</item>+ <item name="android:windowLightStatusBar" tools:targetApi="23">false</item>+ <item name="android:navigationBarColor">@android:color/transparent</item>+ <item name="android:windowLightNavigationBar" tools:targetApi="27">false</item>+ <item name="android:enforceStatusBarContrast" tools:targetApi="29">false</item>+ <item name="android:enforceNavigationBarContrast" tools:targetApi="29">false</item>+ <item name="android:windowLayoutInDisplayCutoutMode" tools:targetApi="27">shortEdges</item>+ </style>+</resources>\ No newline at end of filediff --git a/AndroidLiquidGlass-kmp/androidApp/src/main/res/values/strings.xml b/AndroidLiquidGlass-kmp/androidApp/src/main/res/values/strings.xmlnew file mode 100644index 0000000..f90f9ab--- /dev/null+++ b/AndroidLiquidGlass-kmp/androidApp/src/main/res/values/strings.xml@@ -0,0 +1,3 @@+<resources>+ <string name="app_name">Backdrop Catalog</string>+</resources>\ No newline at end of filediff --git a/AndroidLiquidGlass-kmp/androidApp/src/main/res/values/themes.xml b/AndroidLiquidGlass-kmp/androidApp/src/main/res/values/themes.xmlnew file mode 100644index 0000000..aaf4b6e--- /dev/null+++ b/AndroidLiquidGlass-kmp/androidApp/src/main/res/values/themes.xml@@ -0,0 +1,14 @@+<?xml version="1.0" encoding="utf-8"?>+<resources xmlns:tools="http://schemas.android.com/tools">++ <style name="Theme.Catalog" parent="android:Theme.Material.Light.NoActionBar">+ <item name="android:windowBackground">@android:color/white</item>+ <item name="android:statusBarColor">@android:color/transparent</item>+ <item name="android:windowLightStatusBar" tools:targetApi="23">true</item>+ <item name="android:navigationBarColor">@android:color/transparent</item>+ <item name="android:windowLightNavigationBar" tools:targetApi="27">true</item>+ <item name="android:enforceStatusBarContrast" tools:targetApi="29">false</item>+ <item name="android:enforceNavigationBarContrast" tools:targetApi="29">false</item>+ <item name="android:windowLayoutInDisplayCutoutMode" tools:targetApi="27">shortEdges</item>+ </style>+</resources>\ No newline at end of filediff --git a/AndroidLiquidGlass-kmp/app/.gitignore b/AndroidLiquidGlass-kmp/app/.gitignorenew file mode 100644index 0000000..42afabf--- /dev/null+++ b/AndroidLiquidGlass-kmp/app/.gitignore@@ -0,0 +1 @@+/build\ No newline at end of filediff --git a/AndroidLiquidGlass-kmp/app/build.gradle.kts b/AndroidLiquidGlass-kmp/app/build.gradle.ktsnew file mode 100644index 0000000..41500fb--- /dev/null+++ b/AndroidLiquidGlass-kmp/app/build.gradle.kts@@ -0,0 +1,115 @@+import org.jetbrains.compose.desktop.application.dsl.TargetFormat+import org.jetbrains.kotlin.gradle.dsl.JvmTarget++plugins {+ alias(libs.plugins.android.multiplatform.library)+ alias(libs.plugins.kotlin.multiplatform)+ alias(libs.plugins.kotlin.compose)+ alias(libs.plugins.jetbrains.compose)+}++kotlin {+ android {+ minSdk = 21+ compileSdk = 37+ buildToolsVersion = "37.0.0"+ namespace = "com.kyant.backdrop.catalog.common"+ androidResources.enable = true+ compilerOptions {+ jvmTarget = JvmTarget.JVM_11+ }+ }++ applyDefaultHierarchyTemplate()++ jvm("desktop")++ js {+ browser()+ }+ wasmJs {+ browser()+ }++ listOf(+ macosArm64(),+ iosArm64("iosArm64"),+ iosSimulatorArm64("iosSimulatorArm64")+ ).forEach { iosTarget ->+ iosTarget.binaries.framework {+ baseName = "shared"+ isStatic = true+ }+ }++ sourceSets {+ val commonMain = getByName("commonMain") {+ dependencies {+ implementation(libs.compose.foundation)+ implementation(libs.compose.ui)+ implementation(libs.compose.ui.graphics)+ implementation(libs.compose.resources)+ implementation(libs.compose.material.ripple)+ implementation(libs.kyant.shapes)+ implementation(project(":backdrop"))+ }+ }++ val androidMain = getByName("androidMain") {+ dependencies {+ implementation(libs.androidx.activity.compose)+ }+ }++ val skikoMain = create("skikoMain") {+ dependsOn(commonMain)+ }++ val desktopMain = getByName("desktopMain") {+ dependsOn(skikoMain)+ dependencies {+ implementation(compose.desktop.currentOs)+ }+ }++ val macosArm64Main = getByName("macosArm64Main") {+ dependsOn(skikoMain)+ }++ val iosMain = getByName("iosMain") {+ dependsOn(skikoMain)+ }++ val iosArm64Main = getByName("iosArm64Main") {+ }++ val iosSimulatorArm64Main = getByName("iosSimulatorArm64Main") {+ }++ val jsMain = getByName("jsMain") {+ dependsOn(skikoMain)+ }++ val wasmJsMain = getByName("wasmJsMain") {+ dependsOn(skikoMain)+ }+ }++ compilerOptions {+ freeCompilerArgs.addAll(+ "-Xlambdas=class"+ )+ }+}++compose.desktop {+ application {+ mainClass = "com.kyant.backdrop.catalog.MainKt"++ nativeDistributions {+ targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb)+ packageName = "com.kyant.backdrop.catalog"+ packageVersion = "1.0.0"+ }+ }+}diff --git a/AndroidLiquidGlass-kmp/app/src/androidMain/kotlin/com/kyant/backdrop/catalog/BackdropDemoScaffold.kt b/AndroidLiquidGlass-kmp/app/src/androidMain/kotlin/com/kyant/backdrop/catalog/BackdropDemoScaffold.ktnew file mode 100644index 0000000..76c1aa1--- /dev/null+++ b/AndroidLiquidGlass-kmp/app/src/androidMain/kotlin/com/kyant/backdrop/catalog/BackdropDemoScaffold.kt@@ -0,0 +1,97 @@+package com.kyant.backdrop.catalog++import android.graphics.BitmapFactory+import androidx.activity.compose.rememberLauncherForActivityResult+import androidx.activity.result.PickVisualMediaRequest+import androidx.activity.result.contract.ActivityResultContracts+import androidx.compose.foundation.Image+import androidx.compose.foundation.layout.Box+import androidx.compose.foundation.layout.BoxScope+import androidx.compose.foundation.layout.fillMaxSize+import androidx.compose.foundation.layout.height+import androidx.compose.foundation.layout.navigationBarsPadding+import androidx.compose.foundation.layout.padding+import androidx.compose.foundation.text.BasicText+import androidx.compose.runtime.Composable+import androidx.compose.runtime.getValue+import androidx.compose.runtime.mutableStateOf+import androidx.compose.runtime.remember+import androidx.compose.runtime.setValue+import androidx.compose.ui.Alignment+import androidx.compose.ui.Modifier+import androidx.compose.ui.graphics.Color+import androidx.compose.ui.graphics.asImageBitmap+import androidx.compose.ui.graphics.painter.BitmapPainter+import androidx.compose.ui.graphics.painter.Painter+import androidx.compose.ui.layout.ContentScale+import androidx.compose.ui.platform.LocalContext+import androidx.compose.ui.text.TextStyle+import androidx.compose.ui.unit.dp+import androidx.compose.ui.unit.sp+import com.kyant.backdrop.backdrops.LayerBackdrop+import com.kyant.backdrop.backdrops.layerBackdrop+import com.kyant.backdrop.backdrops.rememberLayerBackdrop+import com.kyant.backdrop.catalog.components.LiquidButton+import glass.app.generated.resources.Res+import glass.app.generated.resources.wallpaper_light+import org.jetbrains.compose.resources.painterResource++@Composable+actual fun BackdropDemoScaffold(+ modifier: Modifier,+ content: @Composable BoxScope.(backdrop: LayerBackdrop) -> Unit+) {+ Box(+ Modifier.fillMaxSize(),+ contentAlignment = Alignment.Center+ ) {+ var painter: Painter? by remember { mutableStateOf(null) }+ val context = LocalContext.current+ val pickMedia = rememberLauncherForActivityResult(+ ActivityResultContracts.PickVisualMedia()+ ) { uri ->+ if (uri != null) {+ try {+ context.contentResolver.openInputStream(uri)?.use { inputStream ->+ val imageBitmap = BitmapFactory.decodeStream(inputStream)?.asImageBitmap()+ if (imageBitmap != null) {+ painter = BitmapPainter(imageBitmap)+ }+ }+ } catch (_: Exception) {+ }+ }+ }++ val backdrop = rememberLayerBackdrop()++ Image(+ painter ?: painterResource(Res.drawable.wallpaper_light),+ null,+ Modifier+ .layerBackdrop(backdrop)+ .then(modifier)+ .fillMaxSize(),+ contentScale = ContentScale.Crop+ )++ content(backdrop)++ LiquidButton(+ { pickMedia.launch(PickVisualMediaRequest(ActivityResultContracts.PickVisualMedia.ImageOnly)) },+ backdrop,+ Modifier+ .padding(16f.dp)+ .navigationBarsPadding()+ .height(56f.dp)+ .align(Alignment.BottomCenter),+ tint = Color(0xFF0088FF)+ ) {+ BasicText(+ "Pick an image",+ Modifier.padding(horizontal = 8f.dp),+ style = TextStyle(Color.White, 16f.sp)+ )+ }+ }+}diff --git a/AndroidLiquidGlass-kmp/app/src/androidMain/kotlin/com/kyant/backdrop/catalog/utils/BackHandler.kt b/AndroidLiquidGlass-kmp/app/src/androidMain/kotlin/com/kyant/backdrop/catalog/utils/BackHandler.ktnew file mode 100644index 0000000..c90c16f--- /dev/null+++ b/AndroidLiquidGlass-kmp/app/src/androidMain/kotlin/com/kyant/backdrop/catalog/utils/BackHandler.kt@@ -0,0 +1,12 @@+package com.kyant.backdrop.catalog.utils++import androidx.activity.compose.BackHandler+import androidx.compose.runtime.Composable++@Composable+actual fun BackHandler(+ enabled: Boolean,+ onBack: () -> Unit+) {+ BackHandler(enabled, onBack)+}diff --git a/AndroidLiquidGlass-kmp/app/src/androidMain/kotlin/com/kyant/backdrop/catalog/utils/Bitmap.kt b/AndroidLiquidGlass-kmp/app/src/androidMain/kotlin/com/kyant/backdrop/catalog/utils/Bitmap.ktnew file mode 100644index 0000000..ab161dc--- /dev/null+++ b/AndroidLiquidGlass-kmp/app/src/androidMain/kotlin/com/kyant/backdrop/catalog/utils/Bitmap.kt@@ -0,0 +1,12 @@+package com.kyant.backdrop.catalog.utils++import android.graphics.Bitmap+import androidx.compose.ui.graphics.ImageBitmap+import androidx.compose.ui.graphics.asAndroidBitmap+import androidx.compose.ui.graphics.asImageBitmap++actual fun ImageBitmap.scale(width: Int, height: Int): ImageBitmap {+ return Bitmap.createScaledBitmap(this.asAndroidBitmap(), 5, 5, false)+ .copy(Bitmap.Config.ARGB_8888, false)+ .asImageBitmap()+}diff --git a/AndroidLiquidGlass-kmp/app/src/androidMain/kotlin/com/kyant/backdrop/catalog/utils/Coroutines.kt b/AndroidLiquidGlass-kmp/app/src/androidMain/kotlin/com/kyant/backdrop/catalog/utils/Coroutines.ktnew file mode 100644index 0000000..c3c0bea--- /dev/null+++ b/AndroidLiquidGlass-kmp/app/src/androidMain/kotlin/com/kyant/backdrop/catalog/utils/Coroutines.kt@@ -0,0 +1,7 @@+package com.kyant.backdrop.catalog.utils++import kotlinx.coroutines.android.awaitFrame++actual suspend fun awaitFrame() {+ awaitFrame()+}diff --git a/AndroidLiquidGlass-kmp/app/src/androidMain/kotlin/com/kyant/backdrop/catalog/utils/SdfShader.android.kt b/AndroidLiquidGlass-kmp/app/src/androidMain/kotlin/com/kyant/backdrop/catalog/utils/SdfShader.android.ktnew file mode 100644index 0000000..0f2cdc0--- /dev/null+++ b/AndroidLiquidGlass-kmp/app/src/androidMain/kotlin/com/kyant/backdrop/catalog/utils/SdfShader.android.kt@@ -0,0 +1,43 @@+package com.kyant.backdrop.catalog.utils++import android.graphics.BitmapShader+import android.graphics.Shader+import androidx.compose.runtime.Immutable+import androidx.compose.ui.graphics.ImageBitmap+import androidx.compose.ui.graphics.asAndroidBitmap+import com.kyant.backdrop.BackdropEffectScope+import com.kyant.backdrop.asAndroidRuntimeShader+import com.kyant.backdrop.effects.runtimeShaderEffect+import com.kyant.backdrop.isRuntimeShaderSupported++actual fun SdfShader(imageBitmap: ImageBitmap): SdfShader {+ return SdfShaderImpl(imageBitmap)+}++@Immutable+private class SdfShaderImpl(val sdfBitmap: ImageBitmap) : SdfShader {++ private val sdfTexture =+ BitmapShader(sdfBitmap.asAndroidBitmap(), Shader.TileMode.CLAMP, Shader.TileMode.CLAMP)++ override val width: Int+ get() = sdfBitmap.width++ override val height: Int+ get() = sdfBitmap.height++ override fun BackdropEffectScope.apply(+ refractionHeight: Float,+ lightAngle: Float,+ ) {+ if (isRuntimeShaderSupported()) {+ runtimeShaderEffect("SdfShader", SdfShaderString, "content") {+ asAndroidRuntimeShader().setInputBuffer("sdfTex", sdfTexture)+ setFloatUniform("size", size.width, size.height)+ setFloatUniform("sdfTexSize", sdfBitmap.width.toFloat(), sdfBitmap.height.toFloat())+ setFloatUniform("refractionHeight", refractionHeight)+ setFloatUniform("lightAngle", lightAngle)+ }+ }+ }+}diff --git a/AndroidLiquidGlass-kmp/app/src/androidMain/kotlin/com/kyant/backdrop/catalog/utils/UISensor.kt b/AndroidLiquidGlass-kmp/app/src/androidMain/kotlin/com/kyant/backdrop/catalog/utils/UISensor.ktnew file mode 100644index 0000000..c677cf3--- /dev/null+++ b/AndroidLiquidGlass-kmp/app/src/androidMain/kotlin/com/kyant/backdrop/catalog/utils/UISensor.kt@@ -0,0 +1,69 @@+package com.kyant.backdrop.catalog.utils++import android.content.Context+import android.hardware.Sensor+import android.hardware.SensorEvent+import android.hardware.SensorEventListener+import android.hardware.SensorManager+import androidx.compose.runtime.Composable+import androidx.compose.runtime.DisposableEffect+import androidx.compose.runtime.getValue+import androidx.compose.runtime.mutableFloatStateOf+import androidx.compose.runtime.mutableStateOf+import androidx.compose.runtime.remember+import androidx.compose.runtime.setValue+import androidx.compose.ui.geometry.Offset+import androidx.compose.ui.platform.LocalContext+import kotlin.math.PI+import kotlin.math.atan2+import kotlin.math.sqrt++@Composable+actual fun rememberUISensor(): UISensor {+ val context = LocalContext.current+ val uiSensor = remember { UISensorImpl(context) }++ DisposableEffect(Unit) {+ uiSensor.start()+ onDispose { uiSensor.stop() }+ }++ return uiSensor+}++private class UISensorImpl(context: Context) : UISensor {++ override var gravityAngle: Float by mutableFloatStateOf(45f)+ private set++ override var gravity: Offset by mutableStateOf(Offset.Zero)+ private set++ private val sensorManager = context.getSystemService(Context.SENSOR_SERVICE) as SensorManager+ private val accelerometer = sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER)+ private val listener = object : SensorEventListener {++ override fun onSensorChanged(event: SensorEvent?) {+ if (event == null) return+ if (event.sensor.type == Sensor.TYPE_ACCELEROMETER) {+ val x = event.values[0]+ val y = event.values[1]+ val norm = sqrt(x * x + y * y + 9.81f * 9.81f)++ val alpha = 0.5f+ gravityAngle = gravityAngle * (1f - alpha) + atan2(y, x) * (180f / PI).toFloat() * alpha+ gravity = gravity * (1f - alpha) + Offset(x / norm, y / norm) * alpha+ }+ }++ override fun onAccuracyChanged(sensor: Sensor?, accuracy: Int) = Unit+ }++ override fun start() {+ sensorManager.registerListener(listener, accelerometer, SensorManager.SENSOR_DELAY_UI)+ }++ override fun stop() {+ sensorManager.unregisterListener(listener)+ }+}diff --git a/AndroidLiquidGlass-kmp/app/src/commonMain/composeResources/drawable/clock_sdf.webp b/AndroidLiquidGlass-kmp/app/src/commonMain/composeResources/drawable/clock_sdf.webpnew file mode 100644index 0000000..41de678Binary files /dev/null and b/AndroidLiquidGlass-kmp/app/src/commonMain/composeResources/drawable/clock_sdf.webp differdiff --git a/AndroidLiquidGlass-kmp/app/src/commonMain/composeResources/drawable/wallpaper_light.webp b/AndroidLiquidGlass-kmp/app/src/commonMain/composeResources/drawable/wallpaper_light.webpnew file mode 100644index 0000000..2315231Binary files /dev/null and b/AndroidLiquidGlass-kmp/app/src/commonMain/composeResources/drawable/wallpaper_light.webp differdiff --git a/AndroidLiquidGlass-kmp/app/src/commonMain/kotlin/com/kyant/backdrop/catalog/BackdropDemoScaffold.kt b/AndroidLiquidGlass-kmp/app/src/commonMain/kotlin/com/kyant/backdrop/catalog/BackdropDemoScaffold.ktnew file mode 100644index 0000000..9d6916d--- /dev/null+++ b/AndroidLiquidGlass-kmp/app/src/commonMain/kotlin/com/kyant/backdrop/catalog/BackdropDemoScaffold.kt@@ -0,0 +1,12 @@+package com.kyant.backdrop.catalog++import androidx.compose.foundation.layout.BoxScope+import androidx.compose.runtime.Composable+import androidx.compose.ui.Modifier+import com.kyant.backdrop.backdrops.LayerBackdrop++@Composable+expect fun BackdropDemoScaffold(+ modifier: Modifier = Modifier,+ content: @Composable BoxScope.(backdrop: LayerBackdrop) -> Unit+)diff --git a/AndroidLiquidGlass-kmp/app/src/commonMain/kotlin/com/kyant/backdrop/catalog/Block.kt b/AndroidLiquidGlass-kmp/app/src/commonMain/kotlin/com/kyant/backdrop/catalog/Block.ktnew file mode 100644index 0000000..0e94dcb--- /dev/null+++ b/AndroidLiquidGlass-kmp/app/src/commonMain/kotlin/com/kyant/backdrop/catalog/Block.kt@@ -0,0 +1,8 @@+package com.kyant.backdrop.catalog++import androidx.compose.runtime.Composable++@Composable+fun Block(content: @Composable () -> Unit) {+ content()+}diff --git a/AndroidLiquidGlass-kmp/app/src/commonMain/kotlin/com/kyant/backdrop/catalog/CatalogDestination.kt b/AndroidLiquidGlass-kmp/app/src/commonMain/kotlin/com/kyant/backdrop/catalog/CatalogDestination.ktnew file mode 100644index 0000000..541b7ad--- /dev/null+++ b/AndroidLiquidGlass-kmp/app/src/commonMain/kotlin/com/kyant/backdrop/catalog/CatalogDestination.kt@@ -0,0 +1,21 @@+package com.kyant.backdrop.catalog++enum class CatalogDestination {+ Home,++ Buttons,+ Toggle,+ Slider,+ BottomTabs,+ Dialog,++ LockScreen,+ ControlCenter,+ Magnifier,++ GlassPlayground,+ AdaptiveLuminanceGlass,+ ProgressiveBlur,+ ScrollContainer,+ LazyScrollContainer,+}diff --git a/AndroidLiquidGlass-kmp/app/src/commonMain/kotlin/com/kyant/backdrop/catalog/FlightIcon.kt b/AndroidLiquidGlass-kmp/app/src/commonMain/kotlin/com/kyant/backdrop/catalog/FlightIcon.ktnew file mode 100644index 0000000..df6e666--- /dev/null+++ b/AndroidLiquidGlass-kmp/app/src/commonMain/kotlin/com/kyant/backdrop/catalog/FlightIcon.kt@@ -0,0 +1,68 @@+package com.kyant.backdrop.catalog++import androidx.compose.ui.graphics.Color+import androidx.compose.ui.graphics.SolidColor+import androidx.compose.ui.graphics.vector.ImageVector+import androidx.compose.ui.graphics.vector.path+import androidx.compose.ui.unit.dp++internal val FlightIcon: ImageVector+ get() {+ if (_FlightIcon != null) return _FlightIcon!!++ _FlightIcon = ImageVector.Builder(+ name = "Flight",+ defaultWidth = 24.dp,+ defaultHeight = 24.dp,+ viewportWidth = 960f,+ viewportHeight = 960f+ ).apply {+ path(+ fill = SolidColor(Color(0xFF1f1f1f))+ ) {+ moveTo(400f, 552f)+ lineTo(147f, 653f)+ quadToRelative(-24f, 10f, -45.5f, -4.5f)+ reflectiveQuadTo(80f, 608f)+ verticalLineToRelative(-22f)+ quadToRelative(0f, -12f, 5.5f, -23f)+ reflectiveQuadToRelative(15.5f, -18f)+ lineToRelative(299f, -209f)+ verticalLineToRelative(-176f)+ quadToRelative(0f, -33f, 23.5f, -56.5f)+ reflectiveQuadTo(480f, 80f)+ quadToRelative(33f, 0f, 56.5f, 23.5f)+ reflectiveQuadTo(560f, 160f)+ verticalLineToRelative(176f)+ lineToRelative(299f, 209f)+ quadToRelative(10f, 7f, 15.5f, 18f)+ reflectiveQuadToRelative(5.5f, 23f)+ verticalLineToRelative(22f)+ quadToRelative(0f, 26f, -21.5f, 40.5f)+ reflectiveQuadTo(813f, 653f)+ lineTo(560f, 552f)+ verticalLineToRelative(144f)+ lineToRelative(103f, 72f)+ quadToRelative(8f, 6f, 12.5f, 14.5f)+ reflectiveQuadTo(680f, 801f)+ verticalLineToRelative(24f)+ quadToRelative(0f, 20f, -16.5f, 32.5f)+ reflectiveQuadTo(627f, 864f)+ lineToRelative(-147f, -44f)+ lineToRelative(-147f, 44f)+ quadToRelative(-20f, 6f, -36.5f, -6.5f)+ reflectiveQuadTo(280f, 825f)+ verticalLineToRelative(-24f)+ quadToRelative(0f, -10f, 4.5f, -18.5f)+ reflectiveQuadTo(297f, 768f)+ lineToRelative(103f, -72f)+ verticalLineToRelative(-144f)+ close()+ }+ }.build()++ return _FlightIcon!!+ }++private var _FlightIcon: ImageVector? = null+diff --git a/AndroidLiquidGlass-kmp/app/src/commonMain/kotlin/com/kyant/backdrop/catalog/MainContent.kt b/AndroidLiquidGlass-kmp/app/src/commonMain/kotlin/com/kyant/backdrop/catalog/MainContent.ktnew file mode 100644index 0000000..58493bf--- /dev/null+++ b/AndroidLiquidGlass-kmp/app/src/commonMain/kotlin/com/kyant/backdrop/catalog/MainContent.kt@@ -0,0 +1,61 @@+package com.kyant.backdrop.catalog++import androidx.compose.foundation.LocalIndication+import androidx.compose.foundation.isSystemInDarkTheme+import androidx.compose.runtime.Composable+import androidx.compose.runtime.CompositionLocalProvider+import androidx.compose.runtime.getValue+import androidx.compose.runtime.mutableStateOf+import androidx.compose.runtime.saveable.rememberSaveable+import androidx.compose.runtime.setValue+import androidx.compose.ui.graphics.Color+import com.kyant.backdrop.catalog.destinations.AdaptiveLuminanceGlassContent+import com.kyant.backdrop.catalog.destinations.BottomTabsContent+import com.kyant.backdrop.catalog.destinations.ButtonsContent+import com.kyant.backdrop.catalog.destinations.ControlCenterContent+import com.kyant.backdrop.catalog.destinations.DialogContent+import com.kyant.backdrop.catalog.destinations.GlassPlaygroundContent+import com.kyant.backdrop.catalog.destinations.HomeContent+import com.kyant.backdrop.catalog.destinations.LazyScrollContainerContent+import com.kyant.backdrop.catalog.destinations.LockScreenContent+import com.kyant.backdrop.catalog.destinations.MagnifierContent+import com.kyant.backdrop.catalog.destinations.ProgressiveBlurContent+import com.kyant.backdrop.catalog.destinations.ScrollContainerContent+import com.kyant.backdrop.catalog.destinations.SliderContent+import com.kyant.backdrop.catalog.destinations.ToggleContent+import com.kyant.backdrop.catalog.utils.BackHandler++@Composable+fun MainContent() {+ val isLightTheme = !isSystemInDarkTheme()++ CompositionLocalProvider(+ LocalIndication provides ripple(color = if (isLightTheme) Color.Black else Color.White)+ ) {+ var destination by rememberSaveable { mutableStateOf(CatalogDestination.Home) }++ when (destination) {+ CatalogDestination.Home -> HomeContent(onNavigate = { destination = it })++ CatalogDestination.Buttons -> ButtonsContent()+ CatalogDestination.Toggle -> ToggleContent()+ CatalogDestination.Slider -> SliderContent()+ CatalogDestination.BottomTabs -> BottomTabsContent()+ CatalogDestination.Dialog -> DialogContent()++ CatalogDestination.LockScreen -> LockScreenContent()+ CatalogDestination.ControlCenter -> ControlCenterContent()+ CatalogDestination.Magnifier -> MagnifierContent()++ CatalogDestination.GlassPlayground -> GlassPlaygroundContent()+ CatalogDestination.AdaptiveLuminanceGlass -> AdaptiveLuminanceGlassContent()+ CatalogDestination.ProgressiveBlur -> ProgressiveBlurContent()+ CatalogDestination.ScrollContainer -> ScrollContainerContent()+ CatalogDestination.LazyScrollContainer -> LazyScrollContainerContent()+ }++ BackHandler(destination != CatalogDestination.Home) {+ destination = CatalogDestination.Home+ }+ }+}diff --git a/AndroidLiquidGlass-kmp/app/src/commonMain/kotlin/com/kyant/backdrop/catalog/Ripple.kt b/AndroidLiquidGlass-kmp/app/src/commonMain/kotlin/com/kyant/backdrop/catalog/Ripple.ktnew file mode 100644index 0000000..32da8ee--- /dev/null+++ b/AndroidLiquidGlass-kmp/app/src/commonMain/kotlin/com/kyant/backdrop/catalog/Ripple.kt@@ -0,0 +1,176 @@+/*+ * Copyright 2024 The Android Open Source Project+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++package com.kyant.backdrop.catalog++import androidx.compose.foundation.IndicationNodeFactory+import androidx.compose.foundation.interaction.InteractionSource+import androidx.compose.material.ripple.RippleAlpha+import androidx.compose.material.ripple.createRippleModifierNode+import androidx.compose.runtime.Immutable+import androidx.compose.runtime.Stable+import androidx.compose.ui.graphics.Color+import androidx.compose.ui.graphics.ColorProducer+import androidx.compose.ui.node.CompositionLocalConsumerModifierNode+import androidx.compose.ui.node.DelegatableNode+import androidx.compose.ui.node.DelegatingNode+import androidx.compose.ui.node.ObserverModifierNode+import androidx.compose.ui.node.observeReads+import androidx.compose.ui.unit.Dp++@Stable+fun ripple(+ bounded: Boolean = true,+ radius: Dp = Dp.Unspecified,+ color: Color = Color.Unspecified+): IndicationNodeFactory {+ return if (radius == Dp.Unspecified && color == Color.Unspecified) {+ if (bounded) DefaultBoundedRipple else DefaultUnboundedRipple+ } else {+ RippleNodeFactory(bounded, radius, color)+ }+}++@Stable+fun ripple(+ color: ColorProducer,+ bounded: Boolean = true,+ radius: Dp = Dp.Unspecified+): IndicationNodeFactory {+ return RippleNodeFactory(bounded, radius, color)+}++object RippleDefaults {++ val RippleAlpha: RippleAlpha =+ RippleAlpha(+ pressedAlpha = 0.1f,+ focusedAlpha = 0.1f,+ draggedAlpha = 0.16f,+ hoveredAlpha = 0.08f+ )+}++@Immutable+class RippleConfiguration(+ val color: Color = Color.Unspecified,+ val rippleAlpha: RippleAlpha? = null+) {+ override fun equals(other: Any?): Boolean {+ if (this === other) return true+ if (other !is RippleConfiguration) return false++ if (color != other.color) return false+ if (rippleAlpha != other.rippleAlpha) return false++ return true+ }++ override fun hashCode(): Int {+ var result = color.hashCode()+ result = 31 * result + (rippleAlpha?.hashCode() ?: 0)+ return result+ }++ override fun toString(): String {+ return "RippleConfiguration(color=$color, rippleAlpha=$rippleAlpha)"+ }+}++@Stable+private class RippleNodeFactory+private constructor(+ private val bounded: Boolean,+ private val radius: Dp,+ private val colorProducer: ColorProducer?,+ private val color: Color+) : IndicationNodeFactory {++ constructor(+ bounded: Boolean,+ radius: Dp,+ colorProducer: ColorProducer+ ) : this(bounded, radius, colorProducer, Color.Unspecified)++ constructor(bounded: Boolean, radius: Dp, color: Color) : this(bounded, radius, null, color)++ override fun create(interactionSource: InteractionSource): DelegatableNode {+ val colorProducer = colorProducer ?: ColorProducer { color }+ return DelegatingThemeAwareRippleNode(interactionSource, bounded, radius, colorProducer)+ }++ override fun equals(other: Any?): Boolean {+ if (this === other) return true+ if (other !is RippleNodeFactory) return false++ if (bounded != other.bounded) return false+ if (radius != other.radius) return false+ if (colorProducer != other.colorProducer) return false+ return color == other.color+ }++ override fun hashCode(): Int {+ var result = bounded.hashCode()+ result = 31 * result + radius.hashCode()+ result = 31 * result + colorProducer.hashCode()+ result = 31 * result + color.hashCode()+ return result+ }+}++private class DelegatingThemeAwareRippleNode(+ private val interactionSource: InteractionSource,+ private val bounded: Boolean,+ private val radius: Dp,+ private val color: ColorProducer,+) : DelegatingNode(), CompositionLocalConsumerModifierNode, ObserverModifierNode {++ private var rippleNode: DelegatableNode? = null++ override fun onAttach() {+ updateConfiguration()+ }++ override fun onObservedReadsChanged() {+ updateConfiguration()+ }++ private fun updateConfiguration() {+ observeReads {+ if (rippleNode == null) {+ attachNewRipple()+ }+ }+ }++ private fun attachNewRipple() {+ rippleNode =+ delegate(+ createRippleModifierNode(+ interactionSource = interactionSource,+ bounded = bounded,+ radius = radius,+ color = color,+ rippleAlpha = { RippleDefaults.RippleAlpha }+ )+ )+ }+}++private val DefaultBoundedRipple =+ RippleNodeFactory(bounded = true, radius = Dp.Unspecified, color = Color.Unspecified)+private val DefaultUnboundedRipple =+ RippleNodeFactory(bounded = false, radius = Dp.Unspecified, color = Color.Unspecified)diff --git a/AndroidLiquidGlass-kmp/app/src/commonMain/kotlin/com/kyant/backdrop/catalog/components/LiquidBottomTab.kt b/AndroidLiquidGlass-kmp/app/src/commonMain/kotlin/com/kyant/backdrop/catalog/components/LiquidBottomTab.ktnew file mode 100644index 0000000..254ccf3--- /dev/null+++ b/AndroidLiquidGlass-kmp/app/src/commonMain/kotlin/com/kyant/backdrop/catalog/components/LiquidBottomTab.kt@@ -0,0 +1,49 @@+package com.kyant.backdrop.catalog.components++import androidx.compose.foundation.clickable+import androidx.compose.foundation.layout.Arrangement+import androidx.compose.foundation.layout.Column+import androidx.compose.foundation.layout.ColumnScope+import androidx.compose.foundation.layout.RowScope+import androidx.compose.foundation.layout.fillMaxHeight+import androidx.compose.runtime.Composable+import androidx.compose.runtime.staticCompositionLocalOf+import androidx.compose.ui.Alignment+import androidx.compose.ui.Modifier+import androidx.compose.ui.draw.clip+import androidx.compose.ui.graphics.graphicsLayer+import androidx.compose.ui.semantics.Role+import androidx.compose.ui.unit.dp+import com.kyant.shapes.Capsule++internal val LocalLiquidBottomTabScale =+ staticCompositionLocalOf { { 1f } }++@Composable+fun RowScope.LiquidBottomTab(+ onClick: () -> Unit,+ modifier: Modifier = Modifier,+ content: @Composable ColumnScope.() -> Unit+) {+ val scale = LocalLiquidBottomTabScale.current+ Column(+ modifier+ .clip(Capsule())+ .clickable(+ interactionSource = null,+ indication = null,+ role = Role.Tab,+ onClick = onClick+ )+ .fillMaxHeight()+ .weight(1f)+ .graphicsLayer {+ val scale = scale()+ scaleX = scale+ scaleY = scale+ },+ verticalArrangement = Arrangement.spacedBy(2f.dp, Alignment.CenterVertically),+ horizontalAlignment = Alignment.CenterHorizontally,+ content = content+ )+}diff --git a/AndroidLiquidGlass-kmp/app/src/commonMain/kotlin/com/kyant/backdrop/catalog/components/LiquidBottomTabs.kt b/AndroidLiquidGlass-kmp/app/src/commonMain/kotlin/com/kyant/backdrop/catalog/components/LiquidBottomTabs.ktnew file mode 100644index 0000000..2106772--- /dev/null+++ b/AndroidLiquidGlass-kmp/app/src/commonMain/kotlin/com/kyant/backdrop/catalog/components/LiquidBottomTabs.kt@@ -0,0 +1,288 @@+package com.kyant.backdrop.catalog.components++import androidx.compose.animation.core.Animatable+import androidx.compose.animation.core.EaseOut+import androidx.compose.animation.core.spring+import androidx.compose.foundation.isSystemInDarkTheme+import androidx.compose.foundation.layout.Box+import androidx.compose.foundation.layout.BoxWithConstraints+import androidx.compose.foundation.layout.Row+import androidx.compose.foundation.layout.RowScope+import androidx.compose.foundation.layout.fillMaxWidth+import androidx.compose.foundation.layout.height+import androidx.compose.foundation.layout.padding+import androidx.compose.runtime.Composable+import androidx.compose.runtime.CompositionLocalProvider+import androidx.compose.runtime.LaunchedEffect+import androidx.compose.runtime.derivedStateOf+import androidx.compose.runtime.getValue+import androidx.compose.runtime.mutableIntStateOf+import androidx.compose.runtime.remember+import androidx.compose.runtime.rememberCoroutineScope+import androidx.compose.runtime.setValue+import androidx.compose.runtime.snapshotFlow+import androidx.compose.ui.Alignment+import androidx.compose.ui.Modifier+import androidx.compose.ui.draw.alpha+import androidx.compose.ui.geometry.Offset+import androidx.compose.ui.graphics.Color+import androidx.compose.ui.graphics.ColorFilter+import androidx.compose.ui.graphics.graphicsLayer+import androidx.compose.ui.platform.LocalDensity+import androidx.compose.ui.platform.LocalLayoutDirection+import androidx.compose.ui.semantics.clearAndSetSemantics+import androidx.compose.ui.unit.LayoutDirection+import androidx.compose.ui.unit.dp+import androidx.compose.ui.util.fastCoerceIn+import androidx.compose.ui.util.fastRoundToInt+import androidx.compose.ui.util.lerp+import com.kyant.backdrop.Backdrop+import com.kyant.backdrop.backdrops.layerBackdrop+import com.kyant.backdrop.backdrops.rememberCombinedBackdrop+import com.kyant.backdrop.backdrops.rememberLayerBackdrop+import com.kyant.backdrop.catalog.utils.DampedDragAnimation+import com.kyant.backdrop.catalog.utils.InteractiveHighlight+import com.kyant.backdrop.drawBackdrop+import com.kyant.backdrop.effects.blur+import com.kyant.backdrop.effects.lens+import com.kyant.backdrop.effects.vibrancy+import com.kyant.backdrop.highlight.Highlight+import com.kyant.backdrop.shadow.InnerShadow+import com.kyant.backdrop.shadow.Shadow+import com.kyant.shapes.Capsule+import kotlinx.coroutines.flow.collectLatest+import kotlinx.coroutines.flow.drop+import kotlinx.coroutines.launch+import kotlin.math.abs+import kotlin.math.sign++@Composable+fun LiquidBottomTabs(+ selectedTabIndex: () -> Int,+ onTabSelected: (index: Int) -> Unit,+ backdrop: Backdrop,+ tabsCount: Int,+ modifier: Modifier = Modifier,+ content: @Composable RowScope.() -> Unit+) {+ val isLightTheme = !isSystemInDarkTheme()+ val accentColor =+ if (isLightTheme) Color(0xFF0088FF)+ else Color(0xFF0091FF)+ val containerColor =+ if (isLightTheme) Color(0xFFFAFAFA).copy(0.4f)+ else Color(0xFF121212).copy(0.4f)++ val tabsBackdrop = rememberLayerBackdrop()++ BoxWithConstraints(+ modifier,+ contentAlignment = Alignment.CenterStart+ ) {+ val density = LocalDensity.current+ val tabWidth = with(density) {+ (constraints.maxWidth.toFloat() - 8f.dp.toPx()) / tabsCount+ }++ val offsetAnimation = remember { Animatable(0f) }+ val panelOffset by remember(density) {+ derivedStateOf {+ val fraction = (offsetAnimation.value / constraints.maxWidth).fastCoerceIn(-1f, 1f)+ with(density) {+ 4f.dp.toPx() * fraction.sign * EaseOut.transform(abs(fraction))+ }+ }+ }++ val isLtr = LocalLayoutDirection.current == LayoutDirection.Ltr+ val animationScope = rememberCoroutineScope()+ var currentIndex by remember(selectedTabIndex) {+ mutableIntStateOf(selectedTabIndex())+ }+ val dampedDragAnimation = remember(animationScope) {+ DampedDragAnimation(+ animationScope = animationScope,+ initialValue = selectedTabIndex().toFloat(),+ valueRange = 0f..(tabsCount - 1).toFloat(),+ visibilityThreshold = 0.001f,+ initialScale = 1f,+ pressedScale = 78f / 56f,+ onDragStarted = {},+ onDragStopped = {+ val targetIndex = targetValue.fastRoundToInt().fastCoerceIn(0, tabsCount - 1)+ currentIndex = targetIndex+ animateToValue(targetIndex.toFloat())+ animationScope.launch {+ offsetAnimation.animateTo(+ 0f,+ spring(1f, 300f, 0.5f)+ )+ }+ },+ onDrag = { _, dragAmount ->+ updateValue(+ (targetValue + dragAmount.x / tabWidth * if (isLtr) 1f else -1f)+ .fastCoerceIn(0f, (tabsCount - 1).toFloat())+ )+ animationScope.launch {+ offsetAnimation.snapTo(offsetAnimation.value + dragAmount.x)+ }+ }+ )+ }+ LaunchedEffect(selectedTabIndex) {+ snapshotFlow { selectedTabIndex() }+ .collectLatest { index ->+ currentIndex = index+ }+ }+ LaunchedEffect(dampedDragAnimation) {+ snapshotFlow { currentIndex }+ .drop(1)+ .collectLatest { index ->+ dampedDragAnimation.animateToValue(index.toFloat())+ onTabSelected(index)+ }+ }++ val interactiveHighlight = remember(animationScope) {+ InteractiveHighlight(+ animationScope = animationScope,+ position = { size, offset ->+ Offset(+ if (isLtr) (dampedDragAnimation.value + 0.5f) * tabWidth + panelOffset+ else size.width - (dampedDragAnimation.value + 0.5f) * tabWidth + panelOffset,+ size.height / 2f+ )+ }+ )+ }++ Row(+ Modifier+ .graphicsLayer {+ translationX = panelOffset+ }+ .drawBackdrop(+ backdrop = backdrop,+ shape = { Capsule() },+ effects = {+ vibrancy()+ blur(8f.dp.toPx())+ lens(24f.dp.toPx(), 24f.dp.toPx())+ },+ layerBlock = {+ val progress = dampedDragAnimation.pressProgress+ val scale = lerp(1f, 1f + 16f.dp.toPx() / size.width, progress)+ scaleX = scale+ scaleY = scale+ },+ onDrawSurface = { drawRect(containerColor) }+ )+ .then(interactiveHighlight.modifier)+ .height(64f.dp)+ .fillMaxWidth()+ .padding(4f.dp),+ verticalAlignment = Alignment.CenterVertically,+ content = content+ )++ CompositionLocalProvider(+ LocalLiquidBottomTabScale provides {+ lerp(1f, 1.2f, dampedDragAnimation.pressProgress)+ }+ ) {+ Row(+ Modifier+ .clearAndSetSemantics {}+ .alpha(0f)+ .layerBackdrop(tabsBackdrop)+ .graphicsLayer {+ translationX = panelOffset+ }+ .drawBackdrop(+ backdrop = backdrop,+ shape = { Capsule() },+ effects = {+ val progress = dampedDragAnimation.pressProgress+ vibrancy()+ blur(8f.dp.toPx())+ lens(+ 24f.dp.toPx() * progress,+ 24f.dp.toPx() * progress+ )+ },+ highlight = {+ val progress = dampedDragAnimation.pressProgress+ Highlight.Default.copy(alpha = progress)+ },+ onDrawSurface = { drawRect(containerColor) }+ )+ .then(interactiveHighlight.modifier)+ .height(56f.dp)+ .fillMaxWidth()+ .padding(horizontal = 4f.dp)+ .graphicsLayer(colorFilter = ColorFilter.tint(accentColor)),+ verticalAlignment = Alignment.CenterVertically,+ content = content+ )+ }++ Box(+ Modifier+ .padding(horizontal = 4f.dp)+ .graphicsLayer {+ translationX =+ if (isLtr) dampedDragAnimation.value * tabWidth + panelOffset+ else size.width - (dampedDragAnimation.value + 1f) * tabWidth + panelOffset+ }+ .then(interactiveHighlight.gestureModifier)+ .then(dampedDragAnimation.modifier)+ .drawBackdrop(+ backdrop = rememberCombinedBackdrop(backdrop, tabsBackdrop),+ shape = { Capsule() },+ effects = {+ val progress = dampedDragAnimation.pressProgress+ lens(+ 10f.dp.toPx() * progress,+ 14f.dp.toPx() * progress,+ chromaticAberration = true+ )+ },+ highlight = {+ val progress = dampedDragAnimation.pressProgress+ Highlight.Default.copy(alpha = progress)+ },+ shadow = {+ val progress = dampedDragAnimation.pressProgress+ Shadow(alpha = progress)+ },+ innerShadow = {+ val progress = dampedDragAnimation.pressProgress+ InnerShadow(+ radius = 8f.dp * progress,+ alpha = progress+ )+ },+ layerBlock = {+ scaleX = dampedDragAnimation.scaleX+ scaleY = dampedDragAnimation.scaleY+ val velocity = dampedDragAnimation.velocity / 10f+ scaleX /= 1f - (velocity * 0.75f).fastCoerceIn(-0.2f, 0.2f)+ scaleY *= 1f - (velocity * 0.25f).fastCoerceIn(-0.2f, 0.2f)+ },+ onDrawSurface = {+ val progress = dampedDragAnimation.pressProgress+ drawRect(+ if (isLightTheme) Color.Black.copy(0.1f)+ else Color.White.copy(0.1f),+ alpha = 1f - progress+ )+ drawRect(Color.Black.copy(alpha = 0.03f * progress))+ }+ )+ .height(56f.dp)+ .fillMaxWidth(1f / tabsCount)+ )+ }+}diff --git a/AndroidLiquidGlass-kmp/app/src/commonMain/kotlin/com/kyant/backdrop/catalog/components/LiquidButton.kt b/AndroidLiquidGlass-kmp/app/src/commonMain/kotlin/com/kyant/backdrop/catalog/components/LiquidButton.ktnew file mode 100644index 0000000..47b8409--- /dev/null+++ b/AndroidLiquidGlass-kmp/app/src/commonMain/kotlin/com/kyant/backdrop/catalog/components/LiquidButton.kt@@ -0,0 +1,122 @@+package com.kyant.backdrop.catalog.components++import androidx.compose.foundation.LocalIndication+import androidx.compose.foundation.clickable+import androidx.compose.foundation.layout.Arrangement+import androidx.compose.foundation.layout.Row+import androidx.compose.foundation.layout.RowScope+import androidx.compose.foundation.layout.height+import androidx.compose.foundation.layout.padding+import androidx.compose.runtime.Composable+import androidx.compose.runtime.remember+import androidx.compose.runtime.rememberCoroutineScope+import androidx.compose.ui.Alignment+import androidx.compose.ui.Modifier+import androidx.compose.ui.graphics.BlendMode+import androidx.compose.ui.graphics.Color+import androidx.compose.ui.graphics.isSpecified+import androidx.compose.ui.semantics.Role+import androidx.compose.ui.unit.dp+import androidx.compose.ui.util.fastCoerceAtMost+import androidx.compose.ui.util.lerp+import com.kyant.backdrop.Backdrop+import com.kyant.backdrop.catalog.utils.InteractiveHighlight+import com.kyant.backdrop.drawBackdrop+import com.kyant.backdrop.effects.blur+import com.kyant.backdrop.effects.lens+import com.kyant.backdrop.effects.vibrancy+import com.kyant.shapes.Capsule+import kotlin.math.abs+import kotlin.math.atan2+import kotlin.math.cos+import kotlin.math.sin+import kotlin.math.tanh++@Composable+fun LiquidButton(+ onClick: () -> Unit,+ backdrop: Backdrop,+ modifier: Modifier = Modifier,+ isInteractive: Boolean = true,+ tint: Color = Color.Unspecified,+ surfaceColor: Color = Color.Unspecified,+ content: @Composable RowScope.() -> Unit+) {+ val animationScope = rememberCoroutineScope()++ val interactiveHighlight = remember(animationScope) {+ InteractiveHighlight(+ animationScope = animationScope+ )+ }++ Row(+ modifier+ .drawBackdrop(+ backdrop = backdrop,+ shape = { Capsule() },+ effects = {+ vibrancy()+ blur(2f.dp.toPx())+ lens(12f.dp.toPx(), 24f.dp.toPx())+ },+ layerBlock = if (isInteractive) {+ {+ val width = size.width+ val height = size.height++ val progress = interactiveHighlight.pressProgress+ val scale = lerp(1f, 1f + 4f.dp.toPx() / size.height, progress)++ val maxOffset = size.minDimension+ val initialDerivative = 0.05f+ val offset = interactiveHighlight.offset+ translationX = maxOffset * tanh(initialDerivative * offset.x / maxOffset)+ translationY = maxOffset * tanh(initialDerivative * offset.y / maxOffset)++ val maxDragScale = 4f.dp.toPx() / size.height+ val offsetAngle = atan2(offset.y, offset.x)+ scaleX =+ scale ++ maxDragScale * abs(cos(offsetAngle) * offset.x / size.maxDimension) *+ (width / height).fastCoerceAtMost(1f)+ scaleY =+ scale ++ maxDragScale * abs(sin(offsetAngle) * offset.y / size.maxDimension) *+ (height / width).fastCoerceAtMost(1f)+ }+ } else {+ null+ },+ onDrawSurface = {+ if (tint.isSpecified) {+ drawRect(tint, blendMode = BlendMode.Hue)+ drawRect(tint.copy(alpha = 0.75f))+ }+ if (surfaceColor.isSpecified) {+ drawRect(surfaceColor)+ }+ }+ )+ .clickable(+ interactionSource = null,+ indication = if (isInteractive) null else LocalIndication.current,+ role = Role.Button,+ onClick = onClick+ )+ .then(+ if (isInteractive) {+ Modifier+ .then(interactiveHighlight.modifier)+ .then(interactiveHighlight.gestureModifier)+ } else {+ Modifier+ }+ )+ .height(48f.dp)+ .padding(horizontal = 16f.dp),+ horizontalArrangement = Arrangement.spacedBy(8f.dp, Alignment.CenterHorizontally),+ verticalAlignment = Alignment.CenterVertically,+ content = content+ )+}diff --git a/AndroidLiquidGlass-kmp/app/src/commonMain/kotlin/com/kyant/backdrop/catalog/components/LiquidSlider.kt b/AndroidLiquidGlass-kmp/app/src/commonMain/kotlin/com/kyant/backdrop/catalog/components/LiquidSlider.ktnew file mode 100644index 0000000..95e7f9d--- /dev/null+++ b/AndroidLiquidGlass-kmp/app/src/commonMain/kotlin/com/kyant/backdrop/catalog/components/LiquidSlider.kt@@ -0,0 +1,212 @@+package com.kyant.backdrop.catalog.components++import androidx.compose.foundation.background+import androidx.compose.foundation.gestures.detectTapGestures+import androidx.compose.foundation.isSystemInDarkTheme+import androidx.compose.foundation.layout.Box+import androidx.compose.foundation.layout.BoxWithConstraints+import androidx.compose.foundation.layout.fillMaxWidth+import androidx.compose.foundation.layout.height+import androidx.compose.foundation.layout.size+import androidx.compose.runtime.Composable+import androidx.compose.runtime.LaunchedEffect+import androidx.compose.runtime.getValue+import androidx.compose.runtime.mutableStateOf+import androidx.compose.runtime.remember+import androidx.compose.runtime.rememberCoroutineScope+import androidx.compose.runtime.setValue+import androidx.compose.runtime.snapshotFlow+import androidx.compose.ui.Alignment+import androidx.compose.ui.Modifier+import androidx.compose.ui.draw.clip+import androidx.compose.ui.graphics.Color+import androidx.compose.ui.graphics.drawscope.scale+import androidx.compose.ui.graphics.graphicsLayer+import androidx.compose.ui.input.pointer.pointerInput+import androidx.compose.ui.layout.layout+import androidx.compose.ui.platform.LocalLayoutDirection+import androidx.compose.ui.unit.LayoutDirection+import androidx.compose.ui.unit.dp+import androidx.compose.ui.util.fastCoerceIn+import androidx.compose.ui.util.fastRoundToInt+import androidx.compose.ui.util.lerp+import com.kyant.backdrop.Backdrop+import com.kyant.backdrop.backdrops.layerBackdrop+import com.kyant.backdrop.backdrops.rememberBackdrop+import com.kyant.backdrop.backdrops.rememberCombinedBackdrop+import com.kyant.backdrop.backdrops.rememberLayerBackdrop+import com.kyant.backdrop.catalog.utils.DampedDragAnimation+import com.kyant.backdrop.drawBackdrop+import com.kyant.backdrop.effects.blur+import com.kyant.backdrop.effects.lens+import com.kyant.backdrop.highlight.Highlight+import com.kyant.backdrop.shadow.InnerShadow+import com.kyant.backdrop.shadow.Shadow+import com.kyant.shapes.Capsule+import kotlinx.coroutines.flow.collectLatest++@Composable+fun LiquidSlider(+ value: () -> Float,+ onValueChange: (Float) -> Unit,+ valueRange: ClosedFloatingPointRange<Float>,+ visibilityThreshold: Float,+ backdrop: Backdrop,+ modifier: Modifier = Modifier+) {+ val isLightTheme = !isSystemInDarkTheme()+ val accentColor =+ if (isLightTheme) Color(0xFF0088FF)+ else Color(0xFF0091FF)+ val trackColor =+ if (isLightTheme) Color(0xFF787878).copy(0.2f)+ else Color(0xFF787880).copy(0.36f)++ val trackBackdrop = rememberLayerBackdrop()++ BoxWithConstraints(+ modifier.fillMaxWidth(),+ contentAlignment = Alignment.CenterStart+ ) {+ val trackWidth = constraints.maxWidth++ val isLtr = LocalLayoutDirection.current == LayoutDirection.Ltr+ val animationScope = rememberCoroutineScope()+ var didDrag by remember { mutableStateOf(false) }+ val dampedDragAnimation = remember(animationScope) {+ DampedDragAnimation(+ animationScope = animationScope,+ initialValue = value(),+ valueRange = valueRange,+ visibilityThreshold = visibilityThreshold,+ initialScale = 1f,+ pressedScale = 1.5f,+ onDragStarted = {},+ onDragStopped = {+ if (didDrag) {+ onValueChange(targetValue)+ }+ },+ onDrag = { _, dragAmount ->+ if (!didDrag) {+ didDrag = dragAmount.x != 0f+ }+ val delta = (valueRange.endInclusive - valueRange.start) * (dragAmount.x / trackWidth)+ onValueChange(+ if (isLtr) (targetValue + delta).coerceIn(valueRange)+ else (targetValue - delta).coerceIn(valueRange)+ )+ }+ )+ }+ LaunchedEffect(dampedDragAnimation) {+ snapshotFlow { value() }+ .collectLatest { value ->+ if (dampedDragAnimation.targetValue != value) {+ dampedDragAnimation.updateValue(value)+ }+ }+ }++ Box(Modifier.layerBackdrop(trackBackdrop)) {+ Box(+ Modifier+ .clip(Capsule())+ .background(trackColor)+ .pointerInput(animationScope) {+ detectTapGestures { position ->+ val delta = (valueRange.endInclusive - valueRange.start) * (position.x / trackWidth)+ val targetValue =+ (if (isLtr) valueRange.start + delta+ else valueRange.endInclusive - delta)+ .coerceIn(valueRange)+ dampedDragAnimation.animateToValue(targetValue)+ onValueChange(targetValue)+ }+ }+ .height(6f.dp)+ .fillMaxWidth()+ )++ Box(+ Modifier+ .clip(Capsule())+ .background(accentColor)+ .height(6f.dp)+ .layout { measurable, constraints ->+ val placeable = measurable.measure(constraints)+ val width = (constraints.maxWidth * dampedDragAnimation.progress).fastRoundToInt()+ layout(width, placeable.height) {+ placeable.place(0, 0)+ }+ }+ )+ }++ Box(+ Modifier+ .graphicsLayer {+ translationX =+ (-size.width / 2f + trackWidth * dampedDragAnimation.progress)+ .fastCoerceIn(-size.width / 4f, trackWidth - size.width * 3f / 4f) * if (isLtr) 1f else -1f+ }+ .then(dampedDragAnimation.modifier)+ .drawBackdrop(+ backdrop = rememberCombinedBackdrop(+ backdrop,+ rememberBackdrop(trackBackdrop) { drawBackdrop ->+ val progress = dampedDragAnimation.pressProgress+ val scaleX = lerp(2f / 3f, 1f, progress)+ val scaleY = lerp(0f, 1f, progress)+ scale(scaleX, scaleY) {+ drawBackdrop()+ }+ }+ ),+ shape = { Capsule() },+ effects = {+ val progress = dampedDragAnimation.pressProgress+ blur(8f.dp.toPx() * (1f - progress))+ lens(+ 10f.dp.toPx() * progress,+ 14f.dp.toPx() * progress,+ chromaticAberration = true+ )+ },+ highlight = {+ val progress = dampedDragAnimation.pressProgress+ Highlight.Ambient.copy(+ width = Highlight.Ambient.width / 1.5f,+ blurRadius = Highlight.Ambient.blurRadius / 1.5f,+ alpha = progress+ )+ },+ shadow = {+ Shadow(+ radius = 4f.dp,+ color = Color.Black.copy(alpha = 0.05f)+ )+ },+ innerShadow = {+ val progress = dampedDragAnimation.pressProgress+ InnerShadow(+ radius = 4f.dp * progress,+ alpha = progress+ )+ },+ layerBlock = {+ scaleX = dampedDragAnimation.scaleX+ scaleY = dampedDragAnimation.scaleY+ val velocity = dampedDragAnimation.velocity / 10f+ scaleX /= 1f - (velocity * 0.75f).fastCoerceIn(-0.2f, 0.2f)+ scaleY *= 1f - (velocity * 0.25f).fastCoerceIn(-0.2f, 0.2f)+ },+ onDrawSurface = {+ val progress = dampedDragAnimation.pressProgress+ drawRect(Color.White.copy(alpha = 1f - progress))+ }+ )+ .size(40f.dp, 24f.dp)+ )+ }+}diff --git a/AndroidLiquidGlass-kmp/app/src/commonMain/kotlin/com/kyant/backdrop/catalog/components/LiquidToggle.kt b/AndroidLiquidGlass-kmp/app/src/commonMain/kotlin/com/kyant/backdrop/catalog/components/LiquidToggle.ktnew file mode 100644index 0000000..dcc6531--- /dev/null+++ b/AndroidLiquidGlass-kmp/app/src/commonMain/kotlin/com/kyant/backdrop/catalog/components/LiquidToggle.kt@@ -0,0 +1,203 @@+package com.kyant.backdrop.catalog.components++import androidx.compose.foundation.isSystemInDarkTheme+import androidx.compose.foundation.layout.Box+import androidx.compose.foundation.layout.size+import androidx.compose.runtime.Composable+import androidx.compose.runtime.LaunchedEffect+import androidx.compose.runtime.getValue+import androidx.compose.runtime.mutableFloatStateOf+import androidx.compose.runtime.mutableStateOf+import androidx.compose.runtime.remember+import androidx.compose.runtime.rememberCoroutineScope+import androidx.compose.runtime.setValue+import androidx.compose.runtime.snapshotFlow+import androidx.compose.ui.Alignment+import androidx.compose.ui.Modifier+import androidx.compose.ui.draw.clip+import androidx.compose.ui.draw.drawBehind+import androidx.compose.ui.graphics.Color+import androidx.compose.ui.graphics.drawscope.scale+import androidx.compose.ui.graphics.graphicsLayer+import androidx.compose.ui.graphics.lerp+import androidx.compose.ui.platform.LocalDensity+import androidx.compose.ui.platform.LocalLayoutDirection+import androidx.compose.ui.semantics.Role+import androidx.compose.ui.semantics.role+import androidx.compose.ui.semantics.semantics+import androidx.compose.ui.unit.LayoutDirection+import androidx.compose.ui.unit.dp+import androidx.compose.ui.util.fastCoerceIn+import androidx.compose.ui.util.lerp+import com.kyant.backdrop.Backdrop+import com.kyant.backdrop.backdrops.layerBackdrop+import com.kyant.backdrop.backdrops.rememberBackdrop+import com.kyant.backdrop.backdrops.rememberCombinedBackdrop+import com.kyant.backdrop.backdrops.rememberLayerBackdrop+import com.kyant.backdrop.catalog.utils.DampedDragAnimation+import com.kyant.backdrop.drawBackdrop+import com.kyant.backdrop.effects.blur+import com.kyant.backdrop.effects.lens+import com.kyant.backdrop.highlight.Highlight+import com.kyant.backdrop.shadow.InnerShadow+import com.kyant.backdrop.shadow.Shadow+import com.kyant.shapes.Capsule+import kotlinx.coroutines.flow.collectLatest++@Composable+fun LiquidToggle(+ selected: () -> Boolean,+ onSelect: (Boolean) -> Unit,+ backdrop: Backdrop,+ modifier: Modifier = Modifier+) {+ val isLightTheme = !isSystemInDarkTheme()+ val accentColor =+ if (isLightTheme) Color(0xFF34C759)+ else Color(0xFF30D158)+ val trackColor =+ if (isLightTheme) Color(0xFF787878).copy(0.2f)+ else Color(0xFF787880).copy(0.36f)++ val density = LocalDensity.current+ val isLtr = LocalLayoutDirection.current == LayoutDirection.Ltr+ val dragWidth = with(density) { 20f.dp.toPx() }+ val animationScope = rememberCoroutineScope()+ var didDrag by remember { mutableStateOf(false) }+ var fraction by remember { mutableFloatStateOf(if (selected()) 1f else 0f) }+ val dampedDragAnimation = remember(animationScope) {+ DampedDragAnimation(+ animationScope = animationScope,+ initialValue = fraction,+ valueRange = 0f..1f,+ visibilityThreshold = 0.001f,+ initialScale = 1f,+ pressedScale = 1.5f,+ onDragStarted = {},+ onDragStopped = {+ if (didDrag) {+ fraction = if (targetValue >= 0.5f) 1f else 0f+ onSelect(fraction == 1f)+ didDrag = false+ } else {+ fraction = if (selected()) 0f else 1f+ onSelect(fraction == 1f)+ }+ },+ onDrag = { _, dragAmount ->+ if (!didDrag) {+ didDrag = dragAmount.x != 0f+ }+ val delta = dragAmount.x / dragWidth+ fraction =+ if (isLtr) (fraction + delta).fastCoerceIn(0f, 1f)+ else (fraction - delta).fastCoerceIn(0f, 1f)+ }+ )+ }+ LaunchedEffect(dampedDragAnimation) {+ snapshotFlow { fraction }+ .collectLatest { fraction ->+ dampedDragAnimation.updateValue(fraction)+ }+ }+ LaunchedEffect(selected) {+ snapshotFlow { selected() }+ .collectLatest { isSelected ->+ val target = if (isSelected) 1f else 0f+ if (target != fraction) {+ fraction = target+ dampedDragAnimation.animateToValue(target)+ }+ }+ }++ val trackBackdrop = rememberLayerBackdrop()++ Box(+ modifier,+ contentAlignment = Alignment.CenterStart+ ) {+ Box(+ Modifier+ .layerBackdrop(trackBackdrop)+ .clip(Capsule())+ .drawBehind {+ val fraction = dampedDragAnimation.value+ drawRect(lerp(trackColor, accentColor, fraction))+ }+ .size(64f.dp, 28f.dp)+ )++ Box(+ Modifier+ .graphicsLayer {+ val fraction = dampedDragAnimation.value+ val padding = 2f.dp.toPx()+ translationX =+ if (isLtr) lerp(padding, padding + dragWidth, fraction)+ else lerp(-padding, -(padding + dragWidth), fraction)+ }+ .semantics {+ role = Role.Switch+ }+ .then(dampedDragAnimation.modifier)+ .drawBackdrop(+ backdrop = rememberCombinedBackdrop(+ backdrop,+ rememberBackdrop(trackBackdrop) { drawBackdrop ->+ val progress = dampedDragAnimation.pressProgress+ val scaleX = lerp(2f / 3f, 0.75f, progress)+ val scaleY = lerp(0f, 0.75f, progress)+ scale(scaleX, scaleY) {+ drawBackdrop()+ }+ }+ ),+ shape = { Capsule() },+ effects = {+ val progress = dampedDragAnimation.pressProgress+ blur(8f.dp.toPx() * (1f - progress))+ lens(+ 5f.dp.toPx() * progress,+ 10f.dp.toPx() * progress,+ chromaticAberration = true+ )+ },+ highlight = {+ val progress = dampedDragAnimation.pressProgress+ Highlight.Ambient.copy(+ width = Highlight.Ambient.width / 1.5f,+ blurRadius = Highlight.Ambient.blurRadius / 1.5f,+ alpha = progress+ )+ },+ shadow = {+ Shadow(+ radius = 4f.dp,+ color = Color.Black.copy(alpha = 0.05f)+ )+ },+ innerShadow = {+ val progress = dampedDragAnimation.pressProgress+ InnerShadow(+ radius = 4f.dp * progress,+ alpha = progress+ )+ },+ layerBlock = {+ scaleX = dampedDragAnimation.scaleX+ scaleY = dampedDragAnimation.scaleY+ val velocity = dampedDragAnimation.velocity / 50f+ scaleX /= 1f - (velocity * 0.75f).fastCoerceIn(-0.2f, 0.2f)+ scaleY *= 1f - (velocity * 0.25f).fastCoerceIn(-0.2f, 0.2f)+ },+ onDrawSurface = {+ val progress = dampedDragAnimation.pressProgress+ drawRect(Color.White.copy(alpha = 1f - progress))+ }+ )+ .size(40f.dp, 24f.dp)+ )+ }+}diff --git a/AndroidLiquidGlass-kmp/app/src/commonMain/kotlin/com/kyant/backdrop/catalog/destinations/AdaptiveLuminanceGlassContent.kt b/AndroidLiquidGlass-kmp/app/src/commonMain/kotlin/com/kyant/backdrop/catalog/destinations/AdaptiveLuminanceGlassContent.ktnew file mode 100644index 0000000..8fc0c6b--- /dev/null+++ b/AndroidLiquidGlass-kmp/app/src/commonMain/kotlin/com/kyant/backdrop/catalog/destinations/AdaptiveLuminanceGlassContent.kt@@ -0,0 +1,163 @@+package com.kyant.backdrop.catalog.destinations++import androidx.compose.animation.Animatable+import androidx.compose.animation.core.Animatable+import androidx.compose.animation.core.VectorConverter+import androidx.compose.animation.core.tween+import androidx.compose.foundation.gestures.detectTransformGestures+import androidx.compose.foundation.isSystemInDarkTheme+import androidx.compose.foundation.layout.Box+import androidx.compose.foundation.layout.size+import androidx.compose.foundation.text.BasicText+import androidx.compose.runtime.Composable+import androidx.compose.runtime.LaunchedEffect+import androidx.compose.runtime.remember+import androidx.compose.runtime.rememberCoroutineScope+import androidx.compose.ui.Alignment+import androidx.compose.ui.Modifier+import androidx.compose.ui.geometry.Offset+import androidx.compose.ui.graphics.Color+import androidx.compose.ui.graphics.TransformOrigin+import androidx.compose.ui.graphics.rememberGraphicsLayer+import androidx.compose.ui.input.pointer.pointerInput+import androidx.compose.ui.text.TextStyle+import androidx.compose.ui.text.style.TextAlign+import androidx.compose.ui.unit.dp+import androidx.compose.ui.unit.sp+import androidx.compose.ui.util.fastRoundToInt+import androidx.compose.ui.util.lerp+import com.kyant.backdrop.catalog.BackdropDemoScaffold+import com.kyant.backdrop.catalog.Block+import com.kyant.backdrop.catalog.utils.scale+import com.kyant.backdrop.drawBackdrop+import com.kyant.backdrop.effects.blur+import com.kyant.backdrop.effects.colorControls+import com.kyant.backdrop.effects.lens+import com.kyant.backdrop.highlight.Highlight+import com.kyant.shapes.RoundedRectangle+import kotlinx.coroutines.isActive+import kotlinx.coroutines.launch+import kotlin.math.PI+import kotlin.math.cos+import kotlin.math.sign+import kotlin.math.sin++@Composable+fun AdaptiveLuminanceGlassContent() {+ val isLightTheme = !isSystemInDarkTheme()++ val layer = rememberGraphicsLayer()+ val luminanceAnimation = remember(isLightTheme) {+ Animatable(if (isLightTheme) 1f else 0f)+ }+ val contentColorAnimation = remember(isLightTheme) {+ Animatable(if (isLightTheme) Color.Black else Color.White)+ }+ LaunchedEffect(layer) {+ val buffer = IntArray(25)+ while (isActive) {+ val imageBitmap = layer.toImageBitmap()+ val thumbnail = imageBitmap.scale(5, 5)+ thumbnail.readPixels(buffer)+ val averageLuminance =+ buffer.sumOf { argb ->+ val r = (argb shr 16 and 0xFF) / 255f+ val g = (argb shr 8 and 0xFF) / 255f+ val b = (argb and 0xFF) / 255f+ 0.2126 * r + 0.7152 * g + 0.0722 * b+ } / buffer.size+ launch {+ contentColorAnimation.animateTo(+ if (averageLuminance > 0.5f) Color.Black else Color.White,+ tween(1000)+ )+ }+ luminanceAnimation.animateTo(+ averageLuminance.toFloat(),+ tween(1000)+ )+ }+ }++ val animationScope = rememberCoroutineScope()+ val offsetAnimation = remember { Animatable(Offset.Zero, Offset.VectorConverter) }+ val zoomAnimation = remember { Animatable(1f) }+ val rotationAnimation = remember { Animatable(0f) }++ BackdropDemoScaffold(content = { backdrop ->+ Box(+ Modifier+ .drawBackdrop(+ backdrop = backdrop,+ shape = { RoundedRectangle(24f.dp) },+ effects = {+ val l = (luminanceAnimation.value * 2f - 1f).let { sign(it) * it * it }+ colorControls(+ brightness =+ if (l > 0f) lerp(0.1f, 0.5f, l)+ else lerp(0.1f, -0.2f, -l),+ contrast =+ if (l > 0f) lerp(1f, 0f, l)+ else 1f,+ saturation = 1.5f+ )+ blur(+ if (l > 0f) lerp(8f.dp.toPx(), 16f.dp.toPx(), l)+ else lerp(8f.dp.toPx(), 2f.dp.toPx(), -l)+ )+ lens(24f.dp.toPx(), size.minDimension / 2f, depthEffect = true)+ },+ highlight = { Highlight.Plain },+ layerBlock = {+ val offset = offsetAnimation.value+ val zoom = zoomAnimation.value+ val rotation = rotationAnimation.value+ translationX = offset.x+ translationY = offset.y+ scaleX = zoom+ scaleY = zoom+ rotationZ = rotation+ transformOrigin = TransformOrigin(0.5f, 0.5f)+ },+ onDrawBackdrop = { drawBackdrop ->+ drawBackdrop()+ layer.record { drawBackdrop() }+ }+ )+ .pointerInput(animationScope) {+ fun Offset.rotateBy(angle: Float): Offset {+ val angleInRadians = angle * (PI / 180)+ val cos = cos(angleInRadians)+ val sin = sin(angleInRadians)+ return Offset((x * cos - y * sin).toFloat(), (x * sin + y * cos).toFloat())+ }++ detectTransformGestures { centroid, pan, gestureZoom, gestureRotate ->+ val offset = offsetAnimation.value+ val zoom = zoomAnimation.value+ val rotation = rotationAnimation.value++ val targetZoom = zoom * gestureZoom+ val targetRotation = rotation + gestureRotate+ val targetOffset = offset + pan.rotateBy(targetRotation) * targetZoom++ animationScope.launch {+ offsetAnimation.snapTo(targetOffset)+ zoomAnimation.snapTo(targetZoom)+ rotationAnimation.snapTo(targetRotation)+ }+ }+ }+ .size(160f.dp),+ contentAlignment = Alignment.Center+ ) {+ Block {+ BasicText(+ "luminance:\n${(luminanceAnimation.value * 100f).fastRoundToInt() / 100.0}",+ style = TextStyle(Color.Unspecified, 16f.sp, textAlign = TextAlign.Center),+ color = { contentColorAnimation.value }+ )+ }+ }+ })+}diff --git a/AndroidLiquidGlass-kmp/app/src/commonMain/kotlin/com/kyant/backdrop/catalog/destinations/BottomTabsContent.kt b/AndroidLiquidGlass-kmp/app/src/commonMain/kotlin/com/kyant/backdrop/catalog/destinations/BottomTabsContent.ktnew file mode 100644index 0000000..e778356--- /dev/null+++ b/AndroidLiquidGlass-kmp/app/src/commonMain/kotlin/com/kyant/backdrop/catalog/destinations/BottomTabsContent.kt@@ -0,0 +1,91 @@+package com.kyant.backdrop.catalog.destinations++import androidx.compose.foundation.isSystemInDarkTheme+import androidx.compose.foundation.layout.Arrangement+import androidx.compose.foundation.layout.Box+import androidx.compose.foundation.layout.Column+import androidx.compose.foundation.layout.padding+import androidx.compose.foundation.layout.size+import androidx.compose.foundation.text.BasicText+import androidx.compose.runtime.Composable+import androidx.compose.runtime.getValue+import androidx.compose.runtime.mutableIntStateOf+import androidx.compose.runtime.saveable.rememberSaveable+import androidx.compose.runtime.setValue+import androidx.compose.ui.Modifier+import androidx.compose.ui.draw.paint+import androidx.compose.ui.graphics.Color+import androidx.compose.ui.graphics.ColorFilter+import androidx.compose.ui.graphics.vector.rememberVectorPainter+import androidx.compose.ui.text.TextStyle+import androidx.compose.ui.unit.dp+import androidx.compose.ui.unit.sp+import com.kyant.backdrop.catalog.BackdropDemoScaffold+import com.kyant.backdrop.catalog.Block+import com.kyant.backdrop.catalog.FlightIcon+import com.kyant.backdrop.catalog.components.LiquidBottomTab+import com.kyant.backdrop.catalog.components.LiquidBottomTabs++@Composable+fun BottomTabsContent() {+ val isLightTheme = !isSystemInDarkTheme()+ val contentColor = if (isLightTheme) Color.Black else Color.White++ val airplaneModeIcon = rememberVectorPainter(FlightIcon)+ val iconColorFilter = ColorFilter.tint(contentColor)++ BackdropDemoScaffold { backdrop ->+ Column(verticalArrangement = Arrangement.spacedBy(32f.dp)) {+ Block {+ var selectedTabIndex by rememberSaveable { mutableIntStateOf(0) }++ LiquidBottomTabs(+ selectedTabIndex = { selectedTabIndex },+ onTabSelected = { selectedTabIndex = it },+ backdrop = backdrop,+ tabsCount = 3,+ modifier = Modifier.padding(horizontal = 36f.dp)+ ) {+ repeat(3) { index ->+ LiquidBottomTab({ selectedTabIndex = index }) {+ Box(+ Modifier+ .size(28f.dp)+ .paint(airplaneModeIcon, colorFilter = iconColorFilter)+ )+ BasicText(+ "Tab ${index + 1}",+ style = TextStyle(contentColor, 12f.sp)+ )+ }+ }+ }+ }+ Block {+ var selectedTabIndex by rememberSaveable { mutableIntStateOf(0) }++ LiquidBottomTabs(+ selectedTabIndex = { selectedTabIndex },+ onTabSelected = { selectedTabIndex = it },+ backdrop = backdrop,+ tabsCount = 4,+ modifier = Modifier.padding(horizontal = 36f.dp)+ ) {+ repeat(4) { index ->+ LiquidBottomTab({ selectedTabIndex = index }) {+ Box(+ Modifier+ .size(28f.dp)+ .paint(airplaneModeIcon, colorFilter = iconColorFilter)+ )+ BasicText(+ "Tab ${index + 1}",+ style = TextStyle(contentColor, 12f.sp)+ )+ }+ }+ }+ }+ }+ }+}diff --git a/AndroidLiquidGlass-kmp/app/src/commonMain/kotlin/com/kyant/backdrop/catalog/destinations/ButtonsContent.kt b/AndroidLiquidGlass-kmp/app/src/commonMain/kotlin/com/kyant/backdrop/catalog/destinations/ButtonsContent.ktnew file mode 100644index 0000000..27e0d82--- /dev/null+++ b/AndroidLiquidGlass-kmp/app/src/commonMain/kotlin/com/kyant/backdrop/catalog/destinations/ButtonsContent.kt@@ -0,0 +1,63 @@+package com.kyant.backdrop.catalog.destinations++import androidx.compose.foundation.layout.Arrangement+import androidx.compose.foundation.layout.Column+import androidx.compose.foundation.text.BasicText+import androidx.compose.runtime.Composable+import androidx.compose.ui.Alignment+import androidx.compose.ui.graphics.Color+import androidx.compose.ui.text.TextStyle+import androidx.compose.ui.unit.dp+import androidx.compose.ui.unit.sp+import com.kyant.backdrop.catalog.BackdropDemoScaffold+import com.kyant.backdrop.catalog.components.LiquidButton++@Composable+fun ButtonsContent() {+ BackdropDemoScaffold { backdrop ->+ Column(+ horizontalAlignment = Alignment.CenterHorizontally,+ verticalArrangement = Arrangement.spacedBy(16f.dp)+ ) {+ LiquidButton(+ {},+ backdrop+ ) {+ BasicText(+ "Transparent Liquid Button",+ style = TextStyle(Color.Black, 15f.sp)+ )+ }+ LiquidButton(+ {},+ backdrop,+ surfaceColor = Color.White.copy(0.3f)+ ) {+ BasicText(+ "Surface Liquid Button",+ style = TextStyle(Color.Black, 15f.sp)+ )+ }+ LiquidButton(+ {},+ backdrop,+ tint = Color(0xFF0088FF)+ ) {+ BasicText(+ "Tinted Liquid Button",+ style = TextStyle(Color.White, 15f.sp)+ )+ }+ LiquidButton(+ {},+ backdrop,+ tint = Color(0xFFFF8D28)+ ) {+ BasicText(+ "Tinted Liquid Button",+ style = TextStyle(Color.White, 15f.sp)+ )+ }+ }+ }+}diff --git a/AndroidLiquidGlass-kmp/app/src/commonMain/kotlin/com/kyant/backdrop/catalog/destinations/ControlCenterContent.kt b/AndroidLiquidGlass-kmp/app/src/commonMain/kotlin/com/kyant/backdrop/catalog/destinations/ControlCenterContent.ktnew file mode 100644index 0000000..9ed271c--- /dev/null+++ b/AndroidLiquidGlass-kmp/app/src/commonMain/kotlin/com/kyant/backdrop/catalog/destinations/ControlCenterContent.kt@@ -0,0 +1,443 @@+package com.kyant.backdrop.catalog.destinations++import androidx.compose.animation.core.Animatable+import androidx.compose.animation.core.EaseIn+import androidx.compose.animation.core.spring+import androidx.compose.foundation.background+import androidx.compose.foundation.gestures.Orientation+import androidx.compose.foundation.gestures.draggable+import androidx.compose.foundation.gestures.rememberDraggableState+import androidx.compose.foundation.isSystemInDarkTheme+import androidx.compose.foundation.layout.Arrangement+import androidx.compose.foundation.layout.Box+import androidx.compose.foundation.layout.Column+import androidx.compose.foundation.layout.Row+import androidx.compose.foundation.layout.Spacer+import androidx.compose.foundation.layout.displayCutoutPadding+import androidx.compose.foundation.layout.fillMaxSize+import androidx.compose.foundation.layout.padding+import androidx.compose.foundation.layout.size+import androidx.compose.foundation.layout.systemBarsPadding+import androidx.compose.runtime.Composable+import androidx.compose.runtime.derivedStateOf+import androidx.compose.runtime.getValue+import androidx.compose.runtime.remember+import androidx.compose.runtime.rememberCoroutineScope+import androidx.compose.ui.Alignment+import androidx.compose.ui.Modifier+import androidx.compose.ui.draw.clip+import androidx.compose.ui.draw.drawWithContent+import androidx.compose.ui.draw.paint+import androidx.compose.ui.draw.scale+import androidx.compose.ui.graphics.BlurEffect+import androidx.compose.ui.graphics.Color+import androidx.compose.ui.graphics.ColorFilter+import androidx.compose.ui.graphics.GraphicsLayerScope+import androidx.compose.ui.graphics.drawscope.DrawScope+import androidx.compose.ui.graphics.graphicsLayer+import androidx.compose.ui.graphics.vector.rememberVectorPainter+import androidx.compose.ui.layout.layout+import androidx.compose.ui.unit.dp+import androidx.compose.ui.util.fastCoerceAtLeast+import androidx.compose.ui.util.fastCoerceIn+import androidx.compose.ui.util.fastRoundToInt+import com.kyant.backdrop.BackdropEffectScope+import com.kyant.backdrop.catalog.BackdropDemoScaffold+import com.kyant.backdrop.catalog.FlightIcon+import com.kyant.backdrop.catalog.utils.ProgressConverter+import com.kyant.backdrop.catalog.utils.rememberUISensor+import com.kyant.backdrop.drawBackdrop+import com.kyant.backdrop.effects.lens+import com.kyant.backdrop.effects.vibrancy+import com.kyant.backdrop.highlight.Highlight+import com.kyant.backdrop.highlight.HighlightStyle+import com.kyant.shapes.Capsule+import com.kyant.shapes.RoundedRectangle+import kotlinx.coroutines.launch++@Composable+fun ControlCenterContent() {+ val isLightTheme = !isSystemInDarkTheme()+ val accentColor =+ if (isLightTheme) Color(0xFF0088FF)+ else Color(0xFF0091FF)+ val containerColor = Color.Black.copy(0.05f)+ val dimColor = Color.Black.copy(0.4f)++ val itemSpacing = 16f.dp+ val itemSize = 68f.dp+ val itemTwoSpanSize = itemSize * 2 + itemSpacing+ val itemShape = RoundedRectangle(itemSize / 2f)++ val innerItemSize = 56f.dp+ val innerItemShape = Capsule()+ val innerItemIconScale = 0.8f++ val inactiveItemColor = Color.White.copy(0.2f)+ val activeItemColor = accentColor++ val airplaneModeIcon = rememberVectorPainter(FlightIcon)+ val iconColorFilter = ColorFilter.tint(Color.White)++ val animationScope = rememberCoroutineScope()+ val enterProgressAnimation = remember { Animatable(1f) }+ val safeEnterProgressAnimation = remember { Animatable(1f) }+ val progress by remember {+ derivedStateOf {+ val progress = enterProgressAnimation.value+ when {+ progress < 0f -> ProgressConverter.Default.convert(progress)+ progress <= 1f -> progress+ else -> 1f + ProgressConverter.Default.convert(progress - 1f)+ }+ }+ }+ val maxDragHeight = 1000f++ val uiSensor = rememberUISensor()+ val glassShape = { itemShape }+ val glassHighlight = {+ Highlight(+ style = HighlightStyle.Default(+ angle = uiSensor.gravityAngle,+ falloff = 2f+ )+ )+ }+ val glassLayer: GraphicsLayerScope.() -> Unit = {+ val progress = progress+ val safeProgress = safeEnterProgressAnimation.value+ translationY = -48f.dp.toPx() * (1f - progress)+ alpha = EaseIn.transform(safeProgress)+ scaleX /= 1f + 0.1f * (progress - 1f).fastCoerceAtLeast(0f)+ scaleY *= 1f + 0.1f * (progress - 1f).fastCoerceAtLeast(0f)+ }+ val glassSurface: DrawScope.() -> Unit = { drawRect(containerColor) }+ val glassEffects: BackdropEffectScope.() -> Unit = {+ val progress = safeEnterProgressAnimation.value+ vibrancy()+ lens(+ 24f.dp.toPx() * progress,+ 48f.dp.toPx() * progress,+ depthEffect = true+ )+ }++ val spacerLayoutModifier = Modifier.layout { measurable, constraints ->+ val placeable = measurable.measure(constraints)+ val progress = progress+ val height =+ itemSpacing.roundToPx() ++ (32f.dp.toPx() * (progress - 1f).fastCoerceAtLeast(0f)).fastRoundToInt()+ layout(constraints.minWidth, height) {+ placeable.place(0, 0)+ }+ }+ val smallSpacerLayoutModifier = Modifier.layout { measurable, constraints ->+ val placeable = measurable.measure(constraints)+ val progress = progress+ val height =+ itemSpacing.roundToPx() ++ (16f.dp.toPx() * (progress - 1f).fastCoerceAtLeast(0f)).fastRoundToInt()+ layout(constraints.minWidth, height) {+ placeable.place(0, 0)+ }+ }++ val backdropModifier = Modifier+ .draggable(+ rememberDraggableState { delta ->+ val targetProgress = enterProgressAnimation.value + delta / maxDragHeight+ animationScope.launch {+ launch {+ enterProgressAnimation.snapTo(targetProgress)+ }+ launch {+ safeEnterProgressAnimation.snapTo(targetProgress.fastCoerceIn(0f, 1f))+ }+ }+ },+ Orientation.Vertical,+ onDragStopped = { velocity ->+ val targetProgress = when {+ velocity < 0f -> 0f+ velocity > 0f -> 1f+ else -> if (enterProgressAnimation.value < 0.5f) 0f else 1f+ }+ animationScope.launch {+ launch {+ enterProgressAnimation.animateTo(+ targetProgress,+ if (targetProgress > 0.5f) {+ spring(0.5f, 300f, 0.5f / maxDragHeight)+ } else {+ spring(1f, 300f, 0.01f)+ },+ velocity / maxDragHeight+ )+ }+ launch {+ safeEnterProgressAnimation.animateTo(+ targetProgress,+ spring(1f, 300f, 0.01f)+ )+ }+ }+ }+ )+ .drawWithContent {+ val progress = safeEnterProgressAnimation.value++ drawContent()+ drawRect(dimColor.copy(dimColor.alpha * progress))+ }+ .graphicsLayer {+ val progress = safeEnterProgressAnimation.value++ val blurRadius = 4f.dp.toPx() * progress+ if (blurRadius > 0f) {+ renderEffect = BlurEffect(blurRadius, blurRadius)+ }+ }++ BackdropDemoScaffold(backdropModifier) { backdrop ->+ Column(+ Modifier+ .padding(top = 80f.dp)+ .systemBarsPadding()+ .displayCutoutPadding()+ .fillMaxSize(),+ horizontalAlignment = Alignment.CenterHorizontally+ ) {+ Row(+ horizontalArrangement = Arrangement.spacedBy(itemSpacing),+ verticalAlignment = Alignment.CenterVertically+ ) {+ Box(+ Modifier+ .drawBackdrop(+ backdrop = backdrop,+ shape = glassShape,+ effects = glassEffects,+ highlight = glassHighlight,+ shadow = null,+ layerBlock = glassLayer,+ onDrawSurface = glassSurface+ )+ .size(itemTwoSpanSize)+ .padding(itemSpacing)+ ) {+ Box(+ Modifier+ .clip(innerItemShape)+ .background(inactiveItemColor)+ .scale(innerItemIconScale)+ .paint(airplaneModeIcon, colorFilter = iconColorFilter)+ .size(innerItemSize)+ .align(Alignment.TopStart)+ )+ Box(+ Modifier+ .clip(innerItemShape)+ .background(activeItemColor)+ .scale(innerItemIconScale)+ .paint(airplaneModeIcon, colorFilter = iconColorFilter)+ .size(innerItemSize)+ .align(Alignment.TopEnd)+ )+ Box(+ Modifier+ .clip(innerItemShape)+ .background(activeItemColor)+ .scale(innerItemIconScale)+ .paint(airplaneModeIcon, colorFilter = iconColorFilter)+ .size(innerItemSize)+ .align(Alignment.BottomStart)+ )+ }+ Box(+ Modifier+ .drawBackdrop(+ backdrop = backdrop,+ shape = glassShape,+ effects = glassEffects,+ highlight = glassHighlight,+ shadow = null,+ layerBlock = glassLayer,+ onDrawSurface = glassSurface+ )+ .size(itemTwoSpanSize)+ )+ }++ Spacer(spacerLayoutModifier)++ Row(+ horizontalArrangement = Arrangement.spacedBy(itemSpacing, Alignment.CenterHorizontally),+ verticalAlignment = Alignment.CenterVertically+ ) {+ Column {+ Row(+ horizontalArrangement = Arrangement.spacedBy(itemSpacing),+ verticalAlignment = Alignment.CenterVertically+ ) {+ Box(+ Modifier+ .drawBackdrop(+ backdrop = backdrop,+ shape = glassShape,+ effects = glassEffects,+ highlight = glassHighlight,+ shadow = null,+ layerBlock = glassLayer,+ onDrawSurface = glassSurface+ )+ .paint(airplaneModeIcon, colorFilter = iconColorFilter)+ .size(itemSize)+ )+ Box(+ Modifier+ .drawBackdrop(+ backdrop = backdrop,+ shape = glassShape,+ effects = glassEffects,+ highlight = glassHighlight,+ shadow = null,+ layerBlock = glassLayer,+ onDrawSurface = glassSurface+ )+ .paint(airplaneModeIcon, colorFilter = iconColorFilter)+ .size(itemSize)+ )+ }++ Spacer(smallSpacerLayoutModifier)++ Box(+ Modifier+ .drawBackdrop(+ backdrop = backdrop,+ shape = glassShape,+ effects = glassEffects,+ highlight = glassHighlight,+ shadow = null,+ layerBlock = glassLayer+ )+ .size(itemTwoSpanSize, itemSize)+ )+ }++ Row(+ horizontalArrangement = Arrangement.spacedBy(itemSpacing),+ verticalAlignment = Alignment.CenterVertically+ ) {+ Box(+ Modifier+ .drawBackdrop(+ backdrop = backdrop,+ shape = glassShape,+ effects = glassEffects,+ highlight = glassHighlight,+ shadow = null,+ layerBlock = glassLayer,+ onDrawSurface = glassSurface+ )+ .size(itemSize, itemTwoSpanSize)+ )+ Box(+ Modifier+ .drawBackdrop(+ backdrop = backdrop,+ shape = glassShape,+ effects = glassEffects,+ highlight = glassHighlight,+ shadow = null,+ layerBlock = glassLayer,+ onDrawSurface = glassSurface+ )+ .size(itemSize, itemTwoSpanSize)+ )+ }+ }++ Spacer(spacerLayoutModifier)++ Row(+ horizontalArrangement = Arrangement.spacedBy(itemSpacing),+ verticalAlignment = Alignment.CenterVertically+ ) {+ Box(+ Modifier+ .drawBackdrop(+ backdrop = backdrop,+ shape = glassShape,+ effects = glassEffects,+ highlight = glassHighlight,+ shadow = null,+ layerBlock = glassLayer,+ onDrawSurface = glassSurface+ )+ .size(itemTwoSpanSize)+ )++ Column {+ Row(+ horizontalArrangement = Arrangement.spacedBy(itemSpacing),+ verticalAlignment = Alignment.CenterVertically+ ) {+ Box(+ Modifier+ .drawBackdrop(+ backdrop = backdrop,+ shape = glassShape,+ effects = glassEffects,+ highlight = glassHighlight,+ shadow = null,+ layerBlock = glassLayer,+ onDrawSurface = glassSurface+ )+ .paint(airplaneModeIcon, colorFilter = iconColorFilter)+ .size(itemSize)+ )+ Box(+ Modifier+ .drawBackdrop(+ backdrop = backdrop,+ shape = glassShape,+ effects = glassEffects,+ highlight = glassHighlight,+ shadow = null,+ layerBlock = glassLayer,+ onDrawSurface = glassSurface+ )+ .paint(airplaneModeIcon, colorFilter = iconColorFilter)+ .size(itemSize)+ )+ }++ Spacer(smallSpacerLayoutModifier)++ Row(+ horizontalArrangement = Arrangement.spacedBy(itemSpacing),+ verticalAlignment = Alignment.CenterVertically+ ) {+ Box(+ Modifier+ .drawBackdrop(+ backdrop = backdrop,+ shape = glassShape,+ effects = glassEffects,+ highlight = glassHighlight,+ shadow = null,+ layerBlock = glassLayer,+ onDrawSurface = glassSurface+ )+ .paint(airplaneModeIcon, colorFilter = iconColorFilter)+ .size(itemSize)+ )+ }+ }+ }+ }+ }+}diff --git a/AndroidLiquidGlass-kmp/app/src/commonMain/kotlin/com/kyant/backdrop/catalog/destinations/DialogContent.kt b/AndroidLiquidGlass-kmp/app/src/commonMain/kotlin/com/kyant/backdrop/catalog/destinations/DialogContent.ktnew file mode 100644index 0000000..ee4ee1a--- /dev/null+++ b/AndroidLiquidGlass-kmp/app/src/commonMain/kotlin/com/kyant/backdrop/catalog/destinations/DialogContent.kt@@ -0,0 +1,139 @@+package com.kyant.backdrop.catalog.destinations++import androidx.compose.foundation.background+import androidx.compose.foundation.clickable+import androidx.compose.foundation.isSystemInDarkTheme+import androidx.compose.foundation.layout.Arrangement+import androidx.compose.foundation.layout.Column+import androidx.compose.foundation.layout.Row+import androidx.compose.foundation.layout.fillMaxWidth+import androidx.compose.foundation.layout.height+import androidx.compose.foundation.layout.padding+import androidx.compose.foundation.text.BasicText+import androidx.compose.runtime.Composable+import androidx.compose.ui.Alignment+import androidx.compose.ui.Modifier+import androidx.compose.ui.draw.clip+import androidx.compose.ui.draw.drawWithContent+import androidx.compose.ui.graphics.BlendMode+import androidx.compose.ui.graphics.Color+import androidx.compose.ui.graphics.graphicsLayer+import androidx.compose.ui.text.TextStyle+import androidx.compose.ui.text.font.FontWeight+import androidx.compose.ui.unit.dp+import androidx.compose.ui.unit.sp+import com.kyant.backdrop.catalog.BackdropDemoScaffold+import com.kyant.backdrop.catalog.utils.LoremIpsum+import com.kyant.backdrop.drawBackdrop+import com.kyant.backdrop.effects.blur+import com.kyant.backdrop.effects.colorControls+import com.kyant.backdrop.effects.lens+import com.kyant.backdrop.highlight.Highlight+import com.kyant.shapes.Capsule+import com.kyant.shapes.RoundedRectangle++@Composable+fun DialogContent() {+ val isLightTheme = !isSystemInDarkTheme()+ val contentColor = if (isLightTheme) Color.Black else Color.White+ val accentColor =+ if (isLightTheme) Color(0xFF0088FF)+ else Color(0xFF0091FF)+ val containerColor =+ if (isLightTheme) Color(0xFFFAFAFA).copy(0.6f)+ else Color(0xFF121212).copy(0.4f)+ val dimColor =+ if (isLightTheme) Color(0xFF29293A).copy(0.23f)+ else Color(0xFF121212).copy(0.56f)++ BackdropDemoScaffold(+ Modifier.drawWithContent {+ drawContent()+ drawRect(dimColor)+ }+ ) { backdrop ->+ Column(+ Modifier+ .padding(40f.dp)+ .drawBackdrop(+ backdrop = backdrop,+ shape = { RoundedRectangle(48f.dp) },+ effects = {+ colorControls(+ brightness = if (isLightTheme) 0.2f else 0f,+ saturation = 1.5f+ )+ blur(if (isLightTheme) 16f.dp.toPx() else 8f.dp.toPx())+ lens(24f.dp.toPx(), 48f.dp.toPx(), depthEffect = true)+ },+ highlight = { Highlight.Plain },+ onDrawSurface = { drawRect(containerColor) }+ )+ .fillMaxWidth()+ ) {+ BasicText(+ "Dialog Title",+ Modifier.padding(28f.dp, 24f.dp, 28f.dp, 12f.dp),+ style = TextStyle(contentColor, 24f.sp, FontWeight.Medium)+ )++ BasicText(+ LoremIpsum,+ Modifier+ .then(+ if (isLightTheme) {+ // plus darker+ Modifier+ } else {+ // plus lighter+ Modifier.graphicsLayer(blendMode = BlendMode.Plus)+ }+ )+ .padding(24f.dp, 12f.dp, 24f.dp, 12f.dp),+ style = TextStyle(contentColor.copy(0.68f), 15f.sp),+ maxLines = 5+ )++ Row(+ Modifier+ .padding(24f.dp, 12f.dp, 24f.dp, 24f.dp)+ .fillMaxWidth(),+ horizontalArrangement = Arrangement.spacedBy(16f.dp),+ verticalAlignment = Alignment.CenterVertically+ ) {+ Row(+ Modifier+ .clip(Capsule())+ .background(containerColor.copy(0.2f))+ .clickable {}+ .height(48f.dp)+ .weight(1f)+ .padding(horizontal = 16f.dp),+ horizontalArrangement = Arrangement.spacedBy(4f.dp, Alignment.CenterHorizontally),+ verticalAlignment = Alignment.CenterVertically+ ) {+ BasicText(+ "Cancel",+ style = TextStyle(contentColor, 16f.sp)+ )+ }+ Row(+ Modifier+ .clip(Capsule())+ .background(accentColor)+ .clickable {}+ .height(48f.dp)+ .weight(1f)+ .padding(horizontal = 16f.dp),+ horizontalArrangement = Arrangement.spacedBy(4f.dp, Alignment.CenterHorizontally),+ verticalAlignment = Alignment.CenterVertically+ ) {+ BasicText(+ "Okay",+ style = TextStyle(Color.White, 16f.sp)+ )+ }+ }+ }+ }+}diff --git a/AndroidLiquidGlass-kmp/app/src/commonMain/kotlin/com/kyant/backdrop/catalog/destinations/GlassPlaygroundContent.kt b/AndroidLiquidGlass-kmp/app/src/commonMain/kotlin/com/kyant/backdrop/catalog/destinations/GlassPlaygroundContent.ktnew file mode 100644index 0000000..290bdc4--- /dev/null+++ b/AndroidLiquidGlass-kmp/app/src/commonMain/kotlin/com/kyant/backdrop/catalog/destinations/GlassPlaygroundContent.kt@@ -0,0 +1,241 @@+package com.kyant.backdrop.catalog.destinations++import androidx.compose.animation.core.Animatable+import androidx.compose.animation.core.VectorConverter+import androidx.compose.foundation.gestures.detectTransformGestures+import androidx.compose.foundation.layout.Arrangement+import androidx.compose.foundation.layout.Box+import androidx.compose.foundation.layout.Column+import androidx.compose.foundation.layout.navigationBarsPadding+import androidx.compose.foundation.layout.padding+import androidx.compose.foundation.layout.size+import androidx.compose.foundation.layout.statusBarsPadding+import androidx.compose.foundation.text.BasicText+import androidx.compose.runtime.Composable+import androidx.compose.runtime.getValue+import androidx.compose.runtime.mutableFloatStateOf+import androidx.compose.runtime.mutableStateOf+import androidx.compose.runtime.remember+import androidx.compose.runtime.rememberCoroutineScope+import androidx.compose.runtime.setValue+import androidx.compose.ui.Alignment+import androidx.compose.ui.Modifier+import androidx.compose.ui.geometry.Offset+import androidx.compose.ui.graphics.Color+import androidx.compose.ui.input.pointer.pointerInput+import androidx.compose.ui.text.TextStyle+import androidx.compose.ui.unit.dp+import androidx.compose.ui.unit.sp+import com.kyant.backdrop.backdrops.rememberLayerBackdrop+import com.kyant.backdrop.catalog.BackdropDemoScaffold+import com.kyant.backdrop.catalog.Block+import com.kyant.backdrop.catalog.components.LiquidButton+import com.kyant.backdrop.catalog.components.LiquidSlider+import com.kyant.backdrop.drawBackdrop+import com.kyant.backdrop.effects.blur+import com.kyant.backdrop.effects.lens+import com.kyant.backdrop.effects.vibrancy+import com.kyant.backdrop.highlight.Highlight+import com.kyant.shapes.RoundedRectangle+import kotlinx.coroutines.launch+import kotlin.math.PI+import kotlin.math.cos+import kotlin.math.sin++@Composable+fun GlassPlaygroundContent() {+ val animationScope = rememberCoroutineScope()+ val offsetAnimation = remember { Animatable(Offset.Zero, Offset.VectorConverter) }+ val zoomAnimation = remember { Animatable(1f) }+ val rotationAnimation = remember { Animatable(0f) }++ var isSheetExpanded by remember { mutableStateOf(true) }++ var cornerRadiusFrac by remember { mutableFloatStateOf(0.5f) }+ var blurRadiusDp by remember { mutableFloatStateOf(0f) }+ var refractionHeightFrac by remember { mutableFloatStateOf(0.2f) }+ var refractionAmountFrac by remember { mutableFloatStateOf(0.2f) }+ var chromaticAberration by remember { mutableFloatStateOf(0f) }++ BackdropDemoScaffold { backdrop ->+ Box(+ Modifier+ .padding(top = 48f.dp)+ .statusBarsPadding()+ .drawBackdrop(+ backdrop = backdrop,+ shape = { RoundedRectangle(256f.dp / 2f * cornerRadiusFrac) },+ effects = {+ val minDimension = size.minDimension+ vibrancy()+ blur(blurRadiusDp.dp.toPx())+ lens(+ refractionHeight = refractionHeightFrac * minDimension * 0.5f,+ refractionAmount = refractionAmountFrac * minDimension,+ depthEffect = true,+ chromaticAberration = chromaticAberration > 0f+ )+ },+ highlight = { Highlight.Plain },+ layerBlock = {+ val offset = offsetAnimation.value+ val zoom = zoomAnimation.value+ val rotation = rotationAnimation.value+ translationX = offset.x+ translationY = offset.y+ scaleX = zoom+ scaleY = zoom+ rotationZ = rotation+ }+ )+ .pointerInput(animationScope) {+ fun Offset.rotateBy(angle: Float): Offset {+ val angleInRadians = angle * (PI / 180)+ val cos = cos(angleInRadians)+ val sin = sin(angleInRadians)+ return Offset((x * cos - y * sin).toFloat(), (x * sin + y * cos).toFloat())+ }++ detectTransformGestures { centroid, pan, gestureZoom, gestureRotate ->+ val offset = offsetAnimation.value+ val zoom = zoomAnimation.value+ val rotation = rotationAnimation.value++ val targetZoom = zoom * gestureZoom+ val targetRotation = rotation + gestureRotate+ val targetOffset = offset + pan.rotateBy(targetRotation) * targetZoom++ animationScope.launch {+ offsetAnimation.snapTo(targetOffset)+ zoomAnimation.snapTo(targetZoom)+ rotationAnimation.snapTo(targetRotation)+ }+ }+ }+ .size(256f.dp)+ .align(Alignment.TopCenter)+ )++ Block {+ if (isSheetExpanded) {+ val sheetBackdrop = rememberLayerBackdrop()+ Column(+ Modifier+ .padding(16f.dp)+ .padding(bottom = 72f.dp)+ .navigationBarsPadding()+ .drawBackdrop(+ backdrop = backdrop,+ shape = { RoundedRectangle(32f.dp) },+ effects = {+ vibrancy()+ blur(4f.dp.toPx())+ lens(16f.dp.toPx(), 32f.dp.toPx())+ },+ highlight = { Highlight.Plain },+ exportedBackdrop = sheetBackdrop,+ onDrawSurface = { drawRect(Color.White.copy(alpha = 0.5f)) }+ )+ .padding(24f.dp)+ .align(Alignment.BottomCenter),+ horizontalAlignment = Alignment.CenterHorizontally,+ verticalArrangement = Arrangement.spacedBy(16f.dp)+ ) {+ Column(verticalArrangement = Arrangement.spacedBy(8f.dp)) {+ BasicText("Corner radius")+ LiquidSlider(+ value = { cornerRadiusFrac },+ onValueChange = { cornerRadiusFrac = it },+ valueRange = 0f..1f,+ visibilityThreshold = 0.001f,+ backdrop = sheetBackdrop+ )+ }+ Column(verticalArrangement = Arrangement.spacedBy(8f.dp)) {+ BasicText("Blur radius")+ LiquidSlider(+ value = { blurRadiusDp },+ onValueChange = { blurRadiusDp = it },+ valueRange = 0f..32f,+ visibilityThreshold = 0.01f,+ backdrop = sheetBackdrop+ )+ }+ Column(verticalArrangement = Arrangement.spacedBy(8f.dp)) {+ BasicText("Refraction height")+ LiquidSlider(+ value = { refractionHeightFrac },+ onValueChange = { refractionHeightFrac = it },+ valueRange = 0f..1f,+ visibilityThreshold = 0.001f,+ backdrop = sheetBackdrop+ )+ }+ Column(verticalArrangement = Arrangement.spacedBy(8f.dp)) {+ BasicText("Refraction amount")+ LiquidSlider(+ value = { refractionAmountFrac },+ onValueChange = { refractionAmountFrac = it },+ valueRange = 0f..1f,+ visibilityThreshold = 0.001f,+ backdrop = sheetBackdrop+ )+ }+ Column(verticalArrangement = Arrangement.spacedBy(8f.dp)) {+ BasicText("Chromatic aberration")+ LiquidSlider(+ value = { chromaticAberration },+ onValueChange = { chromaticAberration = it },+ valueRange = 0f..1f,+ visibilityThreshold = 0.001f,+ backdrop = sheetBackdrop+ )+ }+ }+ }+ }++ Block {+ LiquidButton(+ { isSheetExpanded = !isSheetExpanded },+ backdrop,+ Modifier+ .padding(20f.dp)+ .navigationBarsPadding()+ .align(Alignment.BottomStart),+ tint = Color(0xFFFF8D28)+ ) {+ BasicText(+ if (isSheetExpanded) "🔽" else "🔼",+ style = TextStyle(Color.White, 15f.sp)+ )+ }++ LiquidButton(+ {+ animationScope.launch {+ launch { offsetAnimation.animateTo(Offset.Zero) }+ launch { zoomAnimation.animateTo(1f) }+ launch { rotationAnimation.animateTo(0f) }+ }+ cornerRadiusFrac = 0.5f+ blurRadiusDp = 0f+ refractionHeightFrac = 0.2f+ refractionAmountFrac = 0.2f+ chromaticAberration = 0f+ },+ backdrop,+ Modifier+ .padding(20f.dp)+ .navigationBarsPadding()+ .align(Alignment.BottomEnd),+ tint = Color(0xFFFF8D28)+ ) {+ BasicText(+ "Reset",+ style = TextStyle(Color.White, 15f.sp)+ )+ }+ }+ }+}diff --git a/AndroidLiquidGlass-kmp/app/src/commonMain/kotlin/com/kyant/backdrop/catalog/destinations/HomeContent.kt b/AndroidLiquidGlass-kmp/app/src/commonMain/kotlin/com/kyant/backdrop/catalog/destinations/HomeContent.ktnew file mode 100644index 0000000..6ce2f2b--- /dev/null+++ b/AndroidLiquidGlass-kmp/app/src/commonMain/kotlin/com/kyant/backdrop/catalog/destinations/HomeContent.kt@@ -0,0 +1,93 @@+package com.kyant.backdrop.catalog.destinations++import androidx.compose.foundation.clickable+import androidx.compose.foundation.isSystemInDarkTheme+import androidx.compose.foundation.layout.Arrangement+import androidx.compose.foundation.layout.Column+import androidx.compose.foundation.layout.displayCutoutPadding+import androidx.compose.foundation.layout.fillMaxSize+import androidx.compose.foundation.layout.fillMaxWidth+import androidx.compose.foundation.layout.padding+import androidx.compose.foundation.layout.systemBarsPadding+import androidx.compose.foundation.rememberScrollState+import androidx.compose.foundation.text.BasicText+import androidx.compose.foundation.verticalScroll+import androidx.compose.runtime.Composable+import androidx.compose.ui.Modifier+import androidx.compose.ui.graphics.Color+import androidx.compose.ui.text.TextStyle+import androidx.compose.ui.text.font.FontWeight+import androidx.compose.ui.unit.dp+import androidx.compose.ui.unit.sp+import com.kyant.backdrop.catalog.CatalogDestination++@Composable+fun HomeContent(onNavigate: (CatalogDestination) -> Unit) {+ val isLightTheme = !isSystemInDarkTheme()+ val contentColor = if (isLightTheme) Color.Black else Color.White++ Column(+ Modifier+ .verticalScroll(rememberScrollState())+ .systemBarsPadding()+ .displayCutoutPadding()+ .fillMaxSize(),+ verticalArrangement = Arrangement.spacedBy(16f.dp)+ ) {+ BasicText(+ "Backdrop Catalog",+ Modifier.padding(16f.dp, 40f.dp, 16f.dp, 16f.dp),+ style = TextStyle(contentColor, 28f.sp, FontWeight.Medium)+ )++ Column {+ Subtitle("Liquid glass components")+ ListItem({ onNavigate(CatalogDestination.Buttons) }, "Buttons")+ ListItem({ onNavigate(CatalogDestination.Toggle) }, "Toggle")+ ListItem({ onNavigate(CatalogDestination.Slider) }, "Slider")+ ListItem({ onNavigate(CatalogDestination.BottomTabs) }, "Bottom tabs")+ ListItem({ onNavigate(CatalogDestination.Dialog) }, "Dialog")++ Subtitle("System UIs")+ ListItem({ onNavigate(CatalogDestination.LockScreen) }, "Lock screen (SDF texture)")+ ListItem({ onNavigate(CatalogDestination.ControlCenter) }, "Control center")+ ListItem({ onNavigate(CatalogDestination.Magnifier) }, "Magnifier")++ Subtitle("Experiments")+ ListItem({ onNavigate(CatalogDestination.GlassPlayground) }, "Glass playground")+ ListItem({ onNavigate(CatalogDestination.AdaptiveLuminanceGlass) }, "Adaptive luminance glass")+ ListItem({ onNavigate(CatalogDestination.ProgressiveBlur) }, "Progressive blur")+ ListItem({ onNavigate(CatalogDestination.ScrollContainer) }, "Scroll container")+ ListItem({ onNavigate(CatalogDestination.LazyScrollContainer) }, "Lazy scroll container")+ }+ }+}++@Composable+private fun Subtitle(label: String) {+ BasicText(+ label,+ Modifier+ .padding(16f.dp, 24f.dp, 16f.dp, 8f.dp)+ .fillMaxWidth(),+ style = TextStyle(Color(0xFF0088FF), 15f.sp, FontWeight.Medium)+ )+}++@Composable+private fun ListItem(+ onClick: () -> Unit,+ label: String+) {+ val isLightTheme = !isSystemInDarkTheme()+ val contentColor = if (isLightTheme) Color.Black else Color.White++ BasicText(+ label,+ Modifier+ .clickable(onClick = onClick)+ .padding(16f.dp)+ .fillMaxWidth(),+ style = TextStyle(contentColor, 17f.sp)+ )+}diff --git a/AndroidLiquidGlass-kmp/app/src/commonMain/kotlin/com/kyant/backdrop/catalog/destinations/LazyScrollContainerContent.kt b/AndroidLiquidGlass-kmp/app/src/commonMain/kotlin/com/kyant/backdrop/catalog/destinations/LazyScrollContainerContent.ktnew file mode 100644index 0000000..75143a0--- /dev/null+++ b/AndroidLiquidGlass-kmp/app/src/commonMain/kotlin/com/kyant/backdrop/catalog/destinations/LazyScrollContainerContent.kt@@ -0,0 +1,55 @@+package com.kyant.backdrop.catalog.destinations++import androidx.compose.foundation.layout.Arrangement+import androidx.compose.foundation.layout.Box+import androidx.compose.foundation.layout.PaddingValues+import androidx.compose.foundation.layout.Spacer+import androidx.compose.foundation.layout.WindowInsets+import androidx.compose.foundation.layout.fillMaxSize+import androidx.compose.foundation.layout.fillMaxWidth+import androidx.compose.foundation.layout.height+import androidx.compose.foundation.layout.systemBars+import androidx.compose.foundation.layout.windowInsetsBottomHeight+import androidx.compose.foundation.layout.windowInsetsTopHeight+import androidx.compose.foundation.lazy.LazyColumn+import androidx.compose.runtime.Composable+import androidx.compose.ui.Modifier+import androidx.compose.ui.unit.dp+import com.kyant.backdrop.catalog.BackdropDemoScaffold+import com.kyant.backdrop.drawBackdrop+import com.kyant.backdrop.effects.lens+import com.kyant.backdrop.effects.vibrancy+import com.kyant.shapes.RoundedRectangle++@Composable+fun LazyScrollContainerContent() {+ BackdropDemoScaffold { backdrop ->+ LazyColumn(+ Modifier.fillMaxSize(),+ contentPadding = PaddingValues(16f.dp),+ verticalArrangement = Arrangement.spacedBy(16f.dp)+ ) {+ item {+ Spacer(Modifier.windowInsetsTopHeight(WindowInsets.systemBars))+ }+ items(100) {+ Box(+ Modifier+ .drawBackdrop(+ backdrop = backdrop,+ shape = { RoundedRectangle(32f.dp) },+ effects = {+ vibrancy()+ lens(16f.dp.toPx(), 32f.dp.toPx())+ }+ )+ .height(160f.dp)+ .fillMaxWidth()+ )+ }+ item {+ Spacer(Modifier.windowInsetsBottomHeight(WindowInsets.systemBars))+ }+ }+ }+}diff --git a/AndroidLiquidGlass-kmp/app/src/commonMain/kotlin/com/kyant/backdrop/catalog/destinations/LockScreenContent.kt b/AndroidLiquidGlass-kmp/app/src/commonMain/kotlin/com/kyant/backdrop/catalog/destinations/LockScreenContent.ktnew file mode 100644index 0000000..91b1a89--- /dev/null+++ b/AndroidLiquidGlass-kmp/app/src/commonMain/kotlin/com/kyant/backdrop/catalog/destinations/LockScreenContent.kt@@ -0,0 +1,80 @@+package com.kyant.backdrop.catalog.destinations++import androidx.compose.foundation.background+import androidx.compose.foundation.gestures.draggable2D+import androidx.compose.foundation.gestures.rememberDraggable2DState+import androidx.compose.foundation.layout.Box+import androidx.compose.foundation.layout.Column+import androidx.compose.foundation.layout.aspectRatio+import androidx.compose.foundation.layout.fillMaxSize+import androidx.compose.foundation.layout.fillMaxWidth+import androidx.compose.foundation.layout.padding+import androidx.compose.foundation.layout.widthIn+import androidx.compose.runtime.Composable+import androidx.compose.runtime.getValue+import androidx.compose.runtime.mutableStateOf+import androidx.compose.runtime.remember+import androidx.compose.runtime.setValue+import androidx.compose.ui.Alignment+import androidx.compose.ui.Modifier+import androidx.compose.ui.geometry.Offset+import androidx.compose.ui.graphics.Color+import androidx.compose.ui.graphics.graphicsLayer+import androidx.compose.ui.unit.dp+import com.kyant.backdrop.catalog.BackdropDemoScaffold+import com.kyant.backdrop.catalog.utils.rememberSdfShader+import com.kyant.backdrop.drawPlainBackdrop+import com.kyant.backdrop.effects.blur+import com.kyant.backdrop.effects.colorControls+import com.kyant.shapes.Rectangle+import glass.app.generated.resources.Res+import glass.app.generated.resources.clock_sdf++@Composable+fun LockScreenContent() {+ BackdropDemoScaffold { backdrop ->+ var offset by remember { mutableStateOf(Offset.Zero) }+ val sdfShader = rememberSdfShader(Res.drawable.clock_sdf)++ Column(+ Modifier+ .background(Color.Black.copy(alpha = 0.3f))+ .fillMaxSize()+ ) {+ Box(+ Modifier+ .weight(1f)+ .fillMaxWidth(),+ contentAlignment = Alignment.Center+ ) {+ Box(+ Modifier+ .padding(horizontal = 48f.dp)+ .graphicsLayer {+ val offset = offset+ translationX = offset.x+ translationY = offset.y+ }+ .draggable2D(rememberDraggable2DState { delta -> offset += delta })+ .drawPlainBackdrop(+ backdrop = backdrop,+ shape = { Rectangle },+ effects = {+ colorControls(brightness = -0.1f, contrast = 0.75f, saturation = 1.5f)+ blur(2f.dp.toPx())+ with(sdfShader) { apply() }+ },+ onDrawBackdrop = { drawBackdrop ->+ drawBackdrop()+ drawRect(Color.White.copy(alpha = 0.25f))+ }+ )+ .widthIn(max = 400f.dp)+ .aspectRatio(sdfShader.width.toFloat() / sdfShader.height.toFloat())+ .fillMaxWidth()+ )+ }+ Box(Modifier.weight(1f))+ }+ }+}diff --git a/AndroidLiquidGlass-kmp/app/src/commonMain/kotlin/com/kyant/backdrop/catalog/destinations/MagnifierContent.kt b/AndroidLiquidGlass-kmp/app/src/commonMain/kotlin/com/kyant/backdrop/catalog/destinations/MagnifierContent.ktnew file mode 100644index 0000000..74687da--- /dev/null+++ b/AndroidLiquidGlass-kmp/app/src/commonMain/kotlin/com/kyant/backdrop/catalog/destinations/MagnifierContent.kt@@ -0,0 +1,108 @@+package com.kyant.backdrop.catalog.destinations++import androidx.compose.foundation.background+import androidx.compose.foundation.gestures.draggable2D+import androidx.compose.foundation.gestures.rememberDraggable2DState+import androidx.compose.foundation.isSystemInDarkTheme+import androidx.compose.foundation.layout.Box+import androidx.compose.foundation.layout.padding+import androidx.compose.foundation.layout.size+import androidx.compose.foundation.text.BasicText+import androidx.compose.runtime.Composable+import androidx.compose.runtime.getValue+import androidx.compose.runtime.mutableStateOf+import androidx.compose.runtime.remember+import androidx.compose.runtime.setValue+import androidx.compose.ui.Modifier+import androidx.compose.ui.draw.clip+import androidx.compose.ui.geometry.Offset+import androidx.compose.ui.graphics.Color+import androidx.compose.ui.graphics.drawscope.withTransform+import androidx.compose.ui.graphics.graphicsLayer+import androidx.compose.ui.text.TextStyle+import androidx.compose.ui.unit.dp+import androidx.compose.ui.unit.sp+import com.kyant.backdrop.backdrops.layerBackdrop+import com.kyant.backdrop.backdrops.rememberCombinedBackdrop+import com.kyant.backdrop.backdrops.rememberLayerBackdrop+import com.kyant.backdrop.catalog.BackdropDemoScaffold+import com.kyant.backdrop.catalog.utils.LoremIpsum+import com.kyant.backdrop.drawBackdrop+import com.kyant.backdrop.effects.lens+import com.kyant.backdrop.shadow.InnerShadow+import com.kyant.shapes.Capsule+import com.kyant.shapes.RoundedRectangle++@Composable+fun MagnifierContent() {+ val isLightTheme = !isSystemInDarkTheme()+ val contentColor = if (isLightTheme) Color.Black else Color.White+ val accentColor =+ if (isLightTheme) Color(0xFF0088FF)+ else Color(0xFF0091FF)+ val backgroundColor =+ if (isLightTheme) Color(0xFFFFFFFF)+ else Color(0xFF121212)++ BackdropDemoScaffold { backdrop ->+ val contentBackdrop = rememberLayerBackdrop()+ val cursorBackdrop = rememberLayerBackdrop()+ var offset by remember { mutableStateOf(Offset.Zero) }++ BasicText(+ LoremIpsum,+ Modifier+ .layerBackdrop(contentBackdrop)+ .padding(24f.dp)+ .clip(RoundedRectangle(32f.dp))+ .background(backgroundColor.copy(alpha = 0.9f))+ .padding(24f.dp),+ style = TextStyle(contentColor, 16f.sp)+ )++ Box(+ Modifier+ .graphicsLayer {+ val offset = offset+ translationX = offset.x+ translationY = offset.y+ }+ .draggable2D(rememberDraggable2DState { delta -> offset += delta })+ .layerBackdrop(cursorBackdrop)+ .background(accentColor, Capsule())+ .size(4f.dp, 24f.dp)+ )++ Box(+ Modifier+ .graphicsLayer {+ val offset = offset+ translationX = offset.x+ translationY = offset.y - 80f.dp.toPx()+ }+ .drawBackdrop(+ backdrop = rememberCombinedBackdrop(backdrop, contentBackdrop, cursorBackdrop),+ shape = { Capsule() },+ effects = {+ lens(+ 8f.dp.toPx(),+ 24f.dp.toPx(),+ depthEffect = true,+ chromaticAberration = true+ )+ },+ innerShadow = { InnerShadow(radius = 16f.dp) },+ onDrawBackdrop = { drawBackdrop ->+ withTransform(+ {+ scale(1.5f, 1.5f)+ translate(top = with(this@drawBackdrop) { -80f.dp.toPx() })+ },+ drawBackdrop+ )+ }+ )+ .size(128f.dp, 96f.dp)+ )+ }+}diff --git a/AndroidLiquidGlass-kmp/app/src/commonMain/kotlin/com/kyant/backdrop/catalog/destinations/ProgressiveBlurContent.kt b/AndroidLiquidGlass-kmp/app/src/commonMain/kotlin/com/kyant/backdrop/catalog/destinations/ProgressiveBlurContent.ktnew file mode 100644index 0000000..328cd64--- /dev/null+++ b/AndroidLiquidGlass-kmp/app/src/commonMain/kotlin/com/kyant/backdrop/catalog/destinations/ProgressiveBlurContent.kt@@ -0,0 +1,71 @@+package com.kyant.backdrop.catalog.destinations++import androidx.compose.foundation.isSystemInDarkTheme+import androidx.compose.foundation.layout.Arrangement+import androidx.compose.foundation.layout.Box+import androidx.compose.foundation.layout.Column+import androidx.compose.foundation.layout.fillMaxWidth+import androidx.compose.foundation.layout.height+import androidx.compose.foundation.text.BasicText+import androidx.compose.runtime.Composable+import androidx.compose.ui.Alignment+import androidx.compose.ui.Modifier+import androidx.compose.ui.graphics.Color+import androidx.compose.ui.graphics.RectangleShape+import androidx.compose.ui.text.TextStyle+import androidx.compose.ui.unit.dp+import androidx.compose.ui.unit.sp+import com.kyant.backdrop.catalog.BackdropDemoScaffold+import com.kyant.backdrop.drawPlainBackdrop+import com.kyant.backdrop.effects.blur+import com.kyant.backdrop.effects.runtimeShaderEffect++@Composable+fun ProgressiveBlurContent() {+ val isLightTheme = !isSystemInDarkTheme()+ val contentColor = if (isLightTheme) Color.Black else Color.White+ val tintColor = if (isLightTheme) Color.White else Color(0xFF808080)++ BackdropDemoScaffold { backdrop ->+ Column(+ horizontalAlignment = Alignment.CenterHorizontally,+ verticalArrangement = Arrangement.spacedBy(16f.dp)+ ) {+ Box(+ Modifier+ .drawPlainBackdrop(+ backdrop = backdrop,+ shape = { RectangleShape },+ effects = {+ blur(4f.dp.toPx())+ runtimeShaderEffect(+ "AlphaMask",+ """+ uniform shader content;++ uniform float2 size;+ layout(color) uniform half4 tint;+ uniform float tintIntensity;++ half4 main(float2 coord) {+ float blurAlpha = smoothstep(size.y, size.y * 0.5, coord.y);+ float tintAlpha = smoothstep(size.y, size.y * 0.5, coord.y);+ return mix(content.eval(coord) * blurAlpha, tint * tintAlpha, tintIntensity);+ }""",+ "content"+ ) {+ setFloatUniform("size", size.width, size.height)+ setColorUniform("tint", tintColor)+ setFloatUniform("tintIntensity", 0.8f)+ }+ }+ )+ .height(128f.dp)+ .fillMaxWidth(),+ contentAlignment = Alignment.Center+ ) {+ BasicText("alpha-masked progressive blur", style = TextStyle(contentColor, 16f.sp))+ }+ }+ }+}diff --git a/AndroidLiquidGlass-kmp/app/src/commonMain/kotlin/com/kyant/backdrop/catalog/destinations/ScrollContainerContent.kt b/AndroidLiquidGlass-kmp/app/src/commonMain/kotlin/com/kyant/backdrop/catalog/destinations/ScrollContainerContent.ktnew file mode 100644index 0000000..d26d0b8--- /dev/null+++ b/AndroidLiquidGlass-kmp/app/src/commonMain/kotlin/com/kyant/backdrop/catalog/destinations/ScrollContainerContent.kt@@ -0,0 +1,52 @@+package com.kyant.backdrop.catalog.destinations++import androidx.compose.foundation.layout.Arrangement+import androidx.compose.foundation.layout.Box+import androidx.compose.foundation.layout.Column+import androidx.compose.foundation.layout.displayCutoutPadding+import androidx.compose.foundation.layout.fillMaxSize+import androidx.compose.foundation.layout.fillMaxWidth+import androidx.compose.foundation.layout.height+import androidx.compose.foundation.layout.padding+import androidx.compose.foundation.layout.systemBarsPadding+import androidx.compose.foundation.rememberScrollState+import androidx.compose.foundation.verticalScroll+import androidx.compose.runtime.Composable+import androidx.compose.ui.Modifier+import androidx.compose.ui.unit.dp+import com.kyant.backdrop.catalog.BackdropDemoScaffold+import com.kyant.backdrop.drawBackdrop+import com.kyant.backdrop.effects.lens+import com.kyant.backdrop.effects.vibrancy+import com.kyant.shapes.RoundedRectangle++@Composable+fun ScrollContainerContent() {+ BackdropDemoScaffold { backdrop ->+ Column(+ Modifier+ .verticalScroll(rememberScrollState())+ .padding(16f.dp)+ .systemBarsPadding()+ .displayCutoutPadding()+ .fillMaxSize(),+ verticalArrangement = Arrangement.spacedBy(16f.dp)+ ) {+ repeat(20) {+ Box(+ Modifier+ .drawBackdrop(+ backdrop = backdrop,+ shape = { RoundedRectangle(32f.dp) },+ effects = {+ vibrancy()+ lens(16f.dp.toPx(), 32f.dp.toPx())+ }+ )+ .height(160f.dp)+ .fillMaxWidth()+ )+ }+ }+ }+}diff --git a/AndroidLiquidGlass-kmp/app/src/commonMain/kotlin/com/kyant/backdrop/catalog/destinations/SliderContent.kt b/AndroidLiquidGlass-kmp/app/src/commonMain/kotlin/com/kyant/backdrop/catalog/destinations/SliderContent.ktnew file mode 100644index 0000000..4c85e61--- /dev/null+++ b/AndroidLiquidGlass-kmp/app/src/commonMain/kotlin/com/kyant/backdrop/catalog/destinations/SliderContent.kt@@ -0,0 +1,65 @@+package com.kyant.backdrop.catalog.destinations++import androidx.compose.foundation.background+import androidx.compose.foundation.isSystemInDarkTheme+import androidx.compose.foundation.layout.Arrangement+import androidx.compose.foundation.layout.Box+import androidx.compose.foundation.layout.Column+import androidx.compose.foundation.layout.padding+import androidx.compose.runtime.Composable+import androidx.compose.runtime.getValue+import androidx.compose.runtime.mutableFloatStateOf+import androidx.compose.runtime.saveable.rememberSaveable+import androidx.compose.runtime.setValue+import androidx.compose.ui.Alignment+import androidx.compose.ui.Modifier+import androidx.compose.ui.draw.clip+import androidx.compose.ui.graphics.Color+import androidx.compose.ui.unit.dp+import com.kyant.backdrop.backdrops.rememberCanvasBackdrop+import com.kyant.backdrop.catalog.BackdropDemoScaffold+import com.kyant.backdrop.catalog.components.LiquidSlider+import com.kyant.shapes.RoundedRectangle++@Composable+fun SliderContent() {+ val isLightTheme = !isSystemInDarkTheme()+ val backgroundColor =+ if (isLightTheme) Color(0xFFFFFFFF)+ else Color(0xFF121212)++ BackdropDemoScaffold { backdrop ->+ Column(+ horizontalAlignment = Alignment.CenterHorizontally,+ verticalArrangement = Arrangement.spacedBy(16f.dp)+ ) {+ var value by rememberSaveable { mutableFloatStateOf(50f) }++ LiquidSlider(+ value = { value },+ onValueChange = { value = it },+ valueRange = 0f..100f,+ visibilityThreshold = 0.01f,+ backdrop = backdrop,+ modifier = Modifier.padding(horizontal = 32f.dp)+ )++ Box(+ Modifier+ .padding(24f.dp)+ .clip(RoundedRectangle(32f.dp))+ .background(backgroundColor)+ .padding(24f.dp)+ ) {+ LiquidSlider(+ value = { value },+ onValueChange = { value = it },+ valueRange = 0f..100f,+ visibilityThreshold = 0.01f,+ backdrop = rememberCanvasBackdrop { drawRect(backgroundColor) },+ modifier = Modifier.padding(horizontal = 32f.dp)+ )+ }+ }+ }+}diff --git a/AndroidLiquidGlass-kmp/app/src/commonMain/kotlin/com/kyant/backdrop/catalog/destinations/ToggleContent.kt b/AndroidLiquidGlass-kmp/app/src/commonMain/kotlin/com/kyant/backdrop/catalog/destinations/ToggleContent.ktnew file mode 100644index 0000000..9de360c--- /dev/null+++ b/AndroidLiquidGlass-kmp/app/src/commonMain/kotlin/com/kyant/backdrop/catalog/destinations/ToggleContent.kt@@ -0,0 +1,61 @@+package com.kyant.backdrop.catalog.destinations++import androidx.compose.foundation.background+import androidx.compose.foundation.isSystemInDarkTheme+import androidx.compose.foundation.layout.Arrangement+import androidx.compose.foundation.layout.Box+import androidx.compose.foundation.layout.Column+import androidx.compose.foundation.layout.padding+import androidx.compose.runtime.Composable+import androidx.compose.runtime.getValue+import androidx.compose.runtime.mutableStateOf+import androidx.compose.runtime.saveable.rememberSaveable+import androidx.compose.runtime.setValue+import androidx.compose.ui.Alignment+import androidx.compose.ui.Modifier+import androidx.compose.ui.draw.clip+import androidx.compose.ui.graphics.Color+import androidx.compose.ui.unit.dp+import com.kyant.backdrop.backdrops.rememberCanvasBackdrop+import com.kyant.backdrop.catalog.BackdropDemoScaffold+import com.kyant.backdrop.catalog.components.LiquidToggle+import com.kyant.shapes.RoundedRectangle++@Composable+fun ToggleContent() {+ val isLightTheme = !isSystemInDarkTheme()+ val backgroundColor =+ if (isLightTheme) Color(0xFFFFFFFF)+ else Color(0xFF121212)++ BackdropDemoScaffold { backdrop ->+ Column(+ horizontalAlignment = Alignment.CenterHorizontally,+ verticalArrangement = Arrangement.spacedBy(16f.dp)+ ) {+ var selected by rememberSaveable { mutableStateOf(false) }++ LiquidToggle(+ selected = { selected },+ onSelect = { selected = it },+ backdrop = backdrop,+ modifier = Modifier.padding(horizontal = 32f.dp)+ )++ Box(+ Modifier+ .padding(24f.dp)+ .clip(RoundedRectangle(32f.dp))+ .background(backgroundColor)+ .padding(24f.dp)+ ) {+ LiquidToggle(+ selected = { selected },+ onSelect = { selected = it },+ backdrop = rememberCanvasBackdrop { drawRect(backgroundColor) },+ modifier = Modifier.padding(horizontal = 32f.dp)+ )+ }+ }+ }+}diff --git a/AndroidLiquidGlass-kmp/app/src/commonMain/kotlin/com/kyant/backdrop/catalog/utils/BackHandler.kt b/AndroidLiquidGlass-kmp/app/src/commonMain/kotlin/com/kyant/backdrop/catalog/utils/BackHandler.ktnew file mode 100644index 0000000..9a13dc2--- /dev/null+++ b/AndroidLiquidGlass-kmp/app/src/commonMain/kotlin/com/kyant/backdrop/catalog/utils/BackHandler.kt@@ -0,0 +1,9 @@+package com.kyant.backdrop.catalog.utils++import androidx.compose.runtime.Composable++@Composable+expect fun BackHandler(+ enabled: Boolean = true,+ onBack: () -> Unit+)diff --git a/AndroidLiquidGlass-kmp/app/src/commonMain/kotlin/com/kyant/backdrop/catalog/utils/Bitmap.kt b/AndroidLiquidGlass-kmp/app/src/commonMain/kotlin/com/kyant/backdrop/catalog/utils/Bitmap.ktnew file mode 100644index 0000000..022b223--- /dev/null+++ b/AndroidLiquidGlass-kmp/app/src/commonMain/kotlin/com/kyant/backdrop/catalog/utils/Bitmap.kt@@ -0,0 +1,5 @@+package com.kyant.backdrop.catalog.utils++import androidx.compose.ui.graphics.ImageBitmap++expect fun ImageBitmap.scale(width: Int, height: Int): ImageBitmapdiff --git a/AndroidLiquidGlass-kmp/app/src/commonMain/kotlin/com/kyant/backdrop/catalog/utils/Coroutines.kt b/AndroidLiquidGlass-kmp/app/src/commonMain/kotlin/com/kyant/backdrop/catalog/utils/Coroutines.ktnew file mode 100644index 0000000..c144984--- /dev/null+++ b/AndroidLiquidGlass-kmp/app/src/commonMain/kotlin/com/kyant/backdrop/catalog/utils/Coroutines.kt@@ -0,0 +1,4 @@+package com.kyant.backdrop.catalog.utils++expect suspend fun awaitFrame()+diff --git a/AndroidLiquidGlass-kmp/app/src/commonMain/kotlin/com/kyant/backdrop/catalog/utils/DampedDragAnimation.kt b/AndroidLiquidGlass-kmp/app/src/commonMain/kotlin/com/kyant/backdrop/catalog/utils/DampedDragAnimation.ktnew file mode 100644index 0000000..2d7e445--- /dev/null+++ b/AndroidLiquidGlass-kmp/app/src/commonMain/kotlin/com/kyant/backdrop/catalog/utils/DampedDragAnimation.kt@@ -0,0 +1,137 @@+package com.kyant.backdrop.catalog.utils++import androidx.compose.animation.core.Animatable+import androidx.compose.animation.core.spring+import androidx.compose.foundation.MutatorMutex+import androidx.compose.runtime.snapshotFlow+import androidx.compose.ui.Modifier+import androidx.compose.ui.geometry.Offset+import androidx.compose.ui.input.pointer.pointerInput+import androidx.compose.ui.input.pointer.util.VelocityTracker+import androidx.compose.ui.unit.IntSize+import kotlinx.coroutines.CoroutineScope+import kotlinx.coroutines.flow.filter+import kotlinx.coroutines.flow.first+import kotlinx.coroutines.launch+import kotlin.math.abs+import kotlin.time.Clock++class DampedDragAnimation(+ private val animationScope: CoroutineScope,+ val initialValue: Float,+ val valueRange: ClosedRange<Float>,+ val visibilityThreshold: Float,+ val initialScale: Float,+ val pressedScale: Float,+ val onDragStarted: DampedDragAnimation.(position: Offset) -> Unit,+ val onDragStopped: DampedDragAnimation.() -> Unit,+ val onDrag: DampedDragAnimation.(size: IntSize, dragAmount: Offset) -> Unit,+) {++ private val valueAnimationSpec =+ spring(1f, 1000f, visibilityThreshold)+ private val velocityAnimationSpec =+ spring(0.5f, 300f, visibilityThreshold * 10f)+ private val pressProgressAnimationSpec =+ spring(1f, 1000f, 0.001f)+ private val scaleXAnimationSpec =+ spring(0.6f, 250f, 0.001f)+ private val scaleYAnimationSpec =+ spring(0.7f, 250f, 0.001f)++ private val valueAnimation =+ Animatable(initialValue, visibilityThreshold)+ private val velocityAnimation =+ Animatable(0f, 5f)+ private val pressProgressAnimation =+ Animatable(0f, 0.001f)+ private val scaleXAnimation =+ Animatable(initialScale, 0.001f)+ private val scaleYAnimation =+ Animatable(initialScale, 0.001f)++ private val mutatorMutex = MutatorMutex()++ private val velocityTracker = VelocityTracker()++ val value: Float get() = valueAnimation.value+ val progress: Float get() = (value - valueRange.start) / (valueRange.endInclusive - valueRange.start)+ val targetValue: Float get() = valueAnimation.targetValue+ val pressProgress: Float get() = pressProgressAnimation.value+ val scaleX: Float get() = scaleXAnimation.value+ val scaleY: Float get() = scaleYAnimation.value+ val velocity: Float get() = velocityAnimation.value++ val modifier: Modifier = Modifier.pointerInput(Unit) {+ inspectDragGestures(+ onDragStart = { down ->+ onDragStarted(down.position)+ press()+ },+ onDragEnd = {+ onDragStopped()+ release()+ },+ onDragCancel = {+ onDragStopped()+ release()+ }+ ) { change, dragAmount ->+ onDrag(size, dragAmount)+ }+ }++ fun press() {+ velocityTracker.resetTracking()+ animationScope.launch {+ launch { pressProgressAnimation.animateTo(1f, pressProgressAnimationSpec) }+ launch { scaleXAnimation.animateTo(pressedScale, scaleXAnimationSpec) }+ launch { scaleYAnimation.animateTo(pressedScale, scaleYAnimationSpec) }+ }+ }++ fun release() {+ animationScope.launch {+ awaitFrame()+ if (value != targetValue) {+ val threshold = (valueRange.endInclusive - valueRange.start) * 0.025f+ snapshotFlow { valueAnimation.value }+ .filter { abs(it - valueAnimation.targetValue) < threshold }+ .first()+ }+ launch { pressProgressAnimation.animateTo(0f, pressProgressAnimationSpec) }+ launch { scaleXAnimation.animateTo(initialScale, scaleXAnimationSpec) }+ launch { scaleYAnimation.animateTo(initialScale, scaleYAnimationSpec) }+ }+ }++ fun updateValue(value: Float) {+ val targetValue = value.coerceIn(valueRange)+ animationScope.launch {+ launch { valueAnimation.animateTo(targetValue, valueAnimationSpec) { updateVelocity() } }+ }+ }++ fun animateToValue(value: Float) {+ animationScope.launch {+ mutatorMutex.mutate {+ press()+ val targetValue = value.coerceIn(valueRange)+ launch { valueAnimation.animateTo(targetValue, valueAnimationSpec) }+ if (velocity != 0f) {+ launch { velocityAnimation.animateTo(0f, velocityAnimationSpec) }+ }+ release()+ }+ }+ }++ private fun updateVelocity() {+ velocityTracker.addPosition(+ Clock.System.now().toEpochMilliseconds(),+ Offset(value, 0f)+ )+ val targetVelocity = velocityTracker.calculateVelocity().x / (valueRange.endInclusive - valueRange.start)+ animationScope.launch { velocityAnimation.animateTo(targetVelocity, velocityAnimationSpec) }+ }+}diff --git a/AndroidLiquidGlass-kmp/app/src/commonMain/kotlin/com/kyant/backdrop/catalog/utils/DragGestureInspector.kt b/AndroidLiquidGlass-kmp/app/src/commonMain/kotlin/com/kyant/backdrop/catalog/utils/DragGestureInspector.ktnew file mode 100644index 0000000..d3ae410--- /dev/null+++ b/AndroidLiquidGlass-kmp/app/src/commonMain/kotlin/com/kyant/backdrop/catalog/utils/DragGestureInspector.kt@@ -0,0 +1,85 @@+package com.kyant.backdrop.catalog.utils++import androidx.compose.foundation.gestures.awaitEachGesture+import androidx.compose.foundation.gestures.awaitFirstDown+import androidx.compose.ui.geometry.Offset+import androidx.compose.ui.input.pointer.AwaitPointerEventScope+import androidx.compose.ui.input.pointer.PointerEventPass+import androidx.compose.ui.input.pointer.PointerId+import androidx.compose.ui.input.pointer.PointerInputChange+import androidx.compose.ui.input.pointer.PointerInputScope+import androidx.compose.ui.input.pointer.changedToUpIgnoreConsumed+import androidx.compose.ui.input.pointer.positionChange+import androidx.compose.ui.util.fastFirstOrNull++suspend fun PointerInputScope.inspectDragGestures(+ onDragStart: (down: PointerInputChange) -> Unit = {},+ onDragEnd: (change: PointerInputChange) -> Unit = {},+ onDragCancel: () -> Unit = {},+ onDrag: (change: PointerInputChange, dragAmount: Offset) -> Unit+) {+ awaitEachGesture {+ val initialDown = awaitFirstDown(false, PointerEventPass.Initial)++ val down = awaitFirstDown(false)+ val drag = initialDown++ onDragStart(down)+ onDrag(drag, Offset.Zero)+ val upEvent =+ drag(+ pointerId = drag.id,+ onDrag = { onDrag(it, it.positionChange()) }+ )+ if (upEvent == null) {+ onDragCancel()+ } else {+ onDragEnd(upEvent)+ }+ }+}++private suspend inline fun AwaitPointerEventScope.drag(+ pointerId: PointerId,+ onDrag: (PointerInputChange) -> Unit+): PointerInputChange? {+ val isPointerUp = currentEvent.changes.fastFirstOrNull { it.id == pointerId }?.pressed != true+ if (isPointerUp) {+ return null+ }+ var pointer = pointerId+ while (true) {+ val change = awaitDragOrUp(pointer) ?: return null+ if (change.isConsumed) {+ return null+ }+ if (change.changedToUpIgnoreConsumed()) {+ return change+ }+ onDrag(change)+ pointer = change.id+ }+}++private suspend inline fun AwaitPointerEventScope.awaitDragOrUp(+ pointerId: PointerId+): PointerInputChange? {+ var pointer = pointerId+ while (true) {+ val event = awaitPointerEvent()+ val dragEvent = event.changes.fastFirstOrNull { it.id == pointer } ?: return null+ if (dragEvent.changedToUpIgnoreConsumed()) {+ val otherDown = event.changes.fastFirstOrNull { it.pressed }+ if (otherDown == null) {+ return dragEvent+ } else {+ pointer = otherDown.id+ }+ } else {+ val hasDragged = dragEvent.previousPosition != dragEvent.position+ if (hasDragged) {+ return dragEvent+ }+ }+ }+}diff --git a/AndroidLiquidGlass-kmp/app/src/commonMain/kotlin/com/kyant/backdrop/catalog/utils/InteractiveHighlight.kt b/AndroidLiquidGlass-kmp/app/src/commonMain/kotlin/com/kyant/backdrop/catalog/utils/InteractiveHighlight.ktnew file mode 100644index 0000000..33b91e1--- /dev/null+++ b/AndroidLiquidGlass-kmp/app/src/commonMain/kotlin/com/kyant/backdrop/catalog/utils/InteractiveHighlight.kt@@ -0,0 +1,121 @@+package com.kyant.backdrop.catalog.utils++import androidx.compose.animation.core.Animatable+import androidx.compose.animation.core.VectorConverter+import androidx.compose.animation.core.VisibilityThreshold+import androidx.compose.animation.core.spring+import androidx.compose.ui.Modifier+import androidx.compose.ui.draw.drawWithContent+import androidx.compose.ui.geometry.Offset+import androidx.compose.ui.geometry.Size+import androidx.compose.ui.graphics.BlendMode+import androidx.compose.ui.graphics.Color+import androidx.compose.ui.graphics.ShaderBrush+import androidx.compose.ui.input.pointer.pointerInput+import androidx.compose.ui.util.fastCoerceIn+import com.kyant.backdrop.RuntimeShader+import com.kyant.backdrop.asComposeShader+import com.kyant.backdrop.isRuntimeShaderSupported+import kotlinx.coroutines.CoroutineScope+import kotlinx.coroutines.launch++class InteractiveHighlight(+ val animationScope: CoroutineScope,+ val position: (size: Size, offset: Offset) -> Offset = { _, offset -> offset }+) {++ private val pressProgressAnimationSpec =+ spring(0.5f, 300f, 0.001f)+ private val positionAnimationSpec =+ spring(0.5f, 300f, Offset.VisibilityThreshold)++ private val pressProgressAnimation =+ Animatable(0f, 0.001f)+ private val positionAnimation =+ Animatable(Offset.Zero, Offset.VectorConverter, Offset.VisibilityThreshold)++ private var startPosition = Offset.Zero+ val pressProgress: Float get() = pressProgressAnimation.value+ val offset: Offset get() = positionAnimation.value - startPosition++ private val shader =+ if (isRuntimeShaderSupported()) {+ RuntimeShader(+ """+uniform float2 size;+layout(color) uniform half4 color;+uniform float radius;+uniform float2 position;++half4 main(float2 coord) {+ float dist = distance(coord, position);+ float intensity = smoothstep(radius, radius * 0.5, dist);+ return color * intensity;+}"""+ )+ } else {+ null+ }++ val modifier: Modifier =+ Modifier.drawWithContent {+ val progress = pressProgressAnimation.value+ if (progress > 0f) {+ if (shader != null) {+ drawRect(+ Color.White.copy(0.08f * progress),+ blendMode = BlendMode.Plus+ )+ shader.apply {+ val position = position(size, positionAnimation.value)+ setFloatUniform("size", size.width, size.height)+ setColorUniform("color", Color.White.copy(0.15f * progress))+ setFloatUniform("radius", size.minDimension * 1.5f)+ setFloatUniform(+ "position",+ position.x.fastCoerceIn(0f, size.width),+ position.y.fastCoerceIn(0f, size.height)+ )+ }+ drawRect(+ ShaderBrush(shader.asComposeShader()),+ blendMode = BlendMode.Plus+ )+ } else {+ drawRect(+ Color.White.copy(0.25f * progress),+ blendMode = BlendMode.Plus+ )+ }+ }++ drawContent()+ }++ val gestureModifier: Modifier =+ Modifier.pointerInput(animationScope) {+ inspectDragGestures(+ onDragStart = { down ->+ startPosition = down.position+ animationScope.launch {+ launch { pressProgressAnimation.animateTo(1f, pressProgressAnimationSpec) }+ launch { positionAnimation.snapTo(startPosition) }+ }+ },+ onDragEnd = {+ animationScope.launch {+ launch { pressProgressAnimation.animateTo(0f, pressProgressAnimationSpec) }+ launch { positionAnimation.animateTo(startPosition, positionAnimationSpec) }+ }+ },+ onDragCancel = {+ animationScope.launch {+ launch { pressProgressAnimation.animateTo(0f, pressProgressAnimationSpec) }+ launch { positionAnimation.animateTo(startPosition, positionAnimationSpec) }+ }+ }+ ) { change, _ ->+ animationScope.launch { positionAnimation.snapTo(change.position) }+ }+ }+}diff --git a/AndroidLiquidGlass-kmp/app/src/commonMain/kotlin/com/kyant/backdrop/catalog/utils/LoremIpsum.kt b/AndroidLiquidGlass-kmp/app/src/commonMain/kotlin/com/kyant/backdrop/catalog/utils/LoremIpsum.ktnew file mode 100644index 0000000..9db69ab--- /dev/null+++ b/AndroidLiquidGlass-kmp/app/src/commonMain/kotlin/com/kyant/backdrop/catalog/utils/LoremIpsum.kt@@ -0,0 +1,4 @@+package com.kyant.backdrop.catalog.utils++internal const val LoremIpsum =+ """Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."""diff --git a/AndroidLiquidGlass-kmp/app/src/commonMain/kotlin/com/kyant/backdrop/catalog/utils/ProgressConverter.kt b/AndroidLiquidGlass-kmp/app/src/commonMain/kotlin/com/kyant/backdrop/catalog/utils/ProgressConverter.ktnew file mode 100644index 0000000..f485233--- /dev/null+++ b/AndroidLiquidGlass-kmp/app/src/commonMain/kotlin/com/kyant/backdrop/catalog/utils/ProgressConverter.kt@@ -0,0 +1,18 @@+package com.kyant.backdrop.catalog.utils++import kotlin.math.abs+import kotlin.math.exp+import kotlin.math.sign++fun interface ProgressConverter {++ fun convert(progress: Float): Float++ companion object {++ val Default: ProgressConverter =+ ProgressConverter { progress ->+ (1f - exp(-abs(progress))) * progress.sign+ }+ }+}diff --git a/AndroidLiquidGlass-kmp/app/src/commonMain/kotlin/com/kyant/backdrop/catalog/utils/SdfShader.kt b/AndroidLiquidGlass-kmp/app/src/commonMain/kotlin/com/kyant/backdrop/catalog/utils/SdfShader.ktnew file mode 100644index 0000000..4bee030--- /dev/null+++ b/AndroidLiquidGlass-kmp/app/src/commonMain/kotlin/com/kyant/backdrop/catalog/utils/SdfShader.kt@@ -0,0 +1,75 @@+package com.kyant.backdrop.catalog.utils++import androidx.compose.runtime.Composable+import androidx.compose.runtime.Immutable+import androidx.compose.runtime.remember+import androidx.compose.ui.graphics.ImageBitmap+import androidx.compose.ui.unit.dp+import com.kyant.backdrop.BackdropEffectScope+import org.intellij.lang.annotations.Language+import org.jetbrains.compose.resources.DrawableResource+import org.jetbrains.compose.resources.imageResource++@Composable+fun rememberSdfShader(drawableResource: DrawableResource): SdfShader {+ val imageResource = imageResource(drawableResource)+ return remember(imageResource) { SdfShader(imageResource) }+}++expect fun SdfShader(imageBitmap: ImageBitmap): SdfShader++@Immutable+interface SdfShader {++ val width: Int++ val height: Int++ fun BackdropEffectScope.apply(+ refractionHeight: Float = 48f.dp.toPx(),+ lightAngle: Float = 45f+ )+}++@Language("AGSL")+internal const val SdfShaderString =+ """+uniform shader content;+uniform shader sdfTex;++uniform float2 size;+uniform float2 sdfTexSize;+uniform float refractionHeight;+uniform float lightAngle;++float circleMap(float x) {+ return 1.0 - sqrt(1.0 - x * x);+}++half4 main(float2 coord) {+ half2 p = coord / size * sdfTexSize;+ if (p.x < 0.0 || p.y < 0.0 || p.x >= sdfTexSize.x || p.y >= sdfTexSize.y) {+ return half4(0.0);+ }+ half4 v = sdfTex.eval(p);+ float sd = v.r * 2.0 - 1.0;+ v.a = smoothstep(0.5, 1.0, v.a);+ if (v.a <= 0.0) {+ return half4(0.0);+ }+ if (v.a < 1.0) {+ sd = 0.0;+ }+ float2 normal = normalize(v.gb * 2.0 - 1.0);++ float intensity = circleMap(1.0 - min(1.0, -sd * 1.5));+ float2 refractedCoord = coord - intensity * refractionHeight * normal;++ half4 color = content.eval(refractedCoord) * v.a;+ float2 lightDir = float2(cos(lightAngle * 3.1415926 / 180.0), sin(lightAngle * 3.1415926 / 180.0));+ float bevelIntensity = clamp(dot(normal, lightDir), 0.0, 1.0);+ color.rgb *= 1.0 + 0.5 * intensity * bevelIntensity;+ bevelIntensity = clamp(dot(normal, -lightDir), 0.0, 1.0);+ color.rgb *= 1.0 + 0.5 * bevelIntensity * min(1.0, smoothstep(1.0, 0.0, abs(intensity - 0.25) * 6.0));+ return color;+}"""diff --git a/AndroidLiquidGlass-kmp/app/src/commonMain/kotlin/com/kyant/backdrop/catalog/utils/UISensor.kt b/AndroidLiquidGlass-kmp/app/src/commonMain/kotlin/com/kyant/backdrop/catalog/utils/UISensor.ktnew file mode 100644index 0000000..dfb99b1--- /dev/null+++ b/AndroidLiquidGlass-kmp/app/src/commonMain/kotlin/com/kyant/backdrop/catalog/utils/UISensor.kt@@ -0,0 +1,18 @@+package com.kyant.backdrop.catalog.utils++import androidx.compose.runtime.Composable+import androidx.compose.ui.geometry.Offset++@Composable+expect fun rememberUISensor(): UISensor++interface UISensor {++ val gravityAngle: Float++ val gravity: Offset++ fun start()++ fun stop()+}diff --git a/AndroidLiquidGlass-kmp/app/src/desktopMain/kotlin/com/kyant/backdrop/catalog/Main.kt b/AndroidLiquidGlass-kmp/app/src/desktopMain/kotlin/com/kyant/backdrop/catalog/Main.ktnew file mode 100644index 0000000..8dc6555--- /dev/null+++ b/AndroidLiquidGlass-kmp/app/src/desktopMain/kotlin/com/kyant/backdrop/catalog/Main.kt@@ -0,0 +1,17 @@+package com.kyant.backdrop.catalog++import androidx.compose.ui.Alignment+import androidx.compose.ui.window.Window+import androidx.compose.ui.window.WindowPosition+import androidx.compose.ui.window.application+import androidx.compose.ui.window.rememberWindowState++fun main() = application {+ Window(+ onCloseRequest = ::exitApplication,+ state = rememberWindowState(position = WindowPosition.Aligned(Alignment.Center)),+ title = "Backdrop Catalog"+ ) {+ MainContent()+ }+}diff --git a/AndroidLiquidGlass-kmp/app/src/iosMain/kotlin/main.ios.kt b/AndroidLiquidGlass-kmp/app/src/iosMain/kotlin/main.ios.ktnew file mode 100644index 0000000..c7f17e3--- /dev/null+++ b/AndroidLiquidGlass-kmp/app/src/iosMain/kotlin/main.ios.kt@@ -0,0 +1,13 @@+import androidx.compose.ui.uikit.OnFocusBehavior+import androidx.compose.ui.window.ComposeUIViewController+import com.kyant.backdrop.catalog.MainContent+import platform.UIKit.UIViewController++fun MainViewController(): UIViewController =+ ComposeUIViewController(+ configure = {+ onFocusBehavior = OnFocusBehavior.DoNothing+ },+ ) {+ MainContent()+ }\ No newline at end of filediff --git a/AndroidLiquidGlass-kmp/app/src/skikoMain/kotlin/com/kyant/backdrop/catalog/BackdropDemoScaffold.kt b/AndroidLiquidGlass-kmp/app/src/skikoMain/kotlin/com/kyant/backdrop/catalog/BackdropDemoScaffold.ktnew file mode 100644index 0000000..c854a95--- /dev/null+++ b/AndroidLiquidGlass-kmp/app/src/skikoMain/kotlin/com/kyant/backdrop/catalog/BackdropDemoScaffold.kt@@ -0,0 +1,48 @@+package com.kyant.backdrop.catalog++import androidx.compose.foundation.Image+import androidx.compose.foundation.layout.Box+import androidx.compose.foundation.layout.BoxScope+import androidx.compose.foundation.layout.fillMaxSize+import androidx.compose.runtime.Composable+import androidx.compose.runtime.getValue+import androidx.compose.runtime.mutableStateOf+import androidx.compose.runtime.remember+import androidx.compose.runtime.setValue+import androidx.compose.ui.Alignment+import androidx.compose.ui.Modifier+import androidx.compose.ui.graphics.painter.Painter+import androidx.compose.ui.layout.ContentScale+import com.kyant.backdrop.backdrops.LayerBackdrop+import com.kyant.backdrop.backdrops.layerBackdrop+import com.kyant.backdrop.backdrops.rememberLayerBackdrop+import glass.app.generated.resources.Res+import glass.app.generated.resources.wallpaper_light+import org.jetbrains.compose.resources.painterResource++@Composable+actual fun BackdropDemoScaffold(+ modifier: Modifier,+ content: @Composable BoxScope.(backdrop: LayerBackdrop) -> Unit+) {+ Box(+ Modifier.fillMaxSize(),+ contentAlignment = Alignment.Center+ ) {+ var painter: Painter? by remember { mutableStateOf(null) }++ val backdrop = rememberLayerBackdrop()++ Image(+ painter ?: painterResource(Res.drawable.wallpaper_light),+ null,+ Modifier+ .layerBackdrop(backdrop)+ .then(modifier)+ .fillMaxSize(),+ contentScale = ContentScale.Crop+ )++ content(backdrop)+ }+}diff --git a/AndroidLiquidGlass-kmp/app/src/skikoMain/kotlin/com/kyant/backdrop/catalog/utils/BackHandler.kt b/AndroidLiquidGlass-kmp/app/src/skikoMain/kotlin/com/kyant/backdrop/catalog/utils/BackHandler.ktnew file mode 100644index 0000000..2f91609--- /dev/null+++ b/AndroidLiquidGlass-kmp/app/src/skikoMain/kotlin/com/kyant/backdrop/catalog/utils/BackHandler.kt@@ -0,0 +1,38 @@+package com.kyant.backdrop.catalog.utils++import androidx.compose.foundation.layout.height+import androidx.compose.foundation.layout.padding+import androidx.compose.foundation.layout.safeDrawingPadding+import androidx.compose.foundation.text.BasicText+import androidx.compose.runtime.Composable+import androidx.compose.ui.Modifier+import androidx.compose.ui.graphics.Color+import androidx.compose.ui.text.TextStyle+import androidx.compose.ui.unit.dp+import androidx.compose.ui.unit.sp+import com.kyant.backdrop.backdrops.emptyBackdrop+import com.kyant.backdrop.catalog.components.LiquidButton++@Composable+actual fun BackHandler(+ enabled: Boolean,+ onBack: () -> Unit+) {+ if (enabled) {+ LiquidButton(+ { if (enabled) onBack() },+ emptyBackdrop(),+ Modifier+ .padding(8f.dp)+ .safeDrawingPadding()+ .height(48f.dp),+ tint = Color(0xFF0088FF)+ ) {+ BasicText(+ "Back",+ Modifier.padding(horizontal = 8f.dp),+ style = TextStyle(Color.White, 16f.sp)+ )+ }+ }+}diff --git a/AndroidLiquidGlass-kmp/app/src/skikoMain/kotlin/com/kyant/backdrop/catalog/utils/Bitmap.kt b/AndroidLiquidGlass-kmp/app/src/skikoMain/kotlin/com/kyant/backdrop/catalog/utils/Bitmap.ktnew file mode 100644index 0000000..71f8911--- /dev/null+++ b/AndroidLiquidGlass-kmp/app/src/skikoMain/kotlin/com/kyant/backdrop/catalog/utils/Bitmap.kt@@ -0,0 +1,16 @@+package com.kyant.backdrop.catalog.utils++import androidx.compose.ui.graphics.ImageBitmap+import androidx.compose.ui.graphics.asComposeImageBitmap+import androidx.compose.ui.graphics.asSkiaBitmap+import org.jetbrains.skia.Bitmap+import org.jetbrains.skia.Image+import org.jetbrains.skia.SamplingMode++actual fun ImageBitmap.scale(width: Int, height: Int): ImageBitmap {+ val bitmap = Bitmap()+ bitmap.allocN32Pixels(width, height)+ val image = Image.makeFromBitmap(this.asSkiaBitmap())+ image.scalePixels(bitmap.peekPixels()!!, SamplingMode.LINEAR, false)+ return bitmap.asComposeImageBitmap()+}diff --git a/AndroidLiquidGlass-kmp/app/src/skikoMain/kotlin/com/kyant/backdrop/catalog/utils/Coroutines.kt b/AndroidLiquidGlass-kmp/app/src/skikoMain/kotlin/com/kyant/backdrop/catalog/utils/Coroutines.ktnew file mode 100644index 0000000..44d544f--- /dev/null+++ b/AndroidLiquidGlass-kmp/app/src/skikoMain/kotlin/com/kyant/backdrop/catalog/utils/Coroutines.kt@@ -0,0 +1,7 @@+package com.kyant.backdrop.catalog.utils++import kotlinx.coroutines.delay++actual suspend fun awaitFrame() {+ delay(1000L / 60L)+}diff --git a/AndroidLiquidGlass-kmp/app/src/skikoMain/kotlin/com/kyant/backdrop/catalog/utils/SdfShader.skiko.kt b/AndroidLiquidGlass-kmp/app/src/skikoMain/kotlin/com/kyant/backdrop/catalog/utils/SdfShader.skiko.ktnew file mode 100644index 0000000..99f0435--- /dev/null+++ b/AndroidLiquidGlass-kmp/app/src/skikoMain/kotlin/com/kyant/backdrop/catalog/utils/SdfShader.skiko.kt@@ -0,0 +1,40 @@+package com.kyant.backdrop.catalog.utils++import androidx.compose.runtime.Immutable+import androidx.compose.ui.graphics.ImageBitmap+import androidx.compose.ui.graphics.asSkiaBitmap+import com.kyant.backdrop.BackdropEffectScope+import com.kyant.backdrop.asSkikoRuntimeShader+import com.kyant.backdrop.effects.runtimeShaderEffect+import com.kyant.backdrop.isRuntimeShaderSupported++actual fun SdfShader(imageBitmap: ImageBitmap): SdfShader {+ return SdfShaderImpl(imageBitmap)+}++@Immutable+private class SdfShaderImpl(val sdfBitmap: ImageBitmap) : SdfShader {++ private val sdfTexture = sdfBitmap.asSkiaBitmap().makeShader()++ override val width: Int+ get() = sdfBitmap.width++ override val height: Int+ get() = sdfBitmap.height++ override fun BackdropEffectScope.apply(+ refractionHeight: Float,+ lightAngle: Float,+ ) {+ if (isRuntimeShaderSupported()) {+ runtimeShaderEffect("SdfShader", SdfShaderString, "content") {+ asSkikoRuntimeShader().child("sdfTex", sdfTexture)+ setFloatUniform("size", size.width, size.height)+ setFloatUniform("sdfTexSize", sdfBitmap.width.toFloat(), sdfBitmap.height.toFloat())+ setFloatUniform("refractionHeight", refractionHeight)+ setFloatUniform("lightAngle", lightAngle)+ }+ }+ }+}diff --git a/AndroidLiquidGlass-kmp/app/src/skikoMain/kotlin/com/kyant/backdrop/catalog/utils/UISensor.kt b/AndroidLiquidGlass-kmp/app/src/skikoMain/kotlin/com/kyant/backdrop/catalog/utils/UISensor.ktnew file mode 100644index 0000000..8df0c28--- /dev/null+++ b/AndroidLiquidGlass-kmp/app/src/skikoMain/kotlin/com/kyant/backdrop/catalog/utils/UISensor.kt@@ -0,0 +1,35 @@+package com.kyant.backdrop.catalog.utils++import androidx.compose.runtime.Composable+import androidx.compose.runtime.DisposableEffect+import androidx.compose.runtime.getValue+import androidx.compose.runtime.mutableFloatStateOf+import androidx.compose.runtime.mutableStateOf+import androidx.compose.runtime.remember+import androidx.compose.runtime.setValue+import androidx.compose.ui.geometry.Offset++@Composable+actual fun rememberUISensor(): UISensor {+ val uiSensor = remember { UISensorImpl() }++ DisposableEffect(Unit) {+ uiSensor.start()+ onDispose { uiSensor.stop() }+ }++ return uiSensor+}++private class UISensorImpl : UISensor {++ override var gravityAngle: Float by mutableFloatStateOf(45f)+ private set++ override var gravity: Offset by mutableStateOf(Offset.Zero)+ private set++ override fun start() = Unit++ override fun stop() = Unit+}diff --git a/AndroidLiquidGlass-kmp/artworks/android_inner_refraction.png b/AndroidLiquidGlass-kmp/artworks/android_inner_refraction.pngnew file mode 100644index 0000000..2771370Binary files /dev/null and b/AndroidLiquidGlass-kmp/artworks/android_inner_refraction.png differdiff --git a/AndroidLiquidGlass-kmp/artworks/banner.jpg b/AndroidLiquidGlass-kmp/artworks/banner.jpgnew file mode 100644index 0000000..ed3cf20Binary files /dev/null and b/AndroidLiquidGlass-kmp/artworks/banner.jpg differdiff --git a/AndroidLiquidGlass-kmp/artworks/catalog_app.jpg b/AndroidLiquidGlass-kmp/artworks/catalog_app.jpgnew file mode 100644index 0000000..a52ba74Binary files /dev/null and b/AndroidLiquidGlass-kmp/artworks/catalog_app.jpg differdiff --git a/AndroidLiquidGlass-kmp/artworks/homescreen.png b/AndroidLiquidGlass-kmp/artworks/homescreen.pngnew file mode 100644index 0000000..4ece370Binary files /dev/null and b/AndroidLiquidGlass-kmp/artworks/homescreen.png differdiff --git a/AndroidLiquidGlass-kmp/artworks/ios_inner_refraction.png b/AndroidLiquidGlass-kmp/artworks/ios_inner_refraction.pngnew file mode 100644index 0000000..15d6f01Binary files /dev/null and b/AndroidLiquidGlass-kmp/artworks/ios_inner_refraction.png differdiff --git a/AndroidLiquidGlass-kmp/artworks/playground_app.jpg b/AndroidLiquidGlass-kmp/artworks/playground_app.jpgnew file mode 100644index 0000000..f3e8707Binary files /dev/null and b/AndroidLiquidGlass-kmp/artworks/playground_app.jpg differdiff --git a/AndroidLiquidGlass-kmp/backdrop/.gitignore b/AndroidLiquidGlass-kmp/backdrop/.gitignorenew file mode 100644index 0000000..42afabf--- /dev/null+++ b/AndroidLiquidGlass-kmp/backdrop/.gitignore@@ -0,0 +1 @@+/build\ No newline at end of filediff --git a/AndroidLiquidGlass-kmp/backdrop/build.gradle.kts b/AndroidLiquidGlass-kmp/backdrop/build.gradle.ktsnew file mode 100644index 0000000..290f030--- /dev/null+++ b/AndroidLiquidGlass-kmp/backdrop/build.gradle.kts@@ -0,0 +1,111 @@+import org.jetbrains.kotlin.gradle.dsl.JvmTarget++plugins {+ alias(libs.plugins.android.multiplatform.library)+ alias(libs.plugins.kotlin.multiplatform)+ alias(libs.plugins.kotlin.compose)+ alias(libs.plugins.jetbrains.compose)+ id("com.vanniktech.maven.publish")+}++kotlin {+ android {+ minSdk = 21+ compileSdk = 37+ buildToolsVersion = "37.0.0"+ namespace = "com.kyant.backdrop"+ compilerOptions {+ jvmTarget = JvmTarget.JVM_11+ }+ }++ applyDefaultHierarchyTemplate()++ jvm("desktop")++ js {+ browser()+ }+ wasmJs {+ browser()+ }++ macosArm64()+ iosArm64("iosArm64")+ iosSimulatorArm64("iosSimulatorArm64")++ sourceSets {+ val commonMain = getByName("commonMain") {+ dependencies {+ implementation(libs.compose.foundation)+ implementation(libs.compose.ui)+ implementation(libs.compose.ui.graphics)+ implementation(libs.kyant.shapes)+ implementation("org.jetbrains:annotations:26.1.0")+ }+ }++ val skikoMain = create("skikoMain") {+ dependsOn(commonMain)+ }++ val desktopMain = getByName("desktopMain") {+ dependsOn(skikoMain)+ }++ val macosArm64Main = getByName("macosArm64Main") {+ dependsOn(skikoMain)+ }++ val iosMain = getByName("iosMain") {+ dependsOn(skikoMain)+ }++ val iosArm64Main = getByName("iosArm64Main") {+ }++ val iosSimulatorArm64Main = getByName("iosSimulatorArm64Main") {+ }++ val jsMain = getByName("jsMain") {+ dependsOn(skikoMain)+ }++ val wasmJsMain = getByName("wasmJsMain") {+ dependsOn(skikoMain)+ }+ }+}++mavenPublishing {+ publishToMavenCentral()+ signAllPublications()++ coordinates("io.github.kyant0", "backdrop", "2.0.0")++ pom {+ name.set("Backdrop")+ description.set("Compose Multiplatform Liquid Glass effects")+ inceptionYear.set("2025")+ url.set("https://github.com/Kyant0/AndroidLiquidGlass")+ licenses {+ license {+ name.set("The Apache License, Version 2.0")+ url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")+ distribution.set("repo")+ }+ }+ developers {+ developer {+ id.set("Kyant0")+ name.set("Kyant")+ url.set("https://github.com/Kyant0")+ }+ }+ scm {+ url.set("https://github.com/Kyant0/AndroidLiquidGlass")+ connection.set("scm:git:git://github.com/Kyant0/AndroidLiquidGlass.git")+ developerConnection.set("scm:git:ssh://[email protected]/Kyant0/AndroidLiquidGlass.git")+ }+ }+}diff --git a/AndroidLiquidGlass-kmp/backdrop/consumer-rules.pro b/AndroidLiquidGlass-kmp/backdrop/consumer-rules.pronew file mode 100644index 0000000..e69de29diff --git a/AndroidLiquidGlass-kmp/backdrop/proguard-rules.pro b/AndroidLiquidGlass-kmp/backdrop/proguard-rules.pronew file mode 100644index 0000000..481bb43--- /dev/null+++ b/AndroidLiquidGlass-kmp/backdrop/proguard-rules.pro@@ -0,0 +1,21 @@+# Add project specific ProGuard rules here.+# You can control the set of applied configuration files using the+# proguardFiles setting in build.gradle.+#+# For more details, see+# http://developer.android.com/guide/developing/tools/proguard.html++# If your project uses WebView with JS, uncomment the following+# and specify the fully qualified class name to the JavaScript interface+# class:+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {+# public *;+#}++# Uncomment this to preserve the line number information for+# debugging stack traces.+#-keepattributes SourceFile,LineNumberTable++# If you keep the line number information, uncomment this to+# hide the original source file name.+#-renamesourcefileattribute SourceFile\ No newline at end of filediff --git a/AndroidLiquidGlass-kmp/backdrop/src/androidMain/kotlin/com/kyant/backdrop/Platform.kt b/AndroidLiquidGlass-kmp/backdrop/src/androidMain/kotlin/com/kyant/backdrop/Platform.ktnew file mode 100644index 0000000..4d0e924--- /dev/null+++ b/AndroidLiquidGlass-kmp/backdrop/src/androidMain/kotlin/com/kyant/backdrop/Platform.kt@@ -0,0 +1,10 @@+package com.kyant.backdrop++import android.os.Build+import androidx.annotation.ChecksSdkIntAtLeast++@ChecksSdkIntAtLeast(Build.VERSION_CODES.S)+actual fun isRenderEffectSupported(): Boolean = Build.VERSION.SDK_INT >= Build.VERSION_CODES.S++@ChecksSdkIntAtLeast(Build.VERSION_CODES.TIRAMISU)+actual fun isRuntimeShaderSupported(): Boolean = Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISUdiff --git a/AndroidLiquidGlass-kmp/backdrop/src/androidMain/kotlin/com/kyant/backdrop/RuntimeShader.kt b/AndroidLiquidGlass-kmp/backdrop/src/androidMain/kotlin/com/kyant/backdrop/RuntimeShader.ktnew file mode 100644index 0000000..433ad70--- /dev/null+++ b/AndroidLiquidGlass-kmp/backdrop/src/androidMain/kotlin/com/kyant/backdrop/RuntimeShader.kt@@ -0,0 +1,70 @@+package com.kyant.backdrop++import android.os.Build+import androidx.annotation.RequiresApi+import androidx.compose.ui.graphics.Color+import androidx.compose.ui.graphics.Shader+import androidx.compose.ui.graphics.toArgb+import org.intellij.lang.annotations.Language++@RequiresApi(Build.VERSION_CODES.TIRAMISU)+actual fun RuntimeShader(@Language("AGSL") shaderString: String): RuntimeShader {+ val shader = android.graphics.RuntimeShader(shaderString)+ return AndroidRuntimeShader(shader)+}++actual fun RuntimeShader.asComposeShader(): Shader {+ return this.asAndroidRuntimeShader()+}++fun RuntimeShader.asAndroidRuntimeShader(): android.graphics.RuntimeShader {+ return (this as AndroidRuntimeShader).shader+}++@RequiresApi(Build.VERSION_CODES.TIRAMISU)+internal class AndroidRuntimeShader(val shader: android.graphics.RuntimeShader) : RuntimeShader {++ override fun setFloatUniform(name: String, value: Float) {+ shader.setFloatUniform(name, value)+ }++ override fun setFloatUniform(name: String, value1: Float, value2: Float) {+ shader.setFloatUniform(name, value1, value2)+ }++ override fun setFloatUniform(name: String, value1: Float, value2: Float, value3: Float) {+ shader.setFloatUniform(name, value1, value2, value3)+ }++ override fun setFloatUniform(name: String, value1: Float, value2: Float, value3: Float, value4: Float) {+ shader.setFloatUniform(name, value1, value2, value3, value4)+ }++ override fun setFloatUniform(name: String, values: FloatArray) {+ shader.setFloatUniform(name, values)+ }++ override fun setIntUniform(name: String, value: Int) {+ shader.setIntUniform(name, value)+ }++ override fun setIntUniform(name: String, value1: Int, value2: Int) {+ shader.setIntUniform(name, value1, value2)+ }++ override fun setIntUniform(name: String, value1: Int, value2: Int, value3: Int) {+ shader.setIntUniform(name, value1, value2, value3)+ }++ override fun setIntUniform(name: String, value1: Int, value2: Int, value3: Int, value4: Int) {+ shader.setIntUniform(name, value1, value2, value3, value4)+ }++ override fun setIntUniform(name: String, values: IntArray) {+ shader.setIntUniform(name, values)+ }++ override fun setColorUniform(name: String, color: Color) {+ shader.setColorUniform(name, color.toArgb())+ }+}diff --git a/AndroidLiquidGlass-kmp/backdrop/src/androidMain/kotlin/com/kyant/backdrop/internal/Paint.kt b/AndroidLiquidGlass-kmp/backdrop/src/androidMain/kotlin/com/kyant/backdrop/internal/Paint.ktnew file mode 100644index 0000000..081428b--- /dev/null+++ b/AndroidLiquidGlass-kmp/backdrop/src/androidMain/kotlin/com/kyant/backdrop/internal/Paint.kt@@ -0,0 +1,16 @@+package com.kyant.backdrop.internal++import android.graphics.BlurMaskFilter+import androidx.compose.ui.graphics.Paint+import com.kyant.backdrop.RuntimeShader+import com.kyant.backdrop.asAndroidRuntimeShader++internal actual fun Paint.blur(radius: Float) {+ this.asFrameworkPaint().maskFilter =+ if (radius > 0f) BlurMaskFilter(radius, BlurMaskFilter.Blur.NORMAL)+ else null+}++internal actual fun Paint.setRuntimeShader(runtimeShader: RuntimeShader?) {+ this.asFrameworkPaint().shader = runtimeShader?.asAndroidRuntimeShader()+}diff --git a/AndroidLiquidGlass-kmp/backdrop/src/androidMain/kotlin/com/kyant/backdrop/internal/RenderEffect.kt b/AndroidLiquidGlass-kmp/backdrop/src/androidMain/kotlin/com/kyant/backdrop/internal/RenderEffect.ktnew file mode 100644index 0000000..22048e9--- /dev/null+++ b/AndroidLiquidGlass-kmp/backdrop/src/androidMain/kotlin/com/kyant/backdrop/internal/RenderEffect.kt@@ -0,0 +1,50 @@+package com.kyant.backdrop.internal++import android.os.Build+import androidx.annotation.RequiresApi+import androidx.compose.ui.graphics.ColorFilter+import androidx.compose.ui.graphics.RenderEffect+import androidx.compose.ui.graphics.asAndroidColorFilter+import androidx.compose.ui.graphics.asComposeRenderEffect+import com.kyant.backdrop.RuntimeShader+import com.kyant.backdrop.asAndroidRuntimeShader++@RequiresApi(Build.VERSION_CODES.S)+internal actual fun RenderEffect?.chain(other: RenderEffect): RenderEffect {+ return if (this != null) {+ android.graphics.RenderEffect.createChainEffect(+ other.asAndroidRenderEffect(),+ this.asAndroidRenderEffect()+ ).asComposeRenderEffect()+ } else {+ other+ }+}++@RequiresApi(Build.VERSION_CODES.TIRAMISU)+internal actual fun RuntimeShaderEffect(+ runtimeShader: RuntimeShader,+ uniformShaderName: String+): RenderEffect {+ return android.graphics.RenderEffect.createRuntimeShaderEffect(+ runtimeShader.asAndroidRuntimeShader(),+ uniformShaderName+ ).asComposeRenderEffect()+}++@RequiresApi(Build.VERSION_CODES.S)+internal actual fun ColorFilterEffect(+ renderEffect: RenderEffect?,+ colorFilter: ColorFilter+): RenderEffect {+ return if (renderEffect != null) {+ android.graphics.RenderEffect.createColorFilterEffect(+ colorFilter.asAndroidColorFilter(),+ renderEffect.asAndroidRenderEffect()+ ).asComposeRenderEffect()+ } else {+ android.graphics.RenderEffect.createColorFilterEffect(+ colorFilter.asAndroidColorFilter(),+ ).asComposeRenderEffect()+ }+}diff --git a/AndroidLiquidGlass-kmp/backdrop/src/commonMain/kotlin/com/kyant/backdrop/Backdrop.kt b/AndroidLiquidGlass-kmp/backdrop/src/commonMain/kotlin/com/kyant/backdrop/Backdrop.ktnew file mode 100644index 0000000..a617938--- /dev/null+++ b/AndroidLiquidGlass-kmp/backdrop/src/commonMain/kotlin/com/kyant/backdrop/Backdrop.kt@@ -0,0 +1,17 @@+package com.kyant.backdrop++import androidx.compose.ui.graphics.GraphicsLayerScope+import androidx.compose.ui.graphics.drawscope.DrawScope+import androidx.compose.ui.layout.LayoutCoordinates+import androidx.compose.ui.unit.Density++interface Backdrop {++ val isCoordinatesDependent: Boolean++ fun DrawScope.drawBackdrop(+ density: Density,+ coordinates: LayoutCoordinates?,+ layerBlock: (GraphicsLayerScope.() -> Unit)? = null+ )+}diff --git a/AndroidLiquidGlass-kmp/backdrop/src/commonMain/kotlin/com/kyant/backdrop/BackdropEffectScope.kt b/AndroidLiquidGlass-kmp/backdrop/src/commonMain/kotlin/com/kyant/backdrop/BackdropEffectScope.ktnew file mode 100644index 0000000..dc42af3--- /dev/null+++ b/AndroidLiquidGlass-kmp/backdrop/src/commonMain/kotlin/com/kyant/backdrop/BackdropEffectScope.kt@@ -0,0 +1,74 @@+package com.kyant.backdrop++import androidx.compose.ui.geometry.Size+import androidx.compose.ui.graphics.RenderEffect+import androidx.compose.ui.graphics.Shape+import androidx.compose.ui.graphics.drawscope.DrawScope+import androidx.compose.ui.unit.Density+import androidx.compose.ui.unit.LayoutDirection++sealed interface BackdropEffectScope : Density, RuntimeShaderCache {++ val size: Size++ val layoutDirection: LayoutDirection++ val shape: Shape++ var padding: Float++ var renderEffect: RenderEffect?+}++internal abstract class BackdropEffectScopeImpl : BackdropEffectScope, RuntimeShaderCache {++ override var density: Float = 1f+ override var fontScale: Float = 1f+ override var size: Size = Size.Unspecified+ override var layoutDirection: LayoutDirection = LayoutDirection.Ltr+ override var padding: Float = 0f+ override var renderEffect: RenderEffect? = null++ private val runtimeShaderCache = RuntimeShaderCacheImpl()++ override fun obtainRuntimeShader(key: String, string: String): RuntimeShader {+ return runtimeShaderCache.obtainRuntimeShader(key, string)+ }++ fun update(scope: DrawScope): Boolean {+ val newDensity = scope.density+ val newFontScale = scope.fontScale+ val newSize = scope.size+ val newLayoutDirection = scope.layoutDirection++ val changed = newDensity != density ||+ newFontScale != fontScale ||+ newSize != size ||+ newLayoutDirection != layoutDirection++ if (changed) {+ density = newDensity+ fontScale = newFontScale+ size = newSize+ layoutDirection = newLayoutDirection+ }++ return changed+ }++ fun apply(effects: BackdropEffectScope.() -> Unit) {+ padding = 0f+ renderEffect = null+ effects()+ }++ fun reset() {+ density = 1f+ fontScale = 1f+ size = Size.Unspecified+ layoutDirection = LayoutDirection.Ltr+ padding = 0f+ renderEffect = null+ runtimeShaderCache.clear()+ }+}diff --git a/AndroidLiquidGlass-kmp/backdrop/src/commonMain/kotlin/com/kyant/backdrop/DrawBackdropModifier.kt b/AndroidLiquidGlass-kmp/backdrop/src/commonMain/kotlin/com/kyant/backdrop/DrawBackdropModifier.ktnew file mode 100644index 0000000..d91d6ad--- /dev/null+++ b/AndroidLiquidGlass-kmp/backdrop/src/commonMain/kotlin/com/kyant/backdrop/DrawBackdropModifier.kt@@ -0,0 +1,388 @@+package com.kyant.backdrop++import androidx.compose.runtime.getValue+import androidx.compose.runtime.mutableFloatStateOf+import androidx.compose.runtime.mutableStateOf+import androidx.compose.runtime.neverEqualPolicy+import androidx.compose.runtime.setValue+import androidx.compose.ui.Modifier+import androidx.compose.ui.graphics.GraphicsLayerScope+import androidx.compose.ui.graphics.Shape+import androidx.compose.ui.graphics.drawscope.ContentDrawScope+import androidx.compose.ui.graphics.drawscope.DrawScope+import androidx.compose.ui.graphics.graphicsLayer+import androidx.compose.ui.graphics.layer.GraphicsLayer+import androidx.compose.ui.graphics.layer.drawLayer+import androidx.compose.ui.layout.LayoutCoordinates+import androidx.compose.ui.layout.Measurable+import androidx.compose.ui.layout.MeasureResult+import androidx.compose.ui.layout.MeasureScope+import androidx.compose.ui.node.DrawModifierNode+import androidx.compose.ui.node.GlobalPositionAwareModifierNode+import androidx.compose.ui.node.LayoutModifierNode+import androidx.compose.ui.node.ModifierNodeElement+import androidx.compose.ui.node.ObserverModifierNode+import androidx.compose.ui.node.observeReads+import androidx.compose.ui.node.requireGraphicsContext+import androidx.compose.ui.platform.InspectorInfo+import androidx.compose.ui.unit.Constraints+import androidx.compose.ui.unit.IntOffset+import androidx.compose.ui.unit.IntSize+import com.kyant.backdrop.backdrops.LayerBackdrop+import com.kyant.backdrop.highlight.Highlight+import com.kyant.backdrop.highlight.HighlightElement+import com.kyant.backdrop.internal.ShapeProvider+import com.kyant.backdrop.internal.recordLayer+import com.kyant.backdrop.shadow.InnerShadow+import com.kyant.backdrop.shadow.InnerShadowElement+import com.kyant.backdrop.shadow.Shadow+import com.kyant.backdrop.shadow.ShadowElement++private val DefaultHighlight = { Highlight.Default }+private val DefaultShadow = { Shadow.Default }+private val DefaultOnDrawBackdrop: DrawScope.(DrawScope.() -> Unit) -> Unit = { it() }++fun Modifier.drawPlainBackdrop(+ backdrop: Backdrop,+ shape: () -> Shape,+ effects: BackdropEffectScope.() -> Unit,+ layerBlock: (GraphicsLayerScope.() -> Unit)? = null,+ exportedBackdrop: LayerBackdrop? = null,+ onDrawBehind: (DrawScope.() -> Unit)? = null,+ onDrawBackdrop: DrawScope.(drawBackdrop: DrawScope.() -> Unit) -> Unit = DefaultOnDrawBackdrop,+ onDrawSurface: (DrawScope.() -> Unit)? = null,+ onDrawFront: (DrawScope.() -> Unit)? = null+): Modifier {+ val shapeProvider = ShapeProvider(shape)+ return this+ .then(+ if (layerBlock != null) {+ Modifier.graphicsLayer(layerBlock)+ } else {+ Modifier+ }+ )+ .then(+ DrawBackdropElement(+ backdrop = backdrop,+ shapeProvider = shapeProvider,+ effects = effects,+ layerBlock = layerBlock,+ exportedBackdrop = exportedBackdrop,+ onDrawBehind = onDrawBehind,+ onDrawBackdrop = onDrawBackdrop,+ onDrawSurface = onDrawSurface,+ onDrawFront = onDrawFront+ )+ )+}++fun Modifier.drawBackdrop(+ backdrop: Backdrop,+ shape: () -> Shape,+ effects: BackdropEffectScope.() -> Unit,+ highlight: (() -> Highlight?)? = DefaultHighlight,+ shadow: (() -> Shadow?)? = DefaultShadow,+ innerShadow: (() -> InnerShadow?)? = null,+ layerBlock: (GraphicsLayerScope.() -> Unit)? = null,+ exportedBackdrop: LayerBackdrop? = null,+ onDrawBehind: (DrawScope.() -> Unit)? = null,+ onDrawBackdrop: DrawScope.(drawBackdrop: DrawScope.() -> Unit) -> Unit = DefaultOnDrawBackdrop,+ onDrawSurface: (DrawScope.() -> Unit)? = null,+ onDrawFront: (DrawScope.() -> Unit)? = null+): Modifier {+ val shapeProvider = ShapeProvider(shape)+ return this+ .then(+ if (layerBlock != null) {+ Modifier.graphicsLayer(layerBlock)+ } else {+ Modifier+ }+ )+ .then(+ if (innerShadow != null) {+ InnerShadowElement(+ shapeProvider = shapeProvider,+ shadow = innerShadow+ )+ } else {+ Modifier+ }+ )+ .then(+ if (shadow != null) {+ ShadowElement(+ shapeProvider = shapeProvider,+ shadow = shadow+ )+ } else {+ Modifier+ }+ )+ .then(+ if (highlight != null) {+ HighlightElement(+ shapeProvider = shapeProvider,+ highlight = highlight+ )+ } else {+ Modifier+ }+ )+ .then(+ DrawBackdropElement(+ backdrop = backdrop,+ shapeProvider = shapeProvider,+ effects = effects,+ layerBlock = layerBlock,+ exportedBackdrop = exportedBackdrop,+ onDrawBehind = onDrawBehind,+ onDrawBackdrop = onDrawBackdrop,+ onDrawSurface = onDrawSurface,+ onDrawFront = onDrawFront+ )+ )+}++private class DrawBackdropElement(+ val backdrop: Backdrop,+ val shapeProvider: ShapeProvider,+ val effects: BackdropEffectScope.() -> Unit,+ val layerBlock: (GraphicsLayerScope.() -> Unit)?,+ val exportedBackdrop: LayerBackdrop?,+ val onDrawBehind: (DrawScope.() -> Unit)?,+ val onDrawBackdrop: DrawScope.(drawBackdrop: DrawScope.() -> Unit) -> Unit,+ val onDrawSurface: (DrawScope.() -> Unit)?,+ val onDrawFront: (DrawScope.() -> Unit)?+) : ModifierNodeElement<DrawBackdropNode>() {++ override fun create(): DrawBackdropNode {+ return DrawBackdropNode(+ backdrop = backdrop,+ shapeProvider = shapeProvider,+ effects = effects,+ layerBlock = layerBlock,+ exportedBackdrop = exportedBackdrop,+ onDrawBehind = onDrawBehind,+ onDrawBackdrop = onDrawBackdrop,+ onDrawSurface = onDrawSurface,+ onDrawFront = onDrawFront+ )+ }++ override fun update(node: DrawBackdropNode) {+ node.backdrop = backdrop+ node.shapeProvider = shapeProvider+ node.effects = effects+ node.layerBlock = layerBlock+ if (node.exportedBackdrop != exportedBackdrop) {+ node.exportedBackdrop?.layerCoordinates = null+ node.exportedBackdrop = exportedBackdrop+ }+ node.onDrawBehind = onDrawBehind+ node.onDrawBackdrop = onDrawBackdrop+ node.onDrawSurface = onDrawSurface+ node.onDrawFront = onDrawFront+ node.invalidateDrawCache()+ }++ override fun InspectorInfo.inspectableProperties() {+ name = "drawBackdrop"+ properties["backdrop"] = backdrop+ properties["shapeProvider"] = shapeProvider+ properties["effects"] = effects+ properties["layerBlock"] = layerBlock+ properties["exportedBackdrop"] = exportedBackdrop+ properties["onDrawBehind"] = onDrawBehind+ properties["onDrawBackdrop"] = onDrawBackdrop+ properties["onDrawSurface"] = onDrawSurface+ properties["onDrawFront"] = onDrawFront+ }++ override fun equals(other: Any?): Boolean {+ if (this === other) return true+ if (other !is DrawBackdropElement) return false++ if (backdrop != other.backdrop) return false+ if (shapeProvider != other.shapeProvider) return false+ if (effects != other.effects) return false+ if (layerBlock != other.layerBlock) return false+ if (exportedBackdrop != other.exportedBackdrop) return false+ if (onDrawBehind != other.onDrawBehind) return false+ if (onDrawBackdrop != other.onDrawBackdrop) return false+ if (onDrawSurface != other.onDrawSurface) return false+ if (onDrawFront != other.onDrawFront) return false++ return true+ }++ override fun hashCode(): Int {+ var result = backdrop.hashCode()+ result = 31 * result + shapeProvider.hashCode()+ result = 31 * result + effects.hashCode()+ result = 31 * result + (layerBlock?.hashCode() ?: 0)+ result = 31 * result + (exportedBackdrop?.hashCode() ?: 0)+ result = 31 * result + (onDrawBehind?.hashCode() ?: 0)+ result = 31 * result + onDrawBackdrop.hashCode()+ result = 31 * result + (onDrawSurface?.hashCode() ?: 0)+ result = 31 * result + (onDrawFront?.hashCode() ?: 0)+ return result+ }+}++private class DrawBackdropNode(+ var backdrop: Backdrop,+ var shapeProvider: ShapeProvider,+ var effects: BackdropEffectScope.() -> Unit,+ var layerBlock: (GraphicsLayerScope.() -> Unit)?,+ var exportedBackdrop: LayerBackdrop?,+ var onDrawBehind: (DrawScope.() -> Unit)?,+ var onDrawBackdrop: DrawScope.(drawBackdrop: DrawScope.() -> Unit) -> Unit,+ var onDrawSurface: (DrawScope.() -> Unit)?,+ var onDrawFront: (DrawScope.() -> Unit)?+) : LayoutModifierNode, DrawModifierNode, GlobalPositionAwareModifierNode, ObserverModifierNode, Modifier.Node() {++ private val effectScope =+ object : BackdropEffectScopeImpl() {++ override val shape: Shape get() = shapeProvider.innerShape+ }++ private var graphicsLayer: GraphicsLayer? = null++ private val layoutLayerBlock: GraphicsLayerScope.() -> Unit = {+ clip = true+ shape = shapeProvider.shape+ compositingStrategy = androidx.compose.ui.graphics.CompositingStrategy.Offscreen+ }++ private var layoutCoordinates: LayoutCoordinates? by mutableStateOf(null, neverEqualPolicy())++ private var padding by mutableFloatStateOf(0f)++ private val recordBackdropBlock: (DrawScope.() -> Unit) = {+ val canvas = drawContext.canvas+ val padding = padding++ if (padding != 0f) {+ canvas.translate(padding, padding)+ }+ onDrawBackdrop {+ with(backdrop) {+ drawBackdrop(+ density = effectScope,+ coordinates = layoutCoordinates,+ layerBlock = layerBlock+ )+ }+ }+ if (padding != 0f) {+ canvas.translate(-padding, -padding)+ }+ }++ private val drawBackdropLayer: DrawScope.() -> Unit = {+ val layer = graphicsLayer+ if (layer != null) {+ val padding = padding++ recordLayer(+ layer,+ size = IntSize(+ size.width.toInt() + padding.toInt() * 2,+ size.height.toInt() + padding.toInt() * 2+ ),+ block = recordBackdropBlock+ )++ layer.topLeft =+ if (padding != 0f) IntOffset(-padding.toInt(), -padding.toInt())+ else IntOffset.Zero+ drawLayer(layer)+ }+ }++ override fun MeasureScope.measure(+ measurable: Measurable,+ constraints: Constraints+ ): MeasureResult {+ val placeable = measurable.measure(constraints)+ return layout(placeable.width, placeable.height) {+ placeable.placeWithLayer(IntOffset.Zero, layerBlock = layoutLayerBlock)+ }+ }++ override fun ContentDrawScope.draw() {+ if (effectScope.update(this)) {+ updateEffects()+ }++ onDrawBehind?.invoke(this)+ drawBackdropLayer()+ onDrawSurface?.invoke(this)+ drawContent()+ onDrawFront?.invoke(this)++ exportedBackdrop?.graphicsLayer?.let { layer ->+ recordLayer(layer) {+ onDrawBehind?.invoke(this)+ drawBackdropLayer()+ onDrawSurface?.invoke(this)+ onDrawFront?.invoke(this)+ }+ }+ }++ override fun onGloballyPositioned(coordinates: LayoutCoordinates) {+ if (coordinates.isAttached) {+ if (backdrop.isCoordinatesDependent) {+ layoutCoordinates = coordinates+ } else {+ if (layoutCoordinates != null) {+ layoutCoordinates = null+ }+ }+ exportedBackdrop?.layerCoordinates = coordinates+ }+ }++ override fun onObservedReadsChanged() {+ invalidateDrawCache()+ }++ fun invalidateDrawCache() {+ observeEffects()+ }++ private fun observeEffects() {+ observeReads { updateEffects() }+ }++ private fun updateEffects() {+ if (!isRenderEffectSupported()) return++ effectScope.apply(effects)+ graphicsLayer?.renderEffect = effectScope.renderEffect+ padding = effectScope.padding+ }++ override fun onAttach() {+ val graphicsContext = requireGraphicsContext()+ graphicsLayer = graphicsContext.createGraphicsLayer()++ observeEffects()+ }++ override fun onDetach() {+ val graphicsContext = requireGraphicsContext()+ graphicsLayer?.let { layer ->+ graphicsContext.releaseGraphicsLayer(layer)+ graphicsLayer = null+ }++ effectScope.reset()+ layoutCoordinates = null+ exportedBackdrop?.layerCoordinates = null+ }+}diff --git a/AndroidLiquidGlass-kmp/backdrop/src/commonMain/kotlin/com/kyant/backdrop/Platform.kt b/AndroidLiquidGlass-kmp/backdrop/src/commonMain/kotlin/com/kyant/backdrop/Platform.ktnew file mode 100644index 0000000..38e2b6f--- /dev/null+++ b/AndroidLiquidGlass-kmp/backdrop/src/commonMain/kotlin/com/kyant/backdrop/Platform.kt@@ -0,0 +1,5 @@+package com.kyant.backdrop++expect fun isRenderEffectSupported(): Boolean++expect fun isRuntimeShaderSupported(): Booleandiff --git a/AndroidLiquidGlass-kmp/backdrop/src/commonMain/kotlin/com/kyant/backdrop/RuntimeShader.kt b/AndroidLiquidGlass-kmp/backdrop/src/commonMain/kotlin/com/kyant/backdrop/RuntimeShader.ktnew file mode 100644index 0000000..6f318f2--- /dev/null+++ b/AndroidLiquidGlass-kmp/backdrop/src/commonMain/kotlin/com/kyant/backdrop/RuntimeShader.kt@@ -0,0 +1,26 @@+package com.kyant.backdrop++import androidx.compose.ui.graphics.Color+import androidx.compose.ui.graphics.Shader+import org.intellij.lang.annotations.Language++expect fun RuntimeShader(@Language("AGSL") shaderString: String): RuntimeShader++expect fun RuntimeShader.asComposeShader(): Shader++interface RuntimeShader {++ fun setFloatUniform(name: String, value: Float)+ fun setFloatUniform(name: String, value1: Float, value2: Float)+ fun setFloatUniform(name: String, value1: Float, value2: Float, value3: Float)+ fun setFloatUniform(name: String, value1: Float, value2: Float, value3: Float, value4: Float)+ fun setFloatUniform(name: String, values: FloatArray)++ fun setIntUniform(name: String, value: Int)+ fun setIntUniform(name: String, value1: Int, value2: Int)+ fun setIntUniform(name: String, value1: Int, value2: Int, value3: Int)+ fun setIntUniform(name: String, value1: Int, value2: Int, value3: Int, value4: Int)+ fun setIntUniform(name: String, values: IntArray)++ fun setColorUniform(name: String, color: Color)+}diff --git a/AndroidLiquidGlass-kmp/backdrop/src/commonMain/kotlin/com/kyant/backdrop/RuntimeShaderCache.kt b/AndroidLiquidGlass-kmp/backdrop/src/commonMain/kotlin/com/kyant/backdrop/RuntimeShaderCache.ktnew file mode 100644index 0000000..f7067c1--- /dev/null+++ b/AndroidLiquidGlass-kmp/backdrop/src/commonMain/kotlin/com/kyant/backdrop/RuntimeShaderCache.kt@@ -0,0 +1,21 @@+package com.kyant.backdrop++import org.intellij.lang.annotations.Language++sealed interface RuntimeShaderCache {++ fun obtainRuntimeShader(key: String, @Language("AGSL") string: String): RuntimeShader+}++internal class RuntimeShaderCacheImpl : RuntimeShaderCache {++ private val runtimeShaders = mutableMapOf<String, RuntimeShader>()++ override fun obtainRuntimeShader(key: String, string: String): RuntimeShader {+ return runtimeShaders.getOrPut(key) { RuntimeShader(string) }+ }++ fun clear() {+ runtimeShaders.clear()+ }+}diff --git a/AndroidLiquidGlass-kmp/backdrop/src/commonMain/kotlin/com/kyant/backdrop/backdrops/Backdrop.kt b/AndroidLiquidGlass-kmp/backdrop/src/commonMain/kotlin/com/kyant/backdrop/backdrops/Backdrop.ktnew file mode 100644index 0000000..92bf6ea--- /dev/null+++ b/AndroidLiquidGlass-kmp/backdrop/src/commonMain/kotlin/com/kyant/backdrop/backdrops/Backdrop.kt@@ -0,0 +1,37 @@+package com.kyant.backdrop.backdrops++import androidx.compose.runtime.Composable+import androidx.compose.runtime.Immutable+import androidx.compose.runtime.remember+import androidx.compose.ui.graphics.GraphicsLayerScope+import androidx.compose.ui.graphics.drawscope.DrawScope+import androidx.compose.ui.layout.LayoutCoordinates+import androidx.compose.ui.unit.Density+import com.kyant.backdrop.Backdrop++@Composable+fun rememberBackdrop(+ backdrop: Backdrop,+ onDraw: DrawScope.(drawBackdrop: DrawScope.() -> Unit) -> Unit+): Backdrop {+ return remember(backdrop, onDraw) {+ Backdrop(backdrop, onDraw)+ }+}++@Immutable+private class Backdrop(+ val backdrop: Backdrop,+ val onDraw: DrawScope.(drawBackdrop: DrawScope.() -> Unit) -> Unit+) : Backdrop {++ override val isCoordinatesDependent: Boolean = backdrop.isCoordinatesDependent++ override fun DrawScope.drawBackdrop(+ density: Density,+ coordinates: LayoutCoordinates?,+ layerBlock: (GraphicsLayerScope.() -> Unit)?+ ) {+ onDraw { with(backdrop) { drawBackdrop(density, coordinates, layerBlock) } }+ }+}diff --git a/AndroidLiquidGlass-kmp/backdrop/src/commonMain/kotlin/com/kyant/backdrop/backdrops/CanvasBackdrop.kt b/AndroidLiquidGlass-kmp/backdrop/src/commonMain/kotlin/com/kyant/backdrop/backdrops/CanvasBackdrop.ktnew file mode 100644index 0000000..74156eb--- /dev/null+++ b/AndroidLiquidGlass-kmp/backdrop/src/commonMain/kotlin/com/kyant/backdrop/backdrops/CanvasBackdrop.kt@@ -0,0 +1,35 @@+package com.kyant.backdrop.backdrops++import androidx.compose.runtime.Composable+import androidx.compose.runtime.Immutable+import androidx.compose.runtime.remember+import androidx.compose.ui.graphics.GraphicsLayerScope+import androidx.compose.ui.graphics.drawscope.DrawScope+import androidx.compose.ui.layout.LayoutCoordinates+import androidx.compose.ui.unit.Density+import com.kyant.backdrop.Backdrop++@Composable+fun rememberCanvasBackdrop(+ onDraw: DrawScope.() -> Unit+): Backdrop {+ return remember(onDraw) {+ CanvasBackdrop(onDraw)+ }+}++@Immutable+private class CanvasBackdrop(+ val onDraw: DrawScope.() -> Unit+) : Backdrop {++ override val isCoordinatesDependent: Boolean = false++ override fun DrawScope.drawBackdrop(+ density: Density,+ coordinates: LayoutCoordinates?,+ layerBlock: (GraphicsLayerScope.() -> Unit)?+ ) {+ onDraw()+ }+}diff --git a/AndroidLiquidGlass-kmp/backdrop/src/commonMain/kotlin/com/kyant/backdrop/backdrops/CombinedBackdrop.kt b/AndroidLiquidGlass-kmp/backdrop/src/commonMain/kotlin/com/kyant/backdrop/backdrops/CombinedBackdrop.ktnew file mode 100644index 0000000..943d3d7--- /dev/null+++ b/AndroidLiquidGlass-kmp/backdrop/src/commonMain/kotlin/com/kyant/backdrop/backdrops/CombinedBackdrop.kt@@ -0,0 +1,99 @@+package com.kyant.backdrop.backdrops++import androidx.compose.runtime.Composable+import androidx.compose.runtime.Immutable+import androidx.compose.runtime.remember+import androidx.compose.ui.graphics.GraphicsLayerScope+import androidx.compose.ui.graphics.drawscope.DrawScope+import androidx.compose.ui.layout.LayoutCoordinates+import androidx.compose.ui.unit.Density+import com.kyant.backdrop.Backdrop++@Composable+fun rememberCombinedBackdrop(+ backdrop1: Backdrop,+ backdrop2: Backdrop+): Backdrop {+ return remember(backdrop1, backdrop2) {+ Combined2Backdrops(backdrop1, backdrop2)+ }+}++@Composable+fun rememberCombinedBackdrop(+ backdrop1: Backdrop,+ backdrop2: Backdrop,+ backdrop3: Backdrop+): Backdrop {+ return remember(backdrop1, backdrop2, backdrop3) {+ Combined3Backdrops(backdrop1, backdrop2, backdrop3)+ }+}++@Composable+fun rememberCombinedBackdrop(vararg backdrops: Backdrop): Backdrop {+ return remember(*backdrops) {+ CombinedBackdrops(*backdrops)+ }+}++@Immutable+private class Combined2Backdrops(+ val backdrop1: Backdrop,+ val backdrop2: Backdrop+) : Backdrop {++ override val isCoordinatesDependent: Boolean =+ backdrop1.isCoordinatesDependent || backdrop2.isCoordinatesDependent++ override fun DrawScope.drawBackdrop(+ density: Density,+ coordinates: LayoutCoordinates?,+ layerBlock: (GraphicsLayerScope.() -> Unit)?+ ) {+ with(backdrop1) { drawBackdrop(density, coordinates, layerBlock) }+ with(backdrop2) { drawBackdrop(density, coordinates, layerBlock) }+ }+}++@Immutable+private class Combined3Backdrops(+ val backdrop1: Backdrop,+ val backdrop2: Backdrop,+ val backdrop3: Backdrop+) : Backdrop {++ override val isCoordinatesDependent: Boolean =+ backdrop1.isCoordinatesDependent ||+ backdrop2.isCoordinatesDependent ||+ backdrop3.isCoordinatesDependent++ override fun DrawScope.drawBackdrop(+ density: Density,+ coordinates: LayoutCoordinates?,+ layerBlock: (GraphicsLayerScope.() -> Unit)?+ ) {+ with(backdrop1) { drawBackdrop(density, coordinates, layerBlock) }+ with(backdrop2) { drawBackdrop(density, coordinates, layerBlock) }+ with(backdrop3) { drawBackdrop(density, coordinates, layerBlock) }+ }+}++@Immutable+private class CombinedBackdrops(+ vararg val backdrops: Backdrop+) : Backdrop {++ override val isCoordinatesDependent: Boolean =+ backdrops.any { it.isCoordinatesDependent }++ override fun DrawScope.drawBackdrop(+ density: Density,+ coordinates: LayoutCoordinates?,+ layerBlock: (GraphicsLayerScope.() -> Unit)?+ ) {+ backdrops.forEach { backdrop ->+ with(backdrop) { drawBackdrop(density, coordinates, layerBlock) }+ }+ }+}diff --git a/AndroidLiquidGlass-kmp/backdrop/src/commonMain/kotlin/com/kyant/backdrop/backdrops/EmptyBackdrop.kt b/AndroidLiquidGlass-kmp/backdrop/src/commonMain/kotlin/com/kyant/backdrop/backdrops/EmptyBackdrop.ktnew file mode 100644index 0000000..7701a8c--- /dev/null+++ b/AndroidLiquidGlass-kmp/backdrop/src/commonMain/kotlin/com/kyant/backdrop/backdrops/EmptyBackdrop.kt@@ -0,0 +1,25 @@+package com.kyant.backdrop.backdrops++import androidx.compose.runtime.Immutable+import androidx.compose.runtime.Stable+import androidx.compose.ui.graphics.GraphicsLayerScope+import androidx.compose.ui.graphics.drawscope.DrawScope+import androidx.compose.ui.layout.LayoutCoordinates+import androidx.compose.ui.unit.Density+import com.kyant.backdrop.Backdrop++@Stable+fun emptyBackdrop(): Backdrop = EmptyBackdrop++@Immutable+private object EmptyBackdrop : Backdrop {++ override val isCoordinatesDependent: Boolean = false++ override fun DrawScope.drawBackdrop(+ density: Density,+ coordinates: LayoutCoordinates?,+ layerBlock: (GraphicsLayerScope.() -> Unit)?+ ) {+ }+}diff --git a/AndroidLiquidGlass-kmp/backdrop/src/commonMain/kotlin/com/kyant/backdrop/backdrops/LayerBackdrop.kt b/AndroidLiquidGlass-kmp/backdrop/src/commonMain/kotlin/com/kyant/backdrop/backdrops/LayerBackdrop.ktnew file mode 100644index 0000000..787f532--- /dev/null+++ b/AndroidLiquidGlass-kmp/backdrop/src/commonMain/kotlin/com/kyant/backdrop/backdrops/LayerBackdrop.kt@@ -0,0 +1,74 @@+package com.kyant.backdrop.backdrops++import androidx.compose.runtime.Composable+import androidx.compose.runtime.Stable+import androidx.compose.runtime.getValue+import androidx.compose.runtime.mutableStateOf+import androidx.compose.runtime.remember+import androidx.compose.runtime.setValue+import androidx.compose.ui.graphics.GraphicsLayerScope+import androidx.compose.ui.graphics.drawscope.ContentDrawScope+import androidx.compose.ui.graphics.drawscope.DrawScope+import androidx.compose.ui.graphics.drawscope.withTransform+import androidx.compose.ui.graphics.layer.GraphicsLayer+import androidx.compose.ui.graphics.layer.drawLayer+import androidx.compose.ui.graphics.rememberGraphicsLayer+import androidx.compose.ui.layout.LayoutCoordinates+import androidx.compose.ui.layout.positionInWindow+import androidx.compose.ui.unit.Density+import com.kyant.backdrop.Backdrop+import com.kyant.backdrop.internal.InverseLayerScope++private val DefaultOnDraw: ContentDrawScope.() -> Unit = { drawContent() }++@Composable+fun rememberLayerBackdrop(+ graphicsLayer: GraphicsLayer = rememberGraphicsLayer(),+ onDraw: ContentDrawScope.() -> Unit = DefaultOnDraw+): LayerBackdrop {+ return remember(graphicsLayer, onDraw) {+ LayerBackdrop(graphicsLayer, onDraw)+ }+}++@Stable+class LayerBackdrop internal constructor(+ val graphicsLayer: GraphicsLayer,+ internal val onDraw: ContentDrawScope.() -> Unit+) : Backdrop {++ override val isCoordinatesDependent: Boolean = true++ internal var layerCoordinates: LayoutCoordinates? by mutableStateOf(null)++ private var inverseLayerScope: InverseLayerScope? = null++ override fun DrawScope.drawBackdrop(+ density: Density,+ coordinates: LayoutCoordinates?,+ layerBlock: (GraphicsLayerScope.() -> Unit)?+ ) {+ val coordinates = coordinates ?: return+ val layerCoordinates = layerCoordinates ?: return+ withTransform({+ if (layerBlock != null) {+ with(obtainInverseLayerScope()) { inverseTransform(density, layerBlock) }+ }+ val offset =+ try {+ layerCoordinates.localPositionOf(coordinates)+ } catch (_: Exception) {+ // TODO: outer transformations lead to wrong position calculation+ coordinates.positionInWindow() - layerCoordinates.positionInWindow()+ }+ translate(-offset.x, -offset.y)+ }) {+ drawLayer(graphicsLayer)+ }+ }++ private fun obtainInverseLayerScope(): InverseLayerScope {+ return inverseLayerScope?.apply { reset() }+ ?: InverseLayerScope().also { inverseLayerScope = it }+ }+}diff --git a/AndroidLiquidGlass-kmp/backdrop/src/commonMain/kotlin/com/kyant/backdrop/backdrops/LayerBackdropModifier.kt b/AndroidLiquidGlass-kmp/backdrop/src/commonMain/kotlin/com/kyant/backdrop/backdrops/LayerBackdropModifier.ktnew file mode 100644index 0000000..98bd21f--- /dev/null+++ b/AndroidLiquidGlass-kmp/backdrop/src/commonMain/kotlin/com/kyant/backdrop/backdrops/LayerBackdropModifier.kt@@ -0,0 +1,69 @@+package com.kyant.backdrop.backdrops++import androidx.compose.ui.Modifier+import androidx.compose.ui.graphics.drawscope.ContentDrawScope+import androidx.compose.ui.layout.LayoutCoordinates+import androidx.compose.ui.node.DrawModifierNode+import androidx.compose.ui.node.GlobalPositionAwareModifierNode+import androidx.compose.ui.node.ModifierNodeElement+import androidx.compose.ui.node.invalidateDraw+import androidx.compose.ui.platform.InspectorInfo+import com.kyant.backdrop.internal.recordLayer++fun Modifier.layerBackdrop(backdrop: LayerBackdrop): Modifier =+ this then LayerBackdropElement(backdrop)++private class LayerBackdropElement(+ val backdrop: LayerBackdrop+) : ModifierNodeElement<LayerBackdropNode>() {++ override fun create(): LayerBackdropNode {+ return LayerBackdropNode(backdrop)+ }++ override fun update(node: LayerBackdropNode) {+ if (node.backdrop != backdrop) {+ node.backdrop.layerCoordinates = null+ node.backdrop = backdrop+ }+ node.invalidateDraw()+ }++ override fun InspectorInfo.inspectableProperties() {+ name = "layerBackdrop"+ properties["backdrop"] = backdrop+ }++ override fun equals(other: Any?): Boolean {+ if (this === other) return true+ if (other !is LayerBackdropElement) return false++ if (backdrop != other.backdrop) return false++ return true+ }++ override fun hashCode(): Int {+ return backdrop.hashCode()+ }+}++private class LayerBackdropNode(+ var backdrop: LayerBackdrop+) : DrawModifierNode, GlobalPositionAwareModifierNode, Modifier.Node() {++ override fun ContentDrawScope.draw() {+ drawContent()+ recordLayer(backdrop.graphicsLayer) { backdrop.onDraw(this@draw) }+ }++ override fun onGloballyPositioned(coordinates: LayoutCoordinates) {+ if (coordinates.isAttached) {+ backdrop.layerCoordinates = coordinates+ }+ }++ override fun onDetach() {+ backdrop.layerCoordinates = null+ }+}diff --git a/AndroidLiquidGlass-kmp/backdrop/src/commonMain/kotlin/com/kyant/backdrop/effects/Blur.kt b/AndroidLiquidGlass-kmp/backdrop/src/commonMain/kotlin/com/kyant/backdrop/effects/Blur.ktnew file mode 100644index 0000000..39d85ba--- /dev/null+++ b/AndroidLiquidGlass-kmp/backdrop/src/commonMain/kotlin/com/kyant/backdrop/effects/Blur.kt@@ -0,0 +1,29 @@+package com.kyant.backdrop.effects++import androidx.annotation.FloatRange+import androidx.compose.ui.graphics.BlurEffect+import androidx.compose.ui.graphics.TileMode+import com.kyant.backdrop.BackdropEffectScope+import com.kyant.backdrop.isRenderEffectSupported++fun BackdropEffectScope.blur(+ @FloatRange(from = 0.0) radius: Float,+ edgeTreatment: TileMode = TileMode.Clamp+) {+ if (!isRenderEffectSupported()) return+ if (radius <= 0f) return++ if (edgeTreatment != TileMode.Clamp || renderEffect != null) {+ if (radius > padding) {+ padding = radius+ }+ }++ renderEffect =+ BlurEffect(+ renderEffect,+ radius,+ radius,+ edgeTreatment+ )+}diff --git a/AndroidLiquidGlass-kmp/backdrop/src/commonMain/kotlin/com/kyant/backdrop/effects/ColorFilter.kt b/AndroidLiquidGlass-kmp/backdrop/src/commonMain/kotlin/com/kyant/backdrop/effects/ColorFilter.ktnew file mode 100644index 0000000..0d9712b--- /dev/null+++ b/AndroidLiquidGlass-kmp/backdrop/src/commonMain/kotlin/com/kyant/backdrop/effects/ColorFilter.kt@@ -0,0 +1,75 @@+package com.kyant.backdrop.effects++import androidx.annotation.FloatRange+import androidx.compose.ui.graphics.ColorFilter+import androidx.compose.ui.graphics.ColorMatrix+import androidx.compose.ui.graphics.ColorMatrixColorFilter+import com.kyant.backdrop.BackdropEffectScope+import com.kyant.backdrop.internal.ColorFilterEffect+import com.kyant.backdrop.isRenderEffectSupported++fun BackdropEffectScope.colorFilter(colorFilter: ColorFilter) {+ if (!isRenderEffectSupported()) return++ renderEffect = ColorFilterEffect(renderEffect, colorFilter)+}++fun BackdropEffectScope.opacity(@FloatRange(from = 0.0, to = 1.0) alpha: Float) {+ val colorMatrix = ColorMatrix(+ floatArrayOf(+ 1f, 0f, 0f, 0f, 0f,+ 0f, 1f, 0f, 0f, 0f,+ 0f, 0f, 1f, 0f, 0f,+ 0f, 0f, 0f, alpha, 0f+ )+ )+ colorFilter(ColorMatrixColorFilter(colorMatrix))+}++fun BackdropEffectScope.colorControls(+ brightness: Float = 0f,+ contrast: Float = 1f,+ saturation: Float = 1f+) {+ if (brightness == 0f && contrast == 1f && saturation == 1f) {+ return+ }++ colorFilter(colorControlsColorFilter(brightness, contrast, saturation))+}++private val VibrantColorFilter = colorControlsColorFilter(saturation = 1.5f)++fun BackdropEffectScope.vibrancy() {+ colorFilter(VibrantColorFilter)+}++private fun colorControlsColorFilter(+ brightness: Float = 0f,+ contrast: Float = 1f,+ saturation: Float = 1f+): ColorFilter {+ val invSat = 1f - saturation+ val r = 0.213f * invSat+ val g = 0.715f * invSat+ val b = 0.072f * invSat++ val c = contrast+ val t = (0.5f - c * 0.5f + brightness) * 255f+ val s = saturation++ val cr = c * r+ val cg = c * g+ val cb = c * b+ val cs = c * s++ val colorMatrix = ColorMatrix(+ floatArrayOf(+ cr + cs, cg, cb, 0f, t,+ cr, cg + cs, cb, 0f, t,+ cr, cg, cb + cs, 0f, t,+ 0f, 0f, 0f, 1f, 0f+ )+ )+ return ColorMatrixColorFilter(colorMatrix)+}diff --git a/AndroidLiquidGlass-kmp/backdrop/src/commonMain/kotlin/com/kyant/backdrop/effects/Lens.kt b/AndroidLiquidGlass-kmp/backdrop/src/commonMain/kotlin/com/kyant/backdrop/effects/Lens.ktnew file mode 100644index 0000000..10af02d--- /dev/null+++ b/AndroidLiquidGlass-kmp/backdrop/src/commonMain/kotlin/com/kyant/backdrop/effects/Lens.kt@@ -0,0 +1,120 @@+package com.kyant.backdrop.effects++import androidx.annotation.FloatRange+import androidx.compose.foundation.shape.AbsoluteRoundedCornerShape+import androidx.compose.foundation.shape.CornerBasedShape+import androidx.compose.ui.unit.LayoutDirection+import androidx.compose.ui.util.fastCoerceAtLeast+import androidx.compose.ui.util.fastCoerceAtMost+import com.kyant.backdrop.BackdropEffectScope+import com.kyant.backdrop.internal.RoundedRectRefractionShaderString+import com.kyant.backdrop.internal.RoundedRectRefractionWithDispersionShaderString+import com.kyant.backdrop.internal.RuntimeShaderEffect+import com.kyant.backdrop.isRuntimeShaderSupported+import com.kyant.shapes.RoundedRectangularShape++fun BackdropEffectScope.lens(+ @FloatRange(from = 0.0) refractionHeight: Float,+ @FloatRange(from = 0.0) refractionAmount: Float,+ depthEffect: Boolean = false,+ chromaticAberration: Boolean = false+) {+ if (!isRuntimeShaderSupported()) return+ if (refractionHeight <= 0f || refractionAmount <= 0f) return++ if (padding > 0f) {+ padding = (padding - refractionHeight).fastCoerceAtLeast(0f)+ }++ val cornerRadii = cornerRadii+ val effect =+ if (cornerRadii != null) {+ val shader =+ if (!chromaticAberration) {+ obtainRuntimeShader(+ "Refraction",+ RoundedRectRefractionShaderString+ )+ } else {+ obtainRuntimeShader(+ "RefractionWithDispersion",+ RoundedRectRefractionWithDispersionShaderString+ )+ }+ shader.apply {+ setFloatUniform("size", size.width, size.height)+ setFloatUniform("offset", -padding, -padding)+ setFloatUniform("cornerRadii", cornerRadii)+ setFloatUniform("refractionHeight", refractionHeight)+ setFloatUniform("refractionAmount", -refractionAmount)+ setFloatUniform("depthEffect", if (depthEffect) 1f else 0f)+ if (chromaticAberration) {+ setFloatUniform("chromaticAberration", 1f)+ }+ }+ RuntimeShaderEffect(shader, "content")+ } else {+ throwUnsupportedSDFException()+ }+ effect(effect)+}++private val BackdropEffectScope.cornerRadii: FloatArray?+ get() = when (val shape = shape) {+ is RoundedRectangularShape -> {+ val corners = shape.corners(size, layoutDirection, this)+ floatArrayOf(+ corners.topLeft,+ corners.topRight,+ corners.bottomRight,+ corners.bottomLeft+ )+ }++ is AbsoluteRoundedCornerShape -> {+ val size = size+ val maxRadius = size.minDimension / 2f+ val topLeft = shape.topStart.toPx(size, this)+ val topRight = shape.topEnd.toPx(size, this)+ val bottomRight = shape.bottomEnd.toPx(size, this)+ val bottomLeft = shape.bottomStart.toPx(size, this)+ floatArrayOf(+ topLeft.fastCoerceAtMost(maxRadius),+ topRight.fastCoerceAtMost(maxRadius),+ bottomRight.fastCoerceAtMost(maxRadius),+ bottomLeft.fastCoerceAtMost(maxRadius)+ )+ }++ is CornerBasedShape -> {+ val size = size+ val maxRadius = size.minDimension / 2f+ val isLtr = layoutDirection == LayoutDirection.Ltr+ val topLeft =+ if (isLtr) shape.topStart.toPx(size, this)+ else shape.topEnd.toPx(size, this)+ val topRight =+ if (isLtr) shape.topEnd.toPx(size, this)+ else shape.topStart.toPx(size, this)+ val bottomRight =+ if (isLtr) shape.bottomEnd.toPx(size, this)+ else shape.bottomStart.toPx(size, this)+ val bottomLeft =+ if (isLtr) shape.bottomStart.toPx(size, this)+ else shape.bottomEnd.toPx(size, this)+ floatArrayOf(+ topLeft.fastCoerceAtMost(maxRadius),+ topRight.fastCoerceAtMost(maxRadius),+ bottomRight.fastCoerceAtMost(maxRadius),+ bottomLeft.fastCoerceAtMost(maxRadius)+ )+ }++ else -> null+ }++private fun throwUnsupportedSDFException(): Nothing {+ throw UnsupportedOperationException(+ "Only RoundedRectangularShape or CornerBasedShape is supported in lens effects."+ )+}diff --git a/AndroidLiquidGlass-kmp/backdrop/src/commonMain/kotlin/com/kyant/backdrop/effects/RenderEffect.kt b/AndroidLiquidGlass-kmp/backdrop/src/commonMain/kotlin/com/kyant/backdrop/effects/RenderEffect.ktnew file mode 100644index 0000000..0c6be84--- /dev/null+++ b/AndroidLiquidGlass-kmp/backdrop/src/commonMain/kotlin/com/kyant/backdrop/effects/RenderEffect.kt@@ -0,0 +1,34 @@+package com.kyant.backdrop.effects++import androidx.compose.ui.graphics.RenderEffect+import com.kyant.backdrop.BackdropEffectScope+import com.kyant.backdrop.RuntimeShader+import com.kyant.backdrop.internal.RuntimeShaderEffect+import com.kyant.backdrop.internal.chain+import com.kyant.backdrop.isRenderEffectSupported+import com.kyant.backdrop.isRuntimeShaderSupported+import org.intellij.lang.annotations.Language+import kotlin.contracts.ExperimentalContracts++fun BackdropEffectScope.effect(effect: RenderEffect) {+ if (!isRenderEffectSupported()) return++ renderEffect = renderEffect.chain(effect)+}++@OptIn(ExperimentalContracts::class)+fun BackdropEffectScope.runtimeShaderEffect(+ key: String,+ @Language("AGSL") shaderString: String,+ uniformShaderName: String,+ block: RuntimeShader.() -> Unit+) {+ if (!isRuntimeShaderSupported()) return++ val effect =+ RuntimeShaderEffect(+ runtimeShader = obtainRuntimeShader(key, shaderString).apply(block),+ uniformShaderName = uniformShaderName+ )+ renderEffect = renderEffect.chain(effect)+}diff --git a/AndroidLiquidGlass-kmp/backdrop/src/commonMain/kotlin/com/kyant/backdrop/highlight/Highlight.kt b/AndroidLiquidGlass-kmp/backdrop/src/commonMain/kotlin/com/kyant/backdrop/highlight/Highlight.ktnew file mode 100644index 0000000..eda956f--- /dev/null+++ b/AndroidLiquidGlass-kmp/backdrop/src/commonMain/kotlin/com/kyant/backdrop/highlight/Highlight.kt@@ -0,0 +1,28 @@+package com.kyant.backdrop.highlight++import androidx.annotation.FloatRange+import androidx.compose.runtime.Immutable+import androidx.compose.runtime.Stable+import androidx.compose.ui.unit.Dp+import androidx.compose.ui.unit.dp++@Immutable+data class Highlight(+ val width: Dp = 0.5f.dp,+ val blurRadius: Dp = width / 2f,+ @param:FloatRange(from = 0.0, to = 1.0) val alpha: Float = 1f,+ val style: HighlightStyle = HighlightStyle.Default+) {++ companion object {++ @Stable+ val Default: Highlight = Highlight()++ @Stable+ val Ambient: Highlight = Highlight(style = HighlightStyle.Ambient)++ @Stable+ val Plain: Highlight = Highlight(style = HighlightStyle.Plain)+ }+}diff --git a/AndroidLiquidGlass-kmp/backdrop/src/commonMain/kotlin/com/kyant/backdrop/highlight/HighlightModifier.kt b/AndroidLiquidGlass-kmp/backdrop/src/commonMain/kotlin/com/kyant/backdrop/highlight/HighlightModifier.ktnew file mode 100644index 0000000..60dfe39--- /dev/null+++ b/AndroidLiquidGlass-kmp/backdrop/src/commonMain/kotlin/com/kyant/backdrop/highlight/HighlightModifier.kt@@ -0,0 +1,166 @@+package com.kyant.backdrop.highlight++import androidx.compose.ui.Modifier+import androidx.compose.ui.graphics.Outline+import androidx.compose.ui.graphics.Paint+import androidx.compose.ui.graphics.PaintingStyle+import androidx.compose.ui.graphics.Path+import androidx.compose.ui.graphics.drawOutline+import androidx.compose.ui.graphics.drawscope.ContentDrawScope+import androidx.compose.ui.graphics.drawscope.DrawScope+import androidx.compose.ui.graphics.drawscope.translate+import androidx.compose.ui.graphics.layer.GraphicsLayer+import androidx.compose.ui.graphics.layer.drawLayer+import androidx.compose.ui.node.DrawModifierNode+import androidx.compose.ui.node.ModifierNodeElement+import androidx.compose.ui.node.invalidateDraw+import androidx.compose.ui.node.requireGraphicsContext+import androidx.compose.ui.platform.InspectorInfo+import androidx.compose.ui.unit.Density+import androidx.compose.ui.unit.IntSize+import androidx.compose.ui.util.fastCoerceAtMost+import com.kyant.backdrop.RuntimeShaderCacheImpl+import com.kyant.backdrop.internal.ShapeProvider+import com.kyant.backdrop.internal.blur+import com.kyant.backdrop.internal.clipOutline+import com.kyant.backdrop.internal.setRuntimeShader+import com.kyant.backdrop.isRuntimeShaderSupported+import kotlin.math.ceil++internal class HighlightElement(+ val shapeProvider: ShapeProvider,+ val highlight: () -> Highlight?+) : ModifierNodeElement<HighlightNode>() {++ override fun create(): HighlightNode {+ return HighlightNode(shapeProvider, highlight)+ }++ override fun update(node: HighlightNode) {+ node.shapeProvider = shapeProvider+ node.highlight = highlight+ node.invalidateDraw()+ }++ override fun InspectorInfo.inspectableProperties() {+ name = "highlight"+ properties["shapeProvider"] = shapeProvider+ properties["highlight"] = highlight+ }++ override fun equals(other: Any?): Boolean {+ if (this === other) return true+ if (other !is HighlightElement) return false++ if (shapeProvider != other.shapeProvider) return false+ if (highlight != other.highlight) return false++ return true+ }++ override fun hashCode(): Int {+ var result = shapeProvider.hashCode()+ result = 31 * result + highlight.hashCode()+ return result+ }+}++internal class HighlightNode(+ var shapeProvider: ShapeProvider,+ var highlight: () -> Highlight?+) : DrawModifierNode, Modifier.Node() {++ override val shouldAutoInvalidate: Boolean = false++ private var highlightLayer: GraphicsLayer? = null++ private val paint =+ Paint().apply {+ style = PaintingStyle.Stroke+ }+ private var clipPath: Path? = null++ private val runtimeShaderCache = RuntimeShaderCacheImpl()++ private var prevStyle: HighlightStyle? = null++ override fun ContentDrawScope.draw() {+ val highlight = highlight()+ if (highlight == null || highlight.width.value <= 0f) {+ return drawContent()+ }++ drawContent()++ val highlightLayer = highlightLayer+ if (highlightLayer != null) {+ val size = size+ val density: Density = this+ val layoutDirection = layoutDirection++ val safeSize =+ IntSize(+ ceil(size.width).toInt() + 2,+ ceil(size.height).toInt() + 2+ )++ val outline = shapeProvider.shape.createOutline(size, layoutDirection, density)+ val clipPath =+ if (outline is Outline.Rounded) {+ clipPath ?: Path().also { clipPath = it }+ } else {+ null+ }++ configurePaint(highlight)++ highlightLayer.alpha = highlight.alpha+ highlightLayer.blendMode = highlight.style.blendMode+ highlightLayer.record(safeSize) {+ translate(1f, 1f) {+ val canvas = drawContext.canvas+ canvas.save()+ canvas.clipOutline(outline, clipPath)+ canvas.drawOutline(outline, paint)+ canvas.restore()+ }+ }++ translate(-1f, -1f) {+ drawLayer(highlightLayer)+ }+ }+ }++ override fun onAttach() {+ val graphicsContext = requireGraphicsContext()+ highlightLayer = graphicsContext.createGraphicsLayer()+ }++ override fun onDetach() {+ val graphicsContext = requireGraphicsContext()+ highlightLayer?.let { layer ->+ graphicsContext.releaseGraphicsLayer(layer)+ highlightLayer = null+ }+ clipPath = null+ runtimeShaderCache.clear()+ prevStyle = null+ }++ private fun DrawScope.configurePaint(highlight: Highlight) {+ paint.color = highlight.style.color+ paint.strokeWidth = ceil(highlight.width.toPx().fastCoerceAtMost(size.minDimension / 2f)) * 2f+ paint.blur(highlight.blurRadius.toPx())+ if (isRuntimeShaderSupported()) {+ val shader =+ with(highlight.style) {+ createShader(+ shape = shapeProvider.shape,+ runtimeShaderCache = runtimeShaderCache+ )+ }+ paint.setRuntimeShader(shader)+ }+ }+}diff --git a/AndroidLiquidGlass-kmp/backdrop/src/commonMain/kotlin/com/kyant/backdrop/highlight/HighlightStyle.kt b/AndroidLiquidGlass-kmp/backdrop/src/commonMain/kotlin/com/kyant/backdrop/highlight/HighlightStyle.ktnew file mode 100644index 0000000..209f5b5--- /dev/null+++ b/AndroidLiquidGlass-kmp/backdrop/src/commonMain/kotlin/com/kyant/backdrop/highlight/HighlightStyle.kt@@ -0,0 +1,138 @@+package com.kyant.backdrop.highlight++import androidx.annotation.FloatRange+import androidx.compose.foundation.shape.CornerBasedShape+import androidx.compose.runtime.Immutable+import androidx.compose.runtime.Stable+import androidx.compose.ui.graphics.BlendMode+import androidx.compose.ui.graphics.Color+import androidx.compose.ui.graphics.Shape+import androidx.compose.ui.graphics.drawscope.DrawScope+import androidx.compose.ui.unit.LayoutDirection+import androidx.compose.ui.util.fastCoerceAtMost+import com.kyant.backdrop.RuntimeShader+import com.kyant.backdrop.RuntimeShaderCache+import com.kyant.backdrop.internal.AmbientHighlightShaderString+import com.kyant.backdrop.internal.DefaultHighlightShaderString+import com.kyant.backdrop.isRuntimeShaderSupported+import kotlin.math.PI++@Immutable+interface HighlightStyle {++ val color: Color++ val blendMode: BlendMode++ fun DrawScope.createShader(+ shape: Shape,+ runtimeShaderCache: RuntimeShaderCache+ ): RuntimeShader?++ @Immutable+ data class Plain(+ override val color: Color = Color.White.copy(alpha = 0.38f),+ override val blendMode: BlendMode = BlendMode.Plus+ ) : HighlightStyle {++ override fun DrawScope.createShader(+ shape: Shape,+ runtimeShaderCache: RuntimeShaderCache+ ): RuntimeShader? = null+ }++ @Immutable+ data class Default(+ override val color: Color = Color.White.copy(alpha = 0.5f),+ override val blendMode: BlendMode = BlendMode.Plus,+ val angle: Float = 45f,+ @param:FloatRange(from = 0.0) val falloff: Float = 1f+ ) : HighlightStyle {++ override fun DrawScope.createShader(+ shape: Shape,+ runtimeShaderCache: RuntimeShaderCache+ ): RuntimeShader? {+ return if (isRuntimeShaderSupported()) {+ runtimeShaderCache.obtainRuntimeShader(+ "Default",+ DefaultHighlightShaderString+ ).apply {+ setFloatUniform("size", size.width, size.height)+ setFloatUniform("cornerRadii", getCornerRadii(shape))+ setColorUniform("color", color.copy(alpha = 1f))+ setFloatUniform("angle", angle * (PI / 180f).toFloat())+ setFloatUniform("falloff", falloff)+ }+ } else {+ null+ }+ }+ }++ @Immutable+ data class Ambient(+ @param:FloatRange(from = 0.0, to = 1.0) val intensity: Float = 0.38f+ ) : HighlightStyle {++ override val color: Color = Color.White.copy(alpha = intensity)++ override val blendMode: BlendMode = DrawScope.DefaultBlendMode++ override fun DrawScope.createShader(+ shape: Shape,+ runtimeShaderCache: RuntimeShaderCache+ ): RuntimeShader? {+ return if (isRuntimeShaderSupported()) {+ runtimeShaderCache.obtainRuntimeShader(+ "Ambient",+ AmbientHighlightShaderString+ ).apply {+ setFloatUniform("size", size.width, size.height)+ setFloatUniform("cornerRadii", getCornerRadii(shape))+ setFloatUniform("angle", 45f * (PI / 180f).toFloat())+ setFloatUniform("falloff", 1f)+ }+ } else {+ null+ }+ }+ }++ companion object {++ @Stable+ val Default: Default = Default()++ @Stable+ val Ambient: Ambient = Ambient()++ @Stable+ val Plain: Plain = Plain()+ }+}++private fun DrawScope.getCornerRadii(shape: Shape): FloatArray {+ val size = size+ val maxRadius = size.minDimension / 2f+ val shape = shape as? CornerBasedShape ?: return FloatArray(4) { maxRadius }+ val isLtr = layoutDirection == LayoutDirection.Ltr+ val topLeft =+ if (isLtr) shape.topStart.toPx(size, this)+ else shape.topEnd.toPx(size, this)+ val topRight =+ if (isLtr) shape.topEnd.toPx(size, this)+ else shape.topStart.toPx(size, this)+ val bottomRight =+ if (isLtr) shape.bottomEnd.toPx(size, this)+ else shape.bottomStart.toPx(size, this)+ val bottomLeft =+ if (isLtr) shape.bottomStart.toPx(size, this)+ else shape.bottomEnd.toPx(size, this)+ return floatArrayOf(+ topLeft.fastCoerceAtMost(maxRadius),+ topRight.fastCoerceAtMost(maxRadius),+ bottomRight.fastCoerceAtMost(maxRadius),+ bottomLeft.fastCoerceAtMost(maxRadius)+ )+}diff --git a/AndroidLiquidGlass-kmp/backdrop/src/commonMain/kotlin/com/kyant/backdrop/internal/InverseLayerScope.kt b/AndroidLiquidGlass-kmp/backdrop/src/commonMain/kotlin/com/kyant/backdrop/internal/InverseLayerScope.ktnew file mode 100644index 0000000..f6827ff--- /dev/null+++ b/AndroidLiquidGlass-kmp/backdrop/src/commonMain/kotlin/com/kyant/backdrop/internal/InverseLayerScope.kt@@ -0,0 +1,130 @@+package com.kyant.backdrop.internal++import androidx.compose.ui.geometry.Offset+import androidx.compose.ui.geometry.Size+import androidx.compose.ui.graphics.BlendMode+import androidx.compose.ui.graphics.Color+import androidx.compose.ui.graphics.ColorFilter+import androidx.compose.ui.graphics.CompositingStrategy+import androidx.compose.ui.graphics.DefaultCameraDistance+import androidx.compose.ui.graphics.DefaultShadowColor+import androidx.compose.ui.graphics.GraphicsLayerScope+import androidx.compose.ui.graphics.Matrix+import androidx.compose.ui.graphics.RectangleShape+import androidx.compose.ui.graphics.RenderEffect+import androidx.compose.ui.graphics.Shape+import androidx.compose.ui.graphics.TransformOrigin+import androidx.compose.ui.graphics.drawscope.DrawTransform+import androidx.compose.ui.unit.Density+import kotlin.math.PI+import kotlin.math.cos+import kotlin.math.sin++internal class InverseLayerScope : GraphicsLayerScope {++ override var size: Size = Size.Unspecified+ override var density: Float = 1f+ override var fontScale: Float = 1f++ override var scaleX: Float = 1f+ override var scaleY: Float = 1f+ override var alpha: Float = 0f+ override var translationX: Float = 0f+ override var translationY: Float = 0f+ override var shadowElevation: Float = 0f+ override var ambientShadowColor: Color = DefaultShadowColor+ override var spotShadowColor: Color = DefaultShadowColor+ override var rotationX: Float = 0f+ override var rotationY: Float = 0f+ override var rotationZ: Float = 0f+ override var cameraDistance: Float = DefaultCameraDistance+ override var transformOrigin: TransformOrigin = TransformOrigin.Center+ override var shape: Shape = RectangleShape+ override var clip: Boolean = false+ override var renderEffect: RenderEffect? = null+ override var blendMode: BlendMode = BlendMode.SrcOver+ override var colorFilter: ColorFilter? = null+ override var compositingStrategy: CompositingStrategy = CompositingStrategy.Auto++ private var matrix: Matrix? = null++ fun DrawTransform.inverseTransform(+ density: Density,+ layerBlock: GraphicsLayerScope.() -> Unit+ ) {+ [email protected] = size+ [email protected] = density.density+ fontScale = density.fontScale++ layerBlock()++ inverseTransformAtTopLeft(+ rotationZ = rotationZ,+ scaleX = scaleX,+ scaleY = scaleY+ )+ }++ fun reset() {+ size = Size.Unspecified+ density = 1f+ fontScale = 1f++ scaleX = 1f+ scaleY = 1f+ alpha = 1f+ translationX = 0f+ translationY = 0f+ shadowElevation = 0f+ ambientShadowColor = DefaultShadowColor+ spotShadowColor = DefaultShadowColor+ rotationX = 0f+ rotationY = 0f+ rotationZ = 0f+ cameraDistance = DefaultCameraDistance+ transformOrigin = TransformOrigin.Center+ shape = RectangleShape+ clip = false+ renderEffect = null+ blendMode = BlendMode.SrcOver+ colorFilter = null+ compositingStrategy = CompositingStrategy.Auto++ matrix = null+ }++ private fun DrawTransform.inverseTransformAtTopLeft(+ rotationZ: Float = 0f,+ scaleX: Float = 1f,+ scaleY: Float = 1f+ ) {+ if (rotationZ == 0f) {+ if (scaleX != 0f && scaleY != 0f) {+ scale(1f / scaleX, 1f / scaleY, Offset.Zero)+ }+ return+ }++ val matrix = matrix ?: Matrix().also { matrix = it }+ if (matrix.values.size < 16) return++ val rz = rotationZ * (PI / 180.0)+ val rsz = sin(rz).toFloat()+ val rcz = cos(rz).toFloat()++ val a00 = rcz * scaleX+ val a01 = rsz * scaleY+ val a10 = -rsz * scaleX+ val a11 = rcz * scaleY++ val det = a00 * a11 - a01 * a10+ if (det == 0f) return+ val invDet = 1f / det+ matrix[0, 0] = a11 * invDet+ matrix[0, 1] = -a01 * invDet+ matrix[1, 0] = -a10 * invDet+ matrix[1, 1] = a00 * invDet++ transform(matrix)+ }+}diff --git a/AndroidLiquidGlass-kmp/backdrop/src/commonMain/kotlin/com/kyant/backdrop/internal/LayerRecorder.kt b/AndroidLiquidGlass-kmp/backdrop/src/commonMain/kotlin/com/kyant/backdrop/internal/LayerRecorder.ktnew file mode 100644index 0000000..6876c11--- /dev/null+++ b/AndroidLiquidGlass-kmp/backdrop/src/commonMain/kotlin/com/kyant/backdrop/internal/LayerRecorder.kt@@ -0,0 +1,26 @@+package com.kyant.backdrop.internal++import androidx.compose.ui.graphics.drawscope.DrawScope+import androidx.compose.ui.graphics.layer.GraphicsLayer+import androidx.compose.ui.node.DelegatableNode+import androidx.compose.ui.node.requireDensity+import androidx.compose.ui.unit.IntSize+import androidx.compose.ui.unit.toIntSize++context(node: DelegatableNode)+internal fun DrawScope.recordLayer(+ layer: GraphicsLayer,+ size: IntSize = this.size.toIntSize(),+ block: DrawScope.() -> Unit+) {+ val density = node.requireDensity()+ layer.record(size) {+ val prevDensity = drawContext.density+ drawContext.density = density+ try {+ this.block()+ } finally {+ drawContext.density = prevDensity+ }+ }+}diff --git a/AndroidLiquidGlass-kmp/backdrop/src/commonMain/kotlin/com/kyant/backdrop/internal/Outline.kt b/AndroidLiquidGlass-kmp/backdrop/src/commonMain/kotlin/com/kyant/backdrop/internal/Outline.ktnew file mode 100644index 0000000..1a55526--- /dev/null+++ b/AndroidLiquidGlass-kmp/backdrop/src/commonMain/kotlin/com/kyant/backdrop/internal/Outline.kt@@ -0,0 +1,18 @@+package com.kyant.backdrop.internal++import androidx.compose.ui.graphics.Canvas+import androidx.compose.ui.graphics.Outline+import androidx.compose.ui.graphics.Path++internal fun Canvas.clipOutline(outline: Outline, path: Path?) {+ when (outline) {+ is Outline.Rectangle -> clipRect(outline.rect)+ is Outline.Rounded -> {+ path!!.rewind()+ path.addRoundRect(outline.roundRect)+ clipPath(path)+ }++ is Outline.Generic -> clipPath(outline.path)+ }+}diff --git a/AndroidLiquidGlass-kmp/backdrop/src/commonMain/kotlin/com/kyant/backdrop/internal/Paint.kt b/AndroidLiquidGlass-kmp/backdrop/src/commonMain/kotlin/com/kyant/backdrop/internal/Paint.ktnew file mode 100644index 0000000..8274d69--- /dev/null+++ b/AndroidLiquidGlass-kmp/backdrop/src/commonMain/kotlin/com/kyant/backdrop/internal/Paint.kt@@ -0,0 +1,8 @@+package com.kyant.backdrop.internal++import androidx.compose.ui.graphics.Paint+import com.kyant.backdrop.RuntimeShader++internal expect fun Paint.blur(radius: Float)++internal expect fun Paint.setRuntimeShader(runtimeShader: RuntimeShader?)diff --git a/AndroidLiquidGlass-kmp/backdrop/src/commonMain/kotlin/com/kyant/backdrop/internal/RenderEffect.kt b/AndroidLiquidGlass-kmp/backdrop/src/commonMain/kotlin/com/kyant/backdrop/internal/RenderEffect.ktnew file mode 100644index 0000000..2e94022--- /dev/null+++ b/AndroidLiquidGlass-kmp/backdrop/src/commonMain/kotlin/com/kyant/backdrop/internal/RenderEffect.kt@@ -0,0 +1,17 @@+package com.kyant.backdrop.internal++import androidx.compose.ui.graphics.ColorFilter+import androidx.compose.ui.graphics.RenderEffect+import com.kyant.backdrop.RuntimeShader++internal expect fun RenderEffect?.chain(other: RenderEffect): RenderEffect++internal expect fun RuntimeShaderEffect(+ runtimeShader: RuntimeShader,+ uniformShaderName: String+): RenderEffect++internal expect fun ColorFilterEffect(+ renderEffect: RenderEffect? = null,+ colorFilter: ColorFilter+): RenderEffectdiff --git a/AndroidLiquidGlass-kmp/backdrop/src/commonMain/kotlin/com/kyant/backdrop/internal/Shaders.kt b/AndroidLiquidGlass-kmp/backdrop/src/commonMain/kotlin/com/kyant/backdrop/internal/Shaders.ktnew file mode 100644index 0000000..a96e900--- /dev/null+++ b/AndroidLiquidGlass-kmp/backdrop/src/commonMain/kotlin/com/kyant/backdrop/internal/Shaders.kt@@ -0,0 +1,204 @@+/*+ Copyright 2025 Kyant++ Licensed under the Apache License, Version 2.0 (the "License");+ you may not use this file except in compliance with the License.+ You may obtain a copy of the License at++ http://www.apache.org/licenses/LICENSE-2.0++ Unless required by applicable law or agreed to in writing, software+ distributed under the License is distributed on an "AS IS" BASIS,+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ See the License for the specific language governing permissions and+ limitations under the License.+ */++package com.kyant.backdrop.internal++import org.intellij.lang.annotations.Language++@Language("AGSL")+private const val RoundedRectSDF = """+float radiusAt(float2 coord, float4 radii) {+ if (coord.x >= 0.0) {+ if (coord.y <= 0.0) return radii.y;+ else return radii.z;+ } else {+ if (coord.y <= 0.0) return radii.x;+ else return radii.w;+ }+}++float sdRoundedRect(float2 coord, float2 halfSize, float radius) {+ float2 cornerCoord = abs(coord) - (halfSize - float2(radius));+ float outside = length(max(cornerCoord, 0.0)) - radius;+ float inside = min(max(cornerCoord.x, cornerCoord.y), 0.0);+ return outside + inside;+}++float2 gradSdRoundedRect(float2 coord, float2 halfSize, float radius) {+ float2 cornerCoord = abs(coord) - (halfSize - float2(radius));+ if (cornerCoord.x >= 0.0 || cornerCoord.y >= 0.0) {+ return sign(coord) * normalize(max(cornerCoord, 0.0));+ } else {+ float gradX = step(cornerCoord.y, cornerCoord.x);+ return sign(coord) * float2(gradX, 1.0 - gradX);+ }+}"""++@Language("AGSL")+internal const val RoundedRectRefractionShaderString = """+uniform shader content;++uniform float2 size;+uniform float2 offset;+uniform float4 cornerRadii;+uniform float refractionHeight;+uniform float refractionAmount;+uniform float depthEffect;++$RoundedRectSDF++float circleMap(float x) {+ return 1.0 - sqrt(1.0 - x * x);+}++half4 main(float2 coord) {+ float2 halfSize = size * 0.5;+ float2 centeredCoord = (coord + offset) - halfSize;+ float radius = radiusAt(coord, cornerRadii);++ float sd = sdRoundedRect(centeredCoord, halfSize, radius);+ if (-sd >= refractionHeight) {+ return content.eval(coord);+ }+ sd = min(sd, 0.0);++ float d = circleMap(1.0 - -sd / refractionHeight) * refractionAmount;+ float gradRadius = min(radius * 1.5, min(halfSize.x, halfSize.y));+ float2 grad = normalize(gradSdRoundedRect(centeredCoord, halfSize, gradRadius) + depthEffect * normalize(centeredCoord));++ float2 refractedCoord = coord + d * grad;+ return content.eval(refractedCoord);+}"""++@Language("AGSL")+internal val RoundedRectRefractionWithDispersionShaderString = """+uniform shader content;++uniform float2 size;+uniform float2 offset;+uniform float4 cornerRadii;+uniform float refractionHeight;+uniform float refractionAmount;+uniform float depthEffect;+uniform float chromaticAberration;++$RoundedRectSDF++float circleMap(float x) {+ return 1.0 - sqrt(1.0 - x * x);+}++half4 main(float2 coord) {+ float2 halfSize = size * 0.5;+ float2 centeredCoord = (coord + offset) - halfSize;+ float radius = radiusAt(coord, cornerRadii);++ float sd = sdRoundedRect(centeredCoord, halfSize, radius);+ if (-sd >= refractionHeight) {+ return content.eval(coord);+ }+ sd = min(sd, 0.0);++ float d = circleMap(1.0 - -sd / refractionHeight) * refractionAmount;+ float gradRadius = min(radius * 1.5, min(halfSize.x, halfSize.y));+ float2 grad = normalize(gradSdRoundedRect(centeredCoord, halfSize, gradRadius) + depthEffect * normalize(centeredCoord));++ float2 refractedCoord = coord + d * grad;+ float dispersionIntensity = chromaticAberration * ((centeredCoord.x * centeredCoord.y) / (halfSize.x * halfSize.y));+ float2 dispersedCoord = d * grad * dispersionIntensity;++ half4 color = half4(0.0);++ half4 red = content.eval(refractedCoord + dispersedCoord);+ color.r += red.r / 3.5;+ color.a += red.a / 7.0;++ half4 orange = content.eval(refractedCoord + dispersedCoord * (2.0 / 3.0));+ color.r += orange.r / 3.5;+ color.g += orange.g / 7.0;+ color.a += orange.a / 7.0;++ half4 yellow = content.eval(refractedCoord + dispersedCoord * (1.0 / 3.0));+ color.r += yellow.r / 3.5;+ color.g += yellow.g / 3.5;+ color.a += yellow.a / 7.0;++ half4 green = content.eval(refractedCoord);+ color.g += green.g / 3.5;+ color.a += green.a / 7.0;++ half4 cyan = content.eval(refractedCoord - dispersedCoord * (1.0 / 3.0));+ color.g += cyan.g / 3.5;+ color.b += cyan.b / 3.0;+ color.a += cyan.a / 7.0;++ half4 blue = content.eval(refractedCoord - dispersedCoord * (2.0 / 3.0));+ color.b += blue.b / 3.0;+ color.a += blue.a / 7.0;++ half4 purple = content.eval(refractedCoord - dispersedCoord);+ color.r += purple.r / 7.0;+ color.b += purple.b / 3.0;+ color.a += purple.a / 7.0;++ return color;+}"""++@Language("AGSL")+internal const val DefaultHighlightShaderString = """+uniform float2 size;+uniform float4 cornerRadii;+layout(color) uniform half4 color;+uniform float angle;+uniform float falloff;++$RoundedRectSDF++half4 main(float2 coord) {+ float2 halfSize = size * 0.5;+ float2 centeredCoord = coord - halfSize;+ float radius = radiusAt(coord, cornerRadii);++ float gradRadius = min(radius * 1.5, min(halfSize.x, halfSize.y));+ float2 grad = gradSdRoundedRect(centeredCoord, halfSize, gradRadius);+ float2 normal = float2(cos(angle), sin(angle));+ float d = dot(grad, normal);+ float intensity = pow(abs(d), falloff);+ return color * intensity;+}"""++@Language("AGSL")+internal const val AmbientHighlightShaderString = """+uniform float2 size;+uniform float4 cornerRadii;+uniform float angle;+uniform float falloff;++$RoundedRectSDF++half4 main(float2 coord) {+ float2 halfSize = size * 0.5;+ float2 centeredCoord = coord - halfSize;+ float radius = radiusAt(coord, cornerRadii);++ float gradRadius = min(radius * 1.5, min(halfSize.x, halfSize.y));+ float2 grad = gradSdRoundedRect(centeredCoord, halfSize, gradRadius);+ float2 normal = float2(cos(angle), sin(angle));+ float d = dot(grad, normal);+ float intensity = pow(abs(d), falloff);+ float t = step(0.0, d);+ return half4(t, t, t, 1.0) * intensity;+}"""diff --git a/AndroidLiquidGlass-kmp/backdrop/src/commonMain/kotlin/com/kyant/backdrop/internal/ShapeProvider.kt b/AndroidLiquidGlass-kmp/backdrop/src/commonMain/kotlin/com/kyant/backdrop/internal/ShapeProvider.ktnew file mode 100644index 0000000..7728916--- /dev/null+++ b/AndroidLiquidGlass-kmp/backdrop/src/commonMain/kotlin/com/kyant/backdrop/internal/ShapeProvider.kt@@ -0,0 +1,44 @@+package com.kyant.backdrop.internal++import androidx.compose.runtime.Immutable+import androidx.compose.ui.geometry.Size+import androidx.compose.ui.graphics.Outline+import androidx.compose.ui.graphics.Shape+import androidx.compose.ui.unit.Density+import androidx.compose.ui.unit.LayoutDirection++@Immutable+internal class ShapeProvider(val shapeBlock: () -> Shape) {++ private var _shape: Shape? = null+ private var _outline: Outline? = null+ private var _size: Size = Size.Unspecified+ private var _layoutDirection: LayoutDirection? = null+ private var _density: Float? = null++ val innerShape+ get() = shapeBlock()++ val shape = object : Shape {++ override fun createOutline(+ size: Size,+ layoutDirection: LayoutDirection,+ density: Density+ ): Outline {+ val shape = shapeBlock()+ if (_shape != shape) {+ _shape = shape+ _outline = null+ }+ if (_outline == null || _size != size || _layoutDirection != layoutDirection || _density != density.density) {+ _size = size+ _layoutDirection = layoutDirection+ _density = density.density+ _outline = shape.createOutline(size, layoutDirection, density)+ }++ return _outline!!+ }+ }+}diff --git a/AndroidLiquidGlass-kmp/backdrop/src/commonMain/kotlin/com/kyant/backdrop/shadow/InnerShadow.kt b/AndroidLiquidGlass-kmp/backdrop/src/commonMain/kotlin/com/kyant/backdrop/shadow/InnerShadow.ktnew file mode 100644index 0000000..1475bec--- /dev/null+++ b/AndroidLiquidGlass-kmp/backdrop/src/commonMain/kotlin/com/kyant/backdrop/shadow/InnerShadow.kt@@ -0,0 +1,41 @@+package com.kyant.backdrop.shadow++import androidx.annotation.FloatRange+import androidx.compose.runtime.Immutable+import androidx.compose.runtime.Stable+import androidx.compose.ui.graphics.BlendMode+import androidx.compose.ui.graphics.Color+import androidx.compose.ui.graphics.drawscope.DrawScope+import androidx.compose.ui.graphics.lerp+import androidx.compose.ui.unit.Dp+import androidx.compose.ui.unit.DpOffset+import androidx.compose.ui.unit.dp+import androidx.compose.ui.unit.lerp+import androidx.compose.ui.util.lerp++@Immutable+data class InnerShadow(+ val radius: Dp = 24f.dp,+ val offset: DpOffset = DpOffset(0f.dp, radius),+ val color: Color = Color.Black.copy(alpha = 0.15f),+ @param:FloatRange(from = 0.0, to = 1.0) val alpha: Float = 1f,+ val blendMode: BlendMode = DrawScope.DefaultBlendMode+) {++ companion object {++ @Stable+ val Default: InnerShadow = InnerShadow()+ }+}++@Stable+fun lerp(start: InnerShadow, stop: InnerShadow, fraction: Float): InnerShadow {+ return InnerShadow(+ radius = lerp(start.radius, stop.radius, fraction),+ offset = lerp(start.offset, stop.offset, fraction),+ color = lerp(start.color, stop.color, fraction),+ alpha = lerp(start.alpha, stop.alpha, fraction),+ blendMode = if (fraction < 0.5f) start.blendMode else stop.blendMode+ )+}diff --git a/AndroidLiquidGlass-kmp/backdrop/src/commonMain/kotlin/com/kyant/backdrop/shadow/InnerShadowModifier.kt b/AndroidLiquidGlass-kmp/backdrop/src/commonMain/kotlin/com/kyant/backdrop/shadow/InnerShadowModifier.ktnew file mode 100644index 0000000..a8aecbf--- /dev/null+++ b/AndroidLiquidGlass-kmp/backdrop/src/commonMain/kotlin/com/kyant/backdrop/shadow/InnerShadowModifier.kt@@ -0,0 +1,158 @@+package com.kyant.backdrop.shadow++import androidx.compose.ui.Modifier+import androidx.compose.ui.graphics.BlendMode+import androidx.compose.ui.graphics.BlurEffect+import androidx.compose.ui.graphics.Outline+import androidx.compose.ui.graphics.Paint+import androidx.compose.ui.graphics.Path+import androidx.compose.ui.graphics.TileMode+import androidx.compose.ui.graphics.drawOutline+import androidx.compose.ui.graphics.drawscope.ContentDrawScope+import androidx.compose.ui.graphics.drawscope.DrawScope+import androidx.compose.ui.graphics.layer.CompositingStrategy+import androidx.compose.ui.graphics.layer.GraphicsLayer+import androidx.compose.ui.graphics.layer.drawLayer+import androidx.compose.ui.node.DrawModifierNode+import androidx.compose.ui.node.ModifierNodeElement+import androidx.compose.ui.node.invalidateDraw+import androidx.compose.ui.node.requireGraphicsContext+import androidx.compose.ui.platform.InspectorInfo+import androidx.compose.ui.unit.Density+import com.kyant.backdrop.internal.ShapeProvider+import com.kyant.backdrop.internal.clipOutline+import com.kyant.backdrop.isRenderEffectSupported++internal class InnerShadowElement(+ val shapeProvider: ShapeProvider,+ val shadow: () -> InnerShadow?+) : ModifierNodeElement<InnerShadowNode>() {++ override fun create(): InnerShadowNode {+ return InnerShadowNode(shapeProvider, shadow)+ }++ override fun update(node: InnerShadowNode) {+ node.shapeProvider = shapeProvider+ node.shadow = shadow+ node.invalidateDraw()+ }++ override fun InspectorInfo.inspectableProperties() {+ name = "innerShadow"+ properties["shapeProvider"] = shapeProvider+ properties["shadow"] = shadow+ }++ override fun equals(other: Any?): Boolean {+ if (this === other) return true+ if (other !is InnerShadowElement) return false++ if (shapeProvider != other.shapeProvider) return false+ if (shadow != other.shadow) return false++ return true+ }++ override fun hashCode(): Int {+ var result = shapeProvider.hashCode()+ result = 31 * result + shadow.hashCode()+ return result+ }+}++internal class InnerShadowNode(+ var shapeProvider: ShapeProvider,+ var shadow: () -> InnerShadow?+) : DrawModifierNode, Modifier.Node() {++ override val shouldAutoInvalidate: Boolean = false++ private var shadowLayer: GraphicsLayer? = null++ private val paint = Paint()+ private var clipPath: Path? = null++ private var prevRadius = Float.NaN++ override fun ContentDrawScope.draw() {+ drawContent()++ if (!isRenderEffectSupported()) return++ val shadow = shadow() ?: return++ val shadowLayer = shadowLayer+ if (shadowLayer != null) {+ val size = size+ val density: Density = this+ val layoutDirection = layoutDirection++ val radius = shadow.radius.toPx()+ val offsetX = shadow.offset.x.toPx()+ val offsetY = shadow.offset.y.toPx()++ val outline = shapeProvider.shape.createOutline(size, layoutDirection, density)+ val clipPath =+ if (outline is Outline.Rounded) {+ clipPath ?: Path().also { clipPath = it }+ } else {+ null+ }++ configurePaint(shadow)++ shadowLayer.alpha = shadow.alpha+ shadowLayer.blendMode = shadow.blendMode+ if (prevRadius != radius) {+ shadowLayer.renderEffect =+ if (radius > 0f) {+ BlurEffect(radius, radius, TileMode.Decal)+ } else {+ null+ }+ prevRadius = radius+ }+ shadowLayer.record {+ val canvas = drawContext.canvas+ canvas.save()+ canvas.clipOutline(outline, clipPath)+ canvas.drawOutline(outline, paint)+ canvas.translate(offsetX, offsetY)+ canvas.drawOutline(outline, ShadowMaskPaint)+ canvas.translate(-offsetX, -offsetY)+ canvas.restore()+ }++ val canvas = drawContext.canvas+ canvas.save()+ canvas.clipOutline(outline, clipPath)+ drawLayer(shadowLayer)+ canvas.restore()+ }+ }++ override fun onAttach() {+ val graphicsContext = requireGraphicsContext()+ shadowLayer =+ graphicsContext.createGraphicsLayer().apply {+ compositingStrategy = CompositingStrategy.Offscreen+ }+ }++ override fun onDetach() {+ val graphicsContext = requireGraphicsContext()+ shadowLayer?.let { layer ->+ graphicsContext.releaseGraphicsLayer(layer)+ shadowLayer = null+ }+ }++ private fun DrawScope.configurePaint(shadow: InnerShadow) {+ paint.color = shadow.color+ }+}++private val ShadowMaskPaint = Paint().apply {+ blendMode = BlendMode.Clear+}diff --git a/AndroidLiquidGlass-kmp/backdrop/src/commonMain/kotlin/com/kyant/backdrop/shadow/Shadow.kt b/AndroidLiquidGlass-kmp/backdrop/src/commonMain/kotlin/com/kyant/backdrop/shadow/Shadow.ktnew file mode 100644index 0000000..24684f8--- /dev/null+++ b/AndroidLiquidGlass-kmp/backdrop/src/commonMain/kotlin/com/kyant/backdrop/shadow/Shadow.kt@@ -0,0 +1,27 @@+package com.kyant.backdrop.shadow++import androidx.annotation.FloatRange+import androidx.compose.runtime.Immutable+import androidx.compose.runtime.Stable+import androidx.compose.ui.graphics.BlendMode+import androidx.compose.ui.graphics.Color+import androidx.compose.ui.graphics.drawscope.DrawScope+import androidx.compose.ui.unit.Dp+import androidx.compose.ui.unit.DpOffset+import androidx.compose.ui.unit.dp++@Immutable+data class Shadow(+ val radius: Dp = 24f.dp,+ val offset: DpOffset = DpOffset(0f.dp, radius / 6f),+ val color: Color = Color.Black.copy(alpha = 0.1f),+ @param:FloatRange(from = 0.0, to = 1.0) val alpha: Float = 1f,+ val blendMode: BlendMode = DrawScope.DefaultBlendMode+) {++ companion object {++ @Stable+ val Default: Shadow = Shadow()+ }+}diff --git a/AndroidLiquidGlass-kmp/backdrop/src/commonMain/kotlin/com/kyant/backdrop/shadow/ShadowModifier.kt b/AndroidLiquidGlass-kmp/backdrop/src/commonMain/kotlin/com/kyant/backdrop/shadow/ShadowModifier.ktnew file mode 100644index 0000000..cd4b6e3--- /dev/null+++ b/AndroidLiquidGlass-kmp/backdrop/src/commonMain/kotlin/com/kyant/backdrop/shadow/ShadowModifier.kt@@ -0,0 +1,137 @@+package com.kyant.backdrop.shadow++import androidx.compose.ui.Modifier+import androidx.compose.ui.graphics.BlendMode+import androidx.compose.ui.graphics.Paint+import androidx.compose.ui.graphics.drawOutline+import androidx.compose.ui.graphics.drawscope.ContentDrawScope+import androidx.compose.ui.graphics.drawscope.DrawScope+import androidx.compose.ui.graphics.drawscope.translate+import androidx.compose.ui.graphics.layer.CompositingStrategy+import androidx.compose.ui.graphics.layer.GraphicsLayer+import androidx.compose.ui.graphics.layer.drawLayer+import androidx.compose.ui.node.DrawModifierNode+import androidx.compose.ui.node.ModifierNodeElement+import androidx.compose.ui.node.invalidateDraw+import androidx.compose.ui.node.requireGraphicsContext+import androidx.compose.ui.platform.InspectorInfo+import androidx.compose.ui.unit.Density+import androidx.compose.ui.unit.IntSize+import com.kyant.backdrop.internal.ShapeProvider+import com.kyant.backdrop.internal.blur+import kotlin.math.ceil++internal class ShadowElement(+ val shapeProvider: ShapeProvider,+ val shadow: () -> Shadow?+) : ModifierNodeElement<ShadowNode>() {++ override fun create(): ShadowNode {+ return ShadowNode(shapeProvider, shadow)+ }++ override fun update(node: ShadowNode) {+ node.shapeProvider = shapeProvider+ node.shadow = shadow+ node.invalidateDraw()+ }++ override fun InspectorInfo.inspectableProperties() {+ name = "shadow"+ properties["shapeProvider"] = shapeProvider+ properties["shadow"] = shadow+ }++ override fun equals(other: Any?): Boolean {+ if (this === other) return true+ if (other !is ShadowElement) return false++ if (shapeProvider != other.shapeProvider) return false+ if (shadow != other.shadow) return false++ return true+ }++ override fun hashCode(): Int {+ var result = shapeProvider.hashCode()+ result = 31 * result + shadow.hashCode()+ return result+ }+}++internal class ShadowNode(+ var shapeProvider: ShapeProvider,+ var shadow: () -> Shadow?+) : DrawModifierNode, Modifier.Node() {++ override val shouldAutoInvalidate: Boolean = false++ private var shadowLayer: GraphicsLayer? = null++ private val paint = Paint()++ override fun ContentDrawScope.draw() {+ val shadow = shadow() ?: return drawContent()++ val shadowLayer = shadowLayer+ if (shadowLayer != null) {+ val size = size+ val density: Density = this+ val layoutDirection = layoutDirection++ val radius = shadow.radius.toPx()+ val offsetX = shadow.offset.x.toPx()+ val offsetY = shadow.offset.y.toPx()+ val shadowSize = IntSize(+ ceil(size.width + radius * 4f + offsetX).toInt(),+ ceil(size.height + radius * 4f + offsetY).toInt()+ )+ val outline = shapeProvider.shape.createOutline(size, layoutDirection, density)++ configurePaint(shadow)++ shadowLayer.alpha = shadow.alpha+ shadowLayer.blendMode = shadow.blendMode+ shadowLayer.record(shadowSize) {+ translate(radius * 2f + offsetX, radius * 2f + offsetY) {+ val canvas = drawContext.canvas+ canvas.drawOutline(outline, paint)+ canvas.translate(-offsetX, -offsetY)+ canvas.drawOutline(outline, ShadowMaskPaint)+ canvas.translate(offsetX, offsetY)+ }+ }++ translate(-radius * 2f, -radius * 2f) {+ drawLayer(shadowLayer)+ }+ }++ drawContent()+ }++ override fun onAttach() {+ val graphicsContext = requireGraphicsContext()+ shadowLayer =+ graphicsContext.createGraphicsLayer().apply {+ compositingStrategy = CompositingStrategy.Offscreen+ }+ }++ override fun onDetach() {+ val graphicsContext = requireGraphicsContext()+ shadowLayer?.let { layer ->+ graphicsContext.releaseGraphicsLayer(layer)+ shadowLayer = null+ }+ }++ private fun DrawScope.configurePaint(shadow: Shadow) {+ paint.color = shadow.color+ paint.blur(shadow.radius.toPx())+ }+}++private val ShadowMaskPaint = Paint().apply {+ blendMode = BlendMode.Clear+}diff --git a/AndroidLiquidGlass-kmp/backdrop/src/skikoMain/kotlin/com/kyant/backdrop/Platform.kt b/AndroidLiquidGlass-kmp/backdrop/src/skikoMain/kotlin/com/kyant/backdrop/Platform.ktnew file mode 100644index 0000000..319c228--- /dev/null+++ b/AndroidLiquidGlass-kmp/backdrop/src/skikoMain/kotlin/com/kyant/backdrop/Platform.kt@@ -0,0 +1,5 @@+package com.kyant.backdrop++actual fun isRenderEffectSupported(): Boolean = true++actual fun isRuntimeShaderSupported(): Boolean = truediff --git a/AndroidLiquidGlass-kmp/backdrop/src/skikoMain/kotlin/com/kyant/backdrop/RuntimeShader.kt b/AndroidLiquidGlass-kmp/backdrop/src/skikoMain/kotlin/com/kyant/backdrop/RuntimeShader.ktnew file mode 100644index 0000000..ec33d6b--- /dev/null+++ b/AndroidLiquidGlass-kmp/backdrop/src/skikoMain/kotlin/com/kyant/backdrop/RuntimeShader.kt@@ -0,0 +1,71 @@+package com.kyant.backdrop++import androidx.compose.ui.graphics.Color+import androidx.compose.ui.graphics.Shader+import androidx.compose.ui.graphics.asComposeShader+import androidx.compose.ui.graphics.colorspace.ColorSpaces+import org.intellij.lang.annotations.Language+import org.jetbrains.skia.RuntimeEffect+import org.jetbrains.skia.RuntimeShaderBuilder++actual fun RuntimeShader(@Language("AGSL") shaderString: String): RuntimeShader {+ val shader = RuntimeShaderBuilder(RuntimeEffect.makeForShader(shaderString))+ return SkikoRuntimeShader(shader)+}++actual fun RuntimeShader.asComposeShader(): Shader {+ return this.asSkikoRuntimeShader().makeShader().asComposeShader()+}++fun RuntimeShader.asSkikoRuntimeShader(): RuntimeShaderBuilder {+ return (this as SkikoRuntimeShader).shader+}++internal class SkikoRuntimeShader(val shader: RuntimeShaderBuilder) : RuntimeShader {++ override fun setFloatUniform(name: String, value: Float) {+ shader.uniform(name, value)+ }++ override fun setFloatUniform(name: String, value1: Float, value2: Float) {+ shader.uniform(name, value1, value2)+ }++ override fun setFloatUniform(name: String, value1: Float, value2: Float, value3: Float) {+ shader.uniform(name, value1, value2, value3)+ }++ override fun setFloatUniform(name: String, value1: Float, value2: Float, value3: Float, value4: Float) {+ shader.uniform(name, value1, value2, value3, value4)+ }++ override fun setFloatUniform(name: String, values: FloatArray) {+ shader.uniform(name, values)+ }++ override fun setIntUniform(name: String, value: Int) {+ shader.uniform(name, value)+ }++ override fun setIntUniform(name: String, value1: Int, value2: Int) {+ shader.uniform(name, value1, value2)+ }++ override fun setIntUniform(name: String, value1: Int, value2: Int, value3: Int) {+ shader.uniform(name, value1, value2, value3)+ }++ override fun setIntUniform(name: String, value1: Int, value2: Int, value3: Int, value4: Int) {+ shader.uniform(name, value1, value2, value3, value4)+ }++ override fun setIntUniform(name: String, values: IntArray) {+ throw UnsupportedOperationException("Setting int array uniforms is not supported on Skia RuntimeShader.")+ }++ override fun setColorUniform(name: String, color: Color) {+ val srgb = color.convert(ColorSpaces.Srgb)+ val a = srgb.alpha+ shader.uniform(name, srgb.red * a, srgb.green * a, srgb.blue * a, a)+ }+}diff --git a/AndroidLiquidGlass-kmp/backdrop/src/skikoMain/kotlin/com/kyant/backdrop/internal/Paint.kt b/AndroidLiquidGlass-kmp/backdrop/src/skikoMain/kotlin/com/kyant/backdrop/internal/Paint.ktnew file mode 100644index 0000000..0bdd1c3--- /dev/null+++ b/AndroidLiquidGlass-kmp/backdrop/src/skikoMain/kotlin/com/kyant/backdrop/internal/Paint.kt@@ -0,0 +1,18 @@+package com.kyant.backdrop.internal++import androidx.compose.ui.graphics.Paint+import androidx.compose.ui.graphics.skiaPaint+import com.kyant.backdrop.RuntimeShader+import com.kyant.backdrop.asSkikoRuntimeShader+import org.jetbrains.skia.FilterBlurMode+import org.jetbrains.skia.MaskFilter++internal actual fun Paint.blur(radius: Float) {+ this.skiaPaint.maskFilter =+ if (radius > 0f) MaskFilter.makeBlur(FilterBlurMode.NORMAL, radius)+ else null+}++internal actual fun Paint.setRuntimeShader(runtimeShader: RuntimeShader?) {+ this.skiaPaint.shader = runtimeShader?.asSkikoRuntimeShader()?.makeShader()+}diff --git a/AndroidLiquidGlass-kmp/backdrop/src/skikoMain/kotlin/com/kyant/backdrop/internal/RenderEffect.kt b/AndroidLiquidGlass-kmp/backdrop/src/skikoMain/kotlin/com/kyant/backdrop/internal/RenderEffect.ktnew file mode 100644index 0000000..ee1de05--- /dev/null+++ b/AndroidLiquidGlass-kmp/backdrop/src/skikoMain/kotlin/com/kyant/backdrop/internal/RenderEffect.kt@@ -0,0 +1,40 @@+package com.kyant.backdrop.internal++import androidx.compose.ui.graphics.ColorFilter+import androidx.compose.ui.graphics.RenderEffect+import androidx.compose.ui.graphics.asComposeRenderEffect+import androidx.compose.ui.graphics.asSkiaColorFilter+import androidx.compose.ui.graphics.skiaImageFilter+import com.kyant.backdrop.RuntimeShader+import com.kyant.backdrop.asSkikoRuntimeShader+import org.jetbrains.skia.ImageFilter++internal actual fun RenderEffect?.chain(other: RenderEffect): RenderEffect {+ return if (this != null) {+ ImageFilter.makeCompose(other.skiaImageFilter, this.skiaImageFilter).asComposeRenderEffect()+ } else {+ other+ }+}++internal actual fun RuntimeShaderEffect(+ runtimeShader: RuntimeShader,+ uniformShaderName: String+): RenderEffect {+ return ImageFilter.makeRuntimeShader(+ runtimeShader.asSkikoRuntimeShader(),+ uniformShaderName,+ null+ ).asComposeRenderEffect()+}++internal actual fun ColorFilterEffect(+ renderEffect: RenderEffect?,+ colorFilter: ColorFilter+): RenderEffect {+ return ImageFilter.makeColorFilter(+ colorFilter.asSkiaColorFilter(),+ renderEffect?.skiaImageFilter,+ null+ ).asComposeRenderEffect()+}diff --git a/AndroidLiquidGlass-kmp/build.gradle.kts b/AndroidLiquidGlass-kmp/build.gradle.ktsnew file mode 100644index 0000000..8b94c5e--- /dev/null+++ b/AndroidLiquidGlass-kmp/build.gradle.kts@@ -0,0 +1,9 @@+// Top-level build file where you can add configuration options common to all sub-projects/modules.+plugins {+ alias(libs.plugins.kotlin.multiplatform) apply false+ alias(libs.plugins.kotlin.compose) apply false+ alias(libs.plugins.android.application) apply false+ alias(libs.plugins.android.multiplatform.library) apply false+ alias(libs.plugins.jetbrains.compose) apply false+ id("com.vanniktech.maven.publish") version "0.36.0" apply false+}diff --git a/AndroidLiquidGlass-kmp/gradle.properties b/AndroidLiquidGlass-kmp/gradle.propertiesnew file mode 100644index 0000000..dcad3d2--- /dev/null+++ b/AndroidLiquidGlass-kmp/gradle.properties@@ -0,0 +1,31 @@+# Project-wide Gradle settings.+# IDE (e.g. Android Studio) users:+# Gradle settings configured through the IDE *will override*+# any settings specified in this file.+# For more details on how to configure your build environment visit+# http://www.gradle.org/docs/current/userguide/build_environment.html+# Specifies the JVM arguments used for the daemon process.+# The setting is particularly useful for tweaking memory settings.+org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8+# When configured, Gradle will run in incubating parallel mode.+# This option should only be used with decoupled projects. For more details, visit+# https://developer.android.com/r/tools/gradle-multi-project-decoupled-projects+# org.gradle.parallel=true+# AndroidX package structure to make it clearer which packages are bundled with the+# Android operating system, and which are packaged with your app's APK+# https://developer.android.com/topic/libraries/support-library/androidx-rn+android.useAndroidX=true+# Kotlin code style for this project: "official" or "obsolete":+kotlin.code.style=official+# Enables namespacing of each library's R class so that its R class includes only the+# resources declared in the library itself and none from the library's dependencies,+# thereby reducing the size of the R class for that library+android.nonTransitiveRClass=true+# Enable the build cache to save time by reusing outputs produced by other successful builds.+# https://docs.gradle.org/current/userguide/build_cache.html+org.gradle.caching=true+# Enable the configuration cache to reuse the build configuration and enable parallel task execution.+# (Note that some plugins may not yet be compatible with the configuration cache.)+# https://docs.gradle.org/current/userguide/configuration_cache.html+org.gradle.configuration-cache=true+org.jetbrains.compose.experimental.macos.enabled=truediff --git a/AndroidLiquidGlass-kmp/gradle/gradle-daemon-jvm.properties b/AndroidLiquidGlass-kmp/gradle/gradle-daemon-jvm.propertiesnew file mode 100644index 0000000..d0f0b91--- /dev/null+++ b/AndroidLiquidGlass-kmp/gradle/gradle-daemon-jvm.properties@@ -0,0 +1,13 @@+#This file is generated by updateDaemonJvm+toolchainUrl.FREE_BSD.AARCH64=https\://api.foojay.io/disco/v3.0/ids/ff1d4fc92bcfc9d3799beabb4e70cfa3/redirect+toolchainUrl.FREE_BSD.X86_64=https\://api.foojay.io/disco/v3.0/ids/08ce182188ada0b93565cd9ca4a4ab32/redirect+toolchainUrl.LINUX.AARCH64=https\://api.foojay.io/disco/v3.0/ids/c5760d82d08e6c26884debb23736ea57/redirect+toolchainUrl.LINUX.X86_64=https\://api.foojay.io/disco/v3.0/ids/879378f84c64b2c76003b97a32968399/redirect+toolchainUrl.MAC_OS.AARCH64=https\://api.foojay.io/disco/v3.0/ids/021e528cbed860c875a9016f29ee13c1/redirect+toolchainUrl.MAC_OS.X86_64=https\://api.foojay.io/disco/v3.0/ids/ee5178090598fb4291558827b9f00e0d/redirect+toolchainUrl.UNIX.AARCH64=https\://api.foojay.io/disco/v3.0/ids/ff1d4fc92bcfc9d3799beabb4e70cfa3/redirect+toolchainUrl.UNIX.X86_64=https\://api.foojay.io/disco/v3.0/ids/879378f84c64b2c76003b97a32968399/redirect+toolchainUrl.WINDOWS.AARCH64=https\://api.foojay.io/disco/v3.0/ids/9b6bab41c3ef2acea6116b7821b8dc11/redirect+toolchainUrl.WINDOWS.X86_64=https\://api.foojay.io/disco/v3.0/ids/a6eb06d81d82a782734ef3b616ba2684/redirect+toolchainVendor=JETBRAINS+toolchainVersion=21diff --git a/AndroidLiquidGlass-kmp/gradle/libs.versions.toml b/AndroidLiquidGlass-kmp/gradle/libs.versions.tomlnew file mode 100644index 0000000..b542961--- /dev/null+++ b/AndroidLiquidGlass-kmp/gradle/libs.versions.toml@@ -0,0 +1,25 @@+[versions]+agp = "9.3.0"+kotlin = "2.4.10"++activity = "1.13.0"+core = "1.19.0"+compose = "1.11.1"+kyantShapes = "1.2.0"++[libraries]+androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "core" }+androidx-activity-compose = { group = "androidx.activity", name = "activity-compose", version.ref = "activity" }+compose-resources = { module = "org.jetbrains.compose.components:components-resources", version.ref = "compose" }+compose-foundation = { group = "org.jetbrains.compose.foundation", name = "foundation", version.ref = "compose" }+compose-ui = { group = "org.jetbrains.compose.ui", name = "ui", version.ref = "compose" }+compose-ui-graphics = { group = "org.jetbrains.compose.ui", name = "ui-graphics", version.ref = "compose" }+compose-material-ripple = { group = "org.jetbrains.compose.material", name = "material-ripple", version.ref = "compose" }+kyant-shapes = { group = "io.github.kyant0", name = "shapes", version.ref = "kyantShapes" }++[plugins]+android-application = { id = "com.android.application", version.ref = "agp" }+android-multiplatform-library = { id = "com.android.kotlin.multiplatform.library", version.ref = "agp" }+kotlin-multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }+kotlin-compose = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }+jetbrains-compose = { id = "org.jetbrains.compose", version.ref = "compose" }diff --git a/AndroidLiquidGlass-kmp/gradle/wrapper/gradle-wrapper.jar b/AndroidLiquidGlass-kmp/gradle/wrapper/gradle-wrapper.jarnew file mode 100644index 0000000..b1b8ef5Binary files /dev/null and b/AndroidLiquidGlass-kmp/gradle/wrapper/gradle-wrapper.jar differdiff --git a/AndroidLiquidGlass-kmp/gradle/wrapper/gradle-wrapper.properties b/AndroidLiquidGlass-kmp/gradle/wrapper/gradle-wrapper.propertiesnew file mode 100644index 0000000..eb84db6--- /dev/null+++ b/AndroidLiquidGlass-kmp/gradle/wrapper/gradle-wrapper.properties@@ -0,0 +1,9 @@+distributionBase=GRADLE_USER_HOME+distributionPath=wrapper/dists+distributionUrl=https\://services.gradle.org/distributions/gradle-9.6.0-bin.zip+networkTimeout=10000+retries=0+retryBackOffMs=500+validateDistributionUrl=true+zipStoreBase=GRADLE_USER_HOME+zipStorePath=wrapper/distsdiff --git a/AndroidLiquidGlass-kmp/gradlew b/AndroidLiquidGlass-kmp/gradlewnew file mode 100644index 0000000..b9bb139--- /dev/null+++ b/AndroidLiquidGlass-kmp/gradlew@@ -0,0 +1,248 @@+#!/bin/sh++#+# Copyright © 2015 the original authors.+#+# Licensed under the Apache License, Version 2.0 (the "License");+# you may not use this file except in compliance with the License.+# You may obtain a copy of the License at+#+# https://www.apache.org/licenses/LICENSE-2.0+#+# Unless required by applicable law or agreed to in writing, software+# distributed under the License is distributed on an "AS IS" BASIS,+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+# See the License for the specific language governing permissions and+# limitations under the License.+#+# SPDX-License-Identifier: Apache-2.0+#++##############################################################################+#+# Gradle start up script for POSIX generated by Gradle.+#+# Important for running:+#+# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is+# noncompliant, but you have some other compliant shell such as ksh or+# bash, then to run this script, type that shell name before the whole+# command line, like:+#+# ksh Gradle+#+# Busybox and similar reduced shells will NOT work, because this script+# requires all of these POSIX shell features:+# * functions;+# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,+# «${var#prefix}», «${var%suffix}», and «$( cmd )»;+# * compound commands having a testable exit status, especially «case»;+# * various built-in commands including «command», «set», and «ulimit».+#+# Important for patching:+#+# (2) This script targets any POSIX shell, so it avoids extensions provided+# by Bash, Ksh, etc; in particular arrays are avoided.+#+# The "traditional" practice of packing multiple parameters into a+# space-separated string is a well documented source of bugs and security+# problems, so this is (mostly) avoided, by progressively accumulating+# options in "$@", and eventually passing that to Java.+#+# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,+# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;+# see the in-line comments for details.+#+# There are tweaks for specific operating systems such as AIX, CygWin,+# Darwin, MinGW, and NonStop.+#+# (3) This script is generated from the Groovy template+# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt+# within the Gradle project.+#+# You can find Gradle at https://github.com/gradle/gradle/.+#+##############################################################################++# Attempt to set APP_HOME++# Resolve links: $0 may be a link+app_path=$0++# Need this for daisy-chained symlinks.+while+ APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path+ [ -h "$app_path" ]+do+ ls=$( ls -ld "$app_path" )+ link=${ls#*' -> '}+ case $link in #(+ /*) app_path=$link ;; #(+ *) app_path=$APP_HOME$link ;;+ esac+done++# This is normally unused+# shellcheck disable=SC2034+APP_BASE_NAME=${0##*/}+# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)+APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit++# Use the maximum available, or set MAX_FD != -1 to use that value.+MAX_FD=maximum++warn () {+ echo "$*"+} >&2++die () {+ echo+ echo "$*"+ echo+ exit 1+} >&2++# OS specific support (must be 'true' or 'false').+cygwin=false+msys=false+darwin=false+nonstop=false+case "$( uname )" in #(+ CYGWIN* ) cygwin=true ;; #(+ Darwin* ) darwin=true ;; #(+ MSYS* | MINGW* ) msys=true ;; #(+ NONSTOP* ) nonstop=true ;;+esac++++# Determine the Java command to use to start the JVM.+if [ -n "$JAVA_HOME" ] ; then+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then+ # IBM's JDK on AIX uses strange locations for the executables+ JAVACMD=$JAVA_HOME/jre/sh/java+ else+ JAVACMD=$JAVA_HOME/bin/java+ fi+ if [ ! -x "$JAVACMD" ] ; then+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME++Please set the JAVA_HOME variable in your environment to match the+location of your Java installation."+ fi+else+ JAVACMD=java+ if ! command -v java >/dev/null 2>&1+ then+ die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.++Please set the JAVA_HOME variable in your environment to match the+location of your Java installation."+ fi+fi++# Increase the maximum file descriptors if we can.+if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then+ case $MAX_FD in #(+ max*)+ # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.+ # shellcheck disable=SC2039,SC3045+ MAX_FD=$( ulimit -H -n ) ||+ warn "Could not query maximum file descriptor limit"+ esac+ case $MAX_FD in #(+ '' | soft) :;; #(+ *)+ # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.+ # shellcheck disable=SC2039,SC3045+ ulimit -n "$MAX_FD" ||+ warn "Could not set maximum file descriptor limit to $MAX_FD"+ esac+fi++# Collect all arguments for the java command, stacking in reverse order:+# * args from the command line+# * the main class name+# * -classpath+# * -D...appname settings+# * --module-path (only if needed)+# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.++# For Cygwin or MSYS, switch paths to Windows format before running java+if "$cygwin" || "$msys" ; then+ APP_HOME=$( cygpath --path --mixed "$APP_HOME" )++ JAVACMD=$( cygpath --unix "$JAVACMD" )++ # Now convert the arguments - kludge to limit ourselves to /bin/sh+ for arg do+ if+ case $arg in #(+ -*) false ;; # don't mess with options #(+ /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath+ [ -e "$t" ] ;; #(+ *) false ;;+ esac+ then+ arg=$( cygpath --path --ignore --mixed "$arg" )+ fi+ # Roll the args list around exactly as many times as the number of+ # args, so each arg winds up back in the position where it started, but+ # possibly modified.+ #+ # NB: a `for` loop captures its iteration list before it begins, so+ # changing the positional parameters here affects neither the number of+ # iterations, nor the values presented in `arg`.+ shift # remove old arg+ set -- "$@" "$arg" # push replacement arg+ done+fi+++# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.+DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'++# Collect all arguments for the java command:+# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,+# and any embedded shellness will be escaped.+# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be+# treated as '${Hostname}' itself on the command line.++set -- \+ "-Dorg.gradle.appname=$APP_BASE_NAME" \+ -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \+ "$@"++# Stop when "xargs" is not available.+if ! command -v xargs >/dev/null 2>&1+then+ die "xargs is not available"+fi++# Use "xargs" to parse quoted args.+#+# With -n1 it outputs one arg per line, with the quotes and backslashes removed.+#+# In Bash we could simply go:+#+# readarray ARGS < <( xargs -n1 <<<"$var" ) &&+# set -- "${ARGS[@]}" "$@"+#+# but POSIX shell has neither arrays nor command substitution, so instead we+# post-process each arg (as a line of input to sed) to backslash-escape any+# character that might be a shell metacharacter, then use eval to reverse+# that process (while maintaining the separation between arguments), and wrap+# the whole thing up as a single "set" statement.+#+# This will of course break if any of these variables contains a newline or+# an unmatched quote.+#++eval "set -- $(+ printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |+ xargs -n1 |+ sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |+ tr '\n' ' '+ )" '"$@"'++exec "$JAVACMD" "$@"diff --git a/AndroidLiquidGlass-kmp/gradlew.bat b/AndroidLiquidGlass-kmp/gradlew.batnew file mode 100644index 0000000..24c62d5--- /dev/null+++ b/AndroidLiquidGlass-kmp/gradlew.bat@@ -0,0 +1,82 @@+@rem+@rem Copyright 2015 the original author or authors.+@rem+@rem Licensed under the Apache License, Version 2.0 (the "License");+@rem you may not use this file except in compliance with the License.+@rem You may obtain a copy of the License at+@rem+@rem https://www.apache.org/licenses/LICENSE-2.0+@rem+@rem Unless required by applicable law or agreed to in writing, software+@rem distributed under the License is distributed on an "AS IS" BASIS,+@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+@rem See the License for the specific language governing permissions and+@rem limitations under the License.+@rem+@rem SPDX-License-Identifier: Apache-2.0+@rem++@if "%DEBUG%"=="" @echo off+@rem ##########################################################################+@rem+@rem Gradle startup script for Windows+@rem+@rem ##########################################################################++@rem Set local scope for the variables, and ensure extensions are enabled+setlocal EnableExtensions++set DIRNAME=%~dp0+if "%DIRNAME%"=="" set DIRNAME=.+@rem This is normally unused+set APP_BASE_NAME=%~n0+set APP_HOME=%DIRNAME%++@rem Resolve any "." and ".." in APP_HOME to make it shorter.+for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi++@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.+set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"++@rem Find java.exe+if defined JAVA_HOME goto findJavaFromJavaHome++set JAVA_EXE=java.exe+%JAVA_EXE% -version >NUL 2>&1+if %ERRORLEVEL% equ 0 goto execute++echo. 1>&2+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2+echo. 1>&2+echo Please set the JAVA_HOME variable in your environment to match the 1>&2+echo location of your Java installation. 1>&2++"%COMSPEC%" /c exit 1++:findJavaFromJavaHome+set JAVA_HOME=%JAVA_HOME:"=%+set JAVA_EXE=%JAVA_HOME%/bin/java.exe++if exist "%JAVA_EXE%" goto execute++echo. 1>&2+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2+echo. 1>&2+echo Please set the JAVA_HOME variable in your environment to match the 1>&2+echo location of your Java installation. 1>&2++"%COMSPEC%" /c exit 1++:execute+@rem Setup the command line++++@rem Execute Gradle+@rem endlocal doesn't take effect until after the line is parsed and variables are expanded+@rem which allows us to clear the local environment before executing the java command+endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel++:exitWithErrorLevel+@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts+"%COMSPEC%" /c exit %ERRORLEVEL%diff --git a/AndroidLiquidGlass-kmp/iosApp/Configuration/Config.xcconfig b/AndroidLiquidGlass-kmp/iosApp/Configuration/Config.xcconfignew file mode 100644index 0000000..ee35b6e--- /dev/null+++ b/AndroidLiquidGlass-kmp/iosApp/Configuration/Config.xcconfig@@ -0,0 +1,3 @@+TEAM_ID=+BUNDLE_ID=com.kyant.backdrop.catalog.Catalog+APP_NAME=Backdrop Catalogdiff --git a/AndroidLiquidGlass-kmp/iosApp/iosApp.xcodeproj/project.pbxproj b/AndroidLiquidGlass-kmp/iosApp/iosApp.xcodeproj/project.pbxprojnew file mode 100644index 0000000..5783c17--- /dev/null+++ b/AndroidLiquidGlass-kmp/iosApp/iosApp.xcodeproj/project.pbxproj@@ -0,0 +1,409 @@+// !$*UTF8*$!+{+ archiveVersion = 1;+ classes = {+ };+ objectVersion = 56;+ objects = {++/* Begin PBXBuildFile section */+ 058557BB273AAA24004C7B11 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 058557BA273AAA24004C7B11 /* Assets.xcassets */; };+ 058557D9273AAEEB004C7B11 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 058557D8273AAEEB004C7B11 /* Preview Assets.xcassets */; };+ 2152FB042600AC8F00CF470E /* iOSApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2152FB032600AC8F00CF470E /* iOSApp.swift */; };+ 7555FF83242A565900829871 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7555FF82242A565900829871 /* ContentView.swift */; };+/* End PBXBuildFile section */++/* Begin PBXFileReference section */+ 058557BA273AAA24004C7B11 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };+ 058557D8273AAEEB004C7B11 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = "<group>"; };+ 2152FB032600AC8F00CF470E /* iOSApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = iOSApp.swift; sourceTree = "<group>"; };+ 7555FF7B242A565900829871 /* Backdrop Catalog.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Backdrop Catalog.app"; sourceTree = BUILT_PRODUCTS_DIR; };+ 7555FF82242A565900829871 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };+ 7555FF8C242A565B00829871 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };+ AB3632DC29227652001CCB65 /* Config.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Config.xcconfig; sourceTree = "<group>"; };+/* End PBXFileReference section */++/* Begin PBXFrameworksBuildPhase section */+ B92378962B6B1156000C7307 /* Frameworks */ = {+ isa = PBXFrameworksBuildPhase;+ buildActionMask = 2147483647;+ files = (+ );+ runOnlyForDeploymentPostprocessing = 0;+ };+/* End PBXFrameworksBuildPhase section */++/* Begin PBXGroup section */+ 058557D7273AAEEB004C7B11 /* Preview Content */ = {+ isa = PBXGroup;+ children = (+ 058557D8273AAEEB004C7B11 /* Preview Assets.xcassets */,+ );+ path = "Preview Content";+ sourceTree = "<group>";+ };+ 42799AB246E5F90AF97AA0EF /* Frameworks */ = {+ isa = PBXGroup;+ children = (+ );+ name = Frameworks;+ sourceTree = "<group>";+ };+ 7555FF72242A565900829871 = {+ isa = PBXGroup;+ children = (+ AB1DB47929225F7C00F7AF9C /* Configuration */,+ 7555FF7D242A565900829871 /* iosApp */,+ 7555FF7C242A565900829871 /* Products */,+ 42799AB246E5F90AF97AA0EF /* Frameworks */,+ );+ sourceTree = "<group>";+ };+ 7555FF7C242A565900829871 /* Products */ = {+ isa = PBXGroup;+ children = (+ 7555FF7B242A565900829871 /* Backdrop Catalog.app */,+ );+ name = Products;+ sourceTree = "<group>";+ };+ 7555FF7D242A565900829871 /* iosApp */ = {+ isa = PBXGroup;+ children = (+ 058557BA273AAA24004C7B11 /* Assets.xcassets */,+ 7555FF82242A565900829871 /* ContentView.swift */,+ 7555FF8C242A565B00829871 /* Info.plist */,+ 2152FB032600AC8F00CF470E /* iOSApp.swift */,+ 058557D7273AAEEB004C7B11 /* Preview Content */,+ );+ path = iosApp;+ sourceTree = "<group>";+ };+ AB1DB47929225F7C00F7AF9C /* Configuration */ = {+ isa = PBXGroup;+ children = (+ AB3632DC29227652001CCB65 /* Config.xcconfig */,+ );+ path = Configuration;+ sourceTree = "<group>";+ };+/* End PBXGroup section */++/* Begin PBXNativeTarget section */+ 7555FF7A242A565900829871 /* iosApp */ = {+ isa = PBXNativeTarget;+ buildConfigurationList = 7555FFA5242A565B00829871 /* Build configuration list for PBXNativeTarget "iosApp" */;+ buildPhases = (+ 3D138DB422A60886ED7D114A /* Compile Kotlin */,+ F36B1CEB2AD83DDC00CB74D5 /* Compile Kotlin Framework */,+ 7555FF77242A565900829871 /* Sources */,+ B92378962B6B1156000C7307 /* Frameworks */,+ 7555FF79242A565900829871 /* Resources */,+ );+ buildRules = (+ );+ dependencies = (+ );+ name = iosApp;+ packageProductDependencies = (+ );+ productName = iosApp;+ productReference = 7555FF7B242A565900829871 /* Backdrop Catalog.app */;+ productType = "com.apple.product-type.application";+ };+/* End PBXNativeTarget section */++/* Begin PBXProject section */+ 7555FF73242A565900829871 /* Project object */ = {+ isa = PBXProject;+ attributes = {+ BuildIndependentTargetsInParallel = YES;+ LastSwiftUpdateCheck = 1130;+ LastUpgradeCheck = 1540;+ ORGANIZATIONNAME = orgName;+ TargetAttributes = {+ 7555FF7A242A565900829871 = {+ CreatedOnToolsVersion = 11.3.1;+ };+ };+ };+ buildConfigurationList = 7555FF76242A565900829871 /* Build configuration list for PBXProject "iosApp" */;+ compatibilityVersion = "Xcode 14.0";+ developmentRegion = en;+ hasScannedForEncodings = 0;+ knownRegions = (+ en,+ Base,+ );+ mainGroup = 7555FF72242A565900829871;+ packageReferences = (+ );+ productRefGroup = 7555FF7C242A565900829871 /* Products */;+ projectDirPath = "";+ projectRoot = "";+ targets = (+ 7555FF7A242A565900829871 /* iosApp */,+ );+ };+/* End PBXProject section */++/* Begin PBXResourcesBuildPhase section */+ 7555FF79242A565900829871 /* Resources */ = {+ isa = PBXResourcesBuildPhase;+ buildActionMask = 2147483647;+ files = (+ 058557D9273AAEEB004C7B11 /* Preview Assets.xcassets in Resources */,+ 058557BB273AAA24004C7B11 /* Assets.xcassets in Resources */,+ );+ runOnlyForDeploymentPostprocessing = 0;+ };+/* End PBXResourcesBuildPhase section */++/* Begin PBXShellScriptBuildPhase section */+ 3D138DB422A60886ED7D114A /* Compile Kotlin */ = {+ isa = PBXShellScriptBuildPhase;+ buildActionMask = 2147483647;+ files = (+ );+ inputPaths = (+ );+ name = "Compile Kotlin";+ outputPaths = (+ );+ runOnlyForDeploymentPostprocessing = 0;+ shellPath = /bin/sh;+ 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 :app:embedAndSignAppleFrameworkForXcode\n";+ };+ F36B1CEB2AD83DDC00CB74D5 /* Compile Kotlin Framework */ = {+ isa = PBXShellScriptBuildPhase;+ buildActionMask = 2147483647;+ files = (+ );+ inputFileListPaths = (+ );+ inputPaths = (+ );+ name = "Compile Kotlin Framework";+ outputFileListPaths = (+ );+ outputPaths = (+ );+ runOnlyForDeploymentPostprocessing = 0;+ shellPath = /bin/sh;+ 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 :app:embedAndSignAppleFrameworkForXcode\n";+ };+/* End PBXShellScriptBuildPhase section */++/* Begin PBXSourcesBuildPhase section */+ 7555FF77242A565900829871 /* Sources */ = {+ isa = PBXSourcesBuildPhase;+ buildActionMask = 2147483647;+ files = (+ 2152FB042600AC8F00CF470E /* iOSApp.swift in Sources */,+ 7555FF83242A565900829871 /* ContentView.swift in Sources */,+ );+ runOnlyForDeploymentPostprocessing = 0;+ };+/* End PBXSourcesBuildPhase section */++/* Begin XCBuildConfiguration section */+ 7555FFA3242A565B00829871 /* Debug */ = {+ isa = XCBuildConfiguration;+ baseConfigurationReference = AB3632DC29227652001CCB65 /* Config.xcconfig */;+ buildSettings = {+ ALWAYS_SEARCH_USER_PATHS = NO;+ CLANG_ANALYZER_NONNULL = YES;+ CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";+ CLANG_CXX_LIBRARY = "libc++";+ CLANG_ENABLE_MODULES = YES;+ CLANG_ENABLE_OBJC_ARC = YES;+ CLANG_ENABLE_OBJC_WEAK = YES;+ CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;+ CLANG_WARN_BOOL_CONVERSION = YES;+ CLANG_WARN_COMMA = YES;+ CLANG_WARN_CONSTANT_CONVERSION = YES;+ CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;+ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;+ CLANG_WARN_DOCUMENTATION_COMMENTS = YES;+ CLANG_WARN_EMPTY_BODY = YES;+ CLANG_WARN_ENUM_CONVERSION = YES;+ CLANG_WARN_INFINITE_RECURSION = YES;+ CLANG_WARN_INT_CONVERSION = YES;+ CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;+ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;+ CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;+ CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;+ CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;+ CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;+ CLANG_WARN_STRICT_PROTOTYPES = YES;+ CLANG_WARN_SUSPICIOUS_MOVE = YES;+ CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;+ CLANG_WARN_UNREACHABLE_CODE = YES;+ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;+ COPY_PHASE_STRIP = NO;+ DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";+ ENABLE_STRICT_OBJC_MSGSEND = YES;+ ENABLE_TESTABILITY = YES;+ ENABLE_USER_SCRIPT_SANDBOXING = NO;+ GCC_C_LANGUAGE_STANDARD = gnu11;+ GCC_DYNAMIC_NO_PIC = NO;+ GCC_NO_COMMON_BLOCKS = YES;+ GCC_OPTIMIZATION_LEVEL = 0;+ GCC_PREPROCESSOR_DEFINITIONS = (+ "DEBUG=1",+ "$(inherited)",+ );+ GCC_WARN_64_TO_32_BIT_CONVERSION = YES;+ GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;+ GCC_WARN_UNDECLARED_SELECTOR = YES;+ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;+ GCC_WARN_UNUSED_FUNCTION = YES;+ GCC_WARN_UNUSED_VARIABLE = YES;+ IPHONEOS_DEPLOYMENT_TARGET = 15.3;+ MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;+ MTL_FAST_MATH = YES;+ ONLY_ACTIVE_ARCH = YES;+ SDKROOT = iphoneos;+ SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;+ SWIFT_OPTIMIZATION_LEVEL = "-Onone";+ };+ name = Debug;+ };+ 7555FFA4242A565B00829871 /* Release */ = {+ isa = XCBuildConfiguration;+ baseConfigurationReference = AB3632DC29227652001CCB65 /* Config.xcconfig */;+ buildSettings = {+ ALWAYS_SEARCH_USER_PATHS = NO;+ CLANG_ANALYZER_NONNULL = YES;+ CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";+ CLANG_CXX_LIBRARY = "libc++";+ CLANG_ENABLE_MODULES = YES;+ CLANG_ENABLE_OBJC_ARC = YES;+ CLANG_ENABLE_OBJC_WEAK = YES;+ CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;+ CLANG_WARN_BOOL_CONVERSION = YES;+ CLANG_WARN_COMMA = YES;+ CLANG_WARN_CONSTANT_CONVERSION = YES;+ CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;+ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;+ CLANG_WARN_DOCUMENTATION_COMMENTS = YES;+ CLANG_WARN_EMPTY_BODY = YES;+ CLANG_WARN_ENUM_CONVERSION = YES;+ CLANG_WARN_INFINITE_RECURSION = YES;+ CLANG_WARN_INT_CONVERSION = YES;+ CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;+ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;+ CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;+ CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;+ CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;+ CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;+ CLANG_WARN_STRICT_PROTOTYPES = YES;+ CLANG_WARN_SUSPICIOUS_MOVE = YES;+ CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;+ CLANG_WARN_UNREACHABLE_CODE = YES;+ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;+ COPY_PHASE_STRIP = NO;+ DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";+ ENABLE_NS_ASSERTIONS = NO;+ ENABLE_STRICT_OBJC_MSGSEND = YES;+ ENABLE_USER_SCRIPT_SANDBOXING = NO;+ GCC_C_LANGUAGE_STANDARD = gnu11;+ GCC_NO_COMMON_BLOCKS = YES;+ GCC_WARN_64_TO_32_BIT_CONVERSION = YES;+ GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;+ GCC_WARN_UNDECLARED_SELECTOR = YES;+ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;+ GCC_WARN_UNUSED_FUNCTION = YES;+ GCC_WARN_UNUSED_VARIABLE = YES;+ IPHONEOS_DEPLOYMENT_TARGET = 15.3;+ MTL_ENABLE_DEBUG_INFO = NO;+ MTL_FAST_MATH = YES;+ SDKROOT = iphoneos;+ SWIFT_COMPILATION_MODE = wholemodule;+ SWIFT_OPTIMIZATION_LEVEL = "-O";+ VALIDATE_PRODUCT = YES;+ };+ name = Release;+ };+ 7555FFA6242A565B00829871 /* Debug */ = {+ isa = XCBuildConfiguration;+ buildSettings = {+ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;+ CODE_SIGN_IDENTITY = "Apple Development";+ CODE_SIGN_STYLE = Automatic;+ DEVELOPMENT_ASSET_PATHS = "\"iosApp/Preview Content\"";+ DEVELOPMENT_TEAM = "";+ ENABLE_PREVIEWS = YES;+ FRAMEWORK_SEARCH_PATHS = (+ "$(inherited)",+ "$(SRCROOT)/../shared/build/xcode-frameworks/$(CONFIGURATION)/$(SDK_NAME)\n$(SRCROOT)/../composeApp/build/xcode-frameworks/$(CONFIGURATION)/$(SDK_NAME)\n$(SRCROOT)/../app/build/xcode-frameworks/$(CONFIGURATION)/$(SDK_NAME)",+ );+ INFOPLIST_FILE = iosApp/Info.plist;+ IPHONEOS_DEPLOYMENT_TARGET = 15.3;+ LD_RUNPATH_SEARCH_PATHS = (+ "$(inherited)",+ "@executable_path/Frameworks",+ );+ PRODUCT_BUNDLE_IDENTIFIER = "${BUNDLE_ID}${TEAM_ID}";+ "PRODUCT_BUNDLE_IDENTIFIER[sdk=iphoneos*]" = com.kyant.backdrop.catalog.Catalog;+ PRODUCT_NAME = "${APP_NAME}";+ PROVISIONING_PROFILE_SPECIFIER = "";+ SWIFT_VERSION = 5.0;+ TARGETED_DEVICE_FAMILY = "1,2";+ };+ name = Debug;+ };+ 7555FFA7242A565B00829871 /* Release */ = {+ isa = XCBuildConfiguration;+ buildSettings = {+ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;+ CODE_SIGN_IDENTITY = "Apple Development";+ CODE_SIGN_STYLE = Automatic;+ DEVELOPMENT_ASSET_PATHS = "\"iosApp/Preview Content\"";+ DEVELOPMENT_TEAM = CV9F9VWMF2;+ ENABLE_PREVIEWS = YES;+ FRAMEWORK_SEARCH_PATHS = (+ "$(inherited)",+ "$(SRCROOT)/../shared/build/xcode-frameworks/$(CONFIGURATION)/$(SDK_NAME)\n$(SRCROOT)/../composeApp/build/xcode-frameworks/$(CONFIGURATION)/$(SDK_NAME)",+ );+ INFOPLIST_FILE = iosApp/Info.plist;+ IPHONEOS_DEPLOYMENT_TARGET = 15.3;+ LD_RUNPATH_SEARCH_PATHS = (+ "$(inherited)",+ "@executable_path/Frameworks",+ );+ PRODUCT_BUNDLE_IDENTIFIER = "${BUNDLE_ID}${TEAM_ID}";+ PRODUCT_NAME = "${APP_NAME}";+ PROVISIONING_PROFILE_SPECIFIER = "";+ SWIFT_VERSION = 5.0;+ TARGETED_DEVICE_FAMILY = "1,2";+ };+ name = Release;+ };+/* End XCBuildConfiguration section */++/* Begin XCConfigurationList section */+ 7555FF76242A565900829871 /* Build configuration list for PBXProject "iosApp" */ = {+ isa = XCConfigurationList;+ buildConfigurations = (+ 7555FFA3242A565B00829871 /* Debug */,+ 7555FFA4242A565B00829871 /* Release */,+ );+ defaultConfigurationIsVisible = 0;+ defaultConfigurationName = Release;+ };+ 7555FFA5242A565B00829871 /* Build configuration list for PBXNativeTarget "iosApp" */ = {+ isa = XCConfigurationList;+ buildConfigurations = (+ 7555FFA6242A565B00829871 /* Debug */,+ 7555FFA7242A565B00829871 /* Release */,+ );+ defaultConfigurationIsVisible = 0;+ defaultConfigurationName = Release;+ };+/* End XCConfigurationList section */+ };+ rootObject = 7555FF73242A565900829871 /* Project object */;+}diff --git a/AndroidLiquidGlass-kmp/iosApp/iosApp.xcodeproj/project.xcworkspace/xcuserdata/ienground.xcuserdatad/UserInterfaceState.xcuserstate b/AndroidLiquidGlass-kmp/iosApp/iosApp.xcodeproj/project.xcworkspace/xcuserdata/ienground.xcuserdatad/UserInterfaceState.xcuserstatenew file mode 100644index 0000000..7be67eaBinary files /dev/null and b/AndroidLiquidGlass-kmp/iosApp/iosApp.xcodeproj/project.xcworkspace/xcuserdata/ienground.xcuserdatad/UserInterfaceState.xcuserstate differdiff --git a/AndroidLiquidGlass-kmp/iosApp/iosApp.xcodeproj/xcuserdata/ienground.xcuserdatad/xcschemes/iosApp.xcscheme b/AndroidLiquidGlass-kmp/iosApp/iosApp.xcodeproj/xcuserdata/ienground.xcuserdatad/xcschemes/iosApp.xcschemenew file mode 100644index 0000000..e8b0256--- /dev/null+++ b/AndroidLiquidGlass-kmp/iosApp/iosApp.xcodeproj/xcuserdata/ienground.xcuserdatad/xcschemes/iosApp.xcscheme@@ -0,0 +1,70 @@+<?xml version="1.0" encoding="UTF-8"?>+<Scheme+ version = "1.7">+ <BuildAction+ parallelizeBuildables = "YES"+ buildImplicitDependencies = "YES">+ <BuildActionEntries>+ <BuildActionEntry+ buildForTesting = "YES"+ buildForRunning = "YES"+ buildForProfiling = "YES"+ buildForArchiving = "YES"+ buildForAnalyzing = "YES">+ <BuildableReference+ BuildableIdentifier = "primary"+ BlueprintIdentifier = "7555FF7A242A565900829871"+ BuildableName = "Catalog.app"+ BlueprintName = "iosApp"+ ReferencedContainer = "container:iosApp.xcodeproj">+ </BuildableReference>+ </BuildActionEntry>+ </BuildActionEntries>+ </BuildAction>+ <TestAction+ buildConfiguration = "Debug"+ selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"+ selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"+ shouldUseLaunchSchemeArgsEnv = "YES"+ shouldAutocreateTestPlan = "YES">+ </TestAction>+ <LaunchAction+ buildConfiguration = "Debug"+ selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"+ selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"+ launchStyle = "0"+ useCustomWorkingDirectory = "NO"+ ignoresPersistentStateOnLaunch = "NO"+ debugDocumentVersioning = "YES"+ debugServiceExtension = "internal"+ allowLocationSimulation = "YES">+ <BuildableProductRunnable+ runnableDebuggingMode = "0">+ <BuildableReference+ BuildableIdentifier = "primary"+ BlueprintIdentifier = "7555FF7A242A565900829871"+ BuildableName = "Catalog.app"+ BlueprintName = "iosApp"+ ReferencedContainer = "container:iosApp.xcodeproj">+ </BuildableReference>+ </BuildableProductRunnable>+ <LocationScenarioReference+ identifier = "com.apple.dt.IDEFoundation.CurrentLocationScenarioIdentifier"+ referenceType = "1">+ </LocationScenarioReference>+ </LaunchAction>+ <ProfileAction+ buildConfiguration = "Release"+ shouldUseLaunchSchemeArgsEnv = "YES"+ savedToolIdentifier = ""+ useCustomWorkingDirectory = "NO"+ debugDocumentVersioning = "YES">+ </ProfileAction>+ <AnalyzeAction+ buildConfiguration = "Debug">+ </AnalyzeAction>+ <ArchiveAction+ buildConfiguration = "Release"+ revealArchiveInOrganizer = "YES">+ </ArchiveAction>+</Scheme>diff --git a/AndroidLiquidGlass-kmp/iosApp/iosApp.xcodeproj/xcuserdata/ienground.xcuserdatad/xcschemes/xcschememanagement.plist b/AndroidLiquidGlass-kmp/iosApp/iosApp.xcodeproj/xcuserdata/ienground.xcuserdatad/xcschemes/xcschememanagement.plistnew file mode 100644index 0000000..fa59f97--- /dev/null+++ b/AndroidLiquidGlass-kmp/iosApp/iosApp.xcodeproj/xcuserdata/ienground.xcuserdatad/xcschemes/xcschememanagement.plist@@ -0,0 +1,14 @@+<?xml version="1.0" encoding="UTF-8"?>+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">+<plist version="1.0">+<dict>+ <key>SchemeUserState</key>+ <dict>+ <key>iosApp.xcscheme</key>+ <dict>+ <key>orderHint</key>+ <integer>0</integer>+ </dict>+ </dict>+</dict>+</plist>diff --git a/AndroidLiquidGlass-kmp/iosApp/iosApp/Assets.xcassets/AccentColor.colorset/Contents.json b/AndroidLiquidGlass-kmp/iosApp/iosApp/Assets.xcassets/AccentColor.colorset/Contents.jsonnew file mode 100644index 0000000..ee7e3ca--- /dev/null+++ b/AndroidLiquidGlass-kmp/iosApp/iosApp/Assets.xcassets/AccentColor.colorset/Contents.json@@ -0,0 +1,11 @@+{+ "colors" : [+ {+ "idiom" : "universal"+ }+ ],+ "info" : {+ "author" : "xcode",+ "version" : 1+ }+}\ No newline at end of filediff --git a/AndroidLiquidGlass-kmp/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/Contents.json b/AndroidLiquidGlass-kmp/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/Contents.jsonnew file mode 100644index 0000000..8edf56e--- /dev/null+++ b/AndroidLiquidGlass-kmp/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/Contents.json@@ -0,0 +1,14 @@+{+ "images" : [+ {+ "filename" : "app-icon-1024.png",+ "idiom" : "universal",+ "platform" : "ios",+ "size" : "1024x1024"+ }+ ],+ "info" : {+ "author" : "xcode",+ "version" : 1+ }+}diff --git a/AndroidLiquidGlass-kmp/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/app-icon-1024.png b/AndroidLiquidGlass-kmp/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/app-icon-1024.pngnew file mode 100644index 0000000..53fc536Binary files /dev/null and b/AndroidLiquidGlass-kmp/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/app-icon-1024.png differdiff --git a/AndroidLiquidGlass-kmp/iosApp/iosApp/Assets.xcassets/Contents.json b/AndroidLiquidGlass-kmp/iosApp/iosApp/Assets.xcassets/Contents.jsonnew file mode 100644index 0000000..4aa7c53--- /dev/null+++ b/AndroidLiquidGlass-kmp/iosApp/iosApp/Assets.xcassets/Contents.json@@ -0,0 +1,6 @@+{+ "info" : {+ "author" : "xcode",+ "version" : 1+ }+}\ No newline at end of filediff --git a/AndroidLiquidGlass-kmp/iosApp/iosApp/ContentView.swift b/AndroidLiquidGlass-kmp/iosApp/iosApp/ContentView.swiftnew file mode 100644index 0000000..9fd1cb2--- /dev/null+++ b/AndroidLiquidGlass-kmp/iosApp/iosApp/ContentView.swift@@ -0,0 +1,20 @@+import UIKit+import SwiftUI+import shared++struct ComposeView: UIViewControllerRepresentable {++ func makeUIViewController(context: Context) -> UIViewController {+ Main_iosKt.MainViewController()+ }++ func updateUIViewController(_ uiViewController: UIViewController, context: Context) {}+}++struct ContentView: View {+ var body: some View {+ ComposeView()+ .ignoresSafeArea()+ }+}+diff --git a/AndroidLiquidGlass-kmp/iosApp/iosApp/Info.plist b/AndroidLiquidGlass-kmp/iosApp/iosApp/Info.plistnew file mode 100644index 0000000..aaf5e18--- /dev/null+++ b/AndroidLiquidGlass-kmp/iosApp/iosApp/Info.plist@@ -0,0 +1,50 @@+<?xml version="1.0" encoding="UTF-8"?>+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">+<plist version="1.0">+<dict>+ <key>CADisableMinimumFrameDurationOnPhone</key>+ <true/>+ <key>CFBundleDevelopmentRegion</key>+ <string>$(DEVELOPMENT_LANGUAGE)</string>+ <key>CFBundleExecutable</key>+ <string>$(EXECUTABLE_NAME)</string>+ <key>CFBundleIdentifier</key>+ <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>+ <key>CFBundleInfoDictionaryVersion</key>+ <string>6.0</string>+ <key>CFBundleName</key>+ <string>$(PRODUCT_NAME)</string>+ <key>CFBundlePackageType</key>+ <string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>+ <key>CFBundleShortVersionString</key>+ <string>1.0</string>+ <key>CFBundleVersion</key>+ <string>1</string>+ <key>LSRequiresIPhoneOS</key>+ <true/>+ <key>UIApplicationSceneManifest</key>+ <dict>+ <key>UIApplicationSupportsMultipleScenes</key>+ <false/>+ </dict>+ <key>UILaunchScreen</key>+ <dict/>+ <key>UIRequiredDeviceCapabilities</key>+ <array>+ <string>armv7</string>+ </array>+ <key>UISupportedInterfaceOrientations</key>+ <array>+ <string>UIInterfaceOrientationPortrait</string>+ <string>UIInterfaceOrientationLandscapeLeft</string>+ <string>UIInterfaceOrientationLandscapeRight</string>+ </array>+ <key>UISupportedInterfaceOrientations~ipad</key>+ <array>+ <string>UIInterfaceOrientationPortrait</string>+ <string>UIInterfaceOrientationPortraitUpsideDown</string>+ <string>UIInterfaceOrientationLandscapeLeft</string>+ <string>UIInterfaceOrientationLandscapeRight</string>+ </array>+</dict>+</plist>diff --git a/AndroidLiquidGlass-kmp/iosApp/iosApp/Preview Content/Preview Assets.xcassets/Contents.json b/AndroidLiquidGlass-kmp/iosApp/iosApp/Preview Content/Preview Assets.xcassets/Contents.jsonnew file mode 100644index 0000000..4aa7c53--- /dev/null+++ b/AndroidLiquidGlass-kmp/iosApp/iosApp/Preview Content/Preview Assets.xcassets/Contents.json@@ -0,0 +1,6 @@+{+ "info" : {+ "author" : "xcode",+ "version" : 1+ }+}\ No newline at end of filediff --git a/AndroidLiquidGlass-kmp/iosApp/iosApp/iOSApp.swift b/AndroidLiquidGlass-kmp/iosApp/iosApp/iOSApp.swiftnew file mode 100644index 0000000..5d8e8d0--- /dev/null+++ b/AndroidLiquidGlass-kmp/iosApp/iosApp/iOSApp.swift@@ -0,0 +1,28 @@+import SwiftUI+import shared+++@main+struct iOSApp: App {++ @UIApplicationDelegateAdaptor(AppDelegate.self)+ var appDelegate: AppDelegate++ @Environment(\.scenePhase)+ var scenePhase: ScenePhase++ init() {++ }++ var body: some Scene {+ WindowGroup {+ ContentView()+ }+ }+}+++class AppDelegate: NSObject, UIApplicationDelegate {++}diff --git a/AndroidLiquidGlass-kmp/settings.gradle.kts b/AndroidLiquidGlass-kmp/settings.gradle.ktsnew file mode 100644index 0000000..60e1bee--- /dev/null+++ b/AndroidLiquidGlass-kmp/settings.gradle.kts@@ -0,0 +1,28 @@+pluginManagement {+ repositories {+ google {+ content {+ includeGroupByRegex("com\\.android.*")+ includeGroupByRegex("com\\.google.*")+ includeGroupByRegex("androidx.*")+ }+ }+ mavenCentral()+ gradlePluginPortal()+ }+}+plugins {+ id("org.gradle.toolchains.foojay-resolver-convention") version "1.0.0"+}+dependencyResolutionManagement {+ repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)+ repositories {+ google()+ mavenCentral()+ }+}++rootProject.name = "Glass"+include(":backdrop")+include(":app")+include(":androidApp")diff --git a/app/src/main/java/com/chethan616/clearpdf/ui/DocsApp.kt b/app/src/main/java/com/chethan616/clearpdf/ui/DocsApp.ktindex 5695d5f..8aec9e4 100644--- a/app/src/main/java/com/chethan616/clearpdf/ui/DocsApp.kt+++ b/app/src/main/java/com/chethan616/clearpdf/ui/DocsApp.kt@@ -2,10 +2,6 @@ package com.chethan616.clearpdf.uiimport android.content.Intentimport android.net.Uri-import android.graphics.BitmapFactory-import androidx.activity.compose.rememberLauncherForActivityResult-import androidx.activity.result.PickVisualMediaRequest-import androidx.activity.result.contract.ActivityResultContractsimport androidx.compose.foundation.Imageimport androidx.compose.foundation.clickableimport androidx.compose.foundation.isSystemInDarkTheme@@ -37,9 +33,6 @@ import androidx.compose.runtime.setValueimport androidx.compose.ui.Alignmentimport androidx.compose.ui.Modifierimport androidx.compose.ui.graphics.Color-import androidx.compose.ui.graphics.asImageBitmap-import androidx.compose.ui.graphics.painter.BitmapPainter-import androidx.compose.ui.graphics.painter.Painterimport androidx.compose.ui.layout.ContentScaleimport androidx.compose.ui.platform.LocalContextimport androidx.compose.ui.res.painterResource@@ -106,8 +99,6 @@ fun DocsApp(shortcutRoute: String? = null, incomingPdfUri: android.net.Uri? = nuModifier.fillMaxSize(),contentAlignment = Alignment.TopCenter) {- var painter: Painter? by remember { mutableStateOf(null) }-val backdrop = rememberLayerBackdrop()val navController = rememberNavController()var selectedTab by rememberSaveable { mutableIntStateOf(0) }@@ -153,7 +144,7 @@ fun DocsApp(shortcutRoute: String? = null, incomingPdfUri: android.net.Uri? = nu}Image(- painter ?: painterResource(if (!isDarkMode) R.drawable.wallpaper_light else R.drawable.wallpaper_dark),+ painterResource(if (!isDarkMode) R.drawable.wallpaper_light else R.drawable.wallpaper_dark),contentDescription = null,modifier = Modifier.layerBackdrop(backdrop)diff --git a/app/src/main/java/com/chethan616/clearpdf/ui/components/DocsBottomTabs.kt b/app/src/main/java/com/chethan616/clearpdf/ui/components/DocsBottomTabs.ktindex c6b9bc5..dc8a076 100644--- a/app/src/main/java/com/chethan616/clearpdf/ui/components/DocsBottomTabs.kt+++ b/app/src/main/java/com/chethan616/clearpdf/ui/components/DocsBottomTabs.kt@@ -1,6 +1,5 @@package com.chethan616.clearpdf.ui.components-import androidx.compose.foundation.isSystemInDarkThemeimport androidx.compose.foundation.layout.sizeimport androidx.compose.material.icons.Iconsimport androidx.compose.material.icons.rounded.Home@@ -11,6 +10,7 @@ import androidx.compose.runtime.Composableimport androidx.compose.ui.Modifierimport androidx.compose.ui.graphics.Colorimport androidx.compose.ui.unit.dp+import com.chethan616.clearpdf.ui.theme.LiquidGlassColorsimport com.chethan616.clearpdf.ui.theme.LocalIsDarkModeimport com.kyant.backdrop.Backdrop@@ -22,8 +22,7 @@ fun DocsBottomTabs(modifier: Modifier = Modifier) {val isDarkMode = LocalIsDarkMode.current- val isLight = !isDarkMode- val tint = if (isLight) Color(0xFF444444) else Color(0xFFCCCCCC)+ val tint = LiquidGlassColors.secondary(isDarkMode)LiquidBottomTabs(selectedTabIndex = selectedTab,diff --git a/app/src/main/java/com/chethan616/clearpdf/ui/components/LiquidBottomTabs.kt b/app/src/main/java/com/chethan616/clearpdf/ui/components/LiquidBottomTabs.ktindex da446d0..7fc2a19 100644--- a/app/src/main/java/com/chethan616/clearpdf/ui/components/LiquidBottomTabs.kt+++ b/app/src/main/java/com/chethan616/clearpdf/ui/components/LiquidBottomTabs.kt@@ -3,7 +3,6 @@ package com.chethan616.clearpdf.ui.componentsimport androidx.compose.animation.core.Animatableimport androidx.compose.animation.core.EaseOutimport androidx.compose.animation.core.spring-import androidx.compose.foundation.isSystemInDarkThemeimport androidx.compose.foundation.layout.Boximport androidx.compose.foundation.layout.BoxWithConstraintsimport androidx.compose.foundation.layout.Row@@ -68,8 +67,8 @@ fun LiquidBottomTabs() {val isDarkMode = LocalIsDarkMode.currentval isLightTheme = !isDarkMode- val accentColor = if (isLightTheme) Color(0xFF0088FF) else Color(0xFF0091FF)- val containerColor = if (isLightTheme) Color(0xFFFAFAFA).copy(0.4f) else Color(0xFF121212).copy(0.4f)+ val accentColor = Color(0xFF0A84FF)+ val containerColor = if (isLightTheme) Color.White.copy(0.40f) else Color(0xFF111216).copy(0.48f)val tabsBackdrop = rememberLayerBackdrop()@@ -94,7 +93,10 @@ fun LiquidBottomTabs(val isLtr = LocalLayoutDirection.current == LayoutDirection.Ltrval animationScope = rememberCoroutineScope()- var currentIndex by remember(selectedTabIndex) { mutableIntStateOf(selectedTabIndex()) }+ // Keep the animation state stable when the parent recomposes. The+ // selected-tab lambda is intentionally observed through snapshotFlow+ // below instead of being used as a remember key.+ var currentIndex by remember { mutableIntStateOf(selectedTabIndex()) }val dampedDragAnimation = remember(animationScope) {DampedDragAnimation(animationScope = animationScope,@@ -126,7 +128,7 @@ fun LiquidBottomTabs(})}- LaunchedEffect(selectedTabIndex) {+ LaunchedEffect(Unit) {snapshotFlow { selectedTabIndex() }.collectLatest { index -> currentIndex = index }}@@ -161,8 +163,8 @@ fun LiquidBottomTabs(shape = { Capsule },effects = {vibrancy()- blur(8f.dp.toPx())- lens(24f.dp.toPx(), 24f.dp.toPx())+ blur(6f.dp.toPx())+ lens(18f.dp.toPx(), 20f.dp.toPx())},layerBlock = {val progress = dampedDragAnimation.pressProgress@@ -198,7 +200,7 @@ fun LiquidBottomTabs(effects = {val progress = dampedDragAnimation.pressProgressvibrancy()- blur(8f.dp.toPx())+ blur(6f.dp.toPx())lens(24f.dp.toPx() * progress,24f.dp.toPx() * progressdiff --git a/app/src/main/java/com/chethan616/clearpdf/ui/components/LiquidGlassCard.kt b/app/src/main/java/com/chethan616/clearpdf/ui/components/LiquidGlassCard.ktindex 2502a4a..9639e8d 100644--- a/app/src/main/java/com/chethan616/clearpdf/ui/components/LiquidGlassCard.kt+++ b/app/src/main/java/com/chethan616/clearpdf/ui/components/LiquidGlassCard.kt@@ -2,7 +2,6 @@ package com.chethan616.clearpdf.ui.componentsimport androidx.compose.foundation.backgroundimport androidx.compose.foundation.clickable-import androidx.compose.foundation.isSystemInDarkThemeimport androidx.compose.foundation.layout.Arrangementimport androidx.compose.foundation.layout.Boximport androidx.compose.foundation.layout.Column@@ -31,6 +30,7 @@ import androidx.compose.ui.text.font.FontWeightimport androidx.compose.ui.unit.dpimport androidx.compose.ui.unit.spimport androidx.compose.ui.util.lerp+import com.chethan616.clearpdf.ui.theme.LiquidGlassColorsimport com.chethan616.clearpdf.ui.theme.LocalIsDarkModeimport com.chethan616.clearpdf.ui.utils.InteractiveHighlightimport com.chethan616.clearpdf.ui.utils.UISensor@@ -63,9 +63,9 @@ fun LiquidGlassCard() {val isDarkMode = LocalIsDarkMode.currentval isLight = !isDarkMode- val container = if (isLight) Color(0xFFFAFAFA).copy(0.4f) else Color(0xFF1E1E1E).copy(0.4f)- val titleColor = if (isLight) Color(0xFF1A1A1A) else Color(0xFFF0F0F0)- val subtitleColor = if (isLight) Color(0xFF777777) else Color(0xFFAAAAAA)+ val container = if (isLight) Color.White.copy(0.34f) else Color(0xFF111216).copy(0.46f)+ val titleColor = LiquidGlassColors.text(!isLight)+ val subtitleColor = LiquidGlassColors.secondary(!isLight)val animationScope = rememberCoroutineScope()val interactiveHighlight = remember(animationScope) {@@ -79,14 +79,14 @@ fun LiquidGlassCard(shape = { RoundedRectangle(24f.dp) },effects = {vibrancy()- blur(8f.dp.toPx())- lens(24f.dp.toPx(), 48f.dp.toPx(), depthEffect = true)+ blur(6f.dp.toPx())+ lens(18f.dp.toPx(), 34f.dp.toPx(), depthEffect = true)},highlight = {Highlight(style = HighlightStyle.Default(angle = uiSensor.gravityAngle, falloff = 2f))},- shadow = { Shadow(radius = 8f.dp, color = Color.Black.copy(alpha = 0.12f)) },- innerShadow = { InnerShadow(radius = 4f.dp, alpha = 0.4f) },+ shadow = { Shadow(radius = 7f.dp, color = Color.Black.copy(alpha = 0.10f)) },+ innerShadow = { InnerShadow(radius = 3f.dp, alpha = 0.32f) },layerBlock = {val progress = interactiveHighlight.pressProgressval scale = lerp(1f, 1f + 4f.dp.toPx() / size.height, progress)@@ -99,8 +99,8 @@ fun LiquidGlassCard(scaleX = scale + maxDragScale * abs(cos(offsetAngle) * offset.x / size.maxDimension)scaleY = scale + maxDragScale * abs(sin(offsetAngle) * offset.y / size.maxDimension)},- onDrawSurface = { drawRect(container) }- )+ onDrawSurface = { drawRect(container) }+ ).clickable(interactionSource = null, indication = null, role = Role.Button, onClick = onClick).then(interactiveHighlight.modifier).then(interactiveHighlight.gestureModifier)diff --git a/app/src/main/java/com/chethan616/clearpdf/ui/components/LiquidGlassPanel.kt b/app/src/main/java/com/chethan616/clearpdf/ui/components/LiquidGlassPanel.ktindex fa65c61..072b412 100644--- a/app/src/main/java/com/chethan616/clearpdf/ui/components/LiquidGlassPanel.kt+++ b/app/src/main/java/com/chethan616/clearpdf/ui/components/LiquidGlassPanel.kt@@ -1,10 +1,12 @@package com.chethan616.clearpdf.ui.components-import androidx.compose.foundation.isSystemInDarkThemeimport androidx.compose.runtime.Composable+import androidx.compose.runtime.rememberimport androidx.compose.ui.Modifierimport androidx.compose.ui.graphics.Brushimport androidx.compose.ui.graphics.Color+import androidx.compose.ui.graphics.StrokeCap+import androidx.compose.ui.graphics.drawscope.Strokeimport androidx.compose.ui.unit.dpimport com.chethan616.clearpdf.ui.theme.LocalIsDarkModeimport com.chethan616.clearpdf.ui.utils.UISensor@@ -26,26 +28,36 @@ fun Modifier.liquidGlassPanel(): Modifier {val isDarkMode = LocalIsDarkMode.currentval isLightTheme = !isDarkMode- val containerColor = if (isLightTheme) Color(0xFFFAFAFA).copy(0.45f) else Color(0xFF141414).copy(0.55f)+ // Match the stronger, dimensional glass language used by the Tools cards.+ val containerColor = if (isLightTheme) Color.White.copy(0.34f) else Color(0xFF111216).copy(0.46f)+ val rimColor = if (isLightTheme) Color.White.copy(0.52f) else Color.White.copy(0.16f)+ val surfaceHighlight = remember(isLightTheme) {+ Brush.verticalGradient(+ colors = listOf(+ Color.White.copy(alpha = if (isLightTheme) 0.14f else 0.08f),+ Color.Transparent+ )+ )+ }return this.drawBackdrop(backdrop = backdrop,shape = { RoundedRectangle(28f.dp) },effects = {vibrancy()- blur(8f.dp.toPx())- lens(20f.dp.toPx(), 40f.dp.toPx(), depthEffect = true)+ blur(6f.dp.toPx())+ lens(18f.dp.toPx(), 34f.dp.toPx(), depthEffect = true)},highlight = { Highlight(style = HighlightStyle.Default(angle = uiSensor.gravityAngle, falloff = 2f)) },- shadow = { Shadow(radius = 10f.dp, color = Color.Black.copy(alpha = 0.16f)) },- innerShadow = { InnerShadow(radius = 6f.dp, alpha = 0.55f) },+ shadow = { Shadow(radius = 7f.dp, color = Color.Black.copy(alpha = 0.10f)) },+ innerShadow = { InnerShadow(radius = 3f.dp, alpha = 0.32f) },onDrawSurface = {drawRect(containerColor)- val vignette = Brush.radialGradient(- colors = listOf(Color.Transparent, Color.Black.copy(0.22f)),- center = center,- radius = maxOf(size.width, size.height) * 0.75f+ drawRect(surfaceHighlight)+ drawRoundRect(+ color = rimColor,+ cornerRadius = androidx.compose.ui.geometry.CornerRadius(28f.dp.toPx()),+ style = Stroke(width = 1f.dp.toPx(), cap = StrokeCap.Round))- drawRect(vignette)})}diff --git a/app/src/main/java/com/chethan616/clearpdf/ui/components/LiquidGlassTopBar.kt b/app/src/main/java/com/chethan616/clearpdf/ui/components/LiquidGlassTopBar.ktindex 7918f84..1804661 100644--- a/app/src/main/java/com/chethan616/clearpdf/ui/components/LiquidGlassTopBar.kt+++ b/app/src/main/java/com/chethan616/clearpdf/ui/components/LiquidGlassTopBar.kt@@ -1,6 +1,5 @@package com.chethan616.clearpdf.ui.components-import androidx.compose.foundation.isSystemInDarkThemeimport androidx.compose.foundation.layout.Rowimport androidx.compose.foundation.layout.RowScopeimport androidx.compose.foundation.layout.fillMaxWidth@@ -15,6 +14,7 @@ import androidx.compose.ui.text.TextStyleimport androidx.compose.ui.text.font.FontWeightimport androidx.compose.ui.unit.dpimport androidx.compose.ui.unit.sp+import com.chethan616.clearpdf.ui.theme.LiquidGlassColorsimport com.chethan616.clearpdf.ui.theme.LocalIsDarkModeimport com.chethan616.clearpdf.ui.utils.UISensorimport com.kyant.backdrop.Backdrop@@ -40,8 +40,8 @@ fun LiquidGlassTopBar() {val isDarkMode = LocalIsDarkMode.currentval isLightTheme = !isDarkMode- val containerColor = if (isLightTheme) Color(0xFFFAFAFA).copy(0.35f) else Color(0xFF1E1E1E).copy(0.35f)- val titleColor = if (isLightTheme) Color(0xFF1A1A1A) else Color(0xFFF0F0F0)+ val containerColor = if (isLightTheme) Color.White.copy(0.34f) else Color(0xFF111216).copy(0.42f)+ val titleColor = LiquidGlassColors.text(!isLightTheme)Row(modifier@@ -50,8 +50,8 @@ fun LiquidGlassTopBar(shape = { Capsule },effects = {vibrancy()- blur(8f.dp.toPx())- lens(16f.dp.toPx(), 32f.dp.toPx())+ blur(6f.dp.toPx())+ lens(12f.dp.toPx(), 24f.dp.toPx())},highlight = {Highlight(style = HighlightStyle.Default(angle = uiSensor.gravityAngle, falloff = 2f))@@ -61,7 +61,7 @@ fun LiquidGlassTopBar(onDrawSurface = { drawRect(containerColor) }).fillMaxWidth()- .height(56.dp)+ .height(58.dp).padding(horizontal = 20.dp),verticalAlignment = Alignment.CenterVertically) {diff --git a/app/src/main/java/com/chethan616/clearpdf/ui/components/LiquidSlider.kt b/app/src/main/java/com/chethan616/clearpdf/ui/components/LiquidSlider.ktindex e8fad5e..50088ef 100644--- a/app/src/main/java/com/chethan616/clearpdf/ui/components/LiquidSlider.kt+++ b/app/src/main/java/com/chethan616/clearpdf/ui/components/LiquidSlider.kt@@ -136,7 +136,7 @@ fun LiquidSlider(onValueChangeState.value(targetValue)}}- .height(6f.dp)+ .height(8f.dp).fillMaxWidth())@@ -144,7 +144,7 @@ fun LiquidSlider(Modifier.clip(Capsule).background(accentColor)- .height(6f.dp)+ .height(8f.dp).layout { measurable, constraints ->val placeable = measurable.measure(constraints)val width = (constraints.maxWidth * dampedDragAnimation.progress).fastRoundToInt()@@ -191,7 +191,7 @@ fun LiquidSlider(Highlight.Ambient.copy(width = Highlight.Ambient.width / 1.5f,blurRadius = Highlight.Ambient.blurRadius / 1.5f,- alpha = progress+ alpha = 0.42f + (progress * 0.58f))},shadow = {@@ -213,7 +213,7 @@ fun LiquidSlider(drawRect(Color.White.copy(alpha = 1f - progress))})- .size(40f.dp, 24f.dp)+ .size(44f.dp, 28f.dp))}}diff --git a/app/src/main/java/com/chethan616/clearpdf/ui/screen/HomeScreen.kt b/app/src/main/java/com/chethan616/clearpdf/ui/screen/HomeScreen.ktindex d621268..32c2164 100644--- a/app/src/main/java/com/chethan616/clearpdf/ui/screen/HomeScreen.kt+++ b/app/src/main/java/com/chethan616/clearpdf/ui/screen/HomeScreen.kt@@ -68,6 +68,7 @@ import com.chethan616.clearpdf.ui.components.LiquidButtonimport com.chethan616.clearpdf.ui.components.LiquidIconButtonimport com.chethan616.clearpdf.ui.components.LiquidGlassTopBarimport com.chethan616.clearpdf.ui.components.liquidGlassPanel+import com.chethan616.clearpdf.ui.theme.LiquidGlassColorsimport com.chethan616.clearpdf.ui.theme.LocalIsDarkModeimport com.chethan616.clearpdf.ui.utils.rememberUISensorimport com.kyant.backdrop.backdrops.LayerBackdrop@@ -87,16 +88,17 @@ fun HomeScreen(val homeRecentLimit = 5val isDarkMode = LocalIsDarkMode.currentval isLight = !isDarkMode- val text = if (isLight) Color(0xFF1A1A1A) else Color(0xFFF0F0F0)- val sub = if (isLight) Color(0xFF666666) else Color(0xFFAAAAAA)- val accent = Color(0xFF0088FF)- val redAccent = Color(0xFFEF5350)+ val text = LiquidGlassColors.text(isDarkMode)+ val sub = LiquidGlassColors.secondary(isDarkMode)+ val accent = LiquidGlassColors.Blue+ val redAccent = LiquidGlassColors.Redval uiSensor = rememberUISensor()val context = LocalContext.currentvar recents by remember { mutableStateOf(RecentFilesManager.getRecents(context)) }var showAllRecents by remember { mutableStateOf(false) }var selectedRecent by remember { mutableStateOf<com.chethan616.clearpdf.data.repository.RecentFile?>(null) }+ var infoRecent by remember { mutableStateOf<com.chethan616.clearpdf.data.repository.RecentFile?>(null) }val lifecycleOwner = LocalLifecycleOwner.currentDisposableEffect(lifecycleOwner, context) {@@ -114,56 +116,88 @@ fun HomeScreen(Modifier.fillMaxSize().statusBarsPadding()- .padding(16.dp)+ .padding(horizontal = 16.dp).verticalScroll(rememberScrollState()),verticalArrangement = Arrangement.spacedBy(16.dp)) {- LiquidGlassTopBar(title = "ClearPDF", backdrop = backdrop, uiSensor = uiSensor)+ LiquidGlassTopBar(+ title = "ClearPDF",+ backdrop = backdrop,+ uiSensor = uiSensor,+ actions = {+ Box(+ Modifier+ .clip(RoundedCornerShape(50))+ .background(accent.copy(alpha = if (isLight) 0.12f else 0.18f))+ .padding(horizontal = 10.dp, vertical = 6.dp)+ ) {+ BasicText(+ "ON DEVICE",+ style = TextStyle(accent, 10.sp, FontWeight.Bold)+ )+ }+ }+ )// Welcome cardColumn(Modifier- .fillMaxWidth()- .liquidGlassPanel(backdrop, uiSensor)- .padding(24.dp),+ .fillMaxWidth()+ .liquidGlassPanel(backdrop, uiSensor)+ .padding(horizontal = 22.dp, vertical = 24.dp),horizontalAlignment = Alignment.CenterHorizontally) {Icon(Icons.Rounded.Description, contentDescription = null,- tint = accent, modifier = Modifier.size(56.dp)+ tint = accent, modifier = Modifier.size(50.dp))- Spacer(Modifier.height(16.dp))+ Spacer(Modifier.height(14.dp))+ BasicText(+ "PDF WORKSPACE",+ style = TextStyle(accent, 11.sp, FontWeight.Bold, letterSpacing = 1.4.sp)+ )+ Spacer(Modifier.height(8.dp))BasicText(- "Welcome to ClearPDF",- style = TextStyle(text, 22.sp, FontWeight.Bold, textAlign = TextAlign.Center)+ "PDF work, beautifully simple.",+ style = TextStyle(text, 23.sp, FontWeight.Bold, textAlign = TextAlign.Center))Spacer(Modifier.height(8.dp))BasicText(- "Your all-in-one PDF toolkit.\nScan, open, merge, split, compress, and create PDFs.",+ "Open, scan, and organize your files—privately on your device.",style = TextStyle(sub, 14.sp, textAlign = TextAlign.Center))- Spacer(Modifier.height(20.dp))+ Spacer(Modifier.height(22.dp))- Row(horizontalArrangement = Arrangement.spacedBy(12.dp)) {- LiquidButton(onClick = onNavigateToOpenPdf, backdrop = backdrop, tint = accent) {+ Row(+ Modifier.fillMaxWidth(),+ horizontalArrangement = Arrangement.spacedBy(10.dp)+ ) {+ LiquidButton(+ onClick = onNavigateToOpenPdf,+ backdrop = backdrop,+ tint = accent,+ modifier = Modifier.weight(1f)+ ) {Row(horizontalArrangement = Arrangement.spacedBy(6.dp),verticalAlignment = Alignment.CenterVertically) {Icon(Icons.Rounded.FileOpen, null, Modifier.size(18.dp), Color.White)- BasicText("Open PDF", style = TextStyle(Color.White, 14.sp, FontWeight.Medium))+ BasicText("Open PDF", style = TextStyle(Color.White, 14.sp, FontWeight.SemiBold))}}LiquidButton(- onClick = onNavigateToScan, backdrop = backdrop,- tint = Color(0xFF4CAF50)+ onClick = onNavigateToScan,+ backdrop = backdrop,+ tint = LiquidGlassColors.Green,+ modifier = Modifier.weight(1f)) {Row(horizontalArrangement = Arrangement.spacedBy(6.dp),verticalAlignment = Alignment.CenterVertically) {Icon(Icons.Rounded.Scanner, null, Modifier.size(18.dp), Color.White)- BasicText("Scan", style = TextStyle(Color.White, 14.sp, FontWeight.Medium))+ BasicText("Scan", style = TextStyle(Color.White, 14.sp, FontWeight.SemiBold))}}}@@ -182,7 +216,7 @@ fun HomeScreen(verticalAlignment = Alignment.CenterVertically,horizontalArrangement = Arrangement.SpaceBetween) {- BasicText("Recent Files", style = TextStyle(text, 16.sp, FontWeight.Bold))+ BasicText("Recent files", style = TextStyle(text, 18.sp, FontWeight.Bold))Row(horizontalArrangement = Arrangement.spacedBy(10.dp),verticalAlignment = Alignment.CenterVertically@@ -218,14 +252,14 @@ fun HomeScreen(verticalArrangement = Arrangement.spacedBy(8.dp)) {Icon(Icons.Rounded.PictureAsPdf, null, Modifier.size(36.dp), sub.copy(0.5f))- BasicText(- "No recent files",- style = TextStyle(sub, 14.sp, FontWeight.Medium, textAlign = TextAlign.Center)- )- BasicText(- "Opened and exported PDFs will appear here.",- style = TextStyle(sub.copy(0.7f), 12.sp, textAlign = TextAlign.Center)- )+ BasicText(+ "Your workspace is ready.",+ style = TextStyle(sub, 14.sp, FontWeight.Medium, textAlign = TextAlign.Center)+ )+ BasicText(+ "Opened and exported PDFs will appear here.",+ style = TextStyle(sub.copy(0.7f), 12.sp, textAlign = TextAlign.Center)+ )}} else {val visibleRecents = if (showAllRecents) recents else recents.take(homeRecentLimit)@@ -412,6 +446,7 @@ fun HomeScreen(textColor = text,onClick = {selectedRecent = null+ infoRecent = recent})@@ -449,6 +484,102 @@ fun HomeScreen(}}}++ // File information dialog. Keep it in the same glass layer as the action sheet+ // so the action has an immediate, readable result instead of silently closing.+ AnimatedVisibility(+ visible = infoRecent != null,+ enter = fadeIn() + scaleIn(initialScale = 0.94f),+ exit = fadeOut() + scaleOut(targetScale = 0.96f)+ ) {+ Box(+ Modifier+ .fillMaxSize()+ .background(Color.Black.copy(alpha = 0.45f))+ .clickable { infoRecent = null },+ contentAlignment = Alignment.Center+ ) {+ infoRecent?.let { recent ->+ Column(+ Modifier+ .fillMaxWidth()+ .padding(20.dp)+ .liquidGlassPanel(backdrop, uiSensor)+ .clickable { /* Consume inner taps */ }+ .padding(22.dp),+ verticalArrangement = Arrangement.spacedBy(14.dp)+ ) {+ Row(+ Modifier.fillMaxWidth(),+ verticalAlignment = Alignment.CenterVertically,+ horizontalArrangement = Arrangement.spacedBy(12.dp)+ ) {+ Box(+ Modifier+ .size(44.dp)+ .clip(RoundedCornerShape(12.dp))+ .background(Color(0xFFE53935).copy(alpha = if (isLight) 0.14f else 0.25f)),+ contentAlignment = Alignment.Center+ ) {+ Icon(Icons.Rounded.PictureAsPdf, null, Modifier.size(24.dp), Color(0xFFE53935))+ }+ Column(Modifier.weight(1f)) {+ BasicText(+ "File Info",+ style = TextStyle(text, 18.sp, FontWeight.SemiBold)+ )+ BasicText(+ recent.name,+ style = TextStyle(sub, 12.sp),+ maxLines = 1,+ overflow = TextOverflow.Ellipsis+ )+ }+ }++ Box(+ Modifier+ .fillMaxWidth()+ .height(1.dp)+ .background(if (isLight) Color.Black.copy(0.06f) else Color.White.copy(0.08f))+ )++ InfoRow("Pages", if (recent.pageCount > 0) recent.pageCount.toString() else "Unknown", text, sub)+ InfoRow("Size", if (recent.sizeBytes > 0) formatFileSize(recent.sizeBytes) else "Unknown", text, sub)+ InfoRow("Added", formatTimestamp(recent.timestamp), text, sub)+ InfoRow("Location", recent.uri.toString(), text, sub, maxLines = 3)++ LiquidButton(+ onClick = { infoRecent = null },+ backdrop = backdrop,+ tint = accent,+ modifier = Modifier.fillMaxWidth()+ ) {+ BasicText("Done", style = TextStyle(Color.White, 14.sp, FontWeight.SemiBold))+ }+ }+ }+ }+ }+ }+}++@Composable+private fun InfoRow(+ label: String,+ value: String,+ textColor: Color,+ secondaryColor: Color,+ maxLines: Int = 1+) {+ Column(verticalArrangement = Arrangement.spacedBy(3.dp)) {+ BasicText(label.uppercase(), style = TextStyle(secondaryColor, 10.sp, FontWeight.Bold, letterSpacing = 0.8.sp))+ BasicText(+ value,+ style = TextStyle(textColor, 13.sp, FontWeight.Medium),+ maxLines = maxLines,+ overflow = TextOverflow.Ellipsis+ )}}diff --git a/app/src/main/java/com/chethan616/clearpdf/ui/screen/PdfViewerScreen.kt b/app/src/main/java/com/chethan616/clearpdf/ui/screen/PdfViewerScreen.ktindex dc3fd0e..54245f8 100644--- a/app/src/main/java/com/chethan616/clearpdf/ui/screen/PdfViewerScreen.kt+++ b/app/src/main/java/com/chethan616/clearpdf/ui/screen/PdfViewerScreen.kt@@ -579,7 +579,9 @@ fun PdfViewerScreen(.pointerInput(page, activeTool) {detectTapGestures(onTap = {- controlsVisible = true+ // A single tap is the deliberate immersive-mode toggle:+ // hide the chrome, then bring it back on the next tap.+ controlsVisible = !controlsVisiblelastInteractionAtMs = System.currentTimeMillis()},onDoubleTap = { tap ->@@ -1577,4 +1579,4 @@ private fun androidx.compose.ui.graphics.drawscope.DrawScope.drawArrow(drawLine(color, end,Offset(end.x - (headLen * cos(angle + theta)).toFloat(), end.y - (headLen * sin(angle + theta)).toFloat()),strokeWidth)-}\ No newline at end of file+}diff --git a/app/src/main/java/com/chethan616/clearpdf/ui/screen/SettingsScreen.kt b/app/src/main/java/com/chethan616/clearpdf/ui/screen/SettingsScreen.ktindex b32dc09..41a1d17 100644--- a/app/src/main/java/com/chethan616/clearpdf/ui/screen/SettingsScreen.kt+++ b/app/src/main/java/com/chethan616/clearpdf/ui/screen/SettingsScreen.kt@@ -64,6 +64,7 @@ import com.chethan616.clearpdf.ui.components.LiquidGlassTopBarimport com.chethan616.clearpdf.ui.components.LiquidSliderimport com.chethan616.clearpdf.ui.components.LiquidToggleimport com.chethan616.clearpdf.ui.components.liquidGlassPanel+import com.chethan616.clearpdf.ui.theme.LiquidGlassColorsimport com.chethan616.clearpdf.ui.utils.rememberUISensorimport com.kyant.backdrop.backdrops.LayerBackdropimport kotlinx.coroutines.delaydiff --git a/app/src/main/java/com/chethan616/clearpdf/ui/screen/ToolsScreen.kt b/app/src/main/java/com/chethan616/clearpdf/ui/screen/ToolsScreen.ktindex 71848b6..66ab814 100644--- a/app/src/main/java/com/chethan616/clearpdf/ui/screen/ToolsScreen.kt+++ b/app/src/main/java/com/chethan616/clearpdf/ui/screen/ToolsScreen.kt@@ -1,42 +1,51 @@package com.chethan616.clearpdf.ui.screen-import androidx.compose.foundation.isSystemInDarkThemeimport androidx.compose.foundation.layout.Arrangement-import androidx.compose.foundation.layout.Column-import androidx.compose.foundation.layout.Row-import androidx.compose.foundation.layout.Spacer+import androidx.compose.foundation.layout.PaddingValuesimport androidx.compose.foundation.layout.fillMaxSize-import androidx.compose.foundation.layout.fillMaxWidth-import androidx.compose.foundation.layout.heightimport androidx.compose.foundation.layout.padding-import androidx.compose.foundation.layout.sizeimport androidx.compose.foundation.layout.statusBarsPadding-import androidx.compose.foundation.rememberScrollState+import androidx.compose.foundation.lazy.grid.GridCells+import androidx.compose.foundation.lazy.grid.GridItemSpan+import androidx.compose.foundation.lazy.grid.LazyVerticalGrid+import androidx.compose.foundation.lazy.grid.itemsimport androidx.compose.foundation.text.BasicText-import androidx.compose.foundation.verticalScrollimport androidx.compose.material.icons.Iconsimport androidx.compose.material.icons.automirrored.rounded.CallMergeimport androidx.compose.material.icons.automirrored.rounded.CallSplit+import androidx.compose.material.icons.automirrored.rounded.NoteAddimport androidx.compose.material.icons.rounded.Compressimport androidx.compose.material.icons.rounded.FileOpenimport androidx.compose.material.icons.rounded.Imageimport androidx.compose.material.icons.rounded.Reorderimport androidx.compose.material.icons.rounded.TextSnippet-import androidx.compose.material.icons.automirrored.rounded.NoteAddimport androidx.compose.material3.Iconimport androidx.compose.runtime.Composable+import androidx.compose.runtime.rememberimport androidx.compose.ui.Modifierimport androidx.compose.ui.graphics.Color+import androidx.compose.ui.graphics.vector.ImageVectorimport androidx.compose.ui.text.TextStyle+import androidx.compose.ui.text.font.FontWeightimport androidx.compose.ui.text.style.TextAlignimport androidx.compose.ui.unit.dpimport androidx.compose.ui.unit.spimport com.chethan616.clearpdf.ui.components.LiquidGlassCardimport com.chethan616.clearpdf.ui.components.LiquidGlassTopBar+import com.chethan616.clearpdf.ui.theme.LiquidGlassColorsimport com.chethan616.clearpdf.ui.theme.LocalIsDarkModeimport com.chethan616.clearpdf.ui.utils.rememberUISensorimport com.kyant.backdrop.backdrops.LayerBackdrop+private data class ToolSpec(+ val id: String,+ val title: String,+ val subtitle: String,+ val accent: Color,+ val icon: ImageVector,+ val onClick: () -> Unit+)+@Composablefun ToolsScreen(backdrop: LayerBackdrop,@@ -50,94 +59,67 @@ fun ToolsScreen(onNavigateToImagesToPdf: () -> Unit = {}) {val isDarkMode = LocalIsDarkMode.current- val isLight = !isDarkMode- val sub = if (isLight) Color(0xFF666666) else Color(0xFFAAAAAA)val uiSensor = rememberUISensor()+ val secondary = LiquidGlassColors.secondary(isDarkMode)+ val toolItems = remember(+ onNavigateToOpenPdf,+ onNavigateToMergePdf,+ onNavigateToSplitPdf,+ onNavigateToCompressPdf,+ onNavigateToOrganizePdf,+ onNavigateToImagesToPdf,+ onNavigateToExtractText,+ onNavigateToCreatePdf+ ) {+ listOf(+ ToolSpec("open", "Open PDF", "View and read", LiquidGlassColors.Blue, Icons.Rounded.FileOpen, onNavigateToOpenPdf),+ ToolSpec("merge", "Merge PDFs", "Combine files", LiquidGlassColors.Red, Icons.AutoMirrored.Rounded.CallMerge, onNavigateToMergePdf),+ ToolSpec("split", "Split PDF", "Extract pages", LiquidGlassColors.Purple, Icons.AutoMirrored.Rounded.CallSplit, onNavigateToSplitPdf),+ ToolSpec("compress", "Compress", "Reduce file size", LiquidGlassColors.Green, Icons.Rounded.Compress, onNavigateToCompressPdf),+ ToolSpec("organize", "Organize", "Reorder and rotate", LiquidGlassColors.Teal, Icons.Rounded.Reorder, onNavigateToOrganizePdf),+ ToolSpec("images", "Images to PDF", "Photos to PDF", LiquidGlassColors.Indigo, Icons.Rounded.Image, onNavigateToImagesToPdf),+ ToolSpec("extract", "Extract text", "Copy text out", Color(0xFF5AC8FA), Icons.Rounded.TextSnippet, onNavigateToExtractText),+ ToolSpec("create", "Create PDF", "Blank, images, text", LiquidGlassColors.Orange, Icons.AutoMirrored.Rounded.NoteAdd, onNavigateToCreatePdf)+ )+ }- Column(- Modifier+ LazyVerticalGrid(+ columns = GridCells.Fixed(2),+ modifier = Modifier.fillMaxSize()- .statusBarsPadding()- .padding(16.dp)- .verticalScroll(rememberScrollState()),+ .statusBarsPadding(),+ contentPadding = PaddingValues(start = 16.dp, top = 16.dp, end = 16.dp, bottom = 96.dp),+ horizontalArrangement = Arrangement.spacedBy(12.dp),verticalArrangement = Arrangement.spacedBy(12.dp)) {- LiquidGlassTopBar(title = "Tools", backdrop = backdrop, uiSensor = uiSensor)-- BasicText(- "Every tool you need to work with PDFs",- style = TextStyle(sub, 14.sp, textAlign = TextAlign.Center),- modifier = Modifier.fillMaxWidth().padding(bottom = 4.dp)- )-- Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.spacedBy(12.dp)) {- LiquidGlassCard(- title = "Open PDF", subtitle = "View & read",- accentColor = Color(0xFF1976D2), backdrop = backdrop, uiSensor = uiSensor,- onClick = onNavigateToOpenPdf, modifier = Modifier.weight(1f)- ) {- Icon(Icons.Rounded.FileOpen, null, Modifier.size(26.dp), Color(0xFF1976D2))- }- LiquidGlassCard(- title = "Merge PDFs", subtitle = "Combine files",- accentColor = Color(0xFFD32F2F), backdrop = backdrop, uiSensor = uiSensor,- onClick = onNavigateToMergePdf, modifier = Modifier.weight(1f)- ) {- Icon(Icons.AutoMirrored.Rounded.CallMerge, null, Modifier.size(26.dp), Color(0xFFD32F2F))- }+ item(span = { GridItemSpan(maxLineSpan) }) {+ LiquidGlassTopBar(title = "Tools", backdrop = backdrop, uiSensor = uiSensor)}- Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.spacedBy(12.dp)) {- LiquidGlassCard(- title = "Split PDF", subtitle = "Extract pages",- accentColor = Color(0xFF7B1FA2), backdrop = backdrop, uiSensor = uiSensor,- onClick = onNavigateToSplitPdf, modifier = Modifier.weight(1f)- ) {- Icon(Icons.AutoMirrored.Rounded.CallSplit, null, Modifier.size(26.dp), Color(0xFF7B1FA2))- }- LiquidGlassCard(- title = "Compress", subtitle = "Reduce size",- accentColor = Color(0xFF388E3C), backdrop = backdrop, uiSensor = uiSensor,- onClick = onNavigateToCompressPdf, modifier = Modifier.weight(1f)- ) {- Icon(Icons.Rounded.Compress, null, Modifier.size(26.dp), Color(0xFF388E3C))- }- }-- Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.spacedBy(12.dp)) {- LiquidGlassCard(- title = "Organize", subtitle = "Reorder & rotate",- accentColor = Color(0xFF00897B), backdrop = backdrop, uiSensor = uiSensor,- onClick = onNavigateToOrganizePdf, modifier = Modifier.weight(1f)- ) {- Icon(Icons.Rounded.Reorder, null, Modifier.size(26.dp), Color(0xFF00897B))- }- LiquidGlassCard(- title = "Images → PDF", subtitle = "Photos to PDF",- accentColor = Color(0xFF5E35B1), backdrop = backdrop, uiSensor = uiSensor,- onClick = onNavigateToImagesToPdf, modifier = Modifier.weight(1f)- ) {- Icon(Icons.Rounded.Image, null, Modifier.size(26.dp), Color(0xFF5E35B1))- }+ item(span = { GridItemSpan(maxLineSpan) }) {+ BasicText(+ "Everything you need to work with PDFs.",+ style = TextStyle(+ color = secondary,+ fontSize = 14.sp,+ fontWeight = FontWeight.Medium,+ textAlign = TextAlign.Center+ ),+ modifier = Modifier.padding(vertical = 4.dp)+ )}- Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.spacedBy(12.dp)) {+ items(toolItems, key = { it.id }) { tool ->LiquidGlassCard(- title = "Extract Text", subtitle = "Copy text out",- accentColor = Color(0xFF00838F), backdrop = backdrop, uiSensor = uiSensor,- onClick = onNavigateToExtractText, modifier = Modifier.weight(1f)+ title = tool.title,+ subtitle = tool.subtitle,+ accentColor = tool.accent,+ backdrop = backdrop,+ uiSensor = uiSensor,+ onClick = tool.onClick) {- Icon(Icons.Rounded.TextSnippet, null, Modifier.size(26.dp), Color(0xFF00838F))- }- LiquidGlassCard(- title = "Create PDF", subtitle = "Blank, images, text",- accentColor = Color(0xFFE65100), backdrop = backdrop, uiSensor = uiSensor,- onClick = onNavigateToCreatePdf, modifier = Modifier.weight(1f)- ) {- Icon(Icons.AutoMirrored.Rounded.NoteAdd, null, Modifier.size(26.dp), Color(0xFFE65100))+ Icon(tool.icon, contentDescription = tool.title, tint = tool.accent)}}-- Spacer(Modifier.height(80.dp))}}diff --git a/app/src/main/java/com/chethan616/clearpdf/ui/theme/LiquidGlassTokens.kt b/app/src/main/java/com/chethan616/clearpdf/ui/theme/LiquidGlassTokens.ktnew file mode 100644index 0000000..8bebdd8--- /dev/null+++ b/app/src/main/java/com/chethan616/clearpdf/ui/theme/LiquidGlassTokens.kt@@ -0,0 +1,27 @@+package com.chethan616.clearpdf.ui.theme++import androidx.compose.ui.graphics.Color++/**+ * Small, shared palette for the glass surfaces. Keeping these values in one+ * place makes the visual hierarchy consistent across every screen and avoids+ * scattering near-duplicate colors through composables.+ */+object LiquidGlassColors {+ val LightText = Color(0xFF111216)+ val LightSecondary = Color(0xFF5E6068)+ val DarkText = Color(0xFFF7F7FA)+ val DarkSecondary = Color(0xFFB5B6BF)++ // Apple-style system accents, tuned for translucent surfaces.+ val Blue = Color(0xFF0A84FF)+ val Green = Color(0xFF30D158)+ val Red = Color(0xFFFF453A)+ val Purple = Color(0xFFBF5AF2)+ val Teal = Color(0xFF64D2FF)+ val Indigo = Color(0xFF5E5CE6)+ val Orange = Color(0xFFFF9F0A)++ fun text(isDark: Boolean): Color = if (isDark) DarkText else LightText+ fun secondary(isDark: Boolean): Color = if (isDark) DarkSecondary else LightSecondary+}