Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.
Prev Previous commit
Next Next commit
Autoformat generated Pigeon code
  • Loading branch information
stuartmorgan-g committed Apr 15, 2022
commit 8fd936ac36b918096377aacb8e8543cd7873c91a
27 changes: 17 additions & 10 deletions packages/image_picker/image_picker_ios/ios/Classes/messages.g.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,15 @@ typedef NS_ENUM(NSUInteger, FLTSourceType) {
@class FLTSourceSpecification;

@interface FLTMaxSize : NSObject
+ (instancetype)makeWithWidth:(nullable NSNumber *)width
height:(nullable NSNumber *)height;
@property(nonatomic, strong, nullable) NSNumber * width;
@property(nonatomic, strong, nullable) NSNumber * height;
+ (instancetype)makeWithWidth:(nullable NSNumber *)width height:(nullable NSNumber *)height;
@property(nonatomic, strong, nullable) NSNumber *width;
@property(nonatomic, strong, nullable) NSNumber *height;
@end

@interface FLTSourceSpecification : NSObject
/// `init` unavailable to enforce nonnull fields, see the `make` class method.
- (instancetype)init NS_UNAVAILABLE;
+ (instancetype)makeWithType:(FLTSourceType)type
camera:(FLTSourceCamera)camera;
+ (instancetype)makeWithType:(FLTSourceType)type camera:(FLTSourceCamera)camera;
@property(nonatomic, assign) FLTSourceType type;
@property(nonatomic, assign) FLTSourceCamera camera;
@end
Expand All @@ -44,11 +42,20 @@ typedef NS_ENUM(NSUInteger, FLTSourceType) {
NSObject<FlutterMessageCodec> *FLTImagePickerApiGetCodec(void);

@protocol FLTImagePickerApi
- (void)pickImageWithSource:(FLTSourceSpecification *)source maxSize:(FLTMaxSize *)maxSize quality:(nullable NSNumber *)imageQuality completion:(void(^)(NSString *_Nullable, FlutterError *_Nullable))completion;
- (void)pickMultiImageWithMaxSize:(FLTMaxSize *)maxSize quality:(nullable NSNumber *)imageQuality completion:(void(^)(NSArray<NSString *> *_Nullable, FlutterError *_Nullable))completion;
- (void)pickVideoWithSource:(FLTSourceSpecification *)source maxDuration:(nullable NSNumber *)maxDurationSeconds completion:(void(^)(NSString *_Nullable, FlutterError *_Nullable))completion;
- (void)pickImageWithSource:(FLTSourceSpecification *)source
maxSize:(FLTMaxSize *)maxSize
quality:(nullable NSNumber *)imageQuality
completion:(void (^)(NSString *_Nullable, FlutterError *_Nullable))completion;
- (void)pickMultiImageWithMaxSize:(FLTMaxSize *)maxSize
quality:(nullable NSNumber *)imageQuality
completion:(void (^)(NSArray<NSString *> *_Nullable,
FlutterError *_Nullable))completion;
- (void)pickVideoWithSource:(FLTSourceSpecification *)source
maxDuration:(nullable NSNumber *)maxDurationSeconds
completion:(void (^)(NSString *_Nullable, FlutterError *_Nullable))completion;
@end

extern void FLTImagePickerApiSetup(id<FlutterBinaryMessenger> binaryMessenger, NSObject<FLTImagePickerApi> *_Nullable api);
extern void FLTImagePickerApiSetup(id<FlutterBinaryMessenger> binaryMessenger,
NSObject<FLTImagePickerApi> *_Nullable api);

NS_ASSUME_NONNULL_END
137 changes: 72 additions & 65 deletions packages/image_picker/image_picker_ios/ios/Classes/messages.g.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,25 @@
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]),
};
@"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,
};
@"result" : (result ? result : [NSNull null]),
@"error" : errorDict,
};
}
static id GetNullableObject(NSDictionary* dict, id key) {
static id GetNullableObject(NSDictionary *dict, id key) {
id result = dict[key];
return (result == [NSNull null]) ? nil : result;
}
static id GetNullableObjectAtIndex(NSArray* array, NSInteger key) {
static id GetNullableObjectAtIndex(NSArray *array, NSInteger key) {
id result = array[key];
return (result == [NSNull null]) ? nil : result;
}


@interface FLTMaxSize ()
+ (FLTMaxSize *)fromMap:(NSDictionary *)dict;
- (NSDictionary *)toMap;
Expand All @@ -44,9 +43,8 @@ - (NSDictionary *)toMap;
@end

@implementation FLTMaxSize
+ (instancetype)makeWithWidth:(nullable NSNumber *)width
height:(nullable NSNumber *)height {
FLTMaxSize* pigeonResult = [[FLTMaxSize alloc] init];
+ (instancetype)makeWithWidth:(nullable NSNumber *)width height:(nullable NSNumber *)height {
FLTMaxSize *pigeonResult = [[FLTMaxSize alloc] init];
pigeonResult.width = width;
pigeonResult.height = height;
return pigeonResult;
Expand All @@ -58,14 +56,15 @@ + (FLTMaxSize *)fromMap:(NSDictionary *)dict {
return pigeonResult;
}
- (NSDictionary *)toMap {
return [NSDictionary dictionaryWithObjectsAndKeys:(self.width ? self.width : [NSNull null]), @"width", (self.height ? self.height : [NSNull null]), @"height", nil];
return [NSDictionary
dictionaryWithObjectsAndKeys:(self.width ? self.width : [NSNull null]), @"width",
(self.height ? self.height : [NSNull null]), @"height", nil];
}
@end

@implementation FLTSourceSpecification
+ (instancetype)makeWithType:(FLTSourceType)type
camera:(FLTSourceCamera)camera {
FLTSourceSpecification* pigeonResult = [[FLTSourceSpecification alloc] init];
+ (instancetype)makeWithType:(FLTSourceType)type camera:(FLTSourceCamera)camera {
FLTSourceSpecification *pigeonResult = [[FLTSourceSpecification alloc] init];
pigeonResult.type = type;
pigeonResult.camera = camera;
return pigeonResult;
Expand All @@ -77,43 +76,39 @@ + (FLTSourceSpecification *)fromMap:(NSDictionary *)dict {
return pigeonResult;
}
- (NSDictionary *)toMap {
return [NSDictionary dictionaryWithObjectsAndKeys:@(self.type), @"type", @(self.camera), @"camera", nil];
return [NSDictionary
dictionaryWithObjectsAndKeys:@(self.type), @"type", @(self.camera), @"camera", nil];
}
@end

@interface FLTImagePickerApiCodecReader : FlutterStandardReader
@end
@implementation FLTImagePickerApiCodecReader
- (nullable id)readValueOfType:(UInt8)type
{
- (nullable id)readValueOfType:(UInt8)type {
switch (type) {
case 128:
case 128:
return [FLTMaxSize fromMap:[self readValue]];
case 129:

case 129:
return [FLTSourceSpecification fromMap:[self readValue]];
default:

default:
return [super readValueOfType:type];

}
}
@end

@interface FLTImagePickerApiCodecWriter : FlutterStandardWriter
@end
@implementation FLTImagePickerApiCodecWriter
- (void)writeValue:(id)value
{
- (void)writeValue:(id)value {
if ([value isKindOfClass:[FLTMaxSize class]]) {
[self writeByte:128];
[self writeValue:[value toMap]];
} else
if ([value isKindOfClass:[FLTSourceSpecification class]]) {
} else if ([value isKindOfClass:[FLTSourceSpecification class]]) {
[self writeByte:129];
[self writeValue:[value toMap]];
} else
{
} else {
[super writeValue:value];
}
}
Expand All @@ -134,75 +129,87 @@ - (FlutterStandardReader *)readerWithData:(NSData *)data {
static dispatch_once_t sPred = 0;
static FlutterStandardMessageCodec *sSharedObject = nil;
dispatch_once(&sPred, ^{
FLTImagePickerApiCodecReaderWriter *readerWriter = [[FLTImagePickerApiCodecReaderWriter alloc] init];
FLTImagePickerApiCodecReaderWriter *readerWriter =
[[FLTImagePickerApiCodecReaderWriter alloc] init];
sSharedObject = [FlutterStandardMessageCodec codecWithReaderWriter:readerWriter];
});
return sSharedObject;
}


void FLTImagePickerApiSetup(id<FlutterBinaryMessenger> binaryMessenger, NSObject<FLTImagePickerApi> *api) {
void FLTImagePickerApiSetup(id<FlutterBinaryMessenger> binaryMessenger,
NSObject<FLTImagePickerApi> *api) {
{
FlutterBasicMessageChannel *channel =
[[FlutterBasicMessageChannel alloc]
initWithName:@"dev.flutter.pigeon.ImagePickerApi.pickImage"
FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc]
initWithName:@"dev.flutter.pigeon.ImagePickerApi.pickImage"
binaryMessenger:binaryMessenger
codec:FLTImagePickerApiGetCodec() ];
codec:FLTImagePickerApiGetCodec()];
if (api) {
NSCAssert([api respondsToSelector:@selector(pickImageWithSource:maxSize:quality:completion:)], @"FLTImagePickerApi api (%@) doesn't respond to @selector(pickImageWithSource:maxSize:quality:completion:)", api);
NSCAssert([api respondsToSelector:@selector(pickImageWithSource:maxSize:quality:completion:)],
@"FLTImagePickerApi api (%@) doesn't respond to "
@"@selector(pickImageWithSource:maxSize:quality:completion:)",
api);
[channel setMessageHandler:^(id _Nullable message, FlutterReply callback) {
NSArray *args = message;
FLTSourceSpecification *arg_source = GetNullableObjectAtIndex(args, 0);
FLTMaxSize *arg_maxSize = GetNullableObjectAtIndex(args, 1);
NSNumber *arg_imageQuality = GetNullableObjectAtIndex(args, 2);
[api pickImageWithSource:arg_source maxSize:arg_maxSize quality:arg_imageQuality completion:^(NSString *_Nullable output, FlutterError *_Nullable error) {
callback(wrapResult(output, error));
}];
[api pickImageWithSource:arg_source
maxSize:arg_maxSize
quality:arg_imageQuality
completion:^(NSString *_Nullable output, FlutterError *_Nullable error) {
callback(wrapResult(output, error));
}];
}];
}
else {
} else {
[channel setMessageHandler:nil];
}
}
{
FlutterBasicMessageChannel *channel =
[[FlutterBasicMessageChannel alloc]
initWithName:@"dev.flutter.pigeon.ImagePickerApi.pickMultiImage"
FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc]
initWithName:@"dev.flutter.pigeon.ImagePickerApi.pickMultiImage"
binaryMessenger:binaryMessenger
codec:FLTImagePickerApiGetCodec() ];
codec:FLTImagePickerApiGetCodec()];
if (api) {
NSCAssert([api respondsToSelector:@selector(pickMultiImageWithMaxSize:quality:completion:)], @"FLTImagePickerApi api (%@) doesn't respond to @selector(pickMultiImageWithMaxSize:quality:completion:)", api);
NSCAssert([api respondsToSelector:@selector(pickMultiImageWithMaxSize:quality:completion:)],
@"FLTImagePickerApi api (%@) doesn't respond to "
@"@selector(pickMultiImageWithMaxSize:quality:completion:)",
api);
[channel setMessageHandler:^(id _Nullable message, FlutterReply callback) {
NSArray *args = message;
FLTMaxSize *arg_maxSize = GetNullableObjectAtIndex(args, 0);
NSNumber *arg_imageQuality = GetNullableObjectAtIndex(args, 1);
[api pickMultiImageWithMaxSize:arg_maxSize quality:arg_imageQuality completion:^(NSArray<NSString *> *_Nullable output, FlutterError *_Nullable error) {
callback(wrapResult(output, error));
}];
[api pickMultiImageWithMaxSize:arg_maxSize
quality:arg_imageQuality
completion:^(NSArray<NSString *> *_Nullable output,
FlutterError *_Nullable error) {
callback(wrapResult(output, error));
}];
}];
}
else {
} else {
[channel setMessageHandler:nil];
}
}
{
FlutterBasicMessageChannel *channel =
[[FlutterBasicMessageChannel alloc]
initWithName:@"dev.flutter.pigeon.ImagePickerApi.pickVideo"
FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc]
initWithName:@"dev.flutter.pigeon.ImagePickerApi.pickVideo"
binaryMessenger:binaryMessenger
codec:FLTImagePickerApiGetCodec() ];
codec:FLTImagePickerApiGetCodec()];
if (api) {
NSCAssert([api respondsToSelector:@selector(pickVideoWithSource:maxDuration:completion:)], @"FLTImagePickerApi api (%@) doesn't respond to @selector(pickVideoWithSource:maxDuration:completion:)", api);
NSCAssert([api respondsToSelector:@selector(pickVideoWithSource:maxDuration:completion:)],
@"FLTImagePickerApi api (%@) doesn't respond to "
@"@selector(pickVideoWithSource:maxDuration:completion:)",
api);
[channel setMessageHandler:^(id _Nullable message, FlutterReply callback) {
NSArray *args = message;
FLTSourceSpecification *arg_source = GetNullableObjectAtIndex(args, 0);
NSNumber *arg_maxDurationSeconds = GetNullableObjectAtIndex(args, 1);
[api pickVideoWithSource:arg_source maxDuration:arg_maxDurationSeconds completion:^(NSString *_Nullable output, FlutterError *_Nullable error) {
callback(wrapResult(output, error));
}];
[api pickVideoWithSource:arg_source
maxDuration:arg_maxDurationSeconds
completion:^(NSString *_Nullable output, FlutterError *_Nullable error) {
callback(wrapResult(output, error));
}];
}];
}
else {
} else {
[channel setMessageHandler:nil];
}
}
Expand Down
Loading