-
Notifications
You must be signed in to change notification settings - Fork 6k
[macOS] Make FlutterEngine support multiple views #37976
Changes from 7 commits
74503c6
e249299
f5335ea
fd7d3d9
d705c82
3ac89d9
0f44c6d
9de9616
ad69a76
c05f0e8
c2ebe66
0625db7
63a41c9
d063600
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,12 +36,18 @@ FLUTTER_DARWIN_EXPORT | |
@property(nonnull, readonly) id<FlutterTextureRegistry> textures; | ||
|
||
/** | ||
* The view displaying Flutter content. May return |nil|, for instance in a headless environment. | ||
* The default view displaying Flutter content. | ||
* | ||
* WARNING: If/when multiple Flutter views within the same application are supported (#30701), this | ||
* API will change. | ||
* This method may return |nil|, for instance in a headless environment. | ||
* | ||
* The default view is a special view operated by single-view APIs. | ||
*/ | ||
- (nullable NSView*)view; | ||
dkwingsmt marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't know if it's the same as the internal breakage, but this broke There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, this is exactly why this PR was reverted. I did this only because I thought it was equivalent (for objC). I'll change it back to proprty syntax. |
||
|
||
/** | ||
* The `NSView` associated with the given view ID, if any. | ||
*/ | ||
@property(nullable, readonly) NSView* view; | ||
- (nullable NSView*)viewForId:(uint64_t)viewId; | ||
|
||
/** | ||
* Registers |delegate| to receive handleMethodCall:result: callbacks for the given |channel|. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -89,7 +89,9 @@ FLUTTER_DARWIN_EXPORT | |
NS_DESIGNATED_INITIALIZER; | ||
- (nonnull instancetype)initWithCoder:(nonnull NSCoder*)nibNameOrNil NS_DESIGNATED_INITIALIZER; | ||
/** | ||
* Initializes this FlutterViewController with the specified `FlutterEngine`. | ||
* Initializes this FlutterViewController with an existing `FlutterEngine`. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should there be an empty line between this comment and the previous method? |
||
* | ||
* The initialized view controller will add itself to the engine as part of this process. | ||
* | ||
* This initializer is suitable for both the first Flutter view controller and | ||
* the following ones of the app. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,8 @@ | |
#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterViewProvider.h" | ||
#import "flutter/testing/testing.h" | ||
|
||
extern const uint64_t kFlutterDefaultViewId; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm assuming the reason this is a const global rather than constexpr is that it's part of our public headers and therefore we need it to be pure Obj-C and not Obj-C++? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure which header to put the constexpr to, because the files that rely on this value might not all import the same header. In this way I can put the declaration in any header file and just use it. Also, you can say in this way we're hiding the actual value of this magic value. Do you think I should try to change it? |
||
|
||
@interface FlutterViewMockProvider : NSObject <FlutterViewProvider> { | ||
FlutterView* _defaultView; | ||
} | ||
|
@@ -30,7 +32,7 @@ - (nonnull instancetype)initWithDefaultView:(nonnull FlutterView*)view { | |
return self; | ||
} | ||
|
||
- (nullable FlutterView*)getView:(uint64_t)viewId { | ||
- (nullable FlutterView*)viewForId:(uint64_t)viewId { | ||
if (viewId == kFlutterDefaultViewId) { | ||
return _defaultView; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: seems odd to talk about the "first" view here since this can only have one (for now)?