Skip to content

Commit

Permalink
fix: Remove setting button from toolbar (#33)
Browse files Browse the repository at this point in the history
- Remove setting IconBtn and its implementation from Discovery and Learn toolbar

fix: LEARNER-10138
  • Loading branch information
omerhabib26 authored Aug 16, 2024
1 parent 9080bc3 commit e58517f
Show file tree
Hide file tree
Showing 9 changed files with 3 additions and 69 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ interface DashboardRouter {
resumeBlockId: String = ""
)

fun navigateToSettings(fm: FragmentManager)

fun navigateToAllEnrolledCourses(fm: FragmentManager)

fun getProgramFragment(): Fragment
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -38,7 +36,6 @@ import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import androidx.core.os.bundleOf
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import androidx.viewpager2.widget.ViewPager2
import org.koin.androidx.compose.koinViewModel
import org.koin.androidx.viewmodel.ext.android.viewModel
Expand All @@ -55,7 +52,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) {

Expand All @@ -75,7 +71,6 @@ class LearnFragment : Fragment(R.layout.fragment_learn) {
binding.header.setContent {
OpenEdXTheme {
Header(
fragmentManager = requireParentFragment().parentFragmentManager,
defaultLearnType = defaultLearnType,
viewPager = binding.viewPager
)
Expand Down Expand Up @@ -109,7 +104,7 @@ class LearnFragment : Fragment(R.layout.fragment_learn) {
companion object {
private const val ARG_OPEN_TAB = "open_tab"
fun newInstance(
openTab: String = LearnTab.COURSES.name
openTab: String = LearnTab.COURSES.name,
): LearnFragment {
val fragment = LearnFragment()
fragment.arguments = bundleOf(
Expand All @@ -122,7 +117,6 @@ class LearnFragment : Fragment(R.layout.fragment_learn) {

@Composable
private fun Header(
fragmentManager: FragmentManager,
defaultLearnType: LearnType,
viewPager: ViewPager2,
) {
Expand All @@ -147,9 +141,6 @@ private fun Header(
) {
Title(
label = stringResource(id = R.string.dashboard_learn),
onSettingsClick = {
viewModel.onSettingsClick(fragmentManager)
}
)
if (viewModel.isProgramTypeWebView) {
LearnDropdownMenu(
Expand All @@ -167,7 +158,6 @@ private fun Header(
private fun Title(
modifier: Modifier = Modifier,
label: String,
onSettingsClick: () -> Unit,
) {
Box(
modifier = modifier.fillMaxWidth()
Expand All @@ -180,20 +170,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)
)
}
}
}

Expand Down Expand Up @@ -290,10 +266,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))
}
}

Expand Down
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
Expand All @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Up @@ -168,9 +168,6 @@ class NativeDiscoveryFragment : Fragment() {
onBackClick = {
requireActivity().supportFragmentManager.popBackStackImmediate()
},
onSettingsClick = {
router.navigateToSettings(requireActivity().supportFragmentManager)
}
)
LaunchedEffect(uiState) {
if (querySearch.isNotEmpty()) {
Expand Down Expand Up @@ -218,7 +215,6 @@ internal fun DiscoveryScreen(
onRegisterClick: () -> Unit,
onSignInClick: () -> Unit,
onBackClick: () -> Unit,
onSettingsClick: () -> Unit,
) {
val scaffoldState = rememberScaffoldState()
val scrollState = rememberLazyListState()
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -521,7 +515,6 @@ private fun DiscoveryScreenPreview() {
onSignInClick = {},
onRegisterClick = {},
onBackClick = {},
onSettingsClick = {},
canShowBackButton = false
)
}
Expand Down Expand Up @@ -562,7 +555,6 @@ private fun DiscoveryScreenTabletPreview() {
onSignInClick = {},
onRegisterClick = {},
onBackClick = {},
onSettingsClick = {},
canShowBackButton = false
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,6 @@ class WebViewDiscoveryFragment : Fragment() {
onSignInClick = {
viewModel.navigateToSignIn(parentFragmentManager)
},
onSettingsClick = {
viewModel.navigateToSettings(requireActivity().supportFragmentManager)
},
onBackClick = {
requireActivity().supportFragmentManager.popBackStackImmediate()
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -424,7 +418,6 @@ private fun WebViewDiscoveryScreenPreview() {
onUriClick = { _, _ -> },
onRegisterClick = {},
onSignInClick = {},
onSettingsClick = {},
onBackClick = {},
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,6 @@ class ProgramFragment : Fragment() {
}
}
},
onSettingsClick = {
viewModel.navigateToSettings(requireActivity().supportFragmentManager)
}
)
}
}
Expand Down Expand Up @@ -249,7 +246,6 @@ private fun ProgramInfoScreen(
isNestedFragment: Boolean,
hasInternetConnection: Boolean,
onWebViewUIAction: (WebViewUIAction) -> Unit,
onSettingsClick: () -> Unit,
onBackClick: () -> Unit,
onUriClick: (String, WebViewLink.Authority) -> Unit,
) {
Expand Down Expand Up @@ -304,9 +300,7 @@ private fun ProgramInfoScreen(
Toolbar(
label = stringResource(id = R.string.discovery_programs),
canShowBackBtn = canShowBackBtn,
canShowSettingsIcon = !canShowBackBtn,
onBackClick = onBackClick,
onSettingsClick = onSettingsClick
)
}

Expand Down Expand Up @@ -388,7 +382,6 @@ fun MyProgramsPreview() {
hasInternetConnection = false,
onWebViewUIAction = {},
onBackClick = {},
onSettingsClick = {},
onUriClick = { _, _ -> },
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit e58517f

Please sign in to comment.