Skip to content

Commit

Permalink
Issue mozilla-mobile#21099 - Update items under "Jump back in" sectio…
Browse files Browse the repository at this point in the history
…n to the latest designs
  • Loading branch information
gabrielluong authored and mergify[bot] committed Sep 16, 2021
1 parent 2a92bd5 commit 66a31dd
Show file tree
Hide file tree
Showing 14 changed files with 324 additions and 627 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,10 @@ class CollectionTest {
}.openTabDrawer {
createCollection(webPage.title, firstCollectionName)
verifySnackBarText("Collection saved!")
}.closeTabDrawer {
}.goToHomescreen {
closeTab()
}

homeScreen {
}.expandCollection(firstCollectionName) {
removeTabFromCollection(webPage.title)
verifyTabSavedInCollection(webPage.title, false)
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,55 +5,44 @@
package org.mozilla.fenix.home.recenttabs.view

import android.view.View
import mozilla.components.browser.icons.BrowserIcons
import mozilla.components.browser.state.state.ContentState
import mozilla.components.browser.state.state.TabSessionState
import org.mozilla.fenix.R
import org.mozilla.fenix.databinding.RecentTabsListRowBinding
import org.mozilla.fenix.ext.components
import org.mozilla.fenix.ext.loadIntoView
import androidx.compose.ui.platform.ComposeView
import androidx.compose.ui.platform.ViewCompositionStrategy
import mozilla.components.lib.state.ext.observeAsComposableState
import org.mozilla.fenix.home.HomeFragmentStore
import org.mozilla.fenix.home.recenttabs.interactor.RecentTabInteractor
import org.mozilla.fenix.theme.FirefoxTheme
import org.mozilla.fenix.utils.view.ViewHolder

/**
* View holder for a recent tab item.
*
* @param composeView [ComposeView] which will be populated with Jetpack Compose UI content.
* @param store [HomeFragmentStore] containing the list of recent tabs to be displayed.
* @param interactor [RecentTabInteractor] which will have delegated to all user interactions.
* @param icons an instance of [BrowserIcons] for rendering the sites icon if one isn't found
* in [ContentState.icon].
*/
class RecentTabViewHolder(
private val view: View,
private val interactor: RecentTabInteractor,
private val icons: BrowserIcons = view.context.components.core.icons
) : ViewHolder(view) {

fun bindTab(tab: TabSessionState): View {
// A page may take a while to retrieve a title, so let's show the url until we get one.

val biding = RecentTabsListRowBinding.bind(view)

biding.recentTabTitle.text = if (tab.content.title.isNotEmpty()) {
tab.content.title
} else {
tab.content.url
}

if (tab.content.icon != null) {
biding.recentTabIcon.setImageBitmap(tab.content.icon)
} else {
icons.loadIntoView(biding.recentTabIcon, tab.content.url)
}
biding.recentTabIcon.setImageBitmap(tab.content.icon)

itemView.setOnClickListener {
interactor.onRecentTabClicked(tab.id)
val composeView: ComposeView,
private val store: HomeFragmentStore,
private val interactor: RecentTabInteractor
) : ViewHolder(composeView) {

init {
composeView.setViewCompositionStrategy(
ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed
)
composeView.setContent {
val recentTabs = store.observeAsComposableState { state -> state.recentTabs }

FirefoxTheme {
RecentTabs(
recentTabs = recentTabs.value ?: emptyList(),
onRecentTabClick = { interactor.onRecentTabClicked(it) }
)
}
}

return itemView
}

companion object {
const val LAYOUT_ID = R.layout.recent_tabs_list_row
val LAYOUT_ID = View.generateViewId()
}
}

0 comments on commit 66a31dd

Please sign in to comment.