From f613264623417d4d86eedfb9c5efcf3fc76838b2 Mon Sep 17 00:00:00 2001 From: Kevin Boulongne Date: Thu, 17 Oct 2024 12:51:38 +0200 Subject: [PATCH 01/11] Bump ST Core to `0.3.0` --- .../java/com/infomaniak/swisstransfer/ui/MainApplication.kt | 2 +- .../ui/screen/main/settings/SettingsDownloadsLimitScreen.kt | 2 +- .../swisstransfer/ui/screen/main/settings/SettingsScreen.kt | 2 +- .../ui/screen/main/settings/SettingsScreenWrapper.kt | 2 +- gradle/libs.versions.toml | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/MainApplication.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/MainApplication.kt index 926569f9b..5c14b1207 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/MainApplication.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/MainApplication.kt @@ -40,7 +40,7 @@ class MainApplication : Application() { override fun onCreate() { super.onCreate() - globalCoroutineScope.launch { swissTransferInjection.loadDefaultAccount() } + globalCoroutineScope.launch { swissTransferInjection.accountManager.loadUser(userId = 0) } SentryAndroid.init(this) { options: SentryAndroidOptions -> // Register the callback as an option diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsDownloadsLimitScreen.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsDownloadsLimitScreen.kt index a5325f87f..21d7dc8e9 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsDownloadsLimitScreen.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsDownloadsLimitScreen.kt @@ -60,7 +60,7 @@ private fun SettingsThemeScreenPreview() { SwissTransferTheme { Surface { SettingsDownloadsLimitScreen( - downloadLimit = DownloadLimit.TWOHUNDREDFIFTY, + downloadLimit = DownloadLimit.TWO_HUNDRED_FIFTY, navigateBack = {}, onDownloadLimitChange = {}, ) diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsScreen.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsScreen.kt index e91509901..9827fdcf6 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsScreen.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsScreen.kt @@ -192,7 +192,7 @@ private fun SettingsScreenPreview() { SettingsScreen( theme = GetSetCallbacks(get = { Theme.SYSTEM }, set = {}), validityPeriod = GetSetCallbacks(get = { ValidityPeriod.THIRTY }, set = {}), - downloadLimit = GetSetCallbacks(get = { DownloadLimit.TWOHUNDREDFIFTY }, set = {}), + downloadLimit = GetSetCallbacks(get = { DownloadLimit.TWO_HUNDRED_FIFTY }, set = {}), emailLanguage = GetSetCallbacks(get = { EmailLanguage.ENGLISH }, set = {}), onItemClick = {}, getSelectedSetting = { null }, diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsScreenWrapper.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsScreenWrapper.kt index 56bf8b4ef..d62567528 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsScreenWrapper.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsScreenWrapper.kt @@ -176,7 +176,7 @@ private fun SettingsScreenWrapperPreview() { SettingsScreenWrapper( theme = GetSetCallbacks(get = { Theme.SYSTEM }, set = {}), validityPeriod = GetSetCallbacks(get = { ValidityPeriod.THIRTY }, set = {}), - downloadLimit = GetSetCallbacks(get = { DownloadLimit.TWOHUNDREDFIFTY }, set = {}), + downloadLimit = GetSetCallbacks(get = { DownloadLimit.TWO_HUNDRED_FIFTY }, set = {}), emailLanguage = GetSetCallbacks(get = { EmailLanguage.ENGLISH }, set = {}), ) } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index f28fca5bd..63238dcee 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -16,7 +16,7 @@ kotlin = "2.0.20" lifecycleRuntimeKtx = "2.8.6" navigation = "2.8.1" serialization = "1.7.1" -swisstransfer = "0.1.1" +swisstransfer = "0.3.0" sentry = "4.12.0" sentry-android = "7.15.0" From 63c2fa60e35cb10f5713020d680e81336ceaeb19 Mon Sep 17 00:00:00 2001 From: Kevin Boulongne Date: Thu, 17 Oct 2024 14:14:37 +0200 Subject: [PATCH 02/11] feat: Add `@PreviewAllWindows` --- .../com/infomaniak/swisstransfer/ui/utils/MultiplePreview.kt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/utils/MultiplePreview.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/utils/MultiplePreview.kt index 97dbec6b4..b7b22e5af 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/utils/MultiplePreview.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/utils/MultiplePreview.kt @@ -67,3 +67,8 @@ annotation class PreviewSmallWindow device = "spec:id=reference_tablet,shape=Normal,width=1280,height=800,unit=dp,dpi=240", ) annotation class PreviewLargeWindow + +// Small + Large +@PreviewSmallWindow +@PreviewLargeWindow +annotation class PreviewAllWindows From aed63961af4150806f56917f342f07039ded0a0d Mon Sep 17 00:00:00 2001 From: Kevin Boulongne Date: Thu, 17 Oct 2024 14:27:49 +0200 Subject: [PATCH 03/11] feat: Use `@PreviewAllWindows` --- .../swisstransfer/ui/components/BrandTopAppBar.kt | 6 ++---- .../swisstransfer/ui/components/FileItem.kt | 6 ++---- .../swisstransfer/ui/components/FileItemList.kt | 6 ++---- .../ui/components/SwissTransferTopAppBar.kt | 6 ++---- .../swisstransfer/ui/screen/main/MainScreen.kt | 6 ++---- .../ui/screen/main/received/ReceivedScreen.kt | 6 ++---- .../ui/screen/main/sent/SentEmptyScreen.kt | 6 ++---- .../ui/screen/main/sent/SentListScreen.kt | 6 ++---- .../swisstransfer/ui/screen/main/sent/SentScreen.kt | 6 ++---- .../main/settings/SettingsDownloadsLimitScreen.kt | 4 ++-- .../main/settings/SettingsEmailLanguageScreen.kt | 4 ++-- .../ui/screen/main/settings/SettingsScreen.kt | 4 ++-- .../screen/main/settings/SettingsScreenWrapper.kt | 3 +-- .../ui/screen/main/settings/SettingsThemeScreen.kt | 4 ++-- .../main/settings/SettingsValidityPeriodScreen.kt | 4 ++-- .../main/settings/components/OptionScaffold.kt | 6 ++---- .../ui/screen/newtransfer/NewTransferScreen.kt | 6 ++---- .../newtransfer/importfiles/ImportFilesScreen.kt | 13 ++++++++----- .../importfiles/UploadSourceChoiceBottomSheet.kt | 8 +++----- 19 files changed, 44 insertions(+), 66 deletions(-) diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/components/BrandTopAppBar.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/components/BrandTopAppBar.kt index be9aebe95..c344ffc03 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/components/BrandTopAppBar.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/components/BrandTopAppBar.kt @@ -33,8 +33,7 @@ import com.infomaniak.swisstransfer.ui.images.illus.LogoInfomaniak import com.infomaniak.swisstransfer.ui.images.illus.LogoSwissTransfer import com.infomaniak.swisstransfer.ui.theme.Margin import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme -import com.infomaniak.swisstransfer.ui.utils.PreviewLargeWindow -import com.infomaniak.swisstransfer.ui.utils.PreviewSmallWindow +import com.infomaniak.swisstransfer.ui.utils.PreviewAllWindows @Composable @OptIn(ExperimentalMaterial3Api::class) @@ -58,8 +57,7 @@ fun BrandTopAppBar() { ) } -@PreviewSmallWindow -@PreviewLargeWindow +@PreviewAllWindows @Composable private fun BrandTopAppBarPreview() { SwissTransferTheme { diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/components/FileItem.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/components/FileItem.kt index ed8883c2b..6be98e833 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/components/FileItem.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/components/FileItem.kt @@ -46,8 +46,7 @@ import com.infomaniak.swisstransfer.ui.theme.CustomShapes import com.infomaniak.swisstransfer.ui.theme.LocalIsDarkMode import com.infomaniak.swisstransfer.ui.theme.Margin import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme -import com.infomaniak.swisstransfer.ui.utils.PreviewLargeWindow -import com.infomaniak.swisstransfer.ui.utils.PreviewSmallWindow +import com.infomaniak.swisstransfer.ui.utils.PreviewAllWindows import com.infomaniak.swisstransfer.ui.utils.fileType import com.infomaniak.swisstransfer.ui.utils.hasPreview @@ -196,8 +195,7 @@ private fun FileIcon(fileType: FileType) { } } -@PreviewSmallWindow -@PreviewLargeWindow +@PreviewAllWindows @Composable private fun FileItemPreview() { SwissTransferTheme { diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/components/FileItemList.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/components/FileItemList.kt index 8a7dbbbfd..35299de01 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/components/FileItemList.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/components/FileItemList.kt @@ -26,8 +26,7 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.unit.dp import com.infomaniak.swisstransfer.ui.theme.Margin import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme -import com.infomaniak.swisstransfer.ui.utils.PreviewLargeWindow -import com.infomaniak.swisstransfer.ui.utils.PreviewSmallWindow +import com.infomaniak.swisstransfer.ui.utils.PreviewAllWindows @Composable fun FileItemList( @@ -58,8 +57,7 @@ fun FileItemList( } } -@PreviewSmallWindow -@PreviewLargeWindow +@PreviewAllWindows @Composable private fun FileItemListPreview() { val files = listOf(object : FileUiItem { diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/components/SwissTransferTopAppBar.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/components/SwissTransferTopAppBar.kt index b6f18d2f0..f8106f1e9 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/components/SwissTransferTopAppBar.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/components/SwissTransferTopAppBar.kt @@ -29,8 +29,7 @@ import com.infomaniak.swisstransfer.ui.images.icons.Add import com.infomaniak.swisstransfer.ui.images.icons.ArrowLeft import com.infomaniak.swisstransfer.ui.images.icons.Cross import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme -import com.infomaniak.swisstransfer.ui.utils.PreviewLargeWindow -import com.infomaniak.swisstransfer.ui.utils.PreviewSmallWindow +import com.infomaniak.swisstransfer.ui.utils.PreviewAllWindows @Composable @OptIn(ExperimentalMaterial3Api::class) @@ -75,8 +74,7 @@ data class TopAppBarButton( } } -@PreviewSmallWindow -@PreviewLargeWindow +@PreviewAllWindows @Composable private fun SwissTransferTopAppBarPreview() { SwissTransferTheme { diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/MainScreen.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/MainScreen.kt index b45e46d88..389076787 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/MainScreen.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/MainScreen.kt @@ -28,8 +28,7 @@ import com.infomaniak.swisstransfer.ui.navigation.MainNavigation import com.infomaniak.swisstransfer.ui.navigation.NavigationDestination.Companion.toDestination import com.infomaniak.swisstransfer.ui.screen.main.components.MainScaffold import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme -import com.infomaniak.swisstransfer.ui.utils.PreviewLargeWindow -import com.infomaniak.swisstransfer.ui.utils.PreviewSmallWindow +import com.infomaniak.swisstransfer.ui.utils.PreviewAllWindows @Composable fun MainScreen() { @@ -49,8 +48,7 @@ fun MainScreen() { ) } -@PreviewSmallWindow -@PreviewLargeWindow +@PreviewAllWindows @Composable private fun MainScreenPreview() { SwissTransferTheme { 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 46e2ea386..1a2f21a73 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 @@ -37,8 +37,7 @@ import com.infomaniak.swisstransfer.ui.screen.main.received.components.ReceivedE import com.infomaniak.swisstransfer.ui.screen.main.sent.SentViewModel import com.infomaniak.swisstransfer.ui.theme.Margin import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme -import com.infomaniak.swisstransfer.ui.utils.PreviewLargeWindow -import com.infomaniak.swisstransfer.ui.utils.PreviewSmallWindow +import com.infomaniak.swisstransfer.ui.utils.PreviewAllWindows @Composable fun ReceivedScreen( @@ -104,8 +103,7 @@ private fun ReceivedScreen( } } -@PreviewSmallWindow -@PreviewLargeWindow +@PreviewAllWindows @Composable private fun ReceivedScreenPreview() { SwissTransferTheme { diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/sent/SentEmptyScreen.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/sent/SentEmptyScreen.kt index dafa8336b..1d579916b 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/sent/SentEmptyScreen.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/sent/SentEmptyScreen.kt @@ -35,8 +35,7 @@ import com.infomaniak.swisstransfer.ui.images.illus.ArrowDownRightCurved import com.infomaniak.swisstransfer.ui.theme.Dimens import com.infomaniak.swisstransfer.ui.theme.Margin import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme -import com.infomaniak.swisstransfer.ui.utils.PreviewLargeWindow -import com.infomaniak.swisstransfer.ui.utils.PreviewSmallWindow +import com.infomaniak.swisstransfer.ui.utils.PreviewAllWindows @Composable fun SentEmptyScreen() { @@ -85,8 +84,7 @@ fun SentEmptyScreen() { } } -@PreviewSmallWindow -@PreviewLargeWindow +@PreviewAllWindows @Composable private fun SentEmptyScreenPreview() { SwissTransferTheme { diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/sent/SentListScreen.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/sent/SentListScreen.kt index 634e959dd..2ac1937b4 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/sent/SentListScreen.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/sent/SentListScreen.kt @@ -25,8 +25,7 @@ import com.infomaniak.swisstransfer.ui.components.FileItemList import com.infomaniak.swisstransfer.ui.components.FileUiItem import com.infomaniak.swisstransfer.ui.theme.Margin import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme -import com.infomaniak.swisstransfer.ui.utils.PreviewLargeWindow -import com.infomaniak.swisstransfer.ui.utils.PreviewSmallWindow +import com.infomaniak.swisstransfer.ui.utils.PreviewAllWindows @Composable fun SentListScreen(transfers: List) { @@ -60,8 +59,7 @@ fun SentListScreen(transfers: List) { ) } -@PreviewSmallWindow -@PreviewLargeWindow +@PreviewAllWindows @Composable private fun SentListScreenPreview() { SwissTransferTheme { 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 84a9f7b88..57adb8c33 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 @@ -27,8 +27,7 @@ import com.infomaniak.swisstransfer.ui.components.NewTransferFab import com.infomaniak.swisstransfer.ui.components.NewTransferFabType import com.infomaniak.swisstransfer.ui.screen.main.components.BrandTopAppBarScaffold import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme -import com.infomaniak.swisstransfer.ui.utils.PreviewLargeWindow -import com.infomaniak.swisstransfer.ui.utils.PreviewSmallWindow +import com.infomaniak.swisstransfer.ui.utils.PreviewAllWindows import com.infomaniak.swisstransfer.ui.utils.isWindowSmall @Composable @@ -61,8 +60,7 @@ private fun SentScreen(transfers: List?) { } } -@PreviewSmallWindow -@PreviewLargeWindow +@PreviewAllWindows @Composable private fun SentScreenPreview() { SwissTransferTheme { diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsDownloadsLimitScreen.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsDownloadsLimitScreen.kt index 21d7dc8e9..68c42b695 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsDownloadsLimitScreen.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsDownloadsLimitScreen.kt @@ -25,7 +25,7 @@ import com.infomaniak.swisstransfer.R import com.infomaniak.swisstransfer.ui.screen.main.settings.components.OptionScaffold import com.infomaniak.swisstransfer.ui.screen.main.settings.components.SettingOption import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme -import com.infomaniak.swisstransfer.ui.utils.PreviewSmallWindow +import com.infomaniak.swisstransfer.ui.utils.PreviewAllWindows @Composable fun SettingsDownloadsLimitScreen( @@ -54,7 +54,7 @@ enum class DownloadLimitOption( ONE({ "1" }), } -@PreviewSmallWindow +@PreviewAllWindows @Composable private fun SettingsThemeScreenPreview() { SwissTransferTheme { diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsEmailLanguageScreen.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsEmailLanguageScreen.kt index 68b2b944d..c6bd9cb82 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsEmailLanguageScreen.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsEmailLanguageScreen.kt @@ -26,7 +26,7 @@ import com.infomaniak.swisstransfer.R import com.infomaniak.swisstransfer.ui.screen.main.settings.components.OptionScaffold import com.infomaniak.swisstransfer.ui.screen.main.settings.components.SettingOption import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme -import com.infomaniak.swisstransfer.ui.utils.PreviewSmallWindow +import com.infomaniak.swisstransfer.ui.utils.PreviewAllWindows @Composable fun SettingsEmailLanguageScreen( @@ -56,7 +56,7 @@ enum class EmailLanguageOption( SPANISH({ stringResource(R.string.settingsEmailLanguageValueSpanish) }, imageVectorResId = R.drawable.flag_es), } -@PreviewSmallWindow +@PreviewAllWindows @Composable private fun SettingsThemeScreenPreview() { SwissTransferTheme { diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsScreen.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsScreen.kt index 9827fdcf6..70757eeae 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsScreen.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsScreen.kt @@ -47,7 +47,7 @@ import com.infomaniak.swisstransfer.ui.screen.main.settings.components.SettingTi import com.infomaniak.swisstransfer.ui.theme.Margin import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme import com.infomaniak.swisstransfer.ui.utils.GetSetCallbacks -import com.infomaniak.swisstransfer.ui.utils.PreviewSmallWindow +import com.infomaniak.swisstransfer.ui.utils.PreviewAllWindows @Composable fun SettingsScreen( @@ -184,7 +184,7 @@ enum class SettingsOptionScreens { DISCOVER_INFOMANIAK, SHARE_IDEAS, GIVE_FEEDBACK, } -@PreviewSmallWindow +@PreviewAllWindows @Composable private fun SettingsScreenPreview() { SwissTransferTheme { diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsScreenWrapper.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsScreenWrapper.kt index d62567528..ebb8ed197 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsScreenWrapper.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsScreenWrapper.kt @@ -167,8 +167,7 @@ private fun NoSelectionEmptyState() { } } -@PreviewSmallWindow -@PreviewLargeWindow +@PreviewAllWindows @Composable private fun SettingsScreenWrapperPreview() { SwissTransferTheme { diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsThemeScreen.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsThemeScreen.kt index 1ba15baf4..9289b2db0 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsThemeScreen.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsThemeScreen.kt @@ -30,7 +30,7 @@ import com.infomaniak.swisstransfer.ui.images.icons.CircleWhite import com.infomaniak.swisstransfer.ui.screen.main.settings.components.OptionScaffold import com.infomaniak.swisstransfer.ui.screen.main.settings.components.SettingOption import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme -import com.infomaniak.swisstransfer.ui.utils.PreviewSmallWindow +import com.infomaniak.swisstransfer.ui.utils.PreviewAllWindows @Composable fun SettingsThemeScreen( @@ -58,7 +58,7 @@ enum class ThemeOption( DARK({ stringResource(R.string.settingsOptionThemeDark) }, AppIcons.CircleBlack), } -@PreviewSmallWindow +@PreviewAllWindows @Composable private fun SettingsThemeScreenPreview() { SwissTransferTheme { diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsValidityPeriodScreen.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsValidityPeriodScreen.kt index 71a463ef9..07880b583 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsValidityPeriodScreen.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsValidityPeriodScreen.kt @@ -26,7 +26,7 @@ import com.infomaniak.swisstransfer.R import com.infomaniak.swisstransfer.ui.screen.main.settings.components.OptionScaffold import com.infomaniak.swisstransfer.ui.screen.main.settings.components.SettingOption import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme -import com.infomaniak.swisstransfer.ui.utils.PreviewSmallWindow +import com.infomaniak.swisstransfer.ui.utils.PreviewAllWindows @Composable fun SettingsValidityPeriodScreen( @@ -55,7 +55,7 @@ enum class ValidityPeriodOption( ONE({ pluralStringResource(R.plurals.settingsValidityPeriodValue, 1, 1) }), } -@PreviewSmallWindow +@PreviewAllWindows @Composable private fun SettingsThemeScreenPreview() { SwissTransferTheme { diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/components/OptionScaffold.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/components/OptionScaffold.kt index e9f8fcd33..defed04a6 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/components/OptionScaffold.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/components/OptionScaffold.kt @@ -33,8 +33,7 @@ import com.infomaniak.swisstransfer.ui.components.TopAppBarButton import com.infomaniak.swisstransfer.ui.screen.main.components.SmallWindowTopAppBarScaffold import com.infomaniak.swisstransfer.ui.screen.main.settings.ThemeOption import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme -import com.infomaniak.swisstransfer.ui.utils.PreviewLargeWindow -import com.infomaniak.swisstransfer.ui.utils.PreviewSmallWindow +import com.infomaniak.swisstransfer.ui.utils.PreviewAllWindows @Composable fun OptionScaffold( @@ -64,8 +63,7 @@ fun OptionScaffold( } } -@PreviewSmallWindow -@PreviewLargeWindow +@PreviewAllWindows @Composable private fun OptionScaffoldPreview() { SwissTransferTheme { diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/NewTransferScreen.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/NewTransferScreen.kt index 3b775e7ef..e12920249 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/NewTransferScreen.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/NewTransferScreen.kt @@ -20,8 +20,7 @@ package com.infomaniak.swisstransfer.ui.screen.newtransfer import androidx.compose.runtime.Composable import androidx.navigation.compose.rememberNavController import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme -import com.infomaniak.swisstransfer.ui.utils.PreviewLargeWindow -import com.infomaniak.swisstransfer.ui.utils.PreviewSmallWindow +import com.infomaniak.swisstransfer.ui.utils.PreviewAllWindows @Composable fun NewTransferScreen(closeActivity: () -> Unit) { @@ -29,8 +28,7 @@ fun NewTransferScreen(closeActivity: () -> Unit) { NewTransferNavHost(navController, closeActivity) } -@PreviewSmallWindow -@PreviewLargeWindow +@PreviewAllWindows @Composable private fun NewTransferPreview() { SwissTransferTheme { diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/importfiles/ImportFilesScreen.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/importfiles/ImportFilesScreen.kt index ba400fa79..d447b48b6 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/importfiles/ImportFilesScreen.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/importfiles/ImportFilesScreen.kt @@ -36,8 +36,7 @@ import com.infomaniak.swisstransfer.ui.images.illus.MascotWithMagnifyingGlass import com.infomaniak.swisstransfer.ui.screen.newtransfer.NewTransferViewModel import com.infomaniak.swisstransfer.ui.screen.newtransfer.TransferFile import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme -import com.infomaniak.swisstransfer.ui.utils.PreviewLargeWindow -import com.infomaniak.swisstransfer.ui.utils.PreviewSmallWindow +import com.infomaniak.swisstransfer.ui.utils.PreviewAllWindows @Composable fun ImportFilesScreen( @@ -114,11 +113,15 @@ private fun ImportFilesScreen( ) } -@PreviewSmallWindow -@PreviewLargeWindow +@PreviewAllWindows @Composable private fun ImportFilesScreenPreview() { SwissTransferTheme { - ImportFilesScreen({ emptyList() }, {}, navigateToTransferTypeScreen = {}, closeActivity = {}) + ImportFilesScreen( + transferFiles = { emptyList() }, + addFiles = {}, + navigateToTransferTypeScreen = {}, + closeActivity = {}, + ) } } diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/importfiles/UploadSourceChoiceBottomSheet.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/importfiles/UploadSourceChoiceBottomSheet.kt index 7c762f125..f250c329f 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/importfiles/UploadSourceChoiceBottomSheet.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/importfiles/UploadSourceChoiceBottomSheet.kt @@ -32,8 +32,7 @@ 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.PreviewLargeWindow -import com.infomaniak.swisstransfer.ui.utils.PreviewSmallWindow +import com.infomaniak.swisstransfer.ui.utils.PreviewAllWindows @Composable fun UploadSourceChoiceBottomSheet( @@ -79,8 +78,7 @@ fun UploadSourceChoiceBottomSheet( } } -@PreviewSmallWindow -@PreviewLargeWindow +@PreviewAllWindows @Composable private fun UploadSourceChoiceBottomSheetPreview() { SwissTransferTheme { @@ -88,7 +86,7 @@ private fun UploadSourceChoiceBottomSheetPreview() { UploadSourceChoiceBottomSheet( isBottomSheetVisible = { true }, onFilePickerClicked = {}, - closeBottomSheet = {} + closeBottomSheet = {}, ) } } From 4a1c86b417f89c0160995f678afef8f742092d99 Mon Sep 17 00:00:00 2001 From: Gibran Chevalley Date: Thu, 17 Oct 2024 10:54:46 +0200 Subject: [PATCH 04/11] Add the possibility to make button load --- .../swisstransfer/ui/components/Buttons.kt | 114 ++++++++++++++++-- .../importfiles/ImportFilesScreen.kt | 2 +- 2 files changed, 105 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/components/Buttons.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/components/Buttons.kt index c02cdb43b..f835a4ea1 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/components/Buttons.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/components/Buttons.kt @@ -22,7 +22,12 @@ import androidx.annotation.StringRes import androidx.compose.foundation.layout.* import androidx.compose.material3.* import androidx.compose.runtime.Composable +import androidx.compose.runtime.derivedStateOf +import androidx.compose.runtime.getValue +import androidx.compose.runtime.remember +import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.alpha import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.vector.ImageVector import androidx.compose.ui.res.stringResource @@ -37,28 +42,60 @@ import com.infomaniak.swisstransfer.ui.theme.Dimens import com.infomaniak.swisstransfer.ui.theme.Margin import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme + +/** + * Specifying a progress has the priority over specifying showIndeterminateProgress + */ @Composable fun LargeButton( @StringRes titleRes: Int, modifier: Modifier = Modifier, style: ButtonType = ButtonType.PRIMARY, - enabled: Boolean = true, + enabled: () -> Boolean = { true }, + showIndeterminateProgress: () -> Boolean = { false }, + determinateProgress: (() -> Float)? = null, onClick: () -> Unit, imageVector: ImageVector? = null, ) { - CoreButton(titleRes, modifier, ButtonSize.LARGE, style, enabled, onClick, imageVector) + CoreButton( + titleRes, + modifier, + ButtonSize.LARGE, + style, + enabled, + showIndeterminateProgress, + determinateProgress, + onClick, + imageVector, + ) } + +/** + * Specifying a progress has the priority over specifying showIndeterminateProgress + */ @Composable fun SmallButton( @StringRes titleRes: Int, modifier: Modifier = Modifier, style: ButtonType = ButtonType.PRIMARY, - enabled: Boolean = true, + enabled: () -> Boolean = { true }, + showIndeterminateProgress: () -> Boolean = { false }, + determinateProgress: (() -> Float)? = null, onClick: () -> Unit, imageVector: ImageVector? = null, ) { - CoreButton(titleRes, modifier, ButtonSize.SMALL, style, enabled, onClick, imageVector) + CoreButton( + titleRes, + modifier, + ButtonSize.SMALL, + style, + enabled, + showIndeterminateProgress, + determinateProgress, + onClick, + imageVector, + ) } @Composable @@ -67,17 +104,47 @@ private fun CoreButton( modifier: Modifier, buttonSize: ButtonSize, style: ButtonType, - enabled: Boolean, + enabled: () -> Boolean, + showIndeterminateProgress: () -> Boolean, + progress: (() -> Float)?, onClick: () -> Unit, imageVector: ImageVector?, ) { + val isEnabled by remember { derivedStateOf { enabled() || showIndeterminateProgress() } } + val buttonColors = style.buttonColors() + Button( modifier = modifier.height(buttonSize.height), - colors = style.buttonColors(), + colors = buttonColors, shape = CustomShapes.medium, - enabled = enabled, + enabled = isEnabled, onClick = onClick, ) { + when { + progress != null -> { + val (progressColor, progressModifier) = getProgressSpecs(buttonColors) + Box(contentAlignment = Alignment.Center) { + ButtonTextContent(imageVector, titleRes, Modifier.alpha(0f)) + CircularProgressIndicator(modifier = progressModifier, color = progressColor, progress = progress) + } + } + showIndeterminateProgress() -> { + val (progressColor, progressModifier) = getProgressSpecs(buttonColors) + Box(contentAlignment = Alignment.Center) { + ButtonTextContent(imageVector, titleRes, Modifier.alpha(0f)) + CircularProgressIndicator(modifier = progressModifier, color = progressColor) + } + } + else -> { + ButtonTextContent(imageVector, titleRes) + } + } + } +} + +@Composable +private fun ButtonTextContent(imageVector: ImageVector?, titleRes: Int, modifier: Modifier = Modifier) { + Row(modifier = modifier) { imageVector?.let { Icon(modifier = Modifier.size(Margin.Medium), imageVector = it, contentDescription = null) Spacer(modifier = Modifier.width(Margin.Small)) @@ -86,6 +153,15 @@ private fun CoreButton( } } +@Composable +private fun getProgressSpecs(buttonColors: ButtonColors): Pair { + val progressColor = buttonColors.contentColor + val progressModifier = Modifier + .fillMaxHeight(0.8f) + .aspectRatio(1f) + return Pair(progressColor, progressModifier) +} + enum class ButtonType(val buttonColors: @Composable () -> ButtonColors) { PRIMARY({ ButtonDefaults.buttonColors( @@ -118,8 +194,8 @@ private enum class ButtonSize(val height: Dp) { SMALL(40.dp), } -@Preview(name = "Light") -@Preview(name = "Dark", uiMode = Configuration.UI_MODE_NIGHT_YES or Configuration.UI_MODE_TYPE_NORMAL) +@Preview(name = "Light", widthDp = 800) +@Preview(name = "Dark", widthDp = 800, uiMode = Configuration.UI_MODE_NIGHT_YES or Configuration.UI_MODE_TYPE_NORMAL) @Composable private fun LargeButtonPreview() { SwissTransferTheme { @@ -127,9 +203,27 @@ private fun LargeButtonPreview() { Column { ButtonType.entries.forEach { Row { - LargeButton(titleRes = R.string.appName, style = it, imageVector = AppIcons.Add, onClick = {}) + LargeButton(titleRes = R.string.appName, style = it, onClick = {}, imageVector = AppIcons.Add) + Spacer(modifier = Modifier.width(Margin.Small)) + LargeButton( + titleRes = R.string.appName, + style = it, + determinateProgress = { 0.3f }, + onClick = {}, + imageVector = AppIcons.Add + ) + Spacer(modifier = Modifier.width(Margin.Small)) + SmallButton(titleRes = R.string.appName, style = it, imageVector = AppIcons.Add, onClick = {}) + Spacer(modifier = Modifier.width(Margin.Small)) + SmallButton( + titleRes = R.string.appName, + style = it, + determinateProgress = { 0.3f }, + imageVector = AppIcons.Add, + onClick = {} + ) } Spacer(modifier = Modifier.height(Margin.Medium)) } diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/importfiles/ImportFilesScreen.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/importfiles/ImportFilesScreen.kt index d447b48b6..f9b1e3693 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/importfiles/ImportFilesScreen.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/importfiles/ImportFilesScreen.kt @@ -85,7 +85,7 @@ private fun ImportFilesScreen( LargeButton( modifier = modifier, titleRes = R.string.buttonNext, - enabled = isNextButtonEnabled, + enabled = { isNextButtonEnabled }, onClick = { navigateToTransferTypeScreen() }, ) }, From 12d9f5067ff9bd5a30491f000708951ea0456aa5 Mon Sep 17 00:00:00 2001 From: Gibran Chevalley Date: Thu, 17 Oct 2024 12:47:30 +0200 Subject: [PATCH 05/11] Disable button when it's loading --- .../com/infomaniak/swisstransfer/ui/components/Buttons.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/components/Buttons.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/components/Buttons.kt index f835a4ea1..665ef1364 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/components/Buttons.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/components/Buttons.kt @@ -110,7 +110,7 @@ private fun CoreButton( onClick: () -> Unit, imageVector: ImageVector?, ) { - val isEnabled by remember { derivedStateOf { enabled() || showIndeterminateProgress() } } + val isEnabled by remember { derivedStateOf { enabled() && !showIndeterminateProgress() && progress == null } } val buttonColors = style.buttonColors() Button( @@ -155,7 +155,7 @@ private fun ButtonTextContent(imageVector: ImageVector?, titleRes: Int, modifier @Composable private fun getProgressSpecs(buttonColors: ButtonColors): Pair { - val progressColor = buttonColors.contentColor + val progressColor = buttonColors.disabledContentColor val progressModifier = Modifier .fillMaxHeight(0.8f) .aspectRatio(1f) From bcf66c7cc9fa83850e78e1b944e04a1cdd39f9a0 Mon Sep 17 00:00:00 2001 From: Gibran Chevalley Date: Thu, 17 Oct 2024 13:02:47 +0200 Subject: [PATCH 06/11] Factorize the fact of keep the button's size when loading --- .../swisstransfer/ui/components/Buttons.kt | 26 ++++++++++++------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/components/Buttons.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/components/Buttons.kt index 665ef1364..5e6515193 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/components/Buttons.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/components/Buttons.kt @@ -123,15 +123,13 @@ private fun CoreButton( when { progress != null -> { val (progressColor, progressModifier) = getProgressSpecs(buttonColors) - Box(contentAlignment = Alignment.Center) { - ButtonTextContent(imageVector, titleRes, Modifier.alpha(0f)) + KeepButtonSize(imageVector, titleRes) { CircularProgressIndicator(modifier = progressModifier, color = progressColor, progress = progress) } } showIndeterminateProgress() -> { val (progressColor, progressModifier) = getProgressSpecs(buttonColors) - Box(contentAlignment = Alignment.Center) { - ButtonTextContent(imageVector, titleRes, Modifier.alpha(0f)) + KeepButtonSize(imageVector, titleRes) { CircularProgressIndicator(modifier = progressModifier, color = progressColor) } } @@ -143,16 +141,24 @@ private fun CoreButton( } @Composable -private fun ButtonTextContent(imageVector: ImageVector?, titleRes: Int, modifier: Modifier = Modifier) { - Row(modifier = modifier) { - imageVector?.let { - Icon(modifier = Modifier.size(Margin.Medium), imageVector = it, contentDescription = null) - Spacer(modifier = Modifier.width(Margin.Small)) +fun KeepButtonSize(imageVector: ImageVector?, titleRes: Int, content: @Composable () -> Unit) { + Box(contentAlignment = Alignment.Center) { + Row(modifier = Modifier.alpha(0f)) { + ButtonTextContent(imageVector, titleRes) } - Text(text = stringResource(id = titleRes), style = SwissTransferTheme.typography.bodyMedium) + content() } } +@Composable +private fun ButtonTextContent(imageVector: ImageVector?, titleRes: Int) { + imageVector?.let { + Icon(modifier = Modifier.size(Margin.Medium), imageVector = it, contentDescription = null) + Spacer(modifier = Modifier.width(Margin.Small)) + } + Text(text = stringResource(id = titleRes), style = SwissTransferTheme.typography.bodyMedium) +} + @Composable private fun getProgressSpecs(buttonColors: ButtonColors): Pair { val progressColor = buttonColors.disabledContentColor From 9b35fa283eddf1a59ee61e778ec6a3520d757217 Mon Sep 17 00:00:00 2001 From: Gibran Chevalley Date: Thu, 17 Oct 2024 15:19:08 +0200 Subject: [PATCH 07/11] Fix enabled state not updating when progress nullability changes --- .../java/com/infomaniak/swisstransfer/ui/components/Buttons.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/components/Buttons.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/components/Buttons.kt index 5e6515193..8ec7a013d 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/components/Buttons.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/components/Buttons.kt @@ -110,7 +110,7 @@ private fun CoreButton( onClick: () -> Unit, imageVector: ImageVector?, ) { - val isEnabled by remember { derivedStateOf { enabled() && !showIndeterminateProgress() && progress == null } } + val isEnabled by remember(progress) { derivedStateOf { enabled() && !showIndeterminateProgress() && progress == null } } val buttonColors = style.buttonColors() Button( From 6f2d27f949f22f9713f066153adffc711c2088bd Mon Sep 17 00:00:00 2001 From: Gibran Chevalley Date: Fri, 18 Oct 2024 08:13:28 +0200 Subject: [PATCH 08/11] Rename determinateProgress into progress --- .../swisstransfer/ui/components/Buttons.kt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/components/Buttons.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/components/Buttons.kt index 8ec7a013d..6a49c7b39 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/components/Buttons.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/components/Buttons.kt @@ -53,7 +53,7 @@ fun LargeButton( style: ButtonType = ButtonType.PRIMARY, enabled: () -> Boolean = { true }, showIndeterminateProgress: () -> Boolean = { false }, - determinateProgress: (() -> Float)? = null, + progress: (() -> Float)? = null, onClick: () -> Unit, imageVector: ImageVector? = null, ) { @@ -64,7 +64,7 @@ fun LargeButton( style, enabled, showIndeterminateProgress, - determinateProgress, + progress, onClick, imageVector, ) @@ -81,7 +81,7 @@ fun SmallButton( style: ButtonType = ButtonType.PRIMARY, enabled: () -> Boolean = { true }, showIndeterminateProgress: () -> Boolean = { false }, - determinateProgress: (() -> Float)? = null, + progress: (() -> Float)? = null, onClick: () -> Unit, imageVector: ImageVector? = null, ) { @@ -92,7 +92,7 @@ fun SmallButton( style, enabled, showIndeterminateProgress, - determinateProgress, + progress, onClick, imageVector, ) @@ -214,7 +214,7 @@ private fun LargeButtonPreview() { LargeButton( titleRes = R.string.appName, style = it, - determinateProgress = { 0.3f }, + progress = { 0.3f }, onClick = {}, imageVector = AppIcons.Add ) @@ -226,7 +226,7 @@ private fun LargeButtonPreview() { SmallButton( titleRes = R.string.appName, style = it, - determinateProgress = { 0.3f }, + progress = { 0.3f }, imageVector = AppIcons.Add, onClick = {} ) From be2f8679a4c28e1426a6c8218902d54e1eb80a20 Mon Sep 17 00:00:00 2001 From: Kevin Boulongne Date: Thu, 17 Oct 2024 13:17:40 +0200 Subject: [PATCH 09/11] feat: Add AccountUtils --- .../swisstransfer/ui/MainApplication.kt | 8 ++++- .../swisstransfer/ui/utils/AccountUtils.kt | 29 +++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 app/src/main/java/com/infomaniak/swisstransfer/ui/utils/AccountUtils.kt diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/MainApplication.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/MainApplication.kt index 5c14b1207..f5bfb2e38 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/MainApplication.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/MainApplication.kt @@ -20,6 +20,7 @@ package com.infomaniak.swisstransfer.ui import android.app.Application import com.infomaniak.multiplatform_swisstransfer.SwissTransferInjection import com.infomaniak.swisstransfer.BuildConfig +import com.infomaniak.swisstransfer.ui.utils.AccountUtils import dagger.hilt.android.HiltAndroidApp import io.sentry.SentryEvent import io.sentry.SentryOptions @@ -40,7 +41,8 @@ class MainApplication : Application() { override fun onCreate() { super.onCreate() - globalCoroutineScope.launch { swissTransferInjection.accountManager.loadUser(userId = 0) } + + configureAccountUtils() SentryAndroid.init(this) { options: SentryAndroidOptions -> // Register the callback as an option @@ -50,4 +52,8 @@ class MainApplication : Application() { } } } + + private fun configureAccountUtils() { + globalCoroutineScope.launch { AccountUtils.init(swissTransferInjection) } + } } diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/utils/AccountUtils.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/utils/AccountUtils.kt new file mode 100644 index 000000000..6f57db9e5 --- /dev/null +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/utils/AccountUtils.kt @@ -0,0 +1,29 @@ +/* + * 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 . + */ +package com.infomaniak.swisstransfer.ui.utils + +import com.infomaniak.multiplatform_swisstransfer.SwissTransferInjection + +object AccountUtils { + + private const val DEFAULT_USER_ID = 0 + + suspend fun init(swissTransferInjection: SwissTransferInjection) { + swissTransferInjection.accountManager.loadUser(userId = DEFAULT_USER_ID) + } +} From 30ef4298fc62d520cf2f2c6c330cae9fc1aa3413 Mon Sep 17 00:00:00 2001 From: Gibran Chevalley Date: Thu, 17 Oct 2024 13:37:02 +0200 Subject: [PATCH 10/11] Fix width of double button where only one button is defined --- .../ui/components/DoubleButtonCombo.kt | 54 ++++++++++++++++--- 1 file changed, 48 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/components/DoubleButtonCombo.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/components/DoubleButtonCombo.kt index ab3c363d8..770a892cb 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/components/DoubleButtonCombo.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/components/DoubleButtonCombo.kt @@ -22,7 +22,12 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.unit.dp +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.PreviewLargeWindow +import com.infomaniak.swisstransfer.ui.utils.PreviewSmallWindow + private val WIDTH_LIMIT = 800.dp private val WIDTH_THRESHOLD = 500.dp @@ -92,10 +97,47 @@ private fun HorizontallyStackedButtons( @Composable private fun SingleButton(button: @Composable (Modifier) -> Unit) { - button( - Modifier - .fillMaxWidth() - .widthIn(WIDTH_LIMIT / 2) - .padding(bottom = Margin.Large, start = Margin.Medium, end = Margin.Medium), - ) + Box(Modifier.widthIn(max = WIDTH_LIMIT / 2)) { + button( + Modifier + .fillMaxWidth() + .padding(bottom = Margin.Large, start = Margin.Medium, end = Margin.Medium), + ) + } +} + + +@PreviewSmallWindow +@PreviewLargeWindow +@Composable +private fun DoubleButtonComboPreview() { + SwissTransferTheme { + Column { + DoubleButtonCombo( + topButton = { + LargeButton( + modifier = it, + titleRes = R.string.appName, + onClick = {}, + ) + }, + bottomButton = { + LargeButton( + modifier = it, + titleRes = R.string.appName, + onClick = {}, + ) + } + ) + DoubleButtonCombo( + bottomButton = { + LargeButton( + modifier = it, + titleRes = R.string.appName, + onClick = {}, + ) + } + ) + } + } } From e1ff1f8807c4ae87f1913be9e05f510b7f1fb052 Mon Sep 17 00:00:00 2001 From: Gibran Chevalley Date: Fri, 18 Oct 2024 08:20:23 +0200 Subject: [PATCH 11/11] Add missing comas and remove empty lines --- .../swisstransfer/ui/components/DoubleButtonCombo.kt | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/components/DoubleButtonCombo.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/components/DoubleButtonCombo.kt index 770a892cb..f2372c508 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/components/DoubleButtonCombo.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/components/DoubleButtonCombo.kt @@ -25,9 +25,7 @@ import androidx.compose.ui.unit.dp 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.PreviewLargeWindow -import com.infomaniak.swisstransfer.ui.utils.PreviewSmallWindow - +import com.infomaniak.swisstransfer.ui.utils.PreviewAllWindows private val WIDTH_LIMIT = 800.dp private val WIDTH_THRESHOLD = 500.dp @@ -106,9 +104,7 @@ private fun SingleButton(button: @Composable (Modifier) -> Unit) { } } - -@PreviewSmallWindow -@PreviewLargeWindow +@PreviewAllWindows @Composable private fun DoubleButtonComboPreview() { SwissTransferTheme { @@ -127,7 +123,7 @@ private fun DoubleButtonComboPreview() { titleRes = R.string.appName, onClick = {}, ) - } + }, ) DoubleButtonCombo( bottomButton = { @@ -136,7 +132,7 @@ private fun DoubleButtonComboPreview() { titleRes = R.string.appName, onClick = {}, ) - } + }, ) } }