Skip to content

Commit 490cda3

Browse files
committed
feat(web): improve splash screen and app environment
- Add splash.css for better styling of the splash screen - Update splash screen HTML structure and CSS - Change app environment to demo in main.dart - Reorder imports in main.dart
1 parent 6f309a9 commit 490cda3

File tree

3 files changed

+58
-12
lines changed

3 files changed

+58
-12
lines changed

lib/main.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import 'package:device_preview/device_preview.dart';
2-
import 'package:flutter_news_app_mobile_client_full_source_code/app/services/splash_screen_remover/web_splash_remover.dart';
32
import 'package:flutter/foundation.dart';
43
import 'package:flutter/material.dart';
54
import 'package:flutter_news_app_mobile_client_full_source_code/app/config/config.dart';
5+
import 'package:flutter_news_app_mobile_client_full_source_code/app/services/splash_screen_remover/web_splash_remover.dart';
66
import 'package:flutter_news_app_mobile_client_full_source_code/bootstrap.dart';
77

88
// Define the current application environment (production/development/demo).
9-
const appEnvironment = AppEnvironment.development;
9+
const appEnvironment = AppEnvironment.demo;
1010

1111
void main() async {
1212
final appConfig = switch (appEnvironment) {

web/index.html

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929

3030
<title>Flutter News App</title>
3131
<link rel="manifest" href="manifest.json">
32+
<link rel="stylesheet" type="text/css" href="splash/splash.css">
3233

3334

3435
<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" name="viewport">
@@ -98,25 +99,24 @@
9899
</style>
99100
<script id="splash-screen-script">
100101
function removeSplashFromWeb() {
101-
document.getElementById("splash")?.remove();
102-
document.getElementById("splash-branding")?.remove();
102+
document.getElementById("splash-container")?.remove();
103103
document.body.style.background = "transparent";
104104
}
105105
</script>
106106
</head>
107107
<body>
108-
<picture id="splash">
109-
<source srcset="splash/img/light-1x.png 1x, splash/img/light-2x.png 2x, splash/img/light-3x.png 3x, splash/img/light-4x.png 4x" media="(prefers-color-scheme: light)">
110-
<source srcset="splash/img/dark-1x.png 1x, splash/img/dark-2x.png 2x, splash/img/dark-3x.png 3x, splash/img/dark-4x.png 4x" media="(prefers-color-scheme: dark)">
111-
<img class="center" aria-hidden="true" src="splash/img/light-1x.png" alt="">
112-
</picture>
113-
<div id="loading-indicator">
114-
<div class="spinner"></div>
108+
<div id="splash-container" class="center">
109+
<picture id="splash">
110+
<source srcset="splash/img/light-1x.png 1x, splash/img/light-2x.png 2x, splash/img/light-3x.png 3x, splash/img/light-4x.png 4x" media="(prefers-color-scheme: light)">
111+
<source srcset="splash/img/dark-1x.png 1x, splash/img/dark-2x.png 2x, splash/img/dark-3x.png 3x, splash/img/dark-4x.png 4x" media="(prefers-color-scheme: dark)">
112+
<img aria-hidden="true" src="splash/img/light-1x.png" alt="">
113+
</picture>
114+
<div class="loader"></div>
115115
</div>
116116
<script>
117117
{{flutter_bootstrap_js}}
118118
</script>
119119

120120

121121

122-
</body></html>
122+
</body></html>

web/splash/splash.css

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
.center {
2+
margin: 0;
3+
position: absolute;
4+
top: 50%;
5+
left: 50%;
6+
-ms-transform: translate(-50%, -50%);
7+
transform: translate(-50%, -50%);
8+
}
9+
10+
#splash-container {
11+
display: flex;
12+
flex-direction: column;
13+
align-items: center;
14+
justify-content: center;
15+
}
16+
17+
#splash {
18+
margin-bottom: 20px;
19+
}
20+
21+
.loader {
22+
border: 4px solid #f3f3f3;
23+
border-radius: 50%;
24+
border-top: 4px solid #3498db;
25+
width: 40px;
26+
height: 40px;
27+
-webkit-animation: spin 2s linear infinite; /* Safari */
28+
animation: spin 2s linear infinite;
29+
}
30+
31+
/* Safari */
32+
@-webkit-keyframes spin {
33+
0% { -webkit-transform: rotate(0deg); }
34+
100% { -webkit-transform: rotate(360deg); }
35+
}
36+
37+
@keyframes spin {
38+
0% { transform: rotate(0deg); }
39+
100% { transform: rotate(360deg); }
40+
}
41+
42+
@media (prefers-color-scheme: dark) {
43+
.loader {
44+
border-top: 4px solid #90caf9; /* A lighter blue for dark mode */
45+
}
46+
}

0 commit comments

Comments
 (0)