Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Remove setting button from toolbar
Browse files Browse the repository at this point in the history
- Remove IconBtn and its implementation from Discovery and Learn toolbar

fix: LEARNER-10138
omerhabib26 committed Aug 15, 2024
1 parent dd757fe commit 72516ca
Showing 9 changed files with 2 additions and 65 deletions.
Original file line number Diff line number Diff line change
@@ -13,8 +13,6 @@ interface DashboardRouter {
resumeBlockId: String = ""
)

fun navigateToSettings(fm: FragmentManager)

fun navigateToAllEnrolledCourses(fm: FragmentManager)

fun getProgramFragment(): Fragment
Original file line number Diff line number Diff line change
@@ -15,12 +15,10 @@ import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.DropdownMenu
import androidx.compose.material.DropdownMenuItem
import androidx.compose.material.Icon
import androidx.compose.material.IconButton
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.ExpandMore
import androidx.compose.material.icons.filled.ManageAccounts
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
@@ -55,7 +53,6 @@ import org.openedx.core.ui.windowSizeValue
import org.openedx.dashboard.R
import org.openedx.dashboard.databinding.FragmentLearnBinding
import org.openedx.learn.LearnType
import org.openedx.core.R as CoreR

class LearnFragment : Fragment(R.layout.fragment_learn) {

@@ -147,9 +144,6 @@ private fun Header(
) {
Title(
label = stringResource(id = R.string.dashboard_learn),
onSettingsClick = {
viewModel.onSettingsClick(fragmentManager)
}
)
if (viewModel.isProgramTypeWebView) {
LearnDropdownMenu(
@@ -167,7 +161,6 @@ private fun Header(
private fun Title(
modifier: Modifier = Modifier,
label: String,
onSettingsClick: () -> Unit,
) {
Box(
modifier = modifier.fillMaxWidth()
@@ -180,20 +173,6 @@ private fun Title(
color = MaterialTheme.appColors.textDark,
style = MaterialTheme.appTypography.headlineBold
)
IconButton(
modifier = Modifier
.align(Alignment.CenterEnd)
.padding(end = 12.dp),
onClick = {
onSettingsClick()
}
) {
Icon(
imageVector = Icons.Default.ManageAccounts,
tint = MaterialTheme.appColors.primary,
contentDescription = stringResource(id = CoreR.string.core_accessibility_settings)
)
}
}
}

@@ -290,10 +269,7 @@ private fun LearnDropdownMenu(
@Composable
private fun HeaderPreview() {
OpenEdXTheme {
Title(
label = stringResource(id = R.string.dashboard_learn),
onSettingsClick = {}
)
Title(label = stringResource(id = R.string.dashboard_learn))
}
}

Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.openedx.learn.presentation

import androidx.fragment.app.FragmentManager
import org.openedx.DashboardNavigator
import org.openedx.core.BaseViewModel
import org.openedx.core.config.Config
@@ -18,10 +17,6 @@ class LearnViewModel(
private val dashboardType get() = config.getDashboardConfig().getType()
val isProgramTypeWebView get() = config.getProgramConfig().isViewTypeWebView()

fun onSettingsClick(fragmentManager: FragmentManager) {
dashboardRouter.navigateToSettings(fragmentManager)
}

val getDashboardFragment get() = DashboardNavigator(dashboardType).getDashboardFragment()

val getProgramFragment get() = dashboardRouter.getProgramFragment()
Original file line number Diff line number Diff line change
@@ -24,7 +24,5 @@ interface DiscoveryRouter {

fun navigateToSignIn(fm: FragmentManager, courseId: String?, infoType: String?)

fun navigateToSettings(fm: FragmentManager)

fun navigateToEnrolledProgramInfo(fm: FragmentManager, pathId: String)
}
Original file line number Diff line number Diff line change
@@ -168,9 +168,6 @@ class NativeDiscoveryFragment : Fragment() {
onBackClick = {
requireActivity().supportFragmentManager.popBackStackImmediate()
},
onSettingsClick = {
router.navigateToSettings(requireActivity().supportFragmentManager)
}
)
LaunchedEffect(uiState) {
if (querySearch.isNotEmpty()) {
@@ -218,7 +215,6 @@ internal fun DiscoveryScreen(
onRegisterClick: () -> Unit,
onSignInClick: () -> Unit,
onBackClick: () -> Unit,
onSettingsClick: () -> Unit,
) {
val scaffoldState = rememberScaffoldState()
val scrollState = rememberLazyListState()
@@ -323,9 +319,7 @@ internal fun DiscoveryScreen(
Toolbar(
label = stringResource(id = R.string.discovery_Discovery),
canShowBackBtn = canShowBackButton,
canShowSettingsIcon = !canShowBackButton,
onBackClick = onBackClick,
onSettingsClick = onSettingsClick
)

Spacer(modifier = Modifier.height(16.dp))
@@ -521,7 +515,6 @@ private fun DiscoveryScreenPreview() {
onSignInClick = {},
onRegisterClick = {},
onBackClick = {},
onSettingsClick = {},
canShowBackButton = false
)
}
@@ -562,7 +555,6 @@ private fun DiscoveryScreenTabletPreview() {
onSignInClick = {},
onRegisterClick = {},
onBackClick = {},
onSettingsClick = {},
canShowBackButton = false
)
}
Original file line number Diff line number Diff line change
@@ -168,9 +168,6 @@ class WebViewDiscoveryFragment : Fragment() {
onSignInClick = {
viewModel.navigateToSignIn(parentFragmentManager)
},
onSettingsClick = {
viewModel.navigateToSettings(requireActivity().supportFragmentManager)
},
onBackClick = {
requireActivity().supportFragmentManager.popBackStackImmediate()
}
@@ -207,8 +204,7 @@ private fun WebViewDiscoveryScreen(
onUriClick: (String, WebViewLink.Authority) -> Unit,
onRegisterClick: () -> Unit,
onSignInClick: () -> Unit,
onSettingsClick: () -> Unit,
onBackClick: () -> Unit
onBackClick: () -> Unit,
) {
val scaffoldState = rememberScaffoldState()
val configuration = LocalConfiguration.current
@@ -263,9 +259,7 @@ private fun WebViewDiscoveryScreen(
Toolbar(
label = stringResource(id = R.string.discovery_explore_the_catalog),
canShowBackBtn = isPreLogin,
canShowSettingsIcon = !isPreLogin,
onBackClick = onBackClick,
onSettingsClick = onSettingsClick
)

Surface {
@@ -424,7 +418,6 @@ private fun WebViewDiscoveryScreenPreview() {
onUriClick = { _, _ -> },
onRegisterClick = {},
onSignInClick = {},
onSettingsClick = {},
onBackClick = {},
)
}
Original file line number Diff line number Diff line change
@@ -85,10 +85,6 @@ class WebViewDiscoveryViewModel(
router.navigateToSignIn(fragmentManager, null, null)
}

fun navigateToSettings(fragmentManager: FragmentManager) {
router.navigateToSettings(fragmentManager)
}

fun courseInfoClickedEvent(courseId: String) {
logEvent(DiscoveryAnalyticsEvent.COURSE_INFO, courseId)
}
Original file line number Diff line number Diff line change
@@ -203,9 +203,6 @@ class ProgramFragment : Fragment() {
}
}
},
onSettingsClick = {
viewModel.navigateToSettings(requireActivity().supportFragmentManager)
}
)
}
}
@@ -249,7 +246,6 @@ private fun ProgramInfoScreen(
isNestedFragment: Boolean,
hasInternetConnection: Boolean,
onWebViewUIAction: (WebViewUIAction) -> Unit,
onSettingsClick: () -> Unit,
onBackClick: () -> Unit,
onUriClick: (String, WebViewLink.Authority) -> Unit,
) {
@@ -304,9 +300,7 @@ private fun ProgramInfoScreen(
Toolbar(
label = stringResource(id = R.string.discovery_programs),
canShowBackBtn = canShowBackBtn,
canShowSettingsIcon = !canShowBackBtn,
onBackClick = onBackClick,
onSettingsClick = onSettingsClick
)
}

@@ -388,7 +382,6 @@ fun MyProgramsPreview() {
hasInternetConnection = false,
onWebViewUIAction = {},
onBackClick = {},
onSettingsClick = {},
onUriClick = { _, _ -> },
)
}
Original file line number Diff line number Diff line change
@@ -105,10 +105,6 @@ class ProgramViewModel(
viewModelScope.launch { notifier.send(NavigationToDiscovery()) }
}

fun navigateToSettings(fragmentManager: FragmentManager) {
router.navigateToSettings(fragmentManager)
}

fun onPageLoadError() {
viewModelScope.launch {
_uiState.emit(ProgramUIState.Error(if (networkConnection.isOnline()) ErrorType.UNKNOWN_ERROR else ErrorType.CONNECTION_ERROR))

0 comments on commit 72516ca

Please sign in to comment.