Skip to content

Commit

Permalink
Format code
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinBoulongne committed Sep 3, 2024
1 parent 43df165 commit 6dcb062
Show file tree
Hide file tree
Showing 25 changed files with 2,343 additions and 2,373 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ fun BottomStickyButtonScaffold(
.fillMaxWidth()
.padding(contentPaddings)
) {
Box(modifier = Modifier.weight(1f), content = content)
Box(modifier = Modifier.weight(1.0f), content = content)
DoubleButtonCombo(topButton, bottomButton)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ private fun CoreButton(
enabled: Boolean,
onClick: () -> Unit,
imageVector: ImageVector?,
titleRes: Int
titleRes: Int,
) {
Button(
modifier = modifier.height(buttonSize.height),
Expand Down Expand Up @@ -114,7 +114,8 @@ enum class ButtonType(val buttonColors: @Composable () -> ButtonColors) {
}

private enum class ButtonSize(val height: Dp) {
LARGE(56.dp), SMALL(40.dp)
LARGE(56.dp),
SMALL(40.dp),
}

@Preview(name = "Light")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ private fun HorizontallyStackedButtons(
horizontalArrangement = Arrangement.spacedBy(Margin.Medium),
verticalAlignment = Alignment.CenterVertically,
) {
topButton(Modifier.weight(1f))
bottomButton(Modifier.weight(1f))
topButton(Modifier.weight(1.0f))
bottomButton(Modifier.weight(1.0f))
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,27 +61,17 @@ fun <T> TwoPaneScaffold(
val navigator = rememberListDetailPaneScaffoldNavigator<T>(
scaffoldDirective = paneScaffoldDirective.copy(
maxHorizontalPartitions = maxHorizontalPartitions,
horizontalPartitionSpacerSize = 0.dp
)
horizontalPartitionSpacerSize = 0.dp,
),
)

BackHandler(navigator.canNavigateBack()) {
navigator.navigateBack()
}
BackHandler(navigator.canNavigateBack()) { navigator.navigateBack() }

ListDetailPaneScaffold(
directive = navigator.scaffoldDirective,
value = navigator.scaffoldValue,
listPane = {
AnimatedPane {
navigator.listPane()
}
},
detailPane = {
AnimatedPane {
navigator.detailPane()
}
},
listPane = { AnimatedPane { navigator.listPane() } },
detailPane = { AnimatedPane { navigator.detailPane() } },
modifier = modifier,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ sealed class MainNavigation : NavigationDestination() {
*/
@Serializable
sealed class NewTransferNavigation : NavigationDestination() {

@Serializable
data object ImportFilesDestination : NewTransferNavigation()
@Serializable
Expand Down Expand Up @@ -83,6 +84,7 @@ sealed class NavigationDestination {
}

fun <T : NavigationDestination> toDestination(kClass: KClass<T>, backStackEntry: NavBackStackEntry?): T? {

fun kClassFromRoute(route: String) = kClass.sealedSubclasses.firstOrNull {
route.contains(it.qualifiedName.toString())
}
Expand All @@ -98,9 +100,7 @@ sealed class NavigationDestination {

private fun <T : NavigationDestination> createInstance(kClass: KClass<T>, bundle: Bundle?): T? {
return kClass.primaryConstructor?.let {
val args = it.parameters.associateWith { parameter ->
bundle?.get(parameter.name)
}
val args = it.parameters.associateWith { parameter -> bundle?.get(parameter.name) }
it.callBy(args)
} ?: kClass.objectInstance
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,20 +48,14 @@ fun MainNavHost(
exitTransition = { if (currentDestination.enableTransition) fadeOut() else ExitTransition.None },
) {
composable<SentDestination> {
SentScreen(
navigateToDetails = { navController.navigate(TransferDetailsDestination(it)) },
)
SentScreen(navigateToDetails = { navController.navigate(::TransferDetailsDestination) })
}
composable<ReceivedDestination> {
ReceivedScreen(
navigateToDetails = { navController.navigate(TransferDetailsDestination(it)) },
)
ReceivedScreen(navigateToDetails = { navController.navigate(::TransferDetailsDestination) })
}
composable<TransferDetailsDestination> {
val transferDetails: TransferDetailsDestination = it.toRoute()
TransferDetailsScreen(
transferId = transferDetails.transferId,
)
TransferDetailsScreen(transferId = transferDetails.transferId)
}
composable<SettingsDestination> {
SettingsScreenWrapper(windowAdaptiveInfo)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ fun MainScaffold(
windowAdaptiveInfo: WindowAdaptiveInfo,
content: @Composable () -> Unit = {},
) {

val navType by rememberNavType(currentDestination, windowAdaptiveInfo)

CompositionLocalProvider(LocalNavType provides navType) {
Expand All @@ -64,7 +63,7 @@ private fun MainScaffold(
content()
} else {
Column {
Box(modifier = Modifier.weight(1f)) {
Box(modifier = Modifier.weight(1.0f)) {
content()
}
HorizontalDivider()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ fun EmptyScreen() {
Text(
modifier = Modifier.widthIn(max = maxWidth),
text = stringResource(id = R.string.firstTransferDescription),
style = SwissTransferTheme.typography.bodyRegular
style = SwissTransferTheme.typography.bodyRegular,
)
Spacer(modifier = Modifier.height(Margin.Medium))
ConstraintLayout {
Expand All @@ -95,18 +95,18 @@ fun EmptyScreen() {
Icon(
modifier = Modifier
.constrainAs(icon) {
top.linkTo(parent.top)
end.linkTo(fab.start, margin = Margin.Small)
top.linkTo(anchor = parent.top)
end.linkTo(anchor = fab.start, margin = Margin.Small)
},
imageVector = AppIcons.Illu.ArrowCurvedDownright,
contentDescription = null,
)
NewTransferFab(
modifier = Modifier
.constrainAs(fab) {
start.linkTo(parent.start)
end.linkTo(parent.end)
top.linkTo(parent.top, Margin.Large)
start.linkTo(anchor = parent.start)
end.linkTo(anchor = parent.end)
top.linkTo(anchor = parent.top, margin = Margin.Large)
},
newTransferFabType = NewTransferFabType.EMPTY_STATE,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ fun SettingsDownloadsLimitScreen(navigateBack: (() -> Unit)?) {
Column(
modifier = Modifier
.verticalScroll(rememberScrollState())
.padding(paddingsValue)
.padding(paddingsValue),
) {
SettingTitle(titleRes = R.string.settingsDownloadsLimitTitle)

Expand All @@ -62,8 +62,8 @@ enum class DownloadsLimit(
override val imageVector: ImageVector? = null,
override val imageVectorResId: Int? = null,
) : SettingOption {
TWOHUNDREDFIFTY({ "250" }),
ONEHUNDRED({ "100" }),
TWO_HUNDRED_FIFTY({ "250" }),
ONE_HUNDRED({ "100" }),
TWENTY({ "20" }),
ONE({ "1" }),
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ import com.infomaniak.swisstransfer.ui.utils.*
@Composable
fun SettingsScreenWrapper(windowAdaptiveInfo: WindowAdaptiveInfo = currentWindowAdaptiveInfo()) {
TwoPaneScaffold<SettingsOptionScreens>(
windowAdaptiveInfo,
windowAdaptiveInfo = windowAdaptiveInfo,
listPane = { ListPane(this) },
detailPane = { DetailPane(this) }
detailPane = { DetailPane(this) },
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ fun SettingsThemeScreen(navigateBack: (() -> Unit)?) {
Column(
modifier = Modifier
.verticalScroll(rememberScrollState())
.padding(paddingsValue)
.padding(paddingsValue),
) {
SettingTitle(titleRes = R.string.settingsThemeTitle)

Expand All @@ -67,7 +67,7 @@ fun SettingsThemeScreen(navigateBack: (() -> Unit)?) {
enum class ThemeOption(
override val title: @Composable () -> String,
override val imageVector: ImageVector,
override val imageVectorResId: Int? = null
override val imageVectorResId: Int? = null,
) : SettingOption {
SYSTEM({ stringResource(R.string.settingsOptionThemeSystem) }, AppIcons.BlackAndWhiteCircle),
LIGHT({ stringResource(R.string.settingsOptionThemeLight) }, AppIcons.WhiteCircle),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ private fun SettingItemContent(
icon: ImageVector?,
titleRes: Int,
description: String?,
endIcon: EndIconType?
endIcon: EndIconType?,
) {
Row(
modifier = Modifier
Expand All @@ -92,7 +92,7 @@ private fun SettingItemContent(
Spacer(modifier = Modifier.width(Margin.Medium))
}

Column(modifier = Modifier.weight(1f)) {
Column(modifier = Modifier.weight(1.0f)) {
Text(text = stringResource(id = titleRes), style = SwissTransferTheme.typography.bodyRegular)

description?.let {
Expand All @@ -102,7 +102,6 @@ private fun SettingItemContent(
color = SwissTransferTheme.colors.tertiaryTextColor,
)
}

}

endIcon?.let {
Expand All @@ -119,15 +118,15 @@ private fun SettingItemPreview() {
Surface {
Column(modifier = Modifier.selectableGroup()) {
SettingTitle(R.string.appName)
SettingItem(R.string.appName, { true }, AppIcons.Add, "Clair", EndIconType.CHEVRON) {}
SettingItem(R.string.appName, { false }, AppIcons.Folder, endIcon = EndIconType.OPEN_OUTSIDE) {}
SettingItem(R.string.appName, { false }, description = "1.1.2") {}
SettingItem(R.string.appName, { false }) {}
SettingItem(R.string.appName, isSelected = { true }, AppIcons.Add, "Clair", EndIconType.CHEVRON) {}
SettingItem(R.string.appName, isSelected = { false }, AppIcons.Folder, endIcon = EndIconType.OPEN_OUTSIDE) {}
SettingItem(R.string.appName, isSelected = { false }, description = "1.1.2") {}
SettingItem(R.string.appName, isSelected = { false }) {}
SettingDivider()
SettingTitle(R.string.appName)
SettingItem(R.string.appName, { false }, endIcon = EndIconType.OPEN_OUTSIDE) {}
SettingItem(R.string.appName, { false }, endIcon = EndIconType.OPEN_OUTSIDE) {}
SettingItem(R.string.appName, { false }, description = "0.0.1", onClick = null)
SettingItem(R.string.appName, isSelected = { false }, endIcon = EndIconType.OPEN_OUTSIDE) {}
SettingItem(R.string.appName, isSelected = { false }, endIcon = EndIconType.OPEN_OUTSIDE) {}
SettingItem(R.string.appName, isSelected = { false }, description = "0.0.1", onClick = null)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ fun SingleSelectOptions(items: List<SettingOption>, selectedItem: () -> Int, set
private fun SettingOptionItem(item: SettingOption, isSelected: Boolean, onClick: () -> Unit) {
SharpRippleButton(
modifier = Modifier.selectable(selected = isSelected, onClick = onClick),
onClick = onClick
onClick = onClick,
) {
Row(
Modifier
Expand All @@ -72,7 +72,7 @@ private fun SettingOptionItem(item: SettingOption, isSelected: Boolean, onClick:
Spacer(modifier = Modifier.width(Margin.Medium))
}

Text(text = item.title(), Modifier.weight(1f))
Text(text = item.title(), Modifier.weight(1.0f))

if (isSelected) Spacer(modifier = Modifier.width(Margin.Medium))
AnimatedVisibility(
Expand Down Expand Up @@ -111,8 +111,8 @@ private fun SettingOptionItemPreview() {
override val imageVector: ImageVector = AppIcons.Add
override val imageVectorResId = null
}
SettingOptionItem(item, true) {}
SettingOptionItem(item, false) {}
SettingOptionItem(item = item, isSelected = true) {}
SettingOptionItem(item = item, isSelected = false) {}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ fun NewTransferNavHost(navController: NavHostController) {
ImportFilesScreen(navigateToTransferTypeScreen = { navController.navigate(TransferTypeDestination) })
}
composable<TransferTypeDestination> {
TransferTypeScreen(navigateToTransfer = { /*TODO*/ }, popBack = { navController.navigateUp() })
TransferTypeScreen(navigateToTransfer = { /* TODO */ }, popBack = { navController.navigateUp() })
}
composable<TransferOptionsDestination> {
TransferOptionsScreen()
Expand All @@ -54,5 +54,4 @@ fun NewTransferNavHost(navController: NavHostController) {
UploadSuccessScreen()
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ fun ImportFilesScreen(navigateToTransferTypeScreen: () -> Unit) {
SwissTransferTobAppBar(
titleRes = R.string.importFilesScreenTitle,
navigationMenu = null,
TopAppBarButton.closeButton { /*TODO*/ }
TopAppBarButton.closeButton { /* TODO */ },
)
},
topButton = { modifier ->
Expand Down Expand Up @@ -89,11 +89,11 @@ private fun UploadSourceChoiceBottomSheet(
titleRes = R.string.transferUploadSourceChoiceTitle,
content = {
Column {
BottomSheetItem(AppIcons.Camera, R.string.transferUploadSourceChoiceCamera) { /*TODO*/ }
BottomSheetItem(AppIcons.Camera, R.string.transferUploadSourceChoiceCamera) { /* TODO */ }
HorizontalDivider(Modifier.padding(horizontal = Margin.Medium))
BottomSheetItem(AppIcons.PolaroidLandscape, R.string.transferUploadSourceChoiceGallery) { /*TODO*/ }
BottomSheetItem(AppIcons.PolaroidLandscape, R.string.transferUploadSourceChoiceGallery) { /* TODO */ }
HorizontalDivider(Modifier.padding(horizontal = Margin.Medium))
BottomSheetItem(AppIcons.Folder, R.string.transferUploadSourceChoiceFiles) { /*TODO*/ }
BottomSheetItem(AppIcons.Folder, R.string.transferUploadSourceChoiceFiles) { /* TODO */ }
}
},
)
Expand All @@ -115,7 +115,7 @@ private fun ImportFilesScreenPreview() {
private fun ImportChoiceBottomSheetPreview() {
SwissTransferTheme {
Surface {
UploadSourceChoiceBottomSheet({ true }, {})
UploadSourceChoiceBottomSheet(isBottomSheetVisible = { true }, onDismissRequest = {})
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ fun TransferTypeScreen(navigateToTransfer: (TransferType) -> Unit, popBack: () -
SwissTransferTobAppBar(
titleRes = R.string.transferTypeScreenTitle,
navigationMenu = TopAppBarButton.backButton(popBack),
TopAppBarButton.closeButton { /*TODO*/ }
TopAppBarButton.closeButton { /* TODO */ }
)
}) { contentPaddings ->
Column(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ fun TransferTypeButtons(items: List<TransferType>, navigateToTransfer: (Transfer
TransferTypeButton(
modifier = Modifier.aspectRatio(0.87f),
item = item,
onClick = { navigateToTransfer(item) }
onClick = { navigateToTransfer(item) },
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ fun SwissTransferTheme(
MaterialTheme(
colorScheme = if (darkTheme) DarkColorScheme else LightColorScheme,
shapes = Shapes,
content = content
content = content,
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,5 +136,5 @@ data class CustomTypography(
val specificMedium32: TextStyle,
val specificMedium22: TextStyle,
val specificLight22: TextStyle,
val specificLight18: TextStyle
val specificLight18: TextStyle,
)
Loading

0 comments on commit 6dcb062

Please sign in to comment.