|
@@ -91,6 +91,7 @@ import com.vpn.fastestvpnservice.sealedClass.Screen
|
|
|
import com.vpn.fastestvpnservice.ui.theme.customTypography
|
|
|
import com.vpn.fastestvpnservice.utils.Utils
|
|
|
import com.vpn.fastestvpnservice.utils.VPNConnectionsUtil
|
|
|
+import com.vpn.fastestvpnservice.utils.isTablet
|
|
|
import com.vpn.fastestvpnservice.viewmodels.HomeViewModel
|
|
|
import com.vpn.fastestvpnservice.viewmodels.ServerListViewModel
|
|
|
import com.vpn.fastestvpnservice.widgets.SimpleAppWidget
|
|
@@ -256,6 +257,8 @@ fun Home(
|
|
|
var isConnect: Int? = homeViewModel.isConnect.observeAsState().value
|
|
|
isConnect = basePreferenceHelper.getConnectState()
|
|
|
var server: Server = Server()
|
|
|
+ val configuration = LocalConfiguration.current
|
|
|
+// val isTablet = configuration.screenWidthDp > 840
|
|
|
|
|
|
OnLifecycleEvent{owner, event ->
|
|
|
when(event) {
|
|
@@ -339,10 +342,7 @@ fun Home(
|
|
|
homeViewModel._mutableLiveDataValidate.value = null
|
|
|
}
|
|
|
|
|
|
- val configuration = LocalConfiguration.current
|
|
|
- val expanded = configuration.screenWidthDp > 840
|
|
|
-
|
|
|
- Log.d("test_istablet", "Is Tablet ? $expanded , width = ${configuration.screenWidthDp}, height = ${configuration.screenHeightDp}")
|
|
|
+// Log.d("test_istablet", "Is Tablet ? $isTablet , width = ${configuration.screenWidthDp}, height = ${configuration.screenHeightDp}")
|
|
|
|
|
|
Column(
|
|
|
modifier = Modifier
|
|
@@ -412,7 +412,7 @@ fun Home(
|
|
|
// .offset(y = -(118).dp)
|
|
|
.background(Color.Transparent),
|
|
|
horizontalAlignment = Alignment.CenterHorizontally,
|
|
|
- verticalArrangement = Arrangement.SpaceEvenly
|
|
|
+ verticalArrangement = if (isTablet()) Arrangement.Bottom else Arrangement.SpaceEvenly
|
|
|
) {
|
|
|
val serverObj = basePreferenceHelper.getConnectedServer()
|
|
|
val serverDis = basePreferenceHelper.getIpinfo()
|
|
@@ -423,7 +423,9 @@ fun Home(
|
|
|
text = "IP ${ipInfo ?: ""}",
|
|
|
size = 18.sp,
|
|
|
color = MaterialTheme.colorScheme.primary,
|
|
|
- style = MaterialTheme.typography.customTypography.headlineLarge
|
|
|
+ style = MaterialTheme.typography.customTypography.headlineLarge.copy(
|
|
|
+ fontSize = if (isTablet()) 24.sp else 18.sp
|
|
|
+ )
|
|
|
)
|
|
|
Row(
|
|
|
) {
|
|
@@ -435,11 +437,11 @@ fun Home(
|
|
|
contentDescription = "Country",
|
|
|
modifier = Modifier
|
|
|
.padding(end = 6.dp)
|
|
|
- .size(20.dp)
|
|
|
+ .size(if (isTablet()) 26.dp else 20.dp)
|
|
|
.clip(CircleShape)
|
|
|
.paint(
|
|
|
painter = painterResource(id = image),
|
|
|
- contentScale = ContentScale.FillHeight
|
|
|
+ contentScale = ContentScale.FillBounds
|
|
|
)
|
|
|
)
|
|
|
}
|
|
@@ -447,6 +449,7 @@ fun Home(
|
|
|
text = "${serverObj?.server_name ?: ""}, ${serverObj?.country ?: ""}",
|
|
|
size = 16.sp,
|
|
|
color = MaterialTheme.colorScheme.primary,
|
|
|
+ isTablet()
|
|
|
)
|
|
|
} else {
|
|
|
val image = Utils.getDrawable(context, serverDis?.countryCode)
|
|
@@ -457,18 +460,19 @@ fun Home(
|
|
|
contentDescription = "Server",
|
|
|
modifier = Modifier
|
|
|
.padding(end = 6.dp)
|
|
|
- .size(20.dp)
|
|
|
+ .size(if (isTablet()) 26.dp else 20.dp)
|
|
|
.clip(CircleShape)
|
|
|
.paint(
|
|
|
painter = painterResource(id = image),
|
|
|
- contentScale = ContentScale.FillHeight
|
|
|
+ contentScale = ContentScale.FillBounds
|
|
|
)
|
|
|
)
|
|
|
}
|
|
|
AddText(
|
|
|
text = "${serverDis?.city ?: ""}, ${serverDis?.country ?: ""}",
|
|
|
size = 16.sp,
|
|
|
- color = MaterialTheme.colorScheme.primary
|
|
|
+ color = MaterialTheme.colorScheme.primary,
|
|
|
+ isTablet()
|
|
|
)
|
|
|
}
|
|
|
}
|
|
@@ -477,7 +481,9 @@ fun Home(
|
|
|
text = "Connected",
|
|
|
size = 18.sp,
|
|
|
color = MaterialTheme.colorScheme.surfaceContainerHigh,
|
|
|
- style = MaterialTheme.typography.customTypography.displaySmall
|
|
|
+ style = MaterialTheme.typography.customTypography.displaySmall.copy(
|
|
|
+ fontSize = if (isTablet()) 24.sp else 18.sp
|
|
|
+ )
|
|
|
)
|
|
|
}
|
|
|
else if (isConnect == App.DISCONNECTED) {
|
|
@@ -485,7 +491,9 @@ fun Home(
|
|
|
text = "Disconnected",
|
|
|
size = 18.sp,
|
|
|
color = MaterialTheme.colorScheme.surfaceTint,
|
|
|
- style = MaterialTheme.typography.customTypography.displaySmall
|
|
|
+ style = MaterialTheme.typography.customTypography.displaySmall.copy(
|
|
|
+ fontSize = if (isTablet()) 24.sp else 18.sp
|
|
|
+ )
|
|
|
)
|
|
|
}
|
|
|
else if (isConnect == App.CONNECTING) {
|
|
@@ -493,7 +501,9 @@ fun Home(
|
|
|
text = "Connecting...",
|
|
|
size = 18.sp,
|
|
|
color = MaterialTheme.colorScheme.surfaceTint,
|
|
|
- style = MaterialTheme.typography.customTypography.displaySmall
|
|
|
+ style = MaterialTheme.typography.customTypography.displaySmall.copy(
|
|
|
+ fontSize = if (isTablet()) 24.sp else 18.sp
|
|
|
+ )
|
|
|
)
|
|
|
}
|
|
|
}
|
|
@@ -604,7 +614,7 @@ fun Home(
|
|
|
|
|
|
Box(
|
|
|
modifier = Modifier
|
|
|
- .fillMaxWidth()
|
|
|
+ .fillMaxWidth(fraction = if (isTablet()) 0.5f else 1f)
|
|
|
.padding(horizontal = 20.dp)
|
|
|
.padding(vertical = 5.dp)
|
|
|
.height(120.dp)
|
|
@@ -615,9 +625,11 @@ fun Home(
|
|
|
.background(
|
|
|
shape = RoundedCornerShape(28.dp),
|
|
|
color = MaterialTheme.colorScheme.onBackground
|
|
|
- ),
|
|
|
+ )
|
|
|
+ .align(Alignment.CenterHorizontally)
|
|
|
+ ,
|
|
|
) {
|
|
|
- AddRowSmart(navHostController, basePreferenceHelper, context)
|
|
|
+ AddRowSmart(navHostController, basePreferenceHelper, context, isTablet())
|
|
|
var smartServer = basePreferenceHelper.getSmartServerObject()
|
|
|
val recommended = basePreferenceHelper.getRecommendedServerObject()
|
|
|
val selectedSmartList = basePreferenceHelper.getSmartList()
|
|
@@ -695,7 +707,9 @@ fun Home(
|
|
|
) {
|
|
|
Text(
|
|
|
text = "Smart Connect",
|
|
|
- style = MaterialTheme.typography.customTypography.labelLarge,
|
|
|
+ style = MaterialTheme.typography.customTypography.labelLarge.copy(
|
|
|
+ fontSize = if (isTablet()) 21.sp else 18.sp
|
|
|
+ ),
|
|
|
modifier = Modifier.background(Color.Transparent)
|
|
|
)
|
|
|
}
|
|
@@ -708,7 +722,7 @@ fun Home(
|
|
|
|
|
|
Box(
|
|
|
modifier = Modifier
|
|
|
- .fillMaxWidth()
|
|
|
+ .fillMaxWidth(fraction = if (isTablet()) 0.5f else 1f)
|
|
|
.padding(horizontal = 20.dp, vertical = 5.dp)
|
|
|
.padding(top = 0.dp)
|
|
|
.height(70.dp)
|
|
@@ -719,10 +733,11 @@ fun Home(
|
|
|
.background(
|
|
|
shape = RoundedCornerShape(28.dp),
|
|
|
color = MaterialTheme.colorScheme.onBackground
|
|
|
- ),
|
|
|
+ )
|
|
|
+ .align(Alignment.CenterHorizontally),
|
|
|
contentAlignment = Alignment.CenterStart,
|
|
|
) {
|
|
|
- AddRowSelectServer(navHostController)
|
|
|
+ AddRowSelectServer(navHostController, isTablet())
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -1058,7 +1073,8 @@ fun ColumnScope.ColumnText(
|
|
|
fun BoxScope.AddRowSmart(
|
|
|
navHostController: NavHostController,
|
|
|
basePreferenceHelper: BasePreferenceHelper,
|
|
|
- context: Context
|
|
|
+ context: Context,
|
|
|
+ isTablet: Boolean
|
|
|
) {
|
|
|
val smart = basePreferenceHelper.getSmartServerObject()
|
|
|
val recommended = basePreferenceHelper.getRecommendedServerObject()
|
|
@@ -1147,13 +1163,17 @@ fun BoxScope.AddRowSmart(
|
|
|
text = selectedSmartList,
|
|
|
color = MaterialTheme.colorScheme.surfaceContainerLow,
|
|
|
size = 12.sp,
|
|
|
- style = MaterialTheme.typography.customTypography.headlineSmall
|
|
|
+ style = MaterialTheme.typography.customTypography.headlineSmall.copy(
|
|
|
+ fontSize = if (isTablet()) 16.sp else 12.sp
|
|
|
+ )
|
|
|
)
|
|
|
ColumnText(
|
|
|
text = "${selectedServer?.server_name}",
|
|
|
color = MaterialTheme.colorScheme.primary,
|
|
|
size = 16.sp,
|
|
|
- style = MaterialTheme.typography.labelMedium
|
|
|
+ style = MaterialTheme.typography.labelMedium.copy(
|
|
|
+ fontSize = if (isTablet()) 20.sp else 16.sp
|
|
|
+ )
|
|
|
)
|
|
|
}
|
|
|
Spacer(modifier = Modifier.weight(1F))
|
|
@@ -1164,7 +1184,8 @@ fun BoxScope.AddRowSmart(
|
|
|
ClickableText(
|
|
|
text = AnnotatedString("Change"),
|
|
|
style = MaterialTheme.typography.customTypography.headlineMedium.copy(
|
|
|
- MaterialTheme.colorScheme.surfaceContainerLow
|
|
|
+ MaterialTheme.colorScheme.surfaceContainerLow,
|
|
|
+ fontSize = if (isTablet()) 20.sp else 14.sp
|
|
|
),
|
|
|
onClick = {
|
|
|
toChangeServer.value = true
|
|
@@ -1180,7 +1201,7 @@ fun BoxScope.AddRowSmart(
|
|
|
}
|
|
|
|
|
|
@Composable
|
|
|
-fun BoxScope.AddRowSelectServer(navHostController: NavHostController) {
|
|
|
+fun BoxScope.AddRowSelectServer(navHostController: NavHostController, isTablet: Boolean) {
|
|
|
Row(
|
|
|
modifier = Modifier
|
|
|
.fillMaxWidth()
|
|
@@ -1222,7 +1243,9 @@ fun BoxScope.AddRowSelectServer(navHostController: NavHostController) {
|
|
|
color = Color.Transparent
|
|
|
) {
|
|
|
Text(text = "See All Locations",
|
|
|
- style = MaterialTheme.typography.labelMedium,
|
|
|
+ style = MaterialTheme.typography.labelMedium.copy(
|
|
|
+ fontSize = if (isTablet()) 20.sp else 16.sp
|
|
|
+ ),
|
|
|
color = MaterialTheme.colorScheme.primary,
|
|
|
maxLines = 2,
|
|
|
modifier = Modifier
|
|
@@ -1260,16 +1283,20 @@ fun ColumnScope.AddText(
|
|
|
Text(
|
|
|
text = text,
|
|
|
style = style,
|
|
|
- color = color
|
|
|
+ color = color,
|
|
|
+ modifier = Modifier.padding(bottom = if (isTablet()) 15.dp else 0.dp)
|
|
|
)
|
|
|
}
|
|
|
|
|
|
@Composable
|
|
|
-fun RowScope.AddText(text: String, size: TextUnit, color: Color) {
|
|
|
+fun RowScope.AddText(text: String, size: TextUnit, color: Color, isTablet: Boolean) {
|
|
|
Text(
|
|
|
text = text,
|
|
|
- style = MaterialTheme.typography.labelMedium,
|
|
|
- color = color
|
|
|
+ style = MaterialTheme.typography.labelMedium.copy(
|
|
|
+ fontSize = if (isTablet()) 22.sp else 16.sp
|
|
|
+ ),
|
|
|
+ color = color,
|
|
|
+ modifier = Modifier.padding(bottom = if (isTablet()) 15.dp else 0.dp)
|
|
|
)
|
|
|
}
|
|
|
|