Skip to content

Commit

Permalink
feat(MyKSuiteDashboard): Wrap the dashboard screen in xml Fragment
Browse files Browse the repository at this point in the history
  • Loading branch information
FabianDevel committed Feb 5, 2025
1 parent 78ef215 commit 2fd7e0d
Show file tree
Hide file tree
Showing 7 changed files with 142 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,32 +48,33 @@ import com.infomaniak.lib.myksuite.ui.theme.MyKSuiteTheme
fun MyKSuiteDashboardScreen(
userName: String,
avatarUri: String = "",
dailySendingLimit: () -> String,
dailySendingLimit: String,
onClose: () -> Unit = {},
) {

Scaffold(
topBar = { TopAppBar(onClose) },
containerColor = MyKSuiteTheme.colors.onPrimaryButton,
) { paddingValues ->
Box(
Modifier
.fillMaxHeight()
.verticalScroll(rememberScrollState()),
) {
Image(
modifier = Modifier
.fillMaxWidth()
.fillMaxHeight(0.45f),
contentScale = ContentScale.FillBounds,
imageVector = ImageVector.vectorResource(R.drawable.illu_dashboard_background),
contentDescription = null,
)
Column(Modifier.padding(paddingValues), verticalArrangement = Arrangement.spacedBy(Margin.Large)) {
val paddedModifier = Modifier.padding(horizontal = Margin.Medium)
SubscriptionInfoCard(paddedModifier, avatarUri, userName, dailySendingLimit)
// TODO: Add this line when we'll have In-app payments
// MyKSuitePlusPromotionCard(paddedModifier) {}
MyKSuiteTheme {
Scaffold(
topBar = { TopAppBar(onClose) },
containerColor = MyKSuiteTheme.colors.onPrimaryButton,
) { paddingValues ->
Box(
Modifier
.fillMaxHeight()
.verticalScroll(rememberScrollState()),
) {
Image(
modifier = Modifier
.fillMaxWidth()
.fillMaxHeight(0.45f),
contentScale = ContentScale.FillBounds,
imageVector = ImageVector.vectorResource(R.drawable.illu_dashboard_background),
contentDescription = null,
)
Column(Modifier.padding(paddingValues), verticalArrangement = Arrangement.spacedBy(Margin.Large)) {
val paddedModifier = Modifier.padding(horizontal = Margin.Medium)
SubscriptionInfoCard(paddedModifier, avatarUri, userName, dailySendingLimit)
// TODO: Add this line when we'll have In-app payments
// MyKSuitePlusPromotionCard(paddedModifier) {}
}
}
}
}
Expand Down Expand Up @@ -111,7 +112,7 @@ private fun SubscriptionInfoCard(
paddedModifier: Modifier,
avatarUri: String,
userName: String,
dailySendingLimit: () -> String,
dailySendingLimit: String,
) {
Card(
modifier = paddedModifier.padding(top = Margin.Medium),
Expand Down Expand Up @@ -214,9 +215,7 @@ private fun MyKSuitePlusPromotionCard(modifier: Modifier = Modifier, onButtonCli
@Preview(name = "(2) Dark", uiMode = Configuration.UI_MODE_NIGHT_YES or Configuration.UI_MODE_TYPE_NORMAL)
@Composable
private fun Preview() {
MyKSuiteTheme {
Surface(Modifier.fillMaxSize(), color = Color.White) {
MyKSuiteDashboardScreen(userName = "Toto", avatarUri = "", dailySendingLimit = { "500" })
}
Surface(Modifier.fillMaxSize(), color = Color.White) {
MyKSuiteDashboardScreen(userName = "Toto", avatarUri = "", dailySendingLimit = "500")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import com.infomaniak.lib.myksuite.ui.theme.Margin
import com.infomaniak.lib.myksuite.ui.theme.MyKSuiteTheme

@Composable
fun LimitedFunctionalities(paddedModifier: Modifier, dailySendingLimit: () -> String) {
fun LimitedFunctionalities(paddedModifier: Modifier, dailySendingLimit: String) {
Column(
modifier = paddedModifier.padding(top = Margin.Mini),
verticalArrangement = Arrangement.spacedBy(Margin.Mini),
Expand All @@ -42,7 +42,7 @@ fun LimitedFunctionalities(paddedModifier: Modifier, dailySendingLimit: () -> St
LimitedFunctionalityLabel(modifier = Modifier.weight(1.0f), R.string.myKSuiteDashboardFunctionalityLimit)
Text(
modifier = Modifier.padding(start = Margin.Mini),
text = dailySendingLimit(),
text = dailySendingLimit,
style = MyKSuiteTheme.typography.bodySmallMedium,
)
}
Expand All @@ -66,7 +66,7 @@ private fun LimitedFunctionalityLabel(modifier: Modifier = Modifier, @StringRes
private fun Preview() {
MyKSuiteTheme {
Surface {
LimitedFunctionalities(Modifier.padding(horizontal = Margin.Medium)) { "500" }
LimitedFunctionalities(Modifier.padding(horizontal = Margin.Medium), dailySendingLimit = "500")
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* Infomaniak Core - Android
* Copyright (C) 2025 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 <http://www.gnu.org/licenses/>.
*/
package com.infomaniak.lib.myksuite.ui.views

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.compose.ui.platform.ComposeView
import androidx.compose.ui.platform.ViewCompositionStrategy
import androidx.fragment.app.Fragment
import androidx.navigation.fragment.findNavController
import androidx.navigation.fragment.navArgs
import com.infomaniak.lib.myksuite.ui.screens.MyKSuiteDashboardScreen

open class MyKSuiteDashboardFragment : Fragment() {

private val navigationArgs: MyKSuiteDashboardFragmentArgs by navArgs()

override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
return ComposeView(requireContext()).apply {
setViewCompositionStrategy(ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed)
setContent {
val onClose: () -> Unit = { this@MyKSuiteDashboardFragment.findNavController().popBackStack() }
with(navigationArgs) {
MyKSuiteDashboardScreen(
userName = userName,
avatarUri = avatarUri,
dailySendingLimit = dailySendLimit,
onClose = onClose,
)
}
}
}
}
}
17 changes: 16 additions & 1 deletion MykSuite/src/main/res/navigation/my_ksuite_navigation.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,22 @@
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/my_ksuite_navigation"
app:startDestination="@id/myKSuiteUpgradeBottomSheet">
app:startDestination="@id/myKSuiteDashboardFragment">

<fragment
android:id="@+id/myKSuiteDashboardFragment"
android:name="com.infomaniak.lib.myksuite.ui.views.MyKSuiteDashboardFragment"
android:label="MyKSuiteDashboardFragment">
<argument
android:name="userName"
app:argType="string" />
<argument
android:name="avatarUri"
app:argType="string" />
<argument
android:name="dailySendLimit"
app:argType="string" />
</fragment>

<dialog
android:id="@+id/myKSuiteUpgradeBottomSheet"
Expand Down
20 changes: 20 additions & 0 deletions MykSuite/src/main/res/values-night/colors.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?><!--
~ Infomaniak Core - Android
~ Copyright (C) 2025 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 <http://www.gnu.org/licenses/>.
-->
<resources>
<color name="dashboardBackground">#333333</color>
</resources>
20 changes: 20 additions & 0 deletions MykSuite/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?><!--
~ Infomaniak Core - Android
~ Copyright (C) 2025 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 <http://www.gnu.org/licenses/>.
-->
<resources>
<color name="dashboardBackground">#F4F6FD</color>
</resources>
4 changes: 4 additions & 0 deletions MykSuite/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<resources>

<string name="myKSuiteName" translatable="false">My kSuite</string>
<string name="myKSuitePlusName" translatable="false">My kSuite +</string>

<string name="androidMyKSuiteDashboardSubscriptionButton">Manage my offer</string>
<string name="androidMyKSuiteDashboardSubscriptionLabel">To manage or cancel your subscription, log on to the kSuite web interface.</string>
<string name="buttonClose">Close</string>
Expand Down

0 comments on commit 2fd7e0d

Please sign in to comment.