8000 Support Kotlin Multiplatform by skydoves · Pull Request #63 · skydoves/colorpicker-compose · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Support Kotlin Multiplatform #63

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions app/api/app.api
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ public final class com/github/skydoves/colorpickercomposedemo/BuildConfig {
public final class com/github/skydoves/colorpickercomposedemo/ComposableSingletons$MainActivityKt {
public static final field INSTANCE Lcom/github/skydoves/colorpickercomposedemo/ComposableSingletons$MainActivityKt;
public static field lambda-1 Lkotlin/jvm/functions/Function2;
public static field lambda-2 Lkotlin/jvm/functions/Function2;
public fun <init> ()V
public final fun getLambda-1$app_release ()Lkotlin/jvm/functions/Function2;
public final fun getLambda-2$app_release ()Lkotlin/jvm/functions/Function2;
}

public final class com/github/skydoves/colorpickercomposedemo/ComposableSingletons$MainScreenKt {
Expand Down Expand Up @@ -45,8 +47,8 @@ public final class com/github/skydoves/colorpickercomposedemo/PhotoPickerIconKt

public abstract class com/github/skydoves/colorpickercomposedemo/Screen {
public static final field $stable I
public synthetic fun <init> (Ljava/lang/String;Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
public final fun getDrawable ()I
public synthetic fun <init> (Ljava/lang/String;Ljava/lang/String;Lorg/jetbrains/compose/resources/DrawableResource;Lkotlin/jvm/internal/DefaultConstructorMarker;)V
public final fun getDrawable ()Lorg/jetbrains/compose/resources/DrawableResource;
public final fun getName ()Ljava/lang/String;
public final fun getRoute ()Ljava/lang/String;
}
Expand Down
14 changes: 11 additions & 3 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,17 @@ plugins {
kotlin {
applyDefaultHierarchyTemplate()
androidTarget()
iosX64()
iosArm64()
iosSimulatorArm64()

listOf(
iosX64(),
iosArm64(),
iosSimulatorArm64()
).forEach {
it.binaries.framework {
baseName = "shared"
isStatic = true
}
}

task("testClasses")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.material.BottomNavigation
import androidx.compose.material.BottomNavigationItem
import androidx.compose.material.Icon
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Scaffold
import androidx.compose.material.Text
import androidx.compose.material.TopAppBar
Expand All @@ -43,7 +42,10 @@ import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import androidx.navigation.compose.currentBackStackEntryAsState
import androidx.navigation.compose.rememberNavController
import colorpickercomposedemo.app.generated.resources.*
import colorpickercomposedemo.app.generated.resources.Res
import colorpickercomposedemo.app.generated.resources.app_name
import colorpickercomposedemo.app.generated.resources.image_24px
import colorpickercomposedemo.app.generated.resources.palette_24px
import com.github.skydoves.colorpickercomposedemo.screens.HsvColorPickerColoredSelectorScreen
import com.github.skydoves.colorpickercomposedemo.screens.ImageColorPickerScreen
import org.jetbrains.compose.resources.DrawableResource
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@
*/
package com.github.skydoves.colorpickercomposedemo

//import android.graphics.ImageDecoder
//import android.os.Build
//import android.provider.MediaStore
//import androidx.activity.compose.rememberLauncherForActivityResult
// import android.graphics.ImageDecoder
// import android.os.Build
// import android.provider.MediaStore
// import androidx.activity.compose.rememberLauncherForActivityResult
// import androidx.compose.ui.graphics.asImageBitmap
// import androidx.compose.ui.res.vectorResource
import androidx.compose.foundation.Image
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Box
Expand All @@ -28,13 +30,13 @@ import androidx.compose.foundation.layout.size
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
//import androidx.compose.ui.graphics.asImageBitmap
//import androidx.compose.ui.res.vectorResource
import androidx.compose.ui.unit.dp
import colorpickercomposedemo.app.generated.resources.*
import colorpickercomposedemo.app.generated.resources.Res
import colorpickercomposedemo.app.generated.resources.ic_gallery
import com.github.skydoves.colorpicker.compose.ColorPickerController
import org.jetbrains.compose.resources.vectorResource
//import com.google.modernstorage.photopicker.PhotoPicker

// import com.google.modernstorage.photopicker.PhotoPicker

@Composable
fun ColumnScope.PhotoPickerIcon(
Expand Down Expand Up @@ -64,7 +66,7 @@ fun ColumnScope.PhotoPickerIcon(
.size(42.dp)
.clickable {
// Launch the picker with only one image selectable
//photoPicker.launch(PhotoPicker.Args(PhotoPicker.Type.IMAGES_ONLY, 1))
// photoPicker.launch(PhotoPicker.Args(PhotoPicker.Type.IMAGES_ONLY, 1))
},
imageVector = vectorResource(Res.drawable.ic_gallery),
contentDescription = null,
Expand Down
F438
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import colorpickercomposedemo.app.generated.resources.*
import colorpickercomposedemo.app.generated.resources.Res
import colorpickercomposedemo.app.generated.resources.palettebar
import com.github.skydoves.colorpicker.compose.AlphaSlider
import com.github.skydoves.colorpicker.compose.AlphaTile
import com.github.skydoves.colorpicker.compose.BrightnessSlider
Expand Down
17 changes: 16 additions & 1 deletion app/src/iosMain/kotlin/MainViewController.kt
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
/*
* Designed and developed by 2022 skydoves (Jaewoong Eum)
*
* 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.
*/
import androidx.compose.ui.window.ComposeUIViewController
import com.github.skydoves.colorpickercomposedemo.MainScreen

fun MainViewController() = ComposeUIViewController { MainScreen() }
fun MainViewController() = ComposeUIViewController { MainScreen() }
26 changes: 5 additions & 21 deletions benchmark/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,20 +1,11 @@
import com.github.skydoves.colorpicker.compose.Configuration

@Suppress("DSL_SCOPE_VIOLATION") // TODO: Remove once KTIJ-19369 is fixed
plugins {
id(libs.plugins.android.test.get().pluginId)
id(libs.plugins.kotlin.multiplatform.get().pluginId)
id(libs.plugins.kotlin.android.get().pluginId)
id(libs.plugins.baseline.profile.get().pluginId)
}

kotlin {
applyDefaultHierarchyTemplate()
androidTarget()
iosX64()
iosArm64()
iosSimulatorArm64()
}

android {
namespace = "com.github.skydoves.colorpicker.compose.benchmark"
compileSdk = Configuration.compileSdk
Expand All @@ -24,6 +15,10 @@ android {
targetCompatibility = JavaVersion.VERSION_11
}

kotlinOptions {
jvmTarget = libs.versions.jvmTarget.get()
}

defaultConfig {
minSdk = 24
targetSdk = Configuration.targetSdk
Expand All @@ -41,17 +36,6 @@ android {
}
}

tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile>().configureEach {
compilerOptions {
jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_11)
}
}

tasks.withType<JavaCompile>().configureEach {
this.targetCompatibility = libs.versions.jvmTarget.get()
this.sourceCompatibility = libs.versions.jvmTarget.get()
}

// This is the plugin configuration. Everything is optional. Defaults are in the
// comments. In this example, you use the GMD added earlier and disable connected devices.
baselineProfile {
Expand Down
28 changes: 14 additions & 14 deletions colorpicker-compose/api/colorpicker-compose.api
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,6 @@ public final class com/github/skydoves/colorpicker/compose/AlphaSliderKt {
public static final fun AlphaSlider-I89wPZw (Landroidx/compose/ui/Modifier;Lcom/github/skydoves/colorpicker/compose/ColorPickerController;FFJLandroidx/compose/ui/graphics/ImageBitmap;FJFLandroidx/compose/ui/graphics/Paint;JJFLandroidx/compose/ui/graphics/Color;Landroidx/compose/runtime/Composer;III)V
}

public final class com/github/skydoves/colorpicker/compose/AlphaTileDrawable : android/graphics/drawable/Drawable {
public static final field $stable I
public synthetic fun <init> (FJJLkotlin/jvm/internal/DefaultConstructorMarker;)V
public fun draw (Landroid/graphics/Canvas;)V
public fun getOpacity ()I
public fun setAlpha (I)V
public fun setColorFilter (Landroid/graphics/ColorFilter;)V
}

public final class com/github/skydoves/colorpicker/compose/AlphaTileKt {
public static final fun AlphaTile-Qd0NJH0 (Landroidx/compose/ui/Modifier;Lcom/github/skydoves/colorpicker/compose/ColorPickerController;JJJFLandroidx/compose/runtime/Composer;II)V
}
Expand Down Expand Up @@ -38,21 +29,30 @@ public final class com/github/skydoves/colorpicker/compose/ColorEnvelope {
public final class com/github/skydoves/colorpicker/compose/ColorPickerController {
public static final field $stable I
public fun <init> ()V
public fun <init> (Lkotlinx/coroutines/CoroutineScope;)V
public synthetic fun <init> (Lkotlinx/coroutines/CoroutineScope;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
public final fun getColorFlow (J)Lkotlinx/coroutines/flow/Flow;
public static synthetic fun getColorFlow$default (Lcom/github/skydoves/colorpicker/compose/ColorPickerController;JILjava/lang/Object;)Lkotlinx/coroutines/flow/Flow;
public final fun getEnabled ()Z
public final fun getSelectedColor ()Landroidx/compose/runtime/State;
public final fun getSelectedPoint ()Landroidx/compose/runtime/State;
public final fun getWheelAlpha ()F
public final fun getWheelBitmap ()Landroidx/compose/ui/graphics/ImageBitmap;
public final fun getWheelColor-0d7_KjU ()J
public final fun getWheelPaint ()Landroidx/compose/ui/graphics/Paint;
public final fun getWheelRadius-D9Ej5fM ()F
public final fun selectByColor-DxMtmZc (JZ)V
public final fun selectByCoordinate (FFZ)V
public final fun selectByCoordinate-3MmeM6k (JZ)V
public final fun selectByHsv (FFFFZ)V
public final fun selectByHsv ([FFZ)V
public final fun selectCenter (Z)V
public final fun setAlpha (FZ)V
public final fun setBrightness (FZ)V
public final fun setDebounceDuration (J)V
public final fun setEnabled (Z)V
public final fun setPaletteContentScale (Lcom/github/skydoves/colorpicker/compose/PaletteContentScale;)V
public final fun setPaletteImageBitmap (Landroidx/compose/ui/graphics/ImageBitmap;)V
public final fun setWheelAlpha (F)V
public final fun setWheelBitmap (Landroidx/compose/ui/graphics/ImageBitmap;)V
public final fun setWheelColor-8_81llA (J)V
public final fun setWheelImageBitmap (Landroidx/compose/ui/graphics/ImageBitmap;)V
public final fun setWheelPaint (Landroidx/compose/ui/graphics/Paint;)V
public final fun setWheelRadius-0680j_4 (F)V
}
Expand All @@ -62,7 +62,7 @@ public final class com/github/skydoves/colorpicker/compose/ColorPickerController
}

public final class com/github/skydoves/colorpicker/compose/DrawScopeExtensionsKt {
public static final fun drawColorIndicator-mxwnekA (Landroidx/compose/ui/graphics/drawscope/DrawScope;Landroid/graphics/PointF;J)V
public static final fun drawColorIndicator-wPWG1Vc (Landroidx/compose/ui/graphics/drawscope/DrawScope;JJ)V
}

public final class com/github/skydoves/colorpicker/compose/HsvColorPickerKt {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,17 @@ public fun AlphaSlider(
}

Slider(
modifier,
controller,
borderRadius,
borderSize,
borderColor,
wheelImageBitmap,
wheelRadius,
wheelColor,
wheelAlpha,
wheelPaint,
initialColor,
modifier = modifier,
controller = controller,
borderRadius = borderRadius,
borderSize = borderSize,
borderColor = borderColor,
wheelImageBitmap = wheelImageBitmap,
wheelRadius = wheelRadius,
wheelColor = wheelColor,
wheelAlpha = wheelAlpha,
wheelPaint = wheelPaint,
initialColor = initialColor,
drawBackground = {
drawRoundRect(it, borderRadius.value, paint)
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,17 @@ public fun BrightnessSlider(
}

Slider(
modifier,
controller,
borderRadius,
borderSize,
borderColor,
wheelImageBitmap,
wheelRadius,
wheelColor,
wheelAlpha,
wheelPaint,
initialColor,

modifier = modifier,
controller = controller,
borderRadius = borderRadius,
borderSize = borderSize,
borderColor = borderColor,
wheelImageBitmap = wheelImageBitmap,
wheelRadius = wheelRadius,
wheelColor = wheelColor,
wheelAlpha = wheelAlpha,
wheelPaint = wheelPaint,
initialColor = initialColor,
getValue = { brightness.value },
setValue = ColorPickerController::setBrightness,
computeInitial = { maxOf(it.red, it.green, it.blue) },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ public fun HsvColorPicker(
drawOnPosSelected = drawOnPosSelected,
drawDefaultWheelIndicator = drawDefaultWheelIndicator,
>

sizeChanged = {
size = it
radius = size.radius
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ internal fun Slider(
alpha = wheelAlpha
},
initialColor: Color? = null,

drawBackground: Canvas.(IntSize) -> Unit = {},
getValue: ColorPickerController.() -> Float,
setValue: ColorPickerController.(Float, fromUser: Boolean) -> Unit,
Expand Down Expand Up @@ -144,14 +143,14 @@ internal fun Slider(

// draw wheel bitmap on the canvas.
canvas.drawWheel(
controller.getValue(),
width,
height,
wheelImageBitmap,
wheelRadiusPx,
wheelColor,
wheelAlpha,
wheelPaint,
position = controller.getValue(),
width = width,
height = height,
wheelImageBitmap = wheelImageBitmap,
wheelRadius = wheelRadiusPx,
wheelColor = wheelColor,
wheelAlpha = wheelAlpha,
wheelPaint = wheelPaint,
)
}

Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ android-application = { id = "com.android.application", version.ref = "agp" }
android-library = { id = "com.android.library", version.ref = "agp" }
compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
android-test = { id = "com.android.test", version.ref = "agp" }

kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
kotlin-multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
jetbrains-compose = { id = "org.jetbrains.compose", version.ref = "compose-plugin" }

Expand Down
2 changes: 1 addition & 1 deletion iosApp/iosApp.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -390,4 +390,4 @@
/* End XCConfigurationList section */
};
rootObject = 7555FF73242A565900829871 /* Project object */;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?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>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -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_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
</dict>
</plist>
2 changes: 1 addition & 1 deletion iosApp/iosApp/ContentView.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import UIKit
import SwiftUI
import ComposeApp
import shared

struct ComposeView: UIViewControllerRepresentable {
func makeUIViewController(context: Context) -> UIViewController {
Expand Down
Loading
0