Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Animate splash screen #17477

Merged
merged 30 commits into from
May 18, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
e5341e7
Switch Android to promises queue + remove fade
zoontek Apr 15, 2023
cd83444
Animate splash screen in JS
zoontek Apr 15, 2023
6bd38c8
Generate new assets (previous were 1px off)
zoontek Apr 15, 2023
c22765a
Add iOS support
zoontek Apr 15, 2023
a47a79d
Tweak the animation
zoontek Apr 15, 2023
76e8729
Export to styles
zoontek Apr 15, 2023
75a8ca3
Tweak values
zoontek Apr 15, 2023
29785af
Tweak values
zoontek Apr 15, 2023
d24eeee
Don't apply negative margin on other platforms than Android
zoontek Apr 16, 2023
b9f849b
Tweak animations values
zoontek Apr 16, 2023
809f5c9
Add a comment
zoontek Apr 16, 2023
4842634
Don't run staggering animations
zoontek Apr 16, 2023
6d2f66e
Handle visibility in parent component
zoontek Apr 16, 2023
78196fa
Use @color/status_bar_background
zoontek Apr 16, 2023
d95c1a0
Remove Platform.OS usage
zoontek Apr 27, 2023
8e86ce1
Publish shrinking animation
zoontek Apr 27, 2023
3868784
Fix linting
zoontek Apr 28, 2023
f956e8a
AnimatedSplashScreen -> SplashScreenHider
zoontek Apr 28, 2023
be9b588
Remove Platform usage
zoontek May 4, 2023
0def2a1
Fix linting
zoontek May 4, 2023
34a305b
Fix CSP issue by inlining CSS + logo and hide once the bundle is loaded
zoontek May 10, 2023
961f452
Remove extra logic
zoontek May 10, 2023
710f955
Run prettier
zoontek May 14, 2023
aa6010f
Resolve with a Promise
zoontek May 14, 2023
eba16b2
Replace .web by .native
zoontek May 14, 2023
cc6928a
Remove RCT_REMAP_METHOD
zoontek May 14, 2023
01711d2
Fix splash screen re-rendered on login / logout
zoontek May 14, 2023
5e51f05
Merge branch 'main' into animate-splash-screen
zoontek May 17, 2023
2b892bf
Merge branch 'main' into animate-splash-screen
zoontek May 17, 2023
3edb908
Switch to reanimated
zoontek May 17, 2023
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
20 changes: 2 additions & 18 deletions config/webpack/webpack.common.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
const path = require('path');
const fs = require('fs');
const {IgnorePlugin, DefinePlugin, ProvidePlugin, EnvironmentPlugin} = require('webpack');
const {CleanWebpackPlugin} = require('clean-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CopyPlugin = require('copy-webpack-plugin');
const dotenv = require('dotenv');
const {BundleAnalyzerPlugin} = require('webpack-bundle-analyzer');
const HtmlInlineScriptPlugin = require('html-inline-script-webpack-plugin');
const FontPreloadPlugin = require('webpack-font-preload-plugin');
const CustomVersionFilePlugin = require('./CustomVersionFilePlugin');

Expand Down Expand Up @@ -52,7 +52,6 @@ const webpackConfig = ({envFile = '.env', platform = 'web'}) => ({
devtool: 'source-map',
entry: {
main: ['babel-polyfill', './index.js'],
splash: ['./web/splash/splash.js'],
},
output: {
filename: '[name]-[contenthash].bundle.js',
Expand All @@ -73,11 +72,9 @@ const webpackConfig = ({envFile = '.env', platform = 'web'}) => ({
new HtmlWebpackPlugin({
template: 'web/index.html',
filename: 'index.html',
splashLogo: fs.readFileSync(path.resolve(__dirname, `../../assets/images/new-expensify${mapEnvToLogoSuffix(envFile)}.svg`), 'utf-8'),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line caused a bug to arise, resulting in a regression in #19777. We should have verified that the storybook builds and runs successfully.

usePolyfillIO: platform === 'web',
}),
new HtmlInlineScriptPlugin({
scriptMatchPattern: [/splash.+[.]js$/],
}),
new FontPreloadPlugin({
extensions: ['woff2'],
}),
Expand Down Expand Up @@ -173,18 +170,6 @@ const webpackConfig = ({envFile = '.env', platform = 'web'}) => ({
},
],
},
{
test: /splash.css$/i,
use: [
{
loader: 'style-loader',
options: {
insert: 'head',
injectType: 'singletonStyleTag',
},
},
],
},
{
test: /\.css$/i,
use: ['style-loader', 'css-loader'],
Expand All @@ -201,7 +186,6 @@ const webpackConfig = ({envFile = '.env', platform = 'web'}) => ({
},
resolve: {
alias: {
logo$: path.resolve(__dirname, `../../assets/images/new-expensify${mapEnvToLogoSuffix(envFile)}.svg`),
'react-native-config': 'react-web-config',
'react-native$': '@expensify/react-native-web',
'react-native-web': '@expensify/react-native-web',
Expand Down
19 changes: 0 additions & 19 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,6 @@
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-storybook": "^0.5.13",
"flipper-plugin-bridgespy-client": "^0.1.9",
"html-inline-script-webpack-plugin": "^3.1.0",
"html-webpack-plugin": "^5.5.0",
"jest": "29.4.1",
"jest-circus": "29.4.1",
Expand Down
41 changes: 39 additions & 2 deletions src/libs/BootSplash/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,42 @@
import Log from '../Log';

let areFontsReady = false;
document.fonts.ready.then(() => {
areFontsReady = true;
});

function hide() {
Log.info('[BootSplash] hiding splash screen', false);

return new Promise((resolve) => {
const minMilisecondsToWait = 1.5 * 1000;
let passedMiliseconds = 0;
let isRootMounted = false;
const root = document.getElementById('root');
const splash = document.getElementById('splash');

const intervalId = setInterval(() => {
passedMiliseconds += 250;
isRootMounted = root.children.length > 0;
if (passedMiliseconds >= minMilisecondsToWait && isRootMounted && areFontsReady) {
clearInterval(intervalId);
splash.style.opacity = 0;

setTimeout(() => {
splash.parentNode.removeChild(splash);
resolve();
}, 250);
}
}, 250);
});
}

function getVisibilityStatus() {
return document.getElementById('splash') ? 'visible' : 'hidden';
}

export default {
hide: () => Promise.resolve(),
getVisibilityStatus: () => Promise.resolve('hidden'),
hide,
getVisibilityStatus,
navigationBarHeight: 0,
};
34 changes: 33 additions & 1 deletion web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,36 @@
-webkit-text-fill-color: #ffffff;
caret-color: #ffffff;
}

@media screen and (min-width: 480px) {
.splash-logo > svg {
width: 104px;
height: 104px;
}
}

@media screen and (max-width: 479px) {
.splash-logo > svg {
width: 52px;
height: 52px;
}
}

#splash {
position: absolute;
bottom: 0;
left: 0;
right: 0;
top: 0;
background-color: #061B09;
width: 100%;
height: 100%;
display: flex;
justify-content: center;
align-items: center;
transition-duration: 250ms;
transition-property: opacity;
}
</style>
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1, interactive-widget=resizes-content">
<link rel="shortcut icon" id="favicon" href="/favicon.png">
Expand All @@ -90,7 +120,9 @@
<div style="position: absolute; top: 0; left: 0; right: 0; height: 30px;" id="drag-area"></div>
<div id="root"></div>
<div id="splash">
<div class="splash-logo"></div>
<div class="splash-logo">
<%= htmlWebpackPlugin.options.splashLogo %>
</div>
</div>
</body>
</html>
25 changes: 0 additions & 25 deletions web/splash/splash.css

This file was deleted.

41 changes: 0 additions & 41 deletions web/splash/splash.js

This file was deleted.