Skip to content

Commit

Permalink
prepare edit dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
DatL4g committed May 14, 2024
1 parent 1a6cd85 commit 1d2ab6f
Show file tree
Hide file tree
Showing 16 changed files with 596 additions and 73 deletions.
16 changes: 14 additions & 2 deletions anilist/src/commonMain/graphql/AiringQuery.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,14 @@ query AiringQuery(
},
mediaListEntry {
score(format: POINT_5),
status
status,
progress,
repeat,
startedAt {
year,
month,
day
}
},
trailer {
id,
Expand All @@ -89,7 +96,12 @@ query AiringQuery(
},
siteUrl,
chapters,
volumes
volumes,
startDate {
year,
month,
day
}
}
}
}
Expand Down
6 changes: 0 additions & 6 deletions anilist/src/commonMain/graphql/MediaListEntryQuery.graphql

This file was deleted.

16 changes: 14 additions & 2 deletions anilist/src/commonMain/graphql/MediumQuery.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,14 @@ query MediumQuery($id: Int, $statusVersion: Int, $html: Boolean) {
},
mediaListEntry {
score(format: POINT_5),
status
status,
progress,
repeat,
startedAt {
year,
month,
day
}
},
trailer {
id,
Expand All @@ -78,6 +85,11 @@ query MediumQuery($id: Int, $statusVersion: Int, $html: Boolean) {
},
siteUrl,
chapters,
volumes
volumes,
startDate {
year,
month,
day
}
}
}
16 changes: 14 additions & 2 deletions anilist/src/commonMain/graphql/SeasonQuery.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,14 @@ query SeasonQuery(
},
mediaListEntry {
score(format: POINT_5),
status
status,
progress,
repeat,
startedAt {
year,
month,
day
}
},
trailer {
id,
Expand All @@ -90,7 +97,12 @@ query SeasonQuery(
},
siteUrl,
chapters,
volumes
volumes,
startDate {
year,
month,
day
}
}
}
}
16 changes: 14 additions & 2 deletions anilist/src/commonMain/graphql/TrendingQuery.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,14 @@ query TrendingQuery(
},
mediaListEntry {
score(format: POINT_5),
status
status,
progress,
repeat,
startedAt {
year,
month,
day
}
},
trailer {
id,
Expand All @@ -93,7 +100,12 @@ query TrendingQuery(
},
siteUrl,
chapters,
volumes
volumes,
startDate {
year,
month,
day
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package dev.datlag.aniflow.anilist.common

import dev.datlag.aniflow.anilist.AiringQuery
import dev.datlag.aniflow.anilist.MediumQuery
import dev.datlag.aniflow.anilist.SeasonQuery
import dev.datlag.aniflow.anilist.TrendingQuery
import dev.datlag.aniflow.anilist.type.FuzzyDate
import dev.datlag.aniflow.anilist.type.MediaSeason
import kotlinx.datetime.Instant
import kotlinx.datetime.Month
import kotlinx.datetime.TimeZone
import kotlinx.datetime.toLocalDateTime
import kotlinx.datetime.*

internal val Month.season: MediaSeason
get() {
Expand All @@ -27,4 +29,68 @@ internal val Instant.nextSeason: Pair<MediaSeason, Int>
get() {
val date = this.toLocalDateTime(TimeZone.currentSystemDefault())
return date.month.season.next(date.date)
}
}

internal fun TrendingQuery.StartDate.toLocalDate(): LocalDate? {
return LocalDate(
year = year ?: return null,
monthNumber = month ?: return null,
dayOfMonth = day ?: 1
)
}

internal fun AiringQuery.StartDate.toLocalDate(): LocalDate? {
return LocalDate(
year = year ?: return null,
monthNumber = month ?: return null,
dayOfMonth = day ?: 1
)
}

internal fun SeasonQuery.StartDate.toLocalDate(): LocalDate? {
return LocalDate(
year = year ?: return null,
monthNumber = month ?: return null,
dayOfMonth = day ?: 1
)
}

internal fun MediumQuery.StartDate.toLocalDate(): LocalDate? {
return LocalDate(
year = year ?: return null,
monthNumber = month ?: return null,
dayOfMonth = day ?: 1
)
}

internal fun AiringQuery.StartedAt.toLocalDate(): LocalDate? {
return LocalDate(
year = year ?: return null,
monthNumber = month ?: return null,
dayOfMonth = day ?: 1
)
}

internal fun TrendingQuery.StartedAt.toLocalDate(): LocalDate? {
return LocalDate(
year = year ?: return null,
monthNumber = month ?: return null,
dayOfMonth = day ?: 1
)
}

internal fun MediumQuery.StartedAt.toLocalDate(): LocalDate? {
return LocalDate(
year = year ?: return null,
monthNumber = month ?: return null,
dayOfMonth = day ?: 1
)
}

internal fun SeasonQuery.StartedAt.toLocalDate(): LocalDate? {
return LocalDate(
year = year ?: return null,
monthNumber = month ?: return null,
dayOfMonth = day ?: 1
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ package dev.datlag.aniflow.anilist.model
import dev.datlag.aniflow.anilist.*
import dev.datlag.aniflow.anilist.AdultContent
import dev.datlag.aniflow.anilist.common.lastMonth
import dev.datlag.aniflow.anilist.common.toLocalDate
import dev.datlag.aniflow.anilist.type.*
import dev.datlag.aniflow.model.ifValue
import dev.datlag.aniflow.model.toInt
import kotlinx.datetime.Clock
import kotlinx.datetime.Instant
import kotlinx.datetime.LocalDate
import kotlinx.datetime.Month
import kotlinx.serialization.Serializable
import kotlinx.serialization.Transient
Expand Down Expand Up @@ -49,6 +51,7 @@ data class Medium(
val siteUrl: String = "$SITE_URL$id",
val chapters: Int = -1,
val volumes: Int = -1,
val startDate: LocalDate? = null
) {
constructor(trending: TrendingQuery.Medium) : this(
id = trending.id,
Expand Down Expand Up @@ -98,7 +101,8 @@ data class Medium(
_isFavoriteBlocked = trending.isFavouriteBlocked,
siteUrl = trending.siteUrl?.ifBlank { null } ?: "$SITE_URL${trending.id}",
chapters = trending.chapters ?: -1,
volumes = trending.volumes ?: -1
volumes = trending.volumes ?: -1,
startDate = trending.startDate?.toLocalDate()
)

constructor(airing: AiringQuery.Media) : this(
Expand Down Expand Up @@ -149,7 +153,8 @@ data class Medium(
_isFavoriteBlocked = airing.isFavouriteBlocked,
siteUrl = airing.siteUrl?.ifBlank { null } ?: "$SITE_URL${airing.id}",
chapters = airing.chapters ?: -1,
volumes = airing.volumes ?: -1
volumes = airing.volumes ?: -1,
startDate = airing.startDate?.toLocalDate()
)

constructor(season: SeasonQuery.Medium) : this(
Expand Down Expand Up @@ -200,7 +205,8 @@ data class Medium(
_isFavoriteBlocked = season.isFavouriteBlocked,
siteUrl = season.siteUrl?.ifBlank { null } ?: "$SITE_URL${season.id}",
chapters = season.chapters ?: -1,
volumes = season.volumes ?: -1
volumes = season.volumes ?: -1,
startDate = season.startDate?.toLocalDate()
)

constructor(query: MediumQuery.Media) : this(
Expand Down Expand Up @@ -251,7 +257,8 @@ data class Medium(
_isFavoriteBlocked = query.isFavouriteBlocked,
siteUrl = query.siteUrl?.ifBlank { null } ?: "$SITE_URL${query.id}",
chapters = query.chapters ?: -1,
volumes = query.volumes ?: -1
volumes = query.volumes ?: -1,
startDate = query.startDate?.toLocalDate()
)

@Transient
Expand Down Expand Up @@ -387,26 +394,41 @@ data class Medium(
@Serializable
data class Entry(
val score: Double?,
val status: MediaListStatus
val status: MediaListStatus,
val progress: Int?,
val repeatCount: Int?,
val startDate: LocalDate?
) {
constructor(entry: MediumQuery.MediaListEntry) : this(
score = entry.score,
status = entry.status ?: MediaListStatus.UNKNOWN__
status = entry.status ?: MediaListStatus.UNKNOWN__,
progress = entry.progress,
repeatCount = entry.repeat,
startDate = entry.startedAt?.toLocalDate()
)

constructor(entry: TrendingQuery.MediaListEntry) : this(
score = entry.score,
status = entry.status ?: MediaListStatus.UNKNOWN__
status = entry.status ?: MediaListStatus.UNKNOWN__,
progress = entry.progress,
repeatCount = entry.repeat,
startDate = entry.startedAt?.toLocalDate()
)

constructor(entry: AiringQuery.MediaListEntry) : this(
score = entry.score,
status = entry.status ?: MediaListStatus.UNKNOWN__
status = entry.status ?: MediaListStatus.UNKNOWN__,
progress = entry.progress,
repeatCount = entry.repeat,
startDate = entry.startedAt?.toLocalDate()
)

constructor(entry: SeasonQuery.MediaListEntry) : this(
score = entry.score,
status = entry.status ?: MediaListStatus.UNKNOWN__
status = entry.status ?: MediaListStatus.UNKNOWN__,
progress = entry.progress,
repeatCount = entry.repeat,
startDate = entry.startedAt?.toLocalDate()
)
}

Expand Down
1 change: 1 addition & 0 deletions composeApp/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ kotlin {

implementation("dev.datlag.sheets-compose-dialogs:rating:2.0.0-SNAPSHOT")
implementation("dev.datlag.sheets-compose-dialogs:option:2.0.0-SNAPSHOT")
implementation("dev.datlag.sheets-compose-dialogs:calendar:2.0.0-SNAPSHOT")

implementation(project(":firebase"))
implementation(project(":anilist"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ fun SearchResponse.Result.AniList.asMedium(): Medium {
}

fun MediaListStatus.icon() = when (this) {
MediaListStatus.CURRENT -> Icons.Rounded.Edit
MediaListStatus.CURRENT -> Icons.Rounded.PlayArrow
MediaListStatus.COMPLETED -> Icons.Rounded.Check
MediaListStatus.PAUSED -> Icons.Rounded.Pause
MediaListStatus.DROPPED -> Icons.Rounded.Close
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ fun DefaultOverview(
titleLanguage = titleLanguage,
modifier = Modifier
.width(200.dp)
.height(280.dp)
.animateItemPlacement(),
.height(280.dp),
onClick = onMediumClick,
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,7 @@ fun ScheduleOverview(
titleLanguage = titleLanguage,
modifier = Modifier
.height(150.dp)
.fillParentMaxWidth(fraction = 0.9F)
.animateItemPlacement(),
.fillParentMaxWidth(fraction = 0.9F),
onClick = onMediumClick
)
}
Expand Down
Loading

0 comments on commit 1d2ab6f

Please sign in to comment.