-
Notifications
You must be signed in to change notification settings - Fork 198
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' into single-tap-infrared
- Loading branch information
Showing
110 changed files
with
3,566 additions
and
1,300 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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
plugins { | ||
id("flipper.multiplatform") | ||
id("flipper.multiplatform-dependencies") | ||
} | ||
|
||
android.namespace = "com.flipperdevices.filemanager.create.api" | ||
|
||
commonDependencies { | ||
implementation(projects.components.bridge.connection.feature.storage.api) | ||
|
||
implementation(projects.components.core.ui.decompose) | ||
|
||
implementation(libs.compose.ui) | ||
implementation(libs.decompose) | ||
|
||
implementation(libs.okio) | ||
} |
31 changes: 31 additions & 0 deletions
31
...mmonMain/kotlin/com/flipperdevices/filemanager/create/api/CreateFileDecomposeComponent.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,31 @@ | ||
package com.flipperdevices.filemanager.create.api | ||
|
||
import com.arkivanov.decompose.ComponentContext | ||
import com.flipperdevices.bridge.connection.feature.storage.api.model.FileType | ||
import com.flipperdevices.bridge.connection.feature.storage.api.model.ListingItem | ||
import com.flipperdevices.ui.decompose.ScreenDecomposeComponent | ||
import kotlinx.coroutines.flow.StateFlow | ||
import okio.Path | ||
|
||
abstract class CreateFileDecomposeComponent( | ||
componentContext: ComponentContext | ||
) : ScreenDecomposeComponent(componentContext) { | ||
abstract val canCreateFiles: StateFlow<Boolean> | ||
|
||
abstract fun startCreateFile(parent: Path) | ||
|
||
abstract fun startCreateFolder(parent: Path) | ||
|
||
abstract fun startCreate(parent: Path, type: FileType) | ||
|
||
fun interface Factory { | ||
operator fun invoke( | ||
componentContext: ComponentContext, | ||
createCallback: CreatedCallback, | ||
): CreateFileDecomposeComponent | ||
} | ||
|
||
fun interface CreatedCallback { | ||
fun invoke(item: ListingItem) | ||
} | ||
} |
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,52 @@ | ||
plugins { | ||
id("flipper.multiplatform-compose") | ||
id("flipper.multiplatform-dependencies") | ||
id("flipper.anvil-multiplatform") | ||
id("kotlinx-serialization") | ||
} | ||
android.namespace = "com.flipperdevices.filemanager.create.impl" | ||
|
||
commonDependencies { | ||
implementation(projects.components.core.di) | ||
implementation(projects.components.core.ktx) | ||
implementation(projects.components.core.log) | ||
implementation(projects.components.core.preference) | ||
|
||
implementation(projects.components.core.ui.lifecycle) | ||
implementation(projects.components.core.ui.theme) | ||
implementation(projects.components.core.ui.decompose) | ||
implementation(projects.components.core.ui.ktx) | ||
implementation(projects.components.core.ui.res) | ||
implementation(projects.components.core.ui.dialog) | ||
|
||
implementation(projects.components.bridge.connection.feature.common.api) | ||
implementation(projects.components.bridge.connection.transport.common.api) | ||
implementation(projects.components.bridge.connection.feature.provider.api) | ||
implementation(projects.components.bridge.connection.feature.storage.api) | ||
implementation(projects.components.bridge.connection.feature.storageinfo.api) | ||
implementation(projects.components.bridge.connection.feature.serialspeed.api) | ||
implementation(projects.components.bridge.connection.feature.rpcinfo.api) | ||
implementation(projects.components.bridge.dao.api) | ||
|
||
implementation(projects.components.filemngr.util) | ||
implementation(projects.components.filemngr.uiComponents) | ||
implementation(projects.components.filemngr.create.api) | ||
|
||
// Compose | ||
implementation(libs.compose.ui) | ||
implementation(libs.compose.tooling) | ||
implementation(libs.compose.foundation) | ||
implementation(libs.compose.material) | ||
|
||
implementation(libs.kotlin.serialization.json) | ||
implementation(libs.ktor.client) | ||
|
||
implementation(libs.decompose) | ||
implementation(libs.kotlin.coroutines) | ||
implementation(libs.essenty.lifecycle) | ||
implementation(libs.essenty.lifecycle.coroutines) | ||
|
||
implementation(libs.bundles.decompose) | ||
implementation(libs.okio) | ||
implementation(libs.kotlin.immutable.collections) | ||
} |
7 changes: 7 additions & 0 deletions
7
components/filemngr/create/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,7 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<string name="fmc_create_file_title">Enter Name:</string> | ||
<string name="fml_create_file_btn">Create File</string> | ||
<string name="fml_create_folder_btn">Create Folder</string> | ||
<string name="fmc_create_file_allowed_chars">Allowed characters: %1$s</string> | ||
</resources> |
93 changes: 93 additions & 0 deletions
93
...kotlin/com/flipperdevices/filemanager/create/impl/api/CreateFileDecomposeComponentImpl.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,93 @@ | ||
package com.flipperdevices.filemanager.create.impl.api | ||
|
||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.LaunchedEffect | ||
import androidx.compose.runtime.collectAsState | ||
import androidx.compose.runtime.getValue | ||
import com.arkivanov.decompose.ComponentContext | ||
import com.arkivanov.essenty.instancekeeper.getOrCreate | ||
import com.flipperdevices.bridge.connection.feature.storage.api.model.FileType | ||
import com.flipperdevices.core.di.AppGraph | ||
import com.flipperdevices.filemanager.create.api.CreateFileDecomposeComponent | ||
import com.flipperdevices.filemanager.create.impl.viewmodel.CreateFileViewModel | ||
import com.flipperdevices.filemanager.ui.components.name.NameDialog | ||
import com.flipperdevices.filemanager.util.constant.FileManagerConstants | ||
import dagger.assisted.Assisted | ||
import dagger.assisted.AssistedInject | ||
import flipperapp.components.filemngr.create.impl.generated.resources.fmc_create_file_allowed_chars | ||
import flipperapp.components.filemngr.create.impl.generated.resources.fmc_create_file_title | ||
import flipperapp.components.filemngr.create.impl.generated.resources.fml_create_file_btn | ||
import flipperapp.components.filemngr.create.impl.generated.resources.fml_create_folder_btn | ||
import kotlinx.coroutines.flow.launchIn | ||
import kotlinx.coroutines.flow.onEach | ||
import me.gulya.anvil.assisted.ContributesAssistedFactory | ||
import okio.Path | ||
import org.jetbrains.compose.resources.stringResource | ||
import javax.inject.Provider | ||
import flipperapp.components.filemngr.create.impl.generated.resources.Res as FMC | ||
|
||
@ContributesAssistedFactory(AppGraph::class, CreateFileDecomposeComponent.Factory::class) | ||
class CreateFileDecomposeComponentImpl @AssistedInject constructor( | ||
@Assisted componentContext: ComponentContext, | ||
@Assisted val createdCallback: CreatedCallback, | ||
renameViewModelProvider: Provider<CreateFileViewModel> | ||
) : CreateFileDecomposeComponent(componentContext) { | ||
private val createFileViewModel = instanceKeeper.getOrCreate { | ||
renameViewModelProvider.get() | ||
} | ||
|
||
override val canCreateFiles = createFileViewModel.canCreateFiles | ||
|
||
override fun startCreateFile(parent: Path) { | ||
createFileViewModel.startCreateFile(parent) | ||
} | ||
|
||
override fun startCreateFolder(parent: Path) { | ||
createFileViewModel.startCreateFolder(parent) | ||
} | ||
|
||
override fun startCreate(parent: Path, type: FileType) { | ||
createFileViewModel.startCreate(parent, type) | ||
} | ||
|
||
@Composable | ||
override fun Render() { | ||
val state by createFileViewModel.state.collectAsState() | ||
LaunchedEffect(createFileViewModel) { | ||
createFileViewModel.event | ||
.onEach { event -> | ||
when (event) { | ||
is CreateFileViewModel.Event.Created -> { | ||
createdCallback.invoke(event.item) | ||
} | ||
} | ||
}.launchIn(this) | ||
} | ||
when (val localState = state) { | ||
CreateFileViewModel.State.Pending -> Unit | ||
is CreateFileViewModel.State.Creating -> { | ||
NameDialog( | ||
value = localState.name, | ||
title = stringResource(FMC.string.fmc_create_file_title), | ||
buttonText = when (localState.type) { | ||
FileType.FILE -> stringResource(FMC.string.fml_create_file_btn) | ||
FileType.DIR -> stringResource(FMC.string.fml_create_folder_btn) | ||
}, | ||
subtitle = stringResource( | ||
FMC.string.fmc_create_file_allowed_chars, | ||
FileManagerConstants.FILE_NAME_AVAILABLE_CHARACTERS | ||
), | ||
onFinish = createFileViewModel::onConfirm, | ||
isError = !localState.isValid, | ||
isEnabled = !localState.isCreating, | ||
needShowOptions = localState.needShowOptions, | ||
onTextChange = createFileViewModel::onNameChange, | ||
onDismissRequest = createFileViewModel::dismiss, | ||
onOptionSelect = createFileViewModel::onOptionSelected, | ||
options = localState.options, | ||
isLoading = localState.isCreating | ||
) | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.