kopia lustrzana https://github.com/vitorpamplona/amethyst
Removes unnecessary logs
rodzic
e7909beaab
commit
9aa5993748
|
@ -1,7 +1,6 @@
|
||||||
package com.vitorpamplona.amethyst.ui.navigation
|
package com.vitorpamplona.amethyst.ui.navigation
|
||||||
|
|
||||||
import android.graphics.Rect
|
import android.graphics.Rect
|
||||||
import android.util.Log
|
|
||||||
import android.view.ViewTreeObserver
|
import android.view.ViewTreeObserver
|
||||||
import androidx.compose.foundation.background
|
import androidx.compose.foundation.background
|
||||||
import androidx.compose.foundation.layout.Box
|
import androidx.compose.foundation.layout.Box
|
||||||
|
@ -44,7 +43,6 @@ import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
import kotlin.time.ExperimentalTime
|
import kotlin.time.ExperimentalTime
|
||||||
import kotlin.time.measureTimedValue
|
|
||||||
|
|
||||||
val bottomNavigationItems = listOf(
|
val bottomNavigationItems = listOf(
|
||||||
Route.Home,
|
Route.Home,
|
||||||
|
@ -141,72 +139,64 @@ fun AppBottomBar(navController: NavHostController, accountViewModel: AccountView
|
||||||
@OptIn(ExperimentalTime::class)
|
@OptIn(ExperimentalTime::class)
|
||||||
@Composable
|
@Composable
|
||||||
private fun NotifiableIcon(route: Route, selected: Boolean, accountViewModel: AccountViewModel) {
|
private fun NotifiableIcon(route: Route, selected: Boolean, accountViewModel: AccountViewModel) {
|
||||||
println("Notifiable Icon")
|
Box(Modifier.size(if ("Home" == route.base) 25.dp else 23.dp)) {
|
||||||
|
Icon(
|
||||||
|
painter = painterResource(id = route.icon),
|
||||||
|
contentDescription = null,
|
||||||
|
modifier = Modifier.size(if ("Home" == route.base) 24.dp else 20.dp),
|
||||||
|
tint = if (selected) MaterialTheme.colors.primary else Color.Unspecified
|
||||||
|
)
|
||||||
|
|
||||||
val (value, elapsed) = measureTimedValue {
|
val accountState by accountViewModel.accountLiveData.observeAsState()
|
||||||
Box(Modifier.size(if ("Home" == route.base) 25.dp else 23.dp)) {
|
val account = accountState?.account ?: return
|
||||||
Icon(
|
|
||||||
painter = painterResource(id = route.icon),
|
|
||||||
contentDescription = null,
|
|
||||||
modifier = Modifier.size(if ("Home" == route.base) 24.dp else 20.dp),
|
|
||||||
tint = if (selected) MaterialTheme.colors.primary else Color.Unspecified
|
|
||||||
)
|
|
||||||
|
|
||||||
println("Notifiable Icon")
|
// Notification
|
||||||
|
val dbState = LocalCache.live.observeAsState()
|
||||||
|
val db = dbState.value ?: return
|
||||||
|
|
||||||
val accountState by accountViewModel.accountLiveData.observeAsState()
|
val notifState = NotificationCache.live.observeAsState()
|
||||||
val account = accountState?.account ?: return
|
val notif = notifState.value ?: return
|
||||||
|
|
||||||
// Notification
|
var hasNewItems by remember { mutableStateOf<Boolean>(false) }
|
||||||
val dbState = LocalCache.live.observeAsState()
|
|
||||||
val db = dbState.value ?: return
|
|
||||||
|
|
||||||
val notifState = NotificationCache.live.observeAsState()
|
LaunchedEffect(key1 = notif) {
|
||||||
val notif = notifState.value ?: return
|
withContext(Dispatchers.IO) {
|
||||||
|
hasNewItems = route.hasNewItems(account, notif.cache, emptySet())
|
||||||
var hasNewItems by remember { mutableStateOf<Boolean>(false) }
|
|
||||||
|
|
||||||
LaunchedEffect(key1 = notif) {
|
|
||||||
withContext(Dispatchers.IO) {
|
|
||||||
hasNewItems = route.hasNewItems(account, notif.cache, emptySet())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
LaunchedEffect(key1 = db) {
|
LaunchedEffect(key1 = db) {
|
||||||
withContext(Dispatchers.IO) {
|
withContext(Dispatchers.IO) {
|
||||||
hasNewItems = route.hasNewItems(account, notif.cache, db)
|
hasNewItems = route.hasNewItems(account, notif.cache, db)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (hasNewItems) {
|
if (hasNewItems) {
|
||||||
|
Box(
|
||||||
|
Modifier
|
||||||
|
.width(10.dp)
|
||||||
|
.height(10.dp)
|
||||||
|
.align(Alignment.TopEnd)
|
||||||
|
) {
|
||||||
Box(
|
Box(
|
||||||
Modifier
|
modifier = Modifier
|
||||||
.width(10.dp)
|
.width(10.dp)
|
||||||
.height(10.dp)
|
.height(10.dp)
|
||||||
.align(Alignment.TopEnd)
|
.clip(shape = CircleShape)
|
||||||
|
.background(MaterialTheme.colors.primary),
|
||||||
|
contentAlignment = Alignment.TopEnd
|
||||||
) {
|
) {
|
||||||
Box(
|
Text(
|
||||||
|
"",
|
||||||
|
color = Color.White,
|
||||||
|
textAlign = TextAlign.Center,
|
||||||
|
fontSize = 12.sp,
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.width(10.dp)
|
.wrapContentHeight()
|
||||||
.height(10.dp)
|
.align(Alignment.TopEnd)
|
||||||
.clip(shape = CircleShape)
|
)
|
||||||
.background(MaterialTheme.colors.primary),
|
|
||||||
contentAlignment = Alignment.TopEnd
|
|
||||||
) {
|
|
||||||
Text(
|
|
||||||
"",
|
|
||||||
color = Color.White,
|
|
||||||
textAlign = TextAlign.Center,
|
|
||||||
fontSize = 12.sp,
|
|
||||||
modifier = Modifier
|
|
||||||
.wrapContentHeight()
|
|
||||||
.align(Alignment.TopEnd)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Log.d("Notification time", "$elapsed")
|
|
||||||
}
|
}
|
||||||
|
|
Ładowanie…
Reference in New Issue