From 5b57c553bbc32315ba4abafb6c02f59d3c14d82e Mon Sep 17 00:00:00 2001 From: Dan Field Date: Wed, 17 Oct 2018 10:54:43 -0700 Subject: [PATCH 1/8] Allow FlutterViewController to specify whether its FlutterView is opaque --- .../darwin/ios/framework/Headers/FlutterViewController.h | 8 ++++++++ shell/platform/darwin/ios/framework/Source/FlutterView.mm | 2 +- .../darwin/ios/framework/Source/FlutterViewController.mm | 2 ++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/shell/platform/darwin/ios/framework/Headers/FlutterViewController.h b/shell/platform/darwin/ios/framework/Headers/FlutterViewController.h index 5459c17f4f8e6..1e2baeac89436 100644 --- a/shell/platform/darwin/ios/framework/Headers/FlutterViewController.h +++ b/shell/platform/darwin/ios/framework/Headers/FlutterViewController.h @@ -93,6 +93,14 @@ FLUTTER_EXPORT */ @property(strong, nonatomic) UIView* splashScreenView; +/** + * Controls whether the created view will be opaque or not. + * + * Default is `YES`. Note that setting this to `NO` may negatively impact performance + * when using hardware accelleration. + */ +@property() BOOL viewIsOpaque; + @end #endif // FLUTTER_FLUTTERVIEWCONTROLLER_H_ diff --git a/shell/platform/darwin/ios/framework/Source/FlutterView.mm b/shell/platform/darwin/ios/framework/Source/FlutterView.mm index 32c54f632992f..f40ac6f393ee7 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterView.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterView.mm @@ -45,11 +45,11 @@ - (void)layoutSubviews { if ([self.layer isKindOfClass:[CAEAGLLayer class]]) { CAEAGLLayer* layer = reinterpret_cast(self.layer); layer.allowsGroupOpacity = YES; - layer.opaque = YES; CGFloat screenScale = [UIScreen mainScreen].scale; layer.contentsScale = screenScale; layer.rasterizationScale = screenScale; } + self.layer.opaque = [self flutterViewController].viewIsOpaque; [super layoutSubviews]; } diff --git a/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm b/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm index 2e81213980423..80a47e89abe54 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm @@ -75,6 +75,8 @@ - (instancetype)initWithProject:(FlutterDartProject*)projectOrNil else _dartProject.reset([projectOrNil retain]); + self.viewIsOpaque = YES; + [self performCommonViewControllerInitialization]; } From a8a67dda6c785c307f65758df4fcc6c4ac3d5cba Mon Sep 17 00:00:00 2001 From: Dan Field Date: Wed, 17 Oct 2018 11:23:40 -0700 Subject: [PATCH 2/8] clang-format --- .../darwin/ios/framework/Headers/FlutterViewController.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shell/platform/darwin/ios/framework/Headers/FlutterViewController.h b/shell/platform/darwin/ios/framework/Headers/FlutterViewController.h index 1e2baeac89436..629967f6bfb42 100644 --- a/shell/platform/darwin/ios/framework/Headers/FlutterViewController.h +++ b/shell/platform/darwin/ios/framework/Headers/FlutterViewController.h @@ -95,7 +95,7 @@ FLUTTER_EXPORT /** * Controls whether the created view will be opaque or not. - * + * * Default is `YES`. Note that setting this to `NO` may negatively impact performance * when using hardware accelleration. */ From e751691b7fb8a8f7a05d09ebf816f163307881ab Mon Sep 17 00:00:00 2001 From: Dan Field Date: Wed, 17 Oct 2018 13:38:56 -0700 Subject: [PATCH 3/8] Make property dynamic --- .../framework/Headers/FlutterViewController.h | 5 +- .../darwin/ios/framework/Source/FlutterView.h | 8 +++ .../ios/framework/Source/FlutterView.mm | 54 +++++++++++-------- .../framework/Source/FlutterViewController.mm | 18 ++++++- 4 files changed, 58 insertions(+), 27 deletions(-) diff --git a/shell/platform/darwin/ios/framework/Headers/FlutterViewController.h b/shell/platform/darwin/ios/framework/Headers/FlutterViewController.h index 629967f6bfb42..cdb3d0f0fe24f 100644 --- a/shell/platform/darwin/ios/framework/Headers/FlutterViewController.h +++ b/shell/platform/darwin/ios/framework/Headers/FlutterViewController.h @@ -97,9 +97,10 @@ FLUTTER_EXPORT * Controls whether the created view will be opaque or not. * * Default is `YES`. Note that setting this to `NO` may negatively impact performance - * when using hardware accelleration. + * when using hardware accelleration, and toggling this will trigger a re-layout of the + * view. */ -@property() BOOL viewIsOpaque; +@property(nonatomic, getter=isViewOpaque, setter=isViewOpaque:) BOOL isViewOpaque; @end diff --git a/shell/platform/darwin/ios/framework/Source/FlutterView.h b/shell/platform/darwin/ios/framework/Source/FlutterView.h index 5e3d303401725..7896e14c01128 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterView.h +++ b/shell/platform/darwin/ios/framework/Source/FlutterView.h @@ -9,10 +9,18 @@ #include +#include "flutter/fml/memory/weak_ptr.h" +#include "flutter/shell/platform/darwin/ios/framework/Source/FlutterViewController_Internal.h" #include "flutter/shell/platform/darwin/ios/ios_surface.h" @interface FlutterView : UIView +- (instancetype)init NS_UNAVAILABLE; +- (instancetype)initWithFrame:(CGRect)frame NS_UNAVAILABLE; +- (instancetype)initWithCoder:(NSCoder*)aDecoder NS_UNAVAILABLE; + +- (instancetype)initWithViewController:(fml::WeakPtr)viewController + frame:(CGRect)frame NS_DESIGNATED_INITIALIZER; - (std::unique_ptr)createSurface; @end diff --git a/shell/platform/darwin/ios/framework/Source/FlutterView.mm b/shell/platform/darwin/ios/framework/Source/FlutterView.mm index f40ac6f393ee7..9c29a5a01b10d 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterView.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterView.mm @@ -13,7 +13,6 @@ #include "flutter/shell/common/platform_view.h" #include "flutter/shell/common/rasterizer.h" #include "flutter/shell/common/shell.h" -#include "flutter/shell/platform/darwin/ios/framework/Source/FlutterViewController_Internal.h" #include "flutter/shell/platform/darwin/ios/ios_surface_gl.h" #include "flutter/shell/platform/darwin/ios/ios_surface_software.h" #include "third_party/skia/include/utils/mac/SkCGUtils.h" @@ -24,21 +23,37 @@ @interface FlutterView () @implementation FlutterView -- (FlutterViewController*)flutterViewController { - // Find the first view controller in the responder chain and see if it is a FlutterViewController. - for (UIResponder* responder = self.nextResponder; responder != nil; - responder = responder.nextResponder) { - if ([responder isKindOfClass:[UIViewController class]]) { - if ([responder isKindOfClass:[FlutterViewController class]]) { - return reinterpret_cast(responder); - } else { - // Should only happen if a non-FlutterViewController tries to somehow (via dynamic class - // resolution or reparenting) set a FlutterView as its view. - return nil; - } - } +fml::WeakPtr _viewController; + +- (instancetype)init { + @throw([NSException exceptionWithName:@"FlutterView must initWithViewController" + reason:nil + userInfo:nil]); +} + +- (instancetype)initWithFrame:(CGRect)frame { + @throw([NSException exceptionWithName:@"FlutterView must initWithViewController" + reason:nil + userInfo:nil]); +} + +- (instancetype)initWithCoder:(NSCoder*)aDecoder { + @throw([NSException exceptionWithName:@"FlutterView must initWithViewController" + reason:nil + userInfo:nil]); +} + +- (instancetype)initWithViewController:(fml::WeakPtr)viewController + frame:(CGRect)frame { + FML_DCHECK(viewController) << "viewController must be set"; + self = [super initWithFrame:frame]; + + if (self) { + _viewController = viewController; + self.layer.opaque = _viewController.get().isViewOpaque; } - return nil; + + return self; } - (void)layoutSubviews { @@ -49,7 +64,6 @@ - (void)layoutSubviews { layer.contentsScale = screenScale; layer.rasterizationScale = screenScale; } - self.layer.opaque = [self flutterViewController].viewIsOpaque; [super layoutSubviews]; } @@ -84,13 +98,7 @@ - (void)drawLayer:(CALayer*)layer inContext:(CGContextRef)context { return; } - FlutterViewController* controller = [self flutterViewController]; - - if (controller == nil) { - return; - } - - auto& shell = [controller shell]; + auto& shell = [_viewController.get() shell]; auto screenshot = shell.Screenshot(shell::Rasterizer::ScreenshotType::UncompressedImage, false /* base64 encode */); diff --git a/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm b/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm index 80a47e89abe54..8f376b0d4d424 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm @@ -58,6 +58,7 @@ @implementation FlutterViewController { blink::ViewportMetrics _viewportMetrics; int64_t _nextTextureId; BOOL _initialized; + BOOL _isViewOpaque; fml::scoped_nsobject _publisher; } @@ -75,7 +76,7 @@ - (instancetype)initWithProject:(FlutterDartProject*)projectOrNil else _dartProject.reset([projectOrNil retain]); - self.viewIsOpaque = YES; + self.isViewOpaque = YES; [self performCommonViewControllerInitialization]; } @@ -148,7 +149,8 @@ - (BOOL)setupShell { _threadHost.io_thread->GetTaskRunner() // io ); - _flutterView.reset([[FlutterView alloc] init]); + _flutterView.reset([[FlutterView alloc] initWithViewController:_weakFactory->GetWeakPtr() + frame:CGRectNull]); // Lambda captures by pointers to ObjC objects are fine here because the create call is // synchronous. @@ -182,6 +184,18 @@ - (BOOL)setupShell { return true; } +- (BOOL)isViewOpaque { + return _isViewOpaque; +} + +- (void)isViewOpaque:(BOOL)value { + _isViewOpaque = value; + if (_flutterView.get().layer.opaque != value) { + _flutterView.get().layer.opaque = value; + [_flutterView.get().layer setNeedsLayout]; + } +} + - (void)setupChannels { _localizationChannel.reset([[FlutterMethodChannel alloc] initWithName:@"flutter/localization" From 04d80e0a1410db5796b4a8a44b61560866c84a3e Mon Sep 17 00:00:00 2001 From: Dan Field Date: Wed, 17 Oct 2018 13:42:35 -0700 Subject: [PATCH 4/8] Do not force callers to provide CGNullRect --- shell/platform/darwin/ios/framework/Source/FlutterView.h | 2 +- shell/platform/darwin/ios/framework/Source/FlutterView.mm | 5 ++--- .../darwin/ios/framework/Source/FlutterViewController.mm | 3 +-- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/shell/platform/darwin/ios/framework/Source/FlutterView.h b/shell/platform/darwin/ios/framework/Source/FlutterView.h index 7896e14c01128..31aa23560d018 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterView.h +++ b/shell/platform/darwin/ios/framework/Source/FlutterView.h @@ -20,7 +20,7 @@ - (instancetype)initWithCoder:(NSCoder*)aDecoder NS_UNAVAILABLE; - (instancetype)initWithViewController:(fml::WeakPtr)viewController - frame:(CGRect)frame NS_DESIGNATED_INITIALIZER; + NS_DESIGNATED_INITIALIZER; - (std::unique_ptr)createSurface; @end diff --git a/shell/platform/darwin/ios/framework/Source/FlutterView.mm b/shell/platform/darwin/ios/framework/Source/FlutterView.mm index 9c29a5a01b10d..1494965eb765f 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterView.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterView.mm @@ -43,10 +43,9 @@ - (instancetype)initWithCoder:(NSCoder*)aDecoder { userInfo:nil]); } -- (instancetype)initWithViewController:(fml::WeakPtr)viewController - frame:(CGRect)frame { +- (instancetype)initWithViewController:(fml::WeakPtr)viewController { FML_DCHECK(viewController) << "viewController must be set"; - self = [super initWithFrame:frame]; + self = [super initWithFrame:CGRectNull]; if (self) { _viewController = viewController; diff --git a/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm b/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm index 8f376b0d4d424..e87cf49cf25b9 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm @@ -149,8 +149,7 @@ - (BOOL)setupShell { _threadHost.io_thread->GetTaskRunner() // io ); - _flutterView.reset([[FlutterView alloc] initWithViewController:_weakFactory->GetWeakPtr() - frame:CGRectNull]); + _flutterView.reset([[FlutterView alloc] initWithViewController:_weakFactory->GetWeakPtr()]); // Lambda captures by pointers to ObjC objects are fine here because the create call is // synchronous. From 5c4eab2b72b6a3c3c5f797d487ad13c58b503b2d Mon Sep 17 00:00:00 2001 From: Dan Field Date: Wed, 17 Oct 2018 14:33:03 -0700 Subject: [PATCH 5/8] fix typo, use delegate instead of flutterviewcontroller --- .../framework/Headers/FlutterViewController.h | 2 +- .../darwin/ios/framework/Source/FlutterView.h | 13 +++++++-- .../ios/framework/Source/FlutterView.mm | 29 +++++++------------ .../framework/Source/FlutterViewController.mm | 12 ++++++-- 4 files changed, 31 insertions(+), 25 deletions(-) diff --git a/shell/platform/darwin/ios/framework/Headers/FlutterViewController.h b/shell/platform/darwin/ios/framework/Headers/FlutterViewController.h index cdb3d0f0fe24f..d3d17fa3f166d 100644 --- a/shell/platform/darwin/ios/framework/Headers/FlutterViewController.h +++ b/shell/platform/darwin/ios/framework/Headers/FlutterViewController.h @@ -97,7 +97,7 @@ FLUTTER_EXPORT * Controls whether the created view will be opaque or not. * * Default is `YES`. Note that setting this to `NO` may negatively impact performance - * when using hardware accelleration, and toggling this will trigger a re-layout of the + * when using hardware acceleration, and toggling this will trigger a re-layout of the * view. */ @property(nonatomic, getter=isViewOpaque, setter=isViewOpaque:) BOOL isViewOpaque; diff --git a/shell/platform/darwin/ios/framework/Source/FlutterView.h b/shell/platform/darwin/ios/framework/Source/FlutterView.h index 31aa23560d018..e9cd37281e63a 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterView.h +++ b/shell/platform/darwin/ios/framework/Source/FlutterView.h @@ -10,17 +10,24 @@ #include #include "flutter/fml/memory/weak_ptr.h" -#include "flutter/shell/platform/darwin/ios/framework/Source/FlutterViewController_Internal.h" +#include "flutter/shell/common/shell.h" #include "flutter/shell/platform/darwin/ios/ios_surface.h" +@protocol FlutterScreenshotDelegate + +- (shell::Rasterizer::Screenshot)takeScreenshot:(shell::Rasterizer::ScreenshotType)type + asBase64Encoded:(BOOL)base64Encode; + +@end + @interface FlutterView : UIView - (instancetype)init NS_UNAVAILABLE; - (instancetype)initWithFrame:(CGRect)frame NS_UNAVAILABLE; - (instancetype)initWithCoder:(NSCoder*)aDecoder NS_UNAVAILABLE; -- (instancetype)initWithViewController:(fml::WeakPtr)viewController - NS_DESIGNATED_INITIALIZER; +- (instancetype)initWithDelegate:(id)delegate + opaque:(BOOL)opaque NS_DESIGNATED_INITIALIZER; - (std::unique_ptr)createSurface; @end diff --git a/shell/platform/darwin/ios/framework/Source/FlutterView.mm b/shell/platform/darwin/ios/framework/Source/FlutterView.mm index 1494965eb765f..91c7938414a77 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterView.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterView.mm @@ -12,7 +12,6 @@ #include "flutter/fml/trace_event.h" #include "flutter/shell/common/platform_view.h" #include "flutter/shell/common/rasterizer.h" -#include "flutter/shell/common/shell.h" #include "flutter/shell/platform/darwin/ios/ios_surface_gl.h" #include "flutter/shell/platform/darwin/ios/ios_surface_software.h" #include "third_party/skia/include/utils/mac/SkCGUtils.h" @@ -23,33 +22,27 @@ @interface FlutterView () @implementation FlutterView -fml::WeakPtr _viewController; +id _delegate; - (instancetype)init { - @throw([NSException exceptionWithName:@"FlutterView must initWithViewController" - reason:nil - userInfo:nil]); + @throw([NSException exceptionWithName:@"FlutterView must initWithShell" reason:nil userInfo:nil]); } - (instancetype)initWithFrame:(CGRect)frame { - @throw([NSException exceptionWithName:@"FlutterView must initWithViewController" - reason:nil - userInfo:nil]); + @throw([NSException exceptionWithName:@"FlutterView must initWithShell" reason:nil userInfo:nil]); } - (instancetype)initWithCoder:(NSCoder*)aDecoder { - @throw([NSException exceptionWithName:@"FlutterView must initWithViewController" - reason:nil - userInfo:nil]); + @throw([NSException exceptionWithName:@"FlutterView must initWithShell" reason:nil userInfo:nil]); } -- (instancetype)initWithViewController:(fml::WeakPtr)viewController { - FML_DCHECK(viewController) << "viewController must be set"; +- (instancetype)initWithDelegate:(id)delegate opaque:(BOOL)opaque { + FML_DCHECK(delegate) << "Delegate must not be nil."; self = [super initWithFrame:CGRectNull]; if (self) { - _viewController = viewController; - self.layer.opaque = _viewController.get().isViewOpaque; + _delegate = delegate; + self.layer.opaque = opaque; } return self; @@ -97,10 +90,8 @@ - (void)drawLayer:(CALayer*)layer inContext:(CGContextRef)context { return; } - auto& shell = [_viewController.get() shell]; - - auto screenshot = shell.Screenshot(shell::Rasterizer::ScreenshotType::UncompressedImage, - false /* base64 encode */); + auto screenshot = [_delegate takeScreenshot:shell::Rasterizer::ScreenshotType::UncompressedImage + asBase64Encoded:NO]; if (!screenshot.data || screenshot.data->isEmpty() || screenshot.frame_size.isEmpty()) { return; diff --git a/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm b/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm index e87cf49cf25b9..03c0d7282afc4 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm @@ -22,7 +22,7 @@ #include "flutter/shell/platform/darwin/ios/framework/Source/platform_message_response_darwin.h" #include "flutter/shell/platform/darwin/ios/platform_view_ios.h" -@interface FlutterViewController () +@interface FlutterViewController () @property(nonatomic, readonly) NSMutableDictionary* pluginPublications; @end @@ -149,7 +149,7 @@ - (BOOL)setupShell { _threadHost.io_thread->GetTaskRunner() // io ); - _flutterView.reset([[FlutterView alloc] initWithViewController:_weakFactory->GetWeakPtr()]); + _flutterView.reset([[FlutterView alloc] initWithDelegate:self opaque:self.isViewOpaque]); // Lambda captures by pointers to ObjC objects are fine here because the create call is // synchronous. @@ -855,6 +855,14 @@ - (void)performAction:(FlutterTextInputAction)action withClient:(int)client { arguments:@[ @(client), actionString ]]; } +#pragma mark - Screenshot Delegate + +- (shell::Rasterizer::Screenshot)takeScreenshot:(shell::Rasterizer::ScreenshotType)type + asBase64Encoded:(BOOL)base64Encode { + FML_DCHECK(_shell) << "Cannot takeScreenshot without a shell"; + return _shell->Screenshot(type, base64Encode); +} + #pragma mark - Orientation updates - (void)onOrientationPreferencesUpdated:(NSNotification*)notification { From d0c3cf7f7b27d40f5e088f8aec67f15a88df3072 Mon Sep 17 00:00:00 2001 From: Dan Field Date: Wed, 17 Oct 2018 23:07:20 -0700 Subject: [PATCH 6/8] shell -> delegate --- shell/platform/darwin/ios/framework/Source/FlutterView.mm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/shell/platform/darwin/ios/framework/Source/FlutterView.mm b/shell/platform/darwin/ios/framework/Source/FlutterView.mm index 91c7938414a77..05956c7a83f40 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterView.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterView.mm @@ -25,15 +25,15 @@ @implementation FlutterView id _delegate; - (instancetype)init { - @throw([NSException exceptionWithName:@"FlutterView must initWithShell" reason:nil userInfo:nil]); + @throw([NSException exceptionWithName:@"FlutterView must initWithDelegate" reason:nil userInfo:nil]); } - (instancetype)initWithFrame:(CGRect)frame { - @throw([NSException exceptionWithName:@"FlutterView must initWithShell" reason:nil userInfo:nil]); + @throw([NSException exceptionWithName:@"FlutterView must initWithDelegate" reason:nil userInfo:nil]); } - (instancetype)initWithCoder:(NSCoder*)aDecoder { - @throw([NSException exceptionWithName:@"FlutterView must initWithShell" reason:nil userInfo:nil]); + @throw([NSException exceptionWithName:@"FlutterView must initWithDelegate" reason:nil userInfo:nil]); } - (instancetype)initWithDelegate:(id)delegate opaque:(BOOL)opaque { From f62db18bec94a39f22da1d1dbf453c80338399be Mon Sep 17 00:00:00 2001 From: Dan Field Date: Thu, 18 Oct 2018 08:59:36 -0700 Subject: [PATCH 7/8] format! --- .../darwin/ios/framework/Source/FlutterView.mm | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/shell/platform/darwin/ios/framework/Source/FlutterView.mm b/shell/platform/darwin/ios/framework/Source/FlutterView.mm index 05956c7a83f40..63ee05acc832c 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterView.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterView.mm @@ -25,15 +25,21 @@ @implementation FlutterView id _delegate; - (instancetype)init { - @throw([NSException exceptionWithName:@"FlutterView must initWithDelegate" reason:nil userInfo:nil]); + @throw([NSException exceptionWithName:@"FlutterView must initWithDelegate" + reason:nil + userInfo:nil]); } - (instancetype)initWithFrame:(CGRect)frame { - @throw([NSException exceptionWithName:@"FlutterView must initWithDelegate" reason:nil userInfo:nil]); + @throw([NSException exceptionWithName:@"FlutterView must initWithDelegate" + reason:nil + userInfo:nil]); } - (instancetype)initWithCoder:(NSCoder*)aDecoder { - @throw([NSException exceptionWithName:@"FlutterView must initWithDelegate" reason:nil userInfo:nil]); + @throw([NSException exceptionWithName:@"FlutterView must initWithDelegate" + reason:nil + userInfo:nil]); } - (instancetype)initWithDelegate:(id)delegate opaque:(BOOL)opaque { From 3b16036ceecc8f66f43684d058930b6a9b0f9088 Mon Sep 17 00:00:00 2001 From: Dan Field Date: Mon, 22 Oct 2018 19:40:55 -0700 Subject: [PATCH 8/8] make property more idiomatic --- .../ios/framework/Headers/FlutterViewController.h | 2 +- .../ios/framework/Source/FlutterViewController.mm | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/shell/platform/darwin/ios/framework/Headers/FlutterViewController.h b/shell/platform/darwin/ios/framework/Headers/FlutterViewController.h index d3d17fa3f166d..27b7330ba3457 100644 --- a/shell/platform/darwin/ios/framework/Headers/FlutterViewController.h +++ b/shell/platform/darwin/ios/framework/Headers/FlutterViewController.h @@ -100,7 +100,7 @@ FLUTTER_EXPORT * when using hardware acceleration, and toggling this will trigger a re-layout of the * view. */ -@property(nonatomic, getter=isViewOpaque, setter=isViewOpaque:) BOOL isViewOpaque; +@property(nonatomic, getter=isViewOpaque) BOOL viewOpaque; @end diff --git a/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm b/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm index e239c5b3b7dbf..eeab410c37a0a 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm @@ -58,7 +58,7 @@ @implementation FlutterViewController { blink::ViewportMetrics _viewportMetrics; int64_t _nextTextureId; BOOL _initialized; - BOOL _isViewOpaque; + BOOL _viewOpaque; fml::scoped_nsobject _publisher; } @@ -76,7 +76,7 @@ - (instancetype)initWithProject:(FlutterDartProject*)projectOrNil else _dartProject.reset([projectOrNil retain]); - self.isViewOpaque = YES; + self.viewOpaque = YES; [self performCommonViewControllerInitialization]; } @@ -184,11 +184,11 @@ - (BOOL)setupShell { } - (BOOL)isViewOpaque { - return _isViewOpaque; + return _viewOpaque; } -- (void)isViewOpaque:(BOOL)value { - _isViewOpaque = value; +- (void)viewOpaque:(BOOL)value { + _viewOpaque = value; if (_flutterView.get().layer.opaque != value) { _flutterView.get().layer.opaque = value; [_flutterView.get().layer setNeedsLayout];