-
-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #69 from RajashekarRaju/feat/movie-watch-options
Movie watch options
- Loading branch information
Showing
13 changed files
with
363 additions
and
62 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
11 changes: 11 additions & 0 deletions
11
app/src/main/java/com/developersbreach/composeactors/data/model/MovieProvider.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,11 @@ | ||
package com.developersbreach.composeactors.data.model | ||
|
||
data class MovieProvider( | ||
val flatrate: ArrayList<Flatrate>, | ||
) | ||
|
||
data class Flatrate( | ||
val logo_path: String, | ||
val provider_id: Int, | ||
val provider_name: String | ||
) |
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
141 changes: 141 additions & 0 deletions
141
...a/com/developersbreach/composeactors/ui/screens/modalSheets/SheetContentMovieProviders.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,141 @@ | ||
package com.developersbreach.composeactors.ui.screens.modalSheets | ||
|
||
import androidx.compose.foundation.background | ||
import androidx.compose.foundation.layout.Arrangement | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.Row | ||
import androidx.compose.foundation.layout.Spacer | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.foundation.layout.height | ||
import androidx.compose.foundation.layout.navigationBarsPadding | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.foundation.layout.size | ||
import androidx.compose.foundation.lazy.LazyRow | ||
import androidx.compose.foundation.lazy.items | ||
import androidx.compose.material.MaterialTheme | ||
import androidx.compose.material.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.res.stringResource | ||
import androidx.compose.ui.unit.dp | ||
import androidx.constraintlayout.compose.ConstraintLayout | ||
import com.developersbreach.composeactors.R | ||
import com.developersbreach.composeactors.data.model.Flatrate | ||
import com.developersbreach.composeactors.data.model.MovieProvider | ||
import com.developersbreach.composeactors.ui.components.LoadNetworkImage | ||
import com.developersbreach.composeactors.ui.components.SheetHorizontalSeparator | ||
import com.developersbreach.composeactors.ui.screens.movieDetail.composables.FloatingAddToFavoritesButton | ||
|
||
@Composable | ||
fun SheetContentMovieProviders( | ||
movieProvider: MovieProvider, | ||
isFavoriteMovie: Boolean, | ||
addMovieToFavorites: () -> Unit, | ||
removeMovieFromFavorites: () -> Unit | ||
) { | ||
ConstraintLayout( | ||
modifier = Modifier | ||
.fillMaxWidth() | ||
.height(250.dp) | ||
.background(MaterialTheme.colors.surface) | ||
.navigationBarsPadding() | ||
) { | ||
val (header, streaming, noStreaming, floatingButton) = createRefs() | ||
|
||
HeaderModalSheet( | ||
modifier = Modifier.constrainAs(header) { | ||
top.linkTo(parent.top, margin = 16.dp) | ||
} | ||
) | ||
|
||
if (movieProvider.flatrate.isNotEmpty()) { | ||
Streaming( | ||
flatrate = movieProvider.flatrate, | ||
modifier = Modifier.constrainAs(streaming) { | ||
top.linkTo(header.bottom, margin = 16.dp) | ||
start.linkTo(parent.start, margin = 24.dp) | ||
end.linkTo(parent.end) | ||
} | ||
) | ||
} else { | ||
NoStreaming( | ||
modifier = Modifier.constrainAs(noStreaming) { | ||
top.linkTo(header.bottom, margin = 16.dp) | ||
start.linkTo(parent.start) | ||
end.linkTo(parent.end) | ||
} | ||
) | ||
} | ||
|
||
FloatingAddToFavoritesButton( | ||
isFavorite = isFavoriteMovie, | ||
addToFavorites = addMovieToFavorites, | ||
removeFromFavorites = removeMovieFromFavorites, | ||
modifier = Modifier.constrainAs(floatingButton) { | ||
bottom.linkTo(parent.bottom, margin = 8.dp) | ||
start.linkTo(parent.start) | ||
end.linkTo(parent.end) | ||
} | ||
) | ||
} | ||
} | ||
|
||
@Composable | ||
fun NoStreaming(modifier: Modifier = Modifier) { | ||
Column( | ||
modifier = modifier | ||
.fillMaxWidth() | ||
.padding(16.dp), | ||
verticalArrangement = Arrangement.Center, | ||
horizontalAlignment = Alignment.CenterHorizontally | ||
) { | ||
Text( | ||
text = stringResource(id = R.string.no_watch_options), | ||
style = MaterialTheme.typography.body1, | ||
color = MaterialTheme.colors.onSurface | ||
) | ||
} | ||
} | ||
|
||
@Composable | ||
fun Streaming(flatrate: ArrayList<Flatrate>, modifier: Modifier = Modifier) { | ||
LazyRow( | ||
modifier = modifier | ||
.fillMaxWidth() | ||
.padding(start = 24.dp) | ||
) { | ||
items(flatrate) { flatrate -> | ||
LoadNetworkImage( | ||
imageUrl = flatrate.logo_path, | ||
contentDescription = "", | ||
shape = MaterialTheme.shapes.large, | ||
showAnimProgress = false, | ||
modifier = Modifier | ||
.padding(horizontal = 4.dp) | ||
.size(48.dp) | ||
) | ||
} | ||
} | ||
} | ||
|
||
@Composable | ||
private fun HeaderModalSheet(modifier: Modifier = Modifier) { | ||
Column( | ||
modifier = modifier | ||
.fillMaxWidth() | ||
.padding(horizontal = 16.dp) | ||
) { | ||
Row( | ||
modifier = Modifier.fillMaxWidth(), | ||
horizontalArrangement = Arrangement.Center | ||
) { | ||
SheetHorizontalSeparator() | ||
} | ||
Spacer(modifier = Modifier.height(14.dp)) | ||
Text( | ||
text = stringResource(id = R.string.stream), | ||
style = MaterialTheme.typography.h6 | ||
) | ||
} | ||
} |
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
Oops, something went wrong.