Skip to content

Commit

Permalink
Merge branch 'main' into renovate/major-github-actions-updates
Browse files Browse the repository at this point in the history
  • Loading branch information
kaszabimre authored Oct 9, 2024
2 parents dce86e5 + be7d22d commit c139bf5
Show file tree
Hide file tree
Showing 92 changed files with 873 additions and 476 deletions.
26 changes: 26 additions & 0 deletions .github/actions/kmp_cache/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Kotlin Multiplatform Cache
description: A GitHub Actions workflow for caching a Kotlin Multiplatform project using the Gradle build system.

runs:
using: composite
steps:
- name: Cache Gradle
uses: actions/[email protected]
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties', 'buildSrc/**/Versions.kt', 'buildSrc/**/Dependencies.kt', 'gradle/*.versions.toml') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Cache konan
uses: actions/[email protected]
with:
path: |
~/.konan/caches
~/.konan/dependencies
~/.konan/kotlin-native-prebuilt-*
key: ${{ runner.os }}-konan-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties', 'buildSrc/**/Versions.kt', 'buildSrc/**/Dependencies.kt', 'gradle/*.versions.toml') }}
restore-keys: |
${{ runner.os }}-konan-
9 changes: 9 additions & 0 deletions .github/workflows/PR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ jobs:
distribution: corretto
java-version: 18

- name: Cache Kotlin Multiplatform
uses: ./.github/actions/kmp_cache

- name: detekt
run: ./gradlew detekt --stacktrace

Expand All @@ -46,6 +49,9 @@ jobs:
distribution: corretto
java-version: 18

- name: Cache Kotlin Multiplatform
uses: ./.github/actions/kmp_cache

- name: Build
run: ./gradlew build --stacktrace

Expand All @@ -65,6 +71,9 @@ jobs:
- name: Grant execute permission for gradlew
run: chmod +x ./gradlew

- name: Cache Kotlin Multiplatform
uses: ./.github/actions/kmp_cache

- name: Select Xcode version
run: |
XCODE_VERSION="15.0"
Expand Down
8 changes: 6 additions & 2 deletions composeApp/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ kotlin {
implementation(libs.compose.navigation)
implementation(libs.compose.multiplatform.ui)

implementation(libs.ktor.client.core)
implementation(libs.koin.core)
implementation(libs.koin.compose.multiplatform)
implementation(libs.stately.common)
Expand All @@ -55,9 +54,14 @@ kotlin {
implementation(libs.coil.network.ktor)

// Modules
implementation(projects.shared)
implementation(projects.features.details.view)
implementation(projects.features.details.viewmodel)
implementation(projects.features.list.view)
implementation(projects.features.list.viewmodel)
implementation(projects.modules.core)
implementation(projects.modules.di)
implementation(projects.modules.domain)
implementation(projects.modules.navigation)
implementation(projects.modules.theme)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.runtime.Composable
import androidx.compose.ui.tooling.preview.Preview
import navigation.Navigation
import io.imrekaszab.eaplayers.navigation.Navigation

class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
Expand Down
Binary file not shown.

This file was deleted.

13 changes: 2 additions & 11 deletions composeApp/src/iosMain/kotlin/KoinIOS.kt
Original file line number Diff line number Diff line change
@@ -1,26 +1,17 @@
@file:Suppress("MissingPackageDeclaration")

import co.touchlab.kermit.Logger
import io.imrekaszab.eaplayers.di.initKoin
import io.ktor.client.engine.darwin.Darwin
import kotlinx.cinterop.BetaInteropApi
import kotlinx.cinterop.ObjCClass
import kotlinx.cinterop.ObjCProtocol
import kotlinx.cinterop.getOriginalKotlinClass
import org.koin.core.Koin
import org.koin.core.KoinApplication
import org.koin.core.parameter.parametersOf
import org.koin.dsl.module

fun initKoinIos(
doOnStartup: () -> Unit,
baseUrl: String
): KoinApplication = initKoin(
module {
single { doOnStartup }
single { Darwin.create() }
},
baseUrl
)
): KoinApplication = io.imrekaszab.eaplayers.di.initKoinIos(baseUrl = baseUrl)

// Access from Swift to create a logger
@Suppress("unused")
Expand Down
2 changes: 1 addition & 1 deletion composeApp/src/iosMain/kotlin/MainViewController.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@file:Suppress("MissingPackageDeclaration", "FunctionNaming")
import androidx.compose.ui.window.ComposeUIViewController
import navigation.Navigation
import io.imrekaszab.eaplayers.navigation.Navigation

fun MainViewController() = ComposeUIViewController { Navigation() }
64 changes: 64 additions & 0 deletions features/details/view/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
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.jetbrainsCompose)
alias(libs.plugins.composeMultiplatform)
}

kotlin {
androidTarget {
@OptIn(ExperimentalKotlinGradlePluginApi::class)
compilerOptions {
jvmTarget.set(JvmTarget.JVM_1_8)
}
}

iosX64()
iosArm64()
iosSimulatorArm64()

sourceSets {
commonMain.dependencies {
implementation(compose.runtime)
implementation(compose.foundation)
implementation(compose.material3)
implementation(compose.ui)
implementation(compose.components.resources)
implementation(compose.components.uiToolingPreview)
implementation(libs.compose.navigation)
implementation(libs.compose.multiplatform.ui)
implementation(libs.coil.compose.core)
implementation(libs.coil.compose)
implementation(libs.koin.compose.multiplatform)

implementation(projects.features.details.viewmodel)
implementation(projects.modules.core)
implementation(projects.modules.domain)
implementation(projects.modules.theme)
}
}
}

android {
namespace = "io.imrekaszab.eaplayers.playerdetails.view"

compileSdk = libs.versions.targetSdk.get().toInt()
defaultConfig {
minSdk = libs.versions.minSdk.get().toInt()
}
sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")
sourceSets["main"].res.srcDirs("src/androidMain/res")
sourceSets["main"].resources.srcDirs("src/commonMain/resources")

buildFeatures {
compose = true
buildConfig = true
}
dependencies {
// Detekt
detektPlugins(libs.detekt.formatting)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,5 @@
<string name="player_rank">Rank: %1$s</string>
<string name="nationality">Nationality</string>
<string name="team">Team</string>
<string name="rank">Rank</string>
<string name="rating_with_param">Rating: %1$s</string>
<string name="position_with_param">Position: %1$s</string>
<string name="player_image_desc">%1$s %2$s's image</string>
</resources>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package widget
package io.imrekaszab.eaplayers.view

import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package screen
package io.imrekaszab.eaplayers.view

import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.ArrowBack
import androidx.compose.material3.CircularProgressIndicator
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.Scaffold
Expand All @@ -15,16 +15,16 @@ import androidx.compose.runtime.getValue
import androidx.compose.ui.Modifier
import androidx.navigation.NavHostController
import io.imrekaszab.eaplayers.core.util.invoke
import io.imrekaszab.eaplayers.core.viewmodel.koinViewModel
import io.imrekaszab.eaplayers.theme.AppTheme
import io.imrekaszab.eaplayers.viewmodel.PlayerDetailViewModel
import navigation.EAPlayersScreens
import org.koin.compose.koinInject
import widget.PlayerDetailView
import io.imrekaszab.eaplayers.theme.navigation.EAPlayersScreens
import io.imrekaszab.eaplayers.theme.widgets.LoadingIndicator
import io.imrekaszab.eaplayers.ui.viewmodel.PlayerDetailViewModel

@Composable
fun PlayerDetailScreen(
navHostController: NavHostController,
viewModel: PlayerDetailViewModel = koinInject<PlayerDetailViewModel>()
viewModel: PlayerDetailViewModel = koinViewModel<PlayerDetailViewModel>()
) {
val playerId =
navHostController.currentBackStackEntry?.arguments?.getString("playerId")?.toInt()
Expand Down Expand Up @@ -53,7 +53,7 @@ fun PlayerDetailScreen(
contentColor = AppTheme.colorScheme.onPrimary
) { innerPadding ->
when {
uiState.loading -> CircularProgressIndicator()
uiState.loading -> LoadingIndicator(modifier = Modifier.fillMaxSize())

uiState.error != null ->
Text(text = "Error: ${uiState.error}")
Expand All @@ -63,7 +63,6 @@ fun PlayerDetailScreen(
modifier = Modifier.padding(innerPadding),
player = uiState.player!!,
onTeamMateSelected = {
viewModel.selectPlayer(it)
navHostController.navigate(
EAPlayersScreens.DetailsScreen.createRoute(it.id),
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package widget
package io.imrekaszab.eaplayers.view

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Column
Expand All @@ -15,11 +15,11 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.text.style.TextAlign
import eaplayers.composeapp.generated.resources.Res
import eaplayers.composeapp.generated.resources.abilities
import eaplayers.composeapp.generated.resources.nationality
import eaplayers.composeapp.generated.resources.player_rank
import eaplayers.composeapp.generated.resources.team
import eaplayers.features.details.view.generated.resources.Res
import eaplayers.features.details.view.generated.resources.abilities
import eaplayers.features.details.view.generated.resources.nationality
import eaplayers.features.details.view.generated.resources.player_rank
import eaplayers.features.details.view.generated.resources.team
import io.imrekaszab.eaplayers.domain.model.Player
import io.imrekaszab.eaplayers.theme.AppTheme
import org.jetbrains.compose.resources.stringResource
Expand Down Expand Up @@ -93,16 +93,16 @@ fun PlayerInfoSection(player: Player) {

@Composable
fun AbilitiesSection(player: Player) {
Column(
modifier = Modifier
.clip(AppTheme.shapes.default.roundedDefault)
.background(
color = AppTheme.colors.blue.default,
shape = AppTheme.shapes.default.roundedDefault
)
.padding(AppTheme.dimens.margin.default)
) {
if (player.playerAbilities.isNotEmpty()) {
if (player.playerAbilities.isNotEmpty()) {
Column(
modifier = Modifier
.clip(AppTheme.shapes.default.roundedDefault)
.background(
color = AppTheme.colors.blue.default,
shape = AppTheme.shapes.default.roundedDefault
)
.padding(AppTheme.dimens.margin.default)
) {
Text(
text = stringResource(Res.string.abilities),
style = AppTheme.typography.heading.medium,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package widget
package io.imrekaszab.eaplayers.view

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
Expand All @@ -10,8 +10,8 @@ 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 eaplayers.features.details.view.generated.resources.Res
import eaplayers.features.details.view.generated.resources.player_rank
import io.imrekaszab.eaplayers.domain.model.Player
import io.imrekaszab.eaplayers.theme.AppTheme
import org.jetbrains.compose.resources.stringResource
Expand All @@ -29,7 +29,7 @@ fun PlayerImage(player: Player) {
AsyncImage(
model = player.shieldUrl,
contentDescription = stringResource(
Res.string.player_image_desc,
Res.string.player_rank,
player.firstName,
player.lastName
),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package widget
package io.imrekaszab.eaplayers.view

import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package widget
package io.imrekaszab.eaplayers.view

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
Expand All @@ -12,10 +12,10 @@ 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 eaplayers.features.details.view.generated.resources.Res
import eaplayers.features.details.view.generated.resources.height
import eaplayers.features.details.view.generated.resources.position
import eaplayers.features.details.view.generated.resources.rating
import io.imrekaszab.eaplayers.domain.model.Player
import io.imrekaszab.eaplayers.theme.AppTheme
import org.jetbrains.compose.resources.stringResource
Expand Down
Loading

0 comments on commit c139bf5

Please sign in to comment.