-
Notifications
You must be signed in to change notification settings - Fork 3
[issue-17] - common main to android main #18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[issue-17] - common main to android main #18
Conversation
| import Config | ||
| import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension | ||
|
|
||
| fun KotlinMultiplatformExtension.iosTarget() { |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
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{ |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why?
There was a problem hiding this comment.
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 | |||
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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"] |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
build-logic/src/main/java/Config.kt
Outdated
| 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/" |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why remove it?
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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") | |||
There was a problem hiding this comment.
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") |
There was a problem hiding this comment.
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" } |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adicionado na planilha
|
Future issues to be addressed after this PR - #19 |
| requestTimeoutMillis = TIMEOUT | ||
| connectTimeoutMillis = TIMEOUT | ||
| } | ||
| install(ContentNegotiation) { |
There was a problem hiding this comment.
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
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
Screen_recording_20250203_081527.webm
Checklist
Issues Relacionadas