diff --git a/flexiui-core/build.gradle.kts b/flexiui-core/build.gradle.kts index c8db853..0ca71cd 100644 --- a/flexiui-core/build.gradle.kts +++ b/flexiui-core/build.gradle.kts @@ -32,8 +32,6 @@ kotlin { implementation(compose.foundation) // TODO: We need to remove this and replace with "material-ripple" implementation(compose.material) - @OptIn(org.jetbrains.compose.ExperimentalComposeLibrary::class) - implementation(compose.components.resources) } } val androidMain by getting diff --git a/flexiui-core/src/commonMain/kotlin/com/highcapable/flexiui/component/CheckBox.kt b/flexiui-core/src/commonMain/kotlin/com/highcapable/flexiui/component/CheckBox.kt index e36d265..346d128 100644 --- a/flexiui-core/src/commonMain/kotlin/com/highcapable/flexiui/component/CheckBox.kt +++ b/flexiui-core/src/commonMain/kotlin/com/highcapable/flexiui/component/CheckBox.kt @@ -53,9 +53,9 @@ import androidx.compose.ui.unit.dp import com.highcapable.flexiui.LocalColors import com.highcapable.flexiui.LocalSizes import com.highcapable.flexiui.interaction.clickable -import com.highcapable.flexiui.resources.IconRes +import com.highcapable.flexiui.resources.Icons +import com.highcapable.flexiui.resources.icon.CheckMark import com.highcapable.flexiui.utils.borderOrNot -import org.jetbrains.compose.resources.painterResource @Immutable data class CheckBoxColors( @@ -116,7 +116,7 @@ fun CheckBox( scaleX = animatedContentLayer, scaleY = animatedContentLayer ), - painter = painterResource(IconRes.CHECKMARK), + imageVector = Icons.CheckMark, tint = colors.contentColor ) } diff --git a/flexiui-core/src/commonMain/kotlin/com/highcapable/flexiui/resources/IconRes.kt b/flexiui-core/src/commonMain/kotlin/com/highcapable/flexiui/resources/Icons.kt similarity index 93% rename from flexiui-core/src/commonMain/kotlin/com/highcapable/flexiui/resources/IconRes.kt rename to flexiui-core/src/commonMain/kotlin/com/highcapable/flexiui/resources/Icons.kt index 3c194cd..7cdf6b5 100644 --- a/flexiui-core/src/commonMain/kotlin/com/highcapable/flexiui/resources/IconRes.kt +++ b/flexiui-core/src/commonMain/kotlin/com/highcapable/flexiui/resources/Icons.kt @@ -23,7 +23,4 @@ package com.highcapable.flexiui.resources -object IconRes { - - const val CHECKMARK = "ic-checkmark.xml" -} \ No newline at end of file +object Icons \ No newline at end of file diff --git a/flexiui-core/src/commonMain/kotlin/com/highcapable/flexiui/resources/builder/ImageVector.kt b/flexiui-core/src/commonMain/kotlin/com/highcapable/flexiui/resources/builder/ImageVector.kt new file mode 100644 index 0000000..c494343 --- /dev/null +++ b/flexiui-core/src/commonMain/kotlin/com/highcapable/flexiui/resources/builder/ImageVector.kt @@ -0,0 +1,51 @@ +/* + * Flexi UI - A flexible and useful UI component library. + * Copyright (C) 2019-2023 HighCapable + * https://github.com/BetterAndroid/FlexiUI + * + * Apache License Version 2.0 + * + * 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. + * + * This file is created by fankes on 2023/11/11. + */ +@file:Suppress("unused") + +package com.highcapable.flexiui.resources.builder + +import androidx.compose.ui.graphics.BlendMode +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.graphics.vector.DefaultGroupName +import androidx.compose.ui.graphics.vector.ImageVector +import androidx.compose.ui.unit.Dp + +internal fun buildImageVector( + name: String = DefaultGroupName, + defaultWidth: Dp, + defaultHeight: Dp, + viewportWidth: Float, + viewportHeight: Float, + tintColor: Color = Color.Unspecified, + tintBlendMode: BlendMode = BlendMode.SrcIn, + autoMirror: Boolean = false, + builder: ImageVector.Builder.() -> Unit +) = ImageVector.Builder( + name = name, + defaultWidth = defaultWidth, + defaultHeight = defaultHeight, + viewportWidth = viewportWidth, + viewportHeight = viewportHeight, + tintColor = tintColor, + tintBlendMode = tintBlendMode, + autoMirror = autoMirror +).apply(builder).build() \ No newline at end of file diff --git a/flexiui-core/src/commonMain/kotlin/com/highcapable/flexiui/resources/icon/CheckMark.kt b/flexiui-core/src/commonMain/kotlin/com/highcapable/flexiui/resources/icon/CheckMark.kt new file mode 100644 index 0000000..20d6110 --- /dev/null +++ b/flexiui-core/src/commonMain/kotlin/com/highcapable/flexiui/resources/icon/CheckMark.kt @@ -0,0 +1,59 @@ +/* + * Flexi UI - A flexible and useful UI component library. + * Copyright (C) 2019-2023 HighCapable + * https://github.com/BetterAndroid/FlexiUI + * + * Apache License Version 2.0 + * + * 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. + * + * This file is created by fankes on 2023/11/11. + */ +@file:Suppress("unused") + +package com.highcapable.flexiui.resources.icon + +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.graphics.PathFillType +import androidx.compose.ui.graphics.SolidColor +import androidx.compose.ui.graphics.StrokeCap +import androidx.compose.ui.graphics.StrokeJoin +import androidx.compose.ui.graphics.vector.path +import androidx.compose.ui.unit.dp +import com.highcapable.flexiui.resources.Icons +import com.highcapable.flexiui.resources.builder.buildImageVector + +val Icons.CheckMark by lazy { + buildImageVector( + name = "checkmark", + defaultWidth = 32.dp, + defaultHeight = 32.dp, + viewportWidth = 48f, + viewportHeight = 48f + ) { + path( + fillAlpha = 1.0f, + stroke = SolidColor(Color.White), + strokeAlpha = 1.0f, + strokeLineWidth = 7f, + strokeLineCap = StrokeCap.Round, + strokeLineJoin = StrokeJoin.Round, + strokeLineMiter = 1.0f, + pathFillType = PathFillType.NonZero + ) { + moveTo(43f, 11f) + lineTo(16.875f, 37f) + lineTo(5f, 25.1818f) + } + } +} \ No newline at end of file diff --git a/flexiui-core/src/commonMain/resources/ic-checkmark.xml b/flexiui-core/src/commonMain/resources/ic-checkmark.xml deleted file mode 100644 index 02486e3..0000000 --- a/flexiui-core/src/commonMain/resources/ic-checkmark.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - \ No newline at end of file diff --git a/samples/shared/build.gradle.kts b/samples/shared/build.gradle.kts index 2fb90a2..485f321 100644 --- a/samples/shared/build.gradle.kts +++ b/samples/shared/build.gradle.kts @@ -64,6 +64,8 @@ android { compileSdk = property.project.android.compileSdk sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml") + sourceSets["main"].res.srcDirs("src/androidMain/res") + sourceSets["main"].resources.srcDirs("src/commonMain/resources") defaultConfig { minSdk = property.project.android.minSdk