-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add sorting functionality for player statistics
- Loading branch information
1 parent
0b6067c
commit 5416e4f
Showing
14 changed files
with
557 additions
and
49 deletions.
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
108 changes: 108 additions & 0 deletions
108
...ain/java/com/nickoehler/brawlhalla/core/presentation/components/CustomSortDropDownMenu.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 com.nickoehler.brawlhalla.core.presentation.components | ||
|
||
import androidx.compose.animation.core.animateFloatAsState | ||
import androidx.compose.foundation.background | ||
import androidx.compose.foundation.clickable | ||
import androidx.compose.foundation.layout.Arrangement | ||
import androidx.compose.foundation.layout.Box | ||
import androidx.compose.foundation.layout.ColumnScope | ||
import androidx.compose.foundation.layout.Row | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.foundation.shape.CircleShape | ||
import androidx.compose.material.icons.Icons | ||
import androidx.compose.material.icons.filled.KeyboardArrowDown | ||
import androidx.compose.material.icons.filled.Mode | ||
import androidx.compose.material3.DropdownMenu | ||
import androidx.compose.material3.Icon | ||
import androidx.compose.material3.IconButton | ||
import androidx.compose.material3.MaterialTheme | ||
import androidx.compose.material3.Surface | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.getValue | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.draw.clip | ||
import androidx.compose.ui.draw.rotate | ||
import androidx.compose.ui.graphics.vector.ImageVector | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import androidx.compose.ui.unit.dp | ||
import com.nickoehler.brawlhalla.ui.theme.BrawlhallaTheme | ||
|
||
@Composable | ||
fun CustomSortDropDownMenu( | ||
modifier: Modifier = Modifier, | ||
reversed: Boolean, | ||
expanded: Boolean, | ||
icon: ImageVector, | ||
onSortClick: () -> Unit, | ||
onReversedClick: () -> Unit, | ||
selected: @Composable () -> Unit, | ||
content: @Composable (ColumnScope.() -> Unit), | ||
) { | ||
val rotation by animateFloatAsState(if (reversed) 180f else 0f) | ||
|
||
Box( | ||
modifier = modifier, | ||
) { | ||
Row( | ||
modifier = Modifier.fillMaxWidth(), | ||
horizontalArrangement = Arrangement.SpaceBetween, | ||
verticalAlignment = Alignment.CenterVertically | ||
) { | ||
Row( | ||
modifier = Modifier | ||
.clip(CircleShape) | ||
.clickable { onSortClick() } | ||
.background(MaterialTheme.colorScheme.surfaceContainer) | ||
.padding(16.dp), | ||
horizontalArrangement = Arrangement.spacedBy(8.dp), | ||
verticalAlignment = Alignment.CenterVertically | ||
) { | ||
Icon(icon, null) | ||
selected() | ||
} | ||
IconButton( | ||
onReversedClick, | ||
modifier = Modifier | ||
.clip(CircleShape) | ||
.background(MaterialTheme.colorScheme.surfaceContainer) | ||
) { | ||
Icon( | ||
Icons.Default.KeyboardArrowDown, | ||
null, | ||
modifier = Modifier | ||
.rotate(rotation) | ||
) | ||
} | ||
} | ||
DropdownMenu( | ||
expanded = expanded, | ||
onDismissRequest = { onSortClick() } | ||
) { | ||
content() | ||
} | ||
} | ||
} | ||
|
||
@Preview | ||
@Composable | ||
private fun CustomSortDropDownMenuPreview() { | ||
BrawlhallaTheme { | ||
Surface { | ||
CustomSortDropDownMenu( | ||
reversed = true, | ||
expanded = true, | ||
icon = Icons.Default.Mode, | ||
selected = { | ||
Text("test") | ||
}, | ||
onSortClick = {}, | ||
onReversedClick = {}, | ||
) { | ||
Text("test") | ||
} | ||
} | ||
} | ||
} |
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
8 changes: 6 additions & 2 deletions
8
app/src/main/java/com/nickoehler/brawlhalla/ranking/presentation/StatDetailAction.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 |
---|---|---|
@@ -1,16 +1,20 @@ | ||
package com.nickoehler.brawlhalla.ranking.presentation | ||
|
||
import com.nickoehler.brawlhalla.legends.presentation.models.RankingModalType | ||
import com.nickoehler.brawlhalla.ranking.presentation.models.RankingFilterType | ||
import com.nickoehler.brawlhalla.ranking.presentation.models.RankingModalType | ||
import com.nickoehler.brawlhalla.ranking.presentation.models.RankingSortType | ||
import com.nickoehler.brawlhalla.ranking.presentation.models.StatFilterType | ||
import com.nickoehler.brawlhalla.ranking.presentation.models.StatType | ||
|
||
sealed interface StatDetailAction { | ||
data class SelectPlayer(val brawlhallaId: Int) : StatDetailAction | ||
data class SelectStatType(val stat: StatType) : StatDetailAction | ||
data class SelectClan(val clanId: Int) : StatDetailAction | ||
data class SelectRankingFilterType(val type: RankingFilterType) : StatDetailAction | ||
data class SelectStatFilterType(val type: StatFilterType) : StatDetailAction | ||
data class TogglePlayerFavorites(val brawlhallaId: Int, val name: String) : StatDetailAction | ||
data class SelectRankingModalType(val modalType: RankingModalType?) : StatDetailAction | ||
data class SortBy(val sortType: RankingSortType) : StatDetailAction | ||
data object StatLegendSortTypeReversed : StatDetailAction | ||
data object RankingLegendSortTypeReversed : StatDetailAction | ||
data object TeamSortTypeReversed : StatDetailAction | ||
} |
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
Oops, something went wrong.