Toggle navigation
Toggle navigation
This project
Loading...
Sign in
flutter_package
/
dart_pdf
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
David PHAM-VAN
2022-03-12 12:00:11 -0400
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
e3a7ca9166621fc8d01abd4d2b5b262cdda5cdc3
e3a7ca91
1 parent
1c148719
Update demo project
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
69 additions
and
15 deletions
Makefile
demo/web/index.html
demo/web/manifest.json
Makefile
View file @
e3a7ca9
...
...
@@ -254,10 +254,9 @@ gh-social: all
cd test
;
$(DART_BIN)
--enable-asserts github_social_preview.dart
gh-pages
:
all
cd
demo;
$(FLUTTER_BIN)
build web
cd
demo;
$(FLUTTER_BIN)
build web
--base-href
"/dart_pdf/"
git checkout gh-pages
rm -rf assets icons
mv -fv demo/build/web/
*
.
sed -e
's|<base href="/">|<base href="/dart_pdf/">|'
-i index.html
.PHONY
:
test format format-dart format-clang clean publish-pdf publish-printing analyze ref
...
...
demo/web/index.html
View file @
e3a7ca9
...
...
@@ -8,10 +8,13 @@
The path provided below has to start and end with a slash "/" in order for
it to work correctly.
For
e
more details:
For more details:
* https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base
This is a placeholder for base href that will be replaced by the value of
the `--base-href` argument provided to `flutter build`.
-->
<base
href=
"
/
"
>
<base
href=
"
$FLUTTER_BASE_HREF
"
>
<meta
charset=
"UTF-8"
>
<meta
content=
"IE=Edge"
http-equiv=
"X-UA-Compatible"
>
...
...
@@ -20,7 +23,7 @@
<!-- iOS meta tags & icons -->
<meta
name=
"apple-mobile-web-app-capable"
content=
"yes"
>
<meta
name=
"apple-mobile-web-app-status-bar-style"
content=
"black"
>
<meta
name=
"apple-mobile-web-app-title"
content=
"
printing_d
emo"
>
<meta
name=
"apple-mobile-web-app-title"
content=
"
Flutter PDF D
emo"
>
<link
rel=
"apple-touch-icon"
href=
"icon-192.png"
>
<!-- Favicon -->
...
...
@@ -34,16 +37,68 @@
application. For more information, see:
https://developers.google.com/web/fundamentals/primers/service-workers -->
<script>
var
serviceWorkerVersion
=
null
;
var
scriptLoaded
=
false
;
function
loadMainDartJs
()
{
if
(
scriptLoaded
)
{
return
;
}
scriptLoaded
=
true
;
var
scriptTag
=
document
.
createElement
(
'script'
);
scriptTag
.
src
=
'main.dart.js'
;
scriptTag
.
type
=
'application/javascript'
;
document
.
body
.
append
(
scriptTag
);
}
if
(
'serviceWorker'
in
navigator
)
{
window
.
addEventListener
(
'flutter-first-frame'
,
function
()
{
navigator
.
serviceWorker
.
register
(
'flutter_service_worker.js'
);
// Service workers are supported. Use them.
window
.
addEventListener
(
'load'
,
function
()
{
// Wait for registration to finish before dropping the <script> tag.
// Otherwise, the browser will load the script multiple times,
// potentially different versions.
var
serviceWorkerUrl
=
'flutter_service_worker.js?v='
+
serviceWorkerVersion
;
navigator
.
serviceWorker
.
register
(
serviceWorkerUrl
)
.
then
((
reg
)
=>
{
function
waitForActivation
(
serviceWorker
)
{
serviceWorker
.
addEventListener
(
'statechange'
,
()
=>
{
if
(
serviceWorker
.
state
==
'activated'
)
{
console
.
log
(
'Installed new service worker.'
);
loadMainDartJs
();
}
});
}
if
(
!
reg
.
active
&&
(
reg
.
installing
||
reg
.
waiting
))
{
// No active web worker and we have installed or are installing
// one for the first time. Simply wait for it to activate.
waitForActivation
(
reg
.
installing
||
reg
.
waiting
);
}
else
if
(
!
reg
.
active
.
scriptURL
.
endsWith
(
serviceWorkerVersion
))
{
// When the app updates the serviceWorkerVersion changes, so we
// need to ask the service worker to update.
console
.
log
(
'New service worker available.'
);
reg
.
update
();
waitForActivation
(
reg
.
installing
);
}
else
{
// Existing service worker is still good.
console
.
log
(
'Loading app from service worker.'
);
loadMainDartJs
();
}
});
// If service worker doesn't succeed in a reasonable amount of time,
// fallback to plaint <script> tag.
setTimeout
(()
=>
{
if
(
!
scriptLoaded
)
{
console
.
warn
(
'Failed to load app from service worker. Falling back to plain <script> tag.'
,
);
loadMainDartJs
();
}
},
4000
);
});
}
else
{
// Service workers not supported. Just drop the <script> tag.
loadMainDartJs
();
}
</script>
<script
src=
"//cdnjs.cloudflare.com/ajax/libs/pdf.js/2.8.335/pdf.min.js"
></script>
<script
type=
"text/javascript"
>
pdfjsLib
.
GlobalWorkerOptions
.
workerSrc
=
"//cdnjs.cloudflare.com/ajax/libs/pdf.js/2.8.335/pdf.worker.min.js"
;
</script>
<script
src=
"main.dart.js"
type=
"application/javascript"
></script>
</body>
</html>
...
...
demo/web/manifest.json
View file @
e3a7ca9
{
"name"
:
"printing_demo"
,
"short_name"
:
"printing_demo"
,
"name"
:
"Flutter PDF Demo"
,
"short_name"
:
"Flutter PDF Demo"
,
"start_url"
:
"."
,
"display"
:
"standalone"
,
"background_color"
:
"#0175C2"
,
"theme_color"
:
"#0175C2"
,
"description"
:
"
A new Flutter project
."
,
"description"
:
"
Flutter PDF Demo
."
,
"orientation"
:
"portrait-primary"
,
"prefer_related_applications"
:
false
,
"icons"
:
[
...
...
Please
register
or
login
to post a comment