Skip to content

Commit 50e3651

Browse files
authored
Support voice scroll commands (#2234)
Fixes https://youtrack.jetbrains.com/issue/CMP-7952/iOS-A11y.-Voice-Control.-Scroll-Up-Down-doesnt-work ## Release Notes ### Features - iOS - Support scroll commands with Voice Control
1 parent ea4c7a4 commit 50e3651

File tree

5 files changed

+81
-1
lines changed

5 files changed

+81
-1
lines changed

compose/ui/ui-uikit/src/uikitMain/objc/CMPUIKitUtils/CMPUIKitUtils.xcodeproj/project.pbxproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10+
991A97F72E1FB99300B47130 /* CMPScrollView.m in Sources */ = {isa = PBXBuildFile; fileRef = 991A97F62E1FB99300B47130 /* CMPScrollView.m */; };
1011
9968C35B2D76FE16005E8DE4 /* CMPPanGestureRecognizer.m in Sources */ = {isa = PBXBuildFile; fileRef = 9968C35A2D76FE16005E8DE4 /* CMPPanGestureRecognizer.m */; };
1112
9968C3612D7746BD005E8DE4 /* CMPHoverGestureHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = 9968C3602D7746BD005E8DE4 /* CMPHoverGestureHandler.m */; };
1213
9968C38B2D7892DF005E8DE4 /* CMPScreenEdgePanGestureRecognizer.m in Sources */ = {isa = PBXBuildFile; fileRef = 9968C38A2D7892DF005E8DE4 /* CMPScreenEdgePanGestureRecognizer.m */; };
@@ -63,6 +64,8 @@
6364
/* End PBXCopyFilesBuildPhase section */
6465

6566
/* Begin PBXFileReference section */
67+
991A97F52E1FB99300B47130 /* CMPScrollView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CMPScrollView.h; sourceTree = "<group>"; };
68+
991A97F62E1FB99300B47130 /* CMPScrollView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CMPScrollView.m; sourceTree = "<group>"; };
6669
9968C3592D76FE16005E8DE4 /* CMPPanGestureRecognizer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CMPPanGestureRecognizer.h; sourceTree = "<group>"; };
6770
9968C35A2D76FE16005E8DE4 /* CMPPanGestureRecognizer.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CMPPanGestureRecognizer.m; sourceTree = "<group>"; };
6871
9968C35F2D7746BD005E8DE4 /* CMPHoverGestureHandler.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CMPHoverGestureHandler.h; sourceTree = "<group>"; };
@@ -142,6 +145,8 @@
142145
EADD02922C98484F003F66E8 /* CMPDropInteractionProxy.m */,
143146
99D97A862BF73A9B0035552B /* CMPEditMenuView.h */,
144147
99D97A872BF73A9B0035552B /* CMPEditMenuView.m */,
148+
991A97F52E1FB99300B47130 /* CMPScrollView.h */,
149+
991A97F62E1FB99300B47130 /* CMPScrollView.m */,
145150
EA4B52942C2EDEF200FBB55C /* CMPGestureRecognizer.h */,
146151
EA4B52952C2EDEF200FBB55C /* CMPGestureRecognizer.m */,
147152
9968C35F2D7746BD005E8DE4 /* CMPHoverGestureHandler.h */,
@@ -342,6 +347,7 @@
342347
9968C38B2D7892DF005E8DE4 /* CMPScreenEdgePanGestureRecognizer.m in Sources */,
343348
EAB33E182C12E746002CFF44 /* CMPMetalDrawablesHandler.m in Sources */,
344349
9968C35B2D76FE16005E8DE4 /* CMPPanGestureRecognizer.m in Sources */,
350+
991A97F72E1FB99300B47130 /* CMPScrollView.m in Sources */,
345351
99D97A882BF73A9B0035552B /* CMPEditMenuView.m in Sources */,
346352
EABD912B2BC02B5F00455279 /* CMPInteropWrappingView.m in Sources */,
347353
EADD02902C9846D9003F66E8 /* CMPDragInteractionProxy.m in Sources */,
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* Copyright 2025 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#import <UIKit/UIKit.h>
18+
19+
@interface CMPScrollView : UIScrollView
20+
21+
- (BOOL)accessibilityScrollUpPageSupported;
22+
- (BOOL)accessibilityScrollDownPageSupported;
23+
- (BOOL)accessibilityScrollLeftPageSupported;
24+
- (BOOL)accessibilityScrollRightPageSupported;
25+
26+
@end
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* Copyright 2025 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#import "CMPScrollView.h"
18+
19+
@implementation CMPScrollView
20+
21+
// Private API methods that enable scroll commands.
22+
// The scroll command will be propagated as an accessibilityScroll
23+
// function call for the corresponding accessibility element.
24+
25+
- (BOOL)accessibilityScrollUpPageSupported {
26+
return YES;
27+
}
28+
29+
- (BOOL)accessibilityScrollDownPageSupported {
30+
return YES;
31+
}
32+
33+
- (BOOL)accessibilityScrollLeftPageSupported {
34+
return YES;
35+
}
36+
37+
- (BOOL)accessibilityScrollRightPageSupported {
38+
return YES;
39+
}
40+
41+
@end

compose/ui/ui-uikit/src/uikitMain/objc/CMPUIKitUtils/CMPUIKitUtils/CMPUIKitUtils.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,4 @@ FOUNDATION_EXPORT const unsigned char CMPUIKitUtilsVersionString[];
3333
#import "CMPPanGestureRecognizer.h"
3434
#import "CMPHoverGestureHandler.h"
3535
#import "CMPScreenEdgePanGestureRecognizer.h"
36+
#import "CMPScrollView.h"

compose/ui/ui/src/uikitMain/kotlin/androidx/compose/ui/scene/UIKitTransparentContainerView.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,18 @@ import platform.CoreGraphics.CGRectIsEmpty
2323
import platform.CoreGraphics.CGRectZero
2424
import platform.UIKit.UIEvent
2525
import platform.UIKit.UIView
26+
import androidx.compose.ui.uikit.utils.CMPScrollView
2627

2728
internal class UIKitTransparentContainerView(
2829
var onLayoutSubviews: () -> Unit = {}
29-
) : UIView(CGRectZero.readValue()) {
30+
) : CMPScrollView(CGRectZero.readValue()) {
3031
private var onAppeared: (() -> Unit)? = null
3132

33+
init {
34+
panGestureRecognizer.setEnabled(false)
35+
bounces = false
36+
}
37+
3238
fun runOnceOnAppeared(block: () -> Unit) {
3339
onAppeared = {
3440
block()

0 commit comments

Comments
 (0)