2
0
mirror of https://github.com/fork-maintainers/iceraven-browser synced 2024-11-07 15:20:38 +00:00

For #25490 - Remove PrimaryText and SecondaryText

This commit is contained in:
Noah Bond 2022-06-13 11:18:37 -07:00 committed by mergify[bot]
parent bd37bef0a9
commit 683226541c
8 changed files with 49 additions and 113 deletions

View File

@ -15,6 +15,7 @@ import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.Card
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
@ -51,16 +52,18 @@ fun ListItemTabLarge(
onClick: (() -> Unit)? = null
) {
ListItemTabSurface(imageUrl, onClick) {
PrimaryText(
Text(
text = title,
color = FirefoxTheme.colors.textPrimary,
fontSize = 14.sp,
overflow = TextOverflow.Ellipsis,
maxLines = 3,
)
if (caption != null) {
SecondaryText(
Text(
text = caption,
color = FirefoxTheme.colors.textSecondary,
fontSize = 12.sp,
overflow = TextOverflow.Ellipsis,
maxLines = 1,
@ -167,8 +170,9 @@ private fun ListItemTabSurfacePreview() {
ListItemTabSurface(
imageUrl = ""
) {
PrimaryText(
Text(
text = "This can be anything",
color = FirefoxTheme.colors.textPrimary,
fontSize = 22.sp
)
}

View File

@ -7,6 +7,7 @@ package org.mozilla.fenix.compose
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.layout.Layout
@ -49,20 +50,23 @@ fun TabSubtitleWithInterdot(
Layout(
content = {
SecondaryText(
Text(
text = firstText,
color = FirefoxTheme.colors.textSecondary,
fontSize = 12.sp,
overflow = TextOverflow.Ellipsis,
maxLines = 1,
)
SecondaryText(
Text(
text = " \u00b7 ",
color = FirefoxTheme.colors.textSecondary,
fontSize = 12.sp,
overflow = TextOverflow.Ellipsis,
maxLines = 1,
)
SecondaryText(
Text(
text = secondText,
color = FirefoxTheme.colors.textSecondary,
fontSize = 12.sp,
overflow = TextOverflow.Ellipsis,
maxLines = 1,

View File

@ -1,81 +0,0 @@
/* 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.compose
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.TextUnit
import org.mozilla.fenix.theme.FirefoxTheme
/**
* High level element for displaying Text based on the Primary text style.
*
* @param text The text to be displayed.
* @param modifier [Modifier] to apply to this layout node.
* @param fontSize The size of glyphs to use when painting the text.
* @param fontFamily The font family to be used when rendering the text.
* @param letterSpacing The amount of space to add between each letter.
* @param overflow How visual overflow should be handled.
* @param maxLines An optional maximum number of lines for the text to span.
*/
@Suppress("LongParameterList")
@Composable
fun PrimaryText(
text: String,
modifier: Modifier = Modifier,
fontSize: TextUnit,
fontFamily: FontFamily? = null,
letterSpacing: TextUnit = TextUnit.Unspecified,
overflow: TextOverflow = TextOverflow.Clip,
maxLines: Int = Int.MAX_VALUE
) {
Text(
text = text,
modifier = modifier,
color = FirefoxTheme.colors.textPrimary,
fontSize = fontSize,
fontFamily = fontFamily,
letterSpacing = letterSpacing,
overflow = overflow,
maxLines = maxLines,
)
}
/**
* High level element for displaying Text based on the Secondary text style.
*
* @param text The text to be displayed.
* @param modifier [Modifier] to apply to this layout node.
* @param fontSize The size of glyphs to use when painting the text.
* @param fontFamily The font family to be used when rendering the text.
* @param letterSpacing The amount of space to add between each letter.
* @param overflow How visual overflow should be handled.
* @param maxLines An optional maximum number of lines for the text to span.
*/
@Suppress("LongParameterList")
@Composable
fun SecondaryText(
text: String,
modifier: Modifier = Modifier,
fontSize: TextUnit,
fontFamily: FontFamily? = null,
letterSpacing: TextUnit = TextUnit.Unspecified,
overflow: TextOverflow = TextOverflow.Clip,
maxLines: Int = Int.MAX_VALUE,
) {
Text(
text = text,
modifier = modifier,
color = FirefoxTheme.colors.textSecondary,
fontSize = fontSize,
fontFamily = fontFamily,
letterSpacing = letterSpacing,
overflow = overflow,
maxLines = maxLines
)
}

View File

@ -65,9 +65,7 @@ import org.mozilla.fenix.compose.ListItemTabLargePlaceholder
import org.mozilla.fenix.compose.ListItemTabSurface
import org.mozilla.fenix.compose.SelectableChip
import org.mozilla.fenix.compose.StaggeredHorizontalGrid
import org.mozilla.fenix.compose.PrimaryText
import org.mozilla.fenix.compose.TabSubtitleWithInterdot
import org.mozilla.fenix.compose.SecondaryText
import org.mozilla.fenix.ext.settings
import org.mozilla.fenix.theme.FirefoxTheme
import org.mozilla.fenix.theme.Theme
@ -115,8 +113,9 @@ fun PocketStory(
imageUrl = imageUrl,
onClick = { onStoryClick(story) },
title = {
PrimaryText(
Text(
text = story.title,
color = FirefoxTheme.colors.textPrimary,
fontSize = 14.sp,
overflow = TextOverflow.Ellipsis,
maxLines = 2,
@ -126,15 +125,17 @@ fun PocketStory(
if (isValidPublisher && isValidTimeToRead) {
TabSubtitleWithInterdot(story.publisher, "${story.timeToRead} min")
} else if (isValidPublisher) {
SecondaryText(
Text(
text = story.publisher,
color = FirefoxTheme.colors.textSecondary,
fontSize = 12.sp,
overflow = TextOverflow.Ellipsis,
maxLines = 1,
)
} else if (isValidTimeToRead) {
SecondaryText(
Text(
text = "${story.timeToRead} min",
color = FirefoxTheme.colors.textSecondary,
fontSize = 12.sp,
overflow = TextOverflow.Ellipsis,
maxLines = 1,
@ -164,8 +165,9 @@ fun PocketSponsoredStory(
)
ListItemTabSurface(imageUrl, { onStoryClick(story) }) {
PrimaryText(
Text(
text = story.title,
color = FirefoxTheme.colors.textPrimary,
fontSize = 14.sp,
overflow = TextOverflow.Ellipsis,
maxLines = 2,
@ -182,8 +184,9 @@ fun PocketSponsoredStory(
Spacer(Modifier.width(8.dp))
SecondaryText(
Text(
text = stringResource(R.string.pocket_stories_sponsor_indication),
color = FirefoxTheme.colors.textSecondary,
fontSize = 12.sp,
overflow = TextOverflow.Ellipsis,
maxLines = 1,
@ -192,8 +195,9 @@ fun PocketSponsoredStory(
Spacer(Modifier.height(7.dp))
SecondaryText(
Text(
text = story.sponsor,
color = FirefoxTheme.colors.textSecondary,
fontSize = 12.sp,
overflow = TextOverflow.Ellipsis,
maxLines = 1,

View File

@ -21,6 +21,7 @@ import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.Card
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
@ -33,8 +34,6 @@ import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import mozilla.components.concept.sync.DeviceType
import org.mozilla.fenix.R
import org.mozilla.fenix.compose.PrimaryText
import org.mozilla.fenix.compose.SecondaryText
import org.mozilla.fenix.compose.ThumbnailCard
import org.mozilla.fenix.compose.button.Button
import org.mozilla.fenix.home.recentsyncedtabs.RecentSyncedTab
@ -87,8 +86,9 @@ fun RecentSyncedTab(
if (tab == null) {
RecentTabTitlePlaceholder()
} else {
PrimaryText(
Text(
text = tab.title,
color = FirefoxTheme.colors.textPrimary,
fontSize = 14.sp,
overflow = TextOverflow.Ellipsis,
maxLines = 2,
@ -117,8 +117,9 @@ fun RecentSyncedTab(
if (tab == null) {
TextLinePlaceHolder()
} else {
SecondaryText(
Text(
text = tab.deviceDisplayName,
color = FirefoxTheme.colors.textSecondary,
fontSize = 12.sp,
overflow = TextOverflow.Ellipsis,
maxLines = 1,

View File

@ -56,8 +56,6 @@ import mozilla.components.ui.colors.PhotonColors
import org.mozilla.fenix.R
import org.mozilla.fenix.components.components
import org.mozilla.fenix.compose.Image
import org.mozilla.fenix.compose.PrimaryText
import org.mozilla.fenix.compose.SecondaryText
import org.mozilla.fenix.compose.ThumbnailCard
import org.mozilla.fenix.home.recenttabs.RecentTab
import org.mozilla.fenix.theme.FirefoxTheme
@ -149,8 +147,9 @@ private fun RecentTabItem(
modifier = Modifier.fillMaxSize(),
verticalArrangement = Arrangement.SpaceBetween
) {
PrimaryText(
Text(
text = tab.state.content.title.ifEmpty { tab.state.content.url },
color = FirefoxTheme.colors.textPrimary,
fontSize = 14.sp,
maxLines = 2,
overflow = TextOverflow.Ellipsis,
@ -165,8 +164,9 @@ private fun RecentTabItem(
Spacer(modifier = Modifier.width(8.dp))
SecondaryText(
Text(
text = tab.state.content.url,
color = FirefoxTheme.colors.textSecondary,
fontSize = 12.sp,
overflow = TextOverflow.Ellipsis,
maxLines = 1,
@ -225,8 +225,9 @@ private fun RecentSearchGroupItem(
modifier = Modifier.fillMaxSize(),
verticalArrangement = Arrangement.SpaceBetween
) {
PrimaryText(
Text(
text = stringResource(R.string.recent_tabs_search_term, searchTerm),
color = FirefoxTheme.colors.textPrimary,
fontSize = 14.sp,
overflow = TextOverflow.Ellipsis,
maxLines = 2,
@ -245,8 +246,9 @@ private fun RecentSearchGroupItem(
Spacer(modifier = Modifier.width(8.dp))
SecondaryText(
Text(
text = stringResource(R.string.recent_tabs_search_term_count_2, count),
color = FirefoxTheme.colors.textSecondary,
fontSize = 12.sp,
overflow = TextOverflow.Ellipsis,
maxLines = 1,

View File

@ -21,6 +21,7 @@ import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.Card
import androidx.compose.material.Icon
import androidx.compose.material.IconButton
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
@ -38,8 +39,6 @@ import androidx.compose.ui.unit.sp
import mozilla.components.browser.state.state.ContentState
import mozilla.components.browser.state.state.TabSessionState
import org.mozilla.fenix.R
import org.mozilla.fenix.compose.PrimaryText
import org.mozilla.fenix.compose.SecondaryText
import org.mozilla.fenix.compose.button.TextButton
import org.mozilla.fenix.compose.list.ExpandableListHeader
import org.mozilla.fenix.compose.list.FaviconListItem
@ -186,8 +185,9 @@ private fun InactiveTabsAutoClosePrompt(
Row(
verticalAlignment = Alignment.CenterVertically,
) {
PrimaryText(
Text(
text = stringResource(R.string.tab_tray_inactive_auto_close_title),
color = FirefoxTheme.colors.textPrimary,
modifier = Modifier.weight(1f),
fontSize = 14.sp,
fontFamily = FontFamily(Font(R.font.metropolis_semibold)),
@ -206,11 +206,12 @@ private fun InactiveTabsAutoClosePrompt(
}
}
SecondaryText(
Text(
text = stringResource(
R.string.tab_tray_inactive_auto_close_body_2,
stringResource(R.string.app_name)
),
color = FirefoxTheme.colors.textSecondary,
modifier = Modifier.fillMaxWidth(),
fontSize = 14.sp,
)

View File

@ -22,6 +22,7 @@ import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.material.Divider
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.runtime.toMutableStateList
@ -34,8 +35,6 @@ import androidx.compose.ui.unit.sp
import mozilla.components.browser.storage.sync.TabEntry
import mozilla.components.feature.syncedtabs.view.SyncedTabsView
import org.mozilla.fenix.R
import org.mozilla.fenix.compose.PrimaryText
import org.mozilla.fenix.compose.SecondaryText
import org.mozilla.fenix.compose.button.PrimaryButton
import org.mozilla.fenix.compose.ext.dashedBorder
import org.mozilla.fenix.compose.list.ExpandableListHeader
@ -202,8 +201,9 @@ fun SyncedTabsErrorItem(
.padding(all = 16.dp)
.fillMaxWidth()
) {
PrimaryText(
Text(
text = errorText,
color = FirefoxTheme.colors.textPrimary,
modifier = Modifier.fillMaxWidth(),
fontSize = 14.sp
)
@ -226,8 +226,9 @@ fun SyncedTabsErrorItem(
*/
@Composable
fun SyncedTabsNoTabsItem() {
SecondaryText(
Text(
text = stringResource(R.string.synced_tabs_no_open_tabs),
color = FirefoxTheme.colors.textSecondary,
modifier = Modifier
.padding(horizontal = 16.dp, vertical = 8.dp)
.fillMaxWidth(),