Add Top Categories dashboard card UI#15581
Add Top Categories dashboard card UI#15581JorgeMucientes wants to merge 5 commits intoissue/top-categories-data-layerfrom
Conversation
Generated by 🚫 Danger |
|
|
| import androidx.compose.foundation.layout.height | ||
| import androidx.compose.foundation.layout.padding | ||
| import androidx.compose.foundation.layout.width | ||
| import androidx.compose.material.Divider |
Check warning
Code scanning / Android Lint
material and material3 are separate, incompatible design system libraries Warning
| import androidx.compose.foundation.layout.padding | ||
| import androidx.compose.foundation.layout.width | ||
| import androidx.compose.material.Divider | ||
| import androidx.compose.material.MaterialTheme |
Check warning
Code scanning / Android Lint
material and material3 are separate, incompatible design system libraries Warning
| import androidx.compose.foundation.layout.width | ||
| import androidx.compose.material.Divider | ||
| import androidx.compose.material.MaterialTheme | ||
| import androidx.compose.material.Text |
Check warning
Code scanning / Android Lint
material and material3 are separate, incompatible design system libraries Warning
| import androidx.compose.foundation.layout.padding | ||
| import androidx.compose.foundation.lazy.LazyColumn | ||
| import androidx.compose.foundation.lazy.itemsIndexed | ||
| import androidx.compose.material.CircularProgressIndicator |
Check warning
Code scanning / Android Lint
material and material3 are separate, incompatible design system libraries Warning
| import androidx.compose.foundation.lazy.LazyColumn | ||
| import androidx.compose.foundation.lazy.itemsIndexed | ||
| import androidx.compose.material.CircularProgressIndicator | ||
| import androidx.compose.material.Divider |
Check warning
Code scanning / Android Lint
material and material3 are separate, incompatible design system libraries Warning
| import androidx.compose.foundation.lazy.itemsIndexed | ||
| import androidx.compose.material.CircularProgressIndicator | ||
| import androidx.compose.material.Divider | ||
| import androidx.compose.material.MaterialTheme |
Check warning
Code scanning / Android Lint
material and material3 are separate, incompatible design system libraries Warning
| import androidx.compose.material.CircularProgressIndicator | ||
| import androidx.compose.material.Divider | ||
| import androidx.compose.material.MaterialTheme | ||
| import androidx.compose.material.Text |
Check warning
Code scanning / Android Lint
material and material3 are separate, incompatible design system libraries Warning
7aa9518 to
8eadf43
Compare
Add the ViewModel, Compose UI, and category products screen: - DashboardTopCategoriesViewModel with date range selection and data loading - DashboardTopCategoriesWidgetCard with table layout showing category name, items sold, and net sales - GetSelectedRangeForTopCategories for date range persistence - CategoryProductsFragment/Screen/ViewModel for drill-down into products within a selected category
Add TOP_CATEGORIES to DashboardWidget.Type enum, route widget in DashboardContainer to the card composable, add DashboardRepository status mapping, navigation graph entries for category products screen, and string resources for the card UI.
8eadf43 to
b35fe34
Compare
There was a problem hiding this comment.
Pull request overview
Adds the UI layer for a new “Top categories” dashboard widget, including date range selection and a drill-down screen to view products within a selected category.
Changes:
- Introduces
DashboardTopCategoriesViewModeland a newDashboardTopCategoriesWidgetCardCompose card for displaying category leaderboards. - Adds navigation + new drill-down destination (
CategoryProductsFragment/CategoryProductsScreen/CategoryProductsViewModel) to show products for a selected category and date range. - Registers the widget type (
TOP_CATEGORIES) and wires it into dashboard rendering, status mapping, resources, and unit tests.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| WooCommerce/src/test/kotlin/com/woocommerce/android/ui/dashboard/topcategories/DashboardTopCategoriesViewModelTest.kt | Adds unit tests for DashboardTopCategoriesViewModel core states/events. |
| WooCommerce/src/main/res/values/strings.xml | Adds strings for the new Top Categories widget and products drill-down title. |
| WooCommerce/src/main/res/navigation/nav_graph_main.xml | Adds nav action from dashboard to category-products destination and defines its arguments. |
| WooCommerce/src/main/kotlin/com/woocommerce/android/ui/dashboard/topcategories/categoryproducts/CategoryProductsViewModel.kt | Adds ViewModel to load products for a category within a time range and emit navigation events. |
| WooCommerce/src/main/kotlin/com/woocommerce/android/ui/dashboard/topcategories/categoryproducts/CategoryProductsScreen.kt | Adds Compose UI to render loading/error/empty/product list states for category products. |
| WooCommerce/src/main/kotlin/com/woocommerce/android/ui/dashboard/topcategories/categoryproducts/CategoryProductsFragment.kt | Adds Fragment hosting the Compose screen and handling product navigation. |
| WooCommerce/src/main/kotlin/com/woocommerce/android/ui/dashboard/topcategories/GetSelectedRangeForTopCategories.kt | Adds date range selection persistence wrapper for the Top Categories card. |
| WooCommerce/src/main/kotlin/com/woocommerce/android/ui/dashboard/topcategories/DashboardTopCategoriesWidgetCard.kt | Adds Compose widget card UI, including range header, list/table layout, and navigation event handling. |
| WooCommerce/src/main/kotlin/com/woocommerce/android/ui/dashboard/topcategories/DashboardTopCategoriesViewModel.kt | Adds ViewModel for loading categories leaderboard data, date-range behavior, refresh, and analytics/navigation events. |
| WooCommerce/src/main/kotlin/com/woocommerce/android/ui/dashboard/data/DashboardRepository.kt | Maps TOP_CATEGORIES widget availability status alongside existing widgets. |
| WooCommerce/src/main/kotlin/com/woocommerce/android/ui/dashboard/DashboardContainer.kt | Wires the new widget card into dashboard rendering by widget type. |
| WooCommerce/src/main/kotlin/com/woocommerce/android/model/DashboardWidget.kt | Registers the new TOP_CATEGORIES widget type with title + tracking identifier. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| contentAlignment = Alignment.Center | ||
| ) { | ||
| Text( | ||
| text = stringResource(id = R.string.dashboard_top_categories_empty), |
There was a problem hiding this comment.
The empty state message uses dashboard_top_categories_empty ("No categories found"), but this screen is showing products within a category. This will display the wrong text when a category has no products; use a products-specific empty string (or reuse an existing "No products" message) instead.
| text = stringResource(id = R.string.dashboard_top_categories_empty), | |
| text = stringResource(id = R.string.dashboard_top_performers_empty), |
| override fun getFragmentTitle() = | ||
| viewModel.state.value?.categoryName ?: "" |
There was a problem hiding this comment.
getFragmentTitle() currently reads from viewModel.state.value?.categoryName, but state is derived via StateFlow.asLiveData() and may be null until the LiveData becomes active, resulting in a blank toolbar title. Also, the new dashboard_top_categories_products_title ("Products in %s") string isn’t used, which differs from the PR description. Prefer deriving the title directly from nav args (or a non-LiveData property) and format it with the localized string resource.
Display only the formatted currency amount in the top categories card rows instead of prefixing it with "Net sales:".
Use fixed column widths for Items sold and Net sales columns so numbers align vertically across all category rows.

Description
Adds the UI for the Top Categories dashboard widget, building on the data layer from #15580. The card displays product categories ranked by items sold and net sales, with date range selection (Today/Week/Month/Year/Custom) and drill-down into products within a selected category.
UI Components
DashboardTopCategoriesViewModelwith date range selection and data loadingDashboardTopCategoriesWidgetCardCompose UI with table layout showing category name, items sold, and net salesGetSelectedRangeForTopCategoriesfor date range persistenceCategoryProductsFragment/CategoryProductsScreen/CategoryProductsViewModelfor drill-down into products within a selected categoryWidget Registration & Wiring
TOP_CATEGORIESadded toDashboardWidget.TypeenumDashboardContainerto the card composableDashboardRepositorystatus mappingTests
DashboardTopCategoriesViewModelTest Steps
RELEASE-NOTES.txt
RELEASE-NOTES.txtif so.