Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 613d9a5e authored by Ioana Alexandru's avatar Ioana Alexandru
Browse files

[Compose Notifs] Use TopLineText in collapsed notifs

Handle the inclusion of the title in the top line for collapsed
notifications. Also handle the case when the title might be null.

Bug: 431222735
Test: manual in the Gallery app
Flag: EXEMPT not production code yet
Change-Id: Iac2fcaad6b82ab6f96685053eeb9637c8c8d790d
parent 71331759
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -66,6 +66,7 @@ internal fun ExpandedText(content: String, maxLines: Int, modifier: Modifier = M
@Composable
internal fun TopLineText(
    modifier: Modifier = Modifier,
    title: String? = null,
    appNameText: String? = null,
    headerTextSecondary: String? = null,
    headerText: String? = null,
@@ -87,9 +88,12 @@ internal fun TopLineText(
            }
        }

        // TODO: b/431222735 - Add a title with a separate style.
        if (appNameText != null) {
        if (title != null) {
            isFirstElement = false
            Title(title, Modifier.shrinkable(importance = 5, minWidth = reducedWidth))
        }
        if (appNameText != null) {
            maybeAddSeparator()
            TopLineComponentText(
                text = appNameText,
                modifier = Modifier.shrinkable(importance = 1, minWidth = reducedWidth),
+16 −2
Original line number Diff line number Diff line
@@ -42,7 +42,19 @@ public fun NotificationContent(viewModel: NotificationViewModel, modifier: Modif
    if (!viewModel.isExpanded) {
        NotificationRow(
            viewModel,
            firstLine = { Title(viewModel.title) },
            firstLine = {
                TopLineText(
                    modifier = Modifier.padding(vertical = 2.dp),
                    title = viewModel.title,
                    // When collapsed, app name is only shown when there is no title
                    appNameText = if (viewModel.title == null) viewModel.appName else null,
                    headerTextSecondary = viewModel.headerTextSecondary,
                    headerText = viewModel.headerText,
                    // TODO: b/431222735 - Implement time/chronometer logic.
                    timeText = "now",
                    verificationText = viewModel.verificationText,
                )
            },
            secondLine = { viewModel.text?.let { CollapsedText(it) } },
            modifier,
        )
@@ -60,7 +72,9 @@ public fun NotificationContent(viewModel: NotificationViewModel, modifier: Modif
                    verificationText = viewModel.verificationText,
                )
            },
            secondLine = { Title(viewModel.title) },
            // TODO: b/431222735 - Consider showing the expanded text here when there is no title.
            //  this would require a mechanism for getting the text to wrap around the large icon.
            secondLine = { Title(viewModel.title ?: "") },
            modifier,
        ) {
            viewModel.text?.let { ExpandedText(it, maxLines = viewModel.maxLinesWhenExpanded) }
+1 −1
Original line number Diff line number Diff line
@@ -33,7 +33,7 @@ public interface NotificationViewModel {

    // TODO: b/431222735 - Make this nullable once we implement the top line fields.
    /** The title of the notification, emphasized in the content. */
    public val title: String
    public val title: String?
    /** The content text of the notification, shown below the title. */
    public val text: String?