Skip to content

Commit 6433c0b

Browse files
Update FLEViewController creation (google#453)
Updates example and testbed for the breaking change in flutter/engine#9741 Removes FLEViewController and FLEView from the XIBs, and instead adds the view controllers in code (which now internally manages the view). Fixes google#10
1 parent c183d46 commit 6433c0b

File tree

4 files changed

+24
-61
lines changed

4 files changed

+24
-61
lines changed

example/macos/Base.lproj/MainMenu.xib

Lines changed: 8 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="14109" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
2+
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="14490.70" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
33
<dependencies>
4-
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14109"/>
4+
<deployment identifier="macosx"/>
5+
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14490.70"/>
56
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
67
</dependencies>
78
<objects>
@@ -12,7 +13,7 @@
1213
</customObject>
1314
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
1415
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
15-
<customObject id="Voe-Tx-rLC" customClass="AppDelegate" customModule="Example_Embedder" customModuleProvider="target">
16+
<customObject id="Voe-Tx-rLC" customClass="AppDelegate" customModule="Flutter_Desktop_Example" customModuleProvider="target">
1617
<connections>
1718
<outlet property="window" destination="QvC-M9-y7g" id="gIp-Ho-8D9"/>
1819
</connections>
@@ -322,38 +323,16 @@
322323
</menu>
323324
</menuItem>
324325
</items>
326+
<point key="canvasLocation" x="142" y="-258"/>
325327
</menu>
326-
<window title="Flutter Desktop Example" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" oneShot="NO" releasedWhenClosed="NO" animationBehavior="default" id="QvC-M9-y7g" customClass="ExampleWindow" customModule="Example_Embedder" customModuleProvider="target">
328+
<window title="Flutter Desktop Example" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" animationBehavior="default" id="QvC-M9-y7g" customClass="ExampleWindow" customModule="Flutter_Desktop_Example" customModuleProvider="target">
327329
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
328-
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
329-
<rect key="contentRect" x="335" y="390" width="480" height="360"/>
330+
<rect key="contentRect" x="335" y="390" width="800" height="600"/>
330331
<rect key="screenRect" x="0.0" y="0.0" width="2560" height="1577"/>
331332
<view key="contentView" wantsLayer="YES" id="EiT-Mj-1SZ">
332-
<rect key="frame" x="0.0" y="0.0" width="480" height="360"/>
333+
<rect key="frame" x="0.0" y="0.0" width="800" height="600"/>
333334
<autoresizingMask key="autoresizingMask"/>
334-
<subviews>
335-
<openGLView colorSize="5bit_RGB_8bit_Alpha" useAuxiliaryDepthBufferStencil="NO" useDoubleBufferingEnabled="YES" allowOffline="YES" wantsBestResolutionOpenGLSurface="YES" translatesAutoresizingMaskIntoConstraints="NO" id="gEc-a8-YO4" userLabel="Flutter View" customClass="FLEView">
336-
<rect key="frame" x="0.0" y="0.0" width="480" height="360"/>
337-
<connections>
338-
<outlet property="reshapeListener" destination="G1H-AI-kys" id="1cc-4d-RFE"/>
339-
</connections>
340-
</openGLView>
341-
</subviews>
342-
<constraints>
343-
<constraint firstAttribute="trailing" secondItem="gEc-a8-YO4" secondAttribute="trailing" id="48l-99-Yo3"/>
344-
<constraint firstItem="gEc-a8-YO4" firstAttribute="leading" secondItem="EiT-Mj-1SZ" secondAttribute="leading" id="Hnt-3S-GUm"/>
345-
<constraint firstItem="gEc-a8-YO4" firstAttribute="top" secondItem="EiT-Mj-1SZ" secondAttribute="top" id="Zcl-HH-aUv"/>
346-
<constraint firstAttribute="bottom" secondItem="gEc-a8-YO4" secondAttribute="bottom" id="mOL-Lq-el9"/>
347-
</constraints>
348335
</view>
349-
<connections>
350-
<outlet property="flutterViewController" destination="G1H-AI-kys" id="Icn-Jl-i3i"/>
351-
</connections>
352336
</window>
353-
<viewController id="G1H-AI-kys" userLabel="Flutter View Controller" customClass="FLEViewController">
354-
<connections>
355-
<outlet property="view" destination="gEc-a8-YO4" id="5gV-MI-Qu1"/>
356-
</connections>
357-
</viewController>
358337
</objects>
359338
</document>

example/macos/ExampleWindow.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,12 @@ import Cocoa
1616
import FlutterMacOS
1717

1818
class ExampleWindow: NSWindow {
19-
@IBOutlet weak var flutterViewController: FLEViewController!
20-
2119
override func awakeFromNib() {
20+
let flutterViewController = FLEViewController.init()
21+
let windowFrame = self.frame
22+
self.contentViewController = flutterViewController
23+
self.setFrame(windowFrame, display: true)
24+
2225
RegisterGeneratedPlugins(registry: flutterViewController)
2326

2427
flutterViewController.launchEngine(with: nil)

testbed/macos/Base.lproj/MainMenu.xib

Lines changed: 6 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="14313.18" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
2+
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="14490.70" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
33
<dependencies>
44
<deployment identifier="macosx"/>
5-
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14313.18"/>
5+
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14490.70"/>
66
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
77
</dependencies>
88
<objects>
@@ -323,38 +323,16 @@
323323
</menu>
324324
</menuItem>
325325
</items>
326+
<point key="canvasLocation" x="142" y="-258"/>
326327
</menu>
327328
<window title="Testbed" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" animationBehavior="default" id="QvC-M9-y7g" customClass="FlutterWindow" customModule="Testbed" customModuleProvider="target">
328329
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
329-
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
330-
<rect key="contentRect" x="335" y="390" width="480" height="360"/>
331-
<rect key="screenRect" x="0.0" y="0.0" width="1440" height="877"/>
330+
<rect key="contentRect" x="335" y="390" width="800" height="600"/>
331+
<rect key="screenRect" x="0.0" y="0.0" width="2560" height="1577"/>
332332
<view key="contentView" wantsLayer="YES" id="EiT-Mj-1SZ">
333-
<rect key="frame" x="0.0" y="0.0" width="480" height="360"/>
333+
<rect key="frame" x="0.0" y="0.0" width="800" height="600"/>
334334
<autoresizingMask key="autoresizingMask"/>
335-
<subviews>
336-
<openGLView wantsLayer="YES" colorSize="5bit_RGB_8bit_Alpha" useAuxiliaryDepthBufferStencil="NO" useDoubleBufferingEnabled="YES" allowOffline="YES" wantsBestResolutionOpenGLSurface="YES" translatesAutoresizingMaskIntoConstraints="NO" id="gEc-a8-YO4" userLabel="Flutter View" customClass="FLEView">
337-
<rect key="frame" x="0.0" y="0.0" width="480" height="360"/>
338-
<connections>
339-
<outlet property="reshapeListener" destination="G1H-AI-kys" id="1cc-4d-RFE"/>
340-
</connections>
341-
</openGLView>
342-
</subviews>
343-
<constraints>
344-
<constraint firstAttribute="trailing" secondItem="gEc-a8-YO4" secondAttribute="trailing" id="48l-99-Yo3"/>
345-
<constraint firstItem="gEc-a8-YO4" firstAttribute="leading" secondItem="EiT-Mj-1SZ" secondAttribute="leading" id="Hnt-3S-GUm"/>
346-
<constraint firstItem="gEc-a8-YO4" firstAttribute="top" secondItem="EiT-Mj-1SZ" secondAttribute="top" id="Zcl-HH-aUv"/>
347-
<constraint firstAttribute="bottom" secondItem="gEc-a8-YO4" secondAttribute="bottom" id="mOL-Lq-el9"/>
348-
</constraints>
349335
</view>
350-
<connections>
351-
<outlet property="flutterViewController" destination="G1H-AI-kys" id="Icn-Jl-i3i"/>
352-
</connections>
353336
</window>
354-
<viewController id="G1H-AI-kys" userLabel="Flutter View Controller" customClass="FLEViewController">
355-
<connections>
356-
<outlet property="view" destination="gEc-a8-YO4" id="5gV-MI-Qu1"/>
357-
</connections>
358-
</viewController>
359337
</objects>
360338
</document>

testbed/macos/FlutterWindow.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,12 @@ import Cocoa
1616
import FlutterMacOS
1717

1818
class FlutterWindow: NSWindow {
19-
@IBOutlet weak var flutterViewController: FLEViewController!
20-
2119
override func awakeFromNib() {
20+
let flutterViewController = FLEViewController.init()
21+
let windowFrame = self.frame
22+
self.contentViewController = flutterViewController
23+
self.setFrame(windowFrame, display: true)
24+
2225
RegisterGeneratedPlugins(registry: flutterViewController)
2326

2427
let project = FLEDartProject.init()

0 commit comments

Comments
 (0)