-
Notifications
You must be signed in to change notification settings - Fork 211
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2e05301
commit 50ef64b
Showing
14 changed files
with
582 additions
and
141 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
components/filemngr/transfer/impl/src/commonMain/composeResources/values/strings.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<string name="fmt_otp_create_folder">Create Folder</string> | ||
<string name="fmt_otp_display_list">List</string> | ||
<string name="fmt_otp_display_grid">Grid</string> | ||
<string name="fmt_otp_sort_default">Sort by Default</string> | ||
<string name="fmt_otp_sort_size">Sort by Size</string> | ||
<string name="fmt_otp_show_hidden">Show Hidden Files</string> | ||
|
||
<string name="fmt_items_in_folder">%1$s items</string> | ||
|
||
<string name="fmt_appbar_title_moving">Moving</string> | ||
<string name="fmt_move_button">Move Here</string> | ||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
121 changes: 121 additions & 0 deletions
121
...otlin/com/flipperdevices/filemanager/transfer/impl/composable/ComposableTransferScreen.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
package com.flipperdevices.filemanager.transfer.impl.composable | ||
|
||
import androidx.compose.foundation.background | ||
import androidx.compose.foundation.layout.Arrangement | ||
import androidx.compose.foundation.layout.Box | ||
import androidx.compose.foundation.layout.PaddingValues | ||
import androidx.compose.foundation.layout.fillMaxSize | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.foundation.layout.height | ||
import androidx.compose.foundation.lazy.grid.GridCells | ||
import androidx.compose.foundation.lazy.grid.GridItemSpan | ||
import androidx.compose.foundation.lazy.grid.LazyVerticalGrid | ||
import androidx.compose.foundation.lazy.grid.items | ||
import androidx.compose.material.Scaffold | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.graphics.Color | ||
import androidx.compose.ui.unit.dp | ||
import com.flipperdevices.core.preference.pb.FileManagerOrientation | ||
import com.flipperdevices.filemanager.transfer.api.TransferDecomposeComponent.Param | ||
import com.flipperdevices.filemanager.transfer.impl.viewmodel.FilesViewModel | ||
import com.flipperdevices.filemanager.transfer.impl.viewmodel.OptionsViewModel | ||
import com.flipperdevices.filemanager.ui.components.itemcard.FolderCardPlaceholderComposable | ||
import okio.Path | ||
|
||
@Suppress("LongMethod") | ||
@Composable | ||
fun ComposableTransferScreen( | ||
optionsState: OptionsViewModel.State, | ||
state: FilesViewModel.State, | ||
isMoving: Boolean, | ||
canMoveHere: Boolean, | ||
param: Param, | ||
onBack: () -> Unit, | ||
onOptionsAction: (OptionsViewModel.Action) -> Unit, | ||
onCreateFolder: () -> Unit, | ||
onPathChange: (Path) -> Unit, | ||
onMoveStart: () -> Unit, | ||
modifier: Modifier = Modifier | ||
) { | ||
Scaffold( | ||
modifier = modifier.fillMaxSize(), | ||
topBar = { | ||
TransferAppBar( | ||
transferType = param.transferType, | ||
onBack = onBack, | ||
optionsState = optionsState, | ||
onOptionsAction = onOptionsAction, | ||
onCreateFolder = onCreateFolder | ||
) | ||
} | ||
) { contentPaddings -> | ||
LazyVerticalGrid( | ||
modifier = Modifier.fillMaxSize(), | ||
verticalArrangement = Arrangement.spacedBy(8.dp), | ||
horizontalArrangement = Arrangement.spacedBy(4.dp), | ||
contentPadding = PaddingValues(14.dp), | ||
columns = when (optionsState.orientation) { | ||
FileManagerOrientation.GRID -> GridCells.Fixed(2) | ||
is FileManagerOrientation.Unrecognized, | ||
FileManagerOrientation.LIST -> GridCells.Fixed(1) | ||
} | ||
) { | ||
item(span = { GridItemSpan(maxLineSpan) }) { | ||
TransferPathComposable( | ||
isMoving = isMoving, | ||
path = param.path, | ||
onPathChange = onPathChange | ||
) | ||
} | ||
|
||
when (val localState = state) { | ||
FilesViewModel.State.CouldNotListPath -> { | ||
item( | ||
span = { GridItemSpan(maxLineSpan) }, | ||
content = { Box(Modifier.fillMaxSize().background(Color.Red)) } | ||
) | ||
} | ||
|
||
is FilesViewModel.State.Loaded -> { | ||
items(localState.files) { item -> | ||
TransferFolderCardListComposable( | ||
modifier = Modifier.animateItem(), | ||
fullDirPath = param.path, | ||
item = item, | ||
onPathChange = onPathChange, | ||
isMoving = isMoving | ||
) | ||
} | ||
item( | ||
span = { GridItemSpan(maxLineSpan) }, | ||
content = { Box(Modifier.height(32.dp)) } | ||
) | ||
} | ||
|
||
FilesViewModel.State.Loading -> { | ||
items(count = 6) { | ||
FolderCardPlaceholderComposable( | ||
modifier = Modifier | ||
.fillMaxWidth() | ||
.animateItem(), | ||
orientation = optionsState.orientation, | ||
) | ||
} | ||
} | ||
|
||
FilesViewModel.State.Unsupported -> { | ||
item( | ||
span = { GridItemSpan(maxLineSpan) }, | ||
content = { UnsupportedComposable() } | ||
) | ||
} | ||
} | ||
} | ||
FullScreenMoveButtonComposable( | ||
isLoading = isMoving, | ||
isEnabled = !isMoving && canMoveHere, | ||
onClick = onMoveStart | ||
) | ||
} | ||
} |
Oops, something went wrong.