From 1f427dc8f86a4b9d9c31b87c258a2101da071a8a Mon Sep 17 00:00:00 2001 From: "omer.habib" Date: Fri, 28 Jun 2024 19:36:53 +0500 Subject: [PATCH] refactor: Improve customAppColors usage according to usage - refactor app design to efficiently handle customAppColor variables fix: LEARNER-10043 --- .../logistration/LogistrationFragment.kt | 6 +- .../presentation/signin/compose/SignInView.kt | 6 +- .../presentation/signup/compose/SignUpView.kt | 2 +- .../auth/presentation/ui/SocialAuthView.kt | 5 +- .../dialog/alert/ActionDialogFragment.kt | 17 ++-- .../dialog/alert/InfoDialogFragment.kt | 16 ++-- .../settings/video/VideoQualityFragment.kt | 10 ++- .../java/org/openedx/core/ui/ComposeCommon.kt | 22 ++--- core/src/main/res/values/themes.xml | 2 +- .../presentation/ChapterEndFragmentDialog.kt | 8 +- .../section/CourseSectionFragment.kt | 2 +- .../course/presentation/ui/CourseUI.kt | 18 ++-- .../unit/html/HtmlUnitFragment.kt | 4 +- .../presentation/AllEnrolledCoursesView.kt | 6 +- .../presentation/DashboardGalleryView.kt | 10 +-- .../presentation/DashboardListFragment.kt | 9 +- .../learn/presentation/LearnFragment.kt | 14 ++-- .../presentation/program/ProgramFragment.kt | 5 +- .../comments/DiscussionCommentsFragment.kt | 2 +- .../responses/DiscussionResponsesFragment.kt | 2 +- .../threads/DiscussionAddThreadFragment.kt | 6 +- .../threads/DiscussionThreadsFragment.kt | 2 +- .../presentation/ui/DiscussionUI.kt | 4 +- .../presentation/edit/EditProfileFragment.kt | 82 ++++++++++--------- .../compose/ManageAccountView.kt | 4 +- .../profile/compose/ProfileView.kt | 4 +- .../presentation/settings/SettingsScreenUI.kt | 2 + .../whatsnew/presentation/ui/WhatsNewUI.kt | 13 ++- 28 files changed, 154 insertions(+), 129 deletions(-) diff --git a/auth/src/main/java/org/openedx/auth/presentation/logistration/LogistrationFragment.kt b/auth/src/main/java/org/openedx/auth/presentation/logistration/LogistrationFragment.kt index ae3d2365e..10539746b 100644 --- a/auth/src/main/java/org/openedx/auth/presentation/logistration/LogistrationFragment.kt +++ b/auth/src/main/java/org/openedx/auth/presentation/logistration/LogistrationFragment.kt @@ -135,7 +135,8 @@ private fun LogistrationScreen( style = MaterialTheme.appTypography.headlineSmall, modifier = Modifier .testTag("txt_screen_title") - .padding(bottom = 40.dp) + .padding(bottom = 40.dp), + color = MaterialTheme.appColors.textPrimary, ) val focusManager = LocalFocusManager.current Column(Modifier.padding(bottom = 8.dp)) { @@ -145,6 +146,7 @@ private fun LogistrationScreen( .padding(bottom = 10.dp), style = MaterialTheme.appTypography.titleMedium, text = stringResource(id = R.string.pre_auth_search_title), + color = MaterialTheme.appColors.textPrimary, ) SearchBar( modifier = Modifier @@ -176,7 +178,7 @@ private fun LogistrationScreen( onSearchClick("") }, text = stringResource(id = R.string.pre_auth_explore_all_courses), - color = MaterialTheme.appColors.primary, + color = MaterialTheme.appColors.textHyperLink, style = MaterialTheme.appTypography.labelLarge, textDecoration = TextDecoration.Underline ) 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 cb77faa37..4b91aaa4f 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 @@ -272,7 +272,7 @@ private fun AuthForm( onEvent(AuthEvent.RegisterClick) }, text = stringResource(id = coreR.string.core_register), - color = MaterialTheme.appColors.primary, + color = MaterialTheme.appColors.textHyperLink, style = MaterialTheme.appTypography.labelLarge ) } @@ -284,7 +284,7 @@ private fun AuthForm( onEvent(AuthEvent.ForgotPasswordClick) }, text = stringResource(id = R.string.auth_forgot_password), - color = MaterialTheme.appColors.info_variant, + color = MaterialTheme.appColors.textHyperLink, style = MaterialTheme.appTypography.labelLarge ) } @@ -296,7 +296,7 @@ private fun AuthForm( modifier = buttonWidth.testTag("btn_sign_in"), text = stringResource(id = coreR.string.core_sign_in), textColor = MaterialTheme.appColors.primaryButtonText, - backgroundColor = MaterialTheme.appColors.secondaryButtonBackground, + 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 e1e31c7b8..67cf30754 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 @@ -440,7 +440,7 @@ internal fun SignUpView( modifier = buttonWidth.testTag("btn_create_account"), text = stringResource(id = R.string.auth_create_account), textColor = MaterialTheme.appColors.primaryButtonText, - backgroundColor = MaterialTheme.appColors.secondaryButtonBackground, + backgroundColor = MaterialTheme.appColors.primaryButtonBackground, onClick = { keyboardController?.hide() showErrorMap.clear() 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 028439290..c8ab3df16 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 @@ -40,13 +40,12 @@ internal fun SocialAuthView( } else { R.string.auth_continue_google } - OpenEdXOutlinedButton( + OpenEdXButton( modifier = Modifier .testTag("btn_google_auth") .padding(top = 24.dp) .fillMaxWidth(), backgroundColor = MaterialTheme.appColors.authGoogleButtonBackground, - borderColor = MaterialTheme.appColors.primary, textColor = Color.Unspecified, onClick = { onEvent(AuthType.GOOGLE) @@ -63,7 +62,7 @@ internal fun SocialAuthView( .testTag("txt_google_auth") .padding(start = 10.dp), text = stringResource(id = stringRes), - color = MaterialTheme.appColors.primaryButtonBorderedText, + color = MaterialTheme.appColors.textPrimaryLight, ) } } 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 b7b3167e6..6fba6836c 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 @@ -11,8 +11,10 @@ import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.widthIn import androidx.compose.material.MaterialTheme import androidx.compose.material.Text @@ -170,6 +172,7 @@ private fun ActionDialog( text = stringResource(R.string.core_cancel), onClick = onPositiveClick ) + Spacer(modifier = Modifier.size(16.dp)) DefaultTextButton( text = stringResource(R.string.core_continue), onClick = onNegativeClick @@ -183,10 +186,12 @@ private fun ActionDialog( @Preview(uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable private fun ActionDialogPreview() { - ActionDialog( - title = "Leaving the app", - message = "You are now leaving the app and opening a browser.", - onPositiveClick = {}, - onNegativeClick = {}, - ) + OpenEdXTheme { + ActionDialog( + title = "Leaving the app", + message = "You are now leaving the app and opening a browser.", + onPositiveClick = {}, + 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 bc41d936d..0f6480316 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 @@ -1,5 +1,6 @@ package org.openedx.core.presentation.dialog.alert +import android.content.res.Configuration import android.graphics.Color import android.graphics.drawable.ColorDrawable import android.os.Bundle @@ -116,12 +117,15 @@ private fun InfoDialog( } } -@Preview +@Preview(uiMode = Configuration.UI_MODE_NIGHT_NO) +@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable private fun SimpleDialogPreview() { - InfoDialog( - title = "Important Notice", - message = "This is an important announcement.", - onClick = {} - ) + OpenEdXTheme { + InfoDialog( + title = "Important Notice", + message = "This is an important announcement.", + onClick = {} + ) + } } diff --git a/core/src/main/java/org/openedx/core/presentation/settings/video/VideoQualityFragment.kt b/core/src/main/java/org/openedx/core/presentation/settings/video/VideoQualityFragment.kt index edd00ce53..fabc91513 100644 --- a/core/src/main/java/org/openedx/core/presentation/settings/video/VideoQualityFragment.kt +++ b/core/src/main/java/org/openedx/core/presentation/settings/video/VideoQualityFragment.kt @@ -73,7 +73,7 @@ class VideoQualityFragment : Fragment() { override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, - savedInstanceState: Bundle? + savedInstanceState: Bundle?, ) = ComposeView(requireContext()).apply { setViewCompositionStrategy(ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed) setContent { @@ -125,7 +125,7 @@ private fun VideoQualityScreen( title: String, selectedVideoQuality: VideoQuality, onQualityChanged: (VideoQuality) -> Unit, - onBackClick: () -> Unit + onBackClick: () -> Unit, ) { val scaffoldState = rememberScaffoldState() Scaffold( @@ -136,6 +136,7 @@ private fun VideoQualityScreen( testTagsAsResourceId = true }, scaffoldState = scaffoldState, + backgroundColor = MaterialTheme.appColors.background ) { paddingValues -> val topBarWidth by remember(key1 = windowSize) { @@ -160,7 +161,8 @@ private fun VideoQualityScreen( } Box( - modifier = Modifier.fillMaxSize(), + modifier = Modifier + .fillMaxSize(), contentAlignment = Alignment.TopCenter ) { Column( @@ -205,7 +207,7 @@ private fun QualityOption( title: String, description: String, selected: Boolean, - onClick: () -> Unit + onClick: () -> Unit, ) { Row( Modifier 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 735ca148a..2fa9d0855 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.content.res.Configuration import android.os.Build.VERSION.SDK_INT import androidx.compose.foundation.BorderStroke import androidx.compose.foundation.ExperimentalFoundationApi @@ -202,7 +203,7 @@ fun Toolbar( ) { Icon( imageVector = Icons.Default.ManageAccounts, - tint = MaterialTheme.appColors.textAccent, + tint = MaterialTheme.appColors.primary, contentDescription = stringResource(id = R.string.core_accessibility_settings) ) } @@ -257,7 +258,7 @@ fun SearchBar( }, colors = TextFieldDefaults.outlinedTextFieldColors( textColor = MaterialTheme.appColors.textPrimary, - backgroundColor = if (isFocused) MaterialTheme.appColors.background else MaterialTheme.appColors.textFieldBackground, + backgroundColor = MaterialTheme.appColors.textFieldBackground, focusedBorderColor = MaterialTheme.appColors.primary, unfocusedBorderColor = MaterialTheme.appColors.textFieldBorder, cursorColor = MaterialTheme.appColors.primary, @@ -269,7 +270,7 @@ fun SearchBar( .testTag("txt_search_placeholder") .fillMaxWidth(), text = label, - color = MaterialTheme.appColors.textSecondary, + color = MaterialTheme.appColors.textFieldHint, style = MaterialTheme.appTypography.bodyMedium ) }, @@ -278,7 +279,7 @@ fun SearchBar( modifier = Modifier.padding(start = 16.dp), imageVector = Icons.Filled.Search, contentDescription = null, - tint = if (isFocused) MaterialTheme.appColors.primary else MaterialTheme.appColors.onSurface + tint = if (isFocused) MaterialTheme.appColors.textPrimary else MaterialTheme.appColors.textFieldHint ) }, trailingIcon = { @@ -1059,7 +1060,7 @@ fun OpenEdXButton( enabled: Boolean = true, textColor: Color = MaterialTheme.appColors.primaryButtonText, backgroundColor: Color = MaterialTheme.appColors.primaryButtonBackground, - content: (@Composable RowScope.() -> Unit)? = null + content: (@Composable RowScope.() -> Unit)? = null, ) { Button( modifier = Modifier @@ -1194,7 +1195,7 @@ fun AuthButtonsPanel( .weight(1f), text = stringResource(id = R.string.core_register), textColor = MaterialTheme.appColors.primaryButtonText, - backgroundColor = MaterialTheme.appColors.secondaryButtonBackground, + backgroundColor = MaterialTheme.appColors.primaryButtonBackground, onClick = { onRegisterClick() } ) @@ -1221,7 +1222,7 @@ fun RoundTabsBar( contentPadding: PaddingValues = PaddingValues(), withPager: Boolean = false, rowState: LazyListState = rememberLazyListState(), - onTabClicked: (Int) -> Unit = { } + onTabClicked: (Int) -> Unit = { }, ) { // The pager state does not work without the pager and the tabs do not change. if (!withPager) { @@ -1249,7 +1250,7 @@ fun RoundTabsBar( RoundTab( modifier = Modifier - .height(40.dp) + .height(32.dp) .clip(CircleShape) .background(backgroundColor) .then(border) @@ -1272,7 +1273,7 @@ fun RoundTabsBar( private fun RoundTab( modifier: Modifier = Modifier, item: TabItem, - contentColor: Color + contentColor: Color, ) { Row( modifier = modifier, @@ -1380,7 +1381,8 @@ val mockTab = object : TabItem { } @OptIn(ExperimentalFoundationApi::class) -@Preview +@Preview(uiMode = Configuration.UI_MODE_NIGHT_NO) +@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable private fun RoundTabsBarPreview() { OpenEdXTheme { diff --git a/core/src/main/res/values/themes.xml b/core/src/main/res/values/themes.xml index e6859e022..a092e8d47 100644 --- a/core/src/main/res/values/themes.xml +++ b/core/src/main/res/values/themes.xml @@ -12,7 +12,7 @@ ?attr/colorPrimaryVariant - @android:color/transparent + @color/background