Skip to content
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
4 changes: 2 additions & 2 deletions build-logic/convention/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ plugins {
group = "dev.ohoussein.cryptoapp.buildlogic"

java {
sourceCompatibility = JavaVersion.VERSION_20
targetCompatibility = JavaVersion.VERSION_20
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}

dependencies {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,11 @@ class KotlinMultiplatformLibraryConventionPlugin : Plugin<Project> {
}
}

task("unitTestAll") {
setDependsOn(
listOf(
"cleanTestReleaseUnitTest", "testReleaseUnitTest",
"cleanDesktopTest", "desktopTest",
"cleanIosSimulatorArm64Test", "iosSimulatorArm64Test"
)
tasks.register("unitTestAll") {
dependsOn(
"cleanTestAndroidHostTest", "testAndroidHostTest",
"cleanDesktopTest", "desktopTest",
"cleanIosSimulatorArm64Test", "iosSimulatorArm64Test",
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,41 +2,41 @@ import com.android.build.api.dsl.CommonExtension
import dev.ohoussein.cryptoapp.SdkVersion
import org.gradle.api.JavaVersion
import org.gradle.api.Project
import org.gradle.kotlin.dsl.provideDelegate
import org.gradle.kotlin.dsl.withType
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile

internal fun Project.configureKotlinAndroid(
commonExtension: CommonExtension,
) = commonExtension.apply {
) {
val warningsAsErrors = (findProperty("warningsAsErrors") as? String).toBoolean()

compileSdk = SdkVersion.COMPILE_SDK_VERSION
with(defaultConfig) {
minSdk = SdkVersion.MIN_SDK_VERSION
}
commonExtension.apply {
compileSdk = SdkVersion.COMPILE_SDK_VERSION
with(defaultConfig) {
minSdk = SdkVersion.MIN_SDK_VERSION
}

compileOptions.sourceCompatibility = JavaVersion.VERSION_20
compileOptions.targetCompatibility = JavaVersion.VERSION_20
compileOptions.sourceCompatibility = JavaVersion.VERSION_21
compileOptions.targetCompatibility = JavaVersion.VERSION_21

tasks.withType<KotlinJvmCompile>().configureEach {
compilerOptions {
val warningsAsErrors: String? by project
allWarningsAsErrors.set(warningsAsErrors.toBoolean())
tasks.withType<KotlinJvmCompile>().configureEach {
compilerOptions {
allWarningsAsErrors.set(warningsAsErrors)

jvmTarget.set(JvmTarget.JVM_20)
jvmTarget.set(JvmTarget.JVM_21)

freeCompilerArgs.addAll(
"-opt-in=kotlin.RequiresOptIn",
"-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi",
)
freeCompilerArgs.addAll(
"-opt-in=kotlin.RequiresOptIn",
"-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi",
)
}
}
}

packaging.resources.excludes += arrayOf(
"**/attach_hotspot_windows.dll",
"META-INF/*",
"META-INF/licenses/**",
)
packaging.resources.excludes += arrayOf(
"**/attach_hotspot_windows.dll",
"META-INF/*",
"META-INF/licenses/**",
)
}
}
22 changes: 6 additions & 16 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ plugins {
alias(libs.plugins.compose.compiler) apply false
}

apply(plugin = "com.github.ben-manes.versions")

buildscript {
repositories {
google()
Expand All @@ -16,7 +14,6 @@ buildscript {
dependencies {
classpath(libs.build.android.gradlePlugin)
classpath(libs.build.kotlinPlugin)
classpath(libs.build.gradleVersionsPlugin)
classpath(libs.build.detekt.plugin)
classpath(libs.build.detekt.formatting)
classpath(libs.build.paparazzi)
Expand All @@ -32,36 +29,29 @@ allprojects {
}

tasks.register("clean").configure {
group = "build"
description = "Deletes the root project build directory."
delete("build")
}

tasks.withType<com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask> {
rejectVersionIf {
val version = candidate.version
val stableKeyword = listOf("RELEASE", "FINAL", "GA").any { version.uppercase().contains(it) }
val regex = "^[0-9,.v-]+(-r)?$".toRegex()
val isStable = stableKeyword || regex.matches(version)
isStable.not()
}
}

task("e2eTests", Exec::class) {
tasks.register<Exec>("e2eTests") {
group = "Verification"
description = "Run e2e test on a connected device"
workingDir = file("$projectDir/e2e_tests")
commandLine = listOf("bash", "test_android.sh")
}

task("generateScreenshots", Exec::class) {
tasks.register<Exec>("generateScreenshots") {
group = "Tool"
description = "Generate screenshots on a connected device"
workingDir = file("$projectDir/e2e_tests")
commandLine = listOf("bash", "generate_screenshots.sh")
}



subprojects {
apply(plugin = "org.jetbrains.kotlinx.kover")
pluginManager.apply("org.jetbrains.kotlinx.kover")
}

// Aggregate coverage of every module into the root project's merged report.
Expand Down
2 changes: 0 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ koin = "4.1.1"
koinCompose = "4.1.1"
koinCore = "4.1.1"
detektVersion = "1.23.8"
gradleVersionsPluginVersion = "0.53.0"
kover = "0.9.8"
paparazziVersion = "1.3.5"
sqldelight = "2.2.1"
Expand All @@ -27,7 +26,6 @@ turbineVersion = "1.2.1"
[libraries]
build-kotlinPlugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" }
build-android-gradlePlugin = { module = "com.android.tools.build:gradle", version.ref = "androidGradlePluginVersion" }
build-gradleVersionsPlugin = { module = "com.github.ben-manes:gradle-versions-plugin", version.ref = "gradleVersionsPluginVersion" }
build-detekt-plugin = { module = "io.gitlab.arturbosch.detekt:detekt-gradle-plugin", version.ref = "detektVersion" }
build-detekt-formatting = { module = "io.gitlab.arturbosch.detekt:detekt-formatting", version.ref = "detektVersion" }
build-paparazzi = { module = "app.cash.paparazzi:paparazzi-gradle-plugin", version.ref = "paparazziVersion" }
Expand Down
2 changes: 1 addition & 1 deletion shared/crypto/presentation/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ kotlin {
implementation(libs.composeMp.foundation)
implementation(libs.composeMp.material)
implementation(libs.composeMp.ui)
implementation(libs.composeMp.components.uiToolingPreview)
implementation(libs.composeMp.uiToolingPreview)
implementation(libs.composeMp.materialIconsExtended)
implementation(libs.composeMp.components.resources)
implementation(libs.compose.navigation)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
package dev.ohoussein.cryptoapp.crypto.presentation.core

import kotlinx.datetime.LocalDateTime
import kotlinx.datetime.Month
import kotlinx.datetime.number

@Suppress("LongParameterList")
fun LocalDateTime.copy(
year: Int = this.year,
monthNumber: Int = this.monthNumber,
dayOfMonth: Int = this.dayOfMonth,
monthNumber: Int = this.month.number,
dayOfMonth: Int = this.day,
hour: Int = this.hour,
minute: Int = this.minute,
second: Int = this.second,
nanosecond: Int = this.nanosecond,
) = LocalDateTime(
year = year,
monthNumber = monthNumber,
dayOfMonth = dayOfMonth,
month = Month(monthNumber),
day = dayOfMonth,
hour = hour,
minute = minute,
second = second,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.lifecycle.viewmodel.compose.viewModel
import dev.ohoussein.cryptoapp.crypto.presentation.fake.Fake.previewCryptoDetails
import dev.ohoussein.cryptoapp.crypto.presentation.graph.CryptoPriceGraph
import dev.ohoussein.cryptoapp.crypto.presentation.model.CryptoDetails
import dev.ohoussein.cryptoapp.crypto.presentation.model.DataStatus
Expand All @@ -19,6 +21,7 @@ import dev.ohoussein.cryptoapp.designsystem.base.CryptoAppScaffold
import dev.ohoussein.cryptoapp.designsystem.base.CryptoAppTopBar
import dev.ohoussein.cryptoapp.designsystem.base.StateError
import dev.ohoussein.cryptoapp.designsystem.base.StateLoading
import dev.ohoussein.cryptoapp.designsystem.theme.CryptoAppTheme
import org.koin.compose.getKoin
import org.koin.core.Koin
import org.koin.core.parameter.parametersOf
Expand Down Expand Up @@ -122,3 +125,41 @@ fun CryptoDetailsContent(
Spacer(modifier = Modifier.size(24.dp))
}
}

// The price graph pulls its data from Koin, so this preview renders only the
// header + links which stand on their own.
@Preview
@Composable
private fun PreviewCryptoDetails() {
CryptoAppTheme {
CryptoAppScaffold(
topBar = {
CryptoAppTopBar(
title = with(previewCryptoDetails.base) { "$name ($symbol)" },
onBackButton = {},
)
}
) { innerPadding ->
Column(
Modifier
.fillMaxSize()
.padding(innerPadding)
.padding(vertical = 12.dp),
) {
CryptoDetailsHeader(
modifier = Modifier.padding(all = 12.dp),
crypto = previewCryptoDetails,
)
CryptoLinks(
modifier = Modifier
.fillMaxWidth()
.padding(vertical = 24.dp, horizontal = 12.dp),
crypto = previewCryptoDetails,
onHomePageClicked = {},
onBlockchainSiteClicked = {},
onSourceCodeClicked = {},
)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import coil3.compose.LocalPlatformContext
import coil3.compose.rememberAsyncImagePainter
Expand All @@ -22,7 +23,6 @@ import dev.ohoussein.cryptoapp.crypto.presentation.model.Crypto
import dev.ohoussein.cryptoapp.designsystem.graph.ui.SparkLineGraph
import dev.ohoussein.cryptoapp.designsystem.theme.NegativeColor
import dev.ohoussein.cryptoapp.designsystem.theme.PositiveColor
import org.jetbrains.compose.ui.tooling.preview.Preview

@Composable
fun CryptoItem(
Expand Down
3 changes: 1 addition & 2 deletions shared/designsystem/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ kotlin {
sourceSets {
androidMain.dependencies {
implementation(libs.compose.ui.tooling)
implementation(libs.composeMp.uiToolingPreview)
}
commonMain.dependencies {
implementation(libs.composeMp.runtime)
Expand All @@ -18,7 +17,7 @@ kotlin {
implementation(libs.composeMp.materialIconsExtended)
implementation(libs.composeMp.ui)
implementation(libs.composeMp.components.resources)
implementation(libs.composeMp.components.uiToolingPreview)
implementation(libs.composeMp.uiToolingPreview)
implementation(libs.koin.compose)
implementation(libs.koin.core)
implementation(libs.coil.compose)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.ArrowBack
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp
import cryptoapp.shared.designsystem.generated.resources.Res
import cryptoapp.shared.designsystem.generated.resources.core_back
Expand Down Expand Up @@ -59,8 +60,9 @@ fun CryptoAppTopBar(
}
}
},
contentColor = MaterialTheme.colors.onPrimary,
backgroundColor = MaterialTheme.colors.primary,
elevation = 0.dp,
contentColor = MaterialTheme.colors.onSurface,
backgroundColor = Color.Transparent,
windowInsets = WindowInsets.statusBars,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ import androidx.compose.ui.text.TextMeasurer
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.drawText
import androidx.compose.ui.text.rememberTextMeasurer
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import dev.ohoussein.cryptoapp.designsystem.graph.model.GraphPoint
import dev.ohoussein.cryptoapp.designsystem.graph.model.GridPoint
import org.jetbrains.compose.ui.tooling.preview.Preview

@Suppress("LongMethod")
@Composable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ import androidx.compose.ui.graphics.Path
import androidx.compose.ui.graphics.StrokeCap
import androidx.compose.ui.graphics.drawscope.Fill
import androidx.compose.ui.graphics.drawscope.Stroke
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import dev.ohoussein.cryptoapp.designsystem.graph.model.GraphPoint
import org.jetbrains.compose.ui.tooling.preview.Preview

@Composable
fun SparkLineGraph(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,14 @@ import androidx.navigation.compose.NavHost
import androidx.navigation.compose.rememberNavController
import dev.ohoussein.cryptoapp.crypto.presentation.CryptoFeatNavPath
import dev.ohoussein.cryptoapp.crypto.presentation.nav.cryptoAppNavigation
import org.koin.compose.KoinContext

@Composable
fun SharedApp() {
KoinContext {
val navController = rememberNavController()
NavHost(
navController = navController,
startDestination = CryptoFeatNavPath.HOME,
) {
cryptoAppNavigation(navController)
}
val navController = rememberNavController()
NavHost(
navController = navController,
startDestination = CryptoFeatNavPath.HOME,
) {
cryptoAppNavigation(navController)
}
}
Loading