Bug 1885580 - Add a MenuGroup component for the menu redesign r=android-reviewers,007
[gecko.git] / mobile / android / fenix / app / src / main / java / org / mozilla / fenix / components / menu / compose / MenuGroup.kt
blobd46532f2f3bea0debd261e493203e06bdde5422f
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2  * License, v. 2.0. If a copy of the MPL was not distributed with this
3  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 package org.mozilla.fenix.components.menu.compose
7 import androidx.compose.foundation.BorderStroke
8 import androidx.compose.foundation.background
9 import androidx.compose.foundation.border
10 import androidx.compose.foundation.layout.Column
11 import androidx.compose.foundation.layout.padding
12 import androidx.compose.foundation.shape.RoundedCornerShape
13 import androidx.compose.runtime.Composable
14 import androidx.compose.ui.Modifier
15 import androidx.compose.ui.res.painterResource
16 import androidx.compose.ui.res.stringResource
17 import androidx.compose.ui.unit.dp
18 import org.mozilla.fenix.R
19 import org.mozilla.fenix.compose.Divider
20 import org.mozilla.fenix.compose.annotation.LightDarkPreview
21 import org.mozilla.fenix.compose.list.IconListItem
22 import org.mozilla.fenix.theme.FirefoxTheme
24 private val ROUNDED_CORNER_SHAPE = RoundedCornerShape(12.dp)
26 /**
27  * A menu group container.
28  *
29  * @param content The children composable to be laid out.
30  */
31 @Composable
32 internal fun MenuGroup(content: @Composable () -> Unit) {
33     Column(
34         modifier = Modifier
35             .background(
36                 color = FirefoxTheme.colors.layer2,
37                 shape = ROUNDED_CORNER_SHAPE,
38             )
39             .border(
40                 border = BorderStroke(
41                     width = 0.5.dp,
42                     color = FirefoxTheme.colors.borderPrimary,
43                 ),
44                 shape = ROUNDED_CORNER_SHAPE,
45             ),
46     ) {
47         content()
48     }
51 @LightDarkPreview
52 @Composable
53 private fun MenuGroupPreview() {
54     FirefoxTheme {
55         Column(
56             modifier = Modifier
57                 .background(color = FirefoxTheme.colors.layer3)
58                 .padding(16.dp),
59         ) {
60             MenuGroup {
61                 IconListItem(
62                     label = stringResource(id = R.string.browser_menu_add_to_homescreen),
63                     beforeIconPainter = painterResource(id = R.drawable.mozac_ic_plus_24),
64                 )
66                 Divider(color = FirefoxTheme.colors.borderSecondary)
68                 IconListItem(
69                     label = stringResource(id = R.string.browser_menu_add_to_homescreen),
70                     beforeIconPainter = painterResource(id = R.drawable.mozac_ic_plus_24),
71                 )
72             }
73         }
74     }