zt
07/03/2024, 5:58 PMColton Idle
07/03/2024, 11:15 PMzt
07/03/2024, 11:30 PMzt
07/04/2024, 3:20 AMRow(
modifier = Modifier.padding(horizontal = 4.dp, vertical = 4.dp),
horizontalArrangement = Arrangement.spacedBy(4.dp),
verticalAlignment = Alignment.CenterVertically
) {
var searching by rememberSaveable { mutableStateOf(false) }
Crossfade(
targetState = searching,
animationSpec = tween(200)
) {
if (it) {
TextField(
modifier = Modifier
.width(400.dp)
.heightIn(min = 42.dp, max = 42.dp),
value = state.search,
textStyle = MaterialTheme.typography.bodyMedium,
onValueChange = state::search::set,
placeholder = {
Text(
text = Res.string.search,
style = MaterialTheme.typography.bodyMedium
)
},
// trailingIcon = {
// Icon(Icons.Default.Search, Res.string.search)
// },
shape = CircleShape,
colors = TextFieldDefaults.colors(
focusedIndicatorColor = Color.Transparent,
unfocusedIndicatorColor = Color.Transparent
)
)
} else {
PathBar(
state = state,
modifier = Modifier.weight(1f, true),
location = state.currentLocation,
onClickSegment = state::navigate
)
}
}
Spacer(Modifier.weight(1f, true))
FilledTonalIconToggleButton(
checked = searching,
onCheckedChange = { searching = it }
) {
Icon(
imageVector = Icons.Default.Search,
contentDescription = Res.string.search
)
}
}
Colton Idle
07/04/2024, 3:24 AMzt
07/04/2024, 3:27 AM@Composable
fun PathBar(
state: BrowserState,
location: Path,
onClickSegment: (Path) -> Unit,
modifier: Modifier = Modifier
) {
val rootPath = location.root
val segments = remember(location) {
location
.absolutePathString()
.replace("""^[A-Z]:\\""".toRegex(), "")
.split(File.separatorChar)
.filter(String::isNotBlank)
}
LazyRow(
modifier = modifier,
horizontalArrangement = Arrangement.spacedBy(4.dp)
) {
item {
FilledTonalButton(
shape = MaterialTheme.shapes.large,
onClick = { onClickSegment(rootPath) }
) {
Icon(
imageVector = Icons.Default.Storage,
null
)
Spacer(Modifier.width(2.dp))
Text(rootPath.absolutePathString())
}
}
itemsIndexed(
items = segments,
key = { index, _ -> index }
) { _, segment ->
val fullPath =
remember {
Path(state.currentLocation.toString().substringBefore(segment) + segment)
}
TooltipArea(
tooltip = {
Surface(
shape = MaterialTheme.shapes.medium,
tonalElevation = 6.dp,
shadowElevation = 4.dp
) {
Text(
modifier = Modifier.padding(10.dp),
text = fullPath.absolutePathString()
)
}
}
) {
FolderContextMenu {
FilledTonalButton(
shape = MaterialTheme.shapes.large,
onClick = { onClickSegment(fullPath) }
) {
Text(
text = segment,
overflow = TextOverflow.Ellipsis
)
}
}
}
}
}
Colton Idle
07/04/2024, 3:30 AMzt
07/04/2024, 3:31 AMColton Idle
07/04/2024, 3:39 AM