-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
329 additions
and
79 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
145 changes: 145 additions & 0 deletions
145
core/ui/src/main/java/ru/stersh/youamp/core/ui/HeaderButtons.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,145 @@ | ||
package ru.stersh.youamp.core.ui | ||
|
||
import androidx.compose.foundation.layout.Arrangement | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.size | ||
import androidx.compose.foundation.layout.width | ||
import androidx.compose.material.icons.Icons | ||
import androidx.compose.material.icons.rounded.Favorite | ||
import androidx.compose.material.icons.rounded.FavoriteBorder | ||
import androidx.compose.material.icons.rounded.PlayArrow | ||
import androidx.compose.material.icons.rounded.Shuffle | ||
import androidx.compose.material3.FilledTonalIconButton | ||
import androidx.compose.material3.FilledTonalIconToggleButton | ||
import androidx.compose.material3.Icon | ||
import androidx.compose.material3.LocalTextStyle | ||
import androidx.compose.material3.MaterialTheme | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.CompositionLocalProvider | ||
import androidx.compose.runtime.Stable | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.res.stringResource | ||
import androidx.compose.ui.text.style.TextAlign | ||
import androidx.compose.ui.text.style.TextOverflow | ||
import androidx.compose.ui.unit.dp | ||
|
||
@Composable | ||
fun FavoriteButton( | ||
isFavorite: Boolean, | ||
onChange: (isFavorite: Boolean) -> Unit, | ||
modifier: Modifier = Modifier | ||
) { | ||
val text = if (isFavorite) { | ||
stringResource(R.string.dislike_title) | ||
} else { | ||
stringResource(R.string.like_title) | ||
} | ||
ButtonLayout( | ||
button = { | ||
FilledTonalIconToggleButton( | ||
checked = isFavorite, | ||
onCheckedChange = onChange, | ||
modifier = modifier.size(ButtonSize) | ||
) { | ||
Icon( | ||
imageVector = if (isFavorite) { | ||
Icons.Rounded.Favorite | ||
} else { | ||
Icons.Rounded.FavoriteBorder | ||
}, | ||
contentDescription = text | ||
) | ||
} | ||
}, | ||
title = { | ||
Text( | ||
text = text, | ||
maxLines = 1, | ||
overflow = TextOverflow.Ellipsis, | ||
textAlign = TextAlign.Center | ||
) | ||
}, | ||
modifier = modifier | ||
) | ||
} | ||
|
||
@Composable | ||
fun PlayAllButton( | ||
onClick: () -> Unit, | ||
modifier: Modifier = Modifier | ||
) { | ||
ButtonLayout( | ||
button = { | ||
FilledTonalIconButton( | ||
onClick = onClick, | ||
modifier = modifier.size(ButtonSize) | ||
) { | ||
Icon( | ||
imageVector = Icons.Rounded.PlayArrow, | ||
contentDescription = stringResource(R.string.play_all_title) | ||
) | ||
} | ||
}, | ||
title = { | ||
Text( | ||
text = stringResource(R.string.play_all_title), | ||
maxLines = 1, | ||
overflow = TextOverflow.Ellipsis, | ||
textAlign = TextAlign.Center | ||
) | ||
}, | ||
modifier = modifier | ||
) | ||
} | ||
|
||
@Composable | ||
fun PlayShuffledButton( | ||
onClick: () -> Unit, | ||
modifier: Modifier = Modifier | ||
) { | ||
ButtonLayout( | ||
button = { | ||
FilledTonalIconButton( | ||
onClick = onClick, | ||
modifier = modifier.size(ButtonSize) | ||
) { | ||
Icon( | ||
imageVector = Icons.Rounded.Shuffle, | ||
contentDescription = stringResource(R.string.shuffle_title) | ||
) | ||
} | ||
}, | ||
title = { | ||
Text( | ||
text = stringResource(R.string.shuffle_title), | ||
maxLines = 1, | ||
overflow = TextOverflow.Ellipsis, | ||
textAlign = TextAlign.Center | ||
) | ||
}, | ||
modifier = modifier | ||
) | ||
} | ||
|
||
@Stable | ||
private val ButtonSize = 64.dp | ||
|
||
@Composable | ||
private fun ButtonLayout( | ||
button: @Composable () -> Unit, | ||
title: @Composable () -> Unit, | ||
modifier: Modifier = Modifier | ||
) { | ||
Column( | ||
horizontalAlignment = Alignment.CenterHorizontally, | ||
verticalArrangement = Arrangement.spacedBy(8.dp), | ||
modifier = modifier.width(72.dp) | ||
) { | ||
button() | ||
CompositionLocalProvider(LocalTextStyle provides MaterialTheme.typography.labelSmall) { | ||
title() | ||
} | ||
} | ||
} |
46 changes: 0 additions & 46 deletions
46
core/ui/src/main/java/ru/stersh/youamp/core/ui/PlayButtons.kt
This file was deleted.
Oops, something went wrong.
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
18 changes: 18 additions & 0 deletions
18
...bum/info/src/main/java/ru/stersh/youamp/feature/album/data/AlbumFavoriteRepositoryImpl.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,18 @@ | ||
package ru.stersh.youamp.feature.album.data | ||
|
||
import ru.stersh.youamp.core.api.provider.ApiProvider | ||
import ru.stersh.youamp.feature.album.domain.AlbumFavoriteRepository | ||
|
||
internal class AlbumFavoriteRepositoryImpl( | ||
private val apiProvider: ApiProvider | ||
) : AlbumFavoriteRepository { | ||
|
||
override suspend fun setFavorite(id: String, isFavorite: Boolean) { | ||
val api = apiProvider.getApi() | ||
if (isFavorite) { | ||
api.starAlbum(id) | ||
} else { | ||
api.unstarAlbum(id) | ||
} | ||
} | ||
} |
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
6 changes: 6 additions & 0 deletions
6
...album/info/src/main/java/ru/stersh/youamp/feature/album/domain/AlbumFavoriteRepository.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,6 @@ | ||
package ru.stersh.youamp.feature.album.domain | ||
|
||
internal interface AlbumFavoriteRepository { | ||
|
||
suspend fun setFavorite(id: String, isFavorite: Boolean) | ||
} |
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.