Move date handler out of data

This commit is contained in:
Syer10
2024-09-21 13:49:14 -04:00
parent a4a828dc62
commit 35ea833510
8 changed files with 18 additions and 42 deletions

View File

@@ -0,0 +1,12 @@
package ca.gosyer.jui.core.util
import kotlinx.datetime.Instant
@Suppress("NO_ACTUAL_FOR_EXPECT")
expect class DateHandler {
val formatOptions: List<String>
fun getDateFormat(format: String): (Instant) -> String
val dateTimeFormat: (Instant) -> String
}

View File

@@ -1,19 +1,9 @@
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
package ca.gosyer.jui.data.base
package ca.gosyer.jui.core.util
import androidx.compose.ui.text.intl.Locale
import ca.gosyer.jui.core.lang.toPlatform
import kotlinx.datetime.Instant
import kotlinx.datetime.toNSDate
import me.tatarka.inject.annotations.Inject
import platform.Foundation.NSDateFormatter
import platform.Foundation.NSDateFormatterNoStyle
import platform.Foundation.NSDateFormatterShortStyle
actual class DateHandler
@Inject

View File

@@ -1,10 +1,4 @@
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
package ca.gosyer.jui.data.base
package ca.gosyer.jui.core.util
import androidx.compose.ui.text.intl.Locale
import ca.gosyer.jui.core.lang.toPlatform
@@ -42,8 +36,7 @@ actual class DateHandler
}
actual val dateTimeFormat: (Instant) -> String by lazy {
DateTimeFormatter
.ofLocalizedDateTime(FormatStyle.SHORT)
DateTimeFormatter.ofLocalizedDateTime(FormatStyle.SHORT)
.withLocale(Locale.current.toPlatform())
.withZone(ZoneId.systemDefault())
.let { formatter ->

View File

@@ -1,18 +0,0 @@
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
package ca.gosyer.jui.data.base
import kotlinx.datetime.Instant
@Suppress("NO_ACTUAL_FOR_EXPECT")
expect class DateHandler {
val formatOptions: List<String>
fun getDateFormat(format: String): (Instant) -> String
val dateTimeFormat: (Instant) -> String
}

View File

@@ -85,7 +85,6 @@ kotlin {
api(projects.core)
api(projects.i18n)
api(projects.domain)
api(projects.data)
api(projects.uiCore)
api(compose.runtime)
api(compose.foundation)

View File

@@ -6,7 +6,7 @@
package ca.gosyer.jui.ui.main.about
import ca.gosyer.jui.data.base.DateHandler
import ca.gosyer.jui.core.util.DateHandler
import ca.gosyer.jui.domain.settings.interactor.AboutServer
import ca.gosyer.jui.domain.settings.model.About
import ca.gosyer.jui.domain.updates.interactor.UpdateChecker

View File

@@ -6,7 +6,7 @@
package ca.gosyer.jui.ui.manga
import ca.gosyer.jui.data.base.DateHandler
import ca.gosyer.jui.core.util.DateHandler
import ca.gosyer.jui.domain.category.interactor.AddMangaToCategory
import ca.gosyer.jui.domain.category.interactor.GetCategories
import ca.gosyer.jui.domain.category.interactor.GetMangaCategories

View File

@@ -30,7 +30,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.text.intl.Locale
import ca.gosyer.jui.core.lang.getDisplayName
import ca.gosyer.jui.core.lang.withIOContext
import ca.gosyer.jui.data.base.DateHandler
import ca.gosyer.jui.core.util.DateHandler
import ca.gosyer.jui.domain.ui.model.StartScreen
import ca.gosyer.jui.domain.ui.service.UiPreferences
import ca.gosyer.jui.i18n.MR