Skip to content

Commit

Permalink
feat(TransferAdvancedSettings): Add TransferAdvancedOptionsEnum inter…
Browse files Browse the repository at this point in the history
…face
  • Loading branch information
FabianDevel committed Oct 22, 2024
1 parent d1dfa74 commit b007aec
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import com.infomaniak.multiplatform_swisstransfer.common.models.DownloadLimit
import com.infomaniak.swisstransfer.R
import com.infomaniak.swisstransfer.ui.screen.main.settings.components.OptionScaffold
import com.infomaniak.swisstransfer.ui.screen.main.settings.components.SettingOption
import com.infomaniak.swisstransfer.ui.screen.newtransfer.importfiles.TransferAdvancedOptionsEnum
import com.infomaniak.swisstransfer.ui.screen.newtransfer.importfiles.components.TransferAdvancedSettingType
import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme
import com.infomaniak.swisstransfer.ui.utils.PreviewAllWindows

Expand All @@ -47,7 +49,7 @@ enum class DownloadLimitOption(
override val title: @Composable () -> String,
override val imageVector: ImageVector? = null,
override val imageVectorResId: Int? = null,
) : SettingOption {
) : SettingOption, TransferAdvancedOptionsEnum {
TWO_HUNDRED_FIFTY({ DownloadLimit.TWO_HUNDRED_FIFTY.value }),
ONE_HUNDRED({ DownloadLimit.ONE_HUNDRED.value }),
TWENTY({ DownloadLimit.TWENTY.value }),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import com.infomaniak.multiplatform_swisstransfer.common.models.EmailLanguage
import com.infomaniak.swisstransfer.R
import com.infomaniak.swisstransfer.ui.screen.main.settings.components.OptionScaffold
import com.infomaniak.swisstransfer.ui.screen.main.settings.components.SettingOption
import com.infomaniak.swisstransfer.ui.screen.newtransfer.importfiles.TransferAdvancedOptionsEnum
import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme
import com.infomaniak.swisstransfer.ui.utils.PreviewAllWindows

Expand All @@ -48,7 +49,7 @@ enum class EmailLanguageOption(
override val title: @Composable () -> String,
override val imageVector: ImageVector? = null,
override val imageVectorResId: Int? = null,
) : SettingOption {
) : SettingOption, TransferAdvancedOptionsEnum {
ENGLISH({ stringResource(R.string.settingsEmailLanguageValueEnglish) }, imageVectorResId = R.drawable.flag_gb),
FRENCH({ stringResource(R.string.settingsEmailLanguageValueFrench) }, imageVectorResId = R.drawable.flag_fr),
GERMAN({ stringResource(R.string.settingsEmailLanguageValueGerman) }, imageVectorResId = R.drawable.flag_ge),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import com.infomaniak.multiplatform_swisstransfer.common.models.ValidityPeriod
import com.infomaniak.swisstransfer.R
import com.infomaniak.swisstransfer.ui.screen.main.settings.components.OptionScaffold
import com.infomaniak.swisstransfer.ui.screen.main.settings.components.SettingOption
import com.infomaniak.swisstransfer.ui.screen.newtransfer.importfiles.TransferAdvancedOptionsEnum
import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme
import com.infomaniak.swisstransfer.ui.utils.PreviewAllWindows

Expand All @@ -48,7 +49,7 @@ enum class ValidityPeriodOption(
override val title: @Composable () -> String,
override val imageVector: ImageVector? = null,
override val imageVectorResId: Int? = null,
) : SettingOption {
) : SettingOption, TransferAdvancedOptionsEnum {
THIRTY({ getValidityPeriodTitle(ValidityPeriod.THIRTY) }),
FIFTEEN({ getValidityPeriodTitle(ValidityPeriod.FIFTEEN) }),
SEVEN({ getValidityPeriodTitle(ValidityPeriod.SEVEN) }),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import androidx.compose.runtime.*
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.PreviewParameter
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.lifecycle.compose.collectAsStateWithLifecycle
Expand All @@ -46,7 +47,13 @@ fun ImportFilesScreen(
closeActivity: () -> Unit,
) {
val files by newTransferViewModel.files.collectAsStateWithLifecycle()
ImportFilesScreen({ files }, newTransferViewModel::removeFileByUid, newTransferViewModel::addFiles, closeActivity)
ImportFilesScreen(
files = { files },
removeFileByUid = newTransferViewModel::removeFileByUid,
addFiles = newTransferViewModel::addFiles,
closeActivity = closeActivity,
initialShowUploadSourceChoiceBottomSheet = true,
)
}

@Composable
Expand All @@ -55,9 +62,10 @@ private fun ImportFilesScreen(
removeFileByUid: (uid: String) -> Unit,
addFiles: (List<Uri>) -> Unit,
closeActivity: () -> Unit,
initialShowUploadSourceChoiceBottomSheet: Boolean,
) {
val context = LocalContext.current
var showUploadSourceChoiceBottomSheet by rememberSaveable { mutableStateOf(true) }
var showUploadSourceChoiceBottomSheet by rememberSaveable { mutableStateOf(initialShowUploadSourceChoiceBottomSheet) }

val importedFiles = files()
val humanReadableSize = remember(importedFiles) {
Expand Down Expand Up @@ -109,10 +117,25 @@ private fun ImportFilesScreen(
)
}

enum class PasswordTransferOption(override val title: @Composable () -> String) : TransferAdvancedOptionsEnum {
NONE({ stringResource(R.string.settingsOptionNone) }),
ACTIVATED({ stringResource(R.string.settingsOptionActivated) }),
}

interface TransferAdvancedOptionsEnum {
val title: @Composable () -> String
}

@PreviewAllWindows
@Composable
private fun ImportFilesScreenPreview(@PreviewParameter(FileUiListPreviewParameter::class) files: List<FileUi>) {
SwissTransferTheme {
ImportFilesScreen({ files }, {}, {}, closeActivity = {})
ImportFilesScreen(
files = { files },
removeFileByUid = {},
addFiles = {},
closeActivity = {},
initialShowUploadSourceChoiceBottomSheet = false,
)
}
}
1 change: 1 addition & 0 deletions app/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
<string name="settingsEmailLanguageValueSpanish">Spanisch</string>
<string name="settingsMatomoDescription">Matomo ist ein Analysetool, das ausschliesslich von Infomaniak gehostet und verwaltet wird, um zu verstehen, wie die Anwendung genutzt wird.\n\nDurch die Untersuchung dieser Daten kann unser Team die Schnittstelle der Anwendung kontinuierlich verbessern.</string>
<string name="settingsNotificationsTitle">Wählt eine Präferenz aus</string>
<string name="settingsOptionActivated">Aktiviert</string>
<string name="settingsOptionDataManagement">Verwaltung der Daten</string>
<string name="settingsOptionDiscoverInfomaniak">Entdecke Infomaniak</string>
<string name="settingsOptionDownloadLimit">Limit für Downloads</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
<string name="settingsEmailLanguageValueSpanish">Español</string>
<string name="settingsMatomoDescription">Matomo es una herramienta de análisis alojada y gestionada exclusivamente por Infomaniak para comprender cómo se utiliza la aplicación.\n\nEl estudio de estos datos permite a nuestro equipo mejorar continuamente la interfaz de la aplicación.</string>
<string name="settingsNotificationsTitle">Seleccione una preferencia</string>
<string name="settingsOptionActivated">Activado</string>
<string name="settingsOptionDataManagement">Gestión de datos</string>
<string name="settingsOptionDiscoverInfomaniak">Descubrir Infomaniak</string>
<string name="settingsOptionDownloadLimit">Límite de descarga</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-fr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
<string name="settingsEmailLanguageValueSpanish">Espagnol</string>
<string name="settingsMatomoDescription">Matomo est un outil d’analyse hébergé et géré exclusivement par Infomaniak pour comprendre comment l’application est utilisée.\n\nL’étude de ces données permet à notre équipe d’améliorer en continue l’interface de l’application.</string>
<string name="settingsNotificationsTitle">Sélectionne une préférence</string>
<string name="settingsOptionActivated">Activé</string>
<string name="settingsOptionDataManagement">Gestion des données</string>
<string name="settingsOptionDiscoverInfomaniak">Découvre Infomaniak</string>
<string name="settingsOptionDownloadLimit">Limite de téléchargements</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-it/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
<string name="settingsEmailLanguageValueSpanish">Spagnolo</string>
<string name="settingsMatomoDescription">Matomo è uno strumento di analisi ospitato e gestito esclusivamente da Infomaniak per capire come viene utilizzata l’applicazione.\n\nStudiando questi dati, il nostro team è in grado di migliorare continuamente l’interfaccia dell’applicazione.</string>
<string name="settingsNotificationsTitle">Seleziona una preferenza</string>
<string name="settingsOptionActivated">Attivato</string>
<string name="settingsOptionDataManagement">Gestione dei dati</string>
<string name="settingsOptionDiscoverInfomaniak">Scopri Infomaniak</string>
<string name="settingsOptionDownloadLimit">Limite di download</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
<string name="settingsEmailLanguageValueSpanish">Spanish</string>
<string name="settingsMatomoDescription">Matomo is an analysis tool hosted and managed exclusively by Infomaniak to understand how the application is used.\n\nBy studying this data, our team is able to continually improve the application’s interface.</string>
<string name="settingsNotificationsTitle">Select a preference</string>
<string name="settingsOptionActivated">Activated</string>
<string name="settingsOptionDataManagement">Data management</string>
<string name="settingsOptionDiscoverInfomaniak">Discover Infomaniak</string>
<string name="settingsOptionDownloadLimit">Download limit</string>
Expand Down

0 comments on commit b007aec

Please sign in to comment.