ios demo version

This commit is contained in:
Semyon Babushkin
2017-10-19 14:46:44 +03:00
parent 1b98b320d2
commit 1e9ddbf3a9
145 changed files with 18395 additions and 208 deletions

View File

@@ -0,0 +1,18 @@
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef FLUTTER_FLUTTER_H_
#define FLUTTER_FLUTTER_H_
#include "FlutterAppDelegate.h"
#include "FlutterBinaryMessenger.h"
#include "FlutterChannels.h"
#include "FlutterCodecs.h"
#include "FlutterDartProject.h"
#include "FlutterMacros.h"
#include "FlutterNavigationController.h"
#include "FlutterPlugin.h"
#include "FlutterViewController.h"
#endif // FLUTTER_FLUTTER_H_

View File

@@ -0,0 +1,39 @@
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef FLUTTER_FLUTTERAPPDELEGATE_H_
#define FLUTTER_FLUTTERAPPDELEGATE_H_
#import <UIKit/UIKit.h>
#include "FlutterMacros.h"
#include "FlutterPlugin.h"
/**
* UIApplicationDelegate subclass for simple apps that want default behavior.
*
* This class provides the following behaviors:
* * Status bar touches are forwarded to the key window's root view
* FlutterViewController, in order to trigger scroll to top.
* * Keeps the Flutter connection open in debug mode when the phone screen
* locks.
*
* App delegates for Flutter applications are *not* required to inherit from
* this class. Developers of custom app delegate classes should copy and paste
* code as necessary from FlutterAppDelegate.mm.
*/
FLUTTER_EXPORT
@interface FlutterAppDelegate : UIResponder<UIApplicationDelegate, FlutterPluginRegistry>
@property(strong, nonatomic) UIWindow* window;
// Can be overriden by subclasses to provide a custom FlutterBinaryMessenger,
// typically a FlutterViewController, for plugin interop.
//
// Defaults to window's rootViewController.
- (NSObject<FlutterBinaryMessenger>*)binaryMessenger;
@end
#endif // FLUTTER_FLUTTERDARTPROJECT_H_

View File

@@ -0,0 +1,85 @@
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef FLUTTER_FLUTTERBINARYMESSENGER_H_
#define FLUTTER_FLUTTERBINARYMESSENGER_H_
#import <Foundation/Foundation.h>
#include "FlutterMacros.h"
NS_ASSUME_NONNULL_BEGIN
/**
A message reply callback.
Used for submitting a binary reply back to a Flutter message sender. Also used
in the dual capacity for handling a binary message reply received from Flutter.
- Parameters:
- reply: The reply.
*/
typedef void (^FlutterBinaryReply)(NSData* _Nullable reply);
/**
A strategy for handling incoming binary messages from Flutter and to send
asynchronous replies back to Flutter.
- Parameters:
- message: The message.
- reply: A callback for submitting a reply to the sender.
*/
typedef void (^FlutterBinaryMessageHandler)(NSData* _Nullable message, FlutterBinaryReply reply);
/**
A facility for communicating with the Flutter side using asynchronous message
passing with binary messages.
- SeeAlso:
- `FlutterBasicMessageChannel`, which supports communication using structured
messages.
- `FlutterMethodChannel`, which supports communication using asynchronous
method calls.
- `FlutterEventChannel`, which supports commuication using event streams.
*/
FLUTTER_EXPORT
@protocol FlutterBinaryMessenger<NSObject>
/**
Sends a binary message to the Flutter side on the specified channel, expecting
no reply.
- Parameters:
- channel: The channel name.
- message: The message.
*/
- (void)sendOnChannel:(NSString*)channel message:(NSData* _Nullable)message;
/**
Sends a binary message to the Flutter side on the specified channel, expecting
an asynchronous reply.
- Parameters:
- channel: The channel name.
- message: The message.
- callback: A callback for receiving a reply.
*/
- (void)sendOnChannel:(NSString*)channel
message:(NSData* _Nullable)message
binaryReply:(FlutterBinaryReply _Nullable)callback;
/**
Registers a message handler for incoming binary messages from the Flutter side
on the specified channel.
Replaces any existing handler. Use a `nil` handler for unregistering the
existing handler.
- Parameters:
- channel: The channel name.
- handler: The message handler.
*/
- (void)setMessageHandlerOnChannel:(NSString*)channel
binaryMessageHandler:(FlutterBinaryMessageHandler _Nullable)handler;
@end
NS_ASSUME_NONNULL_END
#endif // FLUTTER_FLUTTERBINARYMESSENGER_H_

View File

@@ -0,0 +1,380 @@
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef FLUTTER_FLUTTERCHANNELS_H_
#define FLUTTER_FLUTTERCHANNELS_H_
#include "FlutterBinaryMessenger.h"
#include "FlutterCodecs.h"
NS_ASSUME_NONNULL_BEGIN
/**
A message reply callback.
Used for submitting a reply back to a Flutter message sender. Also used in
the dual capacity for handling a message reply received from Flutter.
- Parameter reply: The reply.
*/
typedef void (^FlutterReply)(id _Nullable reply);
/**
A strategy for handling incoming messages from Flutter and to send
asynchronous replies back to Flutter.
- Parameters:
- message: The message.
- reply: A callback for submitting a reply to the sender.
*/
typedef void (^FlutterMessageHandler)(id _Nullable message, FlutterReply callback);
/**
A channel for communicating with the Flutter side using basic, asynchronous
message passing.
*/
FLUTTER_EXPORT
@interface FlutterBasicMessageChannel : NSObject
/**
Creates a `FlutterBasicMessageChannel` with the specified name and binary
messenger.
The channel name logically identifies the channel; identically named channels
interfere with each other's communication.
The binary messenger is a facility for sending raw, binary messages to the
Flutter side. This protocol is implemented by `FlutterViewController`.
The channel uses `FlutterStandardMessageCodec` to encode and decode messages.
- Parameters:
- name: The channel name.
- messenger: The binary messenger.
*/
+ (instancetype)messageChannelWithName:(NSString*)name
binaryMessenger:(NSObject<FlutterBinaryMessenger>*)messenger;
/**
Creates a `FlutterBasicMessageChannel` with the specified name, binary
messenger,
and message codec.
The channel name logically identifies the channel; identically named channels
interfere with each other's communication.
The binary messenger is a facility for sending raw, binary messages to the
Flutter side. This protocol is implemented by `FlutterViewController`.
- Parameters:
- name: The channel name.
- messenger: The binary messenger.
- codec: The message codec.
*/
+ (instancetype)messageChannelWithName:(NSString*)name
binaryMessenger:(NSObject<FlutterBinaryMessenger>*)messenger
codec:(NSObject<FlutterMessageCodec>*)codec;
/**
Initializes a `FlutterBasicMessageChannel` with the specified name, binary
messenger, and message codec.
The channel name logically identifies the channel; identically named channels
interfere with each other's communication.
The binary messenger is a facility for sending raw, binary messages to the
Flutter side. This protocol is implemented by `FlutterViewController`.
- Parameters:
- name: The channel name.
- messenger: The binary messenger.
- codec: The message codec.
*/
- (instancetype)initWithName:(NSString*)name
binaryMessenger:(NSObject<FlutterBinaryMessenger>*)messenger
codec:(NSObject<FlutterMessageCodec>*)codec;
/**
Sends the specified message to the Flutter side, ignoring any reply.
- Parameter message: The message. Must be supported by the codec of this
channel.
*/
- (void)sendMessage:(id _Nullable)message;
/**
Sends the specified message to the Flutter side, expecting an asynchronous
reply.
- Parameters:
- message: The message. Must be supported by the codec of this channel.
- callback: A callback to be invoked with the message reply from Flutter.
*/
- (void)sendMessage:(id _Nullable)message reply:(FlutterReply _Nullable)callback;
/**
Registers a message handler with this channel.
Replaces any existing handler. Use a `nil` handler for unregistering the
existing handler.
- Parameter handler: The message handler.
*/
- (void)setMessageHandler:(FlutterMessageHandler _Nullable)handler;
@end
/**
A method call result callback.
Used for submitting a method call result back to a Flutter caller. Also used in
the dual capacity for handling a method call result received from Flutter.
- Parameter result: The result.
*/
typedef void (^FlutterResult)(id _Nullable result);
/**
A strategy for handling method calls.
- Parameters:
- call: The incoming method call.
- result: A callback to asynchronously submit the result of the call.
Invoke the callback with a `FlutterError` to indicate that the call failed.
Invoke the callback with `FlutterMethodNotImplemented` to indicate that the
method was unknown. Any other values, including `nil`, are interpreted as
successful results.
*/
typedef void (^FlutterMethodCallHandler)(FlutterMethodCall* call, FlutterResult result);
/**
A constant used with `FlutterMethodCallHandler` to respond to the call of an
unknown method.
*/
FLUTTER_EXPORT
extern NSObject const* FlutterMethodNotImplemented;
/**
A channel for communicating with the Flutter side using invocation of
asynchronous methods.
*/
FLUTTER_EXPORT
@interface FlutterMethodChannel : NSObject
/**
Creates a `FlutterMethodChannel` with the specified name and binary messenger.
The channel name logically identifies the channel; identically named channels
interfere with each other's communication.
The binary messenger is a facility for sending raw, binary messages to the
Flutter side. This protocol is implemented by `FlutterViewController`.
The channel uses `FlutterStandardMethodCodec` to encode and decode method calls
and result envelopes.
- Parameters:
- name: The channel name.
- messenger: The binary messenger.
*/
+ (instancetype)methodChannelWithName:(NSString*)name
binaryMessenger:(NSObject<FlutterBinaryMessenger>*)messenger;
/**
Creates a `FlutterMethodChannel` with the specified name, binary messenger, and
method codec.
The channel name logically identifies the channel; identically named channels
interfere with each other's communication.
The binary messenger is a facility for sending raw, binary messages to the
Flutter side. This protocol is implemented by `FlutterViewController`.
- Parameters:
- name: The channel name.
- messenger: The binary messenger.
- codec: The method codec.
*/
+ (instancetype)methodChannelWithName:(NSString*)name
binaryMessenger:(NSObject<FlutterBinaryMessenger>*)messenger
codec:(NSObject<FlutterMethodCodec>*)codec;
/**
Initializes a `FlutterMethodChannel` with the specified name, binary messenger,
and method codec.
The channel name logically identifies the channel; identically named channels
interfere with each other's communication.
The binary messenger is a facility for sending raw, binary messages to the
Flutter side. This protocol is implemented by `FlutterViewController`.
- Parameters:
- name: The channel name.
- messenger: The binary messenger.
- codec: The method codec.
*/
- (instancetype)initWithName:(NSString*)name
binaryMessenger:(NSObject<FlutterBinaryMessenger>*)messenger
codec:(NSObject<FlutterMethodCodec>*)codec;
/**
Invokes the specified Flutter method with the specified arguments, expecting
no results.
- Parameters:
- method: The name of the method to invoke.
- arguments: The arguments. Must be a value supported by the codec of this
channel.
*/
- (void)invokeMethod:(NSString*)method arguments:(id _Nullable)arguments;
/**
Invokes the specified Flutter method with the specified arguments, expecting
an asynchronous result.
- Parameters:
- method: The name of the method to invoke.
- arguments: The arguments. Must be a value supported by the codec of this
channel.
- result: A callback that will be invoked with the asynchronous result.
The result will be a `FlutterError` instance, if the method call resulted
in an error on the Flutter side. Will be `FlutterMethodNotImplemented`, if
the method called was not implemented on the Flutter side. Any other value,
including `nil`, should be interpreted as successful results.
*/
- (void)invokeMethod:(NSString*)method
arguments:(id _Nullable)arguments
result:(FlutterResult _Nullable)callback;
/**
Registers a handler for method calls from the Flutter side.
Replaces any existing handler. Use a `nil` handler for unregistering the
existing handler.
- Parameter handler: The method call handler.
*/
- (void)setMethodCallHandler:(FlutterMethodCallHandler _Nullable)handler;
@end
/**
An event sink callback.
- Parameter event: The event.
*/
typedef void (^FlutterEventSink)(id _Nullable event);
/**
A strategy for exposing an event stream to the Flutter side.
*/
FLUTTER_EXPORT
@protocol FlutterStreamHandler
/**
Sets up an event stream and begin emitting events.
Invoked when the first listener is registered with the Stream associated to
this channel on the Flutter side.
- Parameters:
- arguments: Arguments for the stream.
- events: A callback to asynchronously emit events. Invoke the
callback with a `FlutterError` to emit an error event. Invoke the
callback with `FlutterEndOfEventStream` to indicate that no more
events will be emitted. Any other value, including `nil` are emitted as
successful events.
- Returns: A FlutterError instance, if setup fails.
*/
- (FlutterError* _Nullable)onListenWithArguments:(id _Nullable)arguments
eventSink:(FlutterEventSink)events;
/**
Tears down an event stream.
Invoked when the last listener is deregistered from the Stream associated to
this channel on the Flutter side.
- Parameter arguments: Arguments for the stream.
- Returns: A FlutterError instance, if teardown fails.
*/
- (FlutterError* _Nullable)onCancelWithArguments:(id _Nullable)arguments;
@end
/**
A constant used with `FlutterEventChannel` to indicate end of stream.
*/
FLUTTER_EXPORT
extern NSObject const* FlutterEndOfEventStream;
/**
A channel for communicating with the Flutter side using event streams.
*/
FLUTTER_EXPORT
@interface FlutterEventChannel : NSObject
/**
Creates a `FlutterEventChannel` with the specified name and binary messenger.
The channel name logically identifies the channel; identically named channels
interfere with each other's communication.
The binary messenger is a facility for sending raw, binary messages to the
Flutter side. This protocol is implemented by `FlutterViewController`.
The channel uses `FlutterStandardMethodCodec` to decode stream setup and
teardown requests, and to encode event envelopes.
- Parameters:
- name: The channel name.
- messenger: The binary messenger.
- codec: The method codec.
*/
+ (instancetype)eventChannelWithName:(NSString*)name
binaryMessenger:(NSObject<FlutterBinaryMessenger>*)messenger;
/**
Creates a `FlutterEventChannel` with the specified name, binary messenger,
and method codec.
The channel name logically identifies the channel; identically named channels
interfere with each other's communication.
The binary messenger is a facility for sending raw, binary messages to the
Flutter side. This protocol is implemented by `FlutterViewController`.
- Parameters:
- name: The channel name.
- messenger: The binary messenger.
- codec: The method codec.
*/
+ (instancetype)eventChannelWithName:(NSString*)name
binaryMessenger:(NSObject<FlutterBinaryMessenger>*)messenger
codec:(NSObject<FlutterMethodCodec>*)codec;
/**
Initializes a `FlutterEventChannel` with the specified name, binary messenger,
and method codec.
The channel name logically identifies the channel; identically named channels
interfere with each other's communication.
The binary messenger is a facility for sending raw, binary messages to the
Flutter side. This protocol is implemented by `FlutterViewController`.
- Parameters:
- name: The channel name.
- messenger: The binary messenger.
- codec: The method codec.
*/
- (instancetype)initWithName:(NSString*)name
binaryMessenger:(NSObject<FlutterBinaryMessenger>*)messenger
codec:(NSObject<FlutterMethodCodec>*)codec;
/**
Registers a handler for stream setup requests from the Flutter side.
Replaces any existing handler. Use a `nil` handler for unregistering the
existing handler.
- Parameter handler: The stream handler.
*/
- (void)setStreamHandler:(NSObject<FlutterStreamHandler>* _Nullable)handler;
@end
NS_ASSUME_NONNULL_END
#endif // FLUTTER_FLUTTERCHANNELS_H_

View File

@@ -0,0 +1,369 @@
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef FLUTTER_FLUTTERCODECS_H_
#define FLUTTER_FLUTTERCODECS_H_
#import <Foundation/Foundation.h>
#include "FlutterMacros.h"
NS_ASSUME_NONNULL_BEGIN
/**
A message encoding/decoding mechanism.
*/
FLUTTER_EXPORT
@protocol FlutterMessageCodec
/**
Returns a shared instance of this `FlutterMessageCodec`.
*/
+ (instancetype)sharedInstance;
/**
Encodes the specified message into binary.
- Parameter message: The message.
- Returns: The binary encoding, or `nil`, if `message` was `nil`.
*/
- (NSData* _Nullable)encode:(id _Nullable)message;
/**
Decodes the specified message from binary.
- Parameter message: The message.
- Returns: The decoded message, or `nil`, if `message` was `nil`.
*/
- (id _Nullable)decode:(NSData* _Nullable)message;
@end
/**
A `FlutterMessageCodec` using unencoded binary messages, represented as
`NSData` instances.
This codec is guaranteed to be compatible with the corresponding
[BinaryCodec](https://docs.flutter.io/flutter/services/BinaryCodec-class.html)
on the Dart side. These parts of the Flutter SDK are evolved synchronously.
On the Dart side, messages are represented using `ByteData`.
*/
FLUTTER_EXPORT
@interface FlutterBinaryCodec : NSObject<FlutterMessageCodec>
@end
/**
A `FlutterMessageCodec` using UTF-8 encoded `NSString` messages.
This codec is guaranteed to be compatible with the corresponding
[StringCodec](https://docs.flutter.io/flutter/services/StringCodec-class.html)
on the Dart side. These parts of the Flutter SDK are evolved synchronously.
*/
FLUTTER_EXPORT
@interface FlutterStringCodec : NSObject<FlutterMessageCodec>
@end
/**
A `FlutterMessageCodec` using UTF-8 encoded JSON messages.
This codec is guaranteed to be compatible with the corresponding
[JSONMessageCodec](https://docs.flutter.io/flutter/services/JSONMessageCodec-class.html)
on the Dart side. These parts of the Flutter SDK are evolved synchronously.
Supports values accepted by `NSJSONSerialization` plus top-level
`nil`, `NSNumber`, and `NSString`.
On the Dart side, JSON messages are handled by the JSON facilities of the
[`dart:convert`](https://api.dartlang.org/stable/dart-convert/JSON-constant.html)
package.
*/
FLUTTER_EXPORT
@interface FlutterJSONMessageCodec : NSObject<FlutterMessageCodec>
@end
/**
A `FlutterMessageCodec` using the Flutter standard binary encoding.
This codec is guaranteed to be compatible with the corresponding
[StandardMessageCodec](https://docs.flutter.io/flutter/services/StandardMessageCodec-class.html)
on the Dart side. These parts of the Flutter SDK are evolved synchronously.
Supported messages are acyclic values of these forms:
- `nil` or `NSNull`
- `NSNumber` (including their representation of Boolean values)
- `FlutterStandardBigInteger`
- `NSString`
- `FlutterStandardTypedData`
- `NSArray` of supported values
- `NSDictionary` with supported keys and values
On the Dart side, these values are represented as follows:
- `nil` or `NSNull`: `null`
- `NSNumber`: `bool`, `int`, or `double`, depending on the contained value.
- `FlutterStandardBigInteger`: `int`
- `NSString`: `String`
- `FlutterStandardTypedData`: `Uint8List`, `Int32List`, `Int64List`, or `Float64List`
- `NSArray`: `List`
- `NSDictionary`: `Map`
*/
FLUTTER_EXPORT
@interface FlutterStandardMessageCodec : NSObject<FlutterMessageCodec>
@end
/**
Command object representing a method call on a `FlutterMethodChannel`.
*/
FLUTTER_EXPORT
@interface FlutterMethodCall : NSObject
/**
Creates a method call for invoking the specified named method with the
specified arguments.
- Parameters:
- method: the name of the method to call.
- arguments: the arguments value.
*/
+ (instancetype)methodCallWithMethodName:(NSString*)method arguments:(id _Nullable)arguments;
/**
The method name.
*/
@property(readonly, nonatomic) NSString* method;
/**
The arguments.
*/
@property(readonly, nonatomic, nullable) id arguments;
@end
/**
Error object representing an unsuccessful outcome of invoking a method
on a `FlutterMethodChannel`, or an error event on a `FlutterEventChannel`.
*/
FLUTTER_EXPORT
@interface FlutterError : NSObject
/**
Creates a `FlutterError` with the specified error code, message, and details.
- Parameters:
- code: An error code string for programmatic use.
- message: A human-readable error message.
- details: Custom error details.
*/
+ (instancetype)errorWithCode:(NSString*)code
message:(NSString* _Nullable)message
details:(id _Nullable)details;
/**
The error code.
*/
@property(readonly, nonatomic) NSString* code;
/**
The error message.
*/
@property(readonly, nonatomic, nullable) NSString* message;
/**
The error details.
*/
@property(readonly, nonatomic, nullable) id details;
@end
/**
Type of numeric data items encoded in a `FlutterStandardDataType`.
- FlutterStandardDataTypeUInt8: plain bytes
- FlutterStandardDataTypeInt32: 32-bit signed integers
- FlutterStandardDataTypeInt64: 64-bit signed integers
- FlutterStandardDataTypeFloat64: 64-bit floats
*/
typedef NS_ENUM(NSInteger, FlutterStandardDataType) {
FlutterStandardDataTypeUInt8,
FlutterStandardDataTypeInt32,
FlutterStandardDataTypeInt64,
FlutterStandardDataTypeFloat64,
};
/**
A byte buffer holding `UInt8`, `SInt32`, `SInt64`, or `Float64` values, used
with `FlutterStandardMessageCodec` and `FlutterStandardMethodCodec`.
Two's complement encoding is used for signed integers. IEEE754
double-precision representation is used for floats. The platform's native
endianness is assumed.
*/
FLUTTER_EXPORT
@interface FlutterStandardTypedData : NSObject
/**
Creates a `FlutterStandardTypedData` which interprets the specified data
as plain bytes.
- Parameter data: the byte data.
*/
+ (instancetype)typedDataWithBytes:(NSData*)data;
/**
Creates a `FlutterStandardTypedData` which interprets the specified data
as 32-bit signed integers.
- Parameter data: the byte data. The length must be divisible by 4.
*/
+ (instancetype)typedDataWithInt32:(NSData*)data;
/**
Creates a `FlutterStandardTypedData` which interprets the specified data
as 64-bit signed integers.
- Parameter data: the byte data. The length must be divisible by 8.
*/
+ (instancetype)typedDataWithInt64:(NSData*)data;
/**
Creates a `FlutterStandardTypedData` which interprets the specified data
as 64-bit floats.
- Parameter data: the byte data. The length must be divisible by 8.
*/
+ (instancetype)typedDataWithFloat64:(NSData*)data;
/**
The raw underlying data buffer.
*/
@property(readonly, nonatomic) NSData* data;
/**
The type of the encoded values.
*/
@property(readonly, nonatomic) FlutterStandardDataType type;
/**
The number of value items encoded.
*/
@property(readonly, nonatomic) UInt32 elementCount;
/**
The number of bytes used by the encoding of a single value item.
*/
@property(readonly, nonatomic) UInt8 elementSize;
@end
/**
An arbitrarily large integer value, used with `FlutterStandardMessageCodec`
and `FlutterStandardMethodCodec`.
*/
FLUTTER_EXPORT
@interface FlutterStandardBigInteger : NSObject
/**
Creates a `FlutterStandardBigInteger` from a hexadecimal representation.
- Parameter hex: a hexadecimal string.
*/
+ (instancetype)bigIntegerWithHex:(NSString*)hex;
/**
The hexadecimal string representation of this integer.
*/
@property(readonly, nonatomic) NSString* hex;
@end
/**
A codec for method calls and enveloped results.
Method calls are encoded as binary messages with enough structure that the
codec can extract a method name `NSString` and an arguments `NSObject`,
possibly `nil`. These data items are used to populate a `FlutterMethodCall`.
Result envelopes are encoded as binary messages with enough structure that
the codec can determine whether the result was successful or an error. In
the former case, the codec can extract the result `NSObject`, possibly `nil`.
In the latter case, the codec can extract an error code `NSString`, a
human-readable `NSString` error message (possibly `nil`), and a custom
error details `NSObject`, possibly `nil`. These data items are used to
populate a `FlutterError`.
*/
FLUTTER_EXPORT
@protocol FlutterMethodCodec
/**
Provides access to a shared instance this codec.
- Returns: The shared instance.
*/
+ (instancetype)sharedInstance;
/**
Encodes the specified method call into binary.
- Parameter methodCall: The method call. The arguments value
must be supported by this codec.
- Returns: The binary encoding.
*/
- (NSData*)encodeMethodCall:(FlutterMethodCall*)methodCall;
/**
Decodes the specified method call from binary.
- Parameter methodCall: The method call to decode.
- Returns: The decoded method call.
*/
- (FlutterMethodCall*)decodeMethodCall:(NSData*)methodCall;
/**
Encodes the specified successful result into binary.
- Parameter result: The result. Must be a value supported by this codec.
- Returns: The binary encoding.
*/
- (NSData*)encodeSuccessEnvelope:(id _Nullable)result;
/**
Encodes the specified error result into binary.
- Parameter error: The error object. The error details value must be supported
by this codec.
- Returns: The binary encoding.
*/
- (NSData*)encodeErrorEnvelope:(FlutterError*)error;
/**
Deccodes the specified result envelope from binary.
- Parameter error: The error object.
- Returns: The result value, if the envelope represented a successful result,
or a `FlutterError` instance, if not.
*/
- (id _Nullable)decodeEnvelope:(NSData*)envelope;
@end
/**
A `FlutterMethodCodec` using UTF-8 encoded JSON method calls and result
envelopes.
This codec is guaranteed to be compatible with the corresponding
[JSONMethodCodec](https://docs.flutter.io/flutter/services/JSONMethodCodec-class.html)
on the Dart side. These parts of the Flutter SDK are evolved synchronously.
Values supported as methods arguments and result payloads are
those supported as top-level or leaf values by `FlutterJSONMessageCodec`.
*/
FLUTTER_EXPORT
@interface FlutterJSONMethodCodec : NSObject<FlutterMethodCodec>
@end
/**
A `FlutterMethodCodec` using the Flutter standard binary encoding.
This codec is guaranteed to be compatible with the corresponding
[StandardMethodCodec](https://docs.flutter.io/flutter/services/StandardMethodCodec-class.html)
on the Dart side. These parts of the Flutter SDK are evolved synchronously.
Values supported as method arguments and result payloads are those supported by
`FlutterStandardMessageCodec`.
*/
FLUTTER_EXPORT
@interface FlutterStandardMethodCodec : NSObject<FlutterMethodCodec>
@end
NS_ASSUME_NONNULL_END
#endif // FLUTTER_FLUTTERCODECS_H_

