Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
jiangwei committed Oct 28, 2021
0 parents commit 5757e3c
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# ignore following files
.DS_Store
.settings
.idea
*.iml
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
A plugin for cordova-ios@6+
```
[wkWebView.scrollView setContentInsetAdjustmentBehavior:UIScrollViewContentInsetAdjustmentNever]
```
27 changes: 27 additions & 0 deletions hooks/iosAfterPlatformAdd.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env node

module.exports = function (ctx) {
var fs = require('fs'),
path = require('path');

var platformRoot = path.join(ctx.opts.projectRoot, 'platforms', 'ios');

// clear onReceivedSslError body
var fileCDVWebViewEnginePath = path.join(platformRoot, 'CordovaLib', 'Classes', 'Private', 'Plugins', 'CDVWebViewEngine', 'CDVWebViewEngine.m');
if (fs.existsSync(fileCDVWebViewEnginePath)) {
var source = fs.readFileSync(fileCDVWebViewEnginePath, 'utf8');
if (source.indexOf('[wkWebView.scrollView setContentInsetAdjustmentBehavior:UIScrollViewContentInsetAdjustmentNever];') < 0) {
source = source.replace(
'WKWebView* wkWebView = [[WKWebView alloc] initWithFrame:self.engineWebView.frame configuration:configuration];',
`WKWebView* wkWebView = [[WKWebView alloc] initWithFrame:self.engineWebView.frame configuration:configuration];
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000
if (@available(iOS 11.0, *)) {
[wkWebView.scrollView setContentInsetAdjustmentBehavior:UIScrollViewContentInsetAdjustmentNever];
}
#endif
`)
fs.writeFileSync(fileCDVWebViewEnginePath, source, 'utf8');
}
}
};
23 changes: 23 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@

{
"name": "cordova-plugin-wkwebview-inset-adjustment-never",
"description": "WKWebview UIScrollViewContentInsetAdjustmentNever",
"version": "0.0.1",
"homepage": "",
"cordova": {
"id": "cordova-plugin-wkwebview-inset-adjustment-never",
"platforms": [
"ios"
]
},
"engines": [
{
"name": "cordova",
"version": ">=9.0.0"
}
],
"author": "lovelyelfpop",
"license": "MIT",
"scripts": {
}
}
22 changes: 22 additions & 0 deletions plugin.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version='1.0' encoding='utf-8'?>
<plugin id="cordova-plugin-wkwebview-inset-adjustment-never" version="0.0.1"
xmlns="http://apache.org/cordova/ns/plugins/1.0"
xmlns:android="http://schemas.android.com/apk/res/android">

<name>WKWebview UIScrollViewContentInsetAdjustmentNever</name>
<description>WKWebview UIScrollViewContentInsetAdjustmentNever</description>
<author>lovelyelfpop</author>
<license>MIT</license>
<keywords>WKWebview,UIScrollViewContentInsetAdjustmentNever</keywords>
<repo></repo>
<issue></issue>

<engines>
<engine name="cordova" version=">=9" />
<engine name="cordova-ios" version=">=6.0.0" />
</engines>

<platform name="ios">
<hook src="hooks/iosAfterPlatformAdd.js" type="after_platform_add" />
</platform>
</plugin>

0 comments on commit 5757e3c

Please sign in to comment.