Skip to content

Commit b986603

Browse files
committed
feat: splash logo on web
1 parent 122183d commit b986603

2 files changed

Lines changed: 71 additions & 0 deletions

File tree

lib/main.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ import 'utils/talker.dart';
2020
import 'widgets/app_alert_dialog.dart';
2121
import 'widgets/custom_title_bar.dart';
2222
import 'widgets/server_connection_banner.dart';
23+
import 'utils/web_splash_stub.dart'
24+
if (dart.library.js) 'utils/web_splash_web.dart';
2325

2426
Future<void> main() async {
2527
await runZonedGuarded(() async {
@@ -94,6 +96,12 @@ Future<void> main() async {
9496
didResetLocalSettings: startupRecovery.didResetSharedPreferences,
9597
),
9698
);
99+
100+
if (kIsWeb) {
101+
WidgetsBinding.instance.addPostFrameCallback((_) {
102+
removeWebSplash();
103+
});
104+
}
97105
}, logUnhandledAsyncError);
98106
}
99107

web/index.html

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,71 @@
3131

3232
<title>TouchFish Client</title>
3333
<link rel="manifest" href="manifest.json">
34+
35+
<meta
36+
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"
37+
name="viewport"
38+
/>
39+
40+
<style id="splash-screen-style">
41+
html {
42+
height: 100%;
43+
}
44+
45+
body {
46+
margin: 0;
47+
min-height: 100%;
48+
background-color: #ffffff;
49+
background-size: 100% 100%;
50+
}
51+
52+
.center {
53+
margin: 0;
54+
position: absolute;
55+
top: 50%;
56+
left: 50%;
57+
-ms-transform: translate(-50%, -50%);
58+
transform: translate(-50%, -50%);
59+
}
60+
61+
@media (prefers-color-scheme: dark) {
62+
body {
63+
background-color: #121212;
64+
}
65+
}
66+
67+
#splash {
68+
transition: opacity 0.4s ease-out;
69+
}
70+
71+
#splash.fade-out {
72+
opacity: 0;
73+
}
74+
</style>
75+
76+
<script id="splash-screen-script">
77+
function removeSplashFromWeb() {
78+
var splash = document.getElementById("splash");
79+
if (splash) {
80+
splash.classList.add("fade-out");
81+
setTimeout(function () {
82+
splash.remove();
83+
}, 400);
84+
}
85+
document.body.style.background = "transparent";
86+
}
87+
</script>
3488
</head>
3589
<body>
90+
<picture id="splash">
91+
<img
92+
class="center"
93+
aria-hidden="true"
94+
src="splash/img/light-1x.png"
95+
alt="TouchFish"
96+
/>
97+
</picture>
98+
3699
<script src="flutter_bootstrap.js" async></script>
37100
</body>
38101
</html>

0 commit comments

Comments
 (0)