View File

@@ -0,0 +1,27 @@
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef FLUTTER_FLUTTERDARTPROJECT_H_
#define FLUTTER_FLUTTERDARTPROJECT_H_
#import <Foundation/Foundation.h>
#include "FlutterMacros.h"
FLUTTER_EXPORT
@interface FlutterDartProject : NSObject
- (instancetype)initWithPrecompiledDartBundle:(NSBundle*)bundle NS_DESIGNATED_INITIALIZER;
- (instancetype)initWithFLXArchive:(NSURL*)archiveURL
dartMain:(NSURL*)dartMainURL
packages:(NSURL*)dartPackages NS_DESIGNATED_INITIALIZER;
- (instancetype)initWithFLXArchiveWithScriptSnapshot:(NSURL*)archiveURL NS_DESIGNATED_INITIALIZER;
- (instancetype)initFromDefaultSourceForConfiguration;
@end
#endif // FLUTTER_FLUTTERDARTPROJECT_H_

View File

@@ -0,0 +1,23 @@
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef FLUTTER_FLUTTERMACROS_H_
#define FLUTTER_FLUTTERMACROS_H_
#if defined(FLUTTER_FRAMEWORK)
#define FLUTTER_EXPORT __attribute__((visibility("default")))
#else // defined(FLUTTER_SDK)
#define FLUTTER_EXPORT
#endif // defined(FLUTTER_SDK)
#ifndef NS_ASSUME_NONNULL_BEGIN
#define NS_ASSUME_NONNULL_BEGIN _Pragma("clang assume_nonnull begin")
#define NS_ASSUME_NONNULL_END _Pragma("clang assume_nonnull end")
#endif // defined(NS_ASSUME_NONNULL_BEGIN)
#endif // FLUTTER_FLUTTERMACROS_H_

