Skip to content

Commit

Permalink
feat: Add missing previews
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinBoulongne committed Oct 31, 2024
1 parent 2fd0ffe commit 246e2d9
Show file tree
Hide file tree
Showing 3 changed files with 215 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package com.infomaniak.swisstransfer.ui.components.transfer

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.*
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
Expand All @@ -30,6 +31,7 @@ import com.infomaniak.swisstransfer.ui.components.SmallFileTileSize
import com.infomaniak.swisstransfer.ui.theme.CustomShapes
import com.infomaniak.swisstransfer.ui.theme.Margin
import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme
import com.infomaniak.swisstransfer.ui.utils.PreviewAllWindows

@Composable
fun TransferFilePreview(
Expand Down Expand Up @@ -72,3 +74,35 @@ fun TransferFilePreview(
}
}
}

@PreviewAllWindows
@Composable
private fun Preview() {
SwissTransferTheme {
Surface {
Row {
TransferFilePreview(
file = FileUi(
fileName = "The 5-Step Guide to Not Breaking Your Code.txt",
uid = "The 5-Step Guide to Not Breaking Your Code.txt",
fileSize = 57_689_032L,
mimeType = null,
localPath = "",
),
isFirstItem = true,
)
TransferFilePreview(
file =
FileUi(
fileName = "Introduction to Turning It Off and On Again.pptx",
uid = "Introduction to Turning It Off and On Again.pptx",
fileSize = 89_723_143L,
mimeType = null,
localPath = "",
),
)
TransferFilePreview(remainingFilesCount = 42)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,14 @@ package com.infomaniak.swisstransfer.ui.components.transfer

import android.text.format.Formatter
import androidx.compose.foundation.layout.*
import androidx.compose.material3.Card
import androidx.compose.material3.CardDefaults
import androidx.compose.material3.Icon
import androidx.compose.material3.Text
import androidx.compose.material3.*
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextOverflow
import com.infomaniak.multiplatform_swisstransfer.common.interfaces.ui.FileUi
import com.infomaniak.multiplatform_swisstransfer.common.interfaces.ui.TransferUi
import com.infomaniak.swisstransfer.R
import com.infomaniak.swisstransfer.ui.images.AppImages.AppIcons
Expand All @@ -37,8 +35,11 @@ import com.infomaniak.swisstransfer.ui.theme.CustomShapes
import com.infomaniak.swisstransfer.ui.theme.Margin
import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme
import com.infomaniak.swisstransfer.ui.utils.FORMAT_DATE_TITLE
import com.infomaniak.swisstransfer.ui.utils.PreviewAllWindows
import com.infomaniak.swisstransfer.ui.utils.format
import java.util.Calendar
import java.util.Date
import java.util.UUID

@OptIn(ExperimentalLayoutApi::class)
@Composable
Expand Down Expand Up @@ -118,3 +119,72 @@ fun TransferItem(
}
}
}

@PreviewAllWindows
@Composable
private fun Preview() {
SwissTransferTheme {
Surface {
TransferItem(
transfer = TransferUi(
uuid = UUID.randomUUID().toString(),
createdDateTimestamp = Date().time - 30L * 86_400_000L,
expirationDateTimestamp = Calendar.getInstance().apply {
time = Date()
set(Calendar.DATE, get(Calendar.DATE) + 1)
}.time.time,
sizeUploaded = 57_689_032L,
downloadLimit = 10,
downloadLeft = 8,
message = "Coucou c'est moi le message de description du transfert.",
files = listOf(
FileUi(
uid = UUID.randomUUID().toString(),
fileName = "The 5-Step Guide to Not Breaking Your Code (1).txt",
fileSize = 57_689_032L,
mimeType = null,
localPath = null,
),
FileUi(
uid = UUID.randomUUID().toString(),
fileName = "Introduction to Turning It Off and On Again (1).pptx",
fileSize = 89_723_143L,
mimeType = null,
localPath = null,
),
FileUi(
uid = UUID.randomUUID().toString(),
fileName = "Learning to Copy and Paste: A Complete Guide (1).docx",
fileSize = 237_866_728L,
mimeType = null,
localPath = null,
),
FileUi(
uid = UUID.randomUUID().toString(),
fileName = "The 5-Step Guide to Not Breaking Your Code (2).txt",
fileSize = 57_689_032L,
mimeType = null,
localPath = null,
),
FileUi(
uid = UUID.randomUUID().toString(),
fileName = "Introduction to Turning It Off and On Again (2).pptx",
fileSize = 89_723_143L,
mimeType = null,
localPath = null,
),
FileUi(
uid = UUID.randomUUID().toString(),
fileName = "Learning to Copy and Paste: A Complete Guide (2).docx",
fileSize = 237_866_728L,
mimeType = null,
localPath = null,
),
),

),
onClick = {},
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,20 @@ import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import com.infomaniak.multiplatform_swisstransfer.common.interfaces.ui.FileUi
import com.infomaniak.multiplatform_swisstransfer.common.interfaces.ui.TransferUi
import com.infomaniak.swisstransfer.R
import com.infomaniak.swisstransfer.ui.theme.Margin
import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme
import com.infomaniak.swisstransfer.ui.utils.PreviewAllWindows
import java.util.Calendar
import java.util.Date
import java.util.UUID

@Composable
fun TransferItemList(
Expand Down Expand Up @@ -63,3 +69,104 @@ fun TransferItemList(
)
}
}

@PreviewAllWindows
@Composable
private fun Preview() {

val files = listOf(
FileUi(
uid = UUID.randomUUID().toString(),
fileName = "The 5-Step Guide to Not Breaking Your Code (1).txt",
fileSize = 57_689_032L,
mimeType = null,
localPath = null,
),
FileUi(
uid = UUID.randomUUID().toString(),
fileName = "Introduction to Turning It Off and On Again (1).pptx",
fileSize = 89_723_143L,
mimeType = null,
localPath = null,
),
FileUi(
uid = UUID.randomUUID().toString(),
fileName = "Learning to Copy and Paste: A Complete Guide (1).docx",
fileSize = 237_866_728L,
mimeType = null,
localPath = null,
),
FileUi(
uid = UUID.randomUUID().toString(),
fileName = "The 5-Step Guide to Not Breaking Your Code (2).txt",
fileSize = 57_689_032L,
mimeType = null,
localPath = null,
),
FileUi(
uid = UUID.randomUUID().toString(),
fileName = "Introduction to Turning It Off and On Again (2).pptx",
fileSize = 89_723_143L,
mimeType = null,
localPath = null,
),
FileUi(
uid = UUID.randomUUID().toString(),
fileName = "Learning to Copy and Paste: A Complete Guide (2).docx",
fileSize = 237_866_728L,
mimeType = null,
localPath = null,
),
)

val transfers = listOf(
TransferUi(
uuid = UUID.randomUUID().toString(),
createdDateTimestamp = Date().time - 30L * 86_400_000L,
expirationDateTimestamp = Calendar.getInstance().apply {
time = Date()
set(Calendar.DATE, get(Calendar.DATE) + 1)
}.time.time,
sizeUploaded = 57_689_032L,
downloadLimit = 10,
downloadLeft = 8,
message = "Coucou c'est moi le message de description du transfert.",
files = files,
),
TransferUi(
uuid = UUID.randomUUID().toString(),
createdDateTimestamp = Date().time - 5L * 86_400_000L,
expirationDateTimestamp = Calendar.getInstance().apply {
time = Date()
set(Calendar.DATE, get(Calendar.DATE) + 4)
}.time.time,
sizeUploaded = 89_723_143L,
downloadLimit = 2,
downloadLeft = 2,
message = null,
files = files,
),
TransferUi(
uuid = UUID.randomUUID().toString(),
createdDateTimestamp = Date().time - 0.5f.toLong() * 86_400_000L,
expirationDateTimestamp = Calendar.getInstance().apply {
time = Date()
set(Calendar.DATE, get(Calendar.DATE) + 7)
}.time.time,
sizeUploaded = 237_866_728L,
downloadLimit = 420_069,
downloadLeft = 402_690,
message = "3ème transfert. RAS.",
files = files,
),
)

SwissTransferTheme {
Surface {
TransferItemList(
transfers = transfers,
onClick = {},
)
}
}
}

0 comments on commit 246e2d9

Please sign in to comment.