mirror of
https://gitee.com/shuto/cordova-plugin-file-opener2.git
synced 2025-01-31 03:52:51 +08:00
Merge pull request #290 from ucsbricks/feature/ipad-dialog-position
Fix showOpenWithDialog was rendered outside of viewport on iPads
This commit is contained in:
commit
1a128fdefc
@ -112,10 +112,12 @@ cordova.plugins.fileOpener2.showOpenWithDialog(
|
|||||||
},
|
},
|
||||||
success : function () {
|
success : function () {
|
||||||
console.log('file opened successfully');
|
console.log('file opened successfully');
|
||||||
}
|
},
|
||||||
|
position : [0, 0]
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
`position` array of coordinates from top-left device screen, use for iOS dialog positioning.
|
||||||
|
|
||||||
## fileOpener2.uninstall(packageId, callbackContext)
|
## fileOpener2.uninstall(packageId, callbackContext)
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||||||
|
|
||||||
- (void) open: (CDVInvokedUrlCommand*)command {
|
- (void) open: (CDVInvokedUrlCommand*)command {
|
||||||
|
|
||||||
NSString *path = [command.arguments objectAtIndex:0];
|
NSString *path = [command.arguments objectAtIndex:0];
|
||||||
NSString *contentType = [command.arguments objectAtIndex:1];
|
NSString *contentType = [command.arguments objectAtIndex:1];
|
||||||
BOOL showPreview = YES;
|
BOOL showPreview = YES;
|
||||||
|
|
||||||
@ -82,13 +82,20 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||||||
CDVPluginResult* pluginResult = nil;
|
CDVPluginResult* pluginResult = nil;
|
||||||
|
|
||||||
//Opens the file preview
|
//Opens the file preview
|
||||||
|
CGRect rect;
|
||||||
|
if ([command.arguments count] >= 4) {
|
||||||
|
NSArray *positionValues = [command.arguments objectAtIndex:3];
|
||||||
|
rect = CGRectMake(0, 0, [[positionValues objectAtIndex:0] floatValue], [[positionValues objectAtIndex:1] floatValue]);
|
||||||
|
} else {
|
||||||
|
rect = CGRectMake(0, 0, cont.view.bounds.size.width, cont.view.bounds.size.height);
|
||||||
|
}
|
||||||
|
|
||||||
BOOL wasOpened = NO;
|
BOOL wasOpened = NO;
|
||||||
|
|
||||||
if (showPreview) {
|
if (showPreview) {
|
||||||
wasOpened = [docController presentPreviewAnimated: NO];
|
wasOpened = [docController presentPreviewAnimated: NO];
|
||||||
} else {
|
} else {
|
||||||
CDVViewController* cont = self.cdvViewController;
|
CDVViewController* cont = self.cdvViewController;
|
||||||
CGRect rect = CGRectMake(cont.view.bounds.size.width, 0, cont.view.bounds.size.height, 0);
|
|
||||||
wasOpened = [docController presentOpenInMenuFromRect:rect inView:cont.view animated:YES];
|
wasOpened = [docController presentOpenInMenuFromRect:rect inView:cont.view animated:YES];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ FileOpener2.prototype.open = function (fileName, contentType, callbackContext) {
|
|||||||
FileOpener2.prototype.showOpenWithDialog = function (fileName, contentType, callbackContext) {
|
FileOpener2.prototype.showOpenWithDialog = function (fileName, contentType, callbackContext) {
|
||||||
contentType = contentType || '';
|
contentType = contentType || '';
|
||||||
callbackContext = callbackContext || {};
|
callbackContext = callbackContext || {};
|
||||||
exec(callbackContext.success || null, callbackContext.error || null, 'FileOpener2', 'open', [fileName, contentType, false]);
|
exec(callbackContext.success || null, callbackContext.error || null, 'FileOpener2', 'open', [fileName, contentType, false, callbackContext.position]);
|
||||||
};
|
};
|
||||||
|
|
||||||
FileOpener2.prototype.uninstall = function (packageId, callbackContext) {
|
FileOpener2.prototype.uninstall = function (packageId, callbackContext) {
|
||||||
|
Loading…
Reference in New Issue
Block a user