refactor: move PureDark and BookWithCover
This commit is contained in:
parent
b4c6a63878
commit
3a08791cbe
3 changed files with 29 additions and 31 deletions
|
|
@ -4,7 +4,7 @@
|
||||||
* SPDX-License-Identifier: GPL-3.0-only
|
* SPDX-License-Identifier: GPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package ua.acclorite.book_story.data.model.library
|
package ua.acclorite.book_story.data.model.common
|
||||||
|
|
||||||
import androidx.compose.runtime.Immutable
|
import androidx.compose.runtime.Immutable
|
||||||
import ua.acclorite.book_story.core.CoverImage
|
import ua.acclorite.book_story.core.CoverImage
|
||||||
|
|
@ -1,30 +0,0 @@
|
||||||
/*
|
|
||||||
* Book's Story — free and open-source Material You eBook reader.
|
|
||||||
* Copyright (C) 2024-2025 Acclorite
|
|
||||||
* SPDX-License-Identifier: GPL-3.0-only
|
|
||||||
*/
|
|
||||||
|
|
||||||
package ua.acclorite.book_story.presentation.main.model
|
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import android.os.PowerManager
|
|
||||||
import androidx.compose.runtime.Composable
|
|
||||||
import androidx.compose.runtime.Immutable
|
|
||||||
|
|
||||||
@Immutable
|
|
||||||
enum class PureDark {
|
|
||||||
OFF,
|
|
||||||
ON,
|
|
||||||
SAVER
|
|
||||||
}
|
|
||||||
|
|
||||||
@Composable
|
|
||||||
fun PureDark.isPureDark(context: Context): Boolean {
|
|
||||||
val powerManager = context.getSystemService(Context.POWER_SERVICE) as PowerManager
|
|
||||||
|
|
||||||
return when (this) {
|
|
||||||
PureDark.OFF -> false
|
|
||||||
PureDark.ON -> true
|
|
||||||
PureDark.SAVER -> powerManager.isPowerSaveMode
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -0,0 +1,28 @@
|
||||||
|
/*
|
||||||
|
* Book's Story — free and open-source Material You eBook reader.
|
||||||
|
* Copyright (C) 2024-2025 Acclorite
|
||||||
|
* SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
*/
|
||||||
|
|
||||||
|
package ua.acclorite.book_story.ui.theme.model
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.os.PowerManager
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
|
||||||
|
enum class PureDark {
|
||||||
|
OFF,
|
||||||
|
ON,
|
||||||
|
SAVER;
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun isPureDark(context: Context): Boolean {
|
||||||
|
val powerManager = context.getSystemService(Context.POWER_SERVICE) as PowerManager
|
||||||
|
|
||||||
|
return when (this) {
|
||||||
|
OFF -> false
|
||||||
|
ON -> true
|
||||||
|
SAVER -> powerManager.isPowerSaveMode
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue