Skip to content

Commit

Permalink
feat(video): Added assetRepresentationMode prop (#2083)
Browse files Browse the repository at this point in the history
* Added assetRepresentationMode prop

* Added possible values to readme
  • Loading branch information
MakarovAleksey committed May 26, 2023
1 parent c4dca1d commit f2044ee
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ The `callback` will be called with a response object, refer to [The Response Obj
| selectionLimit | OK | OK | OK | Default is `1`, use `0` to allow any number of files. Only iOS version >= 14 & Android version >= 13 support `0` and also it supports providing any integer value |
| presentationStyle | OK | NO | NO | Controls how the picker is presented. 'pageSheet', 'fullScreen', 'pageSheet', 'formSheet', 'popover', 'overFullScreen', 'overCurrentContext'. Default is 'currentContext' |
| formatAsMp4 | OK | NO | NO | Converts the selected video to MP4. iOS Only. |
| assetRepresentationMode | OK | NO | NO | A mode that determines which representation to use if an asset contains more than one. Possible values: 'auto', 'current', 'compatible'. Default is 'auto' |
|
## The Response Object
Expand Down
11 changes: 10 additions & 1 deletion ios/ImagePickerUtils.m
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,17 @@ + (PHPickerConfiguration *)makeConfigurationFromOptions:(NSDictionary *)options
} else {
configuration = [[PHPickerConfiguration alloc] init];
}

if ([[options objectForKey:@"assetRepresentationMode"] isEqualToString:@"current"]) {
configuration.preferredAssetRepresentationMode = PHPickerConfigurationAssetRepresentationModeCurrent;
}
else if ([[options objectForKey:@"assetRepresentationMode"] isEqualToString:@"compatible"]) {
configuration.preferredAssetRepresentationMode = PHPickerConfigurationAssetRepresentationModeCompatible;
}
else {
configuration.preferredAssetRepresentationMode = PHPickerConfigurationAssetRepresentationModeAutomatic;
}

configuration.preferredAssetRepresentationMode = PHPickerConfigurationAssetRepresentationModeAutomatic;
configuration.selectionLimit = [options[@"selectionLimit"] integerValue];

if ([options[@"mediaType"] isEqualToString:@"video"]) {
Expand Down
1 change: 1 addition & 0 deletions src/platforms/native.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const DEFAULT_OPTIONS: ImageLibraryOptions & CameraOptions = {
durationLimit: 0,
includeExtra: false,
presentationStyle: 'pageSheet',
assetRepresentationMode: 'auto',
};

// @ts-ignore We want to check whether __turboModuleProxy exitst, it may not
Expand Down
6 changes: 5 additions & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ export interface OptionsCommon {
| 'formSheet'
| 'popover'
| 'overFullScreen'
| 'overCurrentContext';
| 'overCurrentContext'
assetRepresentationMode?:
| 'auto'
| 'current'
| 'compatible';
}

export interface ImageLibraryOptions extends OptionsCommon {
Expand Down

0 comments on commit f2044ee

Please sign in to comment.