You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
53 lines
1.6 KiB
Kotlin
53 lines
1.6 KiB
Kotlin
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
package org.mozilla.fenix.home.recenttabs.controller
|
|
|
|
import androidx.navigation.NavController
|
|
import mozilla.components.feature.tabs.TabsUseCases.SelectTabUseCase
|
|
import org.mozilla.fenix.R
|
|
import org.mozilla.fenix.ext.nav
|
|
import org.mozilla.fenix.home.HomeFragmentDirections
|
|
import org.mozilla.fenix.home.recenttabs.interactor.RecentTabInteractor
|
|
|
|
/**
|
|
* An interface that handles the view manipulation of the recent tabs in the Home screen.
|
|
*/
|
|
interface RecentTabController {
|
|
|
|
/**
|
|
* @see [RecentTabInteractor.onRecentTabClicked]
|
|
*/
|
|
fun handleRecentTabClicked(tabId: String)
|
|
|
|
/**
|
|
* @see [RecentTabInteractor.onRecentTabShowAllClicked]
|
|
*/
|
|
fun handleRecentTabShowAllClicked()
|
|
}
|
|
|
|
/**
|
|
* The default implementation of [RecentTabController].
|
|
*
|
|
* @param selectTabUseCase [SelectTabUseCase] used selecting a tab.
|
|
* @param navController [NavController] used for navigation.
|
|
*/
|
|
class DefaultRecentTabsController(
|
|
private val selectTabUseCase: SelectTabUseCase,
|
|
private val navController: NavController
|
|
) : RecentTabController {
|
|
|
|
override fun handleRecentTabClicked(tabId: String) {
|
|
selectTabUseCase.invoke(tabId)
|
|
navController.navigate(R.id.browserFragment)
|
|
}
|
|
|
|
override fun handleRecentTabShowAllClicked() {
|
|
navController.nav(
|
|
R.id.homeFragment,
|
|
HomeFragmentDirections.actionGlobalTabsTrayFragment()
|
|
)
|
|
}
|
|
}
|