Skip to content
This repository has been archived by the owner on Nov 5, 2024. It is now read-only.

Commit

Permalink
Persist more menu state after backing one of it's screens
Browse files Browse the repository at this point in the history
  • Loading branch information
Iliyan Germanov committed Dec 7, 2021
1 parent b1b30aa commit f3ce3d2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
7 changes: 7 additions & 0 deletions app/src/main/java/com/ivy/wallet/ui/IvyContext.kt
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,13 @@ class IvyContext {
fun selectMainTab(tab: MainTab) {
mainTab = tab
}

var moreMenuExpanded = false
private set

fun setMoreMenuExpanded(expanded: Boolean) {
moreMenuExpanded = expanded
}
//------------------------------------------ State ---------------------------------------------

//------------------------------------------- BackStack ----------------------------------------
Expand Down
19 changes: 11 additions & 8 deletions app/src/main/java/com/ivy/wallet/ui/home/HomeTab.kt
Original file line number Diff line number Diff line change
Expand Up @@ -167,15 +167,20 @@ private fun BoxWithConstraintsScope.UI(
onSelectNextMonth: () -> Unit = {},
onSelectPreviousMonth: () -> Unit = {},
) {
val ivyContext = LocalIvyContext.current

var bufferModalData: BufferModalData? by remember { mutableStateOf(null) }
var currencyModalVisible by remember { mutableStateOf(false) }
var choosePeriodModal: ChoosePeriodModalData? by remember {
mutableStateOf(null)
}
var expanded by remember { mutableStateOf(false) }
var moreMenuExpanded by remember { mutableStateOf(ivyContext.moreMenuExpanded) }
val setMoreMenuExpanded = { expanded: Boolean ->
moreMenuExpanded = expanded
ivyContext.setMoreMenuExpanded(expanded)
}
val hideBalanceRowState = remember { mutableStateOf(false) }

val ivyContext = LocalIvyContext.current

Column(
modifier = Modifier
Expand All @@ -184,7 +189,7 @@ private fun BoxWithConstraintsScope.UI(
.verticalSwipeListener(
sensitivity = Constants.SWIPE_DOWN_THRESHOLD_OPEN_MORE_MENU,
onSwipeDown = {
expanded = true
setMoreMenuExpanded(true)
}
)
.horizontalSwipeListener(
Expand Down Expand Up @@ -230,7 +235,7 @@ private fun BoxWithConstraintsScope.UI(
balance = balance,
bufferDiff = bufferDiff,
onOpenMoreMenu = {
expanded = true
setMoreMenuExpanded(true)
},
onBalanceClick = {
onBalanceClick()
Expand Down Expand Up @@ -267,16 +272,14 @@ private fun BoxWithConstraintsScope.UI(
}

MoreMenu(
expanded = expanded,
expanded = moreMenuExpanded,
theme = theme,
balance = balance,
currency = currencyCode,
buffer = buffer,
onSwitchTheme = onSwitchTheme,

setExpanded = {
expanded = it
},
setExpanded = setMoreMenuExpanded,
onBufferClick = {
bufferModalData = BufferModalData(
balance = balance,
Expand Down

0 comments on commit f3ce3d2

Please sign in to comment.