improved UI
This commit is contained in:
1 parent
02a40c2589
commit
d8b39057d5
8 files changed
+460
-16
No files matched your search
@@ -3,6 +3,7 @@ package net.sergeych.toread
|
||||
import androidx.compose.ui.graphics.ImageBitmap
|
||||
import kotlinx.browser.window
|
||||
import net.sergeych.toread.fb2.Fb2Binary
|
||||
import net.sergeych.toread.storage.BookReadingStatus
|
||||
import org.w3c.dom.events.Event
|
||||
|
||||
actual fun loadDefaultBookBytes(): ByteArray? = null
|
||||
@@ -39,6 +40,8 @@ actual suspend fun loadLibraryReadingPosition(fileId: String): ReadingPosition?
|
||||
|
||||
actual suspend fun saveLibraryReadingPosition(fileId: String, position: ReadingPosition) = Unit
|
||||
|
||||
actual suspend fun markLibraryReadingStatus(fileId: String, status: BookReadingStatus): Boolean = false
|
||||
|
||||
actual suspend fun loadBookInfoExtras(fileId: String): BookInfoExtras = BookInfoExtras()
|
||||
|
||||
actual suspend fun loadActiveReadingFileId(): String? = null
|
||||
@@ -62,3 +65,29 @@ actual fun watchPlatformDarkTheme(onChange: (Boolean) -> Unit): () -> Unit {
|
||||
}
|
||||
|
||||
actual fun libraryLogPath(): String? = null
|
||||
|
||||
actual fun formatLibraryLastReadTime(millis: Long): String {
|
||||
val totalMinutes = millis / 60_000L
|
||||
val minute = (totalMinutes % 60).toString().padStart(2, '0')
|
||||
val totalHours = totalMinutes / 60
|
||||
val hour = (totalHours % 24).toString().padStart(2, '0')
|
||||
val (yearValue, monthValue, dayValue) = civilDateFromEpochDay(totalHours / 24)
|
||||
val year = yearValue.toString()
|
||||
val month = monthValue.toString().padStart(2, '0')
|
||||
val day = dayValue.toString().padStart(2, '0')
|
||||
return "$year-$month-$day $hour:$minute"
|
||||
}
|
||||
|
||||
private fun civilDateFromEpochDay(epochDay: Long): Triple<Int, Int, Int> {
|
||||
val shiftedDay = epochDay + 719_468
|
||||
val era = shiftedDay / 146_097
|
||||
val dayOfEra = shiftedDay - era * 146_097
|
||||
val yearOfEra = (dayOfEra - dayOfEra / 1_460 + dayOfEra / 36_524 - dayOfEra / 146_096) / 365
|
||||
var year = (yearOfEra + era * 400).toInt()
|
||||
val dayOfYear = dayOfEra - (365 * yearOfEra + yearOfEra / 4 - yearOfEra / 100)
|
||||
val monthPart = (5 * dayOfYear + 2) / 153
|
||||
val day = (dayOfYear - (153 * monthPart + 2) / 5 + 1).toInt()
|
||||
val month = (monthPart + if (monthPart < 10) 3 else -9).toInt()
|
||||
if (month <= 2) year += 1
|
||||
return Triple(year, month, day)
|
||||
}
|
||||
Reference in new issue
Block a user