Skip to content

Commit 379eb3d

Browse files
authored
fix/duplicateRegistration (#38)
* fix/duplicateRegistration * chore/renameIosFiles * chore: update snapshots * fix: remove types/react
1 parent a4e92bb commit 379eb3d

18 files changed

+107
-98
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ $ react-native link @react-native-community/progress-bar-android
4747
<summary>Manually linking the library - iOS</summary>
4848

4949
1. In XCode, in the project navigator, right click `Libraries``Add Files to [your project's name]`
50-
2. Go to `node_modules``@react-native-community/progress-bar-android` and add `RNCAndroidprogressbar.xcodeproj`
51-
3. In XCode, in the project navigator, select your project. Add `libRNCAndroidprogressbar.a` to your project's `Build Phases``Link Binary With Libraries`
50+
2. Go to `node_modules``@react-native-community/progress-bar-android` and add `RNCProgressBar.xcodeproj`
51+
3. In XCode, in the project navigator, select your project. Add `libRNCProgressBar.a` to your project's `Build Phases``Link Binary With Libraries`
5252
4. Run your project (`Cmd+R`)
5353

5454
</details>
@@ -57,8 +57,8 @@ $ react-native link @react-native-community/progress-bar-android
5757
<summary>Manually link the library - android</summary>
5858

5959
1. Open up `android/app/src/main/java/[...]/MainActivity.java`
60-
- Add `import com.reactnativecommunity.androidprogressbar.RNCAndroidprogressbarPackage;` to the imports at the top of the file
61-
- Add `new RNCAndroidprogressbarPackage()` to the list returned by the `getPackages()` method
60+
- Add `import com.reactnativecommunity.androidprogressbar.RNCProgressBarPackage;` to the imports at the top of the file
61+
- Add `new RNCProgressBarPackage()` to the list returned by the `getPackages()` method
6262
2. Append the following lines to `android/settings.gradle`:
6363
```
6464
include ':@react-native-community_progress-bar-android'

android/src/main/java/com/reactnativecommunity/androidprogressbar/RNCAndroidprogressbarPackage.java

Lines changed: 0 additions & 28 deletions
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
1-
21
package com.reactnativecommunity.androidprogressbar;
32

43
import com.facebook.react.bridge.ReactApplicationContext;
54
import com.facebook.react.bridge.ReactContextBaseJavaModule;
65
import com.facebook.react.bridge.ReactMethod;
76
import com.facebook.react.bridge.Callback;
87

9-
public class RNCAndroidprogressbarModule extends ReactContextBaseJavaModule {
8+
public class RNCProgressBarModule extends ReactContextBaseJavaModule {
109

1110
private final ReactApplicationContext reactContext;
1211

13-
public RNCAndroidprogressbarModule(ReactApplicationContext reactContext) {
12+
public RNCProgressBarModule(ReactApplicationContext reactContext) {
1413
super(reactContext);
1514
this.reactContext = reactContext;
1615
}
1716

1817
@Override
1918
public String getName() {
20-
return "RNCAndroidprogressbar";
19+
return "RNCProgressBar";
2120
}
22-
}
21+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
2+
package com.reactnativecommunity.androidprogressbar;
3+
4+
import java.util.Arrays;
5+
import java.util.Collections;
6+
import java.util.List;
7+
8+
import com.facebook.react.ReactPackage;
9+
import com.facebook.react.bridge.NativeModule;
10+
import com.facebook.react.bridge.ReactApplicationContext;
11+
import com.facebook.react.uimanager.ViewManager;
12+
import com.facebook.react.bridge.JavaScriptModule;
13+
14+
public class RNCProgressBarPackage implements ReactPackage {
15+
@Override
16+
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
17+
return Arrays.<NativeModule>asList(new RNCProgressBarModule(reactContext));
18+
}
19+
20+
// Deprecated from RN 0.47
21+
public List<Class<? extends JavaScriptModule>> createJSModules() {
22+
return Collections.emptyList();
23+
}
24+
25+
@Override
26+
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
27+
return Collections.emptyList();
28+
}
29+
}

android/src/main/java/com/reactnativecommunity/androidprogressbar/ReactProgressBarViewManager.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,16 @@
2020
import com.facebook.react.uimanager.ViewProps;
2121

2222
/**
23-
* Manages instances of ProgressBar. ProgressBar is wrapped in a ProgressBarContainerView because
24-
* the style of the ProgressBar can only be set in the constructor; whenever the style of a
25-
* ProgressBar changes, we have to drop the existing ProgressBar (if there is one) and create a new
26-
* one with the style given.
23+
* Manages instances of ProgressBar. ProgressBar is wrapped in a
24+
* ProgressBarContainerView because the style of the ProgressBar can only be set
25+
* in the constructor; whenever the style of a ProgressBar changes, we have to
26+
* drop the existing ProgressBar (if there is one) and create a new one with the
27+
* style given.
2728
*/
2829
@ReactModule(name = ReactProgressBarViewManager.REACT_CLASS)
29-
public class ReactProgressBarViewManager extends
30-
BaseViewManager<ProgressBarContainerView, ProgressBarShadowNode> {
30+
public class ReactProgressBarViewManager extends BaseViewManager<ProgressBarContainerView, ProgressBarShadowNode> {
3131

32-
public static final String REACT_CLASS = "AndroidProgressBar";
32+
public static final String REACT_CLASS = "RNCProgressBar";
3333

3434
/* package */ static final String PROP_STYLE = "styleAttr";
3535
/* package */ static final String PROP_INDETERMINATE = "indeterminate";
@@ -41,9 +41,10 @@ public class ReactProgressBarViewManager extends
4141
private static Object sProgressBarCtorLock = new Object();
4242

4343
/**
44-
* We create ProgressBars on both the UI and shadow threads. There is a race condition in the
45-
* ProgressBar constructor that may cause crashes when two ProgressBars are constructed at the
46-
* same time on two different threads. This static ctor wrapper protects against that.
44+
* We create ProgressBars on both the UI and shadow threads. There is a race
45+
* condition in the ProgressBar constructor that may cause crashes when two
46+
* ProgressBars are constructed at the same time on two different threads. This
47+
* static ctor wrapper protects against that.
4748
*/
4849
public static ProgressBar createProgressBar(Context context, int style) {
4950
synchronized (sProgressBarCtorLock) {
@@ -108,11 +109,10 @@ protected void onAfterUpdateTransaction(ProgressBarContainerView view) {
108109

109110
/* package */ static int getStyleFromString(@Nullable String styleStr) {
110111
if (styleStr == null) {
111-
throw new JSApplicationIllegalArgumentException(
112-
"ProgressBar needs to have a style, null received");
112+
throw new JSApplicationIllegalArgumentException("ProgressBar needs to have a style, null received");
113113
} else if (styleStr.equals("Horizontal")) {
114114
return android.R.attr.progressBarStyleHorizontal;
115-
} else if (styleStr.equals("Small")) {
115+
} else if (styleStr.equals("Small")) {
116116
return android.R.attr.progressBarStyleSmall;
117117
} else if (styleStr.equals("Large")) {
118118
return android.R.attr.progressBarStyleLarge;

example/android/app/.settings/org.eclipse.buildship.core.prefs

Lines changed: 0 additions & 2 deletions
This file was deleted.

example/android/app/.settings/org.eclipse.jdt.core.prefs

Lines changed: 0 additions & 4 deletions
This file was deleted.

index.d.ts

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,43 @@
1-
import React from 'react';
2-
export type ProgressBarAndroidProps = {
1+
import * as React from 'react';
2+
import {ViewProps} from 'react-native';
3+
4+
export type ProgressBarAndroidProps = ViewProps & {
35
/**
46
* styleAttr: style of ProgressBar
57
*
68
* default: 'Normal'
79
*/
8-
styleAttr?: 'Normal'| 'Horizontal' | 'Small' | 'Large' | 'Inverse' |'SmallInverse' |'LargeInverse'
10+
styleAttr?:
11+
| 'Normal'
12+
| 'Horizontal'
13+
| 'Small'
14+
| 'Large'
15+
| 'Inverse'
16+
| 'SmallInverse'
17+
| 'LargeInverse';
918
/**
1019
* color: Color of the ProgressBar
1120
*/
12-
color?: string
21+
color?: string;
1322
/**
1423
* indeterminate: boolean flag for indeterminate mode.
1524
*
1625
* 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.
1726
*
1827
* default: false
1928
*/
20-
indeterminate?: boolean
29+
indeterminate?: boolean;
2130
/**
2231
* progress: sets the amount of progress in 0-100.
2332
*
2433
* 25 will show that a progress bar is 25% complete
2534
*/
26-
progress?: number
35+
progress?: number;
2736
/**
2837
* animating: weather ProgressBar is animated or not.
2938
*
3039
* default: true
3140
*/
32-
animating?: boolean
33-
}
41+
animating?: boolean;
42+
};
3443
export class ProgressBar extends React.Component<ProgressBarAndroidProps> {}

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export { default as ProgressBar } from './js/RNCProgressBarAndroid'
1+
export {default as ProgressBar} from './js/RNCProgressBarAndroid';

ios/RNCAndroidprogressbar.h renamed to ios/RNCProgressBar.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
#import <React/RCTBridgeModule.h>
66
#endif
77

8-
@interface RNCAndroidprogressbar : NSObject <RCTBridgeModule>
8+
@interface RNCProgressBar : NSObject <RCTBridgeModule>
99

1010
@end
11-

0 commit comments

Comments
 (0)