Skip to content

Commit

Permalink
Move UploadSourceChoiceBottomSheet to its own file
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinBoulongne committed Sep 17, 2024
1 parent 55b2025 commit 44f689d
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,15 @@
package com.infomaniak.swisstransfer.ui.screen.newtransfer.importfiles

import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.Surface
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import com.infomaniak.swisstransfer.R
import com.infomaniak.swisstransfer.ui.components.*
import com.infomaniak.swisstransfer.ui.images.AppImages.AppIcons
import com.infomaniak.swisstransfer.ui.images.icons.Add
import com.infomaniak.swisstransfer.ui.images.icons.Camera
import com.infomaniak.swisstransfer.ui.images.icons.Folder
import com.infomaniak.swisstransfer.ui.images.icons.PolaroidLandscape
import com.infomaniak.swisstransfer.ui.theme.Margin
import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme
import com.infomaniak.swisstransfer.ui.utils.PreviewMobile
import com.infomaniak.swisstransfer.ui.utils.PreviewTablet
Expand Down Expand Up @@ -77,28 +69,6 @@ fun ImportFilesScreen(navigateToTransferTypeScreen: () -> Unit) {
}
}

@Composable
private fun UploadSourceChoiceBottomSheet(
isBottomSheetVisible: () -> Boolean,
onDismissRequest: () -> Unit,
) {
if (isBottomSheetVisible()) {
SwissTransferBottomSheet(
onDismissRequest = onDismissRequest,
titleRes = R.string.transferUploadSourceChoiceTitle,
content = {
Column {
BottomSheetItem(AppIcons.Camera, R.string.transferUploadSourceChoiceCamera) { /* TODO */ }
HorizontalDivider(Modifier.padding(horizontal = Margin.Medium))
BottomSheetItem(AppIcons.PolaroidLandscape, R.string.transferUploadSourceChoiceGallery) { /* TODO */ }
HorizontalDivider(Modifier.padding(horizontal = Margin.Medium))
BottomSheetItem(AppIcons.Folder, R.string.transferUploadSourceChoiceFiles) { /* TODO */ }
}
},
)
}
}

@PreviewMobile
@PreviewTablet
@Composable
Expand All @@ -107,14 +77,3 @@ private fun ImportFilesScreenPreview() {
ImportFilesScreen {}
}
}

@PreviewMobile
@PreviewTablet
@Composable
private fun ImportChoiceBottomSheetPreview() {
SwissTransferTheme {
Surface {
UploadSourceChoiceBottomSheet(isBottomSheetVisible = { true }, onDismissRequest = {})
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
* Infomaniak SwissTransfer - Android
* Copyright (C) 2024 Infomaniak Network SA
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.infomaniak.swisstransfer.ui.screen.newtransfer.importfiles

import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.Surface
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import com.infomaniak.swisstransfer.R
import com.infomaniak.swisstransfer.ui.components.BottomSheetItem
import com.infomaniak.swisstransfer.ui.components.SwissTransferBottomSheet
import com.infomaniak.swisstransfer.ui.images.AppImages
import com.infomaniak.swisstransfer.ui.images.icons.Camera
import com.infomaniak.swisstransfer.ui.images.icons.Folder
import com.infomaniak.swisstransfer.ui.images.icons.PolaroidLandscape
import com.infomaniak.swisstransfer.ui.theme.Margin
import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme
import com.infomaniak.swisstransfer.ui.utils.PreviewMobile
import com.infomaniak.swisstransfer.ui.utils.PreviewTablet

@Composable
fun UploadSourceChoiceBottomSheet(
isBottomSheetVisible: () -> Boolean,
onDismissRequest: () -> Unit,
) {
if (isBottomSheetVisible()) {
SwissTransferBottomSheet(
onDismissRequest = onDismissRequest,
titleRes = R.string.transferUploadSourceChoiceTitle,
content = {
Column {
BottomSheetItem(AppImages.AppIcons.Camera, R.string.transferUploadSourceChoiceCamera) { /* TODO */ }
HorizontalDivider(Modifier.padding(horizontal = Margin.Medium))
BottomSheetItem(
AppImages.AppIcons.PolaroidLandscape,
R.string.transferUploadSourceChoiceGallery
) { /* TODO */ }
HorizontalDivider(Modifier.padding(horizontal = Margin.Medium))
BottomSheetItem(AppImages.AppIcons.Folder, R.string.transferUploadSourceChoiceFiles) { /* TODO */ }
}
},
)
}
}

@PreviewMobile
@PreviewTablet
@Composable
private fun UploadSourceChoiceBottomSheetPreview() {
SwissTransferTheme {
Surface {
UploadSourceChoiceBottomSheet(isBottomSheetVisible = { true }, onDismissRequest = {})
}
}
}

0 comments on commit 44f689d

Please sign in to comment.