Skip to content

Commit ce83c15

Browse files
fix: Home Dropdown position
1 parent 50f7032 commit ce83c15

File tree

1 file changed

+34
-24
lines changed
  • mifospay/src/main/java/org/mifos/mobilewallet/mifospay/ui

1 file changed

+34
-24
lines changed

mifospay/src/main/java/org/mifos/mobilewallet/mifospay/ui/MifosApp.kt

+34-24
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,21 @@ package org.mifos.mobilewallet.mifospay.ui
22

33
import android.content.Context
44
import android.content.Intent
5+
import androidx.compose.animation.AnimatedVisibility
6+
import androidx.compose.foundation.layout.Box
57
import androidx.compose.foundation.layout.Column
68
import androidx.compose.foundation.layout.Row
79
import androidx.compose.foundation.layout.WindowInsets
810
import androidx.compose.foundation.layout.WindowInsetsSides
911
import androidx.compose.foundation.layout.consumeWindowInsets
1012
import androidx.compose.foundation.layout.fillMaxSize
13+
import androidx.compose.foundation.layout.fillMaxWidth
1114
import androidx.compose.foundation.layout.only
1215
import androidx.compose.foundation.layout.padding
1316
import androidx.compose.foundation.layout.safeDrawing
1417
import androidx.compose.foundation.layout.safeDrawingPadding
1518
import androidx.compose.foundation.layout.windowInsetsPadding
19+
import androidx.compose.foundation.layout.wrapContentSize
1620
import androidx.compose.material3.DropdownMenu
1721
import androidx.compose.material3.DropdownMenuItem
1822
import androidx.compose.material3.ExperimentalMaterial3Api
@@ -33,6 +37,7 @@ import androidx.compose.runtime.mutableStateOf
3337
import androidx.compose.runtime.remember
3438
import androidx.compose.runtime.saveable.rememberSaveable
3539
import androidx.compose.runtime.setValue
40+
import androidx.compose.ui.Alignment
3641
import androidx.compose.ui.ExperimentalComposeUiApi
3742
import androidx.compose.ui.Modifier
3843
import androidx.compose.ui.composed
@@ -70,6 +75,7 @@ import org.mifos.mobilewallet.mifospay.settings.ui.SettingsActivity
7075
)
7176
@Composable
7277
fun MifosApp(appState: MifosAppState) {
78+
val context = LocalContext.current
7379
val shouldShowGradientBackground =
7480
appState.currentTopLevelDestination == TopLevelDestination.HOME
7581
var showHomeMenuOption by rememberSaveable { mutableStateOf(false) }
@@ -98,12 +104,34 @@ fun MifosApp(appState: MifosAppState) {
98104
}
99105

100106
if (showHomeMenuOption) {
101-
ShowHomeMenuOptions(
102-
showHomeMenuOption = true,
103-
onDismiss = {
104-
showHomeMenuOption = false
107+
AnimatedVisibility(true) {
108+
Box(
109+
modifier = Modifier
110+
.fillMaxWidth()
111+
.wrapContentSize(Alignment.TopEnd)
112+
.padding(end = 24.dp)
113+
) {
114+
DropdownMenu(
115+
expanded = showHomeMenuOption,
116+
onDismissRequest = { showHomeMenuOption = false }
117+
) {
118+
DropdownMenuItem(
119+
text = { Text(stringResource(id = R.string.faq)) },
120+
onClick = {
121+
showHomeMenuOption = false
122+
context.startActivity(Intent(context, FAQActivity::class.java))
123+
}
124+
)
125+
DropdownMenuItem(
126+
text = { Text(stringResource(id = R.string.settings)) },
127+
onClick = {
128+
showHomeMenuOption = false
129+
context.startActivity(Intent(context, SettingsActivity::class.java))
130+
}
131+
)
132+
}
105133
}
106-
)
134+
}
107135
}
108136

109137
// TODO unread destinations to show dot indicator
@@ -121,7 +149,7 @@ fun MifosApp(appState: MifosAppState) {
121149
if (appState.shouldShowBottomBar) {
122150
MifosBottomBar(
123151
destinations = appState.topLevelDestinations,
124-
destinationsWithUnreadResources = emptySet() ,
152+
destinationsWithUnreadResources = emptySet(),
125153
onNavigateToDestination = appState::navigateToTopLevelDestination,
126154
currentDestination = appState.currentDestination,
127155
modifier = Modifier.testTag("NiaBottomBar"),
@@ -189,24 +217,6 @@ fun MifosApp(appState: MifosAppState) {
189217
}
190218
}
191219

192-
@Composable
193-
fun ShowHomeMenuOptions(showHomeMenuOption: Boolean, onDismiss: () -> Unit) {
194-
val context = LocalContext.current
195-
DropdownMenu(
196-
expanded = showHomeMenuOption,
197-
onDismissRequest = { onDismiss() }
198-
) {
199-
DropdownMenuItem(
200-
text = { Text(stringResource(id = R.string.faq)) },
201-
onClick = { context.startActivity(Intent(context, FAQActivity::class.java)) }
202-
)
203-
DropdownMenuItem(
204-
text = { Text(stringResource(id = R.string.settings)) },
205-
onClick = { context.startActivity(Intent(context, SettingsActivity::class.java)) }
206-
)
207-
}
208-
}
209-
210220
@Composable
211221
private fun MifosNavRail(
212222
destinations: List<TopLevelDestination>,

0 commit comments

Comments
 (0)