|
@@ -0,0 +1,264 @@
|
|
|
+package com.vpn.fastestvpnservice.screensTV.helpScreensAll
|
|
|
+
|
|
|
+import android.util.Log
|
|
|
+import androidx.compose.foundation.background
|
|
|
+import androidx.compose.foundation.layout.Arrangement
|
|
|
+import androidx.compose.foundation.layout.Box
|
|
|
+import androidx.compose.foundation.layout.Column
|
|
|
+import androidx.compose.foundation.layout.ColumnScope
|
|
|
+import androidx.compose.foundation.layout.Row
|
|
|
+import androidx.compose.foundation.layout.Spacer
|
|
|
+import androidx.compose.foundation.layout.fillMaxHeight
|
|
|
+import androidx.compose.foundation.layout.fillMaxSize
|
|
|
+import androidx.compose.foundation.layout.fillMaxWidth
|
|
|
+import androidx.compose.foundation.layout.height
|
|
|
+import androidx.compose.foundation.layout.padding
|
|
|
+import androidx.compose.foundation.layout.size
|
|
|
+import androidx.compose.foundation.text.KeyboardActions
|
|
|
+import androidx.compose.foundation.text.KeyboardOptions
|
|
|
+import androidx.compose.material.Icon
|
|
|
+import androidx.compose.material.IconButton
|
|
|
+import androidx.compose.material.Surface
|
|
|
+import androidx.compose.material.Text
|
|
|
+import androidx.compose.material3.CircularProgressIndicator
|
|
|
+import androidx.compose.material3.MaterialTheme
|
|
|
+import androidx.compose.material3.SnackbarHostState
|
|
|
+import androidx.compose.material3.TextField
|
|
|
+import androidx.compose.material3.TextFieldDefaults
|
|
|
+import androidx.compose.runtime.Composable
|
|
|
+import androidx.compose.runtime.LaunchedEffect
|
|
|
+import androidx.compose.runtime.getValue
|
|
|
+import androidx.compose.runtime.livedata.observeAsState
|
|
|
+import androidx.compose.runtime.mutableFloatStateOf
|
|
|
+import androidx.compose.runtime.mutableStateOf
|
|
|
+import androidx.compose.runtime.remember
|
|
|
+import androidx.compose.runtime.rememberCoroutineScope
|
|
|
+import androidx.compose.runtime.setValue
|
|
|
+import androidx.compose.ui.Alignment
|
|
|
+import androidx.compose.ui.Modifier
|
|
|
+import androidx.compose.ui.graphics.Color
|
|
|
+import androidx.compose.ui.platform.LocalFocusManager
|
|
|
+import androidx.compose.ui.platform.LocalSoftwareKeyboardController
|
|
|
+import androidx.compose.ui.res.colorResource
|
|
|
+import androidx.compose.ui.res.painterResource
|
|
|
+import androidx.compose.ui.text.input.ImeAction
|
|
|
+import androidx.compose.ui.text.input.KeyboardType
|
|
|
+import androidx.compose.ui.unit.dp
|
|
|
+import androidx.lifecycle.viewmodel.compose.viewModel
|
|
|
+import androidx.navigation.NavHostController
|
|
|
+import com.vpn.fastestvpnservice.R
|
|
|
+import com.vpn.fastestvpnservice.ui.theme.customTypography
|
|
|
+import com.vpn.fastestvpnservice.viewmodels.HelpViewModel
|
|
|
+import com.vpn.fastestvpnservice.views.CustomValidation
|
|
|
+import com.vpn.fastestvpnservice.views.ShowCustomSnackBar
|
|
|
+import kotlinx.coroutines.delay
|
|
|
+import kotlinx.coroutines.launch
|
|
|
+
|
|
|
+@Composable
|
|
|
+fun EmailUsScreenTV(navHostController: NavHostController) {
|
|
|
+ var textChanged by remember { mutableStateOf("") }
|
|
|
+ val keyboardController = LocalSoftwareKeyboardController.current
|
|
|
+ val focusManager = LocalFocusManager.current
|
|
|
+ val snackBarState = remember { SnackbarHostState() }
|
|
|
+ val snackBarStateRed = remember { SnackbarHostState() }
|
|
|
+ var isShowLoader by remember { mutableStateOf(false) }
|
|
|
+
|
|
|
+ Box(
|
|
|
+ modifier = Modifier
|
|
|
+ .background(colorResource(id = R.color.background_color_gray))
|
|
|
+ .fillMaxSize()
|
|
|
+ ) {
|
|
|
+ ShowCustomSnackBar(snackBarState, R.color.switch_green, R.color.white)
|
|
|
+ ShowCustomSnackBar(snackBarStateRed, R.color.Red, R.color.white)
|
|
|
+
|
|
|
+ if (isShowLoader) {
|
|
|
+ var progress by remember { mutableFloatStateOf(0.1F) }
|
|
|
+
|
|
|
+ LaunchedEffect(key1 = Unit) {
|
|
|
+ while (true) {
|
|
|
+ for (i in 1..100) {
|
|
|
+ progress = i.toFloat()/100F
|
|
|
+ delay(150)
|
|
|
+ }
|
|
|
+ progress = 0.1F
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ CircularProgressIndicator(
|
|
|
+ progress = { progress },
|
|
|
+ modifier = Modifier
|
|
|
+ .size(50.dp)
|
|
|
+ .align(Alignment.Center),
|
|
|
+ color = colorResource(id = R.color.yellow_text),
|
|
|
+ strokeWidth = 5.dp,
|
|
|
+ )
|
|
|
+ }
|
|
|
+
|
|
|
+ Column(
|
|
|
+ modifier = Modifier
|
|
|
+ .fillMaxSize()
|
|
|
+ .background(Color.Transparent),
|
|
|
+ verticalArrangement = Arrangement.Top,
|
|
|
+ horizontalAlignment = Alignment.Start
|
|
|
+ ) {
|
|
|
+ Spacer(modifier = Modifier.height(50.dp))
|
|
|
+
|
|
|
+ ShowHeaderEUTV(
|
|
|
+ navHostController = navHostController,
|
|
|
+ textChanged,
|
|
|
+ snackBarState,
|
|
|
+ snackBarStateRed,
|
|
|
+ isShowLoader = {
|
|
|
+ isShowLoader = it
|
|
|
+ }
|
|
|
+ ) {
|
|
|
+ textChanged = it
|
|
|
+ }
|
|
|
+
|
|
|
+ Text(text = "Your message:",
|
|
|
+ color = colorResource(id = R.color.dark_blue_gray_text),
|
|
|
+ style = MaterialTheme.typography.bodyMedium,
|
|
|
+ modifier = Modifier
|
|
|
+ .padding(start = 20.dp, top = 25.dp)
|
|
|
+ .align(Alignment.Start)
|
|
|
+ )
|
|
|
+
|
|
|
+ TextField(
|
|
|
+ value = textChanged,
|
|
|
+ onValueChange = {
|
|
|
+ textChanged = it
|
|
|
+ },
|
|
|
+
|
|
|
+ textStyle = MaterialTheme.typography.customTypography.bodyMedium.copy(
|
|
|
+ MaterialTheme.colorScheme.primary
|
|
|
+ ),
|
|
|
+ modifier = Modifier
|
|
|
+ .padding(top = 2.dp, start = 5.dp, end = 5.dp, bottom = 10.dp)
|
|
|
+ .fillMaxWidth()
|
|
|
+ .align(Alignment.Start)
|
|
|
+ .fillMaxHeight()
|
|
|
+// .border(
|
|
|
+// 1.dp,
|
|
|
+// color = colorResource(id = R.color.Black),
|
|
|
+// ),
|
|
|
+ ,
|
|
|
+ colors = TextFieldDefaults.colors(
|
|
|
+ focusedLabelColor = Color.Blue,
|
|
|
+ unfocusedContainerColor = colorResource(id = R.color.transparent),
|
|
|
+ focusedContainerColor = colorResource(id = R.color.transparent),
|
|
|
+ focusedIndicatorColor = colorResource(id = R.color.transparent),
|
|
|
+ disabledIndicatorColor = colorResource(id = R.color.transparent),
|
|
|
+ unfocusedIndicatorColor = colorResource(id = R.color.transparent),
|
|
|
+ cursorColor = MaterialTheme.colorScheme.primary
|
|
|
+ ),
|
|
|
+ keyboardOptions = KeyboardOptions(
|
|
|
+ keyboardType = KeyboardType.Email,
|
|
|
+ imeAction = ImeAction.Done
|
|
|
+ ),
|
|
|
+ keyboardActions = KeyboardActions(
|
|
|
+ onDone = {
|
|
|
+ focusManager.clearFocus()
|
|
|
+ keyboardController?.hide()
|
|
|
+ }
|
|
|
+ ),
|
|
|
+ )
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+@Composable
|
|
|
+fun ColumnScope.ShowHeaderEUTV(
|
|
|
+ navHostController: NavHostController,
|
|
|
+ message: String,
|
|
|
+ snackBarState: SnackbarHostState,
|
|
|
+ snackBarStateRed: SnackbarHostState,
|
|
|
+ isShowLoader: (Boolean) -> Unit,
|
|
|
+ textChanged: (String) -> Unit,
|
|
|
+) {
|
|
|
+ Log.d("emailUs: ","EU :: message = $message")
|
|
|
+ val helpViewModel: HelpViewModel = viewModel()
|
|
|
+ val coroutineScope = rememberCoroutineScope()
|
|
|
+
|
|
|
+ Row(
|
|
|
+ modifier = Modifier.fillMaxWidth(),
|
|
|
+ horizontalArrangement = Arrangement.SpaceBetween
|
|
|
+ ) {
|
|
|
+ IconButton(
|
|
|
+ onClick = {
|
|
|
+ navHostController.popBackStack()
|
|
|
+ navHostController.popBackStack()
|
|
|
+// navHostController.navigate(BottomBarScreen.Help.route)
|
|
|
+ },
|
|
|
+ modifier = Modifier
|
|
|
+ .padding(top = 10.dp)
|
|
|
+ .padding(start = 16.dp)
|
|
|
+ .size(30.dp, 32.dp)
|
|
|
+ ) {
|
|
|
+ Icon(
|
|
|
+ painter = painterResource(id = R.drawable.backarrow3x),
|
|
|
+ contentDescription = "Arrow-Back",
|
|
|
+ tint = colorResource(id = R.color.dark_blue_gray_text),
|
|
|
+ modifier = Modifier.size(18.dp, 12.dp)
|
|
|
+ )
|
|
|
+ }
|
|
|
+ Surface(
|
|
|
+ modifier = Modifier
|
|
|
+ .padding(top = 10.dp)
|
|
|
+ .height(32.dp)
|
|
|
+ .padding(5.dp),
|
|
|
+ color = colorResource(id = R.color.transparent)
|
|
|
+ ) {
|
|
|
+ Text(text = "Email Us",
|
|
|
+ color = colorResource(id = R.color.dark_blue_gray_text),
|
|
|
+ style = MaterialTheme.typography.bodyMedium,
|
|
|
+ modifier = Modifier.fillMaxHeight()
|
|
|
+ )
|
|
|
+ }
|
|
|
+ val customValidation = CustomValidation()
|
|
|
+ val isMessageValid = customValidation.isValidText(message, "Message")
|
|
|
+
|
|
|
+ IconButton(
|
|
|
+ onClick = {
|
|
|
+ if (isMessageValid) {
|
|
|
+ isShowLoader(true)
|
|
|
+ helpViewModel.emailUs(message)
|
|
|
+ } else {
|
|
|
+ coroutineScope.launch {
|
|
|
+ snackBarStateRed.showSnackbar("The message field is required.")
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ modifier = Modifier
|
|
|
+ .padding(top = 10.dp)
|
|
|
+ .padding(end = 16.dp)
|
|
|
+ .size(30.dp, 32.dp)
|
|
|
+ ) {
|
|
|
+ Icon(
|
|
|
+ painter = painterResource(id = R.drawable.customer_support3x),
|
|
|
+ contentDescription = "Email-Us",
|
|
|
+ tint = colorResource(id = R.color.dark_blue_gray_text),
|
|
|
+ modifier = Modifier.size(24.dp)
|
|
|
+ )
|
|
|
+
|
|
|
+ val emailUsResponse = helpViewModel.liveDataEmailUs.observeAsState()
|
|
|
+ emailUsResponse.value?.let { data ->
|
|
|
+ Log.d("emailUs: ","emailUs Screen: ${data.status} ${data.message}")
|
|
|
+ isShowLoader(false)
|
|
|
+ if (data.status) {
|
|
|
+ coroutineScope.launch {
|
|
|
+ data.message?.let { snackBarState.showSnackbar(it) }
|
|
|
+ navHostController.popBackStack()
|
|
|
+ navHostController.popBackStack()
|
|
|
+ }
|
|
|
+// textChanged("")
|
|
|
+
|
|
|
+ } else {
|
|
|
+ coroutineScope.launch {
|
|
|
+ data.message?.let { snackBarStateRed.showSnackbar(it) }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ helpViewModel.mutableLiveDataEmailUs.value = null
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|