You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
samples/add_to_app/books/ios_books/IosBooks/api.m

270 lines
8.3 KiB

// Autogenerated from Pigeon (v1.0.1), do not edit directly.
// See also: https://pub.dev/packages/pigeon
#import "api.h"
#import <Flutter/Flutter.h>
#if !__has_feature(objc_arc)
#error File requires ARC to be enabled.
#endif
static NSDictionary<NSString *, id> *wrapResult(id result,
FlutterError *error) {
NSDictionary *errorDict = (NSDictionary *)[NSNull null];
if (error) {
errorDict = @{
@"code" : (error.code ? error.code : [NSNull null]),
@"message" : (error.message ? error.message : [NSNull null]),
@"details" : (error.details ? error.details : [NSNull null]),
};
}
return @{
@"result" : (result ? result : [NSNull null]),
@"error" : errorDict,
};
}
@interface BKBook ()
+ (BKBook *)fromMap:(NSDictionary *)dict;
- (NSDictionary *)toMap;
@end
@interface BKThumbnail ()
+ (BKThumbnail *)fromMap:(NSDictionary *)dict;
- (NSDictionary *)toMap;
@end
@implementation BKBook
+ (BKBook *)fromMap:(NSDictionary *)dict {
BKBook *result = [[BKBook alloc] init];
result.title = dict[@"title"];
if ((NSNull *)result.title == [NSNull null]) {
result.title = nil;
}
result.subtitle = dict[@"subtitle"];
if ((NSNull *)result.subtitle == [NSNull null]) {
result.subtitle = nil;
}
result.author = dict[@"author"];
if ((NSNull *)result.author == [NSNull null]) {
result.author = nil;
}
result.summary = dict[@"summary"];
if ((NSNull *)result.summary == [NSNull null]) {
result.summary = nil;
}
result.publishDate = dict[@"publishDate"];
if ((NSNull *)result.publishDate == [NSNull null]) {
result.publishDate = nil;
}
result.pageCount = dict[@"pageCount"];
if ((NSNull *)result.pageCount == [NSNull null]) {
result.pageCount = nil;
}
result.thumbnail = [BKThumbnail fromMap:dict[@"thumbnail"]];
if ((NSNull *)result.thumbnail == [NSNull null]) {
result.thumbnail = nil;
}
return result;
}
- (NSDictionary *)toMap {
return [NSDictionary
dictionaryWithObjectsAndKeys:
(self.title ? self.title : [NSNull null]), @"title",
(self.subtitle ? self.subtitle : [NSNull null]), @"subtitle",
(self.author ? self.author : [NSNull null]), @"author",
(self.summary ? self.summary : [NSNull null]), @"summary",
(self.publishDate ? self.publishDate : [NSNull null]), @"publishDate",
(self.pageCount ? self.pageCount : [NSNull null]), @"pageCount",
(self.thumbnail ? [self.thumbnail toMap] : [NSNull null]),
@"thumbnail", nil];
}
@end
@implementation BKThumbnail
+ (BKThumbnail *)fromMap:(NSDictionary *)dict {
BKThumbnail *result = [[BKThumbnail alloc] init];
result.url = dict[@"url"];
if ((NSNull *)result.url == [NSNull null]) {
result.url = nil;
}
return result;
}
- (NSDictionary *)toMap {
return [NSDictionary
dictionaryWithObjectsAndKeys:(self.url ? self.url : [NSNull null]),
@"url", nil];
}
@end
@interface BKFlutterBookApiCodecReader : FlutterStandardReader
@end
@implementation BKFlutterBookApiCodecReader
- (nullable id)readValueOfType:(UInt8)type {
switch (type) {
case 128:
return [BKBook fromMap:[self readValue]];
default:
return [super readValueOfType:type];
}
}
@end
@interface BKFlutterBookApiCodecWriter : FlutterStandardWriter
@end
@implementation BKFlutterBookApiCodecWriter
- (void)writeValue:(id)value {
if ([value isKindOfClass:[BKBook class]]) {
[self writeByte:128];
[self writeValue:[value toMap]];
} else {
[super writeValue:value];
}
}
@end
@interface BKFlutterBookApiCodecReaderWriter : FlutterStandardReaderWriter
@end
@implementation BKFlutterBookApiCodecReaderWriter
- (FlutterStandardWriter *)writerWithData:(NSMutableData *)data {
return [[BKFlutterBookApiCodecWriter alloc] initWithData:data];
}
- (FlutterStandardReader *)readerWithData:(NSData *)data {
return [[BKFlutterBookApiCodecReader alloc] initWithData:data];
}
@end
NSObject<FlutterMessageCodec> *BKFlutterBookApiGetCodec() {
static dispatch_once_t s_pred = 0;
static FlutterStandardMessageCodec *s_sharedObject = nil;
dispatch_once(&s_pred, ^{
BKFlutterBookApiCodecReaderWriter *readerWriter =
[[BKFlutterBookApiCodecReaderWriter alloc] init];
s_sharedObject =
[FlutterStandardMessageCodec codecWithReaderWriter:readerWriter];
});
return s_sharedObject;
}
@interface BKFlutterBookApi ()
@property(nonatomic, strong) NSObject<FlutterBinaryMessenger> *binaryMessenger;
@end
@implementation BKFlutterBookApi
- (instancetype)initWithBinaryMessenger:
(NSObject<FlutterBinaryMessenger> *)binaryMessenger {
self = [super init];
if (self) {
_binaryMessenger = binaryMessenger;
}
return self;
}
- (void)displayBookDetailsBook:(BKBook *)arg_book
completion:(void (^)(NSError *_Nullable))completion {
FlutterBasicMessageChannel *channel = [FlutterBasicMessageChannel
messageChannelWithName:
@"dev.flutter.pigeon.FlutterBookApi.displayBookDetails"
binaryMessenger:self.binaryMessenger
codec:BKFlutterBookApiGetCodec()];
[channel sendMessage:@[ arg_book ]
reply:^(id reply) {
completion(nil);
}];
}
@end
@interface BKHostBookApiCodecReader : FlutterStandardReader
@end
@implementation BKHostBookApiCodecReader
- (nullable id)readValueOfType:(UInt8)type {
switch (type) {
case 128:
return [BKBook fromMap:[self readValue]];
default:
return [super readValueOfType:type];
}
}
@end
@interface BKHostBookApiCodecWriter : FlutterStandardWriter
@end
@implementation BKHostBookApiCodecWriter
- (void)writeValue:(id)value {
if ([value isKindOfClass:[BKBook class]]) {
[self writeByte:128];
[self writeValue:[value toMap]];
} else {
[super writeValue:value];
}
}
@end
@interface BKHostBookApiCodecReaderWriter : FlutterStandardReaderWriter
@end
@implementation BKHostBookApiCodecReaderWriter
- (FlutterStandardWriter *)writerWithData:(NSMutableData *)data {
return [[BKHostBookApiCodecWriter alloc] initWithData:data];
}
- (FlutterStandardReader *)readerWithData:(NSData *)data {
return [[BKHostBookApiCodecReader alloc] initWithData:data];
}
@end
NSObject<FlutterMessageCodec> *BKHostBookApiGetCodec() {
static dispatch_once_t s_pred = 0;
static FlutterStandardMessageCodec *s_sharedObject = nil;
dispatch_once(&s_pred, ^{
BKHostBookApiCodecReaderWriter *readerWriter =
[[BKHostBookApiCodecReaderWriter alloc] init];
s_sharedObject =
[FlutterStandardMessageCodec codecWithReaderWriter:readerWriter];
});
return s_sharedObject;
}
void BKHostBookApiSetup(id<FlutterBinaryMessenger> binaryMessenger,
NSObject<BKHostBookApi> *api) {
{
FlutterBasicMessageChannel *channel = [FlutterBasicMessageChannel
messageChannelWithName:@"dev.flutter.pigeon.HostBookApi.cancel"
binaryMessenger:binaryMessenger
codec:BKHostBookApiGetCodec()];
if (api) {
NSCAssert(
[api respondsToSelector:@selector(cancelWithError:)],
@"BKHostBookApi api doesn't respond to @selector(cancelWithError:)");
[channel
setMessageHandler:^(id _Nullable message, FlutterReply callback) {
FlutterError *error;
[api cancelWithError:&error];
callback(wrapResult(nil, error));
}];
} else {
[channel setMessageHandler:nil];
}
}
{
FlutterBasicMessageChannel *channel = [FlutterBasicMessageChannel
messageChannelWithName:
@"dev.flutter.pigeon.HostBookApi.finishEditingBook"
binaryMessenger:binaryMessenger
codec:BKHostBookApiGetCodec()];
if (api) {
NSCAssert([api respondsToSelector:@selector(finishEditingBookBook:
error:)],
@"BKHostBookApi api doesn't respond to "
@"@selector(finishEditingBookBook:error:)");
[channel
setMessageHandler:^(id _Nullable message, FlutterReply callback) {
NSArray *args = message;
BKBook *arg_book = args[0];
FlutterError *error;
[api finishEditingBookBook:arg_book error:&error];
callback(wrapResult(nil, error));
}];
} else {
[channel setMessageHandler:nil];
}
}
}