Skip to content

Commit

Permalink
Support KMP for macos
Browse files Browse the repository at this point in the history
  • Loading branch information
fornewid committed Jun 3, 2024
1 parent 8007ddc commit 8ad8ab0
Show file tree
Hide file tree
Showing 17 changed files with 92 additions and 109 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ class KotlinMultiplatformConventionPlugin : Plugin<Project> {
iosArm64()
iosSimulatorArm64()

macosX64()
macosArm64()

configureKotlin()
}
}
Expand Down
2 changes: 2 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ android.nonTransitiveRClass=true
kotlin.mpp.androidSourceSetLayoutVersion=2
kotlin.mpp.enableCInteropCommonization=true

org.jetbrains.compose.experimental.macos.enabled=true

# Publish
SONATYPE_HOST=S01
RELEASE_SIGNING_ENABLED=true
Expand Down
15 changes: 15 additions & 0 deletions sample/shared/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,21 @@ kotlin {
}
}

macosX64 {
binaries {
executable {
entryPoint = "main"
}
}
}
macosArm64 {
binaries {
executable {
entryPoint = "main"
}
}
}

sourceSets {
commonMain.dependencies {
implementation(projects.foundation)
Expand Down

This file was deleted.

15 changes: 0 additions & 15 deletions sample/shared/src/commonMain/composeResources/values/strings.xml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,6 @@ import androidx.compose.material.TopAppBar
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import org.jetbrains.compose.resources.stringResource
import placeholder.sample.shared.generated.resources.Res
import placeholder.sample.shared.generated.resources.foundation_title_basics
import placeholder.sample.shared.generated.resources.foundation_title_fade
import placeholder.sample.shared.generated.resources.foundation_title_shimmer
import placeholder.sample.shared.generated.resources.home
import placeholder.sample.shared.generated.resources.material3_title_basics
import placeholder.sample.shared.generated.resources.material3_title_fade
import placeholder.sample.shared.generated.resources.material3_title_shimmer
import placeholder.sample.shared.generated.resources.material_title_basics
import placeholder.sample.shared.generated.resources.material_title_fade
import placeholder.sample.shared.generated.resources.material_title_shimmer

private data class Demo(
val title: String,
Expand All @@ -54,47 +42,47 @@ private data class Demo(
fun HomeScreen(onItemClick: (Destination) -> Unit) {
val items: List<Demo> = listOf(
Demo(
title = stringResource(Res.string.foundation_title_basics),
title = StringResources.foundation_title_basics,
destination = Destination.PlaceholderFoundationBasic,
),
Demo(
title = stringResource(Res.string.foundation_title_fade),
title = StringResources.foundation_title_fade,
destination = Destination.PlaceholderFoundationFade,
),
Demo(
title = stringResource(Res.string.foundation_title_shimmer),
title = StringResources.foundation_title_shimmer,
destination = Destination.PlaceholderFoundationShimmer,
),
Demo(
title = stringResource(Res.string.material_title_basics),
title = StringResources.material_title_basics,
destination = Destination.PlaceholderMaterialBasic,
),
Demo(
title = stringResource(Res.string.material_title_fade),
title = StringResources.material_title_fade,
destination = Destination.PlaceholderMaterialFade,
),
Demo(
title = stringResource(Res.string.material_title_shimmer),
title = StringResources.material_title_shimmer,
destination = Destination.PlaceholderMaterialShimmer,
),
Demo(
title = stringResource(Res.string.material3_title_basics),
title = StringResources.material3_title_basics,
destination = Destination.PlaceholderMaterial3Basic,
),
Demo(
title = stringResource(Res.string.material3_title_fade),
title = StringResources.material3_title_fade,
destination = Destination.PlaceholderMaterial3Fade,
),
Demo(
title = stringResource(Res.string.material3_title_shimmer),
title = StringResources.material3_title_shimmer,
destination = Destination.PlaceholderMaterial3Shimmer,
),
)

Scaffold(
topBar = {
TopAppBar(
title = { Text(text = stringResource(Res.string.home)) },
title = { Text(text = StringResources.home_title) },
backgroundColor = MaterialTheme.colors.surface,
)
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package io.github.fornewid.placeholder.sample

object StringResources {
const val home_title: String ="Placeholder"

const val foundation_title_basics: String ="Placeholder Foundation: Basic"
const val foundation_title_fade: String ="Placeholder Foundation: Fade"
const val foundation_title_shimmer: String ="Placeholder Foundation: Shimmer"

const val material_title_basics: String ="Placeholder Material: Basic"
const val material_title_fade: String ="Placeholder Material: Fade"
const val material_title_shimmer: String ="Placeholder Material: Shimmer"

const val material3_title_basics: String ="Placeholder Material3: Basic"
const val material3_title_fade: String ="Placeholder Material3: Fade"
const val material3_title_shimmer: String ="Placeholder Material3: Shimmer"
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,11 @@ import androidx.compose.ui.graphics.vector.rememberVectorPainter
import androidx.compose.ui.unit.dp
import coil3.compose.rememberAsyncImagePainter
import io.github.fornewid.placeholder.foundation.placeholder
import io.github.fornewid.placeholder.sample.StringResources
import io.github.fornewid.placeholder.sample.material.HeaderItem
import io.github.fornewid.placeholder.sample.material.ListItem
import io.github.fornewid.placeholder.sample.randomSampleImageUrl
import kotlinx.coroutines.delay
import org.jetbrains.compose.resources.stringResource
import placeholder.sample.shared.generated.resources.Res
import placeholder.sample.shared.generated.resources.foundation_title_basics

@Composable
fun PlaceholderBasicSample() {
Expand All @@ -64,7 +62,7 @@ private fun Sample() {
Scaffold(
topBar = {
TopAppBar(
title = { Text(stringResource(Res.string.foundation_title_basics)) },
title = { Text(StringResources.foundation_title_basics) },
backgroundColor = MaterialTheme.colors.surface,
)
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,11 @@ import coil3.compose.rememberAsyncImagePainter
import io.github.fornewid.placeholder.foundation.PlaceholderHighlight
import io.github.fornewid.placeholder.foundation.fade
import io.github.fornewid.placeholder.foundation.placeholder
import io.github.fornewid.placeholder.sample.StringResources
import io.github.fornewid.placeholder.sample.material.HeaderItem
import io.github.fornewid.placeholder.sample.material.ListItem
import io.github.fornewid.placeholder.sample.randomSampleImageUrl
import kotlinx.coroutines.delay
import org.jetbrains.compose.resources.stringResource
import placeholder.sample.shared.generated.resources.Res
import placeholder.sample.shared.generated.resources.foundation_title_fade

@Composable
fun PlaceholderFadeSample() {
Expand All @@ -66,7 +64,7 @@ private fun Sample() {
Scaffold(
topBar = {
TopAppBar(
title = { Text(stringResource(Res.string.foundation_title_fade)) },
title = { Text(StringResources.foundation_title_fade) },
backgroundColor = MaterialTheme.colors.surface,
)
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,11 @@ import coil3.compose.rememberAsyncImagePainter
import io.github.fornewid.placeholder.foundation.PlaceholderHighlight
import io.github.fornewid.placeholder.foundation.placeholder
import io.github.fornewid.placeholder.foundation.shimmer
import io.github.fornewid.placeholder.sample.StringResources
import io.github.fornewid.placeholder.sample.material.HeaderItem
import io.github.fornewid.placeholder.sample.material.ListItem
import io.github.fornewid.placeholder.sample.randomSampleImageUrl
import kotlinx.coroutines.delay
import org.jetbrains.compose.resources.stringResource
import placeholder.sample.shared.generated.resources.Res
import placeholder.sample.shared.generated.resources.foundation_title_shimmer

@Composable
fun PlaceholderShimmerSample() {
Expand All @@ -66,7 +64,7 @@ private fun Sample() {
Scaffold(
topBar = {
TopAppBar(
title = { Text(stringResource(Res.string.foundation_title_shimmer)) },
title = { Text(StringResources.foundation_title_shimmer) },
backgroundColor = MaterialTheme.colors.surface,
)
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,9 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.vector.rememberVectorPainter
import coil3.compose.rememberAsyncImagePainter
import io.github.fornewid.placeholder.material.placeholder
import io.github.fornewid.placeholder.sample.StringResources
import io.github.fornewid.placeholder.sample.randomSampleImageUrl
import kotlinx.coroutines.delay
import org.jetbrains.compose.resources.stringResource
import placeholder.sample.shared.generated.resources.Res
import placeholder.sample.shared.generated.resources.material_title_basics

@Composable
fun PlaceholderMaterialBasicSample() {
Expand All @@ -59,7 +57,7 @@ private fun Sample() {
Scaffold(
topBar = {
TopAppBar(
title = { Text(stringResource(Res.string.material_title_basics)) },
title = { Text(StringResources.material_title_basics) },
backgroundColor = MaterialTheme.colors.surface,
)
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,9 @@ import coil3.compose.rememberAsyncImagePainter
import io.github.fornewid.placeholder.foundation.PlaceholderHighlight
import io.github.fornewid.placeholder.material.fade
import io.github.fornewid.placeholder.material.placeholder
import io.github.fornewid.placeholder.sample.StringResources
import io.github.fornewid.placeholder.sample.randomSampleImageUrl
import kotlinx.coroutines.delay
import org.jetbrains.compose.resources.stringResource
import placeholder.sample.shared.generated.resources.Res
import placeholder.sample.shared.generated.resources.material_title_fade

@Composable
fun PlaceholderMaterialFadeSample() {
Expand All @@ -61,7 +59,7 @@ private fun Sample() {
Scaffold(
topBar = {
TopAppBar(
title = { Text(stringResource(Res.string.material_title_fade)) },
title = { Text(StringResources.material_title_fade) },
backgroundColor = MaterialTheme.colors.surface,
)
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,9 @@ import coil3.compose.rememberAsyncImagePainter
import io.github.fornewid.placeholder.foundation.PlaceholderHighlight
import io.github.fornewid.placeholder.material.placeholder
import io.github.fornewid.placeholder.material.shimmer
import io.github.fornewid.placeholder.sample.StringResources
import io.github.fornewid.placeholder.sample.randomSampleImageUrl
import kotlinx.coroutines.delay
import org.jetbrains.compose.resources.stringResource
import placeholder.sample.shared.generated.resources.Res
import placeholder.sample.shared.generated.resources.material_title_shimmer

@Composable
fun PlaceholderMaterialShimmerSample() {
Expand All @@ -61,7 +59,7 @@ private fun Sample() {
Scaffold(
topBar = {
TopAppBar(
title = { Text(stringResource(Res.string.material_title_shimmer)) },
title = { Text(StringResources.material_title_shimmer) },
backgroundColor = MaterialTheme.colors.surface,
)
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,9 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.vector.rememberVectorPainter
import coil3.compose.rememberAsyncImagePainter
import io.github.fornewid.placeholder.material3.placeholder
import io.github.fornewid.placeholder.sample.StringResources
import io.github.fornewid.placeholder.sample.randomSampleImageUrl
import kotlinx.coroutines.delay
import org.jetbrains.compose.resources.stringResource
import placeholder.sample.shared.generated.resources.Res
import placeholder.sample.shared.generated.resources.material3_title_basics

@Composable
fun PlaceholderMaterial3BasicSample() {
Expand All @@ -59,7 +57,7 @@ private fun Sample() {
Scaffold(
topBar = {
TopAppBar(
title = { Text(stringResource(Res.string.material3_title_basics)) },
title = { Text(StringResources.material3_title_basics) },
)
},
modifier = Modifier.fillMaxSize(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,9 @@ import coil3.compose.rememberAsyncImagePainter
import io.github.fornewid.placeholder.foundation.PlaceholderHighlight
import io.github.fornewid.placeholder.material3.fade
import io.github.fornewid.placeholder.material3.placeholder
import io.github.fornewid.placeholder.sample.StringResources
import io.github.fornewid.placeholder.sample.randomSampleImageUrl
import kotlinx.coroutines.delay
import org.jetbrains.compose.resources.stringResource
import placeholder.sample.shared.generated.resources.Res
import placeholder.sample.shared.generated.resources.material3_title_fade

@Composable
fun PlaceholderMaterial3FadeSample() {
Expand All @@ -61,7 +59,7 @@ private fun Sample() {
Scaffold(
topBar = {
TopAppBar(
title = { Text(stringResource(Res.string.material3_title_fade)) },
title = { Text(StringResources.material3_title_fade) },
)
},
modifier = Modifier.fillMaxSize(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,9 @@ import coil3.compose.rememberAsyncImagePainter
import io.github.fornewid.placeholder.foundation.PlaceholderHighlight
import io.github.fornewid.placeholder.material3.placeholder
import io.github.fornewid.placeholder.material3.shimmer
import io.github.fornewid.placeholder.sample.StringResources
import io.github.fornewid.placeholder.sample.randomSampleImageUrl
import kotlinx.coroutines.delay
import org.jetbrains.compose.resources.stringResource
import placeholder.sample.shared.generated.resources.Res
import placeholder.sample.shared.generated.resources.material3_title_shimmer

@Composable
fun PlaceholderMaterial3ShimmerSample() {
Expand All @@ -61,7 +59,7 @@ private fun Sample() {
Scaffold(
topBar = {
TopAppBar(
title = { Text(stringResource(Res.string.material3_title_shimmer)) },
title = { Text(StringResources.material3_title_shimmer) },
)
},
modifier = Modifier.fillMaxSize(),
Expand Down
Loading

0 comments on commit 8ad8ab0

Please sign in to comment.