Skip to content

Commit a55aca9

Browse files
committed
changed parameters
1 parent 78d82f8 commit a55aca9

2 files changed

Lines changed: 44 additions & 8 deletions

File tree

android/src/main/java/com/reactnativecomponent/splashscreen/RCTSplashScreenModule.java

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import com.facebook.react.bridge.ReactApplicationContext;
77
import com.facebook.react.bridge.ReactContextBaseJavaModule;
88
import com.facebook.react.bridge.ReactMethod;
9+
import com.facebook.react.bridge.ReadableMap;
910

1011
import java.util.Collections;
1112
import java.util.HashMap;
@@ -24,14 +25,35 @@ public String getName() {
2425
}
2526

2627
@ReactMethod
27-
public void close(final int animationType, final int duration, int delay) {
28+
public void close(ReadableMap options) {
29+
30+
int animationType = RCTSplashScreen.UIAnimationNone;
31+
int duration = 0;
32+
int delay = 0;
33+
34+
if(options != null) {
35+
if(options.hasKey("animationType")) {
36+
animationType = options.getInt("animationType");
37+
}
38+
if(options.hasKey("duration")) {
39+
duration = options.getInt("duration");
40+
}
41+
if(options.hasKey("delay")) {
42+
delay = options.getInt("delay");
43+
}
44+
}
45+
2846
if(animationType == RCTSplashScreen.UIAnimationNone) {
2947
delay = 0;
3048
}
49+
50+
final int final_animationType = animationType;
51+
final int final_duration = duration;
52+
3153
final Handler handler = new Handler();
3254
handler.postDelayed(new Runnable() {
3355
public void run() {
34-
RCTSplashScreen.removeSplashScreen(getCurrentActivity(), animationType, duration);
56+
RCTSplashScreen.removeSplashScreen(getCurrentActivity(), final_animationType, final_duration);
3557
}
3658
}, delay);
3759
}

ios/RCTSplashScreen/RCTSplashScreen/RCTSplashScreen.m

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,29 @@ + (void)open:(RCTRootView *)v withImageNamed:(NSString *)imageName {
2929
[rootView setLoadingView:view];
3030
}
3131

32-
33-
34-
35-
RCT_EXPORT_METHOD(close:(NSInteger *)animationType
36-
duration:(NSInteger)duration
37-
delay:(NSInteger)delay) {
32+
RCT_EXPORT_METHOD(close:(NSDictionary *)options) {
3833
if (!rootView) {
3934
return;
4035
}
36+
37+
int animationType = UIAnimationNone;
38+
int duration = 0;
39+
int delay = 0;
40+
41+
if(options != nil) {
42+
43+
NSArray *keys = [options allKeys];
44+
45+
if([keys containsObject:@"animationType"]) {
46+
animationType = [[options objectForKey:@"animationType"] intValue];
47+
}
48+
if([keys containsObject:@"duration"]) {
49+
duration = [[options objectForKey:@"duration"] intValue];
50+
}
51+
if([keys containsObject:@"delay"]) {
52+
delay = [[options objectForKey:@"delay"] intValue];
53+
}
54+
}
4155

4256
if(animationType == UIAnimationNone) {
4357
rootView.loadingViewFadeDelay = 0;

0 commit comments

Comments
 (0)