View File

@@ -0,0 +1,9 @@
// Copyright 2017 The Chromium 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 <UIKit/UIKit.h>
@interface FlutterNavigationController : UINavigationController
@end

View File

@@ -0,0 +1,212 @@
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef FLUTTER_FLUTTERPLUGIN_H_
#define FLUTTER_FLUTTERPLUGIN_H_
#import <UIKit/UIKit.h>
#include "FlutterBinaryMessenger.h"
#include "FlutterChannels.h"
#include "FlutterCodecs.h"
NS_ASSUME_NONNULL_BEGIN
@protocol FlutterPluginRegistrar;
/**
Implemented by the iOS part of a Flutter plugin.
Defines a set of optional callback methods and a method to set up the plugin
and register it to be called by other application components.
*/
@protocol FlutterPlugin<NSObject>
@required
/**
Registers this plugin.
- Parameters:
- registrar: A helper providing application context and methods for
registering callbacks
*/
+ (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar>*)registrar;
@optional
/**
Called if this plugin has been registered to receive `FlutterMethodCall`s.
- Parameters:
- call: The method call command object.
- result: A callback for submitting the result of the call.
*/
- (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result;
/**
Called if this plugin has been registered for `UIApplicationDelegate` callbacks.
- Returns: `NO` if this plugin vetoes application launch.
*/
- (BOOL)application:(UIApplication*)application
didFinishLaunchingWithOptions:(NSDictionary*)launchOptions;
/**
Called if this plugin has been registered for `UIApplicationDelegate` callbacks.
*/
- (void)applicationDidBecomeActive:(UIApplication*)application;
/**
Called if this plugin has been registered for `UIApplicationDelegate` callbacks.
*/
- (void)applicationWillResignActive:(UIApplication*)application;
/**
Called if this plugin has been registered for `UIApplicationDelegate` callbacks.
*/
- (void)applicationDidEnterBackground:(UIApplication*)application;
/**
Called if this plugin has been registered for `UIApplicationDelegate` callbacks.
*/
- (void)applicationWillEnterForeground:(UIApplication*)application;
/**
Called if this plugin has been registered for `UIApplicationDelegate` callbacks.
*/
- (void)applicationWillTerminate:(UIApplication*)application;
/**
Called if this plugin has been registered for `UIApplicationDelegate` callbacks.
*/
- (void)application:(UIApplication*)application
didRegisterUserNotificationSettings:(UIUserNotificationSettings*)notificationSettings;
/**
Called if this plugin has been registered for `UIApplicationDelegate` callbacks.
*/
- (void)application:(UIApplication*)application
didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken;
/**
Called if this plugin has been registered for `UIApplicationDelegate` callbacks.
- Returns: `YES` if this plugin handles the request.
*/
- (BOOL)application:(UIApplication*)application
didReceiveRemoteNotification:(NSDictionary*)userInfo
fetchCompletionHandler:(void (^)(UIBackgroundFetchResult result))completionHandler;
/**
Called if this plugin has been registered for `UIApplicationDelegate` callbacks.
- Returns: `YES` if this plugin handles the request.
*/
- (BOOL)application:(UIApplication*)application
openURL:(NSURL*)url
options:(NSDictionary<UIApplicationOpenURLOptionsKey, id>*)options;
/**
Called if this plugin has been registered for `UIApplicationDelegate` callbacks.
- Returns: `YES` if this plugin handles the request.
*/
- (BOOL)application:(UIApplication*)application handleOpenURL:(NSURL*)url;
/**
Called if this plugin has been registered for `UIApplicationDelegate` callbacks.
- Returns: `YES` if this plugin handles the request.
*/
- (BOOL)application:(UIApplication*)application
openURL:(NSURL*)url
sourceApplication:(NSString*)sourceApplication
annotation:(id)annotation;
/**
Called if this plugin has been registered for `UIApplicationDelegate` callbacks.
- Returns: `YES` if this plugin handles the request.
*/
- (BOOL)application:(UIApplication*)application
performActionForShortcutItem:(UIApplicationShortcutItem*)shortcutItem
completionHandler:(void (^)(BOOL succeeded))completionHandler;
@end
/**
Registration context for a single `FlutterPlugin`.
*/
@protocol FlutterPluginRegistrar<NSObject>
/**
Returns a `FlutterBinaryMessenger` for creating Dart/iOS communication
channels to be used by the plugin.
- Returns: The messenger.
*/
- (NSObject<FlutterBinaryMessenger>*)messenger;
/**
Publishes a value for external use of the plugin.
Plugins may publish a single value, such as an instance of the
plugin's main class, for situations where external control or
interaction is needed.
The published value will be available from the `FlutterPluginRegistry`.
Repeated calls overwrite any previous publication.
- Parameter value: The value to be published.
*/
- (void)publish:(NSObject*)value;
/**
Registers the plugin as a receiver of incoming method calls from the Dart side
on the specified `FlutterMethodChannel`.
- Parameters:
- delegate: The receiving object, such as the plugin's main class.
- channel: The channel
*/
- (void)addMethodCallDelegate:(NSObject<FlutterPlugin>*)delegate
channel:(FlutterMethodChannel*)channel;
/**
Registers the plugin as a receiver of `UIApplicationDelegate` calls.
- Parameters delegate: The receiving object, such as the plugin's main class.
*/
- (void)addApplicationDelegate:(NSObject<FlutterPlugin>*)delegate;
@end
/**
A registry of Flutter iOS plugins.
Plugins are identified by unique string keys, typically the name of the
plugin's main class.
*/
@protocol FlutterPluginRegistry<NSObject>
/**
Returns a registrar for registering a plugin.
- Parameter pluginKey: The unique key identifying the plugin.
*/
- (NSObject<FlutterPluginRegistrar>*)registrarForPlugin:(NSString*)pluginKey;
/**
Returns whether the specified plugin has been registered.
- Parameter pluginKey: The unique key identifying the plugin.
- Returns: `YES` if `registrarForPlugin` has been called with `pluginKey`.
*/
- (BOOL)hasPlugin:(NSString*)pluginKey;
/**
Returns a value published by the specified plugin.
- Parameter pluginKey: The unique key identifying the plugin.
- Returns: An object published by the plugin, if any. Will be `NSNull` if
nothing has been published. Will be `nil` if the plugin has not been
registered.
*/
- (NSObject*)valuePublishedByPlugin:(NSString*)pluginKey;
@end
NS_ASSUME_NONNULL_END;
#endif // FLUTTER_FLUTTERPLUGIN_H_

View File

@@ -0,0 +1,33 @@
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef FLUTTER_FLUTTERVIEWCONTROLLER_H_
#define FLUTTER_FLUTTERVIEWCONTROLLER_H_
#import <UIKit/UIKit.h>
#include <sys/cdefs.h>
#include "FlutterBinaryMessenger.h"
#include "FlutterDartProject.h"
#include "FlutterMacros.h"
FLUTTER_EXPORT
@interface FlutterViewController : UIViewController<FlutterBinaryMessenger>
- (instancetype)initWithProject:(FlutterDartProject*)project
nibName:(NSString*)nibNameOrNil
bundle:(NSBundle*)nibBundleOrNil NS_DESIGNATED_INITIALIZER;
- (void)handleStatusBarTouches:(UIEvent*)event;
/**
Sets the first route that the Flutter app shows. The default is "/".
- Parameter route: The name of the first route to show.
*/
- (void)setInitialRoute:(NSString*)route;
@end
#endif // FLUTTER_FLUTTERVIEWCONTROLLER_H_