File tree Expand file tree Collapse file tree 7 files changed +65
-6
lines changed
src/main/java/com/reactlibrary Expand file tree Collapse file tree 7 files changed +65
-6
lines changed Original file line number Diff line number Diff line change 1+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2+ <projectDescription >
3+ <name >android</name >
4+ <comment >Project android created by Buildship.</comment >
5+ <projects >
6+ </projects >
7+ <buildSpec >
8+ <buildCommand >
9+ <name >org.eclipse.buildship.core.gradleprojectbuilder</name >
10+ <arguments >
11+ </arguments >
12+ </buildCommand >
13+ </buildSpec >
14+ <natures >
15+ <nature >org.eclipse.buildship.core.gradleprojectnature</nature >
16+ </natures >
17+ </projectDescription >
Original file line number Diff line number Diff line change 1+ connection.project.dir =
2+ eclipse.preferences.version =1
Original file line number Diff line number Diff line change 11
22package com .reactlibrary ;
33
4+ import java .lang .reflect .*;
45import com .facebook .react .bridge .ReactApplicationContext ;
56import com .facebook .react .bridge .ReactContextBaseJavaModule ;
67import com .facebook .react .bridge .ReactMethod ;
@@ -19,4 +20,25 @@ public RNConfigReaderModule(ReactApplicationContext reactContext) {
1920 public String getName () {
2021 return "RNConfigReader" ;
2122 }
23+
24+ @ Override
25+ public Map <String , Object > getConstants () {
26+ final Map <String , Object > constants = new HashMap <>();
27+ Field [] fields = BuildConfig .class .getDeclaredFields ();
28+ for (Field f : fields ) {
29+ if (Modifier .isStatic (f .getModifiers ())) {
30+ Object value = null ;
31+ try {
32+ value = f .get (null );
33+ }
34+ catch (Exception e ){
35+
36+ }
37+ finally {
38+ constants .put (f .getName (), value );
39+ }
40+ }
41+ }
42+ return constants ;
43+ }
2244}
Original file line number Diff line number Diff line change 11
2- import { NativeModules } from 'react-native' ;
2+ import { NativeModules , Platform } from 'react-native' ;
33
44const { RNConfigReader } = NativeModules ;
55
6- export default RNConfigReader ;
6+ export default Platform . OS === 'ios' ? RNConfigReader . BuildConfigs : RNConfigReader ;
Original file line number Diff line number Diff line change @@ -9,5 +9,10 @@ - (dispatch_queue_t)methodQueue
99}
1010RCT_EXPORT_MODULE ()
1111
12+ - (NSDictionary *)constantsToExport
13+ {
14+ return @{ @" BuildConfigs" : [[NSBundle mainBundle ] infoDictionary ] };
15+ }
16+
1217@end
1318
Original file line number Diff line number Diff line change 22{
33 "name" : " react-native-config-reader" ,
44 "version" : " 1.0.0" ,
5- "description" : " " ,
5+ "description" : " Simply access android build configs and ios info.plist values in JS " ,
66 "main" : " index.js" ,
77 "scripts" : {
88 "test" : " echo \" Error: no test specified\" && exit 1"
99 },
1010 "keywords" : [
1111 " react-native"
1212 ],
13- "author" : " " ,
14- "license" : " " ,
13+ "author" : " csath - chanakaathurugiriya@gmail.com " ,
14+ "license" : " MIT " ,
1515 "peerDependencies" : {
1616 "react-native" : " ^0.41.2" ,
1717 "react-native-windows" : " 0.41.0-rc.1"
18-
1918 }
2019}
Original file line number Diff line number Diff line change @@ -29,5 +29,19 @@ public override string Name
2929 return "RNConfigReader" ;
3030 }
3131 }
32+
33+ [ Obsolete ]
34+ public override IReadOnlyDictionary < string , object > Constants
35+ {
36+ get
37+ {
38+ var constants = new Dictionary < string , object >
39+ {
40+ { "BuildConfigs" , Package . Current . localSettings }
41+ } ;
42+
43+ return constants ;
44+ }
45+ }
3246 }
3347}
You can’t perform that action at this time.
0 commit comments