Skip to content

Commit

Permalink
Remove all codes for best and new (#296)
Browse files Browse the repository at this point in the history
  • Loading branch information
fornewid authored Nov 3, 2024
1 parent 40a83c2 commit ff90578
Show file tree
Hide file tree
Showing 7 changed files with 3 additions and 160 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ data class MovieColors(
val onLotte: Color,
val megabox: Color,
val onMegabox: Color,
val tagNew: Color,
val tagBest: Color,
val tagDDay: Color,
val ageTag12: Color,
val ageTag15: Color,
Expand Down Expand Up @@ -76,8 +74,6 @@ fun lightMovieColors(
onLotte: Color = Color.White,
megabox: Color = Color(0xFF352263),
onMegabox: Color = Color.White,
tagNew: Color = Color(0xFFF44336),
tagBest: Color = Color(0xFFFF9800),
tagDDay: Color = Color(0xFF9E9E9E),
ageTag12: Color = Color(0xFF2196F3),
ageTag15: Color = Color(0xFFFFC107),
Expand All @@ -97,8 +93,6 @@ fun lightMovieColors(
onLotte = onLotte,
megabox = megabox,
onMegabox = onMegabox,
tagNew = tagNew,
tagBest = tagBest,
tagDDay = tagDDay,
ageTag12 = ageTag12,
ageTag15 = ageTag15,
Expand All @@ -120,8 +114,6 @@ fun darkMovieColors(
onLotte: Color = Color.White,
megabox: Color = Color(0xFF352263),
onMegabox: Color = Color.White,
tagNew: Color = Color(0xFFF44336),
tagBest: Color = Color(0xFFFFB74D),
tagDDay: Color = Color(0xFFE0E0E0),
ageTag12: Color = Color(0xFF64B5F6),
ageTag15: Color = Color(0xFFFFD54F),
Expand All @@ -141,8 +133,6 @@ fun darkMovieColors(
onLotte = onLotte,
megabox = megabox,
onMegabox = onMegabox,
tagNew = tagNew,
tagBest = tagBest,
tagDDay = tagDDay,
ageTag12 = ageTag12,
ageTag15 = ageTag15,
Expand Down
49 changes: 0 additions & 49 deletions domain/src/main/java/soup/movie/domain/movie/MovieExt.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@
*/
package soup.movie.domain.movie

import soup.movie.model.CgvInfoModel
import soup.movie.model.LotteInfoModel
import soup.movie.model.MegaboxInfoModel
import soup.movie.model.MovieDetailModel
import soup.movie.model.MovieModel
import java.time.LocalDate
Expand All @@ -39,24 +36,6 @@ private fun MovieModel.hasOpenDate(): Boolean = openDate.toLocalDate() != null

fun MovieModel.isDDay(): Boolean = isPlan and hasOpenDate()

fun MovieModel.isBest(): Boolean {
return theater.cgv.eggIsOver(96) or
theater.lotte.starIsOver(8.8) or
theater.megabox.starIsOver(8.5)
}

fun MovieModel.isNew(): Boolean = isNow and isInThePastWeek()

fun MovieModel.isInThePastWeek(): Boolean = isIn(-6..0)

fun MovieModel.isIn(dayRange: IntRange): Boolean {
val openDate = openDate.toLocalDate()
if (openDate != null) {
return ChronoUnit.DAYS.between(today(), openDate) in dayRange
}
return false
}

fun MovieDetailModel.screenDays(): Int {
val openDate = openDate.toLocalDate()
if (openDate != null) {
Expand All @@ -75,31 +54,3 @@ private fun String.toLocalDate(): LocalDate? = split(".").let {
null
}
}

private fun CgvInfoModel?.eggIsOver(target: Int): Boolean {
return this?.star.eggIsOver(target)
}

private fun String?.eggIsOver(target: Int): Boolean {
return if (this == null || isBlank() || this == "?") {
false
} else {
this >= target.toString()
}
}

private fun LotteInfoModel?.starIsOver(target: Double): Boolean {
return this?.star.starIsOver(target)
}

private fun MegaboxInfoModel?.starIsOver(target: Double): Boolean {
return this?.star.starIsOver(target)
}

private fun String?.starIsOver(target: Double): Boolean {
return if (this == null || isBlank()) {
false
} else {
this >= target.toString()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,9 @@ import soup.movie.core.designsystem.icon.MovieIcons
import soup.movie.core.designsystem.theme.MovieTheme
import soup.movie.core.imageloading.AsyncImage
import soup.movie.domain.movie.getDDayLabel
import soup.movie.domain.movie.isBest
import soup.movie.domain.movie.isDDay
import soup.movie.domain.movie.isNew
import soup.movie.feature.home.favorite.MovieAgeTag
import soup.movie.feature.home.favorite.MovieBestTag
import soup.movie.feature.home.favorite.MovieDDayTag
import soup.movie.feature.home.favorite.MovieNewTag
import soup.movie.model.MovieModel
import soup.movie.resources.R

Expand Down Expand Up @@ -114,16 +110,6 @@ internal fun DetailHeader(
modifier = Modifier.padding(top = 4.dp),
)
}
if (movie.isBest()) {
MovieBestTag(
modifier = Modifier.padding(top = 4.dp),
)
}
if (movie.isNew()) {
MovieNewTag(
modifier = Modifier.padding(top = 4.dp),
)
}
}
}
Column(modifier = Modifier.fillMaxWidth().padding(start = 12.dp)) {
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,9 @@ import soup.movie.core.designsystem.icon.MovieIcons
import soup.movie.core.designsystem.theme.MovieTheme
import soup.movie.core.imageloading.AsyncImage
import soup.movie.domain.movie.getDDayLabel
import soup.movie.domain.movie.isBest
import soup.movie.domain.movie.isDDay
import soup.movie.domain.movie.isNew
import soup.movie.feature.home.favorite.MovieAgeBadge
import soup.movie.feature.home.favorite.MovieBestTag
import soup.movie.feature.home.favorite.MovieDDayTag
import soup.movie.feature.home.favorite.MovieNewTag
import soup.movie.model.MovieModel
import soup.movie.resources.R

Expand Down Expand Up @@ -114,23 +110,13 @@ private fun MovieItem(
.padding(7.dp)
.align(Alignment.BottomStart),
)
when {
movie.isDDay() -> MovieDDayTag(
if (movie.isDDay()) {
MovieDDayTag(
text = movie.getDDayLabel().orEmpty(),
modifier = Modifier
.padding(4.dp)
.align(Alignment.BottomEnd),
)
movie.isBest() -> MovieBestTag(
modifier = Modifier
.padding(4.dp)
.align(Alignment.BottomEnd),
)
movie.isNew() -> MovieNewTag(
modifier = Modifier
.padding(4.dp)
.align(Alignment.BottomEnd),
)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
package soup.movie.feature.tasks.impl

import soup.movie.data.repository.MovieRepository
import soup.movie.domain.movie.isBest
import soup.movie.feature.notification.NotificationBuilder
import soup.movie.model.MovieModel
import javax.inject.Inject
Expand Down Expand Up @@ -44,8 +43,7 @@ class RecommendMoviesUseCaseImpl @Inject constructor(
cgv != null && lotte != null && megabox != null
}
}
.filterIndexed { index, movie -> index < 3 || movie.isBest() }
.take(6)
.take(3)
.toList()
}
}

0 comments on commit ff90578

Please sign in to comment.