feat: вёрстка приведена к соответствию m3
This commit is contained in:
1 parent
cd993fc1e5
commit
5ea21719e2
11 files changed
+217
-148
No files matched your search
@@ -70,6 +70,7 @@ dependencies {
|
||||
implementation(libs.androidx.compose.ui.graphics)
|
||||
implementation(libs.androidx.compose.ui.tooling.preview)
|
||||
implementation(libs.androidx.compose.material3)
|
||||
implementation(libs.androidx.compose.material3.adaptive.nav.suite)
|
||||
|
||||
debugImplementation(libs.androidx.compose.ui.tooling)
|
||||
}
|
||||
@@ -1,19 +1,14 @@
|
||||
package com.freeturn.app.ui.navigation
|
||||
|
||||
import androidx.compose.animation.AnimatedVisibility
|
||||
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.padding
|
||||
import androidx.compose.foundation.layout.statusBarsPadding
|
||||
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.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.getValue
|
||||
import androidx.compose.runtime.remember
|
||||
@@ -21,9 +16,9 @@ import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.freeturn.app.R
|
||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import androidx.navigation.NavHostController
|
||||
import androidx.navigation.compose.NavHost
|
||||
import androidx.navigation.compose.composable
|
||||
import androidx.navigation.compose.currentBackStackEntryAsState
|
||||
@@ -51,7 +46,7 @@ object Routes {
|
||||
const val LOGS = "logs"
|
||||
}
|
||||
|
||||
// Нижнее меню видно только в основном потоке, не во время онбординга
|
||||
// Нижнее меню / рельс видно только в основном потоке, не во время онбординга
|
||||
private val BOTTOM_NAV_ROUTES = setOf(Routes.HOME, Routes.LOGS, Routes.SERVER_MANAGEMENT, Routes.CLIENT_SETUP)
|
||||
|
||||
@Composable
|
||||
@@ -68,43 +63,81 @@ fun AppNavigation(viewModel: MainViewModel) {
|
||||
val navController = rememberNavController()
|
||||
val backStackEntry by navController.currentBackStackEntryAsState()
|
||||
val currentRoute = backStackEntry?.destination?.route
|
||||
val showBottomBar = currentRoute in BOTTOM_NAV_ROUTES
|
||||
val showNavSuite = currentRoute in BOTTOM_NAV_ROUTES
|
||||
|
||||
Scaffold(
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
bottomBar = {
|
||||
AnimatedVisibility(
|
||||
visible = showBottomBar,
|
||||
enter = slideInVertically(initialOffsetY = { it }),
|
||||
exit = slideOutVertically(targetOffsetY = { it })
|
||||
) {
|
||||
AppNavigationBar(
|
||||
currentRoute = currentRoute,
|
||||
onNavigate = { route ->
|
||||
navController.navigate(route) {
|
||||
// Адаптивно: bar на телефоне, rail на ширинах ≥600dp, drawer — при расширенном классе.
|
||||
// На экранах онбординга и SSH-setup навигация скрыта через NavigationSuiteType.None.
|
||||
val adaptiveType = NavigationSuiteScaffoldDefaults
|
||||
.calculateFromAdaptiveInfo(currentWindowAdaptiveInfo())
|
||||
val layoutType = if (showNavSuite) adaptiveType else NavigationSuiteType.None
|
||||
|
||||
val context = LocalContext.current
|
||||
|
||||
NavigationSuiteScaffold(
|
||||
layoutType = layoutType,
|
||||
navigationSuiteItems = {
|
||||
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 }
|
||||
launchSingleTop = 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)
|
||||
)
|
||||
}
|
||||
},
|
||||
contentWindowInsets = WindowInsets(0, 0, 0, 0)
|
||||
) { innerPadding ->
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.padding(bottom = if (showBottomBar) innerPadding.calculateBottomPadding() else 0.dp)
|
||||
label = { Text(stringResource(item.labelResId)) }
|
||||
)
|
||||
}
|
||||
}
|
||||
) {
|
||||
AppNavHost(
|
||||
navController = navController,
|
||||
viewModel = viewModel,
|
||||
startDestination = startDestination
|
||||
)
|
||||
}
|
||||
|
||||
// Диалог капчи поверх любого экрана. Оборачиваем в key(sessionId), чтобы для
|
||||
// каждой новой капча-сессии Compose пересоздавал диалог и WebView грузил URL заново
|
||||
// (бинарник цикличит креды и для каждой выдаёт новую капчу с тем же localhost-URL).
|
||||
val captchaState = proxyState as? ProxyState.CaptchaRequired
|
||||
if (captchaState != null) {
|
||||
androidx.compose.runtime.key(captchaState.sessionId) {
|
||||
CaptchaWebViewDialog(
|
||||
captchaUrl = captchaState.url,
|
||||
onDismiss = { viewModel.dismissCaptcha() }
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun AppNavHost(
|
||||
navController: NavHostController,
|
||||
viewModel: MainViewModel,
|
||||
startDestination: String
|
||||
) {
|
||||
NavHost(
|
||||
navController = navController,
|
||||
startDestination = startDestination,
|
||||
modifier = Modifier.statusBarsPadding() // Добавляем отступ для статус-бара сверху
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.statusBarsPadding()
|
||||
) {
|
||||
|
||||
// Онбординг-мастер (без нижнего меню)
|
||||
|
||||
// Онбординг-мастер (без навигации)
|
||||
composable(Routes.ONBOARDING) {
|
||||
OnboardingScreen(
|
||||
onSetupServer = { navController.navigate(Routes.SSH_SETUP_OB) },
|
||||
@@ -156,8 +189,7 @@ fun AppNavigation(viewModel: MainViewModel) {
|
||||
)
|
||||
}
|
||||
|
||||
// Основной поток (с нижним меню)
|
||||
|
||||
// Основной поток (с навигацией)
|
||||
composable(Routes.SSH_SETUP) {
|
||||
SshSetupScreen(
|
||||
viewModel = viewModel,
|
||||
@@ -177,7 +209,7 @@ fun AppNavigation(viewModel: MainViewModel) {
|
||||
onContinue = {
|
||||
navController.navigate(Routes.CLIENT_SETUP) {
|
||||
// Убираем SERVER_MANAGEMENT из back stack,
|
||||
// иначе он остаётся под CLIENT_SETUP и bottom nav ломается
|
||||
// иначе он остаётся под CLIENT_SETUP и навигация ломается
|
||||
popUpTo(Routes.HOME) { inclusive = false; saveState = false }
|
||||
launchSingleTop = true
|
||||
}
|
||||
@@ -203,21 +235,6 @@ fun AppNavigation(viewModel: MainViewModel) {
|
||||
LogsScreen(viewModel = viewModel)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Диалог капчи поверх любого экрана. Оборачиваем в key(sessionId), чтобы для
|
||||
// каждой новой капча-сессии Compose пересоздавал диалог и WebView грузил URL заново
|
||||
// (бинарник цикличит креды и для каждой выдаёт новую капчу с тем же localhost-URL).
|
||||
val captchaState = proxyState as? ProxyState.CaptchaRequired
|
||||
if (captchaState != null) {
|
||||
androidx.compose.runtime.key(captchaState.sessionId) {
|
||||
CaptchaWebViewDialog(
|
||||
captchaUrl = captchaState.url,
|
||||
onDismiss = { viewModel.dismissCaptcha() }
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private data class NavItem(
|
||||
@@ -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.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.size
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.widthIn
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
import androidx.compose.material3.Button
|
||||
@@ -132,8 +133,14 @@ fun ClientSetupScreen(
|
||||
.fillMaxSize()
|
||||
.padding(padding)
|
||||
.imePadding()
|
||||
.padding(horizontal = 24.dp)
|
||||
.verticalScroll(rememberScrollState()),
|
||||
horizontalAlignment = Alignment.CenterHorizontally
|
||||
) {
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.widthIn(max = 840.dp)
|
||||
.fillMaxWidth()
|
||||
.padding(horizontal = 24.dp),
|
||||
verticalArrangement = Arrangement.spacedBy(16.dp)
|
||||
) {
|
||||
Spacer(Modifier.height(4.dp))
|
||||
@@ -189,7 +196,7 @@ fun ClientSetupScreen(
|
||||
Text(
|
||||
stringResource(R.string.threads_recommendation),
|
||||
style = MaterialTheme.typography.labelSmall,
|
||||
color = MaterialTheme.colorScheme.onSurface.copy(alpha = 0.5f)
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -226,7 +233,7 @@ fun ClientSetupScreen(
|
||||
Text(
|
||||
stringResource(R.string.transport_protocol_desc),
|
||||
style = MaterialTheme.typography.labelSmall,
|
||||
color = MaterialTheme.colorScheme.onSurface.copy(alpha = 0.5f)
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant
|
||||
)
|
||||
}
|
||||
SingleChoiceSegmentedButtonRow(modifier = Modifier.fillMaxWidth()) {
|
||||
@@ -279,7 +286,7 @@ fun ClientSetupScreen(
|
||||
Text(
|
||||
stringResource(R.string.dns_mode_desc),
|
||||
style = MaterialTheme.typography.labelSmall,
|
||||
color = MaterialTheme.colorScheme.onSurface.copy(alpha = 0.5f)
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant
|
||||
)
|
||||
}
|
||||
val dnsOptions = listOf(
|
||||
@@ -358,7 +365,7 @@ fun ClientSetupScreen(
|
||||
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)
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -409,9 +416,7 @@ fun ClientSetupScreen(
|
||||
Spacer(Modifier.height(8.dp))
|
||||
Button(
|
||||
onClick = onFinish,
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.height(56.dp),
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
enabled = serverAddress.isNotBlank() && vkLink.isNotBlank(),
|
||||
shape = MaterialTheme.shapes.large
|
||||
) {
|
||||
@@ -422,6 +427,7 @@ fun ClientSetupScreen(
|
||||
Spacer(Modifier.height(24.dp))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
@@ -441,7 +447,7 @@ private fun SwitchRow(
|
||||
Text(
|
||||
description,
|
||||
style = MaterialTheme.typography.labelSmall,
|
||||
color = MaterialTheme.colorScheme.onSurface.copy(alpha = 0.5f)
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant
|
||||
)
|
||||
}
|
||||
Switch(checked = checked, onCheckedChange = onCheckedChange)
|
||||
|
||||
@@ -83,9 +83,7 @@ import androidx.core.content.ContextCompat
|
||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import kotlinx.coroutines.delay
|
||||
import com.freeturn.app.ui.HapticUtil
|
||||
import com.freeturn.app.ui.theme.StatusBlue
|
||||
import com.freeturn.app.ui.theme.StatusGreen
|
||||
import com.freeturn.app.ui.theme.StatusGreenDark
|
||||
import com.freeturn.app.ui.theme.extendedColorScheme
|
||||
import com.freeturn.app.viewmodel.MainViewModel
|
||||
import com.freeturn.app.viewmodel.ProxyState
|
||||
import com.freeturn.app.viewmodel.SshConnectionState
|
||||
@@ -205,10 +203,10 @@ fun HomeScreen(
|
||||
},
|
||||
style = MaterialTheme.typography.titleMedium,
|
||||
color = when (proxyState) {
|
||||
is ProxyState.Running -> StatusGreen
|
||||
is ProxyState.Running -> MaterialTheme.extendedColorScheme.success
|
||||
is ProxyState.Error -> MaterialTheme.colorScheme.error
|
||||
is ProxyState.CaptchaRequired -> MaterialTheme.colorScheme.error
|
||||
else -> MaterialTheme.colorScheme.onBackground.copy(alpha = 0.65f)
|
||||
else -> MaterialTheme.colorScheme.onSurfaceVariant
|
||||
},
|
||||
textAlign = TextAlign.Center
|
||||
)
|
||||
@@ -249,7 +247,8 @@ fun HomeScreen(
|
||||
modifier = Modifier
|
||||
.size(8.dp)
|
||||
.background(
|
||||
if (sshState is SshConnectionState.Connected) StatusBlue
|
||||
if (sshState is SshConnectionState.Connected)
|
||||
MaterialTheme.extendedColorScheme.info
|
||||
else MaterialTheme.colorScheme.outline,
|
||||
CircleShape
|
||||
)
|
||||
@@ -263,7 +262,7 @@ fun HomeScreen(
|
||||
else -> stringResource(R.string.ssh_disconnected)
|
||||
},
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
color = MaterialTheme.colorScheme.onBackground.copy(alpha = 0.6f)
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant
|
||||
)
|
||||
if (sshState !is SshConnectionState.Connected) {
|
||||
Spacer(Modifier.width(8.dp))
|
||||
@@ -272,8 +271,7 @@ fun HomeScreen(
|
||||
HapticUtil.perform(context, HapticUtil.Pattern.CLICK)
|
||||
viewModel.reconnectSsh()
|
||||
},
|
||||
enabled = sshState !is SshConnectionState.Connecting,
|
||||
modifier = Modifier.height(28.dp)
|
||||
enabled = sshState !is SshConnectionState.Connecting
|
||||
) {
|
||||
Text(stringResource(R.string.reconnect), style = MaterialTheme.typography.labelSmall)
|
||||
}
|
||||
@@ -401,9 +399,10 @@ private fun UpdateDialogs(viewModel: MainViewModel) {
|
||||
|
||||
@Composable
|
||||
private fun ProxyToggleButton(state: ProxyState, onClick: () -> Unit) {
|
||||
val extended = MaterialTheme.extendedColorScheme
|
||||
val containerColor by animateColorAsState(
|
||||
targetValue = when (state) {
|
||||
is ProxyState.Running -> StatusGreenDark
|
||||
is ProxyState.Running -> extended.successContainer
|
||||
is ProxyState.Error -> MaterialTheme.colorScheme.errorContainer
|
||||
is ProxyState.Starting -> MaterialTheme.colorScheme.secondaryContainer
|
||||
else -> MaterialTheme.colorScheme.primaryContainer
|
||||
@@ -413,7 +412,7 @@ private fun ProxyToggleButton(state: ProxyState, onClick: () -> Unit) {
|
||||
)
|
||||
val contentColor by animateColorAsState(
|
||||
targetValue = when (state) {
|
||||
is ProxyState.Running -> StatusGreen
|
||||
is ProxyState.Running -> extended.onSuccessContainer
|
||||
is ProxyState.Error -> MaterialTheme.colorScheme.onErrorContainer
|
||||
is ProxyState.Starting -> MaterialTheme.colorScheme.onSecondaryContainer
|
||||
else -> MaterialTheme.colorScheme.onPrimaryContainer
|
||||
@@ -435,7 +434,7 @@ private fun ProxyToggleButton(state: ProxyState, onClick: () -> Unit) {
|
||||
.clip(CircleShape),
|
||||
shape = CircleShape,
|
||||
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(
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
@@ -561,7 +560,13 @@ private fun InfoBottomSheet(
|
||||
trailingContent = {
|
||||
androidx.compose.material3.Switch(
|
||||
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 = {
|
||||
androidx.compose.material3.Switch(
|
||||
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(
|
||||
label,
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
color = MaterialTheme.colorScheme.onSurface.copy(alpha = 0.6f)
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant
|
||||
)
|
||||
Text(value, style = MaterialTheme.typography.bodySmall)
|
||||
}
|
||||
|
||||
@@ -37,8 +37,7 @@ import androidx.compose.ui.unit.dp
|
||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import com.freeturn.app.R
|
||||
import com.freeturn.app.ui.HapticUtil
|
||||
import com.freeturn.app.ui.theme.StatusGreen
|
||||
import com.freeturn.app.ui.theme.StatusOrange
|
||||
import com.freeturn.app.ui.theme.extendedColorScheme
|
||||
import com.freeturn.app.viewmodel.MainViewModel
|
||||
|
||||
@Composable
|
||||
@@ -95,7 +94,7 @@ fun LogsScreen(viewModel: MainViewModel) {
|
||||
Text(
|
||||
stringResource(R.string.no_logs),
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant.copy(alpha = 0.4f)
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant
|
||||
)
|
||||
}
|
||||
} else {
|
||||
@@ -129,8 +128,8 @@ private fun LogLine(line: String) {
|
||||
|
||||
val textColor = when {
|
||||
isError -> MaterialTheme.colorScheme.error
|
||||
isWarning -> StatusOrange
|
||||
isSuccess -> StatusGreen
|
||||
isWarning -> MaterialTheme.extendedColorScheme.warning
|
||||
isSuccess -> MaterialTheme.extendedColorScheme.success
|
||||
isHeader -> MaterialTheme.colorScheme.primary
|
||||
else -> MaterialTheme.colorScheme.onSurfaceVariant
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@ import androidx.compose.foundation.shape.CircleShape
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import com.freeturn.app.R
|
||||
import androidx.compose.material3.Button
|
||||
import androidx.compose.material3.ButtonDefaults
|
||||
import androidx.compose.material3.Card
|
||||
import androidx.compose.material3.CardDefaults
|
||||
import androidx.compose.material3.Icon
|
||||
@@ -110,7 +109,7 @@ fun OnboardingScreen(
|
||||
Text(
|
||||
text = stringResource(R.string.onboarding_subtitle),
|
||||
style = MaterialTheme.typography.bodyLarge,
|
||||
color = MaterialTheme.colorScheme.onBackground.copy(alpha = 0.65f),
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
textAlign = TextAlign.Center
|
||||
)
|
||||
|
||||
@@ -153,11 +152,8 @@ fun OnboardingScreen(
|
||||
HapticUtil.perform(context, HapticUtil.Pattern.CLICK)
|
||||
onSetupServer()
|
||||
},
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.height(56.dp),
|
||||
shape = MaterialTheme.shapes.large,
|
||||
elevation = ButtonDefaults.buttonElevation(defaultElevation = 4.dp)
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
shape = MaterialTheme.shapes.large
|
||||
) {
|
||||
Icon(painterResource(R.drawable.wifi_24px), contentDescription = null)
|
||||
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.size
|
||||
import androidx.compose.foundation.layout.width
|
||||
import androidx.compose.foundation.layout.widthIn
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.lazy.items
|
||||
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.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import com.freeturn.app.ui.HapticUtil
|
||||
import com.freeturn.app.ui.theme.StatusBlue
|
||||
import com.freeturn.app.ui.theme.StatusGreen
|
||||
import com.freeturn.app.ui.theme.extendedColorScheme
|
||||
import com.freeturn.app.viewmodel.MainViewModel
|
||||
import com.freeturn.app.viewmodel.ServerState
|
||||
import com.freeturn.app.viewmodel.SshConnectionState
|
||||
@@ -105,8 +105,14 @@ fun ServerManagementScreen(
|
||||
.fillMaxSize()
|
||||
.padding(padding)
|
||||
.imePadding()
|
||||
.padding(horizontal = 24.dp)
|
||||
.verticalScroll(rememberScrollState()),
|
||||
horizontalAlignment = Alignment.CenterHorizontally
|
||||
) {
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.widthIn(max = 840.dp)
|
||||
.fillMaxWidth()
|
||||
.padding(horizontal = 24.dp),
|
||||
verticalArrangement = Arrangement.spacedBy(16.dp)
|
||||
) {
|
||||
Spacer(Modifier.height(4.dp))
|
||||
@@ -120,7 +126,7 @@ fun ServerManagementScreen(
|
||||
label = stringResource(R.string.ssh_connection),
|
||||
isActive = isConnected,
|
||||
activeLabel = stringResource(R.string.paired),
|
||||
activeColor = StatusBlue
|
||||
activeColor = MaterialTheme.extendedColorScheme.info
|
||||
)
|
||||
Spacer(Modifier.height(10.dp))
|
||||
StatusRow(stringResource(R.string.vk_turn_proxy), serverKnown?.running == true)
|
||||
@@ -182,7 +188,7 @@ fun ServerManagementScreen(
|
||||
Text(
|
||||
text = stringResource(R.string.server_running_vless),
|
||||
style = MaterialTheme.typography.labelSmall,
|
||||
color = StatusBlue
|
||||
color = MaterialTheme.extendedColorScheme.info
|
||||
)
|
||||
}
|
||||
|
||||
@@ -194,9 +200,7 @@ fun ServerManagementScreen(
|
||||
viewModel.installServer()
|
||||
},
|
||||
enabled = isConnected && !isWorking,
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.height(52.dp),
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
shape = MaterialTheme.shapes.large
|
||||
) {
|
||||
Icon(painterResource(R.drawable.cloud_download_24px), null)
|
||||
@@ -212,9 +216,7 @@ fun ServerManagementScreen(
|
||||
},
|
||||
enabled = (isConnected && !isWorking
|
||||
&& serverKnown?.installed == true) && !serverKnown.running,
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.height(52.dp),
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
shape = MaterialTheme.shapes.large
|
||||
) {
|
||||
Icon(painterResource(R.drawable.play_arrow_24px), null)
|
||||
@@ -228,9 +230,7 @@ fun ServerManagementScreen(
|
||||
viewModel.stopServer()
|
||||
},
|
||||
enabled = isConnected && !isWorking && serverKnown?.running == true,
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.height(52.dp),
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
shape = MaterialTheme.shapes.large,
|
||||
colors = ButtonDefaults.outlinedButtonColors(
|
||||
contentColor = MaterialTheme.colorScheme.error
|
||||
@@ -248,9 +248,7 @@ fun ServerManagementScreen(
|
||||
HapticUtil.perform(context, HapticUtil.Pattern.CLICK)
|
||||
onContinue()
|
||||
},
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.height(56.dp),
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
shape = MaterialTheme.shapes.large
|
||||
) {
|
||||
Text(stringResource(R.string.continue_client_setup))
|
||||
@@ -307,11 +305,14 @@ fun ServerManagementScreen(
|
||||
Spacer(Modifier.height(24.dp))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun SshStatusBadge(sshState: SshConnectionState, ip: String) {
|
||||
val connected = sshState is SshConnectionState.Connected
|
||||
val dotColor = if (connected) MaterialTheme.extendedColorScheme.info
|
||||
else MaterialTheme.colorScheme.error
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
modifier = Modifier.padding(end = 16.dp)
|
||||
@@ -319,13 +320,13 @@ private fun SshStatusBadge(sshState: SshConnectionState, ip: String) {
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.size(8.dp)
|
||||
.background(if (connected) StatusBlue else MaterialTheme.colorScheme.error, CircleShape)
|
||||
.background(dotColor, CircleShape)
|
||||
)
|
||||
Spacer(Modifier.width(6.dp))
|
||||
Text(
|
||||
if (connected) ip else stringResource(R.string.not_connected),
|
||||
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,
|
||||
isActive: Boolean,
|
||||
activeLabel: String = stringResource(R.string.active),
|
||||
activeColor: Color = StatusGreen
|
||||
activeColor: Color = MaterialTheme.extendedColorScheme.success
|
||||
) {
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
|
||||
@@ -75,10 +75,3 @@ val surfaceContainerLowDark = Color(0xFF191C20)
|
||||
val surfaceContainerDark = Color(0xFF1D2024)
|
||||
val surfaceContainerHighDark = Color(0xFF282A2F)
|
||||
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.lightColorScheme
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.CompositionLocalProvider
|
||||
import androidx.compose.runtime.SideEffect
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
@@ -116,9 +117,13 @@ fun FreeTurnTheme(
|
||||
}
|
||||
}
|
||||
|
||||
CompositionLocalProvider(
|
||||
LocalExtendedColorScheme provides extendedColorSchemeFor(darkTheme)
|
||||
) {
|
||||
MaterialTheme(
|
||||
colorScheme = colorScheme,
|
||||
typography = Typography,
|
||||
content = content
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
[versions]
|
||||
agp = "9.1.0"
|
||||
agp = "9.1.1"
|
||||
kotlin = "2.3.20"
|
||||
coreKtx = "1.18.0"
|
||||
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-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-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-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" }
|
||||
|
||||
Reference in new issue
Block a user