From 4e726a725ab4ce3cb03d2860bb9a41083aada2d4 Mon Sep 17 00:00:00 2001 From: PavloNetrebchuk Date: Thu, 29 Jan 2026 12:36:06 +0200 Subject: [PATCH 1/4] chore: migration to material3 --- .../logistration/LogistrationFragment.kt | 13 +- .../restore/RestorePasswordFragment.kt | 26 +- .../presentation/signin/compose/SignInView.kt | 36 +- .../presentation/signup/compose/SignUpView.kt | 115 ++- .../signup/compose/SocialSignedView.kt | 8 +- .../openedx/auth/presentation/ui/AuthUI.kt | 34 +- .../auth/presentation/ui/CheckboxField.kt | 8 +- .../auth/presentation/ui/SocialAuthView.kt | 6 +- build.gradle | 2 +- .../openedx/core/domain/model/DatesSection.kt | 2 +- .../core/presentation/dates/DatesUI.kt | 6 +- .../core/presentation/dialog/DialogUI.kt | 4 +- .../dialog/alert/ActionDialogFragment.kt | 4 +- .../dialog/alert/InfoDialogFragment.kt | 4 +- .../dialog/appreview/AppReviewUI.kt | 26 +- .../DownloadConfirmDialogFragment.kt | 4 +- .../DownloadErrorDialogFragment.kt | 4 +- .../DownloadStorageErrorDialogFragment.kt | 4 +- .../dialog/downloaddialog/DownloadView.kt | 6 +- .../SelectBottomDialogFragment.kt | 4 +- .../global/appupgrade/AppUpdateUI.kt | 21 +- .../calendarsync/CalendarSyncDialog.kt | 14 +- .../calendarsync/CalendarSyncState.kt | 2 +- .../settings/video/VideoQualityFragment.kt | 15 +- .../java/org/openedx/core/ui/ComposeCommon.kt | 75 +- .../java/org/openedx/core/ui/HTMLRenderer.kt | 4 +- .../java/org/openedx/core/ui/PageIndicator.kt | 2 +- .../org/openedx/core/ui/WebContentScreen.kt | 11 +- .../org/openedx/core/ui/theme/AppColors.kt | 64 +- .../org/openedx/core/ui/theme/AppShapes.kt | 6 +- .../openedx/core/ui/theme/AppTypography.kt | 2 +- .../java/org/openedx/core/ui/theme/Theme.kt | 67 +- core/src/main/res/values/themes.xml | 2 +- .../org/openedx/core/ui/theme/LocalShapes.kt | 12 +- .../ui/theme/compose/LogistrationLogoView.kt | 2 +- .../presentation/ChapterEndFragmentDialog.kt | 19 +- .../CourseContentAssignmentScreen.kt | 43 +- .../container/CollapsingLayout.kt | 9 +- .../container/CourseContainerFragment.kt | 182 +++-- .../presentation/container/HeaderContent.kt | 4 +- .../NoAccessCourseContainerFragment.kt | 15 +- .../contenttab/ContentTabEmptyState.kt | 6 +- .../contenttab/ContentTabScreen.kt | 14 +- .../presentation/dates/CourseDatesScreen.kt | 19 +- .../presentation/handouts/HandoutsScreen.kt | 19 +- .../handouts/HandoutsWebViewFragment.kt | 11 +- .../home/AssignmentsHomePagerCardContent.kt | 25 +- .../CourseCompletionHomePagerCardContent.kt | 4 +- .../presentation/home/CourseHomeScreen.kt | 30 +- .../home/GradesHomePagerCardContent.kt | 15 +- .../home/VideosHomePagerCardContent.kt | 71 +- .../offline/CourseOfflineScreen.kt | 30 +- .../outline/CourseContentAllScreen.kt | 15 +- .../progress/CourseProgressScreen.kt | 29 +- .../section/CourseSectionFragment.kt | 25 +- .../course/presentation/ui/CourseUI.kt | 89 +-- .../unit/NotAvailableUnitFragment.kt | 19 +- .../container/CourseUnitContainerFragment.kt | 8 +- .../unit/html/HtmlUnitFragment.kt | 8 +- .../videos/CourseContentVideoScreen.kt | 19 +- .../download/DownloadQueueFragment.kt | 20 +- .../src/main/java/org/openedx/DashboardUI.kt | 4 +- .../presentation/AllEnrolledCoursesView.kt | 68 +- .../presentation/DashboardGalleryView.kt | 203 +++--- .../presentation/DashboardListFragment.kt | 51 +- .../learn/presentation/LearnFragment.kt | 72 +- .../dates/presentation/dates/DatesScreen.kt | 182 +++-- .../presentation/NativeDiscoveryFragment.kt | 51 +- .../presentation/WebViewDiscoveryFragment.kt | 13 +- .../detail/AuthorizationDialogFragment.kt | 15 +- .../detail/CourseDetailsFragment.kt | 25 +- .../presentation/info/CourseInfoFragment.kt | 19 +- .../presentation/program/ProgramFragment.kt | 19 +- .../search/CourseSearchFragment.kt | 71 +- .../discovery/presentation/ui/DiscoveryUI.kt | 14 +- .../comments/DiscussionCommentsFragment.kt | 62 +- .../responses/DiscussionResponsesFragment.kt | 62 +- .../search/DiscussionSearchThreadFragment.kt | 50 +- .../threads/DiscussionAddThreadFragment.kt | 452 ++++++------ .../threads/DiscussionThreadsFragment.kt | 670 ++++++++---------- .../topics/DiscussionTopicsScreen.kt | 23 +- .../presentation/ui/DiscussionUI.kt | 23 +- .../presentation/download/DownloadsScreen.kt | 216 +++--- .../AnothersProfileFragment.kt | 17 +- .../calendar/CalendarAccessDialogFragment.kt | 4 +- .../calendar/CalendarSetUpView.kt | 20 +- .../calendar/CalendarSettingsView.kt | 36 +- .../presentation/calendar/CalendarView.kt | 17 +- .../calendar/CoursesToSyncFragment.kt | 41 +- .../DisableCalendarSyncDialogFragment.kt | 6 +- .../calendar/NewCalendarDialogFragment.kt | 197 +++-- .../delete/DeleteProfileFragment.kt | 15 +- .../presentation/edit/EditProfileFragment.kt | 603 ++++++++-------- .../compose/ManageAccountView.kt | 46 +- .../profile/compose/ProfileView.kt | 45 +- .../presentation/settings/SettingsScreenUI.kt | 31 +- .../profile/presentation/ui/ProfileUI.kt | 11 +- .../profile/presentation/ui/SettingsUI.kt | 10 +- .../video/VideoSettingsFragment.kt | 28 +- settings.gradle | 1 + .../whatsnew/presentation/ui/WhatsNewUI.kt | 18 +- .../presentation/whatsnew/WhatsNewFragment.kt | 13 +- 102 files changed, 2418 insertions(+), 2469 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 f8dbba635..523240f50 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 @@ -13,11 +13,10 @@ import androidx.compose.foundation.layout.navigationBarsPadding import androidx.compose.foundation.layout.padding import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.verticalScroll -import androidx.compose.material.MaterialTheme -import androidx.compose.material.Scaffold -import androidx.compose.material.Surface -import androidx.compose.material.Text -import androidx.compose.material.rememberScaffoldState +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Scaffold +import androidx.compose.material3.Surface +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf @@ -118,17 +117,15 @@ private fun LogistrationScreen( var textFieldValue by rememberSaveable(stateSaver = TextFieldValue.Saver) { mutableStateOf(TextFieldValue("")) } - val scaffoldState = rememberScaffoldState() val scrollState = rememberScrollState() Scaffold( - scaffoldState = scaffoldState, modifier = Modifier .semantics { testTagsAsResourceId = true } .fillMaxSize() .navigationBarsPadding(), - backgroundColor = MaterialTheme.appColors.background + containerColor = MaterialTheme.appColors.background ) { Surface( modifier = Modifier 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 adb8da725..c1bb6461e 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 @@ -20,13 +20,14 @@ import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.widthIn import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.verticalScroll -import androidx.compose.material.CircularProgressIndicator -import androidx.compose.material.Icon -import androidx.compose.material.MaterialTheme -import androidx.compose.material.Scaffold -import androidx.compose.material.Surface -import androidx.compose.material.Text -import androidx.compose.material.rememberScaffoldState +import androidx.compose.material3.CircularProgressIndicator +import androidx.compose.material3.Icon +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Scaffold +import androidx.compose.material3.SnackbarHost +import androidx.compose.material3.SnackbarHostState +import androidx.compose.material3.Surface +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.collectAsState import androidx.compose.runtime.getValue @@ -127,21 +128,21 @@ private fun RestorePasswordScreen( onBackClick: () -> Unit, onRestoreButtonClick: (String) -> Unit, ) { - val scaffoldState = rememberScaffoldState() val scrollState = rememberScrollState() var email by rememberSaveable { mutableStateOf("") } var isEmailError by rememberSaveable { mutableStateOf(false) } val keyboardController = LocalSoftwareKeyboardController.current + val snackbarHostState = remember { SnackbarHostState() } Scaffold( - scaffoldState = scaffoldState, modifier = Modifier .semantics { testTagsAsResourceId = true } .fillMaxSize() .navigationBarsPadding(), - backgroundColor = MaterialTheme.appColors.background + containerColor = MaterialTheme.appColors.background, + snackbarHost = { SnackbarHost(snackbarHostState) } ) { paddingValues -> val contentPaddings by remember { @@ -192,10 +193,7 @@ private fun RestorePasswordScreen( contentDescription = null ) - HandleUIMessage( - uiMessage = uiMessage, - scaffoldState = scaffoldState - ) + HandleUIMessage(uiMessage = uiMessage, snackbarHostState = snackbarHostState) Column( modifier = Modifier 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 e182f51d7..831000b67 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 @@ -20,14 +20,15 @@ import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.text.KeyboardActions import androidx.compose.foundation.text.KeyboardOptions import androidx.compose.foundation.verticalScroll -import androidx.compose.material.CircularProgressIndicator -import androidx.compose.material.MaterialTheme -import androidx.compose.material.OutlinedTextField -import androidx.compose.material.Scaffold -import androidx.compose.material.Surface -import androidx.compose.material.Text -import androidx.compose.material.TextFieldDefaults -import androidx.compose.material.rememberScaffoldState +import androidx.compose.material3.CircularProgressIndicator +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.OutlinedTextField +import androidx.compose.material3.OutlinedTextFieldDefaults +import androidx.compose.material3.Scaffold +import androidx.compose.material3.SnackbarHost +import androidx.compose.material3.SnackbarHostState +import androidx.compose.material3.Surface +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf @@ -88,18 +89,18 @@ internal fun LoginScreen( uiMessage: UIMessage?, onEvent: (AuthEvent) -> Unit, ) { - val scaffoldState = rememberScaffoldState() val scrollState = rememberScrollState() + val snackbarHostState = remember { SnackbarHostState() } Scaffold( - scaffoldState = scaffoldState, modifier = Modifier .semantics { testTagsAsResourceId = true } .fillMaxSize() .navigationBarsPadding(), - backgroundColor = MaterialTheme.appColors.background + containerColor = MaterialTheme.appColors.background, + snackbarHost = { SnackbarHost(snackbarHostState) } ) { val contentPaddings by remember { mutableStateOf( @@ -133,10 +134,7 @@ internal fun LoginScreen( contentScale = ContentScale.FillBounds, contentDescription = null ) - HandleUIMessage( - uiMessage = uiMessage, - scaffoldState = scaffoldState - ) + HandleUIMessage(uiMessage = uiMessage, snackbarHostState = snackbarHostState) if (state.isLogistrationEnabled) { Box( modifier = Modifier @@ -364,9 +362,11 @@ private fun PasswordTextField( passwordTextFieldValue = it onValueChanged(it.text.trim()) }, - colors = TextFieldDefaults.outlinedTextFieldColors( - textColor = MaterialTheme.appColors.textFieldText, - backgroundColor = MaterialTheme.appColors.textFieldBackground, + colors = OutlinedTextFieldDefaults.colors( + focusedTextColor = MaterialTheme.appColors.textFieldText, + unfocusedTextColor = MaterialTheme.appColors.textFieldText, + focusedContainerColor = MaterialTheme.appColors.textFieldBackground, + unfocusedContainerColor = MaterialTheme.appColors.textFieldBackground, unfocusedBorderColor = MaterialTheme.appColors.textFieldBorder, cursorColor = MaterialTheme.appColors.textFieldText, ), 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 8b917ebaa..14b1226bb 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 @@ -20,15 +20,16 @@ import androidx.compose.foundation.layout.widthIn import androidx.compose.foundation.lazy.rememberLazyListState import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.verticalScroll -import androidx.compose.material.CircularProgressIndicator -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.rememberModalBottomSheetState -import androidx.compose.material.rememberScaffoldState +import androidx.compose.material3.CircularProgressIndicator +import androidx.compose.material3.ExperimentalMaterial3Api +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.ModalBottomSheet +import androidx.compose.material3.Scaffold +import androidx.compose.material3.SnackbarHost +import androidx.compose.material3.SnackbarHostState +import androidx.compose.material3.Surface +import androidx.compose.material3.Text +import androidx.compose.material3.rememberModalBottomSheetState import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue @@ -74,8 +75,6 @@ import org.openedx.core.ui.HandleUIMessage import org.openedx.core.ui.OpenEdXButton import org.openedx.core.ui.SheetContent import org.openedx.core.ui.displayCutoutForLandscape -import org.openedx.core.ui.isImeVisibleState -import org.openedx.core.ui.noRippleClickable import org.openedx.core.ui.rememberSaveableMap import org.openedx.core.ui.statusBarsInset import org.openedx.core.ui.theme.OpenEdXTheme @@ -88,7 +87,7 @@ import org.openedx.foundation.presentation.WindowType import org.openedx.foundation.presentation.windowSizeValue import org.openedx.core.R as coreR -@OptIn(ExperimentalComposeUiApi::class) +@OptIn(ExperimentalComposeUiApi::class, ExperimentalMaterial3Api::class) @Composable internal fun SignUpView( windowSize: WindowSize, @@ -99,12 +98,9 @@ internal fun SignUpView( onRegisterClick: (authType: AuthType) -> Unit, onHyperLinkClick: (Map, String) -> Unit, ) { - val scaffoldState = rememberScaffoldState() val focusManager = LocalFocusManager.current - val bottomSheetScaffoldState = rememberModalBottomSheetState( - initialValue = ModalBottomSheetValue.Hidden, - skipHalfExpanded = true - ) + val bottomSheetState = rememberModalBottomSheetState(skipPartiallyExpanded = true) + var showBottomSheet by rememberSaveable { mutableStateOf(false) } val coroutine = rememberCoroutineScope() val keyboardController = LocalSoftwareKeyboardController.current var expandedList by rememberSaveable { @@ -123,6 +119,7 @@ internal fun SignUpView( mutableStateMapOf() } val scrollState = rememberScrollState() + val snackbarHostState = remember { SnackbarHostState() } val haptic = LocalHapticFeedback.current @@ -136,8 +133,6 @@ internal fun SignUpView( mutableStateOf(TextFieldValue()) } - val isImeVisible by isImeVisibleState() - LaunchedEffect(uiState.validationError) { if (uiState.validationError) { coroutine.launch { @@ -156,22 +151,22 @@ internal fun SignUpView( } } - LaunchedEffect(bottomSheetScaffoldState.isVisible) { - if (!bottomSheetScaffoldState.isVisible) { + LaunchedEffect(showBottomSheet) { + if (!showBottomSheet) { focusManager.clearFocus() searchValue = TextFieldValue("") } } Scaffold( - scaffoldState = scaffoldState, modifier = Modifier .semantics { testTagsAsResourceId = true } .fillMaxSize() .navigationBarsPadding(), - backgroundColor = MaterialTheme.appColors.background + containerColor = MaterialTheme.appColors.background, + snackbarHost = { SnackbarHost(snackbarHostState) } ) { val topBarPadding by remember { mutableStateOf( @@ -209,21 +204,14 @@ internal fun SignUpView( ) } - ModalBottomSheetLayout( - modifier = Modifier - .padding(bottom = if (isImeVisible && bottomSheetScaffoldState.isVisible) 120.dp else 0.dp) - .noRippleClickable { - if (bottomSheetScaffoldState.isVisible) { - coroutine.launch { - bottomSheetScaffoldState.hide() - } - } - }, - sheetState = bottomSheetScaffoldState, - sheetShape = MaterialTheme.appShapes.screenBackgroundShape, - scrimColor = Color.Black.copy(alpha = 0.4f), - sheetBackgroundColor = MaterialTheme.appColors.background, - sheetContent = { + if (showBottomSheet) { + ModalBottomSheet( + onDismissRequest = { showBottomSheet = false }, + sheetState = bottomSheetState, + shape = MaterialTheme.appShapes.screenBackgroundShape, + scrimColor = Color.Black.copy(alpha = 0.4f), + containerColor = MaterialTheme.appColors.background, + ) { SheetContent( title = bottomDialogTitle, searchValue = searchValue, @@ -233,7 +221,8 @@ internal fun SignUpView( onFieldUpdated(serverFieldName.value, item.value) selectableNamesMap[serverFieldName.value] = item.name coroutine.launch { - bottomSheetScaffoldState.hide() + bottomSheetState.hide() + showBottomSheet = false } }, searchValueChanged = { @@ -241,20 +230,18 @@ internal fun SignUpView( } ) } - ) { - Image( - modifier = Modifier - .fillMaxWidth() - .fillMaxHeight(fraction = 0.3f), - painter = painterResource(id = coreR.drawable.core_top_header), - contentScale = ContentScale.FillBounds, - contentDescription = null - ) - HandleUIMessage( - uiMessage = uiMessage, - scaffoldState = scaffoldState - ) - Column( + } + + Image( + modifier = Modifier + .fillMaxWidth() + .fillMaxHeight(fraction = 0.3f), + painter = painterResource(id = coreR.drawable.core_top_header), + contentScale = ContentScale.FillBounds, + contentDescription = null + ) + HandleUIMessage(uiMessage = uiMessage, snackbarHostState = snackbarHostState) + Column( Modifier .fillMaxWidth() .padding(it) @@ -355,12 +342,13 @@ internal fun SignUpView( serverFieldName.value = serverName expandedList = list coroutine.launch { - if (bottomSheetScaffoldState.isVisible) { - bottomSheetScaffoldState.hide() + if (showBottomSheet) { + bottomSheetState.hide() + showBottomSheet = false } else { bottomDialogTitle = field.label showErrorMap[field.name] = false - bottomSheetScaffoldState.show() + showBottomSheet = true } } }, @@ -385,12 +373,13 @@ internal fun SignUpView( serverName expandedList = list coroutine.launch { - if (bottomSheetScaffoldState.isVisible) { - bottomSheetScaffoldState.hide() + if (showBottomSheet) { + bottomSheetState.hide() + showBottomSheet = false } else { bottomDialogTitle = field.label showErrorMap[field.name] = false - bottomSheetScaffoldState.show() + showBottomSheet = true } } }, @@ -408,12 +397,13 @@ internal fun SignUpView( serverFieldName.value = serverName expandedList = list coroutine.launch { - if (bottomSheetScaffoldState.isVisible) { - bottomSheetScaffoldState.hide() + if (showBottomSheet) { + bottomSheetState.hide() + showBottomSheet = false } else { bottomDialogTitle = field.label showErrorMap[field.name] = false - bottomSheetScaffoldState.show() + showBottomSheet = true } } }, @@ -463,7 +453,6 @@ internal fun SignUpView( } } } - } } } } diff --git a/auth/src/main/java/org/openedx/auth/presentation/signup/compose/SocialSignedView.kt b/auth/src/main/java/org/openedx/auth/presentation/signup/compose/SocialSignedView.kt index 2045297a5..30cdf50e4 100644 --- a/auth/src/main/java/org/openedx/auth/presentation/signup/compose/SocialSignedView.kt +++ b/auth/src/main/java/org/openedx/auth/presentation/signup/compose/SocialSignedView.kt @@ -6,9 +6,9 @@ import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size -import androidx.compose.material.Icon -import androidx.compose.material.MaterialTheme -import androidx.compose.material.Text +import androidx.compose.material3.Icon +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.res.painterResource @@ -48,7 +48,7 @@ internal fun SocialSignedView(authType: AuthType) { Text( fontSize = 18.sp, fontWeight = FontWeight.Bold, - color = MaterialTheme.colors.primary, + color = MaterialTheme.appColors.primary, text = stringResource( id = R.string.auth_social_signed_title, authType.methodName diff --git a/auth/src/main/java/org/openedx/auth/presentation/ui/AuthUI.kt b/auth/src/main/java/org/openedx/auth/presentation/ui/AuthUI.kt index 61d8f7450..726f14e1b 100644 --- a/auth/src/main/java/org/openedx/auth/presentation/ui/AuthUI.kt +++ b/auth/src/main/java/org/openedx/auth/presentation/ui/AuthUI.kt @@ -16,17 +16,17 @@ import androidx.compose.foundation.layout.padding import androidx.compose.foundation.lazy.rememberLazyListState import androidx.compose.foundation.text.KeyboardActions import androidx.compose.foundation.text.KeyboardOptions -import androidx.compose.material.Icon -import androidx.compose.material.IconButton -import androidx.compose.material.MaterialTheme -import androidx.compose.material.OutlinedTextField -import androidx.compose.material.Text -import androidx.compose.material.TextFieldDefaults import androidx.compose.material.icons.Icons import androidx.compose.material.icons.automirrored.filled.KeyboardArrowRight import androidx.compose.material.icons.filled.ExpandMore import androidx.compose.material.icons.filled.Visibility import androidx.compose.material.icons.filled.VisibilityOff +import androidx.compose.material3.Icon +import androidx.compose.material3.IconButton +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.OutlinedTextField +import androidx.compose.material3.OutlinedTextFieldDefaults +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf @@ -261,9 +261,11 @@ fun LoginTextField( loginTextFieldValue = it onValueChanged(it.text.trim()) }, - colors = TextFieldDefaults.outlinedTextFieldColors( - textColor = MaterialTheme.appColors.textFieldText, - backgroundColor = MaterialTheme.appColors.textFieldBackground, + colors = OutlinedTextFieldDefaults.colors( + focusedTextColor = MaterialTheme.appColors.textFieldText, + unfocusedTextColor = MaterialTheme.appColors.textFieldText, + focusedContainerColor = MaterialTheme.appColors.textFieldBackground, + unfocusedContainerColor = MaterialTheme.appColors.textFieldBackground, unfocusedBorderColor = MaterialTheme.appColors.textFieldBorder, cursorColor = MaterialTheme.appColors.textFieldText, ), @@ -373,9 +375,11 @@ fun InputRegistrationField( onValueChanged(registrationField.name, it.trim(), true) } }, - colors = TextFieldDefaults.outlinedTextFieldColors( - textColor = MaterialTheme.appColors.textFieldText, - backgroundColor = MaterialTheme.appColors.textFieldBackground, + colors = OutlinedTextFieldDefaults.colors( + focusedTextColor = MaterialTheme.appColors.textFieldText, + unfocusedTextColor = MaterialTheme.appColors.textFieldText, + focusedContainerColor = MaterialTheme.appColors.textFieldBackground, + unfocusedContainerColor = MaterialTheme.appColors.textFieldBackground, focusedBorderColor = MaterialTheme.appColors.textFieldBorder, unfocusedBorderColor = MaterialTheme.appColors.textFieldBorder, cursorColor = MaterialTheme.appColors.textFieldText, @@ -459,11 +463,13 @@ fun SelectableRegisterField( enabled = false, singleLine = true, value = initialValue, - colors = TextFieldDefaults.outlinedTextFieldColors( + colors = OutlinedTextFieldDefaults.colors( unfocusedBorderColor = MaterialTheme.appColors.textFieldBorder, disabledBorderColor = MaterialTheme.appColors.textFieldBorder, disabledTextColor = MaterialTheme.appColors.textPrimary, - backgroundColor = MaterialTheme.appColors.textFieldBackground, + focusedContainerColor = MaterialTheme.appColors.textFieldBackground, + unfocusedContainerColor = MaterialTheme.appColors.textFieldBackground, + disabledContainerColor = MaterialTheme.appColors.textFieldBackground, disabledPlaceholderColor = MaterialTheme.appColors.textFieldHint ), shape = MaterialTheme.appShapes.textFieldShape, diff --git a/auth/src/main/java/org/openedx/auth/presentation/ui/CheckboxField.kt b/auth/src/main/java/org/openedx/auth/presentation/ui/CheckboxField.kt index b134cb59a..ffc46caca 100644 --- a/auth/src/main/java/org/openedx/auth/presentation/ui/CheckboxField.kt +++ b/auth/src/main/java/org/openedx/auth/presentation/ui/CheckboxField.kt @@ -2,10 +2,10 @@ package org.openedx.auth.presentation.ui import android.content.res.Configuration import androidx.compose.foundation.layout.Row -import androidx.compose.material.Checkbox -import androidx.compose.material.CheckboxDefaults -import androidx.compose.material.MaterialTheme -import androidx.compose.material.Text +import androidx.compose.material3.Checkbox +import androidx.compose.material3.CheckboxDefaults +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf 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 e4962d072..ceb52dfb4 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 @@ -5,9 +5,9 @@ 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 -import androidx.compose.material.Text +import androidx.compose.material3.Icon +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier diff --git a/build.gradle b/build.gradle index 8570eb77d..4e0b4d12e 100644 --- a/build.gradle +++ b/build.gradle @@ -32,7 +32,7 @@ buildscript { play_services_ads_identifier_version = '18.2.0' install_referrer_version = '2.2' snakeyaml_version = '2.4' - openedx_foundation_version = '1.1.0' + openedx_foundation_version = '1.1.1' openedx_firebase_analytics_version = '1.0.1' braze_sdk_version = '37.0.0' diff --git a/core/src/main/java/org/openedx/core/domain/model/DatesSection.kt b/core/src/main/java/org/openedx/core/domain/model/DatesSection.kt index 33d884bed..01a769819 100644 --- a/core/src/main/java/org/openedx/core/domain/model/DatesSection.kt +++ b/core/src/main/java/org/openedx/core/domain/model/DatesSection.kt @@ -1,6 +1,6 @@ package org.openedx.core.domain.model -import androidx.compose.material.MaterialTheme +import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.ui.graphics.Color import org.openedx.core.R diff --git a/core/src/main/java/org/openedx/core/presentation/dates/DatesUI.kt b/core/src/main/java/org/openedx/core/presentation/dates/DatesUI.kt index 2833998f9..98b4bb892 100644 --- a/core/src/main/java/org/openedx/core/presentation/dates/DatesUI.kt +++ b/core/src/main/java/org/openedx/core/presentation/dates/DatesUI.kt @@ -14,11 +14,11 @@ import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.width import androidx.compose.foundation.layout.wrapContentHeight -import androidx.compose.material.Icon -import androidx.compose.material.MaterialTheme -import androidx.compose.material.Text import androidx.compose.material.icons.Icons import androidx.compose.material.icons.automirrored.filled.KeyboardArrowRight +import androidx.compose.material3.Icon +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier diff --git a/core/src/main/java/org/openedx/core/presentation/dialog/DialogUI.kt b/core/src/main/java/org/openedx/core/presentation/dialog/DialogUI.kt index 17b1d2874..9b49b2ae8 100644 --- a/core/src/main/java/org/openedx/core/presentation/dialog/DialogUI.kt +++ b/core/src/main/java/org/openedx/core/presentation/dialog/DialogUI.kt @@ -7,8 +7,8 @@ import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.widthIn -import androidx.compose.material.MaterialTheme -import androidx.compose.material.Surface +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Surface import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier 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 28f357896..9f0b00c24 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 @@ -14,8 +14,8 @@ import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.widthIn -import androidx.compose.material.MaterialTheme -import androidx.compose.material.Text +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier 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 77c413924..de172374e 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 @@ -12,8 +12,8 @@ import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.widthIn -import androidx.compose.material.MaterialTheme -import androidx.compose.material.Text +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier 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 632669c11..e7645b0af 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,16 +13,16 @@ 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 -import androidx.compose.material.Text -import androidx.compose.material.TextFieldDefaults import androidx.compose.material.icons.Icons import androidx.compose.material.icons.outlined.Star import androidx.compose.material.icons.outlined.StarOutline +import androidx.compose.material3.Button +import androidx.compose.material3.ButtonDefaults +import androidx.compose.material3.Icon +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.OutlinedTextField +import androidx.compose.material3.OutlinedTextFieldDefaults +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.MutableIntState import androidx.compose.runtime.MutableState @@ -170,10 +170,12 @@ fun FeedbackDialog( style = MaterialTheme.appTypography.labelLarge, ) }, - colors = TextFieldDefaults.outlinedTextFieldColors( - backgroundColor = MaterialTheme.appColors.cardViewBackground, + colors = OutlinedTextFieldDefaults.colors( + focusedContainerColor = MaterialTheme.appColors.cardViewBackground, + unfocusedContainerColor = MaterialTheme.appColors.cardViewBackground, unfocusedBorderColor = MaterialTheme.appColors.textFieldBorder, - textColor = MaterialTheme.appColors.textFieldText + focusedTextColor = MaterialTheme.appColors.textFieldText, + unfocusedTextColor = MaterialTheme.appColors.textFieldText ), ) @@ -254,7 +256,7 @@ fun TransparentTextButton( modifier = Modifier .height(42.dp), colors = ButtonDefaults.buttonColors( - backgroundColor = Color.Transparent + containerColor = Color.Transparent ), elevation = null, shape = MaterialTheme.appShapes.navigationButtonShape, @@ -288,7 +290,7 @@ fun DefaultTextButton( modifier = Modifier .height(42.dp), colors = ButtonDefaults.buttonColors( - backgroundColor = backgroundColor, + containerColor = backgroundColor, contentColor = textColor ), elevation = null, diff --git a/core/src/main/java/org/openedx/core/presentation/dialog/downloaddialog/DownloadConfirmDialogFragment.kt b/core/src/main/java/org/openedx/core/presentation/dialog/downloaddialog/DownloadConfirmDialogFragment.kt index 5ab8db529..7881b054a 100644 --- a/core/src/main/java/org/openedx/core/presentation/dialog/downloaddialog/DownloadConfirmDialogFragment.kt +++ b/core/src/main/java/org/openedx/core/presentation/dialog/downloaddialog/DownloadConfirmDialogFragment.kt @@ -16,11 +16,11 @@ 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.MaterialTheme -import androidx.compose.material.Text import androidx.compose.material.icons.Icons import androidx.compose.material.icons.outlined.CloudDownload import androidx.compose.material.icons.rounded.Delete +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier diff --git a/core/src/main/java/org/openedx/core/presentation/dialog/downloaddialog/DownloadErrorDialogFragment.kt b/core/src/main/java/org/openedx/core/presentation/dialog/downloaddialog/DownloadErrorDialogFragment.kt index f7bbe6ea5..e6bdf8e64 100644 --- a/core/src/main/java/org/openedx/core/presentation/dialog/downloaddialog/DownloadErrorDialogFragment.kt +++ b/core/src/main/java/org/openedx/core/presentation/dialog/downloaddialog/DownloadErrorDialogFragment.kt @@ -16,8 +16,8 @@ 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.MaterialTheme -import androidx.compose.material.Text +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier diff --git a/core/src/main/java/org/openedx/core/presentation/dialog/downloaddialog/DownloadStorageErrorDialogFragment.kt b/core/src/main/java/org/openedx/core/presentation/dialog/downloaddialog/DownloadStorageErrorDialogFragment.kt index 8c026bdf2..67c556043 100644 --- a/core/src/main/java/org/openedx/core/presentation/dialog/downloaddialog/DownloadStorageErrorDialogFragment.kt +++ b/core/src/main/java/org/openedx/core/presentation/dialog/downloaddialog/DownloadStorageErrorDialogFragment.kt @@ -25,8 +25,8 @@ import androidx.compose.foundation.layout.width import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.foundation.verticalScroll -import androidx.compose.material.MaterialTheme -import androidx.compose.material.Text +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.remember diff --git a/core/src/main/java/org/openedx/core/presentation/dialog/downloaddialog/DownloadView.kt b/core/src/main/java/org/openedx/core/presentation/dialog/downloaddialog/DownloadView.kt index 58a5f9d22..14ab4e66c 100644 --- a/core/src/main/java/org/openedx/core/presentation/dialog/downloaddialog/DownloadView.kt +++ b/core/src/main/java/org/openedx/core/presentation/dialog/downloaddialog/DownloadView.kt @@ -4,9 +4,9 @@ import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size -import androidx.compose.material.Icon -import androidx.compose.material.MaterialTheme -import androidx.compose.material.Text +import androidx.compose.material3.Icon +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier diff --git a/core/src/main/java/org/openedx/core/presentation/dialog/selectorbottomsheet/SelectBottomDialogFragment.kt b/core/src/main/java/org/openedx/core/presentation/dialog/selectorbottomsheet/SelectBottomDialogFragment.kt index 3890aa360..11e007e51 100644 --- a/core/src/main/java/org/openedx/core/presentation/dialog/selectorbottomsheet/SelectBottomDialogFragment.kt +++ b/core/src/main/java/org/openedx/core/presentation/dialog/selectorbottomsheet/SelectBottomDialogFragment.kt @@ -12,8 +12,8 @@ import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.widthIn import androidx.compose.foundation.lazy.rememberLazyListState -import androidx.compose.material.MaterialTheme -import androidx.compose.material.Surface +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Surface import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.saveable.rememberSaveable diff --git a/core/src/main/java/org/openedx/core/presentation/global/appupgrade/AppUpdateUI.kt b/core/src/main/java/org/openedx/core/presentation/global/appupgrade/AppUpdateUI.kt index e0cbae480..e755e0aa5 100644 --- a/core/src/main/java/org/openedx/core/presentation/global/appupgrade/AppUpdateUI.kt +++ b/core/src/main/java/org/openedx/core/presentation/global/appupgrade/AppUpdateUI.kt @@ -16,13 +16,14 @@ 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 -import androidx.compose.material.Surface -import androidx.compose.material.Text +import androidx.compose.material3.Button +import androidx.compose.material3.ButtonDefaults +import androidx.compose.material3.Card +import androidx.compose.material3.CardDefaults +import androidx.compose.material3.Icon +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Surface +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.ExperimentalComposeUiApi @@ -267,7 +268,7 @@ fun TransparentTextButton( .testTag("btn_secondary") .height(42.dp), colors = ButtonDefaults.buttonColors( - backgroundColor = Color.Transparent + containerColor = Color.Transparent ), elevation = null, shape = MaterialTheme.appShapes.navigationButtonShape, @@ -292,7 +293,7 @@ fun DefaultTextButton( .testTag("btn_primary") .height(42.dp), colors = ButtonDefaults.buttonColors( - backgroundColor = MaterialTheme.appColors.primaryButtonBackground + containerColor = MaterialTheme.appColors.primaryButtonBackground ), elevation = null, shape = MaterialTheme.appShapes.navigationButtonShape, @@ -326,7 +327,7 @@ fun AppUpgradeRecommendedBox( onClick() }, shape = MaterialTheme.appShapes.cardShape, - backgroundColor = MaterialTheme.appColors.primary + colors = CardDefaults.cardColors(containerColor = MaterialTheme.appColors.primary) ) { Row( modifier = Modifier.padding(horizontal = 20.dp, vertical = 8.dp), 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 15f94d338..10c4cf73a 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 @@ -7,11 +7,11 @@ import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding -import androidx.compose.material.AlertDialog -import androidx.compose.material.CircularProgressIndicator -import androidx.compose.material.MaterialTheme -import androidx.compose.material.Surface -import androidx.compose.material.Text +import androidx.compose.material3.AlertDialog +import androidx.compose.material3.CircularProgressIndicator +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Surface +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier @@ -124,7 +124,7 @@ private fun CalendarAlertDialog(dialogProperties: DialogProperties, onDismiss: ( shape = MaterialTheme.appShapes.cardShape ), shape = MaterialTheme.appShapes.cardShape, - backgroundColor = MaterialTheme.appColors.background, + containerColor = MaterialTheme.appColors.background, properties = AlertDialogProperties( dismissOnBackPress = false, @@ -133,7 +133,7 @@ private fun CalendarAlertDialog(dialogProperties: DialogProperties, onDismiss: ( onDismissRequest = onDismiss, title = dialogProperties.title.takeIfNotEmpty()?.let { - @Composable { + { Text( text = dialogProperties.title, color = MaterialTheme.appColors.textPrimary, diff --git a/core/src/main/java/org/openedx/core/presentation/settings/calendarsync/CalendarSyncState.kt b/core/src/main/java/org/openedx/core/presentation/settings/calendarsync/CalendarSyncState.kt index 95a851442..5ad386dee 100644 --- a/core/src/main/java/org/openedx/core/presentation/settings/calendarsync/CalendarSyncState.kt +++ b/core/src/main/java/org/openedx/core/presentation/settings/calendarsync/CalendarSyncState.kt @@ -1,12 +1,12 @@ package org.openedx.core.presentation.settings.calendarsync import androidx.annotation.StringRes -import androidx.compose.material.MaterialTheme import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.CloudSync import androidx.compose.material.icons.filled.SyncDisabled import androidx.compose.material.icons.rounded.EventRepeat import androidx.compose.material.icons.rounded.FreeCancellation +import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.runtime.ReadOnlyComposable import androidx.compose.ui.graphics.Color 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 b370cd56d..6f72776ec 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 @@ -18,14 +18,13 @@ import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.widthIn import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.verticalScroll -import androidx.compose.material.Divider -import androidx.compose.material.Icon -import androidx.compose.material.MaterialTheme -import androidx.compose.material.Scaffold -import androidx.compose.material.Text import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.Done -import androidx.compose.material.rememberScaffoldState +import androidx.compose.material3.HorizontalDivider +import androidx.compose.material3.Icon +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Scaffold +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.livedata.observeAsState @@ -129,7 +128,6 @@ private fun VideoQualityScreen( onQualityChanged: (VideoQuality) -> Unit, onBackClick: () -> Unit ) { - val scaffoldState = rememberScaffoldState() Scaffold( modifier = Modifier .fillMaxSize() @@ -137,7 +135,6 @@ private fun VideoQualityScreen( .semantics { testTagsAsResourceId = true }, - scaffoldState = scaffoldState, ) { paddingValues -> val topBarWidth by remember(key1 = windowSize) { @@ -249,7 +246,7 @@ private fun QualityOption( ) } } - Divider() + HorizontalDivider() } @Preview(uiMode = Configuration.UI_MODE_NIGHT_NO) 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 4230980be..a63e130f3 100644 --- a/core/src/main/java/org/openedx/core/ui/ComposeCommon.kt +++ b/core/src/main/java/org/openedx/core/ui/ComposeCommon.kt @@ -37,18 +37,6 @@ import androidx.compose.foundation.text.BasicText import androidx.compose.foundation.text.KeyboardActions import androidx.compose.foundation.text.KeyboardOptions import androidx.compose.foundation.verticalScroll -import androidx.compose.material.Button -import androidx.compose.material.ButtonDefaults -import androidx.compose.material.CircularProgressIndicator -import androidx.compose.material.Divider -import androidx.compose.material.Icon -import androidx.compose.material.IconButton -import androidx.compose.material.MaterialTheme -import androidx.compose.material.OutlinedButton -import androidx.compose.material.OutlinedTextField -import androidx.compose.material.ScaffoldState -import androidx.compose.material.Text -import androidx.compose.material.TextFieldDefaults import androidx.compose.material.icons.Icons import androidx.compose.material.icons.automirrored.filled.ArrowBack import androidx.compose.material.icons.filled.AccountCircle @@ -56,6 +44,18 @@ import androidx.compose.material.icons.filled.Close import androidx.compose.material.icons.filled.Info import androidx.compose.material.icons.filled.ManageAccounts import androidx.compose.material.icons.filled.Search +import androidx.compose.material3.Button +import androidx.compose.material3.ButtonDefaults +import androidx.compose.material3.CircularProgressIndicator +import androidx.compose.material3.HorizontalDivider +import androidx.compose.material3.Icon +import androidx.compose.material3.IconButton +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.OutlinedButton +import androidx.compose.material3.OutlinedTextField +import androidx.compose.material3.OutlinedTextFieldDefaults +import androidx.compose.material3.SnackbarHostState +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.NonRestartableComposable @@ -258,17 +258,16 @@ fun SearchBar( textFieldValue = it } }, - colors = TextFieldDefaults.outlinedTextFieldColors( - textColor = MaterialTheme.appColors.textPrimary, - backgroundColor = if (isFocused) { - MaterialTheme.appColors.background - } else { - MaterialTheme.appColors.textFieldBackground - }, + colors = OutlinedTextFieldDefaults.colors( + focusedTextColor = MaterialTheme.appColors.textPrimary, + unfocusedTextColor = MaterialTheme.appColors.textPrimary, + focusedContainerColor = MaterialTheme.appColors.background, + unfocusedContainerColor = MaterialTheme.appColors.textFieldBackground, focusedBorderColor = MaterialTheme.appColors.primary, unfocusedBorderColor = MaterialTheme.appColors.textFieldBorder, cursorColor = MaterialTheme.appColors.primary, - leadingIconColor = MaterialTheme.appColors.textPrimary + focusedLeadingIconColor = MaterialTheme.appColors.textPrimary, + unfocusedLeadingIconColor = MaterialTheme.appColors.textPrimary ), placeholder = { Text( @@ -353,17 +352,16 @@ fun SearchBarStateless( onValueChanged(it) } }, - colors = TextFieldDefaults.outlinedTextFieldColors( - textColor = MaterialTheme.appColors.textPrimary, - backgroundColor = if (isFocused) { - MaterialTheme.appColors.background - } else { - MaterialTheme.appColors.textFieldBackground - }, + colors = OutlinedTextFieldDefaults.colors( + focusedTextColor = MaterialTheme.appColors.textPrimary, + unfocusedTextColor = MaterialTheme.appColors.textPrimary, + focusedContainerColor = MaterialTheme.appColors.background, + unfocusedContainerColor = MaterialTheme.appColors.textFieldBackground, focusedBorderColor = MaterialTheme.appColors.primary, unfocusedBorderColor = MaterialTheme.appColors.textFieldBorder, cursorColor = MaterialTheme.appColors.primary, - leadingIconColor = MaterialTheme.appColors.textPrimary + focusedLeadingIconColor = MaterialTheme.appColors.textPrimary, + unfocusedLeadingIconColor = MaterialTheme.appColors.textPrimary ), placeholder = { Text( @@ -409,13 +407,13 @@ fun SearchBarStateless( @NonRestartableComposable fun HandleUIMessage( uiMessage: UIMessage?, - scaffoldState: ScaffoldState, + snackbarHostState: SnackbarHostState, ) { val context = LocalContext.current LaunchedEffect(uiMessage) { when (uiMessage) { is UIMessage.SnackBarMessage -> { - scaffoldState.snackbarHostState.showSnackbar( + snackbarHostState.showSnackbar( message = uiMessage.message, duration = uiMessage.duration ) @@ -567,7 +565,7 @@ fun SheetContent( style = MaterialTheme.appTypography.bodyLarge, textAlign = TextAlign.Center ) - Divider(modifier = Modifier.padding(horizontal = 16.dp)) + HorizontalDivider(modifier = Modifier.padding(horizontal = 16.dp)) } } } @@ -633,7 +631,7 @@ fun SheetContent( style = MaterialTheme.appTypography.bodyLarge, textAlign = TextAlign.Center ) - Divider(modifier = Modifier.padding(horizontal = 16.dp)) + HorizontalDivider(modifier = Modifier.padding(horizontal = 16.dp)) } } } @@ -684,10 +682,13 @@ fun OpenEdXOutlinedTextField( inputFieldValue = it onValueChanged(it.text) }, - colors = TextFieldDefaults.outlinedTextFieldColors( + colors = OutlinedTextFieldDefaults.colors( + focusedTextColor = MaterialTheme.appColors.textFieldText, + unfocusedTextColor = MaterialTheme.appColors.textFieldText, + focusedContainerColor = MaterialTheme.appColors.textFieldBackground, + unfocusedContainerColor = MaterialTheme.appColors.textFieldBackground, + focusedBorderColor = MaterialTheme.appColors.primary, unfocusedBorderColor = MaterialTheme.appColors.textFieldBorder, - textColor = MaterialTheme.appColors.textFieldText, - backgroundColor = MaterialTheme.appColors.textFieldBackground, errorBorderColor = MaterialTheme.appColors.error, ), shape = MaterialTheme.appShapes.textFieldShape, @@ -966,7 +967,7 @@ fun OpenEdXButton( .then(modifier), shape = MaterialTheme.appShapes.buttonShape, colors = ButtonDefaults.buttonColors( - backgroundColor = backgroundColor + containerColor = backgroundColor ), enabled = enabled, onClick = onClick @@ -1004,7 +1005,7 @@ fun OpenEdXOutlinedButton( enabled = enabled, border = BorderStroke(1.dp, borderColor), shape = MaterialTheme.appShapes.buttonShape, - colors = ButtonDefaults.outlinedButtonColors(backgroundColor = backgroundColor) + colors = ButtonDefaults.outlinedButtonColors(containerColor = backgroundColor) ) { if (content == null) { Text( diff --git a/core/src/main/java/org/openedx/core/ui/HTMLRenderer.kt b/core/src/main/java/org/openedx/core/ui/HTMLRenderer.kt index 0105e2cff..34980354c 100644 --- a/core/src/main/java/org/openedx/core/ui/HTMLRenderer.kt +++ b/core/src/main/java/org/openedx/core/ui/HTMLRenderer.kt @@ -14,8 +14,8 @@ import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.width -import androidx.compose.material.MaterialTheme -import androidx.compose.material.Text +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf diff --git a/core/src/main/java/org/openedx/core/ui/PageIndicator.kt b/core/src/main/java/org/openedx/core/ui/PageIndicator.kt index 8e9f4f40b..411de5736 100644 --- a/core/src/main/java/org/openedx/core/ui/PageIndicator.kt +++ b/core/src/main/java/org/openedx/core/ui/PageIndicator.kt @@ -7,7 +7,7 @@ import androidx.compose.foundation.Canvas import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.size -import androidx.compose.material.MaterialTheme +import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.ui.Alignment diff --git a/core/src/main/java/org/openedx/core/ui/WebContentScreen.kt b/core/src/main/java/org/openedx/core/ui/WebContentScreen.kt index 70f320368..dead1913a 100644 --- a/core/src/main/java/org/openedx/core/ui/WebContentScreen.kt +++ b/core/src/main/java/org/openedx/core/ui/WebContentScreen.kt @@ -13,10 +13,9 @@ import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.widthIn -import androidx.compose.material.MaterialTheme -import androidx.compose.material.Scaffold -import androidx.compose.material.Surface -import androidx.compose.material.rememberScaffoldState +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Scaffold +import androidx.compose.material3.Surface import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableFloatStateOf @@ -54,7 +53,6 @@ fun WebContentScreen( htmlBody: String? = null, contentUrl: String? = null, ) { - val scaffoldState = rememberScaffoldState() Scaffold( modifier = Modifier .fillMaxSize() @@ -62,8 +60,7 @@ fun WebContentScreen( .semantics { testTagsAsResourceId = true }, - scaffoldState = scaffoldState, - backgroundColor = MaterialTheme.appColors.background + containerColor = MaterialTheme.appColors.background ) { val screenWidth by remember(key1 = windowSize) { mutableStateOf( diff --git a/core/src/main/java/org/openedx/core/ui/theme/AppColors.kt b/core/src/main/java/org/openedx/core/ui/theme/AppColors.kt index bf20366d9..58da9beac 100644 --- a/core/src/main/java/org/openedx/core/ui/theme/AppColors.kt +++ b/core/src/main/java/org/openedx/core/ui/theme/AppColors.kt @@ -1,10 +1,10 @@ package org.openedx.core.ui.theme -import androidx.compose.material.Colors +import androidx.compose.material3.ColorScheme import androidx.compose.ui.graphics.Color data class AppColors( - val material: Colors, + val material3: ColorScheme, val textPrimary: Color, val textPrimaryVariant: Color, @@ -83,17 +83,51 @@ data class AppColors( val gradeProgressBarBackground: Color, val assignmentCardBorder: Color, ) { - val primary: Color get() = material.primary - val primaryVariant: Color get() = material.primaryVariant - val secondary: Color get() = material.secondary - val secondaryVariant: Color get() = material.secondaryVariant - val background: Color get() = material.background - val surface: Color get() = material.surface - val error: Color get() = material.error - val onPrimary: Color get() = material.onPrimary - val onSecondary: Color get() = material.onSecondary - val onBackground: Color get() = material.onBackground - val onSurface: Color get() = material.onSurface - val onError: Color get() = material.onError - val isLight: Boolean get() = material.isLight + // Material 3 ColorScheme accessors + val primary: Color get() = material3.primary + val onPrimary: Color get() = material3.onPrimary + val primaryContainer: Color get() = material3.primaryContainer + val onPrimaryContainer: Color get() = material3.onPrimaryContainer + val secondary: Color get() = material3.secondary + val onSecondary: Color get() = material3.onSecondary + val secondaryContainer: Color get() = material3.secondaryContainer + val onSecondaryContainer: Color get() = material3.onSecondaryContainer + val tertiary: Color get() = material3.tertiary + val onTertiary: Color get() = material3.onTertiary + val tertiaryContainer: Color get() = material3.tertiaryContainer + val onTertiaryContainer: Color get() = material3.onTertiaryContainer + val background: Color get() = material3.background + val onBackground: Color get() = material3.onBackground + val surface: Color get() = material3.surface + val onSurface: Color get() = material3.onSurface + val surfaceVariant: Color get() = material3.surfaceVariant + val onSurfaceVariant: Color get() = material3.onSurfaceVariant + val error: Color get() = material3.error + val onError: Color get() = material3.onError + val errorContainer: Color get() = material3.errorContainer + val onErrorContainer: Color get() = material3.onErrorContainer + val outline: Color get() = material3.outline + val outlineVariant: Color get() = material3.outlineVariant + val inverseSurface: Color get() = material3.inverseSurface + val inverseOnSurface: Color get() = material3.inverseOnSurface + val inversePrimary: Color get() = material3.inversePrimary + val surfaceTint: Color get() = material3.surfaceTint + val scrim: Color get() = material3.scrim + + // Backward compatibility accessors for M1 color names + @Deprecated("Use primary instead", ReplaceWith("primary")) + val primaryVariant: Color get() = material3.primaryContainer + + @Deprecated("Use secondary instead", ReplaceWith("secondary")) + val secondaryVariant: Color get() = material3.secondaryContainer + + // Helper to determine if this is a light theme + val isLight: Boolean get() = material3.background.luminance() > 0.5f + + private fun Color.luminance(): Float { + val r = red + val g = green + val b = blue + return 0.299f * r + 0.587f * g + 0.114f * b + } } diff --git a/core/src/main/java/org/openedx/core/ui/theme/AppShapes.kt b/core/src/main/java/org/openedx/core/ui/theme/AppShapes.kt index 1a45681f9..214ebdf5b 100644 --- a/core/src/main/java/org/openedx/core/ui/theme/AppShapes.kt +++ b/core/src/main/java/org/openedx/core/ui/theme/AppShapes.kt @@ -1,13 +1,13 @@ package org.openedx.core.ui.theme import androidx.compose.foundation.shape.CornerBasedShape -import androidx.compose.material.MaterialTheme -import androidx.compose.material.Shapes +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Shapes import androidx.compose.runtime.Composable import androidx.compose.runtime.ReadOnlyComposable data class AppShapes( - val material: Shapes, + val material3: Shapes, val buttonShape: CornerBasedShape, val navigationButtonShape: CornerBasedShape, val textFieldShape: CornerBasedShape, diff --git a/core/src/main/java/org/openedx/core/ui/theme/AppTypography.kt b/core/src/main/java/org/openedx/core/ui/theme/AppTypography.kt index 52d9adebb..5fc36d480 100644 --- a/core/src/main/java/org/openedx/core/ui/theme/AppTypography.kt +++ b/core/src/main/java/org/openedx/core/ui/theme/AppTypography.kt @@ -1,6 +1,6 @@ package org.openedx.core.ui.theme -import androidx.compose.material.MaterialTheme +import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.runtime.ReadOnlyComposable import androidx.compose.runtime.staticCompositionLocalOf diff --git a/core/src/main/java/org/openedx/core/ui/theme/Theme.kt b/core/src/main/java/org/openedx/core/ui/theme/Theme.kt index 9b42c90ac..ec7997c72 100644 --- a/core/src/main/java/org/openedx/core/ui/theme/Theme.kt +++ b/core/src/main/java/org/openedx/core/ui/theme/Theme.kt @@ -3,27 +3,40 @@ package org.openedx.core.ui.theme import androidx.compose.foundation.ExperimentalFoundationApi import androidx.compose.foundation.LocalOverscrollFactory import androidx.compose.foundation.isSystemInDarkTheme -import androidx.compose.material.MaterialTheme -import androidx.compose.material.darkColors -import androidx.compose.material.lightColors +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.darkColorScheme +import androidx.compose.material3.lightColorScheme import androidx.compose.runtime.Composable import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.runtime.ReadOnlyComposable +import androidx.compose.runtime.staticCompositionLocalOf + +internal val LocalAppColors = staticCompositionLocalOf { + error("No AppColors provided") +} private val DarkColorPalette = AppColors( - material = darkColors( + material3 = darkColorScheme( primary = dark_primary, - primaryVariant = dark_primary_variant, - secondary = dark_secondary, - secondaryVariant = dark_secondary_variant, - background = dark_background, - surface = dark_surface, - error = dark_error, onPrimary = dark_onPrimary, + primaryContainer = dark_primary_variant, + onPrimaryContainer = dark_onPrimary, + secondary = dark_secondary, onSecondary = dark_onSecondary, + secondaryContainer = dark_secondary_variant, + onSecondaryContainer = dark_onSecondary, + tertiary = dark_secondary, + onTertiary = dark_onSecondary, + background = dark_background, onBackground = dark_onBackground, + surface = dark_surface, onSurface = dark_onSurface, - onError = dark_onError + surfaceVariant = dark_surface, + onSurfaceVariant = dark_onSurface, + error = dark_error, + onError = dark_onError, + outline = dark_text_field_border, + outlineVariant = dark_divider, ), textPrimary = dark_text_primary, textPrimaryVariant = dark_text_primary_variant, @@ -103,19 +116,27 @@ private val DarkColorPalette = AppColors( ) private val LightColorPalette = AppColors( - material = lightColors( + material3 = lightColorScheme( primary = light_primary, - primaryVariant = light_primary_variant, - secondary = light_secondary, - secondaryVariant = light_secondary_variant, - background = light_background, - surface = light_surface, - error = light_error, onPrimary = light_onPrimary, + primaryContainer = light_primary_variant, + onPrimaryContainer = light_onPrimary, + secondary = light_secondary, onSecondary = light_onSecondary, + secondaryContainer = light_secondary_variant, + onSecondaryContainer = light_onSecondary, + tertiary = light_secondary, + onTertiary = light_onSecondary, + background = light_background, onBackground = light_onBackground, + surface = light_surface, onSurface = light_onSurface, - onError = light_onError + surfaceVariant = light_surface, + onSurfaceVariant = light_onSurface, + error = light_error, + onError = light_onError, + outline = light_text_field_border, + outlineVariant = light_divider, ), textPrimary = light_text_primary, textPrimaryVariant = light_text_primary_variant, @@ -197,7 +218,7 @@ private val LightColorPalette = AppColors( val MaterialTheme.appColors: AppColors @Composable @ReadOnlyComposable - get() = if (colors.isLight) LightColorPalette else DarkColorPalette + get() = LocalAppColors.current @OptIn(ExperimentalFoundationApi::class) @Composable @@ -209,11 +230,11 @@ fun OpenEdXTheme(darkTheme: Boolean = isSystemInDarkTheme(), content: @Composabl } MaterialTheme( - colors = colors.material, - // typography = LocalTypography.current.material, - shapes = LocalShapes.current.material, + colorScheme = colors.material3, + shapes = LocalShapes.current.material3, ) { CompositionLocalProvider( + LocalAppColors provides colors, LocalOverscrollFactory provides null, content = content ) diff --git a/core/src/main/res/values/themes.xml b/core/src/main/res/values/themes.xml index e43010475..a55cddceb 100644 --- a/core/src/main/res/values/themes.xml +++ b/core/src/main/res/values/themes.xml @@ -1,6 +1,6 @@ -