@wavemaker/rn-codegen 11.15.6-1.647701 → 11.16.0-rc.269
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 +39 -9
- package/command.js.map +1 -1
- package/npm-shrinkwrap.json +159 -168
- package/package-lock.json +159 -168
- package/package.json +7 -4
- package/src/app.generator.js +167 -36
- 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 +74 -2
- package/src/templates/babel.config.js.template +3 -6
- package/src/templates/bootstrap.template +11 -1
- package/src/templates/component/component.template +1 -0
- package/src/templates/foundation-theme/build/android/wavemaker/design-tokens/basic/icon.less +6 -4
- package/src/templates/foundation-theme/build/android/wavemaker/design-tokens/basic/label.less +46 -4
- package/src/templates/foundation-theme/build/android/wavemaker/design-tokens/container/tabs/tab-header.less +15 -3
- package/src/templates/foundation-theme/build/android/wavemaker/design-tokens/data/form.less +14 -0
- package/src/templates/foundation-theme/build/android/wavemaker/design-tokens/input/chips.less +37 -0
- package/src/templates/foundation-theme/build/android/wavemaker/design-tokens/input/select.less +29 -1
- package/src/templates/foundation-theme/build/android/wavemaker/design-tokens/input/switch.less +4 -4
- package/src/templates/foundation-theme/build/android/wavemaker/design-tokens/navigation/menu.less +1 -0
- package/src/templates/foundation-theme/build/android/wavemaker/design-tokens/studio/basic/icon.less +0 -3
- package/src/templates/foundation-theme/build/android/wavemaker/design-tokens/studio/container/tabs.less +5 -1
- package/src/templates/foundation-theme/build/android/wavemaker/design-tokens/studio/input/form.less +20 -5
- package/src/templates/foundation-theme/build/android/wavemaker/design-tokens/tokens.light.css +18 -1
- package/src/templates/foundation-theme/build/android/wavemaker/design-tokens/variables/chips.variant.less +5 -1
- package/src/templates/foundation-theme/build/ios/wavemaker/design-tokens/basic/icon.less +6 -4
- package/src/templates/foundation-theme/build/ios/wavemaker/design-tokens/basic/label.less +46 -4
- package/src/templates/foundation-theme/build/ios/wavemaker/design-tokens/container/tabs/tab-header.less +15 -3
- package/src/templates/foundation-theme/build/ios/wavemaker/design-tokens/data/form.less +14 -0
- package/src/templates/foundation-theme/build/ios/wavemaker/design-tokens/input/chips.less +37 -0
- package/src/templates/foundation-theme/build/ios/wavemaker/design-tokens/input/select.less +29 -1
- package/src/templates/foundation-theme/build/ios/wavemaker/design-tokens/input/switch.less +4 -4
- package/src/templates/foundation-theme/build/ios/wavemaker/design-tokens/navigation/menu.less +1 -0
- package/src/templates/foundation-theme/build/ios/wavemaker/design-tokens/studio/basic/icon.less +0 -3
- package/src/templates/foundation-theme/build/ios/wavemaker/design-tokens/studio/container/tabs.less +5 -1
- package/src/templates/foundation-theme/build/ios/wavemaker/design-tokens/studio/input/form.less +20 -5
- package/src/templates/foundation-theme/build/ios/wavemaker/design-tokens/tokens.light.css +18 -1
- package/src/templates/foundation-theme/build/ios/wavemaker/design-tokens/variables/chips.variant.less +5 -1
- package/src/templates/foundation-theme/dist/android/style.css +20 -3
- package/src/templates/foundation-theme/dist/android/style.js +178 -50
- package/src/templates/foundation-theme/dist/android/tokens.js +18 -1
- package/src/templates/foundation-theme/dist/ios/style.css +20 -3
- package/src/templates/foundation-theme/dist/ios/style.js +178 -50
- package/src/templates/foundation-theme/dist/ios/tokens.js +18 -1
- package/src/templates/foundation-theme/wavemaker/design-tokens/basic/icon.less +6 -4
- package/src/templates/foundation-theme/wavemaker/design-tokens/basic/label.less +46 -4
- package/src/templates/foundation-theme/wavemaker/design-tokens/container/tabs/tab-header.less +15 -3
- package/src/templates/foundation-theme/wavemaker/design-tokens/data/form.less +14 -0
- package/src/templates/foundation-theme/wavemaker/design-tokens/input/chips.less +37 -0
- package/src/templates/foundation-theme/wavemaker/design-tokens/input/select.less +29 -1
- package/src/templates/foundation-theme/wavemaker/design-tokens/input/switch.less +4 -4
- package/src/templates/foundation-theme/wavemaker/design-tokens/navigation/menu.less +1 -0
- package/src/templates/foundation-theme/wavemaker/design-tokens/studio/basic/icon.less +0 -3
- package/src/templates/foundation-theme/wavemaker/design-tokens/studio/container/tabs.less +5 -1
- package/src/templates/foundation-theme/wavemaker/design-tokens/studio/input/form.less +20 -5
- package/src/templates/foundation-theme/wavemaker/design-tokens/tokens.light.css +18 -1
- package/src/templates/foundation-theme/wavemaker/design-tokens/variables/chips.variant.less +5 -1
- package/src/templates/package.web.json +5 -4
- package/src/templates/project/.npmrc +1 -0
- package/src/templates/project/app.json +2 -1
- package/src/templates/project/esbuild/esbuild.script.js +42 -2
- package/src/templates/project/metro.config.js +7 -1
- package/src/templates/project/package.json +5 -4
- 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 +11 -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/wizard/wizardstep.transformer.js +10 -2
- package/src/transpile/components/container/wizard/wizardstep.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 +7 -1
- 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/variables/variable.transformer.js +7 -7
- package/src/variables/variable.transformer.js.map +1 -1
|
@@ -46,7 +46,8 @@
|
|
|
46
46
|
"android": {
|
|
47
47
|
"enableProguardInReleaseBuilds": true,
|
|
48
48
|
"enableShrinkResourcesInReleaseBuilds": true,
|
|
49
|
-
"useLegacyPackaging": 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); }"
|
|
50
51
|
}
|
|
51
52
|
}
|
|
52
53
|
],
|
|
@@ -418,7 +418,7 @@ class EsBuilder {
|
|
|
418
418
|
const appJson = JSON.parse(fs.readFileSync(appJsonPath, 'utf8'));
|
|
419
419
|
return esbuild.build({
|
|
420
420
|
entryPoints: ['./node_modules/expo/AppEntry.js'],
|
|
421
|
-
external:['./node_modules/react-native-vector-icons'],
|
|
421
|
+
external:['./node_modules/react-native-vector-icons', 'react-native-linear-gradient'],
|
|
422
422
|
bundle: true,
|
|
423
423
|
entryNames: 'bundle-[hash]',
|
|
424
424
|
outdir: 'web-build',
|
|
@@ -433,7 +433,7 @@ class EsBuilder {
|
|
|
433
433
|
metafile: true,
|
|
434
434
|
sourcemap: true,
|
|
435
435
|
plugins: [babel({
|
|
436
|
-
filter: /\/src
|
|
436
|
+
filter: /\/src\/.*\.(js|jsx)$/,
|
|
437
437
|
config : {
|
|
438
438
|
targets: {
|
|
439
439
|
browsers: 'last 2 versions',
|
|
@@ -460,6 +460,20 @@ class EsBuilder {
|
|
|
460
460
|
config: {
|
|
461
461
|
plugins: ['react-native-worklets/plugin']
|
|
462
462
|
}
|
|
463
|
+
}), babel({
|
|
464
|
+
// Transform Flow-typed source files shipped with react-native.
|
|
465
|
+
// The RN Babel preset handles newer Flow syntax beyond simple type stripping.
|
|
466
|
+
filter: /node_modules\/react-native\/.*\.(js|jsx)$/,
|
|
467
|
+
config: {
|
|
468
|
+
babelrc: false,
|
|
469
|
+
configFile: false,
|
|
470
|
+
presets: [require.resolve('@react-native/babel-preset')]
|
|
471
|
+
}
|
|
472
|
+
}), babel({
|
|
473
|
+
filter: /node_modules\/(@wavemaker)\/.*\.(js|jsx)$/,
|
|
474
|
+
config: {
|
|
475
|
+
plugins: ['react-native-worklets/plugin']
|
|
476
|
+
}
|
|
463
477
|
}),resolve({
|
|
464
478
|
'victory-native': 'victory'
|
|
465
479
|
}), {
|
|
@@ -488,6 +502,32 @@ class EsBuilder {
|
|
|
488
502
|
});
|
|
489
503
|
}
|
|
490
504
|
}]
|
|
505
|
+
}), {
|
|
506
|
+
// Fallback resolver: if a bare specifier like `expo-asset` or
|
|
507
|
+
// `@expo/<x>` isn't installed at top-level node_modules (because
|
|
508
|
+
// npm hoisting put it under expo/node_modules/), look for it
|
|
509
|
+
// inside `node_modules/expo/node_modules/` instead.
|
|
510
|
+
name: 'expo-nested-resolver',
|
|
511
|
+
setup(build) {
|
|
512
|
+
const projectModules = path.resolve(__dirname, '../node_modules');
|
|
513
|
+
const expoNested = path.join(projectModules, 'expo/node_modules');
|
|
514
|
+
build.onResolve({ filter: /^(@expo\/|expo-)/ }, (args) => {
|
|
515
|
+
const pkg = args.path.startsWith('@')
|
|
516
|
+
? args.path.split('/').slice(0, 2).join('/')
|
|
517
|
+
: args.path.split('/')[0];
|
|
518
|
+
// Top-level present → let esbuild resolve normally.
|
|
519
|
+
if (fs.existsSync(path.join(projectModules, pkg, 'package.json'))) {
|
|
520
|
+
return null;
|
|
521
|
+
}
|
|
522
|
+
// Top-level missing → try the nested copy under expo/.
|
|
523
|
+
try {
|
|
524
|
+
return { path: require.resolve(args.path, { paths: [expoNested] }) };
|
|
525
|
+
} catch (e) {
|
|
526
|
+
return null;
|
|
527
|
+
}
|
|
528
|
+
});
|
|
529
|
+
}
|
|
530
|
+
}]
|
|
491
531
|
})
|
|
492
532
|
}
|
|
493
533
|
|
|
@@ -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.
|
|
15
|
-
"@wavemaker/variables": "11.
|
|
16
|
-
"@wavemaker/rn-codegen": "11.
|
|
14
|
+
"@wavemaker/app-rn-runtime": "11.16.0-rc.269",
|
|
15
|
+
"@wavemaker/variables": "11.16.0-rc.269",
|
|
16
|
+
"@wavemaker/rn-codegen": "11.16.0-rc.269",
|
|
17
17
|
"@wavemaker/wavepulse-agent": "1.0.11",
|
|
18
18
|
"expo": "54.0.12",
|
|
19
19
|
"expo-build-properties": "1.0.9",
|
|
@@ -102,7 +102,8 @@
|
|
|
102
102
|
"@expo/config-plugins": "54.0.1"
|
|
103
103
|
},
|
|
104
104
|
"overrides": {
|
|
105
|
-
"@react-navigation/core": "7.
|
|
105
|
+
"@react-navigation/core": "7.21.2",
|
|
106
|
+
"postcss": "8.5.26"
|
|
106
107
|
},
|
|
107
108
|
"private": true
|
|
108
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
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@wavemaker/expo-pull-to-refresh",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Native pull-to-refresh for WaveMaker React Native apps. Android: an AndroidX SwipeRefreshLayout port (the gesture). iOS: UIScrollView's own bounce is the gesture; a UIRefreshControl (indicator hidden) supplies the native commit, hold and close. The JS/React layer lives in @wavemaker/app-rn-runtime.",
|
|
5
|
+
"author": "WaveMaker",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"peerDependencies": {
|
|
8
|
+
"expo": ">=52.0.0"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"android",
|
|
12
|
+
"ios",
|
|
13
|
+
"expo-module.config.json"
|
|
14
|
+
]
|
|
15
|
+
}
|
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
const t = require("@babel/types");
|
|
2
2
|
const babel = require("@babel/core");
|
|
3
3
|
const jsx = require('@babel/plugin-syntax-jsx').default;
|
|
4
|
+
const nodePath = require('path');
|
|
5
|
+
|
|
6
|
+
function isInSrc(state) {
|
|
7
|
+
const filename = state && state.filename;
|
|
8
|
+
if (!filename) {
|
|
9
|
+
return true;
|
|
10
|
+
}
|
|
11
|
+
const relative = nodePath.relative(state.cwd || process.cwd(), filename);
|
|
12
|
+
return !relative.startsWith('..') && (relative === 'src' || relative.startsWith('src' + nodePath.sep));
|
|
13
|
+
}
|
|
4
14
|
|
|
5
15
|
function isWatchableExpression(path) {
|
|
6
16
|
const exp = path && path.container && path.container.value && path.container.value.expression;
|
|
@@ -62,7 +72,7 @@ const plugin = function() {
|
|
|
62
72
|
exit(path, state) {
|
|
63
73
|
const { node, parentPath } = path;
|
|
64
74
|
const nodeName = node.openingElement && node.openingElement.name && node.openingElement.name.name;
|
|
65
|
-
if (node.__wm_processed || !nodeName || !nodeName.startsWith('Wm')) {
|
|
75
|
+
if (node.__wm_processed || !nodeName || !nodeName.startsWith('Wm') || !isInSrc(state)) {
|
|
66
76
|
return;
|
|
67
77
|
}
|
|
68
78
|
const nameAttribute = t.jsxAttribute(
|
|
@@ -38,20 +38,31 @@ class RnStylesheetTranspiler {
|
|
|
38
38
|
const rules = [];
|
|
39
39
|
let currentRule = null;
|
|
40
40
|
let currentSelector = null;
|
|
41
|
+
let isInsideMediaSelector = true;
|
|
42
|
+
let mediaQueryCondition = '';
|
|
41
43
|
csstree.walk(ast, {
|
|
42
44
|
enter(node) {
|
|
43
|
-
|
|
45
|
+
// To detect media query condition
|
|
46
|
+
if (node.type === 'Atrule' && node.name === 'media') {
|
|
47
|
+
const condition = csstree.generate(node.prelude);
|
|
48
|
+
mediaQueryCondition = condition;
|
|
49
|
+
isInsideMediaSelector = false;
|
|
50
|
+
}
|
|
51
|
+
if (node.type === 'Rule' || (node === null || node === void 0 ? void 0 : node.name) === 'media') {
|
|
44
52
|
currentRule = {
|
|
45
53
|
selectors: [],
|
|
46
54
|
body: ''
|
|
47
55
|
};
|
|
48
56
|
rules.push(currentRule);
|
|
49
57
|
}
|
|
50
|
-
else if (node.type === 'Selector') {
|
|
58
|
+
else if (node.type === 'Selector' && (node === null || node === void 0 ? void 0 : node.name) !== 'media') {
|
|
51
59
|
currentSelector = [];
|
|
52
60
|
currentRule.selectors.push(currentSelector);
|
|
53
61
|
}
|
|
54
62
|
else if (node.type === 'ClassSelector') {
|
|
63
|
+
if (mediaQueryCondition && !currentSelector.includes('.@media ' + mediaQueryCondition)) {
|
|
64
|
+
currentSelector.push('.@media ' + mediaQueryCondition);
|
|
65
|
+
}
|
|
55
66
|
currentSelector.push('.' + node.name);
|
|
56
67
|
}
|
|
57
68
|
else if (node.type === 'PseudoClassSelector' && node.name === 'theme-variables') {
|
|
@@ -67,11 +78,24 @@ class RnStylesheetTranspiler {
|
|
|
67
78
|
currentSelector.push(node.name);
|
|
68
79
|
}
|
|
69
80
|
else if (node.type === 'Block') {
|
|
70
|
-
|
|
71
|
-
if (
|
|
72
|
-
|
|
73
|
-
|
|
81
|
+
// Due to media query block open empty rule is created
|
|
82
|
+
if (mediaQueryCondition && !isInsideMediaSelector) {
|
|
83
|
+
isInsideMediaSelector = true;
|
|
84
|
+
rules.pop();
|
|
74
85
|
}
|
|
86
|
+
else {
|
|
87
|
+
currentRule.body = csstree.generate(node);
|
|
88
|
+
if (!/\{[\s]*\}/.test(currentRule.body)
|
|
89
|
+
&& !currentRule.body.endsWith(';}')) {
|
|
90
|
+
currentRule.body = currentRule.body.replace('}', ';}');
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
leave(node) {
|
|
96
|
+
if (node.type === 'Atrule' && node.name === 'media') {
|
|
97
|
+
isInsideMediaSelector = false;
|
|
98
|
+
mediaQueryCondition = '';
|
|
75
99
|
}
|
|
76
100
|
}
|
|
77
101
|
});
|