-
Notifications
You must be signed in to change notification settings - Fork 189
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
[Android] Search filters #642
Merged
Merged
Changes from 9 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
44f8460
Added SearchFilter & SearchFilterSheets
d722053
Added getCategories query in TimetableSession.sq
4cf1a25
Hiding keyboard on clicking on filter
acb0bfd
Fixed lint issues
fcb0551
Merge remote-tracking branch 'origin/main' into issue600
a8cae9f
Fixed spotless issues
c7d55b2
Fixed composeLint
81a07af
Fixed spotless
0f57516
Added strings in en and zh
a3504c0
Merge branch 'main' into issue600
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 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 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 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 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
2 changes: 2 additions & 0 deletions
2
core/model/src/commonMain/kotlin/io/github/droidkaigi/confsched2022/model/Filters.kt
This file contains 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 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 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 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 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 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 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
108 changes: 108 additions & 0 deletions
108
...essions/src/main/java/io/github/droidkaigi/confsched2022/feature/sessions/FilterButton.kt
This file contains 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,108 @@ | ||
package io.github.droidkaigi.confsched2022.feature.sessions | ||
|
||
import androidx.compose.animation.animateColor | ||
import androidx.compose.animation.core.animateDp | ||
import androidx.compose.animation.core.tween | ||
import androidx.compose.animation.core.updateTransition | ||
import androidx.compose.foundation.BorderStroke | ||
import androidx.compose.foundation.layout.PaddingValues | ||
import androidx.compose.foundation.layout.Spacer | ||
import androidx.compose.foundation.layout.width | ||
import androidx.compose.material.ButtonDefaults | ||
import androidx.compose.material.OutlinedButton | ||
import androidx.compose.material3.Icon | ||
import androidx.compose.material3.MaterialTheme | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.getValue | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.res.painterResource | ||
import androidx.compose.ui.unit.dp | ||
|
||
private const val TransitionAnimationDuration = 300 | ||
|
||
@Composable | ||
fun FilterButton( | ||
isSelected: Boolean, | ||
isDropDown: Boolean, | ||
text: String, | ||
modifier: Modifier = Modifier, | ||
onClicked: () -> Unit | ||
) { | ||
val transition = updateTransition(targetState = isSelected) | ||
|
||
val backgroundColor by transition.animateColor( | ||
label = "backgroundColor", | ||
transitionSpec = { tween(durationMillis = TransitionAnimationDuration) } | ||
) { | ||
if (it) | ||
MaterialTheme.colorScheme.secondaryContainer | ||
else MaterialTheme.colorScheme.surface | ||
} | ||
|
||
val strokeColor by transition.animateColor( | ||
label = "strokeColor", | ||
transitionSpec = { tween(durationMillis = TransitionAnimationDuration) } | ||
) { | ||
if (it) | ||
MaterialTheme.colorScheme.secondaryContainer | ||
else MaterialTheme.colorScheme.outline | ||
} | ||
|
||
val contentColor by transition.animateColor( | ||
label = "textColor", | ||
transitionSpec = { tween(durationMillis = TransitionAnimationDuration) } | ||
) { | ||
if (it) | ||
MaterialTheme.colorScheme.onSecondaryContainer | ||
else MaterialTheme.colorScheme.onSurface | ||
} | ||
|
||
val checkIconWidth by transition.animateDp( | ||
label = "checkIconWidth", | ||
transitionSpec = { tween(durationMillis = TransitionAnimationDuration) } | ||
) { if (it) 16.dp else 0.dp } | ||
|
||
OutlinedButton( | ||
modifier = modifier, | ||
onClick = onClicked, | ||
colors = ButtonDefaults.outlinedButtonColors( | ||
backgroundColor = backgroundColor | ||
), | ||
contentPadding = PaddingValues( | ||
horizontal = 16.dp, | ||
vertical = 6.dp | ||
), | ||
border = BorderStroke( | ||
width = 1.dp, | ||
color = strokeColor | ||
), | ||
shape = MaterialTheme.shapes.small | ||
) { | ||
if (isSelected) { | ||
Icon( | ||
modifier = Modifier.width(width = checkIconWidth), | ||
painter = painterResource(id = R.drawable.ic_filter_selected), | ||
contentDescription = null, | ||
tint = MaterialTheme.colorScheme.onSecondaryContainer | ||
) | ||
Spacer(modifier = Modifier.width(8.dp)) | ||
} | ||
|
||
Text( | ||
text = text, | ||
style = MaterialTheme.typography.labelLarge, | ||
color = contentColor | ||
) | ||
|
||
if (isDropDown) { | ||
Spacer(modifier = Modifier.width(8.dp)) | ||
|
||
Icon( | ||
painter = painterResource(id = R.drawable.ic_filter_dropdown), | ||
contentDescription = null, | ||
tint = contentColor | ||
) | ||
} | ||
} | ||
} |
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.
🆒