-
Notifications
You must be signed in to change notification settings - Fork 0
Implement Add Favorites Button #119
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
Merged
+164
−65
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
5a27555
Created AddFavorite component
RyanCheung555 5204a17
Added functionality to Add Favorite button
RyanCheung555 67fd264
TODO: create search screen
RyanCheung555 db8b91f
add favorite button parameters
RyanCheung555 efc2562
fix: move add fav button to only show when in favorites tab, fix desi…
RyanCheung555 9c5faca
feat: Add plus icon to add favorites button
RyanCheung555 0b64cf9
fix: change text to use MetadataGray when unselected in FilterRow
RyanCheung555 4eb8ec7
refactor: move state handling logic from home screen to home view model
RyanCheung555 277df1a
Add toast message when location is favorited instead of dismissing bo…
RyanCheung555 17bd173
chore: fix formatting and delete unused imports
RyanCheung555 07ba239
fix: make AddFavoriteButton preview private
RyanCheung555 4f80ab6
refactor: rename instances of 'favorite' to 'favorites'
RyanCheung555 41120f4
refactor: use import of bottomSheetState/Scaffold instead of directly…
RyanCheung555 e9dcad2
refactor: use collectAsStateWithLifeCycle instead of collectAsState
RyanCheung555 fc55ae2
refactor: Use spacer instead of padding
RyanCheung555 a0b62b4
refactor: move component padding to outside container by using spacers
RyanCheung555 1cdcbd6
Merge branch 'main' into ryan/add-favorites
RyanCheung555 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
65 changes: 65 additions & 0 deletions
65
app/src/main/java/com/cornellappdev/transit/ui/components/home/AddFavoritesButton.kt
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| package com.cornellappdev.transit.ui.components.home | ||
|
|
||
| import android.R.attr.text | ||
| import androidx.compose.foundation.layout.Spacer | ||
| import androidx.compose.foundation.layout.fillMaxWidth | ||
| import androidx.compose.foundation.layout.height | ||
| import androidx.compose.foundation.layout.padding | ||
| import androidx.compose.foundation.layout.width | ||
| import androidx.compose.material3.Button | ||
| import androidx.compose.material3.ButtonDefaults | ||
| import androidx.compose.material3.Icon | ||
| import androidx.compose.material3.Text | ||
| import androidx.compose.runtime.Composable | ||
| import androidx.compose.ui.Modifier | ||
| import androidx.compose.ui.graphics.Color | ||
| import androidx.compose.ui.res.painterResource | ||
| import androidx.compose.ui.text.font.FontWeight | ||
| import androidx.compose.ui.tooling.preview.Preview | ||
| import androidx.compose.ui.unit.dp | ||
| import androidx.compose.ui.unit.sp | ||
| import com.cornellappdev.transit.R | ||
| import com.cornellappdev.transit.ui.theme.SecondaryText | ||
| import com.cornellappdev.transit.ui.theme.robotoFamily | ||
|
|
||
| @Composable | ||
| fun AddFavoritesButton( | ||
| onAddFavoritesClick: () -> Unit, | ||
| modifier: Modifier = Modifier | ||
| ) { | ||
| Button( | ||
| onClick = onAddFavoritesClick, | ||
| colors = ButtonDefaults.buttonColors( | ||
| containerColor = Color.White, | ||
| contentColor = Color.Black | ||
| ), | ||
| modifier = modifier | ||
| .fillMaxWidth() | ||
| .height(40.dp) | ||
| ) { | ||
|
|
||
| Icon( | ||
| painter = painterResource(R.drawable.ic_addition), | ||
| contentDescription = "Add Favorite", | ||
| tint = SecondaryText, | ||
| ) | ||
|
|
||
| Spacer(modifier = Modifier.width(8.dp)) | ||
|
|
||
| Text( | ||
| text = "Add Favorites", | ||
RyanCheung555 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| fontFamily = robotoFamily, | ||
| fontWeight = FontWeight.SemiBold, | ||
| fontSize = 16.sp, | ||
| color = SecondaryText | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| @Preview | ||
| @Composable | ||
| private fun AddFavoritesButtonPreview() { | ||
| AddFavoritesButton( | ||
| onAddFavoritesClick = {}, | ||
| ) | ||
| } | ||
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
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
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
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
Oops, something went wrong.
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.
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.
Nit: In the future, would be good to have a general button component eg. NaviButton that you can reuse for any type of button component to reduce redundancy