Modifies the behavior of new posts to clear the background color after 5 seconds
This commit is contained in:
@@ -205,6 +205,7 @@ import com.vitorpamplona.quartz.nip90Dvms.NIP90ContentDiscoveryResponseEvent
|
|||||||
import com.vitorpamplona.quartz.nip90Dvms.NIP90StatusEvent
|
import com.vitorpamplona.quartz.nip90Dvms.NIP90StatusEvent
|
||||||
import com.vitorpamplona.quartz.nip94FileMetadata.FileHeaderEvent
|
import com.vitorpamplona.quartz.nip94FileMetadata.FileHeaderEvent
|
||||||
import com.vitorpamplona.quartz.nip99Classifieds.ClassifiedsEvent
|
import com.vitorpamplona.quartz.nip99Classifieds.ClassifiedsEvent
|
||||||
|
import kotlinx.coroutines.delay
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun NoteCompose(
|
fun NoteCompose(
|
||||||
@@ -363,25 +364,33 @@ fun calculateBackgroundColor(
|
|||||||
): MutableState<Color> {
|
): MutableState<Color> {
|
||||||
val defaultBackgroundColor = MaterialTheme.colorScheme.background
|
val defaultBackgroundColor = MaterialTheme.colorScheme.background
|
||||||
val newItemColor = MaterialTheme.colorScheme.newItemBackgroundColor
|
val newItemColor = MaterialTheme.colorScheme.newItemBackgroundColor
|
||||||
return remember(createdAt) {
|
val bgColor =
|
||||||
mutableStateOf(
|
remember(createdAt) {
|
||||||
if (routeForLastRead != null) {
|
mutableStateOf(
|
||||||
val isNew = accountViewModel.loadAndMarkAsRead(routeForLastRead, createdAt)
|
if (routeForLastRead != null) {
|
||||||
|
val isNew = accountViewModel.loadAndMarkAsRead(routeForLastRead, createdAt)
|
||||||
|
|
||||||
if (isNew) {
|
if (isNew) {
|
||||||
if (parentBackgroundColor != null) {
|
if (parentBackgroundColor != null) {
|
||||||
newItemColor.compositeOver(parentBackgroundColor.value)
|
newItemColor.compositeOver(parentBackgroundColor.value)
|
||||||
|
} else {
|
||||||
|
newItemColor.compositeOver(defaultBackgroundColor)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
newItemColor.compositeOver(defaultBackgroundColor)
|
parentBackgroundColor?.value ?: Color.Transparent
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
parentBackgroundColor?.value ?: Color.Transparent
|
parentBackgroundColor?.value ?: Color.Transparent
|
||||||
}
|
},
|
||||||
} else {
|
)
|
||||||
parentBackgroundColor?.value ?: Color.Transparent
|
}
|
||||||
},
|
|
||||||
)
|
LaunchedEffect(createdAt) {
|
||||||
|
delay(5000)
|
||||||
|
bgColor.value = parentBackgroundColor?.value ?: Color.Transparent
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return bgColor
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
|
|||||||
Reference in New Issue
Block a user