From 65f82199cb5c9c5302e244ecb1e0c2f729afde5d Mon Sep 17 00:00:00 2001 From: chunhtai <47866232+chunhtai@users.noreply.github.com> Date: Wed, 7 Jul 2021 11:59:41 -0700 Subject: [PATCH] Hides the scroll bar from UIScrollView (flutter/engine#27214) * Hides the scroll bar from UIScrollView * fix test --- .../ios/framework/Source/SemanticsObject.mm | 2 ++ .../framework/Source/SemanticsObjectTest.mm | 22 +++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/SemanticsObject.mm b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/SemanticsObject.mm index 1f213be05c..43adae730d 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/SemanticsObject.mm +++ b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/SemanticsObject.mm @@ -153,6 +153,8 @@ CGRect ConvertRectToGlobal(SemanticsObject* reference, CGRect local_rect) { if (self) { _semanticsObject = [semanticsObject retain]; [semanticsObject.bridge->view() addSubview:self]; + [self setShowsHorizontalScrollIndicator:NO]; + [self setShowsVerticalScrollIndicator:NO]; } return self; } diff --git a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/SemanticsObjectTest.mm b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/SemanticsObjectTest.mm index b037956120..61db2ac20e 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/SemanticsObjectTest.mm +++ b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/SemanticsObjectTest.mm @@ -370,6 +370,28 @@ class MockAccessibilityBridge : public AccessibilityBridgeIos { XCTAssertFalse(scrollable_object.isAccessibilityElement); } +- (void)testFlutterScrollableSemanticsObjectHidesScrollBar { + fml::WeakPtrFactory factory( + new flutter::MockAccessibilityBridge()); + fml::WeakPtr bridge = factory.GetWeakPtr(); + + flutter::SemanticsNode node; + node.flags = static_cast(flutter::SemanticsFlags::kHasImplicitScrolling); + node.actions = flutter::kHorizontalScrollSemanticsActions; + node.rect = SkRect::MakeXYWH(0, 0, 100, 200); + node.scrollExtentMax = 100.0; + node.scrollPosition = 0.0; + + FlutterSemanticsObject* delegate = [[FlutterSemanticsObject alloc] initWithBridge:bridge uid:0]; + FlutterScrollableSemanticsObject* scrollable = + [[FlutterScrollableSemanticsObject alloc] initWithSemanticsObject:delegate]; + SemanticsObject* scrollable_object = static_cast(scrollable); + [scrollable_object setSemanticsNode:&node]; + [scrollable_object accessibilityBridgeDidFinishUpdate]; + XCTAssertFalse(scrollable.showsHorizontalScrollIndicator); + XCTAssertFalse(scrollable.showsVerticalScrollIndicator); +} + - (void)testSemanticsObjectBuildsAttributedString { fml::WeakPtrFactory factory( new flutter::MockAccessibilityBridge());