diff --git a/android/build.gradle.kts b/android/build.gradle.kts index a0acc2c..1771f55 100644 --- a/android/build.gradle.kts +++ b/android/build.gradle.kts @@ -23,7 +23,7 @@ android { composeOptions { kotlinCompilerExtensionVersion = Versions.composeCompiler } - packagingOptions { + packaging { resources { excludes += "/META-INF/{AL2.0,LGPL2.1}" } @@ -34,17 +34,17 @@ android { } } compileOptions { - sourceCompatibility = JavaVersion.VERSION_11 - targetCompatibility = JavaVersion.VERSION_11 + sourceCompatibility = JavaVersion.VERSION_21 + targetCompatibility = JavaVersion.VERSION_21 } kotlinOptions { - jvmTarget = "1.8" + jvmTarget = "21" } } dependencies { implementation(project(":shared")) - implementation("androidx.activity:activity-compose:1.6.1") + implementation("androidx.activity:activity-compose:1.8.0") // Koin with(Deps.Koin) { diff --git a/build.gradle.kts b/build.gradle.kts index 7242ed1..16e758d 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,12 +1,12 @@ plugins { //trick: for the same plugin versions in all sub-modules - kotlin("android") version "1.8.10" apply false - kotlin("multiplatform") version "1.8.10" apply false - kotlin("plugin.serialization") version "1.8.10" apply false - id("app.cash.sqldelight") version "2.0.0-alpha05" apply false - id("com.android.application") version "7.3.0" apply false - id("com.android.library") version "7.3.0" apply false - id("org.jetbrains.compose") version "1.3.1" apply false + kotlin("android") version "1.9.20" apply false + kotlin("multiplatform") version "1.9.20" apply false + kotlin("plugin.serialization") version "1.9.20" apply false + id("app.cash.sqldelight") version "2.0.0" apply false + id("com.android.application") version "8.1.3" apply false + id("com.android.library") version "8.1.3" apply false + id("org.jetbrains.compose") version "1.5.10" apply false } allprojects { diff --git a/buildSrc/src/main/java/com/mocoding/pokedex/Configuration.kt b/buildSrc/src/main/java/com/mocoding/pokedex/Configuration.kt index f2109f3..7d4a243 100644 --- a/buildSrc/src/main/java/com/mocoding/pokedex/Configuration.kt +++ b/buildSrc/src/main/java/com/mocoding/pokedex/Configuration.kt @@ -1,8 +1,8 @@ package com.mocoding.pokedex object Configuration { - const val compileSdk = 33 - const val targetSdk = 33 + const val compileSdk = 34 + const val targetSdk = 34 const val minSdk = 24 const val majorVersion = 1 const val minorVersion = 0 diff --git a/buildSrc/src/main/java/com/mocoding/pokedex/Versions.kt b/buildSrc/src/main/java/com/mocoding/pokedex/Versions.kt index 0e15469..be78cc9 100644 --- a/buildSrc/src/main/java/com/mocoding/pokedex/Versions.kt +++ b/buildSrc/src/main/java/com/mocoding/pokedex/Versions.kt @@ -1,19 +1,19 @@ package com.mocoding.pokedex object Versions { - const val gradlePlugin = "7.3.0" - const val kotlin = "1.8.20" - const val compose = "1.4.0" - const val composeCompiler = "1.4.2" - const val coroutines = "1.7.0" - const val serialization = "1.4.1" - const val mviKotlin = "3.1.0" - const val decompose = "1.0.0-compose-experimental" - const val essenty = "1.0.0" - const val ktor = "2.2.3" - const val sqlDelight = "2.0.0-alpha05" - const val koin = "3.2.0" - const val imageLoader = "1.2.10" - const val logbackClassic = "1.2.11" - const val kotlinWrappersBom = "1.0.0-pre.510" + const val gradlePlugin = "8.1.3" + const val kotlin = "1.9.20" + const val compose = "1.5.10" + const val composeCompiler = "1.5.4" + const val coroutines = "1.7.3" + const val serialization = "1.6.0" + const val mviKotlin = "3.3.0" + const val decompose = "2.1.4-compose-experimental" + const val essenty = "1.2.0" + const val ktor = "2.3.6" + const val sqlDelight = "2.0.0" + const val koin = "3.5.2-RC1" + const val imageLoader = "1.7.1" + const val logbackClassic = "1.4.11" + const val kotlinWrappersBom = "1.0.0-pre.641" } \ No newline at end of file diff --git a/desktop/build.gradle.kts b/desktop/build.gradle.kts index a0befb9..6c87aec 100644 --- a/desktop/build.gradle.kts +++ b/desktop/build.gradle.kts @@ -6,11 +6,11 @@ plugins { } group = "com.mocoding" -version = "1.0-SNAPSHOT" +version = "1.0.0-SNAPSHOT" kotlin { jvm { - jvmToolchain(11) + jvmToolchain(21) withJava() } sourceSets { diff --git a/gradle.properties b/gradle.properties index 79fbb1d..f12175d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -11,20 +11,19 @@ android.nonTransitiveRClass=true #MPP kotlin.mpp.enableCInteropCommonization=true kotlin.mpp.androidSourceSetLayoutVersion=2 - +kotlin.mpp.applyDefaultHierarchyTemplate=false #IOS xcodeproj=./ios org.jetbrains.compose.experimental.uikit.enabled=true #Versions -kotlin.version=1.8.10 -agp.version=7.3.0 -compose.version=1.3.1 -sqldelight.version=2.0.0-alpha05 +kotlin.version=1.9.20 +agp.version=8.1.3 +compose.version=1.5.4 +sqldelight.version=2.0.0 # Kotlin/Native Experimental Memory Model kotlin.native.binary.memoryModel=experimental kotlin.native.cocoapods.generate.wrapper=true -kotlin.native.cacheKind=none kotlin.native.useEmbeddableCompilerJar=true \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 249e583..d64cd49 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index ae04661..f6c2a4a 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,7 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-rc-1-bin.zip +networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index a69d9cb..1aa94a4 100755 --- a/gradlew +++ b/gradlew @@ -55,7 +55,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -80,13 +80,11 @@ do esac done -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit - -APP_NAME="Gradle" +# This is normally unused +# shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -133,22 +131,29 @@ location of your Java installation." fi else JAVACMD=java - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." + fi fi # Increase the maximum file descriptors if we can. if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac case $MAX_FD in #( '' | soft) :;; #( *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac @@ -193,11 +198,15 @@ if "$cygwin" || "$msys" ; then done fi -# Collect all arguments for the java command; -# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of -# shell script including quotes and variable substitutions, so put them in -# double quotes to make sure that they get re-expanded; and -# * put everything else in single quotes, so that it's not re-expanded. + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ diff --git a/gradlew.bat b/gradlew.bat index f127cfd..93e3f59 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -26,6 +26,7 @@ if "%OS%"=="Windows_NT" setlocal set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% diff --git a/shared/build.gradle.kts b/shared/build.gradle.kts index e962646..5e8d772 100644 --- a/shared/build.gradle.kts +++ b/shared/build.gradle.kts @@ -1,6 +1,5 @@ import com.mocoding.pokedex.Configuration import com.mocoding.pokedex.Deps -import org.jetbrains.kotlin.gradle.plugin.mpp.pm20.util.targets plugins { kotlin("multiplatform") @@ -15,22 +14,32 @@ plugins { @OptIn(org.jetbrains.compose.ExperimentalComposeLibrary::class) kotlin { jvm("desktop") - android() - ios() - iosSimulatorArm64() - - cocoapods { - summary = "Pokedex the Shared Module" - homepage = "Link to the Shared Module homepage" - version = "1.0" - ios.deploymentTarget = "14.1" - podfile = project.file("../ios/Podfile") - framework { - baseName = "shared" - isStatic = true - - export(Deps.ArkIvanov.Decompose.decompose) - export(Deps.ArkIvanov.Essenty.lifecycle) + + androidTarget{ + compilations.all { + kotlinOptions { + jvmTarget = "21" + } + } + } + + listOf( + iosX64(), + iosArm64(), + iosSimulatorArm64(), + ).forEach { _ -> + cocoapods { + summary = "Pokedex the Shared Module" + homepage = "Link to the Shared Module homepage" + version = "1.0.0" + ios.deploymentTarget = "14.1" + podfile = project.file("../ios/Podfile") + framework { + baseName = "shared" + isStatic = true + export(Deps.ArkIvanov.Decompose.decompose) + export(Deps.ArkIvanov.Essenty.lifecycle) + } } } @@ -124,9 +133,15 @@ kotlin { } } - val iosMain by getting { - dependsOn(commonMain) + val iosX64Main by getting + val iosArm64Main by getting + val iosSimulatorArm64Main by getting + val iosMain by creating { + dependsOn(commonMain) + iosX64Main.dependsOn(this) + iosArm64Main.dependsOn(this) + iosSimulatorArm64Main.dependsOn(this) dependencies { // Ktor implementation(Deps.Io.Ktor.ktorClientDarwin) @@ -135,19 +150,22 @@ kotlin { implementation(Deps.CashApp.SQLDelight.nativeDriver) } } - val iosSimulatorArm64Main by getting { - dependsOn(iosMain) - } - val iosTest by getting { + + val iosX64Test by getting + val iosArm64Test by getting + val iosSimulatorArm64Test by getting + + val iosTest by creating { dependsOn(commonTest) + iosX64Test.dependsOn(this) + iosArm64Test.dependsOn(this) + iosSimulatorArm64Test.dependsOn(this) } - val iosSimulatorArm64Test by getting { - dependsOn(iosTest) - } + } tasks.withType { - kotlinOptions.jvmTarget = "11" + kotlinOptions.jvmTarget = "21" } } @@ -156,11 +174,10 @@ android { compileSdk = Configuration.compileSdk defaultConfig { minSdk = Configuration.minSdk - targetSdk = Configuration.targetSdk } compileOptions { - sourceCompatibility = JavaVersion.VERSION_11 - targetCompatibility = JavaVersion.VERSION_11 + sourceCompatibility = JavaVersion.VERSION_21 + targetCompatibility = JavaVersion.VERSION_21 } } diff --git a/shared/shared.podspec b/shared/shared.podspec index 1f27c49..99e72cc 100644 --- a/shared/shared.podspec +++ b/shared/shared.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |spec| spec.name = 'shared' - spec.version = '1.0' + spec.version = '1.0.0' spec.homepage = 'Link to the Shared Module homepage' spec.source = { :http=> ''} spec.authors = '' @@ -11,6 +11,17 @@ Pod::Spec.new do |spec| spec.ios.deployment_target = '14.1' + if !Dir.exist?('build/cocoapods/framework/shared.framework') || Dir.empty?('build/cocoapods/framework/shared.framework') + raise " + + Kotlin framework 'shared' doesn't exist yet, so a proper Xcode project can't be generated. + 'pod install' should be executed after running ':generateDummyFramework' Gradle task: + + ./gradlew :shared:generateDummyFramework + + Alternatively, proper pod installation is performed during Gradle sync in the IDE (if Podfile location is set)" + end + spec.pod_target_xcconfig = { 'KOTLIN_PROJECT_PATH' => ':shared', 'PRODUCT_MODULE_NAME' => 'shared', @@ -35,5 +46,5 @@ Pod::Spec.new do |spec| SCRIPT } ] - + spec.resources = ['build\compose\ios\shared\compose-resources'] end \ No newline at end of file diff --git a/shared/src/commonMain/kotlin/com/mocoding/pokedex/ui/comingsoon/AsyncImage.kt b/shared/src/commonMain/kotlin/com/mocoding/pokedex/ui/comingsoon/AsyncImage.kt deleted file mode 100644 index 3e5013d..0000000 --- a/shared/src/commonMain/kotlin/com/mocoding/pokedex/ui/comingsoon/AsyncImage.kt +++ /dev/null @@ -1,50 +0,0 @@ -package com.mocoding.pokedex.ui.comingsoon - -import androidx.compose.foundation.Image -import androidx.compose.foundation.layout.* -import androidx.compose.material.icons.Icons -import androidx.compose.material.icons.outlined.Image -import androidx.compose.material3.Icon -import androidx.compose.runtime.Composable -import androidx.compose.ui.Alignment -import androidx.compose.ui.Modifier -import androidx.compose.ui.draw.alpha -import androidx.compose.ui.graphics.ColorFilter -import androidx.compose.ui.layout.ContentScale -import com.seiko.imageloader.ImageRequestState -import com.seiko.imageloader.rememberAsyncImagePainter - -@Composable -internal fun AsyncImage( - url: String, - contentDescription: String?, - contentScale: ContentScale = ContentScale.Fit, - colorFilter: ColorFilter? = null, - modifier: Modifier = Modifier -) { - val painter = rememberAsyncImagePainter(url) - - Box( - contentAlignment = Alignment.Center, - modifier = modifier - ) { - Image( - painter = painter, - contentDescription = contentDescription, - contentScale = contentScale, - colorFilter = colorFilter, - modifier = Modifier.fillMaxSize() - ) - - if (painter.requestState is ImageRequestState.Loading - || painter.requestState is ImageRequestState.Failure) { - Icon( - Icons.Outlined.Image, - contentDescription = null, - modifier = Modifier - .fillMaxSize(.4f) - .alpha(.6f) - ) - } - } -} \ No newline at end of file diff --git a/shared/src/commonMain/kotlin/com/mocoding/pokedex/ui/details/DetailsScreen.kt b/shared/src/commonMain/kotlin/com/mocoding/pokedex/ui/details/DetailsScreen.kt index 680d101..38bf76f 100644 --- a/shared/src/commonMain/kotlin/com/mocoding/pokedex/ui/details/DetailsScreen.kt +++ b/shared/src/commonMain/kotlin/com/mocoding/pokedex/ui/details/DetailsScreen.kt @@ -1,31 +1,9 @@ package com.mocoding.pokedex.ui.details -import androidx.compose.foundation.layout.* -import androidx.compose.foundation.lazy.LazyColumn -import androidx.compose.material.icons.Icons -import androidx.compose.material.icons.rounded.ArrowBackIosNew -import androidx.compose.material.icons.rounded.Favorite -import androidx.compose.material.icons.rounded.FavoriteBorder -import androidx.compose.material3.* import androidx.compose.runtime.Composable import androidx.compose.runtime.collectAsState import androidx.compose.runtime.getValue -import androidx.compose.ui.Alignment -import androidx.compose.ui.Modifier -import androidx.compose.ui.draw.* -import androidx.compose.ui.graphics.Color -import androidx.compose.ui.graphics.ColorFilter -import androidx.compose.ui.graphics.ColorMatrix -import androidx.compose.ui.layout.ContentScale -import androidx.compose.ui.text.font.FontWeight -import androidx.compose.ui.text.style.TextAlign -import androidx.compose.ui.unit.dp -import com.mocoding.pokedex.ui.comingsoon.AsyncImage -import com.mocoding.pokedex.ui.details.components.AbilityRow import com.mocoding.pokedex.ui.details.components.DetailsContent -import com.mocoding.pokedex.ui.details.components.PokemonInfos -import com.mocoding.pokedex.ui.details.components.PokemonStats -import com.mocoding.pokedex.ui.helper.LocalSafeArea @Composable internal fun DetailsScreen(component: DetailsComponent) { diff --git a/shared/src/commonMain/kotlin/com/mocoding/pokedex/ui/details/components/DetailsContent.kt b/shared/src/commonMain/kotlin/com/mocoding/pokedex/ui/details/components/DetailsContent.kt index 4cfccf9..3177631 100644 --- a/shared/src/commonMain/kotlin/com/mocoding/pokedex/ui/details/components/DetailsContent.kt +++ b/shared/src/commonMain/kotlin/com/mocoding/pokedex/ui/details/components/DetailsContent.kt @@ -21,7 +21,7 @@ import androidx.compose.ui.layout.ContentScale import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.dp -import com.mocoding.pokedex.ui.comingsoon.AsyncImage +import com.mocoding.pokedex.ui.main.components.AsyncImage import com.mocoding.pokedex.ui.details.DetailsComponent import com.mocoding.pokedex.ui.details.store.DetailsStore import com.mocoding.pokedex.ui.helper.LocalSafeArea diff --git a/shared/src/commonMain/kotlin/com/mocoding/pokedex/ui/main/components/AsyncImage.kt b/shared/src/commonMain/kotlin/com/mocoding/pokedex/ui/main/components/AsyncImage.kt new file mode 100644 index 0000000..76beff8 --- /dev/null +++ b/shared/src/commonMain/kotlin/com/mocoding/pokedex/ui/main/components/AsyncImage.kt @@ -0,0 +1,63 @@ +package com.mocoding.pokedex.ui.main.components + +import androidx.compose.foundation.Image +import androidx.compose.foundation.layout.* +import androidx.compose.material3.CircularProgressIndicator +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.runtime.derivedStateOf +import androidx.compose.runtime.getValue +import androidx.compose.runtime.remember +import androidx.compose.runtime.rememberUpdatedState +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.ColorFilter +import androidx.compose.ui.layout.ContentScale +import com.seiko.imageloader.model.ImageAction +import com.seiko.imageloader.model.ImageRequest +import com.seiko.imageloader.rememberImageSuccessPainter +import com.seiko.imageloader.ui.AutoSizeBox + + +@Composable +internal fun AsyncImage( + url: String, + contentDescription: String?, + contentScale: ContentScale = ContentScale.Fit, + colorFilter: ColorFilter? = null, + modifier: Modifier = Modifier +) { + Box(modifier, Alignment.Center) { + val dataState by rememberUpdatedState(url) + val request by remember { + derivedStateOf { + ImageRequest { + data(dataState) + } + } + } + + AutoSizeBox( + request, + modifier.matchParentSize(), + ) { action -> + when (action) { + is ImageAction.Loading -> { + CircularProgressIndicator() + } + is ImageAction.Success -> { + Image( + rememberImageSuccessPainter(action), + contentDescription = contentDescription, + contentScale = contentScale, + colorFilter = colorFilter, + modifier = Modifier.matchParentSize(), + ) + } + is ImageAction.Failure -> { + Text(action.error.message ?: "Error") + } + } + } + } +} \ No newline at end of file diff --git a/shared/src/commonMain/kotlin/com/mocoding/pokedex/ui/main/components/CategoryButton.kt b/shared/src/commonMain/kotlin/com/mocoding/pokedex/ui/main/components/CategoryButton.kt index 5d04dc5..1ff402b 100644 --- a/shared/src/commonMain/kotlin/com/mocoding/pokedex/ui/main/components/CategoryButton.kt +++ b/shared/src/commonMain/kotlin/com/mocoding/pokedex/ui/main/components/CategoryButton.kt @@ -1,12 +1,8 @@ package com.mocoding.pokedex.ui.main.components -import androidx.compose.foundation.Image import androidx.compose.foundation.background import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.* -import androidx.compose.foundation.shape.CircleShape -import androidx.compose.material3.Button -import androidx.compose.material3.ButtonDefaults import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Text import androidx.compose.runtime.Composable @@ -14,14 +10,12 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip import androidx.compose.ui.draw.scale -import androidx.compose.ui.draw.shadow import androidx.compose.ui.graphics.Brush import androidx.compose.ui.graphics.Color import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.unit.dp import com.mocoding.pokedex.ui.main.state.CategoryState import com.mocoding.pokedex.ui.theme.Black -import com.seiko.imageloader.rememberAsyncImagePainter @Composable internal fun CategoryButton( @@ -51,8 +45,6 @@ internal fun CategoryButton( Spacer(Modifier.weight(1f)) - val painter = rememberAsyncImagePainter(categoryState.iconUrl) - Box( contentAlignment = Alignment.Center ) { @@ -71,11 +63,11 @@ internal fun CategoryButton( ) ) - Image( - painter = painter, + + AsyncImage( + url = categoryState.iconUrl, contentDescription = categoryState.title, modifier = Modifier - .offset(y = (-8).dp) .size(40.dp) ) } diff --git a/shared/src/commonMain/kotlin/com/mocoding/pokedex/ui/main/components/MainContent.kt b/shared/src/commonMain/kotlin/com/mocoding/pokedex/ui/main/components/MainContent.kt index 584556e..4d34a94 100644 --- a/shared/src/commonMain/kotlin/com/mocoding/pokedex/ui/main/components/MainContent.kt +++ b/shared/src/commonMain/kotlin/com/mocoding/pokedex/ui/main/components/MainContent.kt @@ -2,17 +2,11 @@ package com.mocoding.pokedex.ui.main.components import androidx.compose.foundation.* import androidx.compose.foundation.layout.* -import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.material.icons.Icons -import androidx.compose.material.icons.rounded.Menu import androidx.compose.material.icons.rounded.Search import androidx.compose.material3.* import androidx.compose.runtime.* -import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier -import androidx.compose.ui.draw.drawBehind -import androidx.compose.ui.draw.drawWithCache -import androidx.compose.ui.geometry.center import androidx.compose.ui.graphics.Color import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.unit.dp @@ -20,11 +14,7 @@ import com.mocoding.pokedex.core.model.Video import com.mocoding.pokedex.ui.main.MainComponent import com.mocoding.pokedex.ui.main.state.CategoryState import com.mocoding.pokedex.ui.main.store.MainStore -import com.mocoding.pokedex.ui.theme.* -import com.seiko.imageloader.rememberAsyncImagePainter -import kotlinx.coroutines.delay -@OptIn(ExperimentalMaterial3Api::class) @Composable internal fun MainContent( state: MainStore.State, @@ -46,6 +36,7 @@ internal fun MainContent( modifier = Modifier.padding(horizontal = 20.dp, vertical = 20.dp) ) + val containerColor = MaterialTheme.colorScheme.surface.copy(alpha = .2f) TextField( value = state.search, onValueChange = { onEvent(MainStore.Intent.InputPokemonSearch(it)) }, @@ -59,13 +50,16 @@ internal fun MainContent( Icon(Icons.Rounded.Search, contentDescription = "Search Pokemon") } }, - colors = TextFieldDefaults.textFieldColors( - containerColor = MaterialTheme.colorScheme.surface.copy(alpha = .2f), - placeholderColor = MaterialTheme.colorScheme.surface, + colors = TextFieldDefaults.colors( + focusedContainerColor = containerColor, + unfocusedContainerColor = containerColor, + disabledContainerColor = containerColor, + focusedIndicatorColor = Color.Transparent, + unfocusedIndicatorColor = Color.Transparent, focusedLeadingIconColor = MaterialTheme.colorScheme.surface, unfocusedLeadingIconColor = MaterialTheme.colorScheme.surface, - unfocusedIndicatorColor = Color.Transparent, - focusedIndicatorColor = Color.Transparent, + focusedPlaceholderColor = MaterialTheme.colorScheme.surface, + unfocusedPlaceholderColor = MaterialTheme.colorScheme.surface, ), shape = MaterialTheme.shapes.extraLarge, modifier = Modifier diff --git a/shared/src/commonMain/kotlin/com/mocoding/pokedex/ui/main/components/VideoItem.kt b/shared/src/commonMain/kotlin/com/mocoding/pokedex/ui/main/components/VideoItem.kt index 01bc0b7..20ae20a 100644 --- a/shared/src/commonMain/kotlin/com/mocoding/pokedex/ui/main/components/VideoItem.kt +++ b/shared/src/commonMain/kotlin/com/mocoding/pokedex/ui/main/components/VideoItem.kt @@ -1,6 +1,5 @@ package com.mocoding.pokedex.ui.main.components -import androidx.compose.foundation.Image import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.* import androidx.compose.material.icons.Icons @@ -20,7 +19,6 @@ import androidx.compose.ui.layout.ContentScale import androidx.compose.ui.unit.dp import com.mocoding.pokedex.core.model.Video import com.mocoding.pokedex.ui.theme.Black -import com.seiko.imageloader.rememberAsyncImagePainter @Composable internal fun VideoItem( @@ -29,8 +27,6 @@ internal fun VideoItem( modifier: Modifier = Modifier ) { - val painter = rememberAsyncImagePainter(video.imageUrl) - Column( verticalArrangement = Arrangement.spacedBy(8.dp), modifier = modifier @@ -42,8 +38,8 @@ internal fun VideoItem( Box( contentAlignment = Alignment.Center ) { - Image( - painter = painter, + AsyncImage( + url = video.imageUrl, contentDescription = video.title, contentScale = ContentScale.Crop, colorFilter = ColorFilter.tint(Black.copy(.5f), BlendMode.Darken), @@ -53,7 +49,6 @@ internal fun VideoItem( .clip(MaterialTheme.shapes.medium) ) - Icon( Icons.Rounded.PlayArrow, contentDescription = null, diff --git a/shared/src/commonMain/kotlin/com/mocoding/pokedex/ui/pokedex/components/PokemonItem.kt b/shared/src/commonMain/kotlin/com/mocoding/pokedex/ui/pokedex/components/PokemonItem.kt index fc049d9..ea168db 100644 --- a/shared/src/commonMain/kotlin/com/mocoding/pokedex/ui/pokedex/components/PokemonItem.kt +++ b/shared/src/commonMain/kotlin/com/mocoding/pokedex/ui/pokedex/components/PokemonItem.kt @@ -1,10 +1,7 @@ package com.mocoding.pokedex.ui.pokedex.components -import androidx.compose.foundation.Image import androidx.compose.foundation.background import androidx.compose.foundation.layout.* -import androidx.compose.material.icons.Icons -import androidx.compose.material.icons.outlined.Image import androidx.compose.material3.* import androidx.compose.runtime.Composable import androidx.compose.runtime.remember @@ -17,10 +14,8 @@ import androidx.compose.ui.layout.ContentScale import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.unit.dp import com.mocoding.pokedex.core.model.Pokemon -import com.mocoding.pokedex.ui.comingsoon.AsyncImage +import com.mocoding.pokedex.ui.main.components.AsyncImage import com.mocoding.pokedex.ui.theme.* -import com.seiko.imageloader.ImageRequestState -import com.seiko.imageloader.rememberAsyncImagePainter @OptIn(ExperimentalMaterial3Api::class) @Composable