зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1917862: Part 2- Moved collection and collection item fakes to FakeHomepagePreview. r=gl,android-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D221724
This commit is contained in:
Родитель
1b04316adc
Коммит
79331b2153
|
@ -4,7 +4,6 @@
|
|||
|
||||
package org.mozilla.fenix.home.collections
|
||||
|
||||
import android.content.Context
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.fillMaxHeight
|
||||
|
@ -29,9 +28,6 @@ import androidx.compose.ui.res.painterResource
|
|||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.semantics.semantics
|
||||
import androidx.compose.ui.unit.dp
|
||||
import mozilla.components.browser.state.state.recover.RecoverableTab
|
||||
import mozilla.components.concept.engine.Engine
|
||||
import mozilla.components.feature.tab.collections.Tab
|
||||
import mozilla.components.feature.tab.collections.TabCollection
|
||||
import org.mozilla.fenix.R
|
||||
import org.mozilla.fenix.R.drawable
|
||||
|
@ -41,6 +37,7 @@ import org.mozilla.fenix.compose.MenuItem
|
|||
import org.mozilla.fenix.compose.annotation.LightDarkPreview
|
||||
import org.mozilla.fenix.compose.list.ExpandableListHeader
|
||||
import org.mozilla.fenix.ext.getIconColor
|
||||
import org.mozilla.fenix.home.fake.FakeHomepagePreview
|
||||
import org.mozilla.fenix.theme.FirefoxTheme
|
||||
|
||||
/**
|
||||
|
@ -159,7 +156,7 @@ private fun CollectionExpandedPreview() {
|
|||
var expanded by remember { mutableStateOf(true) }
|
||||
|
||||
Collection(
|
||||
collection = collectionPreview,
|
||||
collection = FakeHomepagePreview.collection(),
|
||||
expanded = expanded,
|
||||
menuItems = emptyList(),
|
||||
onToggleCollectionExpanded = { _, expand ->
|
||||
|
@ -177,7 +174,7 @@ private fun CollectionPreview() {
|
|||
var expanded by remember { mutableStateOf(false) }
|
||||
|
||||
Collection(
|
||||
collection = collectionPreview,
|
||||
collection = FakeHomepagePreview.collection(),
|
||||
expanded = expanded,
|
||||
menuItems = emptyList(),
|
||||
onToggleCollectionExpanded = { _, expand ->
|
||||
|
@ -187,22 +184,3 @@ private fun CollectionPreview() {
|
|||
)
|
||||
}
|
||||
}
|
||||
|
||||
private val collectionPreview = object : TabCollection {
|
||||
override val id: Long = 1L
|
||||
override val tabs: List<Tab> = emptyList()
|
||||
override val title: String = "Collection 1"
|
||||
|
||||
override fun restore(
|
||||
context: Context,
|
||||
engine: Engine,
|
||||
restoreSessionId: Boolean,
|
||||
): List<RecoverableTab> = emptyList()
|
||||
|
||||
override fun restoreSubset(
|
||||
context: Context,
|
||||
engine: Engine,
|
||||
tabs: List<Tab>,
|
||||
restoreSessionId: Boolean,
|
||||
): List<RecoverableTab> = emptyList()
|
||||
}
|
||||
|
|
|
@ -26,8 +26,6 @@ import androidx.compose.ui.res.painterResource
|
|||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.unit.Constraints
|
||||
import androidx.compose.ui.unit.dp
|
||||
import mozilla.components.browser.state.state.recover.RecoverableTab
|
||||
import mozilla.components.concept.engine.Engine
|
||||
import mozilla.components.feature.tab.collections.Tab
|
||||
import org.mozilla.fenix.R.drawable
|
||||
import org.mozilla.fenix.R.string
|
||||
|
@ -35,8 +33,8 @@ import org.mozilla.fenix.compose.annotation.LightDarkPreview
|
|||
import org.mozilla.fenix.compose.list.FaviconListItem
|
||||
import org.mozilla.fenix.compose.tabstray.DismissedTabBackground
|
||||
import org.mozilla.fenix.ext.toShortUrl
|
||||
import org.mozilla.fenix.home.fake.FakeHomepagePreview
|
||||
import org.mozilla.fenix.theme.FirefoxTheme
|
||||
import java.io.File
|
||||
|
||||
/**
|
||||
* Rectangular shape with only right angles used to display a middle tab.
|
||||
|
@ -137,7 +135,7 @@ private fun TabInCollectionPreview() {
|
|||
FirefoxTheme {
|
||||
Column {
|
||||
CollectionItem(
|
||||
tab = tabPreview,
|
||||
tab = FakeHomepagePreview.tab(),
|
||||
isLastInCollection = false,
|
||||
onClick = {},
|
||||
onRemove = {},
|
||||
|
@ -146,7 +144,7 @@ private fun TabInCollectionPreview() {
|
|||
Spacer(Modifier.height(10.dp))
|
||||
|
||||
CollectionItem(
|
||||
tab = tabPreview,
|
||||
tab = FakeHomepagePreview.tab(),
|
||||
isLastInCollection = true,
|
||||
onClick = {},
|
||||
onRemove = {},
|
||||
|
@ -154,15 +152,3 @@ private fun TabInCollectionPreview() {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
private val tabPreview = object : Tab {
|
||||
override val id = 2L
|
||||
override val title = "Mozilla-Firefox"
|
||||
override val url = "https://www.mozilla.org/en-US/firefox/whats-new-in-last-version"
|
||||
|
||||
override fun restore(
|
||||
filesDir: File,
|
||||
engine: Engine,
|
||||
restoreSessionId: Boolean,
|
||||
): RecoverableTab? = null
|
||||
}
|
||||
|
|
|
@ -4,10 +4,15 @@
|
|||
|
||||
package org.mozilla.fenix.home.fake
|
||||
|
||||
import android.content.Context
|
||||
import com.google.firebase.util.nextAlphanumericString
|
||||
import mozilla.components.browser.state.state.ContentState
|
||||
import mozilla.components.browser.state.state.TabSessionState
|
||||
import mozilla.components.browser.state.state.recover.RecoverableTab
|
||||
import mozilla.components.concept.engine.Engine
|
||||
import mozilla.components.concept.sync.DeviceType
|
||||
import mozilla.components.feature.tab.collections.Tab
|
||||
import mozilla.components.feature.tab.collections.TabCollection
|
||||
import mozilla.components.feature.top.sites.TopSite
|
||||
import org.mozilla.fenix.browser.browsingmode.BrowsingMode
|
||||
import org.mozilla.fenix.home.bookmarks.Bookmark
|
||||
|
@ -22,6 +27,7 @@ import org.mozilla.fenix.home.recentvisits.RecentlyVisitedItem.RecentHistoryGrou
|
|||
import org.mozilla.fenix.home.recentvisits.RecentlyVisitedItem.RecentHistoryHighlight
|
||||
import org.mozilla.fenix.home.recentvisits.interactor.RecentVisitsInteractor
|
||||
import org.mozilla.fenix.home.sessioncontrol.TopSiteInteractor
|
||||
import java.io.File
|
||||
import kotlin.random.Random
|
||||
|
||||
/**
|
||||
|
@ -188,6 +194,41 @@ internal object FakeHomepagePreview {
|
|||
}
|
||||
}
|
||||
|
||||
internal fun collection(tabs: List<Tab> = emptyList()): TabCollection {
|
||||
return object : TabCollection {
|
||||
override val id: Long = 1L
|
||||
override val tabs: List<Tab> = tabs
|
||||
override val title: String = "Collection 1"
|
||||
|
||||
override fun restore(
|
||||
context: Context,
|
||||
engine: Engine,
|
||||
restoreSessionId: Boolean,
|
||||
): List<RecoverableTab> = emptyList()
|
||||
|
||||
override fun restoreSubset(
|
||||
context: Context,
|
||||
engine: Engine,
|
||||
tabs: List<Tab>,
|
||||
restoreSessionId: Boolean,
|
||||
): List<RecoverableTab> = emptyList()
|
||||
}
|
||||
}
|
||||
|
||||
internal fun tab(): Tab {
|
||||
return object : Tab {
|
||||
override val id = 2L
|
||||
override val title = "Mozilla-Firefox"
|
||||
override val url = "https://www.mozilla.org/en-US/firefox/whats-new-in-last-version"
|
||||
|
||||
override fun restore(
|
||||
filesDir: File,
|
||||
engine: Engine,
|
||||
restoreSessionId: Boolean,
|
||||
): RecoverableTab? = null
|
||||
}
|
||||
}
|
||||
|
||||
private const val URL = "mozilla.com"
|
||||
|
||||
private fun randomLong() = random.nextLong()
|
||||
|
|
Загрузка…
Ссылка в новой задаче