Reverting background refactoring due to color being stuck in recompositions.
This commit is contained in:
@@ -114,9 +114,6 @@ fun NoteComposeInner(
|
|||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
navController: NavController
|
navController: NavController
|
||||||
) {
|
) {
|
||||||
val defaultBackgroundColor = MaterialTheme.colors.background
|
|
||||||
val defaultPrimaryColor = MaterialTheme.colors.primary
|
|
||||||
|
|
||||||
val accountState by accountViewModel.accountLiveData.observeAsState()
|
val accountState by accountViewModel.accountLiveData.observeAsState()
|
||||||
val account = accountState?.account ?: return
|
val account = accountState?.account ?: return
|
||||||
val loggedIn = account.userProfile()
|
val loggedIn = account.userProfile()
|
||||||
@@ -178,7 +175,7 @@ fun NoteComposeInner(
|
|||||||
} else if (noteEvent is FileStorageHeaderEvent) {
|
} else if (noteEvent is FileStorageHeaderEvent) {
|
||||||
FileStorageHeaderDisplay(note)
|
FileStorageHeaderDisplay(note)
|
||||||
} else {
|
} else {
|
||||||
var backgroundColor by remember { mutableStateOf<Color>(defaultBackgroundColor) }
|
var isNew by remember { mutableStateOf<Boolean>(false) }
|
||||||
|
|
||||||
LaunchedEffect(key1 = routeForLastRead) {
|
LaunchedEffect(key1 = routeForLastRead) {
|
||||||
withContext(Dispatchers.IO) {
|
withContext(Dispatchers.IO) {
|
||||||
@@ -186,25 +183,23 @@ fun NoteComposeInner(
|
|||||||
val lastTime = NotificationCache.load(it)
|
val lastTime = NotificationCache.load(it)
|
||||||
|
|
||||||
val createdAt = note.createdAt()
|
val createdAt = note.createdAt()
|
||||||
val isNew = if (createdAt != null) {
|
if (createdAt != null) {
|
||||||
NotificationCache.markAsRead(it, createdAt)
|
NotificationCache.markAsRead(it, createdAt)
|
||||||
createdAt > lastTime
|
isNew = createdAt > lastTime
|
||||||
} else {
|
}
|
||||||
false
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
backgroundColor = if (isNew) {
|
val backgroundColor = if (isNew) {
|
||||||
val newColor = defaultPrimaryColor.copy(0.12f)
|
val newColor = MaterialTheme.colors.primary.copy(0.12f)
|
||||||
if (parentBackgroundColor != null) {
|
if (parentBackgroundColor != null) {
|
||||||
newColor.compositeOver(parentBackgroundColor)
|
newColor.compositeOver(parentBackgroundColor)
|
||||||
} else {
|
} else {
|
||||||
newColor.compositeOver(defaultBackgroundColor)
|
newColor.compositeOver(MaterialTheme.colors.background)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
parentBackgroundColor ?: defaultBackgroundColor
|
parentBackgroundColor ?: MaterialTheme.colors.background
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Column(
|
Column(
|
||||||
@@ -234,8 +229,7 @@ fun NoteComposeInner(
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
onLongClick = { popupExpanded = true }
|
onLongClick = { popupExpanded = true }
|
||||||
)
|
).background(backgroundColor)
|
||||||
.background(backgroundColor)
|
|
||||||
) {
|
) {
|
||||||
Row(
|
Row(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
|
|||||||
Reference in New Issue
Block a user