Skip to content

Commit

Permalink
iOS multitap selection in selection container (#984)
Browse files Browse the repository at this point in the history
## Proposed Changes

- Allow selecting text in Selection Container by double and triple tap
on the text like in textfields.

## Testing

Test: Open test app, go Components -> Selection, try to select text.

## Issues Fixed

Fixes:
https://youtrack.jetbrains.com/issue/COMPOSE-440/iOS-support-double-tap-text-selection-in-SelectionContainer

## Google CLA
You need to sign the Google Contributor’s License Agreement at
https://cla.developers.google.com/.
This is needed since we synchronise most of the code with Google’s AOSP
repository. Signing this agreement allows us to synchronise code from
your Pull Requests as well.

---------

Co-authored-by: dima.avdeev <dima.avdeev@jetbrains.com>
  • Loading branch information
mazunin-v-jb and dima-avdeev-jb committed Jan 29, 2024
1 parent 3e7e9ad commit 7d6901f
Show file tree
Hide file tree
Showing 7 changed files with 482 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,13 @@ internal class SelectionController(

// this is not chained, but is a standalone factory
@Suppress("ModifierFactoryExtensionFunction")
private fun SelectionRegistrar.makeSelectionModifier(
internal expect fun SelectionRegistrar.makeSelectionModifier(
selectableId: Long,
layoutCoordinates: () -> LayoutCoordinates?,
): Modifier

@Suppress("ModifierFactoryExtensionFunction")
internal fun SelectionRegistrar.makeDefaultSelectionModifier(
selectableId: Long,
layoutCoordinates: () -> LayoutCoordinates?,
): Modifier {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Copyright 2024 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package androidx.compose.foundation.text.modifiers

import androidx.compose.foundation.text.selection.SelectionRegistrar
import androidx.compose.ui.Modifier
import androidx.compose.ui.layout.LayoutCoordinates

internal actual fun SelectionRegistrar.makeSelectionModifier(
selectableId: Long,
layoutCoordinates: () -> LayoutCoordinates?
): Modifier = makeDefaultSelectionModifier(selectableId, layoutCoordinates)
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Copyright 2024 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package androidx.compose.foundation.text.modifiers

import androidx.compose.foundation.text.selection.SelectionRegistrar
import androidx.compose.ui.Modifier
import androidx.compose.ui.layout.LayoutCoordinates

internal actual fun SelectionRegistrar.makeSelectionModifier(
selectableId: Long,
layoutCoordinates: () -> LayoutCoordinates?
): Modifier = makeDefaultSelectionModifier(selectableId, layoutCoordinates)
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Copyright 2024 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package androidx.compose.foundation.text.modifiers

import androidx.compose.foundation.text.selection.SelectionRegistrar
import androidx.compose.ui.Modifier
import androidx.compose.ui.layout.LayoutCoordinates

internal actual fun SelectionRegistrar.makeSelectionModifier(
selectableId: Long,
layoutCoordinates: () -> LayoutCoordinates?
): Modifier = makeDefaultSelectionModifier(selectableId, layoutCoordinates)

0 comments on commit 7d6901f

Please sign in to comment.