Merge pull request #72 from VincentRoth/master

Positioning dialog for iOS
This commit is contained in:
Aaron Faber 2018-12-12 12:26:28 +00:00 committed by GitHub
commit b969aa748a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 183 additions and 174 deletions

View File

@ -24,10 +24,12 @@ cordova.plugins.fileOpener2.open(
fileMIMEType, fileMIMEType,
{ {
error : function(){ }, error : function(){ },
success : function(){ } success : function(){ },
position : [x, y]
} }
); );
``` ```
`position` array of coordinates from top-left device screen, use for iOS dialog positioning.
Examples Examples
-------- --------

View File

@ -39,6 +39,14 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
showPreview = [[command.arguments objectAtIndex:2] boolValue]; showPreview = [[command.arguments objectAtIndex:2] boolValue];
} }
CGRect rect;
if ([command.arguments count] >= 4) {
NSArray *positionValues = command.arguments[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);
}
CDVViewController* cont = (CDVViewController*)[super viewController]; CDVViewController* cont = (CDVViewController*)[super viewController];
self.cdvViewController = cont; self.cdvViewController = cont;
NSString *uti = nil; NSString *uti = nil;
@ -80,7 +88,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
wasOpened = [docController presentPreviewAnimated: NO]; wasOpened = [docController presentPreviewAnimated: NO];
} else { } else {
CDVViewController* cont = self.cdvViewController; CDVViewController* cont = self.cdvViewController;
CGRect rect = CGRectMake(0, 0, cont.view.bounds.size.width, cont.view.bounds.size.height);
wasOpened = [docController presentOpenInMenuFromRect:rect inView:cont.view animated:YES]; wasOpened = [docController presentOpenInMenuFromRect:rect inView:cont.view animated:YES];
} }

View File

@ -26,10 +26,10 @@ var exec = require('cordova/exec');
function FileOpener2() {} function FileOpener2() {}
FileOpener2.prototype.open = function (fileName, contentType, callbackContext) { FileOpener2.prototype.open = function (fileName, contentType, options) {
contentType = contentType || ''; contentType = contentType || '';
callbackContext = callbackContext || {}; options = options || {};
exec(callbackContext.success || null, callbackContext.error || null, 'FileOpener2', 'open', [fileName, contentType]); exec(callbackContext.success || null, callbackContext.error || null, 'FileOpener2', 'open', [fileName, contentType, false, options.position]);
}; };
FileOpener2.prototype.showOpenWithDialog = function (fileName, contentType, callbackContext) { FileOpener2.prototype.showOpenWithDialog = function (fileName, contentType, callbackContext) {