-
Notifications
You must be signed in to change notification settings - Fork 137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dashboard big screen support with staggered grid layout for cards #13079
base: trunk
Are you sure you want to change the base?
Changes from all commits
9939969
83227a1
0eca83c
2b7fbfc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,10 +30,10 @@ import com.woocommerce.android.extensions.getColorCompat | |
import com.woocommerce.android.extensions.handleNotice | ||
import com.woocommerce.android.extensions.handleResult | ||
import com.woocommerce.android.extensions.navigateSafely | ||
import com.woocommerce.android.extensions.scrollStartEvents | ||
import com.woocommerce.android.extensions.showDateRangePicker | ||
import com.woocommerce.android.extensions.startHelpActivity | ||
import com.woocommerce.android.extensions.verticalOffsetChanges | ||
import com.woocommerce.android.extensions.windowSizeClass | ||
import com.woocommerce.android.model.DashboardWidget | ||
import com.woocommerce.android.support.help.HelpOrigin | ||
import com.woocommerce.android.tools.SelectedSite | ||
|
@@ -51,6 +51,7 @@ import com.woocommerce.android.ui.dashboard.DashboardViewModel.DashboardEvent.Fe | |
import com.woocommerce.android.ui.dashboard.DashboardViewModel.DashboardEvent.FeedbackPositiveAction | ||
import com.woocommerce.android.ui.dashboard.DashboardViewModel.DashboardEvent.OpenEditWidgets | ||
import com.woocommerce.android.ui.dashboard.DashboardViewModel.DashboardEvent.OpenRangePicker | ||
import com.woocommerce.android.ui.dashboard.DashboardViewModel.DashboardEvent.RefreshJitm | ||
import com.woocommerce.android.ui.dashboard.DashboardViewModel.DashboardEvent.ShareStore | ||
import com.woocommerce.android.ui.dashboard.DashboardViewModel.DashboardEvent.ShowPrivacyBanner | ||
import com.woocommerce.android.ui.dashboard.DashboardViewModel.DashboardWidgetUiModel | ||
|
@@ -137,24 +138,15 @@ class DashboardFragment : | |
DashboardContainer( | ||
mainActivityViewModel = mainActivityViewModel, | ||
dashboardViewModel = dashboardViewModel, | ||
blazeCampaignCreationDispatcher = blazeCampaignCreationDispatcher | ||
blazeCampaignCreationDispatcher = blazeCampaignCreationDispatcher, | ||
windowSizeClass = requireContext().windowSizeClass | ||
) | ||
} | ||
} | ||
} | ||
|
||
binding.myStoreRefreshLayout.setOnRefreshListener { | ||
binding.myStoreRefreshLayout.isRefreshing = false | ||
dashboardViewModel.onPullToRefresh() | ||
refreshJitm() | ||
} | ||
|
||
prepareJetpackBenefitsBanner() | ||
|
||
binding.statsScrollView.scrollStartEvents() | ||
.onEach { usageTracksEventEmitter.interacted() } | ||
.launchIn(viewLifecycleOwner.lifecycleScope) | ||
|
||
setupStateObservers() | ||
setupResultHandlers() | ||
} | ||
|
@@ -188,6 +180,8 @@ class DashboardFragment : | |
|
||
is ShowSnackbar -> ToastUtils.showToast(requireContext(), event.message) | ||
|
||
is RefreshJitm -> refreshJitm() | ||
|
||
else -> event.isHandled = false | ||
} | ||
} | ||
|
@@ -197,10 +191,10 @@ class DashboardFragment : | |
dashboardViewModel.jetpackBenefitsBannerState.observe(viewLifecycleOwner) { jetpackBenefitsBanner -> | ||
onVisitorStatsUnavailable(jetpackBenefitsBanner) | ||
} | ||
dashboardViewModel.dashboardWidgets.observe(viewLifecycleOwner) { widgets -> | ||
dashboardViewModel.dashboardCardsState.observe(viewLifecycleOwner) { state -> | ||
// Show banners only if onboarding list is NOT displayed | ||
if ( | ||
widgets.none { | ||
state.widgets.none { | ||
(it as? DashboardWidgetUiModel.ConfigurableWidget)?.widget?.type == DashboardWidget.Type.ONBOARDING | ||
} | ||
) { | ||
|
@@ -210,9 +204,6 @@ class DashboardFragment : | |
dashboardViewModel.hasNewWidgets.observe(viewLifecycleOwner) { hasNewWidgets -> | ||
editButtonBadge.isVisible = hasNewWidgets | ||
} | ||
dashboardViewModel.isRefreshingOnBackground.observe(viewLifecycleOwner) { isRefreshing -> | ||
binding.myStoreRefreshLayout.isRefreshing = isRefreshing | ||
} | ||
} | ||
|
||
private fun setupResultHandlers() { | ||
|
@@ -325,10 +316,6 @@ class DashboardFragment : | |
|
||
override fun getFragmentSubtitle(): String = dashboardViewModel.storeName.value ?: "" | ||
|
||
override fun scrollToTop() { | ||
binding.statsScrollView.smoothScrollTo(0, 0) | ||
} | ||
|
||
private fun handleFeedbackRequestPositiveClick() { | ||
// Request a ReviewInfo object from the Google Reviews API. If this fails | ||
// we just move on as there isn't anything we can do. | ||
|
@@ -362,7 +349,11 @@ class DashboardFragment : | |
) | ||
} | ||
|
||
override fun shouldExpandToolbar() = binding.statsScrollView.scrollY == 0 | ||
override fun shouldExpandToolbar() = true | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a small issue I'm not sure it can be resolved with the current implementation. This callback handles showing the toolbar collapsed/expanded properly when navigating back and forth from dashboard. Using LazyColumn or LazyStaggered grid we don't have access to scroll position and thus we won't be able to tell if the toolbar should be expanded or collapsed. By default we'll show it expanded and as soon as the user scrolls it will adjust accordingly: toolbarExpandedDefault.mp4I think this is an acceptable tradeoff if we get proper support for tablet screens. |
||
|
||
override fun scrollToTop() { | ||
return | ||
} | ||
|
||
@OptIn(ExperimentalBadgeUtils::class) | ||
override fun onCreateMenu(menu: Menu, menuInflater: MenuInflater) { | ||
|
Check warning
Code scanning / Android Lint
Guidelines for Modifier parameters in a Composable function Warning