mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-02 12:07:28 +00:00
Konsist: check that if sealed interface is used in parameter of Composable, it has the @Stable or @Immutable annotation
This commit is contained in:
committed by
Benoit Marty
parent
3092ca23f0
commit
21200df294
+3
-1
@@ -18,14 +18,16 @@ package io.element.android.libraries.designsystem.components.button
|
||||
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.Immutable
|
||||
import io.element.android.libraries.designsystem.theme.components.Button
|
||||
import io.element.android.libraries.designsystem.theme.components.IconButton
|
||||
import io.element.android.libraries.designsystem.theme.components.IconSource
|
||||
import io.element.android.libraries.designsystem.theme.components.TextButton
|
||||
|
||||
/**
|
||||
* A sealed class that represents the different visual styles that a button can have.
|
||||
* A sealed interface that represents the different visual styles that a button can have.
|
||||
*/
|
||||
@Immutable
|
||||
sealed interface ButtonVisuals {
|
||||
|
||||
val action: () -> Unit
|
||||
|
||||
+2
@@ -19,6 +19,7 @@ package io.element.android.libraries.designsystem.components.list
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.layout.widthIn
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.Immutable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.unit.DpSize
|
||||
@@ -34,6 +35,7 @@ import io.element.android.libraries.designsystem.theme.components.Text as TextCo
|
||||
/**
|
||||
* This is a helper to set default leading and trailing content for [ListItem]s.
|
||||
*/
|
||||
@Immutable
|
||||
sealed interface ListItemContent {
|
||||
/**
|
||||
* Default Switch content for [ListItem].
|
||||
|
||||
+2
@@ -37,6 +37,7 @@ import androidx.compose.material3.ButtonDefaults
|
||||
import androidx.compose.material3.LocalContentColor
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.Immutable
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
@@ -238,6 +239,7 @@ private fun ButtonInternal(
|
||||
}
|
||||
}
|
||||
|
||||
@Immutable
|
||||
sealed interface IconSource {
|
||||
val contentDescription: String?
|
||||
|
||||
|
||||
+2
@@ -23,6 +23,7 @@ import androidx.compose.material3.LocalContentColor
|
||||
import androidx.compose.material3.LocalTextStyle
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.CompositionLocalProvider
|
||||
import androidx.compose.runtime.Immutable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
@@ -134,6 +135,7 @@ fun ListItem(
|
||||
/**
|
||||
* The style to use for a [ListItem].
|
||||
*/
|
||||
@Immutable
|
||||
sealed interface ListItemStyle {
|
||||
data object Default : ListItemStyle
|
||||
data object Primary : ListItemStyle
|
||||
|
||||
+2
@@ -20,6 +20,7 @@ import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.PaddingValues
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.Immutable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.text.AnnotatedString
|
||||
import androidx.compose.ui.text.ExperimentalTextApi
|
||||
@@ -82,6 +83,7 @@ fun ListSupportingText(
|
||||
object ListSupportingTextDefaults {
|
||||
|
||||
/** Specifies the padding to use for the supporting text. */
|
||||
@Immutable
|
||||
sealed interface Padding {
|
||||
/** No padding. */
|
||||
data object None : Padding
|
||||
|
||||
+2
@@ -30,6 +30,7 @@ import androidx.compose.material3.SearchBarColors
|
||||
import androidx.compose.material3.SearchBarDefaults
|
||||
import androidx.compose.material3.TextFieldDefaults
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.Immutable
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
@@ -180,6 +181,7 @@ object ElementSearchBarDefaults {
|
||||
)
|
||||
}
|
||||
|
||||
@Immutable
|
||||
sealed interface SearchBarResultState<in T> {
|
||||
/** No search results are available yet (e.g. because the user hasn't entered a search term). */
|
||||
class NotSearching<T> : SearchBarResultState<T>
|
||||
|
||||
Reference in New Issue
Block a user