feat: вёрстка приведена к соответствию m3
This commit is contained in:
1 parent
cd993fc1e5
commit
5ea21719e2
11 files changed
+729
-660
No files matched your search
@@ -70,6 +70,7 @@ dependencies {
|
|||||||
implementation(libs.androidx.compose.ui.graphics)
|
implementation(libs.androidx.compose.ui.graphics)
|
||||||
implementation(libs.androidx.compose.ui.tooling.preview)
|
implementation(libs.androidx.compose.ui.tooling.preview)
|
||||||
implementation(libs.androidx.compose.material3)
|
implementation(libs.androidx.compose.material3)
|
||||||
|
implementation(libs.androidx.compose.material3.adaptive.nav.suite)
|
||||||
|
|
||||||
debugImplementation(libs.androidx.compose.ui.tooling)
|
debugImplementation(libs.androidx.compose.ui.tooling)
|
||||||
}
|
}
|
||||||
@@ -1,19 +1,14 @@
|
|||||||
package com.freeturn.app.ui.navigation
|
package com.freeturn.app.ui.navigation
|
||||||
|
|
||||||
import androidx.compose.animation.AnimatedVisibility
|
|
||||||
import androidx.compose.animation.Crossfade
|
import androidx.compose.animation.Crossfade
|
||||||
import androidx.compose.animation.slideInVertically
|
|
||||||
import androidx.compose.animation.slideOutVertically
|
|
||||||
import androidx.compose.foundation.layout.Box
|
|
||||||
import androidx.compose.foundation.layout.WindowInsets
|
|
||||||
import androidx.compose.foundation.layout.fillMaxSize
|
import androidx.compose.foundation.layout.fillMaxSize
|
||||||
import androidx.compose.foundation.layout.padding
|
|
||||||
import androidx.compose.foundation.layout.statusBarsPadding
|
import androidx.compose.foundation.layout.statusBarsPadding
|
||||||
import androidx.compose.material3.Icon
|
import androidx.compose.material3.Icon
|
||||||
import androidx.compose.material3.NavigationBar
|
|
||||||
import androidx.compose.material3.NavigationBarItem
|
|
||||||
import androidx.compose.material3.Scaffold
|
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
|
import androidx.compose.material3.adaptive.currentWindowAdaptiveInfo
|
||||||
|
import androidx.compose.material3.adaptive.navigationsuite.NavigationSuiteScaffold
|
||||||
|
import androidx.compose.material3.adaptive.navigationsuite.NavigationSuiteScaffoldDefaults
|
||||||
|
import androidx.compose.material3.adaptive.navigationsuite.NavigationSuiteType
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
@@ -21,9 +16,9 @@ import androidx.compose.ui.Modifier
|
|||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
import androidx.compose.ui.res.painterResource
|
import androidx.compose.ui.res.painterResource
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import androidx.compose.ui.unit.dp
|
|
||||||
import com.freeturn.app.R
|
import com.freeturn.app.R
|
||||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||||
|
import androidx.navigation.NavHostController
|
||||||
import androidx.navigation.compose.NavHost
|
import androidx.navigation.compose.NavHost
|
||||||
import androidx.navigation.compose.composable
|
import androidx.navigation.compose.composable
|
||||||
import androidx.navigation.compose.currentBackStackEntryAsState
|
import androidx.navigation.compose.currentBackStackEntryAsState
|
||||||
@@ -51,7 +46,7 @@ object Routes {
|
|||||||
const val LOGS = "logs"
|
const val LOGS = "logs"
|
||||||
}
|
}
|
||||||
|
|
||||||
// Нижнее меню видно только в основном потоке, не во время онбординга
|
// Нижнее меню / рельс видно только в основном потоке, не во время онбординга
|
||||||
private val BOTTOM_NAV_ROUTES = setOf(Routes.HOME, Routes.LOGS, Routes.SERVER_MANAGEMENT, Routes.CLIENT_SETUP)
|
private val BOTTOM_NAV_ROUTES = setOf(Routes.HOME, Routes.LOGS, Routes.SERVER_MANAGEMENT, Routes.CLIENT_SETUP)
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
@@ -68,142 +63,51 @@ fun AppNavigation(viewModel: MainViewModel) {
|
|||||||
val navController = rememberNavController()
|
val navController = rememberNavController()
|
||||||
val backStackEntry by navController.currentBackStackEntryAsState()
|
val backStackEntry by navController.currentBackStackEntryAsState()
|
||||||
val currentRoute = backStackEntry?.destination?.route
|
val currentRoute = backStackEntry?.destination?.route
|
||||||
val showBottomBar = currentRoute in BOTTOM_NAV_ROUTES
|
val showNavSuite = currentRoute in BOTTOM_NAV_ROUTES
|
||||||
|
|
||||||
Scaffold(
|
// Адаптивно: bar на телефоне, rail на ширинах ≥600dp, drawer — при расширенном классе.
|
||||||
modifier = Modifier.fillMaxSize(),
|
// На экранах онбординга и SSH-setup навигация скрыта через NavigationSuiteType.None.
|
||||||
bottomBar = {
|
val adaptiveType = NavigationSuiteScaffoldDefaults
|
||||||
AnimatedVisibility(
|
.calculateFromAdaptiveInfo(currentWindowAdaptiveInfo())
|
||||||
visible = showBottomBar,
|
val layoutType = if (showNavSuite) adaptiveType else NavigationSuiteType.None
|
||||||
enter = slideInVertically(initialOffsetY = { it }),
|
|
||||||
exit = slideOutVertically(targetOffsetY = { it })
|
val context = LocalContext.current
|
||||||
) {
|
|
||||||
AppNavigationBar(
|
NavigationSuiteScaffold(
|
||||||
currentRoute = currentRoute,
|
layoutType = layoutType,
|
||||||
onNavigate = { route ->
|
navigationSuiteItems = {
|
||||||
navController.navigate(route) {
|
navItems.forEach { item ->
|
||||||
|
val selected = currentRoute == item.route
|
||||||
|
item(
|
||||||
|
selected = selected,
|
||||||
|
onClick = {
|
||||||
|
if (!selected) HapticUtil.perform(context, HapticUtil.Pattern.SELECTION)
|
||||||
|
navController.navigate(item.route) {
|
||||||
popUpTo(Routes.HOME) { saveState = true; inclusive = false }
|
popUpTo(Routes.HOME) { saveState = true; inclusive = false }
|
||||||
launchSingleTop = true
|
launchSingleTop = true
|
||||||
restoreState = true
|
restoreState = true
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
icon = {
|
||||||
|
Crossfade(targetState = selected, label = "nav_icon_${item.route}") { isSelected ->
|
||||||
|
Icon(
|
||||||
|
painter = painterResource(
|
||||||
|
if (isSelected) item.selectedIconRes else item.unselectedIconRes
|
||||||
|
),
|
||||||
|
contentDescription = stringResource(item.labelResId)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
label = { Text(stringResource(item.labelResId)) }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
},
|
|
||||||
contentWindowInsets = WindowInsets(0, 0, 0, 0)
|
|
||||||
) { innerPadding ->
|
|
||||||
Box(
|
|
||||||
modifier = Modifier
|
|
||||||
.fillMaxSize()
|
|
||||||
.padding(bottom = if (showBottomBar) innerPadding.calculateBottomPadding() else 0.dp)
|
|
||||||
) {
|
|
||||||
NavHost(
|
|
||||||
navController = navController,
|
|
||||||
startDestination = startDestination,
|
|
||||||
modifier = Modifier.statusBarsPadding() // Добавляем отступ для статус-бара сверху
|
|
||||||
) {
|
|
||||||
|
|
||||||
// Онбординг-мастер (без нижнего меню)
|
|
||||||
|
|
||||||
composable(Routes.ONBOARDING) {
|
|
||||||
OnboardingScreen(
|
|
||||||
onSetupServer = { navController.navigate(Routes.SSH_SETUP_OB) },
|
|
||||||
onSkip = {
|
|
||||||
viewModel.setOnboardingDone()
|
|
||||||
navController.navigate(Routes.HOME) {
|
|
||||||
popUpTo(navController.graph.startDestinationId) { inclusive = true }
|
|
||||||
launchSingleTop = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
composable(Routes.SSH_SETUP_OB) {
|
|
||||||
SshSetupScreen(
|
|
||||||
viewModel = viewModel,
|
|
||||||
onConnected = {
|
|
||||||
navController.navigate(Routes.SERVER_MANAGEMENT_OB) {
|
|
||||||
popUpTo(Routes.SSH_SETUP_OB) { inclusive = true }
|
|
||||||
launchSingleTop = true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onBack = { navController.popBackStack() }
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
composable(Routes.SERVER_MANAGEMENT_OB) {
|
|
||||||
ServerManagementScreen(
|
|
||||||
viewModel = viewModel,
|
|
||||||
onContinue = {
|
|
||||||
navController.navigate(Routes.CLIENT_SETUP_OB) {
|
|
||||||
launchSingleTop = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
composable(Routes.CLIENT_SETUP_OB) {
|
|
||||||
ClientSetupScreen(
|
|
||||||
viewModel = viewModel,
|
|
||||||
showFinishButton = true,
|
|
||||||
onFinish = {
|
|
||||||
viewModel.setOnboardingDone()
|
|
||||||
navController.navigate(Routes.HOME) {
|
|
||||||
popUpTo(navController.graph.startDestinationId) { inclusive = true }
|
|
||||||
launchSingleTop = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Основной поток (с нижним меню)
|
|
||||||
|
|
||||||
composable(Routes.SSH_SETUP) {
|
|
||||||
SshSetupScreen(
|
|
||||||
viewModel = viewModel,
|
|
||||||
onConnected = {
|
|
||||||
navController.navigate(Routes.SERVER_MANAGEMENT) {
|
|
||||||
popUpTo(Routes.SSH_SETUP) { inclusive = true }
|
|
||||||
launchSingleTop = true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onBack = { navController.popBackStack() }
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
composable(Routes.SERVER_MANAGEMENT) {
|
|
||||||
ServerManagementScreen(
|
|
||||||
viewModel = viewModel,
|
|
||||||
onContinue = {
|
|
||||||
navController.navigate(Routes.CLIENT_SETUP) {
|
|
||||||
// Убираем SERVER_MANAGEMENT из back stack,
|
|
||||||
// иначе он остаётся под CLIENT_SETUP и bottom nav ломается
|
|
||||||
popUpTo(Routes.HOME) { inclusive = false; saveState = false }
|
|
||||||
launchSingleTop = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
composable(Routes.CLIENT_SETUP) {
|
|
||||||
ClientSetupScreen(
|
|
||||||
viewModel = viewModel,
|
|
||||||
showFinishButton = false
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
composable(Routes.HOME) {
|
|
||||||
HomeScreen(
|
|
||||||
viewModel = viewModel,
|
|
||||||
onNavigateToSshSetup = { navController.navigate(Routes.SSH_SETUP) }
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
composable(Routes.LOGS) {
|
|
||||||
LogsScreen(viewModel = viewModel)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
) {
|
||||||
|
AppNavHost(
|
||||||
|
navController = navController,
|
||||||
|
viewModel = viewModel,
|
||||||
|
startDestination = startDestination
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Диалог капчи поверх любого экрана. Оборачиваем в key(sessionId), чтобы для
|
// Диалог капчи поверх любого экрана. Оборачиваем в key(sessionId), чтобы для
|
||||||
@@ -220,6 +124,119 @@ fun AppNavigation(viewModel: MainViewModel) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
private fun AppNavHost(
|
||||||
|
navController: NavHostController,
|
||||||
|
viewModel: MainViewModel,
|
||||||
|
startDestination: String
|
||||||
|
) {
|
||||||
|
NavHost(
|
||||||
|
navController = navController,
|
||||||
|
startDestination = startDestination,
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxSize()
|
||||||
|
.statusBarsPadding()
|
||||||
|
) {
|
||||||
|
// Онбординг-мастер (без навигации)
|
||||||
|
composable(Routes.ONBOARDING) {
|
||||||
|
OnboardingScreen(
|
||||||
|
onSetupServer = { navController.navigate(Routes.SSH_SETUP_OB) },
|
||||||
|
onSkip = {
|
||||||
|
viewModel.setOnboardingDone()
|
||||||
|
navController.navigate(Routes.HOME) {
|
||||||
|
popUpTo(navController.graph.startDestinationId) { inclusive = true }
|
||||||
|
launchSingleTop = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
composable(Routes.SSH_SETUP_OB) {
|
||||||
|
SshSetupScreen(
|
||||||
|
viewModel = viewModel,
|
||||||
|
onConnected = {
|
||||||
|
navController.navigate(Routes.SERVER_MANAGEMENT_OB) {
|
||||||
|
popUpTo(Routes.SSH_SETUP_OB) { inclusive = true }
|
||||||
|
launchSingleTop = true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onBack = { navController.popBackStack() }
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
composable(Routes.SERVER_MANAGEMENT_OB) {
|
||||||
|
ServerManagementScreen(
|
||||||
|
viewModel = viewModel,
|
||||||
|
onContinue = {
|
||||||
|
navController.navigate(Routes.CLIENT_SETUP_OB) {
|
||||||
|
launchSingleTop = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
composable(Routes.CLIENT_SETUP_OB) {
|
||||||
|
ClientSetupScreen(
|
||||||
|
viewModel = viewModel,
|
||||||
|
showFinishButton = true,
|
||||||
|
onFinish = {
|
||||||
|
viewModel.setOnboardingDone()
|
||||||
|
navController.navigate(Routes.HOME) {
|
||||||
|
popUpTo(navController.graph.startDestinationId) { inclusive = true }
|
||||||
|
launchSingleTop = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Основной поток (с навигацией)
|
||||||
|
composable(Routes.SSH_SETUP) {
|
||||||
|
SshSetupScreen(
|
||||||
|
viewModel = viewModel,
|
||||||
|
onConnected = {
|
||||||
|
navController.navigate(Routes.SERVER_MANAGEMENT) {
|
||||||
|
popUpTo(Routes.SSH_SETUP) { inclusive = true }
|
||||||
|
launchSingleTop = true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onBack = { navController.popBackStack() }
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
composable(Routes.SERVER_MANAGEMENT) {
|
||||||
|
ServerManagementScreen(
|
||||||
|
viewModel = viewModel,
|
||||||
|
onContinue = {
|
||||||
|
navController.navigate(Routes.CLIENT_SETUP) {
|
||||||
|
// Убираем SERVER_MANAGEMENT из back stack,
|
||||||
|
// иначе он остаётся под CLIENT_SETUP и навигация ломается
|
||||||
|
popUpTo(Routes.HOME) { inclusive = false; saveState = false }
|
||||||
|
launchSingleTop = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
composable(Routes.CLIENT_SETUP) {
|
||||||
|
ClientSetupScreen(
|
||||||
|
viewModel = viewModel,
|
||||||
|
showFinishButton = false
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
composable(Routes.HOME) {
|
||||||
|
HomeScreen(
|
||||||
|
viewModel = viewModel,
|
||||||
|
onNavigateToSshSetup = { navController.navigate(Routes.SSH_SETUP) }
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
composable(Routes.LOGS) {
|
||||||
|
LogsScreen(viewModel = viewModel)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private data class NavItem(
|
private data class NavItem(
|
||||||
val route: String,
|
val route: String,
|
||||||
val labelResId: Int,
|
val labelResId: Int,
|
||||||
@@ -233,34 +250,3 @@ private val navItems = listOf(
|
|||||||
NavItem(Routes.CLIENT_SETUP, R.string.client_title, R.drawable.mobile_24px, R.drawable.mobile_outlined_24px),
|
NavItem(Routes.CLIENT_SETUP, R.string.client_title, R.drawable.mobile_24px, R.drawable.mobile_outlined_24px),
|
||||||
NavItem(Routes.LOGS, R.string.logs_title, R.drawable.terminal_24px, R.drawable.terminal_24px)
|
NavItem(Routes.LOGS, R.string.logs_title, R.drawable.terminal_24px, R.drawable.terminal_24px)
|
||||||
)
|
)
|
||||||
|
|
||||||
@Composable
|
|
||||||
private fun AppNavigationBar(
|
|
||||||
currentRoute: String?,
|
|
||||||
onNavigate: (String) -> Unit
|
|
||||||
) {
|
|
||||||
val context = LocalContext.current
|
|
||||||
NavigationBar {
|
|
||||||
navItems.forEach { item ->
|
|
||||||
val selected = currentRoute == item.route
|
|
||||||
NavigationBarItem(
|
|
||||||
selected = selected,
|
|
||||||
onClick = {
|
|
||||||
if (!selected) HapticUtil.perform(context, HapticUtil.Pattern.SELECTION)
|
|
||||||
onNavigate(item.route)
|
|
||||||
},
|
|
||||||
icon = {
|
|
||||||
Crossfade(targetState = selected, label = "nav_icon_${item.route}") { isSelected ->
|
|
||||||
Icon(
|
|
||||||
painter = painterResource(
|
|
||||||
if (isSelected) item.selectedIconRes else item.unselectedIconRes
|
|
||||||
),
|
|
||||||
contentDescription = stringResource(item.labelResId)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
label = { Text(stringResource(item.labelResId)) }
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -15,6 +15,7 @@ import androidx.compose.foundation.layout.height
|
|||||||
import androidx.compose.foundation.layout.imePadding
|
import androidx.compose.foundation.layout.imePadding
|
||||||
import androidx.compose.foundation.layout.size
|
import androidx.compose.foundation.layout.size
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
|
import androidx.compose.foundation.layout.widthIn
|
||||||
import androidx.compose.foundation.rememberScrollState
|
import androidx.compose.foundation.rememberScrollState
|
||||||
import androidx.compose.foundation.verticalScroll
|
import androidx.compose.foundation.verticalScroll
|
||||||
import androidx.compose.material3.Button
|
import androidx.compose.material3.Button
|
||||||
@@ -132,294 +133,299 @@ fun ClientSetupScreen(
|
|||||||
.fillMaxSize()
|
.fillMaxSize()
|
||||||
.padding(padding)
|
.padding(padding)
|
||||||
.imePadding()
|
.imePadding()
|
||||||
.padding(horizontal = 24.dp)
|
|
||||||
.verticalScroll(rememberScrollState()),
|
.verticalScroll(rememberScrollState()),
|
||||||
verticalArrangement = Arrangement.spacedBy(16.dp)
|
horizontalAlignment = Alignment.CenterHorizontally
|
||||||
) {
|
) {
|
||||||
Spacer(Modifier.height(4.dp))
|
Column(
|
||||||
|
modifier = Modifier
|
||||||
// Подключение
|
.widthIn(max = 840.dp)
|
||||||
Text(stringResource(R.string.connection_title), style = MaterialTheme.typography.titleMedium)
|
.fillMaxWidth()
|
||||||
|
.padding(horizontal = 24.dp),
|
||||||
OutlinedTextField(
|
verticalArrangement = Arrangement.spacedBy(16.dp)
|
||||||
value = serverAddress.redact(privacyMode),
|
|
||||||
onValueChange = { if (!privacyMode) serverAddress = it },
|
|
||||||
label = { Text(stringResource(R.string.server_address_label)) },
|
|
||||||
placeholder = { Text(stringResource(R.string.server_address_placeholder)) },
|
|
||||||
modifier = Modifier.fillMaxWidth(),
|
|
||||||
singleLine = true,
|
|
||||||
readOnly = privacyMode,
|
|
||||||
supportingText = { Text(stringResource(R.string.server_address_support)) }
|
|
||||||
)
|
|
||||||
|
|
||||||
OutlinedTextField(
|
|
||||||
value = vkLink.redact(privacyMode),
|
|
||||||
onValueChange = { if (!privacyMode) vkLink = it },
|
|
||||||
label = { Text(stringResource(R.string.vk_link_label)) },
|
|
||||||
placeholder = { Text(stringResource(R.string.vk_link_placeholder)) },
|
|
||||||
modifier = Modifier.fillMaxWidth(),
|
|
||||||
singleLine = true,
|
|
||||||
readOnly = privacyMode,
|
|
||||||
supportingText = { Text(stringResource(R.string.vk_link_support)) }
|
|
||||||
)
|
|
||||||
|
|
||||||
OutlinedTextField(
|
|
||||||
value = localPort.redact(privacyMode),
|
|
||||||
onValueChange = { if (!privacyMode) localPort = it },
|
|
||||||
label = { Text(stringResource(R.string.local_listen_address)) },
|
|
||||||
placeholder = { Text(stringResource(R.string.local_listen_placeholder)) },
|
|
||||||
modifier = Modifier.fillMaxWidth(),
|
|
||||||
singleLine = true,
|
|
||||||
readOnly = privacyMode,
|
|
||||||
supportingText = { Text(stringResource(R.string.local_listen_support)) }
|
|
||||||
)
|
|
||||||
|
|
||||||
HorizontalDivider(Modifier, DividerDefaults.Thickness, DividerDefaults.color)
|
|
||||||
|
|
||||||
// Параметры
|
|
||||||
Text(stringResource(R.string.parameters_title), style = MaterialTheme.typography.titleMedium)
|
|
||||||
|
|
||||||
Column {
|
|
||||||
Row(
|
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
|
||||||
modifier = Modifier.fillMaxWidth()
|
|
||||||
) {
|
|
||||||
Column(modifier = Modifier.weight(1f)) {
|
|
||||||
Text(stringResource(R.string.threads_format, threads.roundToInt()), style = MaterialTheme.typography.bodyMedium)
|
|
||||||
Text(
|
|
||||||
stringResource(R.string.threads_recommendation),
|
|
||||||
style = MaterialTheme.typography.labelSmall,
|
|
||||||
color = MaterialTheme.colorScheme.onSurface.copy(alpha = 0.5f)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Slider(
|
|
||||||
value = threads,
|
|
||||||
onValueChange = {
|
|
||||||
val newInt = it.roundToInt()
|
|
||||||
if (newInt != lastSliderInt) {
|
|
||||||
HapticUtil.perform(context, HapticUtil.Pattern.SELECTION)
|
|
||||||
lastSliderInt = newInt
|
|
||||||
}
|
|
||||||
threads = it
|
|
||||||
},
|
|
||||||
valueRange = 1f..8f,
|
|
||||||
steps = 6,
|
|
||||||
modifier = Modifier.fillMaxWidth()
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
SwitchRow(
|
|
||||||
label = stringResource(R.string.vless_mode),
|
|
||||||
description = stringResource(R.string.vless_mode_desc),
|
|
||||||
checked = saved.vlessMode,
|
|
||||||
onCheckedChange = {
|
|
||||||
HapticUtil.perform(context, if (it) HapticUtil.Pattern.TOGGLE_ON else HapticUtil.Pattern.TOGGLE_OFF)
|
|
||||||
viewModel.setVlessMode(it)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
if (!saved.vlessMode) {
|
|
||||||
Column(verticalArrangement = Arrangement.spacedBy(8.dp)) {
|
|
||||||
Column {
|
|
||||||
Text(stringResource(R.string.transport_protocol), style = MaterialTheme.typography.bodyMedium)
|
|
||||||
Text(
|
|
||||||
stringResource(R.string.transport_protocol_desc),
|
|
||||||
style = MaterialTheme.typography.labelSmall,
|
|
||||||
color = MaterialTheme.colorScheme.onSurface.copy(alpha = 0.5f)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
SingleChoiceSegmentedButtonRow(modifier = Modifier.fillMaxWidth()) {
|
|
||||||
SegmentedButton(
|
|
||||||
selected = !useUdp,
|
|
||||||
onClick = {
|
|
||||||
HapticUtil.perform(context, HapticUtil.Pattern.TOGGLE_ON)
|
|
||||||
useUdp = false
|
|
||||||
noDtls = false
|
|
||||||
},
|
|
||||||
shape = SegmentedButtonDefaults.itemShape(index = 0, count = 2)
|
|
||||||
) { Text(stringResource(R.string.tcp)) }
|
|
||||||
SegmentedButton(
|
|
||||||
selected = useUdp,
|
|
||||||
onClick = {
|
|
||||||
HapticUtil.perform(context, HapticUtil.Pattern.TOGGLE_ON)
|
|
||||||
useUdp = true
|
|
||||||
},
|
|
||||||
shape = SegmentedButtonDefaults.itemShape(index = 1, count = 2)
|
|
||||||
) { Text(stringResource(R.string.udp)) }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (useUdp) {
|
|
||||||
SwitchRow(
|
|
||||||
label = stringResource(R.string.no_dtls),
|
|
||||||
description = stringResource(R.string.no_dtls_desc),
|
|
||||||
checked = noDtls,
|
|
||||||
onCheckedChange = {
|
|
||||||
HapticUtil.perform(context, if (it) HapticUtil.Pattern.TOGGLE_ON else HapticUtil.Pattern.TOGGLE_OFF)
|
|
||||||
noDtls = it
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
SwitchRow(
|
|
||||||
label = stringResource(R.string.manual_captcha),
|
|
||||||
description = stringResource(R.string.manual_captcha_desc),
|
|
||||||
checked = manualCaptcha,
|
|
||||||
onCheckedChange = {
|
|
||||||
HapticUtil.perform(context, if (it) HapticUtil.Pattern.TOGGLE_ON else HapticUtil.Pattern.TOGGLE_OFF)
|
|
||||||
manualCaptcha = it
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
Column(verticalArrangement = Arrangement.spacedBy(8.dp)) {
|
|
||||||
Column {
|
|
||||||
Text(stringResource(R.string.dns_mode_title), style = MaterialTheme.typography.bodyMedium)
|
|
||||||
Text(
|
|
||||||
stringResource(R.string.dns_mode_desc),
|
|
||||||
style = MaterialTheme.typography.labelSmall,
|
|
||||||
color = MaterialTheme.colorScheme.onSurface.copy(alpha = 0.5f)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
val dnsOptions = listOf(
|
|
||||||
DnsMode.AUTO to stringResource(R.string.dns_mode_auto),
|
|
||||||
DnsMode.UDP to stringResource(R.string.dns_mode_udp),
|
|
||||||
DnsMode.DOH to stringResource(R.string.dns_mode_doh)
|
|
||||||
)
|
|
||||||
SingleChoiceSegmentedButtonRow(modifier = Modifier.fillMaxWidth()) {
|
|
||||||
dnsOptions.forEachIndexed { idx, (value, label) ->
|
|
||||||
SegmentedButton(
|
|
||||||
selected = dnsMode == value,
|
|
||||||
onClick = {
|
|
||||||
HapticUtil.perform(context, HapticUtil.Pattern.TOGGLE_ON)
|
|
||||||
dnsMode = value
|
|
||||||
},
|
|
||||||
shape = SegmentedButtonDefaults.itemShape(index = idx, count = dnsOptions.size)
|
|
||||||
) { Text(label) }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
SwitchRow(
|
|
||||||
label = stringResource(R.string.force_port_443),
|
|
||||||
description = stringResource(R.string.force_port_443_desc),
|
|
||||||
checked = forcePort443,
|
|
||||||
onCheckedChange = {
|
|
||||||
HapticUtil.perform(context, if (it) HapticUtil.Pattern.TOGGLE_ON else HapticUtil.Pattern.TOGGLE_OFF)
|
|
||||||
forcePort443 = it
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
HorizontalDivider(Modifier, DividerDefaults.Thickness, DividerDefaults.color)
|
|
||||||
|
|
||||||
// Ядро
|
|
||||||
Text(stringResource(R.string.core_title), style = MaterialTheme.typography.titleMedium)
|
|
||||||
|
|
||||||
Card(
|
|
||||||
modifier = Modifier.fillMaxWidth(),
|
|
||||||
colors = CardDefaults.cardColors(
|
|
||||||
containerColor = if (customKernelExists)
|
|
||||||
MaterialTheme.colorScheme.secondaryContainer
|
|
||||||
else
|
|
||||||
MaterialTheme.colorScheme.surfaceVariant
|
|
||||||
)
|
|
||||||
) {
|
) {
|
||||||
Row(
|
Spacer(Modifier.height(4.dp))
|
||||||
modifier = Modifier
|
|
||||||
.fillMaxWidth()
|
// Подключение
|
||||||
.padding(horizontal = 16.dp, vertical = 14.dp),
|
Text(stringResource(R.string.connection_title), style = MaterialTheme.typography.titleMedium)
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
|
||||||
horizontalArrangement = Arrangement.SpaceBetween
|
OutlinedTextField(
|
||||||
) {
|
value = serverAddress.redact(privacyMode),
|
||||||
|
onValueChange = { if (!privacyMode) serverAddress = it },
|
||||||
|
label = { Text(stringResource(R.string.server_address_label)) },
|
||||||
|
placeholder = { Text(stringResource(R.string.server_address_placeholder)) },
|
||||||
|
modifier = Modifier.fillMaxWidth(),
|
||||||
|
singleLine = true,
|
||||||
|
readOnly = privacyMode,
|
||||||
|
supportingText = { Text(stringResource(R.string.server_address_support)) }
|
||||||
|
)
|
||||||
|
|
||||||
|
OutlinedTextField(
|
||||||
|
value = vkLink.redact(privacyMode),
|
||||||
|
onValueChange = { if (!privacyMode) vkLink = it },
|
||||||
|
label = { Text(stringResource(R.string.vk_link_label)) },
|
||||||
|
placeholder = { Text(stringResource(R.string.vk_link_placeholder)) },
|
||||||
|
modifier = Modifier.fillMaxWidth(),
|
||||||
|
singleLine = true,
|
||||||
|
readOnly = privacyMode,
|
||||||
|
supportingText = { Text(stringResource(R.string.vk_link_support)) }
|
||||||
|
)
|
||||||
|
|
||||||
|
OutlinedTextField(
|
||||||
|
value = localPort.redact(privacyMode),
|
||||||
|
onValueChange = { if (!privacyMode) localPort = it },
|
||||||
|
label = { Text(stringResource(R.string.local_listen_address)) },
|
||||||
|
placeholder = { Text(stringResource(R.string.local_listen_placeholder)) },
|
||||||
|
modifier = Modifier.fillMaxWidth(),
|
||||||
|
singleLine = true,
|
||||||
|
readOnly = privacyMode,
|
||||||
|
supportingText = { Text(stringResource(R.string.local_listen_support)) }
|
||||||
|
)
|
||||||
|
|
||||||
|
HorizontalDivider(Modifier, DividerDefaults.Thickness, DividerDefaults.color)
|
||||||
|
|
||||||
|
// Параметры
|
||||||
|
Text(stringResource(R.string.parameters_title), style = MaterialTheme.typography.titleMedium)
|
||||||
|
|
||||||
|
Column {
|
||||||
Row(
|
Row(
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
horizontalArrangement = Arrangement.spacedBy(12.dp),
|
modifier = Modifier.fillMaxWidth()
|
||||||
modifier = Modifier.weight(1f)
|
) {
|
||||||
|
Column(modifier = Modifier.weight(1f)) {
|
||||||
|
Text(stringResource(R.string.threads_format, threads.roundToInt()), style = MaterialTheme.typography.bodyMedium)
|
||||||
|
Text(
|
||||||
|
stringResource(R.string.threads_recommendation),
|
||||||
|
style = MaterialTheme.typography.labelSmall,
|
||||||
|
color = MaterialTheme.colorScheme.onSurfaceVariant
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Slider(
|
||||||
|
value = threads,
|
||||||
|
onValueChange = {
|
||||||
|
val newInt = it.roundToInt()
|
||||||
|
if (newInt != lastSliderInt) {
|
||||||
|
HapticUtil.perform(context, HapticUtil.Pattern.SELECTION)
|
||||||
|
lastSliderInt = newInt
|
||||||
|
}
|
||||||
|
threads = it
|
||||||
|
},
|
||||||
|
valueRange = 1f..8f,
|
||||||
|
steps = 6,
|
||||||
|
modifier = Modifier.fillMaxWidth()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
SwitchRow(
|
||||||
|
label = stringResource(R.string.vless_mode),
|
||||||
|
description = stringResource(R.string.vless_mode_desc),
|
||||||
|
checked = saved.vlessMode,
|
||||||
|
onCheckedChange = {
|
||||||
|
HapticUtil.perform(context, if (it) HapticUtil.Pattern.TOGGLE_ON else HapticUtil.Pattern.TOGGLE_OFF)
|
||||||
|
viewModel.setVlessMode(it)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
if (!saved.vlessMode) {
|
||||||
|
Column(verticalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||||
|
Column {
|
||||||
|
Text(stringResource(R.string.transport_protocol), style = MaterialTheme.typography.bodyMedium)
|
||||||
|
Text(
|
||||||
|
stringResource(R.string.transport_protocol_desc),
|
||||||
|
style = MaterialTheme.typography.labelSmall,
|
||||||
|
color = MaterialTheme.colorScheme.onSurfaceVariant
|
||||||
|
)
|
||||||
|
}
|
||||||
|
SingleChoiceSegmentedButtonRow(modifier = Modifier.fillMaxWidth()) {
|
||||||
|
SegmentedButton(
|
||||||
|
selected = !useUdp,
|
||||||
|
onClick = {
|
||||||
|
HapticUtil.perform(context, HapticUtil.Pattern.TOGGLE_ON)
|
||||||
|
useUdp = false
|
||||||
|
noDtls = false
|
||||||
|
},
|
||||||
|
shape = SegmentedButtonDefaults.itemShape(index = 0, count = 2)
|
||||||
|
) { Text(stringResource(R.string.tcp)) }
|
||||||
|
SegmentedButton(
|
||||||
|
selected = useUdp,
|
||||||
|
onClick = {
|
||||||
|
HapticUtil.perform(context, HapticUtil.Pattern.TOGGLE_ON)
|
||||||
|
useUdp = true
|
||||||
|
},
|
||||||
|
shape = SegmentedButtonDefaults.itemShape(index = 1, count = 2)
|
||||||
|
) { Text(stringResource(R.string.udp)) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (useUdp) {
|
||||||
|
SwitchRow(
|
||||||
|
label = stringResource(R.string.no_dtls),
|
||||||
|
description = stringResource(R.string.no_dtls_desc),
|
||||||
|
checked = noDtls,
|
||||||
|
onCheckedChange = {
|
||||||
|
HapticUtil.perform(context, if (it) HapticUtil.Pattern.TOGGLE_ON else HapticUtil.Pattern.TOGGLE_OFF)
|
||||||
|
noDtls = it
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SwitchRow(
|
||||||
|
label = stringResource(R.string.manual_captcha),
|
||||||
|
description = stringResource(R.string.manual_captcha_desc),
|
||||||
|
checked = manualCaptcha,
|
||||||
|
onCheckedChange = {
|
||||||
|
HapticUtil.perform(context, if (it) HapticUtil.Pattern.TOGGLE_ON else HapticUtil.Pattern.TOGGLE_OFF)
|
||||||
|
manualCaptcha = it
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
Column(verticalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||||
|
Column {
|
||||||
|
Text(stringResource(R.string.dns_mode_title), style = MaterialTheme.typography.bodyMedium)
|
||||||
|
Text(
|
||||||
|
stringResource(R.string.dns_mode_desc),
|
||||||
|
style = MaterialTheme.typography.labelSmall,
|
||||||
|
color = MaterialTheme.colorScheme.onSurfaceVariant
|
||||||
|
)
|
||||||
|
}
|
||||||
|
val dnsOptions = listOf(
|
||||||
|
DnsMode.AUTO to stringResource(R.string.dns_mode_auto),
|
||||||
|
DnsMode.UDP to stringResource(R.string.dns_mode_udp),
|
||||||
|
DnsMode.DOH to stringResource(R.string.dns_mode_doh)
|
||||||
|
)
|
||||||
|
SingleChoiceSegmentedButtonRow(modifier = Modifier.fillMaxWidth()) {
|
||||||
|
dnsOptions.forEachIndexed { idx, (value, label) ->
|
||||||
|
SegmentedButton(
|
||||||
|
selected = dnsMode == value,
|
||||||
|
onClick = {
|
||||||
|
HapticUtil.perform(context, HapticUtil.Pattern.TOGGLE_ON)
|
||||||
|
dnsMode = value
|
||||||
|
},
|
||||||
|
shape = SegmentedButtonDefaults.itemShape(index = idx, count = dnsOptions.size)
|
||||||
|
) { Text(label) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SwitchRow(
|
||||||
|
label = stringResource(R.string.force_port_443),
|
||||||
|
description = stringResource(R.string.force_port_443_desc),
|
||||||
|
checked = forcePort443,
|
||||||
|
onCheckedChange = {
|
||||||
|
HapticUtil.perform(context, if (it) HapticUtil.Pattern.TOGGLE_ON else HapticUtil.Pattern.TOGGLE_OFF)
|
||||||
|
forcePort443 = it
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
HorizontalDivider(Modifier, DividerDefaults.Thickness, DividerDefaults.color)
|
||||||
|
|
||||||
|
// Ядро
|
||||||
|
Text(stringResource(R.string.core_title), style = MaterialTheme.typography.titleMedium)
|
||||||
|
|
||||||
|
Card(
|
||||||
|
modifier = Modifier.fillMaxWidth(),
|
||||||
|
colors = CardDefaults.cardColors(
|
||||||
|
containerColor = if (customKernelExists)
|
||||||
|
MaterialTheme.colorScheme.secondaryContainer
|
||||||
|
else
|
||||||
|
MaterialTheme.colorScheme.surfaceVariant
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
Row(
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.padding(horizontal = 16.dp, vertical = 14.dp),
|
||||||
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
|
horizontalArrangement = Arrangement.SpaceBetween
|
||||||
|
) {
|
||||||
|
Row(
|
||||||
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
|
horizontalArrangement = Arrangement.spacedBy(12.dp),
|
||||||
|
modifier = Modifier.weight(1f)
|
||||||
|
) {
|
||||||
|
Icon(
|
||||||
|
painter = painterResource(
|
||||||
|
if (customKernelExists) R.drawable.check_circle_24px
|
||||||
|
else R.drawable.memory_24px
|
||||||
|
),
|
||||||
|
contentDescription = null,
|
||||||
|
tint = if (customKernelExists)
|
||||||
|
MaterialTheme.colorScheme.primary
|
||||||
|
else
|
||||||
|
MaterialTheme.colorScheme.onSurfaceVariant
|
||||||
|
)
|
||||||
|
Column(verticalArrangement = Arrangement.spacedBy(2.dp)) {
|
||||||
|
Text(
|
||||||
|
if (customKernelExists) stringResource(R.string.custom_core)
|
||||||
|
else stringResource(R.string.builtin_core),
|
||||||
|
style = MaterialTheme.typography.bodyMedium
|
||||||
|
)
|
||||||
|
Text(
|
||||||
|
if (customKernelExists) stringResource(R.string.loaded_from_memory)
|
||||||
|
else stringResource(R.string.from_apk),
|
||||||
|
style = MaterialTheme.typography.labelSmall,
|
||||||
|
color = MaterialTheme.colorScheme.onSurfaceVariant
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (customKernelExists) {
|
||||||
|
IconButton(onClick = {
|
||||||
|
HapticUtil.perform(context, HapticUtil.Pattern.CLICK)
|
||||||
|
viewModel.clearCustomKernel()
|
||||||
|
}) {
|
||||||
|
Icon(
|
||||||
|
painter = painterResource(R.drawable.delete_24px),
|
||||||
|
contentDescription = stringResource(R.string.reset),
|
||||||
|
tint = MaterialTheme.colorScheme.error
|
||||||
|
)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
FilledTonalButton(onClick = {
|
||||||
|
HapticUtil.perform(context, HapticUtil.Pattern.CLICK)
|
||||||
|
viewModel.clearKernelError()
|
||||||
|
kernelPickerLauncher.launch(arrayOf("*/*"))
|
||||||
|
}) {
|
||||||
|
Text(stringResource(R.string.btn_load))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (kernelError != null) {
|
||||||
|
Row(
|
||||||
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
|
horizontalArrangement = Arrangement.spacedBy(8.dp)
|
||||||
) {
|
) {
|
||||||
Icon(
|
Icon(
|
||||||
painter = painterResource(
|
painter = painterResource(R.drawable.error_24px),
|
||||||
if (customKernelExists) R.drawable.check_circle_24px
|
|
||||||
else R.drawable.memory_24px
|
|
||||||
),
|
|
||||||
contentDescription = null,
|
contentDescription = null,
|
||||||
tint = if (customKernelExists)
|
tint = MaterialTheme.colorScheme.error,
|
||||||
MaterialTheme.colorScheme.primary
|
modifier = Modifier.size(16.dp)
|
||||||
else
|
)
|
||||||
MaterialTheme.colorScheme.onSurfaceVariant
|
Text(
|
||||||
|
kernelError!!,
|
||||||
|
style = MaterialTheme.typography.labelMedium,
|
||||||
|
color = MaterialTheme.colorScheme.error
|
||||||
)
|
)
|
||||||
Column(verticalArrangement = Arrangement.spacedBy(2.dp)) {
|
|
||||||
Text(
|
|
||||||
if (customKernelExists) stringResource(R.string.custom_core)
|
|
||||||
else stringResource(R.string.builtin_core),
|
|
||||||
style = MaterialTheme.typography.bodyMedium
|
|
||||||
)
|
|
||||||
Text(
|
|
||||||
if (customKernelExists) stringResource(R.string.loaded_from_memory)
|
|
||||||
else stringResource(R.string.from_apk),
|
|
||||||
style = MaterialTheme.typography.labelSmall,
|
|
||||||
color = MaterialTheme.colorScheme.onSurface.copy(alpha = 0.55f)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (customKernelExists) {
|
|
||||||
IconButton(onClick = {
|
|
||||||
HapticUtil.perform(context, HapticUtil.Pattern.CLICK)
|
|
||||||
viewModel.clearCustomKernel()
|
|
||||||
}) {
|
|
||||||
Icon(
|
|
||||||
painter = painterResource(R.drawable.delete_24px),
|
|
||||||
contentDescription = stringResource(R.string.reset),
|
|
||||||
tint = MaterialTheme.colorScheme.error
|
|
||||||
)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
FilledTonalButton(onClick = {
|
|
||||||
HapticUtil.perform(context, HapticUtil.Pattern.CLICK)
|
|
||||||
viewModel.clearKernelError()
|
|
||||||
kernelPickerLauncher.launch(arrayOf("*/*"))
|
|
||||||
}) {
|
|
||||||
Text(stringResource(R.string.btn_load))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (kernelError != null) {
|
// Кнопка «Завершить» — только в онбординг-флоу
|
||||||
Row(
|
if (showFinishButton && onFinish != null) {
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
Spacer(Modifier.height(8.dp))
|
||||||
horizontalArrangement = Arrangement.spacedBy(8.dp)
|
Button(
|
||||||
) {
|
onClick = onFinish,
|
||||||
Icon(
|
modifier = Modifier.fillMaxWidth(),
|
||||||
painter = painterResource(R.drawable.error_24px),
|
enabled = serverAddress.isNotBlank() && vkLink.isNotBlank(),
|
||||||
contentDescription = null,
|
shape = MaterialTheme.shapes.large
|
||||||
tint = MaterialTheme.colorScheme.error,
|
) {
|
||||||
modifier = Modifier.size(16.dp)
|
Text(stringResource(R.string.finish_setup), style = MaterialTheme.typography.labelLarge)
|
||||||
)
|
}
|
||||||
Text(
|
|
||||||
kernelError!!,
|
|
||||||
style = MaterialTheme.typography.labelMedium,
|
|
||||||
color = MaterialTheme.colorScheme.error
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Кнопка «Завершить» — только в онбординг-флоу
|
Spacer(Modifier.height(24.dp))
|
||||||
if (showFinishButton && onFinish != null) {
|
|
||||||
Spacer(Modifier.height(8.dp))
|
|
||||||
Button(
|
|
||||||
onClick = onFinish,
|
|
||||||
modifier = Modifier
|
|
||||||
.fillMaxWidth()
|
|
||||||
.height(56.dp),
|
|
||||||
enabled = serverAddress.isNotBlank() && vkLink.isNotBlank(),
|
|
||||||
shape = MaterialTheme.shapes.large
|
|
||||||
) {
|
|
||||||
Text(stringResource(R.string.finish_setup), style = MaterialTheme.typography.labelLarge)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Spacer(Modifier.height(24.dp))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -441,7 +447,7 @@ private fun SwitchRow(
|
|||||||
Text(
|
Text(
|
||||||
description,
|
description,
|
||||||
style = MaterialTheme.typography.labelSmall,
|
style = MaterialTheme.typography.labelSmall,
|
||||||
color = MaterialTheme.colorScheme.onSurface.copy(alpha = 0.5f)
|
color = MaterialTheme.colorScheme.onSurfaceVariant
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
Switch(checked = checked, onCheckedChange = onCheckedChange)
|
Switch(checked = checked, onCheckedChange = onCheckedChange)
|
||||||
|
|||||||
@@ -83,9 +83,7 @@ import androidx.core.content.ContextCompat
|
|||||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||||
import kotlinx.coroutines.delay
|
import kotlinx.coroutines.delay
|
||||||
import com.freeturn.app.ui.HapticUtil
|
import com.freeturn.app.ui.HapticUtil
|
||||||
import com.freeturn.app.ui.theme.StatusBlue
|
import com.freeturn.app.ui.theme.extendedColorScheme
|
||||||
import com.freeturn.app.ui.theme.StatusGreen
|
|
||||||
import com.freeturn.app.ui.theme.StatusGreenDark
|
|
||||||
import com.freeturn.app.viewmodel.MainViewModel
|
import com.freeturn.app.viewmodel.MainViewModel
|
||||||
import com.freeturn.app.viewmodel.ProxyState
|
import com.freeturn.app.viewmodel.ProxyState
|
||||||
import com.freeturn.app.viewmodel.SshConnectionState
|
import com.freeturn.app.viewmodel.SshConnectionState
|
||||||
@@ -205,10 +203,10 @@ fun HomeScreen(
|
|||||||
},
|
},
|
||||||
style = MaterialTheme.typography.titleMedium,
|
style = MaterialTheme.typography.titleMedium,
|
||||||
color = when (proxyState) {
|
color = when (proxyState) {
|
||||||
is ProxyState.Running -> StatusGreen
|
is ProxyState.Running -> MaterialTheme.extendedColorScheme.success
|
||||||
is ProxyState.Error -> MaterialTheme.colorScheme.error
|
is ProxyState.Error -> MaterialTheme.colorScheme.error
|
||||||
is ProxyState.CaptchaRequired -> MaterialTheme.colorScheme.error
|
is ProxyState.CaptchaRequired -> MaterialTheme.colorScheme.error
|
||||||
else -> MaterialTheme.colorScheme.onBackground.copy(alpha = 0.65f)
|
else -> MaterialTheme.colorScheme.onSurfaceVariant
|
||||||
},
|
},
|
||||||
textAlign = TextAlign.Center
|
textAlign = TextAlign.Center
|
||||||
)
|
)
|
||||||
@@ -249,7 +247,8 @@ fun HomeScreen(
|
|||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.size(8.dp)
|
.size(8.dp)
|
||||||
.background(
|
.background(
|
||||||
if (sshState is SshConnectionState.Connected) StatusBlue
|
if (sshState is SshConnectionState.Connected)
|
||||||
|
MaterialTheme.extendedColorScheme.info
|
||||||
else MaterialTheme.colorScheme.outline,
|
else MaterialTheme.colorScheme.outline,
|
||||||
CircleShape
|
CircleShape
|
||||||
)
|
)
|
||||||
@@ -263,7 +262,7 @@ fun HomeScreen(
|
|||||||
else -> stringResource(R.string.ssh_disconnected)
|
else -> stringResource(R.string.ssh_disconnected)
|
||||||
},
|
},
|
||||||
style = MaterialTheme.typography.bodySmall,
|
style = MaterialTheme.typography.bodySmall,
|
||||||
color = MaterialTheme.colorScheme.onBackground.copy(alpha = 0.6f)
|
color = MaterialTheme.colorScheme.onSurfaceVariant
|
||||||
)
|
)
|
||||||
if (sshState !is SshConnectionState.Connected) {
|
if (sshState !is SshConnectionState.Connected) {
|
||||||
Spacer(Modifier.width(8.dp))
|
Spacer(Modifier.width(8.dp))
|
||||||
@@ -272,8 +271,7 @@ fun HomeScreen(
|
|||||||
HapticUtil.perform(context, HapticUtil.Pattern.CLICK)
|
HapticUtil.perform(context, HapticUtil.Pattern.CLICK)
|
||||||
viewModel.reconnectSsh()
|
viewModel.reconnectSsh()
|
||||||
},
|
},
|
||||||
enabled = sshState !is SshConnectionState.Connecting,
|
enabled = sshState !is SshConnectionState.Connecting
|
||||||
modifier = Modifier.height(28.dp)
|
|
||||||
) {
|
) {
|
||||||
Text(stringResource(R.string.reconnect), style = MaterialTheme.typography.labelSmall)
|
Text(stringResource(R.string.reconnect), style = MaterialTheme.typography.labelSmall)
|
||||||
}
|
}
|
||||||
@@ -401,9 +399,10 @@ private fun UpdateDialogs(viewModel: MainViewModel) {
|
|||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun ProxyToggleButton(state: ProxyState, onClick: () -> Unit) {
|
private fun ProxyToggleButton(state: ProxyState, onClick: () -> Unit) {
|
||||||
|
val extended = MaterialTheme.extendedColorScheme
|
||||||
val containerColor by animateColorAsState(
|
val containerColor by animateColorAsState(
|
||||||
targetValue = when (state) {
|
targetValue = when (state) {
|
||||||
is ProxyState.Running -> StatusGreenDark
|
is ProxyState.Running -> extended.successContainer
|
||||||
is ProxyState.Error -> MaterialTheme.colorScheme.errorContainer
|
is ProxyState.Error -> MaterialTheme.colorScheme.errorContainer
|
||||||
is ProxyState.Starting -> MaterialTheme.colorScheme.secondaryContainer
|
is ProxyState.Starting -> MaterialTheme.colorScheme.secondaryContainer
|
||||||
else -> MaterialTheme.colorScheme.primaryContainer
|
else -> MaterialTheme.colorScheme.primaryContainer
|
||||||
@@ -413,7 +412,7 @@ private fun ProxyToggleButton(state: ProxyState, onClick: () -> Unit) {
|
|||||||
)
|
)
|
||||||
val contentColor by animateColorAsState(
|
val contentColor by animateColorAsState(
|
||||||
targetValue = when (state) {
|
targetValue = when (state) {
|
||||||
is ProxyState.Running -> StatusGreen
|
is ProxyState.Running -> extended.onSuccessContainer
|
||||||
is ProxyState.Error -> MaterialTheme.colorScheme.onErrorContainer
|
is ProxyState.Error -> MaterialTheme.colorScheme.onErrorContainer
|
||||||
is ProxyState.Starting -> MaterialTheme.colorScheme.onSecondaryContainer
|
is ProxyState.Starting -> MaterialTheme.colorScheme.onSecondaryContainer
|
||||||
else -> MaterialTheme.colorScheme.onPrimaryContainer
|
else -> MaterialTheme.colorScheme.onPrimaryContainer
|
||||||
@@ -435,7 +434,7 @@ private fun ProxyToggleButton(state: ProxyState, onClick: () -> Unit) {
|
|||||||
.clip(CircleShape),
|
.clip(CircleShape),
|
||||||
shape = CircleShape,
|
shape = CircleShape,
|
||||||
color = containerColor,
|
color = containerColor,
|
||||||
shadowElevation = if (state is ProxyState.Running) 12.dp else 4.dp
|
tonalElevation = if (state is ProxyState.Running) 6.dp else 1.dp
|
||||||
) {
|
) {
|
||||||
Column(
|
Column(
|
||||||
modifier = Modifier.fillMaxSize(),
|
modifier = Modifier.fillMaxSize(),
|
||||||
@@ -561,7 +560,13 @@ private fun InfoBottomSheet(
|
|||||||
trailingContent = {
|
trailingContent = {
|
||||||
androidx.compose.material3.Switch(
|
androidx.compose.material3.Switch(
|
||||||
checked = privacyMode,
|
checked = privacyMode,
|
||||||
onCheckedChange = onPrivacyModeChange
|
onCheckedChange = {
|
||||||
|
HapticUtil.perform(
|
||||||
|
context,
|
||||||
|
if (it) HapticUtil.Pattern.TOGGLE_ON else HapticUtil.Pattern.TOGGLE_OFF
|
||||||
|
)
|
||||||
|
onPrivacyModeChange(it)
|
||||||
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@@ -575,7 +580,13 @@ private fun InfoBottomSheet(
|
|||||||
trailingContent = {
|
trailingContent = {
|
||||||
androidx.compose.material3.Switch(
|
androidx.compose.material3.Switch(
|
||||||
checked = dynamicTheme,
|
checked = dynamicTheme,
|
||||||
onCheckedChange = { viewModel.setDynamicTheme(it) }
|
onCheckedChange = {
|
||||||
|
HapticUtil.perform(
|
||||||
|
context,
|
||||||
|
if (it) HapticUtil.Pattern.TOGGLE_ON else HapticUtil.Pattern.TOGGLE_OFF
|
||||||
|
)
|
||||||
|
viewModel.setDynamicTheme(it)
|
||||||
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@@ -776,7 +787,7 @@ private fun ConfigRow(label: String, value: String) {
|
|||||||
Text(
|
Text(
|
||||||
label,
|
label,
|
||||||
style = MaterialTheme.typography.bodySmall,
|
style = MaterialTheme.typography.bodySmall,
|
||||||
color = MaterialTheme.colorScheme.onSurface.copy(alpha = 0.6f)
|
color = MaterialTheme.colorScheme.onSurfaceVariant
|
||||||
)
|
)
|
||||||
Text(value, style = MaterialTheme.typography.bodySmall)
|
Text(value, style = MaterialTheme.typography.bodySmall)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,8 +37,7 @@ import androidx.compose.ui.unit.dp
|
|||||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||||
import com.freeturn.app.R
|
import com.freeturn.app.R
|
||||||
import com.freeturn.app.ui.HapticUtil
|
import com.freeturn.app.ui.HapticUtil
|
||||||
import com.freeturn.app.ui.theme.StatusGreen
|
import com.freeturn.app.ui.theme.extendedColorScheme
|
||||||
import com.freeturn.app.ui.theme.StatusOrange
|
|
||||||
import com.freeturn.app.viewmodel.MainViewModel
|
import com.freeturn.app.viewmodel.MainViewModel
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
@@ -95,7 +94,7 @@ fun LogsScreen(viewModel: MainViewModel) {
|
|||||||
Text(
|
Text(
|
||||||
stringResource(R.string.no_logs),
|
stringResource(R.string.no_logs),
|
||||||
style = MaterialTheme.typography.bodyMedium,
|
style = MaterialTheme.typography.bodyMedium,
|
||||||
color = MaterialTheme.colorScheme.onSurfaceVariant.copy(alpha = 0.4f)
|
color = MaterialTheme.colorScheme.onSurfaceVariant
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -129,8 +128,8 @@ private fun LogLine(line: String) {
|
|||||||
|
|
||||||
val textColor = when {
|
val textColor = when {
|
||||||
isError -> MaterialTheme.colorScheme.error
|
isError -> MaterialTheme.colorScheme.error
|
||||||
isWarning -> StatusOrange
|
isWarning -> MaterialTheme.extendedColorScheme.warning
|
||||||
isSuccess -> StatusGreen
|
isSuccess -> MaterialTheme.extendedColorScheme.success
|
||||||
isHeader -> MaterialTheme.colorScheme.primary
|
isHeader -> MaterialTheme.colorScheme.primary
|
||||||
else -> MaterialTheme.colorScheme.onSurfaceVariant
|
else -> MaterialTheme.colorScheme.onSurfaceVariant
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ import androidx.compose.foundation.shape.CircleShape
|
|||||||
import androidx.compose.ui.res.painterResource
|
import androidx.compose.ui.res.painterResource
|
||||||
import com.freeturn.app.R
|
import com.freeturn.app.R
|
||||||
import androidx.compose.material3.Button
|
import androidx.compose.material3.Button
|
||||||
import androidx.compose.material3.ButtonDefaults
|
|
||||||
import androidx.compose.material3.Card
|
import androidx.compose.material3.Card
|
||||||
import androidx.compose.material3.CardDefaults
|
import androidx.compose.material3.CardDefaults
|
||||||
import androidx.compose.material3.Icon
|
import androidx.compose.material3.Icon
|
||||||
@@ -110,7 +109,7 @@ fun OnboardingScreen(
|
|||||||
Text(
|
Text(
|
||||||
text = stringResource(R.string.onboarding_subtitle),
|
text = stringResource(R.string.onboarding_subtitle),
|
||||||
style = MaterialTheme.typography.bodyLarge,
|
style = MaterialTheme.typography.bodyLarge,
|
||||||
color = MaterialTheme.colorScheme.onBackground.copy(alpha = 0.65f),
|
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||||
textAlign = TextAlign.Center
|
textAlign = TextAlign.Center
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -153,11 +152,8 @@ fun OnboardingScreen(
|
|||||||
HapticUtil.perform(context, HapticUtil.Pattern.CLICK)
|
HapticUtil.perform(context, HapticUtil.Pattern.CLICK)
|
||||||
onSetupServer()
|
onSetupServer()
|
||||||
},
|
},
|
||||||
modifier = Modifier
|
modifier = Modifier.fillMaxWidth(),
|
||||||
.fillMaxWidth()
|
shape = MaterialTheme.shapes.large
|
||||||
.height(56.dp),
|
|
||||||
shape = MaterialTheme.shapes.large,
|
|
||||||
elevation = ButtonDefaults.buttonElevation(defaultElevation = 4.dp)
|
|
||||||
) {
|
) {
|
||||||
Icon(painterResource(R.drawable.wifi_24px), contentDescription = null)
|
Icon(painterResource(R.drawable.wifi_24px), contentDescription = null)
|
||||||
Spacer(Modifier.width(10.dp))
|
Spacer(Modifier.width(10.dp))
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import androidx.compose.foundation.layout.imePadding
|
|||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.foundation.layout.size
|
import androidx.compose.foundation.layout.size
|
||||||
import androidx.compose.foundation.layout.width
|
import androidx.compose.foundation.layout.width
|
||||||
|
import androidx.compose.foundation.layout.widthIn
|
||||||
import androidx.compose.foundation.lazy.LazyColumn
|
import androidx.compose.foundation.lazy.LazyColumn
|
||||||
import androidx.compose.foundation.lazy.items
|
import androidx.compose.foundation.lazy.items
|
||||||
import androidx.compose.foundation.lazy.rememberLazyListState
|
import androidx.compose.foundation.lazy.rememberLazyListState
|
||||||
@@ -59,8 +60,7 @@ import androidx.compose.ui.text.input.KeyboardType
|
|||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||||
import com.freeturn.app.ui.HapticUtil
|
import com.freeturn.app.ui.HapticUtil
|
||||||
import com.freeturn.app.ui.theme.StatusBlue
|
import com.freeturn.app.ui.theme.extendedColorScheme
|
||||||
import com.freeturn.app.ui.theme.StatusGreen
|
|
||||||
import com.freeturn.app.viewmodel.MainViewModel
|
import com.freeturn.app.viewmodel.MainViewModel
|
||||||
import com.freeturn.app.viewmodel.ServerState
|
import com.freeturn.app.viewmodel.ServerState
|
||||||
import com.freeturn.app.viewmodel.SshConnectionState
|
import com.freeturn.app.viewmodel.SshConnectionState
|
||||||
@@ -105,206 +105,205 @@ fun ServerManagementScreen(
|
|||||||
.fillMaxSize()
|
.fillMaxSize()
|
||||||
.padding(padding)
|
.padding(padding)
|
||||||
.imePadding()
|
.imePadding()
|
||||||
.padding(horizontal = 24.dp)
|
|
||||||
.verticalScroll(rememberScrollState()),
|
.verticalScroll(rememberScrollState()),
|
||||||
verticalArrangement = Arrangement.spacedBy(16.dp)
|
horizontalAlignment = Alignment.CenterHorizontally
|
||||||
) {
|
) {
|
||||||
Spacer(Modifier.height(4.dp))
|
Column(
|
||||||
|
modifier = Modifier
|
||||||
|
.widthIn(max = 840.dp)
|
||||||
|
.fillMaxWidth()
|
||||||
|
.padding(horizontal = 24.dp),
|
||||||
|
verticalArrangement = Arrangement.spacedBy(16.dp)
|
||||||
|
) {
|
||||||
|
Spacer(Modifier.height(4.dp))
|
||||||
|
|
||||||
// Status card
|
// Status card
|
||||||
Card(modifier = Modifier.fillMaxWidth()) {
|
Card(modifier = Modifier.fillMaxWidth()) {
|
||||||
Column(modifier = Modifier.padding(20.dp)) {
|
Column(modifier = Modifier.padding(20.dp)) {
|
||||||
Text(stringResource(R.string.server_status), style = MaterialTheme.typography.titleMedium)
|
Text(stringResource(R.string.server_status), style = MaterialTheme.typography.titleMedium)
|
||||||
Spacer(Modifier.height(16.dp))
|
Spacer(Modifier.height(16.dp))
|
||||||
StatusRow(
|
StatusRow(
|
||||||
label = stringResource(R.string.ssh_connection),
|
label = stringResource(R.string.ssh_connection),
|
||||||
isActive = isConnected,
|
isActive = isConnected,
|
||||||
activeLabel = stringResource(R.string.paired),
|
activeLabel = stringResource(R.string.paired),
|
||||||
activeColor = StatusBlue
|
activeColor = MaterialTheme.extendedColorScheme.info
|
||||||
)
|
)
|
||||||
Spacer(Modifier.height(10.dp))
|
Spacer(Modifier.height(10.dp))
|
||||||
StatusRow(stringResource(R.string.vk_turn_proxy), serverKnown?.running == true)
|
StatusRow(stringResource(R.string.vk_turn_proxy), serverKnown?.running == true)
|
||||||
|
|
||||||
when (serverState) {
|
when (serverState) {
|
||||||
is ServerState.Checking -> {
|
is ServerState.Checking -> {
|
||||||
Spacer(Modifier.height(12.dp))
|
Spacer(Modifier.height(12.dp))
|
||||||
LinearWavyProgressIndicator(modifier = Modifier.fillMaxWidth())
|
LinearWavyProgressIndicator(modifier = Modifier.fillMaxWidth())
|
||||||
|
}
|
||||||
|
is ServerState.Working -> {
|
||||||
|
Spacer(Modifier.height(12.dp))
|
||||||
|
Text(
|
||||||
|
(serverState as ServerState.Working).action,
|
||||||
|
style = MaterialTheme.typography.bodySmall,
|
||||||
|
color = MaterialTheme.colorScheme.secondary
|
||||||
|
)
|
||||||
|
Spacer(Modifier.height(6.dp))
|
||||||
|
LinearWavyProgressIndicator(modifier = Modifier.fillMaxWidth())
|
||||||
|
}
|
||||||
|
is ServerState.Error -> {
|
||||||
|
Spacer(Modifier.height(12.dp))
|
||||||
|
Text(
|
||||||
|
stringResource(R.string.error_format, (serverState as ServerState.Error).message),
|
||||||
|
style = MaterialTheme.typography.bodySmall,
|
||||||
|
color = MaterialTheme.colorScheme.error
|
||||||
|
)
|
||||||
|
}
|
||||||
|
else -> {}
|
||||||
}
|
}
|
||||||
is ServerState.Working -> {
|
|
||||||
Spacer(Modifier.height(12.dp))
|
|
||||||
Text(
|
|
||||||
(serverState as ServerState.Working).action,
|
|
||||||
style = MaterialTheme.typography.bodySmall,
|
|
||||||
color = MaterialTheme.colorScheme.secondary
|
|
||||||
)
|
|
||||||
Spacer(Modifier.height(6.dp))
|
|
||||||
LinearWavyProgressIndicator(modifier = Modifier.fillMaxWidth())
|
|
||||||
}
|
|
||||||
is ServerState.Error -> {
|
|
||||||
Spacer(Modifier.height(12.dp))
|
|
||||||
Text(
|
|
||||||
stringResource(R.string.error_format, (serverState as ServerState.Error).message),
|
|
||||||
style = MaterialTheme.typography.bodySmall,
|
|
||||||
color = MaterialTheme.colorScheme.error
|
|
||||||
)
|
|
||||||
}
|
|
||||||
else -> {}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Server config
|
// Server config
|
||||||
Text(stringResource(R.string.server_config), style = MaterialTheme.typography.titleMedium)
|
Text(stringResource(R.string.server_config), style = MaterialTheme.typography.titleMedium)
|
||||||
|
|
||||||
OutlinedTextField(
|
OutlinedTextField(
|
||||||
value = proxyListenPort,
|
value = proxyListenPort,
|
||||||
onValueChange = { proxyListenPort = it.filter { c -> c.isDigit() } },
|
onValueChange = { proxyListenPort = it.filter { c -> c.isDigit() } },
|
||||||
label = { Text(stringResource(R.string.listen_port)) },
|
label = { Text(stringResource(R.string.listen_port)) },
|
||||||
placeholder = { Text(stringResource(R.string.listen_port_placeholder)) },
|
placeholder = { Text(stringResource(R.string.listen_port_placeholder)) },
|
||||||
modifier = Modifier.fillMaxWidth(),
|
modifier = Modifier.fillMaxWidth(),
|
||||||
singleLine = true,
|
singleLine = true,
|
||||||
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number),
|
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number),
|
||||||
supportingText = { Text(stringResource(R.string.listen_port_desc)) }
|
supportingText = { Text(stringResource(R.string.listen_port_desc)) }
|
||||||
)
|
|
||||||
|
|
||||||
OutlinedTextField(
|
|
||||||
value = proxyConnect,
|
|
||||||
onValueChange = { proxyConnect = it },
|
|
||||||
label = { Text(stringResource(R.string.turn_client_address)) },
|
|
||||||
placeholder = { Text(stringResource(R.string.turn_client_placeholder)) },
|
|
||||||
modifier = Modifier.fillMaxWidth(),
|
|
||||||
singleLine = true,
|
|
||||||
supportingText = { Text(stringResource(R.string.turn_client_desc)) }
|
|
||||||
)
|
|
||||||
|
|
||||||
// Индикатор VLESS-режима сервера
|
|
||||||
if (serverKnown?.running == true && serverKnown.vlessMode == true) {
|
|
||||||
Text(
|
|
||||||
text = stringResource(R.string.server_running_vless),
|
|
||||||
style = MaterialTheme.typography.labelSmall,
|
|
||||||
color = StatusBlue
|
|
||||||
)
|
)
|
||||||
}
|
|
||||||
|
|
||||||
// Action buttons
|
OutlinedTextField(
|
||||||
FilledTonalButton(
|
value = proxyConnect,
|
||||||
onClick = {
|
onValueChange = { proxyConnect = it },
|
||||||
HapticUtil.perform(context, HapticUtil.Pattern.CLICK)
|
label = { Text(stringResource(R.string.turn_client_address)) },
|
||||||
viewModel.saveProxyServerConfig("0.0.0.0:$proxyListenPort", proxyConnect)
|
placeholder = { Text(stringResource(R.string.turn_client_placeholder)) },
|
||||||
viewModel.installServer()
|
modifier = Modifier.fillMaxWidth(),
|
||||||
},
|
singleLine = true,
|
||||||
enabled = isConnected && !isWorking,
|
supportingText = { Text(stringResource(R.string.turn_client_desc)) }
|
||||||
modifier = Modifier
|
|
||||||
.fillMaxWidth()
|
|
||||||
.height(52.dp),
|
|
||||||
shape = MaterialTheme.shapes.large
|
|
||||||
) {
|
|
||||||
Icon(painterResource(R.drawable.cloud_download_24px), null)
|
|
||||||
Spacer(Modifier.width(8.dp))
|
|
||||||
Text(if (serverKnown?.installed == true) stringResource(R.string.update) else stringResource(R.string.install))
|
|
||||||
}
|
|
||||||
|
|
||||||
Button(
|
|
||||||
onClick = {
|
|
||||||
HapticUtil.perform(context, HapticUtil.Pattern.CLICK)
|
|
||||||
viewModel.saveProxyServerConfig("0.0.0.0:$proxyListenPort", proxyConnect)
|
|
||||||
viewModel.startServer()
|
|
||||||
},
|
|
||||||
enabled = (isConnected && !isWorking
|
|
||||||
&& serverKnown?.installed == true) && !serverKnown.running,
|
|
||||||
modifier = Modifier
|
|
||||||
.fillMaxWidth()
|
|
||||||
.height(52.dp),
|
|
||||||
shape = MaterialTheme.shapes.large
|
|
||||||
) {
|
|
||||||
Icon(painterResource(R.drawable.play_arrow_24px), null)
|
|
||||||
Spacer(Modifier.width(8.dp))
|
|
||||||
Text(stringResource(R.string.start_server))
|
|
||||||
}
|
|
||||||
|
|
||||||
OutlinedButton(
|
|
||||||
onClick = {
|
|
||||||
HapticUtil.perform(context, HapticUtil.Pattern.CLICK)
|
|
||||||
viewModel.stopServer()
|
|
||||||
},
|
|
||||||
enabled = isConnected && !isWorking && serverKnown?.running == true,
|
|
||||||
modifier = Modifier
|
|
||||||
.fillMaxWidth()
|
|
||||||
.height(52.dp),
|
|
||||||
shape = MaterialTheme.shapes.large,
|
|
||||||
colors = ButtonDefaults.outlinedButtonColors(
|
|
||||||
contentColor = MaterialTheme.colorScheme.error
|
|
||||||
)
|
)
|
||||||
) {
|
|
||||||
Icon(painterResource(R.drawable.stop_24px), null)
|
|
||||||
Spacer(Modifier.width(8.dp))
|
|
||||||
Text(stringResource(R.string.stop_server))
|
|
||||||
}
|
|
||||||
|
|
||||||
if (serverKnown?.running == true) {
|
// Индикатор VLESS-режима сервера
|
||||||
Spacer(Modifier.height(4.dp))
|
if (serverKnown?.running == true && serverKnown.vlessMode == true) {
|
||||||
|
Text(
|
||||||
|
text = stringResource(R.string.server_running_vless),
|
||||||
|
style = MaterialTheme.typography.labelSmall,
|
||||||
|
color = MaterialTheme.extendedColorScheme.info
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Action buttons
|
||||||
|
FilledTonalButton(
|
||||||
|
onClick = {
|
||||||
|
HapticUtil.perform(context, HapticUtil.Pattern.CLICK)
|
||||||
|
viewModel.saveProxyServerConfig("0.0.0.0:$proxyListenPort", proxyConnect)
|
||||||
|
viewModel.installServer()
|
||||||
|
},
|
||||||
|
enabled = isConnected && !isWorking,
|
||||||
|
modifier = Modifier.fillMaxWidth(),
|
||||||
|
shape = MaterialTheme.shapes.large
|
||||||
|
) {
|
||||||
|
Icon(painterResource(R.drawable.cloud_download_24px), null)
|
||||||
|
Spacer(Modifier.width(8.dp))
|
||||||
|
Text(if (serverKnown?.installed == true) stringResource(R.string.update) else stringResource(R.string.install))
|
||||||
|
}
|
||||||
|
|
||||||
Button(
|
Button(
|
||||||
onClick = {
|
onClick = {
|
||||||
HapticUtil.perform(context, HapticUtil.Pattern.CLICK)
|
HapticUtil.perform(context, HapticUtil.Pattern.CLICK)
|
||||||
onContinue()
|
viewModel.saveProxyServerConfig("0.0.0.0:$proxyListenPort", proxyConnect)
|
||||||
|
viewModel.startServer()
|
||||||
},
|
},
|
||||||
modifier = Modifier
|
enabled = (isConnected && !isWorking
|
||||||
.fillMaxWidth()
|
&& serverKnown?.installed == true) && !serverKnown.running,
|
||||||
.height(56.dp),
|
modifier = Modifier.fillMaxWidth(),
|
||||||
shape = MaterialTheme.shapes.large
|
shape = MaterialTheme.shapes.large
|
||||||
) {
|
) {
|
||||||
Text(stringResource(R.string.continue_client_setup))
|
Icon(painterResource(R.drawable.play_arrow_24px), null)
|
||||||
Spacer(Modifier.width(8.dp))
|
Spacer(Modifier.width(8.dp))
|
||||||
Icon(painterResource(R.drawable.arrow_forward_24px), null)
|
Text(stringResource(R.string.start_server))
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// SSH-лог (вывод всех команд)
|
OutlinedButton(
|
||||||
if (sshLog.isNotEmpty()) {
|
onClick = {
|
||||||
Card(modifier = Modifier.fillMaxWidth()) {
|
HapticUtil.perform(context, HapticUtil.Pattern.CLICK)
|
||||||
Column(modifier = Modifier.padding(20.dp)) {
|
viewModel.stopServer()
|
||||||
Text(stringResource(R.string.ssh_log_title), style = MaterialTheme.typography.titleMedium)
|
},
|
||||||
Spacer(Modifier.height(12.dp))
|
enabled = isConnected && !isWorking && serverKnown?.running == true,
|
||||||
val listState = rememberLazyListState()
|
modifier = Modifier.fillMaxWidth(),
|
||||||
LaunchedEffect(sshLog.size) {
|
shape = MaterialTheme.shapes.large,
|
||||||
if (sshLog.isNotEmpty()) listState.animateScrollToItem(sshLog.lastIndex)
|
colors = ButtonDefaults.outlinedButtonColors(
|
||||||
}
|
contentColor = MaterialTheme.colorScheme.error
|
||||||
Card(
|
)
|
||||||
colors = CardDefaults.cardColors(
|
) {
|
||||||
containerColor = MaterialTheme.colorScheme.surfaceVariant
|
Icon(painterResource(R.drawable.stop_24px), null)
|
||||||
)
|
Spacer(Modifier.width(8.dp))
|
||||||
) {
|
Text(stringResource(R.string.stop_server))
|
||||||
LazyColumn(
|
}
|
||||||
state = listState,
|
|
||||||
modifier = Modifier
|
if (serverKnown?.running == true) {
|
||||||
.fillMaxWidth()
|
Spacer(Modifier.height(4.dp))
|
||||||
.heightIn(max = 400.dp)
|
Button(
|
||||||
.padding(10.dp)
|
onClick = {
|
||||||
|
HapticUtil.perform(context, HapticUtil.Pattern.CLICK)
|
||||||
|
onContinue()
|
||||||
|
},
|
||||||
|
modifier = Modifier.fillMaxWidth(),
|
||||||
|
shape = MaterialTheme.shapes.large
|
||||||
|
) {
|
||||||
|
Text(stringResource(R.string.continue_client_setup))
|
||||||
|
Spacer(Modifier.width(8.dp))
|
||||||
|
Icon(painterResource(R.drawable.arrow_forward_24px), null)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// SSH-лог (вывод всех команд)
|
||||||
|
if (sshLog.isNotEmpty()) {
|
||||||
|
Card(modifier = Modifier.fillMaxWidth()) {
|
||||||
|
Column(modifier = Modifier.padding(20.dp)) {
|
||||||
|
Text(stringResource(R.string.ssh_log_title), style = MaterialTheme.typography.titleMedium)
|
||||||
|
Spacer(Modifier.height(12.dp))
|
||||||
|
val listState = rememberLazyListState()
|
||||||
|
LaunchedEffect(sshLog.size) {
|
||||||
|
if (sshLog.isNotEmpty()) listState.animateScrollToItem(sshLog.lastIndex)
|
||||||
|
}
|
||||||
|
Card(
|
||||||
|
colors = CardDefaults.cardColors(
|
||||||
|
containerColor = MaterialTheme.colorScheme.surfaceVariant
|
||||||
|
)
|
||||||
) {
|
) {
|
||||||
items(sshLog) { line ->
|
LazyColumn(
|
||||||
val isHeader = line.startsWith("===")
|
state = listState,
|
||||||
val isError = line.contains("ERROR", ignoreCase = true) ||
|
modifier = Modifier
|
||||||
line.contains("error", ignoreCase = true) ||
|
.fillMaxWidth()
|
||||||
line.contains("failed", ignoreCase = true)
|
.heightIn(max = 400.dp)
|
||||||
Text(
|
.padding(10.dp)
|
||||||
text = line,
|
) {
|
||||||
style = MaterialTheme.typography.bodySmall.copy(
|
items(sshLog) { line ->
|
||||||
fontFamily = FontFamily.Monospace
|
val isHeader = line.startsWith("===")
|
||||||
),
|
val isError = line.contains("ERROR", ignoreCase = true) ||
|
||||||
color = when {
|
line.contains("error", ignoreCase = true) ||
|
||||||
isHeader -> MaterialTheme.colorScheme.primary
|
line.contains("failed", ignoreCase = true)
|
||||||
isError -> MaterialTheme.colorScheme.error
|
Text(
|
||||||
else -> MaterialTheme.colorScheme.onSurfaceVariant
|
text = line,
|
||||||
}
|
style = MaterialTheme.typography.bodySmall.copy(
|
||||||
)
|
fontFamily = FontFamily.Monospace
|
||||||
|
),
|
||||||
|
color = when {
|
||||||
|
isHeader -> MaterialTheme.colorScheme.primary
|
||||||
|
isError -> MaterialTheme.colorScheme.error
|
||||||
|
else -> MaterialTheme.colorScheme.onSurfaceVariant
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
Spacer(Modifier.height(24.dp))
|
Spacer(Modifier.height(24.dp))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -312,6 +311,8 @@ fun ServerManagementScreen(
|
|||||||
@Composable
|
@Composable
|
||||||
private fun SshStatusBadge(sshState: SshConnectionState, ip: String) {
|
private fun SshStatusBadge(sshState: SshConnectionState, ip: String) {
|
||||||
val connected = sshState is SshConnectionState.Connected
|
val connected = sshState is SshConnectionState.Connected
|
||||||
|
val dotColor = if (connected) MaterialTheme.extendedColorScheme.info
|
||||||
|
else MaterialTheme.colorScheme.error
|
||||||
Row(
|
Row(
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
modifier = Modifier.padding(end = 16.dp)
|
modifier = Modifier.padding(end = 16.dp)
|
||||||
@@ -319,13 +320,13 @@ private fun SshStatusBadge(sshState: SshConnectionState, ip: String) {
|
|||||||
Box(
|
Box(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.size(8.dp)
|
.size(8.dp)
|
||||||
.background(if (connected) StatusBlue else MaterialTheme.colorScheme.error, CircleShape)
|
.background(dotColor, CircleShape)
|
||||||
)
|
)
|
||||||
Spacer(Modifier.width(6.dp))
|
Spacer(Modifier.width(6.dp))
|
||||||
Text(
|
Text(
|
||||||
if (connected) ip else stringResource(R.string.not_connected),
|
if (connected) ip else stringResource(R.string.not_connected),
|
||||||
style = MaterialTheme.typography.labelSmall,
|
style = MaterialTheme.typography.labelSmall,
|
||||||
color = MaterialTheme.colorScheme.onSurface.copy(alpha = 0.7f)
|
color = MaterialTheme.colorScheme.onSurfaceVariant
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -335,7 +336,7 @@ private fun StatusRow(
|
|||||||
label: String,
|
label: String,
|
||||||
isActive: Boolean,
|
isActive: Boolean,
|
||||||
activeLabel: String = stringResource(R.string.active),
|
activeLabel: String = stringResource(R.string.active),
|
||||||
activeColor: Color = StatusGreen
|
activeColor: Color = MaterialTheme.extendedColorScheme.success
|
||||||
) {
|
) {
|
||||||
Row(
|
Row(
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
|
|||||||
@@ -75,10 +75,3 @@ val surfaceContainerLowDark = Color(0xFF191C20)
|
|||||||
val surfaceContainerDark = Color(0xFF1D2024)
|
val surfaceContainerDark = Color(0xFF1D2024)
|
||||||
val surfaceContainerHighDark = Color(0xFF282A2F)
|
val surfaceContainerHighDark = Color(0xFF282A2F)
|
||||||
val surfaceContainerHighestDark = Color(0xFF33353A)
|
val surfaceContainerHighestDark = Color(0xFF33353A)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
val StatusGreen = Color(0xFF4CAF50)
|
|
||||||
val StatusGreenDark = Color(0xFF1B5E20)
|
|
||||||
val StatusBlue = Color(0xFF2196F3)
|
|
||||||
val StatusOrange = Color(0xFFE67E22)
|
|
||||||
@@ -0,0 +1,70 @@
|
|||||||
|
package com.freeturn.app.ui.theme
|
||||||
|
|
||||||
|
import androidx.compose.material3.MaterialTheme
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.runtime.Immutable
|
||||||
|
import androidx.compose.runtime.ReadOnlyComposable
|
||||||
|
import androidx.compose.runtime.staticCompositionLocalOf
|
||||||
|
import androidx.compose.ui.graphics.Color
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Дополнительная цветовая схема для ролей, которых нет в MaterialTheme.colorScheme:
|
||||||
|
* success / warning / info. Значения сгенерированы через Material Theme Builder
|
||||||
|
* (seed: success #4CAF50, warning #E67E22, info #2196F3) и держат полный набор
|
||||||
|
* тональных пар, чтобы корректно пройти контраст 4.5:1 в light/dark.
|
||||||
|
*/
|
||||||
|
@Immutable
|
||||||
|
data class ExtendedColorScheme(
|
||||||
|
val success: Color,
|
||||||
|
val onSuccess: Color,
|
||||||
|
val successContainer: Color,
|
||||||
|
val onSuccessContainer: Color,
|
||||||
|
val warning: Color,
|
||||||
|
val onWarning: Color,
|
||||||
|
val warningContainer: Color,
|
||||||
|
val onWarningContainer: Color,
|
||||||
|
val info: Color,
|
||||||
|
val onInfo: Color,
|
||||||
|
val infoContainer: Color,
|
||||||
|
val onInfoContainer: Color,
|
||||||
|
)
|
||||||
|
|
||||||
|
private val extendedLight = ExtendedColorScheme(
|
||||||
|
success = Color(0xFF006E1C),
|
||||||
|
onSuccess = Color(0xFFFFFFFF),
|
||||||
|
successContainer = Color(0xFF7BFB88),
|
||||||
|
onSuccessContainer = Color(0xFF002204),
|
||||||
|
warning = Color(0xFF8B5000),
|
||||||
|
onWarning = Color(0xFFFFFFFF),
|
||||||
|
warningContainer = Color(0xFFFFDCBE),
|
||||||
|
onWarningContainer = Color(0xFF2D1600),
|
||||||
|
info = Color(0xFF00639C),
|
||||||
|
onInfo = Color(0xFFFFFFFF),
|
||||||
|
infoContainer = Color(0xFFCEE5FF),
|
||||||
|
onInfoContainer = Color(0xFF001D33),
|
||||||
|
)
|
||||||
|
|
||||||
|
private val extendedDark = ExtendedColorScheme(
|
||||||
|
success = Color(0xFF5FDB72),
|
||||||
|
onSuccess = Color(0xFF00390B),
|
||||||
|
successContainer = Color(0xFF005313),
|
||||||
|
onSuccessContainer = Color(0xFF7BFB88),
|
||||||
|
warning = Color(0xFFFFB787),
|
||||||
|
onWarning = Color(0xFF4B2800),
|
||||||
|
warningContainer = Color(0xFF6B3C00),
|
||||||
|
onWarningContainer = Color(0xFFFFDCBE),
|
||||||
|
info = Color(0xFF97CCFF),
|
||||||
|
onInfo = Color(0xFF003354),
|
||||||
|
infoContainer = Color(0xFF004B77),
|
||||||
|
onInfoContainer = Color(0xFFCEE5FF),
|
||||||
|
)
|
||||||
|
|
||||||
|
internal fun extendedColorSchemeFor(darkTheme: Boolean): ExtendedColorScheme =
|
||||||
|
if (darkTheme) extendedDark else extendedLight
|
||||||
|
|
||||||
|
internal val LocalExtendedColorScheme = staticCompositionLocalOf { extendedLight }
|
||||||
|
|
||||||
|
val MaterialTheme.extendedColorScheme: ExtendedColorScheme
|
||||||
|
@Composable
|
||||||
|
@ReadOnlyComposable
|
||||||
|
get() = LocalExtendedColorScheme.current
|
||||||
@@ -9,6 +9,7 @@ import androidx.compose.material3.dynamicDarkColorScheme
|
|||||||
import androidx.compose.material3.dynamicLightColorScheme
|
import androidx.compose.material3.dynamicLightColorScheme
|
||||||
import androidx.compose.material3.lightColorScheme
|
import androidx.compose.material3.lightColorScheme
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.runtime.CompositionLocalProvider
|
||||||
import androidx.compose.runtime.SideEffect
|
import androidx.compose.runtime.SideEffect
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
@@ -116,9 +117,13 @@ fun FreeTurnTheme(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MaterialTheme(
|
CompositionLocalProvider(
|
||||||
colorScheme = colorScheme,
|
LocalExtendedColorScheme provides extendedColorSchemeFor(darkTheme)
|
||||||
typography = Typography,
|
) {
|
||||||
content = content
|
MaterialTheme(
|
||||||
)
|
colorScheme = colorScheme,
|
||||||
|
typography = Typography,
|
||||||
|
content = content
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
[versions]
|
[versions]
|
||||||
agp = "9.1.0"
|
agp = "9.1.1"
|
||||||
kotlin = "2.3.20"
|
kotlin = "2.3.20"
|
||||||
coreKtx = "1.18.0"
|
coreKtx = "1.18.0"
|
||||||
appcompat = "1.7.1"
|
appcompat = "1.7.1"
|
||||||
@@ -19,6 +19,7 @@ androidx-compose-ui-graphics = { group = "androidx.compose.ui", name = "ui-graph
|
|||||||
androidx-compose-ui-tooling = { group = "androidx.compose.ui", name = "ui-tooling" }
|
androidx-compose-ui-tooling = { group = "androidx.compose.ui", name = "ui-tooling" }
|
||||||
androidx-compose-ui-tooling-preview = { group = "androidx.compose.ui", name = "ui-tooling-preview" }
|
androidx-compose-ui-tooling-preview = { group = "androidx.compose.ui", name = "ui-tooling-preview" }
|
||||||
androidx-compose-material3 = { group = "androidx.compose.material3", name = "material3", version = "1.5.0-alpha16" }
|
androidx-compose-material3 = { group = "androidx.compose.material3", name = "material3", version = "1.5.0-alpha16" }
|
||||||
|
androidx-compose-material3-adaptive-nav-suite = { group = "androidx.compose.material3", name = "material3-adaptive-navigation-suite", version = "1.5.0-alpha16" }
|
||||||
androidx-navigation-compose = { group = "androidx.navigation", name = "navigation-compose", version.ref = "navigationCompose" }
|
androidx-navigation-compose = { group = "androidx.navigation", name = "navigation-compose", version.ref = "navigationCompose" }
|
||||||
androidx-datastore-preferences = { group = "androidx.datastore", name = "datastore-preferences", version.ref = "datastorePreferences" }
|
androidx-datastore-preferences = { group = "androidx.datastore", name = "datastore-preferences", version.ref = "datastorePreferences" }
|
||||||
androidx-lifecycle-viewmodel-compose = { group = "androidx.lifecycle", name = "lifecycle-viewmodel-compose", version.ref = "lifecycleViewmodelCompose" }
|
androidx-lifecycle-viewmodel-compose = { group = "androidx.lifecycle", name = "lifecycle-viewmodel-compose", version.ref = "lifecycleViewmodelCompose" }
|
||||||
|
|||||||
Reference in new issue
Block a user