mirror of
https://github.com/flutter/samples.git
synced 2026-05-10 00:47:43 +00:00
Maintenance updates for platform_view_swift (#151)
This commit is contained in:
@@ -8,36 +8,36 @@ import Flutter
|
||||
@UIApplicationMain
|
||||
@objc class AppDelegate: FlutterAppDelegate, PlatformViewControllerDelegate
|
||||
{
|
||||
var flutterResult: FlutterResult?
|
||||
|
||||
override func application(
|
||||
_ application: UIApplication,
|
||||
didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
|
||||
GeneratedPluginRegistrant.register(with: self)
|
||||
let controller: FlutterViewController = window?.rootViewController as! FlutterViewController
|
||||
let channel = FlutterMethodChannel.init(name: "samples.flutter.io/platform_view_swift", binaryMessenger: controller)
|
||||
|
||||
channel.setMethodCallHandler({
|
||||
(call: FlutterMethodCall, result: @escaping FlutterResult) -> Void in
|
||||
if ("switchView" == call.method) {
|
||||
self.flutterResult = result
|
||||
|
||||
let platformViewController = controller.storyboard?.instantiateViewController(withIdentifier: "PlatformView") as! PlatformViewController
|
||||
platformViewController.counter = call.arguments as! Int
|
||||
platformViewController.delegate = self
|
||||
|
||||
let navigationController = UINavigationController(rootViewController: platformViewController)
|
||||
navigationController.navigationBar.topItem?.title = "Platform View"
|
||||
controller.present(navigationController, animated: true, completion: nil)
|
||||
} else {
|
||||
result(FlutterMethodNotImplemented)
|
||||
}
|
||||
});
|
||||
|
||||
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
|
||||
}
|
||||
|
||||
func didUpdateCounter(counter: Int) {
|
||||
flutterResult?(counter)
|
||||
}
|
||||
var flutterResult: FlutterResult?
|
||||
|
||||
override func application(
|
||||
_ application: UIApplication,
|
||||
didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
|
||||
GeneratedPluginRegistrant.register(with: self)
|
||||
let controller: FlutterViewController = window?.rootViewController as! FlutterViewController
|
||||
let channel = FlutterMethodChannel.init(name: "dev.flutter.sample/platform_view_swift", binaryMessenger: controller.binaryMessenger)
|
||||
|
||||
channel.setMethodCallHandler({
|
||||
(call: FlutterMethodCall, result: @escaping FlutterResult) -> Void in
|
||||
if ("switchView" == call.method) {
|
||||
self.flutterResult = result
|
||||
|
||||
let platformViewController = PlatformViewController(nibName: "PlatformViewController", bundle: nil)
|
||||
platformViewController.counter = call.arguments as! Int
|
||||
platformViewController.delegate = self
|
||||
|
||||
let navigationController = UINavigationController(rootViewController: platformViewController)
|
||||
navigationController.navigationBar.topItem?.title = "Platform View"
|
||||
controller.present(navigationController, animated: true, completion: nil)
|
||||
} else {
|
||||
result(FlutterMethodNotImplemented)
|
||||
}
|
||||
});
|
||||
|
||||
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
|
||||
}
|
||||
|
||||
func didUpdateCounter(counter: Int) {
|
||||
flutterResult?(counter)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user