Skip to content

Feature/third search screen#87

Merged
ahmedhgabr merged 66 commits into
developfrom
feature/third-search-screen
Jul 17, 2025
Merged

Feature/third search screen#87
ahmedhgabr merged 66 commits into
developfrom
feature/third-search-screen

Conversation

@Mohamedragabali

Copy link
Copy Markdown
Collaborator

init the search screen run ok

Mohammed-qmr and others added 30 commits July 13, 2025 13:32
- Moved modifier to be the first optional parameter in composables
- Cleaned up unused code
- Applied animateColorAsState for smoother transitions
- Used shape radius from DesignSystem for consistency
This commit introduces the UI components and logic for displaying and managing recent searches.

Key changes:
- Added `RecentSearchHeader.kt` for the header section with a "Clear All" option.
- Added `RecentSearchItem.kt` to display individual recent search terms with a remove icon.
- Added `RecentSearchList.kt` to display a list of recent search items.
- Implemented `RecentSearchSyncWorker.kt` to handle clearing all recent searches in the background.
- Added necessary string resources for "Recent Search", "Clear All", and "Remove".
- Updated `libs.versions.toml` and `build.gradle.kts` to include the `work-runtime-ktx` dependency.
- Made minor adjustments to `MovioText.kt`.
…on" suffix for better organization within the `searchScreen` package.

Specifically:
- `RecentSearchHeader.kt` is now `RecentSearchHeaderSection.kt`
- `RecentSearchItem.kt` is now `RecentSearchItemSection.kt`
- `RecentSearchList.kt` is now `RecentSearchListSection.kt`

A new composable `searchListScreen.kt` has been added to the `searchScreen` package to display the recent search UI.
The `SearchScreen` Composable function and its content `SearchScreenContent` have been removed. This component was responsible for displaying the search interface, including a search bar, recent search list, and handling search-related actions.
This commit introduces recent search functionality to the SearchScreen.

Key changes include:

- **SearchViewModel:**
    - Manages recent search data using `RecentSearchUseCase`.
    - Implements `refreshRecentSearches` to load recent searches.
    - Adds `clearRecentSearchesWithWorker` to clear recent searches using a `RecentSearchSyncWorker`.
    - Handles search query changes and item clicks/removals for recent searches.
- **SearchUiState:**
    - Adds `recentSearches` list to store recent search queries.
- **searchListScreen:**
    - Updates `RecentSearchScreen` to use `SearchViewModel` for state management and actions.
    - Connects UI elements to corresponding ViewModel functions for search query input, clearing searches, and interacting with recent search items.
This commit introduces recent search functionality to the SearchScreen.

Key changes include:

- **SearchViewModel:**
    - Manages recent search data using `RecentSearchUseCase`.
    - Implements `refreshRecentSearches` to load recent searches.
    - Adds `clearRecentSearchesWithWorker` to clear recent searches using a `RecentSearchSyncWorker`.
    - Handles search query changes and item clicks/removals for recent searches.
- **SearchUiState:**
    - Adds `recentSearches` list to store recent search queries.
- **searchListScreen:**
    - Updates `RecentSearchScreen` to use `SearchViewModel` for state management and actions.
    - Connects UI elements to corresponding ViewModel functions for search query input, clearing searches, and interacting with recent search items.
The androidContext method is no longer needed in Koin as of version 3.2.0.
This commit removes the unnecessary call to androidContext during Koin initialization in the MovioApp class.
…ently-searched

# Conflicts:
#	app/src/main/java/com/madrid/movio/app.kt
#	gradle/libs.versions.toml
#	presentation/src/main/java/com/madrid/presentation/screens/searchScreen/SearchViewModel.kt
#	presentation/src/main/java/com/madrid/presentation/screens/searchScreen/features/recentSearchLayout/RecentSearchLayout.kt
#	presentation/src/main/java/com/madrid/presentation/screens/searchScreen/features/recentSearchLayout/RecentSearchLayoutViewModel.kt
This commit introduces Koin for dependency injection of `SearchViewModel` and updates related dependencies.

Key changes include:
- Modified `RecentSearchScreen` to use `koinViewModel()` for `SearchViewModel` instantiation.
- Updated `SearchViewModel` interaction within `RecentSearchScreen` to align with the new state management approach.
- Added `androidx-work-runtime-ktx` to `libs.versions.toml`.
- Implemented `removeRecentSearch` function in `SearchViewModel`.
- Removed unused `wxwx` data class from `SearchScreenState.kt`.
- Updated `appModule` in `app.kt` to use Koin for providing `SearchViewModel` and its dependencies, including new use cases.
The application context is now provided to Koin during initialization.
This allows Koin to correctly inject dependencies that require a context.
This commit introduces several improvements to the search functionality within the `SearchViewModel` and related UI components.

