mirror of
https://github.com/owenlejeune/TVTime.git
synced 2025-11-14 07:42:43 -05:00
delete list item on swipe
This commit is contained in:
@@ -31,7 +31,7 @@ interface ListV4Api {
|
||||
@PUT("list/{id}/items")
|
||||
suspend fun updateListItems(@Path("id") listId: Int, @Body body: UpdateListItemBody): Response<AddToListResponse>
|
||||
|
||||
@HTTP(method = "DELETE", path = "/list/{id}/items", hasBody = true)
|
||||
@HTTP(method = "DELETE", path = "list/{id}/items", hasBody = true)
|
||||
suspend fun deleteListItems(@Path("id") listId: Int, @Body body: DeleteListItemsBody): Response<AddToListResponse>
|
||||
|
||||
@GET("list/{id}/item_status")
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.owenlejeune.tvtime.di.modules
|
||||
|
||||
import com.google.gson.Gson
|
||||
import com.google.gson.GsonBuilder
|
||||
import com.google.gson.JsonDeserializer
|
||||
import com.owenlejeune.tvtime.BuildConfig
|
||||
|
||||
@@ -256,6 +256,7 @@ private fun ListItemView(
|
||||
listItem: ListItem,
|
||||
list: MutableState<MediaList?>
|
||||
) {
|
||||
val context = LocalContext.current
|
||||
RevealSwipe (
|
||||
directions = setOf(RevealDirection.EndToStart),
|
||||
hiddenContentEnd = {
|
||||
@@ -263,8 +264,10 @@ private fun ListItemView(
|
||||
modifier = Modifier.padding(horizontal = 15.dp),
|
||||
onClick = {
|
||||
removeItemFromList(
|
||||
context = context,
|
||||
itemId = listItem.id,
|
||||
itemType = listItem.mediaType,
|
||||
itemName = listItem.title,
|
||||
service = ListV4Service(),
|
||||
list = list
|
||||
)
|
||||
@@ -506,6 +509,8 @@ private fun fetchList(
|
||||
}
|
||||
|
||||
private fun removeItemFromList(
|
||||
context: Context,
|
||||
itemName: String,
|
||||
itemId: Int,
|
||||
itemType: MediaViewType,
|
||||
service: ListV4Service,
|
||||
@@ -522,8 +527,10 @@ private fun removeItemFromList(
|
||||
list.value = it
|
||||
}
|
||||
}
|
||||
Toast.makeText(context, "Successfully removed $itemName", Toast.LENGTH_SHORT).show()
|
||||
} else {
|
||||
Log.w("RemoveListItemError", result.toString())
|
||||
Toast.makeText(context, "An error occurred!", Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import androidx.compose.material.MaterialTheme
|
||||
import androidx.compose.material3.darkColorScheme
|
||||
import androidx.compose.material3.lightColorScheme
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.graphics.compositeOver
|
||||
import com.google.accompanist.systemuicontroller.rememberSystemUiController
|
||||
import com.kieronquinn.monetcompat.core.MonetCompat
|
||||
import com.owenlejeune.tvtime.preferences.AppPreferences
|
||||
@@ -113,7 +114,14 @@ fun TVTimeTheme(
|
||||
shapes = Shapes,
|
||||
content = {
|
||||
val systemUiController = rememberSystemUiController()
|
||||
systemUiController.setSystemBarsColor(color = androidx.compose.material3.MaterialTheme.colorScheme.background)
|
||||
systemUiController.setStatusBarColor(color = androidx.compose.material3.MaterialTheme.colorScheme.background)
|
||||
systemUiController.setNavigationBarColor(
|
||||
color = androidx.compose.material3.MaterialTheme.colorScheme.primary.copy(
|
||||
alpha = 0.08f
|
||||
).compositeOver(
|
||||
background = androidx.compose.material3.MaterialTheme.colorScheme.surface
|
||||
)
|
||||
)
|
||||
|
||||
content()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user