For #21045: Cleanup

- stick to one naming scheme: rename articles to stories and use this all
throughout the app.
- add some spacing above the new section (as per the current design)
upstream-sync
Mugurell 3 years ago committed by mergify[bot]
parent 27d319bc56
commit ccc0f17e4f

@ -243,7 +243,7 @@ class HomeFragment : Fragment() {
if (requireContext().settings().pocketRecommendations) {
lifecycleScope.async(IO) {
val stories = components.core.pocketStoriesService.getStories()
homeFragmentStore.dispatch(HomeFragmentAction.PocketArticlesChange(stories))
homeFragmentStore.dispatch(HomeFragmentAction.PocketStoriesChange(stories))
}
}

@ -63,7 +63,7 @@ data class HomeFragmentState(
val recentTabs: List<TabSessionState> = emptyList(),
val recentBookmarks: List<BookmarkNode> = emptyList(),
val historyMetadata: List<HistoryMetadataGroup> = emptyList(),
val pocketArticles: List<PocketRecommendedStory> = emptyList()
val pocketStories: List<PocketRecommendedStory> = emptyList()
) : State
sealed class HomeFragmentAction : Action {
@ -89,7 +89,7 @@ sealed class HomeFragmentAction : Action {
data class RecentTabsChange(val recentTabs: List<TabSessionState>) : HomeFragmentAction()
data class RecentBookmarksChange(val recentBookmarks: List<BookmarkNode>) : HomeFragmentAction()
data class HistoryMetadataChange(val historyMetadata: List<HistoryMetadataGroup>) : HomeFragmentAction()
data class PocketArticlesChange(val pocketArticles: List<PocketRecommendedStory>) : HomeFragmentAction()
data class PocketStoriesChange(val pocketStories: List<PocketRecommendedStory>) : HomeFragmentAction()
object RemoveCollectionsPlaceholder : HomeFragmentAction()
object RemoveSetDefaultBrowserCard : HomeFragmentAction()
}
@ -132,6 +132,6 @@ private fun homeFragmentStateReducer(
is HomeFragmentAction.RecentTabsChange -> state.copy(recentTabs = action.recentTabs)
is HomeFragmentAction.RecentBookmarksChange -> state.copy(recentBookmarks = action.recentBookmarks)
is HomeFragmentAction.HistoryMetadataChange -> state.copy(historyMetadata = action.historyMetadata)
is HomeFragmentAction.PocketArticlesChange -> state.copy(pocketArticles = action.pocketArticles)
is HomeFragmentAction.PocketStoriesChange -> state.copy(pocketStories = action.pocketStories)
}
}

@ -41,7 +41,7 @@ internal fun normalModeAdapterItems(
showSetAsDefaultBrowserCard: Boolean,
recentTabs: List<TabSessionState>,
historyMetadata: List<HistoryMetadataGroup>,
pocketArticles: List<PocketRecommendedStory>
pocketStories: List<PocketRecommendedStory>
): List<AdapterItem> {
val items = mutableListOf<AdapterItem>()
var shouldShowCustomizeHome = false
@ -81,7 +81,7 @@ internal fun normalModeAdapterItems(
showCollections(collections, expandedCollections, items)
}
if (context.settings().pocketRecommendations && pocketArticles.isNotEmpty()) {
if (context.settings().pocketRecommendations && pocketStories.isNotEmpty()) {
shouldShowCustomizeHome = true
items.add(AdapterItem.PocketStoriesItem)
}
@ -161,7 +161,7 @@ private fun HomeFragmentState.toAdapterList(context: Context): List<AdapterItem>
showSetAsDefaultBrowserCard,
recentTabs,
historyMetadata,
pocketArticles
pocketStories
)
is Mode.Private -> privateModeAdapterItems()
is Mode.Onboarding -> onboardingAdapterItems(mode.state)

@ -238,12 +238,15 @@ fun PocketRecommendations(
* Displays [content] in an expandable card.
*/
@Composable
fun ExpandableCard(content: @Composable (() -> Unit)) {
fun ExpandableCard(
modifier: Modifier = Modifier,
content: @Composable (() -> Unit)
) {
var isExpanded by remember { mutableStateOf(true) }
val chevronRotationState by animateFloatAsState(targetValue = if (isExpanded) 0f else 180f)
Card(
modifier = Modifier.fillMaxWidth(),
modifier = modifier,
shape = RoundedCornerShape(4.dp),
onClick = { isExpanded = !isExpanded }
) {

@ -5,9 +5,13 @@
package org.mozilla.fenix.home.sessioncontrol.viewholders.pocket
import android.view.View
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.ComposeView
import androidx.compose.ui.platform.ViewCompositionStrategy
import androidx.compose.ui.unit.dp
import androidx.recyclerview.widget.RecyclerView
import mozilla.components.concept.fetch.Client
import mozilla.components.lib.state.ext.observeAsComposableState
@ -49,10 +53,14 @@ fun PocketStories(
client: Client
) {
val stories = store
.observeAsComposableState { state -> state.pocketArticles }.value
.observeAsComposableState { state -> state.pocketStories }.value
?.take(STORIES_TO_SHOW_COUNT)
ExpandableCard {
ExpandableCard(
Modifier
.fillMaxWidth()
.padding(top = 40.dp)
) {
PocketRecommendations {
PocketStories(
stories ?: emptyList(),

Loading…
Cancel
Save