Make text clickable when removing item from tracker

This commit is contained in:
arkon 2023-10-18 22:50:09 -04:00
parent 1302461518
commit 8626a55fe4
2 changed files with 14 additions and 6 deletions

View file

@ -1,5 +1,6 @@
package eu.kanade.tachiyomi.data.track.shikimori package eu.kanade.tachiyomi.data.track.shikimori
import android.net.Uri
import androidx.core.net.toUri import androidx.core.net.toUri
import eu.kanade.tachiyomi.data.database.models.Track import eu.kanade.tachiyomi.data.database.models.Track
import eu.kanade.tachiyomi.data.track.model.TrackSearch import eu.kanade.tachiyomi.data.track.model.TrackSearch
@ -37,12 +38,12 @@ class ShikimoriApi(
private val authClient = client.newBuilder().addInterceptor(interceptor).build() private val authClient = client.newBuilder().addInterceptor(interceptor).build()
suspend fun addLibManga(track: Track, user_id: String): Track { suspend fun addLibManga(track: Track, userId: String): Track {
return withIOContext { return withIOContext {
with(json) { with(json) {
val payload = buildJsonObject { val payload = buildJsonObject {
putJsonObject("user_rate") { putJsonObject("user_rate") {
put("user_id", user_id) put("user_id", userId)
put("target_id", track.media_id) put("target_id", track.media_id)
put("target_type", "Manga") put("target_type", "Manga")
put("chapters", track.last_chapter_read.toInt()) put("chapters", track.last_chapter_read.toInt())
@ -65,7 +66,7 @@ class ShikimoriApi(
} }
} }
suspend fun updateLibManga(track: Track, user_id: String): Track = addLibManga(track, user_id) suspend fun updateLibManga(track: Track, userId: String): Track = addLibManga(track, userId)
suspend fun deleteLibManga(track: Track): Track { suspend fun deleteLibManga(track: Track): Track {
return withIOContext { return withIOContext {
@ -201,7 +202,7 @@ class ShikimoriApi(
private const val redirectUrl = "tachiyomi://shikimori-auth" private const val redirectUrl = "tachiyomi://shikimori-auth"
fun authUrl() = loginUrl.toUri().buildUpon() fun authUrl(): Uri = loginUrl.toUri().buildUpon()
.appendQueryParameter("client_id", clientId) .appendQueryParameter("client_id", clientId)
.appendQueryParameter("redirect_uri", redirectUrl) .appendQueryParameter("redirect_uri", redirectUrl)
.appendQueryParameter("response_type", "code") .appendQueryParameter("response_type", "code")

View file

@ -2,6 +2,7 @@ package eu.kanade.tachiyomi.ui.manga.track
import android.app.Application import android.app.Application
import android.content.Context import android.content.Context
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Row
@ -759,8 +760,14 @@ private data class TrackerRemoveScreen(
text = stringResource(R.string.track_delete_text, serviceName), text = stringResource(R.string.track_delete_text, serviceName),
) )
if (sm.isDeletable()) { if (sm.isDeletable()) {
Row(verticalAlignment = Alignment.CenterVertically) { val onChange = { removeRemoteTrack = !removeRemoteTrack }
Checkbox(checked = removeRemoteTrack, onCheckedChange = { removeRemoteTrack = it }) Row(
modifier = Modifier
.fillMaxWidth()
.clickable(onClick = onChange),
verticalAlignment = Alignment.CenterVertically,
) {
Checkbox(checked = removeRemoteTrack, onCheckedChange = { onChange() })
Text(text = stringResource(R.string.track_delete_remote_text, serviceName)) Text(text = stringResource(R.string.track_delete_remote_text, serviceName))
} }
} }