refactor: remove @Immutable from enum classes

This commit is contained in:
Acclorite 2025-07-19 10:35:06 +03:00
parent 3a08791cbe
commit 69689b8be6
No known key found for this signature in database
GPG key ID: 6E54C611F6EE8593
18 changed files with 13 additions and 41 deletions

View file

@ -6,9 +6,7 @@
package ua.acclorite.book_story.presentation.browse.model package ua.acclorite.book_story.presentation.browse.model
import androidx.compose.runtime.Immutable
@Immutable
enum class BrowseLayout { enum class BrowseLayout {
LIST, GRID LIST, GRID
} }

View file

@ -6,9 +6,7 @@
package ua.acclorite.book_story.presentation.browse.model package ua.acclorite.book_story.presentation.browse.model
import androidx.compose.runtime.Immutable
@Immutable
enum class BrowseSortOrder { enum class BrowseSortOrder {
NAME, NAME,
FILE_FORMAT, FILE_FORMAT,

View file

@ -6,9 +6,7 @@
package ua.acclorite.book_story.presentation.library.model package ua.acclorite.book_story.presentation.library.model
import androidx.compose.runtime.Immutable
@Immutable
enum class LibraryLayout { enum class LibraryLayout {
GRID, LIST GRID, LIST
} }

View file

@ -6,9 +6,7 @@
package ua.acclorite.book_story.presentation.library.model package ua.acclorite.book_story.presentation.library.model
import androidx.compose.runtime.Immutable
@Immutable
enum class LibrarySortOrder { enum class LibrarySortOrder {
NAME, NAME,
LAST_READ, LAST_READ,

View file

@ -6,9 +6,7 @@
package ua.acclorite.book_story.presentation.library.model package ua.acclorite.book_story.presentation.library.model
import androidx.compose.runtime.Immutable
@Immutable
enum class LibraryTitlePosition { enum class LibraryTitlePosition {
OFF, BELOW, INSIDE OFF, BELOW, INSIDE
} }

View file

@ -119,12 +119,12 @@ class MainActivity : AppCompatActivity() {
else LibraryScreen, else LibraryScreen,
transitionSpec = { lastEvent -> transitionSpec = { lastEvent ->
when (lastEvent) { when (lastEvent) {
StackEvent.Default -> { StackEvent.DEFAULT -> {
Transitions.SlidingTransitionIn Transitions.SlidingTransitionIn
.togetherWith(Transitions.SlidingTransitionOut) .togetherWith(Transitions.SlidingTransitionOut)
} }
StackEvent.Pop -> { StackEvent.POP -> {
Transitions.BackSlidingTransitionIn Transitions.BackSlidingTransitionIn
.togetherWith(Transitions.BackSlidingTransitionOut) .togetherWith(Transitions.BackSlidingTransitionOut)
} }

View file

@ -41,7 +41,7 @@ class Navigator @AssistedInject constructor(
initialValue = initialScreen initialValue = initialScreen
) )
val lastEvent = savedStateHandle.getStateFlow("stack_event", StackEvent.Default) val lastEvent = savedStateHandle.getStateFlow("stack_event", StackEvent.DEFAULT)
private fun changeStackEvent(stackEvent: StackEvent) { private fun changeStackEvent(stackEvent: StackEvent) {
savedStateHandle["stack_event"] = stackEvent savedStateHandle["stack_event"] = stackEvent
} }
@ -56,8 +56,8 @@ class Navigator @AssistedInject constructor(
if (!saveInBackStack) items.removeLast() if (!saveInBackStack) items.removeLast()
changeStackEvent( changeStackEvent(
if (popping) StackEvent.Pop if (popping) StackEvent.POP
else StackEvent.Default else StackEvent.DEFAULT
) )
if (lastItem.value::class == targetScreen::class) items.removeLast() if (lastItem.value::class == targetScreen::class) items.removeLast()
@ -67,8 +67,8 @@ class Navigator @AssistedInject constructor(
fun pop(popping: Boolean = true) { fun pop(popping: Boolean = true) {
if (items.value.count() > 1) { if (items.value.count() > 1) {
changeStackEvent( changeStackEvent(
if (popping) StackEvent.Pop if (popping) StackEvent.POP
else StackEvent.Default else StackEvent.DEFAULT
) )
items.removeLast() items.removeLast()
} }

View file

@ -7,11 +7,9 @@
package ua.acclorite.book_story.presentation.navigator package ua.acclorite.book_story.presentation.navigator
import android.os.Parcelable import android.os.Parcelable
import androidx.compose.runtime.Immutable
import kotlinx.parcelize.Parcelize import kotlinx.parcelize.Parcelize
@Immutable
@Parcelize @Parcelize
enum class StackEvent : Parcelable { enum class StackEvent : Parcelable {
Default, Pop DEFAULT, POP
} }

View file

@ -6,9 +6,7 @@
package ua.acclorite.book_story.presentation.reader.model package ua.acclorite.book_story.presentation.reader.model
import androidx.compose.runtime.Immutable
@Immutable
enum class ReaderColorEffects { enum class ReaderColorEffects {
OFF, OFF,
GRAYSCALE, GRAYSCALE,

View file

@ -6,10 +6,8 @@
package ua.acclorite.book_story.presentation.reader.model package ua.acclorite.book_story.presentation.reader.model
import androidx.compose.runtime.Immutable
import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.font.FontWeight
@Immutable
enum class ReaderFontThickness(val thickness: FontWeight) { enum class ReaderFontThickness(val thickness: FontWeight) {
THIN(FontWeight.Thin), THIN(FontWeight.Thin),
EXTRA_LIGHT(FontWeight.ExtraLight), EXTRA_LIGHT(FontWeight.ExtraLight),

View file

@ -6,9 +6,7 @@
package ua.acclorite.book_story.presentation.reader.model package ua.acclorite.book_story.presentation.reader.model
import androidx.compose.runtime.Immutable
@Immutable
enum class ReaderHorizontalGesture { enum class ReaderHorizontalGesture {
OFF, OFF,
ON, ON,

View file

@ -6,9 +6,7 @@
package ua.acclorite.book_story.presentation.reader.model package ua.acclorite.book_story.presentation.reader.model
import androidx.compose.runtime.Immutable
@Immutable
enum class ReaderProgressCount { enum class ReaderProgressCount {
PERCENTAGE, PERCENTAGE,
QUANTITY QUANTITY

View file

@ -7,9 +7,7 @@
package ua.acclorite.book_story.presentation.reader.model package ua.acclorite.book_story.presentation.reader.model
import android.content.pm.ActivityInfo import android.content.pm.ActivityInfo
import androidx.compose.runtime.Immutable
@Immutable
enum class ReaderScreenOrientation(val code: Int) { enum class ReaderScreenOrientation(val code: Int) {
DEFAULT(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED), DEFAULT(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED),
FREE(ActivityInfo.SCREEN_ORIENTATION_USER), FREE(ActivityInfo.SCREEN_ORIENTATION_USER),

View file

@ -6,10 +6,8 @@
package ua.acclorite.book_story.presentation.reader.model package ua.acclorite.book_story.presentation.reader.model
import androidx.compose.runtime.Immutable
import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.text.style.TextAlign
@Immutable
enum class ReaderTextAlignment(val textAlignment: TextAlign) { enum class ReaderTextAlignment(val textAlignment: TextAlign) {
START(TextAlign.Start), START(TextAlign.Start),
JUSTIFY(TextAlign.Justify), JUSTIFY(TextAlign.Justify),

View file

@ -56,7 +56,7 @@ object StartScreen : Screen, Parcelable {
val activity = LocalActivity.current val activity = LocalActivity.current
val currentPage = remember { mutableIntStateOf(0) } val currentPage = remember { mutableIntStateOf(0) }
val stackEvent = remember { mutableStateOf(StackEvent.Default) } val stackEvent = remember { mutableStateOf(StackEvent.DEFAULT) }
val languages = remember(settings.language.value) { val languages = remember(settings.language.value) {
CoreData.languages.sortedBy { it.second }.map { CoreData.languages.sortedBy { it.second }.map {
@ -79,14 +79,14 @@ object StartScreen : Screen, Parcelable {
return@StartContent return@StartContent
} }
stackEvent.value = StackEvent.Default stackEvent.value = StackEvent.DEFAULT
currentPage.intValue += 1 currentPage.intValue += 1
}, },
navigateBack = { navigateBack = {
if ((currentPage.intValue - 1) < 0) { if ((currentPage.intValue - 1) < 0) {
activity.finish() activity.finish()
} else { } else {
stackEvent.value = StackEvent.Pop stackEvent.value = StackEvent.POP
currentPage.intValue -= 1 currentPage.intValue -= 1
} }
}, },

View file

@ -6,9 +6,7 @@
package ua.acclorite.book_story.ui.common.model package ua.acclorite.book_story.ui.common.model
import androidx.compose.runtime.Immutable
@Immutable
enum class Direction { enum class Direction {
START, NEUTRAL, END START, NEUTRAL, END
} }

View file

@ -6,9 +6,7 @@
package ua.acclorite.book_story.ui.common.model package ua.acclorite.book_story.ui.common.model
import androidx.compose.runtime.Immutable
@Immutable
enum class Position { enum class Position {
TOP, CENTER, BOTTOM, SOLO TOP, CENTER, BOTTOM, SOLO
} }

View file

@ -28,12 +28,12 @@ fun StartContentTransition(
targetState = targetValue, targetState = targetValue,
transitionSpec = { transitionSpec = {
when (stackEvent) { when (stackEvent) {
StackEvent.Default -> { StackEvent.DEFAULT -> {
Transitions.SlidingTransitionIn Transitions.SlidingTransitionIn
.togetherWith(Transitions.SlidingTransitionOut) .togetherWith(Transitions.SlidingTransitionOut)
} }
StackEvent.Pop -> { StackEvent.POP -> {
Transitions.BackSlidingTransitionIn Transitions.BackSlidingTransitionIn
.togetherWith(Transitions.BackSlidingTransitionOut) .togetherWith(Transitions.BackSlidingTransitionOut)
} }