Bug 1816556 - Add functionality for the share button in the multi selection banner

fenix/115.2.0
Alexandru2909 1 year ago committed by mergify[bot]
parent 83eba3cd89
commit d6d02d094d

@ -19,7 +19,6 @@ import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue import androidx.compose.runtime.setValue
import androidx.compose.runtime.toMutableStateList import androidx.compose.runtime.toMutableStateList
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip import androidx.compose.ui.draw.clip
import androidx.compose.ui.input.nestedscroll.nestedScroll import androidx.compose.ui.input.nestedscroll.nestedScroll
@ -74,8 +73,10 @@ import mozilla.components.browser.storage.sync.Tab as SyncTab
* @param onSyncedTabClick Invoked when the user clicks on a synced tab. * @param onSyncedTabClick Invoked when the user clicks on a synced tab.
* @param onSaveToCollectionClick Invoked when the user clicks on the save to collection button from * @param onSaveToCollectionClick Invoked when the user clicks on the save to collection button from
* the multi select banner. * the multi select banner.
* @param onShareSelectedTabsClick Invoked when the user clicks on the share button from the
* multi select banner.
*/ */
@OptIn(ExperimentalPagerApi::class, ExperimentalComposeUiApi::class) @OptIn(ExperimentalPagerApi::class)
@Suppress("LongMethod", "LongParameterList", "ComplexMethod") @Suppress("LongMethod", "LongParameterList", "ComplexMethod")
@Composable @Composable
fun TabsTray( fun TabsTray(
@ -100,6 +101,7 @@ fun TabsTray(
onInactiveTabClose: (TabSessionState) -> Unit, onInactiveTabClose: (TabSessionState) -> Unit,
onSyncedTabClick: (SyncTab) -> Unit, onSyncedTabClick: (SyncTab) -> Unit,
onSaveToCollectionClick: () -> Unit, onSaveToCollectionClick: () -> Unit,
onShareSelectedTabsClick: () -> Unit,
) { ) {
val normalTabCount = browserStore val normalTabCount = browserStore
.observeAsComposableState { state -> state.normalTabs.size }.value ?: 0 .observeAsComposableState { state -> state.normalTabs.size }.value ?: 0
@ -143,6 +145,7 @@ fun TabsTray(
onTabPageIndicatorClicked = onTabPageClick, onTabPageIndicatorClicked = onTabPageClick,
onExitSelectModeClick = { tabsTrayStore.dispatch(TabsTrayAction.ExitSelectMode) }, onExitSelectModeClick = { tabsTrayStore.dispatch(TabsTrayAction.ExitSelectMode) },
onSaveToCollectionClick = onSaveToCollectionClick, onSaveToCollectionClick = onSaveToCollectionClick,
onShareSelectedTabsClick = onShareSelectedTabsClick,
) )
} }
@ -496,6 +499,7 @@ private fun TabsTrayPreviewRoot(
onInactiveTabClose = inactiveTabsState::remove, onInactiveTabClose = inactiveTabsState::remove,
onSyncedTabClick = {}, onSyncedTabClick = {},
onSaveToCollectionClick = {}, onSaveToCollectionClick = {},
onShareSelectedTabsClick = {},
) )
} }
} }

