|
@@ -1,20 +1,19 @@
|
|
|
package com.vpn.fastestvpnservice.screens.helpScreensAll
|
|
|
|
|
|
+import android.util.Log
|
|
|
import androidx.compose.foundation.background
|
|
|
-import androidx.compose.foundation.border
|
|
|
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.layout.wrapContentHeight
|
|
|
-import androidx.compose.foundation.layout.wrapContentSize
|
|
|
import androidx.compose.foundation.text.KeyboardActions
|
|
|
import androidx.compose.foundation.text.KeyboardOptions
|
|
|
import androidx.compose.material.Icon
|
|
@@ -22,12 +21,15 @@ import androidx.compose.material.IconButton
|
|
|
import androidx.compose.material.Surface
|
|
|
import androidx.compose.material.Text
|
|
|
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.getValue
|
|
|
+import androidx.compose.runtime.livedata.observeAsState
|
|
|
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
|
|
@@ -40,29 +42,48 @@ import androidx.compose.ui.text.input.ImeAction
|
|
|
import androidx.compose.ui.text.input.KeyboardType
|
|
|
import androidx.compose.ui.tooling.preview.Preview
|
|
|
import androidx.compose.ui.unit.dp
|
|
|
+import androidx.lifecycle.viewmodel.compose.viewModel
|
|
|
import androidx.navigation.NavHostController
|
|
|
import androidx.navigation.compose.rememberNavController
|
|
|
import com.vpn.fastestvpnservice.R
|
|
|
import com.vpn.fastestvpnservice.ui.theme.customTypography
|
|
|
+import com.vpn.fastestvpnservice.viewmodels.HelpViewModel
|
|
|
+import com.vpn.fastestvpnservice.views.ShowCustomSnackBar
|
|
|
+import kotlinx.coroutines.launch
|
|
|
|
|
|
@Composable
|
|
|
fun EmailUsScreen(navHostController: NavHostController) {
|
|
|
var textChanged by remember { mutableStateOf("") }
|
|
|
val keyboardController = LocalSoftwareKeyboardController.current
|
|
|
val focusManager = LocalFocusManager.current
|
|
|
+ val snackBarState = remember { SnackbarHostState() }
|
|
|
+ val snackBarStateRed = remember { SnackbarHostState() }
|
|
|
|
|
|
Box(
|
|
|
modifier = Modifier
|
|
|
.background(MaterialTheme.colorScheme.onPrimary)
|
|
|
.fillMaxSize()
|
|
|
) {
|
|
|
+ ShowCustomSnackBar(snackBarState, R.color.yellow_text, R.color.dark_blue_gray_text)
|
|
|
+ ShowCustomSnackBar(snackBarStateRed, R.color.Red, R.color.white)
|
|
|
+
|
|
|
Column(
|
|
|
- modifier = Modifier.fillMaxSize()
|
|
|
+ modifier = Modifier
|
|
|
+ .fillMaxSize()
|
|
|
.background(Color.Transparent),
|
|
|
verticalArrangement = Arrangement.Top,
|
|
|
horizontalAlignment = Alignment.Start
|
|
|
) {
|
|
|
- ShowHeaderEU(navHostController = navHostController)
|
|
|
+ Spacer(modifier = Modifier.height(50.dp))
|
|
|
+
|
|
|
+ ShowHeaderEU(
|
|
|
+ navHostController = navHostController,
|
|
|
+ textChanged,
|
|
|
+ snackBarState,
|
|
|
+ snackBarStateRed
|
|
|
+ ) {
|
|
|
+ textChanged = it
|
|
|
+ }
|
|
|
|
|
|
Text(text = "Your message:",
|
|
|
color = MaterialTheme.colorScheme.primary,
|
|
@@ -116,7 +137,17 @@ fun EmailUsScreen(navHostController: NavHostController) {
|
|
|
}
|
|
|
|
|
|
@Composable
|
|
|
-fun ColumnScope.ShowHeaderEU(navHostController: NavHostController) {
|
|
|
+fun ColumnScope.ShowHeaderEU(
|
|
|
+ navHostController: NavHostController,
|
|
|
+ message: String,
|
|
|
+ snackBarState: SnackbarHostState,
|
|
|
+ snackBarStateRed: SnackbarHostState,
|
|
|
+ textChanged: (String) -> Unit
|
|
|
+) {
|
|
|
+ Log.d("emailUs: ","EU :: message = $message")
|
|
|
+ val helpViewModel: HelpViewModel = viewModel()
|
|
|
+ val coroutineScope = rememberCoroutineScope()
|
|
|
+
|
|
|
Row(
|
|
|
modifier = Modifier.fillMaxWidth(),
|
|
|
horizontalArrangement = Arrangement.SpaceBetween
|
|
@@ -154,7 +185,7 @@ fun ColumnScope.ShowHeaderEU(navHostController: NavHostController) {
|
|
|
}
|
|
|
IconButton(
|
|
|
onClick = {
|
|
|
-
|
|
|
+ helpViewModel.emailUs(message)
|
|
|
},
|
|
|
modifier = Modifier
|
|
|
.padding(top = 10.dp)
|
|
@@ -167,6 +198,24 @@ fun ColumnScope.ShowHeaderEU(navHostController: NavHostController) {
|
|
|
tint = MaterialTheme.colorScheme.primary,
|
|
|
modifier = Modifier.size(24.dp)
|
|
|
)
|
|
|
+
|
|
|
+ val emailUsResponse = helpViewModel.liveDataEmailUs.observeAsState()
|
|
|
+ emailUsResponse.value?.let { data ->
|
|
|
+ Log.d("emailUs: ","emailUs Screen: ${data.status} ${data.message}")
|
|
|
+
|
|
|
+ if (data.status) {
|
|
|
+ coroutineScope.launch {
|
|
|
+ data.message?.let { snackBarState.showSnackbar(it) }
|
|
|
+ }
|
|
|
+ textChanged("")
|
|
|
+
|
|
|
+ } else {
|
|
|
+ coroutineScope.launch {
|
|
|
+ data.message?.let { snackBarStateRed.showSnackbar(it) }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ helpViewModel.mutableLiveDataEmailUs.value = null
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|