Feature/add search screen#28
Merged
Merged
Conversation
- Add `SearchScreen` and `SearchScreenViewModel` using MVI patterns - Implement `ProductGrid`, `SearchBarSection`, and `RecentSearchSection` components - Add shimmer loading skeletons including `ProductCardSkeleton` and `SearchBarSkeleton` - Create `SearchProductsUseCase` and `ProductSearchParams` in the domain layer - Implement search query debouncing and filtering logic
…ture - Add `Search` route to navigation. - Implement search-related UI components: `BrandRow`, `ErrorView`, `EmptySearchResult`, and `BrandRowSkeleton`. - Create `FilterProductsByQueryUseCase` and `SearchProductsUseCase`. - Refactor `AppPreferencesDataSource` and `Datastore` to `com.troves.data.source.local.preferenceses`. - Move `AuthenticationRepository` to the `repository` package. - Update `FilterBottomSheet` with default parameter values and `SheetState` support.
This change: - Implements navigation and UI for the Search screen. - Updates imports across use cases to reflect moving `Result`, `map`, and `AuthenticationRepository` to their respective utility and repository packages. - Adds the Lucide icons dependency to the presentation module.
- Update `HomeViewModel` and `HomeContract` to support navigation to search instead of showing a placeholder toast. - Refactor `Result` and `AuthenticationRepository` to their new package locations (`com.troves.domain.utils` and `com.troves.domain.repository`). - Register `SearchScreenViewModel` in the Koin `PresentationModule`. - Add the `icons-lucide-cmp` dependency to the version catalog. - Update `HomeScreen` to handle the new search navigation effect. - Add `ExperimentalMaterial3Api` opt-in to `ProductsScreen`.
…_screen # Conflicts: # data/src/commonMain/kotlin/com/troves/data/di/DataModule.kt # data/src/commonMain/kotlin/com/troves/data/source/remote/RemoteDatasource.kt # data/src/commonMain/kotlin/com/troves/data/source/remote/RemoteDatasourceImpl.kt # domain/src/commonMain/kotlin/com/troves/domain/repository/AuthenticationRepository.kt # domain/src/commonMain/kotlin/com/troves/domain/usecase/auth/LogoutUseCase.kt # presintation/src/commonMain/kotlin/com/troves/presintation/di/PresentationModule.kt # presintation/src/commonMain/kotlin/com/troves/presintation/navigation/AppNav.kt # presintation/src/commonMain/kotlin/com/troves/presintation/ui/auth/AuthViewModel.kt # presintation/src/commonMain/kotlin/com/troves/presintation/ui/home/HomeContract.kt # presintation/src/commonMain/kotlin/com/troves/presintation/ui/home/HomeScreen.kt # presintation/src/commonMain/kotlin/com/troves/presintation/ui/home/HomeViewModel.kt
…p unused navigation functions
There was a problem hiding this comment.
Pull request overview
This PR adds a new product search screen and end-to-end search/query support (domain → data → remote service), while also standardizing on com.troves.domain.utils.Result and reorganizing the preferences datasource package.
Changes:
- Introduces a new Search UI (screen, view model, UI components) and navigation route wiring.
- Adds product search/query APIs (
searchProducts,getProductsByQuery) across repository/remote service layers with new domain params (ProductSearchParams). - Standardizes
Resultusage undercom.troves.domain.utils.Resultand refactors affected imports/packages (includingAuthenticationRepositoryand preferences datasource relocation).
Reviewed changes
Copilot reviewed 72 out of 72 changed files in this pull request and generated 23 comments.
Show a summary per file
| File | Description |
|---|---|
| presintation/src/commonMain/kotlin/com/troves/presintation/ui/search/SearchScreenViewModel.kt | Implements search screen state/effects and debounced searching logic. |
| presintation/src/commonMain/kotlin/com/troves/presintation/ui/search/SearchScreenContract.kt | Defines Search screen intents/state/effects. |
| presintation/src/commonMain/kotlin/com/troves/presintation/ui/search/SearchScreen.kt | Composable screen wiring Search UI, filters, and results grid. |
| presintation/src/commonMain/kotlin/com/troves/presintation/ui/search/component/SearchLoadingContent.kt | Search loading skeleton layout. |
| presintation/src/commonMain/kotlin/com/troves/presintation/ui/search/component/SearchContent.kt | Alternate search content composable (currently not referenced). |
| presintation/src/commonMain/kotlin/com/troves/presintation/ui/search/component/SearchBarSkeleton.kt | Search bar skeleton shimmer component. |
| presintation/src/commonMain/kotlin/com/troves/presintation/ui/search/component/SearchBarSection.kt | Search bar + suggestions + filter button UI. |
| presintation/src/commonMain/kotlin/com/troves/presintation/ui/search/component/RecentSearchSkeleton.kt | Recent searches skeleton shimmer component. |
| presintation/src/commonMain/kotlin/com/troves/presintation/ui/search/component/RecentSearchSection.kt | Recent searches chip list component. |
| presintation/src/commonMain/kotlin/com/troves/presintation/ui/search/component/ProductLoading.kt | Wraps loading content for search results. |
| presintation/src/commonMain/kotlin/com/troves/presintation/ui/search/component/ProductGrid.kt | Product grid for search results. |
| presintation/src/commonMain/kotlin/com/troves/presintation/ui/search/component/ProductCardSkeleton.kt | Product card skeleton shimmer component. |
| presintation/src/commonMain/kotlin/com/troves/presintation/ui/search/component/ProductCard.kt | Product card UI used in search grid. |
| presintation/src/commonMain/kotlin/com/troves/presintation/ui/search/component/ErrorView.kt | Error UI for search screen. |
| presintation/src/commonMain/kotlin/com/troves/presintation/ui/search/component/EmptySearchResult.kt | Empty-state UI for search results. |
| presintation/src/commonMain/kotlin/com/troves/presintation/ui/search/component/BrandRowSkeleton.kt | Brand row skeleton shimmer component. |
| presintation/src/commonMain/kotlin/com/troves/presintation/ui/search/component/BrandRow.kt | Brand selection row component for search. |
| presintation/src/commonMain/kotlin/com/troves/presintation/ui/products/ProductsViewModel.kt | Migrates to domain.utils.Result utilities. |
| presintation/src/commonMain/kotlin/com/troves/presintation/ui/products/ProductsScreen.kt | Adds Material3 opt-in annotation. |
| presintation/src/commonMain/kotlin/com/troves/presintation/ui/productDetails/ProductDetailsViewModel.kt | Migrates to domain.utils.Result. |
| presintation/src/commonMain/kotlin/com/troves/presintation/ui/home/HomeViewModel.kt | Hooks home search click into navigation and standardizes Result usage. |
| presintation/src/commonMain/kotlin/com/troves/presintation/ui/home/HomeScreen.kt | Adds onNavigateToSearch callback and handles new effect. |
| presintation/src/commonMain/kotlin/com/troves/presintation/ui/home/HomeContract.kt | Adds NavigateToSearch effect. |
| presintation/src/commonMain/kotlin/com/troves/presintation/ui/components/FilterBottomSheet.kt | Adds defaults + sheetState plumbing for bottom sheet. |
| presintation/src/commonMain/kotlin/com/troves/presintation/ui/auth/AuthViewModel.kt | Migrates to domain.utils.Result. |
| presintation/src/commonMain/kotlin/com/troves/presintation/ui/allbrands/AllBrandsViewModel.kt | Migrates to domain.utils.Result. |
| presintation/src/commonMain/kotlin/com/troves/presintation/navigation/AppRoute.kt | Adds Search route. |
| presintation/src/commonMain/kotlin/com/troves/presintation/navigation/AppNav.kt | Wires Search destination into navigation and bottom bar. |
| presintation/src/commonMain/kotlin/com/troves/presintation/di/PresentationModule.kt | Registers SearchScreenViewModel in Koin. |
| presintation/build.gradle.kts | Adds lucide icons dependency for Search UI icons. |
| gradle/libs.versions.toml | Adds version catalog entry for icons-lucide-cmp. |
| domain/src/commonMain/kotlin/com/troves/domain/utils/Result.kt | Moves Result into domain.utils and keeps helper extensions. |
| domain/src/commonMain/kotlin/com/troves/domain/usecase/wishlist/ToggleFavoriteUseCase.kt | Updates repository import paths. |
| domain/src/commonMain/kotlin/com/troves/domain/usecase/wishlist/SyncWishlistUseCase.kt | Updates repository import paths. |
| domain/src/commonMain/kotlin/com/troves/domain/usecase/shared/GetProductsUseCase.kt | Migrates to domain.utils.Result. |
| domain/src/commonMain/kotlin/com/troves/domain/usecase/search/SearchProductsUseCase.kt | Adds new search use case. |
| domain/src/commonMain/kotlin/com/troves/domain/usecase/search/FilterProductsByQueryUseCase.kt | Adds new query-based fetch use case. |
| domain/src/commonMain/kotlin/com/troves/domain/usecase/products/GetProductsByCategoryUseCase.kt | Migrates to domain.utils.Result. |
| domain/src/commonMain/kotlin/com/troves/domain/usecase/products/GetProductsByBrandUseCase.kt | Migrates to domain.utils.Result. |
| domain/src/commonMain/kotlin/com/troves/domain/usecase/onboarding/IsOnboardingDoneUseCase.kt | Updates repository import paths. |
| domain/src/commonMain/kotlin/com/troves/domain/usecase/onboarding/CompleteOnboardingUseCase.kt | Updates repository import paths. |
| domain/src/commonMain/kotlin/com/troves/domain/usecase/home/GetTrendingProductsUseCase.kt | Migrates to domain.utils Result/map helpers. |
| domain/src/commonMain/kotlin/com/troves/domain/usecase/home/GetJustForYouProductsUseCase.kt | Migrates to domain.utils Result/map helpers. |
| domain/src/commonMain/kotlin/com/troves/domain/usecase/home/GetCategoriesUseCase.kt | Migrates to domain.utils.Result. |
| domain/src/commonMain/kotlin/com/troves/domain/usecase/home/GetBrandsUseCase.kt | Migrates to domain.utils.Result. |
| domain/src/commonMain/kotlin/com/troves/domain/usecase/home/GetAdsUseCase.kt | Migrates to domain.utils.Result. |
| domain/src/commonMain/kotlin/com/troves/domain/usecase/auth/SignInWithGoogleUseCase.kt | Updates repository import paths and Result import. |
| domain/src/commonMain/kotlin/com/troves/domain/usecase/auth/RegisterUseCase.kt | Updates repository import paths and Result import. |
| domain/src/commonMain/kotlin/com/troves/domain/usecase/auth/LogoutUseCase.kt | Updates repository import paths. |
| domain/src/commonMain/kotlin/com/troves/domain/usecase/auth/LoginUseCase.kt | Updates repository import paths and Result import. |
| domain/src/commonMain/kotlin/com/troves/domain/usecase/auth/IsLoggedInUseCase.kt | Updates repository import paths. |
| domain/src/commonMain/kotlin/com/troves/domain/repository/TrovesRepository.kt | Adds search/query methods and migrates to domain.utils.Result. |
| domain/src/commonMain/kotlin/com/troves/domain/repository/AuthenticationRepository.kt | Moves AuthenticationRepository to domain.repository and uses domain.utils.Result. |
| domain/src/commonMain/kotlin/com/troves/domain/entity/ProductSearchParams.kt | Adds parameter object for server-side search/query. |
| domain/src/commonMain/kotlin/com/troves/domain/di/DomainModule.kt | Registers new search-related use cases. |
| data/src/iosMain/kotlin/com/troves/data/repository/AuthenticationRepositoryImpl.ios.kt | Updates preferences datasource import to new package. |
| data/src/iosMain/kotlin/com/troves/data/local/preferenceses/Datastore.ios.kt | Updates datastore filename import from new package. |
| data/src/commonMain/kotlin/com/troves/data/source/remote/service/TrovesApiServiceImpl.kt | Implements query/search methods in remote API service. |
| data/src/commonMain/kotlin/com/troves/data/source/remote/service/TrovesApiService.kt | Adds query/search method signatures and migrates to domain.utils.Result. |
| data/src/commonMain/kotlin/com/troves/data/source/remote/service/HttpClientExt.kt | Migrates to domain.utils.Result. |
| data/src/commonMain/kotlin/com/troves/data/source/remote/RemoteDatasourceImpl.kt | Adds query/search delegation methods. |
| data/src/commonMain/kotlin/com/troves/data/source/remote/RemoteDatasource.kt | Adds query/search datasource contract methods. |
| data/src/commonMain/kotlin/com/troves/data/source/local/preferenceses/Datastore.kt | Moves preferences package to data.source.local.preferenceses. |
| data/src/commonMain/kotlin/com/troves/data/source/local/preferenceses/AppPreferencesKeys.kt | Moves preferences package to data.source.local.preferenceses. |
| data/src/commonMain/kotlin/com/troves/data/source/local/preferenceses/AppPreferencesDataSourceImpl.kt | Moves preferences package and cleans up datastore IO handling import usage. |
| data/src/commonMain/kotlin/com/troves/data/source/local/preferenceses/AppPreferencesDatasource.kt | Moves preferences package. |
| data/src/commonMain/kotlin/com/troves/data/repository/WishlistRepositoryImpl.kt | Migrates to domain.utils.Result. |
| data/src/commonMain/kotlin/com/troves/data/repository/TrovesRepositoryImpl.kt | Adds query/search methods and maps results into domain. |
| data/src/commonMain/kotlin/com/troves/data/repository/AuthenticationRepositoryImpl.kt | Updates repository + preferences imports and uses domain.utils.Result. |
| data/src/commonMain/kotlin/com/troves/data/di/DataModule.kt | Updates preferences and AuthenticationRepository imports and module wiring. |
| data/src/androidMain/kotlin/com/troves/data/repository/AuthenticationRepositoryImpl.android.kt | Updates preferences datasource import to new package. |
| data/src/androidMain/kotlin/com/troves/data/local/preferenceses/Datastore.android.kt | Updates datastore filename import from new package. |
Comments suppressed due to low confidence (1)
presintation/src/commonMain/kotlin/com/troves/presintation/navigation/AppNav.kt:93
bottomNavRoutescontainsAppRoute.Profiletwice, which can lead to duplicated bottom-bar items and incorrectselectedIndexcalculations.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+43
to
+52
| override suspend fun searchProducts(params: ProductSearchParams): Result<List<Product>> { | ||
| return ktorClient.getResults { | ||
| method = HttpMethod.Get | ||
| params.vendor?.let { parameter("vendor", it) } | ||
| params.productType?.let { parameter("product_type", it) } | ||
| params.collectionId?.let { parameter("collection_id", it) } | ||
| params.status?.let { parameter("status", it.restValue) } | ||
| parameter("limit", params.limit) | ||
| } | ||
| } |
Comment on lines
13
to
15
| import io.ktor.http.HttpMethod | ||
| import io.ktor.http.parameters | ||
| import io.ktor.http.path |
Comment on lines
+46
to
+61
| override suspend fun searchProducts(params: ProductSearchParams): Result<List<Product>> { | ||
| return try { | ||
| withContext(coroutineDispatcher) { | ||
| var products = | ||
| remoteDataSource.searchProducts(params = params).getOrElse { emptyList() } | ||
| if (!params.query.isNullOrBlank()) { | ||
| products = products.filter { | ||
| it.title.contains(params.query ?: "", ignoreCase = true) | ||
| } | ||
| } | ||
| Result.Success(products) | ||
| } | ||
| } catch (e: IOException) { | ||
| Result.Error(e) | ||
| } | ||
| } |
Comment on lines
31
to
33
| import org.koin.dsl.module | ||
| import kotlin.coroutines.EmptyCoroutineContext.get | ||
|
|
Comment on lines
+4
to
+8
| import com.troves.domain.entity.Brand | ||
| import com.troves.domain.entity.Category | ||
| import com.troves.domain.entity.Product | ||
| import com.troves.presintation.ui.components.FilterOption | ||
|
|
Comment on lines
+159
to
+163
| val params = ProductSearchParams( | ||
| query = query.ifBlank { null }, | ||
| vendor = vendor, | ||
| productType = state.value.sheetFilterOptions.selectedCategories.firstOrNull(), | ||
| ) |
Comment on lines
+16
to
+21
| suspend fun createProduct(productDto: ProductDto): Result<ProductDto> | ||
| suspend fun getAllProducts(): Result<ProductResponse> | ||
| suspend fun getProductsByQuery(queryMap: Map<String, String>): Result<ProductResponse> | ||
| suspend fun searchProducts(params: ProductSearchParams): Result<List<Product>> | ||
|
|
||
| suspend fun getProductImages(productId: String): Result<List<CollectionImage>> |
Comment on lines
+22
to
+25
| import com.troves.designsystem.components.shimmer.shimmerEffect | ||
| import com.troves.designsystem.theme.Theme | ||
| import com.troves.presintation.ui.productDetails.components.shimmer | ||
|
|
Comment on lines
+3
to
+12
| import androidx.compose.foundation.background | ||
| import androidx.compose.foundation.layout.Arrangement | ||
| import androidx.compose.foundation.layout.PaddingValues | ||
| import androidx.compose.foundation.layout.fillMaxSize | ||
| import androidx.compose.foundation.lazy.staggeredgrid.LazyVerticalStaggeredGrid | ||
| import androidx.compose.foundation.lazy.staggeredgrid.StaggeredGridCells | ||
| import androidx.compose.runtime.Composable | ||
| import androidx.compose.ui.Modifier | ||
| import androidx.compose.ui.unit.dp | ||
| import com.troves.designsystem.theme.Theme |
Comment on lines
+5
to
+9
| import androidx.compose.foundation.BorderStroke | ||
| import androidx.compose.foundation.background | ||
| import androidx.compose.foundation.layout.Arrangement | ||
| import androidx.compose.foundation.layout.Box | ||
| import androidx.compose.foundation.layout.Column |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces several important changes to the data and domain layers, focusing on refactoring the preferences data source package structure, standardizing the usage of the
Resultutility, and expanding product search and query functionality in the repository and API service layers.Key highlights:
com.troves.data.local.preferencesestocom.troves.data.source.local.preferencesesfor better organization.com.troves.domain.utils.Result.Refactoring and Standardization
Preferences package restructuring:
com.troves.data.local.preferencesestocom.troves.data.source.local.preferencesesand updated all imports accordingly. This includes files likeAppPreferencesDataSource,AppPreferencesDataSourceImpl,AppPreferencesKeys, andDatastorefor both Android and iOS. [1] [2] [3] [4] [5] [6] [7]Result type standardization:
com.troves.domain.utils.Resultinstead ofcom.troves.domain.Resultfor consistency across repositories, data sources, and API services. [1] [2] [3] [4] [5] [6] [7] [8]Product Search and Query Enhancements
Repository and API service improvements:
getProductsByQueryandsearchProductstoTrovesRepositoryImpl,RemoteDatasource, andTrovesApiService/TrovesApiServiceImplto support advanced querying and searching of products using parameters such as vendor, product type, collection ID, status, and query string. [1] [2] [3] [4] [5]Domain Layer Additions
Use case registration:
FilterProductsByQueryUseCaseandSearchProductsUseCasein the KoindomainModulefor dependency injection, enabling these features in the application layer. [1] [2]These changes improve code organization, consistency, and add essential product search capabilities to the data and domain layers.