Skip to content
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

♻️ Convert Repository module to KMP #533

Merged
merged 3 commits into from Aug 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions data/local/build.gradle.kts
Expand Up @@ -26,6 +26,7 @@ dependencies {
api(libs.androidx.room.runtime)
implementation(libs.androidx.room.ktx)
ksp(libs.androidx.room.compiler)
implementation(libs.kotlinx.datetime)

androidTestImplementation(libs.test.junitext)
androidTestImplementation(libs.test.runner)
Expand Down
14 changes: 8 additions & 6 deletions data/local/src/main/java/com/escodro/local/mapper/TaskMapper.kt
@@ -1,5 +1,7 @@
package com.escodro.local.mapper

import com.escodro.core.extension.toCalendar
import com.escodro.core.extension.toLocalDateTime
import com.escodro.local.model.Task as LocalTask
import com.escodro.repository.model.Task as RepoTask

Expand All @@ -22,9 +24,9 @@ internal class TaskMapper(private val alarmIntervalMapper: AlarmIntervalMapper)
title = repoTask.title,
description = repoTask.description,
categoryId = repoTask.categoryId,
dueDate = repoTask.dueDate,
creationDate = repoTask.creationDate,
completedDate = repoTask.completedDate,
dueDate = repoTask.dueDate?.toCalendar(),
creationDate = repoTask.creationDate?.toCalendar(),
completedDate = repoTask.completedDate?.toCalendar(),
isRepeating = repoTask.isRepeating,
alarmInterval = repoTask.alarmInterval?.let { alarmIntervalMapper.toLocal(it) },
)
Expand All @@ -43,9 +45,9 @@ internal class TaskMapper(private val alarmIntervalMapper: AlarmIntervalMapper)
title = localTask.title,
description = localTask.description,
categoryId = localTask.categoryId,
dueDate = localTask.dueDate,
creationDate = localTask.creationDate,
completedDate = localTask.completedDate,
dueDate = localTask.dueDate?.toLocalDateTime(),
creationDate = localTask.creationDate?.toLocalDateTime(),
completedDate = localTask.completedDate?.toLocalDateTime(),
isRepeating = localTask.isRepeating,
alarmInterval = localTask.alarmInterval?.let { alarmIntervalMapper.toRepo(it) },
)
Expand Down
1 change: 0 additions & 1 deletion data/repository/.gitignore

This file was deleted.

51 changes: 44 additions & 7 deletions data/repository/build.gradle.kts
@@ -1,16 +1,53 @@
plugins {
id("com.escodro.android-library") // TODO revert to Kotlin-only
kotlin("multiplatform")
id("com.android.library")
id("com.escodro.kotlin-quality")
}

dependencies {
implementation(projects.domain)
implementation(projects.libraries.core)
@OptIn(org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi::class)
kotlin {
targetHierarchy.default()

implementation(libs.koin.core)
implementation(libs.kotlinx.coroutines.core)
implementation(libs.kotlinx.datetime)
android {
compilations.all {
kotlinOptions {
jvmTarget = "1.8"
}
}
}

listOf(
iosX64(),
iosArm64(),
iosSimulatorArm64()
).forEach {
it.binaries.framework {
baseName = "repository"
}
}

sourceSets {
val commonMain by getting {
dependencies {
implementation(projects.domain)

implementation(libs.koin.core)
implementation(libs.kotlinx.coroutines.core)
implementation(libs.kotlinx.datetime)
}
}
val commonTest by getting {
dependencies {
implementation(kotlin("test"))
}
}
}
}

android {
namespace = "com.escodro.repository"
compileSdk = Integer.parseInt(libs.versions.android.sdk.compile.get())
defaultConfig {
minSdk = Integer.parseInt(libs.versions.android.sdk.min.get())
}
}
Empty file removed data/repository/consumer-rules.pro
Empty file.
26 changes: 0 additions & 26 deletions data/repository/proguard-rules.pro

This file was deleted.

@@ -1,7 +1,5 @@
package com.escodro.repository.mapper

import com.escodro.core.extension.toCalendar
import com.escodro.core.extension.toLocalDateTime
import com.escodro.domain.model.Task as DomainTask
import com.escodro.repository.model.Task as RepoTask

Expand All @@ -24,9 +22,9 @@ internal class TaskMapper(private val alarmIntervalMapper: AlarmIntervalMapper)
title = repoTask.title,
description = repoTask.description,
categoryId = repoTask.categoryId,
dueDate = repoTask.dueDate?.toLocalDateTime(),
creationDate = repoTask.creationDate?.toLocalDateTime(),
completedDate = repoTask.completedDate?.toLocalDateTime(),
dueDate = repoTask.dueDate,
creationDate = repoTask.creationDate,
completedDate = repoTask.completedDate,
isRepeating = repoTask.isRepeating,
alarmInterval = repoTask.alarmInterval?.let { alarmIntervalMapper.toDomain(it) },
)
Expand Down Expand Up @@ -55,9 +53,9 @@ internal class TaskMapper(private val alarmIntervalMapper: AlarmIntervalMapper)
title = domainTask.title,
description = domainTask.description,
categoryId = domainTask.categoryId,
dueDate = domainTask.dueDate?.toCalendar(),
creationDate = domainTask.creationDate?.toCalendar(),
completedDate = domainTask.completedDate?.toCalendar(),
dueDate = domainTask.dueDate,
creationDate = domainTask.creationDate,
completedDate = domainTask.completedDate,
isRepeating = domainTask.isRepeating,
alarmInterval = domainTask.alarmInterval?.let { alarmIntervalMapper.toRepo(it) },
)
Expand Down
@@ -1,6 +1,6 @@
package com.escodro.repository.model

import java.util.Calendar
import kotlinx.datetime.LocalDateTime

/**
* Data class to represent a Task.
Expand All @@ -22,9 +22,9 @@ data class Task(
val title: String,
val description: String?,
val categoryId: Long? = null,
val dueDate: Calendar? = null,
val creationDate: Calendar? = null,
val completedDate: Calendar? = null,
val dueDate: LocalDateTime? = null,
val creationDate: LocalDateTime? = null,
val completedDate: LocalDateTime? = null,
val isRepeating: Boolean = false,
val alarmInterval: AlarmInterval? = null,
)
1 change: 0 additions & 1 deletion data/repository/src/main/AndroidManifest.xml

This file was deleted.