Skip to content

Commit

Permalink
refactor: Sync Surveys Dialog Compose (#2162)
Browse files Browse the repository at this point in the history
  • Loading branch information
akashmeruva9 committed Aug 5, 2024
1 parent 0e8e54c commit a2f9acf
Show file tree
Hide file tree
Showing 15 changed files with 571 additions and 110 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.mifos.core.common.utils

import android.content.Context
import android.net.ConnectivityManager
import android.net.NetworkCapabilities
import androidx.annotation.MainThread
import dagger.hilt.android.qualifiers.ApplicationContext
import javax.inject.Inject
import javax.inject.Singleton

@Singleton
class NetworkUtilsWrapper @Inject constructor(
@ApplicationContext private val context: Context
) {

@MainThread
fun isNetworkConnected(): Boolean {
val connectivityManager =
context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
val network = connectivityManager.activeNetwork ?: return false
val networkCapabilities =
connectivityManager.getNetworkCapabilities(network) ?: return false

return networkCapabilities.hasCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import com.mifos.core.designsystem.component.MifosScaffold
import com.mifos.core.designsystem.component.UpdateEndpointDialogScreen
import com.mifos.core.designsystem.icon.MifosIcons
import com.mifos.feature.settings.R
import com.mifos.feature.settings.syncSurvey.SyncSurveysDialog
import java.util.Locale

@Composable
Expand Down Expand Up @@ -104,6 +105,7 @@ fun SettingsScreen(
var showLanguageUpdateDialog by rememberSaveable { mutableStateOf(false) }
var showEndpointUpdateDialog by rememberSaveable { mutableStateOf(false) }
var showThemeUpdateDialog by rememberSaveable { mutableStateOf(false) }
var showSyncSurveyDialog by rememberSaveable { mutableStateOf(false) }

MifosScaffold(
icon = MifosIcons.arrowBack,
Expand All @@ -117,9 +119,7 @@ fun SettingsScreen(
SettingsCards(
settingsCardClicked = { item ->
when (item) {
SettingsCardItem.SYNC_SURVEY -> {
// TODO Implement Survey dialog
}
SettingsCardItem.SYNC_SURVEY -> showSyncSurveyDialog = true

SettingsCardItem.LANGUAGE -> showLanguageUpdateDialog = true

Expand All @@ -139,6 +139,14 @@ fun SettingsScreen(
}
}

if( showSyncSurveyDialog ) {
SyncSurveysDialog(
closeDialog = {
showSyncSurveyDialog = false
}
)
}

if (showLanguageUpdateDialog) {
MifosRadioButtonDialog(
titleResId = R.string.feature_settings_choose_language,
Expand Down
Loading

0 comments on commit a2f9acf

Please sign in to comment.