Skip to content

Commit

Permalink
Merge pull request #44 from Rafael2616/multiplatform-support
Browse files Browse the repository at this point in the history
Add support for kotlin multiplatform
  • Loading branch information
nanihadesuka authored Oct 10, 2024
2 parents 04ced5b + e6f5cf5 commit 04fa497
Show file tree
Hide file tree
Showing 43 changed files with 3,064 additions and 194 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# Gradle files
.gradle/
build/
.kotlin

# Local configuration file (sdk path, etc)
local.properties
Expand Down
23 changes: 7 additions & 16 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
plugins {
id("com.android.application")
id("kotlin-android")
alias(libs.plugins.android.application)
alias(libs.plugins.jetbrains.compose)
alias(libs.plugins.jetbrains.compose.compiler)
}

android {
Expand All @@ -22,6 +24,7 @@ android {

buildTypes {
named("release") {
@Suppress("UnstableApiUsage")
postprocessing {
isMinifyEnabled = false
proguardFile("proguard-rules.pro")
Expand All @@ -39,12 +42,6 @@ android {
kotlinOptions {
jvmTarget = "1.8"
}
buildFeatures {
compose = true
}
composeOptions {
kotlinCompilerExtensionVersion = libs.versions.compose.compiler.get()
}
packaging {
resources {
excludes += "/META-INF/{AL2.0,LGPL2.1}"
Expand All @@ -53,16 +50,10 @@ android {
}

dependencies {
implementation(platform(libs.androidx.compose.bom))
implementation(libs.androidx.compose.material)
implementation(libs.androidx.compose.ui.ui)
implementation(libs.androidx.compose.ui.tooling.preview)
implementation(compose.material3)
implementation(compose.ui)
implementation(compose.preview)
implementation(libs.androidx.compose.activity)
implementation(libs.androidx.core.ktx)
implementation(libs.androidx.appcompat)
implementation(libs.android.material)
implementation(libs.androidx.lifecycle.runtime.ktx)
implementation(project(":lib"))

debugImplementation(libs.androidx.compose.ui.tooling)
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Surface
import androidx.compose.material.Text
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
Expand Down Expand Up @@ -74,15 +74,15 @@ enum class TypeTab {
@Composable
fun MainView() {
LazyColumnScrollbarTheme {
Surface(color = MaterialTheme.colors.background) {
Surface(color = MaterialTheme.colorScheme.background) {
val tab = rememberSaveable { mutableStateOf(TypeTab.LazyRow) }
Column {
FlowRow {
for (type in TypeTab.entries) {
Text(
text = type.name,
Modifier
.background(MaterialTheme.colors.surface, RoundedCornerShape(3.dp))
.background(MaterialTheme.colorScheme.surface, RoundedCornerShape(3.dp))
.clickable { tab.value = type }
.padding(18.dp)
)
Expand Down Expand Up @@ -112,7 +112,7 @@ fun LazyColumnView() {
Box(
modifier = Modifier
.padding(16.dp)
.border(width = 1.dp, MaterialTheme.colors.primary)
.border(width = 1.dp, MaterialTheme.colorScheme.primary)
.padding(1.dp)
) {
LazyColumnScrollbar(
Expand Down Expand Up @@ -167,7 +167,7 @@ fun LazyRowView() {
Box(
modifier = Modifier
.padding(16.dp)
.border(width = 1.dp, MaterialTheme.colors.primary)
.border(width = 1.dp, MaterialTheme.colorScheme.primary)
.padding(1.dp)
) {
LazyRowScrollbar(
Expand Down Expand Up @@ -223,7 +223,7 @@ fun LazyVerticalGridView() {
Box(
modifier = Modifier
.padding(16.dp)
.border(width = 1.dp, MaterialTheme.colors.primary)
.border(width = 1.dp, MaterialTheme.colorScheme.primary)
.padding(1.dp)
) {
LazyVerticalGridScrollbar(
Expand All @@ -244,7 +244,7 @@ fun LazyVerticalGridView() {
) {
items(items.size, key = { it }) {
Surface(
elevation = 3.dp,
tonalElevation = 3.dp,
modifier = Modifier.aspectRatio(1f),
color = Color.Yellow
) {
Expand Down Expand Up @@ -273,7 +273,7 @@ fun LazyHorizontalGridView() {
Box(
modifier = Modifier
.padding(16.dp)
.border(width = 1.dp, MaterialTheme.colors.primary)
.border(width = 1.dp, MaterialTheme.colorScheme.primary)
.padding(1.dp)
) {
LazyHorizontalGridScrollbar(
Expand All @@ -295,7 +295,7 @@ fun LazyHorizontalGridView() {
) {
items(items.size, key = { it }) {
Surface(
elevation = 3.dp,
tonalElevation = 3.dp,
modifier = Modifier.aspectRatio(1f),
color = Color.Yellow
) {
Expand Down Expand Up @@ -327,7 +327,7 @@ fun ColumnView() {
Box(
modifier = Modifier
.padding(16.dp)
.border(width = 1.dp, MaterialTheme.colors.primary)
.border(width = 1.dp, MaterialTheme.colorScheme.primary)
.padding(1.dp)
) {
ColumnScrollbar(
Expand Down Expand Up @@ -370,7 +370,7 @@ fun RowView() {
Box(
modifier = Modifier
.padding(12.dp)
.border(width = 1.dp, MaterialTheme.colors.primary)
.border(width = 1.dp, MaterialTheme.colorScheme.primary)
) {
RowScrollbar(
state = listState,
Expand Down Expand Up @@ -415,7 +415,7 @@ fun Indicator(text: String, isThumbSelected: Boolean) {
.background(Color.Green)
.padding(8.dp)
.clip(CircleShape)
.background(if (isThumbSelected) Color.Red else MaterialTheme.colors.background)
.background(if (isThumbSelected) Color.Red else MaterialTheme.colorScheme.background)
.padding(12.dp)
)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package my.nanihadesuka.lazycolumnscrollbar.ui.theme

import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.Shapes
import androidx.compose.material3.Shapes
import androidx.compose.ui.unit.dp

val Shapes = Shapes(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
package my.nanihadesuka.lazycolumnscrollbar.ui.theme

import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.material.MaterialTheme
import androidx.compose.material.darkColors
import androidx.compose.material.lightColors
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.darkColorScheme
import androidx.compose.material3.lightColorScheme
import androidx.compose.runtime.Composable

private val DarkColorPalette = darkColors(
private val DarkColorPalette = darkColorScheme(
primary = Purple200,
primaryVariant = Purple700,
secondary = Teal200
)

private val LightColorPalette = lightColors(
private val LightColorPalette = lightColorScheme(
primary = Purple500,
primaryVariant = Purple700,
secondary = Teal200

/* Other default colors to override
Expand All @@ -40,7 +38,7 @@ fun LazyColumnScrollbarTheme(darkTheme: Boolean = isSystemInDarkTheme(), content
}

MaterialTheme(
colors = colors,
colorScheme = colors,
typography = Typography,
shapes = Shapes,
content = content
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package my.nanihadesuka.lazycolumnscrollbar.ui.theme

import androidx.compose.material.Typography
import androidx.compose.material3.Typography
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.sp

// Set of Material typography styles to start with
val Typography = Typography(
body1 = TextStyle(
bodyLarge = TextStyle(
fontFamily = FontFamily.Default,
fontWeight = FontWeight.Normal,
fontSize = 16.sp
Expand Down
8 changes: 3 additions & 5 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ buildscript {
}

plugins {
alias(libs.plugins.kotlin.android) apply false
alias(libs.plugins.kotlin.multiplatform) apply false
alias(libs.plugins.jetbrains.compose.compiler) apply false
alias(libs.plugins.jetbrains.compose) apply false
alias(libs.plugins.android.application) apply false
alias(libs.plugins.android.library) apply false
}
Expand All @@ -25,7 +27,3 @@ subprojects {
maxParallelForks = (Runtime.getRuntime().availableProcessors() - 1).coerceAtLeast(1)
}
}

tasks.register("clean", Delete::class) {
delete(rootProject.buildDir)
}
8 changes: 7 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,10 @@ android.useAndroidX=true
android.enableJetifier=true
# Kotlin code style for this project: "official" or "obsolete":
kotlin.code.style=official
org.gradle.unsafe.configuration-cache=false
org.gradle.unsafe.configuration-cache=false

kotlin.mpp.androidGradlePluginCompatibility.nowarn=true
kotlin.native.ignoreDisabledTargets=true

org.jetbrains.compose.experimental.jscanvas.enabled=true
org.jetbrains.compose.experimental.macos.enabled=true
32 changes: 10 additions & 22 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,37 +1,25 @@
[versions]
kotlin = "1.9.23"
plugin-agp = "8.1.4"
kotlin = "2.0.20"
plugin-agp = "8.6.0"

compose-bom = "2024.04.00"
compose-compiler = "1.5.11"

activityCompose = "1.9.0"
appcompat = "1.6.1"
coreKtx = "1.13.0"
activityCompose = "1.9.2"
junit = "4.13.2"
lifecycleRuntimeKtx = "2.7.0"
material = "1.11.0"
material = "1.12.0"
robolectric = "4.11.1"
jetbrains-compose = "1.7.0-beta02"
compose = "1.7.1"

[libraries]
androidx-appcompat = { module = "androidx.appcompat:appcompat", version.ref = "appcompat" }
androidx-core-ktx = { module = "androidx.core:core-ktx", version.ref = "coreKtx" }
android-material = { module = "com.google.android.material:material", version.ref = "material" }
androidx-lifecycle-runtime-ktx = { module = "androidx.lifecycle:lifecycle-runtime-ktx", version.ref = "lifecycleRuntimeKtx" }

androidx-compose-bom = { module = "androidx.compose:compose-bom", version.ref = "compose-bom" }
androidx-compose-material = { module = "androidx.compose.material:material" }
androidx-compose-ui-ui = { module = "androidx.compose.ui:ui" }
androidx-compose-ui-tooling-preview = { module = "androidx.compose.ui:ui-tooling-preview" }
androidx-compose-ui-test-junit4 = { module = "androidx.compose.ui:ui-test-junit4" }
androidx-compose-ui-test-manifest = { module = "androidx.compose.ui:ui-test-manifest" }
androidx-compose-activity = { module = "androidx.activity:activity-compose", version.ref = "activityCompose" }
androidx-compose-ui-tooling = { module = "androidx.compose.ui:ui-tooling" }
androidx-compose-ui-test-manifest = { module = "androidx.compose.ui:ui-test-manifest", version.ref = "compose" }

junit = { module = "junit:junit", version.ref = "junit" }
robolectric = { module = "org.robolectric:robolectric", version.ref = "robolectric" }

[plugins]
android-application = { id = "com.android.application", version.ref = "plugin-agp" }
android-library = { id = "com.android.library", version.ref = "plugin-agp" }
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
kotlin-multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
jetbrains-compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
jetbrains-compose = { id = "org.jetbrains.compose", version.ref = "jetbrains-compose" }
Loading

0 comments on commit 04fa497

Please sign in to comment.