Skip to content

Commit

Permalink
Center sync issues resolved
Browse files Browse the repository at this point in the history
  • Loading branch information
Darkeye14 committed Nov 9, 2024
1 parent 30bc23d commit 528bdca
Show file tree
Hide file tree
Showing 12 changed files with 41 additions and 579 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ import com.mifos.core.designsystem.theme.White
import com.mifos.core.objects.group.Center
import com.mifos.core.ui.components.SelectionModeTopAppBar
import com.mifos.feature.center.R
import com.mifos.feature.center.sync_centers_dialog.SyncCenterDialogScreen
import kotlinx.coroutines.flow.flowOf

@Composable
Expand Down Expand Up @@ -105,7 +106,7 @@ fun CenterListScreen(

@Composable
fun CenterListScreen(
paddingValues : PaddingValues,
paddingValues: PaddingValues,
state: CenterListUiState,
createNewCenter: () -> Unit,
onRefresh: () -> Unit,
Expand All @@ -121,6 +122,9 @@ fun CenterListScreen(
isInSelectionMode = false
selectedItems.clear()
}
val sync = remember {
mutableStateOf(false)
}
BackHandler(enabled = isInSelectionMode) {
resetSelectionMode()
}
Expand Down Expand Up @@ -149,8 +153,9 @@ fun CenterListScreen(
actions = {
FilledTonalButton(
onClick = {
sync.value = true
syncClicked(selectedItems.toList())
resetSelectionMode()
// resetSelectionMode()
},
) {
Icon(
Expand Down Expand Up @@ -210,6 +215,17 @@ fun CenterListScreen(

is CenterListUiState.CenterListDb -> CenterListDbContent(centerList = state.centers)
}
if (sync.value) {
SyncCenterDialogScreen(
dismiss = {
sync.value = false
selectedItems.clear()
resetSelectionMode()
},
hide = { sync.value = false },
centers = selectedItems.toList()
)
}
PullRefreshIndicator(
refreshing = refreshState,
state = pullRefreshState,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ fun NavGraphBuilder.centerNavGraph(
centerListScreenRoute(
paddingValues = paddingValues,
createNewCenter = navController::navigateCreateCenterScreenRoute,
syncClicked = navController::navigateSyncCentersDialog, // TODO open sync dialog inside center list screen
syncClicked = { }, // TODO open sync dialog inside center list screen
onCenterSelect = navController::navigateCenterDetailsScreenRoute
)
centerDetailScreenRoute(
Expand All @@ -45,10 +45,7 @@ fun NavGraphBuilder.centerNavGraph(
createCenterScreenRoute(
onCreateSuccess = navController::popBackStack
)
syncCentersDialogRoute(
dismiss = navController::popBackStack,
hide = navController::popBackStack,
)

}
}

Expand Down Expand Up @@ -116,25 +113,6 @@ fun NavGraphBuilder.createCenterScreenRoute(
}
}

fun NavGraphBuilder.syncCentersDialogRoute(
dismiss : ()->Unit,
hide : ()->Unit,
) {
composable(
route = CenterScreens.SyncCenterPayloadsScreen.route,
arguments = listOf(navArgument(Constants.CENTER, builder = { type = NavType.IntType }))
) {
SyncCenterDialogScreen(
dismiss = dismiss,
hide = hide,
)
}
}

fun NavController.navigateSyncCentersDialog(list: List<Center>) {
navigate(CenterScreens.SyncCenterPayloadsScreen.arguments(list))
}

fun NavController.navigateCenterDetailsScreenRoute(centerId: Int) {
navigate(CenterScreens.CenterDetailScreen.argument(centerId))
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.mifos.feature.center.sync_centers_dialog

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
Expand All @@ -19,6 +20,7 @@ import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextAlign
Expand Down Expand Up @@ -102,7 +104,8 @@ fun SyncGroupDialogContent(
Column(
modifier = Modifier
.fillMaxWidth()
.padding(8.dp),
.padding(8.dp)
.background(Color.Yellow),
horizontalAlignment = Alignment.CenterHorizontally
) {
Text(
Expand Down Expand Up @@ -181,14 +184,14 @@ fun SyncGroupDialogContent(
Row(
modifier = Modifier.fillMaxWidth()
) {
if (uiData.isSyncSuccess) {

FilledTonalButton(
onClick = { okClicked() },
modifier = Modifier.weight(1f)
) {
Text(text = stringResource(id = R.string.feature_center_dialog_action_ok))
}
} else {

FilledTonalButton(
onClick = { cancelClicked() },
modifier = Modifier.weight(1f)
Expand All @@ -204,7 +207,7 @@ fun SyncGroupDialogContent(
) {
Text(text = stringResource(id = R.string.feature_center_hide))
}
}

}
}
}
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import com.mifos.feature.activate.navigation.navigateToActivateScreen
import com.mifos.feature.center.navigation.centerNavGraph
import com.mifos.feature.center.navigation.navigateCenterDetailsScreenRoute
import com.mifos.feature.center.navigation.navigateCreateCenterScreenRoute
import com.mifos.feature.center.navigation.navigateSyncCentersDialog
import com.mifos.feature.checker_inbox_task.navigation.checkerInboxTaskGraph
import com.mifos.feature.client.navigation.clientNavGraph
import com.mifos.feature.client.navigation.navigateClientDetailsScreen
Expand Down Expand Up @@ -117,7 +116,12 @@ fun Navigation(
savingsNavGraph(
navController = navController,
onBackPressed = navController::popBackStack,
loadMoreSavingsAccountInfo = { navController.navigateToDataTable(Constants.DATA_TABLE_NAME_SAVINGS, it) },
loadMoreSavingsAccountInfo = {
navController.navigateToDataTable(
Constants.DATA_TABLE_NAME_SAVINGS,
it
)
},
loadDocuments = {
navController.navigateToDocumentListScreen(
it,
Expand Down Expand Up @@ -171,11 +175,10 @@ fun Navigation(
paddingValues = padding,
onActivateCenter = navController::navigateToActivateScreen,
addSavingsAccount = {
// TODO() check this logic
navController.navigateToAddSavingsAccount(it, 0, true)
},

)
)

reportNavGraph(
navController = navController
Expand Down Expand Up @@ -209,12 +212,16 @@ fun Navigation(

dataTableNavGraph(
navController = navController,
clientCreated = { client , userStatus ->
clientCreated = { client, userStatus ->
navController.popBackStack()
navController.popBackStack()
Toast.makeText(context, context.resources.getString(R.string.client) + MifosResponseHandler.response, Toast.LENGTH_LONG).show()
Toast.makeText(
context,
context.resources.getString(R.string.client) + MifosResponseHandler.response,
Toast.LENGTH_LONG
).show()

if(userStatus == Constants.USER_ONLINE){
if (userStatus == Constants.USER_ONLINE) {
client.clientId?.let { navController.navigateClientDetailsScreen(it) }
}
}
Expand Down
Loading

0 comments on commit 528bdca

Please sign in to comment.