forked from flutter/packages
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reland Add platform view wide gamut test (#139101)
Reland of flutter/flutter#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.
- Loading branch information
1 parent
947488d
commit 2150424
Showing
3 changed files
with
117 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 86 additions & 0 deletions
86
dev/integration_tests/wide_gamut_test/ios/Runner/AppDelegate.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
// 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) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters