Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions android/src/main/java/org/devio/rn/splashscreen/SplashScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,16 @@ object SplashScreen {
val animationDuration = (System.currentTimeMillis() - animationStartTime) / 1000.0
setAnimationFinished(true)

if (animationDuration > 0.5) {
hideSplashScreen()
} else {
// Wait for minimum duration
lottie?.postDelayed({
// Only auto-hide if not forced to keep splash until explicit hide() is called
if (!forceToCloseByHideMethod) {
if (animationDuration > 0.5) {
hideSplashScreen()
}, ((2.0 - animationDuration) * 1000).toLong())
} else {
// Wait for minimum duration
lottie?.postDelayed({
hideSplashScreen()
}, ((2.0 - animationDuration) * 1000).toLong())
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ class SplashScreenModule(reactContext: ReactApplicationContext) : ReactContextBa
*/
@ReactMethod
fun hide() {
SplashScreen.hide(currentActivity)
// Safely retrieves the Activity (nullable) and passes it to hide()
val activity = reactApplicationContext.currentActivity
SplashScreen.hide(activity)
}
}
11 changes: 8 additions & 3 deletions ios/RNSplashScreen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,19 @@ public class SplashScreen: NSObject, RCTBridgeModule {
lottieView.play { finished in
DispatchQueue.main.async {
isAnimationFinished = true
hideSplashScreen()
// Only auto-hide if not forced to keep splash until explicit hide() is called
if !forceToCloseByHideMethod {
hideSplashScreen()
}
}
}
} else {
// Fallback for non-Lottie views
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
isAnimationFinished = true
hideSplashScreen()
if !forceToCloseByHideMethod {
hideSplashScreen()
}
}
}
}
Expand Down Expand Up @@ -131,4 +136,4 @@ extension SplashScreen {
@objc public static func requiresMainQueueSetup() -> Bool {
return true
}
}
}