Implement the dialog to add a new shopping list (#280)

* Add endpoint to create new shopping lists

* Initialize editing of lists names

* Implement adding new lists

* Fix invalid password for demo

* Use StateFlow to avoid lost state updates

* Refactor the list update to support empty lists

* Hide add new list button if there's a new list

* Scroll to the newly added list or item

* Replace deprecated Divider

* Move new field name input to dialog

* Display a modal dialog instead of bottom sheet

* Reduce unnecessary recompositions

* Do not hide button since it is overlapped by dialog

* Extract Composable for editable items

* Remove unused imports

* Add UI for removing and editing shopping lists

* Implement editing list name and removing lists

* Fix initial cursor state when editing name

* Add capitalization of list names

* Fix color of divider in dark mode
This commit is contained in:
Kirill Kamakin
2024-07-27 20:12:00 +02:00
committed by GitHub
parent f0098af3f6
commit 86e70e03d0
22 changed files with 1066 additions and 171 deletions

View File

@@ -5,6 +5,8 @@ import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.LazyListScope
import androidx.compose.foundation.lazy.LazyListState
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.material.ExperimentalMaterialApi
import androidx.compose.material.pullrefresh.PullRefreshIndicator
import androidx.compose.material.pullrefresh.PullRefreshState
@@ -22,6 +24,7 @@ fun LazyColumnPullRefresh(
verticalArrangement: Arrangement.Vertical,
lazyColumnContent: LazyListScope.() -> Unit,
modifier: Modifier = Modifier,
lazyListState: LazyListState = rememberLazyListState(),
) {
Box(
modifier = modifier.pullRefresh(refreshState),
@@ -29,6 +32,7 @@ fun LazyColumnPullRefresh(
LazyColumn(
contentPadding = contentPadding,
verticalArrangement = verticalArrangement,
state = lazyListState,
content = lazyColumnContent
)

View File

@@ -5,6 +5,8 @@ import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyListScope
import androidx.compose.foundation.lazy.LazyListState
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.material.ExperimentalMaterialApi
import androidx.compose.material.pullrefresh.rememberPullRefreshState
import androidx.compose.material3.FabPosition
@@ -35,6 +37,7 @@ fun <T> LazyColumnWithLoadingState(
onRefresh: () -> Unit = {},
floatingActionButton: @Composable () -> Unit = {},
floatingActionButtonPosition: FabPosition = FabPosition.End,
lazyListState: LazyListState = rememberLazyListState(),
lazyColumnContent: LazyListScope.(List<T>) -> Unit = {},
) {
val refreshState = rememberPullRefreshState(
@@ -76,6 +79,7 @@ fun <T> LazyColumnWithLoadingState(
contentPadding = contentPadding,
verticalArrangement = verticalArrangement,
lazyColumnContent = { lazyColumnContent(list) },
lazyListState = lazyListState,
modifier = innerModifier,
)