Further breaks down the bottom bar to facilitate recompositions.
This commit is contained in:
@@ -67,11 +67,16 @@ fun keyboardAsState(): State<Keyboard> {
|
|||||||
view.getWindowVisibleDisplayFrame(rect)
|
view.getWindowVisibleDisplayFrame(rect)
|
||||||
val screenHeight = view.rootView.height
|
val screenHeight = view.rootView.height
|
||||||
val keypadHeight = screenHeight - rect.bottom
|
val keypadHeight = screenHeight - rect.bottom
|
||||||
keyboardState.value = if (keypadHeight > screenHeight * 0.15) {
|
|
||||||
|
val newKeyboardValue = if (keypadHeight > screenHeight * 0.15) {
|
||||||
Keyboard.Opened
|
Keyboard.Opened
|
||||||
} else {
|
} else {
|
||||||
Keyboard.Closed
|
Keyboard.Closed
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (newKeyboardValue != keyboardState.value) {
|
||||||
|
keyboardState.value = newKeyboardValue
|
||||||
|
}
|
||||||
}
|
}
|
||||||
view.viewTreeObserver.addOnGlobalLayoutListener(onGlobalListener)
|
view.viewTreeObserver.addOnGlobalLayoutListener(onGlobalListener)
|
||||||
|
|
||||||
@@ -87,18 +92,27 @@ fun keyboardAsState(): State<Keyboard> {
|
|||||||
fun AppBottomBar(accountViewModel: AccountViewModel, navEntryState: State<NavBackStackEntry?>, nav: (Route, Boolean) -> Unit) {
|
fun AppBottomBar(accountViewModel: AccountViewModel, navEntryState: State<NavBackStackEntry?>, nav: (Route, Boolean) -> Unit) {
|
||||||
val isKeyboardOpen by keyboardAsState()
|
val isKeyboardOpen by keyboardAsState()
|
||||||
if (isKeyboardOpen == Keyboard.Closed) {
|
if (isKeyboardOpen == Keyboard.Closed) {
|
||||||
Column() {
|
RenderBottomMenu(accountViewModel, navEntryState, nav)
|
||||||
Divider(
|
}
|
||||||
thickness = 0.25.dp
|
}
|
||||||
)
|
|
||||||
BottomNavigation(
|
@Composable
|
||||||
modifier = Modifier,
|
private fun RenderBottomMenu(
|
||||||
elevation = 0.dp,
|
accountViewModel: AccountViewModel,
|
||||||
backgroundColor = MaterialTheme.colors.background
|
navEntryState: State<NavBackStackEntry?>,
|
||||||
) {
|
nav: (Route, Boolean) -> Unit
|
||||||
bottomNavigationItems.forEach { item ->
|
) {
|
||||||
HasNewItemsIcon(item, accountViewModel, navEntryState, nav)
|
Column() {
|
||||||
}
|
Divider(
|
||||||
|
thickness = 0.25.dp
|
||||||
|
)
|
||||||
|
BottomNavigation(
|
||||||
|
modifier = Modifier,
|
||||||
|
elevation = 0.dp,
|
||||||
|
backgroundColor = MaterialTheme.colors.background
|
||||||
|
) {
|
||||||
|
bottomNavigationItems.forEach { item ->
|
||||||
|
HasNewItemsIcon(item, accountViewModel, navEntryState, nav)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -180,6 +194,18 @@ private fun RowScope.BottomIcon(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NavigationIcon(icon, size, iconSize, selected, hasNewItems, onClick)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
private fun RowScope.NavigationIcon(
|
||||||
|
icon: Int,
|
||||||
|
size: Dp,
|
||||||
|
iconSize: Dp,
|
||||||
|
selected: Boolean,
|
||||||
|
hasNewItems: Boolean,
|
||||||
|
onClick: (Boolean) -> Unit
|
||||||
|
) {
|
||||||
BottomNavigationItem(
|
BottomNavigationItem(
|
||||||
icon = {
|
icon = {
|
||||||
NotifiableIcon(
|
NotifiableIcon(
|
||||||
|
|||||||
Reference in New Issue
Block a user