feat: icons
This commit is contained in:
1 parent
2c3dcce8e5
commit
84ea44813e
32 files changed
+326
-186
No files matched your search
@@ -1,6 +1,7 @@
|
||||
package com.freeturn.app.ui.navigation
|
||||
|
||||
import androidx.compose.animation.AnimatedVisibility
|
||||
import androidx.compose.animation.Crossfade
|
||||
import androidx.compose.animation.core.Animatable
|
||||
import androidx.compose.animation.core.Spring
|
||||
import androidx.compose.animation.core.spring
|
||||
@@ -8,31 +9,21 @@ import androidx.compose.animation.core.tween
|
||||
import androidx.compose.animation.slideInVertically
|
||||
import androidx.compose.animation.slideOutVertically
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.WindowInsets
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.layout.statusBarsPadding
|
||||
import androidx.compose.foundation.layout.width
|
||||
import androidx.compose.foundation.shape.CircleShape
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.Home
|
||||
import androidx.compose.material.icons.filled.PhoneAndroid
|
||||
import androidx.compose.material.icons.filled.Security
|
||||
import androidx.compose.material.icons.filled.Storage
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.NavigationBar
|
||||
import androidx.compose.material3.NavigationBarItem
|
||||
import androidx.compose.material3.Scaffold
|
||||
import androidx.compose.material3.Surface
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
@@ -40,12 +31,12 @@ import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.graphics.graphicsLayer
|
||||
import androidx.compose.ui.graphics.vector.ImageVector
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.freeturn.app.R
|
||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import androidx.navigation.compose.NavHost
|
||||
import androidx.navigation.compose.composable
|
||||
@@ -98,7 +89,7 @@ fun AppNavigation(viewModel: MainViewModel) {
|
||||
enter = slideInVertically(initialOffsetY = { it }),
|
||||
exit = slideOutVertically(targetOffsetY = { it })
|
||||
) {
|
||||
FloatingNavBar(
|
||||
AppNavigationBar(
|
||||
currentRoute = currentRoute,
|
||||
onNavigate = { route ->
|
||||
navController.navigate(route) {
|
||||
@@ -106,17 +97,12 @@ fun AppNavigation(viewModel: MainViewModel) {
|
||||
launchSingleTop = true
|
||||
restoreState = true
|
||||
}
|
||||
},
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(start = 16.dp, end = 16.dp, bottom = 16.dp)
|
||||
}
|
||||
)
|
||||
}
|
||||
},
|
||||
contentWindowInsets = WindowInsets(0, 0, 0, 0) // Мы обрабатываем отступы вручную или через контент
|
||||
contentWindowInsets = WindowInsets(0, 0, 0, 0)
|
||||
) { innerPadding ->
|
||||
// innerPadding содержит отступы для BottomBar.
|
||||
// Если BottomBar "парящий", мы можем игнорировать или использовать часть отступа.
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
@@ -266,7 +252,7 @@ private fun SplashScreen() {
|
||||
contentAlignment = Alignment.Center
|
||||
) {
|
||||
Icon(
|
||||
imageVector = Icons.Filled.Security,
|
||||
painter = painterResource(R.drawable.nearby_24px),
|
||||
contentDescription = null,
|
||||
modifier = Modifier.size(60.dp),
|
||||
tint = Color.White
|
||||
@@ -288,93 +274,46 @@ private fun SplashScreen() {
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun FloatingNavBar(
|
||||
currentRoute: String?,
|
||||
onNavigate: (String) -> Unit,
|
||||
modifier: Modifier = Modifier
|
||||
) {
|
||||
Surface(
|
||||
modifier = modifier,
|
||||
shape = RoundedCornerShape(28.dp),
|
||||
tonalElevation = 8.dp,
|
||||
shadowElevation = 12.dp
|
||||
) {
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(horizontal = 8.dp, vertical = 8.dp),
|
||||
horizontalArrangement = Arrangement.SpaceEvenly
|
||||
) {
|
||||
FloatingNavItem(
|
||||
route = Routes.HOME,
|
||||
icon = Icons.Filled.Home,
|
||||
label = "Главная",
|
||||
currentRoute = currentRoute,
|
||||
onNavigate = onNavigate
|
||||
)
|
||||
FloatingNavItem(
|
||||
route = Routes.SERVER_MANAGEMENT,
|
||||
icon = Icons.Filled.Storage,
|
||||
label = "Сервер",
|
||||
currentRoute = currentRoute,
|
||||
onNavigate = onNavigate
|
||||
)
|
||||
FloatingNavItem(
|
||||
route = Routes.CLIENT_SETUP,
|
||||
icon = Icons.Filled.PhoneAndroid,
|
||||
label = "Клиент",
|
||||
currentRoute = currentRoute,
|
||||
onNavigate = onNavigate
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
private data class NavItem(
|
||||
val route: String,
|
||||
val label: String,
|
||||
val selectedIconRes: Int,
|
||||
val unselectedIconRes: Int
|
||||
)
|
||||
|
||||
private val navItems = listOf(
|
||||
NavItem(Routes.HOME, "Главная", R.drawable.home_24px, R.drawable.home_outlined_24px),
|
||||
NavItem(Routes.SERVER_MANAGEMENT, "Сервер", R.drawable.database_24px, R.drawable.database_outlined_24px),
|
||||
NavItem(Routes.CLIENT_SETUP, "Клиент", R.drawable.mobile_24px, R.drawable.mobile_outlined_24px)
|
||||
)
|
||||
|
||||
@Composable
|
||||
private fun FloatingNavItem(
|
||||
route: String,
|
||||
icon: ImageVector,
|
||||
label: String,
|
||||
private fun AppNavigationBar(
|
||||
currentRoute: String?,
|
||||
onNavigate: (String) -> Unit
|
||||
) {
|
||||
val selected = currentRoute == route
|
||||
val context = LocalContext.current
|
||||
Column(
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
modifier = Modifier
|
||||
.clip(RoundedCornerShape(20.dp))
|
||||
.clickable {
|
||||
if (!selected) HapticUtil.perform(context, HapticUtil.Pattern.SELECTION)
|
||||
onNavigate(route)
|
||||
}
|
||||
.padding(horizontal = 20.dp, vertical = 6.dp)
|
||||
) {
|
||||
Surface(
|
||||
shape = RoundedCornerShape(50),
|
||||
color = if (selected) MaterialTheme.colorScheme.secondaryContainer
|
||||
else Color.Transparent,
|
||||
modifier = Modifier
|
||||
.width(56.dp)
|
||||
.height(28.dp)
|
||||
) {
|
||||
Box(contentAlignment = Alignment.Center) {
|
||||
Icon(
|
||||
imageVector = icon,
|
||||
contentDescription = label,
|
||||
modifier = Modifier.size(20.dp),
|
||||
tint = if (selected) MaterialTheme.colorScheme.onSecondaryContainer
|
||||
else MaterialTheme.colorScheme.onSurface.copy(alpha = 0.55f)
|
||||
)
|
||||
}
|
||||
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 = item.label
|
||||
)
|
||||
}
|
||||
},
|
||||
label = { Text(item.label) }
|
||||
)
|
||||
}
|
||||
Spacer(Modifier.height(3.dp))
|
||||
Text(
|
||||
text = label,
|
||||
style = MaterialTheme.typography.labelSmall,
|
||||
color = if (selected) MaterialTheme.colorScheme.secondary
|
||||
else MaterialTheme.colorScheme.onSurface.copy(alpha = 0.55f)
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,6 @@ package com.freeturn.app.ui.screens
|
||||
|
||||
import androidx.activity.compose.rememberLauncherForActivityResult
|
||||
import androidx.activity.result.contract.ActivityResultContracts
|
||||
import androidx.compose.animation.AnimatedVisibility
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
@@ -15,19 +14,14 @@ import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.imePadding
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.ExpandLess
|
||||
import androidx.compose.material.icons.filled.ExpandMore
|
||||
import androidx.compose.material3.Button
|
||||
import androidx.compose.material3.ButtonDefaults
|
||||
import androidx.compose.material3.Card
|
||||
import androidx.compose.material3.CardDefaults
|
||||
import androidx.compose.material3.DividerDefaults
|
||||
import androidx.compose.material3.HorizontalDivider
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.OutlinedButton
|
||||
import androidx.compose.material3.OutlinedTextField
|
||||
@@ -83,7 +77,6 @@ fun ClientSetupScreen(
|
||||
var useUdp by rememberSaveable(saved.useUdp) { mutableStateOf(saved.useUdp) }
|
||||
var noDtls by rememberSaveable(saved.noDtls) { mutableStateOf(saved.noDtls) }
|
||||
var localPort by rememberSaveable(saved.localPort) { mutableStateOf(saved.localPort) }
|
||||
var showAdvanced by rememberSaveable { mutableStateOf(false) }
|
||||
var lastSliderInt by rememberSaveable { mutableIntStateOf(saved.threads) }
|
||||
|
||||
// Автозаполнение адреса сервера из SSH-конфига если поле пустое
|
||||
@@ -206,48 +199,17 @@ fun ClientSetupScreen(
|
||||
}
|
||||
)
|
||||
|
||||
HorizontalDivider(Modifier, DividerDefaults.Thickness, DividerDefaults.color)
|
||||
|
||||
// ── Дополнительно (сворачиваемый) ─────────────────────────────
|
||||
Card(
|
||||
OutlinedTextField(
|
||||
value = localPort,
|
||||
onValueChange = { localPort = it },
|
||||
label = { Text("Локальный адрес прослушивания") },
|
||||
placeholder = { Text("127.0.0.1:9000") },
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
colors = CardDefaults.cardColors(
|
||||
containerColor = MaterialTheme.colorScheme.surfaceVariant
|
||||
),
|
||||
onClick = {
|
||||
HapticUtil.perform(context, HapticUtil.Pattern.SELECTION)
|
||||
showAdvanced = !showAdvanced
|
||||
singleLine = true,
|
||||
supportingText = {
|
||||
Text("Адрес, на котором клиент принимает трафик от WireGuard/Hysteria")
|
||||
}
|
||||
) {
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(horizontal = 16.dp, vertical = 12.dp),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.SpaceBetween
|
||||
) {
|
||||
Text("Дополнительно", style = MaterialTheme.typography.labelLarge)
|
||||
Icon(
|
||||
if (showAdvanced) Icons.Filled.ExpandLess else Icons.Filled.ExpandMore,
|
||||
contentDescription = null,
|
||||
modifier = Modifier.size(20.dp)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
AnimatedVisibility(visible = showAdvanced) {
|
||||
OutlinedTextField(
|
||||
value = localPort,
|
||||
onValueChange = { localPort = it },
|
||||
label = { Text("Локальный адрес прослушивания") },
|
||||
placeholder = { Text("127.0.0.1:9000") },
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
singleLine = true,
|
||||
supportingText = {
|
||||
Text("Адрес, на котором клиент принимает трафик от WireGuard/Hysteria")
|
||||
}
|
||||
)
|
||||
}
|
||||
)
|
||||
|
||||
HorizontalDivider(Modifier, DividerDefaults.Thickness, DividerDefaults.color)
|
||||
|
||||
|
||||
@@ -27,14 +27,8 @@ import androidx.compose.foundation.lazy.rememberLazyListState
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
import androidx.compose.foundation.shape.CircleShape
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.automirrored.filled.Launch
|
||||
import androidx.compose.material.icons.filled.CheckCircle
|
||||
import androidx.compose.material.icons.filled.ContentCopy
|
||||
import androidx.compose.material.icons.filled.Error
|
||||
import androidx.compose.material.icons.filled.Info
|
||||
import androidx.compose.material.icons.filled.PlayArrow
|
||||
import androidx.compose.material.icons.filled.Refresh
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import com.freeturn.app.R
|
||||
import androidx.compose.material3.AlertDialog
|
||||
import androidx.compose.material3.ButtonDefaults
|
||||
import androidx.compose.material3.Card
|
||||
@@ -160,7 +154,7 @@ fun HomeScreen(
|
||||
HapticUtil.perform(context, HapticUtil.Pattern.CLICK)
|
||||
showBottomSheet.value = true
|
||||
}) {
|
||||
Icon(Icons.Filled.Info, contentDescription = "Информация")
|
||||
Icon(painterResource(R.drawable.info_24px), contentDescription = "Информация")
|
||||
}
|
||||
}
|
||||
)
|
||||
@@ -348,15 +342,15 @@ private fun ProxyToggleButton(state: ProxyState, onClick: () -> Unit) {
|
||||
when (state) {
|
||||
is ProxyState.Starting -> CircularProgressIndicator(color = contentColor)
|
||||
is ProxyState.Running -> Icon(
|
||||
Icons.Filled.CheckCircle, null,
|
||||
painterResource(R.drawable.check_circle_24px), null,
|
||||
Modifier.size(52.dp), tint = contentColor
|
||||
)
|
||||
is ProxyState.Error -> Icon(
|
||||
Icons.Filled.Error, null,
|
||||
painterResource(R.drawable.error_24px), null,
|
||||
Modifier.size(52.dp), tint = contentColor
|
||||
)
|
||||
else -> Icon(
|
||||
Icons.Filled.PlayArrow, null,
|
||||
painterResource(R.drawable.play_arrow_24px), null,
|
||||
Modifier.size(52.dp), tint = contentColor
|
||||
)
|
||||
}
|
||||
@@ -433,7 +427,7 @@ private fun InfoBottomSheet(
|
||||
HapticUtil.perform(context, HapticUtil.Pattern.CLICK)
|
||||
viewModel.reconnectSsh()
|
||||
}) {
|
||||
Icon(Icons.Filled.Refresh, contentDescription = "Переподключить")
|
||||
Icon(painterResource(R.drawable.refresh_24px), contentDescription = "Переподключить")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -455,7 +449,7 @@ private fun InfoBottomSheet(
|
||||
},
|
||||
enabled = logs.isNotEmpty()
|
||||
) {
|
||||
Icon(Icons.Filled.ContentCopy, contentDescription = "Копировать логи", modifier = Modifier.size(18.dp))
|
||||
Icon(painterResource(R.drawable.content_copy_24px), contentDescription = "Копировать логи", modifier = Modifier.size(18.dp))
|
||||
}
|
||||
TextButton(onClick = {
|
||||
HapticUtil.perform(context, HapticUtil.Pattern.CLICK)
|
||||
@@ -577,7 +571,7 @@ private fun RepoLinkItem(
|
||||
},
|
||||
trailingContent = {
|
||||
Icon(
|
||||
Icons.AutoMirrored.Filled.Launch,
|
||||
painterResource(R.drawable.open_in_new_24px),
|
||||
contentDescription = "Открыть",
|
||||
modifier = Modifier.size(18.dp),
|
||||
tint = MaterialTheme.colorScheme.primary
|
||||
|
||||
@@ -19,10 +19,8 @@ import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.layout.width
|
||||
import androidx.compose.foundation.shape.CircleShape
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.Security
|
||||
import androidx.compose.material.icons.filled.Sensors
|
||||
import androidx.compose.material.icons.filled.Wifi
|
||||
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
|
||||
@@ -90,7 +88,7 @@ fun OnboardingScreen(
|
||||
contentAlignment = Alignment.Center
|
||||
) {
|
||||
Icon(
|
||||
imageVector = Icons.Filled.Sensors,
|
||||
painter = painterResource(R.drawable.nearby_24px),
|
||||
contentDescription = null,
|
||||
modifier = Modifier.size(80.dp),
|
||||
tint = MaterialTheme.colorScheme.primary
|
||||
@@ -129,7 +127,7 @@ fun OnboardingScreen(
|
||||
verticalAlignment = Alignment.Top
|
||||
) {
|
||||
Icon(
|
||||
Icons.Filled.Security,
|
||||
painterResource(R.drawable.nearby_24px),
|
||||
contentDescription = null,
|
||||
tint = MaterialTheme.colorScheme.secondary,
|
||||
modifier = Modifier.size(18.dp)
|
||||
@@ -160,7 +158,7 @@ fun OnboardingScreen(
|
||||
shape = MaterialTheme.shapes.large,
|
||||
elevation = ButtonDefaults.buttonElevation(defaultElevation = 4.dp)
|
||||
) {
|
||||
Icon(Icons.Filled.Wifi, contentDescription = null)
|
||||
Icon(painterResource(R.drawable.wifi_24px), contentDescription = null)
|
||||
Spacer(Modifier.width(10.dp))
|
||||
Text("Настроить сервер", style = MaterialTheme.typography.labelLarge)
|
||||
}
|
||||
|
||||
@@ -21,12 +21,8 @@ import androidx.compose.foundation.lazy.rememberLazyListState
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
import androidx.compose.foundation.shape.CircleShape
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.automirrored.filled.ArrowForward
|
||||
import androidx.compose.material.icons.filled.CloudDownload
|
||||
import androidx.compose.material.icons.filled.PlayArrow
|
||||
import androidx.compose.material.icons.filled.Refresh
|
||||
import androidx.compose.material.icons.filled.Stop
|
||||
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
|
||||
@@ -181,7 +177,7 @@ fun ServerManagementScreen(
|
||||
.height(52.dp),
|
||||
shape = MaterialTheme.shapes.large
|
||||
) {
|
||||
Icon(Icons.Filled.CloudDownload, null)
|
||||
Icon(painterResource(R.drawable.cloud_download_24px), null)
|
||||
Spacer(Modifier.width(8.dp))
|
||||
Text(if (serverKnown?.installed == true) "Обновить" else "Установить")
|
||||
}
|
||||
@@ -199,7 +195,7 @@ fun ServerManagementScreen(
|
||||
.height(52.dp),
|
||||
shape = MaterialTheme.shapes.large
|
||||
) {
|
||||
Icon(Icons.Filled.PlayArrow, null)
|
||||
Icon(painterResource(R.drawable.play_arrow_24px), null)
|
||||
Spacer(Modifier.width(8.dp))
|
||||
Text("Запустить сервер")
|
||||
}
|
||||
@@ -218,7 +214,7 @@ fun ServerManagementScreen(
|
||||
contentColor = MaterialTheme.colorScheme.error
|
||||
)
|
||||
) {
|
||||
Icon(Icons.Filled.Stop, null)
|
||||
Icon(painterResource(R.drawable.stop_24px), null)
|
||||
Spacer(Modifier.width(8.dp))
|
||||
Text("Остановить сервер")
|
||||
}
|
||||
@@ -237,7 +233,7 @@ fun ServerManagementScreen(
|
||||
) {
|
||||
Text("Продолжить настройку клиента")
|
||||
Spacer(Modifier.width(8.dp))
|
||||
Icon(Icons.AutoMirrored.Filled.ArrowForward, null)
|
||||
Icon(painterResource(R.drawable.arrow_forward_24px), null)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -257,7 +253,7 @@ fun ServerManagementScreen(
|
||||
},
|
||||
enabled = isConnected
|
||||
) {
|
||||
Icon(Icons.Filled.Refresh, contentDescription = "Запросить server.log", modifier = Modifier.size(18.dp))
|
||||
Icon(painterResource(R.drawable.refresh_24px), contentDescription = "Запросить server.log", modifier = Modifier.size(18.dp))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user