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