rnandroidprogressbar_ModuleProvider(const std::string &moduleName, const JavaTurboModule::InitParams ¶ms)
13 | {
14 | return nullptr;
15 | }
16 |
17 | } // namespace react
18 | } // namespace facebook
19 |
--------------------------------------------------------------------------------
/fabricexample/android/app/src/debug/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/js/__tests__/__snapshots__/RNCProgressBarAndroid.android.test.js.snap:
--------------------------------------------------------------------------------
1 | // Jest Snapshot v1, https://goo.gl/fbAQLP
2 |
3 | exports[` renders Horizontal ProgressBar 1`] = `
4 |
9 | `;
10 |
11 | exports[` renders Inverse ProgressBar 1`] = `
12 |
18 | `;
19 |
20 | exports[` renders enabled ProgressBar 1`] = `
21 |
26 | `;
27 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/fabricexample/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 = "33.0.0"
6 | minSdkVersion = 21
7 | compileSdkVersion = 33
8 | targetSdkVersion = 33
9 |
10 | // We use NDK 23 which has both M1 support and is the side-by-side NDK version from AGP.
11 | ndkVersion = "23.1.7779620"
12 | }
13 | repositories {
14 | google()
15 | mavenCentral()
16 | }
17 | dependencies {
18 | classpath("com.android.tools.build:gradle:7.3.1")
19 | classpath("com.facebook.react:react-native-gradle-plugin")
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es5" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */,
4 | "module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */,
5 | "lib": ["es6"],
6 | "jsx": "react" /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */,
7 | /* Strict Type-Checking Options */
8 | "strict": true /* Enable all strict type-checking options. */,
9 | "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/react-native-progress-bar-android.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 = "react-native-progress-bar-android"
7 | s.version = package['version']
8 | s.summary = package['description']
9 | s.license = package['license']
10 |
11 | s.authors = package['author']
12 | s.homepage = package['homepage']
13 |
14 | s.description = package['description']
15 | s.platform = :ios, "9.0"
16 |
17 | s.source = { :git => "https://github.com/react-native-community/react-native-progress-bar-android.git", :tag => "v#{s.version}" }
18 | s.source_files = "ios/RNCProgressBar/**/*.{h,m}"
19 | s.requires_arc = true
20 |
21 | s.dependency "React"
22 |
23 | end
24 |
--------------------------------------------------------------------------------
/fabricexample/android/app/src/release/java/com/fabricexample/ReactNativeFlipper.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) Meta Platforms, Inc. and affiliates.
3 | *
4 | * This source code is licensed under the MIT license found in the LICENSE file in the root
5 | * directory of this source tree.
6 | */
7 | package com.rndiffapp;
8 | import android.content.Context;
9 | import com.facebook.react.ReactInstanceManager;
10 | /**
11 | * Class responsible of loading Flipper inside your React Native application. This is the release
12 | * flavor of it so it's empty as we don't want to load Flipper.
13 | */
14 | public class ReactNativeFlipper {
15 | public static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) {
16 | // Do nothing as we don't want to initialize Flipper on Release.
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/example/ios/AndroidProgressBarExample/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 | }
--------------------------------------------------------------------------------
/js/__tests__/RNCProgressBarAndroid.android.test.js:
--------------------------------------------------------------------------------
1 | import * as React from 'react';
2 | import renderer from 'react-test-renderer';
3 | import ProgressBar from '../RNCProgressBarAndroid.android';
4 |
5 | describe('', () => {
6 | it('renders enabled ProgressBar', () => {
7 | const tree = renderer.create().toJSON();
8 |
9 | expect(tree).toMatchSnapshot();
10 | });
11 |
12 | it('renders Horizontal ProgressBar', () => {
13 | const tree = renderer
14 | .create()
15 | .toJSON();
16 |
17 | expect(tree).toMatchSnapshot();
18 | });
19 |
20 | it('renders Inverse ProgressBar', () => {
21 | const tree = renderer.create().toJSON();
22 |
23 | expect(tree).toMatchSnapshot();
24 | });
25 | });
26 |
--------------------------------------------------------------------------------
/android/src/paper/java/com/facebook/react/viewmanagers/RNCProgressBarManagerInterface.java:
--------------------------------------------------------------------------------
1 | /**
2 | * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
3 | *
4 | * Do not edit this file as changes may cause incorrect behavior and will be lost
5 | * once the code is regenerated.
6 | *
7 | * @generated by codegen project: GeneratePropsJavaInterface.js
8 | */
9 |
10 | package com.facebook.react.viewmanagers;
11 |
12 | import android.view.View;
13 | import androidx.annotation.Nullable;
14 |
15 | public interface RNCProgressBarManagerInterface {
16 | void setStyleAttr(T view, @Nullable String value);
17 | void setIndeterminate(T view, boolean value);
18 | void setProgress(T view, double value);
19 | void setAnimating(T view, boolean value);
20 | void setColor(T view, @Nullable Integer value);
21 | }
22 |
--------------------------------------------------------------------------------
/fabricexample/ios/fabricexampleTests/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/AndroidProgressBarExampleTests/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/AndroidProgressBarExample-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 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # OSX
2 | #
3 | .DS_Store
4 | .project
5 |
6 | # Xcode
7 | #
8 | build/
9 | *.pbxuser
10 | !default.pbxuser
11 | *.mode1v3
12 | !default.mode1v3
13 | *.mode2v3
14 | !default.mode2v3
15 | *.perspectivev3
16 | !default.perspectivev3
17 | xcuserdata
18 | *.xccheckout
19 | *.moved-aside
20 | DerivedData
21 | *.hmap
22 | *.ipa
23 | *.xcuserstate
24 | project.xcworkspace
25 | Pods/
26 |
27 | # Android/IJ
28 | #
29 | .idea
30 | *.iml
31 | .gradle
32 | local.properties
33 | lib/android/src/main/gen
34 |
35 | # node.js
36 | #
37 | node_modules/
38 | npm-debug.log
39 | yarn-error.log
40 | package-lock.json
41 |
42 | # Rubygem bundles
43 | #
44 | bundles/
45 |
46 | # VS Code
47 | .vscode/*
48 | !.vscode/settings.json
49 | !.vscode/tasks.json
50 | !.vscode/launch.json
51 | !.vscode/extensions.json
52 |
53 | android/gradle
54 | android/gradlew
55 | android/gradlew.bat
56 |
57 | # eclipse build file
58 | .project
59 | .settings
60 |
--------------------------------------------------------------------------------
/fabricexample/patches/@react-native-community+cli-platform-android+10.2.0.patch:
--------------------------------------------------------------------------------
1 | diff --git a/node_modules/@react-native-community/cli-platform-android/native_modules.gradle b/node_modules/@react-native-community/cli-platform-android/native_modules.gradle
2 | index 4a63eaf..a6262ae 100644
3 | --- a/node_modules/@react-native-community/cli-platform-android/native_modules.gradle
4 | +++ b/node_modules/@react-native-community/cli-platform-android/native_modules.gradle
5 | @@ -440,7 +440,7 @@ class ReactNativeModules {
6 | String[] nodeCommand = ["node", "-e", cliResolveScript]
7 | def cliPath = this.getCommandOutput(nodeCommand, this.root)
8 |
9 | - String[] reactNativeConfigCommand = ["node", cliPath, "config"]
10 | + String[] reactNativeConfigCommand = ["node", cliPath, "config", "--enable-rnandroidprogressbar-codegen"]
11 | def reactNativeConfigOutput = this.getCommandOutput(reactNativeConfigCommand, this.root)
12 |
13 | def json
14 |
--------------------------------------------------------------------------------
/android/src/main/java/com/reactnativecommunity/androidprogressbar/BUCK:
--------------------------------------------------------------------------------
1 | load("//tools/build_defs/oss:rn_defs.bzl", "YOGA_TARGET", "react_native_dep", "react_native_target", "rn_android_library")
2 |
3 | rn_android_library(
4 | name = "progressbar",
5 | srcs = glob(["*.java"]),
6 | visibility = [
7 | "PUBLIC",
8 | ],
9 | deps = [
10 | YOGA_TARGET,
11 | react_native_dep("third-party/java/infer-annotations:infer-annotations"),
12 | react_native_dep("third-party/java/jsr-305:jsr-305"),
13 | react_native_target("java/com/facebook/react/bridge:bridge"),
14 | react_native_target("java/com/facebook/react/common:common"),
15 | react_native_target("java/com/facebook/react/module/annotations:annotations"),
16 | react_native_target("java/com/facebook/react/uimanager:uimanager"),
17 | react_native_target("java/com/facebook/react/uimanager/annotations:annotations"),
18 | ],
19 | )
20 |
--------------------------------------------------------------------------------
/android/src/main/java/com/reactnativecommunity/androidprogressbar/RNCProgressBarPackage.java:
--------------------------------------------------------------------------------
1 | package com.reactnativecommunity.androidprogressbar;
2 |
3 | import java.util.Arrays;
4 | import java.util.Collections;
5 | import java.util.List;
6 |
7 | import com.facebook.react.ReactPackage;
8 | import com.facebook.react.bridge.NativeModule;
9 | import com.facebook.react.bridge.ReactApplicationContext;
10 | import com.facebook.react.uimanager.ViewManager;
11 | import com.facebook.react.bridge.JavaScriptModule;
12 |
13 | public class RNCProgressBarPackage implements ReactPackage {
14 | @Override
15 | public List createNativeModules(ReactApplicationContext reactContext) {
16 | return Collections.emptyList();
17 | }
18 |
19 | @Override
20 | @SuppressWarnings("rawtypes")
21 | public List createViewManagers(ReactApplicationContext reactContext) {
22 | return Arrays.asList(new ReactProgressBarViewManager());
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/fabricexample/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "fabricexample",
3 | "version": "0.0.1",
4 | "private": true,
5 | "scripts": {
6 | "android": "react-native run-android",
7 | "ios": "react-native run-ios",
8 | "start": "react-native start",
9 | "test": "jest",
10 | "lint": "eslint .",
11 | "postinstall": "patch-package"
12 | },
13 | "dependencies": {
14 | "@react-native-community/progress-bar-android": "link:../",
15 | "patch-package": "^6.5.0",
16 | "postinstall-postinstall": "^2.1.0",
17 | "react": "18.2.0",
18 | "react-native": "0.71.11"
19 | },
20 | "devDependencies": {
21 | "@babel/core": "^7.20.0",
22 | "@babel/runtime": "^7.20.0",
23 | "@react-native-community/eslint-config": "^3.2.0",
24 | "babel-jest": "^29.2.1",
25 | "eslint": "^7.32.0",
26 | "jest": "^26.6.3",
27 | "metro-react-native-babel-preset": "0.73.1",
28 | "react-test-renderer": "18.2.0"
29 | },
30 | "jest": {
31 | "preset": "react-native"
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/android/src/main/jni/RNCProgressBarShadowNode.cpp:
--------------------------------------------------------------------------------
1 | #include "RNCProgressBarShadowNode.h"
2 | #include "RNCProgressBarMeasurementsManager.h"
3 |
4 | namespace facebook
5 | {
6 | namespace react
7 | {
8 |
9 | extern const char RNCProgressBarComponentName[] = "RNCProgressBar";
10 |
11 | void RNCProgressBarShadowNode::setProgressBarMeasurementsManager(
12 | const std::shared_ptr
13 | &measurementsManager)
14 | {
15 | ensureUnsealed();
16 | measurementsManager_ = measurementsManager;
17 | }
18 |
19 | #pragma mark - LayoutableShadowNode
20 |
21 | Size RNCProgressBarShadowNode::measureContent(
22 | LayoutContext const &layoutContext,
23 | LayoutConstraints const &layoutConstraints) const
24 | {
25 | return measurementsManager_->measure(getSurfaceId(), layoutConstraints, getConcreteProps());
26 | }
27 | } // namespace react
28 | } // namespace facebook
29 |
--------------------------------------------------------------------------------
/example/RNTesterTitle.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015-present, Facebook, Inc.
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 | * @flow
8 | */
9 |
10 | 'use strict';
11 |
12 | import * as React from 'react';
13 | import {StyleSheet, Text, View} from 'react-native';
14 |
15 | type Props = $ReadOnly<{|
16 | title: string,
17 | |}>;
18 |
19 | const RNTesterTitle: React.ComponentType = ({title}) => {
20 | return (
21 |
22 | {title}
23 |
24 | );
25 | };
26 |
27 | const styles = StyleSheet.create({
28 | container: {
29 | borderRadius: 4,
30 | borderWidth: 0.5,
31 | borderColor: '#d6d7da',
32 | margin: 10,
33 | marginBottom: 0,
34 | height: 45,
35 | padding: 10,
36 | backgroundColor: 'white',
37 | },
38 | text: {
39 | fontSize: 19,
40 | fontWeight: '500',
41 | },
42 | });
43 |
44 | export default RNTesterTitle;
45 |
--------------------------------------------------------------------------------
/js/RNCProgressBarAndroidNativeComponent.js:
--------------------------------------------------------------------------------
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 | * @flow
8 | */
9 |
10 | 'use strict';
11 |
12 | import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
13 | import type {ColorValue} from 'react-native/Libraries/StyleSheet/StyleSheetTypes';
14 | import type {ViewProps, Double, WithDefault} from 'react-native';
15 |
16 | type NativeProps = $ReadOnly<{|
17 | ...ViewProps,
18 |
19 | //Props
20 | styleAttr?: string,
21 | indeterminate: boolean,
22 | progress?: WithDefault,
23 | animating?: WithDefault,
24 | color?: ?ColorValue,
25 | |}>;
26 |
27 | // $FlowFixMe Fix react-native version in the repository as the option type is old
28 | export default codegenNativeComponent('RNCProgressBar', {
29 | interfaceOnly: true,
30 | excludedPlatforms: ['iOS'],
31 | });
32 |
--------------------------------------------------------------------------------
/fabricexample/RNTesterTitle.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015-present, Facebook, Inc.
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 | * @flow
8 | */
9 |
10 | 'use strict';
11 |
12 | import * as React from 'react';
13 | import {StyleSheet, Text, View} from 'react-native';
14 |
15 | type Props = $ReadOnly<{|
16 | title: string,
17 | |}>;
18 |
19 | const RNTesterTitle: React.ComponentType = ({title}) => {
20 | return (
21 |
22 | {title}
23 |
24 | );
25 | };
26 |
27 | const styles = StyleSheet.create({
28 | container: {
29 | borderRadius: 4,
30 | borderWidth: 0.5,
31 | borderColor: '#d6d7da',
32 | margin: 10,
33 | marginBottom: 0,
34 | height: 45,
35 | padding: 10,
36 | backgroundColor: 'white',
37 | },
38 | text: {
39 | fontSize: 19,
40 | fontWeight: '500',
41 | },
42 | });
43 |
44 | export default RNTesterTitle;
45 |
--------------------------------------------------------------------------------
/android/src/main/jni/RNCProgressBarMeasurementsManager.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 | #include
5 | #include
6 | #include
7 |
8 | namespace facebook
9 | {
10 | namespace react
11 | {
12 |
13 | class RNCProgressBarMeasurementsManager
14 | {
15 | public:
16 | RNCProgressBarMeasurementsManager(
17 | const ContextContainer::Shared &contextContainer)
18 | : contextContainer_(contextContainer) {}
19 |
20 | Size measure(SurfaceId surfaceId, LayoutConstraints layoutConstraints, RNCProgressBarProps props) const;
21 |
22 | private:
23 | const ContextContainer::Shared contextContainer_;
24 | mutable std::mutex mutex_;
25 | mutable std::unordered_map cachedMeasurements_ = {};
26 | };
27 |
28 | } // namespace react
29 | } // namespace facebook
30 |
--------------------------------------------------------------------------------
/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 |
23 | # Version of flipper SDK to use with React Native
24 | FLIPPER_VERSION=0.37.0
25 |
--------------------------------------------------------------------------------
/android/src/main/jni/RNCProgressBarState.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 | #include
5 | #include
6 |
7 | #ifdef ANDROID
8 | #include
9 | #include
10 | #include
11 | #endif
12 |
13 | namespace facebook
14 | {
15 | namespace react
16 | {
17 |
18 | class JSI_EXPORT RNCProgressBarState final
19 | {
20 | public:
21 | using Shared = std::shared_ptr;
22 |
23 | RNCProgressBarState(){};
24 |
25 | #ifdef ANDROID
26 | RNCProgressBarState(
27 | RNCProgressBarState const &previousState,
28 | folly::dynamic data){};
29 | #endif
30 |
31 | #ifdef ANDROID
32 | folly::dynamic getDynamic() const;
33 | MapBuffer getMapBuffer() const
34 | {
35 | return MapBufferBuilder::EMPTY();
36 | };
37 |
38 | #endif
39 |
40 | #pragma mark - Getters
41 | };
42 |
43 | } // namespace react
44 | } // namespace facebook
45 |
--------------------------------------------------------------------------------
/fabricexample/android/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
12 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2020 react-native-community
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.
--------------------------------------------------------------------------------
/js/type.js:
--------------------------------------------------------------------------------
1 | import type {ViewProps} from 'react-native/Libraries/Components/View/ViewPropTypes';
2 |
3 | export type ProgressBarAndroidProps = $ReadOnly<{|
4 | ...ViewProps,
5 |
6 | /**
7 | * Style of the ProgressBar and whether it shows indeterminate progress (e.g. spinner).
8 | *
9 | * `indeterminate` can only be false if `styleAttr` is Horizontal, and requires a
10 | * `progress` value.
11 | */
12 | ...
13 | | {|
14 | styleAttr: 'Horizontal',
15 | indeterminate: false,
16 | progress: number,
17 | |}
18 | | {|
19 | typeAttr:
20 | | 'Horizontal'
21 | | 'Normal'
22 | | 'Small'
23 | | 'Large'
24 | | 'Inverse'
25 | | 'SmallInverse'
26 | | 'LargeInverse',
27 | indeterminate: true,
28 | |},
29 | /**
30 | * Whether to show the ProgressBar (true, the default) or hide it (false).
31 | */
32 | animating?: ?boolean,
33 | /**
34 | * Color of the progress bar.
35 | */
36 | color?: ?string,
37 | /**
38 | * Used to locate this view in end-to-end tests.
39 | */
40 | testID?: ?string,
41 | |}>;
42 |
--------------------------------------------------------------------------------
/fabricexample/ios/fabricexample/Images.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "scale" : "2x",
6 | "size" : "20x20"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "scale" : "3x",
11 | "size" : "20x20"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "scale" : "2x",
16 | "size" : "29x29"
17 | },
18 | {
19 | "idiom" : "iphone",
20 | "scale" : "3x",
21 | "size" : "29x29"
22 | },
23 | {
24 | "idiom" : "iphone",
25 | "scale" : "2x",
26 | "size" : "40x40"
27 | },
28 | {
29 | "idiom" : "iphone",
30 | "scale" : "3x",
31 | "size" : "40x40"
32 | },
33 | {
34 | "idiom" : "iphone",
35 | "scale" : "2x",
36 | "size" : "60x60"
37 | },
38 | {
39 | "idiom" : "iphone",
40 | "scale" : "3x",
41 | "size" : "60x60"
42 | },
43 | {
44 | "idiom" : "ios-marketing",
45 | "scale" : "1x",
46 | "size" : "1024x1024"
47 | }
48 | ],
49 | "info" : {
50 | "author" : "xcode",
51 | "version" : 1
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/example/android/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
13 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/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 = "29.0.2"
6 | minSdkVersion = 16
7 | compileSdkVersion = 29
8 | targetSdkVersion = 29
9 | }
10 | repositories {
11 | google()
12 | jcenter()
13 | }
14 | dependencies {
15 | classpath("com.android.tools.build:gradle:3.5.3")
16 |
17 | // NOTE: Do not place your application dependencies here; they belong
18 | // in the individual module build.gradle files
19 | }
20 | }
21 |
22 | allprojects {
23 | repositories {
24 | mavenLocal()
25 | maven {
26 | // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
27 | url("$rootDir/../../node_modules/react-native/android")
28 | }
29 | maven {
30 | // Android JSC is installed from npm
31 | url("$rootDir/../../node_modules/jsc-android/dist")
32 | }
33 |
34 | google()
35 | jcenter()
36 | maven { url 'https://www.jitpack.io' }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/fabricexample/metro.config.js:
--------------------------------------------------------------------------------
1 | const path = require('path');
2 | const exclusionList = require('metro-config/src/defaults/exclusionList');
3 | const escape = require('escape-string-regexp');
4 | const pack = require('../package.json');
5 |
6 | const root = path.resolve(__dirname, '..');
7 |
8 | const modules = Object.keys(pack.peerDependencies);
9 |
10 | module.exports = {
11 | projectRoot: __dirname,
12 | watchFolders: [root],
13 |
14 | // We need to make sure that only one version is loaded for peerDependencies
15 | // So we exclude them at the root, and alias them to the versions in example's node_modules
16 | resolver: {
17 | blacklistRE: exclusionList(
18 | modules.map(
19 | m => new RegExp(`^${escape(path.join(root, 'node_modules', m))}\\/.*$`),
20 | ),
21 | ),
22 |
23 | extraNodeModules: modules.reduce((acc, name) => {
24 | acc[name] = path.join(__dirname, 'node_modules', name);
25 | return acc;
26 | }, {}),
27 | },
28 |
29 | transformer: {
30 | getTransformOptions: async () => ({
31 | transform: {
32 | experimentalImportSupport: false,
33 | inlineRequires: true,
34 | },
35 | }),
36 | },
37 | };
38 |
--------------------------------------------------------------------------------
/android/src/main/jni/rnandroidprogressbar.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 | #include
5 | #include
6 |
7 | /**
8 | * Note this imports and that they are not present in autogenerated header file
9 | * under android/build/generated/source/codegen/jni/rnandroidprogressbar.h
10 | *
11 | * It is added here to make the custom symbols visible in autogenerated file with
12 | * code responsible for registering component descriptor providers. See that rncli.cpp,
13 | * located under /android/app/build/generated/rncli/src/main/jni/rncli.cpp,
14 | * includes autogenerated rnandroidprogressbar.h header by default. We change this behaviour
15 | * by appropriate include path configuration so that this header file gets included.
16 | */
17 | #include
18 |
19 | namespace facebook
20 | {
21 | namespace react
22 | {
23 |
24 | JSI_EXPORT
25 | std::shared_ptr rnandroidprogressbar_ModuleProvider(const std::string &moduleName, const JavaTurboModule::InitParams ¶ms);
26 |
27 | } // namespace react
28 | } // namespace facebook
29 |
--------------------------------------------------------------------------------
/fabricexample/.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 | ios/.xcode.env.local
24 |
25 | # Android/IntelliJ
26 | #
27 | build/
28 | .idea
29 | .gradle
30 | local.properties
31 | *.iml
32 | *.hprof
33 | .cxx/
34 | *.keystore
35 | !debug.keystore
36 |
37 | # node.js
38 | #
39 | node_modules/
40 | npm-debug.log
41 | yarn-error.log
42 |
43 | # fastlane
44 | #
45 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
46 | # screenshots whenever they are needed.
47 | # For more information about the recommended setup visit:
48 | # https://docs.fastlane.tools/best-practices/source-control/
49 |
50 | **/fastlane/report.xml
51 | **/fastlane/Preview.html
52 | **/fastlane/screenshots
53 | **/fastlane/test_output
54 |
55 | # Bundle artifact
56 | *.jsbundle
57 |
58 | # Ruby / CocoaPods
59 | /ios/Pods/
60 | /vendor/bundle/
61 |
62 | # Temporary files created by Metro to check the health of the file watcher
63 | .metro-health-check*
64 |
--------------------------------------------------------------------------------
/js/index.d.ts:
--------------------------------------------------------------------------------
1 | import * as React from 'react';
2 | import {ViewProps} from 'react-native';
3 |
4 | export type ProgressBarAndroidProps = ViewProps & {
5 | /**
6 | * styleAttr: style of ProgressBar
7 | *
8 | * default: 'Normal'
9 | */
10 | styleAttr?:
11 | | 'Normal'
12 | | 'Horizontal'
13 | | 'Small'
14 | | 'Large'
15 | | 'Inverse'
16 | | 'SmallInverse'
17 | | 'LargeInverse';
18 | /**
19 | * color: Color of the ProgressBar
20 | */
21 | color?: string;
22 | /**
23 | * indeterminate: boolean flag for indeterminate mode.
24 | *
25 | * Use indeterminate mode for the progress bar when you do not know how long an operation will take. Indeterminate mode is the default for progress bar and shows a cyclic animation without a specific amount of progress indicated.
26 | *
27 | * default: false
28 | */
29 | indeterminate?: boolean;
30 | /**
31 | * progress: sets the amount of progress in 0-100.
32 | *
33 | * 25 will show that a progress bar is 25% complete
34 | */
35 | progress?: number;
36 | /**
37 | * animating: weather ProgressBar is animated or not.
38 | *
39 | * default: true
40 | */
41 | animating?: boolean;
42 | };
43 | export class ProgressBar extends React.Component {}
44 |
--------------------------------------------------------------------------------
/fabricexample/ios/fabricexample/AppDelegate.mm:
--------------------------------------------------------------------------------
1 | #import "AppDelegate.h"
2 |
3 | #import
4 |
5 | @implementation AppDelegate
6 |
7 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
8 | {
9 | self.moduleName = @"fabricexample";
10 | // You can add your custom initial props in the dictionary below.
11 | // They will be passed down to the ViewController used by React Native.
12 | self.initialProps = @{};
13 |
14 | return [super application:application didFinishLaunchingWithOptions:launchOptions];
15 | }
16 |
17 | - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
18 | {
19 | #if DEBUG
20 | return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index"];
21 | #else
22 | return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
23 | #endif
24 | }
25 |
26 | /// This method controls whether the `concurrentRoot`feature of React18 is turned on or off.
27 | ///
28 | /// @see: https://reactjs.org/blog/2022/03/29/react-v18.html
29 | /// @note: This requires to be rendering on Fabric (i.e. on the New Architecture).
30 | /// @return: `true` if the `concurrentRoot` feature is enabled. Otherwise, it returns `false`.
31 | - (BOOL)concurrentRootEnabled
32 | {
33 | return true;
34 | }
35 |
36 | @end
--------------------------------------------------------------------------------
/react-native.config.js:
--------------------------------------------------------------------------------
1 | let supportsCodegenConfig = false;
2 |
3 | try {
4 | const rnCliAndroidVersion = require('@react-native-community/cli-platform-android/package.json')
5 | .version;
6 | const [major] = rnCliAndroidVersion.split('.');
7 | supportsCodegenConfig = major >= 9;
8 | } catch (e) {
9 | // ignore
10 | }
11 |
12 | // this is a quick workaround for enabling custom codegen config in the fabric example app
13 | // the require above picks up the version of the cli-platform-android package from the root node_modules
14 | // instead of the one from the example app and doesn't correctly set the flag
15 | // this, along with the patch to the rncli allows to run the fabric example properly
16 | const codegenSwitch = '--enable-rnandroidprogressbar-codegen';
17 | if (process.argv.includes(codegenSwitch)) {
18 | process.argv = process.argv.filter((arg) => arg !== codegenSwitch);
19 | supportsCodegenConfig = true;
20 | }
21 |
22 | module.exports = {
23 | project: {
24 | android: {sourceDir: './example/android'},
25 | ios: {project: './example/ios/example.xcworkspace'},
26 | },
27 | dependency: {
28 | platforms: {
29 | android: supportsCodegenConfig
30 | ? {
31 | componentDescriptors: ['RNCProgressBarComponentDescriptor'],
32 | cmakeListsPath: '../android/src/main/jni/CMakeLists.txt',
33 | }
34 | : {},
35 | },
36 | },
37 | };
38 |
--------------------------------------------------------------------------------
/fabricexample/android/app/src/main/java/com/fabricexample/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.fabricexample;
2 |
3 | import com.facebook.react.ReactActivity;
4 | import com.facebook.react.ReactActivityDelegate;
5 | import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint;
6 | import com.facebook.react.defaults.DefaultReactActivityDelegate;
7 |
8 | public class MainActivity extends ReactActivity {
9 |
10 | /**
11 | * Returns the name of the main component registered from JavaScript. This is used to schedule
12 | * rendering of the component.
13 | */
14 | @Override
15 | protected String getMainComponentName() {
16 | return "fabricexample";
17 | }
18 |
19 | /**
20 | * Returns the instance of the {@link ReactActivityDelegate}. Here we use a util class {@link
21 | * DefaultReactActivityDelegate} which allows you to easily enable Fabric and Concurrent React
22 | * (aka React 18) with two boolean flags.
23 | */
24 | @Override
25 | protected ReactActivityDelegate createReactActivityDelegate() {
26 | return new DefaultReactActivityDelegate(
27 | this,
28 | getMainComponentName(),
29 | // If you opted-in for the New Architecture, we enable the Fabric Renderer.
30 | DefaultNewArchitectureEntryPoint.getFabricEnabled(), // fabricEnabled
31 | // If you opted-in for the New Architecture, we enable Concurrent React (i.e. React 18).
32 | DefaultNewArchitectureEntryPoint.getConcurrentReactEnabled() // concurrentRootEnabled
33 | );
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/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.androidprogressbar",
39 | )
40 |
41 | android_resource(
42 | name = "res",
43 | package = "com.androidprogressbar",
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/App.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015-present, Facebook, Inc.
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 | * @flow
8 | */
9 |
10 | 'use strict';
11 |
12 | import * as React from 'react';
13 | import {ProgressBar} from '../js';
14 |
15 | import RNTesterBlock from './RNTesterBlock';
16 | import RNTesterPage from './RNTesterPage';
17 |
18 | const MovingBar = (props) => {
19 | const [progress, setProgress] = React.useState(0);
20 | React.useEffect(() => {
21 | setInterval(() => {
22 | setProgress((p) => (p + 0.02) % 1);
23 | }, 50);
24 | }, []);
25 | return ;
26 | };
27 |
28 | const App: React.ComponentType<{}> = () => {
29 | return (
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 | );
48 | };
49 |
50 | export default App;
51 |
--------------------------------------------------------------------------------
/fabricexample/App.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015-present, Facebook, Inc.
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 | * @flow
8 | */
9 |
10 | 'use strict';
11 |
12 | import * as React from 'react';
13 | import {ProgressBar} from '@react-native-community/progress-bar-android';
14 |
15 | import RNTesterBlock from './RNTesterBlock';
16 | import RNTesterPage from './RNTesterPage';
17 |
18 | const MovingBar = props => {
19 | const [progress, setProgress] = React.useState(0);
20 | React.useEffect(() => {
21 | setInterval(() => {
22 | setProgress(p => (p + 0.02) % 1);
23 | }, 50);
24 | }, []);
25 | return ;
26 | };
27 |
28 | const App: React.ComponentType<{}> = () => {
29 | return (
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 | );
48 | };
49 |
50 | export default App;
51 |
--------------------------------------------------------------------------------
/example/ios/AndroidProgressBarExample/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:@"AndroidProgressBarExample"
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:@"example/index" fallbackResource:nil];
37 | #else
38 | return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
39 | #endif
40 | }
41 |
42 | @end
43 |
--------------------------------------------------------------------------------
/js/RNCProgressBarAndroid.android.js:
--------------------------------------------------------------------------------
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 | * @flow
8 | */
9 |
10 | 'use strict';
11 |
12 | import React from 'react';
13 |
14 | import ProgressBarAndroidNativeComponent from './RNCProgressBarAndroidNativeComponent';
15 | import type {ProgressBarAndroidProps} from './types';
16 | /**
17 | * React component that wraps the Android-only `ProgressBar`. This component is
18 | * used to indicate that the app is loading or there is activity in the app.
19 | *
20 | * Example:
21 | *
22 | * ```
23 | * render: function() {
24 | * var progressBar =
25 | *
26 | *
27 | * ;
28 |
29 | * return (
30 | *
35 | * );
36 | * },
37 | * ```
38 | */
39 | const ProgressBarAndroid = (
40 | props: ProgressBarAndroidProps,
41 | forwardedRef: ?React.Ref,
42 | ) => {
43 | return ;
44 | };
45 |
46 | const ProgressBarAndroidToExport = React.forwardRef(ProgressBarAndroid);
47 |
48 | ProgressBarAndroidToExport.defaultProps = {
49 | styleAttr: 'Normal',
50 | indeterminate: true,
51 | animating: true,
52 | };
53 |
54 | export default (ProgressBarAndroidToExport: ProgressBarAndroidNativeComponent);
55 |
--------------------------------------------------------------------------------
/android/src/main/jni/RNCProgressBarShadowNode.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "RNCProgressBarState.h"
4 | #include "RNCProgressBarMeasurementsManager.h"
5 | #include
6 | #include
7 | #include
8 | #include
9 | #include
10 | #include
11 |
12 | namespace facebook
13 | {
14 | namespace react
15 | {
16 |
17 | JSI_EXPORT extern const char RNCProgressBarComponentName[];
18 |
19 | class JSI_EXPORT RNCProgressBarShadowNode final : public ConcreteViewShadowNode<
20 | RNCProgressBarComponentName,
21 | RNCProgressBarProps,
22 | ViewEventEmitter,
23 | RNCProgressBarState>
24 | {
25 | public:
26 | using ConcreteViewShadowNode::ConcreteViewShadowNode;
27 | // Associates a shared `RNCProgressBarMeasurementsManager` with the node.
28 | void setProgressBarMeasurementsManager(
29 | const std::shared_ptr
30 | &measurementsManager);
31 |
32 | #pragma mark - LayoutableShadowNode
33 |
34 | Size measureContent(
35 | LayoutContext const &layoutContext,
36 | LayoutConstraints const &layoutConstraints) const override;
37 |
38 | private:
39 | std::shared_ptr measurementsManager_;
40 | };
41 |
42 | } // namespace react
43 | } // namespace facebook
44 |
--------------------------------------------------------------------------------
/example/RNTesterBlock.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015-present, Facebook, Inc.
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 | * @flow
8 | */
9 |
10 | 'use strict';
11 |
12 | import * as React from 'react';
13 | import {StyleSheet, Text, View} from 'react-native';
14 |
15 | type Props = $ReadOnly<{
16 | title?: string,
17 | description?: string,
18 | children: React.Node,
19 | }>;
20 | const RNTesterBlock: React.ComponentType = ({
21 | title,
22 | description,
23 | children,
24 | }) => {
25 | return (
26 |
27 |
28 | {title}
29 | {description ? (
30 | {description}
31 | ) : null}
32 |
33 | {children}
34 |
35 | );
36 | };
37 |
38 | const styles = StyleSheet.create({
39 | container: {
40 | borderRadius: 3,
41 | borderWidth: 0.5,
42 | borderColor: '#d6d7da',
43 | backgroundColor: '#ffffff',
44 | margin: 10,
45 | marginVertical: 5,
46 | overflow: 'hidden',
47 | },
48 | titleContainer: {
49 | borderBottomWidth: 0.5,
50 | borderTopLeftRadius: 3,
51 | borderTopRightRadius: 2.5,
52 | borderBottomColor: '#d6d7da',
53 | backgroundColor: '#f6f7f8',
54 | paddingHorizontal: 10,
55 | paddingVertical: 5,
56 | },
57 | titleText: {
58 | fontSize: 14,
59 | fontWeight: '500',
60 | },
61 | descriptionText: {
62 | fontSize: 14,
63 | },
64 | children: {
65 | margin: 10,
66 | },
67 | });
68 |
69 | export default RNTesterBlock;
70 |
--------------------------------------------------------------------------------
/fabricexample/RNTesterBlock.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015-present, Facebook, Inc.
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 | * @flow
8 | */
9 |
10 | 'use strict';
11 |
12 | import * as React from 'react';
13 | import {StyleSheet, Text, View} from 'react-native';
14 |
15 | type Props = $ReadOnly<{
16 | title?: string,
17 | description?: string,
18 | children: React.Node,
19 | }>;
20 | const RNTesterBlock: React.ComponentType = ({
21 | title,
22 | description,
23 | children,
24 | }) => {
25 | return (
26 |
27 |
28 | {title}
29 | {description ? (
30 | {description}
31 | ) : null}
32 |
33 | {children}
34 |
35 | );
36 | };
37 |
38 | const styles = StyleSheet.create({
39 | container: {
40 | borderRadius: 3,
41 | borderWidth: 0.5,
42 | borderColor: '#d6d7da',
43 | backgroundColor: '#ffffff',
44 | margin: 10,
45 | marginVertical: 5,
46 | overflow: 'hidden',
47 | },
48 | titleContainer: {
49 | borderBottomWidth: 0.5,
50 | borderTopLeftRadius: 3,
51 | borderTopRightRadius: 2.5,
52 | borderBottomColor: '#d6d7da',
53 | backgroundColor: '#f6f7f8',
54 | paddingHorizontal: 10,
55 | paddingVertical: 5,
56 | },
57 | titleText: {
58 | fontSize: 14,
59 | fontWeight: '500',
60 | },
61 | descriptionText: {
62 | fontSize: 14,
63 | },
64 | children: {
65 | margin: 10,
66 | },
67 | });
68 |
69 | export default RNTesterBlock;
70 |
--------------------------------------------------------------------------------
/android/src/main/jni/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.13)
2 | set(CMAKE_VERBOSE_MAKEFILE ON)
3 |
4 | set(LIB_LITERAL rnandroidprogressbar)
5 | set(LIB_TARGET_NAME react_codegen_${LIB_LITERAL})
6 |
7 | set(LIB_ANDROID_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../..)
8 | set(LIB_COMMON_DIR ${LIB_ANDROID_DIR}/../common/cpp)
9 | set(LIB_ANDROID_GENERATED_JNI_DIR ${LIB_ANDROID_DIR}/build/generated/source/codegen/jni)
10 | set(LIB_ANDROID_GENERATED_COMPONENTS_DIR ${LIB_ANDROID_GENERATED_JNI_DIR}/react/renderer/components/${LIB_LITERAL})
11 |
12 | add_compile_options(
13 | -fexceptions
14 | -frtti
15 | -std=c++17
16 | -Wall
17 | -Wpedantic
18 | -Wno-gnu-zero-variadic-macro-arguments
19 | )
20 |
21 | file(GLOB LIB_CUSTOM_SRCS CONFIGURE_DEPENDS *.cpp)
22 | file(GLOB LIB_CODEGEN_SRCS CONFIGURE_DEPENDS ${LIB_ANDROID_GENERATED_COMPONENTS_DIR}/*.cpp)
23 |
24 | add_library(
25 | ${LIB_TARGET_NAME}
26 | SHARED
27 | ${LIB_CUSTOM_SRCS}
28 | ${LIB_CODEGEN_SRCS}
29 | )
30 |
31 | target_include_directories(
32 | ${LIB_TARGET_NAME}
33 | PUBLIC
34 | .
35 | ${LIB_ANDROID_GENERATED_JNI_DIR}
36 | ${LIB_ANDROID_GENERATED_COMPONENTS_DIR}
37 | )
38 |
39 | target_link_libraries(
40 | ${LIB_TARGET_NAME}
41 | fbjni
42 | folly_runtime
43 | glog
44 | jsi
45 | react_codegen_rncore
46 | react_debug
47 | react_nativemodule_core
48 | react_render_core
49 | react_render_debug
50 | react_render_graphics
51 | react_render_mapbuffer
52 | rrc_view
53 | turbomodulejsijni
54 | yoga
55 | )
56 |
57 | target_compile_options(
58 | ${LIB_TARGET_NAME}
59 | PRIVATE
60 | -DLOG_TAG=\"ReactNative\"
61 | -fexceptions
62 | -frtti
63 | -std=c++17
64 | -Wall
65 | )
66 |
67 | target_include_directories(
68 | ${CMAKE_PROJECT_NAME}
69 | PUBLIC
70 | ${CMAKE_CURRENT_SOURCE_DIR}
71 | )
72 |
--------------------------------------------------------------------------------
/fabricexample/ios/fabricexample/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleDisplayName
8 | fabricexample
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 | NSExceptionDomains
30 |
31 | localhost
32 |
33 | NSExceptionAllowsInsecureHTTPLoads
34 |
35 |
36 |
37 |
38 | NSLocationWhenInUseUsageDescription
39 |
40 | UILaunchStoryboardName
41 | LaunchScreen
42 | UIRequiredDeviceCapabilities
43 |
44 | armv7
45 |
46 | UISupportedInterfaceOrientations
47 |
48 | UIInterfaceOrientationPortrait
49 | UIInterfaceOrientationLandscapeLeft
50 | UIInterfaceOrientationLandscapeRight
51 |
52 | UIViewControllerBasedStatusBarAppearance
53 |
54 |
55 |
56 |
--------------------------------------------------------------------------------
/example/RNTesterPage.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015-present, Facebook, Inc.
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 | * @flow
8 | */
9 |
10 | 'use strict';
11 |
12 | import * as React from 'react';
13 | import {ScrollView, StyleSheet, View} from 'react-native';
14 |
15 | import RNTesterTitle from './RNTesterTitle';
16 |
17 | type Props = $ReadOnly<{
18 | noScroll?: boolean,
19 | noSpacer?: boolean,
20 | title?: string,
21 | children: React.Node,
22 | }>;
23 |
24 | const RNTesterPage: React.ComponentType = ({
25 | noScroll,
26 | noSpacer,
27 | title,
28 | children,
29 | }) => {
30 | let ContentWrapper;
31 | let wrapperProps = {};
32 | if (noScroll) {
33 | ContentWrapper = ((View: any): React.ComponentType);
34 | } else {
35 | ContentWrapper = (ScrollView: React.ComponentType);
36 | // $FlowFixMe found when converting React.createClass to ES6
37 | wrapperProps.automaticallyAdjustContentInsets = !title;
38 | wrapperProps.keyboardShouldPersistTaps = 'handled';
39 | wrapperProps.keyboardDismissMode = 'interactive';
40 | }
41 |
42 | return (
43 |
44 | {title ? : null}
45 |
46 | {children}
47 | {noSpacer ? null : }
48 |
49 |
50 | );
51 | };
52 |
53 | const styles = StyleSheet.create({
54 | container: {
55 | backgroundColor: '#e9eaed',
56 | flex: 1,
57 | },
58 | spacer: {
59 | height: 270,
60 | },
61 | wrapper: {
62 | flex: 1,
63 | paddingTop: 10,
64 | },
65 | });
66 |
67 | export default RNTesterPage;
68 |
--------------------------------------------------------------------------------
/fabricexample/RNTesterPage.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015-present, Facebook, Inc.
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 | * @flow
8 | */
9 |
10 | 'use strict';
11 |
12 | import * as React from 'react';
13 | import {ScrollView, StyleSheet, View} from 'react-native';
14 |
15 | import RNTesterTitle from './RNTesterTitle';
16 |
17 | type Props = $ReadOnly<{
18 | noScroll?: boolean,
19 | noSpacer?: boolean,
20 | title?: string,
21 | children: React.Node,
22 | }>;
23 |
24 | const RNTesterPage: React.ComponentType = ({
25 | noScroll,
26 | noSpacer,
27 | title,
28 | children,
29 | }) => {
30 | let ContentWrapper;
31 | let wrapperProps = {};
32 | if (noScroll) {
33 | ContentWrapper = ((View: any): React.ComponentType);
34 | } else {
35 | ContentWrapper = (ScrollView: React.ComponentType);
36 | // $FlowFixMe found when converting React.createClass to ES6
37 | wrapperProps.automaticallyAdjustContentInsets = !title;
38 | wrapperProps.keyboardShouldPersistTaps = 'handled';
39 | wrapperProps.keyboardDismissMode = 'interactive';
40 | }
41 |
42 | return (
43 |
44 | {title ? : null}
45 |
46 | {children}
47 | {noSpacer ? null : }
48 |
49 |
50 | );
51 | };
52 |
53 | const styles = StyleSheet.create({
54 | container: {
55 | backgroundColor: '#e9eaed',
56 | flex: 1,
57 | },
58 | spacer: {
59 | height: 270,
60 | },
61 | wrapper: {
62 | flex: 1,
63 | paddingTop: 10,
64 | },
65 | });
66 |
67 | export default RNTesterPage;
68 |
--------------------------------------------------------------------------------
/example/ios/AndroidProgressBarExample-tvOS/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 | APPL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 | LSRequiresIPhoneOS
24 |
25 | UILaunchStoryboardName
26 | LaunchScreen
27 | UIRequiredDeviceCapabilities
28 |
29 | armv7
30 |
31 | UISupportedInterfaceOrientations
32 |
33 | UIInterfaceOrientationPortrait
34 | UIInterfaceOrientationLandscapeLeft
35 | UIInterfaceOrientationLandscapeRight
36 |
37 | UIViewControllerBasedStatusBarAppearance
38 |
39 | NSLocationWhenInUseUsageDescription
40 |
41 | NSAppTransportSecurity
42 |
43 |
44 | NSExceptionDomains
45 |
46 | localhost
47 |
48 | NSExceptionAllowsInsecureHTTPLoads
49 |
50 |
51 |
52 |
53 |
54 |
55 |
--------------------------------------------------------------------------------
/android/src/paper/java/com/facebook/react/viewmanagers/RNCProgressBarManagerDelegate.java:
--------------------------------------------------------------------------------
1 | /**
2 | * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
3 | *
4 | * Do not edit this file as changes may cause incorrect behavior and will be lost
5 | * once the code is regenerated.
6 | *
7 | * @generated by codegen project: GeneratePropsJavaDelegate.js
8 | */
9 |
10 | package com.facebook.react.viewmanagers;
11 |
12 | import android.view.View;
13 | import androidx.annotation.Nullable;
14 | import com.facebook.react.bridge.ColorPropConverter;
15 | import com.facebook.react.uimanager.BaseViewManagerDelegate;
16 | import com.facebook.react.uimanager.BaseViewManagerInterface;
17 |
18 | public class RNCProgressBarManagerDelegate & RNCProgressBarManagerInterface> extends BaseViewManagerDelegate {
19 | public RNCProgressBarManagerDelegate(U viewManager) {
20 | super(viewManager);
21 | }
22 | @Override
23 | public void setProperty(T view, String propName, @Nullable Object value) {
24 | switch (propName) {
25 | case "styleAttr":
26 | mViewManager.setStyleAttr(view, value == null ? null : (String) value);
27 | break;
28 | case "indeterminate":
29 | mViewManager.setIndeterminate(view, value == null ? false : (boolean) value);
30 | break;
31 | case "progress":
32 | mViewManager.setProgress(view, value == null ? 0f : ((Double) value).doubleValue());
33 | break;
34 | case "animating":
35 | mViewManager.setAnimating(view, value == null ? true : (boolean) value);
36 | break;
37 | case "color":
38 | mViewManager.setColor(view, ColorPropConverter.getColor(value, view.getContext()));
39 | break;
40 | default:
41 | super.setProperty(view, propName, value);
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/android/src/main/jni/react/renderer/components/rnandroidprogressbar/RNCProgressBarComponentDescriptor.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 | #include "RNCProgressBarShadowNode.h"
5 | #include "RNCProgressBarMeasurementsManager.h"
6 | #include
7 | #include
8 |
9 | namespace facebook
10 | {
11 | namespace react
12 | {
13 |
14 | class RNCProgressBarComponentDescriptor final
15 | : public ConcreteComponentDescriptor
16 | {
17 | public:
18 | RNCProgressBarComponentDescriptor(
19 | ComponentDescriptorParameters const ¶meters)
20 | : ConcreteComponentDescriptor(parameters),
21 | measurementsManager_(std::make_shared(
22 | contextContainer_)) {}
23 |
24 | void adopt(ShadowNode::Unshared const &shadowNode) const override
25 | {
26 | ConcreteComponentDescriptor::adopt(shadowNode);
27 |
28 | assert(std::dynamic_pointer_cast(shadowNode));
29 | auto barShadowNode =
30 | std::static_pointer_cast(shadowNode);
31 |
32 | // `RNCProgressBarShadowNode` uses `RNCProgressBarMeasurementsManager` to
33 | // provide measurements to Yoga.
34 | barShadowNode->setProgressBarMeasurementsManager(
35 | measurementsManager_);
36 |
37 | // All `RNCProgressBarShadowNode`s must have leaf Yoga nodes with properly
38 | // setup measure function.
39 | barShadowNode->enableMeasurement();
40 | }
41 |
42 | private:
43 | const std::shared_ptr measurementsManager_;
44 | };
45 |
46 | } // namespace react
47 | } // namespace facebook
48 |
--------------------------------------------------------------------------------
/example/ios/AndroidProgressBarExample/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleDisplayName
8 | AndroidProgressBarExample
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 | NSLocationWhenInUseUsageDescription
28 |
29 | UILaunchStoryboardName
30 | LaunchScreen
31 | UIRequiredDeviceCapabilities
32 |
33 | armv7
34 |
35 | UISupportedInterfaceOrientations
36 |
37 | UIInterfaceOrientationPortrait
38 | UIInterfaceOrientationLandscapeLeft
39 | UIInterfaceOrientationLandscapeRight
40 |
41 | UIViewControllerBasedStatusBarAppearance
42 |
43 | NSLocationWhenInUseUsageDescription
44 |
45 | NSAppTransportSecurity
46 |
47 |
48 | NSAllowsArbitraryLoads
49 |
50 | NSExceptionDomains
51 |
52 | localhost
53 |
54 | NSExceptionAllowsInsecureHTTPLoads
55 |
56 |
57 |
58 |
59 |
60 |
61 |
--------------------------------------------------------------------------------
/fabricexample/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: -Xmx512m -XX:MaxMetaspaceSize=256m
13 | org.gradle.jvmargs=-Xmx2048m -XX:MaxMetaspaceSize=512m
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 | # AndroidX package structure to make it clearer which packages are bundled with the
21 | # Android operating system, and which are packaged with your app's APK
22 | # https://developer.android.com/topic/libraries/support-library/androidx-rn
23 | android.useAndroidX=true
24 | # Automatically convert third-party libraries to use AndroidX
25 | android.enableJetifier=true
26 |
27 | # Version of flipper SDK to use with React Native
28 | FLIPPER_VERSION=0.125.0
29 |
30 | # Use this property to specify which architecture you want to build.
31 | # You can also override it from the CLI using
32 | # ./gradlew -PreactNativeArchitectures=x86_64
33 | reactNativeArchitectures=armeabi-v7a,arm64-v8a,x86,x86_64
34 |
35 | # Use this property to enable support to the new architecture.
36 | # This will allow you to use TurboModules and the Fabric render in
37 | # your application. You should enable this flag either if you want
38 | # to write custom TurboModules/Fabric components OR use libraries that
39 | # are providing them.
40 | newArchEnabled=true
41 |
42 | # Use this property to enable or disable the Hermes JS engine.
43 | # If set to false, you will be using JSC instead.
44 | hermesEnabled=true
--------------------------------------------------------------------------------
/fabricexample/android/app/src/main/res/drawable/rn_edit_text_material.xml:
--------------------------------------------------------------------------------
1 |
2 |
16 |
21 |
22 |
23 |
32 |
33 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/.flowconfig:
--------------------------------------------------------------------------------
1 | [ignore]
2 | ; We fork some components by platform
3 | .*/*[.]android.js
4 |
5 | ; Ignore templates for 'react-native init'
6 | /template/.*
7 |
8 | ; Ignore the Dangerfile
9 | /bots/dangerfile.js
10 |
11 | ; Ignore "BUCK" generated dirs
12 | /\.buckd/
13 |
14 | ; These should not be required directly
15 | ; require from fbjs/lib instead: require('fbjs/lib/warning')
16 | .*/node_modules/warning/.*
17 |
18 | ; Flow doesn't support platforms
19 | .*/Libraries/Utilities/LoadingView.js
20 |
21 | [untyped]
22 | .*/node_modules/@react-native-community/cli/.*/.*
23 |
24 | [include]
25 |
26 | [declarations]
27 | .*/node_modules/.*
28 |
29 | [libs]
30 | interface.js
31 | flow/
32 |
33 | [options]
34 | emoji=true
35 |
36 | esproposal.optional_chaining=enable
37 | esproposal.nullish_coalescing=enable
38 |
39 | exact_by_default=true
40 |
41 | module.file_ext=.js
42 | module.file_ext=.json
43 | module.file_ext=.ios.js
44 |
45 | munge_underscores=true
46 |
47 | module.name_mapper='^react-native$' -> '/index.js'
48 | module.name_mapper='^react-native/\(.*\)$' -> '/\1'
49 | 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\)$' -> '/Libraries/Image/RelativeImageStub'
50 |
51 | suppress_type=$FlowIssue
52 | suppress_type=$FlowFixMe
53 | suppress_type=$FlowFixMeProps
54 | suppress_type=$FlowFixMeState
55 | suppress_type=$FlowFixMeEmpty
56 |
57 | experimental.abstract_locations=true
58 |
59 | [lints]
60 | sketchy-null-number=warn
61 | sketchy-null-mixed=warn
62 | sketchy-number=warn
63 | untyped-type-import=warn
64 | nonstrict-import=warn
65 | deprecated-type=warn
66 | unsafe-getters-setters=warn
67 | unnecessary-invariant=warn
68 | signature-verification-failure=warn
69 | deprecated-utility=error
70 | unsafe-addition=error
71 |
72 | [strict]
73 | deprecated-type
74 | nonstrict-import
75 | sketchy-null
76 | unclear-type
77 | unsafe-getters-setters
78 | untyped-import
79 | untyped-type-import
80 |
81 | [version]
82 | ^0.129.0
83 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@react-native-community/progress-bar-android",
3 | "version": "1.0.4",
4 | "description": "Progress Bar component for React Native",
5 | "main": "./js/index.js",
6 | "types": "./js/index.d.ts",
7 | "scripts": {
8 | "start": "react-native start",
9 | "android": "react-native run-android",
10 | "test": "jest",
11 | "lint": "eslint 'js/**/*.js' 'example/**/*.js'",
12 | "type-check": "tsc --noEmit",
13 | "flow": "flow"
14 | },
15 | "homepage": "https://github.com/react-native-community/react-native-progress-bar-android#readme",
16 | "repository": {
17 | "type": "git",
18 | "url": "https://github.com/react-native-community/react-native-progress-bar-android.git"
19 | },
20 | "keywords": [
21 | "react-native",
22 | "react native",
23 | "androidprogressbar",
24 | "android",
25 | "progress-bar"
26 | ],
27 | "files": [
28 | "android",
29 | "ios",
30 | "js",
31 | "react-native-progress-bar-android.podspec",
32 | "react-native.config.js"
33 | ],
34 | "author": "Wagner Maciel ",
35 | "contributors": [
36 | "Vivian Fang ",
37 | "Jesse Katsumata "
38 | ],
39 | "license": "MIT",
40 | "peerDependencies": {
41 | "react": ">=16.8.6",
42 | "react-native": ">=0.60.0"
43 | },
44 | "dependencies": {},
45 | "devDependencies": {
46 | "@babel/core": "^7.10.3",
47 | "@babel/runtime": "^7.10.3",
48 | "@react-native-community/eslint-config": "^2.0.0",
49 | "@types/react-native": "^0.62.2",
50 | "babel-jest": "^25.1.0",
51 | "eslint": "^7.12.1",
52 | "flow-bin": "^0.129.0",
53 | "jest": "^25.2.3",
54 | "metro-react-native-babel-preset": "0.63.0",
55 | "react": "16.13.1",
56 | "react-native": "^0.63.3",
57 | "react-test-renderer": "16.13.1",
58 | "typescript": "^3.9.6"
59 | },
60 | "jest": {
61 | "preset": "react-native"
62 | },
63 | "publishConfig": {
64 | "access": "public"
65 | },
66 | "codegenConfig": {
67 | "name": "rnandroidprogressbar",
68 | "type": "components",
69 | "jsSrcsDir": "./js",
70 | "android": {
71 | "javaPackageName": "com.reactnativecommunity.androidprogressbar"
72 | }
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/fabricexample/android/app/src/main/java/com/fabricexample/MainApplication.java:
--------------------------------------------------------------------------------
1 | package com.fabricexample;
2 |
3 | import android.app.Application;
4 | import com.facebook.react.PackageList;
5 | import com.facebook.react.ReactApplication;
6 | import com.facebook.react.ReactNativeHost;
7 | import com.facebook.react.ReactPackage;
8 | import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint;
9 | import com.facebook.react.defaults.DefaultReactNativeHost;
10 | import com.facebook.soloader.SoLoader;
11 | import java.util.List;
12 |
13 | public class MainApplication extends Application implements ReactApplication {
14 |
15 | private final ReactNativeHost mReactNativeHost =
16 | new DefaultReactNativeHost(this) {
17 | @Override
18 | public boolean getUseDeveloperSupport() {
19 | return BuildConfig.DEBUG;
20 | }
21 |
22 | @Override
23 | protected List getPackages() {
24 | @SuppressWarnings("UnnecessaryLocalVariable")
25 | List packages = new PackageList(this).getPackages();
26 | // Packages that cannot be autolinked yet can be added manually here, for example:
27 | // packages.add(new MyReactNativePackage());
28 | return packages;
29 | }
30 |
31 | @Override
32 | protected String getJSMainModuleName() {
33 | return "index";
34 | }
35 |
36 | @Override
37 | protected boolean isNewArchEnabled() {
38 | return BuildConfig.IS_NEW_ARCHITECTURE_ENABLED;
39 | }
40 |
41 | @Override
42 | protected Boolean isHermesEnabled() {
43 | return BuildConfig.IS_HERMES_ENABLED;
44 | }
45 | };
46 |
47 | @Override
48 | public ReactNativeHost getReactNativeHost() {
49 | return mReactNativeHost;
50 | }
51 |
52 | @Override
53 | public void onCreate() {
54 | super.onCreate();
55 | SoLoader.init(this, /* native exopackage */ false);
56 | if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
57 | // If you opted-in for the New Architecture, we load the native entry point for this app.
58 | DefaultNewArchitectureEntryPoint.load();
59 | }
60 | ReactNativeFlipper.initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/example/ios/AndroidProgressBarExampleTests/AndroidProgressBarExampleTests.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 AndroidProgressBarExampleTests : XCTestCase
18 |
19 | @end
20 |
21 | @implementation AndroidProgressBarExampleTests
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 |
--------------------------------------------------------------------------------
/fabricexample/ios/fabricexampleTests/fabricexampleTests.m:
--------------------------------------------------------------------------------
1 | #import
2 | #import
3 |
4 | #import
5 | #import
6 |
7 | #define TIMEOUT_SECONDS 600
8 | #define TEXT_TO_LOOK_FOR @"Welcome to React"
9 |
10 | @interface fabricexampleTests : XCTestCase
11 |
12 | @end
13 |
14 | @implementation fabricexampleTests
15 |
16 | - (BOOL)findSubviewInView:(UIView *)view matching:(BOOL (^)(UIView *view))test
17 | {
18 | if (test(view)) {
19 | return YES;
20 | }
21 | for (UIView *subview in [view subviews]) {
22 | if ([self findSubviewInView:subview matching:test]) {
23 | return YES;
24 | }
25 | }
26 | return NO;
27 | }
28 |
29 | - (void)testRendersWelcomeScreen
30 | {
31 | UIViewController *vc = [[[RCTSharedApplication() delegate] window] rootViewController];
32 | NSDate *date = [NSDate dateWithTimeIntervalSinceNow:TIMEOUT_SECONDS];
33 | BOOL foundElement = NO;
34 |
35 | __block NSString *redboxError = nil;
36 | #ifdef DEBUG
37 | RCTSetLogFunction(
38 | ^(RCTLogLevel level, RCTLogSource source, NSString *fileName, NSNumber *lineNumber, NSString *message) {
39 | if (level >= RCTLogLevelError) {
40 | redboxError = message;
41 | }
42 | });
43 | #endif
44 |
45 | while ([date timeIntervalSinceNow] > 0 && !foundElement && !redboxError) {
46 | [[NSRunLoop mainRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]];
47 | [[NSRunLoop mainRunLoop] runMode:NSRunLoopCommonModes beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]];
48 |
49 | foundElement = [self findSubviewInView:vc.view
50 | matching:^BOOL(UIView *view) {
51 | if ([view.accessibilityLabel isEqualToString:TEXT_TO_LOOK_FOR]) {
52 | return YES;
53 | }
54 | return NO;
55 | }];
56 | }
57 |
58 | #ifdef DEBUG
59 | RCTSetLogFunction(RCTDefaultLogFunction);
60 | #endif
61 |
62 | XCTAssertNil(redboxError, @"RedBox error: %@", redboxError);
63 | XCTAssertTrue(foundElement, @"Couldn't find element with text '%@' in %d seconds", TEXT_TO_LOOK_FOR, TIMEOUT_SECONDS);
64 | }
65 |
66 | @end
67 |
--------------------------------------------------------------------------------
/fabricexample/ios/Podfile:
--------------------------------------------------------------------------------
1 | require_relative '../node_modules/react-native/scripts/react_native_pods'
2 | require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
3 |
4 | platform :ios, min_ios_version_supported
5 | prepare_react_native_project!
6 |
7 | # If you are using a `react-native-flipper` your iOS build will fail when `NO_FLIPPER=1` is set.
8 | # because `react-native-flipper` depends on (FlipperKit,...) that will be excluded
9 | #
10 | # To fix this you can also exclude `react-native-flipper` using a `react-native.config.js`
11 | # ```js
12 | # module.exports = {
13 | # dependencies: {
14 | # ...(process.env.NO_FLIPPER ? { 'react-native-flipper': { platforms: { ios: null } } } : {}),
15 | # ```
16 | flipper_config = ENV['NO_FLIPPER'] == "1" ? FlipperConfiguration.disabled : FlipperConfiguration.enabled
17 |
18 | linkage = ENV['USE_FRAMEWORKS']
19 | if linkage != nil
20 | Pod::UI.puts "Configuring Pod with #{linkage}ally linked Frameworks".green
21 | use_frameworks! :linkage => linkage.to_sym
22 | end
23 |
24 | target 'fabricexample' do
25 | config = use_native_modules!
26 |
27 | # Flags change depending on the env values.
28 | flags = get_default_flags()
29 |
30 | use_react_native!(
31 | :path => config[:reactNativePath],
32 | # Hermes is now enabled by default. Disable by setting this flag to false.
33 | # Upcoming versions of React Native may rely on get_default_flags(), but
34 | # we make it explicit here to aid in the React Native upgrade process.
35 | :hermes_enabled => flags[:hermes_enabled],
36 | :fabric_enabled => flags[:fabric_enabled],
37 | # Enables Flipper.
38 | #
39 | # Note that if you have use_frameworks! enabled, Flipper will not work and
40 | # you should disable the next line.
41 | :flipper_configuration => flipper_config,
42 | # An absolute path to your application root.
43 | :app_path => "#{Pod::Config.instance.installation_root}/.."
44 | )
45 |
46 | target 'fabricexampleTests' do
47 | inherit! :complete
48 | # Pods for testing
49 | end
50 |
51 | post_install do |installer|
52 | react_native_post_install(
53 | installer,
54 | # Set `mac_catalyst_enabled` to `true` in order to apply patches
55 | # necessary for Mac Catalyst builds
56 | :mac_catalyst_enabled => false
57 | )
58 | __apply_Xcode_12_5_M1_post_install_workaround(installer)
59 | end
60 | end
61 |
--------------------------------------------------------------------------------
/example/android/app/src/main/java/com/androidprogressbar/MainApplication.java:
--------------------------------------------------------------------------------
1 | package com.androidprogressbar;
2 |
3 | import android.app.Application;
4 | import android.content.Context;
5 | import com.facebook.react.PackageList;
6 | import com.facebook.react.ReactApplication;
7 | import com.facebook.react.ReactNativeHost;
8 | import com.facebook.react.ReactInstanceManager;
9 | import com.facebook.react.ReactPackage;
10 | import com.facebook.soloader.SoLoader;
11 | import com.reactnativecommunity.androidprogressbar.RNCProgressBarPackage;
12 | import java.lang.reflect.InvocationTargetException;
13 | import java.util.List;
14 |
15 | public class MainApplication extends Application implements ReactApplication {
16 |
17 | private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
18 | @Override
19 | public boolean getUseDeveloperSupport() {
20 | return BuildConfig.DEBUG;
21 | }
22 |
23 | @Override
24 | protected List getPackages() {
25 | @SuppressWarnings("UnnecessaryLocalVariable")
26 | List packages = new PackageList(this).getPackages();
27 | // Packages that cannot be autolinked yet can be added manually here, for
28 | // example:
29 | // packages.add(new MyReactNativePackage());
30 | packages.add(new RNCProgressBarPackage());
31 | return packages;
32 | }
33 |
34 | @Override
35 | protected String getJSMainModuleName() {
36 | return "index";
37 | }
38 | };
39 |
40 | @Override
41 | public ReactNativeHost getReactNativeHost() {
42 | return mReactNativeHost;
43 | }
44 |
45 | @Override
46 | public void onCreate() {
47 | super.onCreate();
48 | SoLoader.init(this, /* native exopackage */ false);
49 | initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
50 | }
51 |
52 | /**
53 | * Loads Flipper in React Native templates.
54 | *
55 | * @param context
56 | */
57 | private static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) {
58 | if (BuildConfig.DEBUG) {
59 | try {
60 | /*
61 | * We use reflection here to pick up the class that initializes Flipper, since
62 | * Flipper library is not available in release mode
63 | */
64 | Class> aClass = Class.forName("com.androidprogressbar.ReactNativeFlipper");
65 | aClass.getMethod("initializeFlipper", Context.class).invoke(null, context, reactInstanceManager);
66 | } catch (ClassNotFoundException e) {
67 | e.printStackTrace();
68 | } catch (NoSuchMethodException e) {
69 | e.printStackTrace();
70 | } catch (IllegalAccessException e) {
71 | e.printStackTrace();
72 | } catch (InvocationTargetException e) {
73 | e.printStackTrace();
74 | }
75 | }
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/android/src/main/java/com/reactnativecommunity/androidprogressbar/ProgressBarShadowNode.java:
--------------------------------------------------------------------------------
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 | package com.reactnativecommunity.androidprogressbar;
9 |
10 | import android.util.SparseIntArray;
11 | import android.view.View;
12 | import android.view.ViewGroup;
13 | import android.widget.ProgressBar;
14 | import com.facebook.react.uimanager.LayoutShadowNode;
15 | import com.facebook.react.uimanager.annotations.ReactProp;
16 | import com.facebook.yoga.YogaMeasureFunction;
17 | import com.facebook.yoga.YogaMeasureMode;
18 | import com.facebook.yoga.YogaMeasureOutput;
19 | import com.facebook.yoga.YogaNode;
20 | import java.util.HashSet;
21 | import java.util.Set;
22 | import javax.annotation.Nullable;
23 |
24 | /**
25 | * Node responsible for holding the style of the ProgressBar, see under
26 | * {@link android.R.attr.progressBarStyle} for possible styles. ReactProgressBarViewManager
27 | * manages how this style is applied to the ProgressBar.
28 | */
29 | public class ProgressBarShadowNode extends LayoutShadowNode implements YogaMeasureFunction {
30 |
31 | private String mStyle = ReactProgressBarViewManager.DEFAULT_STYLE;
32 |
33 | private final SparseIntArray mHeight;
34 | private final SparseIntArray mWidth;
35 | private final Set mMeasured;
36 |
37 | public ProgressBarShadowNode() {
38 | mHeight = new SparseIntArray();
39 | mWidth = new SparseIntArray();
40 | mMeasured = new HashSet<>();
41 | initMeasureFunction();
42 | }
43 |
44 | private void initMeasureFunction() {
45 | setMeasureFunction(this);
46 | }
47 |
48 | public @Nullable String getStyle() {
49 | return mStyle;
50 | }
51 |
52 | @ReactProp(name = ReactProgressBarViewManager.PROP_STYLE)
53 | public void setStyle(@Nullable String style) {
54 | mStyle = style == null ? ReactProgressBarViewManager.DEFAULT_STYLE : style;
55 | }
56 |
57 | @Override
58 | public long measure(
59 | YogaNode node,
60 | float width,
61 | YogaMeasureMode widthMode,
62 | float height,
63 | YogaMeasureMode heightMode) {
64 | final int style = ReactProgressBarViewManager.getStyleFromString(getStyle());
65 | if (!mMeasured.contains(style)) {
66 | ProgressBar progressBar = ReactProgressBarViewManager.createProgressBar(getThemedContext(), style);
67 | final int spec = View.MeasureSpec.makeMeasureSpec(
68 | ViewGroup.LayoutParams.WRAP_CONTENT,
69 | View.MeasureSpec.UNSPECIFIED);
70 | progressBar.measure(spec, spec);
71 | mHeight.put(style, progressBar.getMeasuredHeight());
72 | mWidth.put(style, progressBar.getMeasuredWidth());
73 | mMeasured.add(style);
74 | }
75 |
76 | return YogaMeasureOutput.make(mWidth.get(style), mHeight.get(style));
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/fabricexample/Gemfile.lock:
--------------------------------------------------------------------------------
1 | GEM
2 | remote: https://rubygems.org/
3 | specs:
4 | CFPropertyList (3.0.5)
5 | rexml
6 | activesupport (6.1.7.1)
7 | concurrent-ruby (~> 1.0, >= 1.0.2)
8 | i18n (>= 1.6, < 2)
9 | minitest (>= 5.1)
10 | tzinfo (~> 2.0)
11 | zeitwerk (~> 2.3)
12 | addressable (2.8.1)
13 | public_suffix (>= 2.0.2, < 6.0)
14 | algoliasearch (1.27.5)
15 | httpclient (~> 2.8, >= 2.8.3)
16 | json (>= 1.5.1)
17 | atomos (0.1.3)
18 | claide (1.1.0)
19 | cocoapods (1.12.1)
20 | addressable (~> 2.8)
21 | claide (>= 1.0.2, < 2.0)
22 | cocoapods-core (= 1.12.1)
23 | cocoapods-deintegrate (>= 1.0.3, < 2.0)
24 | cocoapods-downloader (>= 1.6.0, < 2.0)
25 | cocoapods-plugins (>= 1.0.0, < 2.0)
26 | cocoapods-search (>= 1.0.0, < 2.0)
27 | cocoapods-trunk (>= 1.6.0, < 2.0)
28 | cocoapods-try (>= 1.1.0, < 2.0)
29 | colored2 (~> 3.1)
30 | escape (~> 0.0.4)
31 | fourflusher (>= 2.3.0, < 3.0)
32 | gh_inspector (~> 1.0)
33 | molinillo (~> 0.8.0)
34 | nap (~> 1.0)
35 | ruby-macho (>= 2.3.0, < 3.0)
36 | xcodeproj (>= 1.21.0, < 2.0)
37 | cocoapods-core (1.12.1)
38 | activesupport (>= 5.0, < 8)
39 | addressable (~> 2.8)
40 | algoliasearch (~> 1.0)
41 | concurrent-ruby (~> 1.1)
42 | fuzzy_match (~> 2.0.4)
43 | nap (~> 1.0)
44 | netrc (~> 0.11)
45 | public_suffix (~> 4.0)
46 | typhoeus (~> 1.0)
47 | cocoapods-deintegrate (1.0.5)
48 | cocoapods-downloader (1.6.3)
49 | cocoapods-plugins (1.0.0)
50 | nap
51 | cocoapods-search (1.0.1)
52 | cocoapods-trunk (1.6.0)
53 | nap (>= 0.8, < 2.0)
54 | netrc (~> 0.11)
55 | cocoapods-try (1.2.0)
56 | colored2 (3.1.2)
57 | concurrent-ruby (1.1.10)
58 | escape (0.0.4)
59 | ethon (0.16.0)
60 | ffi (>= 1.15.0)
61 | ffi (1.15.5)
62 | fourflusher (2.3.1)
63 | fuzzy_match (2.0.4)
64 | gh_inspector (1.1.3)
65 | httpclient (2.8.3)
66 | i18n (1.12.0)
67 | concurrent-ruby (~> 1.0)
68 | json (2.3.0)
69 | minitest (5.13.0)
70 | molinillo (0.8.0)
71 | nanaimo (0.3.0)
72 | nap (1.1.0)
73 | netrc (0.11.0)
74 | public_suffix (4.0.7)
75 | rexml (3.2.5)
76 | ruby-macho (2.5.1)
77 | typhoeus (1.4.0)
78 | ethon (>= 0.9.0)
79 | tzinfo (2.0.5)
80 | concurrent-ruby (~> 1.0)
81 | xcodeproj (1.22.0)
82 | CFPropertyList (>= 2.3.3, < 4.0)
83 | atomos (~> 0.1.3)
84 | claide (>= 1.0.2, < 2.0)
85 | colored2 (~> 3.1)
86 | nanaimo (~> 0.3.0)
87 | rexml (~> 3.2.4)
88 | zeitwerk (2.6.6)
89 |
90 | PLATFORMS
91 | ruby
92 |
93 | DEPENDENCIES
94 | cocoapods (>= 1.11.3)
95 |
96 | RUBY VERSION
97 | ruby 2.7.5p203
98 |
99 | BUNDLED WITH
100 | 2.1.4
101 |
--------------------------------------------------------------------------------
/fabricexample/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 https://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 Resolve any "." and ".." in APP_HOME to make it shorter.
33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
34 |
35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
37 |
38 | @rem Find java.exe
39 | if defined JAVA_HOME goto findJavaFromJavaHome
40 |
41 | set JAVA_EXE=java.exe
42 | %JAVA_EXE% -version >NUL 2>&1
43 | if "%ERRORLEVEL%" == "0" goto execute
44 |
45 | echo.
46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
47 | echo.
48 | echo Please set the JAVA_HOME variable in your environment to match the
49 | echo location of your Java installation.
50 |
51 | goto fail
52 |
53 | :findJavaFromJavaHome
54 | set JAVA_HOME=%JAVA_HOME:"=%
55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
56 |
57 | if exist "%JAVA_EXE%" goto execute
58 |
59 | echo.
60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
61 | echo.
62 | echo Please set the JAVA_HOME variable in your environment to match the
63 | echo location of your Java installation.
64 |
65 | goto fail
66 |
67 | :execute
68 | @rem Setup the command line
69 |
70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
71 |
72 |
73 | @rem Execute Gradle
74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
75 |
76 | :end
77 | @rem End local scope for the variables with windows NT shell
78 | if "%ERRORLEVEL%"=="0" goto mainEnd
79 |
80 | :fail
81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
82 | rem the _cmd.exe /c_ return code!
83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
84 | exit /b 1
85 |
86 | :mainEnd
87 | if "%OS%"=="Windows_NT" endlocal
88 |
89 | :omega
90 |
--------------------------------------------------------------------------------
/.github/workflows/ci.yml:
--------------------------------------------------------------------------------
1 | name: Build
2 | on: pull_request
3 |
4 | jobs:
5 | lint:
6 | runs-on: ubuntu-latest
7 | strategy:
8 | matrix:
9 | node-version: [16]
10 | steps:
11 | - uses: actions/checkout@v2
12 | - uses: actions/setup-node@v1
13 | with:
14 | node-version: ${{ matrix.node-version }}
15 | - name: Get yarn cache
16 | id: yarn-cache
17 | run: echo "::set-output name=dir::$(yarn cache dir)"
18 | - uses: actions/cache@v2
19 | with:
20 | path: ${{ steps.yarn-cache.outputs.dir }}
21 | key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
22 | - name: Install Dependencies
23 | run: yarn
24 | - name: ESLint Checks
25 | run: yarn lint
26 | flow:
27 | runs-on: ubuntu-latest
28 | strategy:
29 | matrix:
30 | node-version: [16]
31 | steps:
32 | - uses: actions/checkout@v2
33 | - uses: actions/setup-node@v1
34 | with:
35 | node-version: ${{ matrix.node-version }}
36 | - name: Get yarn cache
37 | id: yarn-cache
38 | run: echo "::set-output name=dir::$(yarn cache dir)"
39 | - uses: actions/cache@v2
40 | with:
41 | path: ${{ steps.yarn-cache.outputs.dir }}
42 | key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
43 | - name: Install Dependencies
44 | run: yarn
45 | - name: Install Dependencies in Fabric Example
46 | run: cd fabricexample && yarn
47 | - name: FlowType Check
48 | run: yarn flow
49 | tsc:
50 | runs-on: ubuntu-latest
51 | strategy:
52 | matrix:
53 | node-version: [16]
54 | steps:
55 | - uses: actions/checkout@v2
56 | - uses: actions/setup-node@v1
57 | with:
58 | node-version: ${{ matrix.node-version }}
59 | - name: Get yarn cache
60 | id: yarn-cache
61 | run: echo "::set-output name=dir::$(yarn cache dir)"
62 | - uses: actions/cache@v2
63 | with:
64 | path: ${{ steps.yarn-cache.outputs.dir }}
65 | key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
66 | - name: Install Dependencies
67 | run: yarn
68 | - name: TypeScript type check
69 | run: yarn type-check
70 | android:
71 | runs-on: ubuntu-latest
72 | strategy:
73 | matrix:
74 | node-version: [16]
75 | steps:
76 | - uses: actions/checkout@v2
77 | - uses: actions/setup-node@v1
78 | with:
79 | node-version: ${{ matrix.node-version }}
80 | - name: Get yarn cache
81 | id: yarn-cache
82 | run: echo "::set-output name=dir::$(yarn cache dir)"
83 | - uses: actions/cache@v2
84 | with:
85 | path: ${{ steps.yarn-cache.outputs.dir }}
86 | key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
87 | - name: Install Dependencies
88 | run: yarn
89 | - name: Build Android Example App and Library
90 | run: cd example/android && ./gradlew clean assembleDebug
91 |
--------------------------------------------------------------------------------
/android/src/main/jni/RNCProgressBarMeasurementsManager.cpp:
--------------------------------------------------------------------------------
1 | #include "RNCProgressBarMeasurementsManager.h"
2 |
3 | #include
4 | #include
5 | #include
6 | #include
7 |
8 | using namespace facebook::jni;
9 |
10 | namespace facebook
11 | {
12 | namespace react
13 | {
14 | // Based on react-native/ReactCommon/react/renderer/components/switch/androidswitch/react/renderer/components/androidswitch/AndroidSwitchMeasurementsManager.cpp
15 | // This class is shared between the shadow nodes and allows us to measure the progress bar.
16 | // It calls the measure method of the ReactProgressBarViewManager.java which is responsible for the actual
17 | // measurement of the progress bar.
18 | Size RNCProgressBarMeasurementsManager::measure(
19 | SurfaceId surfaceId,
20 | LayoutConstraints layoutConstraints,
21 | RNCProgressBarProps props) const
22 | {
23 | {
24 | std::lock_guard lock(mutex_);
25 | if (cachedMeasurements_.find(props.styleAttr) != cachedMeasurements_.end())
26 | {
27 | return cachedMeasurements_[props.styleAttr];
28 | }
29 | }
30 |
31 | const jni::global_ref &fabricUIManager =
32 | contextContainer_->at>("FabricUIManager");
33 |
34 | static auto measure =
35 | jni::findClassStatic("com/facebook/react/fabric/FabricUIManager")
36 | ->getMethod("measure");
46 |
47 | auto minimumSize = layoutConstraints.minimumSize;
48 | auto maximumSize = layoutConstraints.maximumSize;
49 |
50 | local_ref componentName = make_jstring("RNCProgressBar");
51 |
52 | folly::dynamic serializedProps = folly::dynamic::object();
53 | serializedProps["styleAttr"] = props.styleAttr;
54 |
55 | local_ref propsRNM =
56 | ReadableNativeMap::newObjectCxxArgs(serializedProps);
57 | local_ref propsRM =
58 | make_local(reinterpret_cast(propsRNM.get()));
59 |
60 | auto measurement = yogaMeassureToSize(measure(
61 | fabricUIManager,
62 | surfaceId,
63 | componentName.get(),
64 | nullptr,
65 | propsRM.get(),
66 | nullptr,
67 | minimumSize.width,
68 | maximumSize.width,
69 | minimumSize.height,
70 | maximumSize.height));
71 |
72 | std::lock_guard lock(mutex_);
73 | cachedMeasurements_[props.styleAttr] = measurement;
74 | return measurement;
75 | }
76 |
77 | } // namespace react
78 | } // namespace facebook
79 |
--------------------------------------------------------------------------------
/android/src/main/java/com/reactnativecommunity/androidprogressbar/ProgressBarContainerView.java:
--------------------------------------------------------------------------------
1 | // Copyright (c) Facebook, Inc. and its affiliates.
2 |
3 | // This source code is licensed under the MIT license found in the
4 | // LICENSE file in the root directory of this source tree.
5 |
6 | package com.reactnativecommunity.androidprogressbar;
7 |
8 | import javax.annotation.Nullable;
9 |
10 | import android.content.Context;
11 | import android.graphics.PorterDuff;
12 | import android.graphics.drawable.Drawable;
13 | import android.view.View;
14 | import android.view.ViewGroup;
15 | import android.widget.FrameLayout;
16 | import android.widget.ProgressBar;
17 |
18 | import com.facebook.react.bridge.JSApplicationIllegalArgumentException;
19 |
20 | /**
21 | * Controls an enclosing ProgressBar. Exists so that the ProgressBar can be recreated if
22 | * the style would change.
23 | */
24 | /* package */ class ProgressBarContainerView extends FrameLayout {
25 | private static final int MAX_PROGRESS = 1000;
26 |
27 | private @Nullable Integer mColor;
28 | private boolean mIndeterminate = true;
29 | private boolean mAnimating = true;
30 | private double mProgress;
31 | private @Nullable ProgressBar mProgressBar;
32 |
33 | public ProgressBarContainerView(Context context) {
34 | super(context);
35 | }
36 |
37 | public void setStyle(@Nullable String styleName) {
38 | int style = ReactProgressBarViewManager.getStyleFromString(styleName);
39 | mProgressBar = ReactProgressBarViewManager.createProgressBar(getContext(), style);
40 | mProgressBar.setMax(MAX_PROGRESS);
41 | removeAllViews();
42 | addView(
43 | mProgressBar,
44 | new ViewGroup.LayoutParams(
45 | ViewGroup.LayoutParams.MATCH_PARENT,
46 | ViewGroup.LayoutParams.MATCH_PARENT));
47 | }
48 |
49 | public void setColor(@Nullable Integer color) {
50 | this.mColor = color;
51 | }
52 |
53 | public void setIndeterminate(boolean indeterminate) {
54 | mIndeterminate = indeterminate;
55 | }
56 |
57 | public void setProgress(double progress) {
58 | mProgress = progress;
59 | }
60 |
61 | public void setAnimating(boolean animating) {
62 | mAnimating = animating;
63 | }
64 |
65 | public void apply() {
66 | if (mProgressBar == null) {
67 | throw new JSApplicationIllegalArgumentException("setStyle() not called");
68 | }
69 |
70 | mProgressBar.setIndeterminate(mIndeterminate);
71 | setColor(mProgressBar);
72 | mProgressBar.setProgress((int) (mProgress * MAX_PROGRESS));
73 | if (mAnimating) {
74 | mProgressBar.setVisibility(View.VISIBLE);
75 | } else {
76 | mProgressBar.setVisibility(View.GONE);
77 | }
78 | }
79 |
80 | private void setColor(ProgressBar progressBar) {
81 | Drawable drawable;
82 | if (progressBar.isIndeterminate()) {
83 | drawable = progressBar.getIndeterminateDrawable();
84 | } else {
85 | drawable = progressBar.getProgressDrawable();
86 | }
87 |
88 | if (drawable == null) {
89 | return;
90 | }
91 |
92 | if (mColor != null) {
93 | drawable.setColorFilter(mColor, PorterDuff.Mode.SRC_IN);
94 | } else {
95 | drawable.clearColorFilter();
96 | }
97 | }
98 | }
99 |
--------------------------------------------------------------------------------
/example/android/app/src/main/java/com/androidprogressbar/ReactNativeFlipper.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) Facebook, Inc. and its affiliates.
3 | *
4 | * This source code is licensed under the MIT license found in the LICENSE file in the root
5 | * directory of this source tree.
6 | */
7 | package com.androidprogressbar;
8 |
9 | import android.content.Context;
10 | import com.facebook.flipper.android.AndroidFlipperClient;
11 | import com.facebook.flipper.android.utils.FlipperUtils;
12 | import com.facebook.flipper.core.FlipperClient;
13 | import com.facebook.flipper.plugins.crashreporter.CrashReporterPlugin;
14 | import com.facebook.flipper.plugins.databases.DatabasesFlipperPlugin;
15 | import com.facebook.flipper.plugins.fresco.FrescoFlipperPlugin;
16 | import com.facebook.flipper.plugins.inspector.DescriptorMapping;
17 | import com.facebook.flipper.plugins.inspector.InspectorFlipperPlugin;
18 | import com.facebook.flipper.plugins.network.FlipperOkhttpInterceptor;
19 | import com.facebook.flipper.plugins.network.NetworkFlipperPlugin;
20 | import com.facebook.flipper.plugins.react.ReactFlipperPlugin;
21 | import com.facebook.flipper.plugins.sharedpreferences.SharedPreferencesFlipperPlugin;
22 | import com.facebook.react.ReactInstanceManager;
23 | import com.facebook.react.bridge.ReactContext;
24 | import com.facebook.react.modules.network.NetworkingModule;
25 | import okhttp3.OkHttpClient;
26 |
27 | public class ReactNativeFlipper {
28 | public static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) {
29 | if (FlipperUtils.shouldEnableFlipper(context)) {
30 | final FlipperClient client = AndroidFlipperClient.getInstance(context);
31 |
32 | client.addPlugin(new InspectorFlipperPlugin(context, DescriptorMapping.withDefaults()));
33 | client.addPlugin(new ReactFlipperPlugin());
34 | client.addPlugin(new DatabasesFlipperPlugin(context));
35 | client.addPlugin(new SharedPreferencesFlipperPlugin(context));
36 | client.addPlugin(CrashReporterPlugin.getInstance());
37 |
38 | NetworkFlipperPlugin networkFlipperPlugin = new NetworkFlipperPlugin();
39 | NetworkingModule.setCustomClientBuilder(new NetworkingModule.CustomClientBuilder() {
40 | @Override
41 | public void apply(OkHttpClient.Builder builder) {
42 | builder.addNetworkInterceptor(new FlipperOkhttpInterceptor(networkFlipperPlugin));
43 | }
44 | });
45 | client.addPlugin(networkFlipperPlugin);
46 | client.start();
47 |
48 | // Fresco Plugin needs to ensure that ImagePipelineFactory is initialized
49 | // Hence we run if after all native modules have been initialized
50 | ReactContext reactContext = reactInstanceManager.getCurrentReactContext();
51 | if (reactContext == null) {
52 | reactInstanceManager.addReactInstanceEventListener(new ReactInstanceManager.ReactInstanceEventListener() {
53 | @Override
54 | public void onReactContextInitialized(ReactContext reactContext) {
55 | reactInstanceManager.removeReactInstanceEventListener(this);
56 | reactContext.runOnNativeModulesQueueThread(new Runnable() {
57 | @Override
58 | public void run() {
59 | client.addPlugin(new FrescoFlipperPlugin());
60 | }
61 | });
62 | }
63 | });
64 | } else {
65 | client.addPlugin(new FrescoFlipperPlugin());
66 | }
67 | }
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/fabricexample/android/app/src/debug/java/com/fabricexample/ReactNativeFlipper.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) Meta Platforms, Inc. and affiliates.
3 | *
4 | *
This source code is licensed under the MIT license found in the LICENSE file in the root
5 | * directory of this source tree.
6 | */
7 | package com.fabricexample;
8 |
9 | import android.content.Context;
10 | import com.facebook.flipper.android.AndroidFlipperClient;
11 | import com.facebook.flipper.android.utils.FlipperUtils;
12 | import com.facebook.flipper.core.FlipperClient;
13 | import com.facebook.flipper.plugins.crashreporter.CrashReporterPlugin;
14 | import com.facebook.flipper.plugins.databases.DatabasesFlipperPlugin;
15 | import com.facebook.flipper.plugins.fresco.FrescoFlipperPlugin;
16 | import com.facebook.flipper.plugins.inspector.DescriptorMapping;
17 | import com.facebook.flipper.plugins.inspector.InspectorFlipperPlugin;
18 | import com.facebook.flipper.plugins.network.FlipperOkhttpInterceptor;
19 | import com.facebook.flipper.plugins.network.NetworkFlipperPlugin;
20 | import com.facebook.flipper.plugins.sharedpreferences.SharedPreferencesFlipperPlugin;
21 | import com.facebook.react.ReactInstanceEventListener;
22 | import com.facebook.react.ReactInstanceManager;
23 | import com.facebook.react.bridge.ReactContext;
24 | import com.facebook.react.modules.network.NetworkingModule;
25 | import okhttp3.OkHttpClient;
26 |
27 |
28 | /**
29 | * Class responsible of loading Flipper inside your React Native application. This is the debug
30 | * flavor of it. Here you can add your own plugins and customize the Flipper setup.
31 | */
32 | public class ReactNativeFlipper {
33 | public static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) {
34 | if (FlipperUtils.shouldEnableFlipper(context)) {
35 | final FlipperClient client = AndroidFlipperClient.getInstance(context);
36 |
37 | client.addPlugin(new InspectorFlipperPlugin(context, DescriptorMapping.withDefaults()));
38 | client.addPlugin(new DatabasesFlipperPlugin(context));
39 | client.addPlugin(new SharedPreferencesFlipperPlugin(context));
40 | client.addPlugin(CrashReporterPlugin.getInstance());
41 |
42 | NetworkFlipperPlugin networkFlipperPlugin = new NetworkFlipperPlugin();
43 | NetworkingModule.setCustomClientBuilder(
44 | new NetworkingModule.CustomClientBuilder() {
45 | @Override
46 | public void apply(OkHttpClient.Builder builder) {
47 | builder.addNetworkInterceptor(new FlipperOkhttpInterceptor(networkFlipperPlugin));
48 | }
49 | });
50 | client.addPlugin(networkFlipperPlugin);
51 | client.start();
52 |
53 | // Fresco Plugin needs to ensure that ImagePipelineFactory is initialized
54 | // Hence we run if after all native modules have been initialized
55 | ReactContext reactContext = reactInstanceManager.getCurrentReactContext();
56 | if (reactContext == null) {
57 | reactInstanceManager.addReactInstanceEventListener(
58 | new ReactInstanceEventListener() {
59 | @Override
60 | public void onReactContextInitialized(ReactContext reactContext) {
61 | reactInstanceManager.removeReactInstanceEventListener(this);
62 | reactContext.runOnNativeModulesQueueThread(
63 | new Runnable() {
64 | @Override
65 | public void run() {
66 | client.addPlugin(new FrescoFlipperPlugin());
67 | }
68 | });
69 | }
70 | });
71 | } else {
72 | client.addPlugin(new FrescoFlipperPlugin());
73 | }
74 | }
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/fabricexample/ios/fabricexample.xcodeproj/xcshareddata/xcschemes/fabricexample.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
33 |
39 |
40 |
41 |
42 |
43 |
53 |
55 |
61 |
62 |
63 |
64 |
70 |
72 |
78 |
79 |
80 |
81 |
83 |
84 |
87 |
88 |
89 |
--------------------------------------------------------------------------------
/android/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | repositories {
3 | google()
4 | mavenCentral()
5 | }
6 |
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:7.2.1'
9 | }
10 | }
11 |
12 | def resolveReactNativeDirectory() {
13 | def reactNativeLocation = safeExtGet("REACT_NATIVE_NODE_MODULES_DIR", null)
14 | if (reactNativeLocation != null) {
15 | return file(reactNativeLocation)
16 | }
17 |
18 | // monorepo workaround
19 | // react-native can be hoisted or in project's own node_modules
20 | def reactNativeFromProjectNodeModules = file("${rootProject.projectDir}/../node_modules/react-native")
21 | if (reactNativeFromProjectNodeModules.exists()) {
22 | return reactNativeFromProjectNodeModules
23 | }
24 |
25 | def reactNativeFromNodeModulesWithProgressBar = file("${projectDir}/../../react-native")
26 | if (reactNativeFromNodeModulesWithProgressBar.exists()) {
27 | return reactNativeFromNodeModulesWithProgressBar
28 | }
29 |
30 | throw new Exception(
31 | "[progress-bar-android] Unable to resolve react-native location in " +
32 | "node_modules. You should add project extension property (in app/build.gradle) " +
33 | "`REACT_NATIVE_NODE_MODULES_DIR` with path to react-native."
34 | )
35 | }
36 |
37 | def getReactNativeMinorVersion() {
38 | def REACT_NATIVE_DIR = resolveReactNativeDirectory()
39 |
40 | def reactProperties = new Properties()
41 | file("$REACT_NATIVE_DIR/ReactAndroid/gradle.properties").withInputStream { reactProperties.load(it) }
42 |
43 | def REACT_NATIVE_VERSION = reactProperties.getProperty("VERSION_NAME")
44 | def REACT_NATIVE_MINOR_VERSION = REACT_NATIVE_VERSION.startsWith("0.0.0-") ? 1000 : REACT_NATIVE_VERSION.split("\\.")[1].toInteger()
45 |
46 | return REACT_NATIVE_MINOR_VERSION
47 | }
48 |
49 | def isNewArchitectureEnabled() {
50 | // To opt-in for the New Architecture, you can either:
51 | // - Set `newArchEnabled` to true inside the `gradle.properties` file
52 | // - Invoke gradle with `-newArchEnabled=true`
53 | // - Set an environment variable `ORG_GRADLE_PROJECT_newArchEnabled=true`
54 | return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true"
55 | }
56 |
57 | apply plugin: 'com.android.library'
58 |
59 | if (isNewArchitectureEnabled()) {
60 | apply plugin: "com.facebook.react"
61 | }
62 |
63 | def safeExtGet(prop, fallback) {
64 | rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
65 | }
66 |
67 | android {
68 | compileSdkVersion safeExtGet('compileSdkVersion', 28)
69 |
70 | defaultConfig {
71 | minSdkVersion safeExtGet('minSdkVersion', 16)
72 | targetSdkVersion safeExtGet('targetSdkVersion', 28)
73 | versionCode 1
74 | versionName "1.0"
75 | }
76 | lintOptions {
77 | abortOnError false
78 | }
79 | sourceSets.main {
80 | java {
81 | if (!isNewArchitectureEnabled()) {
82 | srcDirs += [
83 | "src/paper/java",
84 | ]
85 | }
86 | }
87 | }
88 | }
89 |
90 | repositories {
91 | maven {
92 | // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
93 | url "$projectDir/../node_modules/react-native/android"
94 | }
95 | google()
96 | mavenCentral()
97 | }
98 |
99 | dependencies {
100 | if (isNewArchitectureEnabled() && getReactNativeMinorVersion() < 71) {
101 | implementation project(":ReactAndroid")
102 | } else {
103 | implementation 'com.facebook.react:react-native:+'
104 | }
105 | }
106 |
--------------------------------------------------------------------------------
/example/ios/AndroidProgressBarExample/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 |
--------------------------------------------------------------------------------
/fabricexample/ios/fabricexample/LaunchScreen.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
24 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/example/ios/AndroidProgressBarExample.xcodeproj/xcshareddata/xcschemes/AndroidProgressBarExample.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/AndroidProgressBarExample.xcodeproj/xcshareddata/xcschemes/AndroidProgressBarExample-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/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 | # https://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 or MSYS, switch paths to Windows format before running java
129 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; 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=`expr $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 | exec "$JAVACMD" "$@"
184 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # @react-native-community/progress-bar-android
2 |
3 | [](https://github.com/react-native-progress-view/progress-bar-android/actions/workflows/ci.yml)
4 | [![Version][version-badge]][package]
5 | ![Supports Android][support-badge]
6 | [![MIT License][license-badge]][license]
7 | [![Lean Core Badge][lean-core-badge]][lean-core-issue]
8 |
9 | Progress Bar Component for Android Devices
10 |
11 | 
12 |
13 | ## Getting started
14 |
15 | ```
16 | npm install @react-native-community/progress-bar-android --save
17 |
18 | # or
19 |
20 | yarn add @react-native-community/progress-bar-android
21 | ```
22 |
23 | ### Linking
24 |
25 | - React Native 0.60+
26 |
27 | The package is [automatically linked](https://github.com/react-native-community/cli/blob/master/docs/autolinking.md) when building the app. All you need to do is:
28 |
29 | ```
30 | npx pod-install
31 | ```
32 |
33 | - React Native <= 0.59
34 |
35 | Run the following commands
36 |
37 | ```
38 | $ react-native link @react-native-community/progress-bar-android
39 | ```
40 |
41 | ### Manual installation
42 |
43 |
44 | Manually linking the library - iOS
45 |
46 | 1. In XCode, in the project navigator, right click `Libraries` ➜ `Add Files to [your project's name]`
47 | 2. Go to `node_modules` ➜ `@react-native-community/progress-bar-android` and add `RNCProgressBar.xcodeproj`
48 | 3. In XCode, in the project navigator, select your project. Add `libRNCProgressBar.a` to your project's `Build Phases` ➜ `Link Binary With Libraries`
49 | 4. Run your project (`Cmd+R`)
50 |
51 |
52 |
53 |
54 | Manually link the library - android
55 |
56 | 1. Open up `android/app/src/main/java/[...]/MainActivity.java`
57 |
58 | - Add `import com.reactnativecommunity.androidprogressbar.RNCProgressBarPackage;` to the imports at the top of the file
59 | - Add `new RNCProgressBarPackage()` to the list returned by the `getPackages()` method
60 |
61 | 2. Append the following lines to `android/settings.gradle`:
62 | ```
63 | include ':@react-native-community_progress-bar-android'
64 | project(':@react-native-community_progress-bar-android').projectDir = new File(rootProject.projectDir, '../../node_modules/@react-native-community/progress-bar-android/android')
65 | ```
66 | 3. Insert the following lines inside the dependencies block in `android/app/build.gradle`:
67 | ```
68 | implementation project(':@react-native-community_progress-bar-android')
69 | ```
70 |
71 |
72 |
73 | ## Trying out this package in `example`
74 |
75 | ### Android
76 |
77 | 1. Install dependencies
78 | 1. Install dependencies for example folder
79 | 1. Start the metro bundler
80 | 1. Build the application
81 |
82 | ```sh
83 | yarn install
84 | yarn start
85 | yarn android
86 | ```
87 |
88 | # Example
89 |
90 | ```jsx
91 | import React from 'react';
92 | import {View, StyleSheet, Text} from 'react-native';
93 | import {ProgressBar} from '@react-native-community/progress-bar-android';
94 |
95 | export default function App() {
96 | return (
97 |
98 |
99 | Circle Progress Indicator
100 |
101 |
102 |
103 | Horizontal Progress Indicator
104 |
105 |
106 |
107 | Colored Progress Indicator
108 |
109 |
110 |
111 | Fixed Progress Value
112 |
117 |
118 |
119 | );
120 | }
121 |
122 | const styles = StyleSheet.create({
123 | container: {
124 | flex: 1,
125 | justifyContent: 'center',
126 | alignItems: 'center',
127 | },
128 | example: {
129 | marginVertical: 24,
130 | },
131 | });
132 | ```
133 |
134 | # Reference
135 |
136 | ## Props
137 |
138 | Inherits [View Props](https://reactnative.dev/docs/view#props).
139 |
140 | ### `animating`
141 |
142 | Whether to show the ProgressBar (true, the default) or hide it (false).
143 |
144 | | Type | Required |
145 | | ---- | -------- |
146 | | bool | No |
147 |
148 | ---
149 |
150 | ### `color`
151 |
152 | Color of the progress bar.
153 |
154 | | Type | Required |
155 | | ------------------ | -------- |
156 | | [color](colors.md) | No |
157 |
158 | ---
159 |
160 | ### `indeterminate`
161 |
162 | If the progress bar will show indeterminate progress. Note that this can only be false if styleAttr is Horizontal, and requires a `progress` value.
163 |
164 | | Type | Required |
165 | | ----------------- | -------- |
166 | | indeterminateType | No |
167 |
168 | ---
169 |
170 | ### `progress`
171 |
172 | The progress value (between 0 and 1).
173 |
174 | | Type | Required |
175 | | ------ | -------- |
176 | | number | No |
177 |
178 | ---
179 |
180 | ### `styleAttr`
181 |
182 | Style of the ProgressBar. One of:
183 |
184 | - Horizontal
185 | - Normal (default)
186 | - Small
187 | - Large
188 | - Inverse
189 | - SmallInverse
190 | - LargeInverse
191 |
192 | | Type | Required |
193 | | ----------------------------------------------------------------------------------------- | -------- |
194 | | enum('Horizontal', 'Normal', 'Small', 'Large', 'Inverse', 'SmallInverse', 'LargeInverse') | No |
195 |
196 | ---
197 |
198 | ### `testID`
199 |
200 | Used to locate this view in end-to-end tests.
201 |
202 | | Type | Required |
203 | | ------ | -------- |
204 | | string | No |
205 |
206 | [version-badge]: https://img.shields.io/npm/v/@react-native-community/progress-bar-android.svg?style=flat-square
207 | [package]: https://www.npmjs.com/package/@react-native-community/progress-bar-android
208 | [support-badge]: https://img.shields.io/badge/platforms-android-lightgrey.svg?style=flat-square
209 | [license-badge]: https://img.shields.io/npm/l/@react-native-community/progress-bar-android.svg?style=flat-square
210 | [license]: https://opensource.org/licenses/MIT
211 | [lean-core-badge]: https://img.shields.io/badge/Lean%20Core-Extracted-brightgreen.svg?style=flat-square
212 | [lean-core-issue]: https://github.com/facebook/react-native/issues/23313
213 |
--------------------------------------------------------------------------------
/android/src/main/java/com/reactnativecommunity/androidprogressbar/ReactProgressBarViewManager.java:
--------------------------------------------------------------------------------
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 | package com.reactnativecommunity.androidprogressbar;
9 |
10 | import javax.annotation.Nullable;
11 |
12 | import android.content.Context;
13 | import android.view.View;
14 | import android.widget.ProgressBar;
15 |
16 | import com.facebook.react.bridge.ReadableMap;
17 | import com.facebook.react.bridge.JSApplicationIllegalArgumentException;
18 | import com.facebook.react.module.annotations.ReactModule;
19 | import com.facebook.react.uimanager.BaseViewManager;
20 | import com.facebook.react.uimanager.annotations.ReactProp;
21 | import com.facebook.react.uimanager.ThemedReactContext;
22 | import com.facebook.react.uimanager.ViewProps;
23 | import com.facebook.react.uimanager.ViewManagerDelegate;
24 | import com.facebook.react.uimanager.PixelUtil;
25 |
26 | import com.facebook.yoga.YogaMeasureFunction;
27 | import com.facebook.yoga.YogaMeasureMode;
28 | import com.facebook.yoga.YogaMeasureOutput;
29 | import com.facebook.yoga.YogaNode;
30 |
31 | import com.facebook.react.viewmanagers.RNCProgressBarManagerDelegate;
32 | import com.facebook.react.viewmanagers.RNCProgressBarManagerInterface;
33 |
34 | /**
35 | * Manages instances of ProgressBar. ProgressBar is wrapped in a
36 | * ProgressBarContainerView because the style of the ProgressBar can only be set
37 | * in the constructor; whenever the style of a ProgressBar changes, we have to
38 | * drop the existing ProgressBar (if there is one) and create a new one with the
39 | * style given.
40 | */
41 | @ReactModule(name = ReactProgressBarViewManager.REACT_CLASS)
42 | public class ReactProgressBarViewManager extends BaseViewManager implements RNCProgressBarManagerInterface {
43 |
44 | public static final String REACT_CLASS = "RNCProgressBar";
45 | private final ViewManagerDelegate mDelegate;
46 |
47 | /* package */ static final String PROP_STYLE = "styleAttr";
48 | /* package */ static final String PROP_INDETERMINATE = "indeterminate";
49 | /* package */ static final String PROP_PROGRESS = "progress";
50 | /* package */ static final String PROP_ANIMATING = "animating";
51 |
52 | /* package */ static final String DEFAULT_STYLE = "Normal";
53 |
54 | private static Object sProgressBarCtorLock = new Object();
55 |
56 | @Nullable
57 | @Override
58 | protected ViewManagerDelegate getDelegate() {
59 | return mDelegate;
60 | }
61 |
62 | public ReactProgressBarViewManager() {
63 | mDelegate = new RNCProgressBarManagerDelegate<>(this);
64 | }
65 |
66 | public long measure(
67 | Context context,
68 | ReadableMap localData,
69 | ReadableMap props,
70 | ReadableMap state,
71 | float width,
72 | YogaMeasureMode widthMode,
73 | float height,
74 | YogaMeasureMode heightMode,
75 | @androidx.annotation.Nullable float[] attachmentsPositions) {
76 | final int style = ReactProgressBarViewManager.getStyleFromString(props.getString("styleAttr"));
77 |
78 | ProgressBar view = ReactProgressBarViewManager.createProgressBar(context, style);
79 | int measureSpec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
80 | view.measure(measureSpec, measureSpec);
81 | return YogaMeasureOutput.make(
82 | PixelUtil.toDIPFromPixel(view.getMeasuredWidth()),
83 | PixelUtil.toDIPFromPixel(view.getMeasuredHeight()));
84 | }
85 |
86 | /**
87 | * We create ProgressBars on both the UI and shadow threads. There is a race
88 | * condition in the ProgressBar constructor that may cause crashes when two
89 | * ProgressBars are constructed at the same time on two different threads. This
90 | * static ctor wrapper protects against that.
91 | */
92 | public static ProgressBar createProgressBar(Context context, int style) {
93 | synchronized (sProgressBarCtorLock) {
94 | return new ProgressBar(context, null, style);
95 | }
96 | }
97 |
98 | @Override
99 | public String getName() {
100 | return REACT_CLASS;
101 | }
102 |
103 | @Override
104 | protected ProgressBarContainerView createViewInstance(ThemedReactContext context) {
105 | return new ProgressBarContainerView(context);
106 | }
107 |
108 | @Override
109 | @ReactProp(name = PROP_STYLE)
110 | public void setStyleAttr(ProgressBarContainerView view, @Nullable String styleName) {
111 | view.setStyle(styleName);
112 | }
113 |
114 | @Override
115 | @ReactProp(name = ViewProps.COLOR, customType = "Color")
116 | public void setColor(ProgressBarContainerView view, @Nullable Integer color) {
117 | view.setColor(color);
118 | }
119 |
120 | @Override
121 | @ReactProp(name = PROP_INDETERMINATE)
122 | public void setIndeterminate(ProgressBarContainerView view, boolean indeterminate) {
123 | view.setIndeterminate(indeterminate);
124 | }
125 |
126 | @Override
127 | @ReactProp(name = PROP_PROGRESS)
128 | public void setProgress(ProgressBarContainerView view, double progress) {
129 | view.setProgress(progress);
130 | }
131 |
132 | @Override
133 | @ReactProp(name = PROP_ANIMATING)
134 | public void setAnimating(ProgressBarContainerView view, boolean animating) {
135 | view.setAnimating(animating);
136 | }
137 |
138 | @Override
139 | public ProgressBarShadowNode createShadowNodeInstance() {
140 | return new ProgressBarShadowNode();
141 | }
142 |
143 | @Override
144 | public Class getShadowNodeClass() {
145 | return ProgressBarShadowNode.class;
146 | }
147 |
148 | @Override
149 | public void updateExtraData(ProgressBarContainerView root, Object extraData) {
150 | // do nothing
151 | }
152 |
153 | @Override
154 | protected void onAfterUpdateTransaction(ProgressBarContainerView view) {
155 | view.apply();
156 | }
157 |
158 | /* package */ static int getStyleFromString(@Nullable String styleStr) {
159 | if (styleStr == null) {
160 | throw new JSApplicationIllegalArgumentException("ProgressBar needs to have a style, null received");
161 | } else if (styleStr.equals("Horizontal")) {
162 | return android.R.attr.progressBarStyleHorizontal;
163 | } else if (styleStr.equals("Small")) {
164 | return android.R.attr.progressBarStyleSmall;
165 | } else if (styleStr.equals("Large")) {
166 | return android.R.attr.progressBarStyleLarge;
167 | } else if (styleStr.equals("Inverse")) {
168 | return android.R.attr.progressBarStyleInverse;
169 | } else if (styleStr.equals("SmallInverse")) {
170 | return android.R.attr.progressBarStyleSmallInverse;
171 | } else if (styleStr.equals("LargeInverse")) {
172 | return android.R.attr.progressBarStyleLargeInverse;
173 | } else if (styleStr.equals("Normal")) {
174 | return android.R.attr.progressBarStyle;
175 | } else {
176 | throw new JSApplicationIllegalArgumentException("Unknown ProgressBar style: " + styleStr);
177 | }
178 | }
179 | }
180 |
--------------------------------------------------------------------------------
/fabricexample/android/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: "com.android.application"
2 | apply plugin: "com.facebook.react"
3 |
4 | import com.android.build.OutputFile
5 |
6 | /**
7 | * This is the configuration block to customize your React Native Android app.
8 | * By default you don't need to apply any configuration, just uncomment the lines you need.
9 | */
10 | react {
11 | /* Folders */
12 | // The root of your project, i.e. where "package.json" lives. Default is '..'
13 | // root = file("../")
14 | // The folder where the react-native NPM package is. Default is ../node_modules/react-native
15 | // reactNativeDir = file("../node_modules/react-native")
16 | // The folder where the react-native Codegen package is. Default is ../node_modules/react-native-codegen
17 | // codegenDir = file("../node_modules/react-native-codegen")
18 | // The cli.js file which is the React Native CLI entrypoint. Default is ../node_modules/react-native/cli.js
19 | // cliFile = file("../node_modules/react-native/cli.js")
20 |
21 | /* Variants */
22 | // The list of variants to that are debuggable. For those we're going to
23 | // skip the bundling of the JS bundle and the assets. By default is just 'debug'.
24 | // If you add flavors like lite, prod, etc. you'll have to list your debuggableVariants.
25 | // debuggableVariants = ["liteDebug", "prodDebug"]
26 |
27 | /* Bundling */
28 | // A list containing the node command and its flags. Default is just 'node'.
29 | // nodeExecutableAndArgs = ["node"]
30 | //
31 | // The command to run when bundling. By default is 'bundle'
32 | // bundleCommand = "ram-bundle"
33 | //
34 | // The path to the CLI configuration file. Default is empty.
35 | // bundleConfig = file(../rn-cli.config.js)
36 | //
37 | // The name of the generated asset file containing your JS bundle
38 | // bundleAssetName = "MyApplication.android.bundle"
39 | //
40 | // The entry file for bundle generation. Default is 'index.android.js' or 'index.js'
41 | // entryFile = file("../js/MyApplication.android.js")
42 | //
43 | // A list of extra flags to pass to the 'bundle' commands.
44 | // See https://github.com/react-native-community/cli/blob/main/docs/commands.md#bundle
45 | // extraPackagerArgs = []
46 |
47 | /* Hermes Commands */
48 | // The hermes compiler command to run. By default it is 'hermesc'
49 | // hermesCommand = "$rootDir/my-custom-hermesc/bin/hermesc"
50 | //
51 | // The list of flags to pass to the Hermes compiler. By default is "-O", "-output-source-map"
52 | // hermesFlags = ["-O", "-output-source-map"]
53 | }
54 |
55 | /**
56 | * Set this to true to create four separate APKs instead of one,
57 | * one for each native architecture. This is useful if you don't
58 | * use App Bundles (https://developer.android.com/guide/app-bundle/)
59 | * and want to have separate APKs to upload to the Play Store.
60 | */
61 | def enableSeparateBuildPerCPUArchitecture = false
62 |
63 | /**
64 | * Set this to true to Run Proguard on Release builds to minify the Java bytecode.
65 | */
66 | def enableProguardInReleaseBuilds = false
67 |
68 | /**
69 | * The preferred build flavor of JavaScriptCore (JSC)
70 | *
71 | * For example, to use the international variant, you can use:
72 | * `def jscFlavor = 'org.webkit:android-jsc-intl:+'`
73 | *
74 | * The international variant includes ICU i18n library and necessary data
75 | * allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that
76 | * give correct results when using with locales other than en-US. Note that
77 | * this variant is about 6MiB larger per architecture than default.
78 | */
79 | def jscFlavor = 'org.webkit:android-jsc:+'
80 |
81 | /**
82 | * Private function to get the list of Native Architectures you want to build.
83 | * This reads the value from reactNativeArchitectures in your gradle.properties
84 | * file and works together with the --active-arch-only flag of react-native run-android.
85 | */
86 | def reactNativeArchitectures() {
87 | def value = project.getProperties().get("reactNativeArchitectures")
88 | return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
89 | }
90 |
91 | android {
92 | ndkVersion rootProject.ext.ndkVersion
93 |
94 | compileSdkVersion rootProject.ext.compileSdkVersion
95 |
96 | namespace "com.fabricexample"
97 | defaultConfig {
98 | applicationId "com.fabricexample"
99 | minSdkVersion rootProject.ext.minSdkVersion
100 | targetSdkVersion rootProject.ext.targetSdkVersion
101 | versionCode 1
102 | versionName "1.0"
103 | }
104 |
105 | splits {
106 | abi {
107 | reset()
108 | enable enableSeparateBuildPerCPUArchitecture
109 | universalApk false // If true, also generate a universal APK
110 | include (*reactNativeArchitectures())
111 | }
112 | }
113 | signingConfigs {
114 | debug {
115 | storeFile file('debug.keystore')
116 | storePassword 'android'
117 | keyAlias 'androiddebugkey'
118 | keyPassword 'android'
119 | }
120 | }
121 | buildTypes {
122 | debug {
123 | signingConfig signingConfigs.debug
124 | }
125 | release {
126 | // Caution! In production, you need to generate your own keystore file.
127 | // see https://reactnative.dev/docs/signed-apk-android.
128 | signingConfig signingConfigs.debug
129 | minifyEnabled enableProguardInReleaseBuilds
130 | proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
131 | }
132 | }
133 |
134 | // applicationVariants are e.g. debug, release
135 | applicationVariants.all { variant ->
136 | variant.outputs.each { output ->
137 | // For each separate APK per architecture, set a unique version code as described here:
138 | // https://developer.android.com/studio/build/configure-apk-splits.html
139 | // Example: versionCode 1 will generate 1001 for armeabi-v7a, 1002 for x86, etc.
140 | def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4]
141 | def abi = output.getFilter(OutputFile.ABI)
142 | if (abi != null) { // null for the universal-debug, universal-release variants
143 | output.versionCodeOverride =
144 | defaultConfig.versionCode * 1000 + versionCodes.get(abi)
145 | }
146 |
147 | }
148 | }
149 | }
150 |
151 | dependencies {
152 | // The version of react-native is set by the React Native Gradle Plugin
153 | implementation("com.facebook.react:react-android")
154 |
155 | implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.0.0")
156 |
157 | debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}")
158 | debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
159 | exclude group:'com.squareup.okhttp3', module:'okhttp'
160 | }
161 |
162 | debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}")
163 | if (hermesEnabled.toBoolean()) {
164 | implementation("com.facebook.react:hermes-android")
165 | } else {
166 | implementation jscFlavor
167 | }
168 | }
169 |
170 | apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
171 |
--------------------------------------------------------------------------------
/fabricexample/android/gradlew:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | #
4 | # Copyright © 2015-2021 the original 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 | # https://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 POSIX generated by Gradle.
22 | #
23 | # Important for running:
24 | #
25 | # (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
26 | # noncompliant, but you have some other compliant shell such as ksh or
27 | # bash, then to run this script, type that shell name before the whole
28 | # command line, like:
29 | #
30 | # ksh Gradle
31 | #
32 | # Busybox and similar reduced shells will NOT work, because this script
33 | # requires all of these POSIX shell features:
34 | # * functions;
35 | # * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
36 | # «${var#prefix}», «${var%suffix}», and «$( cmd )»;
37 | # * compound commands having a testable exit status, especially «case»;
38 | # * various built-in commands including «command», «set», and «ulimit».
39 | #
40 | # Important for patching:
41 | #
42 | # (2) This script targets any POSIX shell, so it avoids extensions provided
43 | # by Bash, Ksh, etc; in particular arrays are avoided.
44 | #
45 | # The "traditional" practice of packing multiple parameters into a
46 | # space-separated string is a well documented source of bugs and security
47 | # problems, so this is (mostly) avoided, by progressively accumulating
48 | # options in "$@", and eventually passing that to Java.
49 | #
50 | # Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
51 | # and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
52 | # see the in-line comments for details.
53 | #
54 | # There are tweaks for specific operating systems such as AIX, CygWin,
55 | # Darwin, MinGW, and NonStop.
56 | #
57 | # (3) This script is generated from the Groovy template
58 | # https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
59 | # within the Gradle project.
60 | #
61 | # You can find Gradle at https://github.com/gradle/gradle/.
62 | #
63 | ##############################################################################
64 |
65 | # Attempt to set APP_HOME
66 |
67 | # Resolve links: $0 may be a link
68 | app_path=$0
69 |
70 | # Need this for daisy-chained symlinks.
71 | while
72 | APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
73 | [ -h "$app_path" ]
74 | do
75 | ls=$( ls -ld "$app_path" )
76 | link=${ls#*' -> '}
77 | case $link in #(
78 | /*) app_path=$link ;; #(
79 | *) app_path=$APP_HOME$link ;;
80 | esac
81 | done
82 |
83 | APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
84 |
85 | APP_NAME="Gradle"
86 | APP_BASE_NAME=${0##*/}
87 |
88 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
89 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
90 |
91 | # Use the maximum available, or set MAX_FD != -1 to use that value.
92 | MAX_FD=maximum
93 |
94 | warn () {
95 | echo "$*"
96 | } >&2
97 |
98 | die () {
99 | echo
100 | echo "$*"
101 | echo
102 | exit 1
103 | } >&2
104 |
105 | # OS specific support (must be 'true' or 'false').
106 | cygwin=false
107 | msys=false
108 | darwin=false
109 | nonstop=false
110 | case "$( uname )" in #(
111 | CYGWIN* ) cygwin=true ;; #(
112 | Darwin* ) darwin=true ;; #(
113 | MSYS* | MINGW* ) msys=true ;; #(
114 | NONSTOP* ) nonstop=true ;;
115 | esac
116 |
117 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
118 |
119 |
120 | # Determine the Java command to use to start the JVM.
121 | if [ -n "$JAVA_HOME" ] ; then
122 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
123 | # IBM's JDK on AIX uses strange locations for the executables
124 | JAVACMD=$JAVA_HOME/jre/sh/java
125 | else
126 | JAVACMD=$JAVA_HOME/bin/java
127 | fi
128 | if [ ! -x "$JAVACMD" ] ; then
129 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
130 |
131 | Please set the JAVA_HOME variable in your environment to match the
132 | location of your Java installation."
133 | fi
134 | else
135 | JAVACMD=java
136 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
137 |
138 | Please set the JAVA_HOME variable in your environment to match the
139 | location of your Java installation."
140 | fi
141 |
142 | # Increase the maximum file descriptors if we can.
143 | if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
144 | case $MAX_FD in #(
145 | max*)
146 | MAX_FD=$( ulimit -H -n ) ||
147 | warn "Could not query maximum file descriptor limit"
148 | esac
149 | case $MAX_FD in #(
150 | '' | soft) :;; #(
151 | *)
152 | ulimit -n "$MAX_FD" ||
153 | warn "Could not set maximum file descriptor limit to $MAX_FD"
154 | esac
155 | fi
156 |
157 | # Collect all arguments for the java command, stacking in reverse order:
158 | # * args from the command line
159 | # * the main class name
160 | # * -classpath
161 | # * -D...appname settings
162 | # * --module-path (only if needed)
163 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
164 |
165 | # For Cygwin or MSYS, switch paths to Windows format before running java
166 | if "$cygwin" || "$msys" ; then
167 | APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
168 | CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
169 |
170 | JAVACMD=$( cygpath --unix "$JAVACMD" )
171 |
172 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
173 | for arg do
174 | if
175 | case $arg in #(
176 | -*) false ;; # don't mess with options #(
177 | /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
178 | [ -e "$t" ] ;; #(
179 | *) false ;;
180 | esac
181 | then
182 | arg=$( cygpath --path --ignore --mixed "$arg" )
183 | fi
184 | # Roll the args list around exactly as many times as the number of
185 | # args, so each arg winds up back in the position where it started, but
186 | # possibly modified.
187 | #
188 | # NB: a `for` loop captures its iteration list before it begins, so
189 | # changing the positional parameters here affects neither the number of
190 | # iterations, nor the values presented in `arg`.
191 | shift # remove old arg
192 | set -- "$@" "$arg" # push replacement arg
193 | done
194 | fi
195 |
196 | # Collect all arguments for the java command;
197 | # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
198 | # shell script including quotes and variable substitutions, so put them in
199 | # double quotes to make sure that they get re-expanded; and
200 | # * put everything else in single quotes, so that it's not re-expanded.
201 |
202 | set -- \
203 | "-Dorg.gradle.appname=$APP_BASE_NAME" \
204 | -classpath "$CLASSPATH" \
205 | org.gradle.wrapper.GradleWrapperMain \
206 | "$@"
207 |
208 | # Use "xargs" to parse quoted args.
209 | #
210 | # With -n1 it outputs one arg per line, with the quotes and backslashes removed.
211 | #
212 | # In Bash we could simply go:
213 | #
214 | # readarray ARGS < <( xargs -n1 <<<"$var" ) &&
215 | # set -- "${ARGS[@]}" "$@"
216 | #
217 | # but POSIX shell has neither arrays nor command substitution, so instead we
218 | # post-process each arg (as a line of input to sed) to backslash-escape any
219 | # character that might be a shell metacharacter, then use eval to reverse
220 | # that process (while maintaining the separation between arguments), and wrap
221 | # the whole thing up as a single "set" statement.
222 | #
223 | # This will of course break if any of these variables contains a newline or
224 | # an unmatched quote.
225 | #
226 |
227 | eval "set -- $(
228 | printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
229 | xargs -n1 |
230 | sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
231 | tr '\n' ' '
232 | )" '"$@"'
233 |
234 | exec "$JAVACMD" "$@"
235 |
--------------------------------------------------------------------------------
/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.androidprogressbar"
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 | buildTypes {
146 | debug {
147 | signingConfig signingConfigs.debug
148 | }
149 | release {
150 | // Caution! In production, you need to generate your own keystore file.
151 | // see https://facebook.github.io/react-native/docs/signed-apk-android.
152 | signingConfig signingConfigs.debug
153 | minifyEnabled enableProguardInReleaseBuilds
154 | proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
155 | }
156 | }
157 | // applicationVariants are e.g. debug, release
158 | applicationVariants.all { variant ->
159 | variant.outputs.each { output ->
160 | // For each separate APK per architecture, set a unique version code as described here:
161 | // https://developer.android.com/studio/build/configure-apk-splits.html
162 | def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4]
163 | def abi = output.getFilter(OutputFile.ABI)
164 | if (abi != null) { // null for the universal-debug, universal-release variants
165 | output.versionCodeOverride =
166 | versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
167 | }
168 |
169 | }
170 | }
171 | }
172 |
173 | dependencies {
174 | implementation fileTree(dir: "libs", include: ["*.jar"])
175 | //noinspection GradleDynamicVersion
176 | implementation "com.facebook.react:react-native:+" // From node_modules
177 | // required for example
178 | implementation project(":@react-native-community_progress-bar-android")
179 |
180 | implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
181 | debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") {
182 | exclude group:'com.facebook.fbjni'
183 | }
184 | debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
185 | exclude group:'com.facebook.flipper'
186 | }
187 | debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") {
188 | exclude group:'com.facebook.flipper'
189 | }
190 | if (enableHermes) {
191 | def hermesPath = "../../../node_modules/hermes-engine/android/";
192 | debugImplementation files(hermesPath + "hermes-debug.aar")
193 | releaseImplementation files(hermesPath + "hermes-release.aar")
194 | } else {
195 | implementation jscFlavor
196 | }
197 | }
198 |
199 | // Run this once to be able to run the application with BUCK
200 | // puts all compile dependencies into folder libs for BUCK to use
201 | task copyDownloadableDepsToLibs(type: Copy) {
202 | from configurations.compile
203 | into 'libs'
204 | }
205 |
206 | apply from: file("../../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
207 |
--------------------------------------------------------------------------------