-
Notifications
You must be signed in to change notification settings - Fork 6
Feature/similar movie screen #102
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
Merged
Changes from 9 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
33e4a71
Merge remote-tracking branch 'origin/feature/details-top-cast-screen-…
baraa0abd 19d1190
feat: similar movies screen
baraa0abd 6521bd7
fix: string resources
baraa0abd 1cffc99
Merge branch 'develop' into feature/similar-movie-screen
baraa0abd 5ffa736
Refactor/similar-movies-screen
baraa0abd 48cb143
feat: Enhance SimilarMoviesScreen with loading/error states
baraa0abd c3e217d
Refactor: similar movies screen top app bar
baraa0abd 541d976
Merge remote-tracking branch 'origin/develop' into feature/similar-mo…
AmrNasserSaad 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
74 changes: 74 additions & 0 deletions
74
designSystem/src/main/java/com/madrid/designsystem/component/TopAppBar.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,74 @@ | ||
| package com.madrid.designsystem.component | ||
|
|
||
| import androidx.compose.foundation.layout.Arrangement | ||
| import androidx.compose.foundation.layout.Box | ||
| import androidx.compose.foundation.layout.Row | ||
| import androidx.compose.foundation.layout.fillMaxWidth | ||
| import androidx.compose.foundation.layout.padding | ||
| import androidx.compose.runtime.Composable | ||
| import androidx.compose.ui.Alignment | ||
| import androidx.compose.ui.Modifier | ||
| import androidx.compose.ui.res.painterResource | ||
| import androidx.compose.ui.unit.dp | ||
| import com.madrid.designsystem.AppTheme | ||
| import com.madrid.designsystem.R | ||
|
|
||
| @Composable | ||
| fun TopAppBar( | ||
| text: String?, | ||
| modifier: Modifier = Modifier, | ||
| firstIcon: Int? = R.drawable.arrow_left, | ||
| secondIcon: Int? = R.drawable.share_arrow, | ||
| thirdIcon: Int? = R.drawable.outline_heart | ||
| ) { | ||
| Row( | ||
| modifier = modifier | ||
| .fillMaxWidth() | ||
| .padding(horizontal = 16.dp, vertical = 12.dp), | ||
| verticalAlignment = Alignment.CenterVertically, | ||
| horizontalArrangement = Arrangement.SpaceBetween | ||
| ) { | ||
| firstIcon?.let { iconRes -> | ||
| MovioIcon( | ||
| painter = painterResource(id = iconRes), | ||
| contentDescription = "arrow_left", | ||
| tint = AppTheme.colors.surfaceColor.onSurface | ||
| ) | ||
| } | ||
| Box( | ||
| modifier = Modifier | ||
| .weight(1f) | ||
| .padding(horizontal = AppTheme.spacing.small), | ||
| contentAlignment = Alignment.Center | ||
| ) { | ||
| if (text != null) { | ||
| MovioText( | ||
| text = text, | ||
| textStyle = AppTheme.textStyle.headLine.largeBold18, | ||
| color = AppTheme.colors.surfaceColor.onSurface | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| Row( | ||
| verticalAlignment = Alignment.CenterVertically, | ||
| horizontalArrangement = Arrangement.spacedBy(8.dp) | ||
| ) { | ||
| secondIcon?.let { iconRes -> | ||
| MovioIcon( | ||
| painter = painterResource(id = iconRes), | ||
| contentDescription = "share_arrow", | ||
| tint = AppTheme.colors.surfaceColor.onSurface | ||
| ) | ||
| } | ||
|
|
||
| thirdIcon?.let { iconRes -> | ||
| MovioIcon( | ||
| painter = painterResource(id = iconRes), | ||
| contentDescription = "outline_heart", | ||
| tint = AppTheme.colors.surfaceColor.onSurface | ||
| ) | ||
| } | ||
| } | ||
| } | ||
| } |
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
63 changes: 63 additions & 0 deletions
63
...ation/src/main/java/com/madrid/presentation/screens/detailsScreen/TopCastDetailsScreen.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,63 @@ | ||
| package com.madrid.presentation.screens.detailsScreen | ||
|
|
||
| import androidx.compose.foundation.background | ||
| import androidx.compose.foundation.layout.Arrangement | ||
| import androidx.compose.foundation.layout.PaddingValues | ||
| import androidx.compose.foundation.layout.fillMaxSize | ||
| import androidx.compose.foundation.layout.statusBarsPadding | ||
| import androidx.compose.foundation.lazy.grid.GridCells | ||
| import androidx.compose.foundation.lazy.grid.GridItemSpan | ||
| import androidx.compose.foundation.lazy.grid.LazyVerticalGrid | ||
| import androidx.compose.runtime.Composable | ||
| import androidx.compose.runtime.collectAsState | ||
| import androidx.compose.ui.Modifier | ||
| import androidx.compose.ui.res.stringResource | ||
| import androidx.compose.ui.unit.dp | ||
| import com.madrid.designsystem.AppTheme | ||
| import com.madrid.designsystem.component.TopAppBar | ||
| import com.madrid.presentation.R | ||
| import com.madrid.presentation.composables.movioCards.MovioArtistsCard | ||
| import com.madrid.presentation.screens.searchScreen.viewModel.SearchScreenState | ||
| import com.madrid.presentation.screens.searchScreen.viewModel.SearchViewModel | ||
| import org.koin.androidx.compose.koinViewModel | ||
|
|
||
| @Composable | ||
| fun TopCastDetailsScreen( | ||
| viewModel: SearchViewModel = koinViewModel() | ||
| ) { | ||
| val uiState = viewModel.state.collectAsState().value | ||
|
|
||
| TopCastDetailsContent(artist = uiState.filteredScreenUiState.artist) | ||
| } | ||
|
|
||
| @Composable | ||
| fun TopCastDetailsContent( | ||
| artist: List<SearchScreenState.ArtistUiState> | ||
| ) { | ||
| LazyVerticalGrid( | ||
| columns = GridCells.Adaptive(minSize = 101.dp), | ||
| modifier = Modifier | ||
| .fillMaxSize() | ||
| .background(AppTheme.colors.surfaceColor.surface) | ||
| .statusBarsPadding(), | ||
| contentPadding = PaddingValues(horizontal = 16.dp, vertical = 16.dp), | ||
| horizontalArrangement = Arrangement.spacedBy(12.dp), | ||
| verticalArrangement = Arrangement.spacedBy(12.dp) | ||
| ) { | ||
| item( | ||
| span = { GridItemSpan(maxLineSpan) } | ||
| ) { | ||
| TopAppBar(stringResource(R.string.top_cast), secondIcon = null, thirdIcon = null) | ||
| } | ||
| items( | ||
| count = artist.size, | ||
| ) { index -> | ||
| MovioArtistsCard( | ||
| artistsName = artist[index].name, | ||
| imageUrl = artist[index].imageUrl, | ||
| width = 101.dp, | ||
| onClick = { } | ||
| ) | ||
| } | ||
| } | ||
| } |
138 changes: 138 additions & 0 deletions
138
...tation/src/main/java/com/madrid/presentation/screens/similarMovies/SimilarMoviesScreen.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,138 @@ | ||
| package com.madrid.presentation.screens.similarMovies | ||
|
|
||
| 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.Column | ||
| import androidx.compose.foundation.layout.PaddingValues | ||
| import androidx.compose.foundation.layout.Row | ||
| import androidx.compose.foundation.layout.Spacer | ||
| import androidx.compose.foundation.layout.fillMaxSize | ||
| import androidx.compose.foundation.layout.fillMaxWidth | ||
| import androidx.compose.foundation.layout.padding | ||
| import androidx.compose.foundation.layout.size | ||
| import androidx.compose.foundation.lazy.grid.GridCells | ||
| import androidx.compose.foundation.lazy.grid.LazyVerticalGrid | ||
| import androidx.compose.foundation.lazy.grid.items | ||
| import androidx.compose.runtime.Composable | ||
| import androidx.compose.runtime.collectAsState | ||
| 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.res.painterResource | ||
| import androidx.compose.ui.res.stringResource | ||
| 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 | ||
| import com.madrid.presentation.composables.movioCards.MovioVerticalCard | ||
| import com.madrid.presentation.screens.searchScreen.viewModel.SearchScreenState | ||
| import com.madrid.presentation.screens.searchScreen.viewModel.SearchViewModel | ||
| import org.koin.androidx.compose.koinViewModel | ||
|
|
||
| @Composable | ||
| fun SimilarMoviesScreen( | ||
| onBackClick: () -> Unit = {}, | ||
| onMovieClick: (SearchScreenState.MovieUiState) -> Unit = {}, | ||
| modifier: Modifier = Modifier, | ||
| viewModel: SearchViewModel = koinViewModel() | ||
| ) { | ||
| val state by viewModel.state.collectAsState() | ||
| var selectedMovieId by remember { mutableStateOf<String?>(null) } | ||
|
|
||
| Column( | ||
| modifier = modifier | ||
| .fillMaxSize() | ||
| .background(AppTheme.colors.surfaceColor.surface) | ||
| ) { | ||
| Row( | ||
| modifier = Modifier | ||
| .fillMaxWidth() | ||
| .padding(horizontal = 16.dp, vertical = 12.dp), | ||
| verticalAlignment = Alignment.CenterVertically | ||
| ) { | ||
| Box( | ||
| modifier = Modifier | ||
| .size(40.dp) | ||
| .clickable { onBackClick() }, | ||
| contentAlignment = Alignment.Center | ||
| ) { | ||
| MovioIcon( | ||
| painter = painterResource(R.drawable.arrow_left), | ||
| contentDescription = "", | ||
| tint = AppTheme.colors.surfaceColor.onSurface | ||
| ) | ||
| } | ||
| Spacer(modifier = Modifier.weight(1f)) | ||
| MovioText( | ||
| text = stringResource(id = com.madrid.presentation.R.string.selected_similar_movie), | ||
| textStyle = AppTheme.textStyle.headLine.largeBold18, | ||
| color = AppTheme.colors.surfaceColor.onSurface | ||
| ) | ||
| Spacer(modifier = Modifier.weight(1f)) | ||
| } | ||
| LazyVerticalGrid( | ||
| modifier = Modifier.fillMaxSize(), | ||
|
baraa0abd marked this conversation as resolved.
|
||
| columns = GridCells.Fixed(3), | ||
| contentPadding = PaddingValues(16.dp), | ||
| horizontalArrangement = Arrangement.spacedBy(8.dp), | ||
| verticalArrangement = Arrangement.spacedBy(12.dp), | ||
| ) { | ||
| items(state.searchUiState.exploreMoreMovies) { movie -> | ||
| MovioVerticalCard( | ||
| description = movie.title, | ||
| movieImage = movie.imageUrl, | ||
| rate = movie.rating, | ||
| width = 101.33.dp, | ||
| height = 136.dp, | ||
| onClick = { | ||
| selectedMovieId = movie.id | ||
| onMovieClick(movie) | ||
| }, | ||
| modifier = Modifier, | ||
| paddingvalue = 0.dp | ||
| ) | ||
| } | ||
| } | ||
| if (state.searchUiState.isLoading) { | ||
| Box( | ||
| Modifier | ||
| .fillMaxWidth() | ||
| .padding(16.dp), | ||
| contentAlignment = Alignment.Center | ||
| ) { | ||
| MovioText( | ||
| text = stringResource(id = com.madrid.presentation.R.string.loading), | ||
| color = AppTheme.colors.surfaceColor.onSurface, | ||
| textStyle = AppTheme.textStyle.body.medium14 | ||
| ) | ||
| } | ||
| } | ||
| state.searchUiState.errorMessage?.let { errorMsg -> | ||
| Box(Modifier | ||
| .fillMaxWidth() | ||
| .padding(16.dp), contentAlignment = Alignment.Center) { | ||
| MovioText( | ||
| text = errorMsg, | ||
| color = AppTheme.colors.surfaceColor.outline, | ||
| textStyle = AppTheme.textStyle.body.medium14 | ||
| ) | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| @Preview(showSystemUi = true, showBackground = true) | ||
| @Composable | ||
| fun SimilarMoviesScreenPreview() { | ||
| SimilarMoviesScreen( | ||
| onBackClick = {}, | ||
| onMovieClick = {} | ||
| ) | ||
| } | ||
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.
Uh oh!
There was an error while loading. Please reload this page.