diff --git a/composeApp/build.gradle.kts b/composeApp/build.gradle.kts index 78a3a40..86f3911 100644 --- a/composeApp/build.gradle.kts +++ b/composeApp/build.gradle.kts @@ -29,13 +29,14 @@ kotlin { baseName = "ComposeApp" } } - sourceSets { androidMain.dependencies { implementation(compose.preview) implementation(libs.androidx.activity.compose) } commonMain.dependencies { + implementation(project(":modules:core")) + implementation(project(":modules:domain")) implementation(compose.runtime) implementation(compose.foundation) implementation(compose.material3) diff --git a/composeApp/src/commonMain/kotlin/widget/AbilityItemView.kt b/composeApp/src/commonMain/kotlin/widget/AbilityItemView.kt index aef44e6..e16d91c 100644 --- a/composeApp/src/commonMain/kotlin/widget/AbilityItemView.kt +++ b/composeApp/src/commonMain/kotlin/widget/AbilityItemView.kt @@ -32,7 +32,7 @@ fun AbilityItemView(ability: PlayerAbility) { Text( text = ability.label, style = AppTheme.typography.body.large.copy(fontWeight = FontWeight.Bold), - color = AppTheme.colorScheme.onBackground + color = AppTheme.colors.yellow.light2 ) } } diff --git a/composeApp/src/commonMain/kotlin/widget/PlayerDetailView.kt b/composeApp/src/commonMain/kotlin/widget/PlayerDetailView.kt index a7b8e7e..28305b4 100644 --- a/composeApp/src/commonMain/kotlin/widget/PlayerDetailView.kt +++ b/composeApp/src/commonMain/kotlin/widget/PlayerDetailView.kt @@ -1,46 +1,25 @@ package widget import androidx.compose.foundation.background -import androidx.compose.foundation.clickable -import androidx.compose.foundation.layout.Arrangement -import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer -import androidx.compose.foundation.layout.aspectRatio import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.layout.size -import androidx.compose.foundation.layout.width -import androidx.compose.foundation.lazy.grid.GridCells -import androidx.compose.foundation.lazy.grid.LazyVerticalGrid -import androidx.compose.foundation.lazy.grid.items import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.verticalScroll -import androidx.compose.material.icons.Icons -import androidx.compose.material.icons.filled.CheckCircle -import androidx.compose.material.icons.filled.Menu -import androidx.compose.material.icons.filled.Star import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip -import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.style.TextAlign -import coil3.compose.AsyncImage import eaplayers.composeapp.generated.resources.Res import eaplayers.composeapp.generated.resources.abilities -import eaplayers.composeapp.generated.resources.height import eaplayers.composeapp.generated.resources.nationality -import eaplayers.composeapp.generated.resources.player_image_desc import eaplayers.composeapp.generated.resources.player_rank -import eaplayers.composeapp.generated.resources.position -import eaplayers.composeapp.generated.resources.rating import eaplayers.composeapp.generated.resources.team -import eaplayers.composeapp.generated.resources.team_mates import io.imrekaszab.eaplayers.domain.model.Player import org.jetbrains.compose.resources.stringResource import theme.AppTheme @@ -79,28 +58,6 @@ fun PlayerDetailView( } } -@Composable -fun PlayerImage(player: Player) { - Box( - modifier = Modifier - .fillMaxWidth() - .padding(vertical = AppTheme.dimens.margin.default) - .aspectRatio(1f) - .clip(AppTheme.shapes.default.roundedDefault) - .background(AppTheme.colorScheme.surface) - ) { - AsyncImage( - model = player.shieldUrl, - contentDescription = stringResource( - Res.string.player_image_desc, - player.firstName, - player.lastName - ), - modifier = Modifier.fillMaxSize() - ) - } -} - @Composable fun PlayerInfoSection(player: Player) { Column( @@ -110,7 +67,8 @@ fun PlayerInfoSection(player: Player) { Text( text = "${player.firstName} ${player.lastName}", style = AppTheme.typography.heading.large, - color = AppTheme.colorScheme.onBackground + color = AppTheme.colorScheme.onBackground, + textAlign = TextAlign.Center ) Text( text = stringResource(Res.string.player_rank, player.rank), @@ -133,122 +91,28 @@ fun PlayerInfoSection(player: Player) { } } -@Composable -fun PlayerStatsRow(player: Player) { - Row( - modifier = Modifier.fillMaxWidth(), - horizontalArrangement = Arrangement.SpaceBetween - ) { - PlayerStatItem( - icon = Icons.Default.Star, - stat = player.overallRating.toString(), - label = stringResource(Res.string.rating) - ) - PlayerStatItem( - icon = Icons.Default.Menu, - stat = player.position.shortLabel, - label = stringResource(Res.string.position) - ) - PlayerStatItem( - icon = Icons.Default.CheckCircle, - stat = "${player.height} cm", - label = stringResource(Res.string.height) - ) - } -} - @Composable fun AbilitiesSection(player: Player) { - if (player.playerAbilities.isNotEmpty()) { - Text( - text = stringResource(Res.string.abilities), - style = AppTheme.typography.heading.medium, - color = AppTheme.colorScheme.onBackground - ) - Spacer(modifier = Modifier.height(AppTheme.dimens.margin.tiny)) - - player.playerAbilities.forEach { ability -> - AbilityItemView(ability) - } - } -} - -@Composable -fun TeamMatesSection(player: Player, onTeamMateSelected: (Player) -> Unit) { - Text( - text = stringResource(Res.string.team_mates), - style = AppTheme.typography.heading.medium, - color = AppTheme.colorScheme.onBackground - ) - Spacer(modifier = Modifier.height(AppTheme.dimens.margin.tiny)) - - Box( - modifier = Modifier - .fillMaxWidth() - .height(AppTheme.dimens.playerDetailView.boxSize) - ) { - LazyVerticalGrid( - columns = GridCells.Adaptive(minSize = AppTheme.dimens.playerDetailView.gridMinSize) - ) { - items( - player.teamMates.filter { it.id != player.id } - .sortedByDescending { it.overallRating } - ) { mate -> - TeamMateCard(mate = mate, onTeamMateSelected = onTeamMateSelected) - } - } - } -} - -@Composable -fun TeamMateCard(mate: Player, onTeamMateSelected: (Player) -> Unit) { Column( modifier = Modifier - .padding(AppTheme.dimens.margin.tiny) - .width(AppTheme.dimens.playerDetailView.cardWidth) - .clickable { onTeamMateSelected(mate) }, - horizontalAlignment = Alignment.CenterHorizontally - ) { - AsyncImage( - modifier = Modifier - .size(AppTheme.dimens.playerDetailView.imageSize) - .clip(AppTheme.shapes.default.circle), - model = mate.avatarUrl, - contentDescription = mate.lastName - ) - Spacer(modifier = Modifier.height(AppTheme.dimens.margin.tiny)) - Text( - text = mate.commonName ?: "${mate.firstName}. ${mate.lastName.first()}", - textAlign = TextAlign.Center, - style = AppTheme.typography.body.small.copy(fontWeight = FontWeight.Bold), - color = AppTheme.colorScheme.onSurface - ) - Text( - text = mate.position.shortLabel, - style = AppTheme.typography.body.small, - color = AppTheme.colorScheme.onSurface - ) - } -} - -@Composable -fun PlayerStatRow(statItems: List) { - Row( - modifier = Modifier.fillMaxWidth(), - horizontalArrangement = Arrangement.SpaceEvenly + .clip(AppTheme.shapes.default.roundedDefault) + .background( + color = AppTheme.colors.blue.default, + shape = AppTheme.shapes.default.roundedDefault + ) + .padding(AppTheme.dimens.margin.default) ) { - statItems.forEach { statItem -> - PlayerStatItem( - imageUrl = statItem.imageUrl, - stat = statItem.stat, - label = statItem.label + if (player.playerAbilities.isNotEmpty()) { + Text( + text = stringResource(Res.string.abilities), + style = AppTheme.typography.heading.medium, + color = AppTheme.colors.yellow.default ) + Spacer(modifier = Modifier.height(AppTheme.dimens.margin.tiny)) + + player.playerAbilities.forEach { ability -> + AbilityItemView(ability) + } } } } - -data class PlayerStat( - val imageUrl: String, - val stat: String, - val label: String -) diff --git a/composeApp/src/commonMain/kotlin/widget/PlayerImage.kt b/composeApp/src/commonMain/kotlin/widget/PlayerImage.kt new file mode 100644 index 0000000..551759b --- /dev/null +++ b/composeApp/src/commonMain/kotlin/widget/PlayerImage.kt @@ -0,0 +1,39 @@ +package widget + +import androidx.compose.foundation.background +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.aspectRatio +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.padding +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.clip +import coil3.compose.AsyncImage +import eaplayers.composeapp.generated.resources.Res +import eaplayers.composeapp.generated.resources.player_image_desc +import io.imrekaszab.eaplayers.domain.model.Player +import org.jetbrains.compose.resources.stringResource +import theme.AppTheme + +@Composable +fun PlayerImage(player: Player) { + Box( + modifier = Modifier + .fillMaxWidth() + .padding(vertical = AppTheme.dimens.margin.default) + .aspectRatio(1f) + .clip(AppTheme.shapes.default.roundedDefault) + .background(AppTheme.colorScheme.surface) + ) { + AsyncImage( + model = player.shieldUrl, + contentDescription = stringResource( + Res.string.player_image_desc, + player.firstName, + player.lastName + ), + modifier = Modifier.fillMaxSize() + ) + } +} diff --git a/composeApp/src/commonMain/kotlin/widget/PlayerStatItem.kt b/composeApp/src/commonMain/kotlin/widget/PlayerStatItem.kt index 146aa24..326f449 100644 --- a/composeApp/src/commonMain/kotlin/widget/PlayerStatItem.kt +++ b/composeApp/src/commonMain/kotlin/widget/PlayerStatItem.kt @@ -25,12 +25,12 @@ fun PlayerStatItem(imageUrl: String, stat: String, label: String) { Text( text = stat, style = AppTheme.typography.body.large, - color = AppTheme.colorScheme.onSurface + color = AppTheme.colors.yellow.default ) Text( text = label, style = AppTheme.typography.body.small, - color = AppTheme.colorScheme.onSurfaceVariant + color = AppTheme.colors.yellow.light1 ) } } diff --git a/composeApp/src/commonMain/kotlin/widget/PlayerStatRow.kt b/composeApp/src/commonMain/kotlin/widget/PlayerStatRow.kt new file mode 100644 index 0000000..a768ca0 --- /dev/null +++ b/composeApp/src/commonMain/kotlin/widget/PlayerStatRow.kt @@ -0,0 +1,76 @@ +package widget + +import androidx.compose.foundation.background +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.padding +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.filled.KeyboardArrowUp +import androidx.compose.material.icons.filled.Menu +import androidx.compose.material.icons.filled.Star +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.clip +import eaplayers.composeapp.generated.resources.Res +import eaplayers.composeapp.generated.resources.height +import eaplayers.composeapp.generated.resources.position +import eaplayers.composeapp.generated.resources.rating +import io.imrekaszab.eaplayers.domain.model.Player +import org.jetbrains.compose.resources.stringResource +import theme.AppTheme + +@Composable +fun PlayerStatsRow(player: Player) { + Row( + modifier = Modifier + .fillMaxWidth() + .padding(horizontal = AppTheme.dimens.margin.default), + horizontalArrangement = Arrangement.SpaceBetween + ) { + PlayerStatItem( + icon = Icons.Default.Star, + stat = player.overallRating.toString(), + label = stringResource(Res.string.rating) + ) + PlayerStatItem( + icon = Icons.Default.Menu, + stat = player.position.shortLabel, + label = stringResource(Res.string.position) + ) + PlayerStatItem( + icon = Icons.Default.KeyboardArrowUp, + stat = "${player.height} cm", + label = stringResource(Res.string.height) + ) + } +} + +@Composable +fun PlayerStatRow(statItems: List) { + Row( + modifier = Modifier + .fillMaxWidth() + .clip(AppTheme.shapes.default.roundedDefault) + .background( + color = AppTheme.colors.blue.default, + shape = AppTheme.shapes.default.roundedDefault + ) + .padding(AppTheme.dimens.margin.default), + horizontalArrangement = Arrangement.SpaceEvenly + ) { + statItems.forEach { statItem -> + PlayerStatItem( + imageUrl = statItem.imageUrl, + stat = statItem.stat, + label = statItem.label + ) + } + } +} + +data class PlayerStat( + val imageUrl: String, + val stat: String, + val label: String +) diff --git a/composeApp/src/commonMain/kotlin/widget/TeamMateCard.kt b/composeApp/src/commonMain/kotlin/widget/TeamMateCard.kt new file mode 100644 index 0000000..5f7ec96 --- /dev/null +++ b/composeApp/src/commonMain/kotlin/widget/TeamMateCard.kt @@ -0,0 +1,85 @@ +package widget + +import androidx.compose.foundation.clickable +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.size +import androidx.compose.foundation.layout.width +import androidx.compose.foundation.lazy.grid.GridCells +import androidx.compose.foundation.lazy.grid.LazyVerticalGrid +import androidx.compose.foundation.lazy.grid.items +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.clip +import androidx.compose.ui.text.font.FontWeight +import androidx.compose.ui.text.style.TextAlign +import coil3.compose.AsyncImage +import eaplayers.composeapp.generated.resources.Res +import eaplayers.composeapp.generated.resources.team_mates +import io.imrekaszab.eaplayers.domain.model.Player +import org.jetbrains.compose.resources.stringResource +import theme.AppTheme + +@Composable +fun TeamMatesSection(player: Player, onTeamMateSelected: (Player) -> Unit) { + Text( + text = stringResource(Res.string.team_mates), + style = AppTheme.typography.heading.medium, + color = AppTheme.colorScheme.onBackground + ) + Spacer(modifier = Modifier.height(AppTheme.dimens.margin.tiny)) + + Box( + modifier = Modifier + .fillMaxWidth() + .height(AppTheme.dimens.playerDetailView.boxSize) + ) { + LazyVerticalGrid( + columns = GridCells.Adaptive(minSize = AppTheme.dimens.playerDetailView.gridMinSize) + ) { + items( + player.teamMates.filter { it.id != player.id } + .sortedByDescending { it.overallRating } + ) { mate -> + TeamMateCard(mate = mate, onTeamMateSelected = onTeamMateSelected) + } + } + } +} + +@Composable +fun TeamMateCard(mate: Player, onTeamMateSelected: (Player) -> Unit) { + Column( + modifier = Modifier + .padding(AppTheme.dimens.margin.tiny) + .width(AppTheme.dimens.playerDetailView.cardWidth) + .clickable { onTeamMateSelected(mate) }, + horizontalAlignment = Alignment.CenterHorizontally + ) { + AsyncImage( + modifier = Modifier + .size(AppTheme.dimens.playerDetailView.imageSize) + .clip(AppTheme.shapes.default.circle), + model = mate.avatarUrl, + contentDescription = mate.lastName + ) + Spacer(modifier = Modifier.height(AppTheme.dimens.margin.tiny)) + Text( + text = mate.commonName ?: "${mate.firstName}. ${mate.lastName.first()}", + textAlign = TextAlign.Center, + style = AppTheme.typography.body.small.copy(fontWeight = FontWeight.Bold), + color = AppTheme.colorScheme.onSurface + ) + Text( + text = mate.position.shortLabel, + style = AppTheme.typography.body.small, + color = AppTheme.colorScheme.onSurface + ) + } +} diff --git a/modules/core/build.gradle.kts b/modules/core/build.gradle.kts new file mode 100644 index 0000000..05b7759 --- /dev/null +++ b/modules/core/build.gradle.kts @@ -0,0 +1,59 @@ +import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi +import org.jetbrains.kotlin.gradle.dsl.JvmTarget + +plugins { + alias(libs.plugins.kotlinMultiplatform) + alias(libs.plugins.androidLibrary) + alias(libs.plugins.composeMultiplatform) +} + +kotlin { + androidTarget { + @OptIn(ExperimentalKotlinGradlePluginApi::class) + compilerOptions { + jvmTarget.set(JvmTarget.JVM_1_8) + } + } + + iosX64() + iosArm64() + iosSimulatorArm64() + + sourceSets { + androidMain.dependencies { + implementation(libs.kotlinx.coroutines.android) + } + commonMain.dependencies { + // Logging + implementation(libs.log.kermit) + implementation(libs.log.slf4j) + + // Compose Multiplatform + implementation(libs.compose.viewmodel) + implementation(libs.compose.navigation) + implementation(libs.compose.multiplatform.ui) + + implementation(libs.kotlinx.coroutines.core) + } + commonTest.dependencies { + implementation(libs.kotlin.test) + } + } +} + +android { + namespace = "io.imrekaszab.eaplayers.core" + + compileSdk = libs.versions.targetSdk.get().toInt() + defaultConfig { + minSdk = libs.versions.minSdk.get().toInt() + } + compileOptions { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + } + dependencies { + // Detekt + detektPlugins(libs.detekt.formatting) + } +} diff --git a/shared/src/commonMain/kotlin/io/imrekaszab/eaplayers/core/command/ActionCommand.kt b/modules/core/src/commonMain/kotlin/io/imrekaszab/eaplayers/core/command/ActionCommand.kt similarity index 100% rename from shared/src/commonMain/kotlin/io/imrekaszab/eaplayers/core/command/ActionCommand.kt rename to modules/core/src/commonMain/kotlin/io/imrekaszab/eaplayers/core/command/ActionCommand.kt diff --git a/shared/src/commonMain/kotlin/io/imrekaszab/eaplayers/core/command/BaseActionCommand.kt b/modules/core/src/commonMain/kotlin/io/imrekaszab/eaplayers/core/command/BaseActionCommand.kt similarity index 100% rename from shared/src/commonMain/kotlin/io/imrekaszab/eaplayers/core/command/BaseActionCommand.kt rename to modules/core/src/commonMain/kotlin/io/imrekaszab/eaplayers/core/command/BaseActionCommand.kt diff --git a/shared/src/commonMain/kotlin/io/imrekaszab/eaplayers/core/command/Command.kt b/modules/core/src/commonMain/kotlin/io/imrekaszab/eaplayers/core/command/Command.kt similarity index 100% rename from shared/src/commonMain/kotlin/io/imrekaszab/eaplayers/core/command/Command.kt rename to modules/core/src/commonMain/kotlin/io/imrekaszab/eaplayers/core/command/Command.kt diff --git a/shared/src/commonMain/kotlin/io/imrekaszab/eaplayers/core/command/ParameterCommand.kt b/modules/core/src/commonMain/kotlin/io/imrekaszab/eaplayers/core/command/ParameterCommand.kt similarity index 100% rename from shared/src/commonMain/kotlin/io/imrekaszab/eaplayers/core/command/ParameterCommand.kt rename to modules/core/src/commonMain/kotlin/io/imrekaszab/eaplayers/core/command/ParameterCommand.kt diff --git a/shared/src/commonMain/kotlin/io/imrekaszab/eaplayers/core/exception/HttpException.kt b/modules/core/src/commonMain/kotlin/io/imrekaszab/eaplayers/core/exception/HttpException.kt similarity index 100% rename from shared/src/commonMain/kotlin/io/imrekaszab/eaplayers/core/exception/HttpException.kt rename to modules/core/src/commonMain/kotlin/io/imrekaszab/eaplayers/core/exception/HttpException.kt diff --git a/shared/src/commonMain/kotlin/io/imrekaszab/eaplayers/core/exception/NetworkException.kt b/modules/core/src/commonMain/kotlin/io/imrekaszab/eaplayers/core/exception/NetworkException.kt similarity index 100% rename from shared/src/commonMain/kotlin/io/imrekaszab/eaplayers/core/exception/NetworkException.kt rename to modules/core/src/commonMain/kotlin/io/imrekaszab/eaplayers/core/exception/NetworkException.kt diff --git a/shared/src/commonMain/kotlin/io/imrekaszab/eaplayers/core/util/CommandUtil.kt b/modules/core/src/commonMain/kotlin/io/imrekaszab/eaplayers/core/util/CommandUtil.kt similarity index 100% rename from shared/src/commonMain/kotlin/io/imrekaszab/eaplayers/core/util/CommandUtil.kt rename to modules/core/src/commonMain/kotlin/io/imrekaszab/eaplayers/core/util/CommandUtil.kt diff --git a/shared/src/commonMain/kotlin/io/imrekaszab/eaplayers/core/util/CoroutineUtil.kt b/modules/core/src/commonMain/kotlin/io/imrekaszab/eaplayers/core/util/CoroutineUtil.kt similarity index 100% rename from shared/src/commonMain/kotlin/io/imrekaszab/eaplayers/core/util/CoroutineUtil.kt rename to modules/core/src/commonMain/kotlin/io/imrekaszab/eaplayers/core/util/CoroutineUtil.kt diff --git a/shared/src/commonMain/kotlin/io/imrekaszab/eaplayers/core/util/FlowUtil.kt b/modules/core/src/commonMain/kotlin/io/imrekaszab/eaplayers/core/util/FlowUtil.kt similarity index 100% rename from shared/src/commonMain/kotlin/io/imrekaszab/eaplayers/core/util/FlowUtil.kt rename to modules/core/src/commonMain/kotlin/io/imrekaszab/eaplayers/core/util/FlowUtil.kt diff --git a/shared/src/commonMain/kotlin/io/imrekaszab/eaplayers/core/util/Lifecycle.kt b/modules/core/src/commonMain/kotlin/io/imrekaszab/eaplayers/core/util/Lifecycle.kt similarity index 100% rename from shared/src/commonMain/kotlin/io/imrekaszab/eaplayers/core/util/Lifecycle.kt rename to modules/core/src/commonMain/kotlin/io/imrekaszab/eaplayers/core/util/Lifecycle.kt diff --git a/shared/src/commonMain/kotlin/io/imrekaszab/eaplayers/core/util/SnapshotState.kt b/modules/core/src/commonMain/kotlin/io/imrekaszab/eaplayers/core/util/SnapshotState.kt similarity index 100% rename from shared/src/commonMain/kotlin/io/imrekaszab/eaplayers/core/util/SnapshotState.kt rename to modules/core/src/commonMain/kotlin/io/imrekaszab/eaplayers/core/util/SnapshotState.kt diff --git a/modules/domain/build.gradle.kts b/modules/domain/build.gradle.kts new file mode 100644 index 0000000..e81fbbf --- /dev/null +++ b/modules/domain/build.gradle.kts @@ -0,0 +1,46 @@ +import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi +import org.jetbrains.kotlin.gradle.dsl.JvmTarget + +plugins { + alias(libs.plugins.kotlinMultiplatform) + alias(libs.plugins.androidLibrary) +} + +kotlin { + androidTarget { + @OptIn(ExperimentalKotlinGradlePluginApi::class) + compilerOptions { + jvmTarget.set(JvmTarget.JVM_1_8) + } + } + + iosX64() + iosArm64() + iosSimulatorArm64() + + sourceSets { + commonMain.dependencies { + implementation(libs.kotlinx.coroutines.core) + } + commonTest.dependencies { + implementation(libs.kotlin.test) + } + } +} + +android { + namespace = "io.imrekaszab.eaplayers.domain" + + compileSdk = libs.versions.targetSdk.get().toInt() + defaultConfig { + minSdk = libs.versions.minSdk.get().toInt() + } + compileOptions { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + } + dependencies { + // Detekt + detektPlugins(libs.detekt.formatting) + } +} diff --git a/shared/src/commonMain/kotlin/io/imrekaszab/eaplayers/domain/action/EAPlayerAction.kt b/modules/domain/src/commonMain/kotlin/io/imrekaszab/eaplayers/domain/action/EAPlayerAction.kt similarity index 100% rename from shared/src/commonMain/kotlin/io/imrekaszab/eaplayers/domain/action/EAPlayerAction.kt rename to modules/domain/src/commonMain/kotlin/io/imrekaszab/eaplayers/domain/action/EAPlayerAction.kt diff --git a/shared/src/commonMain/kotlin/io/imrekaszab/eaplayers/domain/model/Player.kt b/modules/domain/src/commonMain/kotlin/io/imrekaszab/eaplayers/domain/model/Player.kt similarity index 100% rename from shared/src/commonMain/kotlin/io/imrekaszab/eaplayers/domain/model/Player.kt rename to modules/domain/src/commonMain/kotlin/io/imrekaszab/eaplayers/domain/model/Player.kt diff --git a/shared/src/commonMain/kotlin/io/imrekaszab/eaplayers/domain/store/EAPlayerStore.kt b/modules/domain/src/commonMain/kotlin/io/imrekaszab/eaplayers/domain/store/EAPlayerStore.kt similarity index 100% rename from shared/src/commonMain/kotlin/io/imrekaszab/eaplayers/domain/store/EAPlayerStore.kt rename to modules/domain/src/commonMain/kotlin/io/imrekaszab/eaplayers/domain/store/EAPlayerStore.kt diff --git a/settings.gradle.kts b/settings.gradle.kts index 6a8b388..09b3a21 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -25,4 +25,6 @@ dependencyResolutionManagement { rootProject.name = "EAPlayers" include(":composeApp") -include(":shared") \ No newline at end of file +include(":shared") +include(":modules:core") +include(":modules:domain") \ No newline at end of file diff --git a/shared/build.gradle.kts b/shared/build.gradle.kts index 6e9776f..9296539 100644 --- a/shared/build.gradle.kts +++ b/shared/build.gradle.kts @@ -42,6 +42,8 @@ kotlin { implementation(libs.ktor.client.ios) } commonMain.dependencies { + implementation(project(":modules:core")) + implementation(project(":modules:domain")) // Logging implementation(libs.log.kermit) implementation(libs.log.slf4j) diff --git a/shared/src/commonMain/kotlin/io/imrekaszab/eaplayers/core/util/CharSequence.kt b/shared/src/commonMain/kotlin/io/imrekaszab/eaplayers/core/util/CharSequence.kt deleted file mode 100644 index b600f1d..0000000 --- a/shared/src/commonMain/kotlin/io/imrekaszab/eaplayers/core/util/CharSequence.kt +++ /dev/null @@ -1,7 +0,0 @@ -package io.imrekaszab.eaplayers.core.util - -fun CharSequence.keepMatching(regex: Regex): CharSequence { - val matchResult = regex.find(this) - val values = matchResult?.groupValues - return values?.joinToString().orEmpty() -} diff --git a/shared/src/commonMain/kotlin/io/imrekaszab/eaplayers/core/util/Interpolation.kt b/shared/src/commonMain/kotlin/io/imrekaszab/eaplayers/core/util/Interpolation.kt deleted file mode 100644 index fa7d30c..0000000 --- a/shared/src/commonMain/kotlin/io/imrekaszab/eaplayers/core/util/Interpolation.kt +++ /dev/null @@ -1,12 +0,0 @@ -package io.imrekaszab.eaplayers.core.util - -import androidx.annotation.FloatRange - -/** - * Linearly interpolate between two values - */ -fun lerp( - startValue: Float, - endValue: Float, - @FloatRange(from = 0.0, to = 1.0) fraction: Float -) = startValue + fraction * (endValue - startValue) diff --git a/shared/src/commonMain/kotlin/io/imrekaszab/eaplayers/core/util/NumberUtil.kt b/shared/src/commonMain/kotlin/io/imrekaszab/eaplayers/core/util/NumberUtil.kt deleted file mode 100644 index 67b006e..0000000 --- a/shared/src/commonMain/kotlin/io/imrekaszab/eaplayers/core/util/NumberUtil.kt +++ /dev/null @@ -1,3 +0,0 @@ -package io.imrekaszab.eaplayers.core.util - -fun Int.isEven() = this % 2 == 0 diff --git a/shared/src/commonMain/kotlin/io/imrekaszab/eaplayers/core/util/ViewModelStoreExt.kt b/shared/src/commonMain/kotlin/io/imrekaszab/eaplayers/core/util/ViewModelStoreExt.kt deleted file mode 100644 index d4b5512..0000000 --- a/shared/src/commonMain/kotlin/io/imrekaszab/eaplayers/core/util/ViewModelStoreExt.kt +++ /dev/null @@ -1,6 +0,0 @@ -@file:Suppress("PackageDirectoryMismatch", "InvalidPackageDeclaration") - -package androidx.lifecycle - -@Suppress("RestrictedApi") -fun ViewModelStore.getAll() = keys().map { get(it) }.toSet()