Skip to content

Conversation

@gabrielbmoro
Copy link

Descrição

A ideia desse PR é mover código android específico para o source set do Android + habilitar o iosTarget (mas não implementar ele).

Testes Realizados

  • Rodar o app
Screen_recording_20250203_081527.webm

Checklist

  • Os testes foram executados e passaram com sucesso.
  • As alterações de código seguem as diretrizes de estilo do projeto.
  • Foram adicionados testes, se aplicável.
  • Se inscreveu no canal?😛

Issues Relacionadas

import Config
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension

fun KotlinMultiplatformExtension.iosTarget() {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Define iosTarget, but not implementing it yet

kotlin {
sourceSets {
androidMain.dependencies {
implementation(libs.koin.android)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Koin android is android specific

sourceSets {
androidMain.dependencies {
implementation(libs.koin.android)
implementation(libs.lottie)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lottie is also android specific

}
}

listOf(
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's move this definition to the base conventional plugin

add("kspIosArm64", libs.room.compiler)
}

configurations.implementation{
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't need it anymore

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This we need (bringing back):

   add("kspIosSimulatorArm64", libs.room.compiler)
    add("kspIosX64", libs.room.compiler)
    add("kspIosArm64", libs.room.compiler)

what we don't need is:

configurations.implementation...

@@ -1,35 +1,44 @@
import com.codingfeline.buildkonfig.compiler.FieldSpec
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding BuildKonfig to deal with the build config variables in multiplatform world

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

keep buildtype release, cause is good example how to use

}

androidMain.dependencies {
implementation(libs.okhttp)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Android specific network dependencies

networking = ["moshi", "okhttp", "interceptor", "ktor_client_core", "ktor_client_okhttp", "ktor_client_content_serialization_json", "ktor_client_content_negotiation", "ktor_client_logger", "ktor_client_auth"]
koin = ["koin_android", "koin_compose"]

test = ["junit", "mockk", "mockk_android", "viewmodel_test", "koin_test", "coroutines_test"]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test was the only bundle I kept (the idea is to create an issue to make the unit tests work in the commonTest. Currently they are broken


import io.ktor.client.engine.HttpClientEngine

expect fun httpClientEngine(): HttpClientEngine No newline at end of file
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Future -> implement httpClientEngine for ios

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the project I work on, I created a pattern that is easier to see

any file that has expect and actual, put it at the end Platform

which is a pattern of understanding that this type of file has this implementation

override fun onReady(youTubePlayer: YouTubePlayer) {
youTubePlayer.loadVideo(videoId, 0f)
}
expect fun PlayerComponent(videoId: String, modifier: Modifier = Modifier)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Future -> implement playerComponent for iOS

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

@rviannaoliveira rviannaoliveira changed the title Feature/issue 17 common main to android main [issue-17 common main to android main Feb 3, 2025
@rviannaoliveira rviannaoliveira changed the title [issue-17 common main to android main [issue-17] - common main to android main Feb 3, 2025
const val host_release = "\"https://api.themoviedb.org/3/\""
const val api_profile_debug = "\"https://demo3364084.mockable.io/\""
const val api_profile_release = "\"https://demo3364084.mockable.io/\""
const val host = "https://api.themoviedb.org/3/"
Copy link

@rviannaoliveira rviannaoliveira Feb 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had left it with buildtype more to show how it would work on this and not necessarily because it needs

if you can come back


val api_bearer_debug = "\"${System.getenv(tmdb_token_name_debug) ?: bearear_without_environment}\""
val api_bearer_release = "\"${System.getenv(tmdb_token_name_release) ?: bearear_without_environment}\""
val api_bearer = System.getenv(tmdb_token_name_debug) ?: bearear_without_environment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aqui mesma coisa

import io.ktor.utils.io.errors.IOException
import kotlinx.serialization.SerializationException

internal fun HttpClientConfig<OkHttpConfig>.validator(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why remove it?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It because this is Moshi (android specific code). Ktor handles this for us.

import com.pierfrancescosoffritti.androidyoutubeplayer.core.player.views.YouTubePlayerView

@Composable
actual fun PlayerComponent(videoId: String, modifier: Modifier) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a suggestions,

In the project I work on, I created a pattern that is easier to see

any file that has expect and actual, put it at the end Platform

which is a pattern of understanding that this type of file has this implementation

@@ -1,105 +1,10 @@
@file:Suppress("EXPECT_AND_ACTUAL_IN_THE_SAME_MODULE")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

@Serializable
data class ListSearchStreamResponse(
@Json(name = "results")
@SerialName("results")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tks i forgot


kover = { id = "org.jetbrains.kotlinx.kover", version.ref = "kover" }
detekt = { id = "io.gitlab.arturbosch.detekt", version.ref = "detekt" }
buildkonfig_plugin = { id = "com.codingfeline.buildkonfig", version.ref = "buildkonfig" }

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make a video about buildKonfig put in kmp trilha pls

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adicionado na planilha

@gabrielbmoro
Copy link
Author

gabrielbmoro commented Feb 5, 2025

requestTimeoutMillis = TIMEOUT
connectTimeoutMillis = TIMEOUT
}
install(ContentNegotiation) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

não entendi, pq precisou mudar essas coisas

@gabrielbmoro gabrielbmoro merged commit 88d61b0 into master Feb 9, 2025
@gabrielbmoro gabrielbmoro deleted the feature/issue-17-commonMain-to-androidMain branch February 9, 2025 20:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants