Skip to content

Commit

Permalink
Extract dashboard container out of the xml NestedScroll and SwipeToRe…
Browse files Browse the repository at this point in the history
…fresh
  • Loading branch information
JorgeMucientes committed Dec 5, 2024
1 parent 9939969 commit 83227a1
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.lazy.staggeredgrid.LazyVerticalStaggeredGrid
import androidx.compose.foundation.lazy.staggeredgrid.StaggeredGridCells
import androidx.compose.foundation.lazy.staggeredgrid.items
Expand Down Expand Up @@ -90,15 +92,17 @@ private fun DashboardWidgets(
val widgetModifier = Modifier
.fillMaxWidth()
.padding(horizontal = 16.dp)
val nestedScrollInterop = rememberNestedScrollInteropConnection()

if (numberOfColumns == 1) {
Column(
modifier = modifier,
LazyColumn(
modifier = modifier.nestedScroll(nestedScrollInterop),
verticalArrangement = Arrangement.spacedBy(16.dp),
) {
widgetUiModels.forEach {
AnimatedVisibility(it.isVisible) {
items(widgetUiModels) { widget ->
AnimatedVisibility(widget.isVisible) {
DashboardWidgetCard(
it,
widget,
mainActivityViewModel,
dashboardViewModel,
blazeCampaignCreationDispatcher,
Expand All @@ -108,7 +112,6 @@ private fun DashboardWidgets(
}
}
} else {
val nestedScrollInterop = rememberNestedScrollInteropConnection()
LazyVerticalStaggeredGrid(
modifier = modifier.nestedScroll(nestedScrollInterop),
columns = StaggeredGridCells.Adaptive(400.dp),
Expand Down
48 changes: 25 additions & 23 deletions WooCommerce/src/main/res/layout/fragment_dashboard.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,31 @@
android:layout_height="wrap_content"
android:orientation="vertical">

<LinearLayout
android:id="@+id/my_store_stats_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:animateLayoutChanges="true"
android:descendantFocusability="blocksDescendants"
android:orientation="vertical">

<androidx.fragment.app.FragmentContainerView
android:id="@+id/jitmFragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/minor_100" />

<!-- Dynamic dashboard container -->
<androidx.compose.ui.platform.ComposeView
android:id="@+id/dashboard_container"
android:layout_width="match_parent"
android:layout_height="wrap_content" />

<include
android:id="@+id/jetpack_benefits_banner"
layout="@layout/view_jetpack_benefits_bottom_banner" />
</LinearLayout>

<com.woocommerce.android.widgets.ScrollChildSwipeRefreshLayout
android:id="@+id/my_store_refresh_layout"
android:layout_width="match_parent"
Expand All @@ -26,32 +51,9 @@
android:layout_height="match_parent"
android:transitionGroup="true">

<LinearLayout
android:id="@+id/my_store_stats_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:animateLayoutChanges="true"
android:descendantFocusability="blocksDescendants"
android:orientation="vertical">

<androidx.fragment.app.FragmentContainerView
android:id="@+id/jitmFragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/minor_100" />

<!-- Dynamic dashboard container -->
<androidx.compose.ui.platform.ComposeView
android:id="@+id/dashboard_container"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</androidx.core.widget.NestedScrollView>

</com.woocommerce.android.widgets.ScrollChildSwipeRefreshLayout>

<include
android:id="@+id/jetpack_benefits_banner"
layout="@layout/view_jetpack_benefits_bottom_banner" />
</androidx.appcompat.widget.LinearLayoutCompat>
</RelativeLayout>

0 comments on commit 83227a1

Please sign in to comment.