diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/components/transfer/TransferItemList.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/components/transfer/TransferItemList.kt index 48dc74932..6dd0ec875 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/components/transfer/TransferItemList.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/components/transfer/TransferItemList.kt @@ -27,6 +27,7 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.PreviewParameter import com.infomaniak.multiplatform_swisstransfer.common.interfaces.ui.TransferUi +import com.infomaniak.multiplatform_swisstransfer.common.models.TransferDirection import com.infomaniak.swisstransfer.R import com.infomaniak.swisstransfer.ui.previewparameter.TransferUiListPreviewParameter import com.infomaniak.swisstransfer.ui.theme.Margin @@ -36,6 +37,7 @@ import com.infomaniak.swisstransfer.ui.utils.PreviewLightAndDark @Composable fun TransferItemList( modifier: Modifier = Modifier, + direction: TransferDirection, transfers: List, getSelectedTransferUuid: () -> String?, onClick: (TransferUi) -> Unit, @@ -51,7 +53,7 @@ fun TransferItemList( item { Text( - text = stringResource(R.string.receivedFilesTitle), + text = stringResource(if (direction == TransferDirection.SENT) R.string.sentFilesTitle else R.string.receivedFilesTitle), style = SwissTransferTheme.typography.h1, ) } @@ -79,6 +81,7 @@ private fun Preview(@PreviewParameter(TransferUiListPreviewParameter::class) tra Surface { TransferItemList( transfers = transfers, + direction = TransferDirection.SENT, getSelectedTransferUuid = { null }, onClick = {}, ) diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/components/transfer/TransfersListWithExpiredBottomSheet.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/components/transfer/TransfersListWithExpiredBottomSheet.kt index 3e32883f5..f8bf925c8 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/components/transfer/TransfersListWithExpiredBottomSheet.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/components/transfer/TransfersListWithExpiredBottomSheet.kt @@ -26,6 +26,7 @@ import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.saveable.rememberSaveable import androidx.compose.runtime.setValue import androidx.compose.ui.Modifier +import com.infomaniak.multiplatform_swisstransfer.common.models.TransferDirection import com.infomaniak.swisstransfer.ui.previewparameter.transfersPreviewData import com.infomaniak.swisstransfer.ui.theme.Margin import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme @@ -34,6 +35,7 @@ import java.util.Date @Composable fun TransfersListWithExpiredBottomSheet( + direction: TransferDirection, navigateToDetails: (transferUuid: String) -> Unit, getSelectedTransferUuid: () -> String?, ) { @@ -44,6 +46,7 @@ fun TransfersListWithExpiredBottomSheet( TransferItemList( modifier = Modifier.padding(Margin.Medium), + direction = direction, transfers = transfersPreviewData, // TODO: Use real data getSelectedTransferUuid = getSelectedTransferUuid, onClick = { transfer -> @@ -82,6 +85,7 @@ private fun Preview() { SwissTransferTheme { Surface { TransfersListWithExpiredBottomSheet( + direction = TransferDirection.RECEIVED, navigateToDetails = {}, getSelectedTransferUuid = { null }, ) diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/MainNavHost.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/MainNavHost.kt index 0ccc66c19..ea7a6f95d 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/MainNavHost.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/MainNavHost.kt @@ -25,11 +25,11 @@ import androidx.compose.runtime.Composable import androidx.navigation.NavHostController import androidx.navigation.compose.NavHost import androidx.navigation.compose.composable +import com.infomaniak.multiplatform_swisstransfer.common.models.TransferDirection import com.infomaniak.swisstransfer.ui.navigation.MainNavigation import com.infomaniak.swisstransfer.ui.navigation.MainNavigation.* -import com.infomaniak.swisstransfer.ui.screen.main.received.ReceivedScreenWrapper -import com.infomaniak.swisstransfer.ui.screen.main.sent.SentScreen import com.infomaniak.swisstransfer.ui.screen.main.settings.SettingsScreenWrapper +import com.infomaniak.swisstransfer.ui.screen.main.transfers.TransfersScreenWrapper @Composable fun MainNavHost( @@ -42,14 +42,8 @@ fun MainNavHost( enterTransition = { if (currentDestination.enableTransition) fadeIn() else EnterTransition.None }, exitTransition = { if (currentDestination.enableTransition) fadeOut() else ExitTransition.None }, ) { - composable { - SentScreen(navigateToDetails = { navController.navigate(TransferDetailsDestination(it)) }) - } - composable { - ReceivedScreenWrapper() - } - composable { - SettingsScreenWrapper() - } + composable { TransfersScreenWrapper(TransferDirection.SENT) } + composable { TransfersScreenWrapper(TransferDirection.RECEIVED) } + composable { SettingsScreenWrapper() } } } diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/received/ReceivedScreen.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/received/ReceivedScreen.kt index 3dfb9a647..979bb2262 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/received/ReceivedScreen.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/received/ReceivedScreen.kt @@ -24,6 +24,7 @@ import androidx.compose.runtime.getValue import androidx.compose.runtime.remember import androidx.hilt.navigation.compose.hiltViewModel import androidx.lifecycle.compose.collectAsStateWithLifecycle +import com.infomaniak.multiplatform_swisstransfer.common.models.TransferDirection import com.infomaniak.swisstransfer.R import com.infomaniak.swisstransfer.ui.components.EmptyState import com.infomaniak.swisstransfer.ui.components.transfer.TransfersListWithExpiredBottomSheet @@ -31,7 +32,7 @@ import com.infomaniak.swisstransfer.ui.images.AppImages.AppIllus import com.infomaniak.swisstransfer.ui.images.illus.MascotSearching import com.infomaniak.swisstransfer.ui.screen.main.components.BrandTopAppBarScaffold import com.infomaniak.swisstransfer.ui.screen.main.received.components.ReceivedEmptyFab -import com.infomaniak.swisstransfer.ui.screen.main.sent.SentViewModel +import com.infomaniak.swisstransfer.ui.screen.main.transfers.TransfersViewModel import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme import com.infomaniak.swisstransfer.ui.utils.PreviewAllWindows @@ -39,9 +40,9 @@ import com.infomaniak.swisstransfer.ui.utils.PreviewAllWindows fun ReceivedScreen( navigateToDetails: (transferUuid: String) -> Unit, getSelectedTransferUuid: () -> String?, - sentViewModel: SentViewModel = hiltViewModel(), + transfersViewModel: TransfersViewModel = hiltViewModel(), ) { - val transfers by sentViewModel.transfers.collectAsStateWithLifecycle() + val transfers by transfersViewModel.receivedTransfers.collectAsStateWithLifecycle() val areTransfersEmpty by remember { derivedStateOf { transfers?.isEmpty() == true } } ReceivedScreen( @@ -67,7 +68,7 @@ private fun ReceivedScreen( descriptionRes = R.string.noTransferReceivedDescription, ) } else { - TransfersListWithExpiredBottomSheet(navigateToDetails, getSelectedTransferUuid) + TransfersListWithExpiredBottomSheet(TransferDirection.RECEIVED, navigateToDetails, getSelectedTransferUuid) } } } @@ -80,7 +81,7 @@ private fun Preview() { ReceivedScreen( navigateToDetails = {}, getSelectedTransferUuid = { null }, - areTransfersEmpty = { true }, + areTransfersEmpty = { false }, ) } } diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/sent/SentScreen.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/sent/SentScreen.kt index b2521f279..8a375da46 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/sent/SentScreen.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/sent/SentScreen.kt @@ -20,12 +20,17 @@ package com.infomaniak.swisstransfer.ui.screen.main.sent import androidx.compose.material3.Surface import androidx.compose.material3.adaptive.currentWindowAdaptiveInfo import androidx.compose.runtime.Composable +import androidx.compose.runtime.derivedStateOf import androidx.compose.runtime.getValue +import androidx.compose.runtime.remember import androidx.hilt.navigation.compose.hiltViewModel import androidx.lifecycle.compose.collectAsStateWithLifecycle +import com.infomaniak.multiplatform_swisstransfer.common.models.TransferDirection import com.infomaniak.swisstransfer.ui.components.NewTransferFab import com.infomaniak.swisstransfer.ui.components.NewTransferFabType +import com.infomaniak.swisstransfer.ui.components.transfer.TransfersListWithExpiredBottomSheet import com.infomaniak.swisstransfer.ui.screen.main.components.BrandTopAppBarScaffold +import com.infomaniak.swisstransfer.ui.screen.main.transfers.TransfersViewModel import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme import com.infomaniak.swisstransfer.ui.utils.PreviewAllWindows import com.infomaniak.swisstransfer.ui.utils.isWindowSmall @@ -33,26 +38,40 @@ import com.infomaniak.swisstransfer.ui.utils.isWindowSmall @Composable fun SentScreen( navigateToDetails: (transferUuid: String) -> Unit, - sentViewModel: SentViewModel = hiltViewModel(), + getSelectedTransferUuid: () -> String?, + transfersViewModel: TransfersViewModel = hiltViewModel(), ) { - val transfers by sentViewModel.transfers.collectAsStateWithLifecycle() - SentScreen(transfers) + val transfers by transfersViewModel.sentTransfers.collectAsStateWithLifecycle() + val areTransfersEmpty by remember { derivedStateOf { transfers?.isEmpty() == true } } + + SentScreen( + navigateToDetails = navigateToDetails, + getSelectedTransferUuid = getSelectedTransferUuid, + areTransfersEmpty = { areTransfersEmpty }, + ) } @Composable -private fun SentScreen(transfers: List?) { +private fun SentScreen( + navigateToDetails: (transferUuid: String) -> Unit, + getSelectedTransferUuid: () -> String?, + areTransfersEmpty: () -> Boolean, +) { - if (transfers == null) return val windowAdaptiveInfo = currentWindowAdaptiveInfo() BrandTopAppBarScaffold( floatingActionButton = { - if (windowAdaptiveInfo.isWindowSmall() && transfers.isNotEmpty()) { + if (windowAdaptiveInfo.isWindowSmall() && !areTransfersEmpty()) { NewTransferFab(newTransferFabType = NewTransferFabType.BOTTOM_BAR) } }, ) { - if (transfers.isEmpty()) SentEmptyScreen() + if (areTransfersEmpty()) { + SentEmptyScreen() + } else { + TransfersListWithExpiredBottomSheet(TransferDirection.SENT, navigateToDetails, getSelectedTransferUuid) + } } } @@ -61,7 +80,11 @@ private fun SentScreen(transfers: List?) { private fun Preview() { SwissTransferTheme { Surface { - SentScreen(transfers = emptyList()) + SentScreen( + navigateToDetails = {}, + getSelectedTransferUuid = { null }, + areTransfersEmpty = { true }, + ) } } } diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/received/ReceivedScreenWrapper.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/transfers/TransfersScreenWrapper.kt similarity index 71% rename from app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/received/ReceivedScreenWrapper.kt rename to app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/transfers/TransfersScreenWrapper.kt index cbae1e170..e534d2d2d 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/received/ReceivedScreenWrapper.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/transfers/TransfersScreenWrapper.kt @@ -15,7 +15,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package com.infomaniak.swisstransfer.ui.screen.main.received +package com.infomaniak.swisstransfer.ui.screen.main.transfers import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.fillMaxSize @@ -28,8 +28,11 @@ import androidx.compose.material3.adaptive.navigation.ThreePaneScaffoldNavigator import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier +import com.infomaniak.multiplatform_swisstransfer.common.models.TransferDirection import com.infomaniak.swisstransfer.ui.components.TwoPaneScaffold import com.infomaniak.swisstransfer.ui.components.safeCurrentContent +import com.infomaniak.swisstransfer.ui.screen.main.received.ReceivedScreen +import com.infomaniak.swisstransfer.ui.screen.main.sent.SentScreen import com.infomaniak.swisstransfer.ui.screen.main.transferdetails.TransferDetailsScreen import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme import com.infomaniak.swisstransfer.ui.utils.PreviewAllWindows @@ -37,20 +40,26 @@ import com.infomaniak.swisstransfer.ui.utils.ScreenWrapperUtils @OptIn(ExperimentalMaterial3AdaptiveApi::class) @Composable -fun ReceivedScreenWrapper() { +fun TransfersScreenWrapper(direction: TransferDirection) { TwoPaneScaffold( - listPane = { ListPane(navigator = this) }, + listPane = { ListPane(direction, navigator = this) }, detailPane = { DetailPane(navigator = this) }, ) } @OptIn(ExperimentalMaterial3AdaptiveApi::class) @Composable -private fun ListPane(navigator: ThreePaneScaffoldNavigator) { - ReceivedScreen( - navigateToDetails = { transferUuid -> navigator.navigateTo(ListDetailPaneScaffoldRole.Detail, transferUuid) }, - getSelectedTransferUuid = { navigator.currentDestination?.content }, - ) +private fun ListPane(direction: TransferDirection, navigator: ThreePaneScaffoldNavigator) { + when (direction) { + TransferDirection.SENT -> SentScreen( + navigateToDetails = { transferUuid -> navigator.navigateTo(ListDetailPaneScaffoldRole.Detail, transferUuid) }, + getSelectedTransferUuid = { navigator.currentDestination?.content }, + ) + TransferDirection.RECEIVED -> ReceivedScreen( + navigateToDetails = { transferUuid -> navigator.navigateTo(ListDetailPaneScaffoldRole.Detail, transferUuid) }, + getSelectedTransferUuid = { navigator.currentDestination?.content }, + ) + } } @OptIn(ExperimentalMaterial3AdaptiveApi::class) @@ -81,7 +90,7 @@ private fun NoSelectionEmptyState() { private fun Preview() { SwissTransferTheme { Surface(color = MaterialTheme.colorScheme.background) { - ReceivedScreenWrapper() + TransfersScreenWrapper(TransferDirection.RECEIVED) } } } diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/sent/SentViewModel.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/transfers/TransfersViewModel.kt similarity index 77% rename from app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/sent/SentViewModel.kt rename to app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/transfers/TransfersViewModel.kt index e7ce982a6..1196b2514 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/sent/SentViewModel.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/transfers/TransfersViewModel.kt @@ -15,7 +15,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package com.infomaniak.swisstransfer.ui.screen.main.sent +package com.infomaniak.swisstransfer.ui.screen.main.transfers import androidx.compose.runtime.mutableStateMapOf import androidx.compose.runtime.snapshots.SnapshotStateMap @@ -28,7 +28,8 @@ import kotlinx.coroutines.flow.stateIn import javax.inject.Inject @HiltViewModel -class SentViewModel @Inject constructor() : ViewModel() { - val transfers = flow> { emit(listOf(1)) }.stateIn(viewModelScope, SharingStarted.Eagerly, null) +class TransfersViewModel @Inject constructor() : ViewModel() { + val sentTransfers = flow> { emit(listOf(1)) }.stateIn(viewModelScope, SharingStarted.Eagerly, null) + val receivedTransfers = flow> { emit(listOf(1)) }.stateIn(viewModelScope, SharingStarted.Eagerly, null) val selectedTransferUuids: SnapshotStateMap = mutableStateMapOf() } diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 07953fbaf..ebf8bb0c1 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -52,6 +52,7 @@ Empfangene Dateien Empfangen Unsere Geschichte beginnt hier + Geteilte Dateien Gesendet Verfolgung genehmigen Über diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index 8840028d5..2978d5c7b 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -52,6 +52,7 @@ Archivos recibidos Recibido Nuestra historia comienza aquí + Archivos compartidos Enviado a Autorizar el seguimiento Quiénes somos diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index 3eece9ab6..bcba3ba57 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -53,6 +53,7 @@ Fichiers reçus Reçu Notre histoire commence ici + Fichiers partagés Envoyé Autoriser le suivi A propos diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index 659893cb6..85ef5002c 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -52,6 +52,7 @@ File ricevuti Ricevuto La nostra storia inizia qui + File condivisi Inviato a Autorizza il tracciamento Chi siamo diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 4b878b5e1..aefc59e4d 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -57,6 +57,7 @@ Received files Received Our story begins here + Shared files Sent Authorize tracking About