From 69f7ff480a76fa11b93580fee888fba8a9ac9eab Mon Sep 17 00:00:00 2001 From: Abdourahamane Boinaidi Date: Thu, 18 Jul 2024 17:38:02 +0200 Subject: [PATCH 1/8] core: Add NavigationArgs --- .../ui/navigation/NavigationArgs.kt | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 app/src/main/java/com/infomaniak/swisstransfer/ui/navigation/NavigationArgs.kt diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/navigation/NavigationArgs.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/navigation/NavigationArgs.kt new file mode 100644 index 000000000..5fa0cd237 --- /dev/null +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/navigation/NavigationArgs.kt @@ -0,0 +1,57 @@ +/* + * 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.navigation + +import androidx.annotation.StringRes +import com.infomaniak.swisstransfer.R + +/** + * Sealed class representing the navigation arguments for the main navigation flow. + * + * @property title The resource ID of the title string. + */ +sealed class MainNavigation private constructor(@StringRes title: Int) : NavigationArgs(title) { + data object SentNavArgs : MainNavigation(R.string.appName) + data object ReceivedNavArgs : MainNavigation(R.string.appName) + data class TransferDetailsNavArgs(val transferId: Int) : MainNavigation(R.string.appName) + + data object SettingsNavArgs : MainNavigation(R.string.appName) +} + +/** + * Sealed class representing the navigation arguments for the new transfer flow. + * + * @property title The resource ID of the title string. + */ +sealed class NewTransferNavigation private constructor(@StringRes title: Int) : NavigationArgs(title) { + data object ImportFilesNavArgs : NavigationArgs(R.string.appName) + data object TransferTypeNavArgs : NavigationArgs(R.string.appName) + data object TransferOptionsNavArgs : NavigationArgs(R.string.appName) + data object ValidateUserEmailNavArgs : NavigationArgs(R.string.appName) + + data object UploadProgressNavArgs : NavigationArgs(R.string.appName) + data object UploadSuccessNavArgs : NavigationArgs(R.string.appName) +} + +/** + * Sealed class representing navigation arguments with a title resource. + * + * @property title The resource ID of the title string. + */ +sealed class NavigationArgs protected constructor(@StringRes val title: Int) From d71451cc303847c895cb147c3a5cd83377297eef Mon Sep 17 00:00:00 2001 From: Abdourahamane Boinaidi Date: Thu, 18 Jul 2024 17:38:52 +0200 Subject: [PATCH 2/8] core: Add NavigationItem for BottomAppBar items --- .../ui/navigation/NavigationItem.kt | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 app/src/main/java/com/infomaniak/swisstransfer/ui/navigation/NavigationItem.kt diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/navigation/NavigationItem.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/navigation/NavigationItem.kt new file mode 100644 index 000000000..11bd8ba1f --- /dev/null +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/navigation/NavigationItem.kt @@ -0,0 +1,46 @@ +/* + * 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.navigation + +import androidx.annotation.StringRes +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.automirrored.filled.Send +import androidx.compose.material.icons.filled.Settings +import androidx.compose.material.icons.filled.Star +import androidx.compose.material3.BottomAppBar +import androidx.compose.material3.NavigationRail +import androidx.compose.ui.graphics.vector.ImageVector +import com.infomaniak.swisstransfer.R + +/** + * Enum class representing the different destinations in the app's [BottomAppBar] or [NavigationRail]. + * + * @property label The resource ID of the string label for the destination. + * @property icon The icon to be displayed for the destination. + * @property contentDescription The resource ID of the content description for accessibility. + */ +enum class NavigationItem( + @StringRes val label: Int, + val icon: ImageVector, + @StringRes val contentDescription: Int, +) { + SENT(R.string.appName, Icons.AutoMirrored.Filled.Send, R.string.appName), + RECEIVED(R.string.appName, Icons.Default.Star, R.string.appName), + SETTINGS(R.string.appName, Icons.Default.Settings, R.string.appName), +} From e212adf6c61922e8353e33ebd57508db3149e1c2 Mon Sep 17 00:00:00 2001 From: Abdourahamane Boinaidi Date: Thu, 18 Jul 2024 17:39:26 +0200 Subject: [PATCH 3/8] core: Update strings.xml --- app/src/main/AndroidManifest.xml | 2 +- app/src/main/res/values/strings.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 9b30401c7..166bce17a 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -24,7 +24,7 @@ android:dataExtractionRules="@xml/data_extraction_rules" android:fullBackupContent="@xml/backup_rules" android:icon="@mipmap/ic_launcher" - android:label="@string/app_name" + android:label="@string/appName" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/Theme.AndroidSwissTransfer" diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 1ddfabc99..1e601be48 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -17,5 +17,5 @@ --> - SwissTransfer + SwissTransfer From da931655da9bd57a941bc0cbe30d884f6dc1a88f Mon Sep 17 00:00:00 2001 From: Abdourahamane Boinaidi Date: Fri, 19 Jul 2024 09:42:38 +0200 Subject: [PATCH 4/8] core: Add navigation compose lib --- app/build.gradle.kts | 1 + .../infomaniak/swisstransfer/ui/MainScreen.kt | 32 +++++++++++++++++++ gradle/libs.versions.toml | 2 ++ 3 files changed, 35 insertions(+) create mode 100644 app/src/main/java/com/infomaniak/swisstransfer/ui/MainScreen.kt diff --git a/app/build.gradle.kts b/app/build.gradle.kts index e6e11bb35..4cf4ecc38 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -62,6 +62,7 @@ dependencies { implementation(libs.compose.ui) implementation(libs.compose.ui.graphics) implementation(libs.compose.material3) + implementation(libs.navigation.compose) // Compose preview tools implementation(libs.compose.ui.tooling.preview) debugImplementation(libs.compose.ui.tooling) diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/MainScreen.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/MainScreen.kt new file mode 100644 index 000000000..49bb35c05 --- /dev/null +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/MainScreen.kt @@ -0,0 +1,32 @@ +/* + * 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 + +import androidx.compose.material3.Icon +import androidx.compose.material3.Text +import androidx.compose.material3.adaptive.navigationsuite.NavigationSuiteScaffold +import androidx.compose.runtime.Composable +import androidx.compose.ui.res.stringResource +import androidx.navigation.compose.rememberNavController +import com.infomaniak.swisstransfer.ui.navigation.NavigationItem + +@Composable +fun MainScreen() { + val navController = rememberNavController() +} diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 6e1fb025f..bd1a60112 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -7,6 +7,7 @@ junit = "4.13.2" junitVersion = "1.2.1" kotlin = "2.0.0" lifecycleRuntimeKtx = "2.8.3" +navigation = "2.7.7" [libraries] androidx-activity-compose = { group = "androidx.activity", name = "activity-compose", version.ref = "activityCompose" } @@ -18,6 +19,7 @@ compose-ui = { group = "androidx.compose.ui", name = "ui" } compose-ui-graphics = { group = "androidx.compose.ui", name = "ui-graphics" } compose-ui-tooling = { group = "androidx.compose.ui", name = "ui-tooling" } compose-ui-tooling-preview = { group = "androidx.compose.ui", name = "ui-tooling-preview" } +navigation-compose = { group = "androidx.navigation", name = "navigation-compose", version.ref = "navigation" } # Tests androidx-junit = { group = "androidx.test.ext", name = "junit", version.ref = "junitVersion" } junit = { group = "junit", name = "junit", version.ref = "junit" } From 1a1bd540aff10885dc07a741c47622990bac945b Mon Sep 17 00:00:00 2001 From: Abdourahamane Boinaidi Date: Fri, 19 Jul 2024 10:02:51 +0200 Subject: [PATCH 5/8] core: Remove not used title --- .../ui/navigation/NavigationArgs.kt | 35 +++++++------------ 1 file changed, 13 insertions(+), 22 deletions(-) diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/navigation/NavigationArgs.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/navigation/NavigationArgs.kt index 5fa0cd237..88721c140 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/navigation/NavigationArgs.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/navigation/NavigationArgs.kt @@ -18,40 +18,31 @@ package com.infomaniak.swisstransfer.ui.navigation -import androidx.annotation.StringRes -import com.infomaniak.swisstransfer.R - /** * Sealed class representing the navigation arguments for the main navigation flow. - * - * @property title The resource ID of the title string. */ -sealed class MainNavigation private constructor(@StringRes title: Int) : NavigationArgs(title) { - data object SentNavArgs : MainNavigation(R.string.appName) - data object ReceivedNavArgs : MainNavigation(R.string.appName) - data class TransferDetailsNavArgs(val transferId: Int) : MainNavigation(R.string.appName) +sealed class MainNavigation private constructor() : NavigationArgs() { + data object SentNavArgs : MainNavigation() + data object ReceivedNavArgs : MainNavigation() + data class TransferDetailsNavArgs(val transferId: Int) : MainNavigation() - data object SettingsNavArgs : MainNavigation(R.string.appName) + data object SettingsNavArgs : MainNavigation() } /** * Sealed class representing the navigation arguments for the new transfer flow. - * - * @property title The resource ID of the title string. */ -sealed class NewTransferNavigation private constructor(@StringRes title: Int) : NavigationArgs(title) { - data object ImportFilesNavArgs : NavigationArgs(R.string.appName) - data object TransferTypeNavArgs : NavigationArgs(R.string.appName) - data object TransferOptionsNavArgs : NavigationArgs(R.string.appName) - data object ValidateUserEmailNavArgs : NavigationArgs(R.string.appName) +sealed class NewTransferNavigation private constructor() : NavigationArgs() { + data object ImportFilesNavArgs : NavigationArgs() + data object TransferTypeNavArgs : NavigationArgs() + data object TransferOptionsNavArgs : NavigationArgs() + data object ValidateUserEmailNavArgs : NavigationArgs() - data object UploadProgressNavArgs : NavigationArgs(R.string.appName) - data object UploadSuccessNavArgs : NavigationArgs(R.string.appName) + data object UploadProgressNavArgs : NavigationArgs() + data object UploadSuccessNavArgs : NavigationArgs() } /** * Sealed class representing navigation arguments with a title resource. - * - * @property title The resource ID of the title string. */ -sealed class NavigationArgs protected constructor(@StringRes val title: Int) +sealed class NavigationArgs From 88c77b3dceacf453beff46c75a9b58549ff7652b Mon Sep 17 00:00:00 2001 From: Abdourahamane Boinaidi Date: Fri, 19 Jul 2024 10:33:21 +0200 Subject: [PATCH 6/8] use compose navigation beta for type safe --- .../ui/navigation/NavigationArgs.kt | 20 +++++++++---------- gradle/libs.versions.toml | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/navigation/NavigationArgs.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/navigation/NavigationArgs.kt index 88721c140..ff5c63790 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/navigation/NavigationArgs.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/navigation/NavigationArgs.kt @@ -22,24 +22,24 @@ package com.infomaniak.swisstransfer.ui.navigation * Sealed class representing the navigation arguments for the main navigation flow. */ sealed class MainNavigation private constructor() : NavigationArgs() { - data object SentNavArgs : MainNavigation() - data object ReceivedNavArgs : MainNavigation() - data class TransferDetailsNavArgs(val transferId: Int) : MainNavigation() + data object Sent : MainNavigation() + data object Received : MainNavigation() + data class TransferDetails(val transferId: Int) : MainNavigation() - data object SettingsNavArgs : MainNavigation() + data object Settings : MainNavigation() } /** * Sealed class representing the navigation arguments for the new transfer flow. */ sealed class NewTransferNavigation private constructor() : NavigationArgs() { - data object ImportFilesNavArgs : NavigationArgs() - data object TransferTypeNavArgs : NavigationArgs() - data object TransferOptionsNavArgs : NavigationArgs() - data object ValidateUserEmailNavArgs : NavigationArgs() + data object ImportFiles : NavigationArgs() + data object TransferType : NavigationArgs() + data object TransferOptions : NavigationArgs() + data object ValidateUserEmail : NavigationArgs() - data object UploadProgressNavArgs : NavigationArgs() - data object UploadSuccessNavArgs : NavigationArgs() + data object UploadProgress : NavigationArgs() + data object UploadSuccess : NavigationArgs() } /** diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index bd1a60112..ad24acfa5 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -7,7 +7,7 @@ junit = "4.13.2" junitVersion = "1.2.1" kotlin = "2.0.0" lifecycleRuntimeKtx = "2.8.3" -navigation = "2.7.7" +navigation = "2.8.0-beta05" [libraries] androidx-activity-compose = { group = "androidx.activity", name = "activity-compose", version.ref = "activityCompose" } From b921ee5219e6fc6eaf0590e6f24e0bb649f1c6ce Mon Sep 17 00:00:00 2001 From: Abdourahamane Boinaidi Date: Fri, 19 Jul 2024 10:36:59 +0200 Subject: [PATCH 7/8] Remove unused imports --- .../main/java/com/infomaniak/swisstransfer/ui/MainScreen.kt | 5 ----- 1 file changed, 5 deletions(-) diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/MainScreen.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/MainScreen.kt index 49bb35c05..9d531e8fa 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/MainScreen.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/MainScreen.kt @@ -18,13 +18,8 @@ package com.infomaniak.swisstransfer.ui -import androidx.compose.material3.Icon -import androidx.compose.material3.Text -import androidx.compose.material3.adaptive.navigationsuite.NavigationSuiteScaffold import androidx.compose.runtime.Composable -import androidx.compose.ui.res.stringResource import androidx.navigation.compose.rememberNavController -import com.infomaniak.swisstransfer.ui.navigation.NavigationItem @Composable fun MainScreen() { From 8ab23c9a6cbef0476366965c3a8d3d72eaf5193e Mon Sep 17 00:00:00 2001 From: Abdourahamane Boinaidi Date: Fri, 19 Jul 2024 10:42:19 +0200 Subject: [PATCH 8/8] Update NewTransferNavigation --- .../swisstransfer/ui/navigation/NavigationArgs.kt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/navigation/NavigationArgs.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/navigation/NavigationArgs.kt index ff5c63790..1a14cd8d0 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/navigation/NavigationArgs.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/navigation/NavigationArgs.kt @@ -33,13 +33,13 @@ sealed class MainNavigation private constructor() : NavigationArgs() { * Sealed class representing the navigation arguments for the new transfer flow. */ sealed class NewTransferNavigation private constructor() : NavigationArgs() { - data object ImportFiles : NavigationArgs() - data object TransferType : NavigationArgs() - data object TransferOptions : NavigationArgs() - data object ValidateUserEmail : NavigationArgs() + data object ImportFiles : NewTransferNavigation() + data object TransferType : NewTransferNavigation() + data object TransferOptions : NewTransferNavigation() + data object ValidateUserEmail : NewTransferNavigation() - data object UploadProgress : NavigationArgs() - data object UploadSuccess : NavigationArgs() + data object UploadProgress : NewTransferNavigation() + data object UploadSuccess : NewTransferNavigation() } /**