Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[2656] - Bug: Resolved Swipe Refresh Not Working in RecentTransaction Screen Compose #2617

Merged
Merged
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
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.mifos.mobile.ui.recent_transactions

import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
Expand Down Expand Up @@ -91,60 +92,70 @@ fun RecentTransactionScreen(
) {
val context = LocalContext.current
val pullRefreshState = rememberPullToRefreshState()
val scrollState = rememberScrollState()

MFScaffold(
topBarTitleResId = R.string.recent_transactions,
navigateBack = navigateBack,
scaffoldContent = { paddingValues ->
Box(modifier = Modifier.padding(paddingValues = paddingValues)) {
when (uiState) {
is RecentTransactionUiState.Error -> {
MifosErrorComponent(
isNetworkConnected = Network.isConnected(context),
isRetryEnabled = true,
onRetry = onRetry
)
}

is RecentTransactionUiState.Loading -> {
MifosProgressIndicatorOverlay()
}
Box(
Modifier
.fillMaxSize()
.nestedScroll(pullRefreshState.nestedScrollConnection)){
Column(modifier = Modifier
.fillMaxSize()
.verticalScroll(scrollState), verticalArrangement = Arrangement.Center) {

is RecentTransactionUiState.Success -> {
if (uiState.transactions.isEmpty()) {
EmptyDataView(
icon = R.drawable.ic_error_black_24dp,
error = R.string.no_transaction,
modifier = Modifier.fillMaxSize()
)
} else {
RecentTransactionsContent(
transactions = uiState.transactions,
isPaginating = isPaginating,
loadMore = loadMore,
canPaginate = uiState.canPaginate
when (uiState) {
is RecentTransactionUiState.Error -> {
MifosErrorComponent(
isNetworkConnected = Network.isConnected(context),
isRetryEnabled = true,
onRetry = onRetry
)
}

is RecentTransactionUiState.Loading -> {
MifosProgressIndicatorOverlay()
}

is RecentTransactionUiState.Success -> {
if (uiState.transactions.isEmpty()) {
EmptyDataView(
icon = R.drawable.ic_error_black_24dp,
error = R.string.no_transaction,
modifier = Modifier.fillMaxSize()
)
} else {
RecentTransactionsContent(
transactions = uiState.transactions,
isPaginating = isPaginating,
loadMore = loadMore,
canPaginate = uiState.canPaginate
)
}
}
}
}
}
}
)
if (pullRefreshState.isRefreshing) {
LaunchedEffect(key1 = true) {
onRefresh()
}
}
LaunchedEffect(key1 = isRefreshing) {
if (isRefreshing)
pullRefreshState.startRefresh()
else
pullRefreshState.endRefresh()
}

if (pullRefreshState.isRefreshing) {
LaunchedEffect(key1 = true) {
onRefresh()
PullToRefreshContainer(
state = pullRefreshState,
modifier = Modifier.padding(top=24.dp).align(Alignment.TopCenter),
)
}
}
}
LaunchedEffect(key1 = isRefreshing) {
if (isRefreshing)
pullRefreshState.startRefresh()
else
pullRefreshState.endRefresh()
}

PullToRefreshContainer(
state = pullRefreshState,
)
}

Expand Down
Loading