Skip to content

Commit

Permalink
更新 example 闪屏,支持 Android 12
Browse files Browse the repository at this point in the history
  • Loading branch information
listenzz committed Jan 30, 2024
1 parent fb2a7f0 commit 58475c5
Show file tree
Hide file tree
Showing 10 changed files with 51 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
"source.fixAll.eslint": "explicit"
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.reactnative.hybridnavigation.example;

import android.os.Build;
import android.os.Bundle;

import androidx.annotation.NonNull;
Expand Down Expand Up @@ -28,6 +29,13 @@ public void setActivityRootFragment(@NonNull AwesomeFragment fragment) {
private SplashFragment splashFragment;

private void launchSplash(Bundle savedInstanceState) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
getSplashScreen().setOnExitAnimationListener(view -> {
view.remove(); // 移除 fade 动画
getSplashScreen().clearOnExitAnimationListener();
});
}

if (savedInstanceState != null) {
String tag = savedInstanceState.getString("splash_tag");
if (tag != null) {
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified example/android/app/src/main/res/drawable-xxhdpi/splash_text.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion example/android/app/src/main/res/drawable/splash.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</shape>
</item>

<item android:bottom="60dp">
<item>
<bitmap
android:antialias="true"
android:dither="true"
Expand Down
4 changes: 4 additions & 0 deletions example/android/app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
<item name="android:windowLayoutInDisplayCutoutMode" tools:targetApi="27">shortEdges</item>
<item name="android:enforceStatusBarContrast" tools:targetApi="29">false</item>
<item name="android:enforceNavigationBarContrast" tools:targetApi="29">false</item>

<item name="android:windowSplashScreenBackground" tools:targetApi="31">@color/colorAccent</item>
<item name="android:windowSplashScreenAnimatedIcon" tools:targetApi="31">@drawable/splash_text</item>
<item name="android:windowSplashScreenBehavior" tools:targetApi="33">icon_preferred</item>
</style>

</resources>
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 15 additions & 19 deletions example/ios/HybridNavigation/LaunchScreen.storyboard
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="17701" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="qOY-3e-eBq">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="22505" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="qOY-3e-eBq">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17703"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="22504"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
Expand All @@ -16,32 +16,28 @@
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Navigation Hybrid" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="v7j-SZ-hhT">
<rect key="frame" x="106" y="369.5" width="202" height="29"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="24"/>
<color key="textColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="example" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="tRd-RZ-VUL">
<rect key="frame" x="170" y="414.5" width="74" height="24"/>
<fontDescription key="fontDescription" type="system" pointSize="20"/>
<color key="textColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<nil key="highlightedColor"/>
</label>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="splash_icon" translatesAutoresizingMaskIntoConstraints="NO" id="m1f-2n-l4J">
<rect key="frame" x="63" y="304" width="288" height="288"/>
<constraints>
<constraint firstAttribute="height" constant="288" id="vIE-zJ-15j"/>
<constraint firstAttribute="width" constant="288" id="yCi-fO-jXm"/>
</constraints>
</imageView>
</subviews>
<viewLayoutGuide key="safeArea" id="chL-4O-p0P"/>
<color key="backgroundColor" red="0.97647058819999999" green="0.30196078430000001" blue="0.32549019610000002" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="tRd-RZ-VUL" firstAttribute="top" secondItem="v7j-SZ-hhT" secondAttribute="bottom" constant="16" id="RQn-uy-2vT"/>
<constraint firstItem="tRd-RZ-VUL" firstAttribute="centerX" secondItem="olh-mJ-sAc" secondAttribute="centerX" id="bak-tS-AQz"/>
<constraint firstItem="v7j-SZ-hhT" firstAttribute="centerX" secondItem="olh-mJ-sAc" secondAttribute="centerX" id="uBv-ps-xDz"/>
<constraint firstItem="v7j-SZ-hhT" firstAttribute="centerY" secondItem="olh-mJ-sAc" secondAttribute="centerY" constant="-64" id="xhn-n5-JjP"/>
<constraint firstItem="m1f-2n-l4J" firstAttribute="centerY" secondItem="olh-mJ-sAc" secondAttribute="centerY" id="A9R-UQ-1fn"/>
<constraint firstItem="m1f-2n-l4J" firstAttribute="centerX" secondItem="olh-mJ-sAc" secondAttribute="centerX" id="LWD-im-4md"/>
</constraints>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="i21-rN-bFj" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="53" y="375"/>
<point key="canvasLocation" x="52.173913043478265" y="375"/>
</scene>
</scenes>
<resources>
<image name="splash_icon" width="288" height="288"/>
</resources>
</document>

0 comments on commit 58475c5

Please sign in to comment.