Skip to content

Commit

Permalink
Fix movie detail UI
Browse files Browse the repository at this point in the history
Removed Compose ConstraintLayout due to slower updates compared to core Compose
  • Loading branch information
yasinkacmaz committed Sep 17, 2024
1 parent c6abd63 commit 8c2b378
Show file tree
Hide file tree
Showing 17 changed files with 174 additions and 314 deletions.
1 change: 0 additions & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ dependencies {
implementation(libs.compose.paging)
implementation(libs.compose.activity)
implementation(libs.compose.navigation)
implementation(libs.compose.constraintLayout)
implementation(libs.bundles.io)
implementation(libs.bundles.koin)
implementation(libs.coil)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import androidx.compose.ui.test.performScrollTo
import androidx.compose.ui.test.performScrollToIndex
import androidx.compose.ui.test.runComposeUiTest
import com.yasinkacmaz.jetflix.R
import com.yasinkacmaz.jetflix.data.remote.Genre
import com.yasinkacmaz.jetflix.ui.moviedetail.LocalVibrantColor
import com.yasinkacmaz.jetflix.ui.moviedetail.MovieDetail
import com.yasinkacmaz.jetflix.ui.moviedetail.credits.Credits
Expand All @@ -36,7 +35,7 @@ class MovieDetailScreenTest {
duration = 137,
voteAverage = 7.3,
voteCount = 1337,
genres = listOf(Genre(1, "Action"), Genre(2, "Drama"), Genre(3, "Family")),
genres = listOf("Action", "Drama", "Family"),
tagline = "Tagline",
overview = "Overview",
)
Expand Down Expand Up @@ -69,12 +68,10 @@ class MovieDetailScreenTest {
cast = listOf(
person.copy("Scarlett Johansson", "Natasha Romanoff", gender = Gender.FEMALE),
person.copy("Stan Lee", "Characters", gender = Gender.MALE),
person.copy("Al Pacino", "Tony Montana", gender = Gender.MALE),
),
crew = listOf(
person.copy("Quentin Tarantino", "Director", gender = Gender.MALE),
person.copy("J.K. Rowling", "Novel", gender = Gender.FEMALE),
person.copy("Hans Zimmer", "Music Composer", gender = Gender.MALE),
),
)
renderMovieDetail(movieDetail, credits)
Expand All @@ -83,7 +80,7 @@ class MovieDetailScreenTest {
onNodeWithText("${movieDetail.duration} min", useUnmergedTree = false).assertIsDisplayed()
onNodeWithText(movieDetail.voteAverage.toString(), useUnmergedTree = false).assertIsDisplayed()
onNodeWithText(movieDetail.voteCount.toString(), useUnmergedTree = false).assertIsDisplayed()
movieDetail.genres.forEach { onNodeWithText(it.name!!, useUnmergedTree = false).assertIsDisplayed() }
movieDetail.genres.forEach { onNodeWithText(it, useUnmergedTree = false).assertIsDisplayed() }
onNodeWithText(movieDetail.tagline).performScrollTo()
onNodeWithText(movieDetail.tagline, useUnmergedTree = false).assertIsDisplayed()
onNodeWithText(movieDetail.overview).performScrollTo()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package com.yasinkacmaz.jetflix.ui.moviedetail

import com.yasinkacmaz.jetflix.data.remote.Genre

data class MovieDetail(
val id: Int,
val title: String = "",
Expand All @@ -10,7 +8,7 @@ data class MovieDetail(
val overview: String = "",
val backdropUrl: String = "",
val posterUrl: String = "",
val genres: List<Genre> = emptyList(),
val genres: List<String> = emptyList(),
val releaseDate: String = "",
val voteAverage: Double = 0.0,
val voteCount: Int = 0,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.yasinkacmaz.jetflix.ui.moviedetail

import com.yasinkacmaz.jetflix.data.remote.Genre
import com.yasinkacmaz.jetflix.data.remote.MovieDetailResponse
import com.yasinkacmaz.jetflix.util.Mapper
import com.yasinkacmaz.jetflix.util.parseAsDate
import com.yasinkacmaz.jetflix.util.toBackdropUrl
import com.yasinkacmaz.jetflix.util.toPosterUrl

Expand All @@ -18,8 +20,8 @@ class MovieDetailMapper : Mapper<MovieDetailResponse, MovieDetail> {
tagline = input.tagline.dropLastWhile { it == '.' },
backdropUrl = input.backdropPath.orEmpty().toBackdropUrl(),
posterUrl = input.posterPath.toPosterUrl(),
genres = input.genres,
releaseDate = input.releaseDate.orEmpty(),
genres = input.genres.mapNotNull(Genre::name).take(4),
releaseDate = input.releaseDate.parseAsDate(),
voteAverage = input.voteAverage,
voteCount = input.voteCount,
duration = input.runtime ?: -1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.remember
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.tooling.preview.Preview
import com.yasinkacmaz.jetflix.data.remote.Genre
import com.yasinkacmaz.jetflix.ui.moviedetail.credits.Credits
import com.yasinkacmaz.jetflix.ui.moviedetail.credits.Gender
import com.yasinkacmaz.jetflix.ui.moviedetail.credits.Person
Expand All @@ -28,7 +27,7 @@ private fun MovieDetailPreview() {
tagline = "My first movie",
backdropUrl = "url",
posterUrl = "url",
genres = listOf(Genre(1, "Action"), Genre(2, "Comedy"), Genre(3, "Fantasy")),
genres = listOf("Action", "Comedy", "Fantasy"),
releaseDate = "06.12.1994",
voteAverage = 5.7,
voteCount = 1337,
Expand Down
Loading

0 comments on commit 8c2b378

Please sign in to comment.