Skip to content

Commit

Permalink
refactor(m3): move model ui in dedicated module.
Browse files Browse the repository at this point in the history
  • Loading branch information
GerardPaligot committed Oct 12, 2023
1 parent b614092 commit 7f1e696
Show file tree
Hide file tree
Showing 124 changed files with 237 additions and 202 deletions.
1 change: 0 additions & 1 deletion android-data/.gitignore

This file was deleted.

12 changes: 0 additions & 12 deletions android-data/build.gradle.kts

This file was deleted.

2 changes: 0 additions & 2 deletions android-data/src/main/AndroidManifest.xml

This file was deleted.

2 changes: 1 addition & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ pluginManagement {

rootProject.name = "conferences4hall"
include(":androidApp")
include(":android-data")
include(":shared")
include(":models")
include(":backend")
Expand All @@ -36,4 +35,5 @@ include(":theme-m3:event-list:event-list-ui")
include(":theme-m3:event-list:event-list-feature")
include(":theme-m3:navigation")
include(":theme-m3:style")
include(":ui-models")
include(":ui-camera")
1 change: 1 addition & 0 deletions shared/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ kotlin {
val commonMain by getting {
dependencies {
api(projects.models)
api(projects.uiModels)
implementation(libs.kotlinx.coroutines)

implementation(libs.ktor.client.core)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import kotlinx.datetime.minus
import kotlinx.datetime.toInstant
import kotlinx.datetime.toLocalDateTime
import org.gdglille.devfest.android.theme.m3.style.R
import org.gdglille.devfest.models.TalkItemUi
import org.gdglille.devfest.models.ui.TalkItemUi
import org.gdglille.devfest.repositories.AgendaRepository
import java.util.Locale

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import io.ktor.client.engine.HttpClientEngine
import io.ktor.client.engine.android.Android
import okio.FileSystem
import okio.Path.Companion.toPath
import org.gdglille.devfest.models.ui.Image
import java.io.ByteArrayOutputStream

data class AndroidContext(val context: Context)
Expand Down Expand Up @@ -39,7 +40,6 @@ actual class DecimalFormat {
}
}

actual typealias Image = Bitmap
actual fun ByteArray.toNativeImage(): Image = BitmapFactory.decodeByteArray(this, 0, this.size)
actual fun Image.toByteArray(): ByteArray {
val stream = ByteArrayOutputStream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package org.gdglille.devfest

import com.google.zxing.BarcodeFormat
import com.journeyapps.barcodescanner.BarcodeEncoder
import org.gdglille.devfest.models.ui.Image
import org.gdglille.devfest.repositories.QrCodeGenerator

class QrCodeGeneratorAndroid : QrCodeGenerator {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package org.gdglille.devfest
import io.ktor.client.engine.HttpClientEngine
import okio.FileSystem
import okio.Path
import org.gdglille.devfest.models.ui.Image

data class FileEngine(
val fileSystem: FileSystem,
Expand All @@ -22,7 +23,5 @@ expect class DecimalFormat() {
fun format(number: Int): String
}

expect class Image

expect fun ByteArray.toNativeImage(): Image
expect fun Image.toByteArray(): ByteArray
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,23 @@ import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.combineTransform
import kotlinx.coroutines.flow.map
import org.gdglille.devfest.Image
import org.gdglille.devfest.db.Conferences4HallDatabase
import org.gdglille.devfest.exceptions.EventSavedException
import org.gdglille.devfest.models.Attendee
import org.gdglille.devfest.models.CoCUi
import org.gdglille.devfest.models.EventInfoUi
import org.gdglille.devfest.models.EventItemList
import org.gdglille.devfest.models.EventItemListUi
import org.gdglille.devfest.models.EventItemUi
import org.gdglille.devfest.models.EventUi
import org.gdglille.devfest.models.EventV3
import org.gdglille.devfest.models.MenuItemUi
import org.gdglille.devfest.models.QuestionAndResponse
import org.gdglille.devfest.models.QuestionAndResponseActionUi
import org.gdglille.devfest.models.QuestionAndResponseUi
import org.gdglille.devfest.models.TicketInfoUi
import org.gdglille.devfest.models.TicketUi
import org.gdglille.devfest.models.ui.CoCUi
import org.gdglille.devfest.models.ui.EventInfoUi
import org.gdglille.devfest.models.ui.EventItemListUi
import org.gdglille.devfest.models.ui.EventItemUi
import org.gdglille.devfest.models.ui.EventUi
import org.gdglille.devfest.models.ui.Image
import org.gdglille.devfest.models.ui.MenuItemUi
import org.gdglille.devfest.models.ui.QuestionAndResponseActionUi
import org.gdglille.devfest.models.ui.QuestionAndResponseUi
import org.gdglille.devfest.models.ui.TicketInfoUi
import org.gdglille.devfest.models.ui.TicketUi
import org.gdglille.devfest.toByteArray
import org.gdglille.devfest.toNativeImage

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import kotlinx.coroutines.IO
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.combine
import org.gdglille.devfest.db.Conferences4HallDatabase
import org.gdglille.devfest.models.ScaffoldConfigUi
import org.gdglille.devfest.models.ui.ScaffoldConfigUi

class FeaturesActivatedDao(private val db: Conferences4HallDatabase) {
fun fetchFeatures(eventId: String): Flow<ScaffoldConfigUi> = combine(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ import kotlinx.coroutines.flow.flatMapConcat
import kotlinx.coroutines.flow.map
import org.gdglille.devfest.Platform
import org.gdglille.devfest.db.Conferences4HallDatabase
import org.gdglille.devfest.models.JobUi
import org.gdglille.devfest.models.PartnerGroupUi
import org.gdglille.devfest.models.PartnerGroupsUi
import org.gdglille.devfest.models.PartnerItemUi
import org.gdglille.devfest.models.PartnerV2
import org.gdglille.devfest.models.SalaryUi
import org.gdglille.devfest.models.ui.JobUi
import org.gdglille.devfest.models.ui.PartnerGroupUi
import org.gdglille.devfest.models.ui.PartnerGroupsUi
import org.gdglille.devfest.models.ui.PartnerItemUi
import org.gdglille.devfest.models.ui.SalaryUi

class PartnerDao(private val db: Conferences4HallDatabase, private val platform: Platform) {
private val partnerMapper =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ import org.gdglille.devfest.database.mappers.convertTalkItemUi
import org.gdglille.devfest.database.mappers.convertToDb
import org.gdglille.devfest.database.mappers.convertToEntity
import org.gdglille.devfest.db.Conferences4HallDatabase
import org.gdglille.devfest.models.AgendaUi
import org.gdglille.devfest.models.AgendaV3
import org.gdglille.devfest.models.CategoryUi
import org.gdglille.devfest.models.FiltersUi
import org.gdglille.devfest.models.FormatUi
import org.gdglille.devfest.models.ui.AgendaUi
import org.gdglille.devfest.models.ui.CategoryUi
import org.gdglille.devfest.models.ui.FiltersUi
import org.gdglille.devfest.models.ui.FormatUi

@FlowPreview
@ExperimentalCoroutinesApi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import kotlinx.coroutines.flow.map
import org.gdglille.devfest.database.mappers.SpeakerMappers
import org.gdglille.devfest.database.mappers.convertTalkItemUi
import org.gdglille.devfest.db.Conferences4HallDatabase
import org.gdglille.devfest.models.SpeakerItemUi
import org.gdglille.devfest.models.SpeakerUi
import org.gdglille.devfest.models.TalkItemUi
import org.gdglille.devfest.models.ui.SpeakerItemUi
import org.gdglille.devfest.models.ui.SpeakerUi
import org.gdglille.devfest.models.ui.TalkItemUi

class SpeakerDao(private val db: Conferences4HallDatabase) {
fun fetchSpeaker(eventId: String, speakerId: String): Flow<SpeakerUi> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package org.gdglille.devfest.database

import org.gdglille.devfest.database.mappers.convertTalkUi
import org.gdglille.devfest.db.Conferences4HallDatabase
import org.gdglille.devfest.models.TalkUi
import org.gdglille.devfest.models.ui.TalkUi

class TalkDao(private val db: Conferences4HallDatabase) {
fun fetchTalk(eventId: String, talkId: String): TalkUi = db.transactionWithResult {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import kotlinx.datetime.Clock
import okio.Path.Companion.toPath
import org.gdglille.devfest.Platform
import org.gdglille.devfest.db.Conferences4HallDatabase
import org.gdglille.devfest.models.UserNetworkingUi
import org.gdglille.devfest.models.UserProfileUi
import org.gdglille.devfest.models.ui.UserNetworkingUi
import org.gdglille.devfest.models.ui.UserProfileUi
import org.gdglille.devfest.toByteArray
import org.gdglille.devfest.toNativeImage

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.gdglille.devfest.database.mappers

import org.gdglille.devfest.models.Category
import org.gdglille.devfest.models.CategoryUi
import org.gdglille.devfest.models.ui.CategoryUi
import org.gdglille.devfest.db.Category as CategoryDb

fun Category.convertToDb(eventId: String): CategoryDb = CategoryDb(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.gdglille.devfest.database.mappers

import org.gdglille.devfest.models.Format
import org.gdglille.devfest.models.FormatUi
import org.gdglille.devfest.models.ui.FormatUi
import org.gdglille.devfest.db.Format as FormatDb

fun Format.convertToDb(eventId: String): FormatDb = FormatDb(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ import org.gdglille.devfest.db.Session
import org.gdglille.devfest.db.TalkSession
import org.gdglille.devfest.db.TalkSessionWithSpeakers
import org.gdglille.devfest.extensions.formatHoursMinutes
import org.gdglille.devfest.models.CategoryUi
import org.gdglille.devfest.models.FormatUi
import org.gdglille.devfest.models.ScheduleItemV3
import org.gdglille.devfest.models.SpeakerItemUi
import org.gdglille.devfest.models.TalkItemUi
import org.gdglille.devfest.models.TalkUi
import org.gdglille.devfest.models.TalkV3
import org.gdglille.devfest.models.ui.CategoryUi
import org.gdglille.devfest.models.ui.FormatUi
import org.gdglille.devfest.models.ui.SpeakerItemUi
import org.gdglille.devfest.models.ui.TalkItemUi
import org.gdglille.devfest.models.ui.TalkUi
import kotlin.reflect.KFunction1

private const val BREAK_TITLE = "break"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package org.gdglille.devfest.database.mappers

import kotlinx.collections.immutable.persistentListOf
import org.gdglille.devfest.models.Speaker
import org.gdglille.devfest.models.SpeakerItemUi
import org.gdglille.devfest.models.SpeakerUi
import org.gdglille.devfest.models.ui.SpeakerItemUi
import org.gdglille.devfest.models.ui.SpeakerUi
import org.gdglille.devfest.db.Speaker as SpeakerDb

object SpeakerMappers {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,19 @@ import org.gdglille.devfest.database.ScheduleDao
import org.gdglille.devfest.database.SpeakerDao
import org.gdglille.devfest.database.TalkDao
import org.gdglille.devfest.exceptions.AgendaNotModifiedException
import org.gdglille.devfest.models.AgendaUi
import org.gdglille.devfest.models.CategoryUi
import org.gdglille.devfest.models.CoCUi
import org.gdglille.devfest.models.EventUi
import org.gdglille.devfest.models.FiltersUi
import org.gdglille.devfest.models.FormatUi
import org.gdglille.devfest.models.MenuItemUi
import org.gdglille.devfest.models.PartnerGroupsUi
import org.gdglille.devfest.models.PartnerItemUi
import org.gdglille.devfest.models.QuestionAndResponseUi
import org.gdglille.devfest.models.ScaffoldConfigUi
import org.gdglille.devfest.models.SpeakerUi
import org.gdglille.devfest.models.TalkUi
import org.gdglille.devfest.models.ui.AgendaUi
import org.gdglille.devfest.models.ui.CategoryUi
import org.gdglille.devfest.models.ui.CoCUi
import org.gdglille.devfest.models.ui.EventUi
import org.gdglille.devfest.models.ui.FiltersUi
import org.gdglille.devfest.models.ui.FormatUi
import org.gdglille.devfest.models.ui.MenuItemUi
import org.gdglille.devfest.models.ui.PartnerGroupsUi
import org.gdglille.devfest.models.ui.PartnerItemUi
import org.gdglille.devfest.models.ui.QuestionAndResponseUi
import org.gdglille.devfest.models.ui.ScaffoldConfigUi
import org.gdglille.devfest.models.ui.SpeakerUi
import org.gdglille.devfest.models.ui.TalkUi
import org.gdglille.devfest.network.ConferenceApi

interface AgendaRepository {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import kotlinx.coroutines.coroutineScope
import kotlinx.coroutines.flow.Flow
import org.gdglille.devfest.database.EventDao
import org.gdglille.devfest.exceptions.EventSavedException
import org.gdglille.devfest.models.EventItemListUi
import org.gdglille.devfest.models.ui.EventItemListUi
import org.gdglille.devfest.network.ConferenceApi

interface EventRepository {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import kotlinx.coroutines.MainScope
import kotlinx.coroutines.flow.Flow
import org.gdglille.devfest.database.EventDao
import org.gdglille.devfest.database.SpeakerDao
import org.gdglille.devfest.models.SpeakerItemUi
import org.gdglille.devfest.models.ui.SpeakerItemUi

interface SpeakerRepository {
fun speakers(): Flow<ImmutableList<SpeakerItemUi>>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.MainScope
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.combine
import org.gdglille.devfest.Image
import org.gdglille.devfest.database.EventDao
import org.gdglille.devfest.database.UserDao
import org.gdglille.devfest.models.ExportNetworkingUi
import org.gdglille.devfest.models.UserNetworkingUi
import org.gdglille.devfest.models.UserProfileUi
import org.gdglille.devfest.models.ui.ExportNetworkingUi
import org.gdglille.devfest.models.ui.Image
import org.gdglille.devfest.models.ui.UserNetworkingUi
import org.gdglille.devfest.models.ui.UserProfileUi
import org.gdglille.devfest.vcard.encodeToString

interface UserRepository {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.gdglille.devfest.vcard

import org.gdglille.devfest.models.UserNetworkingUi
import org.gdglille.devfest.models.ui.UserNetworkingUi

inline fun UserNetworkingUi.encodeToString(): String = """BEGIN:VCARD
VERSION:4.0
Expand Down
3 changes: 1 addition & 2 deletions shared/src/iosMain/kotlin/org/gdglille/devfest/Platform.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import kotlinx.cinterop.memScoped
import kotlinx.cinterop.toCValues
import kotlinx.cinterop.usePinned
import okio.FileSystem
import org.gdglille.devfest.models.ui.Image
import platform.Foundation.NSBundle
import platform.Foundation.NSData
import platform.Foundation.NSNumber
Expand Down Expand Up @@ -56,8 +57,6 @@ actual class DecimalFormat {
}
}

actual typealias Image = UIImage

actual fun ByteArray.toNativeImage(): Image = memScoped {
toCValues()
.ptr
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import org.gdglille.devfest.android.theme.m3.style.Conferences4HallTheme
import org.gdglille.devfest.android.theme.m3.style.Scaffold
import org.gdglille.devfest.android.theme.m3.style.R
import org.gdglille.devfest.android.theme.m3.style.actions.TabActionsUi
import org.gdglille.devfest.models.EventItemListUi
import org.gdglille.devfest.models.ui.EventItemListUi

@OptIn(ExperimentalFoundationApi::class)
@Composable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import kotlinx.coroutines.flow.catch
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.stateIn
import kotlinx.coroutines.launch
import org.gdglille.devfest.models.EventItemListUi
import org.gdglille.devfest.models.ui.EventItemListUi
import org.gdglille.devfest.repositories.EventRepository

sealed class EventListUiState {
Expand Down
2 changes: 1 addition & 1 deletion theme-m3/event-list/event-list-ui/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ android {
}

dependencies {
implementation(projects.shared)
implementation(projects.uiModels)
implementation(projects.themeM3.style)

implementation(platform(libs.androidx.compose.bom))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import org.gdglille.devfest.android.theme.m3.style.Conferences4HallTheme
import org.gdglille.devfest.android.theme.m3.style.placeholder
import org.gdglille.devfest.models.EventItemUi
import org.gdglille.devfest.models.ui.EventItemUi

@Composable
fun EventItem(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import com.halilibo.richtext.ui.RichText
import com.halilibo.richtext.ui.RichTextThemeIntegration
import org.gdglille.devfest.android.theme.m3.style.Conferences4HallTheme
import org.gdglille.devfest.android.theme.m3.style.R
import org.gdglille.devfest.models.CoCUi
import org.gdglille.devfest.models.ui.CoCUi

@Composable
fun CoC(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import com.google.firebase.ktx.Firebase
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.launch
import org.gdglille.devfest.models.CoCUi
import org.gdglille.devfest.models.ui.CoCUi
import org.gdglille.devfest.repositories.AgendaRepository

sealed class CoCUiState {
Expand Down
Loading

0 comments on commit 7f1e696

Please sign in to comment.