Removed unused Column(LibraryTopBar)
This commit is contained in:
parent
b1ebe72cc3
commit
8100902cba
1 changed files with 122 additions and 126 deletions
|
|
@ -4,10 +4,8 @@ import androidx.compose.animation.animateColorAsState
|
||||||
import androidx.compose.animation.core.Spring
|
import androidx.compose.animation.core.Spring
|
||||||
import androidx.compose.animation.core.spring
|
import androidx.compose.animation.core.spring
|
||||||
import androidx.compose.foundation.background
|
import androidx.compose.foundation.background
|
||||||
import androidx.compose.foundation.layout.Column
|
|
||||||
import androidx.compose.foundation.layout.Row
|
import androidx.compose.foundation.layout.Row
|
||||||
import androidx.compose.foundation.layout.Spacer
|
import androidx.compose.foundation.layout.Spacer
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.foundation.layout.width
|
import androidx.compose.foundation.layout.width
|
||||||
import androidx.compose.foundation.pager.PagerState
|
import androidx.compose.foundation.pager.PagerState
|
||||||
|
|
@ -58,133 +56,131 @@ fun LibraryTopBar(
|
||||||
) {
|
) {
|
||||||
val focusRequester = remember { FocusRequester() }
|
val focusRequester = remember { FocusRequester() }
|
||||||
|
|
||||||
Column(Modifier.fillMaxWidth()) {
|
AnimatedTopAppBar(
|
||||||
AnimatedTopAppBar(
|
scrollBehavior = null,
|
||||||
scrollBehavior = null,
|
isTopBarScrolled = state.value.hasSelectedItems,
|
||||||
isTopBarScrolled = state.value.hasSelectedItems,
|
|
||||||
|
|
||||||
content1Visibility = !state.value.hasSelectedItems && !state.value.showSearch,
|
content1Visibility = !state.value.hasSelectedItems && !state.value.showSearch,
|
||||||
content1NavigationIcon = {},
|
content1NavigationIcon = {},
|
||||||
content1Title = {
|
content1Title = {
|
||||||
Row(verticalAlignment = Alignment.CenterVertically) {
|
Row(verticalAlignment = Alignment.CenterVertically) {
|
||||||
Text(stringResource(id = R.string.library_screen))
|
Text(stringResource(id = R.string.library_screen))
|
||||||
Spacer(modifier = Modifier.width(6.dp))
|
Spacer(modifier = Modifier.width(6.dp))
|
||||||
Text(
|
|
||||||
text = state.value.books.size.toString(),
|
|
||||||
modifier = Modifier
|
|
||||||
.background(
|
|
||||||
MaterialTheme.colorScheme.surfaceContainer,
|
|
||||||
RoundedCornerShape(14.dp)
|
|
||||||
)
|
|
||||||
.padding(horizontal = 8.dp, vertical = 3.dp),
|
|
||||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
|
||||||
fontSize = 16.sp
|
|
||||||
)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
content1Actions = {
|
|
||||||
CustomIconButton(
|
|
||||||
icon = Icons.Default.Search,
|
|
||||||
contentDescription = R.string.search_content_desc,
|
|
||||||
disableOnClick = true,
|
|
||||||
) {
|
|
||||||
onEvent(LibraryEvent.OnSearchShowHide)
|
|
||||||
}
|
|
||||||
MoreDropDown()
|
|
||||||
},
|
|
||||||
|
|
||||||
content2Visibility = state.value.hasSelectedItems,
|
|
||||||
content2NavigationIcon = {
|
|
||||||
CustomIconButton(
|
|
||||||
icon = Icons.Default.Clear,
|
|
||||||
contentDescription = R.string.clear_selected_items_content_desc,
|
|
||||||
disableOnClick = true
|
|
||||||
) {
|
|
||||||
onEvent(LibraryEvent.OnClearSelectedBooks)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
content2Title = {
|
|
||||||
Text(
|
Text(
|
||||||
stringResource(
|
text = state.value.books.size.toString(),
|
||||||
id = R.string.selected_items_count_query,
|
|
||||||
state.value.selectedItemsCount.coerceAtLeast(1)
|
|
||||||
),
|
|
||||||
overflow = TextOverflow.Ellipsis,
|
|
||||||
maxLines = 1
|
|
||||||
)
|
|
||||||
},
|
|
||||||
content2Actions = {
|
|
||||||
CustomIconButton(
|
|
||||||
icon = Icons.AutoMirrored.Outlined.DriveFileMove,
|
|
||||||
contentDescription = R.string.move_books_content_desc,
|
|
||||||
enabled = !state.value.isLoading
|
|
||||||
&& !state.value.isRefreshing
|
|
||||||
&& !state.value.showMoveDialog,
|
|
||||||
disableOnClick = false,
|
|
||||||
|
|
||||||
) {
|
|
||||||
onEvent(LibraryEvent.OnShowHideMoveDialog)
|
|
||||||
}
|
|
||||||
CustomIconButton(
|
|
||||||
icon = Icons.Outlined.Delete,
|
|
||||||
contentDescription = R.string.delete_books_content_desc,
|
|
||||||
enabled = !state.value.isLoading
|
|
||||||
&& !state.value.isRefreshing
|
|
||||||
&& !state.value.showDeleteDialog,
|
|
||||||
disableOnClick = false
|
|
||||||
) {
|
|
||||||
onEvent(LibraryEvent.OnShowHideDeleteDialog)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
content3Visibility = state.value.showSearch && !state.value.hasSelectedItems,
|
|
||||||
content3NavigationIcon = {
|
|
||||||
CustomIconButton(
|
|
||||||
icon = Icons.AutoMirrored.Default.ArrowBack,
|
|
||||||
contentDescription = R.string.exit_search_content_desc,
|
|
||||||
disableOnClick = true
|
|
||||||
) {
|
|
||||||
onEvent(
|
|
||||||
LibraryEvent.OnSearchShowHide
|
|
||||||
)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
content3Title = {
|
|
||||||
CustomSearchTextField(
|
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.focusRequester(focusRequester)
|
.background(
|
||||||
.onGloballyPositioned {
|
MaterialTheme.colorScheme.surfaceContainer,
|
||||||
onEvent(LibraryEvent.OnRequestFocus(focusRequester))
|
RoundedCornerShape(14.dp)
|
||||||
},
|
)
|
||||||
query = state.value.searchQuery,
|
.padding(horizontal = 8.dp, vertical = 3.dp),
|
||||||
onQueryChange = {
|
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||||
onEvent(LibraryEvent.OnSearchQueryChange(it))
|
fontSize = 16.sp
|
||||||
},
|
|
||||||
onSearch = {
|
|
||||||
onEvent(LibraryEvent.OnSearch)
|
|
||||||
},
|
|
||||||
placeholder = stringResource(
|
|
||||||
id = R.string.search_query,
|
|
||||||
stringResource(id = R.string.books)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
},
|
|
||||||
content3Actions = {
|
|
||||||
MoreDropDown()
|
|
||||||
},
|
|
||||||
customContent = {
|
|
||||||
LibraryTabRow(
|
|
||||||
onEvent = onEvent,
|
|
||||||
books = state.value.categorizedBooks,
|
|
||||||
itemCountBackgroundColor = animateColorAsState(
|
|
||||||
if (state.value.hasSelectedItems) MaterialTheme.colorScheme.surfaceContainerHighest
|
|
||||||
else MaterialTheme.colorScheme.surfaceContainer,
|
|
||||||
animationSpec = spring(stiffness = Spring.StiffnessMediumLow),
|
|
||||||
label = stringResource(id = R.string.top_app_bar_anim_content_desc)
|
|
||||||
).value,
|
|
||||||
pagerState = pagerState
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
)
|
},
|
||||||
}
|
content1Actions = {
|
||||||
|
CustomIconButton(
|
||||||
|
icon = Icons.Default.Search,
|
||||||
|
contentDescription = R.string.search_content_desc,
|
||||||
|
disableOnClick = true,
|
||||||
|
) {
|
||||||
|
onEvent(LibraryEvent.OnSearchShowHide)
|
||||||
|
}
|
||||||
|
MoreDropDown()
|
||||||
|
},
|
||||||
|
|
||||||
|
content2Visibility = state.value.hasSelectedItems,
|
||||||
|
content2NavigationIcon = {
|
||||||
|
CustomIconButton(
|
||||||
|
icon = Icons.Default.Clear,
|
||||||
|
contentDescription = R.string.clear_selected_items_content_desc,
|
||||||
|
disableOnClick = true
|
||||||
|
) {
|
||||||
|
onEvent(LibraryEvent.OnClearSelectedBooks)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
content2Title = {
|
||||||
|
Text(
|
||||||
|
stringResource(
|
||||||
|
id = R.string.selected_items_count_query,
|
||||||
|
state.value.selectedItemsCount.coerceAtLeast(1)
|
||||||
|
),
|
||||||
|
overflow = TextOverflow.Ellipsis,
|
||||||
|
maxLines = 1
|
||||||
|
)
|
||||||
|
},
|
||||||
|
content2Actions = {
|
||||||
|
CustomIconButton(
|
||||||
|
icon = Icons.AutoMirrored.Outlined.DriveFileMove,
|
||||||
|
contentDescription = R.string.move_books_content_desc,
|
||||||
|
enabled = !state.value.isLoading
|
||||||
|
&& !state.value.isRefreshing
|
||||||
|
&& !state.value.showMoveDialog,
|
||||||
|
disableOnClick = false,
|
||||||
|
|
||||||
|
) {
|
||||||
|
onEvent(LibraryEvent.OnShowHideMoveDialog)
|
||||||
|
}
|
||||||
|
CustomIconButton(
|
||||||
|
icon = Icons.Outlined.Delete,
|
||||||
|
contentDescription = R.string.delete_books_content_desc,
|
||||||
|
enabled = !state.value.isLoading
|
||||||
|
&& !state.value.isRefreshing
|
||||||
|
&& !state.value.showDeleteDialog,
|
||||||
|
disableOnClick = false
|
||||||
|
) {
|
||||||
|
onEvent(LibraryEvent.OnShowHideDeleteDialog)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
content3Visibility = state.value.showSearch && !state.value.hasSelectedItems,
|
||||||
|
content3NavigationIcon = {
|
||||||
|
CustomIconButton(
|
||||||
|
icon = Icons.AutoMirrored.Default.ArrowBack,
|
||||||
|
contentDescription = R.string.exit_search_content_desc,
|
||||||
|
disableOnClick = true
|
||||||
|
) {
|
||||||
|
onEvent(
|
||||||
|
LibraryEvent.OnSearchShowHide
|
||||||
|
)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
content3Title = {
|
||||||
|
CustomSearchTextField(
|
||||||
|
modifier = Modifier
|
||||||
|
.focusRequester(focusRequester)
|
||||||
|
.onGloballyPositioned {
|
||||||
|
onEvent(LibraryEvent.OnRequestFocus(focusRequester))
|
||||||
|
},
|
||||||
|
query = state.value.searchQuery,
|
||||||
|
onQueryChange = {
|
||||||
|
onEvent(LibraryEvent.OnSearchQueryChange(it))
|
||||||
|
},
|
||||||
|
onSearch = {
|
||||||
|
onEvent(LibraryEvent.OnSearch)
|
||||||
|
},
|
||||||
|
placeholder = stringResource(
|
||||||
|
id = R.string.search_query,
|
||||||
|
stringResource(id = R.string.books)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
},
|
||||||
|
content3Actions = {
|
||||||
|
MoreDropDown()
|
||||||
|
},
|
||||||
|
customContent = {
|
||||||
|
LibraryTabRow(
|
||||||
|
onEvent = onEvent,
|
||||||
|
books = state.value.categorizedBooks,
|
||||||
|
itemCountBackgroundColor = animateColorAsState(
|
||||||
|
if (state.value.hasSelectedItems) MaterialTheme.colorScheme.surfaceContainerHighest
|
||||||
|
else MaterialTheme.colorScheme.surfaceContainer,
|
||||||
|
animationSpec = spring(stiffness = Spring.StiffnessMediumLow),
|
||||||
|
label = stringResource(id = R.string.top_app_bar_anim_content_desc)
|
||||||
|
).value,
|
||||||
|
pagerState = pagerState
|
||||||
|
)
|
||||||
|
}
|
||||||
|
)
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue