|
|
|
@ -1,4 +1,4 @@
|
|
|
|
|
// Autogenerated from Pigeon (v0.1.17), do not edit directly.
|
|
|
|
|
// Autogenerated from Pigeon (v1.0.1), do not edit directly.
|
|
|
|
|
// See also: https://pub.dev/packages/pigeon
|
|
|
|
|
#import "api.h"
|
|
|
|
|
#import <Flutter/Flutter.h>
|
|
|
|
@ -7,29 +7,34 @@
|
|
|
|
|
#error File requires ARC to be enabled.
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
static NSDictionary* wrapResult(NSDictionary *result, FlutterError *error) {
|
|
|
|
|
static NSDictionary<NSString *, id> *wrapResult(id result,
|
|
|
|
|
FlutterError *error) {
|
|
|
|
|
NSDictionary *errorDict = (NSDictionary *)[NSNull null];
|
|
|
|
|
if (error) {
|
|
|
|
|
errorDict = [NSDictionary dictionaryWithObjectsAndKeys:
|
|
|
|
|
(error.code ? error.code : [NSNull null]), @"code",
|
|
|
|
|
(error.message ? error.message : [NSNull null]), @"message",
|
|
|
|
|
(error.details ? error.details : [NSNull null]), @"details",
|
|
|
|
|
nil];
|
|
|
|
|
errorDict = @{
|
|
|
|
|
@"code" : (error.code ? error.code : [NSNull null]),
|
|
|
|
|
@"message" : (error.message ? error.message : [NSNull null]),
|
|
|
|
|
@"details" : (error.details ? error.details : [NSNull null]),
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
return [NSDictionary dictionaryWithObjectsAndKeys:
|
|
|
|
|
(result ? result : [NSNull null]), @"result",
|
|
|
|
|
errorDict, @"error",
|
|
|
|
|
nil];
|
|
|
|
|
return @{
|
|
|
|
|
@"result" : (result ? result : [NSNull null]),
|
|
|
|
|
@"error" : errorDict,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@interface BKBook ()
|
|
|
|
|
+(BKBook*)fromMap:(NSDictionary*)dict;
|
|
|
|
|
-(NSDictionary*)toMap;
|
|
|
|
|
+ (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];
|
|
|
|
|
+ (BKBook *)fromMap:(NSDictionary *)dict {
|
|
|
|
|
BKBook *result = [[BKBook alloc] init];
|
|
|
|
|
result.title = dict[@"title"];
|
|
|
|
|
if ((NSNull *)result.title == [NSNull null]) {
|
|
|
|
|
result.title = nil;
|
|
|
|
@ -54,68 +59,210 @@ static NSDictionary* wrapResult(NSDictionary *result, FlutterError *error) {
|
|
|
|
|
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.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", nil];
|
|
|
|
|
- (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;
|
|
|
|
|
@property(nonatomic, strong) NSObject<FlutterBinaryMessenger> *binaryMessenger;
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
@implementation BKFlutterBookApi
|
|
|
|
|
- (instancetype)initWithBinaryMessenger:(NSObject<FlutterBinaryMessenger>*)binaryMessenger {
|
|
|
|
|
- (instancetype)initWithBinaryMessenger:
|
|
|
|
|
(NSObject<FlutterBinaryMessenger> *)binaryMessenger {
|
|
|
|
|
self = [super init];
|
|
|
|
|
if (self) {
|
|
|
|
|
self.binaryMessenger = binaryMessenger;
|
|
|
|
|
_binaryMessenger = binaryMessenger;
|
|
|
|
|
}
|
|
|
|
|
return self;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)displayBookDetails:(BKBook*)input completion:(void(^)(NSError* _Nullable))completion {
|
|
|
|
|
FlutterBasicMessageChannel *channel =
|
|
|
|
|
[FlutterBasicMessageChannel
|
|
|
|
|
messageChannelWithName:@"dev.flutter.pigeon.FlutterBookApi.displayBookDetails"
|
|
|
|
|
binaryMessenger:self.binaryMessenger];
|
|
|
|
|
NSDictionary* inputMap = [input toMap];
|
|
|
|
|
[channel sendMessage:inputMap reply:^(id reply) {
|
|
|
|
|
completion(nil);
|
|
|
|
|
}];
|
|
|
|
|
- (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
|
|
|
|
|
void BKHostBookApiSetup(id<FlutterBinaryMessenger> binaryMessenger, id<BKHostBookApi> api) {
|
|
|
|
|
|
|
|
|
|
@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
|
|
|
|
|
FlutterBasicMessageChannel *channel = [FlutterBasicMessageChannel
|
|
|
|
|
messageChannelWithName:@"dev.flutter.pigeon.HostBookApi.cancel"
|
|
|
|
|
binaryMessenger:binaryMessenger];
|
|
|
|
|
binaryMessenger:binaryMessenger
|
|
|
|
|
codec:BKHostBookApiGetCodec()];
|
|
|
|
|
if (api) {
|
|
|
|
|
[channel setMessageHandler:^(id _Nullable message, FlutterReply callback) {
|
|
|
|
|
FlutterError *error;
|
|
|
|
|
[api cancel:&error];
|
|
|
|
|
callback(wrapResult(nil, error));
|
|
|
|
|
}];
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
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];
|
|
|
|
|
FlutterBasicMessageChannel *channel = [FlutterBasicMessageChannel
|
|
|
|
|
messageChannelWithName:
|
|
|
|
|
@"dev.flutter.pigeon.HostBookApi.finishEditingBook"
|
|
|
|
|
binaryMessenger:binaryMessenger
|
|
|
|
|
codec:BKHostBookApiGetCodec()];
|
|
|
|
|
if (api) {
|
|
|
|
|
[channel setMessageHandler:^(id _Nullable message, FlutterReply callback) {
|
|
|
|
|
FlutterError *error;
|
|
|
|
|
BKBook *input = [BKBook fromMap:message];
|
|
|
|
|
[api finishEditingBook:input error:&error];
|
|
|
|
|
callback(wrapResult(nil, error));
|
|
|
|
|
}];
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
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];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|