Key changes:
- **SearchViewModel:**
    - Manages search query state using `MutableStateFlow` and `StateFlow`.
    - Implements `onSearchQueryChange` to update the query.
    - Adds `onSearchSubmit` to handle search submission, including adding the query to recent searches and clearing the input.
    - Modifies `removeRecentSearch` to update the UI state directly by removing the item from the current list.
    - Introduces `addToRecentSearches` to manage adding new search terms to the recent searches list, ensuring no duplicates and limiting the list size.
- **searchListScreen.kt:**
    - Binds the `searchQuery` to `SearchViewModel.searchQuery`.
    - Updates `BasicTextInputField`'s `onValueChange` and `onClickEndIcon` to use `SearchViewModel` methods.
    - Implements keyboard actions for "Done" to trigger search submission and hide the keyboard.
    - Simplifies `onRemove` and `onItemClick` in `RecentSearchList` to directly pass the item string.
- **RecentSearchListSection.kt:**
    - Updates `onRemove` and `onItemClick` lambda signatures to accept the `String` item directly, instead of an index.
- **BasicTextInputField.kt:**
    - Adds `keyboardOptions` and `keyboardActions` parameters to allow customization of keyboard behavior.
… feature/third-search-screen

# Conflicts:
#	.idea/deploymentTargetSelector.xml
This commit introduces several improvements to the recent search feature:

- Implemented text highlighting for search queries within recent search items.
- Introduced `HighlightedText` composable for displaying text with highlighted search terms.
- Added `MovioTextHighlight` composable to the design system for styled highlighted text.
- Ensured that when a search query is empty, the full list of recent searches is displayed.
- Removed the "No results" message when the filtered recent search list is empty.
- Added functionality to clear all recent searches in the `SearchViewModel`, updating the UI accordingly.
# Conflicts:
#	app/src/main/java/com/madrid/movio/app.kt
#	presentation/src/main/java/com/example/presentation/viewModel/base/SearchViewModel.kt
#	presentation/src/main/java/com/madrid/presentation/base/UiMapper.kt
- Moved `SearchViewModel` to `presentation/screens/searchScreen`.
- Implemented `addToRecentSearches` and `removeRecentSearch` methods in `SearchViewModel`.
- Updated `BaseViewModel` to include `searchQuery`, `recentSearchUseCase`, and search-related methods.
- Modified `MainActivity` to use `RecentSearchScreen`.
- Updated `searchListScreen.kt` to import `SearchViewModel` from its new location.
This commit removes the `RecentSearchSyncWorker` class.
Additionally, the message displayed when there are no recent search results has been removed from `RecentSearchListSection.kt`, resulting in an empty display in that scenario.
This commit introduces the `RecentSearchDao` for managing recent search entries in the local database, along with the `RecentSearchEntity` data class. Additionally, a new `RecentSearchSyncWorker` is added to periodically clear recent searches. The `SearchViewModel` is updated to include a static method for clearing recent searches, enhancing the overall search functionality.
This commit introduces a new composable `RecentSearchHeader` for displaying "Recent search" text and a "Clear all" button.

Additionally, `RecentSearchSyncWorker` now uses an injected `RecentSearchUseCase` dependency instead of retrieving it from the global Koin context.
fatimafaisalghazi and others added 15 commits July 16, 2025 16:37
# Conflicts:
#	app/src/main/java/com/madrid/movio/MainActivity.kt
#	presentation/src/main/java/com/madrid/presentation/screens/searchScreen/SearchViewModel.kt
…rch-screen

# Conflicts:
#	presentation/src/main/java/com/madrid/presentation/screens/searchScreen/SearchScreenState.kt
#	presentation/src/main/java/com/madrid/presentation/screens/searchScreen/viewModel/SearchViewModel.kt
#	presentation/src/main/java/com/madrid/presentation/screens/searchScreen/viewModel/base/BaseViewModel.kt
#	presentation/src/main/res/values-ar/string.xml
#	presentation/src/main/res/values/string.xml
…o feature/third-search-screen

# Conflicts:
#	presentation/src/main/java/com/madrid/presentation/screens/searchScreen/FillteredSearchScreen.kt
# Conflicts:
#	app/src/main/java/com/madrid/movio/app.kt
@ahmedhgabr ahmedhgabr merged commit f06ec9d into develop Jul 17, 2025
1 of 2 checks passed
@yasserahmed10 yasserahmed10 deleted the feature/third-search-screen branch July 22, 2025 12:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants