This repository has been archived by the owner on Sep 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Blocks and mutes list part 2 - Created and populated blocks list scre…
…en with api result (#285) I've been reading the [API guidelines for compose](https://android.googlesource.com/platform/frameworks/support/+/androidx-main/compose/docs/compose-component-api-guidelines.md#component_s-purpose), and I've tried to implement a few suggestions in this PR: - Created separate named styled text composables (see `SmallTextLabel`, `LargeTextTitle`, etc.) instead of manually always needing to pass in style to emulate "building blocks" described in docs - Started updating parameter order - Added modifier to all components (as the first optional param always) - Tried to give each component only one problem to solve - Updated `QuickAccountView` with a button slot (and other guidelines)
- Loading branch information
1 parent
971f0a3
commit 20057d2
Showing
18 changed files
with
745 additions
and
55 deletions.
There are no files selected for viewing
135 changes: 135 additions & 0 deletions
135
core/designsystem/src/main/java/org/mozilla/social/core/designsystem/component/TextBody.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
package org.mozilla.social.core.designsystem.component | ||
|
||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.graphics.Color | ||
import androidx.compose.ui.text.TextLayoutResult | ||
import androidx.compose.ui.text.font.FontFamily | ||
import androidx.compose.ui.text.font.FontStyle | ||
import androidx.compose.ui.text.font.FontWeight | ||
import androidx.compose.ui.text.style.TextAlign | ||
import androidx.compose.ui.text.style.TextDecoration | ||
import androidx.compose.ui.text.style.TextOverflow | ||
import androidx.compose.ui.unit.TextUnit | ||
import org.mozilla.social.core.designsystem.theme.MoSoTheme | ||
|
||
@Composable | ||
fun SmallTextBody( | ||
text: String, | ||
modifier: Modifier = Modifier, | ||
color: Color = Color.Unspecified, | ||
fontSize: TextUnit = TextUnit.Unspecified, | ||
fontStyle: FontStyle? = null, | ||
fontWeight: FontWeight? = null, | ||
fontFamily: FontFamily? = null, | ||
letterSpacing: TextUnit = TextUnit.Unspecified, | ||
textDecoration: TextDecoration? = null, | ||
textAlign: TextAlign? = null, | ||
lineHeight: TextUnit = TextUnit.Unspecified, | ||
overflow: TextOverflow = TextOverflow.Clip, | ||
softWrap: Boolean = true, | ||
maxLines: Int = Int.MAX_VALUE, | ||
minLines: Int = 1, | ||
onTextLayout: (TextLayoutResult) -> Unit = {}, | ||
) { | ||
Text( | ||
text = text, | ||
modifier = modifier, | ||
color = color, | ||
fontSize = fontSize, | ||
fontStyle = fontStyle, | ||
fontWeight = fontWeight, | ||
fontFamily = fontFamily, | ||
letterSpacing = letterSpacing, | ||
textDecoration = textDecoration, | ||
textAlign = textAlign, | ||
lineHeight = lineHeight, | ||
overflow = overflow, | ||
softWrap = softWrap, | ||
maxLines = maxLines, | ||
minLines = minLines, | ||
onTextLayout = onTextLayout, | ||
style = MoSoTheme.typography.bodySmall, | ||
) | ||
} | ||
|
||
@Composable | ||
fun MediumTextBody( | ||
text: String, | ||
modifier: Modifier = Modifier, | ||
color: Color = Color.Unspecified, | ||
fontSize: TextUnit = TextUnit.Unspecified, | ||
fontStyle: FontStyle? = null, | ||
fontWeight: FontWeight? = null, | ||
fontFamily: FontFamily? = null, | ||
letterSpacing: TextUnit = TextUnit.Unspecified, | ||
textDecoration: TextDecoration? = null, | ||
textAlign: TextAlign? = null, | ||
lineHeight: TextUnit = TextUnit.Unspecified, | ||
overflow: TextOverflow = TextOverflow.Clip, | ||
softWrap: Boolean = true, | ||
maxLines: Int = Int.MAX_VALUE, | ||
minLines: Int = 1, | ||
onTextLayout: (TextLayoutResult) -> Unit = {}, | ||
) { | ||
Text( | ||
text = text, | ||
modifier = modifier, | ||
color = color, | ||
fontSize = fontSize, | ||
fontStyle = fontStyle, | ||
fontWeight = fontWeight, | ||
fontFamily = fontFamily, | ||
letterSpacing = letterSpacing, | ||
textDecoration = textDecoration, | ||
textAlign = textAlign, | ||
lineHeight = lineHeight, | ||
overflow = overflow, | ||
softWrap = softWrap, | ||
maxLines = maxLines, | ||
minLines = minLines, | ||
onTextLayout = onTextLayout, | ||
style = MoSoTheme.typography.bodyMedium, | ||
) | ||
} | ||
|
||
@Composable | ||
fun LargeTextBody( | ||
text: String, | ||
modifier: Modifier = Modifier, | ||
color: Color = Color.Unspecified, | ||
fontSize: TextUnit = TextUnit.Unspecified, | ||
fontStyle: FontStyle? = null, | ||
fontWeight: FontWeight? = null, | ||
fontFamily: FontFamily? = null, | ||
letterSpacing: TextUnit = TextUnit.Unspecified, | ||
textDecoration: TextDecoration? = null, | ||
textAlign: TextAlign? = null, | ||
lineHeight: TextUnit = TextUnit.Unspecified, | ||
overflow: TextOverflow = TextOverflow.Clip, | ||
softWrap: Boolean = true, | ||
maxLines: Int = Int.MAX_VALUE, | ||
minLines: Int = 1, | ||
onTextLayout: (TextLayoutResult) -> Unit = {}, | ||
) { | ||
Text( | ||
text = text, | ||
modifier = modifier, | ||
color = color, | ||
fontSize = fontSize, | ||
fontStyle = fontStyle, | ||
fontWeight = fontWeight, | ||
fontFamily = fontFamily, | ||
letterSpacing = letterSpacing, | ||
textDecoration = textDecoration, | ||
textAlign = textAlign, | ||
lineHeight = lineHeight, | ||
overflow = overflow, | ||
softWrap = softWrap, | ||
maxLines = maxLines, | ||
minLines = minLines, | ||
onTextLayout = onTextLayout, | ||
style = MoSoTheme.typography.bodyLarge, | ||
) | ||
} |
135 changes: 135 additions & 0 deletions
135
.../designsystem/src/main/java/org/mozilla/social/core/designsystem/component/TextDisplay.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
package org.mozilla.social.core.designsystem.component | ||
|
||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.graphics.Color | ||
import androidx.compose.ui.text.TextLayoutResult | ||
import androidx.compose.ui.text.font.FontFamily | ||
import androidx.compose.ui.text.font.FontStyle | ||
import androidx.compose.ui.text.font.FontWeight | ||
import androidx.compose.ui.text.style.TextAlign | ||
import androidx.compose.ui.text.style.TextDecoration | ||
import androidx.compose.ui.text.style.TextOverflow | ||
import androidx.compose.ui.unit.TextUnit | ||
import org.mozilla.social.core.designsystem.theme.MoSoTheme | ||
|
||
@Composable | ||
fun SmallTextDisplay( | ||
text: String, | ||
modifier: Modifier = Modifier, | ||
color: Color = Color.Unspecified, | ||
fontSize: TextUnit = TextUnit.Unspecified, | ||
fontStyle: FontStyle? = null, | ||
fontWeight: FontWeight? = null, | ||
fontFamily: FontFamily? = null, | ||
letterSpacing: TextUnit = TextUnit.Unspecified, | ||
textDecoration: TextDecoration? = null, | ||
textAlign: TextAlign? = null, | ||
lineHeight: TextUnit = TextUnit.Unspecified, | ||
overflow: TextOverflow = TextOverflow.Clip, | ||
softWrap: Boolean = true, | ||
maxLines: Int = Int.MAX_VALUE, | ||
minLines: Int = 1, | ||
onTextLayout: (TextLayoutResult) -> Unit = {}, | ||
) { | ||
Text( | ||
text = text, | ||
modifier = modifier, | ||
color = color, | ||
fontSize = fontSize, | ||
fontStyle = fontStyle, | ||
fontWeight = fontWeight, | ||
fontFamily = fontFamily, | ||
letterSpacing = letterSpacing, | ||
textDecoration = textDecoration, | ||
textAlign = textAlign, | ||
lineHeight = lineHeight, | ||
overflow = overflow, | ||
softWrap = softWrap, | ||
maxLines = maxLines, | ||
minLines = minLines, | ||
onTextLayout = onTextLayout, | ||
style = MoSoTheme.typography.displaySmall, | ||
) | ||
} | ||
|
||
@Composable | ||
fun MediumTextDisplay( | ||
text: String, | ||
modifier: Modifier = Modifier, | ||
color: Color = Color.Unspecified, | ||
fontSize: TextUnit = TextUnit.Unspecified, | ||
fontStyle: FontStyle? = null, | ||
fontWeight: FontWeight? = null, | ||
fontFamily: FontFamily? = null, | ||
letterSpacing: TextUnit = TextUnit.Unspecified, | ||
textDecoration: TextDecoration? = null, | ||
textAlign: TextAlign? = null, | ||
lineHeight: TextUnit = TextUnit.Unspecified, | ||
overflow: TextOverflow = TextOverflow.Clip, | ||
softWrap: Boolean = true, | ||
maxLines: Int = Int.MAX_VALUE, | ||
minLines: Int = 1, | ||
onTextLayout: (TextLayoutResult) -> Unit = {}, | ||
) { | ||
Text( | ||
text = text, | ||
modifier = modifier, | ||
color = color, | ||
fontSize = fontSize, | ||
fontStyle = fontStyle, | ||
fontWeight = fontWeight, | ||
fontFamily = fontFamily, | ||
letterSpacing = letterSpacing, | ||
textDecoration = textDecoration, | ||
textAlign = textAlign, | ||
lineHeight = lineHeight, | ||
overflow = overflow, | ||
softWrap = softWrap, | ||
maxLines = maxLines, | ||
minLines = minLines, | ||
onTextLayout = onTextLayout, | ||
style = MoSoTheme.typography.displayMedium, | ||
) | ||
} | ||
|
||
@Composable | ||
fun LargeTextDisplay( | ||
text: String, | ||
modifier: Modifier = Modifier, | ||
color: Color = Color.Unspecified, | ||
fontSize: TextUnit = TextUnit.Unspecified, | ||
fontStyle: FontStyle? = null, | ||
fontWeight: FontWeight? = null, | ||
fontFamily: FontFamily? = null, | ||
letterSpacing: TextUnit = TextUnit.Unspecified, | ||
textDecoration: TextDecoration? = null, | ||
textAlign: TextAlign? = null, | ||
lineHeight: TextUnit = TextUnit.Unspecified, | ||
overflow: TextOverflow = TextOverflow.Clip, | ||
softWrap: Boolean = true, | ||
maxLines: Int = Int.MAX_VALUE, | ||
minLines: Int = 1, | ||
onTextLayout: (TextLayoutResult) -> Unit = {}, | ||
) { | ||
Text( | ||
text = text, | ||
modifier = modifier, | ||
color = color, | ||
fontSize = fontSize, | ||
fontStyle = fontStyle, | ||
fontWeight = fontWeight, | ||
fontFamily = fontFamily, | ||
letterSpacing = letterSpacing, | ||
textDecoration = textDecoration, | ||
textAlign = textAlign, | ||
lineHeight = lineHeight, | ||
overflow = overflow, | ||
softWrap = softWrap, | ||
maxLines = maxLines, | ||
minLines = minLines, | ||
onTextLayout = onTextLayout, | ||
style = MoSoTheme.typography.displayLarge, | ||
) | ||
} |
Oops, something went wrong.