Skip to content
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

Implemented Material3 SearchBar feature in FoodExpirationDates App #284

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

anuragkanojiya1
Copy link
Contributor

Related Issue

Closes #232

Description

Implemented Material3 SearchBar

This PR introduces a search functionality that allows users to easily search for items by name. The search bar is conveniently located at the top of the main screen, ensuring a seamless user experience.

Type of change

This new search feature enhances user experience by enabling quick access to desired items in FoodExpirationDates app's main screen.

Screen_recording_20250103_234153.mp4
  • ✨ New feature (non-breaking change which adds functionality)
  • 🛠️ Bug fix (non-breaking change which fixes an issue)
  • ❌ Breaking change (fix or feature that would cause existing functionality to change)
  • 🧹 Code refactor
  • ✅ Build configuration change
  • 📝 Documentation

@lorenzovngl
Copy link
Owner

Hello @anuragkanojiya1, great job so far. Thank you for your efforts!

It seems your branch is currently 50 commits behind, which is a significant number and may miss important updates from the main branch. To bring it up to date, please rebase your branch by following these steps:


Steps to Rebase search-feature

Before starting, it's recommended to manually create a backup copy of your work to avoid losing progress in case of issues.

  1. Switch to your search-feature branch:

    git checkout search-feature
  2. Fetch the latest changes from the remote repository:

    git fetch origin
  3. Rebase your branch onto the main branch:

    git rebase origin/main

    This will apply your commits from search-feature on top of the latest commits in the main branch.

  4. Force push your rebased branch to the remote repository:

    git push --force

I think the process will be straightforward. However, let me know if you encounter any issues or need further assistance.

@lorenzovngl
Copy link
Owner

I rebased the branch. Here's what I did:

  1. Reset the branch to the state it was when you opened the PR. Hard reset, I was not interested in keeping duplicate commits.
    Screenshot 2025-01-08 211245
    Screenshot 2025-01-08 211329

  2. Go to your fork on GitHub and synced the main branch using the button Sync fork. Not feature-branch, because I would lose your commit.
    Screenshot 2025-01-08 211706

  3. Return to Android Studio to fetch the latest changes.
    Screenshot 2025-01-08 211741

  4. Update local main with the latest changes.
    Screenshot 2025-01-08 211759

  5. Rebase search-feature onto main.
    Screenshot 2025-01-08 211827

  6. Finally, git push --force.

Please wait for my review in next days 😊

@@ -57,13 +62,15 @@ fun MyScaffold(
navController: NavHostController,
navDestination: String? = null,
showSnackbar: MutableState<Boolean>,
content: @Composable () -> Unit
searchQuery : MutableState<String>,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whenever possible, if you introduce a new parameter, add a default. This prevent you from having to change all calls of the function. Think about the situation in which a function is called 100 times.

Suggested change
searchQuery : MutableState<String>,
searchQuery : MutableState<String> = mutableStateOf(""),

Comment on lines +178 to +179
showSnackbar = showSnackbar,
searchQuery = mutableStateOf("")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change no longer necessary after introducing a default.

Suggested change
showSnackbar = showSnackbar,
searchQuery = mutableStateOf("")
showSnackbar = showSnackbar

Comment on lines +183 to +184
navController = rememberNavController(),
searchQuery = mutableStateOf("")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change no longer necessary after introducing a default.

Suggested change
navController = rememberNavController(),
searchQuery = mutableStateOf("")
navController = rememberNavController()

@@ -38,7 +38,7 @@ import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.tooling.preview.PreviewLightDark
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.lorenzovainigli.foodexpirationdates.BuildConfig
import com.google.android.datatransport.BuildConfig
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrong, please revert this.

@@ -45,7 +47,8 @@ import kotlin.math.min
fun MainScreen(
activity: MainActivity? = null,
navController: NavHostController,
showSnackbar: MutableState<Boolean>? = null
showSnackbar: MutableState<Boolean>? = null,
searchQuery: MutableState<String>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same consideration as in MyScaffold: add a default value.

Suggested change
searchQuery: MutableState<String>
searchQuery: MutableState<String> = mutableStateOf("")

@@ -1,5 +1,6 @@
package com.lorenzovainigli.foodexpirationdates.view.preview

import android.annotation.SuppressLint
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be removed

@@ -74,6 +75,7 @@ fun PlayStoreScreenshot(
}
}

@SuppressLint("UnrememberedMutableState")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be removed

@@ -86,11 +88,12 @@ fun PlayStoreScreenshotPreview() {
val showSnackbar = remember {
mutableStateOf(false)
}
MyScaffold(navController = navController, showSnackbar = showSnackbar) {
MyScaffold(navController = navController, showSnackbar = showSnackbar, searchQuery = mutableStateOf("")) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not necessary, please revert this change.

Comment on lines +95 to +96
startDestination = Screen.AboutScreen.route,
searchQuery = mutableStateOf("")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not necessary, please revert this change.

Comment on lines +72 to +85


// TopAppBar(
// title = {
// BasicTextField(
// value = searchQuery,
// onValueChange = { searchQuery = it },
// textStyle = TextStyle(color = Color.White, fontSize = 18.sp),
// modifier = Modifier.fillMaxWidth()
// )
// },
// backgroundColor = MaterialTheme.colorScheme.primary
// )

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to introduce commented code.

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.

[Feature] Add possibility to search or filter items
2 participants