Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.flow.channelFlow
import kotlinx.coroutines.flow.collectLatest
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.conflate
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.stateIn
Expand All @@ -78,12 +77,6 @@ abstract class BaseCrossAppLoginViewModel(applicationId: String, clientId: Strin
initialValue = AccountsCheckingState(status = Checking)
)

// TODO: Remove once mail uses the compose onboarding screen as well. This value won't be needed anymore then.
val selectedAccounts: StateFlow<List<ExternalAccount>> =
combine(availableAccounts, skippedAccountIds) { allExternalAccounts, idsToSkip ->
allExternalAccounts.filterSelectedAccounts(idsToSkip)
}.stateIn(viewModelScope, started = SharingStarted.Eagerly, initialValue = emptyList())

private val derivedTokenGenerator: DerivedTokenGenerator = DerivedTokenGeneratorImpl(
coroutineScope = viewModelScope,
tokenRetrievalUrl = "$LOGIN_ENDPOINT_URL/token",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,11 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.LocalRippleConfiguration
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.RippleConfiguration
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.RectangleShape
Expand All @@ -54,40 +51,36 @@ internal fun AddAccount(
contentPadding: PaddingValues = PaddingValues(horizontal = Margin.Medium),
onClick: () -> Unit,
) {
CompositionLocalProvider(
LocalRippleConfiguration provides RippleConfiguration(color = customization.colors.primaryColor)
TextButton(
modifier = Modifier
.fillMaxWidth()
.heightIn(min = Dimens.buttonHeight),
shape = RectangleShape,
onClick = onClick,
contentPadding = contentPadding,
) {
TextButton(
Row(
modifier = Modifier
.fillMaxWidth()
.heightIn(min = Dimens.buttonHeight),
shape = RectangleShape,
onClick = onClick,
contentPadding = contentPadding,
.padding(vertical = Margin.Mini),
horizontalArrangement = Arrangement.spacedBy(Margin.Mini),
verticalAlignment = Alignment.CenterVertically,
) {
Row(
modifier = Modifier
.fillMaxWidth()
.padding(vertical = Margin.Mini),
horizontalArrangement = Arrangement.spacedBy(Margin.Mini),
verticalAlignment = Alignment.CenterVertically,
) {

Icon(
modifier = Modifier
.padding(all = Margin.Mini)
.size(size = Dimens.iconSize),
imageVector = AddUser,
tint = customization.colors.primaryColor,
contentDescription = null,
)
Icon(
modifier = Modifier
.padding(all = Margin.Mini)
.size(size = Dimens.iconSize),
imageVector = AddUser,
tint = MaterialTheme.colorScheme.primary,
contentDescription = null,
)

Text(
text = stringResource(R.string.buttonUseOtherAccount),
style = Typography.bodyRegular,
color = customization.colors.titleColor,
)
}
Text(
text = stringResource(R.string.buttonUseOtherAccount),
style = Typography.bodyRegular,
color = customization.colors.titleColor,
)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,10 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.LocalRippleConfiguration
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.RippleConfiguration
import androidx.compose.material3.Surface
import androidx.compose.material3.TextButton
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.RectangleShape
Expand All @@ -58,36 +55,32 @@ internal fun BottomSheetItem(
contentPadding: PaddingValues = PaddingValues(horizontal = Margin.Medium),
onClick: () -> Unit,
) {
CompositionLocalProvider(
LocalRippleConfiguration provides RippleConfiguration(color = customization.colors.primaryColor)
TextButton(
modifier = Modifier
.fillMaxWidth()
.heightIn(min = Dimens.buttonHeight)
.semantics { toggleableState = if (isSelected()) ToggleableState.On else ToggleableState.Off },
shape = RectangleShape,
onClick = onClick,
contentPadding = contentPadding,
) {
TextButton(
Row(
modifier = Modifier
.fillMaxWidth()
.heightIn(min = Dimens.buttonHeight)
.semantics { toggleableState = if (isSelected()) ToggleableState.On else ToggleableState.Off },
shape = RectangleShape,
onClick = onClick,
contentPadding = contentPadding,
.padding(vertical = Margin.Mini),
verticalAlignment = Alignment.CenterVertically,
) {
Row(
modifier = Modifier
.fillMaxWidth()
.padding(vertical = Margin.Mini),
verticalAlignment = Alignment.CenterVertically,
) {

SingleAccount(account, customization, Modifier.weight(1.0f))
SingleAccount(account, customization, Modifier.weight(1.0f))

Spacer(Modifier.width(Margin.Mini))
Spacer(Modifier.width(Margin.Mini))

if (isSelected()) {
Icon(
imageVector = Checkmark,
tint = customization.colors.primaryColor,
contentDescription = null,
)
}
if (isSelected()) {
Icon(
imageVector = Checkmark,
tint = MaterialTheme.colorScheme.primary,
contentDescription = null,
)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.height
import androidx.compose.material3.Button
import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
Expand All @@ -42,8 +43,8 @@ internal fun PrimaryButton(
Button(
modifier = modifier.height(customization.buttonStyle.height),
colors = ButtonDefaults.buttonColors(
containerColor = customization.colors.primaryColor,
contentColor = customization.colors.onPrimaryColor,
containerColor = MaterialTheme.colorScheme.primary,
contentColor = MaterialTheme.colorScheme.onPrimary,
),
shape = customization.buttonStyle.shape,
onClick = onClick,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,10 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.LocalRippleConfiguration
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.RippleConfiguration
import androidx.compose.material3.Surface
import androidx.compose.material3.TextButton
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
Expand All @@ -57,34 +54,30 @@ internal fun SelectedAccountsButton(
contentPadding: PaddingValues = PaddingValues(horizontal = Margin.Medium),
content: @Composable RowScope.() -> Unit,
) {
CompositionLocalProvider(
LocalRippleConfiguration provides RippleConfiguration(color = customization.colors.primaryColor)
TextButton(
modifier = modifier
.fillMaxWidth()
.height(Dimens.buttonHeight),
border = BorderStroke(1.dp, customization.colors.buttonStrokeColor),
shape = RoundedCornerShape(Dimens.largeCornerRadius),
onClick = onClick,
contentPadding = contentPadding,
) {
TextButton(
modifier = modifier
Row(
modifier = Modifier
.fillMaxWidth()
.height(Dimens.buttonHeight),
border = BorderStroke(1.dp, customization.colors.buttonStrokeColor),
shape = RoundedCornerShape(Dimens.largeCornerRadius),
onClick = onClick,
contentPadding = contentPadding,
.padding(vertical = Margin.Mini),
horizontalArrangement = Arrangement.spacedBy(Margin.Mini),
verticalAlignment = Alignment.CenterVertically,
) {
Row(
modifier = Modifier
.fillMaxWidth()
.padding(vertical = Margin.Mini),
horizontalArrangement = Arrangement.spacedBy(Margin.Mini),
verticalAlignment = Alignment.CenterVertically,
) {

content()
content()

Icon(
imageVector = Chevron,
contentDescription = null,
tint = customization.colors.primaryColor,
)
}
Icon(
imageVector = Chevron,
contentDescription = null,
tint = MaterialTheme.colorScheme.primary,
)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ data class CrossLoginCustomization(
)

data class CrossLoginColors(
val primaryColor: Color, // Only needed in kMail because we are dissociated from the Material theme actual value
val onPrimaryColor: Color, // Only needed in kMail because we are dissociated from the Material theme actual value
val titleColor: Color,
val descriptionColor: Color,
val avatarStrokeColor: Color,
Expand All @@ -47,15 +45,11 @@ object CrossLoginDefaults {

@Composable
fun colors(
primaryColor: Color? = null,
onPrimaryColor: Color? = null,
titleColor: Color? = null,
descriptionColor: Color? = null,
avatarStrokeColor: Color? = null,
buttonStrokeColor: Color? = null,
): CrossLoginColors = CrossLoginColors(
primaryColor = primaryColor ?: MaterialTheme.colorScheme.primary,
onPrimaryColor = onPrimaryColor ?: MaterialTheme.colorScheme.onPrimary,
titleColor = titleColor ?: MaterialTheme.colorScheme.onSurface,
descriptionColor = descriptionColor ?: MaterialTheme.colorScheme.onSurfaceVariant,
avatarStrokeColor = avatarStrokeColor ?: MaterialTheme.colorScheme.surface,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* 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.core.crossapplogin.front.previews

import androidx.compose.ui.tooling.preview.PreviewParameterProvider
import com.infomaniak.core.crossapplogin.back.BaseCrossAppLoginViewModel.AccountsCheckingState
import com.infomaniak.core.crossapplogin.back.BaseCrossAppLoginViewModel.AccountsCheckingStatus

class AccountsCheckingStatePreviewParameter : PreviewParameterProvider<AccountsCheckingState> {
override val values: Sequence<AccountsCheckingState> = sequenceOf(accounts)
}

private val accounts = AccountsCheckingState(AccountsCheckingStatus.UpToDate, accountsPreviewData)
Loading