├── .eslintrc.js ├── .gitignore ├── .prettierrc.js ├── Example ├── .buckconfig ├── .eslintrc.js ├── .flowconfig ├── .gitattributes ├── .gitignore ├── .prettierrc.js ├── .watchmanconfig ├── App.js ├── __tests__ │ └── App-test.js ├── android │ ├── .project │ ├── app │ │ ├── .classpath │ │ ├── .project │ │ ├── BUCK │ │ ├── build.gradle │ │ ├── build_defs.bzl │ │ ├── proguard-rules.pro │ │ └── src │ │ │ ├── debug │ │ │ └── AndroidManifest.xml │ │ │ └── main │ │ │ ├── AndroidManifest.xml │ │ │ ├── java │ │ │ └── com │ │ │ │ └── aexample │ │ │ │ ├── MainActivity.java │ │ │ │ └── MainApplication.java │ │ │ └── res │ │ │ ├── mipmap-hdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-mdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxxhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ └── values │ │ │ ├── strings.xml │ │ │ └── styles.xml │ ├── build.gradle │ ├── gradle.properties │ ├── gradle │ │ └── wrapper │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ ├── gradlew │ ├── gradlew.bat │ └── settings.gradle ├── app.json ├── babel.config.js ├── index.js ├── ios │ ├── 1.swift │ ├── Podfile │ ├── aexample-tvOS │ │ └── Info.plist │ ├── aexample-tvOSTests │ │ └── Info.plist │ ├── aexample.xcodeproj │ │ ├── project.pbxproj │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ ├── aexample-tvOS.xcscheme │ │ │ └── aexample.xcscheme │ ├── aexample.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ ├── aexample │ │ ├── AppDelegate.h │ │ ├── AppDelegate.m │ │ ├── Base.lproj │ │ │ └── LaunchScreen.xib │ │ ├── Images.xcassets │ │ │ ├── AppIcon.appiconset │ │ │ │ └── Contents.json │ │ │ └── Contents.json │ │ ├── Info.plist │ │ └── main.m │ └── aexampleTests │ │ ├── Info.plist │ │ └── aexampleTests.m ├── metro.config.js ├── package.json └── src │ ├── RefreshAnimateHeader.js │ ├── RefreshNormalHeader.js │ ├── assets │ ├── 142-loading-animation.json │ ├── 7911-3d-box.json │ ├── 8209-blue-dots-throbber.json │ ├── 8572-liquid-blobby-loader.json │ ├── cycle_animation.json │ ├── icon_down_arrow.png │ ├── lectureLoading.json │ ├── loading.json │ └── loop.json │ └── index.js ├── LICENSE ├── README.md ├── RNRefresh.podspec ├── android ├── build.gradle └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── jiasong │ │ └── refresh │ │ ├── RCTRefreshHeader.java │ │ ├── RCTRefreshHeaderManager.java │ │ ├── RCTRefreshLayout.java │ │ ├── RCTRefreshLayoutManager.java │ │ └── RCTRefreshLayoutPackage.java │ └── res │ └── values │ └── strings.xml ├── ios ├── RNRefresh.xcodeproj │ └── project.pbxproj └── RNRefresh │ ├── RCTRefreshHeader.h │ ├── RCTRefreshHeader.m │ ├── RCTRefreshHeaderManager.h │ ├── RCTRefreshHeaderManager.m │ ├── RCTRefreshLayout.h │ ├── RCTRefreshLayout.m │ ├── RCTRefreshLayoutManager.h │ └── RCTRefreshLayoutManager.m ├── package.json └── src ├── RefreshHeader.android.js ├── RefreshHeader.ios.js ├── RefreshLayout.android.js ├── RefreshLayout.ios.js ├── RefreshState.js ├── index.d.ts └── index.js /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | env: { 3 | es6: true, 4 | node: true, 5 | }, 6 | parser: 'babel-eslint', 7 | parserOptions: { 8 | ecmaFeatures: { 9 | legacyDecorators: true, 10 | experimentalObjectRestSpread: true, 11 | jsx: true, 12 | }, 13 | sourceType: 'module', 14 | }, 15 | plugins: [ 16 | 'eslint-comments', 17 | 'prettier', 18 | 'react', 19 | 'react-hooks', 20 | 'react-native', 21 | ], 22 | settings: { 23 | react: { 24 | version: 'detect', 25 | }, 26 | }, 27 | // Map from global var to bool specifying if it can be redefined 28 | globals: { 29 | __DEV__: true, 30 | __dirname: false, 31 | __fbBatchedBridgeConfig: false, 32 | it: true, 33 | alert: true, 34 | cancelAnimationFrame: false, 35 | cancelIdleCallback: false, 36 | clearImmediate: true, 37 | clearInterval: false, 38 | clearTimeout: false, 39 | console: false, 40 | document: false, 41 | escape: false, 42 | Event: false, 43 | EventTarget: false, 44 | exports: false, 45 | fetch: false, 46 | FormData: false, 47 | global: false, 48 | Map: true, 49 | module: false, 50 | navigator: false, 51 | process: false, 52 | Promise: true, 53 | requestAnimationFrame: true, 54 | requestIdleCallback: true, 55 | require: false, 56 | Set: true, 57 | setImmediate: true, 58 | setInterval: false, 59 | setTimeout: false, 60 | window: false, 61 | XMLHttpRequest: false, 62 | }, 63 | rules: { 64 | // General 65 | 'no-cond-assign': 1, // disallow assignment in conditional expressions 66 | 'no-console': 0, // disallow use of console (off by default in the node environment) 67 | 'no-const-assign': 2, // disallow assignment to const-declared variables 68 | 'no-constant-condition': 0, // disallow use of constant expressions in conditions 69 | 'no-control-regex': 1, // disallow control characters in regular expressions 70 | 'no-debugger': 1, // disallow use of debugger 71 | 'no-dupe-class-members': 2, // Disallow duplicate name in class members 72 | 'no-dupe-keys': 2, // disallow duplicate keys when creating object literals 73 | 'no-empty': 0, // disallow empty statements 74 | 'no-ex-assign': 1, // disallow assigning to the exception in a catch block 75 | 'no-extra-boolean-cast': 1, // disallow double-negation boolean casts in a boolean context 76 | 'no-extra-parens': 0, // disallow unnecessary parentheses (off by default) 77 | 'no-extra-semi': 1, // disallow unnecessary semicolons 78 | 'no-func-assign': 1, // disallow overwriting functions written as function declarations 79 | 'no-inner-declarations': 0, // disallow function or variable declarations in nested blocks 80 | 'no-invalid-regexp': 1, // disallow invalid regular expression strings in the RegExp constructor 81 | 'no-negated-in-lhs': 1, // disallow negation of the left operand of an in expression 82 | 'no-obj-calls': 1, // disallow the use of object properties of the global object (Math and JSON) as functions 83 | 'no-regex-spaces': 1, // disallow multiple spaces in a regular expression literal 84 | 'no-reserved-keys': 0, // disallow reserved words being used as object literal keys (off by default) 85 | 'no-sparse-arrays': 1, // disallow sparse arrays 86 | 'no-unreachable': 2, // disallow unreachable statements after a return, throw, continue, or break statement 87 | 'use-isnan': 1, // disallow comparisons with the value NaN 88 | 'valid-jsdoc': 0, // Ensure JSDoc comments are valid (off by default) 89 | 'valid-typeof': 1, // Ensure that the results of typeof are compared against a valid string 90 | 91 | // Best Practices 92 | // These are rules designed to prevent you from making mistakes. They either prescribe a better way of doing something or help you avoid footguns. 93 | 'block-scoped-var': 0, // treat var statements as if they were block scoped (off by default) 94 | complexity: 0, // specify the maximum cyclomatic complexity allowed in a program (off by default) 95 | 'consistent-return': 0, // require return statements to either always or never specify values 96 | curly: 1, // specify curly brace conventions for all control statements 97 | 'default-case': 0, // require default case in switch statements (off by default) 98 | 'dot-notation': 1, // encourages use of dot notation whenever possible 99 | eqeqeq: [1, 'allow-null'], // require the use of === and !== 100 | 'guard-for-in': 0, // make sure for-in loops have an if statement (off by default) 101 | 'no-alert': 0, // disallow the use of alert, confirm, and prompt 102 | 'no-caller': 1, // disallow use of arguments.caller or arguments.callee 103 | 'no-div-regex': 1, // disallow division operators explicitly at beginning of regular expression (off by default) 104 | 'no-else-return': 0, // disallow else after a return in an if (off by default) 105 | 'no-eq-null': 0, // disallow comparisons to null without a type-checking operator (off by default) 106 | 'no-eval': 2, // disallow use of eval() 107 | 'no-extend-native': 1, // disallow adding to native types 108 | 'no-extra-bind': 1, // disallow unnecessary function binding 109 | 'no-fallthrough': 1, // disallow fallthrough of case statements 110 | 'no-floating-decimal': 1, // disallow the use of leading or trailing decimal points in numeric literals (off by default) 111 | 'no-implied-eval': 1, // disallow use of eval()-like methods 112 | 'no-labels': 1, // disallow use of labeled statements 113 | 'no-iterator': 1, // disallow usage of __iterator__ property 114 | 'no-lone-blocks': 1, // disallow unnecessary nested blocks 115 | 'no-loop-func': 0, // disallow creation of functions within loops 116 | 'no-multi-str': 0, // disallow use of multiline strings 117 | 'no-native-reassign': 0, // disallow reassignments of native objects 118 | 'no-new': 1, // disallow use of new operator when not part of the assignment or comparison 119 | 'no-new-func': 2, // disallow use of new operator for Function object 120 | 'no-new-wrappers': 1, // disallows creating new instances of String,Number, and Boolean 121 | 'no-octal': 1, // disallow use of octal literals 122 | 'no-octal-escape': 1, // disallow use of octal escape sequences in string literals, such as var foo = "Copyright \251"; 123 | 'no-proto': 1, // disallow usage of __proto__ property 124 | 'no-redeclare': 0, // disallow declaring the same variable more then once 125 | 'no-return-assign': 1, // disallow use of assignment in return statement 126 | 'no-script-url': 1, // disallow use of javascript: urls. 127 | 'no-self-compare': 1, // disallow comparisons where both sides are exactly the same (off by default) 128 | 'no-sequences': 1, // disallow use of comma operator 129 | 'no-unused-expressions': 0, // disallow usage of expressions in statement position 130 | 'no-void': 1, // disallow use of void operator (off by default) 131 | 'no-warning-comments': 0, // disallow usage of configurable warning terms in comments": 1, // e.g. TODO or FIXME (off by default) 132 | 'no-with': 1, // disallow use of the with statement 133 | radix: 0, // require use of the second argument for parseInt() (off by default) 134 | 'semi-spacing': 1, // require a space after a semi-colon 135 | 'vars-on-top': 0, // requires to declare all vars on top of their containing scope (off by default) 136 | 'wrap-iife': 0, // require immediate function invocation to be wrapped in parentheses (off by default) 137 | yoda: 1, // require or disallow Yoda conditions 138 | 139 | // Variables 140 | // These rules have to do with variable declarations. 141 | 'no-catch-shadow': 0, // disallow the catch clause parameter name being the same as a variable in the outer scope (off by default in the node environment) 142 | 'no-delete-var': 1, // disallow deletion of variables 143 | 'no-label-var': 1, // disallow labels that share a name with a variable 144 | 'no-shadow': 1, // disallow declaration of variables already declared in the outer scope 145 | 'no-shadow-restricted-names': 1, // disallow shadowing of names such as arguments 146 | 'no-undef': 2, // disallow use of undeclared variables unless mentioned in a /*global */ block 147 | 'no-undefined': 0, // disallow use of undefined variable (off by default) 148 | 'no-undef-init': 1, // disallow use of undefined when initializing variables 149 | 'no-unused-vars': [ 150 | 2, 151 | { vars: 'all', args: 'after-used', ignoreRestSiblings: true }, 152 | ], // disallow declaration of variables that are not used in the code 153 | 'no-use-before-define': 0, // disallow use of variables before they are defined 154 | // Node.js 155 | // These rules are specific to JavaScript running on Node.js. 156 | 157 | 'handle-callback-err': 1, // enforces error handling in callbacks (off by default) (on by default in the node environment) 158 | 'no-mixed-requires': 1, // disallow mixing regular variable and require declarations (off by default) (on by default in the node environment) 159 | 'no-new-require': 1, // disallow use of new operator with the require function (off by default) (on by default in the node environment) 160 | 'no-path-concat': 1, // disallow string concatenation with __dirname and __filename (off by default) (on by default in the node environment) 161 | 'no-process-exit': 0, // disallow process.exit() (on by default in the node environment) 162 | 'no-restricted-modules': 1, // restrict usage of specified node modules (off by default) 163 | 'no-sync': 0, // disallow use of synchronous methods (off by default) 164 | 165 | // ESLint Comments Plugin 166 | // The following rules are made available via `eslint-plugin-eslint-comments` 167 | 'eslint-comments/no-aggregating-enable': 1, // disallows eslint-enable comments for multiple eslint-disable comments 168 | 'eslint-comments/no-unlimited-disable': 1, // disallows eslint-disable comments without rule names 169 | 'eslint-comments/no-unused-disable': 1, // disallow disables that don't cover any errors 170 | 'eslint-comments/no-unused-enable': 1, // // disallow enables that don't enable anything or enable rules that weren't disabled 171 | 172 | // Prettier Plugin 173 | // https://github.com/prettier/eslint-plugin-prettier 174 | 'prettier/prettier': 2, 175 | 176 | // Stylistic Issues 177 | // These rules are purely matters of style and are quite subjective. 178 | 'key-spacing': 0, 179 | 'keyword-spacing': 1, // enforce spacing before and after keywords 180 | 'jsx-quotes': [1, 'prefer-double'], // enforces the usage of double quotes for all JSX attribute values which doesn’t contain a double quote 181 | 'comma-spacing': 0, 182 | 'no-multi-spaces': 0, 183 | 'brace-style': 0, // enforce one true brace style (off by default) 184 | camelcase: 0, // require camel case names 185 | 'consistent-this': 1, // enforces consistent naming when capturing the current execution context (off by default) 186 | 'eol-last': 1, // enforce newline at the end of file, with no multiple empty lines 187 | 'func-names': 0, // require function expressions to have a name (off by default) 188 | 'func-style': 0, // enforces use of function declarations or expressions (off by default) 189 | 'new-cap': 0, // require a capital letter for constructors 190 | 'new-parens': 1, // disallow the omission of parentheses when invoking a constructor with no arguments 191 | 'no-nested-ternary': 0, // disallow nested ternary expressions (off by default) 192 | 'no-array-constructor': 1, // disallow use of the Array constructor 193 | 'no-empty-character-class': 1, // disallow the use of empty character classes in regular expressions 194 | 'no-lonely-if': 0, // disallow if as the only statement in an else block (off by default) 195 | 'no-new-object': 1, // disallow use of the Object constructor 196 | 'no-spaced-func': 1, // disallow space between function identifier and application 197 | 'no-ternary': 0, // disallow the use of ternary operators (off by default) 198 | 'no-trailing-spaces': 1, // disallow trailing whitespace at the end of lines 199 | 'no-underscore-dangle': 0, // disallow dangling underscores in identifiers 200 | quotes: [1, 'single', 'avoid-escape'], // specify whether double or single quotes should be used 201 | 'quote-props': 0, // require quotes around object literal property names (off by default) 202 | semi: 0, // require or disallow use of semicolons instead of ASI 203 | 'sort-vars': 0, // sort variables within the same declaration block (off by default) 204 | 'space-in-brackets': 0, // require or disallow spaces inside brackets (off by default) 205 | 'space-in-parens': 0, // require or disallow spaces inside parentheses (off by default) 206 | 'space-infix-ops': 1, // require spaces around operators 207 | 'space-unary-ops': [1, { words: true, nonwords: false }], // require or disallow spaces before/after unary operators (words on by default, nonwords off by default) 208 | 'max-nested-callbacks': 0, // specify the maximum depth callbacks can be nested (off by default) 209 | 'one-var': 0, // allow just one var statement per function (off by default) 210 | 'wrap-regex': 0, // require regex literals to be wrapped in parentheses (off by default) 211 | 212 | // Legacy 213 | // The following rules are included for compatibility with JSHint and JSLint. While the names of the rules may not match up with the JSHint/JSLint counterpart, the functionality is the same. 214 | 215 | 'max-depth': 0, // specify the maximum depth that blocks can be nested (off by default) 216 | 'max-len': 0, // specify the maximum length of a line in your program (off by default) 217 | 'max-params': 0, // limits the number of parameters that can be used in the function declaration. (off by default) 218 | 'max-statements': 0, // specify the maximum number of statement allowed in a function (off by default) 219 | 'no-bitwise': 1, // disallow use of bitwise operators (off by default) 220 | 'no-plusplus': 0, // disallow use of unary operators, ++ and -- (off by default) 221 | 222 | // React Plugin 223 | // The following rules are made available via `eslint-plugin-react`. 224 | 225 | 'react/display-name': 0, 226 | 'react/jsx-boolean-value': 0, 227 | 'react/jsx-no-comment-textnodes': 1, 228 | 'react/jsx-no-duplicate-props': 2, 229 | 'react/jsx-no-undef': 2, 230 | 'react/jsx-sort-props': 0, 231 | 'react/jsx-uses-react': 1, 232 | 'react/jsx-uses-vars': 1, 233 | 'react/no-did-mount-set-state': 1, 234 | 'react/no-did-update-set-state': 1, 235 | 'react/no-multi-comp': 0, 236 | 'react/no-string-refs': 1, 237 | 'react/no-unknown-property': 0, 238 | 'react/prop-types': 0, 239 | 'react/react-in-jsx-scope': 1, 240 | 'react/self-closing-comp': 1, 241 | 'react/wrap-multilines': 0, 242 | 243 | // React-Hooks Plugin 244 | // The following rules are made available via `eslint-plugin-react-hooks` 245 | 'react-hooks/rules-of-hooks': 2, 246 | 'react-hooks/exhaustive-deps': 2, 247 | 248 | // React-Native Plugin 249 | // The following rules are made available via `eslint-plugin-react-native` 250 | 251 | 'react-native/no-unused-styles': 0, 252 | 'react-native/split-platform-components': 0, 253 | 'react-native/no-inline-styles': 0, 254 | 'react-native/no-color-literals': 0, 255 | 'react-native/no-raw-text': 2, 256 | }, 257 | }; 258 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # OSX 2 | # 3 | .DS_Store 4 | 5 | # Xcode 6 | # 7 | build/ 8 | *.pbxuser 9 | !default.pbxuser 10 | *.mode1v3 11 | !default.mode1v3 12 | *.mode2v3 13 | !default.mode2v3 14 | *.perspectivev3 15 | !default.perspectivev3 16 | xcuserdata 17 | *.xccheckout 18 | *.moved-aside 19 | DerivedData 20 | *.hmap 21 | *.ipa 22 | *.xcuserstate 23 | project.xcworkspace 24 | Carthage/Build 25 | Pods/ 26 | Podfile.lock 27 | 28 | # Android/IntelliJ 29 | # 30 | build/ 31 | .idea 32 | .gradle 33 | local.properties 34 | *.iml 35 | .settings 36 | android/bin 37 | 38 | # node.js 39 | # 40 | modify_modules/ 41 | node_modules/ 42 | npm-debug.log 43 | yarn-error.log 44 | package-lock.json 45 | ios/bundle/* 46 | yarn.lock 47 | Hyphenate.framework 48 | 49 | 50 | 51 | # BUCK 52 | buck-out/ 53 | \.buckd/ 54 | *.keystore 55 | 56 | # fastlane 57 | # 58 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 59 | # screenshots whenever they are needed. 60 | # For more information about the recommended setup visit: 61 | # https://docs.fastlane.tools/best-practices/source-control/ 62 | 63 | */fastlane/report.xml 64 | */fastlane/Preview.html 65 | */fastlane/screenshots 66 | 67 | # Bundle artifact 68 | *.jsbundle 69 | package-lock.json 70 | android/.project 71 | 72 | 73 | # IDE 74 | .vscode -------------------------------------------------------------------------------- /.prettierrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | semi: true, 3 | bracketSpacing: true, 4 | jsxBracketSameLine: false, 5 | singleQuote: true, 6 | trailingComma: 'all', 7 | proseWrap: 'preserve', 8 | arrowParens: 'always', 9 | }; 10 | -------------------------------------------------------------------------------- /Example/.buckconfig: -------------------------------------------------------------------------------- 1 | 2 | [android] 3 | target = Google Inc.:Google APIs:23 4 | 5 | [maven_repositories] 6 | central = https://repo1.maven.org/maven2 7 | -------------------------------------------------------------------------------- /Example/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | env: { 3 | es6: true, 4 | node: true, 5 | }, 6 | parser: 'babel-eslint', 7 | parserOptions: { 8 | ecmaFeatures: { 9 | legacyDecorators: true, 10 | experimentalObjectRestSpread: true, 11 | jsx: true, 12 | }, 13 | sourceType: 'module', 14 | }, 15 | plugins: [ 16 | // 'eslint-comments', 17 | 'prettier', 18 | 'react', 19 | 'react-hooks', 20 | 'react-native', 21 | ], 22 | settings: { 23 | react: { 24 | version: 'detect', 25 | }, 26 | }, 27 | // Map from global var to bool specifying if it can be redefined 28 | globals: { 29 | __DEV__: true, 30 | __dirname: false, 31 | __fbBatchedBridgeConfig: false, 32 | it: true, 33 | alert: false, 34 | cancelAnimationFrame: false, 35 | cancelIdleCallback: false, 36 | clearImmediate: true, 37 | clearInterval: false, 38 | clearTimeout: false, 39 | console: false, 40 | document: false, 41 | escape: false, 42 | Event: false, 43 | EventTarget: false, 44 | exports: false, 45 | fetch: false, 46 | FormData: false, 47 | global: false, 48 | Map: true, 49 | module: false, 50 | navigator: false, 51 | process: false, 52 | Promise: true, 53 | requestAnimationFrame: true, 54 | requestIdleCallback: true, 55 | require: false, 56 | Set: true, 57 | setImmediate: true, 58 | setInterval: false, 59 | setTimeout: false, 60 | window: false, 61 | XMLHttpRequest: false, 62 | }, 63 | rules: { 64 | // General 65 | 'no-cond-assign': 1, // disallow assignment in conditional expressions 66 | 'no-console': 0, // disallow use of console (off by default in the node environment) 67 | 'no-const-assign': 2, // disallow assignment to const-declared variables 68 | 'no-constant-condition': 0, // disallow use of constant expressions in conditions 69 | 'no-control-regex': 1, // disallow control characters in regular expressions 70 | 'no-debugger': 1, // disallow use of debugger 71 | 'no-dupe-class-members': 2, // Disallow duplicate name in class members 72 | 'no-dupe-keys': 2, // disallow duplicate keys when creating object literals 73 | 'no-empty': 0, // disallow empty statements 74 | 'no-ex-assign': 1, // disallow assigning to the exception in a catch block 75 | 'no-extra-boolean-cast': 1, // disallow double-negation boolean casts in a boolean context 76 | 'no-extra-parens': 0, // disallow unnecessary parentheses (off by default) 77 | 'no-extra-semi': 1, // disallow unnecessary semicolons 78 | 'no-func-assign': 1, // disallow overwriting functions written as function declarations 79 | 'no-inner-declarations': 0, // disallow function or variable declarations in nested blocks 80 | 'no-invalid-regexp': 1, // disallow invalid regular expression strings in the RegExp constructor 81 | 'no-negated-in-lhs': 1, // disallow negation of the left operand of an in expression 82 | 'no-obj-calls': 1, // disallow the use of object properties of the global object (Math and JSON) as functions 83 | 'no-regex-spaces': 1, // disallow multiple spaces in a regular expression literal 84 | 'no-reserved-keys': 0, // disallow reserved words being used as object literal keys (off by default) 85 | 'no-sparse-arrays': 1, // disallow sparse arrays 86 | 'no-unreachable': 2, // disallow unreachable statements after a return, throw, continue, or break statement 87 | 'use-isnan': 1, // disallow comparisons with the value NaN 88 | 'valid-jsdoc': 0, // Ensure JSDoc comments are valid (off by default) 89 | 'valid-typeof': 1, // Ensure that the results of typeof are compared against a valid string 90 | 91 | // Best Practices 92 | // These are rules designed to prevent you from making mistakes. They either prescribe a better way of doing something or help you avoid footguns. 93 | 'block-scoped-var': 0, // treat var statements as if they were block scoped (off by default) 94 | complexity: 0, // specify the maximum cyclomatic complexity allowed in a program (off by default) 95 | 'consistent-return': 0, // require return statements to either always or never specify values 96 | curly: 1, // specify curly brace conventions for all control statements 97 | 'default-case': 0, // require default case in switch statements (off by default) 98 | 'dot-notation': 1, // encourages use of dot notation whenever possible 99 | eqeqeq: [1, 'allow-null'], // require the use of === and !== 100 | 'guard-for-in': 0, // make sure for-in loops have an if statement (off by default) 101 | 'no-alert': 1, // disallow the use of alert, confirm, and prompt 102 | 'no-caller': 1, // disallow use of arguments.caller or arguments.callee 103 | 'no-div-regex': 1, // disallow division operators explicitly at beginning of regular expression (off by default) 104 | 'no-else-return': 0, // disallow else after a return in an if (off by default) 105 | 'no-eq-null': 0, // disallow comparisons to null without a type-checking operator (off by default) 106 | 'no-eval': 2, // disallow use of eval() 107 | 'no-extend-native': 1, // disallow adding to native types 108 | 'no-extra-bind': 1, // disallow unnecessary function binding 109 | 'no-fallthrough': 1, // disallow fallthrough of case statements 110 | 'no-floating-decimal': 1, // disallow the use of leading or trailing decimal points in numeric literals (off by default) 111 | 'no-implied-eval': 1, // disallow use of eval()-like methods 112 | 'no-labels': 1, // disallow use of labeled statements 113 | 'no-iterator': 1, // disallow usage of __iterator__ property 114 | 'no-lone-blocks': 1, // disallow unnecessary nested blocks 115 | 'no-loop-func': 0, // disallow creation of functions within loops 116 | 'no-multi-str': 0, // disallow use of multiline strings 117 | 'no-native-reassign': 0, // disallow reassignments of native objects 118 | 'no-new': 1, // disallow use of new operator when not part of the assignment or comparison 119 | 'no-new-func': 2, // disallow use of new operator for Function object 120 | 'no-new-wrappers': 1, // disallows creating new instances of String,Number, and Boolean 121 | 'no-octal': 1, // disallow use of octal literals 122 | 'no-octal-escape': 1, // disallow use of octal escape sequences in string literals, such as var foo = "Copyright \251"; 123 | 'no-proto': 1, // disallow usage of __proto__ property 124 | 'no-redeclare': 0, // disallow declaring the same variable more then once 125 | 'no-return-assign': 1, // disallow use of assignment in return statement 126 | 'no-script-url': 1, // disallow use of javascript: urls. 127 | 'no-self-compare': 1, // disallow comparisons where both sides are exactly the same (off by default) 128 | 'no-sequences': 1, // disallow use of comma operator 129 | 'no-unused-expressions': 0, // disallow usage of expressions in statement position 130 | 'no-void': 1, // disallow use of void operator (off by default) 131 | 'no-warning-comments': 0, // disallow usage of configurable warning terms in comments": 1, // e.g. TODO or FIXME (off by default) 132 | 'no-with': 1, // disallow use of the with statement 133 | radix: 0, // require use of the second argument for parseInt() (off by default) 134 | 'semi-spacing': 1, // require a space after a semi-colon 135 | 'vars-on-top': 0, // requires to declare all vars on top of their containing scope (off by default) 136 | 'wrap-iife': 0, // require immediate function invocation to be wrapped in parentheses (off by default) 137 | yoda: 1, // require or disallow Yoda conditions 138 | 139 | // Variables 140 | // These rules have to do with variable declarations. 141 | 'no-catch-shadow': 0, // disallow the catch clause parameter name being the same as a variable in the outer scope (off by default in the node environment) 142 | 'no-delete-var': 1, // disallow deletion of variables 143 | 'no-label-var': 1, // disallow labels that share a name with a variable 144 | 'no-shadow': 1, // disallow declaration of variables already declared in the outer scope 145 | 'no-shadow-restricted-names': 1, // disallow shadowing of names such as arguments 146 | 'no-undef': 2, // disallow use of undeclared variables unless mentioned in a /*global */ block 147 | 'no-undefined': 0, // disallow use of undefined variable (off by default) 148 | 'no-undef-init': 1, // disallow use of undefined when initializing variables 149 | 'no-unused-vars': [ 150 | 2, 151 | { vars: 'all', args: 'after-used', ignoreRestSiblings: true }, 152 | ], // disallow declaration of variables that are not used in the code 153 | 'no-use-before-define': 0, // disallow use of variables before they are defined 154 | // Node.js 155 | // These rules are specific to JavaScript running on Node.js. 156 | 157 | 'handle-callback-err': 1, // enforces error handling in callbacks (off by default) (on by default in the node environment) 158 | 'no-mixed-requires': 1, // disallow mixing regular variable and require declarations (off by default) (on by default in the node environment) 159 | 'no-new-require': 1, // disallow use of new operator with the require function (off by default) (on by default in the node environment) 160 | 'no-path-concat': 1, // disallow string concatenation with __dirname and __filename (off by default) (on by default in the node environment) 161 | 'no-process-exit': 0, // disallow process.exit() (on by default in the node environment) 162 | 'no-restricted-modules': 1, // restrict usage of specified node modules (off by default) 163 | 'no-sync': 0, // disallow use of synchronous methods (off by default) 164 | 165 | // ESLint Comments Plugin 166 | // The following rules are made available via `eslint-plugin-eslint-comments` 167 | 'eslint-comments/no-aggregating-enable': 1, // disallows eslint-enable comments for multiple eslint-disable comments 168 | 'eslint-comments/no-unlimited-disable': 1, // disallows eslint-disable comments without rule names 169 | 'eslint-comments/no-unused-disable': 1, // disallow disables that don't cover any errors 170 | 'eslint-comments/no-unused-enable': 1, // // disallow enables that don't enable anything or enable rules that weren't disabled 171 | 172 | // Prettier Plugin 173 | // https://github.com/prettier/eslint-plugin-prettier 174 | 'prettier/prettier': 2, 175 | 176 | // Stylistic Issues 177 | // These rules are purely matters of style and are quite subjective. 178 | 'key-spacing': 0, 179 | 'keyword-spacing': 1, // enforce spacing before and after keywords 180 | 'jsx-quotes': [1, 'prefer-double'], // enforces the usage of double quotes for all JSX attribute values which doesn’t contain a double quote 181 | 'comma-spacing': 0, 182 | 'no-multi-spaces': 0, 183 | 'brace-style': 0, // enforce one true brace style (off by default) 184 | camelcase: 0, // require camel case names 185 | 'consistent-this': 1, // enforces consistent naming when capturing the current execution context (off by default) 186 | 'eol-last': 1, // enforce newline at the end of file, with no multiple empty lines 187 | 'func-names': 0, // require function expressions to have a name (off by default) 188 | 'func-style': 0, // enforces use of function declarations or expressions (off by default) 189 | 'new-cap': 0, // require a capital letter for constructors 190 | 'new-parens': 1, // disallow the omission of parentheses when invoking a constructor with no arguments 191 | 'no-nested-ternary': 0, // disallow nested ternary expressions (off by default) 192 | 'no-array-constructor': 1, // disallow use of the Array constructor 193 | 'no-empty-character-class': 1, // disallow the use of empty character classes in regular expressions 194 | 'no-lonely-if': 0, // disallow if as the only statement in an else block (off by default) 195 | 'no-new-object': 1, // disallow use of the Object constructor 196 | 'no-spaced-func': 1, // disallow space between function identifier and application 197 | 'no-ternary': 0, // disallow the use of ternary operators (off by default) 198 | 'no-trailing-spaces': 1, // disallow trailing whitespace at the end of lines 199 | 'no-underscore-dangle': 0, // disallow dangling underscores in identifiers 200 | quotes: [1, 'single', 'avoid-escape'], // specify whether double or single quotes should be used 201 | 'quote-props': 0, // require quotes around object literal property names (off by default) 202 | semi: 0, // require or disallow use of semicolons instead of ASI 203 | 'sort-vars': 0, // sort variables within the same declaration block (off by default) 204 | 'space-in-brackets': 0, // require or disallow spaces inside brackets (off by default) 205 | 'space-in-parens': 0, // require or disallow spaces inside parentheses (off by default) 206 | 'space-infix-ops': 1, // require spaces around operators 207 | 'space-unary-ops': [1, { words: true, nonwords: false }], // require or disallow spaces before/after unary operators (words on by default, nonwords off by default) 208 | 'max-nested-callbacks': 0, // specify the maximum depth callbacks can be nested (off by default) 209 | 'one-var': 0, // allow just one var statement per function (off by default) 210 | 'wrap-regex': 0, // require regex literals to be wrapped in parentheses (off by default) 211 | 212 | // Legacy 213 | // The following rules are included for compatibility with JSHint and JSLint. While the names of the rules may not match up with the JSHint/JSLint counterpart, the functionality is the same. 214 | 215 | 'max-depth': 0, // specify the maximum depth that blocks can be nested (off by default) 216 | 'max-len': 0, // specify the maximum length of a line in your program (off by default) 217 | 'max-params': 0, // limits the number of parameters that can be used in the function declaration. (off by default) 218 | 'max-statements': 0, // specify the maximum number of statement allowed in a function (off by default) 219 | 'no-bitwise': 1, // disallow use of bitwise operators (off by default) 220 | 'no-plusplus': 0, // disallow use of unary operators, ++ and -- (off by default) 221 | 222 | // React Plugin 223 | // The following rules are made available via `eslint-plugin-react`. 224 | 225 | 'react/display-name': 0, 226 | 'react/jsx-boolean-value': 0, 227 | 'react/jsx-no-comment-textnodes': 1, 228 | 'react/jsx-no-duplicate-props': 2, 229 | 'react/jsx-no-undef': 2, 230 | 'react/jsx-sort-props': 0, 231 | 'react/jsx-uses-react': 1, 232 | 'react/jsx-uses-vars': 1, 233 | 'react/no-did-mount-set-state': 1, 234 | 'react/no-did-update-set-state': 1, 235 | 'react/no-multi-comp': 0, 236 | 'react/no-string-refs': 1, 237 | 'react/no-unknown-property': 0, 238 | 'react/prop-types': 0, 239 | 'react/react-in-jsx-scope': 1, 240 | 'react/self-closing-comp': 1, 241 | 'react/wrap-multilines': 0, 242 | 243 | // React-Hooks Plugin 244 | // The following rules are made available via `eslint-plugin-react-hooks` 245 | 'react-hooks/rules-of-hooks': 'error', 246 | 'react-hooks/exhaustive-deps': 'error', 247 | 248 | // React-Native Plugin 249 | // The following rules are made available via `eslint-plugin-react-native` 250 | 251 | 'react-native/no-unused-styles': 0, 252 | 'react-native/split-platform-components': 0, 253 | 'react-native/no-inline-styles': 0, 254 | 'react-native/no-color-literals': 0, 255 | 'react-native/no-raw-text': 2, 256 | }, 257 | }; 258 | -------------------------------------------------------------------------------- /Example/.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | ; We fork some components by platform 3 | .*/*[.]android.js 4 | 5 | ; Ignore "BUCK" generated dirs 6 | /\.buckd/ 7 | 8 | ; Ignore unexpected extra "@providesModule" 9 | .*/node_modules/.*/node_modules/fbjs/.* 10 | 11 | ; Ignore duplicate module providers 12 | ; For RN Apps installed via npm, "Libraries" folder is inside 13 | ; "node_modules/react-native" but in the source repo it is in the root 14 | node_modules/react-native/Libraries/react-native/React.js 15 | 16 | ; Ignore polyfills 17 | node_modules/react-native/Libraries/polyfills/.* 18 | 19 | ; These should not be required directly 20 | ; require from fbjs/lib instead: require('fbjs/lib/warning') 21 | node_modules/warning/.* 22 | 23 | ; Flow doesn't support platforms 24 | .*/Libraries/Utilities/HMRLoadingView.js 25 | 26 | [untyped] 27 | .*/node_modules/@react-native-community/cli/.*/.* 28 | 29 | [include] 30 | 31 | [libs] 32 | node_modules/react-native/Libraries/react-native/react-native-interface.js 33 | node_modules/react-native/flow/ 34 | 35 | [options] 36 | emoji=true 37 | 38 | esproposal.optional_chaining=enable 39 | esproposal.nullish_coalescing=enable 40 | 41 | module.file_ext=.js 42 | module.file_ext=.json 43 | module.file_ext=.ios.js 44 | 45 | module.system=haste 46 | module.system.haste.use_name_reducers=true 47 | # get basename 48 | module.system.haste.name_reducers='^.*/\([a-zA-Z0-9$_.-]+\.js\(\.flow\)?\)$' -> '\1' 49 | # strip .js or .js.flow suffix 50 | module.system.haste.name_reducers='^\(.*\)\.js\(\.flow\)?$' -> '\1' 51 | # strip .ios suffix 52 | module.system.haste.name_reducers='^\(.*\)\.ios$' -> '\1' 53 | module.system.haste.name_reducers='^\(.*\)\.android$' -> '\1' 54 | module.system.haste.name_reducers='^\(.*\)\.native$' -> '\1' 55 | module.system.haste.paths.blacklist=.*/__tests__/.* 56 | module.system.haste.paths.blacklist=.*/__mocks__/.* 57 | module.system.haste.paths.whitelist=/node_modules/react-native/Libraries/.* 58 | module.system.haste.paths.whitelist=/node_modules/react-native/RNTester/.* 59 | module.system.haste.paths.whitelist=/node_modules/react-native/IntegrationTests/.* 60 | module.system.haste.paths.blacklist=/node_modules/react-native/Libraries/react-native/react-native-implementation.js 61 | module.system.haste.paths.blacklist=/node_modules/react-native/Libraries/Animated/src/polyfills/.* 62 | 63 | munge_underscores=true 64 | 65 | module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> 'RelativeImageStub' 66 | 67 | suppress_type=$FlowIssue 68 | suppress_type=$FlowFixMe 69 | suppress_type=$FlowFixMeProps 70 | suppress_type=$FlowFixMeState 71 | 72 | suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(\\)? *\\(site=[a-z,_]*react_native\\(_ios\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\) 73 | suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(\\)? *\\(site=[a-z,_]*react_native\\(_ios\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\)?:? #[0-9]+ 74 | suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError 75 | 76 | [lints] 77 | sketchy-null-number=warn 78 | sketchy-null-mixed=warn 79 | sketchy-number=warn 80 | untyped-type-import=warn 81 | nonstrict-import=warn 82 | deprecated-type=warn 83 | unsafe-getters-setters=warn 84 | inexact-spread=warn 85 | unnecessary-invariant=warn 86 | signature-verification-failure=warn 87 | deprecated-utility=error 88 | 89 | [strict] 90 | deprecated-type 91 | nonstrict-import 92 | sketchy-null 93 | unclear-type 94 | unsafe-getters-setters 95 | untyped-import 96 | untyped-type-import 97 | 98 | [version] 99 | ^0.98.0 100 | -------------------------------------------------------------------------------- /Example/.gitattributes: -------------------------------------------------------------------------------- 1 | *.pbxproj -text 2 | -------------------------------------------------------------------------------- /Example/.gitignore: -------------------------------------------------------------------------------- 1 | # OSX 2 | # 3 | .DS_Store 4 | 5 | # Xcode 6 | # 7 | build/ 8 | *.pbxuser 9 | !default.pbxuser 10 | *.mode1v3 11 | !default.mode1v3 12 | *.mode2v3 13 | !default.mode2v3 14 | *.perspectivev3 15 | !default.perspectivev3 16 | xcuserdata 17 | *.xccheckout 18 | *.moved-aside 19 | DerivedData 20 | *.hmap 21 | *.ipa 22 | *.xcuserstate 23 | project.xcworkspace 24 | 25 | # Android/IntelliJ 26 | # 27 | build/ 28 | .idea 29 | .gradle 30 | local.properties 31 | *.iml 32 | 33 | # node.js 34 | # 35 | node_modules/ 36 | npm-debug.log 37 | yarn-error.log 38 | 39 | # BUCK 40 | buck-out/ 41 | \.buckd/ 42 | *.keystore 43 | 44 | # fastlane 45 | # 46 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 47 | # screenshots whenever they are needed. 48 | # For more information about the recommended setup visit: 49 | # https://docs.fastlane.tools/best-practices/source-control/ 50 | 51 | */fastlane/report.xml 52 | */fastlane/Preview.html 53 | */fastlane/screenshots 54 | 55 | # Bundle artifact 56 | *.jsbundle 57 | 58 | # CocoaPods 59 | /ios/Pods/ 60 | -------------------------------------------------------------------------------- /Example/.prettierrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | semi: true, 3 | bracketSpacing: true, 4 | jsxBracketSameLine: false, 5 | singleQuote: true, 6 | trailingComma: 'all', 7 | proseWrap: 'preserve', 8 | arrowParens: 'always', 9 | }; 10 | -------------------------------------------------------------------------------- /Example/.watchmanconfig: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /Example/App.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | import React, { useState } from 'react'; 3 | import { 4 | View, 5 | Text, 6 | StyleSheet, 7 | FlatList, 8 | TouchableOpacity, 9 | } from 'react-native'; 10 | // eslint-disable-next-line no-unused-vars 11 | import RefreshNormalHeader from './src/RefreshNormalHeader'; 12 | import RefreshAnimateHeader from './src/RefreshAnimateHeader'; 13 | 14 | const dataTemp = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]; 15 | 16 | function App() { 17 | const [refreshing, setRefreshing] = useState(false); 18 | const [data, setData] = useState(dataTemp); 19 | 20 | return ( 21 | 22 | { 28 | setRefreshing(true); 29 | setTimeout(() => { 30 | setRefreshing(false); 31 | }, 3000); 32 | }} 33 | /> 34 | } 35 | keyExtractor={(item, index) => index + ''} 36 | data={data} 37 | renderItem={({ index }) => { 38 | return ( 39 | { 42 | alert('点击'); 43 | }} 44 | > 45 | {'Item' + index} 46 | 47 | ); 48 | }} 49 | /> 50 | 51 | ); 52 | } 53 | 54 | const styles = StyleSheet.create({ 55 | container: { 56 | flex: 1, 57 | marginTop: 20, 58 | }, 59 | }); 60 | 61 | export default React.memo(App); 62 | -------------------------------------------------------------------------------- /Example/__tests__/App-test.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @format 3 | */ 4 | 5 | import 'react-native'; 6 | import React from 'react'; 7 | import App from '../App'; 8 | 9 | // Note: test renderer must be required after react-native. 10 | import renderer from 'react-test-renderer'; 11 | 12 | it('renders correctly', () => { 13 | renderer.create(); 14 | }); 15 | -------------------------------------------------------------------------------- /Example/android/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | aexample 4 | Project android created by Buildship. 5 | 6 | 7 | 8 | 9 | org.eclipse.buildship.core.gradleprojectbuilder 10 | 11 | 12 | 13 | 14 | 15 | org.eclipse.buildship.core.gradleprojectnature 16 | 17 | 18 | -------------------------------------------------------------------------------- /Example/android/app/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /Example/android/app/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | app 4 | Project app created by Buildship. 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.buildship.core.gradleprojectbuilder 15 | 16 | 17 | 18 | 19 | 20 | org.eclipse.jdt.core.javanature 21 | org.eclipse.buildship.core.gradleprojectnature 22 | 23 | 24 | -------------------------------------------------------------------------------- /Example/android/app/BUCK: -------------------------------------------------------------------------------- 1 | # To learn about Buck see [Docs](https://buckbuild.com/). 2 | # To run your application with Buck: 3 | # - install Buck 4 | # - `npm start` - to start the packager 5 | # - `cd android` 6 | # - `keytool -genkey -v -keystore keystores/debug.keystore -storepass android -alias androiddebugkey -keypass android -dname "CN=Android Debug,O=Android,C=US"` 7 | # - `./gradlew :app:copyDownloadableDepsToLibs` - make all Gradle compile dependencies available to Buck 8 | # - `buck install -r android/app` - compile, install and run application 9 | # 10 | 11 | load(":build_defs.bzl", "create_aar_targets", "create_jar_targets") 12 | 13 | lib_deps = [] 14 | 15 | create_aar_targets(glob(["libs/*.aar"])) 16 | 17 | create_jar_targets(glob(["libs/*.jar"])) 18 | 19 | android_library( 20 | name = "all-libs", 21 | exported_deps = lib_deps, 22 | ) 23 | 24 | android_library( 25 | name = "app-code", 26 | srcs = glob([ 27 | "src/main/java/**/*.java", 28 | ]), 29 | deps = [ 30 | ":all-libs", 31 | ":build_config", 32 | ":res", 33 | ], 34 | ) 35 | 36 | android_build_config( 37 | name = "build_config", 38 | package = "com.aexample", 39 | ) 40 | 41 | android_resource( 42 | name = "res", 43 | package = "com.aexample", 44 | res = "src/main/res", 45 | ) 46 | 47 | android_binary( 48 | name = "app", 49 | keystore = "//android/keystores:debug", 50 | manifest = "src/main/AndroidManifest.xml", 51 | package_type = "debug", 52 | deps = [ 53 | ":app-code", 54 | ], 55 | ) 56 | -------------------------------------------------------------------------------- /Example/android/app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: "com.android.application" 2 | 3 | import com.android.build.OutputFile 4 | 5 | /** 6 | * The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets 7 | * and bundleReleaseJsAndAssets). 8 | * These basically call `react-native bundle` with the correct arguments during the Android build 9 | * cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the 10 | * bundle directly from the development server. Below you can see all the possible configurations 11 | * and their defaults. If you decide to add a configuration block, make sure to add it before the 12 | * `apply from: "../../node_modules/react-native/react.gradle"` line. 13 | * 14 | * project.ext.react = [ 15 | * // the name of the generated asset file containing your JS bundle 16 | * bundleAssetName: "index.android.bundle", 17 | * 18 | * // the entry file for bundle generation 19 | * entryFile: "index.android.js", 20 | * 21 | * // https://facebook.github.io/react-native/docs/performance#enable-the-ram-format 22 | * bundleCommand: "ram-bundle", 23 | * 24 | * // whether to bundle JS and assets in debug mode 25 | * bundleInDebug: false, 26 | * 27 | * // whether to bundle JS and assets in release mode 28 | * bundleInRelease: true, 29 | * 30 | * // whether to bundle JS and assets in another build variant (if configured). 31 | * // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants 32 | * // The configuration property can be in the following formats 33 | * // 'bundleIn${productFlavor}${buildType}' 34 | * // 'bundleIn${buildType}' 35 | * // bundleInFreeDebug: true, 36 | * // bundleInPaidRelease: true, 37 | * // bundleInBeta: true, 38 | * 39 | * // whether to disable dev mode in custom build variants (by default only disabled in release) 40 | * // for example: to disable dev mode in the staging build type (if configured) 41 | * devDisabledInStaging: true, 42 | * // The configuration property can be in the following formats 43 | * // 'devDisabledIn${productFlavor}${buildType}' 44 | * // 'devDisabledIn${buildType}' 45 | * 46 | * // the root of your project, i.e. where "package.json" lives 47 | * root: "../../", 48 | * 49 | * // where to put the JS bundle asset in debug mode 50 | * jsBundleDirDebug: "$buildDir/intermediates/assets/debug", 51 | * 52 | * // where to put the JS bundle asset in release mode 53 | * jsBundleDirRelease: "$buildDir/intermediates/assets/release", 54 | * 55 | * // where to put drawable resources / React Native assets, e.g. the ones you use via 56 | * // require('./image.png')), in debug mode 57 | * resourcesDirDebug: "$buildDir/intermediates/res/merged/debug", 58 | * 59 | * // where to put drawable resources / React Native assets, e.g. the ones you use via 60 | * // require('./image.png')), in release mode 61 | * resourcesDirRelease: "$buildDir/intermediates/res/merged/release", 62 | * 63 | * // by default the gradle tasks are skipped if none of the JS files or assets change; this means 64 | * // that we don't look at files in android/ or ios/ to determine whether the tasks are up to 65 | * // date; if you have any other folders that you want to ignore for performance reasons (gradle 66 | * // indexes the entire tree), add them here. Alternatively, if you have JS files in android/ 67 | * // for example, you might want to remove it from here. 68 | * inputExcludes: ["android/**", "ios/**"], 69 | * 70 | * // override which node gets called and with what additional arguments 71 | * nodeExecutableAndArgs: ["node"], 72 | * 73 | * // supply additional arguments to the packager 74 | * extraPackagerArgs: [] 75 | * ] 76 | */ 77 | 78 | project.ext.react = [ 79 | entryFile: "index.js", 80 | enableHermes: false, // clean and rebuild if changing 81 | ] 82 | 83 | apply from: "../../node_modules/react-native/react.gradle" 84 | 85 | /** 86 | * Set this to true to create two separate APKs instead of one: 87 | * - An APK that only works on ARM devices 88 | * - An APK that only works on x86 devices 89 | * The advantage is the size of the APK is reduced by about 4MB. 90 | * Upload all the APKs to the Play Store and people will download 91 | * the correct one based on the CPU architecture of their device. 92 | */ 93 | def enableSeparateBuildPerCPUArchitecture = false 94 | 95 | /** 96 | * Run Proguard to shrink the Java bytecode in release builds. 97 | */ 98 | def enableProguardInReleaseBuilds = false 99 | 100 | /** 101 | * The preferred build flavor of JavaScriptCore. 102 | * 103 | * For example, to use the international variant, you can use: 104 | * `def jscFlavor = 'org.webkit:android-jsc-intl:+'` 105 | * 106 | * The international variant includes ICU i18n library and necessary data 107 | * allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that 108 | * give correct results when using with locales other than en-US. Note that 109 | * this variant is about 6MiB larger per architecture than default. 110 | */ 111 | def jscFlavor = 'org.webkit:android-jsc:+' 112 | 113 | /** 114 | * Whether to enable the Hermes VM. 115 | * 116 | * This should be set on project.ext.react and mirrored here. If it is not set 117 | * on project.ext.react, JavaScript will not be compiled to Hermes Bytecode 118 | * and the benefits of using Hermes will therefore be sharply reduced. 119 | */ 120 | def enableHermes = project.ext.react.get("enableHermes", false); 121 | 122 | android { 123 | compileSdkVersion rootProject.ext.compileSdkVersion 124 | 125 | compileOptions { 126 | sourceCompatibility JavaVersion.VERSION_1_8 127 | targetCompatibility JavaVersion.VERSION_1_8 128 | } 129 | 130 | defaultConfig { 131 | applicationId "com.aexample" 132 | minSdkVersion rootProject.ext.minSdkVersion 133 | targetSdkVersion rootProject.ext.targetSdkVersion 134 | versionCode 1 135 | versionName "1.0" 136 | } 137 | splits { 138 | abi { 139 | reset() 140 | enable enableSeparateBuildPerCPUArchitecture 141 | universalApk false // If true, also generate a universal APK 142 | include "armeabi-v7a", "x86", "arm64-v8a", "x86_64" 143 | } 144 | } 145 | signingConfigs { 146 | debug { 147 | // storeFile file('debug.keystore') 148 | // storePassword 'android' 149 | // keyAlias 'androiddebugkey' 150 | // keyPassword 'android' 151 | } 152 | } 153 | buildTypes { 154 | debug { 155 | signingConfig signingConfigs.debug 156 | } 157 | release { 158 | // Caution! In production, you need to generate your own keystore file. 159 | // see https://facebook.github.io/react-native/docs/signed-apk-android. 160 | signingConfig signingConfigs.debug 161 | minifyEnabled enableProguardInReleaseBuilds 162 | proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" 163 | } 164 | } 165 | // applicationVariants are e.g. debug, release 166 | applicationVariants.all { variant -> 167 | variant.outputs.each { output -> 168 | // For each separate APK per architecture, set a unique version code as described here: 169 | // https://developer.android.com/studio/build/configure-apk-splits.html 170 | def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4] 171 | def abi = output.getFilter(OutputFile.ABI) 172 | if (abi != null) { // null for the universal-debug, universal-release variants 173 | output.versionCodeOverride = 174 | versionCodes.get(abi) * 1048576 + defaultConfig.versionCode 175 | } 176 | 177 | } 178 | } 179 | 180 | packagingOptions { 181 | pickFirst '**/armeabi-v7a/libc++_shared.so' 182 | pickFirst '**/x86/libc++_shared.so' 183 | pickFirst '**/arm64-v8a/libc++_shared.so' 184 | pickFirst '**/x86_64/libc++_shared.so' 185 | pickFirst '**/x86/libjsc.so' 186 | pickFirst '**/armeabi-v7a/libjsc.so' 187 | } 188 | } 189 | 190 | dependencies { 191 | implementation fileTree(dir: "libs", include: ["*.jar"]) 192 | implementation "com.facebook.react:react-native:+" // From node_modules 193 | 194 | if (enableHermes) { 195 | def hermesPath = "../../node_modules/hermesvm/android/"; 196 | debugImplementation files(hermesPath + "hermes-debug.aar") 197 | releaseImplementation files(hermesPath + "hermes-release.aar") 198 | } else { 199 | implementation jscFlavor 200 | } 201 | } 202 | 203 | // Run this once to be able to run the application with BUCK 204 | // puts all compile dependencies into folder libs for BUCK to use 205 | task copyDownloadableDepsToLibs(type: Copy) { 206 | from configurations.compile 207 | into 'libs' 208 | } 209 | 210 | apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project) 211 | -------------------------------------------------------------------------------- /Example/android/app/build_defs.bzl: -------------------------------------------------------------------------------- 1 | """Helper definitions to glob .aar and .jar targets""" 2 | 3 | def create_aar_targets(aarfiles): 4 | for aarfile in aarfiles: 5 | name = "aars__" + aarfile[aarfile.rindex("/") + 1:aarfile.rindex(".aar")] 6 | lib_deps.append(":" + name) 7 | android_prebuilt_aar( 8 | name = name, 9 | aar = aarfile, 10 | ) 11 | 12 | def create_jar_targets(jarfiles): 13 | for jarfile in jarfiles: 14 | name = "jars__" + jarfile[jarfile.rindex("/") + 1:jarfile.rindex(".jar")] 15 | lib_deps.append(":" + name) 16 | prebuilt_jar( 17 | name = name, 18 | binary_jar = jarfile, 19 | ) 20 | -------------------------------------------------------------------------------- /Example/android/app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /usr/local/Cellar/android-sdk/24.3.3/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | -------------------------------------------------------------------------------- /Example/android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Example/android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 13 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Example/android/app/src/main/java/com/aexample/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.aexample; 2 | 3 | import com.facebook.react.ReactActivity; 4 | 5 | public class MainActivity extends ReactActivity { 6 | 7 | /** 8 | * Returns the name of the main component registered from JavaScript. 9 | * This is used to schedule rendering of the component. 10 | */ 11 | @Override 12 | protected String getMainComponentName() { 13 | return "aexample"; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Example/android/app/src/main/java/com/aexample/MainApplication.java: -------------------------------------------------------------------------------- 1 | package com.aexample; 2 | 3 | import android.app.Application; 4 | import android.util.Log; 5 | 6 | import com.facebook.react.PackageList; 7 | import com.facebook.hermes.reactexecutor.HermesExecutorFactory; 8 | import com.facebook.react.bridge.JavaScriptExecutorFactory; 9 | import com.facebook.react.ReactApplication; 10 | import com.facebook.react.ReactNativeHost; 11 | import com.facebook.react.ReactPackage; 12 | import com.facebook.soloader.SoLoader; 13 | 14 | import java.util.List; 15 | 16 | public class MainApplication extends Application implements ReactApplication { 17 | 18 | private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) { 19 | @Override 20 | public boolean getUseDeveloperSupport() { 21 | return BuildConfig.DEBUG; 22 | } 23 | 24 | @Override 25 | protected List getPackages() { 26 | @SuppressWarnings("UnnecessaryLocalVariable") 27 | List packages = new PackageList(this).getPackages(); 28 | // Packages that cannot be autolinked yet can be added manually here, for example: 29 | // packages.add(new MyReactNativePackage()); 30 | return packages; 31 | } 32 | 33 | @Override 34 | protected String getJSMainModuleName() { 35 | return "index"; 36 | } 37 | }; 38 | 39 | @Override 40 | public ReactNativeHost getReactNativeHost() { 41 | return mReactNativeHost; 42 | } 43 | 44 | @Override 45 | public void onCreate() { 46 | super.onCreate(); 47 | SoLoader.init(this, /* native exopackage */ false); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CloudlessMoon/react-native-refresh/8d768f65697d0e4c8109ff967ca086ee28f561cc/Example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /Example/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CloudlessMoon/react-native-refresh/8d768f65697d0e4c8109ff967ca086ee28f561cc/Example/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /Example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CloudlessMoon/react-native-refresh/8d768f65697d0e4c8109ff967ca086ee28f561cc/Example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /Example/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CloudlessMoon/react-native-refresh/8d768f65697d0e4c8109ff967ca086ee28f561cc/Example/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /Example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CloudlessMoon/react-native-refresh/8d768f65697d0e4c8109ff967ca086ee28f561cc/Example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /Example/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CloudlessMoon/react-native-refresh/8d768f65697d0e4c8109ff967ca086ee28f561cc/Example/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /Example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CloudlessMoon/react-native-refresh/8d768f65697d0e4c8109ff967ca086ee28f561cc/Example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /Example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CloudlessMoon/react-native-refresh/8d768f65697d0e4c8109ff967ca086ee28f561cc/Example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /Example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CloudlessMoon/react-native-refresh/8d768f65697d0e4c8109ff967ca086ee28f561cc/Example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /Example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CloudlessMoon/react-native-refresh/8d768f65697d0e4c8109ff967ca086ee28f561cc/Example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /Example/android/app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | aexample 3 | 4 | -------------------------------------------------------------------------------- /Example/android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /Example/android/build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | ext { 5 | buildToolsVersion = "28.0.3" 6 | minSdkVersion = 16 7 | compileSdkVersion = 28 8 | targetSdkVersion = 28 9 | supportLibVersion = "28.0.0" 10 | } 11 | repositories { 12 | google() 13 | jcenter() 14 | } 15 | dependencies { 16 | classpath("com.android.tools.build:gradle:3.4.1") 17 | 18 | // NOTE: Do not place your application dependencies here; they belong 19 | // in the individual module build.gradle files 20 | } 21 | } 22 | 23 | allprojects { 24 | repositories { 25 | mavenLocal() 26 | maven { 27 | // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm 28 | url("$rootDir/../node_modules/react-native/android") 29 | } 30 | maven { 31 | // Android JSC is installed from npm 32 | url("$rootDir/../node_modules/jsc-android/dist") 33 | } 34 | 35 | google() 36 | jcenter() 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Example/android/gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true 19 | 20 | android.useAndroidX=true 21 | android.enableJetifier=true 22 | -------------------------------------------------------------------------------- /Example/android/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CloudlessMoon/react-native-refresh/8d768f65697d0e4c8109ff967ca086ee28f561cc/Example/android/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /Example/android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /Example/android/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | # 4 | # Copyright 2015 the original author or authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | ############################################################################## 20 | ## 21 | ## Gradle start up script for UN*X 22 | ## 23 | ############################################################################## 24 | 25 | # Attempt to set APP_HOME 26 | # Resolve links: $0 may be a link 27 | PRG="$0" 28 | # Need this for relative symlinks. 29 | while [ -h "$PRG" ] ; do 30 | ls=`ls -ld "$PRG"` 31 | link=`expr "$ls" : '.*-> \(.*\)$'` 32 | if expr "$link" : '/.*' > /dev/null; then 33 | PRG="$link" 34 | else 35 | PRG=`dirname "$PRG"`"/$link" 36 | fi 37 | done 38 | SAVED="`pwd`" 39 | cd "`dirname \"$PRG\"`/" >/dev/null 40 | APP_HOME="`pwd -P`" 41 | cd "$SAVED" >/dev/null 42 | 43 | APP_NAME="Gradle" 44 | APP_BASE_NAME=`basename "$0"` 45 | 46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 48 | 49 | # Use the maximum available, or set MAX_FD != -1 to use that value. 50 | MAX_FD="maximum" 51 | 52 | warn () { 53 | echo "$*" 54 | } 55 | 56 | die () { 57 | echo 58 | echo "$*" 59 | echo 60 | exit 1 61 | } 62 | 63 | # OS specific support (must be 'true' or 'false'). 64 | cygwin=false 65 | msys=false 66 | darwin=false 67 | nonstop=false 68 | case "`uname`" in 69 | CYGWIN* ) 70 | cygwin=true 71 | ;; 72 | Darwin* ) 73 | darwin=true 74 | ;; 75 | MINGW* ) 76 | msys=true 77 | ;; 78 | NONSTOP* ) 79 | nonstop=true 80 | ;; 81 | esac 82 | 83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 84 | 85 | # Determine the Java command to use to start the JVM. 86 | if [ -n "$JAVA_HOME" ] ; then 87 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 88 | # IBM's JDK on AIX uses strange locations for the executables 89 | JAVACMD="$JAVA_HOME/jre/sh/java" 90 | else 91 | JAVACMD="$JAVA_HOME/bin/java" 92 | fi 93 | if [ ! -x "$JAVACMD" ] ; then 94 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 95 | 96 | Please set the JAVA_HOME variable in your environment to match the 97 | location of your Java installation." 98 | fi 99 | else 100 | JAVACMD="java" 101 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 102 | 103 | Please set the JAVA_HOME variable in your environment to match the 104 | location of your Java installation." 105 | fi 106 | 107 | # Increase the maximum file descriptors if we can. 108 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 109 | MAX_FD_LIMIT=`ulimit -H -n` 110 | if [ $? -eq 0 ] ; then 111 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 112 | MAX_FD="$MAX_FD_LIMIT" 113 | fi 114 | ulimit -n $MAX_FD 115 | if [ $? -ne 0 ] ; then 116 | warn "Could not set maximum file descriptor limit: $MAX_FD" 117 | fi 118 | else 119 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 120 | fi 121 | fi 122 | 123 | # For Darwin, add options to specify how the application appears in the dock 124 | if $darwin; then 125 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 126 | fi 127 | 128 | # For Cygwin, switch paths to Windows format before running java 129 | if $cygwin ; then 130 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 131 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 132 | JAVACMD=`cygpath --unix "$JAVACMD"` 133 | 134 | # We build the pattern for arguments to be converted via cygpath 135 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 136 | SEP="" 137 | for dir in $ROOTDIRSRAW ; do 138 | ROOTDIRS="$ROOTDIRS$SEP$dir" 139 | SEP="|" 140 | done 141 | OURCYGPATTERN="(^($ROOTDIRS))" 142 | # Add a user-defined pattern to the cygpath arguments 143 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 144 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 145 | fi 146 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 147 | i=0 148 | for arg in "$@" ; do 149 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 150 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 151 | 152 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 153 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 154 | else 155 | eval `echo args$i`="\"$arg\"" 156 | fi 157 | i=$((i+1)) 158 | done 159 | case $i in 160 | (0) set -- ;; 161 | (1) set -- "$args0" ;; 162 | (2) set -- "$args0" "$args1" ;; 163 | (3) set -- "$args0" "$args1" "$args2" ;; 164 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 165 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 166 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 167 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 168 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 169 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 170 | esac 171 | fi 172 | 173 | # Escape application args 174 | save () { 175 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 176 | echo " " 177 | } 178 | APP_ARGS=$(save "$@") 179 | 180 | # Collect all arguments for the java command, following the shell quoting and substitution rules 181 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 182 | 183 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong 184 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then 185 | cd "$(dirname "$0")" 186 | fi 187 | 188 | exec "$JAVACMD" "$@" 189 | -------------------------------------------------------------------------------- /Example/android/gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem http://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%" == "" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%" == "" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 33 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 34 | 35 | @rem Find java.exe 36 | if defined JAVA_HOME goto findJavaFromJavaHome 37 | 38 | set JAVA_EXE=java.exe 39 | %JAVA_EXE% -version >NUL 2>&1 40 | if "%ERRORLEVEL%" == "0" goto init 41 | 42 | echo. 43 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 44 | echo. 45 | echo Please set the JAVA_HOME variable in your environment to match the 46 | echo location of your Java installation. 47 | 48 | goto fail 49 | 50 | :findJavaFromJavaHome 51 | set JAVA_HOME=%JAVA_HOME:"=% 52 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 53 | 54 | if exist "%JAVA_EXE%" goto init 55 | 56 | echo. 57 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 58 | echo. 59 | echo Please set the JAVA_HOME variable in your environment to match the 60 | echo location of your Java installation. 61 | 62 | goto fail 63 | 64 | :init 65 | @rem Get command-line arguments, handling Windows variants 66 | 67 | if not "%OS%" == "Windows_NT" goto win9xME_args 68 | 69 | :win9xME_args 70 | @rem Slurp the command line arguments. 71 | set CMD_LINE_ARGS= 72 | set _SKIP=2 73 | 74 | :win9xME_args_slurp 75 | if "x%~1" == "x" goto execute 76 | 77 | set CMD_LINE_ARGS=%* 78 | 79 | :execute 80 | @rem Setup the command line 81 | 82 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 83 | 84 | @rem Execute Gradle 85 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 86 | 87 | :end 88 | @rem End local scope for the variables with windows NT shell 89 | if "%ERRORLEVEL%"=="0" goto mainEnd 90 | 91 | :fail 92 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 93 | rem the _cmd.exe /c_ return code! 94 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 95 | exit /b 1 96 | 97 | :mainEnd 98 | if "%OS%"=="Windows_NT" endlocal 99 | 100 | :omega 101 | -------------------------------------------------------------------------------- /Example/android/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'aexample' 2 | apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings) 3 | include ':app' 4 | -------------------------------------------------------------------------------- /Example/app.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "aexample", 3 | "displayName": "aexample" 4 | } -------------------------------------------------------------------------------- /Example/babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: ['module:metro-react-native-babel-preset'], 3 | }; 4 | -------------------------------------------------------------------------------- /Example/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @format 3 | */ 4 | 5 | import {AppRegistry} from 'react-native'; 6 | import App from './App'; 7 | import {name as appName} from './app.json'; 8 | 9 | AppRegistry.registerComponent(appName, () => App); 10 | -------------------------------------------------------------------------------- /Example/ios/1.swift: -------------------------------------------------------------------------------- 1 | // 2 | // 1.swift 3 | // aexample 4 | // 5 | // Created by RuanMei on 2019/8/30. 6 | // Copyright © 2019 Facebook. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | -------------------------------------------------------------------------------- /Example/ios/Podfile: -------------------------------------------------------------------------------- 1 | platform :ios, '10.0' 2 | require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules' 3 | 4 | target 'aexample' do 5 | # Pods for aexample 6 | pod 'React', :path => '../node_modules/react-native/' 7 | pod 'React-Core', :path => '../node_modules/react-native/React' 8 | pod 'React-DevSupport', :path => '../node_modules/react-native/React' 9 | pod 'React-RCTActionSheet', :path => '../node_modules/react-native/Libraries/ActionSheetIOS' 10 | pod 'React-RCTAnimation', :path => '../node_modules/react-native/Libraries/NativeAnimation' 11 | pod 'React-RCTBlob', :path => '../node_modules/react-native/Libraries/Blob' 12 | pod 'React-RCTImage', :path => '../node_modules/react-native/Libraries/Image' 13 | pod 'React-RCTLinking', :path => '../node_modules/react-native/Libraries/LinkingIOS' 14 | pod 'React-RCTNetwork', :path => '../node_modules/react-native/Libraries/Network' 15 | pod 'React-RCTSettings', :path => '../node_modules/react-native/Libraries/Settings' 16 | pod 'React-RCTText', :path => '../node_modules/react-native/Libraries/Text' 17 | pod 'React-RCTVibration', :path => '../node_modules/react-native/Libraries/Vibration' 18 | pod 'React-RCTWebSocket', :path => '../node_modules/react-native/Libraries/WebSocket' 19 | 20 | pod 'React-cxxreact', :path => '../node_modules/react-native/ReactCommon/cxxreact' 21 | pod 'React-jsi', :path => '../node_modules/react-native/ReactCommon/jsi' 22 | pod 'React-jsiexecutor', :path => '../node_modules/react-native/ReactCommon/jsiexecutor' 23 | pod 'React-jsinspector', :path => '../node_modules/react-native/ReactCommon/jsinspector' 24 | pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga' 25 | 26 | pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec' 27 | pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec' 28 | pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec' 29 | 30 | pod 'LookinServer', :configurations => ['Debug'] 31 | 32 | target 'aexampleTests' do 33 | inherit! :search_paths 34 | # Pods for testing 35 | end 36 | 37 | use_native_modules! 38 | end 39 | 40 | target 'aexample-tvOS' do 41 | # Pods for aexample-tvOS 42 | 43 | target 'aexample-tvOSTests' do 44 | inherit! :search_paths 45 | # Pods for testing 46 | end 47 | 48 | end 49 | -------------------------------------------------------------------------------- /Example/ios/aexample-tvOS/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | NSAppTransportSecurity 26 | 27 | NSExceptionDomains 28 | 29 | localhost 30 | 31 | NSExceptionAllowsInsecureHTTPLoads 32 | 33 | 34 | 35 | 36 | NSLocationWhenInUseUsageDescription 37 | 38 | UILaunchStoryboardName 39 | LaunchScreen 40 | UIRequiredDeviceCapabilities 41 | 42 | armv7 43 | 44 | UISupportedInterfaceOrientations 45 | 46 | UIInterfaceOrientationPortrait 47 | UIInterfaceOrientationLandscapeLeft 48 | UIInterfaceOrientationLandscapeRight 49 | 50 | UIViewControllerBasedStatusBarAppearance 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /Example/ios/aexample-tvOSTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /Example/ios/aexample.xcodeproj/xcshareddata/xcschemes/aexample-tvOS.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 29 | 35 | 36 | 37 | 43 | 49 | 50 | 51 | 52 | 53 | 58 | 59 | 61 | 67 | 68 | 69 | 70 | 71 | 77 | 78 | 79 | 80 | 81 | 82 | 92 | 94 | 100 | 101 | 102 | 103 | 104 | 105 | 111 | 113 | 119 | 120 | 121 | 122 | 124 | 125 | 128 | 129 | 130 | -------------------------------------------------------------------------------- /Example/ios/aexample.xcodeproj/xcshareddata/xcschemes/aexample.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 29 | 35 | 36 | 37 | 43 | 49 | 50 | 51 | 52 | 53 | 58 | 59 | 61 | 67 | 68 | 69 | 70 | 71 | 77 | 78 | 79 | 80 | 81 | 82 | 92 | 94 | 100 | 101 | 102 | 103 | 104 | 105 | 111 | 113 | 119 | 120 | 121 | 122 | 124 | 125 | 128 | 129 | 130 | -------------------------------------------------------------------------------- /Example/ios/aexample.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /Example/ios/aexample.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Example/ios/aexample/AppDelegate.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Facebook, Inc. and its affiliates. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | #import 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (nonatomic, strong) UIWindow *window; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /Example/ios/aexample/AppDelegate.m: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Facebook, Inc. and its affiliates. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | #import "AppDelegate.h" 9 | 10 | #import 11 | #import 12 | #import 13 | 14 | @implementation AppDelegate 15 | 16 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 17 | { 18 | RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions]; 19 | RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge 20 | moduleName:@"aexample" 21 | initialProperties:nil]; 22 | 23 | rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1]; 24 | 25 | self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; 26 | UIViewController *rootViewController = [UIViewController new]; 27 | rootViewController.view = rootView; 28 | self.window.rootViewController = rootViewController; 29 | [self.window makeKeyAndVisible]; 30 | return YES; 31 | } 32 | 33 | - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge 34 | { 35 | #if DEBUG 36 | return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil]; 37 | #else 38 | return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"]; 39 | #endif 40 | } 41 | 42 | @end 43 | -------------------------------------------------------------------------------- /Example/ios/aexample/Base.lproj/LaunchScreen.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 21 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /Example/ios/aexample/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /Example/ios/aexample/Images.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /Example/ios/aexample/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | aexample 9 | CFBundleExecutable 10 | $(EXECUTABLE_NAME) 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1 25 | LSRequiresIPhoneOS 26 | 27 | NSAppTransportSecurity 28 | 29 | NSAllowsArbitraryLoads 30 | 31 | NSExceptionDomains 32 | 33 | localhost 34 | 35 | NSExceptionAllowsInsecureHTTPLoads 36 | 37 | 38 | 39 | 40 | NSLocationWhenInUseUsageDescription 41 | 42 | UILaunchStoryboardName 43 | LaunchScreen 44 | UIRequiredDeviceCapabilities 45 | 46 | armv7 47 | 48 | UISupportedInterfaceOrientations 49 | 50 | UIInterfaceOrientationPortrait 51 | UIInterfaceOrientationLandscapeLeft 52 | UIInterfaceOrientationLandscapeRight 53 | 54 | UIViewControllerBasedStatusBarAppearance 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /Example/ios/aexample/main.m: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Facebook, Inc. and its affiliates. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | #import 9 | 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Example/ios/aexampleTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /Example/ios/aexampleTests/aexampleTests.m: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Facebook, Inc. and its affiliates. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | #import 9 | #import 10 | 11 | #import 12 | #import 13 | 14 | #define TIMEOUT_SECONDS 600 15 | #define TEXT_TO_LOOK_FOR @"Welcome to React Native!" 16 | 17 | @interface aexampleTests : XCTestCase 18 | 19 | @end 20 | 21 | @implementation aexampleTests 22 | 23 | - (BOOL)findSubviewInView:(UIView *)view matching:(BOOL(^)(UIView *view))test 24 | { 25 | if (test(view)) { 26 | return YES; 27 | } 28 | for (UIView *subview in [view subviews]) { 29 | if ([self findSubviewInView:subview matching:test]) { 30 | return YES; 31 | } 32 | } 33 | return NO; 34 | } 35 | 36 | - (void)testRendersWelcomeScreen 37 | { 38 | UIViewController *vc = [[[RCTSharedApplication() delegate] window] rootViewController]; 39 | NSDate *date = [NSDate dateWithTimeIntervalSinceNow:TIMEOUT_SECONDS]; 40 | BOOL foundElement = NO; 41 | 42 | __block NSString *redboxError = nil; 43 | RCTSetLogFunction(^(RCTLogLevel level, RCTLogSource source, NSString *fileName, NSNumber *lineNumber, NSString *message) { 44 | if (level >= RCTLogLevelError) { 45 | redboxError = message; 46 | } 47 | }); 48 | 49 | while ([date timeIntervalSinceNow] > 0 && !foundElement && !redboxError) { 50 | [[NSRunLoop mainRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]; 51 | [[NSRunLoop mainRunLoop] runMode:NSRunLoopCommonModes beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]; 52 | 53 | foundElement = [self findSubviewInView:vc.view matching:^BOOL(UIView *view) { 54 | if ([view.accessibilityLabel isEqualToString:TEXT_TO_LOOK_FOR]) { 55 | return YES; 56 | } 57 | return NO; 58 | }]; 59 | } 60 | 61 | RCTSetLogFunction(RCTDefaultLogFunction); 62 | 63 | XCTAssertNil(redboxError, @"RedBox error: %@", redboxError); 64 | XCTAssertTrue(foundElement, @"Couldn't find element with text '%@' in %d seconds", TEXT_TO_LOOK_FOR, TIMEOUT_SECONDS); 65 | } 66 | 67 | 68 | @end 69 | -------------------------------------------------------------------------------- /Example/metro.config.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Metro configuration for React Native 3 | * https://github.com/facebook/react-native 4 | * 5 | * @format 6 | */ 7 | 8 | module.exports = { 9 | transformer: { 10 | getTransformOptions: async () => ({ 11 | transform: { 12 | experimentalImportSupport: false, 13 | inlineRequires: false, 14 | }, 15 | }), 16 | }, 17 | }; 18 | -------------------------------------------------------------------------------- /Example/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "example", 3 | "version": "0.0.1", 4 | "private": false, 5 | "scripts": { 6 | "start": "react-native start", 7 | "test": "jest", 8 | "lint": "eslint .", 9 | "postinstall": "npx jetify" 10 | }, 11 | "dependencies": { 12 | "dayjs": "^1.8.16", 13 | "lottie-ios": "^3.1.9", 14 | "lottie-react-native": "^3.5.0", 15 | "react": "16.8.6", 16 | "react-native": "0.60.5", 17 | "react-native-refresh": "^2.0.17" 18 | }, 19 | "devDependencies": { 20 | "@babel/core": "^7.5.5", 21 | "@babel/runtime": "^7.5.5", 22 | "babel-eslint": "^10.0.3", 23 | "babel-jest": "^24.9.0", 24 | "eslint": "^6.2.2", 25 | "eslint-plugin-eslint-comments": "^3.1.2", 26 | "eslint-plugin-prettier": "^3.1.0", 27 | "eslint-plugin-react": "^7.14.3", 28 | "eslint-plugin-react-hooks": "^2.0.1", 29 | "eslint-plugin-react-native": "^3.7.0", 30 | "jest": "^24.9.0", 31 | "metro-react-native-babel-preset": "^0.56.0", 32 | "prettier": "^1.18.2", 33 | "react-test-renderer": "16.8.6" 34 | }, 35 | "jest": { 36 | "preset": "react-native" 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Example/src/RefreshAnimateHeader.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | import React, { useRef, useCallback, useMemo } from 'react'; 3 | import { StyleSheet, Animated, Platform, RefreshControl } from 'react-native'; 4 | import LottieView from 'lottie-react-native'; 5 | import { 6 | RefreshLayout, 7 | RefreshHeader, 8 | RefreshState, 9 | } from 'react-native-refresh'; 10 | 11 | const AnimateTime = 286; 12 | 13 | function RefreshAnimateHeader(props) { 14 | const { refreshing, onRefresh, source } = props; 15 | 16 | const lottieRef = useRef(React.createRef()); 17 | const progressRef = useRef(new Animated.Value(1)); 18 | const currentState = useRef(RefreshState.Idle); 19 | 20 | const onPullingRefreshCallBack = useCallback((state) => { 21 | currentState.current = state; 22 | }, []); 23 | 24 | const onRefreshCallBack = useCallback( 25 | (state) => { 26 | setTimeout(() => { 27 | lottieRef.current.play(); 28 | }, 0); 29 | onRefresh && onRefresh(state); 30 | currentState.current = state; 31 | }, 32 | [onRefresh], 33 | ); 34 | 35 | const onEndRefreshCallBack = useCallback((state) => { 36 | currentState.current = state; 37 | }, []); 38 | 39 | const onIdleRefreshCallBack = useCallback((state) => { 40 | if (currentState.current === RefreshState.End) { 41 | setTimeout(() => { 42 | lottieRef.current.reset(); 43 | }, 0); 44 | } 45 | currentState.current = state; 46 | }, []); 47 | 48 | const onChangeOffsetCallBack = useCallback((event) => { 49 | const { offset } = event.nativeEvent; 50 | if ( 51 | currentState.current !== RefreshState.Refreshing && 52 | currentState.current !== RefreshState.End 53 | ) { 54 | progressRef.current.setValue(offset); 55 | } 56 | }, []); 57 | 58 | return ( 59 | 67 | 68 | 85 | 86 | {props.children} 87 | 88 | ); 89 | } 90 | 91 | const styles = StyleSheet.create({ 92 | container: { 93 | height: 80, 94 | justifyContent: 'center', 95 | alignItems: 'center', 96 | }, 97 | lottery: { 98 | height: 80, 99 | }, 100 | }); 101 | 102 | export default React.memo(RefreshAnimateHeader); 103 | -------------------------------------------------------------------------------- /Example/src/RefreshNormalHeader.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | import React, { useRef, useState, useCallback } from 'react'; 3 | import { 4 | View, 5 | Animated, 6 | ActivityIndicator, 7 | Text, 8 | StyleSheet, 9 | } from 'react-native'; 10 | import Dayjs from 'dayjs'; 11 | import { RefreshLayout, RefreshHeader } from 'react-native-refresh'; 12 | 13 | function NormalRefreshHeader(props) { 14 | const { refreshing, onRefresh } = props; 15 | 16 | const [title, setTitle] = useState('下拉刷新'); 17 | const [lastTime, setLastTime] = useState(Dayjs().format('HH:mm')); 18 | const rotateZRef = useRef(new Animated.Value(0)); 19 | 20 | const onPullingRefreshCallBack = useCallback((state) => { 21 | Animated.timing(rotateZRef.current, { 22 | toValue: -180, 23 | duration: 200, 24 | useNativeDriver: true, 25 | }).start(() => {}); 26 | setTitle('松开立即刷新'); 27 | }, []); 28 | 29 | const onRefreshCallBack = useCallback( 30 | (state) => { 31 | onRefresh && onRefresh(state); 32 | setLastTime(Dayjs().format('HH:mm')); 33 | setTitle('正在刷新...'); 34 | }, 35 | [onRefresh], 36 | ); 37 | 38 | const onEndRefreshCallBack = useCallback((state) => { 39 | setTitle('下拉刷新'); 40 | }, []); 41 | 42 | const onIdleRefreshCallBack = useCallback((state) => { 43 | Animated.timing(rotateZRef.current, { 44 | toValue: 0, 45 | duration: 200, 46 | useNativeDriver: true, 47 | }).start(() => {}); 48 | setTitle('下拉刷新'); 49 | }, []); 50 | 51 | console.log('refreshing', refreshing); 52 | return ( 53 | 60 | 61 | 62 | 79 | 85 | 86 | 87 | {title} 88 | {`最后更新:${lastTime}`} 89 | 90 | 91 | {props.children} 92 | 93 | ); 94 | } 95 | 96 | const styles = StyleSheet.create({ 97 | container: { 98 | height: 80, 99 | flexDirection: 'row', 100 | justifyContent: 'center', 101 | alignItems: 'center', 102 | }, 103 | titleStyle: { 104 | fontSize: 16, 105 | color: '#333', 106 | }, 107 | timeStyle: { 108 | fontSize: 16, 109 | color: '#333', 110 | marginTop: 10, 111 | }, 112 | leftContainer: { 113 | width: 30, 114 | height: 30, 115 | flexDirection: 'row', 116 | justifyContent: 'center', 117 | }, 118 | rightContainer: { 119 | width: 150, 120 | justifyContent: 'center', 121 | alignItems: 'center', 122 | }, 123 | image: { 124 | position: 'absolute', 125 | width: 30, 126 | height: 30, 127 | resizeMode: 'contain', 128 | }, 129 | }); 130 | 131 | export default React.memo(NormalRefreshHeader); 132 | -------------------------------------------------------------------------------- /Example/src/assets/142-loading-animation.json: -------------------------------------------------------------------------------- 1 | {"v":"4.6.4","fr":25,"ip":0,"op":750,"w":1920,"h":1080,"nm":"Comp 2","ddd":0,"assets":[],"layers":[{"ddd":0,"ind":1,"ty":4,"nm":"Shape Layer 3","ks":{"o":{"a":0,"k":100},"r":{"a":0,"k":0},"p":{"a":0,"k":[964,540,0]},"a":{"a":0,"k":[0,0,0]},"s":{"a":0,"k":[100,100,100]}},"ao":0,"shapes":[{"ty":"gr","it":[{"d":3,"ty":"el","s":{"a":0,"k":[30,30]},"p":{"a":0,"k":[0,0]},"nm":"Ellipse Path 1","mn":"ADBE Vector Shape - Ellipse"},{"ty":"tm","s":{"a":1,"k":[{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"n":["0p833_0p833_0p167_0p167"],"t":5,"s":[0],"e":[25]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"n":["0p833_0p833_0p167_0p167"],"t":25,"s":[25],"e":[100]},{"t":45}],"x":"var $bm_rt;\n$bm_rt = loopOut();","ix":1},"e":{"a":1,"k":[{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"n":["0p833_0p833_0p167_0p167"],"t":5,"s":[2],"e":[95]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"n":["0p833_0p833_0p167_0p167"],"t":25,"s":[95],"e":[99]},{"t":45}],"x":"var $bm_rt;\n$bm_rt = loopOut();","ix":2},"o":{"a":0,"k":0,"ix":3},"m":1,"ix":2,"nm":"Trim Paths 1","mn":"ADBE Vector Filter - Trim"},{"ty":"st","c":{"a":0,"k":[0.6313726,0.2078431,0.3843137,1]},"o":{"a":0,"k":100},"w":{"a":0,"k":15},"lc":2,"lj":2,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke"},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Ellipse 1","np":3,"cix":2,"ix":1,"mn":"ADBE Vector Group"}],"ip":5,"op":755,"st":5,"bm":0,"sr":1},{"ddd":0,"ind":2,"ty":4,"nm":"Shape Layer 2","ks":{"o":{"a":0,"k":100},"r":{"a":0,"k":0},"p":{"a":0,"k":[960,540,0]},"a":{"a":0,"k":[0,0,0]},"s":{"a":0,"k":[100,100,100]}},"ao":0,"shapes":[{"ty":"gr","it":[{"d":1,"ty":"el","s":{"a":0,"k":[125,125]},"p":{"a":0,"k":[0,0]},"nm":"Ellipse Path 1","mn":"ADBE Vector Shape - Ellipse"},{"ty":"tm","s":{"a":1,"k":[{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"n":["0p833_0p833_0p167_0p167"],"t":5,"s":[0],"e":[25]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"n":["0p833_0p833_0p167_0p167"],"t":25,"s":[25],"e":[100]},{"t":45}],"x":"var $bm_rt;\n$bm_rt = loopOut();","ix":1},"e":{"a":1,"k":[{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"n":["0p833_0p833_0p167_0p167"],"t":5,"s":[2],"e":[95]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"n":["0p833_0p833_0p167_0p167"],"t":25,"s":[95],"e":[99]},{"t":45}],"x":"var $bm_rt;\n$bm_rt = loopOut();","ix":2},"o":{"a":0,"k":0,"ix":3},"m":1,"ix":2,"nm":"Trim Paths 1","mn":"ADBE Vector Filter - Trim"},{"ty":"st","c":{"a":0,"k":[0.9411765,0.4823529,0.5294118,1]},"o":{"a":0,"k":100},"w":{"a":0,"k":20},"lc":2,"lj":2,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke"},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Ellipse 1","np":3,"cix":2,"ix":1,"mn":"ADBE Vector Group"}],"ip":5,"op":755,"st":5,"bm":0,"sr":1},{"ddd":0,"ind":3,"ty":4,"nm":"Shape Layer 1","ks":{"o":{"a":0,"k":100},"r":{"a":0,"k":0},"p":{"a":0,"k":[960,540,0]},"a":{"a":0,"k":[0,0,0]},"s":{"a":0,"k":[100,100,100]}},"ao":0,"shapes":[{"ty":"gr","it":[{"d":1,"ty":"el","s":{"a":0,"k":[250,250]},"p":{"a":0,"k":[0,0]},"nm":"Ellipse Path 1","mn":"ADBE Vector Shape - Ellipse"},{"ty":"tm","s":{"a":1,"k":[{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"n":["0p833_0p833_0p167_0p167"],"t":0,"s":[0],"e":[25]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"n":["0p833_0p833_0p167_0p167"],"t":20,"s":[25],"e":[100]},{"t":40}],"x":"var $bm_rt;\n$bm_rt = loopOut();","ix":1},"e":{"a":1,"k":[{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"n":["0p833_0p833_0p167_0p167"],"t":0,"s":[2],"e":[95]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"n":["0p833_0p833_0p167_0p167"],"t":20,"s":[95],"e":[99]},{"t":40}],"x":"var $bm_rt;\n$bm_rt = loopOut();","ix":2},"o":{"a":0,"k":0,"ix":3},"m":1,"ix":2,"nm":"Trim Paths 1","mn":"ADBE Vector Filter - Trim"},{"ty":"st","c":{"a":0,"k":[0.0117647,0.8352941,0.8078431,1]},"o":{"a":0,"k":100},"w":{"a":0,"k":20},"lc":2,"lj":2,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke"},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Ellipse 1","np":3,"cix":2,"ix":1,"mn":"ADBE Vector Group"}],"ip":0,"op":750,"st":0,"bm":0,"sr":1}]} -------------------------------------------------------------------------------- /Example/src/assets/8209-blue-dots-throbber.json: -------------------------------------------------------------------------------- 1 | {"v":"5.5.7","fr":60,"ip":0,"op":131,"w":1920,"h":1080,"nm":"blue dot test 2","ddd":0,"assets":[],"layers":[{"ddd":0,"ind":1,"ty":4,"nm":"dot3","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":1,"k":[{"i":{"x":0.426,"y":0.26},"o":{"x":0.223,"y":0},"t":20,"s":[960,540,0],"to":[0,0,0],"ti":[2.998,-0.097,0]},{"i":{"x":0.881,"y":0.609},"o":{"x":0.657,"y":0.218},"t":34,"s":[960,587,0],"to":[-216,7,0],"ti":[-256.048,-0.815,0]},{"i":{"x":0.129,"y":1},"o":{"x":0.189,"y":0.5},"t":75.527,"s":[960,253,0],"to":[314,1,0],"ti":[162,293,0]},{"t":115,"s":[960,540,0]}],"ix":2},"a":{"a":0,"k":[0,0,0],"ix":1},"s":{"a":1,"k":[{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.732,0.732,0.333],"y":[0,0,0]},"t":34,"s":[100,100,100]},{"i":{"x":[0.154,0.154,0.667],"y":[1,1,1]},"o":{"x":[0.333,0.333,0.333],"y":[0,0,0]},"t":76,"s":[175,175,100]},{"t":103,"s":[100,100,100]}],"ix":6}},"ao":0,"shapes":[{"ty":"gr","it":[{"d":1,"ty":"el","s":{"a":0,"k":[100,100],"ix":2},"p":{"a":0,"k":[0,0],"ix":3},"nm":"Ellipse Path 1","mn":"ADBE Vector Shape - Ellipse","hd":false},{"ty":"fl","c":{"a":0,"k":[0,0.541176378727,1,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[120,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 1","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":600,"st":0,"bm":0},{"ddd":0,"ind":2,"ty":4,"nm":"dot2","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":1,"k":[{"i":{"x":0.426,"y":0.26},"o":{"x":0.223,"y":0},"t":10,"s":[960,540,0],"to":[0,0,0],"ti":[2.998,-0.097,0]},{"i":{"x":0.881,"y":0.609},"o":{"x":0.657,"y":0.218},"t":24,"s":[960,587,0],"to":[-216,7,0],"ti":[-256.048,-0.815,0]},{"i":{"x":0.129,"y":1},"o":{"x":0.189,"y":0.5},"t":65.527,"s":[960,253,0],"to":[314,1,0],"ti":[162,293,0]},{"t":105,"s":[960,540,0]}],"ix":2},"a":{"a":0,"k":[0,0,0],"ix":1},"s":{"a":1,"k":[{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.732,0.732,0.333],"y":[0,0,0]},"t":24,"s":[100,100,100]},{"i":{"x":[0.154,0.154,0.667],"y":[1,1,1]},"o":{"x":[0.333,0.333,0.333],"y":[0,0,0]},"t":66,"s":[175,175,100]},{"t":93,"s":[100,100,100]}],"ix":6}},"ao":0,"shapes":[{"ty":"gr","it":[{"d":1,"ty":"el","s":{"a":0,"k":[100,100],"ix":2},"p":{"a":0,"k":[0,0],"ix":3},"nm":"Ellipse Path 1","mn":"ADBE Vector Shape - Ellipse","hd":false},{"ty":"fl","c":{"a":0,"k":[0,0.541176378727,1,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 1","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":600,"st":0,"bm":0},{"ddd":0,"ind":3,"ty":4,"nm":"dot1","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":1,"k":[{"i":{"x":0.426,"y":0.26},"o":{"x":0.223,"y":0},"t":0,"s":[960,540,0],"to":[0,0,0],"ti":[2.998,-0.097,0]},{"i":{"x":0.881,"y":0.609},"o":{"x":0.657,"y":0.218},"t":14,"s":[960,587,0],"to":[-216,7,0],"ti":[-256.048,-0.815,0]},{"i":{"x":0.129,"y":1},"o":{"x":0.189,"y":0.5},"t":55.527,"s":[960,253,0],"to":[314,1,0],"ti":[162,293,0]},{"t":95,"s":[960,540,0]}],"ix":2},"a":{"a":0,"k":[0,0,0],"ix":1},"s":{"a":1,"k":[{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.732,0.732,0.333],"y":[0,0,0]},"t":14,"s":[100,100,100]},{"i":{"x":[0.154,0.154,0.667],"y":[1,1,1]},"o":{"x":[0.333,0.333,0.333],"y":[0,0,0]},"t":56,"s":[175,175,100]},{"t":83,"s":[100,100,100]}],"ix":6}},"ao":0,"shapes":[{"ty":"gr","it":[{"d":1,"ty":"el","s":{"a":0,"k":[100,100],"ix":2},"p":{"a":0,"k":[0,0],"ix":3},"nm":"Ellipse Path 1","mn":"ADBE Vector Shape - Ellipse","hd":false},{"ty":"fl","c":{"a":0,"k":[0,0.541176378727,1,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[-120,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 1","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":600,"st":0,"bm":0},{"ddd":0,"ind":4,"ty":4,"nm":"line3","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[960,536,0],"ix":2},"a":{"a":0,"k":[0,0,0],"ix":1},"s":{"a":0,"k":[100,100,100],"ix":6}},"ao":0,"shapes":[{"ty":"gr","it":[{"d":1,"ty":"el","s":{"a":0,"k":[270,270],"ix":2},"p":{"a":0,"k":[0,0],"ix":3},"nm":"Ellipse Path 1","mn":"ADBE Vector Shape - Ellipse","hd":false},{"ty":"st","c":{"a":0,"k":[0,0.541176470588,1,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":6,"ix":5},"lc":1,"lj":1,"ml":4,"bm":0,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 1","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false},{"ty":"tm","s":{"a":1,"k":[{"i":{"x":[0.536],"y":[0.658]},"o":{"x":[0.693],"y":[0]},"t":88,"s":[0]},{"i":{"x":[0.564],"y":[1]},"o":{"x":[0.245],"y":[2.23]},"t":117,"s":[90.865]},{"t":153,"s":[100]}],"ix":1},"e":{"a":1,"k":[{"i":{"x":[0.536],"y":[0.741]},"o":{"x":[0.57],"y":[0]},"t":75,"s":[0]},{"i":{"x":[0.605],"y":[1]},"o":{"x":[0.278],"y":[2.274]},"t":117,"s":[94.476]},{"t":153,"s":[100]}],"ix":2},"o":{"a":0,"k":0,"ix":3},"m":1,"ix":2,"nm":"Trim Paths 1","mn":"ADBE Vector Filter - Trim","hd":false}],"ip":0,"op":600,"st":0,"bm":0},{"ddd":0,"ind":5,"ty":4,"nm":"line2","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[960,536,0],"ix":2},"a":{"a":0,"k":[0,0,0],"ix":1},"s":{"a":0,"k":[100,100,100],"ix":6}},"ao":0,"shapes":[{"ty":"gr","it":[{"d":1,"ty":"el","s":{"a":0,"k":[320,320],"ix":2},"p":{"a":0,"k":[0,0],"ix":3},"nm":"Ellipse Path 1","mn":"ADBE Vector Shape - Ellipse","hd":false},{"ty":"st","c":{"a":0,"k":[0,0.541176470588,1,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":10,"ix":5},"lc":1,"lj":1,"ml":4,"bm":0,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 1","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false},{"ty":"tm","s":{"a":1,"k":[{"i":{"x":[0.536],"y":[0.658]},"o":{"x":[0.693],"y":[0]},"t":83,"s":[0]},{"i":{"x":[0.564],"y":[1]},"o":{"x":[0.245],"y":[2.23]},"t":112,"s":[90.865]},{"t":148,"s":[100]}],"ix":1},"e":{"a":1,"k":[{"i":{"x":[0.536],"y":[0.741]},"o":{"x":[0.57],"y":[0]},"t":70,"s":[0]},{"i":{"x":[0.605],"y":[1]},"o":{"x":[0.278],"y":[2.274]},"t":112,"s":[94.476]},{"t":148,"s":[100]}],"ix":2},"o":{"a":0,"k":0,"ix":3},"m":1,"ix":2,"nm":"Trim Paths 1","mn":"ADBE Vector Filter - Trim","hd":false}],"ip":0,"op":600,"st":0,"bm":0},{"ddd":0,"ind":6,"ty":4,"nm":"line1","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[960,536,0],"ix":2},"a":{"a":0,"k":[0,0,0],"ix":1},"s":{"a":0,"k":[100,100,100],"ix":6}},"ao":0,"shapes":[{"ty":"gr","it":[{"d":1,"ty":"el","s":{"a":0,"k":[366,366],"ix":2},"p":{"a":0,"k":[0,0],"ix":3},"nm":"Ellipse Path 1","mn":"ADBE Vector Shape - Ellipse","hd":false},{"ty":"st","c":{"a":0,"k":[0,0.541176470588,1,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":15,"ix":5},"lc":1,"lj":1,"ml":4,"bm":0,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 1","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false},{"ty":"tm","s":{"a":1,"k":[{"i":{"x":[0.536],"y":[0.658]},"o":{"x":[0.693],"y":[0]},"t":78,"s":[0]},{"i":{"x":[0.564],"y":[1]},"o":{"x":[0.245],"y":[2.23]},"t":107,"s":[90.865]},{"t":143,"s":[100]}],"ix":1},"e":{"a":1,"k":[{"i":{"x":[0.536],"y":[0.741]},"o":{"x":[0.57],"y":[0]},"t":65,"s":[0]},{"i":{"x":[0.605],"y":[1]},"o":{"x":[0.278],"y":[2.274]},"t":107,"s":[94.476]},{"t":143,"s":[100]}],"ix":2},"o":{"a":0,"k":0,"ix":3},"m":1,"ix":2,"nm":"Trim Paths 1","mn":"ADBE Vector Filter - Trim","hd":false}],"ip":0,"op":600,"st":0,"bm":0}],"markers":[]} -------------------------------------------------------------------------------- /Example/src/assets/icon_down_arrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CloudlessMoon/react-native-refresh/8d768f65697d0e4c8109ff967ca086ee28f561cc/Example/src/assets/icon_down_arrow.png -------------------------------------------------------------------------------- /Example/src/assets/lectureLoading.json: -------------------------------------------------------------------------------- 1 | { 2 | "v": "5.4.4", 3 | "fr": 24, 4 | "ip": 0, 5 | "op": 48, 6 | "w": 100, 7 | "h": 100, 8 | "nm": "合成 1", 9 | "ddd": 0, 10 | "assets": [], 11 | "layers": [{ 12 | "ddd": 0, 13 | "ind": 1, 14 | "ty": 4, 15 | "nm": "形状图层 5", 16 | "sr": 1, 17 | "ks": { 18 | "o": { 19 | "a": 0, 20 | "k": 100, 21 | "ix": 11 22 | }, 23 | "r": { 24 | "a": 1, 25 | "k": [{ 26 | "i": { 27 | "x": [0.833], 28 | "y": [0.833] 29 | }, 30 | "o": { 31 | "x": [0.167], 32 | "y": [0.167] 33 | }, 34 | "t": 32, 35 | "s": [0], 36 | "e": [118.551] 37 | }, { 38 | "t": 40 39 | }], 40 | "ix": 10 41 | }, 42 | "p": { 43 | "a": 1, 44 | "k": [{ 45 | "i": { 46 | "x": 0.833, 47 | "y": 0.833 48 | }, 49 | "o": { 50 | "x": 0.167, 51 | "y": 0.167 52 | }, 53 | "t": 32, 54 | "s": [50.625, 29, 0], 55 | "e": [50.625, 80, 0], 56 | "to": [0, 8.5, 0], 57 | "ti": [0, -8.5, 0] 58 | }, { 59 | "t": 40 60 | }], 61 | "ix": 2 62 | }, 63 | "a": { 64 | "a": 0, 65 | "k": [-5.561, -5.25, 0], 66 | "ix": 1 67 | }, 68 | "s": { 69 | "a": 0, 70 | "k": [105.786, 146.031, 100], 71 | "ix": 6 72 | } 73 | }, 74 | "ao": 0, 75 | "shapes": [{ 76 | "ty": "gr", 77 | "it": [{ 78 | "ind": 0, 79 | "ty": "sh", 80 | "ix": 1, 81 | "ks": { 82 | "a": 0, 83 | "k": { 84 | "i": [ 85 | [0, 0], 86 | [0, 0], 87 | [0, 0] 88 | ], 89 | "o": [ 90 | [0, 0], 91 | [0, 0], 92 | [0, 0] 93 | ], 94 | "v": [ 95 | [-5.666, -13.536], 96 | [-16.059, -0.107], 97 | [4.638, -0.107] 98 | ], 99 | "c": true 100 | }, 101 | "ix": 2 102 | }, 103 | "nm": "路径 1", 104 | "mn": "ADBE Vector Shape - Group", 105 | "hd": false 106 | }, { 107 | "ty": "fl", 108 | "c": { 109 | "a": 0, 110 | "k": [1, 0.850980392157, 0.329411764706, 1], 111 | "ix": 4 112 | }, 113 | "o": { 114 | "a": 0, 115 | "k": 100, 116 | "ix": 5 117 | }, 118 | "r": 1, 119 | "bm": 0, 120 | "nm": "填充 1", 121 | "mn": "ADBE Vector Graphic - Fill", 122 | "hd": false 123 | }, { 124 | "ty": "tr", 125 | "p": { 126 | "a": 0, 127 | "k": [0, 0], 128 | "ix": 2 129 | }, 130 | "a": { 131 | "a": 0, 132 | "k": [0, 0], 133 | "ix": 1 134 | }, 135 | "s": { 136 | "a": 0, 137 | "k": [100, 100], 138 | "ix": 3 139 | }, 140 | "r": { 141 | "a": 0, 142 | "k": 0, 143 | "ix": 6 144 | }, 145 | "o": { 146 | "a": 0, 147 | "k": 100, 148 | "ix": 7 149 | }, 150 | "sk": { 151 | "a": 0, 152 | "k": 0, 153 | "ix": 4 154 | }, 155 | "sa": { 156 | "a": 0, 157 | "k": 0, 158 | "ix": 5 159 | }, 160 | "nm": "变换" 161 | }], 162 | "nm": "形状 1", 163 | "np": 3, 164 | "cix": 2, 165 | "bm": 0, 166 | "ix": 1, 167 | "mn": "ADBE Vector Group", 168 | "hd": false 169 | }], 170 | "ip": 32, 171 | "op": 40, 172 | "st": 8, 173 | "bm": 0 174 | }, { 175 | "ddd": 0, 176 | "ind": 2, 177 | "ty": 4, 178 | "nm": "形状图层 4", 179 | "sr": 1, 180 | "ks": { 181 | "o": { 182 | "a": 0, 183 | "k": 100, 184 | "ix": 11 185 | }, 186 | "r": { 187 | "a": 1, 188 | "k": [{ 189 | "i": { 190 | "x": [0.833], 191 | "y": [0.833] 192 | }, 193 | "o": { 194 | "x": [0.167], 195 | "y": [0.167] 196 | }, 197 | "t": 24, 198 | "s": [0], 199 | "e": [120] 200 | }, { 201 | "t": 32 202 | }], 203 | "ix": 10 204 | }, 205 | "p": { 206 | "a": 1, 207 | "k": [{ 208 | "i": { 209 | "x": 0.833, 210 | "y": 0.833 211 | }, 212 | "o": { 213 | "x": 0.167, 214 | "y": 0.167 215 | }, 216 | "t": 24, 217 | "s": [50.625, 78, 0], 218 | "e": [50.625, 29.5, 0], 219 | "to": [0, -8.083, 0], 220 | "ti": [0, 8.083, 0] 221 | }, { 222 | "t": 32 223 | }], 224 | "ix": 2 225 | }, 226 | "a": { 227 | "a": 0, 228 | "k": [-5.561, -5.25, 0], 229 | "ix": 1 230 | }, 231 | "s": { 232 | "a": 0, 233 | "k": [105.786, 146.031, 100], 234 | "ix": 6 235 | } 236 | }, 237 | "ao": 0, 238 | "shapes": [{ 239 | "ty": "gr", 240 | "it": [{ 241 | "ind": 0, 242 | "ty": "sh", 243 | "ix": 1, 244 | "ks": { 245 | "a": 0, 246 | "k": { 247 | "i": [ 248 | [0, 0], 249 | [0, 0], 250 | [0, 0] 251 | ], 252 | "o": [ 253 | [0, 0], 254 | [0, 0], 255 | [0, 0] 256 | ], 257 | "v": [ 258 | [-5.666, -13.536], 259 | [-16.059, -0.107], 260 | [4.638, -0.107] 261 | ], 262 | "c": true 263 | }, 264 | "ix": 2 265 | }, 266 | "nm": "路径 1", 267 | "mn": "ADBE Vector Shape - Group", 268 | "hd": false 269 | }, { 270 | "ty": "fl", 271 | "c": { 272 | "a": 0, 273 | "k": [1, 0.850980392157, 0.329411764706, 1], 274 | "ix": 4 275 | }, 276 | "o": { 277 | "a": 0, 278 | "k": 100, 279 | "ix": 5 280 | }, 281 | "r": 1, 282 | "bm": 0, 283 | "nm": "填充 1", 284 | "mn": "ADBE Vector Graphic - Fill", 285 | "hd": false 286 | }, { 287 | "ty": "tr", 288 | "p": { 289 | "a": 0, 290 | "k": [0, 0], 291 | "ix": 2 292 | }, 293 | "a": { 294 | "a": 0, 295 | "k": [0, 0], 296 | "ix": 1 297 | }, 298 | "s": { 299 | "a": 0, 300 | "k": [100, 100], 301 | "ix": 3 302 | }, 303 | "r": { 304 | "a": 0, 305 | "k": 0, 306 | "ix": 6 307 | }, 308 | "o": { 309 | "a": 0, 310 | "k": 100, 311 | "ix": 7 312 | }, 313 | "sk": { 314 | "a": 0, 315 | "k": 0, 316 | "ix": 4 317 | }, 318 | "sa": { 319 | "a": 0, 320 | "k": 0, 321 | "ix": 5 322 | }, 323 | "nm": "变换" 324 | }], 325 | "nm": "形状 1", 326 | "np": 3, 327 | "cix": 2, 328 | "bm": 0, 329 | "ix": 1, 330 | "mn": "ADBE Vector Group", 331 | "hd": false 332 | }], 333 | "ip": 24, 334 | "op": 32, 335 | "st": 0, 336 | "bm": 0 337 | }, { 338 | "ddd": 0, 339 | "ind": 3, 340 | "ty": 4, 341 | "nm": "形状图层 3", 342 | "sr": 1, 343 | "ks": { 344 | "o": { 345 | "a": 0, 346 | "k": 100, 347 | "ix": 11 348 | }, 349 | "r": { 350 | "a": 1, 351 | "k": [{ 352 | "i": { 353 | "x": [0.833], 354 | "y": [0.833] 355 | }, 356 | "o": { 357 | "x": [0.167], 358 | "y": [0.167] 359 | }, 360 | "t": 16, 361 | "s": [135], 362 | "e": [270] 363 | }, { 364 | "t": 23 365 | }], 366 | "ix": 10 367 | }, 368 | "p": { 369 | "a": 1, 370 | "k": [{ 371 | "i": { 372 | "x": 0.833, 373 | "y": 0.833 374 | }, 375 | "o": { 376 | "x": 0.167, 377 | "y": 0.167 378 | }, 379 | "t": 16, 380 | "s": [50.5, 24, 0], 381 | "e": [50.5, 73.75, 0], 382 | "to": [0, 8.292, 0], 383 | "ti": [0, -8.292, 0] 384 | }, { 385 | "t": 23 386 | }], 387 | "ix": 2 388 | }, 389 | "a": { 390 | "a": 0, 391 | "k": [0.5, 23.75, 0], 392 | "ix": 1 393 | }, 394 | "s": { 395 | "a": 0, 396 | "k": [100, 100, 100], 397 | "ix": 6 398 | } 399 | }, 400 | "ao": 0, 401 | "shapes": [{ 402 | "ty": "gr", 403 | "it": [{ 404 | "ty": "rc", 405 | "d": 1, 406 | "s": { 407 | "a": 0, 408 | "k": [20.56, 20.001], 409 | "ix": 2 410 | }, 411 | "p": { 412 | "a": 0, 413 | "k": [0, 0], 414 | "ix": 3 415 | }, 416 | "r": { 417 | "a": 0, 418 | "k": 0, 419 | "ix": 4 420 | }, 421 | "nm": "矩形路径 1", 422 | "mn": "ADBE Vector Shape - Rect", 423 | "hd": false 424 | }, { 425 | "ty": "fl", 426 | "c": { 427 | "a": 0, 428 | "k": [1, 0.356862745098, 0.329411764706, 1], 429 | "ix": 4 430 | }, 431 | "o": { 432 | "a": 0, 433 | "k": 100, 434 | "ix": 5 435 | }, 436 | "r": 1, 437 | "bm": 0, 438 | "nm": "填充 1", 439 | "mn": "ADBE Vector Graphic - Fill", 440 | "hd": false 441 | }, { 442 | "ty": "tr", 443 | "p": { 444 | "a": 0, 445 | "k": [0.28, 23.376], 446 | "ix": 2 447 | }, 448 | "a": { 449 | "a": 0, 450 | "k": [0, 0], 451 | "ix": 1 452 | }, 453 | "s": { 454 | "a": 0, 455 | "k": [100, 100], 456 | "ix": 3 457 | }, 458 | "r": { 459 | "a": 0, 460 | "k": 0, 461 | "ix": 6 462 | }, 463 | "o": { 464 | "a": 0, 465 | "k": 100, 466 | "ix": 7 467 | }, 468 | "sk": { 469 | "a": 0, 470 | "k": 0, 471 | "ix": 4 472 | }, 473 | "sa": { 474 | "a": 0, 475 | "k": 0, 476 | "ix": 5 477 | }, 478 | "nm": "变换" 479 | }], 480 | "nm": "矩形 1", 481 | "np": 3, 482 | "cix": 2, 483 | "bm": 0, 484 | "ix": 1, 485 | "mn": "ADBE Vector Group", 486 | "hd": false 487 | }], 488 | "ip": 16, 489 | "op": 24, 490 | "st": 14, 491 | "bm": 0 492 | }, { 493 | "ddd": 0, 494 | "ind": 4, 495 | "ty": 4, 496 | "nm": "形状图层 2", 497 | "sr": 1, 498 | "ks": { 499 | "o": { 500 | "a": 0, 501 | "k": 100, 502 | "ix": 11 503 | }, 504 | "r": { 505 | "a": 1, 506 | "k": [{ 507 | "i": { 508 | "x": [0.833], 509 | "y": [0.833] 510 | }, 511 | "o": { 512 | "x": [0.167], 513 | "y": [0.167] 514 | }, 515 | "t": 8, 516 | "s": [0], 517 | "e": [135] 518 | }, { 519 | "t": 16 520 | }], 521 | "ix": 10 522 | }, 523 | "p": { 524 | "a": 1, 525 | "k": [{ 526 | "i": { 527 | "x": 0.833, 528 | "y": 0.833 529 | }, 530 | "o": { 531 | "x": 0.167, 532 | "y": 0.167 533 | }, 534 | "t": 8, 535 | "s": [50.5, 73.75, 0], 536 | "e": [50.5, 24, 0], 537 | "to": [0, -8.292, 0], 538 | "ti": [0, 8.292, 0] 539 | }, { 540 | "t": 16 541 | }], 542 | "ix": 2 543 | }, 544 | "a": { 545 | "a": 0, 546 | "k": [0.5, 23.75, 0], 547 | "ix": 1 548 | }, 549 | "s": { 550 | "a": 0, 551 | "k": [100, 100, 100], 552 | "ix": 6 553 | } 554 | }, 555 | "ao": 0, 556 | "shapes": [{ 557 | "ty": "gr", 558 | "it": [{ 559 | "ty": "rc", 560 | "d": 1, 561 | "s": { 562 | "a": 0, 563 | "k": [20.56, 20.001], 564 | "ix": 2 565 | }, 566 | "p": { 567 | "a": 0, 568 | "k": [0, 0], 569 | "ix": 3 570 | }, 571 | "r": { 572 | "a": 0, 573 | "k": 0, 574 | "ix": 4 575 | }, 576 | "nm": "矩形路径 1", 577 | "mn": "ADBE Vector Shape - Rect", 578 | "hd": false 579 | }, { 580 | "ty": "fl", 581 | "c": { 582 | "a": 0, 583 | "k": [1, 0.356862745098, 0.329411764706, 1], 584 | "ix": 4 585 | }, 586 | "o": { 587 | "a": 0, 588 | "k": 100, 589 | "ix": 5 590 | }, 591 | "r": 1, 592 | "bm": 0, 593 | "nm": "填充 1", 594 | "mn": "ADBE Vector Graphic - Fill", 595 | "hd": false 596 | }, { 597 | "ty": "tr", 598 | "p": { 599 | "a": 0, 600 | "k": [0.28, 23.376], 601 | "ix": 2 602 | }, 603 | "a": { 604 | "a": 0, 605 | "k": [0, 0], 606 | "ix": 1 607 | }, 608 | "s": { 609 | "a": 0, 610 | "k": [100, 100], 611 | "ix": 3 612 | }, 613 | "r": { 614 | "a": 0, 615 | "k": 0, 616 | "ix": 6 617 | }, 618 | "o": { 619 | "a": 0, 620 | "k": 100, 621 | "ix": 7 622 | }, 623 | "sk": { 624 | "a": 0, 625 | "k": 0, 626 | "ix": 4 627 | }, 628 | "sa": { 629 | "a": 0, 630 | "k": 0, 631 | "ix": 5 632 | }, 633 | "nm": "变换" 634 | }], 635 | "nm": "矩形 1", 636 | "np": 3, 637 | "cix": 2, 638 | "bm": 0, 639 | "ix": 1, 640 | "mn": "ADBE Vector Group", 641 | "hd": false 642 | }], 643 | "ip": 8, 644 | "op": 16, 645 | "st": 6, 646 | "bm": 0 647 | }, { 648 | "ddd": 0, 649 | "ind": 5, 650 | "ty": 4, 651 | "nm": "形状图层 6", 652 | "sr": 1, 653 | "ks": { 654 | "o": { 655 | "a": 0, 656 | "k": 100, 657 | "ix": 11 658 | }, 659 | "r": { 660 | "a": 0, 661 | "k": 0, 662 | "ix": 10 663 | }, 664 | "p": { 665 | "a": 1, 666 | "k": [{ 667 | "i": { 668 | "x": 0.833, 669 | "y": 0.833 670 | }, 671 | "o": { 672 | "x": 0.167, 673 | "y": 0.167 674 | }, 675 | "t": 40, 676 | "s": [50, 105.25, 0], 677 | "e": [50, 54.237, 0], 678 | "to": [0, -8.502, 0], 679 | "ti": [0, 8.502, 0] 680 | }, { 681 | "t": 48 682 | }], 683 | "ix": 2 684 | }, 685 | "a": { 686 | "a": 0, 687 | "k": [0, 0, 0], 688 | "ix": 1 689 | }, 690 | "s": { 691 | "a": 0, 692 | "k": [100, 100, 100], 693 | "ix": 6 694 | } 695 | }, 696 | "ao": 0, 697 | "shapes": [{ 698 | "ty": "gr", 699 | "it": [{ 700 | "d": 1, 701 | "ty": "el", 702 | "s": { 703 | "a": 0, 704 | "k": [23.104, 23.104], 705 | "ix": 2 706 | }, 707 | "p": { 708 | "a": 0, 709 | "k": [0, 0], 710 | "ix": 3 711 | }, 712 | "nm": "椭圆路径 1", 713 | "mn": "ADBE Vector Shape - Ellipse", 714 | "hd": false 715 | }, { 716 | "ty": "fl", 717 | "c": { 718 | "a": 0, 719 | "k": [0.2, 0.525490196078, 0.972549019608, 1], 720 | "ix": 4 721 | }, 722 | "o": { 723 | "a": 0, 724 | "k": 100, 725 | "ix": 5 726 | }, 727 | "r": 1, 728 | "bm": 0, 729 | "nm": "填充 1", 730 | "mn": "ADBE Vector Graphic - Fill", 731 | "hd": false 732 | }, { 733 | "ty": "tr", 734 | "p": { 735 | "a": 0, 736 | "k": [0.917, -29.259], 737 | "ix": 2 738 | }, 739 | "a": { 740 | "a": 0, 741 | "k": [0, 0], 742 | "ix": 1 743 | }, 744 | "s": { 745 | "a": 0, 746 | "k": [81.26, 81.26], 747 | "ix": 3 748 | }, 749 | "r": { 750 | "a": 0, 751 | "k": 0, 752 | "ix": 6 753 | }, 754 | "o": { 755 | "a": 0, 756 | "k": 100, 757 | "ix": 7 758 | }, 759 | "sk": { 760 | "a": 0, 761 | "k": 0, 762 | "ix": 4 763 | }, 764 | "sa": { 765 | "a": 0, 766 | "k": 0, 767 | "ix": 5 768 | }, 769 | "nm": "变换" 770 | }], 771 | "nm": "椭圆 1", 772 | "np": 3, 773 | "cix": 2, 774 | "bm": 0, 775 | "ix": 1, 776 | "mn": "ADBE Vector Group", 777 | "hd": false 778 | }], 779 | "ip": 40, 780 | "op": 48, 781 | "st": 40, 782 | "bm": 0 783 | }, { 784 | "ddd": 0, 785 | "ind": 6, 786 | "ty": 4, 787 | "nm": "形状图层 1", 788 | "sr": 1, 789 | "ks": { 790 | "o": { 791 | "a": 0, 792 | "k": 100, 793 | "ix": 11 794 | }, 795 | "r": { 796 | "a": 0, 797 | "k": 0, 798 | "ix": 10 799 | }, 800 | "p": { 801 | "a": 1, 802 | "k": [{ 803 | "i": { 804 | "x": 0.833, 805 | "y": 0.833 806 | }, 807 | "o": { 808 | "x": 0.167, 809 | "y": 0.167 810 | }, 811 | "t": 0, 812 | "s": [50, 50, 0], 813 | "e": [50, 105.25, 0], 814 | "to": [0, 9.208, 0], 815 | "ti": [0, -9.208, 0] 816 | }, { 817 | "t": 7 818 | }], 819 | "ix": 2 820 | }, 821 | "a": { 822 | "a": 0, 823 | "k": [0, 0, 0], 824 | "ix": 1 825 | }, 826 | "s": { 827 | "a": 0, 828 | "k": [100, 100, 100], 829 | "ix": 6 830 | } 831 | }, 832 | "ao": 0, 833 | "shapes": [{ 834 | "ty": "gr", 835 | "it": [{ 836 | "d": 1, 837 | "ty": "el", 838 | "s": { 839 | "a": 0, 840 | "k": [23.104, 23.104], 841 | "ix": 2 842 | }, 843 | "p": { 844 | "a": 0, 845 | "k": [0, 0], 846 | "ix": 3 847 | }, 848 | "nm": "椭圆路径 1", 849 | "mn": "ADBE Vector Shape - Ellipse", 850 | "hd": false 851 | }, { 852 | "ty": "fl", 853 | "c": { 854 | "a": 0, 855 | "k": [0.2, 0.525490196078, 0.972549019608, 1], 856 | "ix": 4 857 | }, 858 | "o": { 859 | "a": 0, 860 | "k": 100, 861 | "ix": 5 862 | }, 863 | "r": 1, 864 | "bm": 0, 865 | "nm": "填充 1", 866 | "mn": "ADBE Vector Graphic - Fill", 867 | "hd": false 868 | }, { 869 | "ty": "tr", 870 | "p": { 871 | "a": 0, 872 | "k": [0.917, -29.259], 873 | "ix": 2 874 | }, 875 | "a": { 876 | "a": 0, 877 | "k": [0, 0], 878 | "ix": 1 879 | }, 880 | "s": { 881 | "a": 0, 882 | "k": [81.26, 81.26], 883 | "ix": 3 884 | }, 885 | "r": { 886 | "a": 0, 887 | "k": 0, 888 | "ix": 6 889 | }, 890 | "o": { 891 | "a": 0, 892 | "k": 100, 893 | "ix": 7 894 | }, 895 | "sk": { 896 | "a": 0, 897 | "k": 0, 898 | "ix": 4 899 | }, 900 | "sa": { 901 | "a": 0, 902 | "k": 0, 903 | "ix": 5 904 | }, 905 | "nm": "变换" 906 | }], 907 | "nm": "椭圆 1", 908 | "np": 3, 909 | "cix": 2, 910 | "bm": 0, 911 | "ix": 1, 912 | "mn": "ADBE Vector Group", 913 | "hd": false 914 | }], 915 | "ip": 0, 916 | "op": 8, 917 | "st": 0, 918 | "bm": 0 919 | }], 920 | "markers": [] 921 | } -------------------------------------------------------------------------------- /Example/src/assets/loop.json: -------------------------------------------------------------------------------- 1 | {"v":"4.12.0","fr":29.9700012207031,"ip":0,"op":204.00000830909,"w":800,"h":600,"nm":"Comp 1","ddd":0,"assets":[],"layers":[{"ddd":0,"ind":1,"ty":4,"nm":"Shape Layer 1","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[400,300,0],"ix":2},"a":{"a":0,"k":[0,0,0],"ix":1},"s":{"a":0,"k":[100,100,100],"ix":6}},"ao":0,"shapes":[{"ty":"gr","it":[{"d":1,"ty":"el","s":{"a":0,"k":[360,360],"ix":2},"p":{"a":0,"k":[0,0],"ix":3},"nm":"Ellipse Path 1","mn":"ADBE Vector Shape - Ellipse","hd":false},{"ty":"tm","s":{"a":0,"k":99.7,"ix":1},"e":{"a":0,"k":100,"ix":2},"o":{"a":0,"k":2,"ix":3},"m":1,"ix":2,"nm":"Trim Paths 1","mn":"ADBE Vector Filter - Trim","hd":false},{"ty":"gs","o":{"a":0,"k":100,"ix":9},"w":{"a":0,"k":40,"ix":10},"g":{"p":3,"k":{"a":0,"k":[0,0.973,0.408,0.022,0.491,0.811,0.534,0.34,1,0.649,0.659,0.658],"ix":8}},"s":{"a":0,"k":[0,0],"ix":4},"e":{"a":0,"k":[100,0],"ix":5},"t":1,"lc":2,"lj":1,"ml":4,"nm":"Gradient Stroke 1","mn":"ADBE Vector Graphic - G-Stroke","hd":false},{"ty":"tr","p":{"a":0,"k":[0,20],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":1,"k":[{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"n":["0p833_0p833_0p167_0p167"],"t":0,"s":[180],"e":[898]},{"t":200.000008146167}],"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Ellipse 3","np":4,"cix":2,"ix":4,"mn":"ADBE Vector Group","hd":false},{"ty":"gr","it":[{"d":1,"ty":"el","s":{"a":0,"k":[360,360],"ix":2},"p":{"a":0,"k":[0,0],"ix":3},"nm":"Ellipse Path 1","mn":"ADBE Vector Shape - Ellipse","hd":false},{"ty":"tm","s":{"a":0,"k":99.7,"ix":1},"e":{"a":0,"k":100,"ix":2},"o":{"a":0,"k":2,"ix":3},"m":1,"ix":2,"nm":"Trim Paths 1","mn":"ADBE Vector Filter - Trim","hd":false},{"ty":"gs","o":{"a":0,"k":100,"ix":9},"w":{"a":0,"k":40,"ix":10},"g":{"p":3,"k":{"a":0,"k":[0,0.973,0.408,0.022,0.491,0.811,0.534,0.34,1,0.649,0.659,0.658],"ix":8}},"s":{"a":0,"k":[0,0],"ix":4},"e":{"a":0,"k":[100,0],"ix":5},"t":1,"lc":2,"lj":1,"ml":4,"nm":"Gradient Stroke 1","mn":"ADBE Vector Graphic - G-Stroke","hd":false},{"ty":"tr","p":{"a":0,"k":[0,20],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":1,"k":[{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"n":["0p833_0p833_0p167_0p167"],"t":0,"s":[0],"e":[719]},{"t":200.000008146167}],"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Ellipse 2","np":4,"cix":2,"ix":5,"mn":"ADBE Vector Group","hd":false},{"ty":"gr","it":[{"d":1,"ty":"el","s":{"a":0,"k":[280,280],"ix":2},"p":{"a":0,"k":[0,0],"ix":3},"nm":"Ellipse Path 1","mn":"ADBE Vector Shape - Ellipse","hd":false},{"ty":"gf","o":{"a":0,"k":100,"ix":10},"r":1,"g":{"p":3,"k":{"a":0,"k":[0,0.519,0.514,0.521,0.5,0.746,0.463,0.274,1,0.973,0.412,0.027],"ix":9}},"s":{"a":0,"k":[0,0],"ix":5},"e":{"a":0,"k":[218.086,25.777],"ix":6},"t":2,"h":{"a":0,"k":0,"ix":7},"a":{"a":0,"k":0,"ix":8},"nm":"Gradient Fill 1","mn":"ADBE Vector Graphic - G-Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[-1,19.555],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Ellipse 1","np":3,"cix":2,"ix":6,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":300.00001221925,"st":0,"bm":0}]} -------------------------------------------------------------------------------- /Example/src/index.js: -------------------------------------------------------------------------------- 1 | import RefreshAnimateHeader from './RefreshAnimateHeader'; 2 | import RefreshNormalHeader from './RefreshNormalHeader'; 3 | 4 | export { RefreshAnimateHeader, RefreshNormalHeader }; 5 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Jia Song 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # react-native-refresh 2 | 原生集成的下拉刷新。 3 | 4 | # 原理 5 | 此库iOS基于MJRefresh,安卓基于SmartRefreshLayout,均是原生中使用非常广泛的下拉刷新库。 6 | 此库只提供基础的Base部分,但是Demo中提供了两种此库的用法,一个是默认的文字形式,一个是结合lottie实现的下拉刷新动画。 7 | 8 | # 注意!!! 9 | - 支持0.59+,使用Android X的开发者在项目根目录执行 `npx jetify`。 10 | - 0.57以下,因为RN iOS平台的ScrollView添加RefreshControl的方式还未改变,不支持自定义,需要改动ScrollView源码才能实现,故不会适配。 11 | - 如果使用上遇到问题或者疑惑,请提交issue,比较着急的话请加我QQ:593908937。 12 | 13 | ## 下载 14 | ### React Native >= 0.60.0 15 | 16 | ``` 17 | $ npm install react-native-refresh --save 18 | $ cd ios && pod install 19 | $ cd .. && npx jetify 20 | $ npm run ios // npm run android 21 | 22 | ``` 23 | 24 | ### React Native >= 0.59 25 | 26 | ``` 27 | $ npm install react-native-refresh --save 28 | $ react-native link react-native-refresh 29 | $ npm run ios // npm run android 30 | 31 | ``` 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /RNRefresh.podspec: -------------------------------------------------------------------------------- 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 = "RNRefresh" 7 | s.version = package['version'] 8 | s.summary = package['description'] 9 | s.authors = package['author'] 10 | s.homepage = package['homepage'] 11 | s.license = package['license'] 12 | s.platform = :ios, "10.0" 13 | s.framework = 'UIKit' 14 | s.requires_arc = true 15 | s.source = { :git => "https://github.com/jiasongs/react-native-refresh.git" } 16 | s.source_files = "ios/**/*.{h,m}" 17 | 18 | s.dependency 'React' 19 | s.dependency 'MJRefresh', '~> 3.5.0' 20 | end -------------------------------------------------------------------------------- /android/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | def safeExtGet(prop, fallback) { 4 | rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback 5 | } 6 | 7 | 8 | android { 9 | compileSdkVersion safeExtGet("compileSdkVersion", 25) 10 | buildToolsVersion safeExtGet("buildToolsVersion", '25.0.2') 11 | 12 | defaultConfig { 13 | minSdkVersion safeExtGet('minSdkVersion', 16) 14 | targetSdkVersion safeExtGet('targetSdkVersion', 25) 15 | versionCode 1 16 | versionName "1.0" 17 | } 18 | } 19 | 20 | dependencies { 21 | implementation "com.facebook.react:react-native:+" 22 | implementation "com.android.support:support-v4:${safeExtGet("supportLibVersion", "27.0.2")}" 23 | implementation "com.android.support:support-annotations:${safeExtGet("supportLibVersion", "27.0.2")}" 24 | implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' 25 | implementation fileTree(dir: 'libs', include: ['*.jar']) 26 | } 27 | -------------------------------------------------------------------------------- /android/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /android/src/main/java/com/jiasong/refresh/RCTRefreshHeader.java: -------------------------------------------------------------------------------- 1 | package com.jiasong.refresh; 2 | 3 | import android.support.annotation.ColorInt; 4 | import android.support.annotation.NonNull; 5 | 6 | import android.content.Context; 7 | import android.view.View; 8 | 9 | import com.facebook.react.views.view.ReactViewGroup; 10 | import com.scwang.smartrefresh.layout.api.RefreshHeader; 11 | import com.scwang.smartrefresh.layout.api.RefreshKernel; 12 | import com.scwang.smartrefresh.layout.api.RefreshLayout; 13 | import com.scwang.smartrefresh.layout.constant.RefreshState; 14 | import com.scwang.smartrefresh.layout.constant.SpinnerStyle; 15 | 16 | public class RCTRefreshHeader extends ReactViewGroup implements RefreshHeader { 17 | 18 | public RCTRefreshHeader(Context context) { 19 | super(context); 20 | } 21 | 22 | @Override 23 | public void onInitialized(@NonNull RefreshKernel kernel, int height, int extendHeight) { 24 | 25 | } 26 | 27 | @NonNull 28 | public View getView() { 29 | return this; // 真实的视图就是自己,不能返回null 30 | } 31 | 32 | @Override 33 | public SpinnerStyle getSpinnerStyle() { 34 | return SpinnerStyle.Translate; // 指定为平移,不能null 35 | } 36 | 37 | @Override 38 | public void onStartAnimator(RefreshLayout layout, int headHeight, int maxDragHeight) { 39 | 40 | } 41 | 42 | @Override 43 | public int onFinish(RefreshLayout layout, boolean success) { 44 | return 0; 45 | } 46 | 47 | @Override 48 | public void onStateChanged(RefreshLayout refreshLayout, RefreshState oldState, RefreshState newState) { 49 | 50 | } 51 | 52 | @Override 53 | public boolean isSupportHorizontalDrag() { 54 | return false; 55 | } 56 | 57 | @Override 58 | public void onHorizontalDrag(float percentX, int offsetX, int offsetMax) { 59 | } 60 | 61 | @Override 62 | public void onMoving(boolean isDragging, float percent, int offset, int height, int maxDragHeight) { 63 | 64 | } 65 | 66 | @Override 67 | public void onReleased(@NonNull RefreshLayout refreshLayout, int height, int maxDragHeight) { 68 | 69 | } 70 | 71 | @Override 72 | public void setPrimaryColors(@ColorInt int... colors) { 73 | 74 | } 75 | 76 | } 77 | -------------------------------------------------------------------------------- /android/src/main/java/com/jiasong/refresh/RCTRefreshHeaderManager.java: -------------------------------------------------------------------------------- 1 | package com.jiasong.refresh; 2 | 3 | import com.facebook.react.uimanager.ThemedReactContext; 4 | import com.facebook.react.uimanager.ViewGroupManager; 5 | 6 | public class RCTRefreshHeaderManager extends ViewGroupManager { 7 | 8 | @Override 9 | public String getName() { 10 | return "RCTRefreshHeader"; 11 | } 12 | 13 | @Override 14 | protected RCTRefreshHeader createViewInstance(ThemedReactContext reactContext) { 15 | return new RCTRefreshHeader(reactContext); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /android/src/main/java/com/jiasong/refresh/RCTRefreshLayout.java: -------------------------------------------------------------------------------- 1 | package com.jiasong.refresh; 2 | 3 | import android.support.annotation.NonNull; 4 | 5 | import android.view.View; 6 | 7 | import com.facebook.react.bridge.WritableMap; 8 | import com.facebook.react.bridge.WritableNativeMap; 9 | import com.facebook.react.uimanager.ThemedReactContext; 10 | import com.facebook.react.uimanager.events.RCTEventEmitter; 11 | import com.facebook.react.views.scroll.ReactScrollView; 12 | import com.scwang.smartrefresh.layout.SmartRefreshLayout; 13 | import com.scwang.smartrefresh.layout.api.RefreshHeader; 14 | import com.scwang.smartrefresh.layout.api.RefreshLayout; 15 | import com.scwang.smartrefresh.layout.constant.RefreshState; 16 | import com.scwang.smartrefresh.layout.listener.OnRefreshListener; 17 | import com.scwang.smartrefresh.layout.listener.SimpleMultiPurposeListener; 18 | import com.scwang.smartrefresh.layout.util.SmartUtil; 19 | 20 | public class RCTRefreshLayout extends SmartRefreshLayout { 21 | 22 | public static final String onChangeOffsetEvent = "onChangeOffset"; 23 | public static final String onChangeStateEvent = "onChangeState"; 24 | private ThemedReactContext mReactContext; 25 | private RCTEventEmitter eventEmitter; 26 | 27 | public RCTRefreshLayout(ThemedReactContext context) { 28 | super(context); 29 | mReactContext = context; 30 | eventEmitter = context.getJSModule(RCTEventEmitter.class); 31 | this.setEnableLoadMore(false); 32 | this.setHeaderMaxDragRate(2); 33 | this.setHeaderTriggerRate(1); 34 | this.setDragRate((float) 0.5); 35 | this.setEnableOverScrollDrag(true); 36 | this.setEnablePureScrollMode(false); 37 | this.setEnableOverScrollBounce(false); 38 | this.setOnRefreshListener(new RefreshListener()); 39 | this.setOnMultiPurposeListener(new MultiPurposeListener()); 40 | } 41 | 42 | @Override 43 | public void addView(View child, int index) { 44 | if (child instanceof RCTRefreshHeader) { 45 | this.setRefreshHeader((RCTRefreshHeader) child); 46 | } else if (child instanceof ReactScrollView) { 47 | this.setRefreshContent(child); 48 | } 49 | } 50 | 51 | 52 | public void setRefreshing(Boolean refreshing) { 53 | RefreshState newState = this.getState(); 54 | if (refreshing && newState == RefreshState.None) { 55 | this.autoRefresh(); 56 | } else if (!refreshing && (newState == RefreshState.Refreshing || newState == RefreshState.RefreshReleased)) { 57 | this.finishRefresh(); 58 | } 59 | } 60 | 61 | private int getTargetId() { 62 | return this.getId(); 63 | } 64 | 65 | private class RefreshListener implements OnRefreshListener { 66 | @Override 67 | public void onRefresh(@NonNull RefreshLayout refreshLayout) { 68 | 69 | } 70 | } 71 | 72 | private class MultiPurposeListener extends SimpleMultiPurposeListener { 73 | 74 | @Override 75 | public void onHeaderMoving(RefreshHeader header, boolean isDragging, float percent, int offset, 76 | int headerHeight, int maxDragHeight) { 77 | WritableMap map = new WritableNativeMap(); 78 | map.putDouble("offset", SmartUtil.px2dp(offset)); 79 | eventEmitter.receiveEvent(getTargetId(), onChangeOffsetEvent, map); 80 | } 81 | 82 | @Override 83 | public void onStateChanged(@NonNull RefreshLayout refreshLayout, @NonNull RefreshState oldState, 84 | @NonNull RefreshState newState) { 85 | WritableMap map = new WritableNativeMap(); 86 | if (newState == RefreshState.None) { 87 | map.putInt("state", 1); 88 | eventEmitter.receiveEvent(getTargetId(), onChangeStateEvent, map); 89 | } else if (newState == RefreshState.PullDownToRefresh) { 90 | map.putInt("state", 1); 91 | eventEmitter.receiveEvent(getTargetId(), onChangeStateEvent, map); 92 | } else if (newState == RefreshState.ReleaseToRefresh) { 93 | map.putInt("state", 2); 94 | eventEmitter.receiveEvent(getTargetId(), onChangeStateEvent, map); 95 | } else if (newState == RefreshState.RefreshReleased) { 96 | map.putInt("state", 3); 97 | eventEmitter.receiveEvent(getTargetId(), onChangeStateEvent, map); 98 | } else if (newState == RefreshState.RefreshFinish) { 99 | map.putInt("state", 4); 100 | eventEmitter.receiveEvent(getTargetId(), onChangeStateEvent, map); 101 | } 102 | } 103 | 104 | @Override 105 | public void onHeaderReleased(RefreshHeader header, int headerHeight, int extendHeight) { 106 | 107 | } 108 | 109 | @Override 110 | public void onHeaderStartAnimator(RefreshHeader header, int headerHeight, int extendHeight) { 111 | 112 | } 113 | 114 | @Override 115 | public void onHeaderFinish(RefreshHeader header, boolean success) { 116 | 117 | } 118 | } 119 | 120 | } -------------------------------------------------------------------------------- /android/src/main/java/com/jiasong/refresh/RCTRefreshLayoutManager.java: -------------------------------------------------------------------------------- 1 | package com.jiasong.refresh; 2 | 3 | import com.facebook.react.common.MapBuilder; 4 | import com.facebook.react.uimanager.ThemedReactContext; 5 | import com.facebook.react.uimanager.ViewGroupManager; 6 | import com.facebook.react.uimanager.annotations.ReactProp; 7 | 8 | import java.util.Map; 9 | 10 | public class RCTRefreshLayoutManager extends ViewGroupManager { 11 | 12 | @Override 13 | public String getName() { 14 | return "RCTRefreshLayout"; 15 | } 16 | 17 | @Override 18 | protected RCTRefreshLayout createViewInstance(ThemedReactContext reactContext) { 19 | return new RCTRefreshLayout(reactContext); 20 | } 21 | 22 | @ReactProp(name = "headerHeight") 23 | public void setHeaderHeight(RCTRefreshLayout view, float headerHeight) { 24 | if (headerHeight != 0.0f) { 25 | view.setHeaderHeight(headerHeight); 26 | } 27 | } 28 | 29 | @ReactProp(name = "refreshing") 30 | public void setRefreshing(RCTRefreshLayout view, Boolean refreshing) { 31 | view.setRefreshing(refreshing); 32 | } 33 | 34 | @ReactProp(name = "enable") 35 | public void setEnable(RCTRefreshLayout view, Boolean enable) { 36 | view.setEnableRefresh(enable); 37 | 38 | } 39 | 40 | @Override 41 | public Map getExportedCustomDirectEventTypeConstants() { 42 | String onChangeStateEvent = RCTRefreshLayout.onChangeStateEvent; 43 | String onChangeOffsetEvent = RCTRefreshLayout.onChangeOffsetEvent; 44 | return MapBuilder.builder() 45 | .put(onChangeStateEvent, MapBuilder.of("registrationName", onChangeStateEvent)) 46 | .put(onChangeOffsetEvent, MapBuilder.of("registrationName", onChangeOffsetEvent)).build(); 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /android/src/main/java/com/jiasong/refresh/RCTRefreshLayoutPackage.java: -------------------------------------------------------------------------------- 1 | package com.jiasong.refresh; 2 | 3 | import com.facebook.react.ReactPackage; 4 | import com.facebook.react.bridge.NativeModule; 5 | import com.facebook.react.bridge.ReactApplicationContext; 6 | import com.facebook.react.uimanager.ViewManager; 7 | 8 | import java.util.ArrayList; 9 | import java.util.Arrays; 10 | import java.util.List; 11 | 12 | public class RCTRefreshLayoutPackage implements ReactPackage { 13 | 14 | @Override 15 | public List createNativeModules(ReactApplicationContext reactContext) { 16 | List modules = new ArrayList<>(); 17 | return modules; 18 | } 19 | 20 | @Override 21 | public List createViewManagers(ReactApplicationContext reactContext) { 22 | return Arrays.asList( 23 | new RCTRefreshHeaderManager(), 24 | new RCTRefreshLayoutManager() 25 | ); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /android/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | refresh 3 | 4 | -------------------------------------------------------------------------------- /ios/RNRefresh.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 50; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 591CBE20231CA21000FBB197 /* RCTRefreshHeader.m in Sources */ = {isa = PBXBuildFile; fileRef = 591CBE19231CA20F00FBB197 /* RCTRefreshHeader.m */; }; 11 | 591CBE21231CA21000FBB197 /* RCTRefreshHeaderManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 591CBE1B231CA20F00FBB197 /* RCTRefreshHeaderManager.m */; }; 12 | 591CBE22231CA21000FBB197 /* RCTRefreshLayout.m in Sources */ = {isa = PBXBuildFile; fileRef = 591CBE1C231CA20F00FBB197 /* RCTRefreshLayout.m */; }; 13 | 591CBE23231CA21000FBB197 /* RCTRefreshLayoutManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 591CBE1D231CA21000FBB197 /* RCTRefreshLayoutManager.m */; }; 14 | /* End PBXBuildFile section */ 15 | 16 | /* Begin PBXCopyFilesBuildPhase section */ 17 | 591CBE0A231CA1E000FBB197 /* CopyFiles */ = { 18 | isa = PBXCopyFilesBuildPhase; 19 | buildActionMask = 2147483647; 20 | dstPath = "include/$(PRODUCT_NAME)"; 21 | dstSubfolderSpec = 16; 22 | files = ( 23 | ); 24 | runOnlyForDeploymentPostprocessing = 0; 25 | }; 26 | /* End PBXCopyFilesBuildPhase section */ 27 | 28 | /* Begin PBXFileReference section */ 29 | 591CBE0C231CA1E000FBB197 /* libRNRefresh.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRNRefresh.a; sourceTree = BUILT_PRODUCTS_DIR; }; 30 | 591CBE18231CA20F00FBB197 /* RCTRefreshLayout.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTRefreshLayout.h; sourceTree = ""; }; 31 | 591CBE19231CA20F00FBB197 /* RCTRefreshHeader.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTRefreshHeader.m; sourceTree = ""; }; 32 | 591CBE1A231CA20F00FBB197 /* RCTRefreshHeader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTRefreshHeader.h; sourceTree = ""; }; 33 | 591CBE1B231CA20F00FBB197 /* RCTRefreshHeaderManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTRefreshHeaderManager.m; sourceTree = ""; }; 34 | 591CBE1C231CA20F00FBB197 /* RCTRefreshLayout.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTRefreshLayout.m; sourceTree = ""; }; 35 | 591CBE1D231CA21000FBB197 /* RCTRefreshLayoutManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTRefreshLayoutManager.m; sourceTree = ""; }; 36 | 591CBE1E231CA21000FBB197 /* RCTRefreshHeaderManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTRefreshHeaderManager.h; sourceTree = ""; }; 37 | 591CBE1F231CA21000FBB197 /* RCTRefreshLayoutManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTRefreshLayoutManager.h; sourceTree = ""; }; 38 | /* End PBXFileReference section */ 39 | 40 | /* Begin PBXFrameworksBuildPhase section */ 41 | 591CBE09231CA1E000FBB197 /* Frameworks */ = { 42 | isa = PBXFrameworksBuildPhase; 43 | buildActionMask = 2147483647; 44 | files = ( 45 | ); 46 | runOnlyForDeploymentPostprocessing = 0; 47 | }; 48 | /* End PBXFrameworksBuildPhase section */ 49 | 50 | /* Begin PBXGroup section */ 51 | 591CBE03231CA1E000FBB197 = { 52 | isa = PBXGroup; 53 | children = ( 54 | 591CBE0E231CA1E000FBB197 /* RNRefresh */, 55 | 591CBE0D231CA1E000FBB197 /* Products */, 56 | ); 57 | sourceTree = ""; 58 | }; 59 | 591CBE0D231CA1E000FBB197 /* Products */ = { 60 | isa = PBXGroup; 61 | children = ( 62 | 591CBE0C231CA1E000FBB197 /* libRNRefresh.a */, 63 | ); 64 | name = Products; 65 | sourceTree = ""; 66 | }; 67 | 591CBE0E231CA1E000FBB197 /* RNRefresh */ = { 68 | isa = PBXGroup; 69 | children = ( 70 | 591CBE1A231CA20F00FBB197 /* RCTRefreshHeader.h */, 71 | 591CBE19231CA20F00FBB197 /* RCTRefreshHeader.m */, 72 | 591CBE1E231CA21000FBB197 /* RCTRefreshHeaderManager.h */, 73 | 591CBE1B231CA20F00FBB197 /* RCTRefreshHeaderManager.m */, 74 | 591CBE18231CA20F00FBB197 /* RCTRefreshLayout.h */, 75 | 591CBE1C231CA20F00FBB197 /* RCTRefreshLayout.m */, 76 | 591CBE1F231CA21000FBB197 /* RCTRefreshLayoutManager.h */, 77 | 591CBE1D231CA21000FBB197 /* RCTRefreshLayoutManager.m */, 78 | ); 79 | path = RNRefresh; 80 | sourceTree = ""; 81 | }; 82 | /* End PBXGroup section */ 83 | 84 | /* Begin PBXNativeTarget section */ 85 | 591CBE0B231CA1E000FBB197 /* RNRefresh */ = { 86 | isa = PBXNativeTarget; 87 | buildConfigurationList = 591CBE15231CA1E000FBB197 /* Build configuration list for PBXNativeTarget "RNRefresh" */; 88 | buildPhases = ( 89 | 591CBE08231CA1E000FBB197 /* Sources */, 90 | 591CBE09231CA1E000FBB197 /* Frameworks */, 91 | 591CBE0A231CA1E000FBB197 /* CopyFiles */, 92 | ); 93 | buildRules = ( 94 | ); 95 | dependencies = ( 96 | ); 97 | name = RNRefresh; 98 | productName = RNRefresh; 99 | productReference = 591CBE0C231CA1E000FBB197 /* libRNRefresh.a */; 100 | productType = "com.apple.product-type.library.static"; 101 | }; 102 | /* End PBXNativeTarget section */ 103 | 104 | /* Begin PBXProject section */ 105 | 591CBE04231CA1E000FBB197 /* Project object */ = { 106 | isa = PBXProject; 107 | attributes = { 108 | LastUpgradeCheck = 1020; 109 | ORGANIZATIONNAME = jiasong; 110 | TargetAttributes = { 111 | 591CBE0B231CA1E000FBB197 = { 112 | CreatedOnToolsVersion = 10.2.1; 113 | }; 114 | }; 115 | }; 116 | buildConfigurationList = 591CBE07231CA1E000FBB197 /* Build configuration list for PBXProject "RNRefresh" */; 117 | compatibilityVersion = "Xcode 9.3"; 118 | developmentRegion = en; 119 | hasScannedForEncodings = 0; 120 | knownRegions = ( 121 | en, 122 | Base, 123 | ); 124 | mainGroup = 591CBE03231CA1E000FBB197; 125 | productRefGroup = 591CBE0D231CA1E000FBB197 /* Products */; 126 | projectDirPath = ""; 127 | projectRoot = ""; 128 | targets = ( 129 | 591CBE0B231CA1E000FBB197 /* RNRefresh */, 130 | ); 131 | }; 132 | /* End PBXProject section */ 133 | 134 | /* Begin PBXSourcesBuildPhase section */ 135 | 591CBE08231CA1E000FBB197 /* Sources */ = { 136 | isa = PBXSourcesBuildPhase; 137 | buildActionMask = 2147483647; 138 | files = ( 139 | 591CBE23231CA21000FBB197 /* RCTRefreshLayoutManager.m in Sources */, 140 | 591CBE20231CA21000FBB197 /* RCTRefreshHeader.m in Sources */, 141 | 591CBE21231CA21000FBB197 /* RCTRefreshHeaderManager.m in Sources */, 142 | 591CBE22231CA21000FBB197 /* RCTRefreshLayout.m in Sources */, 143 | ); 144 | runOnlyForDeploymentPostprocessing = 0; 145 | }; 146 | /* End PBXSourcesBuildPhase section */ 147 | 148 | /* Begin XCBuildConfiguration section */ 149 | 591CBE13231CA1E000FBB197 /* Debug */ = { 150 | isa = XCBuildConfiguration; 151 | buildSettings = { 152 | ALWAYS_SEARCH_USER_PATHS = NO; 153 | CLANG_ANALYZER_NONNULL = YES; 154 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 155 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 156 | CLANG_CXX_LIBRARY = "libc++"; 157 | CLANG_ENABLE_MODULES = YES; 158 | CLANG_ENABLE_OBJC_ARC = YES; 159 | CLANG_ENABLE_OBJC_WEAK = YES; 160 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 161 | CLANG_WARN_BOOL_CONVERSION = YES; 162 | CLANG_WARN_COMMA = YES; 163 | CLANG_WARN_CONSTANT_CONVERSION = YES; 164 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 165 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 166 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 167 | CLANG_WARN_EMPTY_BODY = YES; 168 | CLANG_WARN_ENUM_CONVERSION = YES; 169 | CLANG_WARN_INFINITE_RECURSION = YES; 170 | CLANG_WARN_INT_CONVERSION = YES; 171 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 172 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 173 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 174 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 175 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 176 | CLANG_WARN_STRICT_PROTOTYPES = YES; 177 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 178 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 179 | CLANG_WARN_UNREACHABLE_CODE = YES; 180 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 181 | CODE_SIGN_IDENTITY = "iPhone Developer"; 182 | COPY_PHASE_STRIP = NO; 183 | DEBUG_INFORMATION_FORMAT = dwarf; 184 | ENABLE_STRICT_OBJC_MSGSEND = YES; 185 | ENABLE_TESTABILITY = YES; 186 | GCC_C_LANGUAGE_STANDARD = gnu11; 187 | GCC_DYNAMIC_NO_PIC = NO; 188 | GCC_NO_COMMON_BLOCKS = YES; 189 | GCC_OPTIMIZATION_LEVEL = 0; 190 | GCC_PREPROCESSOR_DEFINITIONS = ( 191 | "DEBUG=1", 192 | "$(inherited)", 193 | ); 194 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 195 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 196 | GCC_WARN_UNDECLARED_SELECTOR = YES; 197 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 198 | GCC_WARN_UNUSED_FUNCTION = YES; 199 | GCC_WARN_UNUSED_VARIABLE = YES; 200 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 201 | MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; 202 | MTL_FAST_MATH = YES; 203 | ONLY_ACTIVE_ARCH = YES; 204 | SDKROOT = iphoneos; 205 | }; 206 | name = Debug; 207 | }; 208 | 591CBE14231CA1E000FBB197 /* Release */ = { 209 | isa = XCBuildConfiguration; 210 | buildSettings = { 211 | ALWAYS_SEARCH_USER_PATHS = NO; 212 | CLANG_ANALYZER_NONNULL = YES; 213 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 214 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 215 | CLANG_CXX_LIBRARY = "libc++"; 216 | CLANG_ENABLE_MODULES = YES; 217 | CLANG_ENABLE_OBJC_ARC = YES; 218 | CLANG_ENABLE_OBJC_WEAK = YES; 219 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 220 | CLANG_WARN_BOOL_CONVERSION = YES; 221 | CLANG_WARN_COMMA = YES; 222 | CLANG_WARN_CONSTANT_CONVERSION = YES; 223 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 224 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 225 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 226 | CLANG_WARN_EMPTY_BODY = YES; 227 | CLANG_WARN_ENUM_CONVERSION = YES; 228 | CLANG_WARN_INFINITE_RECURSION = YES; 229 | CLANG_WARN_INT_CONVERSION = YES; 230 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 231 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 232 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 233 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 234 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 235 | CLANG_WARN_STRICT_PROTOTYPES = YES; 236 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 237 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 238 | CLANG_WARN_UNREACHABLE_CODE = YES; 239 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 240 | CODE_SIGN_IDENTITY = "iPhone Developer"; 241 | COPY_PHASE_STRIP = NO; 242 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 243 | ENABLE_NS_ASSERTIONS = NO; 244 | ENABLE_STRICT_OBJC_MSGSEND = YES; 245 | GCC_C_LANGUAGE_STANDARD = gnu11; 246 | GCC_NO_COMMON_BLOCKS = YES; 247 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 248 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 249 | GCC_WARN_UNDECLARED_SELECTOR = YES; 250 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 251 | GCC_WARN_UNUSED_FUNCTION = YES; 252 | GCC_WARN_UNUSED_VARIABLE = YES; 253 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 254 | MTL_ENABLE_DEBUG_INFO = NO; 255 | MTL_FAST_MATH = YES; 256 | SDKROOT = iphoneos; 257 | VALIDATE_PRODUCT = YES; 258 | }; 259 | name = Release; 260 | }; 261 | 591CBE16231CA1E000FBB197 /* Debug */ = { 262 | isa = XCBuildConfiguration; 263 | buildSettings = { 264 | CODE_SIGN_STYLE = Automatic; 265 | OTHER_LDFLAGS = "-ObjC"; 266 | PRODUCT_NAME = "$(TARGET_NAME)"; 267 | SKIP_INSTALL = YES; 268 | TARGETED_DEVICE_FAMILY = "1,2"; 269 | }; 270 | name = Debug; 271 | }; 272 | 591CBE17231CA1E000FBB197 /* Release */ = { 273 | isa = XCBuildConfiguration; 274 | buildSettings = { 275 | CODE_SIGN_STYLE = Automatic; 276 | OTHER_LDFLAGS = "-ObjC"; 277 | PRODUCT_NAME = "$(TARGET_NAME)"; 278 | SKIP_INSTALL = YES; 279 | TARGETED_DEVICE_FAMILY = "1,2"; 280 | }; 281 | name = Release; 282 | }; 283 | /* End XCBuildConfiguration section */ 284 | 285 | /* Begin XCConfigurationList section */ 286 | 591CBE07231CA1E000FBB197 /* Build configuration list for PBXProject "RNRefresh" */ = { 287 | isa = XCConfigurationList; 288 | buildConfigurations = ( 289 | 591CBE13231CA1E000FBB197 /* Debug */, 290 | 591CBE14231CA1E000FBB197 /* Release */, 291 | ); 292 | defaultConfigurationIsVisible = 0; 293 | defaultConfigurationName = Release; 294 | }; 295 | 591CBE15231CA1E000FBB197 /* Build configuration list for PBXNativeTarget "RNRefresh" */ = { 296 | isa = XCConfigurationList; 297 | buildConfigurations = ( 298 | 591CBE16231CA1E000FBB197 /* Debug */, 299 | 591CBE17231CA1E000FBB197 /* Release */, 300 | ); 301 | defaultConfigurationIsVisible = 0; 302 | defaultConfigurationName = Release; 303 | }; 304 | /* End XCConfigurationList section */ 305 | }; 306 | rootObject = 591CBE04231CA1E000FBB197 /* Project object */; 307 | } 308 | -------------------------------------------------------------------------------- /ios/RNRefresh/RCTRefreshHeader.h: -------------------------------------------------------------------------------- 1 | // 2 | // RCTRefreshHeader.h 3 | // RNRefresh 4 | // 5 | // Created by jiasong on 2019/9/2. 6 | // Copyright © 2020 jiasong. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @interface RCTRefreshHeader : RCTView 14 | 15 | @end 16 | 17 | NS_ASSUME_NONNULL_END 18 | -------------------------------------------------------------------------------- /ios/RNRefresh/RCTRefreshHeader.m: -------------------------------------------------------------------------------- 1 | // 2 | // RCTRefreshHeader.m 3 | // RNRefresh 4 | // 5 | // Created by jiasong on 2019/9/2. 6 | // Copyright © 2020 jiasong. All rights reserved. 7 | // 8 | 9 | #import "RCTRefreshHeader.h" 10 | 11 | @implementation RCTRefreshHeader 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /ios/RNRefresh/RCTRefreshHeaderManager.h: -------------------------------------------------------------------------------- 1 | // 2 | // RCTRefreshHeaderManager.h 3 | // RNRefresh 4 | // 5 | // Created by jiasong on 2019/9/2. 6 | // Copyright © 2020 jiasong. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @interface RCTRefreshHeaderManager : RCTViewManager 14 | 15 | @end 16 | 17 | NS_ASSUME_NONNULL_END 18 | -------------------------------------------------------------------------------- /ios/RNRefresh/RCTRefreshHeaderManager.m: -------------------------------------------------------------------------------- 1 | // 2 | // RCTRefreshHeaderManager.m 3 | // RNRefresh 4 | // 5 | // Created by jiasong on 2019/9/2. 6 | // Copyright © 2020 jiasong. All rights reserved. 7 | // 8 | 9 | #import "RCTRefreshHeaderManager.h" 10 | #import "RCTRefreshHeader.h" 11 | 12 | @implementation RCTRefreshHeaderManager 13 | 14 | RCT_EXPORT_MODULE() 15 | 16 | - (UIView *)view { 17 | return [[RCTRefreshHeader alloc] init]; 18 | } 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /ios/RNRefresh/RCTRefreshLayout.h: -------------------------------------------------------------------------------- 1 | // 2 | // RCTRefreshLayout.h 3 | // RNRefresh 4 | // 5 | // Created by jiasong on 2019/9/2. 6 | // Copyright © 2020 jiasong. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | #import 12 | #import 13 | 14 | NS_ASSUME_NONNULL_BEGIN 15 | 16 | @interface RCTRefreshLayout : MJRefreshHeader 17 | 18 | @property (nullable, nonatomic, copy) RCTDirectEventBlock onRefresh; 19 | @property (nullable, nonatomic, copy) RCTDirectEventBlock onChangeState; 20 | @property (nullable, nonatomic, copy) RCTDirectEventBlock onChangeOffset; 21 | 22 | @end 23 | 24 | NS_ASSUME_NONNULL_END 25 | -------------------------------------------------------------------------------- /ios/RNRefresh/RCTRefreshLayout.m: -------------------------------------------------------------------------------- 1 | // 2 | // RCTRefreshLayout 3 | // RNRefresh 4 | // 5 | // Created by jiasong on 2019/9/2. 6 | // Copyright © 2020 jiasong. All rights reserved. 7 | // 8 | 9 | #import "RCTRefreshLayout.h" 10 | 11 | @interface RCTRefreshLayout () 12 | 13 | @property (nonatomic, assign) MJRefreshState preState; 14 | 15 | @end 16 | 17 | @implementation RCTRefreshLayout 18 | 19 | - (instancetype)init { 20 | if (self = [super init]) { 21 | _preState = MJRefreshStateIdle; 22 | } 23 | return self; 24 | } 25 | 26 | - (void)setState:(MJRefreshState)state { 27 | [super setState:state]; 28 | if (self.onChangeState) { 29 | if (state == MJRefreshStateIdle && (_preState == MJRefreshStateRefreshing || _preState == MJRefreshStateWillRefresh)) { 30 | self.onChangeState(@{@"state":@(4)}); // 结束刷新 31 | } else if (state == MJRefreshStateWillRefresh){ 32 | self.onChangeState(@{@"state":@(3)}); // 正在刷新 33 | } else { 34 | self.onChangeState(@{@"state":@(state)}); 35 | } 36 | } 37 | _preState = state; 38 | } 39 | 40 | - (void)scrollViewContentOffsetDidChange:(NSDictionary *)change { 41 | [super scrollViewContentOffsetDidChange:change]; 42 | if (self.onChangeOffset) { 43 | CGPoint newPoint = [change[@"new"] CGPointValue]; 44 | CGPoint oldPoint = [change[@"old"] CGPointValue]; 45 | if (!CGPointEqualToPoint(newPoint, oldPoint)) { 46 | self.onChangeOffset(@{@"offset":@(fabs(newPoint.y))}); 47 | } 48 | } 49 | } 50 | 51 | - (void)setRefreshing:(BOOL)refreshing { 52 | if (refreshing && self.state == MJRefreshStateIdle) { 53 | MJRefreshDispatchAsyncOnMainQueue({ 54 | [self beginRefreshing]; 55 | }) 56 | } else if (!refreshing && (self.state == MJRefreshStateRefreshing || self.state == MJRefreshStateWillRefresh)) { 57 | __weak typeof(self) weakSelf = self; 58 | [self endRefreshingWithCompletionBlock:^{ 59 | typeof(weakSelf) self = weakSelf; 60 | if (self.onChangeState) { 61 | self.onChangeState(@{@"state":@(MJRefreshStateIdle)}); 62 | } 63 | }]; 64 | } 65 | } 66 | 67 | @end 68 | -------------------------------------------------------------------------------- /ios/RNRefresh/RCTRefreshLayoutManager.h: -------------------------------------------------------------------------------- 1 | // 2 | // RCTRefreshLayoutManager.h 3 | // RNRefresh 4 | // 5 | // Created by jiasong on 2019/9/2. 6 | // Copyright © 2020 jiasong. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @interface RCTRefreshLayoutManager : RCTViewManager 14 | 15 | @end 16 | 17 | NS_ASSUME_NONNULL_END 18 | -------------------------------------------------------------------------------- /ios/RNRefresh/RCTRefreshLayoutManager.m: -------------------------------------------------------------------------------- 1 | // 2 | // RCTRefreshLayoutManager.m 3 | // RNRefresh 4 | // 5 | // Created by jiasong on 2019/9/2. 6 | // Copyright © 2020 jiasong. All rights reserved. 7 | // 8 | 9 | #import "RCTRefreshLayoutManager.h" 10 | #import "RCTRefreshLayout.h" 11 | 12 | @implementation RCTRefreshLayoutManager 13 | 14 | RCT_EXPORT_MODULE() 15 | 16 | - (UIView *)view { 17 | return [[RCTRefreshLayout alloc] init]; 18 | } 19 | 20 | RCT_EXPORT_VIEW_PROPERTY(refreshing, BOOL) 21 | RCT_EXPORT_VIEW_PROPERTY(onRefresh, RCTDirectEventBlock) 22 | RCT_EXPORT_VIEW_PROPERTY(onChangeState, RCTDirectEventBlock) 23 | RCT_EXPORT_VIEW_PROPERTY(onChangeOffset, RCTDirectEventBlock) 24 | 25 | @end 26 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-native-refresh", 3 | "version": "2.0.17", 4 | "author": { 5 | "name": "jiasong" 6 | }, 7 | "bugs": { 8 | "url": "https://github.com/jiasongs/react-native-refresh/issues" 9 | }, 10 | "deprecated": false, 11 | "description": "原生集成的下拉刷新。", 12 | "files": [ 13 | "android", 14 | "!android/build", 15 | "!android/bin", 16 | "!android/react-native-refresh.iml", 17 | "!android/.project", 18 | "!android/.settings", 19 | "!android/.gradle", 20 | "ios", 21 | "!ios/build", 22 | "src", 23 | "RNRefresh.podspec" 24 | ], 25 | "keywords": [ 26 | "refresh", 27 | "refreshControl", 28 | "react-native", 29 | "react", 30 | "MJRefresh", 31 | "SmartRefreshLayout" 32 | ], 33 | "homepage": "https://github.com/jiasongs/react-native-refresh#readme", 34 | "license": "MIT", 35 | "main": "src/index.js", 36 | "types": "src/index.d.ts", 37 | "devDependencies": { 38 | "babel-eslint": "^10.1.0", 39 | "eslint": "^7.15.0", 40 | "eslint-plugin-eslint-comments": "^3.2.0", 41 | "eslint-plugin-prettier": "^3.2.0", 42 | "eslint-plugin-react": "^7.21.5", 43 | "eslint-plugin-react-hooks": "^4.2.0", 44 | "eslint-plugin-react-native": "^3.10.0", 45 | "prettier": "^2.2.1" 46 | }, 47 | "repository": { 48 | "type": "git", 49 | "url": "git+https://github.com/jiasongs/react-native-refresh.git" 50 | }, 51 | "scripts": { 52 | "test": "echo \"Error: no test specified\" && exit 1" 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/RefreshHeader.android.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | import React, { useMemo } from 'react'; 3 | import { 4 | StyleSheet, 5 | ViewPropTypes, 6 | requireNativeComponent, 7 | View, 8 | } from 'react-native'; 9 | 10 | function RefreshHeader(props) { 11 | const { children, style } = props; 12 | 13 | const buildStyles = useMemo(() => { 14 | const flattenStyle = StyleSheet.flatten(style ? style : {}); 15 | if (!flattenStyle.height) { 16 | console.warn('style中必须设置固定高度'); 17 | } 18 | return { 19 | style: flattenStyle, 20 | }; 21 | }, [style]); 22 | 23 | return ( 24 | 25 | {children} 26 | 27 | ); 28 | } 29 | 30 | RefreshHeader.propTypes = { 31 | style: ViewPropTypes.style, 32 | }; 33 | 34 | RefreshHeader.defaultProps = {}; 35 | 36 | const RCTRefreshHeader = requireNativeComponent('RCTRefreshHeader'); 37 | 38 | const MemoRefreshHeader = React.memo(RefreshHeader); 39 | 40 | MemoRefreshHeader.displayName = 'RCTRefreshHeader'; 41 | 42 | export default MemoRefreshHeader; 43 | -------------------------------------------------------------------------------- /src/RefreshHeader.ios.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | import React, { useMemo } from 'react'; 3 | import { 4 | StyleSheet, 5 | ViewPropTypes, 6 | requireNativeComponent, 7 | } from 'react-native'; 8 | 9 | function RefreshHeader(props) { 10 | const { children, style } = props; 11 | 12 | const buildStyles = useMemo(() => { 13 | const flattenStyle = StyleSheet.flatten(style ? style : {}); 14 | if (!flattenStyle.height) { 15 | console.warn('style中必须设置固定高度'); 16 | } 17 | return { 18 | style: flattenStyle, 19 | }; 20 | }, [style]); 21 | 22 | return ( 23 | {children} 24 | ); 25 | } 26 | 27 | RefreshHeader.propTypes = { 28 | style: ViewPropTypes.style, 29 | }; 30 | 31 | RefreshHeader.defaultProps = {}; 32 | 33 | const RCTRefreshHeader = requireNativeComponent('RCTRefreshHeader'); 34 | 35 | const MemoRefreshHeader = React.memo(RefreshHeader); 36 | 37 | MemoRefreshHeader.displayName = 'RCTRefreshHeader'; 38 | 39 | export default MemoRefreshHeader; 40 | -------------------------------------------------------------------------------- /src/RefreshLayout.android.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | import React, { useRef, useCallback, useMemo } from 'react'; 3 | import { 4 | StyleSheet, 5 | requireNativeComponent, 6 | View, 7 | PanResponder, 8 | } from 'react-native'; 9 | import PropTypes from 'prop-types'; 10 | import State from './RefreshState'; 11 | 12 | function RefreshLayout(props) { 13 | const { 14 | children, 15 | refreshing, 16 | enable, 17 | onPullingRefresh, 18 | onRefresh, 19 | onEndRefresh, 20 | onIdleRefresh, 21 | onChangeOffset, 22 | forwardedRef, 23 | } = props; 24 | 25 | const currentState = useRef(1); 26 | const offsetRef = useRef(0); 27 | const panResponderRef = useRef( 28 | PanResponder.create({ 29 | onMoveShouldSetPanResponderCapture: () => { 30 | if (offsetRef.current >= 2) { 31 | //满足条件捕获事件 32 | return true; 33 | } 34 | return false; 35 | }, 36 | }), 37 | ); 38 | 39 | const onChangeState = useCallback( 40 | (event) => { 41 | const { state } = event.nativeEvent; 42 | if (currentState.current !== state) { 43 | currentState.current = state; 44 | if (state === 1) { 45 | onIdleRefresh && onIdleRefresh(State.Idle); 46 | } else if (state === 2) { 47 | onPullingRefresh && onPullingRefresh(State.Pulling); 48 | } else if (state === 3) { 49 | onRefresh && onRefresh(State.Refreshing); 50 | } else if (state === 4) { 51 | onEndRefresh && onEndRefresh(State.End); 52 | } 53 | } 54 | }, 55 | [onEndRefresh, onIdleRefresh, onPullingRefresh, onRefresh], 56 | ); 57 | 58 | const offsetCallback = useCallback( 59 | (event) => { 60 | const { offset } = event.nativeEvent; 61 | offsetRef.current = offset; 62 | onChangeOffset && onChangeOffset(event); 63 | }, 64 | [onChangeOffset], 65 | ); 66 | 67 | const build = useMemo(() => { 68 | let height = 0; 69 | const newChildren = React.Children.map(children, (element) => { 70 | const type = 71 | element && typeof element.type === 'object' ? element.type : {}; 72 | if (type.displayName === 'RCTRefreshHeader') { 73 | if (enable) { 74 | const elementProps = element.props; 75 | const flattenStyle = StyleSheet.flatten( 76 | elementProps && elementProps.style ? elementProps.style : {}, 77 | ); 78 | height = flattenStyle.height; 79 | return element; 80 | } else { 81 | return null; 82 | } 83 | } else { 84 | return element; 85 | } 86 | }); 87 | return { 88 | children: newChildren, 89 | headerHeight: height, 90 | }; 91 | }, [children, enable]); 92 | 93 | return ( 94 | 95 | 105 | {build.children} 106 | 107 | 108 | ); 109 | } 110 | 111 | const styles = StyleSheet.create({ 112 | layoutStyle: { 113 | flex: 1, 114 | overflow: 'hidden', 115 | }, 116 | }); 117 | 118 | RefreshLayout.propTypes = { 119 | refreshing: PropTypes.bool, 120 | enable: PropTypes.bool, 121 | onRefresh: PropTypes.func, // 刷新中 122 | onPullingRefresh: PropTypes.func, // 松开就可以进行刷新 123 | onEndRefresh: PropTypes.func, // 刷新结束, 但是动画还未结束 124 | onIdleRefresh: PropTypes.func, // 闲置状态或者刷新完全结束 125 | onChangeOffset: PropTypes.func, 126 | }; 127 | 128 | RefreshLayout.defaultProps = { 129 | refreshing: false, 130 | enable: true, 131 | }; 132 | 133 | const RCTRefreshLayout = requireNativeComponent('RCTRefreshLayout'); 134 | 135 | const MemoRefreshLayout = React.memo(RefreshLayout); 136 | 137 | const ForwardRefreshLayout = React.forwardRef((props, ref) => ( 138 | 139 | )); 140 | 141 | ForwardRefreshLayout.displayName = 'RefreshLayout'; 142 | 143 | export default ForwardRefreshLayout; 144 | -------------------------------------------------------------------------------- /src/RefreshLayout.ios.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | import React, { useMemo, useRef, useCallback } from 'react'; 3 | import { StyleSheet, requireNativeComponent } from 'react-native'; 4 | import PropTypes from 'prop-types'; 5 | import State from './RefreshState'; 6 | 7 | function RefreshLayout(props) { 8 | const { 9 | children, 10 | refreshing, 11 | enable, 12 | onPullingRefresh, 13 | onRefresh, 14 | onEndRefresh, 15 | onIdleRefresh, 16 | onChangeOffset, 17 | forwardedRef, 18 | } = props; 19 | 20 | const currentState = useRef(1); 21 | 22 | const onChangeState = useCallback( 23 | (event) => { 24 | const { state } = event.nativeEvent; 25 | if (currentState.current !== state) { 26 | currentState.current = state; 27 | if (state === 1) { 28 | onIdleRefresh && onIdleRefresh(State.Idle); 29 | } else if (state === 2) { 30 | onPullingRefresh && onPullingRefresh(State.Pulling); 31 | } else if (state === 3) { 32 | onRefresh && onRefresh(State.Refreshing); 33 | } else if (state === 4) { 34 | onEndRefresh && onEndRefresh(State.End); 35 | } 36 | } 37 | }, 38 | [onEndRefresh, onIdleRefresh, onPullingRefresh, onRefresh], 39 | ); 40 | 41 | const build = useMemo(() => { 42 | const newChildren = React.Children.map(children, (element) => { 43 | const type = 44 | element && typeof element.type === 'object' ? element.type : {}; 45 | if (type.displayName === 'RCTRefreshHeader') { 46 | if (enable) { 47 | return element; 48 | } else { 49 | return null; 50 | } 51 | } else { 52 | return element; 53 | } 54 | }); 55 | return { 56 | children: newChildren, 57 | }; 58 | }, [children, enable]); 59 | 60 | if (!enable) { 61 | return build.children; 62 | } 63 | 64 | return ( 65 | 72 | {build.children} 73 | 74 | ); 75 | } 76 | 77 | const styles = StyleSheet.create({ 78 | positionStyle: { 79 | position: 'absolute', 80 | left: 0, 81 | right: 0, 82 | }, 83 | }); 84 | 85 | RefreshLayout.propTypes = { 86 | refreshing: PropTypes.bool, 87 | enable: PropTypes.bool, 88 | onRefresh: PropTypes.func, // 刷新中 89 | onPullingRefresh: PropTypes.func, // 松开就可以进行刷新 90 | onEndRefresh: PropTypes.func, // 刷新结束, 但是动画还未结束 91 | onIdleRefresh: PropTypes.func, // 闲置状态或者刷新完全结束 92 | onChangeOffset: PropTypes.func, 93 | }; 94 | 95 | RefreshLayout.defaultProps = { 96 | refreshing: false, 97 | enable: true, 98 | }; 99 | 100 | const RCTRefreshLayout = requireNativeComponent('RCTRefreshLayout'); 101 | 102 | const MemoRefreshLayout = React.memo(RefreshLayout); 103 | 104 | const ForwardRefreshLayout = React.forwardRef((props, ref) => ( 105 | 106 | )); 107 | 108 | ForwardRefreshLayout.displayName = 'RefreshLayout'; 109 | 110 | export default ForwardRefreshLayout; 111 | -------------------------------------------------------------------------------- /src/RefreshState.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | export default { 4 | Idle: 'Idle' /** 普通闲置状态 */, 5 | Pulling: 'Pulling' /** 松开就可以进行刷新的状态 */, 6 | Refreshing: 'Refreshing' /** 正在刷新中的状态 */, 7 | End: 'End' /** 结束刷新,但还没有执行完重置动画 */, 8 | }; 9 | -------------------------------------------------------------------------------- /src/index.d.ts: -------------------------------------------------------------------------------- 1 | import * as React from 'react'; 2 | import { StyleProp } from 'react-native'; 3 | 4 | type State = 'Idle' | 'Pulling' | 'Refreshing' | 'End'; 5 | 6 | interface Event { 7 | nativeEvent: { 8 | offset: number; 9 | }; 10 | } 11 | 12 | export interface RefreshState { 13 | Idle: 'Idle' /** 普通闲置状态 */; 14 | Pulling: 'Pulling' /** 松开就可以进行刷新的状态 */; 15 | Refreshing: 'Refreshing' /** 正在刷新中的状态 */; 16 | End: 'End' /** 结束刷新,但还没有执行完动画 */; 17 | } 18 | 19 | export interface RefreshHeaderProps { 20 | style?: StyleProp; 21 | } 22 | 23 | export interface RefreshLayoutProps { 24 | enable?: boolean; 25 | refreshing?: boolean; 26 | onIdleRefresh?: (state: State) => void; 27 | onRefresh?: (state: State) => void; 28 | onPullingRefresh?: (state: State) => void; 29 | onEndRefresh?: (state: State) => void; 30 | onChangeOffset?: (event: Event) => void; 31 | } 32 | 33 | export const RefreshHeader: React.ComponentClass; 34 | 35 | export const RefreshLayout: React.ComponentClass; 36 | 37 | export const RefreshState: RefreshState; 38 | -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | import RefreshLayout from './RefreshLayout'; 2 | import RefreshHeader from './RefreshHeader'; 3 | import RefreshState from './RefreshState'; 4 | 5 | export { RefreshLayout, RefreshHeader, RefreshState }; 6 | --------------------------------------------------------------------------------