Unverified Commit c5890f0c authored by Alex Wallen's avatar Alex Wallen Committed by GitHub

[macOS] Add `platform_view` example. (#111005)

parent dca85127
...@@ -54,10 +54,11 @@ class _MyHomePageState extends State<MyHomePage> { ...@@ -54,10 +54,11 @@ class _MyHomePageState extends State<MyHomePage> {
case TargetPlatform.iOS: case TargetPlatform.iOS:
return const Text('Continue in iOS view'); return const Text('Continue in iOS view');
case TargetPlatform.windows: case TargetPlatform.windows:
return const Text('Cotninue in Windows view'); return const Text('Continue in Windows view');
case TargetPlatform.macOS:
return const Text('Continue in macOS view');
case TargetPlatform.fuchsia: case TargetPlatform.fuchsia:
case TargetPlatform.linux: case TargetPlatform.linux:
case TargetPlatform.macOS:
throw UnimplementedError('Platform not yet implemented'); throw UnimplementedError('Platform not yet implemented');
} }
} }
......
# Flutter-related
**/Flutter/ephemeral/
**/Pods/
# Xcode-related
**/dgph
**/xcuserdata/
#include "ephemeral/Flutter-Generated.xcconfig"
#include "ephemeral/Flutter-Generated.xcconfig"
This diff is collapsed.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1300"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "33CC10EC2044A3C60003C045"
BuildableName = "platform_view.app"
BlueprintName = "Runner"
ReferencedContainer = "container:Runner.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "33CC10EC2044A3C60003C045"
BuildableName = "platform_view.app"
BlueprintName = "Runner"
ReferencedContainer = "container:Runner.xcodeproj">
</BuildableReference>
</MacroExpansion>
<Testables>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "33CC10EC2044A3C60003C045"
BuildableName = "platform_view.app"
BlueprintName = "Runner"
ReferencedContainer = "container:Runner.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</LaunchAction>
<ProfileAction
buildConfiguration = "Profile"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "33CC10EC2044A3C60003C045"
BuildableName = "platform_view.app"
BlueprintName = "Runner"
ReferencedContainer = "container:Runner.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "group:Runner.xcodeproj">
</FileRef>
</Workspace>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import Cocoa
import FlutterMacOS
@NSApplicationMain
class AppDelegate: FlutterAppDelegate {
override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {
return true
}
}
This diff is collapsed.
// Application-level settings for the Runner target.
//
// This may be replaced with something auto-generated from metadata (e.g., pubspec.yaml) in the
// future. If not, the values below would default to using the project name when this becomes a
// 'flutter create' template.
// The application's name. By default this is also the title of the Flutter window.
PRODUCT_NAME = platform_view
// The application's bundle identifier
PRODUCT_BUNDLE_IDENTIFIER = io.flutter.examples.platformView
// The copyright displayed in application information
PRODUCT_COPYRIGHT = Copyright © 2022 io.flutter.examples. All rights reserved.
#include "../../Flutter/Flutter-Debug.xcconfig"
#include "Warnings.xcconfig"
#include "../../Flutter/Flutter-Release.xcconfig"
#include "Warnings.xcconfig"
WARNING_CFLAGS = -Wall -Wconditional-uninitialized -Wnullable-to-nonnull-conversion -Wmissing-method-return-type -Woverlength-strings
GCC_WARN_UNDECLARED_SELECTOR = YES
CLANG_UNDEFINED_BEHAVIOR_SANITIZER_NULLABILITY = YES
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES
CLANG_WARN_PRAGMA_PACK = YES
CLANG_WARN_STRICT_PROTOTYPES = YES
CLANG_WARN_COMMA = YES
GCC_WARN_STRICT_SELECTOR_MATCH = YES
CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES
GCC_WARN_SHADOW = YES
CLANG_WARN_UNREACHABLE_CODE = YES
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.cs.allow-jit</key>
<true/>
<key>com.apple.security.network.server</key>
<true/>
</dict>
</plist>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIconFile</key>
<string></string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>$(FLUTTER_BUILD_NAME)</string>
<key>CFBundleVersion</key>
<string>$(FLUTTER_BUILD_NUMBER)</string>
<key>LSMinimumSystemVersion</key>
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
<key>NSHumanReadableCopyright</key>
<string>$(PRODUCT_COPYRIGHT)</string>
<key>NSMainNibFile</key>
<string>MainMenu</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
</dict>
</plist>
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import Cocoa
import FlutterMacOS
class MainFlutterWindow: NSWindow {
override func awakeFromNib() {
let flutterViewController = FlutterViewController.init()
let windowFrame = self.frame
self.contentViewController = flutterViewController
self.setFrame(windowFrame, display: true)
RegisterGeneratedPlugins(registry: flutterViewController)
RegisterMethodChannel(registry: flutterViewController)
super.awakeFromNib()
}
func RegisterMethodChannel(registry: FlutterPluginRegistry) {
let registrar = registry.registrar(forPlugin: "platform_view")
let channel = FlutterMethodChannel(name: "samples.flutter.io/platform_view",
binaryMessenger: registrar.messenger)
channel.setMethodCallHandler({ (call, result) in
if (call.method == "switchView") {
let count = call.arguments as! Int
let controller: NSViewController = PlatformViewController(
withCount: count,
onClose: { platformViewController in
result(platformViewController.count)
}
)
self.contentViewController?.presentAsSheet(controller)
}
})
}
}
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import Cocoa
class PlatformViewController: NSViewController {
var count: Int = 0
var dispose: ((PlatformViewController)->())?
@IBOutlet weak var label: NSTextField!
var labelText: String {
get {
return "Button tapped \(self.count) time\(self.count != 1 ? "s" : "")."
}
}
override func viewDidLoad() {
super.viewDidLoad()
self.label.stringValue = labelText
}
public required init?(coder aDecoder: NSCoder) {
self.count = 0
self.dispose = nil
super.init(coder: aDecoder)
}
init(withCount count: Int, onClose dispose: ((PlatformViewController)->())?) {
self.count = count
self.dispose = dispose
super.init(nibName: nil, bundle: nil)
}
@IBAction func pop(_ sender: Any) {
self.dispose?(self)
dismiss(self)
}
@IBAction func increment(_ sender: Any) {
self.count += 1
self.label.stringValue = labelText
}
}
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="21208.1" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="21208.1"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="PlatformViewController" customModule="platform_view" customModuleProvider="target">
<connections>
<outlet property="label" destination="Eug-C1-PRv" id="wbw-1a-uP2"/>
<outlet property="view" destination="Hz6-mo-xeY" id="0bl-1N-x8E"/>
</connections>
</customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
<customView wantsLayer="YES" id="Hz6-mo-xeY" userLabel="Platform View">
<rect key="frame" x="0.0" y="0.0" width="587" height="356"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<subviews>
<stackView distribution="fill" orientation="vertical" alignment="leading" spacing="0.0" horizontalStackHuggingPriority="249.99998474121094" verticalStackHuggingPriority="249.99998474121094" detachesHiddenViews="YES" translatesAutoresizingMaskIntoConstraints="NO" id="asX-Cr-4ZL">
<rect key="frame" x="0.0" y="0.0" width="587" height="356"/>
<subviews>
<customView translatesAutoresizingMaskIntoConstraints="NO" id="LRL-SV-BW7" userLabel="Top">
<rect key="frame" x="0.0" y="70" width="587" height="286"/>
<subviews>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Eug-C1-PRv">
<rect key="frame" x="193" y="133" width="202" height="21"/>
<textFieldCell key="cell" lineBreakMode="clipping" title="Button tapped X time(s)." id="e4z-H9-rSi">
<font key="font" metaFont="system" size="18"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Jn3-XC-Bej">
<rect key="frame" x="204" y="90" width="179" height="32"/>
<buttonCell key="cell" type="push" title="Continue in Flutter View" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="1Sq-bc-nHD">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="pop:" target="-2" id="KiK-HY-d8D"/>
</connections>
</button>
</subviews>
<constraints>
<constraint firstItem="Jn3-XC-Bej" firstAttribute="centerX" secondItem="Eug-C1-PRv" secondAttribute="centerX" id="0Wb-kD-KeP"/>
<constraint firstItem="Jn3-XC-Bej" firstAttribute="top" secondItem="Eug-C1-PRv" secondAttribute="bottom" constant="16" id="55w-Yj-iSV"/>
<constraint firstItem="Eug-C1-PRv" firstAttribute="centerX" secondItem="LRL-SV-BW7" secondAttribute="centerX" id="E6g-Q5-V9j"/>
<constraint firstItem="Eug-C1-PRv" firstAttribute="centerY" secondItem="LRL-SV-BW7" secondAttribute="centerY" id="FPs-Lq-4vX"/>
</constraints>
</customView>
<customView translatesAutoresizingMaskIntoConstraints="NO" id="ocC-s8-csF" userLabel="Bottom">
<rect key="frame" x="0.0" y="0.0" width="587" height="70"/>
<subviews>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="ibp-9J-zlZ">
<rect key="frame" x="18" y="12" width="100" height="35"/>
<textFieldCell key="cell" lineBreakMode="clipping" title="macOS" id="gQ0-QK-wuE">
<font key="font" metaFont="system" size="30"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<button verticalHuggingPriority="750" misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="p1C-yr-atP">
<rect key="frame" x="540" y="13" width="34" height="32"/>
<buttonCell key="cell" type="push" title="+" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="Zhj-im-lGH">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="increment:" target="-2" id="t7P-hc-bBq"/>
</connections>
</button>
</subviews>
<constraints>
<constraint firstAttribute="bottom" secondItem="p1C-yr-atP" secondAttribute="bottom" constant="20" symbolic="YES" id="O6I-0q-C2q"/>
<constraint firstItem="ibp-9J-zlZ" firstAttribute="leading" secondItem="ocC-s8-csF" secondAttribute="leading" constant="20" symbolic="YES" id="RaJ-kB-iMn"/>
<constraint firstAttribute="bottom" secondItem="ibp-9J-zlZ" secondAttribute="bottom" constant="12" id="bHW-eU-Qry"/>
<constraint firstAttribute="height" constant="70" id="ipW-qa-zLH"/>
<constraint firstAttribute="trailing" secondItem="p1C-yr-atP" secondAttribute="trailing" constant="20" symbolic="YES" id="rQt-7N-1IH"/>
</constraints>
</customView>
</subviews>
<visibilityPriorities>
<integer value="1000"/>
<integer value="1000"/>
</visibilityPriorities>
<customSpacing>
<real value="3.4028234663852886e+38"/>
<real value="3.4028234663852886e+38"/>
</customSpacing>
</stackView>
</subviews>
<constraints>
<constraint firstAttribute="trailing" secondItem="asX-Cr-4ZL" secondAttribute="trailing" id="2mi-qA-Xg7"/>
<constraint firstAttribute="bottom" secondItem="asX-Cr-4ZL" secondAttribute="bottom" id="4yQ-Dc-p85"/>
<constraint firstItem="asX-Cr-4ZL" firstAttribute="top" secondItem="Hz6-mo-xeY" secondAttribute="top" id="QUl-ar-P9E"/>
<constraint firstItem="asX-Cr-4ZL" firstAttribute="leading" secondItem="Hz6-mo-xeY" secondAttribute="leading" id="o34-Uf-9SV"/>
</constraints>
<point key="canvasLocation" x="138.5" y="96"/>
</customView>
</objects>
</document>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.app-sandbox</key>
<true/>
</dict>
</plist>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment