fix: мелкие исправления в модалке выбора сервера
This commit is contained in:
1 parent
cb2e41d3fd
commit
1dc67a44df
2 files changed
+47
-28
No files matched your search
@@ -201,7 +201,7 @@ fun HomeScreen(
|
|||||||
val sheetColor = MaterialTheme.colorScheme.surfaceContainerLow
|
val sheetColor = MaterialTheme.colorScheme.surfaceContainerLow
|
||||||
BottomSheetScaffold(
|
BottomSheetScaffold(
|
||||||
scaffoldState = sheetScaffoldState,
|
scaffoldState = sheetScaffoldState,
|
||||||
sheetPeekHeight = 132.dp,
|
sheetPeekHeight = 112.dp,
|
||||||
sheetContainerColor = sheetColor,
|
sheetContainerColor = sheetColor,
|
||||||
sheetContent = {
|
sheetContent = {
|
||||||
ProfilesSheetContent(
|
ProfilesSheetContent(
|
||||||
|
|||||||
@@ -19,10 +19,13 @@ import androidx.compose.foundation.lazy.LazyColumn
|
|||||||
import androidx.compose.foundation.lazy.items
|
import androidx.compose.foundation.lazy.items
|
||||||
import androidx.compose.foundation.shape.CircleShape
|
import androidx.compose.foundation.shape.CircleShape
|
||||||
import androidx.compose.material3.AlertDialog
|
import androidx.compose.material3.AlertDialog
|
||||||
import androidx.compose.material3.AssistChip
|
|
||||||
import androidx.compose.material3.ButtonDefaults
|
import androidx.compose.material3.ButtonDefaults
|
||||||
import androidx.compose.material3.DropdownMenu
|
import androidx.compose.material3.DropdownMenu
|
||||||
import androidx.compose.material3.DropdownMenuItem
|
import androidx.compose.material3.DropdownMenuItem
|
||||||
|
import androidx.compose.material3.ExposedDropdownMenuAnchorType
|
||||||
|
import androidx.compose.material3.ExposedDropdownMenuBox
|
||||||
|
import androidx.compose.material3.ExposedDropdownMenuDefaults
|
||||||
|
import androidx.compose.material3.FilterChip
|
||||||
import androidx.compose.material3.FilledTonalButton
|
import androidx.compose.material3.FilledTonalButton
|
||||||
import androidx.compose.material3.HorizontalDivider
|
import androidx.compose.material3.HorizontalDivider
|
||||||
import androidx.compose.material3.Icon
|
import androidx.compose.material3.Icon
|
||||||
@@ -31,7 +34,11 @@ import androidx.compose.material3.MaterialTheme
|
|||||||
import androidx.compose.material3.RadioButton
|
import androidx.compose.material3.RadioButton
|
||||||
import androidx.compose.material3.Surface
|
import androidx.compose.material3.Surface
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
|
import androidx.compose.material3.PlainTooltip
|
||||||
import androidx.compose.material3.TextButton
|
import androidx.compose.material3.TextButton
|
||||||
|
import androidx.compose.material3.TooltipBox
|
||||||
|
import androidx.compose.material3.TooltipDefaults
|
||||||
|
import androidx.compose.material3.rememberTooltipState
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.runtime.mutableStateOf
|
import androidx.compose.runtime.mutableStateOf
|
||||||
@@ -46,6 +53,7 @@ import androidx.compose.ui.res.stringResource
|
|||||||
import androidx.compose.ui.semantics.semantics
|
import androidx.compose.ui.semantics.semantics
|
||||||
import androidx.compose.ui.semantics.selected
|
import androidx.compose.ui.semantics.selected
|
||||||
import androidx.compose.ui.text.style.TextAlign
|
import androidx.compose.ui.text.style.TextAlign
|
||||||
|
import androidx.compose.ui.text.style.TextOverflow
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import com.freeturn.app.R
|
import com.freeturn.app.R
|
||||||
import com.freeturn.app.data.Profile
|
import com.freeturn.app.data.Profile
|
||||||
@@ -89,17 +97,26 @@ fun ProfilesSheetContent(
|
|||||||
.padding(horizontal = 24.dp, vertical = 4.dp),
|
.padding(horizontal = 24.dp, vertical = 4.dp),
|
||||||
horizontalAlignment = Alignment.CenterHorizontally
|
horizontalAlignment = Alignment.CenterHorizontally
|
||||||
) {
|
) {
|
||||||
Text(
|
val profileName = when {
|
||||||
// Пока snapshot не загружен - пустая строка (держит высоту строки),
|
active != null -> active.name
|
||||||
// чтобы на холодном старте не мигало «несохранённый».
|
snapshot.loaded -> stringResource(R.string.profile_unsaved_label)
|
||||||
when {
|
else -> ""
|
||||||
active != null -> active.name
|
}
|
||||||
snapshot.loaded -> stringResource(R.string.profile_unsaved_label)
|
TooltipBox(
|
||||||
else -> ""
|
positionProvider = TooltipDefaults.rememberTooltipPositionProvider(),
|
||||||
},
|
tooltip = { PlainTooltip { Text(profileName) } },
|
||||||
style = MaterialTheme.typography.headlineMedium,
|
state = rememberTooltipState(),
|
||||||
textAlign = TextAlign.Center
|
enableUserInput = active != null
|
||||||
)
|
) {
|
||||||
|
Text(
|
||||||
|
profileName,
|
||||||
|
style = MaterialTheme.typography.titleLarge,
|
||||||
|
textAlign = TextAlign.Center,
|
||||||
|
maxLines = 1,
|
||||||
|
overflow = TextOverflow.Ellipsis,
|
||||||
|
modifier = Modifier.fillMaxWidth()
|
||||||
|
)
|
||||||
|
}
|
||||||
val sub = active?.let {
|
val sub = active?.let {
|
||||||
val addr = (it.client.serverAddress.takeIf { a -> a.isNotBlank() }
|
val addr = (it.client.serverAddress.takeIf { a -> a.isNotBlank() }
|
||||||
?: it.ssh.ip.takeIf { a -> a.isNotBlank() })?.redact(privacyMode)
|
?: it.ssh.ip.takeIf { a -> a.isNotBlank() })?.redact(privacyMode)
|
||||||
@@ -279,7 +296,6 @@ private fun ProfileRow(
|
|||||||
onRename: () -> Unit,
|
onRename: () -> Unit,
|
||||||
onDelete: () -> Unit,
|
onDelete: () -> Unit,
|
||||||
) {
|
) {
|
||||||
val context = LocalContext.current
|
|
||||||
Row(
|
Row(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
@@ -358,22 +374,25 @@ private fun ProviderChip(
|
|||||||
) {
|
) {
|
||||||
val context = LocalContext.current
|
val context = LocalContext.current
|
||||||
var expanded by remember { mutableStateOf(false) }
|
var expanded by remember { mutableStateOf(false) }
|
||||||
Box(modifier = modifier) {
|
ExposedDropdownMenuBox(
|
||||||
AssistChip(
|
expanded = expanded,
|
||||||
onClick = {
|
onExpandedChange = {
|
||||||
HapticUtil.perform(context, HapticUtil.Pattern.CLICK)
|
HapticUtil.perform(context, HapticUtil.Pattern.CLICK)
|
||||||
expanded = true
|
expanded = it
|
||||||
},
|
},
|
||||||
|
modifier = modifier
|
||||||
|
) {
|
||||||
|
FilterChip(
|
||||||
|
selected = true,
|
||||||
|
onClick = {},
|
||||||
label = { Text(providerLabel(current)) },
|
label = { Text(providerLabel(current)) },
|
||||||
trailingIcon = {
|
trailingIcon = { ExposedDropdownMenuDefaults.TrailingIcon(expanded) },
|
||||||
Icon(
|
modifier = Modifier.menuAnchor(ExposedDropdownMenuAnchorType.PrimaryNotEditable)
|
||||||
painterResource(R.drawable.arrow_drop_down_24px),
|
|
||||||
contentDescription = stringResource(R.string.profiles_provider_label),
|
|
||||||
modifier = Modifier.size(18.dp)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
DropdownMenu(expanded = expanded, onDismissRequest = { expanded = false }) {
|
ExposedDropdownMenu(
|
||||||
|
expanded = expanded,
|
||||||
|
onDismissRequest = { expanded = false }
|
||||||
|
) {
|
||||||
Provider.ALL.forEach { value ->
|
Provider.ALL.forEach { value ->
|
||||||
DropdownMenuItem(
|
DropdownMenuItem(
|
||||||
text = { Text(providerLabel(value)) },
|
text = { Text(providerLabel(value)) },
|
||||||
|
|||||||
Reference in new issue
Block a user