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
import androidx.compose.runtime.Immutable
@Immutable
enum class BrowseLayout {
LIST, GRID
}

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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