Skip to content

Commit

Permalink
Updating formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinSchildhorn committed Oct 24, 2024
1 parent ced0ff6 commit 8c1bfb5
Show file tree
Hide file tree
Showing 84 changed files with 360 additions and 682 deletions.
5 changes: 4 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
root = true

[*.{kt,kts}]
end_of_line = lf
ij_kotlin_packages_to_use_import_on_demand = true
Expand All @@ -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

Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,5 @@ class DefaultParseUrlViewService : ParseUrlViewService {

private val urlRegex = Patterns.WEB_URL.toRegex()

override fun parse(text: String): List<WebLink> {
return urlRegex.findAll(text).map { WebLink(it.range, it.value) }.toList()
}
override fun parse(text: String): List<WebLink> = urlRegex.findAll(text).map { WebLink(it.range, it.value) }.toList()
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
3 changes: 3 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ subprojects {
jvmTarget = "1.8"
}
}
configure<org.jlleitschuh.gradle.ktlint.KtlintExtension> {
version.set("1.4.0")
}
}

tasks.register<Delete>("clean") {
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
6 changes: 3 additions & 3 deletions ios/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ kotlin {
val targets = listOf(
iosX64(),
iosArm64(),
iosSimulatorArm64()
iosSimulatorArm64(),
)

sourceSets {
Expand Down Expand Up @@ -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)
Expand All @@ -78,7 +78,7 @@ kotlin {
}

afterEvaluate {
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinNativeCompile>() {
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinNativeCompile> {
(compilerPluginClasspath as? Configuration)?.isTransitive = true
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<ObservableSettings> { NSUserDefaultsSettings(delegate = userDefaults) }
Expand All @@ -40,7 +37,7 @@ fun initKoinIos(
single { analyticsService }

single<ParseUrlViewService> { DefaultParseUrlViewService() }
} + uiModule
} + uiModule,
)

// Workaround class for injecting an `NSObject` class.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<WebLink> {
return urlRegex.findAll(text).map { WebLink(it.range, it.value) }.toList()
}
override fun parse(text: String): List<WebLink> = urlRegex.findAll(text).map { WebLink(it.range, it.value) }.toList()
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,44 +7,35 @@ 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 {
NSString
.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")
}
Original file line number Diff line number Diff line change
Expand Up @@ -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("")
Expand Down
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ internal fun SessionDetailView(viewModel: SessionDetailViewModel) {
NavigationStack(
key = viewModel,
links = {
NavigationLink(viewModel.observePresentedSpeakerDetail) {
navigationLink(viewModel.observePresentedSpeakerDetail) {
SpeakerDetailView(viewModel = it)
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ internal fun SponsorDetailView(viewModel: SponsorDetailViewModel) {
NavigationStack(
key = viewModel,
links = {
NavigationLink(viewModel.observePresentedSpeakerDetail) {
navigationLink(viewModel.observePresentedSpeakerDetail) {
SpeakerDetailView(viewModel = it)
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ internal fun SponsorsView(viewModel: SponsorListViewModel) {
NavigationStack(
key = viewModel,
links = {
NavigationLink(viewModel.observePresentedSponsorDetail) {
navigationLink(viewModel.observePresentedSponsorDetail) {
SponsorDetailView(viewModel = it)
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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()
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@file:Suppress("ktlint:standard:filename")

package co.touchlab.droidcon.util

import kotlinx.datetime.LocalDateTime
Expand Down
Loading

0 comments on commit 8c1bfb5

Please sign in to comment.