diff --git a/CrossAppLogin/Back/src/main/kotlin/com/infomaniak/core/crossapplogin/back/BaseCrossAppLoginViewModel.kt b/CrossAppLogin/Back/src/main/kotlin/com/infomaniak/core/crossapplogin/back/BaseCrossAppLoginViewModel.kt index e890e882b..3cd859759 100644 --- a/CrossAppLogin/Back/src/main/kotlin/com/infomaniak/core/crossapplogin/back/BaseCrossAppLoginViewModel.kt +++ b/CrossAppLogin/Back/src/main/kotlin/com/infomaniak/core/crossapplogin/back/BaseCrossAppLoginViewModel.kt @@ -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 @@ -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> = - 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", diff --git a/CrossAppLogin/Front/src/main/kotlin/com/infomaniak/core/crossapplogin/front/components/AddAccount.kt b/CrossAppLogin/Front/src/main/kotlin/com/infomaniak/core/crossapplogin/front/components/AddAccount.kt index 97af2178d..e5649cc77 100644 --- a/CrossAppLogin/Front/src/main/kotlin/com/infomaniak/core/crossapplogin/front/components/AddAccount.kt +++ b/CrossAppLogin/Front/src/main/kotlin/com/infomaniak/core/crossapplogin/front/components/AddAccount.kt @@ -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 @@ -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, + ) } } } diff --git a/CrossAppLogin/Front/src/main/kotlin/com/infomaniak/core/crossapplogin/front/components/BottomSheetItem.kt b/CrossAppLogin/Front/src/main/kotlin/com/infomaniak/core/crossapplogin/front/components/BottomSheetItem.kt index d4356a73e..682b8857a 100644 --- a/CrossAppLogin/Front/src/main/kotlin/com/infomaniak/core/crossapplogin/front/components/BottomSheetItem.kt +++ b/CrossAppLogin/Front/src/main/kotlin/com/infomaniak/core/crossapplogin/front/components/BottomSheetItem.kt @@ -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 @@ -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, + ) } } } diff --git a/CrossAppLogin/Front/src/main/kotlin/com/infomaniak/core/crossapplogin/front/components/PrimaryButton.kt b/CrossAppLogin/Front/src/main/kotlin/com/infomaniak/core/crossapplogin/front/components/PrimaryButton.kt index 670fe7ce4..e11c43b6c 100644 --- a/CrossAppLogin/Front/src/main/kotlin/com/infomaniak/core/crossapplogin/front/components/PrimaryButton.kt +++ b/CrossAppLogin/Front/src/main/kotlin/com/infomaniak/core/crossapplogin/front/components/PrimaryButton.kt @@ -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 @@ -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, diff --git a/CrossAppLogin/Front/src/main/kotlin/com/infomaniak/core/crossapplogin/front/components/SelectedAccountsButton.kt b/CrossAppLogin/Front/src/main/kotlin/com/infomaniak/core/crossapplogin/front/components/SelectedAccountsButton.kt index 08de7ec60..052ccc52d 100644 --- a/CrossAppLogin/Front/src/main/kotlin/com/infomaniak/core/crossapplogin/front/components/SelectedAccountsButton.kt +++ b/CrossAppLogin/Front/src/main/kotlin/com/infomaniak/core/crossapplogin/front/components/SelectedAccountsButton.kt @@ -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 @@ -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, + ) } } } diff --git a/CrossAppLogin/Front/src/main/kotlin/com/infomaniak/core/crossapplogin/front/data/CrossLoginCustomization.kt b/CrossAppLogin/Front/src/main/kotlin/com/infomaniak/core/crossapplogin/front/data/CrossLoginCustomization.kt index 8fb56198d..2592a6287 100644 --- a/CrossAppLogin/Front/src/main/kotlin/com/infomaniak/core/crossapplogin/front/data/CrossLoginCustomization.kt +++ b/CrossAppLogin/Front/src/main/kotlin/com/infomaniak/core/crossapplogin/front/data/CrossLoginCustomization.kt @@ -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, @@ -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, diff --git a/CrossAppLogin/Front/src/main/kotlin/com/infomaniak/core/crossapplogin/front/previews/AccountsCheckingStatePreviewParameterProvider.kt b/CrossAppLogin/Front/src/main/kotlin/com/infomaniak/core/crossapplogin/front/previews/AccountsCheckingStatePreviewParameterProvider.kt new file mode 100644 index 000000000..6e20278a7 --- /dev/null +++ b/CrossAppLogin/Front/src/main/kotlin/com/infomaniak/core/crossapplogin/front/previews/AccountsCheckingStatePreviewParameterProvider.kt @@ -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 . + */ +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 { + override val values: Sequence = sequenceOf(accounts) +} + +private val accounts = AccountsCheckingState(AccountsCheckingStatus.UpToDate, accountsPreviewData) diff --git a/CrossAppLogin/Front/src/main/kotlin/com/infomaniak/core/crossapplogin/front/views/CrossLoginListAccountsView.kt b/CrossAppLogin/Front/src/main/kotlin/com/infomaniak/core/crossapplogin/front/views/CrossLoginListAccountsView.kt deleted file mode 100644 index e6e4d3fbe..000000000 --- a/CrossAppLogin/Front/src/main/kotlin/com/infomaniak/core/crossapplogin/front/views/CrossLoginListAccountsView.kt +++ /dev/null @@ -1,145 +0,0 @@ -/* - * 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 . - */ -package com.infomaniak.core.crossapplogin.front.views - -import android.content.Context -import android.util.AttributeSet -import androidx.annotation.ColorInt -import androidx.compose.runtime.Composable -import androidx.compose.runtime.getValue -import androidx.compose.runtime.mutableStateListOf -import androidx.compose.runtime.mutableStateOf -import androidx.compose.runtime.mutableStateSetOf -import androidx.compose.runtime.setValue -import androidx.compose.ui.graphics.Color -import androidx.compose.ui.platform.AbstractComposeView -import com.infomaniak.core.ui.compose.basics.ButtonType -import com.infomaniak.core.ui.compose.materialthemefromxml.MaterialThemeFromXml -import com.infomaniak.core.crossapplogin.back.ExternalAccount -import com.infomaniak.core.crossapplogin.front.R -import com.infomaniak.core.crossapplogin.front.data.CrossLoginCustomization -import com.infomaniak.core.crossapplogin.front.data.CrossLoginDefaults -import com.infomaniak.core.crossapplogin.front.utils.getColorOrNull -import com.infomaniak.core.crossapplogin.front.utils.getStringOrNull -import com.infomaniak.core.crossapplogin.front.views.components.CrossLoginListAccounts -import com.infomaniak.core.utils.enumValueOfOrNull - -class CrossLoginListAccountsView @JvmOverloads constructor( - context: Context, - attrs: AttributeSet? = null, - defStyleAttr: Int = 0, -) : AbstractComposeView(context, attrs, defStyleAttr) { - - private val accounts = mutableStateListOf() - private val skippedIds = mutableStateSetOf() - private var isLoading by mutableStateOf(false) - - private var onAnotherAccountClickedListener: (() -> Unit)? = null - private var onSaveClicked: SaveListener? = null - - private var primaryColor by mutableStateOf(null) - private var onPrimaryColor by mutableStateOf(null) - private var titleColor: Color? - private var descriptionColor: Color? - private var avatarStrokeColor: Color? - private var buttonStrokeColor: Color? - private var buttonType: ButtonType? - - init { - context.obtainStyledAttributes(attrs, R.styleable.CrossLoginListAccountsView, defStyleAttr, 0).apply { - primaryColor = getColorOrNull(R.styleable.CrossLoginListAccountsView_crossLoginPrimaryColor) - onPrimaryColor = getColorOrNull(R.styleable.CrossLoginListAccountsView_crossLoginOnPrimaryColor) - titleColor = getColorOrNull(R.styleable.CrossLoginListAccountsView_crossLoginTitleColor) - descriptionColor = getColorOrNull(R.styleable.CrossLoginListAccountsView_crossLoginDescriptionColor) - avatarStrokeColor = getColorOrNull(R.styleable.CrossLoginListAccountsView_crossLoginAvatarStrokeColor) - buttonStrokeColor = getColorOrNull(R.styleable.CrossLoginListAccountsView_crossLoginButtonStrokeColor) - val crossLoginButtonType = getStringOrNull(R.styleable.CrossLoginListAccountsView_crossLoginButtonType) - buttonType = enumValueOfOrNull(crossLoginButtonType) - - recycle() - } - } - - @Composable - override fun Content() { - MaterialThemeFromXml { - - val customization = CrossLoginCustomization( - colors = CrossLoginDefaults.colors( - primaryColor = primaryColor, - onPrimaryColor = onPrimaryColor, - titleColor = titleColor, - descriptionColor = descriptionColor, - avatarStrokeColor = avatarStrokeColor, - buttonStrokeColor = buttonStrokeColor, - ), - buttonStyle = CrossLoginDefaults.buttonType(buttonType), - ) - - CrossLoginListAccounts( - accounts = { accounts }, - skippedIds = { skippedIds }, - isLoading = { isLoading }, - customization = customization, - onAccountClicked = { accountId -> - if (accountId in skippedIds) skippedIds -= accountId else skippedIds += accountId - }, - onAnotherAccountClicked = { onAnotherAccountClickedListener?.invoke() }, - onSaveClicked = { onSaveClicked?.onSaveClicked(skippedAccountIds = skippedIds.toSet()) }, - ) - } - } - - fun setPrimaryColor(@ColorInt newPrimaryColor: Int) { - primaryColor = Color(newPrimaryColor) - } - - fun setOnPrimaryColor(@ColorInt newOnPrimaryColor: Int) { - onPrimaryColor = Color(newOnPrimaryColor) - } - - fun setAccounts(items: List) { - accounts.apply { - clear() - addAll(items) - } - } - - fun setSkippedIds(items: Set) { - skippedIds.apply { - clear() - addAll(items) - } - } - - fun setLoader(isLoading: Boolean) { - this.isLoading = isLoading - } - - fun setOnAnotherAccountClickedListener(listener: () -> Unit) { - onAnotherAccountClickedListener = listener - } - - fun setOnSaveClickedListener(listener: SaveListener) { - onSaveClicked = listener - } - - fun interface SaveListener { - fun onSaveClicked(skippedAccountIds: Set) - } -} diff --git a/CrossAppLogin/Front/src/main/kotlin/com/infomaniak/core/crossapplogin/front/views/CrossLoginSelectAccountsView.kt b/CrossAppLogin/Front/src/main/kotlin/com/infomaniak/core/crossapplogin/front/views/CrossLoginSelectAccountsView.kt deleted file mode 100644 index b6a60c63f..000000000 --- a/CrossAppLogin/Front/src/main/kotlin/com/infomaniak/core/crossapplogin/front/views/CrossLoginSelectAccountsView.kt +++ /dev/null @@ -1,132 +0,0 @@ -/* - * 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 . - */ -package com.infomaniak.core.crossapplogin.front.views - -import android.content.Context -import android.util.AttributeSet -import androidx.annotation.ColorInt -import androidx.compose.runtime.Composable -import androidx.compose.runtime.getValue -import androidx.compose.runtime.mutableStateListOf -import androidx.compose.runtime.mutableStateOf -import androidx.compose.runtime.mutableStateSetOf -import androidx.compose.runtime.setValue -import androidx.compose.ui.graphics.Color -import androidx.compose.ui.platform.AbstractComposeView -import com.infomaniak.core.ui.compose.basics.ButtonType -import com.infomaniak.core.ui.compose.materialthemefromxml.MaterialThemeFromXml -import com.infomaniak.core.crossapplogin.back.ExternalAccount -import com.infomaniak.core.crossapplogin.front.R -import com.infomaniak.core.crossapplogin.front.data.CrossLoginCustomization -import com.infomaniak.core.crossapplogin.front.data.CrossLoginDefaults -import com.infomaniak.core.crossapplogin.front.utils.getColorOrNull -import com.infomaniak.core.crossapplogin.front.utils.getStringOrNull -import com.infomaniak.core.crossapplogin.front.views.components.CrossLoginSelectAccounts -import com.infomaniak.core.utils.enumValueOfOrNull - -class CrossLoginSelectAccountsView @JvmOverloads constructor( - context: Context, - attrs: AttributeSet? = null, - defStyleAttr: Int = 0, -) : AbstractComposeView(context, attrs, defStyleAttr) { - - private val accounts = mutableStateListOf() - private val skippedIds = mutableStateSetOf() - private var isLoading = false - - private var onClickListener: OnClickListener? = null - - private var primaryColor by mutableStateOf(null) - private var onPrimaryColor by mutableStateOf(null) - private var titleColor: Color? - private var descriptionColor: Color? - private var avatarStrokeColor: Color? - private var buttonStrokeColor: Color? - private var buttonType: ButtonType? - - init { - context.obtainStyledAttributes(attrs, R.styleable.CrossLoginSelectAccountsView, defStyleAttr, 0).apply { - primaryColor = getColorOrNull(R.styleable.CrossLoginSelectAccountsView_crossLoginPrimaryColor) - onPrimaryColor = getColorOrNull(R.styleable.CrossLoginSelectAccountsView_crossLoginOnPrimaryColor) - titleColor = getColorOrNull(R.styleable.CrossLoginSelectAccountsView_crossLoginTitleColor) - descriptionColor = getColorOrNull(R.styleable.CrossLoginSelectAccountsView_crossLoginDescriptionColor) - avatarStrokeColor = getColorOrNull(R.styleable.CrossLoginSelectAccountsView_crossLoginAvatarStrokeColor) - buttonStrokeColor = getColorOrNull(R.styleable.CrossLoginSelectAccountsView_crossLoginButtonStrokeColor) - val crossLoginButtonType = getStringOrNull(R.styleable.CrossLoginListAccountsView_crossLoginButtonType) - buttonType = enumValueOfOrNull(crossLoginButtonType) - - recycle() - } - } - - @Composable - override fun Content() { - MaterialThemeFromXml { - - val customization = CrossLoginCustomization( - colors = CrossLoginDefaults.colors( - primaryColor = primaryColor, - onPrimaryColor = onPrimaryColor, - titleColor = titleColor, - descriptionColor = descriptionColor, - avatarStrokeColor = avatarStrokeColor, - buttonStrokeColor = buttonStrokeColor, - ), - buttonStyle = CrossLoginDefaults.buttonType(buttonType), - ) - - CrossLoginSelectAccounts( - accounts = { accounts }, - skippedIds = { skippedIds }, - customization = customization, - isLoading = { isLoading }, - onClick = { onClickListener?.onClick(this) }, - ) - } - } - - fun setPrimaryColor(@ColorInt newPrimaryColor: Int) { - primaryColor = Color(newPrimaryColor) - } - - fun setOnPrimaryColor(@ColorInt newOnPrimaryColor: Int) { - onPrimaryColor = Color(newOnPrimaryColor) - } - - fun setAccounts(items: List) { - accounts.apply { - clear() - addAll(items) - } - } - - fun setSkippedIds(items: Set) { - skippedIds.apply { - clear() - addAll(items) - } - } - - fun setLoader(isLoading: Boolean) { - this.isLoading = isLoading - } - - override fun setOnClickListener(l: OnClickListener?) { - onClickListener = l - } -} diff --git a/CrossAppLogin/Front/src/main/res/values/attrs.xml b/CrossAppLogin/Front/src/main/res/values/attrs.xml deleted file mode 100644 index 2405bad00..000000000 --- a/CrossAppLogin/Front/src/main/res/values/attrs.xml +++ /dev/null @@ -1,50 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Legacy/src/main/java/com/infomaniak/core/legacy/utils/Extensions.kt b/Legacy/src/main/java/com/infomaniak/core/legacy/utils/Extensions.kt index e9826a279..b942f09a3 100644 --- a/Legacy/src/main/java/com/infomaniak/core/legacy/utils/Extensions.kt +++ b/Legacy/src/main/java/com/infomaniak/core/legacy/utils/Extensions.kt @@ -71,7 +71,6 @@ import com.github.razir.progressbutton.DrawableButton.Companion.GRAVITY_CENTER import com.github.razir.progressbutton.TextChangeAnimatorParams import com.github.razir.progressbutton.attachTextChangeAnimator import com.github.razir.progressbutton.bindProgressButton -import com.github.razir.progressbutton.detachTextChangeAnimator import com.github.razir.progressbutton.hideProgress import com.github.razir.progressbutton.showProgress import com.google.android.material.button.MaterialButton @@ -127,11 +126,6 @@ fun MaterialButton.initProgress(lifecycle: LifecycleOwner? = null, color: Int? = params?.let(::attachTextChangeAnimator) ?: attachTextChangeAnimator() } -fun MaterialButton.updateTextColor(color: Int?) { - detachTextChangeAnimator() - initProgress(color = color) -} - fun MaterialButton.showProgressCatching(color: Int? = null) { isClickable = false // showProgress stores references to views which crashes when the view is freed diff --git a/Onboarding/src/main/kotlin/com/infomaniak/core/onboarding/components/OnboardingComponents.kt b/Onboarding/src/main/kotlin/com/infomaniak/core/onboarding/components/OnboardingComponents.kt index 60b76c473..bda5452c0 100644 --- a/Onboarding/src/main/kotlin/com/infomaniak/core/onboarding/components/OnboardingComponents.kt +++ b/Onboarding/src/main/kotlin/com/infomaniak/core/onboarding/components/OnboardingComponents.kt @@ -33,6 +33,7 @@ import androidx.compose.runtime.remember import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color +import androidx.compose.ui.graphics.ColorFilter import androidx.compose.ui.graphics.vector.ImageVector import androidx.compose.ui.layout.ContentScale import androidx.compose.ui.text.TextStyle @@ -61,12 +62,13 @@ object OnboardingComponents { * situations as all backgrounds should consist of simple vector images. */ @Composable - fun DefaultBackground(background: ImageVector, modifier: Modifier = Modifier) { + fun DefaultBackground(background: ImageVector, modifier: Modifier = Modifier, colorFilter: ColorFilter? = null) { Image( imageVector = background, contentDescription = null, modifier = modifier.fillMaxSize(), contentScale = ContentScale.FillBounds, + colorFilter = colorFilter, ) }