Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Rename transferLink into transferUrl #169

Merged
merged 1 commit into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ import io.github.alexzhirkevich.qrose.options.solid
import io.github.alexzhirkevich.qrose.rememberQrCodePainter

@Composable
fun QrCode(transferLink: String) {
fun QrCode(transferUrl: String) {

val centralIcon = rememberVectorPainter(AppIcons.QrInfomaniak.image())
val darkPixelsColor = QrBrush.solid(SwissTransferTheme.colors.qrCodeDarkPixels)
val lightPixelsColor = QrBrush.solid(SwissTransferTheme.colors.qrCodeLightPixels)
val painter = rememberQrCodePainter(transferLink) {
val painter = rememberQrCodePainter(transferUrl) {
colors {
dark = darkPixelsColor
light = lightPixelsColor
Expand All @@ -65,7 +65,7 @@ fun QrCode(transferLink: String) {
private fun QrCodePreview() {
SwissTransferTheme {
Surface {
QrCode(transferLink = "https://chk.me/83azQOl")
QrCode(transferUrl = "https://chk.me/83azQOl")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ sealed class NewTransferNavigation : NavigationDestination() {
@Serializable
data class UploadProgressDestination(val transferType: TransferType, val totalSize: Long) : NewTransferNavigation()
@Serializable
data class UploadSuccessDestination(val transferType: TransferType, val transferLink: String) : NewTransferNavigation()
data class UploadSuccessDestination(val transferType: TransferType, val transferUrl: String) : NewTransferNavigation()
@Serializable
data object UploadErrorDestination : NewTransferNavigation()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,19 @@
*/
package com.infomaniak.swisstransfer.ui.screen.main.transferdetails

import android.text.format.Formatter
import androidx.annotation.StringRes
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.*
import androidx.compose.material3.*
import androidx.compose.runtime.*
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.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.pluralStringResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
Expand All @@ -38,7 +39,8 @@ import com.infomaniak.multiplatform_swisstransfer.common.interfaces.ui.TransferU
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.*
import com.infomaniak.swisstransfer.ui.images.icons.ArrowDownBar
import com.infomaniak.swisstransfer.ui.images.icons.Share
import com.infomaniak.swisstransfer.ui.previewparameter.transfersPreviewData
import com.infomaniak.swisstransfer.ui.screen.main.components.SmallWindowTopAppBarScaffold
import com.infomaniak.swisstransfer.ui.screen.main.transferdetails.components.TransferInfo
Expand All @@ -57,7 +59,7 @@ fun TransferDetailsScreen(

val transfer = transfersPreviewData.first() // TODO: Use real data
val transferSenderEmail: String? = "[email protected]" // TODO
val transferLink = "https://chk.me/83azQOl" // TODO
val transferUrl = "https://chk.me/83azQOl" // TODO

var isMultiselectOn: Boolean by rememberSaveable { mutableStateOf(false) }
val context = LocalContext.current
Expand Down Expand Up @@ -96,7 +98,7 @@ fun TransferDetailsScreen(
isMultiselectOn = { isMultiselectOn },
onClick = { item ->
when (item) {
BottomBarItem.SHARE -> context.shareText(transferLink)
BottomBarItem.SHARE -> context.shareText(transferUrl)
BottomBarItem.DOWNLOAD -> {
// TODO: Move the multiselect elsewhere, and implement this feature
isMultiselectOn = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ fun NewTransferNavHost(navController: NavHostController, closeActivity: () -> Un
val args = it.toRoute<UploadProgressDestination>()
UploadProgressScreen(
totalSizeInBytes = args.totalSize,
navigateToUploadSuccess = { transferLink ->
navController.navigate(UploadSuccessDestination(args.transferType, transferLink))
navigateToUploadSuccess = { transferUrl ->
navController.navigate(UploadSuccessDestination(args.transferType, transferUrl))
},
navigateToUploadError = { navController.navigate(UploadErrorDestination) },
closeActivity = closeActivity
Expand All @@ -60,7 +60,7 @@ fun NewTransferNavHost(navController: NavHostController, closeActivity: () -> Un
val args = it.toRoute<UploadSuccessDestination>()
UploadSuccessScreen(
transferType = args.transferType,
transferLink = args.transferLink,
transferUrl = args.transferUrl,
closeActivity = closeActivity
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ private fun HandleProgressState(
val currentUiState = uiState()
LaunchedEffect(uiState()) {
when (currentUiState) {
is UploadProgressUiState.Success -> navigateToUploadSuccess(currentUiState.transferLink)
is UploadProgressUiState.Success -> navigateToUploadSuccess(currentUiState.transferUrl)
is UploadProgressUiState.Cancelled -> navigateToUploadError()
else -> Unit
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ import com.infomaniak.swisstransfer.ui.utils.shareText
import kotlinx.coroutines.launch

@Composable
fun UploadSuccessQrScreen(transferType: TransferType, transferLink: String, closeActivity: () -> Unit) {
fun UploadSuccessQrScreen(transferType: TransferType, transferUrl: String, closeActivity: () -> Unit) {

val context = LocalContext.current
val snackbarHostState = remember { SnackbarHostState() }
Expand All @@ -64,7 +64,7 @@ fun UploadSuccessQrScreen(transferType: TransferType, transferLink: String, clos
style = ButtonType.PRIMARY,
titleRes = R.string.buttonShare,
imageVector = AppIcons.PersonBadgeShare,
onClick = { context.shareText(transferLink) },
onClick = { context.shareText(transferUrl) },
)
},
bottomButton = {
Expand All @@ -75,12 +75,12 @@ fun UploadSuccessQrScreen(transferType: TransferType, transferLink: String, clos
onClick = closeActivity,
)
},
content = { Content(context, snackbarHostState, transferType, transferLink) },
content = { Content(context, snackbarHostState, transferType, transferUrl) },
)
}

@Composable
private fun Content(context: Context, snackbarHostState: SnackbarHostState, transferType: TransferType, transferLink: String) {
private fun Content(context: Context, snackbarHostState: SnackbarHostState, transferType: TransferType, transferUrl: String) {

val scope = rememberCoroutineScope()

Expand Down Expand Up @@ -108,7 +108,7 @@ private fun Content(context: Context, snackbarHostState: SnackbarHostState, tran

Spacer(Modifier.height(Margin.Huge))

QrCode(transferLink)
QrCode(transferUrl)

transferType.descriptionRes?.let { descriptionRes ->
Spacer(Modifier.height(Margin.Huge))
Expand All @@ -130,7 +130,7 @@ private fun Content(context: Context, snackbarHostState: SnackbarHostState, tran
imageVector = AppIcons.DocumentOnDocument,
onClick = {
context.copyText(
text = transferLink,
text = transferUrl,
showSnackbar = { scope.launch { snackbarHostState.showSnackbar(it) } },
)
},
Expand All @@ -144,7 +144,7 @@ private fun UploadSuccessQrScreenPreview() {
Surface {
UploadSuccessQrScreen(
transferType = TransferType.LINK,
transferLink = "https://chk.me/83azQOl",
transferUrl = "https://chk.me/83azQOl",
closeActivity = {}
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ import com.infomaniak.swisstransfer.ui.utils.PreviewAllWindows
@Composable
fun UploadSuccessScreen(
transferType: TransferType,
transferLink: String,
transferUrl: String,
closeActivity: () -> Unit,
) {
BackHandler(onBack = closeActivity)

if (transferType == TransferType.MAIL) {
UploadSuccessEmailScreen(closeActivity = closeActivity)
} else {
UploadSuccessQrScreen(transferType, transferLink, closeActivity)
UploadSuccessQrScreen(transferType, transferUrl, closeActivity)
}
}

Expand All @@ -46,7 +46,7 @@ private fun UploadSuccessScreenPreview() {
Surface {
UploadSuccessScreen(
transferType = TransferType.QR_CODE,
transferLink = "https://chk.me/83azQOl",
transferUrl = "https://chk.me/83azQOl",
closeActivity = {}
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,12 @@ class UploadWorker @AssistedInject constructor(
}

@Immutable
data class Success(override val uploadedSize: Long, val transferLink: String) : UploadProgressUiState(uploadedSize) {
data class Success(override val uploadedSize: Long, val transferUrl: String) : UploadProgressUiState(uploadedSize) {
companion object {
fun create(outputData: Data, sharedApiUrlCreator: SharedApiUrlCreator): Success? {
return Success(
uploadedSize = outputData.getLong(UPLOADED_BYTES_TAG, 0L),
transferLink = outputData.getString(TRANSFER_UUID_TAG)
transferUrl = outputData.getString(TRANSFER_UUID_TAG)
?.let { transferUuid -> sharedApiUrlCreator.shareTransferUrl(transferUuid) } ?: return null
)
}
Expand Down
Loading