@ -24,6 +24,8 @@ import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.outlined.ArrowDropDown
import androidx.compose.material.icons.outlined.ArrowDropDown
import androidx.compose.material.icons.outlined.Clear
import androidx.compose.material.icons.outlined.Close
import androidx.compose.material.icons.outlined.Search
import androidx.compose.material.icons.outlined.Search
import androidx.compose.material.icons.outlined.Settings
import androidx.compose.material.icons.outlined.Settings
import androidx.compose.material3.Button
import androidx.compose.material3.Button
@ -33,16 +35,20 @@ import androidx.compose.material3.IconButton
import androidx.compose.material3.ListItem
import androidx.compose.material3.ListItem
import androidx.compose.material3.ListItemDefaults
import androidx.compose.material3.ListItemDefaults
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.OutlinedTextField
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Scaffold
import androidx.compose.material3.SearchBar
import androidx.compose.material3.SearchBarDefaults
import androidx.compose.material3.Text
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.draw.clip
import androidx.compose.ui.focus.onFocusChanged
import androidx.compose.ui.platform.LocalFocusManager
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.text.SpanStyle
import androidx.compose.ui.text.SpanStyle
@ -66,6 +72,7 @@ import com.tailscale.ipn.ui.model.Tailcfg
import com.tailscale.ipn.ui.theme.disabled
import com.tailscale.ipn.ui.theme.disabled
import com.tailscale.ipn.ui.theme.listItem
import com.tailscale.ipn.ui.theme.listItem
import com.tailscale.ipn.ui.theme.primaryListItem
import com.tailscale.ipn.ui.theme.primaryListItem
import com.tailscale.ipn.ui.theme.searchBarColors
import com.tailscale.ipn.ui.theme.secondaryButton
import com.tailscale.ipn.ui.theme.secondaryButton
import com.tailscale.ipn.ui.theme.surfaceContainerListItem
import com.tailscale.ipn.ui.theme.surfaceContainerListItem
import com.tailscale.ipn.ui.util.Lists
import com.tailscale.ipn.ui.util.Lists
@ -318,24 +325,45 @@ fun PeerList(
val searchTermStr by viewModel . searchTerm . collectAsState ( initial = " " )
val searchTermStr by viewModel . searchTerm . collectAsState ( initial = " " )
val netmap = viewModel . netmap . collectAsState ( )
val netmap = viewModel . netmap . collectAsState ( )
SearchBar (
val focusManager = LocalFocusManager . current
query = searchTermStr ,
var isFocussed by remember { mutableStateOf ( false ) }
onQueryChange = onSearch ,
onSearch = onSearch ,
Box ( modifier = Modifier . fillMaxWidth ( ) . background ( color = MaterialTheme . colorScheme . surface ) ) {
active = true ,
OutlinedTextField (
onActiveChange = { } ,
modifier =
shape = RoundedCornerShape ( 10. dp ) ,
Modifier . fillMaxWidth ( ) . padding ( horizontal = 16. dp , vertical = 8. dp ) . onFocusChanged {
leadingIcon = { Icon ( Icons . Outlined . Search , null ) } ,
isFocussed = it . isFocused
} ,
singleLine = true ,
shape = MaterialTheme . shapes . large ,
colors = MaterialTheme . colorScheme . searchBarColors ,
leadingIcon = { Icon ( imageVector = Icons . Outlined . Search , contentDescription = " search " ) } ,
trailingIcon = {
trailingIcon = {
if ( searchTermStr . isNotEmpty ( ) ) ClearButton ( { onSearch ( " " ) } ) else CloseButton ( )
if ( isFocussed ) {
IconButton (
onClick = {
focusManager . clearFocus ( )
onSearch ( " " )
} ) {
Icon (
imageVector =
if ( searchTermStr . isEmpty ( ) ) Icons . Outlined . Close
else Icons . Outlined . Clear ,
contentDescription = " clear search " ,
tint = MaterialTheme . colorScheme . onSurfaceVariant )
}
}
} ,
} ,
tonalElevation = 0. dp ,
placeholder = {
shadowElevation = 0. dp ,
Text (
colors =
text = stringResource ( id = R . string . search ) ,
SearchBarDefaults . colors (
style = MaterialTheme . typography . bodyLarge ,
containerColor = MaterialTheme . colorScheme . surface ,
maxLines = 1 )
dividerColor = MaterialTheme . colorScheme . outline ) ,
} ,
modifier = Modifier . fillMaxWidth ( ) ) {
value = searchTermStr ,
onValueChange = { onSearch ( it ) } )
}
LazyColumn (
LazyColumn (
modifier = Modifier . fillMaxSize ( ) ,
modifier = Modifier . fillMaxSize ( ) ,
) {
) {
@ -354,8 +382,7 @@ fun PeerList(
modifier = Modifier . heightIn ( max = 48. dp ) ,
modifier = Modifier . heightIn ( max = 48. dp ) ,
headlineContent = {
headlineContent = {
Text (
Text (
text =
text = peerSet . user ?. DisplayName ?: stringResource ( id = R . string . unknown _user ) ,
peerSet . user ?. DisplayName ?: stringResource ( id = R . string . unknown _user ) ,
style = MaterialTheme . typography . titleLarge ,
style = MaterialTheme . typography . titleLarge ,
fontWeight = FontWeight . SemiBold )
fontWeight = FontWeight . SemiBold )
} )
} )
@ -387,7 +414,6 @@ fun PeerList(
}
}
}
}
}
}
}
@OptIn ( ExperimentalPermissionsApi :: class )
@OptIn ( ExperimentalPermissionsApi :: class )
@Composable
@Composable