|
5 | 5 | package mozilla.components.feature.summarize.ui |
6 | 6 |
|
7 | 7 | import androidx.compose.foundation.background |
| 8 | +import androidx.compose.foundation.isSystemInDarkTheme |
| 9 | +import androidx.compose.foundation.layout.Arrangement |
8 | 10 | import androidx.compose.foundation.layout.Box |
| 11 | +import androidx.compose.foundation.layout.Column |
9 | 12 | import androidx.compose.foundation.layout.fillMaxSize |
10 | 13 | import androidx.compose.foundation.layout.fillMaxWidth |
11 | 14 | import androidx.compose.foundation.layout.height |
12 | 15 | import androidx.compose.foundation.layout.padding |
| 16 | +import androidx.compose.foundation.layout.requiredHeight |
| 17 | +import androidx.compose.foundation.layout.requiredSize |
| 18 | +import androidx.compose.foundation.layout.size |
13 | 19 | import androidx.compose.foundation.shape.RoundedCornerShape |
| 20 | +import androidx.compose.material3.Icon |
14 | 21 | import androidx.compose.material3.MaterialTheme |
15 | 22 | import androidx.compose.material3.Surface |
16 | 23 | import androidx.compose.material3.Text |
17 | 24 | import androidx.compose.runtime.Composable |
18 | 25 | import androidx.compose.ui.Alignment |
19 | 26 | import androidx.compose.ui.Modifier |
| 27 | +import androidx.compose.ui.res.painterResource |
20 | 28 | import androidx.compose.ui.res.stringResource |
21 | 29 | import androidx.compose.ui.text.font.FontWeight |
22 | 30 | import androidx.compose.ui.text.style.TextAlign |
23 | | -import androidx.compose.ui.tooling.preview.Preview |
24 | 31 | import androidx.compose.ui.unit.dp |
25 | 32 | import androidx.compose.ui.unit.sp |
| 33 | +import mozilla.components.compose.base.annotation.FlexibleWindowLightDarkPreview |
| 34 | +import mozilla.components.compose.base.theme.AcornTheme |
26 | 35 | import mozilla.components.feature.summarize.R |
| 36 | +import mozilla.components.feature.summarize.ui.gradient.summaryLoadingGradient |
| 37 | +import mozilla.components.ui.icons.R as iconsR |
| 38 | + |
| 39 | +private const val DRAG_HANDLE_CORNER_RATIO = 50 |
27 | 40 |
|
28 | 41 | /** |
29 | 42 | * Content shown while a page summary is being generated. |
30 | | - * Displays the animated gradient background with centered loading text. |
| 43 | + * Displays a Firefox logo icon and loading text over the animated gradient background. |
31 | 44 | */ |
32 | 45 | @Composable |
33 | 46 | internal fun SummarizingContent( |
| 47 | + modifier: Modifier = Modifier, |
34 | 48 | title: String = stringResource(R.string.mozac_feature_summarize_loading_title), |
35 | 49 | ) { |
36 | | - Box( |
37 | | - contentAlignment = Alignment.Center, |
| 50 | + Column( |
| 51 | + modifier = modifier |
| 52 | + .fillMaxWidth() |
| 53 | + .padding(top = 80.dp), |
| 54 | + horizontalAlignment = Alignment.CenterHorizontally, |
| 55 | + verticalArrangement = Arrangement.spacedBy(10.dp), |
38 | 56 | ) { |
| 57 | + val contentColor = if (isSystemInDarkTheme()) { |
| 58 | + MaterialTheme.colorScheme.onSurface |
| 59 | + } else { |
| 60 | + MaterialTheme.colorScheme.onPrimary |
| 61 | + } |
| 62 | + |
| 63 | + Icon( |
| 64 | + painter = painterResource(id = iconsR.drawable.mozac_ic_logo_firefox_24), |
| 65 | + contentDescription = null, |
| 66 | + modifier = Modifier.size(48.dp), |
| 67 | + tint = contentColor, |
| 68 | + ) |
| 69 | + |
39 | 70 | Text( |
40 | 71 | text = title, |
41 | | - modifier = Modifier |
42 | | - .fillMaxWidth() |
43 | | - .padding(horizontal = 16.dp), |
44 | 72 | textAlign = TextAlign.Center, |
45 | | - color = MaterialTheme.colorScheme.onSurface, |
46 | | - fontSize = 20.sp, |
47 | | - fontWeight = FontWeight.Medium, |
48 | | - lineHeight = 24.sp, |
49 | | - letterSpacing = 0.15.sp, |
| 73 | + color = contentColor.copy(alpha = 0.5f), |
| 74 | + fontSize = 16.sp, |
| 75 | + fontWeight = FontWeight.SemiBold, |
| 76 | + lineHeight = 21.sp, |
| 77 | + letterSpacing = (-0.31).sp, |
50 | 78 | ) |
51 | 79 | } |
52 | 80 | } |
53 | 81 |
|
54 | | -@Preview(showBackground = true, heightDp = 800) |
| 82 | +@FlexibleWindowLightDarkPreview |
55 | 83 | @Composable |
56 | 84 | private fun SummarizingContentPreview() { |
57 | | - Box( |
58 | | - modifier = Modifier |
59 | | - .fillMaxSize() |
60 | | - .background(MaterialTheme.colorScheme.surfaceVariant), |
61 | | - contentAlignment = Alignment.BottomCenter, |
62 | | - ) { |
63 | | - Surface( |
| 85 | + AcornTheme { |
| 86 | + Box( |
64 | 87 | modifier = Modifier |
65 | | - .fillMaxWidth() |
66 | | - .height(400.dp), |
67 | | - shape = RoundedCornerShape(topStart = 28.dp, topEnd = 28.dp), |
| 88 | + .fillMaxSize() |
| 89 | + .background(MaterialTheme.colorScheme.surfaceVariant), |
| 90 | + contentAlignment = Alignment.BottomCenter, |
68 | 91 | ) { |
69 | | - SummarizingContent() |
| 92 | + Surface( |
| 93 | + modifier = Modifier |
| 94 | + .fillMaxWidth() |
| 95 | + .height(336.dp), |
| 96 | + shape = RoundedCornerShape(topStart = 28.dp, topEnd = 28.dp), |
| 97 | + ) { |
| 98 | + Box(modifier = Modifier.fillMaxSize().summaryLoadingGradient()) { |
| 99 | + Column(modifier = Modifier.fillMaxWidth()) { |
| 100 | + Box( |
| 101 | + modifier = Modifier.fillMaxWidth().requiredHeight(36.dp), |
| 102 | + contentAlignment = Alignment.Center, |
| 103 | + ) { |
| 104 | + Box( |
| 105 | + modifier = Modifier |
| 106 | + .requiredSize(width = 32.dp, height = 4.dp) |
| 107 | + .background( |
| 108 | + color = MaterialTheme.colorScheme.outline, |
| 109 | + shape = RoundedCornerShape(DRAG_HANDLE_CORNER_RATIO), |
| 110 | + ), |
| 111 | + ) |
| 112 | + } |
| 113 | + SummarizingContent() |
| 114 | + } |
| 115 | + } |
| 116 | + } |
70 | 117 | } |
71 | 118 | } |
72 | 119 | } |
0 commit comments