-
-
Notifications
You must be signed in to change notification settings - Fork 26
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
base: main
Are you sure you want to change the base?
Conversation
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 Steps to Rebase
|
6de88d6
to
40cac60
Compare
40cac60
to
0693488
Compare
0693488
to
e1bc02d
Compare
@@ -57,13 +62,15 @@ fun MyScaffold( | |||
navController: NavHostController, | |||
navDestination: String? = null, | |||
showSnackbar: MutableState<Boolean>, | |||
content: @Composable () -> Unit | |||
searchQuery : MutableState<String>, |
There was a problem hiding this comment.
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.
searchQuery : MutableState<String>, | |
searchQuery : MutableState<String> = mutableStateOf(""), |
showSnackbar = showSnackbar, | ||
searchQuery = mutableStateOf("") |
There was a problem hiding this comment.
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.
showSnackbar = showSnackbar, | |
searchQuery = mutableStateOf("") | |
showSnackbar = showSnackbar |
navController = rememberNavController(), | ||
searchQuery = mutableStateOf("") |
There was a problem hiding this comment.
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.
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 |
There was a problem hiding this comment.
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> |
There was a problem hiding this comment.
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.
searchQuery: MutableState<String> | |
searchQuery: MutableState<String> = mutableStateOf("") |
@@ -1,5 +1,6 @@ | |||
package com.lorenzovainigli.foodexpirationdates.view.preview | |||
|
|||
import android.annotation.SuppressLint |
There was a problem hiding this comment.
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") |
There was a problem hiding this comment.
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("")) { |
There was a problem hiding this comment.
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.
startDestination = Screen.AboutScreen.route, | ||
searchQuery = mutableStateOf("") |
There was a problem hiding this comment.
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.
|
||
|
||
// TopAppBar( | ||
// title = { | ||
// BasicTextField( | ||
// value = searchQuery, | ||
// onValueChange = { searchQuery = it }, | ||
// textStyle = TextStyle(color = Color.White, fontSize = 18.sp), | ||
// modifier = Modifier.fillMaxWidth() | ||
// ) | ||
// }, | ||
// backgroundColor = MaterialTheme.colorScheme.primary | ||
// ) | ||
|
There was a problem hiding this comment.
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.
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