@wavemaker/rn-codegen 11.14.1-34.647830 → 11.14.1-37.647870
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/command.js +6 -0
- package/command.js.map +1 -1
- package/npm-shrinkwrap.json +249 -217
- package/package-lock.json +249 -217
- package/package.json +6 -10
- package/src/app.generator.js +194 -22
- package/src/app.generator.js.map +1 -1
- package/src/increment-builder.js +2 -1
- package/src/increment-builder.js.map +1 -1
- package/src/project.service.js +14 -0
- package/src/project.service.js.map +1 -1
- package/src/templates/app.template +45 -37
- package/src/templates/babel.config.js.template +6 -3
- package/src/templates/bootstrap.template +8 -3
- package/src/templates/component/component.template +1 -0
- package/src/templates/package.web.json +7 -17
- package/src/templates/project/app.json +1 -3
- package/src/templates/project/esbuild/esbuild.script.js +35 -4
- package/src/templates/project/metro.config.js +7 -1
- package/src/templates/project/package.json +7 -17
- package/src/templates/project/plugins/expo-pull-to-refresh/android/build.gradle +15 -0
- package/src/templates/project/plugins/expo-pull-to-refresh/android/src/main/java/expo/modules/pulltorefresh/ExpoPullToRefreshModule.kt +21 -0
- package/src/templates/project/plugins/expo-pull-to-refresh/android/src/main/java/expo/modules/pulltorefresh/ExpoPullToRefreshView.kt +221 -0
- package/src/templates/project/plugins/expo-pull-to-refresh/expo-module.config.json +16 -0
- package/src/templates/project/plugins/expo-pull-to-refresh/ios/ExpoPullToRefresh.podspec +24 -0
- package/src/templates/project/plugins/expo-pull-to-refresh/ios/ExpoPullToRefreshControlModule.swift +17 -0
- package/src/templates/project/plugins/expo-pull-to-refresh/ios/ExpoPullToRefreshControlView.swift +92 -0
- package/src/templates/project/plugins/expo-pull-to-refresh/package.json +15 -0
- package/src/templates/project/scripts/wm-babel.transform.plugin.js +1 -11
- package/src/theme/components/input/currency.styledef.js +8 -0
- package/src/theme/components/input/currency.styledef.js.map +1 -1
- package/src/theme/components/input/number.styledef.js +30 -0
- package/src/theme/components/input/number.styledef.js.map +1 -1
- package/src/theme/components/input/text.styledef.js +121 -2
- package/src/theme/components/input/text.styledef.js.map +1 -1
- package/src/theme/components/input/textarea.styledef.js +62 -2
- package/src/theme/components/input/textarea.styledef.js.map +1 -1
- package/src/theme/rn-stylesheet.transpiler.js +30 -6
- package/src/theme/rn-stylesheet.transpiler.js.map +1 -1
- package/src/transpile/components/container/tabs.transformer.js +9 -1
- package/src/transpile/components/container/tabs.transformer.js.map +1 -1
- package/src/transpile/components/container/wizard/wizardstep.transformer.js +2 -10
- package/src/transpile/components/container/wizard/wizardstep.transformer.js.map +1 -1
- package/src/transpile/components/data/form/form-field.transformer.js +23 -1
- package/src/transpile/components/data/form/form-field.transformer.js.map +1 -1
- package/src/transpile/components/page/page.transformer.js +11 -1
- package/src/transpile/components/page/page.transformer.js.map +1 -1
- package/src/transpile/property/property-parser.js +10 -0
- package/src/transpile/property/property-parser.js.map +1 -1
- package/src/transpile/style.transformer.js +1 -0
- package/src/transpile/style.transformer.js.map +1 -1
- package/src/transpile/transpile.js +10 -1
- package/src/transpile/transpile.js.map +1 -1
- package/src/templates/project/.npmrc +0 -1
|
@@ -19,7 +19,6 @@ import * as config from './wm_rn_config.json';
|
|
|
19
19
|
|
|
20
20
|
export const appConfig = {
|
|
21
21
|
url : config.serverPath !== 'http://NOSERVERREQUIRED.com' ? config.serverPath : null,
|
|
22
|
-
appId: config.id,
|
|
23
22
|
theme: appTheme,
|
|
24
23
|
preferences: config.preferences,
|
|
25
24
|
splash: config.splash,
|
|
@@ -35,10 +34,16 @@ export const appConfig = {
|
|
|
35
34
|
},
|
|
36
35
|
revertLayoutToExpo50: config.revertLayoutToExpo50,
|
|
37
36
|
edgeToEdgeConfig:config.edgeToEdgeConfig,
|
|
38
|
-
|
|
37
|
+
pulltorefreshsource:config.pulltorefreshsource,
|
|
38
|
+
// CSS class(es) for the pull-to-refresh WmLottie, styled from the app stylesheet over app-lottie.
|
|
39
|
+
pulltorefreshclass:config.pulltorefreshclass || '',
|
|
39
40
|
disableNavigationAnimation:config.disableNavigationAnimation,
|
|
41
|
+
pageTransitionAnimation:config.pageTransitionAnimation,
|
|
40
42
|
detachInactiveScreens:config.detachInactiveScreens,
|
|
41
|
-
isLegacyTappable:config.isLegacyTappable
|
|
43
|
+
isLegacyTappable:config.isLegacyTappable,
|
|
44
|
+
enablePageCache:config.enablePageCache,
|
|
45
|
+
defaultProfile: config.defaultProfile,
|
|
46
|
+
deviceBreakPoints:config.deviceBreakPoints
|
|
42
47
|
};
|
|
43
48
|
|
|
44
49
|
{{#if profile.generateWeb}}
|
|
@@ -82,6 +82,7 @@ export default class {{name}}{{typeLabel}} extends Base{{typeLabel}} {
|
|
|
82
82
|
this.startUpVariables = [{{#each startUpVariables}}'{{this}}',{{/each}}];
|
|
83
83
|
this.startUpActions = [{{#each startUpActions}}'{{this}}',{{/each}}];
|
|
84
84
|
this.autoUpdateVariables = [{{#each autoUpdateVariables}}'{{this}}',{{/each}}];
|
|
85
|
+
this.pullToRefreshVariables = [{{#each pullToRefreshVariables}}'{{this}}',{{/each}}];
|
|
85
86
|
add{{typeLabel}}Script(this.App, this.proxy);
|
|
86
87
|
}
|
|
87
88
|
|
|
@@ -11,9 +11,9 @@
|
|
|
11
11
|
"postinstall": ""
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@wavemaker/app-rn-runtime": "11.14.1-
|
|
15
|
-
"@wavemaker/variables": "11.14.1-
|
|
16
|
-
"@wavemaker/rn-codegen": "11.14.1-
|
|
14
|
+
"@wavemaker/app-rn-runtime": "11.14.1-37.647870",
|
|
15
|
+
"@wavemaker/variables": "11.14.1-37.647870",
|
|
16
|
+
"@wavemaker/rn-codegen": "11.14.1-37.647870",
|
|
17
17
|
"@wavemaker/wavepulse-agent": "1.0.11",
|
|
18
18
|
"expo": "54.0.12",
|
|
19
19
|
"expo-build-properties": "1.0.9",
|
|
@@ -38,7 +38,6 @@
|
|
|
38
38
|
"@react-native/assets": "1.0.0",
|
|
39
39
|
"hermes-engine": "0.11.0",
|
|
40
40
|
"imask": "7.6.1",
|
|
41
|
-
"moment": "2.31.0",
|
|
42
41
|
"punycode": "2.3.1",
|
|
43
42
|
"react": "19.1.0",
|
|
44
43
|
"react-dom": "19.1.0",
|
|
@@ -83,12 +82,11 @@
|
|
|
83
82
|
"expo-screen-capture": "8.0.8",
|
|
84
83
|
"expo-secure-store": "15.0.7",
|
|
85
84
|
"@react-native/metro-babel-transformer": "0.81.4",
|
|
86
|
-
"react-native-worklets": "0.5.1"
|
|
87
|
-
"axios": "1.20.0"
|
|
85
|
+
"react-native-worklets": "0.5.1"
|
|
88
86
|
},
|
|
89
87
|
"devDependencies": {
|
|
90
88
|
"metro-minify-terser": "0.80.10",
|
|
91
|
-
"webpack-dev-middleware": "
|
|
89
|
+
"webpack-dev-middleware": "6.1.2",
|
|
92
90
|
"react-devtools-core": "4.28.5",
|
|
93
91
|
"esbuild": "0.15.15",
|
|
94
92
|
"esbuild-plugin-resolve": "1.0.3",
|
|
@@ -104,16 +102,8 @@
|
|
|
104
102
|
"@expo/config-plugins": "54.0.1"
|
|
105
103
|
},
|
|
106
104
|
"overrides": {
|
|
107
|
-
"
|
|
108
|
-
"
|
|
109
|
-
"inflight": "npm:inflight-lru@1.0.0",
|
|
110
|
-
"uri-js": "npm:uri-js-replace@1.0.1",
|
|
111
|
-
"metro": {
|
|
112
|
-
"image-size": "0.6.2"
|
|
113
|
-
},
|
|
114
|
-
"@expo/metro-config": {
|
|
115
|
-
"postcss": "8.5.30"
|
|
116
|
-
}
|
|
105
|
+
"@react-navigation/core": "7.21.2",
|
|
106
|
+
"postcss": "8.5.26"
|
|
117
107
|
},
|
|
118
108
|
"private": true
|
|
119
109
|
}
|
|
@@ -7,7 +7,6 @@
|
|
|
7
7
|
},
|
|
8
8
|
"name": "wm-react-native-app",
|
|
9
9
|
"slug": "wm-react-native-app",
|
|
10
|
-
"scheme": "wm-react-native-app",
|
|
11
10
|
"version": "1.0.0",
|
|
12
11
|
"jsEngine": "hermes",
|
|
13
12
|
"orientation": "portrait",
|
|
@@ -46,8 +45,7 @@
|
|
|
46
45
|
"android": {
|
|
47
46
|
"enableProguardInReleaseBuilds": true,
|
|
48
47
|
"enableShrinkResourcesInReleaseBuilds": true,
|
|
49
|
-
"useLegacyPackaging": true
|
|
50
|
-
"extraProguardRules": "-keep class com.facebook.react.views.view.WindowUtilKt { *; }\n-keepclassmembers class com.facebook.react.views.view.WindowUtilKt { public static *** isEdgeToEdgeFeatureFlagOn(); public static *** setEdgeToEdgeFeatureFlagOn(); public static *** enableEdgeToEdge(android.view.Window); public static *** disableEdgeToEdge(android.view.Window); }"
|
|
48
|
+
"useLegacyPackaging": true
|
|
51
49
|
}
|
|
52
50
|
}
|
|
53
51
|
],
|
|
@@ -105,6 +105,22 @@ class EsBuilder {
|
|
|
105
105
|
.replace(` | $TEMPORARY$string<'raw'> `, '');
|
|
106
106
|
});
|
|
107
107
|
}
|
|
108
|
+
|
|
109
|
+
async patchReactNativePaperDates() {
|
|
110
|
+
let path = `${__dirname}/../node_modules/react-native-paper-dates/lib/module/Date/Calendar.js`;
|
|
111
|
+
if(fs.existsSync(path)) {
|
|
112
|
+
await readAndReplaceFileContent(path, (content) => {
|
|
113
|
+
return content.replace("scrollMode === 'horizontal'", "scrollMode === 'horizontal' && selectingYear ");
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
path = `${__dirname}/../node_modules/react-native-paper-dates/lib/module/Date/AnimatedCrossView.js`;
|
|
117
|
+
if(fs.existsSync(path)) {
|
|
118
|
+
await readAndReplaceFileContent(path, (content) => {
|
|
119
|
+
return content.replace("calendar), /*#__PURE__*/React.createElement(Animated.View", "calendar), collapsed ? null : /*#__PURE__*/React.createElement(Animated.View");
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
console.log('Patched react-native-paper-dates Calendar.js and AnimatedCrossView.js');
|
|
123
|
+
}
|
|
108
124
|
|
|
109
125
|
async patchReactNativeWeb() {
|
|
110
126
|
const path = `${__dirname}/../node_modules/react-native-web/dist/cjs/exports/render/index.js`;
|
|
@@ -363,6 +379,7 @@ class EsBuilder {
|
|
|
363
379
|
// .then(() => this.patchReactNavigation())
|
|
364
380
|
.then(() => this.patchReactNativeReanimated())
|
|
365
381
|
.then(() => this.patchExpoVideo())
|
|
382
|
+
.then(() => this.patchReactNativePaperDates())
|
|
366
383
|
.then(() => {
|
|
367
384
|
console.log('*********** LIBRARIES ARE BUILT FOR ESBUILD **************');
|
|
368
385
|
}, (e) => {
|
|
@@ -378,7 +395,7 @@ class EsBuilder {
|
|
|
378
395
|
const appJson = JSON.parse(fs.readFileSync(appJsonPath, 'utf8'));
|
|
379
396
|
return esbuild.build({
|
|
380
397
|
entryPoints: ['./node_modules/expo/AppEntry.js'],
|
|
381
|
-
external:['./node_modules/react-native-vector-icons'],
|
|
398
|
+
external:['./node_modules/react-native-vector-icons', 'react-native-linear-gradient'],
|
|
382
399
|
bundle: true,
|
|
383
400
|
entryNames: 'bundle-[hash]',
|
|
384
401
|
outdir: 'web-build',
|
|
@@ -393,7 +410,7 @@ class EsBuilder {
|
|
|
393
410
|
metafile: true,
|
|
394
411
|
sourcemap: true,
|
|
395
412
|
plugins: [babel({
|
|
396
|
-
filter: /\/src
|
|
413
|
+
filter: /\/src\/.*\.(js|jsx)$/,
|
|
397
414
|
config : {
|
|
398
415
|
targets: {
|
|
399
416
|
browsers: 'last 2 versions',
|
|
@@ -409,13 +426,27 @@ class EsBuilder {
|
|
|
409
426
|
}), babel({
|
|
410
427
|
// Strip Flow types from React Native packages that ship Flow source
|
|
411
428
|
// (e.g. @react-native/assets-registry/registry.js).
|
|
412
|
-
filter: /node_modules
|
|
429
|
+
filter: /node_modules\/@react-native\/.*\.(js|jsx)$/,
|
|
413
430
|
config: {
|
|
414
431
|
babelrc: false,
|
|
415
432
|
configFile: false,
|
|
416
433
|
plugins: [require.resolve('@babel/plugin-transform-flow-strip-types')]
|
|
417
434
|
}
|
|
418
|
-
}),
|
|
435
|
+
}), babel({
|
|
436
|
+
// Transform Flow-typed source files shipped with react-native.
|
|
437
|
+
// The RN Babel preset handles newer Flow syntax beyond simple type stripping.
|
|
438
|
+
filter: /node_modules\/react-native\/.*\.(js|jsx)$/,
|
|
439
|
+
config: {
|
|
440
|
+
babelrc: false,
|
|
441
|
+
configFile: false,
|
|
442
|
+
presets: [require.resolve('@react-native/babel-preset')]
|
|
443
|
+
}
|
|
444
|
+
}), babel({
|
|
445
|
+
filter: /node_modules\/(@wavemaker)\/.*\.(js|jsx)$/,
|
|
446
|
+
config: {
|
|
447
|
+
plugins: ['react-native-worklets/plugin']
|
|
448
|
+
}
|
|
449
|
+
}),resolve({
|
|
419
450
|
'victory-native': 'victory'
|
|
420
451
|
}), {
|
|
421
452
|
// Fallback resolver: if a bare specifier like `expo-asset` or
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
const { getDefaultConfig } = require('expo/metro-config');
|
|
2
2
|
const path = require('path');
|
|
3
|
+
const fs = require('fs');
|
|
3
4
|
|
|
4
5
|
module.exports = (async () => {
|
|
5
6
|
try {
|
|
6
7
|
const projectRoot = __dirname;
|
|
7
|
-
|
|
8
|
+
let config = getDefaultConfig(projectRoot);
|
|
8
9
|
config.watchFolders = [projectRoot];
|
|
9
10
|
config.resolver.nodeModulesPaths = [
|
|
10
11
|
path.resolve(projectRoot, 'node_modules')
|
|
@@ -31,6 +32,11 @@ module.exports = (async () => {
|
|
|
31
32
|
}
|
|
32
33
|
})
|
|
33
34
|
}
|
|
35
|
+
const customMetroConfigPath = path.join(projectRoot, 'custommetro.config.js');
|
|
36
|
+
if (fs.existsSync(customMetroConfigPath)) {
|
|
37
|
+
const customizeMetroConfig = require(customMetroConfigPath);
|
|
38
|
+
config = (await customizeMetroConfig(config)) || config;
|
|
39
|
+
}
|
|
34
40
|
return config;
|
|
35
41
|
}
|
|
36
42
|
catch (e) {
|
|
@@ -11,9 +11,9 @@
|
|
|
11
11
|
"postinstall": "node ./scripts/post-build.js"
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@wavemaker/app-rn-runtime": "11.14.1-
|
|
15
|
-
"@wavemaker/variables": "11.14.1-
|
|
16
|
-
"@wavemaker/rn-codegen": "11.14.1-
|
|
14
|
+
"@wavemaker/app-rn-runtime": "11.14.1-37.647870",
|
|
15
|
+
"@wavemaker/variables": "11.14.1-37.647870",
|
|
16
|
+
"@wavemaker/rn-codegen": "11.14.1-37.647870",
|
|
17
17
|
"@wavemaker/wavepulse-agent": "1.0.11",
|
|
18
18
|
"expo": "54.0.12",
|
|
19
19
|
"expo-build-properties": "1.0.9",
|
|
@@ -38,7 +38,6 @@
|
|
|
38
38
|
"@react-native/assets": "1.0.0",
|
|
39
39
|
"hermes-engine": "0.11.0",
|
|
40
40
|
"imask": "7.6.1",
|
|
41
|
-
"moment": "2.31.0",
|
|
42
41
|
"punycode": "2.3.1",
|
|
43
42
|
"react": "19.1.0",
|
|
44
43
|
"react-dom": "19.1.0",
|
|
@@ -83,12 +82,11 @@
|
|
|
83
82
|
"expo-screen-capture": "8.0.8",
|
|
84
83
|
"expo-secure-store": "15.0.7",
|
|
85
84
|
"@react-native/metro-babel-transformer": "0.81.4",
|
|
86
|
-
"react-native-worklets": "0.5.1"
|
|
87
|
-
"axios": "1.20.0"
|
|
85
|
+
"react-native-worklets": "0.5.1"
|
|
88
86
|
},
|
|
89
87
|
"devDependencies": {
|
|
90
88
|
"metro-minify-terser": "0.80.10",
|
|
91
|
-
"webpack-dev-middleware": "
|
|
89
|
+
"webpack-dev-middleware": "6.1.2",
|
|
92
90
|
"react-devtools-core": "4.28.5",
|
|
93
91
|
"esbuild": "0.15.15",
|
|
94
92
|
"esbuild-plugin-resolve": "1.0.3",
|
|
@@ -104,16 +102,8 @@
|
|
|
104
102
|
"@expo/config-plugins": "54.0.1"
|
|
105
103
|
},
|
|
106
104
|
"overrides": {
|
|
107
|
-
"
|
|
108
|
-
"
|
|
109
|
-
"inflight": "npm:inflight-lru@1.0.0",
|
|
110
|
-
"uri-js": "npm:uri-js-replace@1.0.1",
|
|
111
|
-
"metro": {
|
|
112
|
-
"image-size": "0.6.2"
|
|
113
|
-
},
|
|
114
|
-
"@expo/metro-config": {
|
|
115
|
-
"postcss": "8.5.30"
|
|
116
|
-
}
|
|
105
|
+
"@react-navigation/core": "7.21.2",
|
|
106
|
+
"postcss": "8.5.26"
|
|
117
107
|
},
|
|
118
108
|
"private": true
|
|
119
109
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
plugins {
|
|
2
|
+
id 'com.android.library'
|
|
3
|
+
id 'expo-module-gradle-plugin'
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
group = 'expo.modules.pulltorefresh'
|
|
7
|
+
version = '0.1.0'
|
|
8
|
+
|
|
9
|
+
android {
|
|
10
|
+
namespace "expo.modules.pulltorefresh"
|
|
11
|
+
defaultConfig {
|
|
12
|
+
versionCode 1
|
|
13
|
+
versionName "0.1.0"
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
package expo.modules.pulltorefresh
|
|
2
|
+
|
|
3
|
+
import expo.modules.kotlin.modules.Module
|
|
4
|
+
import expo.modules.kotlin.modules.ModuleDefinition
|
|
5
|
+
|
|
6
|
+
// Android pull-to-refresh view: hosts the scrollable content and reports drag progress to JS.
|
|
7
|
+
class ExpoPullToRefreshModule : Module() {
|
|
8
|
+
override fun definition() = ModuleDefinition {
|
|
9
|
+
Name("ExpoPullToRefresh")
|
|
10
|
+
|
|
11
|
+
View(ExpoPullToRefreshView::class) {
|
|
12
|
+
// Controlled, same contract as RN's RefreshControl.refreshing.
|
|
13
|
+
Prop("refreshing") { view: ExpoPullToRefreshView, refreshing: Boolean? ->
|
|
14
|
+
view.setRefreshingProp(refreshing ?: false)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// onPullProgress is 0..1+ (above 1 in the slingshot phase); JS draws the spinner from it.
|
|
18
|
+
Events("onPullProgress", "onRefresh")
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2018 The Android Open Source Project
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*
|
|
16
|
+
* Modified by WaveMaker: drag math and touch arbitration ported from AndroidX
|
|
17
|
+
* SwipeRefreshLayout to Kotlin, hosting one React child and reporting progress.
|
|
18
|
+
*/
|
|
19
|
+
package expo.modules.pulltorefresh
|
|
20
|
+
|
|
21
|
+
import android.content.Context
|
|
22
|
+
import android.view.MotionEvent
|
|
23
|
+
import android.view.View
|
|
24
|
+
import android.view.ViewConfiguration
|
|
25
|
+
import expo.modules.kotlin.AppContext
|
|
26
|
+
import expo.modules.kotlin.viewevent.EventDispatcher
|
|
27
|
+
import expo.modules.kotlin.views.ExpoView
|
|
28
|
+
import kotlin.math.abs
|
|
29
|
+
import kotlin.math.max
|
|
30
|
+
import kotlin.math.min
|
|
31
|
+
import kotlin.math.pow
|
|
32
|
+
|
|
33
|
+
class ExpoPullToRefreshView(context: Context, appContext: AppContext) : ExpoView(context, appContext) {
|
|
34
|
+
|
|
35
|
+
companion object {
|
|
36
|
+
private const val INVALID_POINTER = -1
|
|
37
|
+
private const val DRAG_RATE = .5f
|
|
38
|
+
// Matches SwipeRefreshLayout.DEFAULT_CIRCLE_TARGET.
|
|
39
|
+
private const val DEFAULT_CIRCLE_TARGET_DP = 64f
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
private val onPullProgress by EventDispatcher()
|
|
43
|
+
private val onRefresh by EventDispatcher()
|
|
44
|
+
|
|
45
|
+
// The single React child: the wrapper around the scrollable content.
|
|
46
|
+
private var contentView: View? = null
|
|
47
|
+
|
|
48
|
+
private val touchSlop = ViewConfiguration.get(context).scaledTouchSlop
|
|
49
|
+
private val totalDragDistance = dpToPx(DEFAULT_CIRCLE_TARGET_DP)
|
|
50
|
+
private val spinnerOffsetEnd = totalDragDistance
|
|
51
|
+
private var customSlingshotDistance = 0f
|
|
52
|
+
|
|
53
|
+
private var initialMotionY = 0f
|
|
54
|
+
private var initialDownY = 0f
|
|
55
|
+
private var isBeingDragged = false
|
|
56
|
+
private var activePointerId = INVALID_POINTER
|
|
57
|
+
private var refreshing = false
|
|
58
|
+
|
|
59
|
+
override fun addView(child: View, index: Int, params: android.view.ViewGroup.LayoutParams?) {
|
|
60
|
+
super.addView(child, index, params)
|
|
61
|
+
if (contentView == null) {
|
|
62
|
+
contentView = child
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// Controlled `refreshing` prop, same contract as RN's RefreshControl.
|
|
67
|
+
fun setRefreshingProp(refreshing: Boolean) {
|
|
68
|
+
if (this.refreshing == refreshing) return
|
|
69
|
+
this.refreshing = refreshing
|
|
70
|
+
if (!refreshing) {
|
|
71
|
+
emitProgress(0f)
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// The real scrollable inside the wrapper (the wrapper itself never scrolls).
|
|
76
|
+
private var scrollableChild: View? = null
|
|
77
|
+
|
|
78
|
+
private fun findScrollable(view: View?): View? {
|
|
79
|
+
if (view == null) return null
|
|
80
|
+
if (view is android.widget.ScrollView ||
|
|
81
|
+
view is android.widget.HorizontalScrollView ||
|
|
82
|
+
view is androidx.core.widget.NestedScrollView ||
|
|
83
|
+
view.javaClass.name.contains("ReactScrollView")
|
|
84
|
+
) {
|
|
85
|
+
return view
|
|
86
|
+
}
|
|
87
|
+
if (view is android.view.ViewGroup) {
|
|
88
|
+
for (i in 0 until view.childCount) {
|
|
89
|
+
val found = findScrollable(view.getChildAt(i))
|
|
90
|
+
if (found != null) return found
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return null
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
private fun canChildScrollUp(): Boolean {
|
|
97
|
+
if (scrollableChild == null) {
|
|
98
|
+
scrollableChild = findScrollable(contentView)
|
|
99
|
+
}
|
|
100
|
+
return scrollableChild?.canScrollVertically(-1) ?: false
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// ---- Touch arbitration --------------------------------------------------
|
|
104
|
+
override fun onInterceptTouchEvent(ev: MotionEvent): Boolean {
|
|
105
|
+
if (!isEnabled || canChildScrollUp() || refreshing) {
|
|
106
|
+
isBeingDragged = false
|
|
107
|
+
return false
|
|
108
|
+
}
|
|
109
|
+
when (ev.actionMasked) {
|
|
110
|
+
MotionEvent.ACTION_DOWN -> {
|
|
111
|
+
activePointerId = ev.getPointerId(0)
|
|
112
|
+
isBeingDragged = false
|
|
113
|
+
val pointerIndex = ev.findPointerIndex(activePointerId)
|
|
114
|
+
if (pointerIndex < 0) return false
|
|
115
|
+
initialDownY = ev.getY(pointerIndex)
|
|
116
|
+
}
|
|
117
|
+
MotionEvent.ACTION_MOVE -> {
|
|
118
|
+
if (activePointerId == INVALID_POINTER) return false
|
|
119
|
+
val pointerIndex = ev.findPointerIndex(activePointerId)
|
|
120
|
+
if (pointerIndex < 0) return false
|
|
121
|
+
startDragging(ev.getY(pointerIndex))
|
|
122
|
+
}
|
|
123
|
+
MotionEvent.ACTION_UP, MotionEvent.ACTION_CANCEL -> {
|
|
124
|
+
isBeingDragged = false
|
|
125
|
+
activePointerId = INVALID_POINTER
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return isBeingDragged
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
override fun onTouchEvent(ev: MotionEvent): Boolean {
|
|
132
|
+
if (!isEnabled || canChildScrollUp() || refreshing) {
|
|
133
|
+
return false
|
|
134
|
+
}
|
|
135
|
+
when (ev.actionMasked) {
|
|
136
|
+
MotionEvent.ACTION_DOWN -> {
|
|
137
|
+
activePointerId = ev.getPointerId(0)
|
|
138
|
+
isBeingDragged = false
|
|
139
|
+
}
|
|
140
|
+
MotionEvent.ACTION_MOVE -> {
|
|
141
|
+
val pointerIndex = ev.findPointerIndex(activePointerId)
|
|
142
|
+
if (pointerIndex < 0) return false
|
|
143
|
+
val y = ev.getY(pointerIndex)
|
|
144
|
+
startDragging(y)
|
|
145
|
+
if (isBeingDragged) {
|
|
146
|
+
val overscrollTop = (y - initialMotionY) * DRAG_RATE
|
|
147
|
+
if (overscrollTop > 0) {
|
|
148
|
+
// Stop the child ScrollView reclaiming the gesture mid-drag.
|
|
149
|
+
parent?.requestDisallowInterceptTouchEvent(true)
|
|
150
|
+
moveSpinner(overscrollTop)
|
|
151
|
+
} else {
|
|
152
|
+
return false
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
MotionEvent.ACTION_UP -> {
|
|
157
|
+
val pointerIndex = ev.findPointerIndex(activePointerId)
|
|
158
|
+
if (pointerIndex < 0) return false
|
|
159
|
+
if (isBeingDragged) {
|
|
160
|
+
val y = ev.getY(pointerIndex)
|
|
161
|
+
val overscrollTop = (y - initialMotionY) * DRAG_RATE
|
|
162
|
+
isBeingDragged = false
|
|
163
|
+
finishSpinner(overscrollTop)
|
|
164
|
+
}
|
|
165
|
+
activePointerId = INVALID_POINTER
|
|
166
|
+
return false
|
|
167
|
+
}
|
|
168
|
+
MotionEvent.ACTION_CANCEL -> {
|
|
169
|
+
isBeingDragged = false
|
|
170
|
+
emitProgress(0f)
|
|
171
|
+
return false
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
return true
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
private fun startDragging(y: Float) {
|
|
178
|
+
val yDiff = y - initialDownY
|
|
179
|
+
if (yDiff > touchSlop && !isBeingDragged) {
|
|
180
|
+
initialMotionY = initialDownY + touchSlop
|
|
181
|
+
isBeingDragged = true
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
override fun requestDisallowInterceptTouchEvent(disallowIntercept: Boolean) {
|
|
186
|
+
if (isBeingDragged) return
|
|
187
|
+
super.requestDisallowInterceptTouchEvent(disallowIntercept)
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
// Ported moveSpinner/finishSpinner math; reports progress to JS instead of moving views.
|
|
191
|
+
private fun moveSpinner(overscrollTop: Float) {
|
|
192
|
+
val originalDragPercent = overscrollTop / totalDragDistance
|
|
193
|
+
val dragPercent = min(1f, abs(originalDragPercent))
|
|
194
|
+
val extraOS = abs(overscrollTop) - totalDragDistance
|
|
195
|
+
val slingshotDist = if (customSlingshotDistance > 0) customSlingshotDistance else spinnerOffsetEnd
|
|
196
|
+
val tensionSlingshotPercent = max(0f, min(extraOS, slingshotDist * 2) / slingshotDist)
|
|
197
|
+
val tensionPercent = ((tensionSlingshotPercent / 4) - (tensionSlingshotPercent / 4).toDouble().pow(2.0).toFloat()) * 2f
|
|
198
|
+
|
|
199
|
+
// Same composition as moveSpinner's targetY math, normalised to 0..1+.
|
|
200
|
+
val extraMove = tensionPercent * 2
|
|
201
|
+
val progress = dragPercent + extraMove
|
|
202
|
+
emitProgress(progress)
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
private fun finishSpinner(overscrollTop: Float) {
|
|
206
|
+
if (overscrollTop > totalDragDistance) {
|
|
207
|
+
refreshing = true
|
|
208
|
+
emitProgress(1f)
|
|
209
|
+
onRefresh(emptyMap<String, Any>())
|
|
210
|
+
} else {
|
|
211
|
+
// Released below the threshold: retract.
|
|
212
|
+
emitProgress(0f)
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
private fun emitProgress(progress: Float) {
|
|
217
|
+
onPullProgress(mapOf("progress" to progress))
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
private fun dpToPx(dp: Float): Float = dp * resources.displayMetrics.density
|
|
221
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
require 'json'
|
|
2
|
+
|
|
3
|
+
package = JSON.parse(File.read(File.join(__dir__, '..', 'package.json')))
|
|
4
|
+
|
|
5
|
+
Pod::Spec.new do |s|
|
|
6
|
+
s.name = 'ExpoPullToRefresh'
|
|
7
|
+
s.version = package['version']
|
|
8
|
+
s.summary = package['description']
|
|
9
|
+
s.license = package['license']
|
|
10
|
+
s.author = package['author']
|
|
11
|
+
s.homepage = 'https://www.wavemaker.com'
|
|
12
|
+
s.platforms = { :ios => '15.1' }
|
|
13
|
+
s.swift_version = '5.9'
|
|
14
|
+
s.source = { git: '' }
|
|
15
|
+
s.static_framework = true
|
|
16
|
+
|
|
17
|
+
s.dependency 'ExpoModulesCore'
|
|
18
|
+
|
|
19
|
+
s.pod_target_xcconfig = {
|
|
20
|
+
'DEFINES_MODULE' => 'YES'
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
s.source_files = '**/*.swift'
|
|
24
|
+
end
|
package/src/templates/project/plugins/expo-pull-to-refresh/ios/ExpoPullToRefreshControlModule.swift
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import ExpoModulesCore
|
|
2
|
+
|
|
3
|
+
// iOS: supplies a hidden UIRefreshControl for the native commit, hold and close (the bounce is the gesture).
|
|
4
|
+
public class ExpoPullToRefreshControlModule: Module {
|
|
5
|
+
public func definition() -> ModuleDefinition {
|
|
6
|
+
Name("ExpoPullToRefreshControl")
|
|
7
|
+
|
|
8
|
+
View(ExpoPullToRefreshControlView.self) {
|
|
9
|
+
Events("onRefresh")
|
|
10
|
+
|
|
11
|
+
// Only `false` is acted on (ends a user-started refresh); see setRefreshing.
|
|
12
|
+
Prop("refreshing") { (view: ExpoPullToRefreshControlView, refreshing: Bool) in
|
|
13
|
+
view.setRefreshing(refreshing)
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
package/src/templates/project/plugins/expo-pull-to-refresh/ios/ExpoPullToRefreshControlView.swift
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import ExpoModulesCore
|
|
2
|
+
import UIKit
|
|
3
|
+
|
|
4
|
+
// Attaches a hidden UIRefreshControl to the sibling ScrollView, so UIKit commits, holds and closes smoothly behind the Lottie.
|
|
5
|
+
class ExpoPullToRefreshControlView: ExpoView {
|
|
6
|
+
let onRefresh = EventDispatcher()
|
|
7
|
+
|
|
8
|
+
private let refreshControl = UIRefreshControl()
|
|
9
|
+
private weak var attachedScrollView: UIScrollView?
|
|
10
|
+
|
|
11
|
+
required init(appContext: AppContext? = nil) {
|
|
12
|
+
super.init(appContext: appContext)
|
|
13
|
+
// The app's Lottie is the indicator; UIKit's spinner must never show.
|
|
14
|
+
refreshControl.tintColor = .clear
|
|
15
|
+
refreshControl.addTarget(self, action: #selector(handleValueChanged), for: .valueChanged)
|
|
16
|
+
isUserInteractionEnabled = false
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
@objc private func handleValueChanged() {
|
|
20
|
+
onRefresh()
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// Only ever ends a refresh: beginRefreshing() on a user pull is what makes RN's RefreshControl jump.
|
|
24
|
+
func setRefreshing(_ refreshing: Bool) {
|
|
25
|
+
if !refreshing && refreshControl.isRefreshing {
|
|
26
|
+
refreshControl.endRefreshing()
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
override func didMoveToWindow() {
|
|
31
|
+
super.didMoveToWindow()
|
|
32
|
+
if window != nil {
|
|
33
|
+
attachWhenReady(attemptsLeft: 10)
|
|
34
|
+
} else {
|
|
35
|
+
detach()
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// The sibling ScrollView may mount a run-loop turn later, so retry briefly.
|
|
40
|
+
private func attachWhenReady(attemptsLeft: Int) {
|
|
41
|
+
guard attachedScrollView == nil, window != nil else { return }
|
|
42
|
+
if let scrollView = findSiblingScrollView() {
|
|
43
|
+
attach(to: scrollView)
|
|
44
|
+
return
|
|
45
|
+
}
|
|
46
|
+
guard attemptsLeft > 0 else { return }
|
|
47
|
+
DispatchQueue.main.async { [weak self] in
|
|
48
|
+
self?.attachWhenReady(attemptsLeft: attemptsLeft - 1)
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// RCTScrollViewComponentView's first subview is its UIScrollView, so depth-first finds it first.
|
|
53
|
+
private func findSiblingScrollView() -> UIScrollView? {
|
|
54
|
+
guard let parent = superview else { return nil }
|
|
55
|
+
for sibling in parent.subviews where sibling !== self {
|
|
56
|
+
if let scrollView = Self.firstScrollView(in: sibling) {
|
|
57
|
+
return scrollView
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return nil
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
private static func firstScrollView(in view: UIView) -> UIScrollView? {
|
|
64
|
+
if let scrollView = view as? UIScrollView {
|
|
65
|
+
return scrollView
|
|
66
|
+
}
|
|
67
|
+
for subview in view.subviews {
|
|
68
|
+
if let scrollView = firstScrollView(in: subview) {
|
|
69
|
+
return scrollView
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return nil
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
private func attach(to scrollView: UIScrollView) {
|
|
76
|
+
// Never take over a refresh control someone else put there.
|
|
77
|
+
guard scrollView.refreshControl == nil || scrollView.refreshControl === refreshControl else {
|
|
78
|
+
return
|
|
79
|
+
}
|
|
80
|
+
scrollView.refreshControl = refreshControl
|
|
81
|
+
attachedScrollView = scrollView
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
private func detach() {
|
|
85
|
+
if let scrollView = attachedScrollView, scrollView.refreshControl === refreshControl {
|
|
86
|
+
// UIKit requires a refresh to be ended before its control is removed.
|
|
87
|
+
refreshControl.endRefreshing()
|
|
88
|
+
scrollView.refreshControl = nil
|
|
89
|
+
}
|
|
90
|
+
attachedScrollView = nil
|
|
91
|
+
}
|
|
92
|
+
}
|