Showing
1 changed file
with
77 additions
and
2 deletions
| @@ -18,7 +18,7 @@ | @@ -18,7 +18,7 @@ | ||
| 18 | 18 | ||
| 19 | <meta charset="UTF-8"> | 19 | <meta charset="UTF-8"> |
| 20 | <meta content="IE=Edge" http-equiv="X-UA-Compatible"> | 20 | <meta content="IE=Edge" http-equiv="X-UA-Compatible"> |
| 21 | - <meta name="description" content="A new Flutter project."> | 21 | + <meta name="description" content="Pdf Printing Demo"> |
| 22 | 22 | ||
| 23 | <!-- iOS meta tags & icons --> | 23 | <!-- iOS meta tags & icons --> |
| 24 | <meta name="apple-mobile-web-app-capable" content="yes"> | 24 | <meta name="apple-mobile-web-app-capable" content="yes"> |
| @@ -31,8 +31,83 @@ | @@ -31,8 +31,83 @@ | ||
| 31 | 31 | ||
| 32 | <title>Flutter PDF Demo</title> | 32 | <title>Flutter PDF Demo</title> |
| 33 | <link rel="manifest" href="manifest.json"> | 33 | <link rel="manifest" href="manifest.json"> |
| 34 | + <style type="text/css"> | ||
| 35 | + #loading { | ||
| 36 | + position: absolute; | ||
| 37 | + width: 400px; | ||
| 38 | + height: 300px; | ||
| 39 | + top: 50%; | ||
| 40 | + left: 50%; | ||
| 41 | + margin: -200px 0 0 -200px; | ||
| 42 | + text-align: center; | ||
| 43 | + font-family: sans-serif | ||
| 44 | + } | ||
| 45 | + | ||
| 46 | + #progress { | ||
| 47 | + margin-top: 20px; | ||
| 48 | + height: 10px; | ||
| 49 | + background-color: #ebebeb; | ||
| 50 | + } | ||
| 51 | + | ||
| 52 | + #progress div { | ||
| 53 | + background-color: #08a5d7; | ||
| 54 | + height: 100%; | ||
| 55 | + width: 0; | ||
| 56 | + transition: width ease-out 300ms; | ||
| 57 | + } | ||
| 58 | + | ||
| 59 | + @media (prefers-color-scheme: dark) { | ||
| 60 | + body { | ||
| 61 | + background-color: black; | ||
| 62 | + } | ||
| 63 | + | ||
| 64 | + #loading { | ||
| 65 | + color: white; | ||
| 66 | + } | ||
| 67 | + | ||
| 68 | + #progress { | ||
| 69 | + background-color: #393939; | ||
| 70 | + } | ||
| 71 | + } | ||
| 72 | + </style> | ||
| 34 | </head> | 73 | </head> |
| 74 | + | ||
| 35 | <body> | 75 | <body> |
| 36 | - <script src="flutter_bootstrap.js" async></script> | 76 | + <div id="loading"> |
| 77 | + <img src="icons/Icon-192.png" width="192" height="192" alt=""> | ||
| 78 | + <h1>Flutter PDF Demo</h1> | ||
| 79 | + <div id="progress"> | ||
| 80 | + <div></div> | ||
| 81 | + </div> | ||
| 82 | + </div> | ||
| 83 | + <script> | ||
| 84 | + {{flutter_js}} | ||
| 85 | + {{flutter_build_config}} | ||
| 86 | + | ||
| 87 | + function progress(value) { | ||
| 88 | + let el = document.getElementById("progress"); | ||
| 89 | + if (el) el.firstElementChild.style.width = value + "%"; | ||
| 90 | + } | ||
| 91 | + | ||
| 92 | + window.addEventListener('load', function (ev) { | ||
| 93 | + progress(30); | ||
| 94 | + }); | ||
| 95 | + | ||
| 96 | + | ||
| 97 | + window.addEventListener('flutter-first-frame', function () { | ||
| 98 | + let el = document.getElementById("loading"); | ||
| 99 | + if (el) el.remove(); | ||
| 100 | + }); | ||
| 101 | + | ||
| 102 | + _flutter.loader.load({ | ||
| 103 | + onEntrypointLoaded: async function (engineInitializer) { | ||
| 104 | + progress(60); | ||
| 105 | + const appRunner = await engineInitializer.initializeEngine(); | ||
| 106 | + progress(100); | ||
| 107 | + await new Promise(resolve => setTimeout(resolve, 200)); | ||
| 108 | + await appRunner.runApp(); | ||
| 109 | + } | ||
| 110 | + }); | ||
| 111 | + </script> | ||
| 37 | </body> | 112 | </body> |
| 38 | </html> | 113 | </html> |
-
Please register or login to post a comment