Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion cmp-android/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*
* See https://github.com/openMF/android-client/blob/master/LICENSE.md
*/

import org.mifos.MifosBuildType
import org.mifos.dynamicVersion

Expand Down Expand Up @@ -153,4 +154,4 @@ dependencyGuard {
modules = true
tree = true
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@ private val SCRIM_COLOR: Int = Color.TRANSPARENT
* [here](https://github.com/android/nowinandroid/blob/689ef92e41427ab70f82e2c9fe59755441deae92/app/src/main/kotlin/com/google/samples/apps/nowinandroid/MainActivity.kt#L94).
*/
@Suppress("MaxLineLength")
fun ComponentActivity.setupEdgeToEdge(
appThemeFlow: Flow<DarkThemeConfig>,
) {
fun ComponentActivity.setupEdgeToEdge(appThemeFlow: Flow<DarkThemeConfig>) {
lifecycleScope.launch {
lifecycle.repeatOnLifecycle(state = Lifecycle.State.STARTED) {
combine(
Expand All @@ -55,12 +53,13 @@ fun ComponentActivity.setupEdgeToEdge(
// This handles all the settings to go edge-to-edge. We are using a transparent
// scrim for system bars and switching between "light" and "dark" based on the
// system and internal app theme settings.
val style = SystemBarStyle.auto(
darkScrim = SCRIM_COLOR,
lightScrim = SCRIM_COLOR,
// Disabling Dark Mode for this app
detectDarkMode = { false },
)
val style =
SystemBarStyle.auto(
darkScrim = SCRIM_COLOR,
lightScrim = SCRIM_COLOR,
// Disabling Dark Mode for this app
detectDarkMode = { false },
)
enableEdgeToEdge(statusBarStyle = style, navigationBarStyle = style)
}
}
Expand All @@ -75,9 +74,10 @@ fun ComponentActivity.setupEdgeToEdge(
private fun ComponentActivity.isSystemInDarkModeFlow(): Flow<Boolean> =
callbackFlow {
channel.trySend(element = resources.configuration.isSystemInDarkMode)
val listener = Consumer<Configuration> {
channel.trySend(element = it.isSystemInDarkMode)
}
val listener =
Consumer<Configuration> {
channel.trySend(element = it.isSystemInDarkMode)
}
addOnConfigurationChangedListener(listener = listener)
awaitClose { removeOnConfigurationChangedListener(listener = listener) }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ fun MifosBreadcrumbNavBar(
isActive = index == routes.lastIndex,
onClick = {
if (index != routes.lastIndex && route != "...") {
navController.previousBackStackEntry
?.savedStateHandle
?.set("shouldRefresh", true)
navController.popBackStack(route, inclusive = false)
}
},
Expand All @@ -93,10 +96,13 @@ fun MifosBreadcrumbNavBar(
}
}

IconButton(
onClick = { navController.popBackStack() },
modifier = Modifier.size(DesignToken.sizes.iconMedium),
) {

IconButton(onClick = {
navController.previousBackStackEntry
?.savedStateHandle
?.set("shouldRefresh", true)
navController.popBackStack()
}) {
Icon(
painter = painterResource(Res.drawable.bread_crumb_back_icon),
contentDescription = "Back",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
Expand Down Expand Up @@ -88,6 +90,20 @@ internal fun ClientProfileDetailsScreen(
viewModel: ClientProfileDetailsViewModel = koinViewModel(),
) {
val state by viewModel.stateFlow.collectAsStateWithLifecycle()
val currentBackStackEntry = navController.currentBackStackEntry
val savedStateHandle = currentBackStackEntry?.savedStateHandle

val profileUpdated by savedStateHandle
?.getStateFlow("shouldRefresh", false)
?.collectAsStateWithLifecycle(initialValue = false)
?: remember { mutableStateOf(false) }

LaunchedEffect(profileUpdated) {
if (profileUpdated) {
viewModel.trySendAction(ClientProfileDetailsAction.OnRetry)
savedStateHandle?.set("shouldRefresh", false) // reset after refresh
}
}

EventsEffect(viewModel.eventFlow) { event ->
when (event) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.lifecycle.compose.collectAsStateWithLifecycle
Expand Down Expand Up @@ -61,6 +63,20 @@ internal fun ClientProfileScreen(
viewModel: ClientProfileViewModel = koinViewModel(),
) {
val state by viewModel.stateFlow.collectAsStateWithLifecycle()
val currentBackStackEntry = navController.currentBackStackEntry
val savedStateHandle = currentBackStackEntry?.savedStateHandle

val profileUpdated by savedStateHandle
?.getStateFlow("shouldRefresh", false)
?.collectAsStateWithLifecycle(initialValue = false)
?: remember { mutableStateOf(false) }

LaunchedEffect(profileUpdated) {
if (profileUpdated) {
viewModel.trySendAction(ClientProfileAction.OnRetry)
savedStateHandle?.set("shouldRefresh", false) // reset after refresh
}
}

EventsEffect(viewModel.eventFlow) { event ->
when (event) {
Expand Down