WIP: Make :core:designsystem as the multiplatform module

pull/1323/head
lihenggui 2 years ago
parent 3fc3452304
commit 0dce05406c

@ -14,8 +14,8 @@
* limitations under the License.
*/
plugins {
alias(libs.plugins.nowinandroid.android.library)
alias(libs.plugins.nowinandroid.android.library.compose)
alias(libs.plugins.nowinandroid.kmp.library)
alias(libs.plugins.jetbrains.compose)
alias(libs.plugins.nowinandroid.android.library.jacoco)
alias(libs.plugins.roborazzi)
}
@ -27,26 +27,41 @@ android {
namespace = "com.google.samples.apps.nowinandroid.core.designsystem"
}
kotlin {
sourceSets {
androidMain.dependencies {
implementation(libs.compose.ui.tooling.preview)
implementation(libs.androidx.activity.compose)
}
androidUnitTest.dependencies {
implementation(libs.androidx.compose.ui.test)
implementation(projects.core.testing)
}
commonMain.dependencies {
implementation(libs.coil.compose)
implementation(compose.runtime)
implementation(compose.foundation)
implementation(compose.material)
implementation(compose.material3)
implementation(compose.materialIconsExtended)
implementation(compose.ui)
implementation(compose.uiUtil)
implementation(compose.components.resources)
implementation(compose.components.uiToolingPreview)
}
commonTest.dependencies {
implementation(libs.kotlin.test)
}
}
}
dependencies {
lintPublish(projects.lint)
api(libs.androidx.compose.foundation)
api(libs.androidx.compose.foundation.layout)
api(libs.androidx.compose.material.iconsExtended)
api(libs.androidx.compose.material3)
api(libs.androidx.compose.runtime)
api(libs.androidx.compose.ui.util)
implementation(libs.coil.compose)
testImplementation(libs.androidx.compose.ui.test)
testImplementation(libs.accompanist.testharness)
testImplementation(libs.hilt.android.testing)
testImplementation(libs.robolectric)
testImplementation(libs.roborazzi)
testImplementation(projects.core.screenshotTesting)
testImplementation(projects.core.testing)
androidTestImplementation(libs.androidx.compose.ui.test)
androidTestImplementation(projects.core.testing)
}

@ -16,7 +16,6 @@
package com.google.samples.apps.nowinandroid.core.designsystem.component
import android.content.res.Configuration
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.size
@ -31,13 +30,14 @@ import androidx.compose.ui.draw.drawWithCache
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import com.google.samples.apps.nowinandroid.core.designsystem.theme.GradientColors
import com.google.samples.apps.nowinandroid.core.designsystem.theme.LocalBackgroundTheme
import com.google.samples.apps.nowinandroid.core.designsystem.theme.LocalGradientColors
import com.google.samples.apps.nowinandroid.core.designsystem.theme.NiaTheme
import org.jetbrains.compose.ui.tooling.preview.Preview
import kotlin.math.PI
import kotlin.math.tan
/**
@ -95,14 +95,14 @@ fun NiaGradientBackground(
.drawWithCache {
// Compute the start and end coordinates such that the gradients are angled 11.06
// degrees off the vertical axis
// Math.toRadians is replaced by deg / 180.0 * PI
val offset = size.height * tan(
Math
.toRadians(11.06)
(11.06) / 180.0 * PI
.toFloat(),
)
val start = Offset(size.width / 2 + offset / 2, 0f)
val end = Offset(size.width / 2 - offset / 2, size.height)
val start = Offset((size.width / 2 + offset / 2).toFloat(), 0f)
val end = Offset((size.width / 2 - offset / 2).toFloat(), size.height)
// Create the top gradient that fades out after the halfway point vertically
val topGradient = Brush.linearGradient(
@ -143,8 +143,9 @@ fun NiaGradientBackground(
* Multipreview annotation that represents light and dark themes. Add this annotation to a
* composable to render the both themes.
*/
@Preview(uiMode = Configuration.UI_MODE_NIGHT_NO, name = "Light theme")
@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES, name = "Dark theme")
//@Preview(uiMode = Configuration.UI_MODE_NIGHT_NO, name = "Light theme")
//@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES, name = "Dark theme")
@Preview
annotation class ThemePreviews
@ThemePreviews

@ -31,6 +31,7 @@ import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp
import com.google.samples.apps.nowinandroid.core.designsystem.icon.NiaIcons
import com.google.samples.apps.nowinandroid.core.designsystem.theme.NiaTheme
import org.jetbrains.compose.ui.tooling.preview.Preview
/**
* Now in Android filter chip with included leading checked icon as well as text content slot.
@ -43,7 +44,6 @@ import com.google.samples.apps.nowinandroid.core.designsystem.theme.NiaTheme
* @param label The text label content.
*/
@Composable
@OptIn(ExperimentalMaterial3Api::class)
fun NiaFilterChip(
selected: Boolean,
onSelectedChange: (Boolean) -> Unit,

@ -35,12 +35,13 @@ import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.platform.LocalInspectionMode
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.unit.dp
import coil.compose.AsyncImage
import coil.compose.AsyncImagePainter.State.Error
import coil.compose.AsyncImagePainter.State.Loading
import coil.compose.rememberAsyncImagePainter
import coil3.compose.AsyncImage
import coil3.compose.AsyncImagePainter.State.Error
import coil3.compose.AsyncImagePainter.State.Loading
import coil3.compose.rememberAsyncImagePainter
import com.google.samples.apps.nowinandroid.core.designsystem.R
import com.google.samples.apps.nowinandroid.core.designsystem.theme.LocalTintTheme
import org.jetbrains.compose.resources.painterResource
/**
* A wrapper around [AsyncImage] which determines the colorFilter based on the theme

@ -16,7 +16,6 @@
package com.google.samples.apps.nowinandroid.core.designsystem.component.scrollbar
import android.annotation.SuppressLint
import androidx.compose.animation.animateColorAsState
import androidx.compose.animation.core.Spring
import androidx.compose.animation.core.SpringSpec
@ -164,9 +163,6 @@ private fun ScrollableState.DecorativeScrollbarThumb(
)
}
// TODO: This lint is removed in 1.6 as the recommendation has changed
// remove when project is upgraded
@SuppressLint("ComposableModifierFactory")
@Composable
private fun Modifier.scrollThumb(
scrollableState: ScrollableState,

@ -57,6 +57,7 @@ import androidx.compose.ui.util.unpackFloat2
import kotlinx.coroutines.TimeoutCancellationException
import kotlinx.coroutines.delay
import kotlinx.coroutines.withTimeout
import kotlin.jvm.JvmInline
import kotlin.math.max
import kotlin.math.min
import kotlin.math.roundToInt

@ -17,8 +17,6 @@
package com.google.samples.apps.nowinandroid.core.designsystem.theme
import android.os.Build
import androidx.annotation.ChecksSdkIntAtLeast
import androidx.annotation.VisibleForTesting
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.darkColorScheme
@ -35,7 +33,6 @@ import androidx.compose.ui.unit.dp
/**
* Light default theme color scheme
*/
@VisibleForTesting
val LightDefaultColorScheme = lightColorScheme(
primary = Purple40,
onPrimary = Color.White,

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save