Skip to content

Commit

Permalink
[ios platform view] fix overlay zPosition (#29930)
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Yang committed Dec 8, 2021
1 parent e32d04a commit 6981c04
Show file tree
Hide file tree
Showing 5 changed files with 234 additions and 75 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -575,15 +575,19 @@

if (platform_view_root.superview != flutter_view) {
[flutter_view addSubview:platform_view_root];
} else {
platform_view_root.layer.zPosition = zIndex++;
}
// Make sure the platform_view_root is higher than the last platform_view_root in
// composition_order_.
platform_view_root.layer.zPosition = zIndex++;

for (const std::shared_ptr<FlutterPlatformViewLayer>& layer : layers) {
if ([layer->overlay_view_wrapper superview] != flutter_view) {
if ([layer->overlay_view_wrapper.get() superview] != flutter_view) {
[flutter_view addSubview:layer->overlay_view_wrapper];
} else {
layer->overlay_view_wrapper.get().layer.zPosition = zIndex++;
}
// Make sure all the overlays are higher than the platform view.
layer->overlay_view_wrapper.get().layer.zPosition = zIndex++;
FML_DCHECK(layer->overlay_view_wrapper.get().layer.zPosition >
platform_view_root.layer.zPosition);
}
active_composition_order_.push_back(platform_view_id);
}
Expand Down
1 change: 1 addition & 0 deletions testing/scenario_app/ios/Scenarios/Scenarios/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ - (BOOL)application:(UIApplication*)application
@"--bogus-font-text" : @"bogus_font_text",
@"--spawn-engine-works" : @"spawn_engine_works",
@"--pointer-events" : @"pointer_events",
@"--platform-view-scrolling-under-widget" : @"platform_view_scrolling_under_widget"
};
__block NSString* flutterViewControllerTestName = nil;
[launchArgsMap
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,3 +257,40 @@ - (void)testPlatformViewWithContinuousTexture {
}

@end

@interface PlatformViewScrollingUnderWidget : XCTestCase

@end

@implementation PlatformViewScrollingUnderWidget

- (void)setUp {
[super setUp];
self.continueAfterFailure = NO;
}

- (void)testPlatformViewScrollingUnderWidget {
XCUIApplication* app = [[XCUIApplication alloc] init];
app.launchArguments =
@[ @"--platform-view-scrolling-under-widget", @"--with-continuous-texture" ];
[app launch];

XCUIElement* platformView = app.textViews.firstMatch;
BOOL exists = [platformView waitForExistenceWithTimeout:kSecondsToWaitForPlatformView];
if (!exists) {
XCTFail(@"It took longer than %@ second to find the platform view."
@"There might be issues with the platform view's construction,"
@"or with how the scenario is built.",
@(kSecondsToWaitForPlatformView));
}

// Wait and let the scenario app scroll a bit.
XCTWaiterResult waitResult = [XCTWaiter
waitForExpectations:@[ [[XCTestExpectation alloc] initWithDescription:@"Wait for 5 seconds"] ]
timeout:5];
// If the waiter is not interrupted, we know the app is in a valid state after timeout, thus the
// test passes.
XCTAssert(waitResult != XCTWaiterResultInterrupted);
}

@end
Loading

0 comments on commit 6981c04

Please sign in to comment.