From 3539cd3b1a846e7c6a235cc8609ae909ca79f59d Mon Sep 17 00:00:00 2001 From: Amir Hardon Date: Wed, 31 Oct 2018 16:15:42 -0700 Subject: [PATCH] Decode UIView's creation parameters and pass them to the view factory. (flutter/engine#6715) --- .../framework/Source/FlutterPlatformViews.mm | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm index 0f26dd93e7..2f4cefa84d 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm +++ b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm @@ -60,10 +60,21 @@ void FlutterPlatformViewsController::OnCreate(FlutterMethodCall* call, FlutterRe return; } - // TODO(amirh): decode and pass the creation args. - FlutterTouchInterceptingView* view = [[[FlutterTouchInterceptingView alloc] - initWithEmbeddedView:[factory createWithFrame:CGRectZero viewIdentifier:viewId arguments:nil] - flutterView:flutter_view_] autorelease]; + id params = nil; + if ([factory respondsToSelector:@selector(createArgsCodec)]) { + NSObject* codec = [factory createArgsCodec]; + if (codec != nil && args[@"params"] != nil) { + FlutterStandardTypedData* paramsData = args[@"params"]; + params = [codec decode:paramsData.data]; + } + } + + UIView* embedded_view = [factory createWithFrame:CGRectZero + viewIdentifier:viewId + arguments:params]; + FlutterTouchInterceptingView* view = + [[[FlutterTouchInterceptingView alloc] initWithEmbeddedView:embedded_view + flutterView:flutter_view_] autorelease]; views_[viewId] = fml::scoped_nsobject([view retain]); result(nil);