flutter/dev/integration_tests/wide_gamut_test/ios/Runner/AppDelegate.swift
Jonah Williams 2150424cee
Reland Add platform view wide gamut test (#139101)
Reland of https://github.com/flutter/flutter/pull/138837

I reverted too many config files, the app needed the pbx project file in order to find the new class I added. Instead, just put the new platform view in the app delegate so it builds.
2023-11-28 02:23:21 +00:00

87 lines
2.1 KiB
Swift

// 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 Foundation
import UIKit
import Flutter
class FLNativeViewFactory: NSObject, FlutterPlatformViewFactory {
private var messenger: FlutterBinaryMessenger
init(messenger: FlutterBinaryMessenger) {
self.messenger = messenger
super.init()
}
func create(
withFrame frame: CGRect,
viewIdentifier viewId: Int64,
arguments args: Any?
) -> FlutterPlatformView {
return FLNativeView(
frame: frame,
viewIdentifier: viewId,
arguments: args,
binaryMessenger: messenger)
}
public func createArgsCodec() -> FlutterMessageCodec & NSObjectProtocol {
return FlutterStandardMessageCodec.sharedInstance()
}
}
class SolidColorView: UIView {
override init(frame: CGRect) {
super.init(frame: frame)
setupView()
}
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
setupView()
}
private func setupView() {
backgroundColor = .blue
}
}
class FLNativeView: NSObject, FlutterPlatformView {
private var childView: UIView
init(
frame: CGRect,
viewIdentifier viewId: Int64,
arguments args: Any?,
binaryMessenger messenger: FlutterBinaryMessenger?
) {
childView = SolidColorView()
super.init()
}
func view() -> UIView {
return childView
}
}
@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
GeneratedPluginRegistrant.register(with: self)
var registrar = self.registrar(forPlugin: "plugin-name")
let factory = FLNativeViewFactory(messenger: registrar!.messenger())
self.registrar(forPlugin: "<plugin-name>")!.register(
factory,
withId: "<dummy-view>")
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
}