diff --git a/data/src/main/java/com/madrid/data/dataSource/local/dao/RecentSearchDao.kt b/data/src/main/java/com/madrid/data/dataSource/local/dao/RecentSearchDao.kt index c96a82000..6ecc9e524 100644 --- a/data/src/main/java/com/madrid/data/dataSource/local/dao/RecentSearchDao.kt +++ b/data/src/main/java/com/madrid/data/dataSource/local/dao/RecentSearchDao.kt @@ -11,7 +11,7 @@ interface RecentSearchDao { @Insert(onConflict = OnConflictStrategy.REPLACE) suspend fun addRecentSearch(query: RecentSearchEntity) - @Query("SELECT * FROM RECENT_TABLE") + @Query("SELECT * FROM RECENT_TABLE ORDER BY timestamp DESC") fun getRecentSearches(): List @Query("DELETE FROM RECENT_TABLE WHERE searchQuery = :query") diff --git a/designSystem/src/main/res/drawable/icon_paly.xml b/designSystem/src/main/res/drawable/icon_paly.xml new file mode 100644 index 000000000..fd179c684 --- /dev/null +++ b/designSystem/src/main/res/drawable/icon_paly.xml @@ -0,0 +1,9 @@ + + + diff --git a/presentation/src/main/java/com/madrid/presentation/composables/BottomMediaActions.kt b/presentation/src/main/java/com/madrid/presentation/composables/BottomMediaActions.kt new file mode 100644 index 000000000..21051fa5b --- /dev/null +++ b/presentation/src/main/java/com/madrid/presentation/composables/BottomMediaActions.kt @@ -0,0 +1,149 @@ +package com.madrid.presentation.composables + +import androidx.compose.animation.animateColorAsState +import androidx.compose.foundation.background +import androidx.compose.foundation.clickable +import androidx.compose.foundation.interaction.MutableInteractionSource +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.size +import androidx.compose.foundation.shape.CircleShape +import androidx.compose.runtime.Composable +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.setValue +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Brush +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.res.painterResource +import androidx.compose.ui.tooling.preview.Preview +import androidx.compose.ui.unit.dp +import com.madrid.designsystem.AppTheme +import com.madrid.designsystem.R +import com.madrid.designsystem.component.MovioIcon +import com.madrid.designsystem.component.MovioText +@Composable +fun BottomMediaActions( + onRateClick: ((Boolean) -> Unit)? = null, + onPlayClick: (() -> Unit)? = null, + onAddToListClick: ((Boolean) -> Unit)? = null, + modifier: Modifier = Modifier, +) { + var isRated by remember { mutableStateOf(false) } + var isSaved by remember { mutableStateOf(false) } + Row( + modifier = modifier + .fillMaxWidth() + .padding(vertical = 12.dp), + verticalAlignment = Alignment.CenterVertically, + horizontalArrangement = Arrangement.SpaceEvenly + ) { + if (onRateClick != null) { + MediaActionItem( + label = "Rate it", + isActive = isRated, + activeIcon = R.drawable.bold_star, + inactiveIcon = R.drawable.outline_star, + activeColor = Color.Yellow, + onToggle = { + isRated = !isRated + onRateClick(isRated) + } + ) + } + if (onPlayClick != null) { + PlayButton(onClick = onPlayClick) + } + + if (onAddToListClick != null) { + MediaActionItem( + label = "Add to list", + isActive = isSaved, + activeIcon = R.drawable.bold_bookmark, + inactiveIcon = R.drawable.outline_bookmark, + activeColor = Color(0xFF4CAF50), + onToggle = { + isSaved = !isSaved + onAddToListClick(isSaved) + } + ) + } + } +} +@Composable +private fun MediaActionItem( + label: String, + isActive: Boolean, + activeIcon: Int, + inactiveIcon: Int, + activeColor: Color, + onToggle: () -> Unit +) { + val animatedColor by animateColorAsState( + targetValue = if (isActive) activeColor else AppTheme.colors.surfaceColor.onSurfaceContainer, + label = "ActionIconColor" + ) + val icon = if (isActive) activeIcon else inactiveIcon + Column(horizontalAlignment = Alignment.CenterHorizontally) { + MovioIcon( + painter = painterResource(icon), + contentDescription = label, + modifier = Modifier + .size(28.dp) + .clickable( + onClick = onToggle, + indication = null, + interactionSource = remember { MutableInteractionSource() } + ), + tint = animatedColor + ) + MovioText( + text = label, + textStyle = AppTheme.textStyle.label.smallRegular14, + color = AppTheme.colors.surfaceColor.onSurface + ) + } +} +@Composable +private fun PlayButton(onClick: () -> Unit) { + Box( + modifier = Modifier + .size(56.dp) + .background( + brush = Brush.horizontalGradient( + listOf(Color(0xFFB7A4FB), Color(0xFF663EF6)) + ), + shape = CircleShape + ) + .clickable( + onClick = onClick, + indication = null, + interactionSource = remember { MutableInteractionSource() } + ), + contentAlignment = Alignment.Center + ) { + MovioIcon( + painter = painterResource(R.drawable.icon_paly), + contentDescription = "Play", + modifier = Modifier.size(28.dp), + tint = Color.White + ) + } +} +@Preview(showBackground = true) +@Composable +fun BottomActionBarPreview() { + AppTheme { + BottomMediaActions( + onRateClick = {}, + onPlayClick = {}, + onAddToListClick = {} + ) + } +} diff --git a/presentation/src/main/java/com/madrid/presentation/composables/ReviewActionBar.kt b/presentation/src/main/java/com/madrid/presentation/composables/ReviewActionBar.kt new file mode 100644 index 000000000..bc60da027 --- /dev/null +++ b/presentation/src/main/java/com/madrid/presentation/composables/ReviewActionBar.kt @@ -0,0 +1,115 @@ +package com.madrid.presentation.composables + +import androidx.compose.animation.animateColorAsState +import androidx.compose.foundation.clickable +import androidx.compose.foundation.interaction.MutableInteractionSource +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.size +import androidx.compose.runtime.Composable +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.saveable.rememberSaveable +import androidx.compose.runtime.setValue +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.res.painterResource +import androidx.compose.ui.tooling.preview.Preview +import androidx.compose.ui.unit.dp +import com.madrid.designsystem.AppTheme +import com.madrid.designsystem.R +import com.madrid.designsystem.component.MovioIcon +import com.madrid.designsystem.component.MovioText +@Composable +fun ReviewTopBar( + onBackClick: () -> Unit, + modifier: Modifier = Modifier, + centerText: String? = null, + onShareClick: (() -> Unit)? = null, + onFavoriteClick: (() -> Unit)? = null, + initiallyFavorite: Boolean = false +) { + var isFavorite by rememberSaveable { mutableStateOf(initiallyFavorite) } + val favoriteColor by animateColorAsState( + targetValue = if (isFavorite) Color.Red else AppTheme.colors.surfaceColor.onSurface, + label = "FavoriteColor" + ) + Row( + modifier = modifier + .fillMaxWidth() + .height(40.dp) + .padding(horizontal = AppTheme.spacing.medium), + verticalAlignment = Alignment.CenterVertically, + horizontalArrangement = Arrangement.SpaceBetween + ) { + IconButton( + iconRes = R.drawable.arrow_left, + contentDescription = "Back", + tint = AppTheme.colors.surfaceColor.onSurface, + onClick = onBackClick + ) + centerText?.let { + MovioText( + text = it, + textStyle = AppTheme.textStyle.label.medium14, + color = AppTheme.colors.surfaceColor.onSurface + ) + } + Row(horizontalArrangement = Arrangement.spacedBy(AppTheme.spacing.medium)) { + onShareClick?.let { + IconButton( + iconRes = R.drawable.share_arrow, + contentDescription = "Share", + tint = AppTheme.colors.surfaceColor.onSurface, + onClick = it + ) + } + onFavoriteClick?.let { + IconButton( + iconRes = if (isFavorite) R.drawable.bold_heart else R.drawable.outline_heart, + contentDescription = "Favorite", + tint = favoriteColor, + onClick = { + isFavorite = !isFavorite + it() + } + ) + } + } + } +} +@Composable +private fun IconButton( + iconRes: Int, + contentDescription: String?, + tint: Color, + onClick: () -> Unit +) { + MovioIcon( + painter = painterResource(iconRes), + contentDescription = contentDescription, + modifier = Modifier + .size(24.dp) + .clickable( + onClick = onClick, + indication = null, + interactionSource = remember { MutableInteractionSource() } + ), + tint = tint + ) +} +@Preview(showBackground = true, showSystemUi = true) +@Composable +fun ReviewActionBarPreview() { + ReviewTopBar( + onBackClick = { }, + onShareClick = {}, + onFavoriteClick = {} + + ) +} diff --git a/presentation/src/main/res/values-ar/string.xml b/presentation/src/main/res/values-ar/string.xml index fd925b334..924537e23 100644 --- a/presentation/src/main/res/values-ar/string.xml +++ b/presentation/src/main/res/values-ar/string.xml @@ -18,9 +18,14 @@ الافلام المسلسلات الممثلون + نتائج البحث (%1$s عنصر) البحث الأخير مسح الكل + إحذف + التقيم + أضف الى القائمة + تشغيل من أجلك رؤية الكل البحث عن المزيد diff --git a/presentation/src/main/res/values/string.xml b/presentation/src/main/res/values/string.xml index cf17fe9e2..4d13c1a6d 100644 --- a/presentation/src/main/res/values/string.xml +++ b/presentation/src/main/res/values/string.xml @@ -21,7 +21,10 @@ Movies Series Artists - Search Result (%1$s items) + SearchResult (%1$s items) + Rate it + Add to list + Play For You See all Explore more