Skip to content

Commit 1fbc853

Browse files
No Internet dialog Handling
1 parent 7da371e commit 1fbc853

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

coremodule/src/main/java/com/vimalraj/coremodule/common/utils/ViewUtils.kt

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@ import androidx.compose.foundation.Image
44
import androidx.compose.foundation.layout.Box
55
import androidx.compose.foundation.layout.Column
66
import androidx.compose.foundation.layout.fillMaxSize
7+
import androidx.compose.foundation.layout.fillMaxWidth
78
import androidx.compose.foundation.layout.height
89
import androidx.compose.foundation.layout.padding
910
import androidx.compose.foundation.layout.width
11+
import androidx.compose.foundation.shape.RoundedCornerShape
1012
import androidx.compose.material3.AlertDialog
1113
import androidx.compose.material3.CircularProgressIndicator
1214
import androidx.compose.material3.Icon
@@ -26,6 +28,7 @@ import androidx.compose.ui.res.stringResource
2628
import androidx.compose.ui.text.font.FontStyle
2729
import androidx.compose.ui.unit.dp
2830
import androidx.compose.ui.unit.sp
31+
import androidx.compose.ui.window.DialogProperties
2932
import com.vimalraj.coremodule.R
3033

3134
@Composable
@@ -120,4 +123,36 @@ fun GenericAlertDialog(
120123
}
121124
}
122125
)
126+
}
127+
128+
129+
@Composable
130+
fun NoInternetAlertDialog(
131+
onDismissRequest: () -> Unit,
132+
) {
133+
Box(modifier = Modifier.fillMaxSize(), contentAlignment = Alignment.Center) {
134+
AlertDialog(
135+
modifier = Modifier.fillMaxWidth(0.9f),
136+
properties = DialogProperties(
137+
usePlatformDefaultWidth = false,
138+
decorFitsSystemWindows = true,
139+
dismissOnClickOutside = true,
140+
dismissOnBackPress = true
141+
),
142+
shape = RoundedCornerShape(8.dp),
143+
onDismissRequest = {
144+
onDismissRequest()
145+
},
146+
confirmButton = {
147+
TextButton(onClick = {
148+
onDismissRequest()
149+
}) {
150+
Text(text = stringResource(R.string.ok))
151+
}
152+
},
153+
title = {
154+
Text(text = stringResource(R.string.no_internet_message), fontSize = 16.sp)
155+
},
156+
)
157+
}
123158
}

coremodule/src/main/res/values/strings.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,6 @@
55
<string name="are_you_sure_to_delete_all">Are you sure to delete all ?</string>
66
<string name="delete_all_desc">All the tasks will be deleted once you click confirm. Click Confirm to delete or Dismiss.</string>
77
<string name="something_went_wrong_try_again_later">Something went wrong. Try again later.</string>
8+
<string name="ok">OK</string>
9+
<string name="no_internet_message">No Internet. Please check your connection.</string>
810
</resources>

0 commit comments

Comments
 (0)