diff --git a/core/ui/src/main/res/values/strings.xml b/core/ui/src/main/res/values/strings.xml index c2b05705f..92b80b211 100644 --- a/core/ui/src/main/res/values/strings.xml +++ b/core/ui/src/main/res/values/strings.xml @@ -138,6 +138,7 @@ %1$s seconds Share Delete - Delete the following file + The following file will be deleted permanently Subtitle text encoding + All video files in the following folder will be deleted permanently. \ No newline at end of file diff --git a/feature/videopicker/src/main/java/dev/anilbeesetti/nextplayer/feature/videopicker/composables/FolderItem.kt b/feature/videopicker/src/main/java/dev/anilbeesetti/nextplayer/feature/videopicker/composables/FolderItem.kt index 35880d459..bc4a00c0b 100644 --- a/feature/videopicker/src/main/java/dev/anilbeesetti/nextplayer/feature/videopicker/composables/FolderItem.kt +++ b/feature/videopicker/src/main/java/dev/anilbeesetti/nextplayer/feature/videopicker/composables/FolderItem.kt @@ -1,7 +1,5 @@ package dev.anilbeesetti.nextplayer.feature.videopicker.composables -import androidx.compose.foundation.ExperimentalFoundationApi -import androidx.compose.foundation.combinedClickable import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.ExperimentalLayoutApi import androidx.compose.foundation.layout.FlowRow @@ -28,13 +26,11 @@ import dev.anilbeesetti.nextplayer.core.ui.designsystem.NextIcons import dev.anilbeesetti.nextplayer.core.ui.preview.DayNightPreview import dev.anilbeesetti.nextplayer.core.ui.theme.NextPlayerTheme -@OptIn(ExperimentalFoundationApi::class, ExperimentalLayoutApi::class) +@OptIn(ExperimentalLayoutApi::class) @Composable fun FolderItem( directory: Directory, - modifier: Modifier = Modifier, - onClick: () -> Unit, - onLongClick: () -> Unit + modifier: Modifier = Modifier ) { ListItem( leadingContent = { @@ -84,10 +80,7 @@ fun FolderItem( ) } }, - modifier = modifier.combinedClickable( - onClick = onClick, - onLongClick = onLongClick - ) + modifier = modifier ) } @@ -95,11 +88,7 @@ fun FolderItem( @Composable fun FolderItemPreview() { NextPlayerTheme { - FolderItem( - directory = Directory.sample, - onClick = { }, - onLongClick = { } - ) + FolderItem(directory = Directory.sample) } } diff --git a/feature/videopicker/src/main/java/dev/anilbeesetti/nextplayer/feature/videopicker/composables/MediaContent.kt b/feature/videopicker/src/main/java/dev/anilbeesetti/nextplayer/feature/videopicker/composables/MediaContent.kt index c8006ee89..6480c0dc1 100644 --- a/feature/videopicker/src/main/java/dev/anilbeesetti/nextplayer/feature/videopicker/composables/MediaContent.kt +++ b/feature/videopicker/src/main/java/dev/anilbeesetti/nextplayer/feature/videopicker/composables/MediaContent.kt @@ -2,7 +2,9 @@ package dev.anilbeesetti.nextplayer.feature.videopicker.composables import android.content.Intent import android.net.Uri +import androidx.compose.foundation.ExperimentalFoundationApi import androidx.compose.foundation.clickable +import androidx.compose.foundation.combinedClickable import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.ColumnScope import androidx.compose.foundation.layout.PaddingValues @@ -39,6 +41,7 @@ import androidx.compose.ui.platform.testTag import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.text.style.TextOverflow +import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import dev.anilbeesetti.nextplayer.core.model.Directory import dev.anilbeesetti.nextplayer.core.model.Video @@ -84,7 +87,7 @@ fun NoVideosFound() { ) } -@OptIn(ExperimentalMaterial3Api::class) +@OptIn(ExperimentalMaterial3Api::class, ExperimentalFoundationApi::class) @Composable fun VideosListFromState( videosState: VideosState, @@ -107,11 +110,13 @@ fun VideosListFromState( items(videosState.data, key = { it.path }) { VideoItem( video = it, - onClick = { onVideoClick(Uri.parse(it.uriString)) }, - onLongClick = { - haptic.performHapticFeedback(HapticFeedbackType.LongPress) - showMediaActionsFor = it - } + modifier = Modifier.combinedClickable( + onClick = { onVideoClick(Uri.parse(it.uriString)) }, + onLongClick = { + haptic.performHapticFeedback(HapticFeedbackType.LongPress) + showMediaActionsFor = it + } + ) ) } } @@ -157,17 +162,18 @@ fun VideosListFromState( deleteAction?.let { DeleteConfirmationDialog( + subText = stringResource(id = R.string.delete_file), onCancel = { deleteAction = null }, onConfirm = { onDeleteVideoClick(it.uriString) deleteAction = null }, - deleteItems = listOf(it.nameWithExtension) + fileNames = listOf(it.nameWithExtension) ) } } -@OptIn(ExperimentalMaterial3Api::class) +@OptIn(ExperimentalMaterial3Api::class, ExperimentalFoundationApi::class) @Composable fun FoldersListFromState( foldersState: FoldersState, @@ -189,11 +195,13 @@ fun FoldersListFromState( items(foldersState.data, key = { it.path }) { FolderItem( directory = it, - onClick = { onFolderClick(it.path) }, - onLongClick = { - haptic.performHapticFeedback(HapticFeedbackType.LongPress) - showDirectoryActionsFor = it - } + modifier = Modifier.combinedClickable( + onClick = { onFolderClick(it.path) }, + onLongClick = { + haptic.performHapticFeedback(HapticFeedbackType.LongPress) + showDirectoryActionsFor = it + } + ) ) } } @@ -220,39 +228,61 @@ fun FoldersListFromState( deleteAction?.let { DeleteConfirmationDialog( + subText = stringResource(R.string.delete_folder), onCancel = { deleteAction = null }, onConfirm = { onDeleteFolderClick(it.path) deleteAction = null }, - deleteItems = listOf(it.name) + fileNames = listOf(it.name) ) } } @Composable fun DeleteConfirmationDialog( + subText: String, onConfirm: () -> Unit, onCancel: () -> Unit, - deleteItems: List + fileNames: List, + modifier: Modifier = Modifier ) { NextDialog( onDismissRequest = onCancel, - title = { Text(text = stringResource(R.string.delete_file), modifier = Modifier.fillMaxWidth()) }, + title = { Text(text = stringResource(R.string.delete), modifier = Modifier.fillMaxWidth()) }, confirmButton = { DoneButton(onClick = onConfirm) }, dismissButton = { CancelButton(onClick = onCancel) }, + modifier = modifier, content = { - deleteItems.map { - Text( - text = it, - maxLines = 1, - overflow = TextOverflow.Ellipsis - ) + Text( + text = subText, + style = MaterialTheme.typography.titleSmall + ) + Spacer(modifier = Modifier.height(20.dp)) + LazyColumn { + items(fileNames) { + Text( + text = it, + overflow = TextOverflow.Ellipsis, + style = MaterialTheme.typography.bodyLarge + ) + } } } ) } +@Preview +@Composable +fun DeleteDialogPreview() { + DeleteConfirmationDialog( + subText = "The following files will be deleted permanently", + onConfirm = { /*TODO*/ }, + onCancel = { /*TODO*/ }, + fileNames = listOf("Harry potter 1", "Harry potter 2", "Harry potter 3", "Harry potter 4") + ) +} + @OptIn(ExperimentalMaterial3Api::class) @Composable fun OptionsBottomSheet( diff --git a/feature/videopicker/src/main/java/dev/anilbeesetti/nextplayer/feature/videopicker/composables/VideoItem.kt b/feature/videopicker/src/main/java/dev/anilbeesetti/nextplayer/feature/videopicker/composables/VideoItem.kt index fd84192f8..5a757caf3 100644 --- a/feature/videopicker/src/main/java/dev/anilbeesetti/nextplayer/feature/videopicker/composables/VideoItem.kt +++ b/feature/videopicker/src/main/java/dev/anilbeesetti/nextplayer/feature/videopicker/composables/VideoItem.kt @@ -1,8 +1,6 @@ package dev.anilbeesetti.nextplayer.feature.videopicker.composables -import androidx.compose.foundation.ExperimentalFoundationApi import androidx.compose.foundation.background -import androidx.compose.foundation.combinedClickable import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.ExperimentalLayoutApi @@ -32,13 +30,11 @@ import dev.anilbeesetti.nextplayer.core.ui.preview.DayNightPreview import dev.anilbeesetti.nextplayer.core.ui.preview.DevicePreviews import dev.anilbeesetti.nextplayer.core.ui.theme.NextPlayerTheme -@OptIn(ExperimentalFoundationApi::class, ExperimentalLayoutApi::class) +@OptIn(ExperimentalLayoutApi::class) @Composable fun VideoItem( video: Video, - modifier: Modifier = Modifier, - onClick: () -> Unit, - onLongClick: () -> Unit + modifier: Modifier = Modifier ) { ListItem( leadingContent = { @@ -103,10 +99,7 @@ fun VideoItem( } } }, - modifier = modifier.combinedClickable( - onClick = onClick, - onLongClick = onLongClick - ) + modifier = modifier ) } @@ -116,11 +109,7 @@ fun VideoItem( fun VideoItemPreview() { NextPlayerTheme { Surface { - VideoItem( - video = Video.sample, - onClick = {}, - onLongClick = {} - ) + VideoItem(video = Video.sample) } } }