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.toMutableStateList
import androidx.compose.ui.Alignment
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
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 onSaveToCollectionClick Invoked when the user clicks on the save to collection button from
* 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")
@Composable
fun TabsTray(
@ -100,6 +101,7 @@ fun TabsTray(
onInactiveTabClose: (TabSessionState) -> Unit,
onSyncedTabClick: (SyncTab) -> Unit,
onSaveToCollectionClick: () -> Unit,
onShareSelectedTabsClick: () -> Unit,
) {
val normalTabCount = browserStore
.observeAsComposableState { state -> state.normalTabs.size }.value ?: 0
@ -143,6 +145,7 @@ fun TabsTray(
onTabPageIndicatorClicked = onTabPageClick,
onExitSelectModeClick = { tabsTrayStore.dispatch(TabsTrayAction.ExitSelectMode) },
onSaveToCollectionClick = onSaveToCollectionClick,
onShareSelectedTabsClick = onShareSelectedTabsClick,
)
}
@ -496,6 +499,7 @@ private fun TabsTrayPreviewRoot(
onInactiveTabClose = inactiveTabsState::remove,
onSyncedTabClick = {},
onSaveToCollectionClick = {},
onShareSelectedTabsClick = {},
)
}
}

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

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

Loading…
Cancel
Save