Skip to content

Commit cc2e33f

Browse files
committed
[design] #62 upload ui
1 parent 92cb9c4 commit cc2e33f

File tree

6 files changed

+228
-103
lines changed

6 files changed

+228
-103
lines changed

feature/upload/src/main/java/com/record/upload/SelectedVideoScreen.kt

+10-2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import androidx.compose.ui.unit.dp
2121
import coil.ImageLoader
2222
import coil.compose.rememberAsyncImagePainter
2323
import coil.decode.VideoFrameDecoder
24+
import com.record.ui.extension.customClickable
2425

2526
@Composable
2627
fun SelectedVideoRoute(
@@ -36,7 +37,10 @@ fun SelectedVideoScreen() {
3637
}
3738

3839
@Composable
39-
fun VideoThumbnail(video: GalleryVideo) {
40+
fun VideoThumbnail(
41+
video: GalleryVideo,
42+
setVideo: (GalleryVideo) -> Unit,
43+
) {
4044
val context = LocalContext.current
4145
val imageLoader = ImageLoader.Builder(context)
4246
.components {
@@ -61,10 +65,14 @@ fun VideoThumbnail(video: GalleryVideo) {
6165
contentScale = ContentScale.Crop,
6266
modifier = Modifier
6367
.fillMaxSize()
64-
.clip(RectangleShape),
68+
.clip(RectangleShape)
69+
.customClickable(
70+
onClick = { setVideo(video) },
71+
),
6572
)
6673
}
6774
}
75+
6876
fun getAllVideos(
6977
loadSize: Int,
7078
currentLocation: String?,

feature/upload/src/main/java/com/record/upload/UploadContract.kt

+4
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,12 @@ package com.record.upload
22

33
import com.record.ui.base.SideEffect
44
import com.record.ui.base.UiState
5+
import kotlinx.collections.immutable.persistentListOf
56

67
data class UploadState(
8+
val contentList: List<String> = persistentListOf(),
9+
val selectedList: List<String> = persistentListOf(),
10+
val video: GalleryVideo? = null,
711
val showShouldShowRationaleDialog: Boolean = false,
812
val isSelectedVideoSheetOpen: Boolean = false,
913
val isSelectedDefinedContentSheetOpen: Boolean = false,

feature/upload/src/main/java/com/record/upload/UploadViewModel.kt

+12
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,18 @@ import javax.inject.Inject
77
@HiltViewModel
88
class UploadViewModel @Inject constructor() :
99
BaseViewModel<UploadState, UploadSideEffect>(UploadState()) {
10+
fun setSelectedList(selectedContent: String) = intent {
11+
val newSelectedList = selectedList.toMutableList()
12+
if (newSelectedList.contains(selectedContent)) {
13+
newSelectedList.remove(selectedContent)
14+
} else {
15+
if (newSelectedList.size < 3) newSelectedList.add(selectedContent)
16+
}
17+
copy(selectedList = newSelectedList)
18+
}
19+
fun setVideo(video: GalleryVideo) = intent {
20+
copy(video = video)
21+
}
1022
fun showShouldShowRationaleDialog() = intent {
1123
copy(showShouldShowRationaleDialog = true)
1224
}

0 commit comments

Comments
 (0)