You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
60 lines
1.8 KiB
Swift
60 lines
1.8 KiB
Swift
//
|
|
// BlueGpsViewFactory.swift
|
|
// Runner
|
|
//
|
|
// Created by Penguin .
|
|
//
|
|
|
|
import Foundation
|
|
import Flutter
|
|
|
|
/**
|
|
* A factory class for creating instances of [PenguinView].
|
|
* This class implements `FlutterPlatformViewFactory` to create and manage native views.
|
|
*/
|
|
class PenguinViewFactory: NSObject, FlutterPlatformViewFactory {
|
|
|
|
// The binary messenger used for communication with the Flutter engine
|
|
private var messenger: FlutterBinaryMessenger
|
|
|
|
/**
|
|
* Initializes the PenguinViewFactory with the given messenger.
|
|
*
|
|
* @param messenger The [FlutterBinaryMessenger] used to communicate with Dart code.
|
|
*/
|
|
init(messenger: FlutterBinaryMessenger) {
|
|
self.messenger = messenger
|
|
super.init()
|
|
}
|
|
|
|
/**
|
|
* Creates a new instance of [PenguinView].
|
|
*
|
|
* @param frame The frame of the view, specifying its size and position.
|
|
* @param viewId A unique identifier for this view instance.
|
|
* @param args Optional arguments provided for creating the view.
|
|
* @return An instance of [PenguinView] configured with the provided parameters.
|
|
*/
|
|
func create(
|
|
withFrame frame: CGRect,
|
|
viewIdentifier viewId: Int64,
|
|
arguments args: Any?
|
|
) -> FlutterPlatformView {
|
|
return PenguinView(
|
|
frame: frame,
|
|
viewIdentifier: viewId,
|
|
arguments: args,
|
|
binaryMessenger: messenger)
|
|
}
|
|
|
|
/**
|
|
* Returns the codec used for encoding and decoding method channel arguments.
|
|
* This method is required when `arguments` in `create` is not `nil`.
|
|
*
|
|
* @return A [FlutterMessageCodec] instance used for serialization.
|
|
*/
|
|
public func createArgsCodec() -> FlutterMessageCodec & NSObjectProtocol {
|
|
return FlutterStandardMessageCodec.sharedInstance()
|
|
}
|
|
}
|