@ -65,6 +65,7 @@ private val ICON_SIZE = 24.dp
* multi select banner. * multi select banner.
* @param onSaveToCollectionClick Invoked when the user clicks on the save to collection button from * @param onSaveToCollectionClick Invoked when the user clicks on the save to collection button from
* the multi select banner. * the multi select banner.
* @param onShareSelectedTabsClick Invoked when the user clicks on the share button from the multi select banner.
*/ */
@Suppress("LongParameterList") @Suppress("LongParameterList")
@Composable @Composable
@ -76,6 +77,7 @@ fun TabsTrayBanner(
onTabPageIndicatorClicked: (Page) -> Unit, onTabPageIndicatorClicked: (Page) -> Unit,
onExitSelectModeClick: () -> Unit, onExitSelectModeClick: () -> Unit,
onSaveToCollectionClick: () -> Unit, onSaveToCollectionClick: () -> Unit,
onShareSelectedTabsClick: () -> Unit,
) { ) {
if (selectMode is TabsTrayState.Mode.Select) { if (selectMode is TabsTrayState.Mode.Select) {
MultiSelectBanner( MultiSelectBanner(
@ -83,6 +85,7 @@ fun TabsTrayBanner(
shouldShowInactiveButton = isInDebugMode, shouldShowInactiveButton = isInDebugMode,
onExitSelectModeClick = onExitSelectModeClick, onExitSelectModeClick = onExitSelectModeClick,
onSaveToCollectionsClick = onSaveToCollectionClick, onSaveToCollectionsClick = onSaveToCollectionClick,
onShareSelectedTabs = onShareSelectedTabsClick,
) )
} else { } else {
SingleSelectBanner( SingleSelectBanner(
@ -227,6 +230,7 @@ private fun NormalTabsTabIcon(normalTabCount: Int) {
* @param shouldShowInactiveButton Whether or not to show the inactive tabs menu item. * @param shouldShowInactiveButton Whether or not to show the inactive tabs menu item.
* @param onExitSelectModeClick Invoked when the user clicks on exit select mode button. * @param onExitSelectModeClick Invoked when the user clicks on exit select mode button.
* @param onSaveToCollectionsClick Invoked when the user clicks on the save to collection button. * @param onSaveToCollectionsClick Invoked when the user clicks on the save to collection button.
* @param onShareSelectedTabs Invoked when the user clicks on the share button.
*/ */
@Suppress("LongMethod") @Suppress("LongMethod")
@Composable @Composable
@ -235,6 +239,7 @@ private fun MultiSelectBanner(
shouldShowInactiveButton: Boolean, shouldShowInactiveButton: Boolean,
onExitSelectModeClick: () -> Unit, onExitSelectModeClick: () -> Unit,
onSaveToCollectionsClick: () -> Unit, onSaveToCollectionsClick: () -> Unit,
onShareSelectedTabs: () -> Unit,
) { ) {
var showMenu by remember { mutableStateOf(false) } var showMenu by remember { mutableStateOf(false) }
val menuItems = mutableListOf( val menuItems = mutableListOf(
@ -288,7 +293,7 @@ private fun MultiSelectBanner(
) )
} }
IconButton(onClick = {}) { IconButton(onClick = onShareSelectedTabs) {
Icon( Icon(
painter = painterResource(id = R.drawable.ic_share), painter = painterResource(id = R.drawable.ic_share),
contentDescription = stringResource( contentDescription = stringResource(
@ -376,6 +381,7 @@ private fun TabsTrayBannerPreviewRoot(
}, },
onExitSelectModeClick = { selectModeState = TabsTrayState.Mode.Normal }, onExitSelectModeClick = { selectModeState = TabsTrayState.Mode.Normal },
onSaveToCollectionClick = {}, onSaveToCollectionClick = {},
onShareSelectedTabsClick = {},
) )
} }
} }

@ -259,6 +259,7 @@ class TabsTrayFragment : AppCompatDialogFragment() {
onInactiveTabClose = tabsTrayInteractor::onInactiveTabClosed, onInactiveTabClose = tabsTrayInteractor::onInactiveTabClosed,
onSyncedTabClick = tabsTrayInteractor::onSyncedTabClicked, onSyncedTabClick = tabsTrayInteractor::onSyncedTabClicked,
onSaveToCollectionClick = tabsTrayInteractor::onAddSelectedTabsToCollectionClicked, onSaveToCollectionClick = tabsTrayInteractor::onAddSelectedTabsToCollectionClicked,
onShareSelectedTabsClick = tabsTrayInteractor::onShareSelectedTabs,
) )
} }
} }

Loading…
Cancel
Save