diff --git a/auth/src/main/java/org/openedx/auth/presentation/restore/RestorePasswordFragment.kt b/auth/src/main/java/org/openedx/auth/presentation/restore/RestorePasswordFragment.kt index 84d2d584e..027778a3f 100644 --- a/auth/src/main/java/org/openedx/auth/presentation/restore/RestorePasswordFragment.kt +++ b/auth/src/main/java/org/openedx/auth/presentation/restore/RestorePasswordFragment.kt @@ -62,7 +62,7 @@ import org.openedx.core.UIMessage import org.openedx.core.presentation.global.app_upgrade.AppUpgradeRequiredScreen import org.openedx.core.ui.BackBtn import org.openedx.core.ui.HandleUIMessage -import org.openedx.core.ui.OpenEdXButton +import org.openedx.core.ui.OpenEdXBrandButton import org.openedx.core.ui.WindowSize import org.openedx.core.ui.WindowType import org.openedx.core.ui.displayCutoutForLandscape @@ -186,7 +186,7 @@ private fun RestorePasswordScreen( modifier = Modifier .fillMaxWidth() .height(200.dp), - painter = painterResource(id = org.openedx.core.R.drawable.core_top_header), + painter = painterResource(id = R.drawable.core_top_header), contentScale = ContentScale.FillBounds, contentDescription = null ) @@ -297,8 +297,8 @@ private fun RestorePasswordScreen( CircularProgressIndicator(color = MaterialTheme.appColors.primary) } } else { - OpenEdXButton( - modifier = buttonWidth.testTag("btn_reset_password"), + OpenEdXBrandButton( + modifier = buttonWidth, text = stringResource(id = authR.string.auth_reset_password), onClick = { keyboardController?.hide() @@ -350,7 +350,7 @@ private fun RestorePasswordScreen( color = MaterialTheme.appColors.textPrimary ) Spacer(Modifier.height(48.dp)) - OpenEdXButton( + OpenEdXBrandButton( modifier = buttonWidth, text = stringResource(id = R.string.core_sign_in), onClick = { diff --git a/auth/src/main/java/org/openedx/auth/presentation/signin/compose/SignInView.kt b/auth/src/main/java/org/openedx/auth/presentation/signin/compose/SignInView.kt index 4b91aaa4f..eec450070 100644 --- a/auth/src/main/java/org/openedx/auth/presentation/signin/compose/SignInView.kt +++ b/auth/src/main/java/org/openedx/auth/presentation/signin/compose/SignInView.kt @@ -67,7 +67,7 @@ import org.openedx.core.extension.TextConverter import org.openedx.core.ui.BackBtn import org.openedx.core.ui.HandleUIMessage import org.openedx.core.ui.HyperlinkText -import org.openedx.core.ui.OpenEdXButton +import org.openedx.core.ui.OpenEdXBrandButton import org.openedx.core.ui.WindowSize import org.openedx.core.ui.WindowType import org.openedx.core.ui.displayCutoutForLandscape @@ -292,11 +292,9 @@ private fun AuthForm( if (state.showProgress) { CircularProgressIndicator(color = MaterialTheme.appColors.primary) } else { - OpenEdXButton( - modifier = buttonWidth.testTag("btn_sign_in"), + OpenEdXBrandButton( + modifier = buttonWidth, text = stringResource(id = coreR.string.core_sign_in), - textColor = MaterialTheme.appColors.primaryButtonText, - backgroundColor = MaterialTheme.appColors.primaryButtonBackground, onClick = { keyboardController?.hide() if (login.isNotEmpty() && password.isNotEmpty()) { diff --git a/auth/src/main/java/org/openedx/auth/presentation/signup/compose/SignUpView.kt b/auth/src/main/java/org/openedx/auth/presentation/signup/compose/SignUpView.kt index f820b5cf8..0623d3432 100644 --- a/auth/src/main/java/org/openedx/auth/presentation/signup/compose/SignUpView.kt +++ b/auth/src/main/java/org/openedx/auth/presentation/signup/compose/SignUpView.kt @@ -73,7 +73,7 @@ import org.openedx.core.domain.model.RegistrationField import org.openedx.core.domain.model.RegistrationFieldType import org.openedx.core.ui.BackBtn import org.openedx.core.ui.HandleUIMessage -import org.openedx.core.ui.OpenEdXButton +import org.openedx.core.ui.OpenEdXBrandButton import org.openedx.core.ui.SheetContent import org.openedx.core.ui.WindowSize import org.openedx.core.ui.WindowType @@ -436,11 +436,9 @@ internal fun SignUpView( CircularProgressIndicator(color = MaterialTheme.appColors.primary) } } else { - OpenEdXButton( - modifier = buttonWidth.testTag("btn_create_account"), + OpenEdXBrandButton( + modifier = buttonWidth, text = stringResource(id = R.string.auth_create_account), - textColor = MaterialTheme.appColors.primaryButtonText, - backgroundColor = MaterialTheme.appColors.primaryButtonBackground, onClick = { keyboardController?.hide() showErrorMap.clear() @@ -506,6 +504,10 @@ private fun RegistrationScreenTabletPreview() { requiredFields = listOf(field, field), optionalFields = listOf(field, field), agreementFields = listOf(field), + isGoogleAuthEnabled = true, + isFacebookAuthEnabled = true, + isMicrosoftAuthEnabled = true, + isSocialAuthEnabled = true, ), uiMessage = null, onBackClick = {}, diff --git a/auth/src/main/java/org/openedx/auth/presentation/ui/SocialAuthView.kt b/auth/src/main/java/org/openedx/auth/presentation/ui/SocialAuthView.kt index c8ab3df16..2d69a131b 100644 --- a/auth/src/main/java/org/openedx/auth/presentation/ui/SocialAuthView.kt +++ b/auth/src/main/java/org/openedx/auth/presentation/ui/SocialAuthView.kt @@ -1,9 +1,9 @@ package org.openedx.auth.presentation.ui import android.content.res.Configuration +import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row -import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.material.Icon import androidx.compose.material.MaterialTheme @@ -19,8 +19,7 @@ import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import org.openedx.auth.R import org.openedx.auth.data.model.AuthType -import org.openedx.core.ui.OpenEdXButton -import org.openedx.core.ui.OpenEdXOutlinedButton +import org.openedx.core.ui.OpenEdXBrandButton import org.openedx.core.ui.theme.OpenEdXTheme import org.openedx.core.ui.theme.appColors @@ -33,23 +32,20 @@ internal fun SocialAuthView( isSignIn: Boolean = false, onEvent: (AuthType) -> Unit, ) { - Column(modifier = modifier) { + Column( + modifier = modifier + .padding(top = 24.dp), + verticalArrangement = Arrangement.spacedBy(12.dp) + ) { if (isGoogleAuthEnabled) { val stringRes = if (isSignIn) { R.string.auth_google } else { R.string.auth_continue_google } - OpenEdXButton( - modifier = Modifier - .testTag("btn_google_auth") - .padding(top = 24.dp) - .fillMaxWidth(), + OpenEdXBrandButton( backgroundColor = MaterialTheme.appColors.authGoogleButtonBackground, - textColor = Color.Unspecified, - onClick = { - onEvent(AuthType.GOOGLE) - } + onClick = { onEvent(AuthType.GOOGLE) } ) { Row(verticalAlignment = Alignment.CenterVertically) { Icon( @@ -58,9 +54,7 @@ internal fun SocialAuthView( tint = Color.Unspecified, ) Text( - modifier = Modifier - .testTag("txt_google_auth") - .padding(start = 10.dp), + modifier = Modifier.padding(start = 10.dp), text = stringResource(id = stringRes), color = MaterialTheme.appColors.textPrimaryLight, ) @@ -73,15 +67,9 @@ internal fun SocialAuthView( } else { R.string.auth_continue_facebook } - OpenEdXButton( - modifier = Modifier - .testTag("btn_facebook_auth") - .padding(top = 12.dp) - .fillMaxWidth(), + OpenEdXBrandButton( backgroundColor = MaterialTheme.appColors.authFacebookButtonBackground, - onClick = { - onEvent(AuthType.FACEBOOK) - } + onClick = { onEvent(AuthType.FACEBOOK) } ) { Row(verticalAlignment = Alignment.CenterVertically) { Icon( @@ -105,15 +93,9 @@ internal fun SocialAuthView( } else { R.string.auth_continue_microsoft } - OpenEdXButton( - modifier = Modifier - .testTag("btn_microsoft_auth") - .padding(top = 12.dp) - .fillMaxWidth(), + OpenEdXBrandButton( backgroundColor = MaterialTheme.appColors.authMicrosoftButtonBackground, - onClick = { - onEvent(AuthType.MICROSOFT) - } + onClick = { onEvent(AuthType.MICROSOFT) } ) { Row(verticalAlignment = Alignment.CenterVertically) { Icon( diff --git a/core/src/edx/org/openedx/core/ui/theme/LocalShapes.kt b/core/src/edx/org/openedx/core/ui/theme/LocalShapes.kt index 98e44e55e..ec533e525 100644 --- a/core/src/edx/org/openedx/core/ui/theme/LocalShapes.kt +++ b/core/src/edx/org/openedx/core/ui/theme/LocalShapes.kt @@ -13,7 +13,7 @@ internal val LocalShapes = staticCompositionLocalOf { medium = RoundedCornerShape(8.dp), large = RoundedCornerShape(0.dp) ), - buttonShape = RoundedCornerShape(CornerSize(8.dp)), + buttonShape = RoundedCornerShape(CornerSize(24.dp)), navigationButtonShape = RoundedCornerShape(8.dp), textFieldShape = RoundedCornerShape(CornerSize(8.dp)), screenBackgroundShape = RoundedCornerShape(topStart = 30.dp, topEnd = 30.dp, bottomStart = 0.dp, bottomEnd = 0.dp), diff --git a/core/src/main/java/org/openedx/core/presentation/dialog/IAPDialogFragment.kt b/core/src/main/java/org/openedx/core/presentation/dialog/IAPDialogFragment.kt index a136b8cba..cdddd24c1 100644 --- a/core/src/main/java/org/openedx/core/presentation/dialog/IAPDialogFragment.kt +++ b/core/src/main/java/org/openedx/core/presentation/dialog/IAPDialogFragment.kt @@ -43,7 +43,7 @@ import org.openedx.core.presentation.iap.IAPUIState import org.openedx.core.presentation.iap.IAPViewModel import org.openedx.core.ui.HandleUIMessage import org.openedx.core.ui.IAPErrorDialog -import org.openedx.core.ui.OpenEdXButton +import org.openedx.core.ui.OpenEdXBrandButton import org.openedx.core.ui.UnlockingAccessView import org.openedx.core.ui.ValuePropUpgradeFeatures import org.openedx.core.ui.theme.OpenEdXTheme @@ -108,7 +108,7 @@ class IAPDialogFragment : DialogFragment() { iapState is IAPUIState.ProductData && iapViewModel.purchaseData.formattedPrice.isNullOrEmpty() .not() -> { - OpenEdXButton(modifier = Modifier.fillMaxWidth(), + OpenEdXBrandButton( text = stringResource( id = R.string.iap_upgrade_price, iapViewModel.purchaseData.formattedPrice!!, diff --git a/core/src/main/java/org/openedx/core/presentation/dialog/alert/ActionDialogFragment.kt b/core/src/main/java/org/openedx/core/presentation/dialog/alert/ActionDialogFragment.kt index 6fba6836c..35b6e0c70 100644 --- a/core/src/main/java/org/openedx/core/presentation/dialog/alert/ActionDialogFragment.kt +++ b/core/src/main/java/org/openedx/core/presentation/dialog/alert/ActionDialogFragment.kt @@ -36,8 +36,7 @@ import org.openedx.core.config.Config import org.openedx.core.presentation.CoreAnalytics import org.openedx.core.presentation.CoreAnalyticsEvent import org.openedx.core.presentation.CoreAnalyticsKey -import org.openedx.core.presentation.global.app_upgrade.DefaultTextButton -import org.openedx.core.presentation.global.app_upgrade.TransparentTextButton +import org.openedx.core.ui.OpenEdXTertiaryButton import org.openedx.core.ui.theme.OpenEdXTheme import org.openedx.core.ui.theme.appColors import org.openedx.core.ui.theme.appShapes @@ -168,12 +167,12 @@ private fun ActionDialog( style = MaterialTheme.appTypography.bodyMedium ) Row { - TransparentTextButton( + OpenEdXTertiaryButton( text = stringResource(R.string.core_cancel), onClick = onPositiveClick ) Spacer(modifier = Modifier.size(16.dp)) - DefaultTextButton( + OpenEdXTertiaryButton( text = stringResource(R.string.core_continue), onClick = onNegativeClick ) diff --git a/core/src/main/java/org/openedx/core/presentation/dialog/alert/InfoDialogFragment.kt b/core/src/main/java/org/openedx/core/presentation/dialog/alert/InfoDialogFragment.kt index 0f6480316..212e3791d 100644 --- a/core/src/main/java/org/openedx/core/presentation/dialog/alert/InfoDialogFragment.kt +++ b/core/src/main/java/org/openedx/core/presentation/dialog/alert/InfoDialogFragment.kt @@ -28,7 +28,7 @@ import androidx.compose.ui.unit.dp import androidx.core.os.bundleOf import androidx.fragment.app.DialogFragment import org.openedx.core.R -import org.openedx.core.presentation.global.app_upgrade.DefaultTextButton +import org.openedx.core.ui.OpenEdXTertiaryButton import org.openedx.core.ui.theme.OpenEdXTheme import org.openedx.core.ui.theme.appColors import org.openedx.core.ui.theme.appShapes @@ -109,7 +109,7 @@ private fun InfoDialog( textAlign = TextAlign.Center, style = MaterialTheme.appTypography.bodyMedium ) - DefaultTextButton( + OpenEdXTertiaryButton( text = stringResource(R.string.core_ok), onClick = onClick ) diff --git a/core/src/main/java/org/openedx/core/presentation/dialog/appreview/AppReviewUI.kt b/core/src/main/java/org/openedx/core/presentation/dialog/appreview/AppReviewUI.kt index a1df55a05..55131d068 100644 --- a/core/src/main/java/org/openedx/core/presentation/dialog/appreview/AppReviewUI.kt +++ b/core/src/main/java/org/openedx/core/presentation/dialog/appreview/AppReviewUI.kt @@ -13,8 +13,6 @@ import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size -import androidx.compose.material.Button -import androidx.compose.material.ButtonDefaults import androidx.compose.material.Icon import androidx.compose.material.MaterialTheme import androidx.compose.material.OutlinedTextField @@ -48,6 +46,7 @@ import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import org.openedx.core.R import org.openedx.core.presentation.dialog.DefaultDialogBox +import org.openedx.core.ui.OpenEdXTertiaryButton import org.openedx.core.ui.theme.OpenEdXTheme import org.openedx.core.ui.theme.appColors import org.openedx.core.ui.theme.appShapes @@ -102,11 +101,11 @@ fun ThankYouDialog( Row( horizontalArrangement = Arrangement.spacedBy(24.dp) ) { - TransparentTextButton( + OpenEdXTertiaryButton( text = stringResource(id = R.string.core_not_now), onClick = onNotNowClick ) - DefaultTextButton( + OpenEdXTertiaryButton( text = stringResource(id = R.string.core_rate_us), onClick = onRateUsClick ) @@ -180,12 +179,12 @@ fun FeedbackDialog( Row( horizontalArrangement = Arrangement.spacedBy(24.dp) ) { - TransparentTextButton( + OpenEdXTertiaryButton( text = stringResource(id = R.string.core_not_now), onClick = onNotNowClick ) - DefaultTextButton( - isEnabled = feedback.value.isNotEmpty(), + OpenEdXTertiaryButton( + enabled = feedback.value.isNotEmpty(), text = stringResource(id = R.string.core_share_feedback), onClick = onShareClick ) @@ -213,7 +212,10 @@ fun RateDialog( verticalArrangement = Arrangement.spacedBy(20.dp) ) { Text( - text = stringResource(R.string.core_rate_dialog_title, stringResource(R.string.app_name)), + text = stringResource( + R.string.core_rate_dialog_title, + stringResource(R.string.app_name) + ), color = MaterialTheme.appColors.textPrimary, style = MaterialTheme.appTypography.titleMedium ) @@ -231,12 +233,12 @@ fun RateDialog( Row( horizontalArrangement = Arrangement.spacedBy(24.dp) ) { - TransparentTextButton( + OpenEdXTertiaryButton( text = stringResource(id = R.string.core_not_now), onClick = onNotNowClick ) - DefaultTextButton( - isEnabled = rating.intValue > 0, + OpenEdXTertiaryButton( + enabled = rating.intValue > 0, text = stringResource(id = R.string.core_submit), onClick = onSubmitClick ) @@ -245,69 +247,6 @@ fun RateDialog( } } -@Composable -fun TransparentTextButton( - text: String, - onClick: () -> Unit -) { - Button( - modifier = Modifier - .height(42.dp), - colors = ButtonDefaults.buttonColors( - backgroundColor = Color.Transparent - ), - elevation = null, - shape = MaterialTheme.appShapes.navigationButtonShape, - onClick = onClick - ) { - Text( - color = MaterialTheme.appColors.textAccent, - style = MaterialTheme.appTypography.labelLarge, - text = text - ) - } -} - -@Composable -fun DefaultTextButton( - isEnabled: Boolean = true, - text: String, - onClick: () -> Unit -) { - val textColor: Color - val backgroundColor: Color - if (isEnabled) { - textColor = MaterialTheme.appColors.primaryButtonText - backgroundColor = MaterialTheme.appColors.primaryButtonBackground - } else { - textColor = MaterialTheme.appColors.inactiveButtonText - backgroundColor = MaterialTheme.appColors.inactiveButtonBackground - } - - Button( - modifier = Modifier - .height(42.dp), - colors = ButtonDefaults.buttonColors( - backgroundColor = backgroundColor, - contentColor = textColor - ), - elevation = null, - shape = MaterialTheme.appShapes.navigationButtonShape, - enabled = isEnabled, - onClick = onClick - ) { - Row( - verticalAlignment = Alignment.CenterVertically, - horizontalArrangement = Arrangement.Center - ) { - Text( - text = text, - style = MaterialTheme.appTypography.labelLarge - ) - } - } -} - @Composable fun RatingBar( modifier: Modifier = Modifier, @@ -394,7 +333,8 @@ private fun FeedbackDialogPreview() { } } -@Preview +@Preview(uiMode = UI_MODE_NIGHT_NO) +@Preview(uiMode = UI_MODE_NIGHT_YES) @Composable private fun ThankYouDialogWithButtonsPreview() { OpenEdXTheme { @@ -407,7 +347,8 @@ private fun ThankYouDialogWithButtonsPreview() { } } -@Preview +@Preview(uiMode = UI_MODE_NIGHT_NO) +@Preview(uiMode = UI_MODE_NIGHT_YES) @Composable private fun ThankYouDialogWithoutButtonsPreview() { OpenEdXTheme { diff --git a/core/src/main/java/org/openedx/core/presentation/global/app_upgrade/AppUpdateUI.kt b/core/src/main/java/org/openedx/core/presentation/global/app_upgrade/AppUpdateUI.kt index 3f8dd6fa9..4663c2327 100644 --- a/core/src/main/java/org/openedx/core/presentation/global/app_upgrade/AppUpdateUI.kt +++ b/core/src/main/java/org/openedx/core/presentation/global/app_upgrade/AppUpdateUI.kt @@ -12,12 +12,9 @@ import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.widthIn -import androidx.compose.material.Button -import androidx.compose.material.ButtonDefaults import androidx.compose.material.Card import androidx.compose.material.Icon import androidx.compose.material.MaterialTheme @@ -29,6 +26,7 @@ import androidx.compose.ui.ExperimentalComposeUiApi import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip import androidx.compose.ui.graphics.Color +import androidx.compose.ui.graphics.ColorFilter import androidx.compose.ui.platform.LocalConfiguration import androidx.compose.ui.platform.testTag import androidx.compose.ui.res.painterResource @@ -39,6 +37,7 @@ import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import org.openedx.core.R +import org.openedx.core.ui.OpenEdXTertiaryButton import org.openedx.core.ui.noRippleClickable import org.openedx.core.ui.statusBarsInset import org.openedx.core.ui.theme.OpenEdXTheme @@ -148,7 +147,8 @@ fun AppUpgradeRecommendDialog( Image( modifier = imageModifier, painter = painterResource(id = R.drawable.core_ic_icon_upgrade), - contentDescription = null + contentDescription = null, + colorFilter = ColorFilter.tint(MaterialTheme.appColors.primary) ) Text( modifier = Modifier.testTag("txt_app_upgrade_title"), @@ -226,12 +226,12 @@ fun AppUpgradeRequiredButtons( horizontalArrangement = Arrangement.spacedBy(24.dp) ) { if (showAccountSettingsButton) { - TransparentTextButton( + OpenEdXTertiaryButton( text = stringResource(id = R.string.core_account_settings), onClick = onAccountSettingsClick ) } - DefaultTextButton( + OpenEdXTertiaryButton( text = stringResource(id = R.string.core_update), onClick = onUpdateClick ) @@ -246,72 +246,17 @@ fun AppUpgradeDialogButtons( Row( horizontalArrangement = Arrangement.spacedBy(24.dp) ) { - TransparentTextButton( + OpenEdXTertiaryButton( text = stringResource(id = R.string.core_not_now), onClick = onNotNowClick ) - DefaultTextButton( + OpenEdXTertiaryButton( text = stringResource(id = R.string.core_update), onClick = onUpdateClick ) } } -@Composable -fun TransparentTextButton( - text: String, - onClick: () -> Unit -) { - Button( - modifier = Modifier - .testTag("btn_secondary") - .height(42.dp), - colors = ButtonDefaults.buttonColors( - backgroundColor = Color.Transparent - ), - elevation = null, - shape = MaterialTheme.appShapes.navigationButtonShape, - onClick = onClick - ) { - Text( - modifier = Modifier.testTag("txt_secondary"), - color = MaterialTheme.appColors.textAccent, - style = MaterialTheme.appTypography.labelLarge, - text = text - ) - } -} - -@Composable -fun DefaultTextButton( - text: String, - onClick: () -> Unit -) { - Button( - modifier = Modifier - .testTag("btn_primary") - .height(42.dp), - colors = ButtonDefaults.buttonColors( - backgroundColor = MaterialTheme.appColors.primaryButtonBackground - ), - elevation = null, - shape = MaterialTheme.appShapes.navigationButtonShape, - onClick = onClick - ) { - Row( - verticalAlignment = Alignment.CenterVertically, - horizontalArrangement = Arrangement.Center - ) { - Text( - modifier = Modifier.testTag("txt_primary"), - text = text, - color = MaterialTheme.appColors.primaryButtonText, - style = MaterialTheme.appTypography.labelLarge - ) - } - } -} - @Composable fun AppUpgradeRecommendedBox( modifier: Modifier = Modifier, diff --git a/core/src/main/java/org/openedx/core/presentation/settings/calendarsync/CalendarSyncDialog.kt b/core/src/main/java/org/openedx/core/presentation/settings/calendarsync/CalendarSyncDialog.kt index ac358228e..a2acb19a6 100644 --- a/core/src/main/java/org/openedx/core/presentation/settings/calendarsync/CalendarSyncDialog.kt +++ b/core/src/main/java/org/openedx/core/presentation/settings/calendarsync/CalendarSyncDialog.kt @@ -25,7 +25,7 @@ import androidx.compose.ui.unit.dp import androidx.compose.ui.window.Dialog import org.openedx.core.R import org.openedx.core.extension.takeIfNotEmpty -import org.openedx.core.presentation.global.app_upgrade.TransparentTextButton +import org.openedx.core.ui.OpenEdXTertiaryButton import org.openedx.core.ui.theme.OpenEdXTheme import org.openedx.core.ui.theme.appColors import org.openedx.core.ui.theme.appShapes @@ -151,20 +151,22 @@ private fun CalendarAlertDialog(dialogProperties: DialogProperties, onDismiss: ( ) }, confirmButton = { - TransparentTextButton( - text = dialogProperties.positiveButton - ) { - onDismiss() - dialogProperties.positiveAction.invoke() - } + OpenEdXTertiaryButton( + text = dialogProperties.positiveButton, + onClick = { + onDismiss() + dialogProperties.positiveAction.invoke() + } + ) }, dismissButton = { - TransparentTextButton( - text = dialogProperties.negativeButton - ) { - onDismiss() - dialogProperties.negativeAction.invoke() - } + OpenEdXTertiaryButton( + text = dialogProperties.negativeButton, + onClick = { + onDismiss() + dialogProperties.negativeAction.invoke() + } + ) }, ) } diff --git a/core/src/main/java/org/openedx/core/ui/ComposeCommon.kt b/core/src/main/java/org/openedx/core/ui/ComposeCommon.kt index 11d00f8dd..0179c08eb 100644 --- a/core/src/main/java/org/openedx/core/ui/ComposeCommon.kt +++ b/core/src/main/java/org/openedx/core/ui/ComposeCommon.kt @@ -1,5 +1,6 @@ package org.openedx.core.ui +import android.annotation.SuppressLint import android.content.res.Configuration import android.os.Build.VERSION.SDK_INT import androidx.compose.foundation.BorderStroke @@ -23,6 +24,7 @@ import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.width import androidx.compose.foundation.layout.widthIn +import androidx.compose.foundation.layout.wrapContentSize import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.LazyListState import androidx.compose.foundation.lazy.LazyRow @@ -115,6 +117,7 @@ import org.openedx.core.UIMessage import org.openedx.core.domain.model.RegistrationField import org.openedx.core.extension.LinkedImageText import org.openedx.core.extension.tagId +import org.openedx.core.extension.takeIfNotEmpty import org.openedx.core.extension.toastMessage import org.openedx.core.presentation.global.ErrorType import org.openedx.core.ui.theme.OpenEdXTheme @@ -1060,7 +1063,8 @@ fun OfflineModeDialog( } @Composable -fun OpenEdXButton( +@SuppressLint("ModifierParameter") +fun OpenEdXBrandButton( modifier: Modifier = Modifier.fillMaxWidth(), text: String = "", onClick: () -> Unit, @@ -1071,22 +1075,28 @@ fun OpenEdXButton( ) { Button( modifier = Modifier - .testTag("btn_${text.tagId()}") + .testTag( + text + .takeIfNotEmpty() + ?.let { "btn_${text.tagId()}" } ?: "" + ) .then(modifier) - .height(42.dp), + .heightIn(min = 42.dp), shape = MaterialTheme.appShapes.buttonShape, colors = ButtonDefaults.buttonColors( - backgroundColor = backgroundColor + backgroundColor = backgroundColor, + disabledBackgroundColor = backgroundColor.copy(alpha = 0.3f) ), enabled = enabled, - onClick = onClick + onClick = onClick, ) { if (content == null) { Text( modifier = Modifier.testTag("txt_${text.tagId()}"), text = text, + style = MaterialTheme.appTypography.labelLarge, color = textColor, - style = MaterialTheme.appTypography.labelLarge + textAlign = TextAlign.Center ) } else { content() @@ -1095,33 +1105,129 @@ fun OpenEdXButton( } @Composable -fun OpenEdXOutlinedButton( +@SuppressLint("ModifierParameter") +fun OpenEdXOutlineBrandButton( modifier: Modifier = Modifier.fillMaxWidth(), - backgroundColor: Color = Color.Transparent, - borderColor: Color, - textColor: Color, - text: String = "", - enabled: Boolean = true, + text: String, onClick: () -> Unit, + enabled: Boolean = true, + textColor: Color = MaterialTheme.appColors.primaryButtonBackground, + backgroundColor: Color = Color.White, + borderColor: Color = MaterialTheme.appColors.primaryButtonBackground, content: (@Composable RowScope.() -> Unit)? = null, ) { OutlinedButton( modifier = Modifier - .testTag("btn_${text.tagId()}") + .testTag( + text + .takeIfNotEmpty() + ?.let { "btn_${text.tagId()}" } ?: "" + ) .then(modifier) - .height(42.dp), + .heightIn(min = 42.dp), onClick = onClick, enabled = enabled, - border = BorderStroke(1.dp, borderColor), + border = BorderStroke(1.dp, if (enabled) borderColor else borderColor.copy(alpha = 0.3f)), shape = MaterialTheme.appShapes.buttonShape, - colors = ButtonDefaults.outlinedButtonColors(backgroundColor = backgroundColor) + colors = ButtonDefaults.buttonColors( + backgroundColor = backgroundColor, + disabledBackgroundColor = backgroundColor, + ), ) { if (content == null) { Text( modifier = Modifier.testTag("txt_${text.tagId()}"), text = text, style = MaterialTheme.appTypography.labelLarge, - color = textColor + color = if (enabled) textColor else textColor.copy(alpha = 0.3f), + textAlign = TextAlign.Center + ) + } else { + content() + } + } +} + +@Composable +@SuppressLint("ModifierParameter") +fun OpenEdXPrimaryButton( + modifier: Modifier = Modifier.fillMaxWidth(), + text: String, + onClick: () -> Unit, + enabled: Boolean = true, + textColor: Color = MaterialTheme.appColors.secondaryButtonText, + backgroundColor: Color = MaterialTheme.appColors.secondaryButtonBackground, + content: (@Composable RowScope.() -> Unit)? = null, +) { + OpenEdXBrandButton( + modifier = modifier, + text = text, + onClick = onClick, + enabled = enabled, + textColor = textColor, + backgroundColor = backgroundColor, + content = content + ) +} + +@Composable +@SuppressLint("ModifierParameter") +fun OpenEdXOutlinePrimaryButton( + modifier: Modifier = Modifier.fillMaxWidth(), + text: String, + onClick: () -> Unit, + enabled: Boolean = true, + textColor: Color = MaterialTheme.appColors.primaryButtonBorderedText, + backgroundColor: Color = MaterialTheme.appColors.background, + borderColor: Color = MaterialTheme.appColors.primaryButtonBorderedText, + content: (@Composable RowScope.() -> Unit)? = null, +) { + OpenEdXOutlineBrandButton( + modifier = modifier, + text = text, + onClick = onClick, + enabled = enabled, + textColor = textColor, + backgroundColor = backgroundColor, + borderColor = borderColor, + content = content + ) +} + +@Composable +@SuppressLint("ModifierParameter") +fun OpenEdXTertiaryButton( + modifier: Modifier = Modifier.wrapContentSize(), + text: String, + onClick: () -> Unit, + enabled: Boolean = true, + textColor: Color = MaterialTheme.appColors.textPrimary, + content: (@Composable RowScope.() -> Unit)? = null, +) { + Button( + modifier = Modifier + .testTag( + text + .takeIfNotEmpty() + ?.let { "btn_${text.tagId()}" } ?: "" + ) + .then(modifier) + .height(42.dp), + shape = MaterialTheme.appShapes.buttonShape, + colors = ButtonDefaults.buttonColors( + backgroundColor = Color.Transparent, + disabledBackgroundColor = Color.Transparent + ), + elevation = null, + enabled = enabled, + onClick = onClick, + ) { + if (content == null) { + Text( + modifier = Modifier.testTag("txt_${text.tagId()}"), + text = text, + style = MaterialTheme.appTypography.labelLarge, + color = textColor.copy(alpha = if (enabled) 1f else 0.3f) ) } else { content() @@ -1186,7 +1292,7 @@ fun FullScreenErrorView( textAlign = TextAlign.Center ) Spacer(Modifier.height(16.dp)) - OpenEdXButton( + OpenEdXPrimaryButton( modifier = Modifier .widthIn(Dp.Unspecified, 162.dp), text = stringResource(id = errorType.actionResId), @@ -1238,18 +1344,16 @@ fun AuthButtonsPanel( onSignInClick: () -> Unit, ) { Row { - OpenEdXButton( + OpenEdXBrandButton( modifier = Modifier .testTag("btn_register") .width(0.dp) .weight(1f), text = stringResource(id = R.string.core_register), - textColor = MaterialTheme.appColors.primaryButtonText, - backgroundColor = MaterialTheme.appColors.primaryButtonBackground, onClick = { onRegisterClick() } ) - OpenEdXOutlinedButton( + OpenEdXOutlineBrandButton( modifier = Modifier .testTag("btn_sign_in") .width(100.dp) @@ -1402,6 +1506,39 @@ private fun AuthButtonsPanelPreview() { AuthButtonsPanel(onRegisterClick = {}, onSignInClick = {}) } +@Preview(uiMode = Configuration.UI_MODE_NIGHT_NO) +@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES) +@Composable +private fun ButtonsPreview() { + OpenEdXTheme { + Column( + modifier = Modifier + .background(MaterialTheme.appColors.background) + .padding(16.dp), + verticalArrangement = Arrangement.spacedBy(16.dp) + ) { + OpenEdXBrandButton(text = "BrandButton", onClick = {}, enabled = true) + OpenEdXBrandButton(text = "BrandButtonDisabled", onClick = {}, enabled = false) + OpenEdXOutlineBrandButton(text = "OutlineBrandButton", onClick = {}, enabled = true) + OpenEdXOutlineBrandButton( + text = "OutlineBrandButtonDisabled", + onClick = {}, + enabled = false + ) + OpenEdXPrimaryButton(text = "PrimaryButton", onClick = {}, enabled = true) + OpenEdXPrimaryButton(text = "PrimaryButtonDisabled", onClick = {}, enabled = false) + OpenEdXOutlinePrimaryButton(text = "OutlinePrimaryButton", onClick = {}, enabled = true) + OpenEdXOutlinePrimaryButton( + text = "OutlinePrimaryButtonDisabled", + onClick = {}, + enabled = false + ) + OpenEdXTertiaryButton(text = "TertiaryButton", onClick = {}, enabled = true) + OpenEdXTertiaryButton(text = "TertiaryButtonDisabled", onClick = {}, enabled = false) + } + } +} + @Preview @Composable private fun OpenEdXOutlinedTextFieldPreview() { @@ -1426,10 +1563,11 @@ private fun IconTextPreview() { ) } -@Preview +@Preview(uiMode = Configuration.UI_MODE_NIGHT_NO) +@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable private fun ConnectionErrorViewPreview() { - OpenEdXTheme(darkTheme = true) { + OpenEdXTheme { ConnectionErrorView(onReloadClick = {}) } } @@ -1454,6 +1592,15 @@ private fun RoundTabsBarPreview() { } } +@Preview(uiMode = Configuration.UI_MODE_NIGHT_NO) +@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES) +@Composable +private fun OfflinePreview() { + OpenEdXTheme { + OfflineModeDialog(Modifier, {}, {}) + } +} + @Preview @Composable private fun PreviewNoContentScreen() { diff --git a/core/src/main/java/org/openedx/core/ui/IAPUI.kt b/core/src/main/java/org/openedx/core/ui/IAPUI.kt index 3fcbd380b..fb55b7915 100644 --- a/core/src/main/java/org/openedx/core/ui/IAPUI.kt +++ b/core/src/main/java/org/openedx/core/ui/IAPUI.kt @@ -1,12 +1,12 @@ package org.openedx.core.ui +import android.content.res.Configuration import androidx.compose.foundation.background import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.layout.wrapContentSize import androidx.compose.material.AlertDialog import androidx.compose.material.CircularProgressIndicator import androidx.compose.material.Icon @@ -28,6 +28,7 @@ import org.openedx.core.R import org.openedx.core.exception.iap.IAPException import org.openedx.core.presentation.iap.IAPAction import org.openedx.core.presentation.iap.IAPErrorDialogType +import org.openedx.core.ui.theme.OpenEdXTheme import org.openedx.core.ui.theme.appColors import org.openedx.core.ui.theme.appShapes import org.openedx.core.ui.theme.appTypography @@ -99,7 +100,8 @@ fun IAPErrorDialog(iapException: IAPException, onIAPAction: (IAPAction) -> Unit) } IAPErrorDialogType.ADD_TO_BASKET_NOT_ACCEPTABLE_ERROR_DIALOG, - IAPErrorDialogType.CHECKOUT_NOT_ACCEPTABLE_ERROR_DIALOG -> { + IAPErrorDialogType.CHECKOUT_NOT_ACCEPTABLE_ERROR_DIALOG, + -> { UpgradeErrorDialog( title = stringResource(id = R.string.iap_error_title), description = stringResource(id = dialogType.messageResId), @@ -114,7 +116,8 @@ fun IAPErrorDialog(iapException: IAPException, onIAPAction: (IAPAction) -> Unit) IAPErrorDialogType.EXECUTE_FORBIDDEN_ERROR_DIALOG, IAPErrorDialogType.EXECUTE_NOT_ACCEPTABLE_ERROR_DIALOG, IAPErrorDialogType.EXECUTE_GENERAL_ERROR_DIALOG, - IAPErrorDialogType.CONSUME_ERROR_DIALOG -> { + IAPErrorDialogType.CONSUME_ERROR_DIALOG, + -> { CourseAlreadyPurchasedExecuteErrorDialog( description = stringResource(id = dialogType.messageResId), positiveText = stringResource(id = dialogType.positiveButtonResId), @@ -177,8 +180,7 @@ fun NoSkuErrorDialog( ) }, confirmButton = { - OpenEdXButton( - modifier = Modifier.wrapContentSize(), + OpenEdXTertiaryButton( text = stringResource(id = R.string.core_ok), onClick = onConfirm ) @@ -226,28 +228,20 @@ fun CourseAlreadyPurchasedExecuteErrorDialog( modifier = Modifier .fillMaxWidth() .padding(horizontal = 8.dp), - verticalArrangement = Arrangement.SpaceBetween, + horizontalAlignment = Alignment.End, + verticalArrangement = Arrangement.spacedBy(4.dp) ) { - OpenEdXButton( - modifier = Modifier - .fillMaxWidth() - .padding(2.dp), + OpenEdXTertiaryButton( text = positiveText, onClick = onPositiveClick ) - OpenEdXButton( - modifier = Modifier - .fillMaxWidth() - .padding(2.dp), + OpenEdXTertiaryButton( text = negativeText, onClick = onNegativeClick ) - OpenEdXButton( - modifier = Modifier - .fillMaxWidth() - .padding(2.dp), + OpenEdXTertiaryButton( text = neutralText, onClick = onNeutralClick ) @@ -291,15 +285,13 @@ fun UpgradeErrorDialog( ) }, confirmButton = { - OpenEdXButton( - modifier = Modifier.wrapContentSize(), + OpenEdXTertiaryButton( text = confirmText, onClick = onConfirm ) }, dismissButton = { - OpenEdXButton( - modifier = Modifier.wrapContentSize(), + OpenEdXTertiaryButton( text = dismissText, onClick = onDismiss ) @@ -365,15 +357,13 @@ fun FakePurchasesFulfillmentCompleted(onCancel: () -> Unit, onGetHelp: () -> Uni ) }, confirmButton = { - OpenEdXButton( - modifier = Modifier.wrapContentSize(), + OpenEdXTertiaryButton( text = stringResource(id = R.string.core_cancel), onClick = onCancel ) }, dismissButton = { - OpenEdXButton( - modifier = Modifier.wrapContentSize(), + OpenEdXTertiaryButton( text = stringResource(id = R.string.iap_get_help), onClick = onGetHelp ) @@ -409,15 +399,13 @@ fun PurchasesFulfillmentCompletedDialog(onConfirm: () -> Unit, onDismiss: () -> ) }, confirmButton = { - OpenEdXButton( - modifier = Modifier.wrapContentSize(), + OpenEdXTertiaryButton( text = stringResource(id = R.string.iap_label_refresh_now), onClick = onConfirm ) }, dismissButton = { - OpenEdXButton( - modifier = Modifier.wrapContentSize(), + OpenEdXTertiaryButton( text = stringResource(id = R.string.iap_label_continue_without_update), onClick = onDismiss ) @@ -427,55 +415,76 @@ fun PurchasesFulfillmentCompletedDialog(onConfirm: () -> Unit, onDismiss: () -> ) } -@Preview +@Preview(uiMode = Configuration.UI_MODE_NIGHT_NO) +@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable private fun PreviewValuePropUpgradeFeatures() { - ValuePropUpgradeFeatures(modifier = Modifier.background(Color.White), "Test Course") + OpenEdXTheme { + ValuePropUpgradeFeatures(modifier = Modifier.background(Color.White), "Test Course") + } } -@Preview +@Preview(uiMode = Configuration.UI_MODE_NIGHT_NO) +@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable private fun PreviewUpgradeErrorDialog() { - UpgradeErrorDialog( - title = "Error while Upgrading", - description = "Description of the error", - confirmText = "Confirm", - onConfirm = {}, - dismissText = "Dismiss", - onDismiss = {}) + OpenEdXTheme { + UpgradeErrorDialog( + title = "Error while Upgrading", + description = "Description of the error", + confirmText = "Confirm", + onConfirm = {}, + dismissText = "Dismiss", + onDismiss = {}) + } } -@Preview +@Preview(uiMode = Configuration.UI_MODE_NIGHT_NO) +@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable private fun PreviewPurchasesFulfillmentCompletedDialog() { - PurchasesFulfillmentCompletedDialog(onConfirm = {}, onDismiss = {}) + OpenEdXTheme { + PurchasesFulfillmentCompletedDialog(onConfirm = {}, onDismiss = {}) + } } -@Preview +@Preview(uiMode = Configuration.UI_MODE_NIGHT_NO) +@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable private fun PreviewCheckingPurchasesDialog() { - CheckingPurchasesDialog() + OpenEdXTheme { + CheckingPurchasesDialog() + } } -@Preview +@Preview(uiMode = Configuration.UI_MODE_NIGHT_NO) +@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable private fun PreviewFakePurchasesFulfillmentCompleted() { - FakePurchasesFulfillmentCompleted(onCancel = {}, onGetHelp = {}) + OpenEdXTheme { + FakePurchasesFulfillmentCompleted(onCancel = {}, onGetHelp = {}) + } } -@Preview +@Preview(uiMode = Configuration.UI_MODE_NIGHT_NO) +@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable private fun PreviewCourseAlreadyPurchasedExecuteErrorDialog() { - CourseAlreadyPurchasedExecuteErrorDialog( - description = stringResource(id = R.string.iap_course_not_fullfilled), - positiveText = stringResource(id = R.string.iap_label_refresh_now), - negativeText = stringResource(id = R.string.iap_get_help), - neutralText = stringResource(id = R.string.core_cancel), - onPositiveClick = {}, onNegativeClick = {}, onNeutralClick = {}) + OpenEdXTheme { + CourseAlreadyPurchasedExecuteErrorDialog( + description = stringResource(id = R.string.iap_course_not_fullfilled), + positiveText = stringResource(id = R.string.iap_label_refresh_now), + negativeText = stringResource(id = R.string.iap_get_help), + neutralText = stringResource(id = R.string.core_cancel), + onPositiveClick = {}, onNegativeClick = {}, onNeutralClick = {}) + } } -@Preview +@Preview(uiMode = Configuration.UI_MODE_NIGHT_NO) +@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable private fun PreviewNoSkuErrorDialog() { - NoSkuErrorDialog(onConfirm = {}) + OpenEdXTheme { + NoSkuErrorDialog(onConfirm = {}) + } } diff --git a/course/src/main/java/org/openedx/course/presentation/ChapterEndFragmentDialog.kt b/course/src/main/java/org/openedx/course/presentation/ChapterEndFragmentDialog.kt index 58da7cebd..1c8e8e813 100644 --- a/course/src/main/java/org/openedx/course/presentation/ChapterEndFragmentDialog.kt +++ b/course/src/main/java/org/openedx/course/presentation/ChapterEndFragmentDialog.kt @@ -41,9 +41,8 @@ import androidx.compose.ui.unit.dp import androidx.core.os.bundleOf import androidx.fragment.app.DialogFragment import org.openedx.core.extension.setWidthPercent -import org.openedx.core.ui.AutoSizeText -import org.openedx.core.ui.OpenEdXButton -import org.openedx.core.ui.OpenEdXOutlinedButton +import org.openedx.core.ui.OpenEdXOutlinePrimaryButton +import org.openedx.core.ui.OpenEdXPrimaryButton import org.openedx.core.ui.TextIcon import org.openedx.core.ui.theme.OpenEdXTheme import org.openedx.core.ui.theme.appColors @@ -203,13 +202,13 @@ private fun ChapterEndDialogScreen( ) Spacer(Modifier.height(42.dp)) if (nextSectionName.isNotEmpty()) { - OpenEdXButton( + OpenEdXPrimaryButton( text = stringResource(id = R.string.course_next_section), content = { TextIcon( text = stringResource(id = R.string.course_next_section), painter = painterResource(org.openedx.core.R.drawable.core_ic_forward), - color = MaterialTheme.appColors.primaryButtonText, + color = MaterialTheme.appColors.secondaryButtonText, textStyle = MaterialTheme.appTypography.labelLarge, iconModifier = Modifier.rotate(if (isVerticalNavigation) 90f else 0f) ) @@ -218,18 +217,9 @@ private fun ChapterEndDialogScreen( ) Spacer(Modifier.height(16.dp)) } - OpenEdXOutlinedButton( - borderColor = MaterialTheme.appColors.primaryButtonBorder, - textColor = MaterialTheme.appColors.primaryButtonBorderedText, + OpenEdXOutlinePrimaryButton( text = stringResource(id = R.string.course_back_to_outline), onClick = onBackButtonClick, - content = { - AutoSizeText( - text = stringResource(id = R.string.course_back_to_outline), - style = MaterialTheme.appTypography.bodyMedium, - color = MaterialTheme.appColors.primaryButtonBorderedText - ) - } ) if (nextSectionName.isNotEmpty()) { Spacer(Modifier.height(24.dp)) @@ -320,13 +310,13 @@ private fun ChapterEndDialogScreenLandscape( horizontalAlignment = Alignment.CenterHorizontally ) { if (nextSectionName.isNotEmpty()) { - OpenEdXButton( + OpenEdXPrimaryButton( text = stringResource(id = R.string.course_next_section), content = { TextIcon( text = stringResource(id = R.string.course_next_section), painter = painterResource(org.openedx.core.R.drawable.core_ic_forward), - color = MaterialTheme.appColors.primaryButtonText, + color = MaterialTheme.appColors.secondaryButtonText, textStyle = MaterialTheme.appTypography.labelLarge ) }, @@ -334,18 +324,9 @@ private fun ChapterEndDialogScreenLandscape( ) Spacer(Modifier.height(16.dp)) } - OpenEdXOutlinedButton( - borderColor = MaterialTheme.appColors.primaryButtonBorder, - textColor = MaterialTheme.appColors.primaryButtonBorderedText, + OpenEdXOutlinePrimaryButton( text = stringResource(id = R.string.course_back_to_outline), - onClick = onBackButtonClick, - content = { - AutoSizeText( - text = stringResource(id = R.string.course_back_to_outline), - style = MaterialTheme.appTypography.bodyMedium, - color = MaterialTheme.appColors.primaryButtonBorderedText - ) - } + onClick = onBackButtonClick ) if (nextSectionName.isNotEmpty()) { Spacer(Modifier.height(24.dp)) diff --git a/course/src/main/java/org/openedx/course/presentation/container/CourseContainerFragment.kt b/course/src/main/java/org/openedx/course/presentation/container/CourseContainerFragment.kt index 829781ac2..92c8fe55a 100644 --- a/course/src/main/java/org/openedx/course/presentation/container/CourseContainerFragment.kt +++ b/course/src/main/java/org/openedx/course/presentation/container/CourseContainerFragment.kt @@ -86,8 +86,8 @@ import org.openedx.core.ui.CheckmarkView import org.openedx.core.ui.HandleUIMessage import org.openedx.core.ui.IAPErrorDialog import org.openedx.core.ui.OfflineModeDialog -import org.openedx.core.ui.OpenEdXButton -import org.openedx.core.ui.OpenEdXOutlinedButton +import org.openedx.core.ui.OpenEdXOutlinePrimaryButton +import org.openedx.core.ui.OpenEdXPrimaryButton import org.openedx.core.ui.RoundTabsBar import org.openedx.core.ui.UnlockingAccessView import org.openedx.core.ui.UpgradeToAccessView @@ -911,18 +911,15 @@ private fun SetupCourseAccessErrorButtons( CourseAccessError.AUDIT_EXPIRED_NOT_UPGRADABLE, CourseAccessError.NOT_YET_STARTED, -> { - OpenEdXButton( + OpenEdXPrimaryButton( text = stringResource(R.string.course_label_back), onClick = { fragmentManager.popBackStack() }, ) } CourseAccessError.AUDIT_EXPIRED_UPGRADABLE -> { - OpenEdXOutlinedButton( + OpenEdXOutlinePrimaryButton( text = stringResource(R.string.course_find_new_course_button), - backgroundColor = MaterialTheme.appColors.background, - textColor = MaterialTheme.appColors.primary, - borderColor = MaterialTheme.appColors.primary, onClick = { viewModel.courseRouter.navigateToDiscover(fragmentManager) } @@ -948,7 +945,7 @@ private fun SetupCourseAccessErrorButtons( CourseAccessError.UNKNOWN -> { if (viewModel.hasInternetConnection) { - OpenEdXButton( + OpenEdXPrimaryButton( text = stringResource(R.string.course_label_back), onClick = { fragmentManager.popBackStack() }, ) diff --git a/course/src/main/java/org/openedx/course/presentation/outline/CourseOutlineScreen.kt b/course/src/main/java/org/openedx/course/presentation/outline/CourseOutlineScreen.kt index 1c176a56d..50bd446be 100644 --- a/course/src/main/java/org/openedx/course/presentation/outline/CourseOutlineScreen.kt +++ b/course/src/main/java/org/openedx/course/presentation/outline/CourseOutlineScreen.kt @@ -61,7 +61,7 @@ import org.openedx.core.presentation.course.CourseViewMode import org.openedx.core.ui.CircularProgress import org.openedx.core.ui.HandleUIMessage import org.openedx.core.ui.NoContentScreen -import org.openedx.core.ui.OpenEdXOutlinedButton +import org.openedx.core.ui.OpenEdXOutlinePrimaryButton import org.openedx.core.ui.TextIcon import org.openedx.core.ui.WindowSize import org.openedx.core.ui.WindowType @@ -391,7 +391,7 @@ private fun ResumeCourse( ) } Spacer(Modifier.height(16.dp)) - OpenEdXOutlinedButton( + OpenEdXOutlinePrimaryButton( text = stringResource(id = R.string.course_resume), textColor = MaterialTheme.appColors.primaryButtonBorderedText, borderColor = MaterialTheme.appColors.primaryButtonBorder, @@ -452,7 +452,7 @@ private fun ResumeCourseTablet( ) } } - OpenEdXOutlinedButton( + OpenEdXOutlinePrimaryButton( modifier = Modifier.width(210.dp), text = stringResource(id = R.string.course_resume), textColor = MaterialTheme.appColors.primaryButtonBorderedText, diff --git a/course/src/main/java/org/openedx/course/presentation/ui/CourseUI.kt b/course/src/main/java/org/openedx/course/presentation/ui/CourseUI.kt index 2f1ac5876..636dc6417 100644 --- a/course/src/main/java/org/openedx/course/presentation/ui/CourseUI.kt +++ b/course/src/main/java/org/openedx/course/presentation/ui/CourseUI.kt @@ -29,8 +29,6 @@ import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.LazyListState import androidx.compose.foundation.lazy.itemsIndexed import androidx.compose.foundation.shape.CircleShape -import androidx.compose.material.Button -import androidx.compose.material.ButtonDefaults import androidx.compose.material.Card import androidx.compose.material.CircularProgressIndicator import androidx.compose.material.Divider @@ -38,7 +36,6 @@ import androidx.compose.material.Icon import androidx.compose.material.IconButton import androidx.compose.material.LinearProgressIndicator import androidx.compose.material.MaterialTheme -import androidx.compose.material.OutlinedButton import androidx.compose.material.Scaffold import androidx.compose.material.Snackbar import androidx.compose.material.Surface @@ -91,8 +88,8 @@ import org.openedx.core.module.db.DownloadedState import org.openedx.core.module.db.FileType import org.openedx.core.ui.BackBtn import org.openedx.core.ui.IconText -import org.openedx.core.ui.OpenEdXButton -import org.openedx.core.ui.OpenEdXOutlinedButton +import org.openedx.core.ui.OpenEdXOutlinePrimaryButton +import org.openedx.core.ui.OpenEdXPrimaryButton import org.openedx.core.ui.displayCutoutForLandscape import org.openedx.core.ui.noRippleClickable import org.openedx.core.ui.theme.OpenEdXTheme @@ -344,15 +341,10 @@ fun NavigationUnitsButtons( horizontalArrangement = Arrangement.Center ) { if (hasPrevBlock) { - OutlinedButton( + OpenEdXOutlinePrimaryButton( modifier = Modifier .height(42.dp), - colors = ButtonDefaults.outlinedButtonColors( - backgroundColor = MaterialTheme.appColors.background - ), - border = BorderStroke(1.dp, MaterialTheme.appColors.primaryButtonBorder), - elevation = null, - shape = MaterialTheme.appShapes.navigationButtonShape, + text = stringResource(R.string.course_navigation_prev), onClick = onPrevClick, ) { Row( @@ -375,14 +367,10 @@ fun NavigationUnitsButtons( } Spacer(Modifier.width(16.dp)) } - Button( + OpenEdXPrimaryButton( modifier = Modifier .height(42.dp), - colors = ButtonDefaults.buttonColors( - backgroundColor = MaterialTheme.appColors.secondaryButtonBackground - ), - elevation = null, - shape = MaterialTheme.appShapes.navigationButtonShape, + text = nextButtonText, onClick = onNextClick ) { Row( @@ -1018,11 +1006,9 @@ fun CourseDatesBanner( } banner.bannerType.buttonResId.nonZero()?.let { - OpenEdXButton( + OpenEdXPrimaryButton( text = stringResource(id = it), onClick = resetDates, - textColor = MaterialTheme.appColors.secondaryButtonText, - backgroundColor = MaterialTheme.appColors.secondaryButtonBackground, ) } } @@ -1074,12 +1060,10 @@ fun CourseDatesBannerTablet( } } banner.bannerType.buttonResId.nonZero()?.let { - OpenEdXButton( + OpenEdXPrimaryButton( modifier = Modifier.width(210.dp), text = stringResource(id = it), onClick = resetDates, - textColor = MaterialTheme.appColors.secondaryButtonText, - backgroundColor = MaterialTheme.appColors.secondaryButtonBackground, ) } } @@ -1122,17 +1106,12 @@ fun DatesShiftedSnackBar( style = MaterialTheme.appTypography.titleSmall, ) if (showAction) { - OpenEdXOutlinedButton( + OpenEdXOutlinePrimaryButton( modifier = Modifier - .padding(top = 16.dp) - .fillMaxWidth(), + .padding(top = 16.dp), text = stringResource(id = coreR.string.core_dates_view_all_dates), - backgroundColor = MaterialTheme.appColors.background, - textColor = MaterialTheme.appColors.primary, - borderColor = MaterialTheme.appColors.primary, - onClick = { - onViewDates() - }) + onClick = { onViewDates() } + ) } } } diff --git a/course/src/main/java/org/openedx/course/presentation/ui/CourseVideosUI.kt b/course/src/main/java/org/openedx/course/presentation/ui/CourseVideosUI.kt index 32a2c31ed..f51e522f8 100644 --- a/course/src/main/java/org/openedx/course/presentation/ui/CourseVideosUI.kt +++ b/course/src/main/java/org/openedx/course/presentation/ui/CourseVideosUI.kt @@ -29,7 +29,6 @@ import androidx.compose.material.Surface import androidx.compose.material.Switch import androidx.compose.material.SwitchDefaults import androidx.compose.material.Text -import androidx.compose.material.TextButton import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.ChevronRight import androidx.compose.material.icons.outlined.Settings @@ -71,6 +70,7 @@ import org.openedx.core.presentation.settings.video.VideoQualityType import org.openedx.core.ui.CircularProgress import org.openedx.core.ui.HandleUIMessage import org.openedx.core.ui.NoContentScreen +import org.openedx.core.ui.OpenEdXTertiaryButton import org.openedx.core.ui.WindowSize import org.openedx.core.ui.WindowType import org.openedx.core.ui.displayCutoutForLandscape @@ -314,25 +314,21 @@ private fun CourseVideosUI( isDownloadConfirmationShowed = false }, confirmButton = { - TextButton( + OpenEdXTertiaryButton( + text = stringResource(id = org.openedx.core.R.string.core_confirm), onClick = { isDownloadConfirmationShowed = false onDownloadAllClick(false) } - ) { - Text( - text = stringResource(id = org.openedx.core.R.string.core_confirm) - ) - } + ) }, dismissButton = { - TextButton( + OpenEdXTertiaryButton( + text = stringResource(id = org.openedx.core.R.string.core_dismiss), onClick = { isDownloadConfirmationShowed = false } - ) { - Text(text = stringResource(id = org.openedx.core.R.string.core_dismiss)) - } + ) } ) } @@ -362,25 +358,21 @@ private fun CourseVideosUI( isDeleteDownloadsConfirmationShowed = false }, confirmButton = { - TextButton( + OpenEdXTertiaryButton( + text = stringResource(id = org.openedx.core.R.string.core_delete), onClick = { isDeleteDownloadsConfirmationShowed = false onDownloadAllClick(true) } - ) { - Text( - text = stringResource(id = org.openedx.core.R.string.core_delete) - ) - } + ) }, dismissButton = { - TextButton( + OpenEdXTertiaryButton( + text = stringResource(id = org.openedx.core.R.string.core_cancel), onClick = { isDeleteDownloadsConfirmationShowed = false } - ) { - Text(text = stringResource(id = org.openedx.core.R.string.core_cancel)) - } + ) } ) } @@ -404,27 +396,21 @@ private fun CourseVideosUI( deleteDownloadBlock = null }, confirmButton = { - TextButton( + OpenEdXTertiaryButton( + text = stringResource(id = org.openedx.core.R.string.core_delete), onClick = { deleteDownloadBlock?.let { block -> onDownloadClick(listOf(block.id)) } deleteDownloadBlock = null } - ) { - Text( - text = stringResource(id = org.openedx.core.R.string.core_delete) - ) - } + ) }, dismissButton = { - TextButton( - onClick = { - deleteDownloadBlock = null - } - ) { - Text(text = stringResource(id = org.openedx.core.R.string.core_cancel)) - } + OpenEdXTertiaryButton( + text = stringResource(id = org.openedx.core.R.string.core_cancel), + onClick = { deleteDownloadBlock = null } + ) } ) } diff --git a/course/src/main/java/org/openedx/course/presentation/unit/NotSupportedUnitFragment.kt b/course/src/main/java/org/openedx/course/presentation/unit/NotSupportedUnitFragment.kt index 0aaae4a3c..a7c79e2c1 100644 --- a/course/src/main/java/org/openedx/course/presentation/unit/NotSupportedUnitFragment.kt +++ b/course/src/main/java/org/openedx/course/presentation/unit/NotSupportedUnitFragment.kt @@ -1,12 +1,26 @@ package org.openedx.course.presentation.unit +import android.content.res.Configuration import android.os.Bundle import android.view.LayoutInflater import android.view.ViewGroup -import androidx.compose.foundation.layout.* +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.size +import androidx.compose.foundation.layout.width import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.verticalScroll -import androidx.compose.material.* +import androidx.compose.material.Icon +import androidx.compose.material.MaterialTheme +import androidx.compose.material.Scaffold +import androidx.compose.material.Text +import androidx.compose.material.rememberScaffoldState import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf @@ -19,14 +33,16 @@ import androidx.compose.ui.platform.ViewCompositionStrategy import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.style.TextAlign +import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import androidx.core.os.bundleOf import androidx.fragment.app.Fragment +import org.openedx.core.ui.OpenEdXPrimaryButton import org.openedx.core.ui.WindowSize +import org.openedx.core.ui.WindowType import org.openedx.core.ui.rememberWindowSize import org.openedx.core.ui.theme.OpenEdXTheme import org.openedx.core.ui.theme.appColors -import org.openedx.core.ui.theme.appShapes import org.openedx.core.ui.theme.appTypography import org.openedx.core.ui.windowSizeValue import org.openedx.course.R as courseR @@ -134,24 +150,28 @@ private fun NotSupportedUnitScreen( textAlign = TextAlign.Center ) Spacer(Modifier.height(40.dp)) - Button(modifier = Modifier - .width(216.dp) - .height(42.dp), - shape = MaterialTheme.appShapes.buttonShape, - colors = ButtonDefaults.buttonColors( - backgroundColor = MaterialTheme.appColors.primaryButtonBackground - ), + OpenEdXPrimaryButton( + modifier = Modifier + .width(216.dp) + .height(42.dp), + text = stringResource(id = courseR.string.course_open_in_browser), onClick = { uriHandler.openUri(uri) - }) { - Text( - text = stringResource(id = courseR.string.course_open_in_browser), - color = MaterialTheme.appColors.primaryButtonText, - style = MaterialTheme.appTypography.labelLarge - ) - } + }) Spacer(Modifier.height(20.dp)) } } } -} \ No newline at end of file +} + +@Preview(uiMode = Configuration.UI_MODE_NIGHT_NO) +@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES) +@Composable +private fun PageIndicatorViewPreview() { + OpenEdXTheme { + NotSupportedUnitScreen( + windowSize = WindowSize(WindowType.Compact, WindowType.Compact), + uri = "https://www.text.com" + ) + } +} diff --git a/dashboard/src/main/java/org/openedx/courses/presentation/DashboardGalleryView.kt b/dashboard/src/main/java/org/openedx/courses/presentation/DashboardGalleryView.kt index 87329ab68..cc7db920f 100644 --- a/dashboard/src/main/java/org/openedx/courses/presentation/DashboardGalleryView.kt +++ b/dashboard/src/main/java/org/openedx/courses/presentation/DashboardGalleryView.kt @@ -93,7 +93,7 @@ import org.openedx.core.presentation.iap.IAPAction import org.openedx.core.presentation.iap.IAPUIState import org.openedx.core.ui.HandleUIMessage import org.openedx.core.ui.OfflineModeDialog -import org.openedx.core.ui.OpenEdXButton +import org.openedx.core.ui.OpenEdXBrandButton import org.openedx.core.ui.PurchasesFulfillmentCompletedDialog import org.openedx.core.ui.TextIcon import org.openedx.core.ui.UpgradeErrorDialog @@ -944,19 +944,14 @@ private fun FindACourseButton( modifier: Modifier = Modifier, findACourseClick: () -> Unit ) { - OpenEdXButton( + OpenEdXBrandButton( modifier = modifier - .fillMaxWidth() .padding(horizontal = 8.dp, vertical = 20.dp), + text = stringResource(id = R.string.dashboard_find_a_course), onClick = { findACourseClick() } - ) { - Text( - color = MaterialTheme.appColors.primaryButtonText, - text = stringResource(id = R.string.dashboard_find_a_course) - ) - } + ) } @Composable @@ -1095,6 +1090,15 @@ private fun DashboardGalleryViewPreview() { @Composable private fun NoCoursesInfoPreview() { OpenEdXTheme { - NoCoursesInfo() + Box( + modifier = Modifier + .fillMaxSize() + .background(MaterialTheme.appColors.background), + ) { + NoCoursesInfo(modifier = Modifier.align(Alignment.Center)) + FindACourseButton( + modifier = Modifier.align(Alignment.BottomCenter), + findACourseClick = {}) + } } } diff --git a/discovery/src/main/java/org/openedx/discovery/presentation/detail/CourseDetailsFragment.kt b/discovery/src/main/java/org/openedx/discovery/presentation/detail/CourseDetailsFragment.kt index a1cef9677..a5d1dd935 100644 --- a/discovery/src/main/java/org/openedx/discovery/presentation/detail/CourseDetailsFragment.kt +++ b/discovery/src/main/java/org/openedx/discovery/presentation/detail/CourseDetailsFragment.kt @@ -86,7 +86,7 @@ import org.openedx.core.extension.isEmailValid import org.openedx.core.ui.AuthButtonsPanel import org.openedx.core.ui.HandleUIMessage import org.openedx.core.ui.OfflineModeDialog -import org.openedx.core.ui.OpenEdXButton +import org.openedx.core.ui.OpenEdXBrandButton import org.openedx.core.ui.Toolbar import org.openedx.core.ui.WindowSize import org.openedx.core.ui.WindowType @@ -487,7 +487,7 @@ private fun CourseDetailNativeContent( ) if (!(enrollmentEnd != null && Date() > enrollmentEnd)) { Spacer(Modifier.height(32.dp)) - OpenEdXButton( + OpenEdXBrandButton( modifier = buttonWidth, text = buttonText, onClick = onButtonClick @@ -565,7 +565,7 @@ private fun CourseDetailNativeContentLandscape( EnrollOverLabel() Spacer(Modifier.height(24.dp)) } else { - OpenEdXButton( + OpenEdXBrandButton( modifier = buttonWidth, text = buttonText, onClick = onButtonClick diff --git a/discussion/src/main/java/org/openedx/discussion/presentation/threads/DiscussionAddThreadFragment.kt b/discussion/src/main/java/org/openedx/discussion/presentation/threads/DiscussionAddThreadFragment.kt index 9a3f6f37e..8b206c2b9 100644 --- a/discussion/src/main/java/org/openedx/discussion/presentation/threads/DiscussionAddThreadFragment.kt +++ b/discussion/src/main/java/org/openedx/discussion/presentation/threads/DiscussionAddThreadFragment.kt @@ -76,7 +76,7 @@ import org.koin.core.parameter.parametersOf import org.openedx.core.UIMessage import org.openedx.core.ui.BackBtn import org.openedx.core.ui.HandleUIMessage -import org.openedx.core.ui.OpenEdXButton +import org.openedx.core.ui.OpenEdXBrandButton import org.openedx.core.ui.OpenEdXOutlinedTextField import org.openedx.core.ui.SheetContent import org.openedx.core.ui.WindowSize @@ -437,7 +437,7 @@ private fun DiscussionAddThreadScreen( if (isLoading) { CircularProgressIndicator(color = MaterialTheme.appColors.primary) } else { - OpenEdXButton( + OpenEdXBrandButton( modifier = buttonWidth, text = if (currentPage == 0) { stringResource(id = discussionR.string.discussion_create_post) diff --git a/discussion/src/main/java/org/openedx/discussion/presentation/threads/DiscussionThreadsFragment.kt b/discussion/src/main/java/org/openedx/discussion/presentation/threads/DiscussionThreadsFragment.kt index 8693514b1..ff8fe6a0e 100644 --- a/discussion/src/main/java/org/openedx/discussion/presentation/threads/DiscussionThreadsFragment.kt +++ b/discussion/src/main/java/org/openedx/discussion/presentation/threads/DiscussionThreadsFragment.kt @@ -6,20 +6,49 @@ import android.view.LayoutInflater import android.view.ViewGroup import androidx.compose.foundation.background import androidx.compose.foundation.clickable -import androidx.compose.foundation.layout.* +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.PaddingValues +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.navigationBarsPadding +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.size +import androidx.compose.foundation.layout.widthIn import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.items import androidx.compose.foundation.lazy.rememberLazyListState import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.shape.CircleShape import androidx.compose.foundation.verticalScroll -import androidx.compose.material.* +import androidx.compose.material.CircularProgressIndicator +import androidx.compose.material.Divider +import androidx.compose.material.ExperimentalMaterialApi +import androidx.compose.material.Icon +import androidx.compose.material.MaterialTheme +import androidx.compose.material.ModalBottomSheetLayout +import androidx.compose.material.ModalBottomSheetValue +import androidx.compose.material.Scaffold +import androidx.compose.material.Surface +import androidx.compose.material.Text import androidx.compose.material.pullrefresh.PullRefreshIndicator import androidx.compose.material.pullrefresh.pullRefresh import androidx.compose.material.pullrefresh.rememberPullRefreshState -import androidx.compose.runtime.* +import androidx.compose.material.rememberModalBottomSheetState +import androidx.compose.material.rememberScaffoldState +import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.getValue import androidx.compose.runtime.livedata.observeAsState +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.runtime.saveable.rememberSaveable +import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip @@ -46,8 +75,24 @@ import org.koin.core.parameter.parametersOf import org.openedx.core.FragmentViewType import org.openedx.core.UIMessage import org.openedx.core.extension.TextConverter -import org.openedx.core.ui.* -import org.openedx.core.ui.theme.* +import org.openedx.core.ui.BackBtn +import org.openedx.core.ui.HandleUIMessage +import org.openedx.core.ui.IconText +import org.openedx.core.ui.OpenEdXOutlinePrimaryButton +import org.openedx.core.ui.SheetContent +import org.openedx.core.ui.WindowSize +import org.openedx.core.ui.WindowType +import org.openedx.core.ui.displayCutoutForLandscape +import org.openedx.core.ui.isImeVisibleState +import org.openedx.core.ui.noRippleClickable +import org.openedx.core.ui.rememberWindowSize +import org.openedx.core.ui.shouldLoadMore +import org.openedx.core.ui.statusBarsInset +import org.openedx.core.ui.theme.OpenEdXTheme +import org.openedx.core.ui.theme.appColors +import org.openedx.core.ui.theme.appShapes +import org.openedx.core.ui.theme.appTypography +import org.openedx.core.ui.windowSizeValue import org.openedx.discussion.domain.model.DiscussionType import org.openedx.discussion.presentation.DiscussionRouter import org.openedx.discussion.presentation.ui.ThreadItem @@ -484,7 +529,9 @@ private fun DiscussionThreadsScreen( Icon( modifier = Modifier.size(16.dp), painter = painterResource(id = discussionR.drawable.discussion_ic_add_comment), - contentDescription = stringResource(id = discussionR.string.discussion_add_comment), + contentDescription = stringResource( + id = discussionR.string.discussion_add_comment + ), tint = MaterialTheme.appColors.primaryButtonText ) } @@ -557,7 +604,7 @@ private fun DiscussionThreadsScreen( textAlign = TextAlign.Center ) Spacer(Modifier.height(40.dp)) - OpenEdXOutlinedButton( + OpenEdXOutlinePrimaryButton( modifier = Modifier .widthIn(184.dp, Dp.Unspecified), text = stringResource(id = discussionR.string.discussion_create_post), @@ -565,20 +612,13 @@ private fun DiscussionThreadsScreen( onCreatePostClick() }, content = { - Icon( - painter = painterResource(id = discussionR.drawable.discussion_ic_add_comment), - contentDescription = null, - tint = MaterialTheme.appColors.primary - ) - Spacer(modifier = Modifier.width(6.dp)) - Text( + IconText( text = stringResource(id = discussionR.string.discussion_create_post), + painter = painterResource(id = discussionR.drawable.discussion_ic_add_comment), color = MaterialTheme.appColors.primary, - style = MaterialTheme.appTypography.labelLarge + textStyle = MaterialTheme.appTypography.labelLarge, ) }, - borderColor = MaterialTheme.appColors.primary, - textColor = MaterialTheme.appColors.primary ) } } @@ -610,8 +650,6 @@ private fun DiscussionThreadsScreen( @Preview(uiMode = Configuration.UI_MODE_NIGHT_NO) @Preview(uiMode = Configuration.UI_MODE_NIGHT_YES) -@Preview(name = "NEXUS_5_Light", device = Devices.NEXUS_5, uiMode = Configuration.UI_MODE_NIGHT_NO) -@Preview(name = "NEXUS_5_Dark", device = Devices.NEXUS_5, uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable private fun DiscussionThreadsScreenPreview() { OpenEdXTheme { @@ -634,6 +672,30 @@ private fun DiscussionThreadsScreenPreview() { } } +@Preview(uiMode = Configuration.UI_MODE_NIGHT_NO) +@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES) +@Composable +private fun DiscussionThreadsEmptyScreenPreview() { + OpenEdXTheme { + DiscussionThreadsScreen( + windowSize = WindowSize(WindowType.Compact, WindowType.Compact), + "All posts", + uiState = DiscussionThreadsUIState.Threads(emptyList()), + uiMessage = null, + onItemClick = {}, + onBackClick = {}, + updatedOrder = {}, + updatedFilter = {}, + onCreatePostClick = {}, + viewType = FragmentViewType.FULL_CONTENT, + onSwipeRefresh = {}, + paginationCallback = {}, + refreshing = false, + canLoadMore = false + ) + } +} + @Preview(name = "NEXUS_9_Light", device = Devices.NEXUS_9, uiMode = Configuration.UI_MODE_NIGHT_NO) @Preview(name = "NEXUS_9_Dark", device = Devices.NEXUS_9, uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable diff --git a/profile/src/main/java/org/openedx/profile/presentation/calendar/CalendarAccessDialogFragment.kt b/profile/src/main/java/org/openedx/profile/presentation/calendar/CalendarAccessDialogFragment.kt index 8d49fb8ec..d3e444a0a 100644 --- a/profile/src/main/java/org/openedx/profile/presentation/calendar/CalendarAccessDialogFragment.kt +++ b/profile/src/main/java/org/openedx/profile/presentation/calendar/CalendarAccessDialogFragment.kt @@ -33,8 +33,8 @@ import androidx.fragment.app.DialogFragment import org.koin.android.ext.android.inject import org.openedx.core.config.Config import org.openedx.core.presentation.dialog.DefaultDialogBox -import org.openedx.core.ui.OpenEdXButton -import org.openedx.core.ui.OpenEdXOutlinedButton +import org.openedx.core.ui.OpenEdXOutlinePrimaryButton +import org.openedx.core.ui.OpenEdXPrimaryButton import org.openedx.core.ui.TextIcon import org.openedx.core.ui.theme.OpenEdXTheme import org.openedx.core.ui.theme.appColors @@ -119,8 +119,8 @@ private fun CalendarAccessDialog( style = MaterialTheme.appTypography.bodyMedium, color = MaterialTheme.appColors.textDark ) - OpenEdXButton( - modifier = Modifier.fillMaxWidth(), + OpenEdXPrimaryButton( + text = stringResource(id = R.string.profile_grant_access_calendar), onClick = { onGrantCalendarAccessClick() }, @@ -128,21 +128,15 @@ private fun CalendarAccessDialog( TextIcon( text = stringResource(id = R.string.profile_grant_access_calendar), icon = Icons.AutoMirrored.Filled.OpenInNew, - color = MaterialTheme.appColors.primaryButtonText, + color = MaterialTheme.appColors.secondaryButtonText, textStyle = MaterialTheme.appTypography.labelLarge, iconModifier = Modifier.padding(start = 4.dp) ) } ) - OpenEdXOutlinedButton( - modifier = Modifier.fillMaxWidth(), + OpenEdXOutlinePrimaryButton( text = stringResource(id = CoreR.string.core_cancel), - backgroundColor = MaterialTheme.appColors.background, - borderColor = MaterialTheme.appColors.primaryButtonBackground, - textColor = MaterialTheme.appColors.primaryButtonBackground, - onClick = { - onCancelClick() - } + onClick = { onCancelClick() } ) } } diff --git a/profile/src/main/java/org/openedx/profile/presentation/calendar/CalendarFragment.kt b/profile/src/main/java/org/openedx/profile/presentation/calendar/CalendarFragment.kt index 8a8794c94..e143ba81a 100644 --- a/profile/src/main/java/org/openedx/profile/presentation/calendar/CalendarFragment.kt +++ b/profile/src/main/java/org/openedx/profile/presentation/calendar/CalendarFragment.kt @@ -43,7 +43,7 @@ import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp import androidx.fragment.app.Fragment import org.koin.androidx.viewmodel.ext.android.viewModel -import org.openedx.core.ui.OpenEdXButton +import org.openedx.core.ui.OpenEdXBrandButton import org.openedx.core.ui.Toolbar import org.openedx.core.ui.WindowSize import org.openedx.core.ui.WindowType @@ -233,7 +233,7 @@ private fun CalendarScreen( color = MaterialTheme.appColors.textDark ) Spacer(modifier = Modifier.height(16.dp)) - OpenEdXButton( + OpenEdXBrandButton( modifier = Modifier.fillMaxWidth(0.75f), text = stringResource(id = R.string.profile_set_up_calendar_sync), onClick = { diff --git a/profile/src/main/java/org/openedx/profile/presentation/calendar/NewCalendarDialogFragment.kt b/profile/src/main/java/org/openedx/profile/presentation/calendar/NewCalendarDialogFragment.kt index 8e55b885b..e8fd57af9 100644 --- a/profile/src/main/java/org/openedx/profile/presentation/calendar/NewCalendarDialogFragment.kt +++ b/profile/src/main/java/org/openedx/profile/presentation/calendar/NewCalendarDialogFragment.kt @@ -60,8 +60,8 @@ import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import androidx.fragment.app.DialogFragment import org.openedx.core.presentation.dialog.DefaultDialogBox -import org.openedx.core.ui.OpenEdXButton -import org.openedx.core.ui.OpenEdXOutlinedButton +import org.openedx.core.ui.OpenEdXBrandButton +import org.openedx.core.ui.OpenEdXOutlineBrandButton import org.openedx.core.ui.crop import org.openedx.core.ui.theme.OpenEdXTheme import org.openedx.core.ui.theme.appColors @@ -168,26 +168,23 @@ private fun NewCalendarDialog( textAlign = TextAlign.Center, color = MaterialTheme.appColors.textDark ) - OpenEdXOutlinedButton( - modifier = Modifier.fillMaxWidth(), - text = stringResource(id = CoreR.string.core_cancel), - backgroundColor = MaterialTheme.appColors.background, - borderColor = MaterialTheme.appColors.primaryButtonBackground, - textColor = MaterialTheme.appColors.primaryButtonBackground, - onClick = { - onCancelClick() - } - ) - OpenEdXButton( - modifier = Modifier.fillMaxWidth(), + OpenEdXBrandButton( text = stringResource(id = R.string.profile_begin_syncing), onClick = { onBeginSyncingClick( - calendarName.ifEmpty { NewCalendarDialogFragment.getDefaultCalendarName(context) }, + calendarName.ifEmpty { + NewCalendarDialogFragment.getDefaultCalendarName( + context + ) + }, calendarColor ) } ) + OpenEdXOutlineBrandButton( + text = stringResource(id = CoreR.string.core_cancel), + onClick = { onCancelClick() } + ) } } } diff --git a/profile/src/main/java/org/openedx/profile/presentation/delete/DeleteProfileFragment.kt b/profile/src/main/java/org/openedx/profile/presentation/delete/DeleteProfileFragment.kt index 85952c9f4..6e68ef12e 100644 --- a/profile/src/main/java/org/openedx/profile/presentation/delete/DeleteProfileFragment.kt +++ b/profile/src/main/java/org/openedx/profile/presentation/delete/DeleteProfileFragment.kt @@ -58,7 +58,7 @@ import org.koin.androidx.viewmodel.ext.android.viewModel import org.openedx.core.R import org.openedx.core.UIMessage import org.openedx.core.ui.HandleUIMessage -import org.openedx.core.ui.OpenEdXButton +import org.openedx.core.ui.OpenEdXBrandButton import org.openedx.core.ui.OpenEdXOutlinedTextField import org.openedx.core.ui.Toolbar import org.openedx.core.ui.WindowSize @@ -275,7 +275,7 @@ fun DeleteProfileScreen( errorText = errorText ) Spacer(Modifier.height(38.dp)) - OpenEdXButton( + OpenEdXBrandButton( text = stringResource(id = profileR.string.profile_yes_delete_account), enabled = uiState !is DeleteProfileFragmentUIState.Loading && password.isNotEmpty(), backgroundColor = MaterialTheme.appColors.error, diff --git a/profile/src/main/java/org/openedx/profile/presentation/edit/EditProfileFragment.kt b/profile/src/main/java/org/openedx/profile/presentation/edit/EditProfileFragment.kt index deece15ec..32c2372d7 100644 --- a/profile/src/main/java/org/openedx/profile/presentation/edit/EditProfileFragment.kt +++ b/profile/src/main/java/org/openedx/profile/presentation/edit/EditProfileFragment.kt @@ -120,12 +120,12 @@ import org.openedx.core.domain.model.RegistrationField import org.openedx.core.extension.getFileName import org.openedx.core.extension.parcelable import org.openedx.core.extension.tagId -import org.openedx.core.ui.AutoSizeText import org.openedx.core.ui.BackBtn import org.openedx.core.ui.HandleUIMessage import org.openedx.core.ui.IconText -import org.openedx.core.ui.OpenEdXButton -import org.openedx.core.ui.OpenEdXOutlinedButton +import org.openedx.core.ui.OpenEdXOutlinePrimaryButton +import org.openedx.core.ui.OpenEdXPrimaryButton +import org.openedx.core.ui.OpenEdXTertiaryButton import org.openedx.core.ui.SheetContent import org.openedx.core.ui.WindowSize import org.openedx.core.ui.WindowType @@ -504,6 +504,7 @@ private fun EditProfileScreen( if (isOpenChangeImageDialogState && uiState.account.isOlderThanMinAge()) { ChangeImageDialog( + hasProfileImage = imageRes != coreR.drawable.core_ic_default_profile_picture, onSelectFromGalleryClick = { isOpenChangeImageDialogState = false onSelectImageClick() @@ -842,6 +843,7 @@ private fun LimitedProfileDialog( @Composable private fun ChangeImageDialog( + hasProfileImage: Boolean, onSelectFromGalleryClick: () -> Unit, onRemoveImageClick: () -> Unit, onCancelClick: () -> Unit, @@ -886,7 +888,7 @@ private fun ChangeImageDialog( color = MaterialTheme.appColors.textPrimary ) Spacer(Modifier.height(20.dp)) - OpenEdXButton( + OpenEdXPrimaryButton( text = stringResource(id = R.string.profile_select_from_gallery), onClick = onSelectFromGalleryClick, content = { @@ -894,31 +896,29 @@ private fun ChangeImageDialog( modifier = Modifier.testTag("it_select_from_gallery"), text = stringResource(id = R.string.profile_select_from_gallery), painter = painterResource(id = R.drawable.profile_ic_gallery), - color = Color.White, - textStyle = MaterialTheme.appTypography.labelLarge - ) - } - ) - Spacer(Modifier.height(16.dp)) - OpenEdXOutlinedButton( - borderColor = MaterialTheme.appColors.error, - textColor = MaterialTheme.appColors.textPrimary, - text = stringResource(id = R.string.profile_remove_photo), - onClick = onRemoveImageClick, - content = { - IconText( - modifier = Modifier.testTag("it_remove_photo"), - text = stringResource(id = R.string.profile_remove_photo), - painter = painterResource(id = R.drawable.profile_ic_remove_image), - color = MaterialTheme.appColors.error, + color = MaterialTheme.appColors.secondaryButtonText, textStyle = MaterialTheme.appTypography.labelLarge ) } ) + if (hasProfileImage) { + Spacer(Modifier.height(16.dp)) + OpenEdXOutlinePrimaryButton( + text = stringResource(id = R.string.profile_remove_photo), + onClick = onRemoveImageClick, + content = { + IconText( + modifier = Modifier.testTag("it_remove_photo"), + text = stringResource(id = R.string.profile_remove_photo), + painter = painterResource(id = R.drawable.profile_ic_remove_image), + color = MaterialTheme.appColors.primaryButtonBorderedText, + textStyle = MaterialTheme.appTypography.labelLarge + ) + } + ) + } Spacer(Modifier.height(40.dp)) - OpenEdXOutlinedButton( - borderColor = MaterialTheme.appColors.primaryButtonBorder, - textColor = MaterialTheme.appColors.primaryButtonBorderedText, + OpenEdXTertiaryButton( text = stringResource(id = coreR.string.core_cancel), onClick = onCancelClick ) @@ -1171,26 +1171,12 @@ private fun LeaveProfile( textAlign = TextAlign.Center ) Spacer(Modifier.size(40.dp)) - OpenEdXButton( + OpenEdXPrimaryButton( text = stringResource(id = R.string.profile_leave), onClick = onLeaveClick, - backgroundColor = MaterialTheme.appColors.primaryButtonBackground, - content = { - Text( - modifier = Modifier - .testTag("txt_leave") - .fillMaxWidth(), - text = stringResource(id = R.string.profile_leave), - color = MaterialTheme.appColors.primaryButtonText, - style = MaterialTheme.appTypography.labelLarge, - textAlign = TextAlign.Center - ) - } ) Spacer(Modifier.height(24.dp)) - OpenEdXOutlinedButton( - borderColor = MaterialTheme.appColors.primaryButtonBorder, - textColor = MaterialTheme.appColors.primaryButtonBorderedText, + OpenEdXOutlinePrimaryButton( text = stringResource(id = R.string.profile_keep_editing), onClick = onDismissRequest ) @@ -1264,34 +1250,14 @@ private fun LeaveProfileLandscape( Modifier.weight(1f), horizontalAlignment = Alignment.CenterHorizontally ) { - OpenEdXButton( + OpenEdXPrimaryButton( text = stringResource(id = R.string.profile_leave), - backgroundColor = MaterialTheme.appColors.primaryButtonBackground, - content = { - AutoSizeText( - modifier = Modifier.testTag("txt_leave_profile_dialog_leave"), - text = stringResource(id = R.string.profile_leave), - style = MaterialTheme.appTypography.bodyMedium, - color = MaterialTheme.appColors.primaryButtonText - ) - }, onClick = onLeaveClick ) Spacer(Modifier.height(16.dp)) - OpenEdXOutlinedButton( - borderColor = MaterialTheme.appColors.primaryButtonBorder, - textColor = MaterialTheme.appColors.primaryButtonBorderedText, + OpenEdXOutlinePrimaryButton( text = stringResource(id = R.string.profile_keep_editing), onClick = onDismissRequest, - content = { - AutoSizeText( - modifier = Modifier - .testTag("btn_leave_profile_dialog_keep_editing"), - text = stringResource(id = R.string.profile_keep_editing), - style = MaterialTheme.appTypography.bodyMedium, - color = MaterialTheme.appColors.primaryButtonBorderedText - ) - } ) } } @@ -1311,8 +1277,8 @@ fun LeaveProfilePreview() { } } -@Preview(device = Devices.NEXUS_9, uiMode = Configuration.UI_MODE_NIGHT_NO) -@Preview(device = Devices.NEXUS_9, uiMode = Configuration.UI_MODE_NIGHT_YES) +@Preview(device = Devices.PIXEL_TABLET, uiMode = Configuration.UI_MODE_NIGHT_NO) +@Preview(device = Devices.PIXEL_TABLET, uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable fun LeaveProfileLandscapePreview() { OpenEdXTheme { @@ -1329,6 +1295,7 @@ fun LeaveProfileLandscapePreview() { fun ChangeProfileImagePreview() { OpenEdXTheme { ChangeImageDialog( + hasProfileImage = true, onSelectFromGalleryClick = {}, onRemoveImageClick = {}, onCancelClick = {} diff --git a/profile/src/main/java/org/openedx/profile/presentation/manageaccount/compose/ManageAccountView.kt b/profile/src/main/java/org/openedx/profile/presentation/manageaccount/compose/ManageAccountView.kt index 6a6590662..956a6faf6 100644 --- a/profile/src/main/java/org/openedx/profile/presentation/manageaccount/compose/ManageAccountView.kt +++ b/profile/src/main/java/org/openedx/profile/presentation/manageaccount/compose/ManageAccountView.kt @@ -41,7 +41,8 @@ import org.openedx.core.R import org.openedx.core.UIMessage import org.openedx.core.ui.HandleUIMessage import org.openedx.core.ui.IconText -import org.openedx.core.ui.OpenEdXOutlinedButton +import org.openedx.core.ui.OpenEdXOutlinePrimaryButton +import org.openedx.core.ui.OpenEdXTertiaryButton import org.openedx.core.ui.Toolbar import org.openedx.core.ui.WindowSize import org.openedx.core.ui.WindowType @@ -167,24 +168,25 @@ internal fun ManageAccountView( title = uiState.account.name, subtitle = uiState.account.email ?: "" ) - OpenEdXOutlinedButton( - modifier = Modifier - .fillMaxWidth(), + OpenEdXOutlinePrimaryButton( text = stringResource(id = ProfileR.string.profile_edit_profile), onClick = { onAction(ManageAccountViewAction.EditAccountClick) }, - borderColor = MaterialTheme.appColors.primaryButtonBorderedText, - textColor = MaterialTheme.appColors.primaryButtonBorderedText ) - IconText( + OpenEdXTertiaryButton( text = stringResource(id = ProfileR.string.profile_delete_profile), - painter = painterResource(id = ProfileR.drawable.profile_ic_trash), - textStyle = MaterialTheme.appTypography.labelLarge, - color = MaterialTheme.appColors.error, - onClick = { - onAction(ManageAccountViewAction.DeleteAccount) - }) + onClick = { onAction(ManageAccountViewAction.DeleteAccount) }, + content = { + IconText( + text = stringResource(id = ProfileR.string.profile_delete_profile), + painter = painterResource(id = ProfileR.drawable.profile_ic_trash), + textStyle = MaterialTheme.appTypography.labelLarge, + color = MaterialTheme.appColors.error, + ) + } + ) + Spacer(modifier = Modifier.height(12.dp)) } } } diff --git a/profile/src/main/java/org/openedx/profile/presentation/profile/compose/ProfileView.kt b/profile/src/main/java/org/openedx/profile/presentation/profile/compose/ProfileView.kt index c167253f8..22a1fc1f4 100644 --- a/profile/src/main/java/org/openedx/profile/presentation/profile/compose/ProfileView.kt +++ b/profile/src/main/java/org/openedx/profile/presentation/profile/compose/ProfileView.kt @@ -39,7 +39,7 @@ import androidx.compose.ui.unit.dp import org.openedx.core.R import org.openedx.core.UIMessage import org.openedx.core.ui.HandleUIMessage -import org.openedx.core.ui.OpenEdXOutlinedButton +import org.openedx.core.ui.OpenEdXOutlinePrimaryButton import org.openedx.core.ui.Toolbar import org.openedx.core.ui.WindowSize import org.openedx.core.ui.WindowType @@ -142,15 +142,11 @@ internal fun ProfileView( subtitle = "@${uiState.account.username}" ) ProfileInfoSection(uiState.account) - OpenEdXOutlinedButton( - modifier = Modifier - .fillMaxWidth(), + OpenEdXOutlinePrimaryButton( text = stringResource(id = org.openedx.profile.R.string.profile_edit_profile), onClick = { onAction(ProfileViewAction.EditAccountClick) }, - borderColor = MaterialTheme.appColors.primaryButtonBorderedText, - textColor = MaterialTheme.appColors.primaryButtonBorderedText ) Spacer(modifier = Modifier.height(12.dp)) } diff --git a/profile/src/main/java/org/openedx/profile/presentation/settings/SettingsScreenUI.kt b/profile/src/main/java/org/openedx/profile/presentation/settings/SettingsScreenUI.kt index bb5d31781..f326a793d 100644 --- a/profile/src/main/java/org/openedx/profile/presentation/settings/SettingsScreenUI.kt +++ b/profile/src/main/java/org/openedx/profile/presentation/settings/SettingsScreenUI.kt @@ -39,7 +39,6 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.ExperimentalComposeUiApi import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip -import androidx.compose.ui.graphics.Color import androidx.compose.ui.platform.LocalUriHandler import androidx.compose.ui.platform.testTag import androidx.compose.ui.res.painterResource @@ -61,7 +60,7 @@ import org.openedx.core.presentation.iap.IAPUIState import org.openedx.core.system.notifier.app.AppUpgradeEvent import org.openedx.core.ui.CheckingPurchasesDialog import org.openedx.core.ui.FakePurchasesFulfillmentCompleted -import org.openedx.core.ui.OpenEdXButton +import org.openedx.core.ui.OpenEdXBrandButton import org.openedx.core.ui.Toolbar import org.openedx.core.ui.UpgradeErrorDialog import org.openedx.core.ui.WindowSize @@ -450,12 +449,12 @@ private fun LogoutButton(onClick: () -> Unit) { modifier = Modifier.testTag("txt_logout"), text = stringResource(id = profileR.string.profile_logout), style = MaterialTheme.appTypography.titleMedium, - color = MaterialTheme.appColors.error + color = MaterialTheme.appColors.textPrimary ) Icon( painterResource(id = profileR.drawable.profile_ic_logout), contentDescription = null, - tint = MaterialTheme.appColors.error + tint = MaterialTheme.appColors.textPrimary ) } } @@ -522,9 +521,8 @@ private fun LogoutDialog( textAlign = TextAlign.Center ) Spacer(Modifier.size(36.dp)) - OpenEdXButton( + OpenEdXBrandButton( text = stringResource(id = profileR.string.profile_logout), - backgroundColor = MaterialTheme.appColors.warning, onClick = onLogoutClick, content = { Box( @@ -538,7 +536,7 @@ private fun LogoutDialog( .testTag("txt_logout") .fillMaxWidth(), text = stringResource(id = profileR.string.profile_logout), - color = MaterialTheme.appColors.textWarning, + color = MaterialTheme.appColors.primaryButtonText, style = MaterialTheme.appTypography.labelLarge, textAlign = TextAlign.Center ) @@ -547,7 +545,7 @@ private fun LogoutDialog( .testTag("ic_logout"), painter = painterResource(id = profileR.drawable.profile_ic_logout), contentDescription = null, - tint = Color.Black + tint = MaterialTheme.appColors.primaryButtonText, ) } } @@ -774,10 +772,13 @@ private fun AppVersionItemUpgradeRequiredPreview() { } } -@Preview +@Preview(uiMode = android.content.res.Configuration.UI_MODE_NIGHT_NO) +@Preview(uiMode = android.content.res.Configuration.UI_MODE_NIGHT_YES) @Composable private fun LogoutDialogPreview() { - LogoutDialog({}, {}) + OpenEdXTheme { + LogoutDialog({}, {}) + } } @Preview diff --git a/whatsnew/src/main/java/org/openedx/whatsnew/presentation/ui/WhatsNewUI.kt b/whatsnew/src/main/java/org/openedx/whatsnew/presentation/ui/WhatsNewUI.kt index 9546f2622..b4ec13bfe 100644 --- a/whatsnew/src/main/java/org/openedx/whatsnew/presentation/ui/WhatsNewUI.kt +++ b/whatsnew/src/main/java/org/openedx/whatsnew/presentation/ui/WhatsNewUI.kt @@ -9,7 +9,6 @@ import androidx.compose.animation.core.tween import androidx.compose.animation.fadeIn import androidx.compose.animation.fadeOut import androidx.compose.animation.togetherWith -import androidx.compose.foundation.BorderStroke import androidx.compose.foundation.Canvas import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Row @@ -18,11 +17,8 @@ import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.width -import androidx.compose.material.Button -import androidx.compose.material.ButtonDefaults import androidx.compose.material.Icon import androidx.compose.material.MaterialTheme -import androidx.compose.material.OutlinedButton import androidx.compose.material.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue @@ -39,9 +35,10 @@ import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp +import org.openedx.core.ui.OpenEdXOutlinePrimaryButton +import org.openedx.core.ui.OpenEdXPrimaryButton import org.openedx.core.ui.theme.OpenEdXTheme import org.openedx.core.ui.theme.appColors -import org.openedx.core.ui.theme.appShapes import org.openedx.core.ui.theme.appTypography import org.openedx.whatsnew.R @@ -169,17 +166,11 @@ fun PrevButton( label = "" ) - OutlinedButton( + OpenEdXOutlinePrimaryButton( modifier = Modifier - .testTag("btn_previous") .height(42.dp) .alpha(prevButtonAnimationFactor), - colors = ButtonDefaults.outlinedButtonColors( - backgroundColor = MaterialTheme.appColors.background - ), - border = BorderStroke(1.dp, MaterialTheme.appColors.primary), - elevation = null, - shape = MaterialTheme.appShapes.navigationButtonShape, + text = stringResource(R.string.whats_new_navigation_previous), onClick = onPrevClick, ) { Row( @@ -206,15 +197,10 @@ fun NextFinishButton( onNextClick: () -> Unit, hasNextPage: Boolean ) { - Button( + OpenEdXPrimaryButton( modifier = Modifier - .testTag("btn_next") .height(42.dp), - colors = ButtonDefaults.buttonColors( - backgroundColor = MaterialTheme.appColors.primaryButtonBackground - ), - elevation = null, - shape = MaterialTheme.appShapes.navigationButtonShape, + text = stringResource(id = R.string.whats_new_navigation_next), onClick = onNextClick ) { AnimatedContent( @@ -232,14 +218,13 @@ fun NextFinishButton( Text( modifier = Modifier.testTag("txt_next"), text = stringResource(id = R.string.whats_new_navigation_next), - color = MaterialTheme.appColors.primaryButtonText, style = MaterialTheme.appTypography.labelLarge ) Spacer(Modifier.width(8.dp)) Icon( painter = painterResource(id = org.openedx.core.R.drawable.core_ic_forward), contentDescription = null, - tint = MaterialTheme.appColors.primaryButtonText + tint = MaterialTheme.appColors.secondaryButtonText, ) } } else { @@ -250,14 +235,13 @@ fun NextFinishButton( Text( modifier = Modifier.testTag("txt_done"), text = stringResource(id = R.string.whats_new_navigation_done), - color = MaterialTheme.appColors.primaryButtonText, style = MaterialTheme.appTypography.labelLarge ) Spacer(Modifier.width(8.dp)) Icon( painter = painterResource(id = org.openedx.core.R.drawable.core_ic_check), contentDescription = null, - tint = MaterialTheme.appColors.primaryButtonText + tint = MaterialTheme.appColors.secondaryButtonText, ) } }