The group dialogs list a group we may not assign only when the client is in it, and the rows drop the 48dp minimum touch target for a 6dp padding. The Server groups and Channel group actions share one row. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -15,12 +15,14 @@ import androidx.compose.material3.AlertDialog
|
|||||||
import androidx.compose.material3.Checkbox
|
import androidx.compose.material3.Checkbox
|
||||||
import androidx.compose.material3.DropdownMenu
|
import androidx.compose.material3.DropdownMenu
|
||||||
import androidx.compose.material3.DropdownMenuItem
|
import androidx.compose.material3.DropdownMenuItem
|
||||||
|
import androidx.compose.material3.LocalMinimumInteractiveComponentSize
|
||||||
import androidx.compose.material3.OutlinedButton
|
import androidx.compose.material3.OutlinedButton
|
||||||
import androidx.compose.material3.OutlinedTextField
|
import androidx.compose.material3.OutlinedTextField
|
||||||
import androidx.compose.material3.RadioButton
|
import androidx.compose.material3.RadioButton
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.material3.TextButton
|
import androidx.compose.material3.TextButton
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.runtime.CompositionLocalProvider
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.runtime.mutableStateOf
|
import androidx.compose.runtime.mutableStateOf
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
@@ -30,6 +32,7 @@ import androidx.compose.ui.Modifier
|
|||||||
import androidx.compose.ui.draw.alpha
|
import androidx.compose.ui.draw.alpha
|
||||||
import androidx.compose.ui.text.input.KeyboardType
|
import androidx.compose.ui.text.input.KeyboardType
|
||||||
import androidx.compose.ui.text.style.TextAlign
|
import androidx.compose.ui.text.style.TextAlign
|
||||||
|
import androidx.compose.ui.unit.Dp
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import eu.lixko.ts3j.client.android.ClientItem
|
import eu.lixko.ts3j.client.android.ClientItem
|
||||||
import eu.lixko.ts3j.client.android.ServerController
|
import eu.lixko.ts3j.client.android.ServerController
|
||||||
@@ -132,7 +135,8 @@ internal fun BanDurationField(state: BanDurationState, maxSeconds: Long, modifie
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* A client's groups to tick: several server groups, or with [single] the one channel group.
|
* A client's groups to tick: several server groups, or with [single] the one channel group.
|
||||||
* Groups we have no power over show greyed out; a change shows once the server made it.
|
* Groups we may not assign are listed only when the client is in them, greyed out; a change shows once the server
|
||||||
|
* made it.
|
||||||
*/
|
*/
|
||||||
@Composable
|
@Composable
|
||||||
fun GroupsDialog(
|
fun GroupsDialog(
|
||||||
@@ -146,28 +150,30 @@ fun GroupsDialog(
|
|||||||
onDismissRequest = onDismiss,
|
onDismissRequest = onDismiss,
|
||||||
title = { Text(title) },
|
title = { Text(title) },
|
||||||
text = {
|
text = {
|
||||||
LazyColumn {
|
CompositionLocalProvider(LocalMinimumInteractiveComponentSize provides Dp.Unspecified) {
|
||||||
items(choices, key = { it.group().id }) { choice ->
|
LazyColumn {
|
||||||
val group = choice.group()
|
items(choices.filter { it.allowed() || it.assigned() }, key = { it.group().id }) { choice ->
|
||||||
// A client always has one channel group: picking another is the only change.
|
val group = choice.group()
|
||||||
val changeable = choice.allowed() && !(single && choice.assigned())
|
// A client always has one channel group: picking another is the only change.
|
||||||
val toggle = { if (changeable) onChange(group.id, !choice.assigned()) }
|
val changeable = choice.allowed() && !(single && choice.assigned())
|
||||||
Row(
|
val toggle = { if (changeable) onChange(group.id, !choice.assigned()) }
|
||||||
Modifier.fillMaxWidth()
|
Row(
|
||||||
.clickable(enabled = changeable, onClick = toggle)
|
Modifier.fillMaxWidth()
|
||||||
.alpha(if (choice.allowed()) 1f else 0.38f)
|
.clickable(enabled = changeable, onClick = toggle)
|
||||||
.padding(vertical = 2.dp),
|
.alpha(if (choice.allowed()) 1f else 0.38f)
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
.padding(vertical = 6.dp),
|
||||||
) {
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
if (single) {
|
) {
|
||||||
RadioButton(choice.assigned(), onClick = toggle, enabled = choice.allowed())
|
if (single) {
|
||||||
} else {
|
RadioButton(choice.assigned(), onClick = toggle, enabled = choice.allowed())
|
||||||
Checkbox(choice.assigned(), onCheckedChange = { toggle() }, enabled = choice.allowed())
|
} else {
|
||||||
|
Checkbox(choice.assigned(), onCheckedChange = { toggle() }, enabled = choice.allowed())
|
||||||
|
}
|
||||||
|
Box(Modifier.width(24.dp), contentAlignment = Alignment.Center) {
|
||||||
|
if (group.iconId != 0L) ServerIcon(group.iconId)
|
||||||
|
}
|
||||||
|
Text(group.name, Modifier.padding(start = 8.dp))
|
||||||
}
|
}
|
||||||
Box(Modifier.width(24.dp), contentAlignment = Alignment.Center) {
|
|
||||||
if (group.iconId != 0L) ServerIcon(group.iconId)
|
|
||||||
}
|
|
||||||
Text(group.name, Modifier.padding(start = 8.dp))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -190,9 +196,13 @@ fun ClientModeration(server: ServerController, client: ClientItem, onDone: () ->
|
|||||||
if (server.canKickFromServer) Action("KICK_FROM_SERVER", "Kick from server") { kick = true }
|
if (server.canKickFromServer) Action("KICK_FROM_SERVER", "Kick from server") { kick = true }
|
||||||
if (server.canBanClients) Action("BAN_CLIENT", "Ban") { banning = true }
|
if (server.canBanClients) Action("BAN_CLIENT", "Ban") { banning = true }
|
||||||
}
|
}
|
||||||
if (serverGroups.any { it.allowed() }) Action("PERMISSIONS_SERVER_GROUPS", "Server groups") { groups = true }
|
val showServerGroups = serverGroups.any { it.allowed() }
|
||||||
if (channelGroups.any { it.allowed() && !it.assigned() }) {
|
val showChannelGroups = channelGroups.any { it.allowed() && !it.assigned() }
|
||||||
Action("PERMISSIONS_CHANNEL_GROUPS", "Channel group") { groups = false }
|
if (showServerGroups || showChannelGroups) {
|
||||||
|
Row {
|
||||||
|
if (showServerGroups) Action("PERMISSIONS_SERVER_GROUPS", "Server groups", Modifier.weight(1f)) { groups = true }
|
||||||
|
if (showChannelGroups) Action("PERMISSIONS_CHANNEL_GROUPS", "Channel group", Modifier.weight(1f)) { groups = false }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
kick?.let { fromServer ->
|
kick?.let { fromServer ->
|
||||||
|
|||||||
Reference in New Issue
Block a user