Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinSchildhorn committed Oct 24, 2024
1 parent b97f85e commit 7ab4ad1
Show file tree
Hide file tree
Showing 42 changed files with 553 additions and 163 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ class MainApp : Application() {
single<Context> { this@MainApp }
single<Class<out Activity>> { MainActivity::class.java }
single<SharedPreferences> {
get<Context>().getSharedPreferences("DROIDCON_SETTINGS_2023", Context.MODE_PRIVATE)
get<Context>().getSharedPreferences(
"DROIDCON_SETTINGS_2023",
Context.MODE_PRIVATE
)
}
single<ObservableSettings> { SharedPreferencesSettings(delegate = get()) }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ 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.notificationType] == Notification.Values.refreshDataType
) {
MainScope().launch {
notificationService.handleNotification(
Notification.Remote.RefreshData
Expand All @@ -32,7 +35,10 @@ class DefaultFirebaseMessagingService : FirebaseMessagingService() {

// If we have notification, we're running in foreground and should show it ourselves.
val originalNotification = message.notification ?: return
val notification = NotificationCompat.Builder(this, message.notification?.channelId ?: "")
val notification = NotificationCompat.Builder(
this,
message.notification?.channelId ?: ""
)
.setContentTitle(originalNotification.title)
.setContentText(originalNotification.body)
.apply {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ class NotificationLocalizedStringFactory(
) : NotificationSchedulingService.LocalizedStringFactory {

override fun reminderTitle(roomName: String?): String {
val ending = roomName?.let { context.getString(R.string.notification_reminder_title_in_room, it) } ?: ""
val ending = roomName?.let {
context.getString(R.string.notification_reminder_title_in_room, it)
} ?: ""
return context.getString(R.string.notification_reminder_title_base, ending)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,32 @@ class NotificationLocalizedStringFactory(
) : 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) } ?: ""
return NSString.stringWithFormat(bundle.localizedStringForKey("Notification.Reminder.Title.Base", null, null).convertParametersForPrintf(), ending.cstr)
val ending = roomName?.let {
NSString.stringWithFormat(
bundle.localizedStringForKey("Notification.Reminder.Title.InRoom", null, null)
.convertParametersForPrintf(),
it.cstr
)
} ?: ""
return NSString.stringWithFormat(
bundle.localizedStringForKey(
"Notification.Reminder.Title.Base",
null,
null
).convertParametersForPrintf(),
ending.cstr
)
}

override fun reminderBody(sessionTitle: String): String {
return NSString.stringWithFormat(bundle.localizedStringForKey("Notification.Reminder.Body", null, null).convertParametersForPrintf(), sessionTitle.cstr)
return NSString.stringWithFormat(
bundle.localizedStringForKey(
"Notification.Reminder.Body",
null,
null
).convertParametersForPrintf(),
sessionTitle.cstr
)
}

override fun feedbackTitle(): String {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ class IOSDateFormatter : DateFormatter {
private val monthWithDay: NSDateFormatter by lazy {
NSDateFormatter().also {
val dateTemplate = "MMM d"
it.dateFormat = NSDateFormatter.dateFormatFromTemplate(dateTemplate, 0.toULong(), NSLocale.currentLocale)!!
it.dateFormat = NSDateFormatter.dateFormatFromTemplate(
dateTemplate,
0.toULong(),
NSLocale.currentLocale
)!!
}
}

Expand All @@ -30,7 +34,11 @@ class IOSDateFormatter : DateFormatter {
private val timeOnlyNoPeriod: NSDateFormatter by lazy {
NSDateFormatter().also {
val dateTemplate = "hh:mm"
it.dateFormat = NSDateFormatter.dateFormatFromTemplate(dateTemplate, 0.toULong(), NSLocale.currentLocale)!!
it.dateFormat = NSDateFormatter.dateFormatFromTemplate(
dateTemplate,
0.toULong(),
NSLocale.currentLocale
)!!
}
}

Expand All @@ -40,15 +48,18 @@ class IOSDateFormatter : DateFormatter {
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) }
)
override fun timeOnlyInterval(fromDateTime: LocalDateTime, toDateTime: LocalDateTime) =
interval(
fromDateTime.date()?.let { timeOnlyNoPeriod.stringFromDate(it) },
toDateTime.date()?.let { timeOnly.stringFromDate(it) }
)

private fun LocalDate.date() = NSCalendar.currentCalendar.dateFromComponents(toNSDateComponents())
private fun LocalDate.date() =
NSCalendar.currentCalendar.dateFromComponents(toNSDateComponents())

private fun LocalDateTime.date() =
NSCalendar.currentCalendar.dateFromComponents(toNSDateComponents()) // TODOKPG - Pretty sure this is device time zone, might be OK. Just for local formating
// 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("")
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ internal actual fun PlatformSwitchApp() {
val context = LocalContext.current
Button(
onClick = {
val intent = context.packageManager.getLaunchIntentForPackage(Constants.SisterApp.androidPackageName)
val intent =
context
.packageManager
.getLaunchIntentForPackage(Constants.SisterApp.androidPackageName)
if (intent != null) {
context.startActivity(intent)
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,19 @@ package co.touchlab.droidcon.ui.util

import androidx.compose.runtime.Composable
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.window.DialogProperties
import androidx.compose.ui.window.Dialog as AndroidXComposeDialog
import androidx.compose.ui.window.DialogProperties

@OptIn(ExperimentalComposeUiApi::class)
@Composable
internal actual fun Dialog(dismiss: () -> Unit, content: @Composable () -> Unit) {
AndroidXComposeDialog(
onDismissRequest = dismiss,
properties = DialogProperties(dismissOnBackPress = false, dismissOnClickOutside = false, usePlatformDefaultWidth = false),
properties = DialogProperties(
dismissOnBackPress = false,
dismissOnClickOutside = false,
usePlatformDefaultWidth = false
),
) {
content()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,15 @@ import co.touchlab.droidcon.ui.theme.Dimensions
// platforms and on each platform we need to get the drawable according to provided name.
@SuppressLint("ComposableNaming", "DiscouragedApi")
@Composable
internal actual fun __LocalImage(imageResourceName: String, modifier: Modifier, contentDescription: String?) {
internal actual fun __LocalImage(
imageResourceName: String,
modifier: Modifier,
contentDescription: String?
) {
val context = LocalContext.current
val imageRes = context.resources.getIdentifier(imageResourceName, "drawable", context.packageName).takeIf { it != 0 }
val imageRes =
context.resources.getIdentifier(imageResourceName, "drawable", context.packageName)
.takeIf { it != 0 }
if (imageRes != null) {
androidx.compose.foundation.Image(
modifier = modifier,
Expand All @@ -36,7 +42,10 @@ internal actual fun __LocalImage(imageResourceName: String, modifier: Modifier,
)
} else {
Row(
modifier = modifier.background(MaterialTheme.colorScheme.primary, RoundedCornerShape(Dimensions.Padding.half)),
modifier = modifier.background(
MaterialTheme.colorScheme.primary,
RoundedCornerShape(Dimensions.Padding.half)
),
verticalAlignment = Alignment.CenterVertically
) {
Spacer(modifier = Modifier.weight(1f))
Expand All @@ -46,7 +55,11 @@ internal actual fun __LocalImage(imageResourceName: String, modifier: Modifier,
modifier = Modifier.padding(Dimensions.Padding.half),
tint = Color.White
)
Text("Image not supported", modifier = Modifier.padding(Dimensions.Padding.default), color = Color.White)
Text(
"Image not supported",
modifier = Modifier.padding(Dimensions.Padding.default),
color = Color.White
)
Spacer(modifier = Modifier.weight(1f))
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,13 @@ internal fun BottomNavigationView(viewModel: ApplicationViewModel, modifier: Mod
NavigationBar {
viewModel.tabs.forEach { tab ->
val (title, icon) = when (tab) {
ApplicationViewModel.Tab.Schedule -> "Schedule" to Icons.Filled.CalendarMonth
ApplicationViewModel.Tab.Schedule ->
"Schedule" to Icons.Filled.CalendarMonth
// FIXME: Was originally "My agenda" but then it doesn't seem to fit.
ApplicationViewModel.Tab.MyAgenda -> "Agenda" to Icons.Filled.Schedule
ApplicationViewModel.Tab.Venue -> "Venue" to Icons.Filled.Map
ApplicationViewModel.Tab.Sponsors -> "Sponsors" to Icons.Filled.LocalFireDepartment
ApplicationViewModel.Tab.Sponsors ->
"Sponsors" to Icons.Filled.LocalFireDepartment
ApplicationViewModel.Tab.Settings -> "Settings" to Icons.Filled.Settings
}
NavigationBarItem(
Expand All @@ -66,11 +68,13 @@ internal fun BottomNavigationView(viewModel: ApplicationViewModel, modifier: Mod
title = "Droidcon NYC 2024",
emptyText = "Sessions could not be loaded.",
)

ApplicationViewModel.Tab.MyAgenda -> SessionListView(
viewModel = viewModel.agenda,
title = "Agenda",
emptyText = "Add sessions to your agenda from session detail in schedule.",
)

ApplicationViewModel.Tab.Venue -> VenueView()
ApplicationViewModel.Tab.Sponsors -> SponsorsView(viewModel.sponsors)
ApplicationViewModel.Tab.Settings -> SettingsView(viewModel.settings)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,11 @@ internal fun SettingsView(viewModel: SettingsViewModel) {
}

@Composable
internal fun IconTextSwitchRow(text: String, image: ImageVector, checked: MutableObservableProperty<Boolean>) {
internal fun IconTextSwitchRow(
text: String,
image: ImageVector,
checked: MutableObservableProperty<Boolean>
) {
val isChecked by checked.observeAsState()
Row(
modifier = Modifier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,17 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier

@Composable
internal expect fun __LocalImage(imageResourceName: String, modifier: Modifier, contentDescription: String?)
internal expect fun __LocalImage(
imageResourceName: String,
modifier: Modifier,
contentDescription: String?
)

@Composable
internal fun LocalImage(imageResourceName: String, modifier: Modifier = Modifier, contentDescription: String? = null) {
internal fun LocalImage(
imageResourceName: String,
modifier: Modifier = Modifier,
contentDescription: String? = null
) {
__LocalImage(imageResourceName, modifier, contentDescription)
}
Loading

0 comments on commit 7ab4ad1

Please sign in to comment.