Skip to content

Commit 342d0a2

Browse files
committed
feat: share a folder
1 parent de832b2 commit 342d0a2

File tree

12 files changed

+41
-39
lines changed

12 files changed

+41
-39
lines changed

features/cells/src/main/java/com/wire/android/feature/cells/ui/AllFilesScreen.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,14 @@ fun AllFilesScreen(
6767
menuState = viewModel.menu,
6868
isAllFiles = true,
6969
isSearchResult = viewModel.hasSearchQuery(),
70-
showPublicLinkScreen = { assetId, fileName, linkId ->
70+
showPublicLinkScreen = { assetId, fileName, linkId, isFolder ->
7171
navigator.navigate(
7272
NavigationCommand(
7373
PublicLinkScreenDestination(
7474
assetId = assetId,
7575
fileName = fileName,
76-
publicLinkId = linkId
76+
publicLinkId = linkId,
77+
isFolder = isFolder
7778
)
7879
)
7980
)

features/cells/src/main/java/com/wire/android/feature/cells/ui/CellScreenContent.kt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ internal fun CellScreenContent(
6464
onFolderClick: (CellNodeUi.Folder) -> Unit,
6565
downloadFileState: StateFlow<CellNodeUi.File?>,
6666
menuState: Flow<MenuOptions?>,
67-
showPublicLinkScreen: (String, String, String?) -> Unit,
67+
showPublicLinkScreen: (String, String, String?, Boolean) -> Unit,
6868
isAllFiles: Boolean,
6969
isSearchResult: Boolean = false,
7070
) {
@@ -154,9 +154,10 @@ internal fun CellScreenContent(
154154
is ShowError -> Toast.makeText(context, action.error.message, Toast.LENGTH_SHORT).show()
155155
is ShowDeleteConfirmation -> deleteConfirmation = action.file
156156
is ShowPublicLinkScreen -> showPublicLinkScreen(
157-
action.file.uuid,
158-
action.file.name ?: action.file.uuid,
159-
action.file.publicLinkId
157+
action.cellNode.uuid,
158+
action.cellNode.name ?: action.cellNode.uuid,
159+
action.cellNode.publicLinkId,
160+
action.cellNode is CellNodeUi.Folder
160161
)
161162
is RefreshData -> pagingListItems.refresh()
162163
}

features/cells/src/main/java/com/wire/android/feature/cells/ui/CellViewModel.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -286,10 +286,11 @@ class CellViewModel @Inject constructor(
286286
}
287287
}
288288

289-
@Suppress("UNUSED_PARAMETER")
290289
private fun onMenuFolderAction(folder: CellNodeUi.Folder, action: BottomSheetAction) {
291290
when ((action as BottomSheetAction.Folder).action) {
292-
FolderAction.SHARE -> TODO()
291+
FolderAction.SHARE -> {
292+
sendAction(ShowPublicLinkScreen(folder))
293+
}
293294
FolderAction.MOVE -> TODO()
294295
FolderAction.DOWNLOAD -> TODO()
295296
FolderAction.DELETE -> TODO()
@@ -354,7 +355,7 @@ sealed interface CellViewIntent {
354355
sealed interface CellViewAction
355356
internal data class ShowDeleteConfirmation(val file: CellNodeUi.File) : CellViewAction
356357
internal data class ShowError(val error: CellError) : CellViewAction
357-
internal data class ShowPublicLinkScreen(val file: CellNodeUi.File) : CellViewAction
358+
internal data class ShowPublicLinkScreen(val cellNode: CellNodeUi) : CellViewAction
358359
internal data object RefreshData : CellViewAction
359360

360361
internal enum class CellError(val message: Int) {

features/cells/src/main/java/com/wire/android/feature/cells/ui/ConversationFilesScreen.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,13 +173,14 @@ fun ConversationFilesScreenContent(
173173
)
174174
)
175175
},
176-
showPublicLinkScreen = { assetId, fileName, linkId ->
176+
showPublicLinkScreen = { assetId, fileName, linkId, isFolder ->
177177
navigator.navigate(
178178
NavigationCommand(
179179
PublicLinkScreenDestination(
180180
assetId = assetId,
181181
fileName = fileName,
182-
publicLinkId = linkId
182+
publicLinkId = linkId,
183+
isFolder = isFolder
183184
)
184185
)
185186
)

features/cells/src/main/java/com/wire/android/feature/cells/ui/dialog/FileActionsBottomSheet.kt

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ import androidx.compose.foundation.layout.height
2727
import androidx.compose.foundation.layout.padding
2828
import androidx.compose.material3.Text
2929
import androidx.compose.runtime.Composable
30-
import androidx.compose.runtime.rememberCoroutineScope
3130
import androidx.compose.ui.Alignment
3231
import androidx.compose.ui.Modifier
3332
import androidx.compose.ui.graphics.ColorFilter
@@ -50,7 +49,6 @@ import com.wire.android.ui.common.dimensions
5049
import com.wire.android.ui.common.divider.WireDivider
5150
import com.wire.android.ui.common.typography
5251
import com.wire.android.ui.theme.WireTheme
53-
import kotlinx.coroutines.launch
5452

5553
@Composable
5654
internal fun FileActionsBottomSheet(
@@ -60,8 +58,6 @@ internal fun FileActionsBottomSheet(
6058
sheetState: WireModalSheetState<Unit> = rememberWireModalSheetState<Unit>(WireSheetValue.Expanded(Unit))
6159
) {
6260

63-
val scope = rememberCoroutineScope()
64-
6561
WireModalSheetLayout(
6662
onDismissRequest = {
6763
onDismiss()
@@ -71,11 +67,7 @@ internal fun FileActionsBottomSheet(
7167
SheetContent(
7268
menuOptions = menuOptions,
7369
onAction = { action ->
74-
scope.launch { sheetState.hide() }.invokeOnCompletion {
75-
if (!sheetState.isVisible) {
76-
onAction(action)
77-
}
78-
}
70+
onAction(action)
7971
}
8072
)
8173
}
@@ -165,13 +157,7 @@ private fun PreviewFileActionsBottomSheet() {
165157
localPath = "",
166158
userName = null,
167159
conversationName = null,
168-
modifiedTime = null,
169-
remotePath = null,
170-
contentHash = null,
171-
contentUrl = null,
172-
previewUrl = null,
173-
downloadProgress = null,
174-
publicLinkId = null,
160+
modifiedTime = null
175161
),
176162
actions = listOf(
177163
BottomSheetAction.File(FileAction.SHARE),

features/cells/src/main/java/com/wire/android/feature/cells/ui/dialog/FolderActionsBottomSheet.kt

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ import com.wire.android.ui.common.dimensions
4747
import com.wire.android.ui.common.divider.WireDivider
4848
import com.wire.android.ui.common.typography
4949
import com.wire.android.ui.theme.WireTheme
50-
import kotlinx.coroutines.launch
5150

5251
@Composable
5352
internal fun FolderActionsBottomSheet(
@@ -56,7 +55,6 @@ internal fun FolderActionsBottomSheet(
5655
onDismiss: () -> Unit,
5756
sheetState: WireModalSheetState<Unit> = rememberWireModalSheetState<Unit>(WireSheetValue.Expanded(Unit))
5857
) {
59-
val scope = rememberCoroutineScope()
6058

6159
WireModalSheetLayout(
6260
onDismissRequest = {
@@ -75,11 +73,7 @@ internal fun FolderActionsBottomSheet(
7573
menuOptions.actions.forEach { action ->
7674
MenuItem(
7775
modifier = Modifier.clickable {
78-
scope.launch { sheetState.hide() }.invokeOnCompletion {
79-
if (!sheetState.isVisible) {
80-
onAction(action)
81-
}
82-
}
76+
onAction(action)
8377
},
8478
action = action
8579
)

features/cells/src/main/java/com/wire/android/feature/cells/ui/model/CellNodeUi.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,15 @@ sealed class CellNodeUi {
3131
abstract val userName: String?
3232
abstract val conversationName: String?
3333
abstract val modifiedTime: String?
34+
abstract val publicLinkId: String?
3435

3536
data class Folder(
3637
override val name: String?,
3738
override val uuid: String,
3839
override val userName: String?,
3940
override val conversationName: String?,
4041
override val modifiedTime: String?,
42+
override val publicLinkId: String? = null,
4143
val contents: List<CellNodeUi> // folder can has files and nested folders
4244
) : CellNodeUi()
4345

@@ -47,6 +49,7 @@ sealed class CellNodeUi {
4749
override val userName: String?,
4850
override val conversationName: String?,
4951
override val modifiedTime: String?,
52+
override val publicLinkId: String? = null,
5053
val mimeType: String,
5154
val assetType: AttachmentFileType,
5255
val assetSize: Long?,
@@ -56,7 +59,6 @@ sealed class CellNodeUi {
5659
val contentUrl: String? = null,
5760
val previewUrl: String? = null,
5861
val downloadProgress: Float? = null,
59-
val publicLinkId: String? = null,
6062
) : CellNodeUi()
6163
}
6264

features/cells/src/main/java/com/wire/android/feature/cells/ui/publiclink/PublicLinkNavArgs.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,5 @@ data class PublicLinkNavArgs(
2121
val assetId: String,
2222
val fileName: String,
2323
val publicLinkId: String?,
24+
val isFolder: Boolean,
2425
)

features/cells/src/main/java/com/wire/android/feature/cells/ui/publiclink/PublicLinkScreen.kt

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,11 @@ fun PublicLinkScreen(
8484
topBar = {
8585
WireCenterAlignedTopAppBar(
8686
onNavigationPressed = { resultNavigator.navigateBack() },
87-
title = stringResource(R.string.share_file_via_link),
87+
title = if (viewModel.isFolder()) {
88+
stringResource(R.string.share_folder_via_link)
89+
} else {
90+
stringResource(R.string.share_file_via_link)
91+
},
8892
navigationIconType = NavigationIconType.Close(),
8993
elevation = dimensions().spacing0x
9094
)
@@ -95,6 +99,7 @@ fun PublicLinkScreen(
9599
) {
96100
EnableLinkSection(
97101
checked = state.enabled,
102+
isFolder = viewModel.isFolder(),
98103
onCheckChange = {
99104
viewModel.onEnabled(it)
100105
}
@@ -144,6 +149,7 @@ fun PublicLinkScreen(
144149
@Composable
145150
private fun EnableLinkSection(
146151
checked: Boolean,
152+
isFolder: Boolean,
147153
onCheckChange: (Boolean) -> Unit
148154
) {
149155
Column(
@@ -174,7 +180,11 @@ private fun EnableLinkSection(
174180
modifier = Modifier.height(dimensions().spacing16x)
175181
)
176182
Text(
177-
text = stringResource(R.string.public_link_message),
183+
text = if (isFolder) {
184+
stringResource(R.string.public_link_message_folder)
185+
} else {
186+
stringResource(R.string.public_link_message_file)
187+
},
178188
style = typography().body01
179189
)
180190
}
@@ -238,6 +248,7 @@ private fun PreviewCreatePublicLinkScreen() {
238248
Column {
239249
EnableLinkSection(
240250
checked = true,
251+
isFolder = false,
241252
onCheckChange = {}
242253
)
243254
PublicLinkSection(

features/cells/src/main/java/com/wire/android/feature/cells/ui/publiclink/PublicLinkViewModel.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ class PublicLinkViewModel @Inject constructor(
7777
}
7878
}
7979

80+
fun isFolder(): Boolean = navArgs.isFolder
81+
8082
fun onEnabled(enabled: Boolean) {
8183
_state.update {
8284
it.copy(

0 commit comments

Comments
 (0)