diff --git a/.editorconfig b/.editorconfig index e498c932..e5c8cdda 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,3 +1,5 @@ +root = true + [*.{kt,kts}] end_of_line = lf ij_kotlin_packages_to_use_import_on_demand = true @@ -15,8 +17,9 @@ ktlint_chain_method_rule_force_multiline_when_chain_operator_count_greater_or_eq ktlint_class_signature_rule_force_multiline_when_parameter_count_greater_or_equal_than = unset ktlint_code_style = android_studio ktlint_enum_entry_name_casing = upper_or_camel_cases -ktlint_function_naming_ignore_when_annotated_with = [unset] +ktlint_function_naming_ignore_when_annotated_with = Composable ktlint_function_signature_body_expression_wrapping = default ktlint_function_signature_rule_force_multiline_when_parameter_count_greater_or_equal_than = unset ktlint_ignore_back_ticked_identifier = false max_line_length = 140 + diff --git a/android/src/main/java/co/touchlab/droidcon/android/MainActivity.kt b/android/src/main/java/co/touchlab/droidcon/android/MainActivity.kt index 2fb3dab9..a5c4e27b 100644 --- a/android/src/main/java/co/touchlab/droidcon/android/MainActivity.kt +++ b/android/src/main/java/co/touchlab/droidcon/android/MainActivity.kt @@ -44,7 +44,9 @@ import org.brightify.hyperdrive.multiplatformx.LifecycleGraph import org.koin.core.component.KoinComponent import org.koin.core.component.inject -class MainActivity : ComponentActivity(), KoinComponent { +class MainActivity : + ComponentActivity(), + KoinComponent { private val notificationSchedulingService: NotificationSchedulingService by inject() private val syncService: SyncService by inject() diff --git a/android/src/main/java/co/touchlab/droidcon/android/service/impl/DefaultFirebaseMessagingService.kt b/android/src/main/java/co/touchlab/droidcon/android/service/impl/DefaultFirebaseMessagingService.kt index 7fa34636..8f19da9f 100644 --- a/android/src/main/java/co/touchlab/droidcon/android/service/impl/DefaultFirebaseMessagingService.kt +++ b/android/src/main/java/co/touchlab/droidcon/android/service/impl/DefaultFirebaseMessagingService.kt @@ -21,7 +21,7 @@ class DefaultFirebaseMessagingService : FirebaseMessagingService() { override fun onMessageReceived(message: RemoteMessage) { super.onMessageReceived(message) - if (message.data.isNotEmpty() && message.data[Notification.Keys.notificationType] == Notification.Values.refreshDataType) { + if (message.data.isNotEmpty() && message.data[Notification.Keys.NOTIFICATION_TYPE] == Notification.Values.REFRESH_DATA_TYPE) { MainScope().launch { notificationService.handleNotification( Notification.Remote.RefreshData, diff --git a/android/src/main/java/co/touchlab/droidcon/android/service/impl/DefaultParseUrlViewService.kt b/android/src/main/java/co/touchlab/droidcon/android/service/impl/DefaultParseUrlViewService.kt index 14d7e86d..0824b44f 100644 --- a/android/src/main/java/co/touchlab/droidcon/android/service/impl/DefaultParseUrlViewService.kt +++ b/android/src/main/java/co/touchlab/droidcon/android/service/impl/DefaultParseUrlViewService.kt @@ -8,7 +8,5 @@ class DefaultParseUrlViewService : ParseUrlViewService { private val urlRegex = Patterns.WEB_URL.toRegex() - override fun parse(text: String): List { - return urlRegex.findAll(text).map { WebLink(it.range, it.value) }.toList() - } + override fun parse(text: String): List = urlRegex.findAll(text).map { WebLink(it.range, it.value) }.toList() } diff --git a/android/src/main/java/co/touchlab/droidcon/android/util/NotificationLocalizedStringFactory.kt b/android/src/main/java/co/touchlab/droidcon/android/util/NotificationLocalizedStringFactory.kt index 96f07e38..41856c25 100644 --- a/android/src/main/java/co/touchlab/droidcon/android/util/NotificationLocalizedStringFactory.kt +++ b/android/src/main/java/co/touchlab/droidcon/android/util/NotificationLocalizedStringFactory.kt @@ -4,24 +4,16 @@ import android.content.Context import co.touchlab.droidcon.R import co.touchlab.droidcon.application.service.NotificationSchedulingService -class NotificationLocalizedStringFactory( - private val context: Context, -) : NotificationSchedulingService.LocalizedStringFactory { +class NotificationLocalizedStringFactory(private val context: Context) : NotificationSchedulingService.LocalizedStringFactory { override fun reminderTitle(roomName: String?): String { val ending = roomName?.let { context.getString(R.string.notification_reminder_title_in_room, it) } ?: "" return context.getString(R.string.notification_reminder_title_base, ending) } - override fun reminderBody(sessionTitle: String): String { - return context.getString(R.string.notification_reminder_body, sessionTitle) - } + override fun reminderBody(sessionTitle: String): String = context.getString(R.string.notification_reminder_body, sessionTitle) - override fun feedbackTitle(): String { - return context.getString(R.string.notification_feedback_title) - } + override fun feedbackTitle(): String = context.getString(R.string.notification_feedback_title) - override fun feedbackBody(): String { - return context.getString(R.string.notification_feedback_body) - } + override fun feedbackBody(): String = context.getString(R.string.notification_feedback_body) } diff --git a/build.gradle.kts b/build.gradle.kts index 3249f2af..287ebc65 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -37,6 +37,9 @@ subprojects { jvmTarget = "1.8" } } + configure { + version.set("1.4.0") + } } tasks.register("clean") { diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index bad9ff8a..c971bbfa 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -49,7 +49,7 @@ android-desugaring = "2.1.2" koin = "3.5.3" uuid = "0.8.3" # TODO: Update Ktlint when fix is available -ktlint = "11.0.0" +ktlint = "12.1.1" # TODO: Update Coil library when Ktor is updated to 3.0 coil = "3.0.0-alpha04" zoomimage = "1.1.0-alpha06" diff --git a/ios/build.gradle.kts b/ios/build.gradle.kts index 33a6f509..6686af72 100644 --- a/ios/build.gradle.kts +++ b/ios/build.gradle.kts @@ -15,7 +15,7 @@ kotlin { val targets = listOf( iosX64(), iosArm64(), - iosSimulatorArm64() + iosSimulatorArm64(), ) sourceSets { @@ -55,7 +55,7 @@ kotlin { "-linker-option", "-framework", "-linker-option", "Metal", "-linker-option", "-framework", "-linker-option", "CoreText", "-linker-option", "-framework", "-linker-option", "CoreGraphics", - "-Xdisable-phases=VerifyBitcode" + "-Xdisable-phases=VerifyBitcode", ) linkerOpts.add("-lsqlite3") export(libs.kermit) @@ -78,7 +78,7 @@ kotlin { } afterEvaluate { - tasks.withType() { + tasks.withType { (compilerPluginClasspath as? Configuration)?.isTransitive = true } } diff --git a/ios/src/iosMain/kotlin/co/touchlab/droidcon/ios/DependencyInjection.kt b/ios/src/iosMain/kotlin/co/touchlab/droidcon/ios/DependencyInjection.kt index b7207246..cddc4631 100644 --- a/ios/src/iosMain/kotlin/co/touchlab/droidcon/ios/DependencyInjection.kt +++ b/ios/src/iosMain/kotlin/co/touchlab/droidcon/ios/DependencyInjection.kt @@ -22,10 +22,7 @@ import platform.Foundation.NSBundle import platform.Foundation.NSUserDefaults @OptIn(ExperimentalSettingsApi::class) -fun initKoinIos( - userDefaults: NSUserDefaults, - analyticsService: AnalyticsService -): KoinApplication = initKoin( +fun initKoinIos(userDefaults: NSUserDefaults, analyticsService: AnalyticsService): KoinApplication = initKoin( module { single { BundleProvider(bundle = NSBundle.mainBundle) } single { NSUserDefaultsSettings(delegate = userDefaults) } @@ -40,7 +37,7 @@ fun initKoinIos( single { analyticsService } single { DefaultParseUrlViewService() } - } + uiModule + } + uiModule, ) // Workaround class for injecting an `NSObject` class. diff --git a/ios/src/iosMain/kotlin/co/touchlab/droidcon/ios/service/DefaultParseUrlViewService.kt b/ios/src/iosMain/kotlin/co/touchlab/droidcon/ios/service/DefaultParseUrlViewService.kt index 90dbc71e..f4b4c1ab 100644 --- a/ios/src/iosMain/kotlin/co/touchlab/droidcon/ios/service/DefaultParseUrlViewService.kt +++ b/ios/src/iosMain/kotlin/co/touchlab/droidcon/ios/service/DefaultParseUrlViewService.kt @@ -8,7 +8,5 @@ class DefaultParseUrlViewService : ParseUrlViewService { private val urlRegex = "https?:\\/\\/(www\\.)?[-a-zA-Z0-9@:%._\\+~#=]{1,256}\\.[a-zA-Z0-9()]{1,6}\\b([-a-zA-Z0-9()@:%_\\+.~#?&//=]*)".toRegex() - override fun parse(text: String): List { - return urlRegex.findAll(text).map { WebLink(it.range, it.value) }.toList() - } + override fun parse(text: String): List = urlRegex.findAll(text).map { WebLink(it.range, it.value) }.toList() } diff --git a/ios/src/iosMain/kotlin/co/touchlab/droidcon/ios/util/NotificationLocalizedStringFactory.kt b/ios/src/iosMain/kotlin/co/touchlab/droidcon/ios/util/NotificationLocalizedStringFactory.kt index 8ff23978..21ee3bf5 100644 --- a/ios/src/iosMain/kotlin/co/touchlab/droidcon/ios/util/NotificationLocalizedStringFactory.kt +++ b/ios/src/iosMain/kotlin/co/touchlab/droidcon/ios/util/NotificationLocalizedStringFactory.kt @@ -7,9 +7,7 @@ import platform.Foundation.NSString import platform.Foundation.stringWithFormat @OptIn(kotlinx.cinterop.ExperimentalForeignApi::class) -class NotificationLocalizedStringFactory( - private val bundle: NSBundle, -) : NotificationSchedulingService.LocalizedStringFactory { +class NotificationLocalizedStringFactory(private val bundle: NSBundle) : NotificationSchedulingService.LocalizedStringFactory { override fun reminderTitle(roomName: String?): String { val ending = roomName?.let { @@ -17,34 +15,27 @@ class NotificationLocalizedStringFactory( .stringWithFormat( bundle.localizedStringForKey("Notification.Reminder.Title.InRoom", null, null) .convertParametersForPrintf(), - it.cstr + it.cstr, ) } ?: "" return NSString .stringWithFormat( bundle.localizedStringForKey("Notification.Reminder.Title.Base", null, null) .convertParametersForPrintf(), - ending.cstr + ending.cstr, ) } - override fun reminderBody(sessionTitle: String): String { - return NSString - .stringWithFormat( - bundle.localizedStringForKey("Notification.Reminder.Body", null, null) - .convertParametersForPrintf(), - sessionTitle.cstr - ) - } + override fun reminderBody(sessionTitle: String): String = NSString + .stringWithFormat( + bundle.localizedStringForKey("Notification.Reminder.Body", null, null) + .convertParametersForPrintf(), + sessionTitle.cstr, + ) - override fun feedbackTitle(): String { - return bundle.localizedStringForKey("Notification.Feedback.Title", null, null) - } + override fun feedbackTitle(): String = bundle.localizedStringForKey("Notification.Feedback.Title", null, null) - override fun feedbackBody(): String { - return bundle.localizedStringForKey("Notification.Feedback.Body", null, null) - } + override fun feedbackBody(): String = bundle.localizedStringForKey("Notification.Feedback.Body", null, null) - private fun String.convertParametersForPrintf(): String = - replace("%@", "%s") + private fun String.convertParametersForPrintf(): String = replace("%@", "%s") } diff --git a/ios/src/iosMain/kotlin/co/touchlab/droidcon/ios/util/formatter/IOSDateFormatter.kt b/ios/src/iosMain/kotlin/co/touchlab/droidcon/ios/util/formatter/IOSDateFormatter.kt index a2140f47..15d01ea1 100644 --- a/ios/src/iosMain/kotlin/co/touchlab/droidcon/ios/util/formatter/IOSDateFormatter.kt +++ b/ios/src/iosMain/kotlin/co/touchlab/droidcon/ios/util/formatter/IOSDateFormatter.kt @@ -34,21 +34,18 @@ class IOSDateFormatter : DateFormatter { } } - override fun monthWithDay(date: LocalDate) = - date.date()?.let { monthWithDay.stringFromDate(it) } + override fun monthWithDay(date: LocalDate) = date.date()?.let { monthWithDay.stringFromDate(it) } - override fun timeOnly(dateTime: LocalDateTime) = - dateTime.date()?.let { timeOnly.stringFromDate(it) } + override fun timeOnly(dateTime: LocalDateTime) = dateTime.date()?.let { timeOnly.stringFromDate(it) } override fun timeOnlyInterval(fromDateTime: LocalDateTime, toDateTime: LocalDateTime) = interval( fromDateTime.date()?.let { timeOnlyNoPeriod.stringFromDate(it) }, - toDateTime.date()?.let { timeOnly.stringFromDate(it) } + toDateTime.date()?.let { timeOnly.stringFromDate(it) }, ) private fun LocalDate.date() = NSCalendar.currentCalendar.dateFromComponents(toNSDateComponents()) - private fun LocalDateTime.date() = - // TODOKPG - Pretty sure this is device time zone, might be OK. Just for local formating + private fun LocalDateTime.date() = // TODOKPG - Pretty sure this is device time zone, might be OK. Just for local formating NSCalendar.currentCalendar.dateFromComponents(toNSDateComponents()) private fun interval(from: String?, to: String?) = listOfNotNull(from, to).joinToString(" – ") diff --git a/shared-ui/src/androidMain/kotlin/co/touchlab/droidcon/ui/util/Dialog.kt b/shared-ui/src/androidMain/kotlin/co/touchlab/droidcon/ui/util/Dialog.kt index 50d1c2cd..82eb170e 100644 --- a/shared-ui/src/androidMain/kotlin/co/touchlab/droidcon/ui/util/Dialog.kt +++ b/shared-ui/src/androidMain/kotlin/co/touchlab/droidcon/ui/util/Dialog.kt @@ -1,8 +1,8 @@ package co.touchlab.droidcon.ui.util -import androidx.compose.ui.window.Dialog as AndroidXComposeDialog import androidx.compose.runtime.Composable import androidx.compose.ui.ExperimentalComposeUiApi +import androidx.compose.ui.window.Dialog as AndroidXComposeDialog import androidx.compose.ui.window.DialogProperties @OptIn(ExperimentalComposeUiApi::class) diff --git a/shared-ui/src/androidMain/kotlin/co/touchlab/droidcon/ui/util/LocalImage.jvm.kt b/shared-ui/src/androidMain/kotlin/co/touchlab/droidcon/ui/util/LocalImage.jvm.kt index 587c72ec..6f7813f4 100644 --- a/shared-ui/src/androidMain/kotlin/co/touchlab/droidcon/ui/util/LocalImage.jvm.kt +++ b/shared-ui/src/androidMain/kotlin/co/touchlab/droidcon/ui/util/LocalImage.jvm.kt @@ -1,4 +1,6 @@ -package co.touchlab.droidcon.ui.util // ktlint-disable filename +@file:Suppress("ktlint:standard:filename") + +package co.touchlab.droidcon.ui.util import android.annotation.SuppressLint import androidx.compose.foundation.background diff --git a/shared-ui/src/commonMain/kotlin/co.touchlab.droidcon/ui/session/SessionDetailView.kt b/shared-ui/src/commonMain/kotlin/co.touchlab.droidcon/ui/session/SessionDetailView.kt index 563f0e79..5ddcc439 100644 --- a/shared-ui/src/commonMain/kotlin/co.touchlab.droidcon/ui/session/SessionDetailView.kt +++ b/shared-ui/src/commonMain/kotlin/co.touchlab.droidcon/ui/session/SessionDetailView.kt @@ -62,7 +62,7 @@ internal fun SessionDetailView(viewModel: SessionDetailViewModel) { NavigationStack( key = viewModel, links = { - NavigationLink(viewModel.observePresentedSpeakerDetail) { + navigationLink(viewModel.observePresentedSpeakerDetail) { SpeakerDetailView(viewModel = it) } }, diff --git a/shared-ui/src/commonMain/kotlin/co.touchlab.droidcon/ui/session/SessionListView.kt b/shared-ui/src/commonMain/kotlin/co.touchlab.droidcon/ui/session/SessionListView.kt index c4261e5f..dfa6d727 100644 --- a/shared-ui/src/commonMain/kotlin/co.touchlab.droidcon/ui/session/SessionListView.kt +++ b/shared-ui/src/commonMain/kotlin/co.touchlab.droidcon/ui/session/SessionListView.kt @@ -60,15 +60,11 @@ import kotlinx.coroutines.launch @OptIn(ExperimentalMaterial3Api::class, ExperimentalFoundationApi::class) @Composable -internal fun SessionListView( - viewModel: BaseSessionListViewModel, - title: String, - emptyText: String, -) { +internal fun SessionListView(viewModel: BaseSessionListViewModel, title: String, emptyText: String) { NavigationStack( key = viewModel, links = { - NavigationLink(viewModel.observePresentedSessionDetail) { + navigationLink(viewModel.observePresentedSessionDetail) { SessionDetailView(viewModel = it) } }, diff --git a/shared-ui/src/commonMain/kotlin/co.touchlab.droidcon/ui/sponsors/SponsorDetailView.kt b/shared-ui/src/commonMain/kotlin/co.touchlab.droidcon/ui/sponsors/SponsorDetailView.kt index 8aeb4366..416f58f5 100644 --- a/shared-ui/src/commonMain/kotlin/co.touchlab.droidcon/ui/sponsors/SponsorDetailView.kt +++ b/shared-ui/src/commonMain/kotlin/co.touchlab.droidcon/ui/sponsors/SponsorDetailView.kt @@ -51,7 +51,7 @@ internal fun SponsorDetailView(viewModel: SponsorDetailViewModel) { NavigationStack( key = viewModel, links = { - NavigationLink(viewModel.observePresentedSpeakerDetail) { + navigationLink(viewModel.observePresentedSpeakerDetail) { SpeakerDetailView(viewModel = it) } }, diff --git a/shared-ui/src/commonMain/kotlin/co.touchlab.droidcon/ui/sponsors/SponsorsView.kt b/shared-ui/src/commonMain/kotlin/co.touchlab.droidcon/ui/sponsors/SponsorsView.kt index 9147cb6d..e1755a5d 100644 --- a/shared-ui/src/commonMain/kotlin/co.touchlab.droidcon/ui/sponsors/SponsorsView.kt +++ b/shared-ui/src/commonMain/kotlin/co.touchlab.droidcon/ui/sponsors/SponsorsView.kt @@ -55,7 +55,7 @@ internal fun SponsorsView(viewModel: SponsorListViewModel) { NavigationStack( key = viewModel, links = { - NavigationLink(viewModel.observePresentedSponsorDetail) { + navigationLink(viewModel.observePresentedSponsorDetail) { SponsorDetailView(viewModel = it) } }, diff --git a/shared-ui/src/commonMain/kotlin/co.touchlab.droidcon/ui/theme/Theme.kt b/shared-ui/src/commonMain/kotlin/co.touchlab.droidcon/ui/theme/Theme.kt index 923cb186..85aa1274 100644 --- a/shared-ui/src/commonMain/kotlin/co.touchlab.droidcon/ui/theme/Theme.kt +++ b/shared-ui/src/commonMain/kotlin/co.touchlab.droidcon/ui/theme/Theme.kt @@ -14,6 +14,7 @@ private val DarkColorScheme = darkColorScheme( primary = Colors.primary, ) +@Suppress("ktlint:standard:backing-property-naming") private val _LightColorScheme = lightColorScheme( primary = Colors.primary, onPrimary = Colors.droidcon_theme_light_onPrimary, @@ -46,6 +47,7 @@ private val _LightColorScheme = lightColorScheme( onSurfaceVariant = Colors.droidcon_theme_light_onSurfaceVariant, ) +@Suppress("ktlint:standard:backing-property-naming") private val _DarkColorScheme = darkColorScheme( primary = Colors.droidcon_theme_dark_primary, onPrimary = Colors.droidcon_theme_dark_onPrimary, @@ -79,10 +81,7 @@ private val _DarkColorScheme = darkColorScheme( ) @Composable -internal fun DroidconTheme( - darkTheme: Boolean = isSystemInDarkTheme(), - content: @Composable () -> Unit, -) { +internal fun DroidconTheme(darkTheme: Boolean = isSystemInDarkTheme(), content: @Composable () -> Unit) { val colorScheme = when { darkTheme -> DarkColorScheme else -> LightColorScheme diff --git a/shared-ui/src/commonMain/kotlin/co.touchlab.droidcon/ui/util/Image.kt b/shared-ui/src/commonMain/kotlin/co.touchlab.droidcon/ui/util/Image.kt index 55db9dc4..197c04ec 100644 --- a/shared-ui/src/commonMain/kotlin/co.touchlab.droidcon/ui/util/Image.kt +++ b/shared-ui/src/commonMain/kotlin/co.touchlab.droidcon/ui/util/Image.kt @@ -10,12 +10,7 @@ import coil3.request.crossfade import coil3.util.DebugLogger @Composable -fun DcAsyncImage( - logTag: String, - model: Any?, - contentDescription: String?, - modifier: Modifier = Modifier, -) { +fun DcAsyncImage(logTag: String, model: Any?, contentDescription: String?, modifier: Modifier = Modifier) { AsyncImage( modifier = modifier, model = model, @@ -30,16 +25,11 @@ fun DcAsyncImage( ) } -fun dcImageLoader( - context: PlatformContext, - debug: Boolean = false, -): ImageLoader { - return ImageLoader.Builder(context) - .crossfade(true) - .apply { - if (debug) { - logger(DebugLogger()) - } +fun dcImageLoader(context: PlatformContext, debug: Boolean = false): ImageLoader = ImageLoader.Builder(context) + .crossfade(true) + .apply { + if (debug) { + logger(DebugLogger()) } - .build() -} + } + .build() diff --git a/shared-ui/src/commonMain/kotlin/co.touchlab.droidcon/util/LocalDateTime+startOfMinute.kt b/shared-ui/src/commonMain/kotlin/co.touchlab.droidcon/util/LocalDateTime+startOfMinute.kt index ca0f3191..00317ab1 100644 --- a/shared-ui/src/commonMain/kotlin/co.touchlab.droidcon/util/LocalDateTime+startOfMinute.kt +++ b/shared-ui/src/commonMain/kotlin/co.touchlab.droidcon/util/LocalDateTime+startOfMinute.kt @@ -1,3 +1,5 @@ +@file:Suppress("ktlint:standard:filename") + package co.touchlab.droidcon.util import kotlinx.datetime.LocalDateTime diff --git a/shared-ui/src/commonMain/kotlin/co.touchlab.droidcon/util/NavigationController.kt b/shared-ui/src/commonMain/kotlin/co.touchlab.droidcon/util/NavigationController.kt index b3629fd4..66eaa404 100644 --- a/shared-ui/src/commonMain/kotlin/co.touchlab.droidcon/util/NavigationController.kt +++ b/shared-ui/src/commonMain/kotlin/co.touchlab.droidcon/util/NavigationController.kt @@ -48,16 +48,13 @@ class NavigationController : BaseViewModel() { internal sealed class NavigationStackItem { class BackPressHandler(val onBackPressed: BackPressHandlerScope.() -> Unit) : NavigationStackItem() { - override fun toString(): String { - return "BackPress@${hashCode().toUInt().toString(16)}" - } + override fun toString(): String = "BackPress@${hashCode().toUInt().toString(16)}" } class Push(val item: MutableObservableProperty, val content: @Composable (T) -> Unit) : NavigationStackItem() { - override fun toString(): String { - return "Push(${item.value}@${item.hashCode().toUInt().toString(16)})@${hashCode().toUInt().toString(16)}" - } + override fun toString(): String = + "Push(${item.value}@${item.hashCode().toUInt().toString(16)})@${hashCode().toUInt().toString(16)}" } } @@ -176,9 +173,7 @@ class NavigationController : BaseViewModel() { } } -internal data class NavigationViewDimensions( - val constraints: Constraints, -) +internal data class NavigationViewDimensions(val constraints: Constraints) @Composable internal fun rememberNavigationController(): NavigationController = remember { @@ -213,7 +208,7 @@ internal fun BackPressHandler(onBackPressed: NavigationController.BackPressHandl internal interface NavigationStackScope { - fun NavigationLink(item: MutableObservableProperty, content: @Composable (T) -> Unit) + fun navigationLink(item: MutableObservableProperty, content: @Composable (T) -> Unit) } internal class NavigationLinkWrapper( @@ -235,13 +230,11 @@ internal class NavigationLinkWrapper( } } - override fun equals(other: Any?): Boolean { - return (other as? NavigationLinkWrapper<*>)?.let { it.index == index && it.value == value } ?: false - } + override fun equals(other: Any?): Boolean = (other as? NavigationLinkWrapper<*>)?.let { + it.index == index && it.value == value + } ?: false - override fun hashCode(): Int { - return listOfNotNull(index, value).hashCode() - } + override fun hashCode(): Int = listOfNotNull(index, value).hashCode() } @OptIn(ExperimentalAnimationApi::class) @@ -250,10 +243,7 @@ internal fun NavigationStack(key: Any?, links: NavigationStackScope.() -> Unit, val activeLinkComposables by remember(key) { val constructedLinks = mutableListOf>>() val scope = object : NavigationStackScope { - override fun NavigationLink( - item: MutableObservableProperty, - content: @Composable (T) -> Unit, - ) { + override fun navigationLink(item: MutableObservableProperty, content: @Composable (T) -> Unit) { constructedLinks.add( item.map { NavigationLinkWrapper(index = constructedLinks.size, value = it, reset = { item.value = null }, content) diff --git a/shared-ui/src/commonMain/kotlin/co.touchlab.droidcon/viewmodel/ApplicationViewModel.kt b/shared-ui/src/commonMain/kotlin/co.touchlab.droidcon/viewmodel/ApplicationViewModel.kt index 715e5111..44887a98 100644 --- a/shared-ui/src/commonMain/kotlin/co.touchlab.droidcon/viewmodel/ApplicationViewModel.kt +++ b/shared-ui/src/commonMain/kotlin/co.touchlab.droidcon/viewmodel/ApplicationViewModel.kt @@ -25,7 +25,8 @@ class ApplicationViewModel( private val notificationService: NotificationService, private val feedbackService: FeedbackService, private val settingsGateway: SettingsGateway, -) : BaseViewModel(), DeepLinkNotificationHandler { +) : BaseViewModel(), + DeepLinkNotificationHandler { val schedule by managed(scheduleFactory.create()) val agenda by managed(agendaFactory.create()) @@ -107,6 +108,10 @@ class ApplicationViewModel( } enum class Tab { - Schedule, MyAgenda, Venue, Sponsors, Settings; + Schedule, + MyAgenda, + Venue, + Sponsors, + Settings, } } diff --git a/shared-ui/src/commonMain/kotlin/co.touchlab.droidcon/viewmodel/FeedbackDialogViewModel.kt b/shared-ui/src/commonMain/kotlin/co.touchlab.droidcon/viewmodel/FeedbackDialogViewModel.kt index 6d550363..4254cc1d 100644 --- a/shared-ui/src/commonMain/kotlin/co.touchlab.droidcon/viewmodel/FeedbackDialogViewModel.kt +++ b/shared-ui/src/commonMain/kotlin/co.touchlab.droidcon/viewmodel/FeedbackDialogViewModel.kt @@ -38,19 +38,21 @@ class FeedbackDialogViewModel( fun skipTapped() = instanceLock.runExclusively(skip::invoke) - private fun feedbackRatingToRating(rating: Int): Rating? = - when (rating) { - Session.Feedback.Rating.DISSATISFIED -> Rating.Dissatisfied - Session.Feedback.Rating.NORMAL -> Rating.Normal - Session.Feedback.Rating.SATISFIED -> Rating.Satisfied - else -> { - log.w("Unknown feedback rating $rating.") - null - } + private fun feedbackRatingToRating(rating: Int): Rating? = when (rating) { + Session.Feedback.Rating.DISSATISFIED -> Rating.Dissatisfied + Session.Feedback.Rating.NORMAL -> Rating.Normal + Session.Feedback.Rating.SATISFIED -> Rating.Satisfied + else -> { + log.w("Unknown feedback rating $rating.") + null } + } enum class Rating { - Dissatisfied, Normal, Satisfied; + Dissatisfied, + Normal, + Satisfied, + ; val entityValue: Int get() = when (this) { @@ -60,10 +62,7 @@ class FeedbackDialogViewModel( } } - class Factory( - private val sessionGateway: SessionGateway, - private val log: Logger, - ) { + class Factory(private val sessionGateway: SessionGateway, private val log: Logger) { fun create( session: Session, diff --git a/shared-ui/src/commonMain/kotlin/co.touchlab.droidcon/viewmodel/session/SessionBlockViewModel.kt b/shared-ui/src/commonMain/kotlin/co.touchlab.droidcon/viewmodel/session/SessionBlockViewModel.kt index c3e2fa9e..79434eb3 100644 --- a/shared-ui/src/commonMain/kotlin/co.touchlab.droidcon/viewmodel/session/SessionBlockViewModel.kt +++ b/shared-ui/src/commonMain/kotlin/co.touchlab.droidcon/viewmodel/session/SessionBlockViewModel.kt @@ -24,14 +24,8 @@ class SessionBlockViewModel( }, ) - class Factory( - private val sessionListItemFactory: SessionListItemViewModel.Factory, - private val dateFormatter: DateFormatter, - ) { - fun create( - startsAt: LocalDateTime, - items: List, - onScheduleItemSelected: (ScheduleItem) -> Unit, - ) = SessionBlockViewModel(sessionListItemFactory, dateFormatter, startsAt, items, onScheduleItemSelected) + class Factory(private val sessionListItemFactory: SessionListItemViewModel.Factory, private val dateFormatter: DateFormatter) { + fun create(startsAt: LocalDateTime, items: List, onScheduleItemSelected: (ScheduleItem) -> Unit) = + SessionBlockViewModel(sessionListItemFactory, dateFormatter, startsAt, items, onScheduleItemSelected) } } diff --git a/shared-ui/src/commonMain/kotlin/co.touchlab.droidcon/viewmodel/session/SessionDayViewModel.kt b/shared-ui/src/commonMain/kotlin/co.touchlab.droidcon/viewmodel/session/SessionDayViewModel.kt index d1c070b7..7c9ee9fd 100644 --- a/shared-ui/src/commonMain/kotlin/co.touchlab.droidcon/viewmodel/session/SessionDayViewModel.kt +++ b/shared-ui/src/commonMain/kotlin/co.touchlab.droidcon/viewmodel/session/SessionDayViewModel.kt @@ -43,20 +43,16 @@ class SessionDayViewModel( private val sessionDetailScrollStateStorage: SessionDetailScrollStateStorage, ) { - fun create( - date: LocalDate, - attendingOnly: Boolean, - items: List, - onScheduleItemSelected: (ScheduleItem) -> Unit, - ) = SessionDayViewModel( - sessionBlockFactory, - dateFormatter, - dateTimeService, - date, - attendingOnly, - sessionDetailScrollStateStorage, - items, - onScheduleItemSelected, - ) + fun create(date: LocalDate, attendingOnly: Boolean, items: List, onScheduleItemSelected: (ScheduleItem) -> Unit) = + SessionDayViewModel( + sessionBlockFactory, + dateFormatter, + dateTimeService, + date, + attendingOnly, + sessionDetailScrollStateStorage, + items, + onScheduleItemSelected, + ) } } diff --git a/shared-ui/src/commonMain/kotlin/co.touchlab.droidcon/viewmodel/session/SessionDetailScrollStateStorage.kt b/shared-ui/src/commonMain/kotlin/co.touchlab.droidcon/viewmodel/session/SessionDetailScrollStateStorage.kt index ba1ce1ca..b1c8e3bb 100644 --- a/shared-ui/src/commonMain/kotlin/co.touchlab.droidcon/viewmodel/session/SessionDetailScrollStateStorage.kt +++ b/shared-ui/src/commonMain/kotlin/co.touchlab.droidcon/viewmodel/session/SessionDetailScrollStateStorage.kt @@ -8,12 +8,11 @@ class SessionDetailScrollStateStorage { val agendaScrollStates: MutableMap = mutableMapOf() var selectedDay: LocalDate? = null - fun getScrollState(day: LocalDate, agenda: Boolean): SessionDayViewModel.ScrollState = - if (agenda) { - agendaScrollStates[day] - } else { - scrollStates[day] - } ?: SessionDayViewModel.ScrollState(firstVisibleItemIndex = 0, firstVisibleItemScrollOffset = 0) + fun getScrollState(day: LocalDate, agenda: Boolean): SessionDayViewModel.ScrollState = if (agenda) { + agendaScrollStates[day] + } else { + scrollStates[day] + } ?: SessionDayViewModel.ScrollState(firstVisibleItemIndex = 0, firstVisibleItemScrollOffset = 0) fun setScrollState(day: LocalDate, agenda: Boolean, scrollState: SessionDayViewModel.ScrollState) { if (agenda) { diff --git a/shared-ui/src/commonMain/kotlin/co.touchlab.droidcon/viewmodel/session/SessionDetailViewModel.kt b/shared-ui/src/commonMain/kotlin/co.touchlab.droidcon/viewmodel/session/SessionDetailViewModel.kt index d1b9337e..10c9e56f 100644 --- a/shared-ui/src/commonMain/kotlin/co.touchlab.droidcon/viewmodel/session/SessionDetailViewModel.kt +++ b/shared-ui/src/commonMain/kotlin/co.touchlab.droidcon/viewmodel/session/SessionDetailViewModel.kt @@ -146,7 +146,9 @@ class SessionDetailViewModel( } enum class SessionState { - InConflict, InProgress, Ended + InConflict, + InProgress, + Ended, } class Factory( @@ -162,9 +164,7 @@ class SessionDetailViewModel( private val notificationService: NotificationService, ) { - fun create( - item: ScheduleItem, - ) = SessionDetailViewModel( + fun create(item: ScheduleItem) = SessionDetailViewModel( sessionGateway, settingsGateway, speakerListItemFactory, diff --git a/shared-ui/src/commonMain/kotlin/co.touchlab.droidcon/viewmodel/session/SessionListItemViewModel.kt b/shared-ui/src/commonMain/kotlin/co.touchlab.droidcon/viewmodel/session/SessionListItemViewModel.kt index 3f5ddd0b..dd074975 100644 --- a/shared-ui/src/commonMain/kotlin/co.touchlab.droidcon/viewmodel/session/SessionListItemViewModel.kt +++ b/shared-ui/src/commonMain/kotlin/co.touchlab.droidcon/viewmodel/session/SessionListItemViewModel.kt @@ -6,11 +6,7 @@ import kotlinx.coroutines.delay import kotlinx.coroutines.flow.flow import org.brightify.hyperdrive.multiplatformx.BaseViewModel -class SessionListItemViewModel( - dateTimeService: DateTimeService, - item: ScheduleItem, - val selected: () -> Unit, -) : BaseViewModel() { +class SessionListItemViewModel(dateTimeService: DateTimeService, item: ScheduleItem, val selected: () -> Unit) : BaseViewModel() { val title: String = item.session.title val isServiceSession: Boolean = item.session.isServiceSession val isAttending: Boolean = item.session.rsvp.isAttending @@ -30,12 +26,7 @@ class SessionListItemViewModel( ) val observeIsInPast by observe(::isInPast) - class Factory( - private val dateTimeService: DateTimeService, - ) { - fun create( - item: ScheduleItem, - selected: () -> Unit, - ) = SessionListItemViewModel(dateTimeService, item, selected) + class Factory(private val dateTimeService: DateTimeService) { + fun create(item: ScheduleItem, selected: () -> Unit) = SessionListItemViewModel(dateTimeService, item, selected) } } diff --git a/shared-ui/src/commonMain/kotlin/co.touchlab.droidcon/viewmodel/session/SpeakerDetailViewModel.kt b/shared-ui/src/commonMain/kotlin/co.touchlab.droidcon/viewmodel/session/SpeakerDetailViewModel.kt index 75e38d07..e571ddb4 100644 --- a/shared-ui/src/commonMain/kotlin/co.touchlab.droidcon/viewmodel/session/SpeakerDetailViewModel.kt +++ b/shared-ui/src/commonMain/kotlin/co.touchlab.droidcon/viewmodel/session/SpeakerDetailViewModel.kt @@ -6,10 +6,7 @@ import co.touchlab.droidcon.dto.WebLink import co.touchlab.droidcon.service.ParseUrlViewService import org.brightify.hyperdrive.multiplatformx.BaseViewModel -class SpeakerDetailViewModel( - private val parseUrlViewService: ParseUrlViewService, - profile: Profile, -) : BaseViewModel() { +class SpeakerDetailViewModel(private val parseUrlViewService: ParseUrlViewService, profile: Profile) : BaseViewModel() { val avatarUrl = profile.profilePicture @@ -25,11 +22,7 @@ class SpeakerDetailViewModel( val bio = profile.bio val bioWebLinks: List = bio?.let(parseUrlViewService::parse) ?: emptyList() - data class Socials( - val website: Url?, - val twitter: Url?, - val linkedIn: Url?, - ) { + data class Socials(val website: Url?, val twitter: Url?, val linkedIn: Url?) { val isEmpty: Boolean = listOfNotNull( website, diff --git a/shared-ui/src/commonMain/kotlin/co.touchlab.droidcon/viewmodel/settings/AboutItemViewModel.kt b/shared-ui/src/commonMain/kotlin/co.touchlab.droidcon/viewmodel/settings/AboutItemViewModel.kt index 01bfc1ab..ede6717c 100644 --- a/shared-ui/src/commonMain/kotlin/co.touchlab.droidcon/viewmodel/settings/AboutItemViewModel.kt +++ b/shared-ui/src/commonMain/kotlin/co.touchlab.droidcon/viewmodel/settings/AboutItemViewModel.kt @@ -3,9 +3,4 @@ package co.touchlab.droidcon.viewmodel.settings import co.touchlab.droidcon.dto.WebLink import org.brightify.hyperdrive.multiplatformx.BaseViewModel -class AboutItemViewModel( - val title: String, - val detail: String, - val webLinks: List, - val icon: String, -) : BaseViewModel() +class AboutItemViewModel(val title: String, val detail: String, val webLinks: List, val icon: String) : BaseViewModel() diff --git a/shared-ui/src/commonMain/kotlin/co.touchlab.droidcon/viewmodel/settings/AboutViewModel.kt b/shared-ui/src/commonMain/kotlin/co.touchlab.droidcon/viewmodel/settings/AboutViewModel.kt index 14c092e0..0550b052 100644 --- a/shared-ui/src/commonMain/kotlin/co.touchlab.droidcon/viewmodel/settings/AboutViewModel.kt +++ b/shared-ui/src/commonMain/kotlin/co.touchlab.droidcon/viewmodel/settings/AboutViewModel.kt @@ -5,10 +5,8 @@ import co.touchlab.droidcon.application.repository.AboutRepository import co.touchlab.droidcon.service.ParseUrlViewService import org.brightify.hyperdrive.multiplatformx.BaseViewModel -class AboutViewModel( - private val aboutRepository: AboutRepository, - private val parseUrlViewService: ParseUrlViewService, -) : BaseViewModel() { +class AboutViewModel(private val aboutRepository: AboutRepository, private val parseUrlViewService: ParseUrlViewService) : + BaseViewModel() { var items: List by published(emptyList()) private set diff --git a/shared-ui/src/commonMain/kotlin/co.touchlab.droidcon/viewmodel/settings/SettingsViewModel.kt b/shared-ui/src/commonMain/kotlin/co.touchlab.droidcon/viewmodel/settings/SettingsViewModel.kt index 9e9c7a4a..cca11382 100644 --- a/shared-ui/src/commonMain/kotlin/co.touchlab.droidcon/viewmodel/settings/SettingsViewModel.kt +++ b/shared-ui/src/commonMain/kotlin/co.touchlab.droidcon/viewmodel/settings/SettingsViewModel.kt @@ -3,10 +3,7 @@ package co.touchlab.droidcon.viewmodel.settings import co.touchlab.droidcon.application.gateway.SettingsGateway import org.brightify.hyperdrive.multiplatformx.BaseViewModel -class SettingsViewModel( - settingsGateway: SettingsGateway, - private val aboutFactory: AboutViewModel.Factory, -) : BaseViewModel() { +class SettingsViewModel(settingsGateway: SettingsGateway, private val aboutFactory: AboutViewModel.Factory) : BaseViewModel() { var isFeedbackEnabled by binding( settingsGateway.settings(), @@ -46,10 +43,7 @@ class SettingsViewModel( ) val observeUseCompose by observe(::useCompose) - class Factory( - private val settingsGateway: SettingsGateway, - private val aboutFactory: AboutViewModel.Factory, - ) { + class Factory(private val settingsGateway: SettingsGateway, private val aboutFactory: AboutViewModel.Factory) { fun create() = SettingsViewModel(settingsGateway, aboutFactory) } diff --git a/shared-ui/src/commonMain/kotlin/co.touchlab.droidcon/viewmodel/sponsor/SponsorGroupItemViewModel.kt b/shared-ui/src/commonMain/kotlin/co.touchlab.droidcon/viewmodel/sponsor/SponsorGroupItemViewModel.kt index aec1adae..f5514181 100644 --- a/shared-ui/src/commonMain/kotlin/co.touchlab.droidcon/viewmodel/sponsor/SponsorGroupItemViewModel.kt +++ b/shared-ui/src/commonMain/kotlin/co.touchlab.droidcon/viewmodel/sponsor/SponsorGroupItemViewModel.kt @@ -5,10 +5,7 @@ import io.ktor.http.URLParserException import io.ktor.http.Url import org.brightify.hyperdrive.multiplatformx.BaseViewModel -class SponsorGroupItemViewModel( - private val sponsor: Sponsor, - val selected: () -> Unit, -) : BaseViewModel() { +class SponsorGroupItemViewModel(private val sponsor: Sponsor, val selected: () -> Unit) : BaseViewModel() { val name = sponsor.name val imageUrl = sponsor.icon @@ -22,7 +19,6 @@ class SponsorGroupItemViewModel( class Factory { - fun create(sponsor: Sponsor, selected: () -> Unit) = - SponsorGroupItemViewModel(sponsor, selected) + fun create(sponsor: Sponsor, selected: () -> Unit) = SponsorGroupItemViewModel(sponsor, selected) } } diff --git a/shared-ui/src/commonMain/kotlin/co.touchlab.droidcon/viewmodel/sponsor/SponsorGroupViewModel.kt b/shared-ui/src/commonMain/kotlin/co.touchlab.droidcon/viewmodel/sponsor/SponsorGroupViewModel.kt index 1ef514cc..2131db07 100644 --- a/shared-ui/src/commonMain/kotlin/co.touchlab.droidcon/viewmodel/sponsor/SponsorGroupViewModel.kt +++ b/shared-ui/src/commonMain/kotlin/co.touchlab.droidcon/viewmodel/sponsor/SponsorGroupViewModel.kt @@ -18,12 +18,8 @@ class SponsorGroupViewModel( ) val observeSponsors by observe(::sponsors) - class Factory( - private val sponsorGroupItemFactory: SponsorGroupItemViewModel.Factory, - ) { - fun create( - sponsorGroup: SponsorGroupWithSponsors, - onSponsorSelected: (Sponsor) -> Unit, - ) = SponsorGroupViewModel(sponsorGroupItemFactory, sponsorGroup, onSponsorSelected) + class Factory(private val sponsorGroupItemFactory: SponsorGroupItemViewModel.Factory) { + fun create(sponsorGroup: SponsorGroupWithSponsors, onSponsorSelected: (Sponsor) -> Unit) = + SponsorGroupViewModel(sponsorGroupItemFactory, sponsorGroup, onSponsorSelected) } } diff --git a/shared/src/androidMain/kotlin/co/touchlab/droidcon/domain/repository/impl/SqlDelightDriverFactory.android.kt b/shared/src/androidMain/kotlin/co/touchlab/droidcon/domain/repository/impl/SqlDelightDriverFactory.android.kt index 208ddbbb..036402b0 100644 --- a/shared/src/androidMain/kotlin/co/touchlab/droidcon/domain/repository/impl/SqlDelightDriverFactory.android.kt +++ b/shared/src/androidMain/kotlin/co/touchlab/droidcon/domain/repository/impl/SqlDelightDriverFactory.android.kt @@ -5,10 +5,6 @@ import app.cash.sqldelight.db.SqlDriver import app.cash.sqldelight.driver.android.AndroidSqliteDriver import co.touchlab.droidcon.db.DroidconDatabase -actual class SqlDelightDriverFactory( - private val context: Context, -) { - actual fun createDriver(): SqlDriver { - return AndroidSqliteDriver(DroidconDatabase.Schema, context, "new-droidcon2023.db") - } +actual class SqlDelightDriverFactory(private val context: Context) { + actual fun createDriver(): SqlDriver = AndroidSqliteDriver(DroidconDatabase.Schema, context, "new-droidcon2023.db") } diff --git a/shared/src/androidMain/kotlin/co/touchlab/droidcon/service/AndroidNotificationService.kt b/shared/src/androidMain/kotlin/co/touchlab/droidcon/service/AndroidNotificationService.kt index a8ea51fb..eb4ac2d1 100644 --- a/shared/src/androidMain/kotlin/co/touchlab/droidcon/service/AndroidNotificationService.kt +++ b/shared/src/androidMain/kotlin/co/touchlab/droidcon/service/AndroidNotificationService.kt @@ -96,16 +96,16 @@ class AndroidNotificationService( } val typeValue = when (notification) { - is Notification.Local.Feedback -> Notification.Values.feedbackType - is Notification.Local.Reminder -> Notification.Values.reminderType + is Notification.Local.Feedback -> Notification.Values.FEEDBACK_TYPE + is Notification.Local.Reminder -> Notification.Values.REMINDER_TYPE } val contentIntent = PendingIntent.getActivity( context, requestCode, Intent(context, entrypointActivity).apply { - putExtra(Notification.Keys.sessionId, sessionId.value) - putExtra(Notification.Keys.notificationType, typeValue) + putExtra(Notification.Keys.SESSION_ID, sessionId.value) + putExtra(Notification.Keys.NOTIFICATION_TYPE, typeValue) flags = Intent.FLAG_ACTIVITY_CLEAR_TOP }, if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { @@ -186,10 +186,10 @@ class AndroidNotificationService( } private fun Intent.parseNotification(): Notification? = - when (val typeValue = this.getStringExtra(Notification.Keys.notificationType)) { - Notification.Values.reminderType -> this.parseReminderNotification() - Notification.Values.feedbackType -> this.parseFeedbackNotification() - Notification.Values.refreshDataType -> Notification.Remote.RefreshData + when (val typeValue = this.getStringExtra(Notification.Keys.NOTIFICATION_TYPE)) { + Notification.Values.REMINDER_TYPE -> this.parseReminderNotification() + Notification.Values.FEEDBACK_TYPE -> this.parseFeedbackNotification() + Notification.Values.REFRESH_DATA_TYPE -> Notification.Remote.RefreshData // Expected on Android as this could've been just a regular app open without a notification. null -> null else -> { @@ -199,7 +199,7 @@ class AndroidNotificationService( } private fun Intent.parseReminderNotification(): Notification.Local.Reminder? { - val sessionId = this.getStringExtra(Notification.Keys.sessionId) ?: run { + val sessionId = this.getStringExtra(Notification.Keys.SESSION_ID) ?: run { log.e { "Couldn't parse reminder notification. Session ID doesn't exist or isn't String." } return null } @@ -210,7 +210,7 @@ class AndroidNotificationService( } private fun Intent.parseFeedbackNotification(): Notification.Local.Feedback? { - val sessionId = this.getStringExtra(Notification.Keys.sessionId) ?: run { + val sessionId = this.getStringExtra(Notification.Keys.SESSION_ID) ?: run { log.e { "Couldn't parse feedback notification. Session ID doesn't exist or isn't String." } return null } diff --git a/shared/src/androidMain/kotlin/co/touchlab/droidcon/service/NotificationRescheduler.kt b/shared/src/androidMain/kotlin/co/touchlab/droidcon/service/NotificationRescheduler.kt index 593cb0d5..ab6cf9f0 100644 --- a/shared/src/androidMain/kotlin/co/touchlab/droidcon/service/NotificationRescheduler.kt +++ b/shared/src/androidMain/kotlin/co/touchlab/droidcon/service/NotificationRescheduler.kt @@ -9,7 +9,9 @@ import kotlinx.coroutines.launch import org.koin.core.component.KoinComponent import org.koin.core.component.inject -class NotificationRescheduler : BroadcastReceiver(), KoinComponent { +class NotificationRescheduler : + BroadcastReceiver(), + KoinComponent { private val notificationSchedulingService by inject() override fun onReceive(context: Context?, intent: Intent?) { diff --git a/shared/src/androidMain/kotlin/co/touchlab/droidcon/util/AssetResourceReader.kt b/shared/src/androidMain/kotlin/co/touchlab/droidcon/util/AssetResourceReader.kt index 54773b47..cd4ed601 100644 --- a/shared/src/androidMain/kotlin/co/touchlab/droidcon/util/AssetResourceReader.kt +++ b/shared/src/androidMain/kotlin/co/touchlab/droidcon/util/AssetResourceReader.kt @@ -4,9 +4,7 @@ import android.content.Context import co.touchlab.droidcon.domain.service.impl.ResourceReader import java.io.InputStreamReader -class AssetResourceReader( - private val context: Context, -) : ResourceReader { +class AssetResourceReader(private val context: Context) : ResourceReader { override fun readResource(name: String): String { // TODO: Catch Android-only exceptions and map them to common ones. return context.assets.open(name).use { stream -> diff --git a/shared/src/androidMain/kotlin/co/touchlab/droidcon/util/IdentifiableIntent.kt b/shared/src/androidMain/kotlin/co/touchlab/droidcon/util/IdentifiableIntent.kt index 57dd958a..c730b6b0 100644 --- a/shared/src/androidMain/kotlin/co/touchlab/droidcon/util/IdentifiableIntent.kt +++ b/shared/src/androidMain/kotlin/co/touchlab/droidcon/util/IdentifiableIntent.kt @@ -3,11 +3,7 @@ package co.touchlab.droidcon.util import android.content.Context import android.content.Intent -class IdentifiableIntent( - private val id: String, - packageContext: Context, - cls: Class<*>, -) : Intent(packageContext, cls) { +class IdentifiableIntent(private val id: String, packageContext: Context, cls: Class<*>) : Intent(packageContext, cls) { override fun filterEquals(other: Intent?): Boolean { if (this === other) return true diff --git a/shared/src/androidMain/kotlin/co/touchlab/droidcon/util/formatter/AndroidDateFormatter.kt b/shared/src/androidMain/kotlin/co/touchlab/droidcon/util/formatter/AndroidDateFormatter.kt index 4509497a..e01a7551 100644 --- a/shared/src/androidMain/kotlin/co/touchlab/droidcon/util/formatter/AndroidDateFormatter.kt +++ b/shared/src/androidMain/kotlin/co/touchlab/droidcon/util/formatter/AndroidDateFormatter.kt @@ -18,19 +18,14 @@ class AndroidDateFormatter(private val dateTimeService: DateTimeService) : DateF private val minuteHourTimeFormat = DateFormat.getTimeInstance(DateFormat.SHORT, Locale.getDefault()) .apply { timeZone = java.util.TimeZone.getTimeZone(conferenceTimeZone.id) } - override fun monthWithDay(date: LocalDate): String { - return shortDateFormat.format( - Date(with(dateTimeService) { date.atTime(0, 0).fromConferenceDateTime() }.toEpochMilliseconds()), - ).uppercase() - } + override fun monthWithDay(date: LocalDate): String = shortDateFormat.format( + Date(with(dateTimeService) { date.atTime(0, 0).fromConferenceDateTime() }.toEpochMilliseconds()), + ).uppercase() - override fun timeOnly(dateTime: LocalDateTime): String? { - return minuteHourTimeFormat.format( - Date(with(dateTimeService) { dateTime.fromConferenceDateTime() }.toEpochMilliseconds()), - ) - } + override fun timeOnly(dateTime: LocalDateTime): String? = minuteHourTimeFormat.format( + Date(with(dateTimeService) { dateTime.fromConferenceDateTime() }.toEpochMilliseconds()), + ) - override fun timeOnlyInterval(fromDateTime: LocalDateTime, toDateTime: LocalDateTime): String { - return timeOnly(fromDateTime) + " - " + timeOnly(toDateTime) - } + override fun timeOnlyInterval(fromDateTime: LocalDateTime, toDateTime: LocalDateTime): String = + timeOnly(fromDateTime) + " - " + timeOnly(toDateTime) } diff --git a/shared/src/commonMain/kotlin/co/touchlab/droidcon/Constants.kt b/shared/src/commonMain/kotlin/co/touchlab/droidcon/Constants.kt index e09a3345..9569dcda 100644 --- a/shared/src/commonMain/kotlin/co/touchlab/droidcon/Constants.kt +++ b/shared/src/commonMain/kotlin/co/touchlab/droidcon/Constants.kt @@ -2,6 +2,7 @@ package co.touchlab.droidcon import kotlinx.datetime.TimeZone +@Suppress("ktlint:standard:property-naming") object Constants { val conferenceTimeZone = TimeZone.of("America/New_York") @@ -12,17 +13,16 @@ object Constants { val conferenceTimeZoneHash = "11ee5758034d91b8a40a4e89f6cf9324" object Firestore { - const val projectId = "droidcon-148cc" const val databaseName = "(default)" // Known variants: "sponsors", "sponsors-lisbon-2019", "sponsors-sf-2019", "sponsors-sf-2022", "sponsors-berlin-2022", "sponsors-nyc-2022" + const val collectionName = "sponsors-nyc-2024" const val apiKey = "AIzaSyCkD5DH2rUJ8aZuJzANpIFj0AVuCNik1l0" } object Sessionize { - const val scheduleId = "orzenzbc" const val sponsorsId = "orzenzbc" } diff --git a/shared/src/commonMain/kotlin/co/touchlab/droidcon/Koin.kt b/shared/src/commonMain/kotlin/co/touchlab/droidcon/Koin.kt index 9b9b92b8..18f932f0 100644 --- a/shared/src/commonMain/kotlin/co/touchlab/droidcon/Koin.kt +++ b/shared/src/commonMain/kotlin/co/touchlab/droidcon/Koin.kt @@ -67,13 +67,9 @@ fun initKoin(additionalModules: List): KoinApplication { } val intToLongAdapter = object : ColumnAdapter { - override fun decode(databaseValue: Long): Int { - return databaseValue.toInt() - } + override fun decode(databaseValue: Long): Int = databaseValue.toInt() - override fun encode(value: Int): Long { - return value.toLong() - } + override fun encode(value: Int): Long = value.toLong() } private val coreModule = module { single { @@ -237,8 +233,6 @@ private val coreModule = module { } } -internal inline fun Scope.getWith(vararg params: Any?): T { - return get(parameters = { parametersOf(*params) }) -} +internal inline fun Scope.getWith(vararg params: Any?): T = get(parameters = { parametersOf(*params) }) expect val platformModule: Module diff --git a/shared/src/commonMain/kotlin/co/touchlab/droidcon/application/composite/AboutItem.kt b/shared/src/commonMain/kotlin/co/touchlab/droidcon/application/composite/AboutItem.kt index 410d404b..0b4631ff 100644 --- a/shared/src/commonMain/kotlin/co/touchlab/droidcon/application/composite/AboutItem.kt +++ b/shared/src/commonMain/kotlin/co/touchlab/droidcon/application/composite/AboutItem.kt @@ -1,7 +1,3 @@ package co.touchlab.droidcon.application.composite -data class AboutItem( - val icon: String, - val title: String, - val detail: String, -) +data class AboutItem(val icon: String, val title: String, val detail: String) diff --git a/shared/src/commonMain/kotlin/co/touchlab/droidcon/application/composite/Settings.kt b/shared/src/commonMain/kotlin/co/touchlab/droidcon/application/composite/Settings.kt index ad851db9..4d9bdd7b 100644 --- a/shared/src/commonMain/kotlin/co/touchlab/droidcon/application/composite/Settings.kt +++ b/shared/src/commonMain/kotlin/co/touchlab/droidcon/application/composite/Settings.kt @@ -1,7 +1,3 @@ package co.touchlab.droidcon.application.composite -data class Settings( - val isFeedbackEnabled: Boolean, - val isRemindersEnabled: Boolean, - val useComposeForIos: Boolean, -) +data class Settings(val isFeedbackEnabled: Boolean, val isRemindersEnabled: Boolean, val useComposeForIos: Boolean) diff --git a/shared/src/commonMain/kotlin/co/touchlab/droidcon/application/gateway/impl/DefaultSettingsGateway.kt b/shared/src/commonMain/kotlin/co/touchlab/droidcon/application/gateway/impl/DefaultSettingsGateway.kt index 80e860ec..2bb3cca7 100644 --- a/shared/src/commonMain/kotlin/co/touchlab/droidcon/application/gateway/impl/DefaultSettingsGateway.kt +++ b/shared/src/commonMain/kotlin/co/touchlab/droidcon/application/gateway/impl/DefaultSettingsGateway.kt @@ -5,9 +5,7 @@ import co.touchlab.droidcon.application.gateway.SettingsGateway import co.touchlab.droidcon.application.repository.SettingsRepository import kotlinx.coroutines.flow.StateFlow -class DefaultSettingsGateway( - private val settingsRepository: SettingsRepository, -) : SettingsGateway { +class DefaultSettingsGateway(private val settingsRepository: SettingsRepository) : SettingsGateway { override fun settings(): StateFlow = settingsRepository.settings diff --git a/shared/src/commonMain/kotlin/co/touchlab/droidcon/application/repository/impl/DefaultAboutRepository.kt b/shared/src/commonMain/kotlin/co/touchlab/droidcon/application/repository/impl/DefaultAboutRepository.kt index 235570a8..4d85f948 100644 --- a/shared/src/commonMain/kotlin/co/touchlab/droidcon/application/repository/impl/DefaultAboutRepository.kt +++ b/shared/src/commonMain/kotlin/co/touchlab/droidcon/application/repository/impl/DefaultAboutRepository.kt @@ -4,17 +4,13 @@ import co.touchlab.droidcon.application.composite.AboutItem import co.touchlab.droidcon.application.repository.AboutRepository import co.touchlab.droidcon.domain.service.impl.json.AboutJsonResourceDataSource -class DefaultAboutRepository( - private val aboutJsonResourceDataSource: AboutJsonResourceDataSource, -) : AboutRepository { +class DefaultAboutRepository(private val aboutJsonResourceDataSource: AboutJsonResourceDataSource) : AboutRepository { - override suspend fun getAboutItems(): List { - return aboutJsonResourceDataSource.getAboutItems().map { - AboutItem( - icon = it.icon, - title = it.title, - detail = it.detail, - ) - } + override suspend fun getAboutItems(): List = aboutJsonResourceDataSource.getAboutItems().map { + AboutItem( + icon = it.icon, + title = it.title, + detail = it.detail, + ) } } diff --git a/shared/src/commonMain/kotlin/co/touchlab/droidcon/application/repository/impl/DefaultSettingsRepository.kt b/shared/src/commonMain/kotlin/co/touchlab/droidcon/application/repository/impl/DefaultSettingsRepository.kt index 29896fb8..fae75afc 100644 --- a/shared/src/commonMain/kotlin/co/touchlab/droidcon/application/repository/impl/DefaultSettingsRepository.kt +++ b/shared/src/commonMain/kotlin/co/touchlab/droidcon/application/repository/impl/DefaultSettingsRepository.kt @@ -9,9 +9,7 @@ import com.russhwolf.settings.set import kotlinx.coroutines.flow.MutableStateFlow @OptIn(ExperimentalSettingsApi::class) -class DefaultSettingsRepository( - private val observableSettings: ObservableSettings, -) : SettingsRepository { +class DefaultSettingsRepository(private val observableSettings: ObservableSettings) : SettingsRepository { private companion object { private const val SETTINGS_FEEDBACK_ENABLED_KEY = "SETTINGS_FEEDBACK_ENABLED" private const val SETTINGS_REMINDERS_ENABLED_KEY = "SETTINGS_REMINDERS_ENABLED" diff --git a/shared/src/commonMain/kotlin/co/touchlab/droidcon/application/service/Notification.kt b/shared/src/commonMain/kotlin/co/touchlab/droidcon/application/service/Notification.kt index f9cd8e3e..92e463a5 100644 --- a/shared/src/commonMain/kotlin/co/touchlab/droidcon/application/service/Notification.kt +++ b/shared/src/commonMain/kotlin/co/touchlab/droidcon/application/service/Notification.kt @@ -6,13 +6,13 @@ sealed interface Notification { sealed interface DeepLink : Notification sealed interface Local : Notification { - data class Reminder( - val sessionId: Session.Id, - ) : Local, DeepLink + data class Reminder(val sessionId: Session.Id) : + Local, + DeepLink - data class Feedback( - val sessionId: Session.Id, - ) : Local, DeepLink + data class Feedback(val sessionId: Session.Id) : + Local, + DeepLink } sealed interface Remote : Notification { @@ -20,13 +20,13 @@ sealed interface Notification { } object Keys { - const val notificationType = "notification_type" - const val sessionId = "session_id" + const val NOTIFICATION_TYPE = "notification_type" + const val SESSION_ID = "session_id" } object Values { - const val reminderType = "reminder" - const val feedbackType = "feedback" - const val refreshDataType = "refresh_data" + const val REMINDER_TYPE = "reminder" + const val FEEDBACK_TYPE = "feedback" + const val REFRESH_DATA_TYPE = "refresh_data" } } diff --git a/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/composite/ScheduleItem.kt b/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/composite/ScheduleItem.kt index dfc8ee8a..8fce0afa 100644 --- a/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/composite/ScheduleItem.kt +++ b/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/composite/ScheduleItem.kt @@ -4,9 +4,4 @@ import co.touchlab.droidcon.domain.entity.Profile import co.touchlab.droidcon.domain.entity.Room import co.touchlab.droidcon.domain.entity.Session -data class ScheduleItem( - val session: Session, - val isInConflict: Boolean, - val room: Room?, - val speakers: List, -) +data class ScheduleItem(val session: Session, val isInConflict: Boolean, val room: Room?, val speakers: List) diff --git a/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/composite/SponsorGroupWithSponsors.kt b/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/composite/SponsorGroupWithSponsors.kt index 51ef710e..0189f865 100644 --- a/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/composite/SponsorGroupWithSponsors.kt +++ b/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/composite/SponsorGroupWithSponsors.kt @@ -3,7 +3,4 @@ package co.touchlab.droidcon.domain.composite import co.touchlab.droidcon.domain.entity.Sponsor import co.touchlab.droidcon.domain.entity.SponsorGroup -data class SponsorGroupWithSponsors( - val group: SponsorGroup, - val sponsors: List, -) +data class SponsorGroupWithSponsors(val group: SponsorGroup, val sponsors: List) diff --git a/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/entity/Room.kt b/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/entity/Room.kt index d3bfa39b..7716393b 100644 --- a/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/entity/Room.kt +++ b/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/entity/Room.kt @@ -1,8 +1,5 @@ package co.touchlab.droidcon.domain.entity -class Room( - override val id: Id, - val name: String, -) : DomainEntity() { +class Room(override val id: Id, val name: String) : DomainEntity() { data class Id(val value: Long) } diff --git a/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/entity/Session.kt b/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/entity/Session.kt index 3a58a6c2..726812a0 100644 --- a/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/entity/Session.kt +++ b/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/entity/Session.kt @@ -21,16 +21,9 @@ class Session( data class Id(val value: String) - data class RSVP( - val isAttending: Boolean, - val isSent: Boolean, - ) + data class RSVP(val isAttending: Boolean, val isSent: Boolean) - data class Feedback( - val rating: Int, - val comment: String, - val isSent: Boolean, - ) { + data class Feedback(val rating: Int, val comment: String, val isSent: Boolean) { object Rating { const val DISSATISFIED = 1 const val NORMAL = 2 diff --git a/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/entity/Sponsor.kt b/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/entity/Sponsor.kt index 93ec0485..1bf0d84f 100644 --- a/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/entity/Sponsor.kt +++ b/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/entity/Sponsor.kt @@ -2,13 +2,8 @@ package co.touchlab.droidcon.domain.entity import co.touchlab.droidcon.composite.Url -class Sponsor( - override val id: Id, - val hasDetail: Boolean, - val description: String?, - val icon: Url, - val url: Url, -) : DomainEntity() { +class Sponsor(override val id: Id, val hasDetail: Boolean, val description: String?, val icon: Url, val url: Url) : + DomainEntity() { val name: String get() = id.name diff --git a/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/entity/SponsorGroup.kt b/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/entity/SponsorGroup.kt index cfc10793..6f799168 100644 --- a/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/entity/SponsorGroup.kt +++ b/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/entity/SponsorGroup.kt @@ -1,10 +1,6 @@ package co.touchlab.droidcon.domain.entity -class SponsorGroup( - override val id: Id, - val displayPriority: Int, - val isProminent: Boolean, -) : DomainEntity() { +class SponsorGroup(override val id: Id, val displayPriority: Int, val isProminent: Boolean) : DomainEntity() { val name: String get() = id.value diff --git a/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/gateway/impl/DefaultSessionGateway.kt b/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/gateway/impl/DefaultSessionGateway.kt index 382db92c..32f0b2ad 100644 --- a/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/gateway/impl/DefaultSessionGateway.kt +++ b/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/gateway/impl/DefaultSessionGateway.kt @@ -17,35 +17,28 @@ class DefaultSessionGateway( private val scheduleService: ScheduleService, ) : SessionGateway { - override fun observeSchedule(): Flow> { - return sessionRepository.observeAll().map { sessions -> - sessions.map { session -> - scheduleItemForSession(session) - } + override fun observeSchedule(): Flow> = sessionRepository.observeAll().map { sessions -> + sessions.map { session -> + scheduleItemForSession(session) } } - override fun observeAgenda(): Flow> { - return sessionRepository.observeAllAttending().map { sessions -> - sessions.map { session -> - scheduleItemForSession(session) - } + override fun observeAgenda(): Flow> = sessionRepository.observeAllAttending().map { sessions -> + sessions.map { session -> + scheduleItemForSession(session) } } - override fun observeScheduleItem(id: Session.Id): Flow { - return sessionRepository.observe(id).map { session -> - scheduleItemForSession(session) - } + override fun observeScheduleItem(id: Session.Id): Flow = sessionRepository.observe(id).map { session -> + scheduleItemForSession(session) } - private suspend fun scheduleItemForSession(session: Session): ScheduleItem = - ScheduleItem( - session, - scheduleService.isInConflict(session), - session.room?.let { roomRepository.find(it) }, - profileRepository.getSpeakersBySession(session.id), - ) + private suspend fun scheduleItemForSession(session: Session): ScheduleItem = ScheduleItem( + session, + scheduleService.isInConflict(session), + session.room?.let { roomRepository.find(it) }, + profileRepository.getSpeakersBySession(session.id), + ) override suspend fun setAttending(session: Session, attending: Boolean) { sessionRepository.setRsvp(session.id, Session.RSVP(attending, false)) @@ -55,7 +48,5 @@ class DefaultSessionGateway( sessionRepository.setFeedback(session.id, feedback) } - override suspend fun getScheduleItem(id: Session.Id): ScheduleItem? { - return sessionRepository.find(id)?.let { scheduleItemForSession(it) } - } + override suspend fun getScheduleItem(id: Session.Id): ScheduleItem? = sessionRepository.find(id)?.let { scheduleItemForSession(it) } } diff --git a/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/gateway/impl/DefaultSponsorGateway.kt b/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/gateway/impl/DefaultSponsorGateway.kt index ccfe8992..6aeeb281 100644 --- a/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/gateway/impl/DefaultSponsorGateway.kt +++ b/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/gateway/impl/DefaultSponsorGateway.kt @@ -16,19 +16,16 @@ class DefaultSponsorGateway( private val profileRepository: ProfileRepository, ) : SponsorGateway { - override fun observeSponsors(): Flow> = - sponsorGroupRepository.observeAll().map { groups -> - groups.map { group -> - SponsorGroupWithSponsors( - group, - sponsorRepository.allByGroupName(group.name), - ) - } + override fun observeSponsors(): Flow> = sponsorGroupRepository.observeAll().map { groups -> + groups.map { group -> + SponsorGroupWithSponsors( + group, + sponsorRepository.allByGroupName(group.name), + ) } + } - override fun observeSponsorById(id: Sponsor.Id): Flow = - sponsorRepository.observe(id) + override fun observeSponsorById(id: Sponsor.Id): Flow = sponsorRepository.observe(id) - override suspend fun getRepresentatives(sponsorId: Sponsor.Id): List = - profileRepository.getSponsorRepresentatives(sponsorId) + override suspend fun getRepresentatives(sponsorId: Sponsor.Id): List = profileRepository.getSponsorRepresentatives(sponsorId) } diff --git a/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/repository/impl/BaseRepository.kt b/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/repository/impl/BaseRepository.kt index 2790bd41..4c76ae71 100644 --- a/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/repository/impl/BaseRepository.kt +++ b/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/repository/impl/BaseRepository.kt @@ -6,21 +6,13 @@ import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.first abstract class BaseRepository> : Repository { - override suspend fun get(id: ID): ENTITY { - return observe(id).first() - } + override suspend fun get(id: ID): ENTITY = observe(id).first() - override suspend fun find(id: ID): ENTITY? { - return observeOrNull(id).first() - } + override suspend fun find(id: ID): ENTITY? = observeOrNull(id).first() - override fun observe(entity: ENTITY): Flow { - return observe(entity.id) - } + override fun observe(entity: ENTITY): Flow = observe(entity.id) - override suspend fun all(): List { - return observeAll().first() - } + override suspend fun all(): List = observeAll().first() override fun add(entity: ENTITY) { if (!contains(entity.id)) { diff --git a/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/repository/impl/SqlDelightProfileRepository.kt b/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/repository/impl/SqlDelightProfileRepository.kt index 24d35df8..3077042a 100644 --- a/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/repository/impl/SqlDelightProfileRepository.kt +++ b/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/repository/impl/SqlDelightProfileRepository.kt @@ -19,11 +19,11 @@ class SqlDelightProfileRepository( private val profileQueries: ProfileQueries, private val speakerQueries: SessionSpeakerQueries, private val representativeQueries: SponsorRepresentativeQueries, -) : BaseRepository(), ProfileRepository { +) : BaseRepository(), + ProfileRepository { - override suspend fun getSpeakersBySession(id: Session.Id): List { - return profileQueries.selectBySession(id.value, ::profileFactory).executeAsList() - } + override suspend fun getSpeakersBySession(id: Session.Id): List = + profileQueries.selectBySession(id.value, ::profileFactory).executeAsList() override fun setSessionSpeakers(session: Session, speakers: List) { speakerQueries.deleteBySessionId(session.id.value) @@ -48,26 +48,19 @@ class SqlDelightProfileRepository( } } - override suspend fun getSponsorRepresentatives(sponsorId: Sponsor.Id): List { - return profileQueries.selectBySponsor(sponsorName = sponsorId.name, sponsorGroupName = sponsorId.group, mapper = ::profileFactory) + override suspend fun getSponsorRepresentatives(sponsorId: Sponsor.Id): List = + profileQueries.selectBySponsor(sponsorName = sponsorId.name, sponsorGroupName = sponsorId.group, mapper = ::profileFactory) .executeAsList() - } - override fun allSync(): List { - return profileQueries.selectAll(mapper = ::profileFactory).executeAsList() - } + override fun allSync(): List = profileQueries.selectAll(mapper = ::profileFactory).executeAsList() - override fun observe(id: Profile.Id): Flow { - return profileQueries.selectById(id.value, ::profileFactory).asFlow().mapToOne(Dispatchers.Main) - } + override fun observe(id: Profile.Id): Flow = + profileQueries.selectById(id.value, ::profileFactory).asFlow().mapToOne(Dispatchers.Main) - override fun observeOrNull(id: Profile.Id): Flow { - return profileQueries.selectById(id.value, ::profileFactory).asFlow().mapToOneOrNull(Dispatchers.Main) - } + override fun observeOrNull(id: Profile.Id): Flow = + profileQueries.selectById(id.value, ::profileFactory).asFlow().mapToOneOrNull(Dispatchers.Main) - override fun observeAll(): Flow> { - return profileQueries.selectAll(::profileFactory).asFlow().mapToList(Dispatchers.Main) - } + override fun observeAll(): Flow> = profileQueries.selectAll(::profileFactory).asFlow().mapToList(Dispatchers.Main) override fun doUpsert(entity: Profile) { profileQueries.upsert( @@ -86,9 +79,7 @@ class SqlDelightProfileRepository( profileQueries.delete(id.value) } - override fun contains(id: Profile.Id): Boolean { - return profileQueries.existsById(id.value).executeAsOne().toBoolean() - } + override fun contains(id: Profile.Id): Boolean = profileQueries.existsById(id.value).executeAsOne().toBoolean() private fun profileFactory( id: String, diff --git a/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/repository/impl/SqlDelightRoomRepository.kt b/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/repository/impl/SqlDelightRoomRepository.kt index 2c581a2a..271ef264 100644 --- a/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/repository/impl/SqlDelightRoomRepository.kt +++ b/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/repository/impl/SqlDelightRoomRepository.kt @@ -10,23 +10,18 @@ import co.touchlab.droidcon.domain.repository.RoomRepository import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.flow.Flow -class SqlDelightRoomRepository( - private val roomQueries: RoomQueries, -) : BaseRepository(), RoomRepository { +class SqlDelightRoomRepository(private val roomQueries: RoomQueries) : + BaseRepository(), + RoomRepository { override fun allSync(): List = roomQueries.selectAll(::roomFactory).executeAsList() - override fun observe(id: Room.Id): Flow { - return roomQueries.selectById(id.value, ::roomFactory).asFlow().mapToOne(Dispatchers.Main) - } + override fun observe(id: Room.Id): Flow = roomQueries.selectById(id.value, ::roomFactory).asFlow().mapToOne(Dispatchers.Main) - override fun observeOrNull(id: Room.Id): Flow { - return roomQueries.selectById(id.value, ::roomFactory).asFlow().mapToOneOrNull(Dispatchers.Main) - } + override fun observeOrNull(id: Room.Id): Flow = + roomQueries.selectById(id.value, ::roomFactory).asFlow().mapToOneOrNull(Dispatchers.Main) - override fun observeAll(): Flow> { - return roomQueries.selectAll(::roomFactory).asFlow().mapToList(Dispatchers.Main) - } + override fun observeAll(): Flow> = roomQueries.selectAll(::roomFactory).asFlow().mapToList(Dispatchers.Main) override fun doUpsert(entity: Room) { roomQueries.upsert(id = entity.id.value, name = entity.name) @@ -36,9 +31,7 @@ class SqlDelightRoomRepository( roomQueries.deleteById(id.value) } - override fun contains(id: Room.Id): Boolean { - return roomQueries.existsById(id.value).executeAsOne() != 0L - } + override fun contains(id: Room.Id): Boolean = roomQueries.existsById(id.value).executeAsOne() != 0L private fun roomFactory(id: Long, name: String) = Room(id = Room.Id(id), name = name) } diff --git a/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/repository/impl/SqlDelightSessionRepository.kt b/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/repository/impl/SqlDelightSessionRepository.kt index 3f37a837..24d5857b 100644 --- a/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/repository/impl/SqlDelightSessionRepository.kt +++ b/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/repository/impl/SqlDelightSessionRepository.kt @@ -14,27 +14,21 @@ import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.first import kotlinx.datetime.Instant -class SqlDelightSessionRepository( - private val dateTimeService: DateTimeService, - private val sessionQueries: SessionQueries, -) : BaseRepository(), SessionRepository { - override fun observe(id: Session.Id): Flow { - return sessionQueries.sessionById(id.value, ::sessionFactory).asFlow().mapToOne(Dispatchers.Main) - } +class SqlDelightSessionRepository(private val dateTimeService: DateTimeService, private val sessionQueries: SessionQueries) : + BaseRepository(), + SessionRepository { + override fun observe(id: Session.Id): Flow = + sessionQueries.sessionById(id.value, ::sessionFactory).asFlow().mapToOne(Dispatchers.Main) fun sessionById(id: Session.Id): Session? = sessionQueries.sessionById(id.value, ::sessionFactory).executeAsOneOrNull() - override fun observeOrNull(id: Session.Id): Flow { - return sessionQueries.sessionById(id.value, ::sessionFactory).asFlow().mapToOneOrNull(Dispatchers.Main) - } + override fun observeOrNull(id: Session.Id): Flow = + sessionQueries.sessionById(id.value, ::sessionFactory).asFlow().mapToOneOrNull(Dispatchers.Main) - override fun observeAllAttending(): Flow> { - return sessionQueries.attendingSessions(::sessionFactory).asFlow().mapToList(Dispatchers.Main) - } + override fun observeAllAttending(): Flow> = + sessionQueries.attendingSessions(::sessionFactory).asFlow().mapToList(Dispatchers.Main) - override suspend fun allAttending(): List { - return observeAllAttending().first() - } + override suspend fun allAttending(): List = observeAllAttending().first() override suspend fun setRsvp(sessionId: Session.Id, rsvp: Session.RSVP) { sessionQueries.updateRsvp(rsvp.isAttending.toLong(), sessionId.value) @@ -56,9 +50,7 @@ class SqlDelightSessionRepository( override fun findSync(id: Session.Id): Session? = sessionQueries.sessionById(id.value, mapper = ::sessionFactory).executeAsOneOrNull() - override fun observeAll(): Flow> { - return sessionQueries.allSessions(::sessionFactory).asFlow().mapToList(Dispatchers.Main) - } + override fun observeAll(): Flow> = sessionQueries.allSessions(::sessionFactory).asFlow().mapToList(Dispatchers.Main) override fun doUpsert(entity: Session) { sessionQueries.upsert( @@ -77,13 +69,9 @@ class SqlDelightSessionRepository( ) } - override fun doDelete(id: Session.Id) { - return sessionQueries.deleteById(id.value) - } + override fun doDelete(id: Session.Id) = sessionQueries.deleteById(id.value) - override fun contains(id: Session.Id): Boolean { - return sessionQueries.existsById(id.value).executeAsOne().toBoolean() - } + override fun contains(id: Session.Id): Boolean = sessionQueries.existsById(id.value).executeAsOne().toBoolean() private fun sessionFactory( id: String, diff --git a/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/repository/impl/SqlDelightSponsorGroupRepository.kt b/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/repository/impl/SqlDelightSponsorGroupRepository.kt index 6b310860..145bb588 100644 --- a/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/repository/impl/SqlDelightSponsorGroupRepository.kt +++ b/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/repository/impl/SqlDelightSponsorGroupRepository.kt @@ -10,27 +10,22 @@ import co.touchlab.droidcon.domain.repository.SponsorGroupRepository import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.flow.Flow -class SqlDelightSponsorGroupRepository( - private val sponsorGroupQueries: SponsorGroupQueries, -) : BaseRepository(), SponsorGroupRepository { +class SqlDelightSponsorGroupRepository(private val sponsorGroupQueries: SponsorGroupQueries) : + BaseRepository(), + SponsorGroupRepository { override fun allSync(): List = sponsorGroupQueries.selectAll(::sponsorGroupFactory).executeAsList() - override fun observe(id: SponsorGroup.Id): Flow { - return sponsorGroupQueries.sponsorGroupByName(id.value, ::sponsorGroupFactory).asFlow().mapToOne(Dispatchers.Main) - } + override fun observe(id: SponsorGroup.Id): Flow = + sponsorGroupQueries.sponsorGroupByName(id.value, ::sponsorGroupFactory).asFlow().mapToOne(Dispatchers.Main) - override fun observeOrNull(id: SponsorGroup.Id): Flow { - return sponsorGroupQueries.sponsorGroupByName(id.value, ::sponsorGroupFactory).asFlow().mapToOneOrNull(Dispatchers.Main) - } + override fun observeOrNull(id: SponsorGroup.Id): Flow = + sponsorGroupQueries.sponsorGroupByName(id.value, ::sponsorGroupFactory).asFlow().mapToOneOrNull(Dispatchers.Main) - override fun observeAll(): Flow> { - return sponsorGroupQueries.selectAll(::sponsorGroupFactory).asFlow().mapToList(Dispatchers.Main) - } + override fun observeAll(): Flow> = + sponsorGroupQueries.selectAll(::sponsorGroupFactory).asFlow().mapToList(Dispatchers.Main) - override fun contains(id: SponsorGroup.Id): Boolean { - return sponsorGroupQueries.existsByName(id.value).executeAsOne().toBoolean() - } + override fun contains(id: SponsorGroup.Id): Boolean = sponsorGroupQueries.existsByName(id.value).executeAsOne().toBoolean() override fun doUpsert(entity: SponsorGroup) { sponsorGroupQueries.upsert( @@ -44,11 +39,7 @@ class SqlDelightSponsorGroupRepository( sponsorGroupQueries.deleteByName(id.value) } - private fun sponsorGroupFactory( - name: String, - displayPriority: Int, - isProminent: Boolean, - ) = SponsorGroup( + private fun sponsorGroupFactory(name: String, displayPriority: Int, isProminent: Boolean) = SponsorGroup( id = SponsorGroup.Id(name), displayPriority = displayPriority, isProminent = isProminent, diff --git a/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/repository/impl/SqlDelightSponsorRepository.kt b/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/repository/impl/SqlDelightSponsorRepository.kt index 5f798697..9d95d8c1 100644 --- a/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/repository/impl/SqlDelightSponsorRepository.kt +++ b/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/repository/impl/SqlDelightSponsorRepository.kt @@ -11,29 +11,22 @@ import co.touchlab.droidcon.domain.repository.SponsorRepository import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.flow.Flow -class SqlDelightSponsorRepository( - private val sponsorQueries: SponsorQueries, -) : BaseRepository(), SponsorRepository { +class SqlDelightSponsorRepository(private val sponsorQueries: SponsorQueries) : + BaseRepository(), + SponsorRepository { - override fun observe(id: Sponsor.Id): Flow { - return sponsorQueries.sponsorById(id.name, id.group, ::sponsorFactory).asFlow().mapToOne(Dispatchers.Main) - } + override fun observe(id: Sponsor.Id): Flow = + sponsorQueries.sponsorById(id.name, id.group, ::sponsorFactory).asFlow().mapToOne(Dispatchers.Main) - override fun observeOrNull(id: Sponsor.Id): Flow { - return sponsorQueries.sponsorById(id.name, id.group, ::sponsorFactory).asFlow().mapToOneOrNull(Dispatchers.Main) - } + override fun observeOrNull(id: Sponsor.Id): Flow = + sponsorQueries.sponsorById(id.name, id.group, ::sponsorFactory).asFlow().mapToOneOrNull(Dispatchers.Main) - override fun observeAll(): Flow> { - return sponsorQueries.selectAll(::sponsorFactory).asFlow().mapToList(Dispatchers.Main) - } + override fun observeAll(): Flow> = sponsorQueries.selectAll(::sponsorFactory).asFlow().mapToList(Dispatchers.Main) - override fun contains(id: Sponsor.Id): Boolean { - return sponsorQueries.existsById(id.name, id.group).executeAsOne().toBoolean() - } + override fun contains(id: Sponsor.Id): Boolean = sponsorQueries.existsById(id.name, id.group).executeAsOne().toBoolean() - override suspend fun allByGroupName(group: String): List { - return sponsorQueries.sponsorsByGroup(group, ::sponsorFactory).executeAsList() - } + override suspend fun allByGroupName(group: String): List = + sponsorQueries.sponsorsByGroup(group, ::sponsorFactory).executeAsList() override fun allSync(): List = sponsorQueries.selectAll(::sponsorFactory).executeAsList() @@ -52,18 +45,12 @@ class SqlDelightSponsorRepository( sponsorQueries.deleteById(id.name, id.group) } - private fun sponsorFactory( - name: String, - groupName: String, - hasDetail: Boolean, - description: String?, - iconUrl: String, - url: String, - ) = Sponsor( - id = Sponsor.Id(name, groupName), - hasDetail = hasDetail, - description = description, - icon = Url(iconUrl), - url = Url(url), - ) + private fun sponsorFactory(name: String, groupName: String, hasDetail: Boolean, description: String?, iconUrl: String, url: String) = + Sponsor( + id = Sponsor.Id(name, groupName), + hasDetail = hasDetail, + description = description, + icon = Url(iconUrl), + url = Url(url), + ) } diff --git a/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/service/impl/DefaultApiDataSource.kt b/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/service/impl/DefaultApiDataSource.kt index 1197e3be..20c269b1 100644 --- a/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/service/impl/DefaultApiDataSource.kt +++ b/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/service/impl/DefaultApiDataSource.kt @@ -14,10 +14,7 @@ import io.ktor.http.takeFrom import kotlinx.serialization.builtins.ListSerializer import kotlinx.serialization.json.Json -class DefaultApiDataSource( - private val client: HttpClient, - private val json: Json, -) : DefaultSyncService.DataSource { +class DefaultApiDataSource(private val client: HttpClient, private val json: Json) : DefaultSyncService.DataSource { override suspend fun getSpeakers(): List { val jsonString = client.get { // We want to use the `sponsorsId` to get "speakers" for the sponsors as well as speakers for real sessions. diff --git a/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/service/impl/DefaultDateTimeService.kt b/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/service/impl/DefaultDateTimeService.kt index 5575bd9e..52e05fd2 100644 --- a/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/service/impl/DefaultDateTimeService.kt +++ b/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/service/impl/DefaultDateTimeService.kt @@ -8,20 +8,13 @@ import kotlinx.datetime.TimeZone import kotlinx.datetime.toInstant import kotlinx.datetime.toLocalDateTime -class DefaultDateTimeService( - private val clock: Clock, - private val conferenceTimeZone: TimeZone, -) : DateTimeService { +class DefaultDateTimeService(private val clock: Clock, private val conferenceTimeZone: TimeZone) : DateTimeService { override fun now(): Instant = clock.now() override fun conferenceNow(): LocalDateTime = now().toConferenceDateTime() - override fun Instant.toConferenceDateTime(): LocalDateTime { - return toLocalDateTime(conferenceTimeZone) - } + override fun Instant.toConferenceDateTime(): LocalDateTime = toLocalDateTime(conferenceTimeZone) - override fun LocalDateTime.fromConferenceDateTime(): Instant { - return toInstant(conferenceTimeZone) - } + override fun LocalDateTime.fromConferenceDateTime(): Instant = toInstant(conferenceTimeZone) } diff --git a/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/service/impl/DefaultFeedbackService.kt b/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/service/impl/DefaultFeedbackService.kt index 14d280bc..e9e169a5 100644 --- a/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/service/impl/DefaultFeedbackService.kt +++ b/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/service/impl/DefaultFeedbackService.kt @@ -26,11 +26,9 @@ class DefaultFeedbackService( json.decodeFromString(it) } ?: emptySet() - override suspend fun next(): Session? { - return sessionGateway.observeAgenda().first() - .firstOrNull { it.session.endsAt < clock.now() && !completedSessionIds.contains(it.session.id.value) } - ?.session - } + override suspend fun next(): Session? = sessionGateway.observeAgenda().first() + .firstOrNull { it.session.endsAt < clock.now() && !completedSessionIds.contains(it.session.id.value) } + ?.session override suspend fun submit(session: Session, feedback: Session.Feedback) { sessionGateway.setFeedback(session, feedback) diff --git a/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/service/impl/DefaultScheduleService.kt b/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/service/impl/DefaultScheduleService.kt index 2e468e1f..a9812839 100644 --- a/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/service/impl/DefaultScheduleService.kt +++ b/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/service/impl/DefaultScheduleService.kt @@ -5,9 +5,7 @@ import co.touchlab.droidcon.domain.repository.SessionRepository import co.touchlab.droidcon.domain.service.ScheduleService import kotlinx.datetime.Instant -class DefaultScheduleService( - private val sessionRepository: SessionRepository, -) : ScheduleService { +class DefaultScheduleService(private val sessionRepository: SessionRepository) : ScheduleService { override suspend fun isInConflict(session: Session): Boolean { if (!session.rsvp.isAttending) { @@ -19,8 +17,7 @@ class DefaultScheduleService( } } - private fun ClosedRange.intersects(otherRange: ClosedRange): Boolean { - return start.epochSeconds < otherRange.endInclusive.epochSeconds && + private fun ClosedRange.intersects(otherRange: ClosedRange): Boolean = + start.epochSeconds < otherRange.endInclusive.epochSeconds && endInclusive.epochSeconds > otherRange.start.epochSeconds - } } diff --git a/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/service/impl/DefaultServerApi.kt b/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/service/impl/DefaultServerApi.kt index 467e36be..116d4712 100644 --- a/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/service/impl/DefaultServerApi.kt +++ b/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/service/impl/DefaultServerApi.kt @@ -13,11 +13,7 @@ import io.ktor.http.isSuccess import io.ktor.http.takeFrom import kotlinx.serialization.json.Json -class DefaultServerApi( - private val userIdProvider: UserIdProvider, - private val client: HttpClient, - private val json: Json, -) : ServerApi { +class DefaultServerApi(private val userIdProvider: UserIdProvider, private val client: HttpClient, private val json: Json) : ServerApi { override suspend fun setRsvp(sessionId: Session.Id, isAttending: Boolean): Boolean { val methodName = if (isAttending) { "sessionizeRsvpEvent" @@ -31,16 +27,14 @@ class DefaultServerApi( }.status.isSuccess() } - override suspend fun setFeedback(sessionId: Session.Id, rating: Int, comment: String): Boolean { - return client.submitForm( - formParameters = Parameters.build { - append("rating", rating.toString()) - append("comment", comment) - }, - ) { - droidcon("/dataTest/sessionizeFeedbackEvent/${sessionId.value}/${userIdProvider.getId()}") - }.status.isSuccess() - } + override suspend fun setFeedback(sessionId: Session.Id, rating: Int, comment: String): Boolean = client.submitForm( + formParameters = Parameters.build { + append("rating", rating.toString()) + append("comment", comment) + }, + ) { + droidcon("/dataTest/sessionizeFeedbackEvent/${sessionId.value}/${userIdProvider.getId()}") + }.status.isSuccess() private fun HttpRequestBuilder.droidcon(path: String) { url { diff --git a/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/service/impl/DefaultSyncService.kt b/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/service/impl/DefaultSyncService.kt index 8fd4f65f..2ecd5d1e 100644 --- a/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/service/impl/DefaultSyncService.kt +++ b/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/service/impl/DefaultSyncService.kt @@ -168,14 +168,12 @@ class DefaultSyncService( } } - override suspend fun forceSynchronize(): Boolean { - return try { - runApiDataSourcesSynchronization() - true - } catch (e: Exception) { - log.e(e) { "Failed to update repositories from API data source." } - false - } + override suspend fun forceSynchronize(): Boolean = try { + runApiDataSourcesSynchronization() + true + } catch (e: Exception) { + log.e(e) { "Failed to update repositories from API data source." } + false } private suspend fun seedLocalRepositoriesIfNeeded() { @@ -356,7 +354,8 @@ class DefaultSyncService( interface DataSource { enum class Kind { - Seed, Api + Seed, + Api, } suspend fun getSpeakers(): List diff --git a/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/service/impl/DefaultUserIdProvider.kt b/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/service/impl/DefaultUserIdProvider.kt index 53959911..570341a9 100644 --- a/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/service/impl/DefaultUserIdProvider.kt +++ b/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/service/impl/DefaultUserIdProvider.kt @@ -8,9 +8,7 @@ import com.russhwolf.settings.get import com.russhwolf.settings.set @OptIn(ExperimentalSettingsApi::class) -class DefaultUserIdProvider( - private val observableSettings: ObservableSettings, -) : UserIdProvider { +class DefaultUserIdProvider(private val observableSettings: ObservableSettings) : UserIdProvider { companion object { const val USER_ID_KEY = "USER_ID_KEY" } diff --git a/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/service/impl/dto/AboutDto.kt b/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/service/impl/dto/AboutDto.kt index 5326ab82..c69ae7b7 100644 --- a/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/service/impl/dto/AboutDto.kt +++ b/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/service/impl/dto/AboutDto.kt @@ -5,9 +5,5 @@ import kotlinx.serialization.Serializable object AboutDto { @Serializable - data class AboutItemDto( - val icon: String, - val title: String, - val detail: String, - ) + data class AboutItemDto(val icon: String, val title: String, val detail: String) } diff --git a/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/service/impl/dto/ScheduleDto.kt b/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/service/impl/dto/ScheduleDto.kt index ae4de1ff..e3d264c1 100644 --- a/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/service/impl/dto/ScheduleDto.kt +++ b/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/service/impl/dto/ScheduleDto.kt @@ -7,17 +7,10 @@ import kotlinx.serialization.json.JsonArray object ScheduleDto { @Serializable - data class DayDto( - val date: String, - val rooms: List, - ) + data class DayDto(val date: String, val rooms: List) @Serializable - data class RoomDto( - val id: Long, - val name: String, - val sessions: List, - ) + data class RoomDto(val id: Long, val name: String, val sessions: List) @Serializable data class SessionDto( @@ -39,10 +32,7 @@ object ScheduleDto { ) @Serializable - data class SpeakerDto( - val id: String, - val name: String, - ) + data class SpeakerDto(val id: String, val name: String) fun List.sessions(): List = flatMap { day -> day.rooms.flatMap { room -> diff --git a/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/service/impl/dto/SpeakersDto.kt b/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/service/impl/dto/SpeakersDto.kt index 4ae7f4f2..741eda48 100644 --- a/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/service/impl/dto/SpeakersDto.kt +++ b/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/service/impl/dto/SpeakersDto.kt @@ -28,11 +28,7 @@ object SpeakersDto { ) @Serializable - data class LinkDto( - val title: String, - val url: String, - val linkType: LinkType, - ) + data class LinkDto(val title: String, val url: String, val linkType: LinkType) @Serializable(with = LinkType.Companion::class) data class LinkType(val value: String) { @@ -67,8 +63,5 @@ object SpeakersDto { } @Serializable - data class SessionDto( - val id: Long, - val name: String, - ) + data class SessionDto(val id: Long, val name: String) } diff --git a/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/service/impl/dto/SponsorSessionsDto.kt b/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/service/impl/dto/SponsorSessionsDto.kt index d48b88c9..06abfbc4 100644 --- a/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/service/impl/dto/SponsorSessionsDto.kt +++ b/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/service/impl/dto/SponsorSessionsDto.kt @@ -5,21 +5,11 @@ import kotlinx.serialization.Serializable object SponsorSessionsDto { @Serializable - data class SessionGroupDto( - val sessions: List, - ) + data class SessionGroupDto(val sessions: List) @Serializable - data class SessionDto( - val id: String, - val title: String, - val description: String?, - val speakers: List, - ) + data class SessionDto(val id: String, val title: String, val description: String?, val speakers: List) @Serializable - data class SpeakerReferenceDto( - val id: String, - val name: String, - ) + data class SpeakerReferenceDto(val id: String, val name: String) } diff --git a/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/service/impl/dto/SponsorsDto.kt b/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/service/impl/dto/SponsorsDto.kt index 40c4e136..a48ba488 100644 --- a/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/service/impl/dto/SponsorsDto.kt +++ b/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/service/impl/dto/SponsorsDto.kt @@ -12,60 +12,32 @@ object SponsorsDto { ) @Serializable - data class SponsorGroupDto( - val name: String, - val fields: DocumentFields, - val createTime: String, - val updateTime: String, - ) + data class SponsorGroupDto(val name: String, val fields: DocumentFields, val createTime: String, val updateTime: String) @Serializable - data class DocumentFields( - val displayOrder: DisplayOrder, - val sponsors: Sponsors, - val prominent: BooleanValue? = null, - ) + data class DocumentFields(val displayOrder: DisplayOrder, val sponsors: Sponsors, val prominent: BooleanValue? = null) @Serializable - data class DisplayOrder( - val integerValue: String, - ) + data class DisplayOrder(val integerValue: String) @Serializable - data class Sponsors( - val arrayValue: ArrayValue, - ) + data class Sponsors(val arrayValue: ArrayValue) @Serializable - data class ArrayValue( - val values: List, - ) + data class ArrayValue(val values: List) @Serializable - data class Value( - val mapValue: MapValue, - ) + data class Value(val mapValue: MapValue) @Serializable - data class MapValue( - val fields: MapValueFields, - ) + data class MapValue(val fields: MapValueFields) @Serializable - data class MapValueFields( - val sponsorId: StringValue? = null, - val name: StringValue, - val icon: StringValue, - val url: StringValue, - ) + data class MapValueFields(val sponsorId: StringValue? = null, val name: StringValue, val icon: StringValue, val url: StringValue) @Serializable - data class StringValue( - val stringValue: String, - ) + data class StringValue(val stringValue: String) @Serializable - data class BooleanValue( - val booleanValue: Boolean, - ) + data class BooleanValue(val booleanValue: Boolean) } diff --git a/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/service/impl/json/AboutJsonResourceDataSource.kt b/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/service/impl/json/AboutJsonResourceDataSource.kt index 7d9e7419..140e090f 100644 --- a/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/service/impl/json/AboutJsonResourceDataSource.kt +++ b/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/service/impl/json/AboutJsonResourceDataSource.kt @@ -5,7 +5,6 @@ import kotlinx.serialization.builtins.ListSerializer class AboutJsonResourceDataSource(private val jsonResourceReader: JsonResourceReader) { - fun getAboutItems(): List { - return jsonResourceReader.readAndDecodeResource("about.json", ListSerializer(AboutDto.AboutItemDto.serializer())) - } + fun getAboutItems(): List = + jsonResourceReader.readAndDecodeResource("about.json", ListSerializer(AboutDto.AboutItemDto.serializer())) } diff --git a/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/service/impl/json/JsonResourceReader.kt b/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/service/impl/json/JsonResourceReader.kt index adba7ad6..dab005b6 100644 --- a/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/service/impl/json/JsonResourceReader.kt +++ b/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/service/impl/json/JsonResourceReader.kt @@ -4,10 +4,7 @@ import co.touchlab.droidcon.domain.service.impl.ResourceReader import kotlinx.serialization.DeserializationStrategy import kotlinx.serialization.json.Json -class JsonResourceReader( - private val resourceReader: ResourceReader, - private val json: Json, -) { +class JsonResourceReader(private val resourceReader: ResourceReader, private val json: Json) { internal fun readAndDecodeResource(name: String, strategy: DeserializationStrategy): T { val text = resourceReader.readResource(name) return json.decodeFromString(strategy, text) diff --git a/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/service/impl/json/JsonSeedResourceDataSource.kt b/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/service/impl/json/JsonSeedResourceDataSource.kt index c78e3b83..9ceee8e3 100644 --- a/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/service/impl/json/JsonSeedResourceDataSource.kt +++ b/shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/service/impl/json/JsonSeedResourceDataSource.kt @@ -7,29 +7,21 @@ import co.touchlab.droidcon.domain.service.impl.dto.SponsorSessionsDto import co.touchlab.droidcon.domain.service.impl.dto.SponsorsDto import kotlinx.serialization.builtins.ListSerializer -class JsonSeedResourceDataSource( - private val jsonResourceReader: JsonResourceReader, -) : DefaultSyncService.DataSource { +class JsonSeedResourceDataSource(private val jsonResourceReader: JsonResourceReader) : DefaultSyncService.DataSource { - override suspend fun getSpeakers(): List { - return jsonResourceReader.readAndDecodeResource("speakers.json", ListSerializer(SpeakersDto.SpeakerDto.serializer())) - } + override suspend fun getSpeakers(): List = + jsonResourceReader.readAndDecodeResource("speakers.json", ListSerializer(SpeakersDto.SpeakerDto.serializer())) - override suspend fun getSchedule(): List { - return jsonResourceReader.readAndDecodeResource("schedule.json", ListSerializer(ScheduleDto.DayDto.serializer())) - } + override suspend fun getSchedule(): List = + jsonResourceReader.readAndDecodeResource("schedule.json", ListSerializer(ScheduleDto.DayDto.serializer())) - override suspend fun getSponsorSessions(): List { - return jsonResourceReader.readAndDecodeResource( - "sponsor_sessions.json", - ListSerializer(SponsorSessionsDto.SessionGroupDto.serializer()), - ) - } + override suspend fun getSponsorSessions(): List = jsonResourceReader.readAndDecodeResource( + "sponsor_sessions.json", + ListSerializer(SponsorSessionsDto.SessionGroupDto.serializer()), + ) - override suspend fun getSponsors(): SponsorsDto.SponsorCollectionDto { - return jsonResourceReader.readAndDecodeResource( - "sponsors.json", - SponsorsDto.SponsorCollectionDto.serializer(), - ) - } + override suspend fun getSponsors(): SponsorsDto.SponsorCollectionDto = jsonResourceReader.readAndDecodeResource( + "sponsors.json", + SponsorsDto.SponsorCollectionDto.serializer(), + ) } diff --git a/shared/src/commonMain/kotlin/co/touchlab/droidcon/dto/WebLink.kt b/shared/src/commonMain/kotlin/co/touchlab/droidcon/dto/WebLink.kt index 4e73642a..08eaa196 100644 --- a/shared/src/commonMain/kotlin/co/touchlab/droidcon/dto/WebLink.kt +++ b/shared/src/commonMain/kotlin/co/touchlab/droidcon/dto/WebLink.kt @@ -6,7 +6,6 @@ data class WebLink(val range: IntRange, val link: String) { companion object { - fun fromUrl(url: Url): WebLink = - WebLink(IntRange(0, url.string.length - 1), url.string) + fun fromUrl(url: Url): WebLink = WebLink(IntRange(0, url.string.length - 1), url.string) } } diff --git a/shared/src/commonMain/kotlin/co/touchlab/droidcon/util/AppChecker.kt b/shared/src/commonMain/kotlin/co/touchlab/droidcon/util/AppChecker.kt index 472a4767..a8e44aea 100644 --- a/shared/src/commonMain/kotlin/co/touchlab/droidcon/util/AppChecker.kt +++ b/shared/src/commonMain/kotlin/co/touchlab/droidcon/util/AppChecker.kt @@ -15,7 +15,5 @@ object AppChecker { } } - private fun toMD5(text: String): String { - return text.encodeToByteArray().md5().hex - } + private fun toMD5(text: String): String = text.encodeToByteArray().md5().hex } diff --git a/shared/src/iosMain/kotlin/co/touchlab/droidcon/domain/repository/impl/SqlDelightDriverFactory.ios.kt b/shared/src/iosMain/kotlin/co/touchlab/droidcon/domain/repository/impl/SqlDelightDriverFactory.ios.kt index 79b4eaa9..679f83b4 100644 --- a/shared/src/iosMain/kotlin/co/touchlab/droidcon/domain/repository/impl/SqlDelightDriverFactory.ios.kt +++ b/shared/src/iosMain/kotlin/co/touchlab/droidcon/domain/repository/impl/SqlDelightDriverFactory.ios.kt @@ -5,7 +5,5 @@ import app.cash.sqldelight.driver.native.NativeSqliteDriver import co.touchlab.droidcon.db.DroidconDatabase actual class SqlDelightDriverFactory { - actual fun createDriver(): SqlDriver { - return NativeSqliteDriver(DroidconDatabase.Schema, "droidcon2023.db") - } + actual fun createDriver(): SqlDriver = NativeSqliteDriver(DroidconDatabase.Schema, "droidcon2023.db") } diff --git a/shared/src/iosMain/kotlin/co/touchlab/droidcon/service/IOSNotificationService.kt b/shared/src/iosMain/kotlin/co/touchlab/droidcon/service/IOSNotificationService.kt index 3c64b401..92058b87 100644 --- a/shared/src/iosMain/kotlin/co/touchlab/droidcon/service/IOSNotificationService.kt +++ b/shared/src/iosMain/kotlin/co/touchlab/droidcon/service/IOSNotificationService.kt @@ -28,10 +28,7 @@ import platform.UserNotifications.UNNotificationRequest import platform.UserNotifications.UNNotificationSound import platform.UserNotifications.UNUserNotificationCenter -class IOSNotificationService( - private val log: Logger, - private val syncService: SyncService, -) : NotificationService { +class IOSNotificationService(private val log: Logger, private val syncService: SyncService) : NotificationService { private val notificationCenter = UNUserNotificationCenter.currentNotificationCenter() private var notificationHandler: DeepLinkNotificationHandler? = null @@ -92,13 +89,13 @@ class IOSNotificationService( content.setBody(body) content.setSound(UNNotificationSound.defaultSound) val (typeValue, sessionId) = when (notification) { - is Notification.Local.Feedback -> Notification.Values.feedbackType to notification.sessionId - is Notification.Local.Reminder -> Notification.Values.reminderType to notification.sessionId + is Notification.Local.Feedback -> Notification.Values.FEEDBACK_TYPE to notification.sessionId + is Notification.Local.Reminder -> Notification.Values.REMINDER_TYPE to notification.sessionId } content.setUserInfo( mapOf( - Notification.Keys.notificationType to typeValue, - Notification.Keys.sessionId to sessionId.value, + Notification.Keys.NOTIFICATION_TYPE to typeValue, + Notification.Keys.SESSION_ID to sessionId.value, ), ) @@ -150,20 +147,19 @@ class IOSNotificationService( } } - private fun Map.parseNotification(): Notification? { - return when (val typeValue = this[Notification.Keys.notificationType] as? String) { - Notification.Values.reminderType -> this.parseReminderNotification() - Notification.Values.feedbackType -> this.parseFeedbackNotification() - Notification.Values.refreshDataType -> Notification.Remote.RefreshData + private fun Map.parseNotification(): Notification? = + when (val typeValue = this[Notification.Keys.NOTIFICATION_TYPE] as? String) { + Notification.Values.REMINDER_TYPE -> this.parseReminderNotification() + Notification.Values.FEEDBACK_TYPE -> this.parseFeedbackNotification() + Notification.Values.REFRESH_DATA_TYPE -> Notification.Remote.RefreshData else -> { log.e { "Unknown notification type <$typeValue>, ignoring." } null } } - } private fun Map.parseReminderNotification(): Notification.Local.Reminder? { - val sessionId = this[Notification.Keys.sessionId] as? String ?: run { + val sessionId = this[Notification.Keys.SESSION_ID] as? String ?: run { log.e { "Couldn't parse reminder notification. Session ID doesn't exist or isn't String." } return null } @@ -174,7 +170,7 @@ class IOSNotificationService( } private fun Map.parseFeedbackNotification(): Notification.Local.Feedback? { - val sessionId = this[Notification.Keys.sessionId] as? String ?: run { + val sessionId = this[Notification.Keys.SESSION_ID] as? String ?: run { log.e { "Couldn't parse feedback notification. Session ID doesn't exist or isn't String." } return null } diff --git a/shared/src/iosMain/kotlin/co/touchlab/droidcon/util/BundleResourceReader.kt b/shared/src/iosMain/kotlin/co/touchlab/droidcon/util/BundleResourceReader.kt index 29f5ce5d..2b94136a 100644 --- a/shared/src/iosMain/kotlin/co/touchlab/droidcon/util/BundleResourceReader.kt +++ b/shared/src/iosMain/kotlin/co/touchlab/droidcon/util/BundleResourceReader.kt @@ -17,9 +17,7 @@ import platform.darwin.NSObjectMeta @OptIn(kotlinx.cinterop.ExperimentalForeignApi::class) @BetaInteropApi -class BundleResourceReader( - private val bundle: NSBundle = NSBundle.bundleForClass(BundleMarker), -) : ResourceReader { +class BundleResourceReader(private val bundle: NSBundle = NSBundle.bundleForClass(BundleMarker)) : ResourceReader { override fun readResource(name: String): String { // TODO: Catch iOS-only exceptions and map them to common ones. val (filename, type) = when (val lastPeriodIndex = name.lastIndexOf('.')) { diff --git a/shared/src/iosMain/kotlin/co/touchlab/droidcon/util/wrapMultiThreadCallback.kt b/shared/src/iosMain/kotlin/co/touchlab/droidcon/util/WrapMultiThreadCallback.kt similarity index 100% rename from shared/src/iosMain/kotlin/co/touchlab/droidcon/util/wrapMultiThreadCallback.kt rename to shared/src/iosMain/kotlin/co/touchlab/droidcon/util/WrapMultiThreadCallback.kt